Title: [239306] trunk
Revision
239306
Author
[email protected]
Date
2018-12-17 17:45:47 -0800 (Mon, 17 Dec 2018)

Log Message

Don't use more expensive layer backing store formats when subpixel text antialiasing is not enabled
https://bugs.webkit.org/show_bug.cgi?id=192780
rdar://problem/43394387

Reviewed by Tim Horton.
Source/WebCore:

macOS Mojave disabled text subpixel antialiasing by default, so we no longer need to use the
memory-hungry "linear glyph mask" CALayer backing store formats for non-opaque with text in them.

Add FontCascade::isSubpixelAntialiasingAvailable() which reports whether subpixel antialiasing is available,
and consult it when making decisions that affect layer backing store format.

Tested by new results for existing tests.

* platform/graphics/FontCascade.cpp:
(WebCore::FontCascade::isSubpixelAntialiasingAvailable):
* platform/graphics/FontCascade.h:
* platform/graphics/cocoa/FontCascadeCocoa.mm:
(WebCore::FontCascade::isSubpixelAntialiasingAvailable): CGFontRenderingGetFontSmoothingDisabled() isn't super cheap, so fetch
it once.
* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::updateAfterDescendants):
* testing/Internals.cpp:
(WebCore::Internals::setFontSmoothingEnabled): Remove a WebCore::

Source/WebCore/PAL:

Add CGFontRenderingGetFontSmoothingDisabled().

* pal/spi/cg/CoreGraphicsSPI.h:

Tools:

No need to set "AppleFontSmoothing" defaults for WK2.

* WebKitTestRunner/InjectedBundle/mac/InjectedBundleMac.mm:
(WTR::InjectedBundle::platformInitialize):

LayoutTests:

New macOS Mojave and later results.

* platform/mac-mojave/compositing/contents-format/subpixel-antialiased-nested-layer-expected.txt: Added.
* platform/mac-mojave/compositing/contents-format/subpixel-antialiased-text-configs-antialiasing-style-expected.txt: Added.
* platform/mac-mojave/compositing/contents-format/subpixel-antialiased-text-configs-expected.txt: Added.
* platform/mac-mojave/compositing/contents-format/subpixel-antialiased-text-enabled-expected.txt: Added.
* platform/mac-mojave/compositing/contents-format/subpixel-antialiased-text-images-expected.txt: Added.
* platform/mac-mojave/compositing/contents-format/subpixel-antialiased-text-traversal-expected.txt: Added.
* platform/mac-mojave/compositing/contents-format/subpixel-antialiased-text-visibility-expected.txt: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (239305 => 239306)


--- trunk/LayoutTests/ChangeLog	2018-12-18 01:32:34 UTC (rev 239305)
+++ trunk/LayoutTests/ChangeLog	2018-12-18 01:45:47 UTC (rev 239306)
@@ -1,3 +1,21 @@
+2018-12-17  Simon Fraser  <[email protected]>
+
+        Don't use more expensive layer backing store formats when subpixel text antialiasing is not enabled
+        https://bugs.webkit.org/show_bug.cgi?id=192780
+        rdar://problem/43394387
+
+        Reviewed by Tim Horton.
+        
+        New macOS Mojave and later results.
+
+        * platform/mac-mojave/compositing/contents-format/subpixel-antialiased-nested-layer-expected.txt: Added.
+        * platform/mac-mojave/compositing/contents-format/subpixel-antialiased-text-configs-antialiasing-style-expected.txt: Added.
+        * platform/mac-mojave/compositing/contents-format/subpixel-antialiased-text-configs-expected.txt: Added.
+        * platform/mac-mojave/compositing/contents-format/subpixel-antialiased-text-enabled-expected.txt: Added.
+        * platform/mac-mojave/compositing/contents-format/subpixel-antialiased-text-images-expected.txt: Added.
+        * platform/mac-mojave/compositing/contents-format/subpixel-antialiased-text-traversal-expected.txt: Added.
+        * platform/mac-mojave/compositing/contents-format/subpixel-antialiased-text-visibility-expected.txt: Added.
+
 2018-12-17  Justin Fan  <[email protected]>
 
         [WebGPU] Implement WebGPUBindGroupLayoutDescriptor and its supporting dictionaries

