Only use layer backing store which supports subpixel antialiased text if we know...
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 6 Mar 2017 21:45:38 +0000 (21:45 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 6 Mar 2017 21:45:38 +0000 (21:45 +0000)
commit97f129a1336fb99ebeb2cd21f5e9237371576860
tree0cc311ac85bca0a6276ddada859a38ca280abd73
parentb5506c337275703c88193c4860048d968fdb2a31
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.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@213466 268f45cc-cd09-0410-ab3c-d52691b4dbfc
33 files changed:
LayoutTests/ChangeLog
LayoutTests/compositing/contents-format/subpixel-antialiased-text-configs-antialiasing-style-expected.txt [new file with mode: 0644]
LayoutTests/compositing/contents-format/subpixel-antialiased-text-configs-antialiasing-style.html [new file with mode: 0644]
LayoutTests/compositing/contents-format/subpixel-antialiased-text-configs-expected.txt [new file with mode: 0644]
LayoutTests/compositing/contents-format/subpixel-antialiased-text-configs.html [new file with mode: 0644]
LayoutTests/compositing/contents-format/subpixel-antialiased-text-enabled-expected.txt
LayoutTests/compositing/contents-format/subpixel-antialiased-text-enabled.html
LayoutTests/compositing/contents-format/subpixel-antialiased-text-images-expected.txt [new file with mode: 0644]
LayoutTests/compositing/contents-format/subpixel-antialiased-text-images.html [new file with mode: 0644]
LayoutTests/compositing/contents-format/subpixel-antialiased-text-visibility-expected.txt [new file with mode: 0644]
LayoutTests/compositing/contents-format/subpixel-antialiased-text-visibility.html [new file with mode: 0644]
LayoutTests/compositing/resources/circle-with-text.svg [new file with mode: 0644]
LayoutTests/compositing/resources/circle.svg [new file with mode: 0644]
LayoutTests/platform/mac-wk1/compositing/contents-format/subpixel-antialiased-text-enabled-expected.txt
LayoutTests/platform/mac/compositing/contents-format/subpixel-antialiased-text-configs-antialiasing-style-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/compositing/contents-format/subpixel-antialiased-text-configs-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/compositing/contents-format/subpixel-antialiased-text-enabled-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/compositing/contents-format/subpixel-antialiased-text-images-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/compositing/contents-format/subpixel-antialiased-text-visibility-expected.txt [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/GraphicsLayer.cpp
Source/WebCore/platform/graphics/GraphicsLayer.h
Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp
Source/WebCore/rendering/RenderImage.cpp
Source/WebCore/rendering/RenderImage.h
Source/WebCore/rendering/RenderLayer.cpp
Source/WebCore/rendering/RenderLayer.h
Source/WebCore/rendering/RenderLayerBacking.cpp
Source/WebCore/rendering/RenderLayerBacking.h
Source/WebCore/rendering/RenderLayerCompositor.cpp
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/Internals.h
Source/WebCore/testing/Internals.idl