Skip to content

Commit e477d92

Browse files
committed
[Skia] Text rendered as much less heavy compared to other browsers
https://bugs.webkit.org/show_bug.cgi?id=309152 Reviewed by NOBODY (OOPS!). Explanation of why this fixes the bug (OOPS!). No new tests (OOPS!).
1 parent 5107e3d commit e477d92

File tree

13 files changed

+19
-9
lines changed

13 files changed

+19
-9
lines changed

LayoutTests/fast/snapshot/nested-stacking-context.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4-
<meta name="fuzzy" content="maxDifference=0-1; totalPixels=0-10000" />
4+
<meta name="fuzzy" content="maxDifference=0-2; totalPixels=0-10000" />
55
<style>
66
#box {
77
width: 100px;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<!DOCTYPE HTML>
22
<link rel="help" href="https://drafts.csswg.org/css-text-decor-3/#text-shadow-property">
33
<link rel="match" href="color-inherit-ref.html">
4+
<meta name="fuzzy" content="maxDifference=0-1; totalPixels=0-1">
45
<div style="position: absolute; top: 24px; left: 24px; color: blue; text-shadow: 3px 3px;">Hello</div>
56

LayoutTests/imported/w3c/web-platform-tests/css/css-view-transitions/table-caption.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<link rel="author" href="mailto:[email protected]" title="Emilio Cobos Álvarez">
88
<link rel="author" href="https://mozilla.org" title="Mozilla">
99
<link rel="match" href="table-caption-ref.html">
10+
<meta name="fuzzy" content="maxDifference=0-1; totalPixels=0-2">
1011
<style>
1112
table {
1213
view-transition-name: table;

LayoutTests/imported/w3c/web-platform-tests/webvtt/rendering/cues-with-video/processing-model/selectors/cue_function/bold_object/bold_timestamp_future.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<html class="reftest-wait">
33
<title>WebVTT rendering, bold object transition with timestamp, ::cue(b:future) selector</title>
44
<link rel="match" href="bold_timestamp_future-ref.html">
5+
<meta name="fuzzy" content="maxDifference=0-1; totalPixels=0-1">
56
<style>
67
html { overflow:hidden }
78
body { margin:0 }

LayoutTests/imported/w3c/web-platform-tests/webvtt/rendering/cues-with-video/processing-model/selectors/cue_function/not_root_selector.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<html class="reftest-wait">
33
<title>WebVTT rendering, ::cue(:not(:root)) should not match the root</title>
44
<link rel="match" href="not_root_selector-ref.html">
5+
<meta name="fuzzy" content="maxDifference=0-1; totalPixels=0-1">
56
<style>
67
html { overflow:hidden }
78
body { margin:0 }

Source/WebCore/platform/graphics/FontRenderOptions.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,12 @@ class FontRenderOptions {
8686
SkPixelGeometry subpixelOrder() const;
8787
void setUseSubpixelPositioning(bool enable) { m_useSubpixelPositioning = enable; }
8888
bool useSubpixelPositioning() const;
89+
90+
// Make text look better at the expense of incorrect anti-aliasing blending.
91+
static constexpr SkScalar s_textContrast { 0 };
92+
static constexpr SkScalar s_textGamma { 1 };
93+
SkScalar textContrast() const { return s_textContrast; };
94+
SkScalar textGamma() const { return s_textGamma; };
8995
#endif
9096

9197
WEBCORE_EXPORT void disableHintingForTesting();

Source/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1154,7 +1154,7 @@ static sk_sp<SkSurface> createAcceleratedSurface(const IntSize& size)
11541154
RELEASE_ASSERT(grContext);
11551155

11561156
auto imageInfo = SkImageInfo::Make(size.width(), size.height(), kRGBA_8888_SkColorType, kPremul_SkAlphaType, SkColorSpace::MakeSRGB());
1157-
SkSurfaceProps properties { 0, FontRenderOptions::singleton().subpixelOrder() };
1157+
SkSurfaceProps properties { 0, FontRenderOptions::singleton().subpixelOrder(), FontRenderOptions::singleton().textContrast(), FontRenderOptions::singleton().textGamma() };
11581158
auto surface = SkSurfaces::RenderTarget(grContext, skgpu::Budgeted::kNo, imageInfo, PlatformDisplay::sharedDisplay().msaaSampleCount(), kTopLeft_GrSurfaceOrigin, &properties);
11591159
if (!surface || !surface->getCanvas())
11601160
return nullptr;

Source/WebCore/platform/graphics/skia/ImageBufferSkiaAcceleratedBackend.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ std::unique_ptr<ImageBufferSkiaAcceleratedBackend> ImageBufferSkiaAcceleratedBac
121121
flags |= SkSurfaceProps::kDynamicMSAA_Flag;
122122
msaaSampleCount = 1;
123123
}
124-
SkSurfaceProps properties { flags, FontRenderOptions::singleton().subpixelOrder() };
124+
SkSurfaceProps properties { flags, FontRenderOptions::singleton().subpixelOrder(), FontRenderOptions::singleton().textContrast(), FontRenderOptions::singleton().textGamma() };
125125
auto surface = SkSurfaces::RenderTarget(grContext, skgpu::Budgeted::kNo, imageInfo, msaaSampleCount, kTopLeft_GrSurfaceOrigin, &properties);
126126
if (!surface || !surface->getCanvas())
127127
return nullptr;

Source/WebCore/platform/graphics/skia/ImageBufferSkiaUnacceleratedBackend.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ std::unique_ptr<ImageBufferSkiaUnacceleratedBackend> ImageBufferSkiaUnaccelerate
4646
return nullptr;
4747

4848
auto imageInfo = SkImageInfo::MakeN32Premul(backendSize.width(), backendSize.height(), parameters.colorSpace.platformColorSpace());
49-
SkSurfaceProps properties = { 0, FontRenderOptions::singleton().subpixelOrder() };
49+
SkSurfaceProps properties = { 0, FontRenderOptions::singleton().subpixelOrder(), FontRenderOptions::singleton().textContrast(), FontRenderOptions::singleton().textGamma() };
5050
auto surface = SkSurfaces::Raster(imageInfo, &properties);
5151
if (!surface || !surface->getCanvas())
5252
return nullptr;

Source/WebCore/platform/graphics/skia/PlatformDisplaySkia.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ static unsigned initializeMSAASampleCount(GrDirectContext* grContext)
217217
// knows there are bugs. The only way to know whether our sample count will work is trying to create a
218218
// surface with that value and check whether it works.
219219
auto imageInfo = SkImageInfo::Make(512, 512, kRGBA_8888_SkColorType, kPremul_SkAlphaType, SkColorSpace::MakeSRGB());
220-
SkSurfaceProps properties = { 0, FontRenderOptions::singleton().subpixelOrder() };
220+
SkSurfaceProps properties = { 0, FontRenderOptions::singleton().subpixelOrder(), FontRenderOptions::singleton().textContrast(), FontRenderOptions::singleton().textGamma() };
221221
auto surface = SkSurfaces::RenderTarget(grContext, skgpu::Budgeted::kNo, imageInfo, sampleCount, kTopLeft_GrSurfaceOrigin, &properties);
222222

223223
// If the creation of the surface failed, disable MSAA.

0 commit comments

Comments
 (0)