Added: trunk/LayoutTests/platform/mac-mojave/compositing/contents-format/subpixel-antialiased-nested-layer-expected.txt (0 => 239306)


--- trunk/LayoutTests/platform/mac-mojave/compositing/contents-format/subpixel-antialiased-nested-layer-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/mac-mojave/compositing/contents-format/subpixel-antialiased-nested-layer-expected.txt	2018-12-18 01:45:47 UTC (rev 239306)
@@ -0,0 +1,20 @@
+This layer should get smoothing.
+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 800.00 600.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 800.00 600.00)
+      (contentsOpaque 1)
+      (children 1
+        (GraphicsLayer
+          (offsetFromRenderer width=-6 height=-6)
+          (position 12.00 4.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+        )
+      )
+    )
+  )
+)
+

Added: trunk/LayoutTests/platform/mac-mojave/compositing/contents-format/subpixel-antialiased-text-configs-antialiasing-style-expected.txt (0 => 239306)


--- trunk/LayoutTests/platform/mac-mojave/compositing/contents-format/subpixel-antialiased-text-configs-antialiasing-style-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/mac-mojave/compositing/contents-format/subpixel-antialiased-text-configs-antialiasing-style-expected.txt	2018-12-18 01:45:47 UTC (rev 239306)
@@ -0,0 +1,130 @@
+     
+Text here
+
+Antialiased text
+
+Smoothed text
+
+Antialised text
+Smoothed text
+
+Child composited layer
+
+Smoothed text
+
+Antialiased text
+
+Antialiased text
+
+Smoothed text
+
+Exceeds depth test antialiased
+
+Exceeds depth test smoothed
+
+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 800.00 600.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 800.00 600.00)
+      (contentsOpaque 1)
+      (children 12
+        (GraphicsLayer
+          (offsetFromRenderer width=-6 height=-6)
+          (position 12.00 17.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (offsetFromRenderer width=-6 height=-6)
+          (position 182.00 17.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (offsetFromRenderer width=-6 height=-6)
+          (position 352.00 17.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (offsetFromRenderer width=-6 height=-6)
+          (position 522.00 17.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (offsetFromRenderer width=-6 height=-6)
+          (position 12.00 187.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (offsetFromRenderer width=-6 height=-6)
+          (position 182.00 187.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (offsetFromRenderer width=-6 height=-6)
+          (position 352.00 187.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (offsetFromRenderer width=-6 height=-6)
+          (position 522.00 187.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+          (children 1
+            (GraphicsLayer
+              (position 27.00 43.00)
+              (bounds 108.00 60.00)
+              (drawsContent 1)
+            )
+          )
+        )
+        (GraphicsLayer
+          (offsetFromRenderer width=-6 height=-6)
+          (position 12.00 357.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+          (children 1
+            (GraphicsLayer
+              (position 27.00 43.00)
+              (bounds 108.00 20.00)
+              (drawsContent 1)
+            )
+          )
+        )
+        (GraphicsLayer
+          (offsetFromRenderer width=-6 height=-6)
+          (position 182.00 357.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+          (children 1
+            (GraphicsLayer
+              (position 27.00 43.00)
+              (bounds 108.00 20.00)
+              (drawsContent 1)
+            )
+          )
+        )
+        (GraphicsLayer
+          (offsetFromRenderer width=-6 height=-6)
+          (position 352.00 357.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (offsetFromRenderer width=-6 height=-6)
+          (position 522.00 357.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+        )
+      )
+    )
+  )
+)
+

Added: trunk/LayoutTests/platform/mac-mojave/compositing/contents-format/subpixel-antialiased-text-configs-expected.txt (0 => 239306)


--- trunk/LayoutTests/platform/mac-mojave/compositing/contents-format/subpixel-antialiased-text-configs-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/mac-mojave/compositing/contents-format/subpixel-antialiased-text-configs-expected.txt	2018-12-18 01:45:47 UTC (rev 239306)
@@ -0,0 +1,114 @@
+      Solid background
+Text here
+
+Text here
+
+Negative z-index child
+And more content
+Child layer
+
+Child composited layer
+
+Child composited layer
+
+Text here.  
+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 800.00 600.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 800.00 600.00)
+      (contentsOpaque 1)
+      (children 11
+        (GraphicsLayer
+          (offsetFromRenderer width=-6 height=-6)
+          (position 12.00 17.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (offsetFromRenderer width=-6 height=-6)
+          (position 182.00 17.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (offsetFromRenderer width=-6 height=-6)
+          (position 352.00 17.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (offsetFromRenderer width=-6 height=-6)
+          (position 522.00 17.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (offsetFromRenderer width=-6 height=-6)
+          (position 12.00 187.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (offsetFromRenderer width=-6 height=-6)
+          (position 182.00 187.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+          (children 1
+            (GraphicsLayer
+              (position 27.00 79.00)
+              (bounds 100.00 40.00)
+              (drawsContent 1)
+            )
+          )
+        )
+        (GraphicsLayer
+          (offsetFromRenderer width=-6 height=-6)
+          (position 352.00 187.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (offsetFromRenderer width=-6 height=-6)
+          (position 522.00 187.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+          (children 1
+            (GraphicsLayer
+              (position 27.00 43.00)
+              (bounds 108.00 60.00)
+              (drawsContent 1)
+            )
+          )
+        )
+        (GraphicsLayer
+          (offsetFromRenderer width=-6 height=-6)
+          (position 12.00 357.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+          (children 1
+            (GraphicsLayer
+              (position 27.00 43.00)
+              (bounds 108.00 60.00)
+              (drawsContent 1)
+            )
+          )
+        )
+        (GraphicsLayer
+          (offsetFromRenderer width=-6 height=-6)
+          (position 182.00 357.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (offsetFromRenderer width=-6 height=-6)
+          (position 352.00 357.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+        )
+      )
+    )
+  )
+)
+

Added: trunk/LayoutTests/platform/mac-mojave/compositing/contents-format/subpixel-antialiased-text-enabled-expected.txt (0 => 239306)


--- trunk/LayoutTests/platform/mac-mojave/compositing/contents-format/subpixel-antialiased-text-enabled-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/mac-mojave/compositing/contents-format/subpixel-antialiased-text-enabled-expected.txt	2018-12-18 01:45:47 UTC (rev 239306)
@@ -0,0 +1,45 @@
+Normal layer
+Tiled layer
+Become-tiled layer
+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 5018.00 2018.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 5018.00 2018.00)
+      (contentsOpaque 1)
+      (tile cache coverage 0, 0 1024 x 1024)
+      (tile size 512 x 512)
+      (top left tile 0, 0 tiles grid 2 x 2)
+      (in window 1)
+      (children 3
+        (GraphicsLayer
+          (position 18.00 10.00)
+          (bounds 100.00 100.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (position 18.00 120.00)
+          (bounds 5000.00 100.00)
+          (usingTiledLayer 1)
+          (drawsContent 1)
+          (tile cache coverage 0, 0 1024 x 100)
+          (tile size 512 x 512)
+          (top left tile 0, 0 tiles grid 2 x 1)
+          (in window 1)
+        )
+        (GraphicsLayer
+          (position 18.00 230.00)
+          (bounds 5000.00 100.00)
+          (usingTiledLayer 1)
+          (drawsContent 1)
+          (tile cache coverage 0, 0 1024 x 100)
+          (tile size 512 x 512)
+          (top left tile 0, 0 tiles grid 2 x 1)
+          (in window 1)
+        )
+      )
+    )
+  )
+)
+

Added: trunk/LayoutTests/platform/mac-mojave/compositing/contents-format/subpixel-antialiased-text-images-expected.txt (0 => 239306)


--- trunk/LayoutTests/platform/mac-mojave/compositing/contents-format/subpixel-antialiased-text-images-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/mac-mojave/compositing/contents-format/subpixel-antialiased-text-images-expected.txt	2018-12-18 01:45:47 UTC (rev 239306)
@@ -0,0 +1,68 @@
+ Image and some text   
+Image and some text child layer
+
+Image and some text with z-index
+
+Image and some text child composited
+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 800.00 600.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 800.00 600.00)
+      (contentsOpaque 1)
+      (children 7
+        (GraphicsLayer
+          (offsetFromRenderer width=-6 height=-6)
+          (position 12.00 17.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (offsetFromRenderer width=-6 height=-6)
+          (position 182.00 17.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (offsetFromRenderer width=-6 height=-6)
+          (position 352.00 17.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (offsetFromRenderer width=-6 height=-6)
+          (position 522.00 17.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (offsetFromRenderer width=-6 height=-6)
+          (position 12.00 187.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (offsetFromRenderer width=-6 height=-6)
+          (position 182.00 187.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (offsetFromRenderer width=-6 height=-6)
+          (position 352.00 187.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+          (children 1
+            (GraphicsLayer
+              (position 27.00 101.00)
+              (bounds 108.00 60.00)
+              (drawsContent 1)
+            )
+          )
+        )
+      )
+    )
+  )
+)
+

Added: trunk/LayoutTests/platform/mac-mojave/compositing/contents-format/subpixel-antialiased-text-traversal-expected.txt (0 => 239306)


--- trunk/LayoutTests/platform/mac-mojave/compositing/contents-format/subpixel-antialiased-text-traversal-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/mac-mojave/compositing/contents-format/subpixel-antialiased-text-traversal-expected.txt	2018-12-18 01:45:47 UTC (rev 239306)
@@ -0,0 +1,40 @@
+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 1163.00 1244.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 1163.00 1244.00)
+      (contentsOpaque 1)
+      (children 4
+        (GraphicsLayer
+          (offsetFromRenderer width=-6 height=-6)
+          (position 12.00 17.00)
+          (bounds 162.00 606.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (offsetFromRenderer width=-6 height=-6)
+          (position 182.00 17.00)
+          (bounds 162.00 606.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (offsetFromRenderer width=-6 height=-6)
+          (position 352.00 17.00)
+          (bounds 635.00 1215.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (offsetFromRenderer width=-6 height=-6)
+          (position 522.00 17.00)
+          (bounds 641.00 1227.00)
+          (drawsContent 1)
+        )
+      )
+    )
+  )
+)
+01234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
+0123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
+0
+0

Added: trunk/LayoutTests/platform/mac-mojave/compositing/contents-format/subpixel-antialiased-text-visibility-expected.txt (0 => 239306)


--- trunk/LayoutTests/platform/mac-mojave/compositing/contents-format/subpixel-antialiased-text-visibility-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/mac-mojave/compositing/contents-format/subpixel-antialiased-text-visibility-expected.txt	2018-12-18 01:45:47 UTC (rev 239306)
@@ -0,0 +1,46 @@
+Visibility hidden ancestor with visible child
+
+
+
+Only visible text is antialiased
+
+This text is antialiased. There is a hidden smoothed child
+
+
+(GraphicsLayer
+  (anchor 0.00 0.00)
+  (bounds 800.00 600.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 800.00 600.00)
+      (contentsOpaque 1)
+      (children 4
+        (GraphicsLayer
+          (offsetFromRenderer width=-6 height=-6)
+          (position 12.00 17.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (offsetFromRenderer width=-6 height=-6)
+          (position 182.00 17.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (offsetFromRenderer width=-6 height=-6)
+          (position 352.00 17.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (offsetFromRenderer width=-6 height=-6)
+          (position 522.00 17.00)
+          (bounds 162.00 162.00)
+          (drawsContent 1)
+        )
+      )
+    )
+  )
+)
+

Modified: trunk/Source/WTF/wtf/Platform.h (239305 => 239306)


--- trunk/Source/WTF/wtf/Platform.h	2018-12-18 01:32:34 UTC (rev 239305)
+++ trunk/Source/WTF/wtf/Platform.h	2018-12-18 01:45:47 UTC (rev 239306)
@@ -1415,6 +1415,10 @@
 #endif
 #endif
 
+#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
+#define HAVE_CG_FONT_RENDERING_GET_FONT_SMOOTHING_DISABLED 1
+#endif
+
 #ifdef __APPLE__
 #define HAVE_FUNC_USLEEP 1
 #endif

Modified: trunk/Source/WebCore/ChangeLog (239305 => 239306)


--- trunk/Source/WebCore/ChangeLog	2018-12-18 01:32:34 UTC (rev 239305)
+++ trunk/Source/WebCore/ChangeLog	2018-12-18 01:45:47 UTC (rev 239306)
@@ -1,3 +1,30 @@
+2018-12-17  Simon Fraser  <[email protected]>
+
+        Don't use more expensive layer backing store formats when subpixel text antialiasing is not enabled
+        https://bugs.webkit.org/show_bug.cgi?id=192780
+        rdar://problem/43394387
+
+        Reviewed by Tim Horton.
+        
+        macOS Mojave disabled text subpixel antialiasing by default, so we no longer need to use the
+        memory-hungry "linear glyph mask" CALayer backing store formats for non-opaque with text in them.
+        
+        Add FontCascade::isSubpixelAntialiasingAvailable() which reports whether subpixel antialiasing is available,
+        and consult it when making decisions that affect layer backing store format.
+
+        Tested by new results for existing tests.
+
+        * platform/graphics/FontCascade.cpp:
+        (WebCore::FontCascade::isSubpixelAntialiasingAvailable):
+        * platform/graphics/FontCascade.h:
+        * platform/graphics/cocoa/FontCascadeCocoa.mm:
+        (WebCore::FontCascade::isSubpixelAntialiasingAvailable): CGFontRenderingGetFontSmoothingDisabled() isn't super cheap, so fetch
+        it once.
+        * rendering/RenderLayerBacking.cpp:
+        (WebCore::RenderLayerBacking::updateAfterDescendants):
+        * testing/Internals.cpp:
+        (WebCore::Internals::setFontSmoothingEnabled): Remove a WebCore::
+
 2018-12-17  Daniel Bates  <[email protected]>
 
         Make DocumentMarker::allMarkers() constexpr

Modified: trunk/Source/WebCore/PAL/ChangeLog (239305 => 239306)


--- trunk/Source/WebCore/PAL/ChangeLog	2018-12-18 01:32:34 UTC (rev 239305)
+++ trunk/Source/WebCore/PAL/ChangeLog	2018-12-18 01:45:47 UTC (rev 239306)
@@ -1,3 +1,15 @@
+2018-12-17  Simon Fraser  <[email protected]>
+
+        Don't use more expensive layer backing store formats when subpixel text antialiasing is not enabled
+        https://bugs.webkit.org/show_bug.cgi?id=192780
+        rdar://problem/43394387
+
+        Reviewed by Tim Horton.
+
+        Add CGFontRenderingGetFontSmoothingDisabled().
+
+        * pal/spi/cg/CoreGraphicsSPI.h:
+
 2018-12-17  Daniel Bates  <[email protected]>
 
         Implement UIScriptController::toggleCapsLock() for iOS

Modified: trunk/Source/WebCore/PAL/pal/spi/cg/CoreGraphicsSPI.h (239305 => 239306)


--- trunk/Source/WebCore/PAL/pal/spi/cg/CoreGraphicsSPI.h	2018-12-18 01:32:34 UTC (rev 239305)
+++ trunk/Source/WebCore/PAL/pal/spi/cg/CoreGraphicsSPI.h	2018-12-18 01:45:47 UTC (rev 239306)
@@ -255,7 +255,7 @@
 CGImageRef CGIOSurfaceContextCreateImageReference(CGContextRef);
 CGColorSpaceRef CGIOSurfaceContextGetColorSpace(CGContextRef);
 void CGIOSurfaceContextSetDisplayMask(CGContextRef, uint32_t mask);
-#endif
+#endif // HAVE(IOSURFACE)
 
 #if PLATFORM(COCOA)
 bool CGColorSpaceUsesExtendedRange(CGColorSpaceRef);
@@ -285,8 +285,13 @@
 #if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400) || (PLATFORM(IOS_FAMILY) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 120000)
 void CGPathAddUnevenCornersRoundedRect(CGMutablePathRef, const CGAffineTransform *, CGRect, const CGSize corners[4]);
 #endif
+
+#if HAVE(CG_FONT_RENDERING_GET_FONT_SMOOTHING_DISABLED)
+bool CGFontRenderingGetFontSmoothingDisabled(void);
 #endif
 
+#endif // PLATFORM(COCOA)
+
 #if PLATFORM(WIN)
 CGFontCache* CGFontCacheGetLocalCache();
 void CGFontCacheSetShouldAutoExpire(CGFontCache*, bool);
@@ -296,7 +301,7 @@
 uint32_t CGContextGetFontSmoothingStyle(CGContextRef);
 void CGContextSetShouldUsePlatformNativeGlyphs(CGContextRef, bool);
 void CGContextSetFocusRingWithColor(CGContextRef, CGFloat blur, CGColorRef, const CGRect *clipRect, CFDictionaryRef options);
-#endif
+#endif // PLATFORM(WIN)
 
 #if PLATFORM(MAC)
 void CGSShutdownServerConnections(void);
@@ -321,6 +326,6 @@
 
 #endif // ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)
 
-#endif
+#endif // PLATFORM(MAC)
 
 WTF_EXTERN_C_END

Modified: trunk/Source/WebCore/platform/graphics/FontCascade.cpp (239305 => 239306)


--- trunk/Source/WebCore/platform/graphics/FontCascade.cpp	2018-12-18 01:32:34 UTC (rev 239305)
+++ trunk/Source/WebCore/platform/graphics/FontCascade.cpp	2018-12-18 01:45:47 UTC (rev 239306)
@@ -595,6 +595,13 @@
     return shouldUseFontSmoothing;
 }
 
+#if !PLATFORM(COCOA)
+bool FontCascade::isSubpixelAntialiasingAvailable()
+{
+    return false;
+}
+#endif
+
 void FontCascade::setCodePath(CodePath p)
 {
     s_codePath = p;

Modified: trunk/Source/WebCore/platform/graphics/FontCascade.h (239305 => 239306)


--- trunk/Source/WebCore/platform/graphics/FontCascade.h	2018-12-18 01:32:34 UTC (rev 239305)
+++ trunk/Source/WebCore/platform/graphics/FontCascade.h	2018-12-18 01:45:47 UTC (rev 239306)
@@ -181,6 +181,8 @@
     WEBCORE_EXPORT static void setShouldUseSmoothing(bool);
     WEBCORE_EXPORT static bool shouldUseSmoothing();
 
+    static bool isSubpixelAntialiasingAvailable();
+
     enum CodePath { Auto, Simple, Complex, SimpleWithGlyphOverflow };
     CodePath codePath(const TextRun&, std::optional<unsigned> from = std::nullopt, std::optional<unsigned> to = std::nullopt) const;
     static CodePath characterRangeCodePath(const LChar*, unsigned) { return Simple; }

Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm (239305 => 239306)


--- trunk/Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm	2018-12-18 01:32:34 UTC (rev 239305)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm	2018-12-18 01:45:47 UTC (rev 239306)
@@ -58,6 +58,24 @@
 
 namespace WebCore {
 
+// Confusingly, even when CGFontRenderingGetFontSmoothingDisabled() returns true, CGContextSetShouldSmoothFonts() still impacts text
+// rendering, which is why this function uses the "subpixel antialiasing" rather than "smoothing" terminology.
+bool FontCascade::isSubpixelAntialiasingAvailable()
+{
+#if HAVE(CG_FONT_RENDERING_GET_FONT_SMOOTHING_DISABLED)
+    static bool subpixelAntialiasingEnabled;
+    static std::once_flag onceFlag;
+    std::call_once(onceFlag, [&] () {
+        subpixelAntialiasingEnabled = !CGFontRenderingGetFontSmoothingDisabled();
+    });
+    return subpixelAntialiasingEnabled;
+#elif PLATFORM(MAC)
+    return true;
+#else
+    return false;
+#endif
+}
+
 bool FontCascade::canReturnFallbackFontsForComplexText()
 {
     return true;

Modified: trunk/Source/WebCore/rendering/RenderLayerBacking.cpp (239305 => 239306)


--- trunk/Source/WebCore/rendering/RenderLayerBacking.cpp	2018-12-18 01:32:34 UTC (rev 239305)
+++ trunk/Source/WebCore/rendering/RenderLayerBacking.cpp	2018-12-18 01:45:47 UTC (rev 239306)
@@ -1259,7 +1259,7 @@
 {
     // FIXME: this potentially duplicates work we did in updateConfiguration().
     PaintedContentsInfo contentsInfo(*this);
-    contentsInfo.setWantsSubpixelAntialiasedTextState(GraphicsLayer::supportsSubpixelAntialiasedLayerText());
+    contentsInfo.setWantsSubpixelAntialiasedTextState(GraphicsLayer::supportsSubpixelAntialiasedLayerText() && FontCascade::isSubpixelAntialiasingAvailable());
 
     if (!m_owningLayer.isRenderViewLayer()) {
         bool didUpdateContentsRect = false;

Modified: trunk/Source/WebCore/testing/Internals.cpp (239305 => 239306)


--- trunk/Source/WebCore/testing/Internals.cpp	2018-12-18 01:32:34 UTC (rev 239305)
+++ trunk/Source/WebCore/testing/Internals.cpp	2018-12-18 01:45:47 UTC (rev 239306)
@@ -1629,7 +1629,7 @@
 
 void Internals::setFontSmoothingEnabled(bool enabled)
 {
-    WebCore::FontCascade::setShouldUseSmoothing(enabled);
+    FontCascade::setShouldUseSmoothing(enabled);
 }
 
 ExceptionOr<void> Internals::setLowPowerModeEnabled(bool isEnabled)

Modified: trunk/Tools/ChangeLog (239305 => 239306)


--- trunk/Tools/ChangeLog	2018-12-18 01:32:34 UTC (rev 239305)
+++ trunk/Tools/ChangeLog	2018-12-18 01:45:47 UTC (rev 239306)
@@ -1,3 +1,16 @@
+2018-12-17  Simon Fraser  <[email protected]>
+
+        Don't use more expensive layer backing store formats when subpixel text antialiasing is not enabled
+        https://bugs.webkit.org/show_bug.cgi?id=192780
+        rdar://problem/43394387
+
+        Reviewed by Tim Horton.
+
+        No need to set "AppleFontSmoothing" defaults for WK2.
+
+        * WebKitTestRunner/InjectedBundle/mac/InjectedBundleMac.mm:
+        (WTR::InjectedBundle::platformInitialize):
+
 2018-12-17  Jonathan Bedard  <[email protected]>
 
         webkitpy: Handle case where stdout and stderr don't accept unicode

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/mac/InjectedBundleMac.mm (239305 => 239306)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/mac/InjectedBundleMac.mm	2018-12-18 01:32:34 UTC (rev 239305)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/mac/InjectedBundleMac.mm	2018-12-18 01:45:47 UTC (rev 239306)
@@ -36,7 +36,6 @@
 
 void InjectedBundle::platformInitialize(WKTypeRef initializationUserData)
 {
-    static const int NoFontSmoothing = 0;
     static const int BlueTintedAppearance = 1;
 
     // Work around missing /etc/catalog <rdar://problem/4292995>.
@@ -50,9 +49,6 @@
 
     NSDictionary *dict = @{
         @"AppleAntiAliasingThreshold": @4,
-        // FIXME: Setting AppleFontSmoothing is likely unnecessary and ineffective. WebKit2 has its own preference for font smoothing, which is
-        // applied to each context via CGContextSetShouldSmoothFonts, presumably overriding the default.
-        @"AppleFontSmoothing": @(NoFontSmoothing),
         @"AppleAquaColorVariant": @(BlueTintedAppearance),
         @"AppleHighlightColor": @"0.709800 0.835300 1.000000",
         @"AppleOtherHighlightColor": @"0.500000 0.500000 0.500000",
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to