- Revision
- 213600
- Author
- [email protected]
- Date
- 2017-03-08 14:53:20 -0800 (Wed, 08 Mar 2017)
Log Message
Change determineNonLayerDescendantsPaintedContent to max out based on renderers traversed
https://bugs.webkit.org/show_bug.cgi?id=169384
Reviewed by Zalan Bujtas.
Source/WebCore:
determineNonLayerDescendantsPaintedContent() would bail after depth 3, sibling count 20. However,
empirical testing shows that it would run to completion more often if the limit was based on the
number of nodes traversed (in particular, it's common to see fairly deep subtrees with few siblings).
Running to completion has huge memory advantages, because we can then be sure to have checked all the
renderers for smoothed text, allowing us, on some pages, to avoid the extra memory cost of using
layers that support subpixel-antialiased text.
Performance measurement shows that mean runtime of this function goes up from 0.30us to 0.34us
with a 200 renderer limit, which seems worthwhile.
Test: compositing/contents-format/subpixel-antialiased-text-traversal.html
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::calculateClipRects):
LayoutTests:
Rebaseline an existing test which changes behavior, and add a new test that generates divs
on both sides of the threshold, in depth and breadth.
* compositing/contents-format/subpixel-antialiased-text-traversal-expected.txt: Added.
* compositing/contents-format/subpixel-antialiased-text-traversal.html: Added.
* platform/mac/compositing/contents-format/subpixel-antialiased-text-configs-antialiasing-style-expected.txt:
* platform/mac/compositing/contents-format/subpixel-antialiased-text-traversal-expected.txt: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (213599 => 213600)
--- trunk/LayoutTests/ChangeLog 2017-03-08 22:50:51 UTC (rev 213599)
+++ trunk/LayoutTests/ChangeLog 2017-03-08 22:53:20 UTC (rev 213600)
@@ -1,3 +1,18 @@
+2017-03-08 Simon Fraser <[email protected]>
+
+ Change determineNonLayerDescendantsPaintedContent to max out based on renderers traversed
+ https://bugs.webkit.org/show_bug.cgi?id=169384
+
+ Reviewed by Zalan Bujtas.
+
+ Rebaseline an existing test which changes behavior, and add a new test that generates divs
+ on both sides of the threshold, in depth and breadth.
+
+ * compositing/contents-format/subpixel-antialiased-text-traversal-expected.txt: Added.
+ * compositing/contents-format/subpixel-antialiased-text-traversal.html: Added.
+ * platform/mac/compositing/contents-format/subpixel-antialiased-text-configs-antialiasing-style-expected.txt:
+ * platform/mac/compositing/contents-format/subpixel-antialiased-text-traversal-expected.txt: Added.
+
2017-03-08 Youenn Fablet <[email protected]>
Support canvas captureStream
Added: trunk/LayoutTests/compositing/contents-format/subpixel-antialiased-text-traversal-expected.txt (0 => 213600)
--- trunk/LayoutTests/compositing/contents-format/subpixel-antialiased-text-traversal-expected.txt (rev 0)
+++ trunk/LayoutTests/compositing/contents-format/subpixel-antialiased-text-traversal-expected.txt 2017-03-08 22:53:20 UTC (rev 213600)
@@ -0,0 +1,36 @@
+(GraphicsLayer
+ (anchor 0.00 0.00)
+ (bounds 1163.00 1244.00)
+ (children 1
+ (GraphicsLayer
+ (bounds 1163.00 1244.00)
+ (contentsOpaque 1)
+ (children 4
+ (GraphicsLayer
+ (position 12.00 17.00)
+ (bounds 162.00 606.00)
+ (drawsContent 1)
+ )
+ (GraphicsLayer
+ (position 182.00 17.00)
+ (bounds 162.00 606.00)
+ (drawsContent 1)
+ )
+ (GraphicsLayer
+ (position 352.00 17.00)
+ (bounds 635.00 1215.00)
+ (drawsContent 1)
+ )
+ (GraphicsLayer
+ (position 522.00 17.00)
+ (bounds 641.00 1227.00)
+ (drawsContent 1)
+ )
+ )
+ )
+ )
+)
+01234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
+0123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
+0
+0
Added: trunk/LayoutTests/compositing/contents-format/subpixel-antialiased-text-traversal.html (0 => 213600)
--- trunk/LayoutTests/compositing/contents-format/subpixel-antialiased-text-traversal.html (rev 0)
+++ trunk/LayoutTests/compositing/contents-format/subpixel-antialiased-text-traversal.html 2017-03-08 22:53:20 UTC (rev 213600)
@@ -0,0 +1,91 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+ <style>
+ .container {
+ height: 150px;
+ width: 150px;
+ float: left;
+ position: relative;
+ border: 1px solid black;
+ padding: 20px;
+ margin: 10px;
+ box-sizing: border-box;
+ box-shadow: 0 0 4px rgba(0, 0, 0, 0.2);
+ }
+
+ .container div {
+ border: 1px solid rgba(0, 0, 0, 0.5);
+ padding: 2px;
+ }
+
+ .inner {
+ float: left;
+ }
+
+ .composited {
+ will-change: transform;
+ }
+
+ .antialiased {
+ -webkit-font-smoothing: antialiased;
+ }
+ </style>
+ <script>
+ if (window.testRunner)
+ testRunner.dumpAsText();
+
+ if (window.internals) {
+ internals.setFontSmoothingEnabled(true);
+ internals.settings.setSubpixelAntialiasedLayerTextEnabled(true)
+ }
+
+ function createContainer(maxDepth, leafSiblings)
+ {
+ var container = document.createElement('div');
+ container.className = 'composited antialiased container';
+
+ var parent = container;
+
+ for (var depth = 0; depth < maxDepth; ++depth) {
+ var innerDiv = document.createElement('div');
+ parent.appendChild(innerDiv);
+ parent = innerDiv;
+ }
+
+ for (var breadth = 0; breadth < leafSiblings; ++breadth) {
+ var child = document.createElement('div');
+ child.className = 'inner';
+ child.textContent = breadth;
+ parent.appendChild(child);
+ }
+
+ return container;
+ }
+
+ function createContainers()
+ {
+ document.body.appendChild(createContainer(1, 99));
+ document.body.appendChild(createContainer(1, 100));
+ document.body.appendChild(createContainer(198, 1));
+ document.body.appendChild(createContainer(200, 1));
+ }
+
+ function doTest()
+ {
+ createContainers();
+
+ if (window.internals)
+ document.getElementById('layers').innerText = internals.layerTreeAsText(document);
+ }
+
+ window.addEventListener('load', doTest, false);
+ </script>
+</head>
+<body>
+
+<pre id="layers"></pre>
+
+</body>
+</html>
Modified: trunk/LayoutTests/platform/mac/compositing/contents-format/subpixel-antialiased-text-configs-antialiasing-style-expected.txt (213599 => 213600)
--- trunk/LayoutTests/platform/mac/compositing/contents-format/subpixel-antialiased-text-configs-antialiasing-style-expected.txt 2017-03-08 22:50:51 UTC (rev 213599)
+++ trunk/LayoutTests/platform/mac/compositing/contents-format/subpixel-antialiased-text-configs-antialiasing-style-expected.txt 2017-03-08 22:53:20 UTC (rev 213600)
@@ -111,7 +111,6 @@
(GraphicsLayer
(position 352.00 357.00)
(bounds 162.00 162.00)
- (supports subpixel antialiased text 1)
(drawsContent 1)
)
(GraphicsLayer
Added: trunk/LayoutTests/platform/mac/compositing/contents-format/subpixel-antialiased-text-traversal-expected.txt (0 => 213600)
--- trunk/LayoutTests/platform/mac/compositing/contents-format/subpixel-antialiased-text-traversal-expected.txt (rev 0)
+++ trunk/LayoutTests/platform/mac/compositing/contents-format/subpixel-antialiased-text-traversal-expected.txt 2017-03-08 22:53:20 UTC (rev 213600)
@@ -0,0 +1,38 @@
+(GraphicsLayer
+ (anchor 0.00 0.00)
+ (bounds 1163.00 1244.00)
+ (children 1
+ (GraphicsLayer
+ (bounds 1163.00 1244.00)
+ (contentsOpaque 1)
+ (children 4
+ (GraphicsLayer
+ (position 12.00 17.00)
+ (bounds 162.00 606.00)
+ (drawsContent 1)
+ )
+ (GraphicsLayer
+ (position 182.00 17.00)
+ (bounds 162.00 606.00)
+ (supports subpixel antialiased text 1)
+ (drawsContent 1)
+ )
+ (GraphicsLayer
+ (position 352.00 17.00)
+ (bounds 635.00 1215.00)
+ (drawsContent 1)
+ )
+ (GraphicsLayer
+ (position 522.00 17.00)
+ (bounds 641.00 1227.00)
+ (supports subpixel antialiased text 1)
+ (drawsContent 1)
+ )
+ )
+ )
+ )
+)
+01234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
+0123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
+0
+0
Modified: trunk/Source/WebCore/ChangeLog (213599 => 213600)
--- trunk/Source/WebCore/ChangeLog 2017-03-08 22:50:51 UTC (rev 213599)
+++ trunk/Source/WebCore/ChangeLog 2017-03-08 22:53:20 UTC (rev 213600)
@@ -1,3 +1,25 @@
+2017-03-08 Simon Fraser <[email protected]>
+
+ Change determineNonLayerDescendantsPaintedContent to max out based on renderers traversed
+ https://bugs.webkit.org/show_bug.cgi?id=169384
+
+ Reviewed by Zalan Bujtas.
+
+ determineNonLayerDescendantsPaintedContent() would bail after depth 3, sibling count 20. However,
+ empirical testing shows that it would run to completion more often if the limit was based on the
+ number of nodes traversed (in particular, it's common to see fairly deep subtrees with few siblings).
+ Running to completion has huge memory advantages, because we can then be sure to have checked all the
+ renderers for smoothed text, allowing us, on some pages, to avoid the extra memory cost of using
+ layers that support subpixel-antialiased text.
+
+ Performance measurement shows that mean runtime of this function goes up from 0.30us to 0.34us
+ with a 200 renderer limit, which seems worthwhile.
+
+ Test: compositing/contents-format/subpixel-antialiased-text-traversal.html
+
+ * rendering/RenderLayer.cpp:
+ (WebCore::RenderLayer::calculateClipRects):
+
2017-03-08 Youenn Fablet <[email protected]>
Support canvas captureStream
Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (213599 => 213600)
--- trunk/Source/WebCore/rendering/RenderLayer.cpp 2017-03-08 22:50:51 UTC (rev 213599)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp 2017-03-08 22:53:20 UTC (rev 213600)
@@ -6587,19 +6587,12 @@
}
// Constrain the depth and breadth of the search for performance.
-static const int maxDescendentDepth = 3;
-static const int maxSiblingCount = 20;
+static const unsigned maxRendererTraversalCount = 200;
-static void determineNonLayerDescendantsPaintedContent(const RenderElement& renderer, int depth, RenderLayer::PaintedContentRequest& request)
+static void determineNonLayerDescendantsPaintedContent(const RenderElement& renderer, unsigned& renderersTraversed, RenderLayer::PaintedContentRequest& request)
{
- if (depth > maxDescendentDepth) {
- request.makeStatesUndetermined();
- return;
- }
-
- int siblingCount = 0;
for (const auto& child : childrenOfType<RenderObject>(renderer)) {
- if (++siblingCount > maxSiblingCount) {
+ if (++renderersTraversed > maxRendererTraversalCount) {
request.makeStatesUndetermined();
return;
}
@@ -6651,7 +6644,7 @@
return;
}
- determineNonLayerDescendantsPaintedContent(renderElementChild, depth + 1, request);
+ determineNonLayerDescendantsPaintedContent(renderElementChild, renderersTraversed, request);
if (request.isSatisfied())
return;
}
@@ -6659,7 +6652,8 @@
bool RenderLayer::hasNonEmptyChildRenderers(PaintedContentRequest& request) const
{
- determineNonLayerDescendantsPaintedContent(renderer(), 0, request);
+ unsigned renderersTraversed = 0;
+ determineNonLayerDescendantsPaintedContent(renderer(), renderersTraversed, request);
return request.probablyHasPaintedContent();
}