Changeset 197981 in webkit


Ignore:
Timestamp:
Mar 10, 2016 5:49:22 PM (8 years ago)
Author:
Simon Fraser
Message:

Font antialiasing (smoothing) changes when elements are rendered into compositing layers
https://bugs.webkit.org/show_bug.cgi?id=23364

Reviewed by Tim Horton.

Source/WebCore:

Improve the appearance of subpixel-antialiased ("smoothed") text in non-opaque layers
by opting in to a new CALayer backing store format.

GraphicsLayer now has setSupportsSmoothedFonts(), which is called by RenderLayerBacking
when the platform has support for the new feature. Ideally this would only be set when
we know a layer has smoothed text drawn into it, but, for now, enable this for all
layers. The right thing happens with opaque layers under the hood.

setSupportsSmoothedFonts() is turned into a PlatformCALayer contentsFormat flag, which
is ultimately passed to setBackingStoreFormat().

We also need to propagate this flag to TileController tiles.

  • platform/graphics/GraphicsLayer.cpp:

(WebCore::GraphicsLayer::supportsSmoothedLayerText):
(WebCore::GraphicsLayer::setSmoothedLayerTextEnabled):
(WebCore::GraphicsLayer::smoothedLayerTextEnabled):
(WebCore::GraphicsLayer::GraphicsLayer):

  • platform/graphics/GraphicsLayer.h:

(WebCore::GraphicsLayer::supportsSmoothedFonts):
(WebCore::GraphicsLayer::setSupportsSmoothedFonts):

  • platform/graphics/TiledBacking.h:
  • platform/graphics/ca/GraphicsLayerCA.cpp:

(WebCore::GraphicsLayer::supportsSmoothedLayerText):
(WebCore::GraphicsLayer::setSmoothedLayerTextEnabled):
(WebCore::GraphicsLayer::smoothedLayerTextEnabled):
(WebCore::GraphicsLayerCA::setSupportsSmoothedFonts):
(WebCore::GraphicsLayerCA::commitLayerChangesBeforeSublayers):
(WebCore::GraphicsLayerCA::updateContentsFormat):

  • platform/graphics/ca/GraphicsLayerCA.h:
  • platform/graphics/ca/PlatformCALayer.cpp:

(WebCore::PlatformCALayer::drawRepaintIndicator): Give the number a "shadow" when
the contents format says we support smoothed fonts.

  • platform/graphics/ca/PlatformCALayer.h:
  • platform/graphics/ca/TileController.cpp:

(WebCore::TileController::setTileContentsFormatFlags):
(WebCore::TileController::createTileLayer):

  • platform/graphics/ca/TileController.h:
  • platform/graphics/ca/TileGrid.cpp:

(WebCore::TileGrid::updateTileLayerProperties):

  • platform/graphics/ca/cocoa/PlatformCALayerCocoa.h:
  • platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm:

(WebCore::setBackingStoreFormat):
(PlatformCALayerCocoa::commonInit):
(PlatformCALayerCocoa::setContentsFormat):
(PlatformCALayer::drawLayerContents): Previously, we turned off font smoothing in
non-opaque layers to improve text appearance. We no longer need to do that when
the contents format has "SmoothedFonts".

  • platform/graphics/ca/win/PlatformCALayerWin.cpp:

(PlatformCALayerWin::setContentsFormat):
(PlatformCALayerWin::contentsFormat):

  • platform/graphics/ca/win/PlatformCALayerWin.h:
  • platform/ios/LegacyTileGridTile.mm:

(WebCore::setBackingStoreFormat):
(WebCore::LegacyTileGridTile::LegacyTileGridTile):

  • rendering/RenderLayerBacking.cpp:

(WebCore::RenderLayerBacking::createGraphicsLayer):

Source/WebKit/mac:

Allow internal clients to turn off smoothed layer text, so that WebKitTestRunner
can disable it.

  • WebView/WebView.mm:

(+[WebView _setSmoothedLayerTextEnabled:]):
(+[WebView _smoothedLayerTextEnabled]):

  • WebView/WebViewPrivate.h:

Source/WebKit2:

Send the ContentsFormat to the UI process (but nothing happens to it there yet).

Allow internal clients to turn off smoothed layer text, so that WebKitTestRunner
can disable it.

  • Shared/WebProcessCreationParameters.cpp:

(WebKit::WebProcessCreationParameters::WebProcessCreationParameters):
(WebKit::WebProcessCreationParameters::encode):
(WebKit::WebProcessCreationParameters::decode):

  • Shared/WebProcessCreationParameters.h:
  • Shared/mac/RemoteLayerTreeTransaction.h:
  • Shared/mac/RemoteLayerTreeTransaction.mm:

(WebKit::RemoteLayerTreeTransaction::LayerProperties::encode):
(WebKit::RemoteLayerTreeTransaction::LayerProperties::decode):

  • UIProcess/API/C/WKContext.cpp:

(WKContextEnableSmoothedLayerText):

  • UIProcess/API/C/WKContextPrivate.h:
  • UIProcess/WebProcessPool.cpp:

(WebKit::WebProcessPool::createNewWebProcess):
(WebKit::WebProcessPool::enableSmoothedLayerText):
(WebKit::WebProcessPool::WebProcessPool): Deleted.

  • UIProcess/WebProcessPool.h:
  • WebProcess/WebPage/mac/PlatformCALayerRemote.cpp:

(WebKit::PlatformCALayerRemote::setContentsFormat):
(WebKit::PlatformCALayerRemote::contentsFormat):

  • WebProcess/WebPage/mac/PlatformCALayerRemote.h:
  • WebProcess/WebProcess.cpp:

(WebKit::WebProcess::initializeWebProcess):
(WebKit::WebProcess::enableSmoothedLayerText):

  • WebProcess/WebProcess.h:
  • WebProcess/WebProcess.messages.in:

Tools:

Turn off smoothed layer text because it affects many layout test results.

  • DumpRenderTree/mac/DumpRenderTree.mm:

(resetWebViewToConsistentStateBeforeTesting):

  • WebKitTestRunner/TestController.cpp:

(WTR::TestController::resetStateToConsistentValues):

Location:
trunk
Files:
37 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r197980 r197981  
     12016-03-10  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Font antialiasing (smoothing) changes when elements are rendered into compositing layers
     4        https://bugs.webkit.org/show_bug.cgi?id=23364
     5
     6        Reviewed by Tim Horton.
     7
     8        Improve the appearance of subpixel-antialiased ("smoothed") text in non-opaque layers
     9        by opting in to a new CALayer backing store format.
     10
     11        GraphicsLayer now has setSupportsSmoothedFonts(), which is called by RenderLayerBacking
     12        when the platform has support for the new feature. Ideally this would only be set when
     13        we know a layer has smoothed text drawn into it, but, for now, enable this for all
     14        layers. The right thing happens with opaque layers under the hood.
     15
     16        setSupportsSmoothedFonts() is turned into a PlatformCALayer contentsFormat flag, which
     17        is ultimately passed to setBackingStoreFormat().
     18
     19        We also need to propagate this flag to TileController tiles.
     20
     21        * platform/graphics/GraphicsLayer.cpp:
     22        (WebCore::GraphicsLayer::supportsSmoothedLayerText):
     23        (WebCore::GraphicsLayer::setSmoothedLayerTextEnabled):
     24        (WebCore::GraphicsLayer::smoothedLayerTextEnabled):
     25        (WebCore::GraphicsLayer::GraphicsLayer):
     26        * platform/graphics/GraphicsLayer.h:
     27        (WebCore::GraphicsLayer::supportsSmoothedFonts):
     28        (WebCore::GraphicsLayer::setSupportsSmoothedFonts):
     29        * platform/graphics/TiledBacking.h:
     30        * platform/graphics/ca/GraphicsLayerCA.cpp:
     31        (WebCore::GraphicsLayer::supportsSmoothedLayerText):
     32        (WebCore::GraphicsLayer::setSmoothedLayerTextEnabled):
     33        (WebCore::GraphicsLayer::smoothedLayerTextEnabled):
     34        (WebCore::GraphicsLayerCA::setSupportsSmoothedFonts):
     35        (WebCore::GraphicsLayerCA::commitLayerChangesBeforeSublayers):
     36        (WebCore::GraphicsLayerCA::updateContentsFormat):
     37        * platform/graphics/ca/GraphicsLayerCA.h:
     38        * platform/graphics/ca/PlatformCALayer.cpp:
     39        (WebCore::PlatformCALayer::drawRepaintIndicator): Give the number a "shadow" when
     40        the contents format says we support smoothed fonts.
     41        * platform/graphics/ca/PlatformCALayer.h:
     42        * platform/graphics/ca/TileController.cpp:
     43        (WebCore::TileController::setTileContentsFormatFlags):
     44        (WebCore::TileController::createTileLayer):
     45        * platform/graphics/ca/TileController.h:
     46        * platform/graphics/ca/TileGrid.cpp:
     47        (WebCore::TileGrid::updateTileLayerProperties):
     48        * platform/graphics/ca/cocoa/PlatformCALayerCocoa.h:
     49        * platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm:
     50        (WebCore::setBackingStoreFormat):
     51        (PlatformCALayerCocoa::commonInit):
     52        (PlatformCALayerCocoa::setContentsFormat):
     53        (PlatformCALayer::drawLayerContents): Previously, we turned off font smoothing in
     54        non-opaque layers to improve text appearance. We no longer need to do that when
     55        the contents format has "SmoothedFonts".
     56        * platform/graphics/ca/win/PlatformCALayerWin.cpp:
     57        (PlatformCALayerWin::setContentsFormat):
     58        (PlatformCALayerWin::contentsFormat):
     59        * platform/graphics/ca/win/PlatformCALayerWin.h:
     60        * platform/ios/LegacyTileGridTile.mm:
     61        (WebCore::setBackingStoreFormat):
     62        (WebCore::LegacyTileGridTile::LegacyTileGridTile):
     63        * rendering/RenderLayerBacking.cpp:
     64        (WebCore::RenderLayerBacking::createGraphicsLayer):
     65
    1662016-03-10  Commit Queue  <commit-queue@webkit.org>
    267
  • trunk/Source/WebCore/platform/graphics/GraphicsLayer.cpp

    r197941 r197981  
    106106#endif
    107107
     108#if !USE(CA)
     109bool GraphicsLayer::supportsSmoothedLayerText()
     110{
     111    return false;
     112}
     113
     114void GraphicsLayer::setSmoothedLayerTextEnabled(bool)
     115{
     116}
     117
     118bool GraphicsLayer::smoothedLayerTextEnabled()
     119{
     120    return false;
     121}
     122#endif
     123
    108124GraphicsLayer::GraphicsLayer(Type type, GraphicsLayerClient& client)
    109125    : m_client(client)
     
    116132    , m_type(type)
    117133    , m_contentsOpaque(false)
     134    , m_supportsSmoothedFonts(false)
    118135    , m_preserves3D(false)
    119136    , m_backfaceVisibility(true)
  • trunk/Source/WebCore/platform/graphics/GraphicsLayer.h

    r197941 r197981  
    365365    virtual void setContentsOpaque(bool b) { m_contentsOpaque = b; }
    366366
     367    bool supportsSmoothedFonts() const { return m_supportsSmoothedFonts; }
     368    virtual void setSupportsSmoothedFonts(bool b) { m_supportsSmoothedFonts = b; }
     369
    367370    bool backfaceVisibility() const { return m_backfaceVisibility; }
    368371    virtual void setBackfaceVisibility(bool b) { m_backfaceVisibility = b; }
     
    541544    static bool supportsLayerType(Type);
    542545    static bool supportsContentsTiling();
     546    static bool supportsSmoothedLayerText();
     547
     548    WEBCORE_EXPORT static void setSmoothedLayerTextEnabled(bool);
     549    WEBCORE_EXPORT static bool smoothedLayerTextEnabled();
    543550
    544551    void updateDebugIndicators();
     
    614621
    615622    bool m_contentsOpaque : 1;
     623    bool m_supportsSmoothedFonts : 1;
    616624    bool m_preserves3D: 1;
    617625    bool m_backfaceVisibility : 1;
  • trunk/Source/WebCore/platform/graphics/TiledBacking.h

    r197941 r197981  
    8080    virtual void setTopContentInset(float) = 0;
    8181
     82    virtual void setTileContentsFormatFlags(unsigned) = 0;
     83
    8284    virtual void setVelocity(const VelocityData&) = 0;
    8385   
  • trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp

    r197941 r197981  
    310310}
    311311
     312static bool isSmoothedLayerTextEnabled = true;
     313
     314bool GraphicsLayer::supportsSmoothedLayerText()
     315{
     316#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
     317    return isSmoothedLayerTextEnabled;
     318#endif
     319    return false;
     320}
     321
     322void GraphicsLayer::setSmoothedLayerTextEnabled(bool flag)
     323{
     324    isSmoothedLayerTextEnabled = flag;
     325}
     326
     327bool GraphicsLayer::smoothedLayerTextEnabled()
     328{
     329    return isSmoothedLayerTextEnabled;
     330}
     331
    312332std::unique_ptr<GraphicsLayer> GraphicsLayer::create(GraphicsLayerFactory* factory, GraphicsLayerClient& client, Type layerType)
    313333{
     
    708728    GraphicsLayer::setContentsOpaque(opaque);
    709729    noteLayerPropertyChanged(ContentsOpaqueChanged);
     730}
     731
     732void GraphicsLayerCA::setSupportsSmoothedFonts(bool supportsSmoothedFonts)
     733{
     734    if (m_supportsSmoothedFonts == supportsSmoothedFonts)
     735        return;
     736
     737    GraphicsLayer::setSupportsSmoothedFonts(supportsSmoothedFonts);
     738    noteLayerPropertyChanged(ContentsFormatChanged);
    710739}
    711740
     
    15811610        updateContentsOpaque(pageScaleFactor);
    15821611
     1612    if (m_uncommittedChanges & ContentsFormatChanged)
     1613        updateContentsFormat();
     1614
    15831615    if (m_uncommittedChanges & BackfaceVisibilityChanged)
    15841616        updateBackfaceVisibility();
     
    18881920        for (auto& layer : layerCloneMap->values())
    18891921            layer->setOpaque(contentsOpaque);
     1922    }
     1923}
     1924
     1925void GraphicsLayerCA::updateContentsFormat()
     1926{
     1927    PlatformCALayer::ContentsFormatFlags formatFlags = 0;
     1928    if (supportsSmoothedFonts())
     1929        formatFlags |= PlatformCALayer::SmoothedFonts;
     1930
     1931    m_layer->setContentsFormat(formatFlags);
     1932
     1933    if (LayerMap* layerCloneMap = m_layerClones.get()) {
     1934        for (auto& layer : layerCloneMap->values())
     1935            layer->setContentsFormat(formatFlags);
    18901936    }
    18911937}
  • trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h

    r197941 r197981  
    9696
    9797    WEBCORE_EXPORT void setContentsOpaque(bool) override;
     98    WEBCORE_EXPORT void setSupportsSmoothedFonts(bool) override;
     99
    98100    WEBCORE_EXPORT void setBackfaceVisibility(bool) override;
    99101
     
    392394    void updateContentsVisibility();
    393395    void updateContentsOpaque(float pageScaleFactor);
     396    void updateContentsFormat();
    394397    void updateBackfaceVisibility();
    395398    void updateStructuralLayer();
     
    456459
    457460    enum LayerChange : uint64_t {
    458         NoChange =                      0,
    459         NameChanged =                   1LLU << 1,
    460         ChildrenChanged =               1LLU << 2, // also used for content layer, and preserves-3d, and size if tiling changes?
    461         GeometryChanged =               1LLU << 3,
    462         TransformChanged =              1LLU << 4,
    463         ChildrenTransformChanged =      1LLU << 5,
    464         Preserves3DChanged =            1LLU << 6,
    465         MasksToBoundsChanged =          1LLU << 7,
    466         DrawsContentChanged =           1LLU << 8,
    467         BackgroundColorChanged =        1LLU << 9,
    468         ContentsOpaqueChanged =         1LLU << 10,
    469         BackfaceVisibilityChanged =     1LLU << 11,
    470         OpacityChanged =                1LLU << 12,
    471         AnimationChanged =              1LLU << 13,
    472         DirtyRectsChanged =             1LLU << 14,
    473         ContentsImageChanged =          1LLU << 15,
    474         ContentsPlatformLayerChanged =  1LLU << 16,
    475         ContentsColorLayerChanged =     1LLU << 17,
    476         ContentsRectsChanged =          1LLU << 18,
    477         MasksToBoundsRectChanged =      1LLU << 19,
    478         MaskLayerChanged =              1LLU << 20,
    479         ReplicatedLayerChanged =        1LLU << 21,
    480         ContentsNeedsDisplay =          1LLU << 22,
    481         AcceleratesDrawingChanged =     1LLU << 23,
    482         ContentsScaleChanged =          1LLU << 24,
    483         ContentsVisibilityChanged =     1LLU << 25,
    484         CoverageRectChanged =           1LLU << 26,
    485         FiltersChanged =                1LLU << 27,
    486         BackdropFiltersChanged =        1LLU << 28,
    487         BackdropFiltersRectChanged =    1LLU << 29,
    488         TilingAreaChanged =             1LLU << 30,
    489         TilesAdded =                    1LLU << 31,
    490         DebugIndicatorsChanged =        1LLU << 32,
    491         CustomAppearanceChanged =       1LLU << 33,
    492         BlendModeChanged =              1LLU << 34,
    493         ShapeChanged =                  1LLU << 35,
    494         WindRuleChanged =               1LLU << 36,
     461        NoChange                        = 0,
     462        NameChanged                     = 1LLU << 1,
     463        ChildrenChanged                 = 1LLU << 2, // also used for content layer, and preserves-3d, and size if tiling changes?
     464        GeometryChanged                 = 1LLU << 3,
     465        TransformChanged                = 1LLU << 4,
     466        ChildrenTransformChanged        = 1LLU << 5,
     467        Preserves3DChanged              = 1LLU << 6,
     468        MasksToBoundsChanged            = 1LLU << 7,
     469        DrawsContentChanged             = 1LLU << 8,
     470        BackgroundColorChanged          = 1LLU << 9,
     471        ContentsOpaqueChanged           = 1LLU << 10,
     472        ContentsFormatChanged           = 1LLU << 11,
     473        BackfaceVisibilityChanged       = 1LLU << 12,
     474        OpacityChanged                  = 1LLU << 13,
     475        AnimationChanged                = 1LLU << 14,
     476        DirtyRectsChanged               = 1LLU << 15,
     477        ContentsImageChanged            = 1LLU << 16,
     478        ContentsPlatformLayerChanged    = 1LLU << 17,
     479        ContentsColorLayerChanged       = 1LLU << 18,
     480        ContentsRectsChanged            = 1LLU << 19,
     481        MasksToBoundsRectChanged        = 1LLU << 20,
     482        MaskLayerChanged                = 1LLU << 21,
     483        ReplicatedLayerChanged          = 1LLU << 22,
     484        ContentsNeedsDisplay            = 1LLU << 23,
     485        AcceleratesDrawingChanged       = 1LLU << 24,
     486        ContentsScaleChanged            = 1LLU << 25,
     487        ContentsVisibilityChanged       = 1LLU << 26,
     488        CoverageRectChanged             = 1LLU << 27,
     489        FiltersChanged                  = 1LLU << 28,
     490        BackdropFiltersChanged          = 1LLU << 29,
     491        BackdropFiltersRectChanged      = 1LLU << 30,
     492        TilingAreaChanged               = 1LLU << 31,
     493        TilesAdded                      = 1LLU << 32,
     494        DebugIndicatorsChanged          = 1LLU << 33,
     495        CustomAppearanceChanged         = 1LLU << 34,
     496        BlendModeChanged                = 1LLU << 35,
     497        ShapeChanged                    = 1LLU << 36,
     498        WindRuleChanged                 = 1LLU << 37,
    495499    };
    496500    typedef uint64_t LayerChangeFlags;
  • trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.cpp

    r197941 r197981  
    8181   
    8282    CGContextFillRect(context, indicatorBox);
    83    
     83
     84    if (platformCALayer->owner()->isUsingDisplayListDrawing(platformCALayer)) {
     85        CGContextSetRGBStrokeColor(context, 0, 0, 0, 0.65);
     86        CGContextSetLineWidth(context, 2);
     87        CGContextStrokeRect(context, indicatorBox);
     88    }
     89   
     90    if (!platformCALayer->isOpaque() && (platformCALayer->contentsFormat() & SmoothedFonts)) {
     91        CGContextSetRGBFillColor(context, 1, 1, 1, 0.4);
     92        platformCALayer->drawTextAtPoint(context, indicatorBox.origin.x + 7, indicatorBox.origin.y + 24, CGSizeMake(1, -1), 22, text, strlen(text));
     93    }
     94
    8495    if (platformCALayer->acceleratesDrawing())
    8596        CGContextSetRGBFillColor(context, 1, 0, 0, 1);
    8697    else
    8798        CGContextSetRGBFillColor(context, 1, 1, 1, 1);
    88 
    89     if (platformCALayer->owner()->isUsingDisplayListDrawing(platformCALayer)) {
    90         CGContextSetRGBStrokeColor(context, 0, 0, 0, 0.65);
    91         CGContextSetLineWidth(context, 2);
    92         CGContextStrokeRect(context, indicatorBox);
    93     }
    9499   
    95100    platformCALayer->drawTextAtPoint(context, indicatorBox.origin.x + 5, indicatorBox.origin.y + 22, CGSizeMake(1, -1), 22, text, strlen(text));
  • trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.h

    r197941 r197981  
    140140    virtual void setOpaque(bool) = 0;
    141141
     142    enum ContentsFormatFlag {
     143        DeepColor       = 1 << 0,
     144        SmoothedFonts   = 1 << 1,
     145    };
     146    typedef unsigned ContentsFormatFlags;
     147    virtual void setContentsFormat(ContentsFormatFlags) = 0;
     148    virtual ContentsFormatFlags contentsFormat() const = 0;
     149
    142150    virtual FloatRect bounds() const = 0;
    143151    virtual void setBounds(const FloatRect&) = 0;
  • trunk/Source/WebCore/platform/graphics/ca/TileController.cpp

    r197941 r197981  
    176176}
    177177
     178void TileController::setTileContentsFormatFlags(PlatformCALayer::ContentsFormatFlags flags)
     179{
     180    if (flags == m_contentsFormatFlags)
     181        return;
     182
     183    m_contentsFormatFlags = flags;
     184    tileGrid().updateTileLayerProperties();
     185}
     186
    178187void TileController::setVisibleRect(const FloatRect& rect)
    179188{
     
    676685    layer->setEdgeAntialiasingMask(0);
    677686    layer->setOpaque(m_tilesAreOpaque);
     687    layer->setContentsFormat(m_contentsFormatFlags);
    678688#ifndef NDEBUG
    679689    layer->setName("Tile");
  • trunk/Source/WebCore/platform/graphics/ca/TileController.h

    r197941 r197981  
    7878    WEBCORE_EXPORT void setTilesOpaque(bool);
    7979    bool tilesAreOpaque() const { return m_tilesAreOpaque; }
     80
     81    void setTileContentsFormatFlags(PlatformCALayer::ContentsFormatFlags) override;
     82    PlatformCALayer::ContentsFormatFlags tileContentsFormatFlags() const { return m_contentsFormatFlags; }
    8083
    8184    PlatformCALayer& rootLayer() { return *m_tileCacheLayer; }
     
    207210    int m_marginSize { kDefaultTileSize };
    208211
     212    PlatformCALayer::ContentsFormatFlags m_contentsFormatFlags { 0 };
     213
    209214    // m_marginTop and m_marginBottom are the height in pixels of the top and bottom margin tiles. The width
    210215    // of those tiles will be equivalent to the width of the other tiles in the grid. m_marginRight and
  • trunk/Source/WebCore/platform/graphics/ca/TileGrid.cpp

    r197941 r197981  
    176176    bool acceleratesDrawing = m_controller.acceleratesDrawing();
    177177    bool opaque = m_controller.tilesAreOpaque();
     178    PlatformCALayer::ContentsFormatFlags formatFlags = m_controller.tileContentsFormatFlags();
    178179    Color tileDebugBorderColor = m_controller.tileDebugBorderColor();
    179180    float tileDebugBorderWidth = m_controller.tileDebugBorderWidth();
     
    183184        tileInfo.layer->setAcceleratesDrawing(acceleratesDrawing);
    184185        tileInfo.layer->setOpaque(opaque);
     186        tileInfo.layer->setContentsFormat(formatFlags);
    185187        tileInfo.layer->setBorderColor(tileDebugBorderColor);
    186188        tileInfo.layer->setBorderWidth(tileDebugBorderWidth);
  • trunk/Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.h

    r197941 r197981  
    7272    bool isOpaque() const override;
    7373    void setOpaque(bool) override;
     74
     75    void setContentsFormat(ContentsFormatFlags) override;
     76    ContentsFormatFlags contentsFormat() const override { return m_contentsFormatFlags; }
    7477
    7578    FloatRect bounds() const override;
     
    180183    GraphicsLayer::CustomAppearance m_customAppearance;
    181184    std::unique_ptr<FloatRoundedRect> m_shapeRoundedRect;
     185    ContentsFormatFlags m_contentsFormatFlags { 0 };
    182186};
    183187
  • trunk/Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm

    r197941 r197981  
    7070#else
    7171namespace WebCore {
    72 static void setBackingStoreFormat(CALayer *)
     72static void setBackingStoreFormat(CALayer *, PlatformCALayer::ContentsFormatFlags)
    7373{
    7474}
     
    309309
    310310    if (m_layerType == LayerTypeWebLayer || m_layerType == LayerTypeTiledBackingTileLayer)
    311         setBackingStoreFormat(m_layer.get());
     311        setBackingStoreFormat(m_layer.get(), 0);
    312312
    313313    // So that the scrolling thread's performance logging code can find all the tiles, mark this as being a tile.
     
    546546}
    547547
     548void PlatformCALayerCocoa::setContentsFormat(ContentsFormatFlags flags)
     549{
     550    if (flags == m_contentsFormatFlags)
     551        return;
     552
     553    m_contentsFormatFlags = flags;
     554
     555    if (usesTiledBackingLayer()) {
     556        WebTiledBackingLayer* tiledBackingLayer = static_cast<WebTiledBackingLayer*>(m_layer.get());
     557        tiledBackingLayer.tiledBacking->setTileContentsFormatFlags(flags);
     558        return;
     559    }
     560
     561    setBackingStoreFormat(m_layer.get(), flags);
     562}
     563
    548564FloatRect PlatformCALayerCocoa::bounds() const
    549565{
     
    10571073    graphicsContext.setIsAcceleratedContext(platformCALayer->acceleratesDrawing());
    10581074   
    1059     if (!layerContents->platformCALayerContentsOpaque()) {
     1075    if (!layerContents->platformCALayerContentsOpaque() && !(platformCALayer->contentsFormat() & SmoothedFonts)) {
    10601076        // Turn off font smoothing to improve the appearance of text rendered onto a transparent background.
    10611077        graphicsContext.setShouldSmoothFonts(false);
  • trunk/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.cpp

    r197941 r197981  
    378378}
    379379
     380void PlatformCALayerWin::setContentsFormat(ContentsFormatFlags formatFlags)
     381{
     382    m_contentsFormat = formatFlags;
     383}
     384
     385PlatformCALayer::ContentsFormatFlags PlatformCALayerWin::contentsFormat() const
     386{
     387    return m_contentsFormat;
     388}
     389
    380390FloatRect PlatformCALayerWin::bounds() const
    381391{
  • trunk/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.h

    r197941 r197981  
    6464    bool isOpaque() const override;
    6565    void setOpaque(bool) override;
     66
     67    void setContentsFormat(ContentsFormatFlags) override;
     68    ContentsFormatFlags contentsFormat() const override;
    6669
    6770    FloatRect bounds() const override;
     
    164167    std::unique_ptr<PlatformCALayerList> m_customSublayers;
    165168    GraphicsLayer::CustomAppearance m_customAppearance;
     169    ContentsFormatFlags m_contentsFormat { 0 };
    166170};
    167171
  • trunk/Source/WebCore/platform/ios/LegacyTileGridTile.mm

    r197941 r197981  
    2929#if PLATFORM(IOS)
    3030
     31#include "BlockExceptions.h"
    3132#include "Color.h"
    3233#include "LegacyTileCache.h"
     
    3435#include "LegacyTileLayer.h"
    3536#include "LegacyTileLayerPool.h"
     37#include "PlatformCALayer.h"
    3638#include "QuartzCoreSPI.h"
    3739#include "WAKWindow.h"
     
    4446#else
    4547namespace WebCore {
    46 static void setBackingStoreFormat(CALayer *)
     48static void setBackingStoreFormat(CALayer *, PlatformCALayer::ContentsFormatFlags)
    4749{
    4850}
     
    7274    }
    7375    LegacyTileLayer* layer = m_tileLayer.get();
    74     setBackingStoreFormat(layer);
     76    setBackingStoreFormat(layer, 0);
    7577    [layer setTileGrid:tileGrid];
    7678    [layer setOpaque:m_tileGrid->tileCache().tilesOpaque()];
  • trunk/Source/WebCore/rendering/RenderLayerBacking.cpp

    r197941 r197981  
    179179    graphicsLayer->setUsesDisplayListDrawing(compositor().displayListDrawingEnabled());
    180180#endif
     181
     182    // FIXME: ideally we'd only do this if the layer contains smoothed text.
     183    if (GraphicsLayer::supportsSmoothedLayerText())
     184        graphicsLayer->setSupportsSmoothedFonts(true);
    181185   
    182186    return graphicsLayer;
  • trunk/Source/WebKit/mac/ChangeLog

    r197968 r197981  
     12016-03-10  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Font antialiasing (smoothing) changes when elements are rendered into compositing layers
     4        https://bugs.webkit.org/show_bug.cgi?id=23364
     5
     6        Reviewed by Tim Horton.
     7
     8        Allow internal clients to turn off smoothed layer text, so that WebKitTestRunner
     9        can disable it.
     10
     11        * WebView/WebView.mm:
     12        (+[WebView _setSmoothedLayerTextEnabled:]):
     13        (+[WebView _smoothedLayerTextEnabled]):
     14        * WebView/WebViewPrivate.h:
     15
    1162016-03-10  Jer Noble  <jer.noble@apple.com>
    217
  • trunk/Source/WebKit/mac/WebView/WebView.mm

    r197968 r197981  
    141141#import <WebCore/GeolocationController.h>
    142142#import <WebCore/GeolocationError.h>
     143#import <WebCore/GraphicsLayer.h>
    143144#import <WebCore/HTMLNames.h>
    144145#import <WebCore/HTMLVideoElement.h>
     
    32373238}
    32383239
     3240+ (void)_setSmoothedLayerTextEnabled:(BOOL)f
     3241{
     3242    GraphicsLayer::setSmoothedLayerTextEnabled(f);
     3243}
     3244
     3245+ (BOOL)_smoothedLayerTextEnabled
     3246{
     3247    return GraphicsLayer::smoothedLayerTextEnabled();
     3248}
     3249
    32393250#if !PLATFORM(IOS)
    32403251+ (void)_setUsesTestModeFocusRingColor:(BOOL)f
  • trunk/Source/WebKit/mac/WebView/WebViewPrivate.h

    r196024 r197981  
    533533+ (BOOL)_shouldUseFontSmoothing;
    534534
     535+ (void)_setSmoothedLayerTextEnabled:(BOOL)f;
     536+ (BOOL)_smoothedLayerTextEnabled;
     537
    535538#if !TARGET_OS_IPHONE
    536539// These two methods are useful for a test harness that needs a consistent appearance for the focus rings
  • trunk/Source/WebKit2/ChangeLog

    r197976 r197981  
     12016-03-10  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Font antialiasing (smoothing) changes when elements are rendered into compositing layers
     4        https://bugs.webkit.org/show_bug.cgi?id=23364
     5
     6        Reviewed by Tim Horton.
     7
     8        Send the ContentsFormat to the UI process (but nothing happens to it there yet).
     9
     10        Allow internal clients to turn off smoothed layer text, so that WebKitTestRunner
     11        can disable it.
     12
     13        * Shared/WebProcessCreationParameters.cpp:
     14        (WebKit::WebProcessCreationParameters::WebProcessCreationParameters):
     15        (WebKit::WebProcessCreationParameters::encode):
     16        (WebKit::WebProcessCreationParameters::decode):
     17        * Shared/WebProcessCreationParameters.h:
     18        * Shared/mac/RemoteLayerTreeTransaction.h:
     19        * Shared/mac/RemoteLayerTreeTransaction.mm:
     20        (WebKit::RemoteLayerTreeTransaction::LayerProperties::encode):
     21        (WebKit::RemoteLayerTreeTransaction::LayerProperties::decode):
     22        * UIProcess/API/C/WKContext.cpp:
     23        (WKContextEnableSmoothedLayerText):
     24        * UIProcess/API/C/WKContextPrivate.h:
     25        * UIProcess/WebProcessPool.cpp:
     26        (WebKit::WebProcessPool::createNewWebProcess):
     27        (WebKit::WebProcessPool::enableSmoothedLayerText):
     28        (WebKit::WebProcessPool::WebProcessPool): Deleted.
     29        * UIProcess/WebProcessPool.h:
     30        * WebProcess/WebPage/mac/PlatformCALayerRemote.cpp:
     31        (WebKit::PlatformCALayerRemote::setContentsFormat):
     32        (WebKit::PlatformCALayerRemote::contentsFormat):
     33        * WebProcess/WebPage/mac/PlatformCALayerRemote.h:
     34        * WebProcess/WebProcess.cpp:
     35        (WebKit::WebProcess::initializeWebProcess):
     36        (WebKit::WebProcess::enableSmoothedLayerText):
     37        * WebProcess/WebProcess.h:
     38        * WebProcess/WebProcess.messages.in:
     39
    1402016-03-10  Enrica Casucci  <enrica@apple.com>
    241
  • trunk/Source/WebKit2/Shared/WebProcessCreationParameters.cpp

    r197592 r197981  
    3636
    3737WebProcessCreationParameters::WebProcessCreationParameters()
    38     : shouldAlwaysUseComplexTextCodePath(false)
    39     , shouldEnableMemoryPressureReliefLogging(false)
    40     , shouldUseFontSmoothing(true)
    41     , defaultRequestTimeoutInterval(INT_MAX)
    42 #if PLATFORM(COCOA)
    43     , shouldEnableJIT(false)
    44     , shouldEnableFTLJIT(false)
    45 #endif
    46     , memoryCacheDisabled(false)
    47 #if ENABLE(SERVICE_CONTROLS)
    48     , hasImageServices(false)
    49     , hasSelectionServices(false)
    50     , hasRichContentServices(false)
    51 #endif
     38    : defaultRequestTimeoutInterval(INT_MAX)
    5239{
    5340}
     
    9784    encoder << shouldSuppressMemoryPressureHandler;
    9885    encoder << shouldUseFontSmoothing;
     86    encoder << enabledSmoothedLayerText;
    9987    encoder << resourceLoadStatisticsEnabled;
    10088    encoder << fontWhitelist;
     
    215203    if (!decoder.decode(parameters.shouldUseFontSmoothing))
    216204        return false;
     205    if (!decoder.decode(parameters.enabledSmoothedLayerText))
     206        return false;
    217207    if (!decoder.decode(parameters.resourceLoadStatisticsEnabled))
    218208        return false;
  • trunk/Source/WebKit2/Shared/WebProcessCreationParameters.h

    r197592 r197981  
    104104    CacheModel cacheModel;
    105105
    106     bool shouldAlwaysUseComplexTextCodePath;
    107     bool shouldEnableMemoryPressureReliefLogging;
     106    bool shouldAlwaysUseComplexTextCodePath { false };
     107    bool shouldEnableMemoryPressureReliefLogging { false };
    108108    bool shouldSuppressMemoryPressureHandler { false };
    109     bool shouldUseFontSmoothing;
     109    bool shouldUseFontSmoothing { true };
     110    bool enabledSmoothedLayerText { true };
    110111    bool resourceLoadStatisticsEnabled { false };
    111112
     
    139140    SandboxExtension::Handle uiProcessBundleResourcePathExtensionHandle;
    140141
    141     bool shouldEnableJIT;
    142     bool shouldEnableFTLJIT;
     142    bool shouldEnableJIT { false };
     143    bool shouldEnableFTLJIT { false };
    143144   
    144145    RefPtr<API::Data> bundleParameterData;
     
    153154    Vector<String> plugInAutoStartOrigins;
    154155
    155     bool memoryCacheDisabled;
     156    bool memoryCacheDisabled { false };
    156157
    157158#if ENABLE(SERVICE_CONTROLS)
    158     bool hasImageServices;
    159     bool hasSelectionServices;
    160     bool hasRichContentServices;
     159    bool hasImageServices { false };
     160    bool hasSelectionServices { false };
     161    bool hasRichContentServices { false };
    161162#endif
    162163
  • trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.h

    r197941 r197981  
    8888        AnimationsChanged               = 1LLU << 33,
    8989        EdgeAntialiasingMaskChanged     = 1LLU << 34,
    90         CustomAppearanceChanged         = 1LLU << 35,
     90        ContentsFormatFlagsChanged      = 1LLU << 35,
     91        CustomAppearanceChanged         = 1LLU << 36,
    9192    };
    9293    typedef uint64_t LayerChange;
     
    154155        WebCore::Color borderColor;
    155156        unsigned edgeAntialiasingMask;
     157        WebCore::PlatformCALayer::ContentsFormatFlags contentsFormatFlags;
    156158        WebCore::GraphicsLayer::CustomAppearance customAppearance;
    157159        WebCore::PlatformCALayer::FilterType minificationFilter;
  • trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.mm

    r197941 r197981  
    212212        encoder << opaque;
    213213
     214    if (changedProperties & ContentsFormatFlagsChanged)
     215        encoder << contentsFormatFlags;
     216
    214217    if (changedProperties & MaskLayerChanged)
    215218        encoder << maskLayerID;
     
    372375    if (result.changedProperties & OpaqueChanged) {
    373376        if (!decoder.decode(result.opaque))
     377            return false;
     378    }
     379
     380    if (result.changedProperties & ContentsFormatFlagsChanged) {
     381        if (!decoder.decode(result.contentsFormatFlags))
    374382            return false;
    375383    }
  • trunk/Source/WebKit2/UIProcess/API/C/WKContext.cpp

    r197563 r197981  
    348348}
    349349
     350void WKContextEnableSmoothedLayerText(WKContextRef contextRef, bool smoothedLayerText)
     351{
     352    toImpl(contextRef)->enableSmoothedLayerText(smoothedLayerText);
     353}
     354
    350355void WKContextSetAdditionalPluginsDirectory(WKContextRef contextRef, WKStringRef pluginsDirectory)
    351356{
  • trunk/Source/WebKit2/UIProcess/API/C/WKContextPrivate.h

    r195589 r197981  
    5151WK_EXPORT void WKContextSetShouldUseFontSmoothing(WKContextRef context, bool useFontSmoothing);
    5252
     53WK_EXPORT void WKContextEnableSmoothedLayerText(WKContextRef context, bool);
     54
    5355WK_EXPORT void WKContextRegisterURLSchemeAsSecure(WKContextRef context, WKStringRef urlScheme);
    5456
  • trunk/Source/WebKit2/UIProcess/WebProcessPool.cpp

    r197914 r197981  
    149149    , m_visitedLinksPopulated(false)
    150150    , m_plugInAutoStartProvider(this)
    151     , m_alwaysUsesComplexTextCodePath(false)
    152     , m_shouldUseFontSmoothing(true)
    153151    , m_memorySamplerEnabled(false)
    154152    , m_memorySamplerInterval(1400.0)
     
    587585    parameters.shouldAlwaysUseComplexTextCodePath = m_alwaysUsesComplexTextCodePath;
    588586    parameters.shouldUseFontSmoothing = m_shouldUseFontSmoothing;
     587    parameters.enabledSmoothedLayerText = m_enabledSmoothedLayerText;
    589588
    590589    // FIXME: This leaves UI process and WebProcess disagreeing about the state if the client hasn't set the path.
     
    873872}
    874873
     874void WebProcessPool::enableSmoothedLayerText(bool enableSmoothedText)
     875{
     876    m_enabledSmoothedLayerText = enableSmoothedText;
     877    sendToAllProcesses(Messages::WebProcess::EnableSmoothedLayerText(enableSmoothedText));
     878}
     879
    875880void WebProcessPool::registerURLSchemeAsEmptyDocument(const String& urlScheme)
    876881{
  • trunk/Source/WebKit2/UIProcess/WebProcessPool.h

    r197914 r197981  
    192192    void setAlwaysUsesComplexTextCodePath(bool);
    193193    void setShouldUseFontSmoothing(bool);
     194    void enableSmoothedLayerText(bool);
    194195   
    195196    void registerURLSchemeAsEmptyDocument(const String&);
     
    464465#endif
    465466
    466     bool m_alwaysUsesComplexTextCodePath;
    467     bool m_shouldUseFontSmoothing;
     467    bool m_alwaysUsesComplexTextCodePath { false };
     468    bool m_shouldUseFontSmoothing { true };
     469    bool m_enabledSmoothedLayerText { true };
    468470
    469471    Vector<String> m_fontWhitelist;
  • trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.cpp

    r197941 r197981  
    402402}
    403403
     404void PlatformCALayerRemote::setContentsFormat(ContentsFormatFlags formatFlags)
     405{
     406    if (formatFlags == m_properties.contentsFormatFlags)
     407        return;
     408
     409    m_properties.contentsFormatFlags = formatFlags;
     410    m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::ContentsFormatFlagsChanged);
     411}
     412
     413PlatformCALayer::ContentsFormatFlags PlatformCALayerRemote::contentsFormat() const
     414{
     415    return m_properties.contentsFormatFlags;
     416}
     417
    404418void PlatformCALayerRemote::setClonedLayer(const PlatformCALayer* layer)
    405419{
  • trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.h

    r197941 r197981  
    7777    void setOpaque(bool) override;
    7878
     79    void setContentsFormat(ContentsFormatFlags) override;
     80    ContentsFormatFlags contentsFormat() const override;
     81
    7982    WebCore::FloatRect bounds() const override;
    8083    void setBounds(const WebCore::FloatRect&) override;
  • trunk/Source/WebKit2/WebProcess/WebProcess.cpp

    r197592 r197981  
    7777#include <WebCore/GCController.h>
    7878#include <WebCore/GlyphPage.h>
     79#include <WebCore/GraphicsLayer.h>
    7980#include <WebCore/IconDatabase.h>
    8081#include <WebCore/JSDOMWindow.h>
     
    344345        setShouldUseFontSmoothing(true);
    345346
     347    enableSmoothedLayerText(parameters.enabledSmoothedLayerText);
     348       
    346349#if PLATFORM(COCOA) || USE(CFNETWORK)
    347350    setApplicationBundleIdentifier(parameters.uiProcessBundleIdentifier);
     
    475478{
    476479    WebCore::FontCascade::setShouldUseSmoothing(useFontSmoothing);
     480}
     481
     482void WebProcess::enableSmoothedLayerText(bool smoothedLayerText)
     483{
     484    WebCore::GraphicsLayer::setSmoothedLayerTextEnabled(smoothedLayerText);
    477485}
    478486
  • trunk/Source/WebKit2/WebProcess/WebProcess.h

    r197901 r197981  
    239239    void setAlwaysUsesComplexTextCodePath(bool);
    240240    void setShouldUseFontSmoothing(bool);
     241    void enableSmoothedLayerText(bool);
     242
    241243    void setResourceLoadStatisticsEnabled(bool);
    242244    void userPreferredLanguagesChanged(const Vector<String>&) const;
  • trunk/Source/WebKit2/WebProcess/WebProcess.messages.in

    r197592 r197981  
    4343    SetAlwaysUsesComplexTextCodePath(bool alwaysUseComplexText)
    4444    SetShouldUseFontSmoothing(bool useFontSmoothing)
     45    EnableSmoothedLayerText(bool smoothedLayerText)
    4546    SetResourceLoadStatisticsEnabled(bool resourceLoadStatisticsEnabled);
    4647    UserPreferredLanguagesChanged(Vector<String> languages)
  • trunk/Tools/ChangeLog

    r197964 r197981  
     12016-03-10  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Font antialiasing (smoothing) changes when elements are rendered into compositing layers
     4        https://bugs.webkit.org/show_bug.cgi?id=23364
     5
     6        Reviewed by Tim Horton.
     7
     8        Turn off smoothed layer text because it affects many layout test results.
     9
     10        * DumpRenderTree/mac/DumpRenderTree.mm:
     11        (resetWebViewToConsistentStateBeforeTesting):
     12        * WebKitTestRunner/TestController.cpp:
     13        (WTR::TestController::resetStateToConsistentValues):
     14
    1152016-03-10  Jer Noble  <jer.noble@apple.com>
    216
  • trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm

    r197953 r197981  
    18481848#endif
    18491849    [webView setTracksRepaints:NO];
     1850    [WebView _setSmoothedLayerTextEnabled:NO];
    18501851
    18511852    [WebCache clearCachedCredentials];
  • trunk/Tools/WebKitTestRunner/TestController.cpp

    r197956 r197981  
    718718
    719719    WKContextSetShouldUseFontSmoothing(TestController::singleton().context(), false);
     720    WKContextEnableSmoothedLayerText(TestController::singleton().context(), false);
    720721
    721722    WKContextSetCacheModel(TestController::singleton().context(), kWKCacheModelDocumentBrowser);
Note: See TracChangeset for help on using the changeset viewer.