Changeset 213466 in webkit


Ignore:
Timestamp:
Mar 6, 2017, 1:45:38 PM (9 years ago)
Author:
Simon Fraser
Message:

Only use layer backing store which supports subpixel antialiased text if we know subpixel antialiased will be painted into it
https://bugs.webkit.org/show_bug.cgi?id=169191

Reviewed by Zalan Bujtas.

Source/WebCore:

Instead of unconditionally calling setSupportsSubpixelAntialiasedText() on GraphicsLayers created
by RenderLayerBacking, only do so when we know (or suspect) that a layer contains smoothed text.

This is done by enhancing RenderLayer::isVisuallyNonEmpty() and RenderLayer::hasNonEmptyChildRenderers()
to take a PaintedContentRequest parameter, which allows the caller to specify what qualities of
the layer contents it is interested in. Most of the time, this is just any painted content, but on
platforms where GraphicsLayer::supportsSubpixelAntialiasedLayerText() returns true, the query also
asks about whether the layer will contain subpixel-antialiased text. In this case, it can't early
return as soon as painted content is found; it must keep iterating renderers while all the query
requests are unsatisfied, or until it hits depth or sibling limits. If a limit is hit, we take the
same path of assuming there is subpixel-antialiased text (via the "Undetermined" state).

RenderLayerBacking also makes use of PaintedContentRequest during its non-composited child layer walk.

To offset the additional cost of this tree walking, RenderLayerBacking now caches information about its
painted content for the duration of a single update via PaintedContentsInfo, so we no longer call
isDirectlyCompositedImage() and isSimpleContainerCompositingLayer() multiple times per backing per update.
The traversal code here too now has to continue until all necessary states in the request have been computed.

Add some functions to RenderImage so that we know if it's showing the alt text or has a non-bitmap image
(which may contain text).

Subpixel-antialiased ("smoothed") text is disabled by DRT and WTR by default, so we need Internals API to enable it.

Platforms now express their support for subpixel-antialiased text via GraphicsLayer::supportsSubpixelAntialiasedLayerText()
which only returns true on Mac.

Tests: compositing/contents-format/subpixel-antialiased-text-configs-antialiasing-style.html

compositing/contents-format/subpixel-antialiased-text-configs.html
compositing/contents-format/subpixel-antialiased-text-images.html
compositing/contents-format/subpixel-antialiased-text-visibility.html

  • platform/graphics/GraphicsLayer.cpp:

(WebCore::GraphicsLayer::supportsSubpixelAntialiasedLayerText):

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

(WebCore::GraphicsLayer::supportsSubpixelAntialiasedLayerText):
(WebCore::GraphicsLayerCA::changeLayerTypeTo):

  • rendering/RenderImage.cpp:

(WebCore::RenderImage::isShowingMissingOrImageError):
(WebCore::RenderImage::isShowingAltText):
(WebCore::RenderImage::hasNonBitmapImage):

  • rendering/RenderImage.h:
  • rendering/RenderLayer.cpp:

(WebCore::RenderLayer::calculateClipRects):

  • rendering/RenderLayer.h:
  • rendering/RenderLayerBacking.cpp:

(WebCore::PaintedContentsInfo::PaintedContentsInfo):
(WebCore::PaintedContentsInfo::setWantsSubpixelAntialiasedTextState):
(WebCore::PaintedContentsInfo::paintsBoxDecorations):
(WebCore::PaintedContentsInfo::paintsContent):
(WebCore::PaintedContentsInfo::paintsSubpixelAntialiasedText):
(WebCore::PaintedContentsInfo::isSimpleContainer):
(WebCore::PaintedContentsInfo::isDirectlyCompositedImage):
(WebCore::PaintedContentsInfo::paintsBoxDecorationsDetermination):
(WebCore::PaintedContentsInfo::paintsContentDetermination):
(WebCore::PaintedContentsInfo::paintsSubpixelAntialiasedTextDetermination):
(WebCore::PaintedContentsInfo::contentsTypeDetermination):
(WebCore::RenderLayerBacking::createGraphicsLayer):
(WebCore::RenderLayerBacking::updateConfiguration):
(WebCore::RenderLayerBacking::computeParentGraphicsLayerRect):
(WebCore::RenderLayerBacking::updateAfterDescendants):
(WebCore::RenderLayerBacking::updateDirectlyCompositedBoxDecorations):
(WebCore::RenderLayerBacking::updateDrawsContent):
(WebCore::RenderLayerBacking::updateDirectlyCompositedBackgroundColor):
(WebCore::RenderLayerBacking::updateDirectlyCompositedBackgroundImage):
(WebCore::RenderLayerBacking::paintsContent):
(WebCore::RenderLayerBacking::isSimpleContainerCompositingLayer):
(WebCore::RenderLayerBacking::isPaintDestinationForDescendantLayers):
(WebCore::RenderLayerBacking::hasVisibleNonCompositedDescendants):
(WebCore::RenderLayerBacking::containsPaintedContent):
(WebCore::RenderLayerBacking::contentChanged):
(WebCore::RenderLayerBacking::updateImageContents):
(WebCore::RenderLayerBacking::paintsChildRenderers): Deleted.

  • rendering/RenderLayerBacking.h:
  • rendering/RenderLayerCompositor.cpp:

(WebCore::RenderLayerCompositor::logLayerInfo):

  • testing/Internals.cpp:

(WebCore::Internals::setFontSmoothingEnabled):

  • testing/Internals.h:
  • testing/Internals.idl:

LayoutTests:

Test lots of layer configs for subpixel antialiased text support. Only Mac results show the
"(supports subpixel antialiased text 1)" flag on layers now, since the patch makes this
dependent on platform support.

  • compositing/contents-format/subpixel-antialiased-text-configs-antialiasing-style-expected.txt: Added.
  • compositing/contents-format/subpixel-antialiased-text-configs-antialiasing-style.html: Added.
  • compositing/contents-format/subpixel-antialiased-text-configs-expected.txt: Added.
  • compositing/contents-format/subpixel-antialiased-text-configs.html: Added.
  • compositing/contents-format/subpixel-antialiased-text-enabled-expected.txt:
  • compositing/contents-format/subpixel-antialiased-text-enabled.html:
  • compositing/contents-format/subpixel-antialiased-text-images-expected.txt: Added.
  • compositing/contents-format/subpixel-antialiased-text-images.html: Added.
  • compositing/contents-format/subpixel-antialiased-text-visibility-expected.txt: Added.
  • compositing/contents-format/subpixel-antialiased-text-visibility.html: Added.
  • compositing/resources/circle-with-text.svg: Added.
  • compositing/resources/circle.svg: Added.
  • platform/mac-wk1/compositing/contents-format/subpixel-antialiased-text-enabled-expected.txt:
  • platform/mac/compositing/contents-format/subpixel-antialiased-text-configs-antialiasing-style-expected.txt: Added.
  • platform/mac/compositing/contents-format/subpixel-antialiased-text-configs-expected.txt: Added.
  • platform/mac/compositing/contents-format/subpixel-antialiased-text-enabled-expected.txt: Copied from LayoutTests/compositing/contents-format/subpixel-antialiased-text-enabled-expected.txt.
  • platform/mac/compositing/contents-format/subpixel-antialiased-text-images-expected.txt: Added.
  • platform/mac/compositing/contents-format/subpixel-antialiased-text-visibility-expected.txt: Added.
