Changeset 239306 in webkit


Ignore:
Timestamp:
Dec 17, 2018 5:45:47 PM (5 years ago)
Author:
Simon Fraser
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.
Location:
trunk
Files:
9 added
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r239288 r239306  
     12018-12-17  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Don't use more expensive layer backing store formats when subpixel text antialiasing is not enabled
     4        https://bugs.webkit.org/show_bug.cgi?id=192780
     5        rdar://problem/43394387
     6
     7        Reviewed by Tim Horton.
     8       
     9        New macOS Mojave and later results.
     10
     11        * platform/mac-mojave/compositing/contents-format/subpixel-antialiased-nested-layer-expected.txt: Added.
     12        * platform/mac-mojave/compositing/contents-format/subpixel-antialiased-text-configs-antialiasing-style-expected.txt: Added.
     13        * platform/mac-mojave/compositing/contents-format/subpixel-antialiased-text-configs-expected.txt: Added.
     14        * platform/mac-mojave/compositing/contents-format/subpixel-antialiased-text-enabled-expected.txt: Added.
     15        * platform/mac-mojave/compositing/contents-format/subpixel-antialiased-text-images-expected.txt: Added.
     16        * platform/mac-mojave/compositing/contents-format/subpixel-antialiased-text-traversal-expected.txt: Added.
     17        * platform/mac-mojave/compositing/contents-format/subpixel-antialiased-text-visibility-expected.txt: Added.
     18
    1192018-12-17  Justin Fan  <justin_fan@apple.com>
    220
  • trunk/Source/WTF/wtf/Platform.h

    r239134 r239306  
    14161416#endif
    14171417
     1418#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
     1419#define HAVE_CG_FONT_RENDERING_GET_FONT_SMOOTHING_DISABLED 1
     1420#endif
     1421
    14181422#ifdef __APPLE__
    14191423#define HAVE_FUNC_USLEEP 1
  • trunk/Source/WebCore/ChangeLog

    r239289 r239306  
     12018-12-17  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Don't use more expensive layer backing store formats when subpixel text antialiasing is not enabled
     4        https://bugs.webkit.org/show_bug.cgi?id=192780
     5        rdar://problem/43394387
     6
     7        Reviewed by Tim Horton.
     8       
     9        macOS Mojave disabled text subpixel antialiasing by default, so we no longer need to use the
     10        memory-hungry "linear glyph mask" CALayer backing store formats for non-opaque with text in them.
     11       
     12        Add FontCascade::isSubpixelAntialiasingAvailable() which reports whether subpixel antialiasing is available,
     13        and consult it when making decisions that affect layer backing store format.
     14
     15        Tested by new results for existing tests.
     16
     17        * platform/graphics/FontCascade.cpp:
     18        (WebCore::FontCascade::isSubpixelAntialiasingAvailable):
     19        * platform/graphics/FontCascade.h:
     20        * platform/graphics/cocoa/FontCascadeCocoa.mm:
     21        (WebCore::FontCascade::isSubpixelAntialiasingAvailable): CGFontRenderingGetFontSmoothingDisabled() isn't super cheap, so fetch
     22        it once.
     23        * rendering/RenderLayerBacking.cpp:
     24        (WebCore::RenderLayerBacking::updateAfterDescendants):
     25        * testing/Internals.cpp:
     26        (WebCore::Internals::setFontSmoothingEnabled): Remove a WebCore::
     27
    1282018-12-17  Daniel Bates  <dabates@apple.com>
    229
  • trunk/Source/WebCore/PAL/ChangeLog

    r239277 r239306  
     12018-12-17  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Don't use more expensive layer backing store formats when subpixel text antialiasing is not enabled
     4        https://bugs.webkit.org/show_bug.cgi?id=192780
     5        rdar://problem/43394387
     6
     7        Reviewed by Tim Horton.
     8
     9        Add CGFontRenderingGetFontSmoothingDisabled().
     10
     11        * pal/spi/cg/CoreGraphicsSPI.h:
     12
    1132018-12-17  Daniel Bates  <dabates@apple.com>
    214
  • trunk/Source/WebCore/PAL/pal/spi/cg/CoreGraphicsSPI.h

    r238265 r239306  
    256256CGColorSpaceRef CGIOSurfaceContextGetColorSpace(CGContextRef);
    257257void CGIOSurfaceContextSetDisplayMask(CGContextRef, uint32_t mask);
    258 #endif
     258#endif // HAVE(IOSURFACE)
    259259
    260260#if PLATFORM(COCOA)
     
    286286void CGPathAddUnevenCornersRoundedRect(CGMutablePathRef, const CGAffineTransform *, CGRect, const CGSize corners[4]);
    287287#endif
    288 #endif
     288
     289#if HAVE(CG_FONT_RENDERING_GET_FONT_SMOOTHING_DISABLED)
     290bool CGFontRenderingGetFontSmoothingDisabled(void);
     291#endif
     292
     293#endif // PLATFORM(COCOA)
    289294
    290295#if PLATFORM(WIN)
     
    297302void CGContextSetShouldUsePlatformNativeGlyphs(CGContextRef, bool);
    298303void CGContextSetFocusRingWithColor(CGContextRef, CGFloat blur, CGColorRef, const CGRect *clipRect, CFDictionaryRef options);
    299 #endif
     304#endif // PLATFORM(WIN)
    300305
    301306#if PLATFORM(MAC)
     
    322327#endif // ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)
    323328
    324 #endif
     329#endif // PLATFORM(MAC)
    325330
    326331WTF_EXTERN_C_END
  • trunk/Source/WebCore/platform/graphics/FontCascade.cpp

    r238413 r239306  
    595595    return shouldUseFontSmoothing;
    596596}
     597
     598#if !PLATFORM(COCOA)
     599bool FontCascade::isSubpixelAntialiasingAvailable()
     600{
     601    return false;
     602}
     603#endif
    597604
    598605void FontCascade::setCodePath(CodePath p)
  • trunk/Source/WebCore/platform/graphics/FontCascade.h

    r238253 r239306  
    182182    WEBCORE_EXPORT static bool shouldUseSmoothing();
    183183
     184    static bool isSubpixelAntialiasingAvailable();
     185
    184186    enum CodePath { Auto, Simple, Complex, SimpleWithGlyphOverflow };
    185187    CodePath codePath(const TextRun&, std::optional<unsigned> from = std::nullopt, std::optional<unsigned> to = std::nullopt) const;
  • trunk/Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm

    r237845 r239306  
    5959namespace WebCore {
    6060
     61// Confusingly, even when CGFontRenderingGetFontSmoothingDisabled() returns true, CGContextSetShouldSmoothFonts() still impacts text
     62// rendering, which is why this function uses the "subpixel antialiasing" rather than "smoothing" terminology.
     63bool FontCascade::isSubpixelAntialiasingAvailable()
     64{
     65#if HAVE(CG_FONT_RENDERING_GET_FONT_SMOOTHING_DISABLED)
     66    static bool subpixelAntialiasingEnabled;
     67    static std::once_flag onceFlag;
     68    std::call_once(onceFlag, [&] () {
     69        subpixelAntialiasingEnabled = !CGFontRenderingGetFontSmoothingDisabled();
     70    });
     71    return subpixelAntialiasingEnabled;
     72#elif PLATFORM(MAC)
     73    return true;
     74#else
     75    return false;
     76#endif
     77}
     78
    6179bool FontCascade::canReturnFallbackFontsForComplexText()
    6280{
  • trunk/Source/WebCore/rendering/RenderLayerBacking.cpp

    r238727 r239306  
    12601260    // FIXME: this potentially duplicates work we did in updateConfiguration().
    12611261    PaintedContentsInfo contentsInfo(*this);
    1262     contentsInfo.setWantsSubpixelAntialiasedTextState(GraphicsLayer::supportsSubpixelAntialiasedLayerText());
     1262    contentsInfo.setWantsSubpixelAntialiasedTextState(GraphicsLayer::supportsSubpixelAntialiasedLayerText() && FontCascade::isSubpixelAntialiasingAvailable());
    12631263
    12641264    if (!m_owningLayer.isRenderViewLayer()) {
  • trunk/Source/WebCore/testing/Internals.cpp

    r239279 r239306  
    16301630void Internals::setFontSmoothingEnabled(bool enabled)
    16311631{
    1632     WebCore::FontCascade::setShouldUseSmoothing(enabled);
     1632    FontCascade::setShouldUseSmoothing(enabled);
    16331633}
    16341634
  • trunk/Tools/ChangeLog

    r239303 r239306  
     12018-12-17  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Don't use more expensive layer backing store formats when subpixel text antialiasing is not enabled
     4        https://bugs.webkit.org/show_bug.cgi?id=192780
     5        rdar://problem/43394387
     6
     7        Reviewed by Tim Horton.
     8
     9        No need to set "AppleFontSmoothing" defaults for WK2.
     10
     11        * WebKitTestRunner/InjectedBundle/mac/InjectedBundleMac.mm:
     12        (WTR::InjectedBundle::platformInitialize):
     13
    1142018-12-17  Jonathan Bedard  <jbedard@apple.com>
    215
  • trunk/Tools/WebKitTestRunner/InjectedBundle/mac/InjectedBundleMac.mm

    r230190 r239306  
    3737void InjectedBundle::platformInitialize(WKTypeRef initializationUserData)
    3838{
    39     static const int NoFontSmoothing = 0;
    4039    static const int BlueTintedAppearance = 1;
    4140
     
    5150    NSDictionary *dict = @{
    5251        @"AppleAntiAliasingThreshold": @4,
    53         // FIXME: Setting AppleFontSmoothing is likely unnecessary and ineffective. WebKit2 has its own preference for font smoothing, which is
    54         // applied to each context via CGContextSetShouldSmoothFonts, presumably overriding the default.
    55         @"AppleFontSmoothing": @(NoFontSmoothing),
    5652        @"AppleAquaColorVariant": @(BlueTintedAppearance),
    5753        @"AppleHighlightColor": @"0.709800 0.835300 1.000000",
Note: See TracChangeset for help on using the changeset viewer.