Location:
trunk
Files:
15 added
18 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r213464 r213466  
     12017-03-06  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Only use layer backing store which supports subpixel antialiased text if we know subpixel antialiased will be painted into it
     4        https://bugs.webkit.org/show_bug.cgi?id=169191
     5
     6        Reviewed by Zalan Bujtas.
     7
     8        Test lots of layer configs for subpixel antialiased text support. Only Mac results show the
     9        "(supports subpixel antialiased text 1)" flag on layers now, since the patch makes this
     10        dependent on platform support.
     11
     12        * compositing/contents-format/subpixel-antialiased-text-configs-antialiasing-style-expected.txt: Added.
     13        * compositing/contents-format/subpixel-antialiased-text-configs-antialiasing-style.html: Added.
     14        * compositing/contents-format/subpixel-antialiased-text-configs-expected.txt: Added.
     15        * compositing/contents-format/subpixel-antialiased-text-configs.html: Added.
     16        * compositing/contents-format/subpixel-antialiased-text-enabled-expected.txt:
     17        * compositing/contents-format/subpixel-antialiased-text-enabled.html:
     18        * compositing/contents-format/subpixel-antialiased-text-images-expected.txt: Added.
     19        * compositing/contents-format/subpixel-antialiased-text-images.html: Added.
     20        * compositing/contents-format/subpixel-antialiased-text-visibility-expected.txt: Added.
     21        * compositing/contents-format/subpixel-antialiased-text-visibility.html: Added.
     22        * compositing/resources/circle-with-text.svg: Added.
     23        * compositing/resources/circle.svg: Added.
     24        * platform/mac-wk1/compositing/contents-format/subpixel-antialiased-text-enabled-expected.txt:
     25        * platform/mac/compositing/contents-format/subpixel-antialiased-text-configs-antialiasing-style-expected.txt: Added.
     26        * platform/mac/compositing/contents-format/subpixel-antialiased-text-configs-expected.txt: Added.
     27        * platform/mac/compositing/contents-format/subpixel-antialiased-text-enabled-expected.txt: Copied from LayoutTests/compositing/contents-format/subpixel-antialiased-text-enabled-expected.txt.
     28        * platform/mac/compositing/contents-format/subpixel-antialiased-text-images-expected.txt: Added.
     29        * platform/mac/compositing/contents-format/subpixel-antialiased-text-visibility-expected.txt: Added.
     30
    1312017-03-06  Myles C. Maxfield  <mmaxfield@apple.com>
    232
  • trunk/LayoutTests/compositing/contents-format/subpixel-antialiased-text-enabled-expected.txt

    r212776 r213466  
    11Normal layer
    22Tiled layer
     3Become-tiled layer
    34(GraphicsLayer
    45  (anchor 0.00 0.00)
     
    89      (bounds 5018.00 2018.00)
    910      (contentsOpaque 1)
    10       (supports subpixel antialiased text 1)
    1111      (tile cache coverage 0, 0 1024 x 1024)
    1212      (tile size 512 x 512)
    1313      (top left tile 0, 0 tiles grid 2 x 2)
    1414      (in window 1)
    15       (children 2
     15      (children 3
    1616        (GraphicsLayer
    1717          (position 18.00 10.00)
    1818          (bounds 100.00 100.00)
    19           (contentsOpaque 1)
    20           (supports subpixel antialiased text 1)
    2119          (drawsContent 1)
    2220        )
     
    2523          (bounds 5000.00 100.00)
    2624          (usingTiledLayer 1)
    27           (contentsOpaque 1)
    28           (supports subpixel antialiased text 1)
     25          (drawsContent 1)
     26          (tile cache coverage 0, 0 1024 x 100)
     27          (tile size 512 x 512)
     28          (top left tile 0, 0 tiles grid 2 x 1)
     29          (in window 1)
     30        )
     31        (GraphicsLayer
     32          (position 18.00 230.00)
     33          (bounds 5000.00 100.00)
     34          (usingTiledLayer 1)
    2935          (drawsContent 1)
    3036          (tile cache coverage 0, 0 1024 x 100)
  • trunk/LayoutTests/compositing/contents-format/subpixel-antialiased-text-enabled.html

    r212776 r213466  
    66        body {
    77            height: 2000px;
     8            -webkit-font-smoothing: subpixel-antialiased;
    89        }
    910       
     
    1112            height: 100px;
    1213            width: 100px;
    13             background-color: blue;
     14            background-color: rgba(0, 0, 128, 0.6);
    1415            margin: 10px;
    1516        }
     
    1718        .composited {
    1819            transform: translateZ(0);
     20        }
     21
     22        p {
     23            line-height: 20px;
    1924        }
    2025       
     
    3136        function doAfterReload()
    3237        {
    33             if (window.internals)
    34                 document.getElementById('layers').innerText = internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_TILE_CACHES);
     38            setTimeout(function() {
     39                document.getElementById('become-tiled').classList.add('tiled');
     40                setTimeout(function() {
     41                    if (window.internals)
     42                        document.getElementById('layers').innerText = internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_TILE_CACHES);
    3543
    36             delete window.localStorage.stage;
     44                    delete window.localStorage.stage;
    3745
    38             if (window.testRunner)
    39                 testRunner.notifyDone();
     46                    if (window.testRunner)
     47                        testRunner.notifyDone();
     48                }, 0);
     49            }, 0);
    4050        }
    4151
     
    4353        {
    4454            window.localStorage.stage = 1;
    45             if (window.internals)
     55            if (window.internals) {
     56                internals.setFontSmoothingEnabled(true);
    4657                internals.settings.setSubpixelAntialiasedLayerTextEnabled(true)
     58            }
    4759
    4860            // Reload so that the setting affects page tiles.
     
    7082</div>
    7183
     84<div id="become-tiled" class="composited box">
     85    Become-tiled layer
     86</div>
     87
    7288<pre id="layers"></pre>
    7389</body>
  • trunk/LayoutTests/platform/mac-wk1/compositing/contents-format/subpixel-antialiased-text-enabled-expected.txt

    r212776 r213466  
    11Normal layer
    22Tiled layer
     3Become-tiled layer
    34(GraphicsLayer
    45  (anchor 0.00 0.00)
     
    89      (bounds 5018.00 2018.00)
    910      (contentsOpaque 1)
    10       (supports subpixel antialiased text 1)
    11       (children 2
     11      (children 3
    1212        (GraphicsLayer
    1313          (position 18.00 10.00)
    1414          (bounds 100.00 100.00)
    15           (contentsOpaque 1)
    1615          (supports subpixel antialiased text 1)
    1716          (drawsContent 1)
     
    2120          (bounds 5000.00 100.00)
    2221          (usingTiledLayer 1)
    23           (contentsOpaque 1)
     22          (supports subpixel antialiased text 1)
     23          (drawsContent 1)
     24          (tile cache coverage 0, 0 1024 x 100)
     25          (tile size 512 x 512)
     26          (top left tile 0, 0 tiles grid 2 x 1)
     27          (in window 1)
     28        )
     29        (GraphicsLayer
     30          (position 18.00 230.00)
     31          (bounds 5000.00 100.00)
     32          (usingTiledLayer 1)
    2433          (supports subpixel antialiased text 1)
    2534          (drawsContent 1)
  • trunk/LayoutTests/platform/mac/compositing/contents-format/subpixel-antialiased-text-enabled-expected.txt

    r213465 r213466  
    11Normal layer
    22Tiled layer
     3Become-tiled layer
    34(GraphicsLayer
    45  (anchor 0.00 0.00)
     
    89      (bounds 5018.00 2018.00)
    910      (contentsOpaque 1)
    10       (supports subpixel antialiased text 1)
    1111      (tile cache coverage 0, 0 1024 x 1024)
    1212      (tile size 512 x 512)
    1313      (top left tile 0, 0 tiles grid 2 x 2)
    1414      (in window 1)
    15       (children 2
     15      (children 3
    1616        (GraphicsLayer
    1717          (position 18.00 10.00)
    1818          (bounds 100.00 100.00)
    19           (contentsOpaque 1)
    2019          (supports subpixel antialiased text 1)
    2120          (drawsContent 1)
     
    2524          (bounds 5000.00 100.00)
    2625          (usingTiledLayer 1)
    27           (contentsOpaque 1)
     26          (supports subpixel antialiased text 1)
     27          (drawsContent 1)
     28          (tile cache coverage 0, 0 1024 x 100)
     29          (tile size 512 x 512)
     30          (top left tile 0, 0 tiles grid 2 x 1)
     31          (in window 1)
     32        )
     33        (GraphicsLayer
     34          (position 18.00 230.00)
     35          (bounds 5000.00 100.00)
     36          (usingTiledLayer 1)
    2837          (supports subpixel antialiased text 1)
    2938          (drawsContent 1)
  • trunk/Source/WebCore/ChangeLog

    r213464 r213466  
     12017-03-06  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Only use layer backing store which supports subpixel antialiased text if we know subpixel antialiased will be painted into it
     4        https://bugs.webkit.org/show_bug.cgi?id=169191
     5
     6        Reviewed by Zalan Bujtas.
     7
     8        Instead of unconditionally calling setSupportsSubpixelAntialiasedText() on GraphicsLayers created
     9        by RenderLayerBacking, only do so when we know (or suspect) that a layer contains smoothed text.
     10       
     11        This is done by enhancing RenderLayer::isVisuallyNonEmpty() and RenderLayer::hasNonEmptyChildRenderers()
     12        to take a PaintedContentRequest parameter, which allows the caller to specify what qualities of
     13        the layer contents it is interested in. Most of the time, this is just any painted content, but on
     14        platforms where GraphicsLayer::supportsSubpixelAntialiasedLayerText() returns true, the query also
     15        asks about whether the layer will contain subpixel-antialiased text. In this case, it can't early
     16        return as soon as painted content is found; it must keep iterating renderers while all the query
     17        requests are unsatisfied, or until it hits depth or sibling limits. If a limit is hit, we take the
     18        same path of assuming there is subpixel-antialiased text (via the "Undetermined" state).
     19
     20        RenderLayerBacking also makes use of PaintedContentRequest during its non-composited child layer walk.
     21
     22        To offset the additional cost of this tree walking, RenderLayerBacking now caches information about its
     23        painted content for the duration of a single update via PaintedContentsInfo, so we no longer call
     24        isDirectlyCompositedImage() and isSimpleContainerCompositingLayer() multiple times per backing per update.
     25        The traversal code here too now has to continue until all necessary states in the request have been computed.
     26       
     27        Add some functions to RenderImage so that we know if it's showing the alt text or has a non-bitmap image
     28        (which may contain text).
     29       
     30        Subpixel-antialiased ("smoothed") text is disabled by DRT and WTR by default, so we need Internals API to enable it.
     31       
     32        Platforms now express their support for subpixel-antialiased text via GraphicsLayer::supportsSubpixelAntialiasedLayerText()
     33        which only returns true on Mac.
     34
     35        Tests: compositing/contents-format/subpixel-antialiased-text-configs-antialiasing-style.html
     36               compositing/contents-format/subpixel-antialiased-text-configs.html
     37               compositing/contents-format/subpixel-antialiased-text-images.html
     38               compositing/contents-format/subpixel-antialiased-text-visibility.html
     39
     40        * platform/graphics/GraphicsLayer.cpp:
     41        (WebCore::GraphicsLayer::supportsSubpixelAntialiasedLayerText):
     42        * platform/graphics/GraphicsLayer.h:
     43        * platform/graphics/ca/GraphicsLayerCA.cpp:
     44        (WebCore::GraphicsLayer::supportsSubpixelAntialiasedLayerText):
     45        (WebCore::GraphicsLayerCA::changeLayerTypeTo):
     46        * rendering/RenderImage.cpp:
     47        (WebCore::RenderImage::isShowingMissingOrImageError):
     48        (WebCore::RenderImage::isShowingAltText):
     49        (WebCore::RenderImage::hasNonBitmapImage):
     50        * rendering/RenderImage.h:
     51        * rendering/RenderLayer.cpp:
     52        (WebCore::RenderLayer::calculateClipRects):
     53        * rendering/RenderLayer.h:
     54        * rendering/RenderLayerBacking.cpp:
     55        (WebCore::PaintedContentsInfo::PaintedContentsInfo):
     56        (WebCore::PaintedContentsInfo::setWantsSubpixelAntialiasedTextState):
     57        (WebCore::PaintedContentsInfo::paintsBoxDecorations):
     58        (WebCore::PaintedContentsInfo::paintsContent):
     59        (WebCore::PaintedContentsInfo::paintsSubpixelAntialiasedText):
     60        (WebCore::PaintedContentsInfo::isSimpleContainer):
     61        (WebCore::PaintedContentsInfo::isDirectlyCompositedImage):
     62        (WebCore::PaintedContentsInfo::paintsBoxDecorationsDetermination):
     63        (WebCore::PaintedContentsInfo::paintsContentDetermination):
     64        (WebCore::PaintedContentsInfo::paintsSubpixelAntialiasedTextDetermination):
     65        (WebCore::PaintedContentsInfo::contentsTypeDetermination):
     66        (WebCore::RenderLayerBacking::createGraphicsLayer):
     67        (WebCore::RenderLayerBacking::updateConfiguration):
     68        (WebCore::RenderLayerBacking::computeParentGraphicsLayerRect):
     69        (WebCore::RenderLayerBacking::updateAfterDescendants):
     70        (WebCore::RenderLayerBacking::updateDirectlyCompositedBoxDecorations):
     71        (WebCore::RenderLayerBacking::updateDrawsContent):
     72        (WebCore::RenderLayerBacking::updateDirectlyCompositedBackgroundColor):
     73        (WebCore::RenderLayerBacking::updateDirectlyCompositedBackgroundImage):
     74        (WebCore::RenderLayerBacking::paintsContent):
     75        (WebCore::RenderLayerBacking::isSimpleContainerCompositingLayer):
     76        (WebCore::RenderLayerBacking::isPaintDestinationForDescendantLayers):
     77        (WebCore::RenderLayerBacking::hasVisibleNonCompositedDescendants):
     78        (WebCore::RenderLayerBacking::containsPaintedContent):
     79        (WebCore::RenderLayerBacking::contentChanged):
     80        (WebCore::RenderLayerBacking::updateImageContents):
     81        (WebCore::RenderLayerBacking::paintsChildRenderers): Deleted.
     82        * rendering/RenderLayerBacking.h:
     83        * rendering/RenderLayerCompositor.cpp:
     84        (WebCore::RenderLayerCompositor::logLayerInfo):
     85        * testing/Internals.cpp:
     86        (WebCore::Internals::setFontSmoothingEnabled):
     87        * testing/Internals.h:
     88        * testing/Internals.idl:
     89
    1902017-03-06  Myles C. Maxfield  <mmaxfield@apple.com>
    291
  • trunk/Source/WebCore/platform/graphics/GraphicsLayer.cpp

    r212776 r213466  
    9595    return false;
    9696#endif
     97}
     98
     99bool GraphicsLayer::supportsSubpixelAntialiasedLayerText()
     100{
     101    return false;
    97102}
    98103#endif
  • trunk/Source/WebCore/platform/graphics/GraphicsLayer.h

    r212776 r213466  
    555555    static bool supportsLayerType(Type);
    556556    static bool supportsContentsTiling();
     557    static bool supportsSubpixelAntialiasedLayerText();
    557558
    558559    void updateDebugIndicators();
  • trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp

    r212941 r213466  
    318318}
    319319
     320bool GraphicsLayer::supportsSubpixelAntialiasedLayerText()
     321{
     322#if PLATFORM(MAC)
     323    return true;
     324#else
     325    return false;
     326#endif
     327}
     328
    320329std::unique_ptr<GraphicsLayer> GraphicsLayer::create(GraphicsLayerFactory* factory, GraphicsLayerClient& client, Type layerType)
    321330{
     
    36173626        | ContentsScaleChanged
    36183627        | AcceleratesDrawingChanged
     3628        | SupportsSubpixelAntialiasedTextChanged
    36193629        | FiltersChanged
    36203630        | BackdropFiltersChanged
  • trunk/Source/WebCore/rendering/RenderImage.cpp

    r213404 r213466  
    350350}
    351351
     352bool RenderImage::isShowingMissingOrImageError() const
     353{
     354    return !imageResource().hasImage() || imageResource().errorOccurred();
     355}
     356
     357bool RenderImage::isShowingAltText() const
     358{
     359    return isShowingMissingOrImageError() && !m_altText.isEmpty();
     360}
     361
     362bool RenderImage::hasNonBitmapImage() const
     363{
     364    if (!imageResource().hasImage())
     365        return false;
     366
     367    Image* image = cachedImage()->imageForRenderer(this);
     368    return image && !is<BitmapImage>(image);
     369}
     370
    352371void RenderImage::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
    353372{
  • trunk/Source/WebCore/rendering/RenderImage.h

    r206903 r213466  
    7070
    7171    void setHasShadowControls(bool hasShadowControls) { m_hasShadowControls = hasShadowControls; }
     72   
     73    bool isShowingMissingOrImageError() const;
     74    bool isShowingAltText() const;
     75
     76    bool hasNonBitmapImage() const;
    7277
    7378protected:
  • trunk/Source/WebCore/rendering/RenderLayer.cpp

    r213440 r213466  
    9090#include "RenderFlowThread.h"
    9191#include "RenderGeometryMap.h"
     92#include "RenderImage.h"
    9293#include "RenderInline.h"
    9394#include "RenderIterator.h"
     
    65806581}
    65816582
     6583static bool styleHasSmoothingTextMode(const RenderStyle& style)
     6584{
     6585    FontSmoothingMode smoothingMode = style.fontDescription().fontSmoothing();
     6586    return smoothingMode == AutoSmoothing || smoothingMode == SubpixelAntialiased;
     6587}
     6588
    65826589// Constrain the depth and breadth of the search for performance.
    65836590static const int maxDescendentDepth = 3;
    65846591static const int maxSiblingCount = 20;
    65856592
    6586 static bool hasPaintingNonLayerDescendants(const RenderElement& renderer, int depth)
    6587 {
    6588     if (depth > maxDescendentDepth)
    6589         return true;
     6593static void determineNonLayerDescendantsPaintedContent(const RenderElement& renderer, int depth, RenderLayer::PaintedContentRequest& request)
     6594{
     6595    if (depth > maxDescendentDepth) {
     6596        request.makeStatesUndetermined();
     6597        return;
     6598    }
    65906599   
    65916600    int siblingCount = 0;
    65926601    for (const auto& child : childrenOfType<RenderObject>(renderer)) {
    6593         if (++siblingCount > maxSiblingCount)
    6594             return true;
     6602        if (++siblingCount > maxSiblingCount) {
     6603            request.makeStatesUndetermined();
     6604            return;
     6605        }
    65956606
    65966607        if (is<RenderText>(child)) {
     
    66006611
    66016612            if (renderer.style().userSelect() != SELECT_NONE)
    6602                 return true;
    6603 
    6604             if (!renderText.text()->containsOnlyWhitespace())
    6605                 return true;
     6613                request.setHasPaintedContent();
     6614
     6615            if (!renderText.text()->containsOnlyWhitespace()) {
     6616                request.setHasPaintedContent();
     6617
     6618                if (request.needToDetermineSubpixelAntialiasedTextState() && styleHasSmoothingTextMode(child.style()))
     6619                    request.setHasSubpixelAntialiasedText();
     6620            }
     6621
     6622            if (request.isSatisfied())
     6623                return;
    66066624        }
    66076625       
     
    66146632            continue;
    66156633
    6616         if (hasVisibleBoxDecorationsOrBackground(renderElementChild))
    6617             return true;
     6634        if (hasVisibleBoxDecorationsOrBackground(renderElementChild)) {
     6635            request.setHasPaintedContent();
     6636            if (request.isSatisfied())
     6637                return;
     6638        }
    66186639       
    6619         if (is<RenderReplaced>(renderElementChild))
    6620             return true;
    6621 
    6622         if (hasPaintingNonLayerDescendants(renderElementChild, depth + 1))
    6623             return true;
    6624     }
    6625 
    6626     return false;
    6627 }
    6628 
    6629 bool RenderLayer::hasNonEmptyChildRenderers() const
    6630 {
    6631     return hasPaintingNonLayerDescendants(renderer(), 0);
     6640        if (is<RenderReplaced>(renderElementChild)) {
     6641            request.setHasPaintedContent();
     6642
     6643            if (is<RenderImage>(renderElementChild) && request.needToDetermineSubpixelAntialiasedTextState()) {
     6644                auto& imageRenderer = downcast<RenderImage>(renderElementChild);
     6645                // May draw text if showing alt text, or image is an SVG image or PDF image.
     6646                if ((imageRenderer.isShowingAltText() || imageRenderer.hasNonBitmapImage()) && styleHasSmoothingTextMode(child.style()))
     6647                    request.setHasSubpixelAntialiasedText();
     6648            }
     6649
     6650            if (request.isSatisfied())
     6651                return;
     6652        }
     6653
     6654        determineNonLayerDescendantsPaintedContent(renderElementChild, depth + 1, request);
     6655        if (request.isSatisfied())
     6656            return;
     6657    }
     6658}
     6659
     6660bool RenderLayer::hasNonEmptyChildRenderers(PaintedContentRequest& request) const
     6661{
     6662    determineNonLayerDescendantsPaintedContent(renderer(), 0, request);
     6663    return request.probablyHasPaintedContent();
    66326664}
    66336665
     
    66456677}
    66466678
    6647 bool RenderLayer::isVisuallyNonEmpty() const
     6679bool RenderLayer::isVisuallyNonEmpty(PaintedContentRequest* request) const
    66486680{
    66496681    ASSERT(!m_visibleDescendantStatusDirty);
     
    66526684        return false;
    66536685
    6654     if (renderer().isRenderReplaced() || hasOverflowControls())
     6686    if (renderer().isRenderReplaced() || hasOverflowControls()) {
     6687        if (request)
     6688            request->setHasPaintedContent();
    66556689        return true;
    6656 
    6657     if (hasVisibleBoxDecorationsOrBackground())
     6690    }
     6691
     6692    if (hasVisibleBoxDecorationsOrBackground()) {
     6693        if (request)
     6694            request->setHasPaintedContent();
    66586695        return true;
    6659    
    6660     if (hasNonEmptyChildRenderers())
    6661         return true;
    6662 
    6663     return false;
     6696    }
     6697   
     6698    PaintedContentRequest localRequest;
     6699    if (!request)
     6700        request = &localRequest;
     6701    return hasNonEmptyChildRenderers(*request);
    66646702}
    66656703
  • trunk/Source/WebCore/rendering/RenderLayer.h

    r210469 r213466  
    110110typedef unsigned LayerScrollCoordinationRoles;
    111111
     112enum class RequestState {
     113    Unknown,
     114    DontCare,
     115    False,
     116    True,
     117    Undetermined
     118};
     119
    112120class RenderLayer final : public ScrollableArea {
    113121    WTF_MAKE_FAST_ALLOCATED;
     
    389397    bool hasVisibleBoxDecorationsOrBackground() const;
    390398    bool hasVisibleBoxDecorations() const;
     399
     400    struct PaintedContentRequest {
     401        void makeStatesUndetermined()
     402        {
     403            if (hasPaintedContent == RequestState::Unknown)
     404                hasPaintedContent = RequestState::Undetermined;
     405
     406            if (hasSubpixelAntialiasedText == RequestState::Unknown)
     407                hasSubpixelAntialiasedText = RequestState::Undetermined;
     408        }
     409
     410        void setHasPaintedContent() { hasPaintedContent = RequestState::True; }
     411        void setHasSubpixelAntialiasedText() { hasSubpixelAntialiasedText = RequestState::True; }
     412
     413        bool needToDeterminePaintedContentState() const { return hasPaintedContent == RequestState::Unknown; }
     414        bool needToDetermineSubpixelAntialiasedTextState() const { return hasSubpixelAntialiasedText == RequestState::Unknown; }
     415
     416        bool probablyHasPaintedContent() const { return hasPaintedContent == RequestState::True || hasPaintedContent == RequestState::Undetermined; }
     417        bool probablyHasSubpixelAntialiasedText() const { return hasSubpixelAntialiasedText == RequestState::True || hasSubpixelAntialiasedText == RequestState::Undetermined; }
     418       
     419        bool isSatisfied() const { return hasPaintedContent != RequestState::Unknown && hasSubpixelAntialiasedText != RequestState::Unknown; }
     420
     421        RequestState hasPaintedContent { RequestState::Unknown };
     422        RequestState hasSubpixelAntialiasedText { RequestState::DontCare };
     423    };
     424
    391425    // Returns true if this layer has visible content (ignoring any child layers).
    392     bool isVisuallyNonEmpty() const;
     426    bool isVisuallyNonEmpty(PaintedContentRequest* = nullptr) const;
    393427    // True if this layer container renderers that paint.
    394     bool hasNonEmptyChildRenderers() const;
     428    bool hasNonEmptyChildRenderers(PaintedContentRequest&) const;
    395429
    396430    // FIXME: We should ASSERT(!m_hasSelfPaintingLayerDescendantDirty); here but we hit the same bugs as visible content above.
  • trunk/Source/WebCore/rendering/RenderLayerBacking.cpp

    r213435 r213466  
    9292}
    9393
     94// This acts as a cache of what we know about what is painting into this RenderLayerBacking.
     95class PaintedContentsInfo {
     96public:
     97    enum class ContentsTypeDetermination {
     98        Unknown,
     99        SimpleContainer,
     100        DirectlyCompositedImage,
     101        Painted
     102    };
     103
     104    PaintedContentsInfo(RenderLayerBacking& inBacking)
     105        : m_backing(inBacking)
     106    {
     107    }
     108   
     109    void setWantsSubpixelAntialiasedTextState(bool wantsSubpixelAntialiasedTextState)
     110    {
     111        m_subpixelAntialiasedText = wantsSubpixelAntialiasedTextState ? RequestState::Unknown : RequestState::DontCare;
     112    }
     113
     114    RequestState paintsBoxDecorationsDetermination();
     115    bool paintsBoxDecorations()
     116    {
     117        RequestState state = paintsBoxDecorationsDetermination();
     118        return state == RequestState::True || state == RequestState::Undetermined;
     119    }
     120
     121    RequestState paintsContentDetermination();
     122    bool paintsContent()
     123    {
     124        RequestState state = paintsContentDetermination();
     125        return state == RequestState::True || state == RequestState::Undetermined;
     126    }
     127
     128    RequestState paintsSubpixelAntialiasedTextDetermination();
     129    bool paintsSubpixelAntialiasedText()
     130    {
     131        RequestState state = paintsSubpixelAntialiasedTextDetermination();
     132        return state == RequestState::True || state == RequestState::Undetermined;
     133    }
     134
     135    ContentsTypeDetermination contentsTypeDetermination();
     136    bool isSimpleContainer()
     137    {
     138        return contentsTypeDetermination() == ContentsTypeDetermination::SimpleContainer;
     139    }
     140
     141    bool isDirectlyCompositedImage()
     142    {
     143        return contentsTypeDetermination() == ContentsTypeDetermination::DirectlyCompositedImage;
     144    }
     145
     146    RenderLayerBacking& m_backing;
     147    RequestState m_boxDecorations { RequestState::Unknown };
     148    RequestState m_content { RequestState::Unknown };
     149    RequestState m_subpixelAntialiasedText { RequestState::DontCare };
     150
     151    ContentsTypeDetermination m_contentsType { ContentsTypeDetermination::Unknown };
     152};
     153
     154RequestState PaintedContentsInfo::paintsBoxDecorationsDetermination()
     155{
     156    if (m_boxDecorations != RequestState::Unknown)
     157        return m_boxDecorations;
     158
     159    m_boxDecorations = m_backing.paintsBoxDecorations() ? RequestState::True : RequestState::False;
     160    return m_boxDecorations;
     161}
     162
     163RequestState PaintedContentsInfo::paintsContentDetermination()
     164{
     165    if (m_content != RequestState::Unknown && m_subpixelAntialiasedText != RequestState::Unknown)
     166        return m_content;
     167
     168    RenderLayer::PaintedContentRequest contentRequest;
     169    if (m_subpixelAntialiasedText == RequestState::Unknown)
     170        contentRequest.hasSubpixelAntialiasedText = RequestState::Unknown;
     171
     172    m_content = m_backing.paintsContent(contentRequest) ? RequestState::True : RequestState::False;
     173
     174    if (m_subpixelAntialiasedText == RequestState::Unknown)
     175        m_subpixelAntialiasedText = contentRequest.hasSubpixelAntialiasedText;
     176
     177    return m_content;
     178}
     179
     180RequestState PaintedContentsInfo::paintsSubpixelAntialiasedTextDetermination()
     181{
     182    if (m_subpixelAntialiasedText != RequestState::Unknown)
     183        return m_subpixelAntialiasedText;
     184
     185    paintsContentDetermination();
     186
     187    return m_subpixelAntialiasedText;
     188}
     189
     190PaintedContentsInfo::ContentsTypeDetermination PaintedContentsInfo::contentsTypeDetermination()
     191{
     192    if (m_contentsType != ContentsTypeDetermination::Unknown)
     193        return m_contentsType;
     194
     195    if (m_backing.isSimpleContainerCompositingLayer(*this))
     196        m_contentsType = ContentsTypeDetermination::SimpleContainer;
     197    else if (m_backing.isDirectlyCompositedImage())
     198        m_contentsType = ContentsTypeDetermination::DirectlyCompositedImage;
     199    else
     200        m_contentsType = ContentsTypeDetermination::Painted;
     201
     202    return m_contentsType;
     203}
     204
     205
    94206RenderLayerBacking::RenderLayerBacking(RenderLayer& layer)
    95207    : m_owningLayer(layer)
     
    143255    graphicsLayer->setAcceleratesDrawing(compositor().acceleratedDrawingEnabled());
    144256    graphicsLayer->setUsesDisplayListDrawing(compositor().displayListDrawingEnabled());
    145     graphicsLayer->setSupportsSubpixelAntialiasedText(renderer().settings().subpixelAntialiasedLayerTextEnabled());
    146257#endif
    147258   
     
    610721        m_graphicsLayer->setReplicatedByLayer(nullptr);
    611722
     723    PaintedContentsInfo contentsInfo(*this);
     724
    612725    if (!m_owningLayer.isRootLayer()) {
    613         bool isSimpleContainer = isSimpleContainerCompositingLayer();
    614726        bool didUpdateContentsRect = false;
    615         updateDirectlyCompositedBoxDecorations(isSimpleContainer, didUpdateContentsRect);
     727        updateDirectlyCompositedBoxDecorations(contentsInfo, didUpdateContentsRect);
    616728    } else
    617729        updateRootLayerConfiguration();
    618730   
    619     if (isDirectlyCompositedImage())
    620         updateImageContents();
     731    if (contentsInfo.isDirectlyCompositedImage())
     732        updateImageContents(contentsInfo);
    621733
    622734    if (is<RenderEmbeddedObject>(renderer()) && downcast<RenderEmbeddedObject>(renderer()).allowsAcceleratedCompositing()) {
     
    785897    LayoutRect parentGraphicsLayerRect;
    786898    if (m_owningLayer.isInsideFlowThread()) {
    787         /// FIXME: flows/columns need work.
     899        // FIXME: flows/columns need work.
    788900        LayoutRect ancestorCompositedBounds = ancestorBackingLayer->compositedBounds();
    789901        ancestorCompositedBounds.setLocation(LayoutPoint());
     
    10931205void RenderLayerBacking::updateAfterDescendants()
    10941206{
    1095     bool isSimpleContainer = false;
     1207    // FIXME: this potentially duplicates work we did in updateConfiguration().
     1208    PaintedContentsInfo contentsInfo(*this);
     1209    contentsInfo.setWantsSubpixelAntialiasedTextState(GraphicsLayer::supportsSubpixelAntialiasedLayerText());
     1210
    10961211    if (!m_owningLayer.isRootLayer()) {
    10971212        bool didUpdateContentsRect = false;
    1098         // FIXME: this duplicates work we did in updateConfiguration().
    1099         isSimpleContainer = isSimpleContainerCompositingLayer();
    1100         updateDirectlyCompositedBoxDecorations(isSimpleContainer, didUpdateContentsRect);
     1213        updateDirectlyCompositedBoxDecorations(contentsInfo, didUpdateContentsRect);
    11011214        if (!didUpdateContentsRect && m_graphicsLayer->usesContentsLayer())
    11021215            resetContentsRect();
    11031216    }
    11041217
    1105     updateDrawsContent(isSimpleContainer);
     1218    updateDrawsContent(contentsInfo);
    11061219
    11071220    m_graphicsLayer->setContentsVisible(m_owningLayer.hasVisibleContent() || hasVisibleNonCompositedDescendants());
     
    11821295}
    11831296
    1184 void RenderLayerBacking::updateDirectlyCompositedBoxDecorations(bool isSimpleContainer, bool& didUpdateContentsRect)
     1297void RenderLayerBacking::updateDirectlyCompositedBoxDecorations(PaintedContentsInfo& contentsInfo, bool& didUpdateContentsRect)
    11851298{
    11861299    if (!m_owningLayer.hasVisibleContent())
     
    11891302    // The order of operations here matters, since the last valid type of contents needs
    11901303    // to also update the contentsRect.
    1191     updateDirectlyCompositedBackgroundColor(isSimpleContainer, didUpdateContentsRect);
    1192     updateDirectlyCompositedBackgroundImage(isSimpleContainer, didUpdateContentsRect);
     1304    updateDirectlyCompositedBackgroundColor(contentsInfo, didUpdateContentsRect);
     1305    updateDirectlyCompositedBackgroundImage(contentsInfo, didUpdateContentsRect);
    11931306}
    11941307
     
    12591372void RenderLayerBacking::updateDrawsContent()
    12601373{
    1261     updateDrawsContent(isSimpleContainerCompositingLayer());
    1262 }
    1263 
    1264 void RenderLayerBacking::updateDrawsContent(bool isSimpleContainer)
     1374    PaintedContentsInfo contentsInfo(*this);
     1375    contentsInfo.setWantsSubpixelAntialiasedTextState(GraphicsLayer::supportsSubpixelAntialiasedLayerText());
     1376
     1377    updateDrawsContent(contentsInfo);
     1378}
     1379
     1380void RenderLayerBacking::updateDrawsContent(PaintedContentsInfo& contentsInfo)
    12651381{
    12661382    if (m_scrollingLayer) {
     
    12721388        m_graphicsLayer->setDrawsContent(hasNonScrollingPaintedContent);
    12731389
    1274         bool hasScrollingPaintedContent = m_owningLayer.hasVisibleContent() && (renderer().hasBackground() || paintsChildRenderers());
     1390        bool hasScrollingPaintedContent = m_owningLayer.hasVisibleContent() && (renderer().hasBackground() || contentsInfo.paintsContent());
    12751391        m_scrollingContentsLayer->setDrawsContent(hasScrollingPaintedContent);
    12761392        return;
    12771393    }
    12781394
    1279     bool hasPaintedContent = containsPaintedContent(isSimpleContainer);
     1395    bool hasPaintedContent = containsPaintedContent(contentsInfo);
     1396
     1397    m_paintsSubpixelAntialiasedText = renderer().settings().subpixelAntialiasedLayerTextEnabled() && contentsInfo.paintsSubpixelAntialiasedText();
    12801398
    12811399    // FIXME: we could refine this to only allocate backing for one of these layers if possible.
    12821400    m_graphicsLayer->setDrawsContent(hasPaintedContent);
    1283     if (m_foregroundLayer)
     1401    if (m_foregroundLayer) {
    12841402        m_foregroundLayer->setDrawsContent(hasPaintedContent);
     1403        m_foregroundLayer->setSupportsSubpixelAntialiasedText(m_paintsSubpixelAntialiasedText);
     1404        // The text content is painted into the foreground layer.
     1405        // FIXME: this ignores SVG background images which may contain text.
     1406        m_graphicsLayer->setSupportsSubpixelAntialiasedText(false);
     1407    } else
     1408        m_graphicsLayer->setSupportsSubpixelAntialiasedText(m_paintsSubpixelAntialiasedText);
    12851409
    12861410    if (m_backgroundLayer)
     
    17711895}
    17721896
    1773 void RenderLayerBacking::updateDirectlyCompositedBackgroundColor(bool isSimpleContainer, bool& didUpdateContentsRect)
    1774 {
    1775     if (!isSimpleContainer || (is<RenderBox>(renderer()) && !downcast<RenderBox>(renderer()).paintsOwnBackground())) {
     1897void RenderLayerBacking::updateDirectlyCompositedBackgroundColor(PaintedContentsInfo& contentsInfo, bool& didUpdateContentsRect)
     1898{
     1899    if (!contentsInfo.isSimpleContainer() || (is<RenderBox>(renderer()) && !downcast<RenderBox>(renderer()).paintsOwnBackground())) {
    17761900        m_graphicsLayer->setContentsToSolidColor(Color());
    17771901        return;
     
    17881912}
    17891913
    1790 void RenderLayerBacking::updateDirectlyCompositedBackgroundImage(bool isSimpleContainer, bool& didUpdateContentsRect)
     1914void RenderLayerBacking::updateDirectlyCompositedBackgroundImage(PaintedContentsInfo& contentsInfo, bool& didUpdateContentsRect)
    17911915{
    17921916    if (!GraphicsLayer::supportsContentsTiling())
    17931917        return;
    17941918
    1795     if (isDirectlyCompositedImage())
     1919    if (contentsInfo.isDirectlyCompositedImage())
    17961920        return;
    17971921
    17981922    auto& style = renderer().style();
    1799     if (!isSimpleContainer || !style.hasBackgroundImage()) {
     1923    if (!contentsInfo.isSimpleContainer() || !style.hasBackgroundImage()) {
    18001924        m_graphicsLayer->setContentsToImage(0);
    18011925        return;
     
    18721996}
    18731997
    1874 bool RenderLayerBacking::paintsChildRenderers() const
    1875 {
    1876     if (m_owningLayer.hasVisibleContent() && m_owningLayer.hasNonEmptyChildRenderers())
    1877         return true;
    1878 
    1879     if (isPaintDestinationForDescendantLayers())
    1880         return true;
    1881 
    1882     return false;
     1998bool RenderLayerBacking::paintsContent(RenderLayer::PaintedContentRequest& request) const
     1999{
     2000    bool paintsContent = false;
     2001
     2002    if (m_owningLayer.hasVisibleContent() && m_owningLayer.hasNonEmptyChildRenderers(request))
     2003        paintsContent = true;
     2004
     2005    if (request.isSatisfied())
     2006        return paintsContent;
     2007
     2008    if (isPaintDestinationForDescendantLayers(request))
     2009        paintsContent = true;
     2010
     2011    if (request.isSatisfied())
     2012        return paintsContent;
     2013
     2014    if (request.hasPaintedContent == RequestState::Unknown)
     2015        request.hasPaintedContent = RequestState::False;
     2016
     2017    if (request.hasSubpixelAntialiasedText == RequestState::Unknown)
     2018        request.hasSubpixelAntialiasedText = RequestState::False;
     2019
     2020    return paintsContent;
    18832021}
    18842022
     
    19032041// It may have no children, or all its children may be themselves composited.
    19042042// This is a useful optimization, because it allows us to avoid allocating backing store.
    1905 bool RenderLayerBacking::isSimpleContainerCompositingLayer() const
     2043bool RenderLayerBacking::isSimpleContainerCompositingLayer(PaintedContentsInfo& contentsInfo) const
    19062044{
    19072045    if (renderer().isRenderReplaced() && (!isCompositedPlugin(renderer()) || isRestartedPlugin(renderer())))
     
    19112049        return false;
    19122050
    1913     if (paintsBoxDecorations() || paintsChildRenderers())
     2051    if (contentsInfo.paintsBoxDecorations() || contentsInfo.paintsContent())
    19142052        return false;
    19152053
     
    19492087}
    19502088
     2089// Returning true stops the traversal.
    19512090enum class LayerTraversal { Continue, Stop };
    19522091
     
    20092148
    20102149// Conservative test for having no rendered children.
    2011 bool RenderLayerBacking::isPaintDestinationForDescendantLayers() const
     2150bool RenderLayerBacking::isPaintDestinationForDescendantLayers(RenderLayer::PaintedContentRequest& request) const
    20122151{
    20132152    bool hasPaintingDescendant = false;
    2014     traverseVisibleNonCompositedDescendantLayers(m_owningLayer, [&hasPaintingDescendant](const RenderLayer& layer) {
    2015         hasPaintingDescendant = layer.isVisuallyNonEmpty();
    2016         return hasPaintingDescendant ? LayerTraversal::Stop : LayerTraversal::Continue;
     2153    traverseVisibleNonCompositedDescendantLayers(m_owningLayer, [&hasPaintingDescendant, &request](const RenderLayer& layer) {
     2154        hasPaintingDescendant |= layer.isVisuallyNonEmpty(&request);
     2155        return (hasPaintingDescendant && request.isSatisfied()) ? LayerTraversal::Stop : LayerTraversal::Continue;
    20172156    });
    20182157
     
    20242163    bool hasVisibleDescendant = false;
    20252164    traverseVisibleNonCompositedDescendantLayers(m_owningLayer, [&hasVisibleDescendant](const RenderLayer& layer) {
    2026         hasVisibleDescendant = layer.hasVisibleContent();
     2165        hasVisibleDescendant |= layer.hasVisibleContent();
    20272166        return hasVisibleDescendant ? LayerTraversal::Stop : LayerTraversal::Continue;
    20282167    });
     
    20312170}
    20322171
    2033 bool RenderLayerBacking::containsPaintedContent(bool isSimpleContainer) const
    2034 {
    2035     if (isSimpleContainer || paintsIntoWindow() || paintsIntoCompositedAncestor() || m_artificiallyInflatedBounds || m_owningLayer.isReflection())
    2036         return false;
    2037 
    2038     if (isDirectlyCompositedImage())
     2172bool RenderLayerBacking::containsPaintedContent(PaintedContentsInfo& contentsInfo) const
     2173{
     2174    if (contentsInfo.isSimpleContainer() || paintsIntoWindow() || paintsIntoCompositedAncestor() || m_artificiallyInflatedBounds || m_owningLayer.isReflection())
     2175        return false;
     2176
     2177    if (contentsInfo.isDirectlyCompositedImage())
    20392178        return false;
    20402179
     
    20862225void RenderLayerBacking::contentChanged(ContentChangeType changeType)
    20872226{
    2088     if ((changeType == ImageChanged) && isDirectlyCompositedImage()) {
    2089         updateImageContents();
     2227    PaintedContentsInfo contentsInfo(*this);
     2228    if ((changeType == ImageChanged) && contentsInfo.isDirectlyCompositedImage()) {
     2229        updateImageContents(contentsInfo);
    20902230        return;
    20912231    }
     
    21082248}
    21092249
    2110 void RenderLayerBacking::updateImageContents()
     2250void RenderLayerBacking::updateImageContents(PaintedContentsInfo& contentsInfo)
    21112251{
    21122252    auto& imageRenderer = downcast<RenderImage>(renderer());
     
    21332273
    21342274    m_graphicsLayer->setContentsToImage(image);
    2135     bool isSimpleContainer = false;
    2136     updateDrawsContent(isSimpleContainer);
     2275   
     2276    updateDrawsContent(contentsInfo);
    21372277   
    21382278    // Image animation is "lazy", in that it automatically stops unless someone is drawing
  • trunk/Source/WebCore/rendering/RenderLayerBacking.h

    r213435 r213466  
    3636
    3737class KeyframeList;
     38class PaintedContentsInfo;
    3839class RenderLayerCompositor;
    3940class TiledBacking;
     
    189190   
    190191    void updateDebugIndicators(bool showBorder, bool showRepaintCounter);
     192    bool paintsSubpixelAntialiasedText() const { return m_paintsSubpixelAntialiasedText; }
    191193
    192194    // GraphicsLayerClient interface
     
    252254
    253255private:
     256    friend class PaintedContentsInfo;
     257
    254258    FloatRect backgroundBoxForSimpleContainerPainting() const;
    255259
     
    278282    bool requiresScrollCornerLayer() const;
    279283    bool updateScrollingLayers(bool scrollingLayers);
    280     void updateDrawsContent(bool isSimpleContainer);
     284
    281285    void updateChildClippingStrategy(bool needsDescendantsClippingLayer);
    282286
     
    307311    // Return the opacity value that this layer should use for compositing.
    308312    float compositingOpacity(float rendererOpacity) const;
    309    
     313    Color rendererBackgroundColor() const;
     314
    310315    bool isMainFrameRenderViewLayer() const;
    311316   
    312317    bool paintsBoxDecorations() const;
    313     bool paintsChildRenderers() const;
     318    bool paintsContent(RenderLayer::PaintedContentRequest&) const;
     319
     320    void updateDrawsContent(PaintedContentsInfo&);
    314321
    315322    // Returns true if this compositing layer has no visible content.
    316     bool isSimpleContainerCompositingLayer() const;
     323    bool isSimpleContainerCompositingLayer(PaintedContentsInfo&) const;
    317324    // Returns true if this layer has content that needs to be rendered by painting into the backing store.
    318     bool containsPaintedContent(bool isSimpleContainer) const;
     325    bool containsPaintedContent(PaintedContentsInfo&) const;
    319326    // Returns true if the RenderLayer just contains an image that we can composite directly.
    320327    bool isDirectlyCompositedImage() const;
    321     void updateImageContents();
    322 
    323     Color rendererBackgroundColor() const;
    324 
    325     void updateDirectlyCompositedBoxDecorations(bool isSimpleContainer, bool& didUpdateContentsRect);
    326     void updateDirectlyCompositedBackgroundColor(bool isSimpleContainer, bool& didUpdateContentsRect);
    327     void updateDirectlyCompositedBackgroundImage(bool isSimpleContainer, bool& didUpdateContentsRect);
     328    void updateImageContents(PaintedContentsInfo&);
     329
     330    void updateDirectlyCompositedBoxDecorations(PaintedContentsInfo&, bool& didUpdateContentsRect);
     331    void updateDirectlyCompositedBackgroundColor(PaintedContentsInfo&, bool& didUpdateContentsRect);
     332    void updateDirectlyCompositedBackgroundImage(PaintedContentsInfo&, bool& didUpdateContentsRect);
    328333
    329334    void resetContentsRect();
    330335
    331     bool isPaintDestinationForDescendantLayers() const;
     336    bool isPaintDestinationForDescendantLayers(RenderLayer::PaintedContentRequest&) const;
    332337    bool hasVisibleNonCompositedDescendants() const;
    333338
     
    383388#endif
    384389    bool m_backgroundLayerPaintsFixedRootBackground { false };
     390    bool m_paintsSubpixelAntialiasedText { false }; // This is for logging only.
    385391};
    386392
  • trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp

    r212484 r213466  
    842842                logString.appendLiteral("background");
    843843        }
     844       
     845        if (backing->paintsSubpixelAntialiasedText()) {
     846            if (prependSpace)
     847                logString.appendLiteral(", ");
     848            logString.appendLiteral("texty");
     849        }
    844850
    845851        logString.appendLiteral("] ");
  • trunk/Source/WebCore/testing/Internals.cpp

    r213458 r213466  
    13491349}
    13501350
     1351void Internals::setFontSmoothingEnabled(bool enabled)
     1352{
     1353    WebCore::FontCascade::setShouldUseSmoothing(enabled);
     1354}
     1355
    13511356ExceptionOr<void> Internals::setLowPowerModeEnabled(bool isEnabled)
    13521357{
  • trunk/Source/WebCore/testing/Internals.h

    r213393 r213466  
    177177
    178178    void invalidateFontCache();
     179    void setFontSmoothingEnabled(bool);
     180   
    179181    ExceptionOr<void> setLowPowerModeEnabled(bool);
    180182
  • trunk/Source/WebCore/testing/Internals.idl

    r213393 r213466  
    161161
    162162    void invalidateFontCache();
     163    void setFontSmoothingEnabled(boolean enabled);
    163164
    164165    [MayThrowException] void setScrollViewPosition(long x, long y);
Note: See TracChangeset for help on using the changeset viewer.