- Revision
- 175656
- Author
- simon.fra...@apple.com
- Date
- 2014-11-05 18:21:51 -0800 (Wed, 05 Nov 2014)
Log Message
Avoid backing store for opacity:0 descendant layers
https://bugs.webkit.org/show_bug.cgi?id=138448
Reviewed by Dean Jackson.
Source/WebCore:
If a composited layer has no rendered content but a painting zero-opacity descendant
layer, than we can avoid making backing store.
When the opacity on such a child changes, we need to trigger a tree rebuild
to force the backing store to come back (this could be optimized later).
Tests: compositing/backing/no-backing-for-opacity-0-child.html
compositing/backing/toggle-opacity-0-child.html
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::calculateClipRects):
* rendering/RenderLayerCompositor.cpp:
(WebCore::styleChangeRequiresLayerRebuild):
* rendering/RenderObject.cpp:
(WebCore::RenderObject::containerForRepaint):
LayoutTests:
Test for no backing store with opacity:0 child, and that we get backing
store when dynamically changing the opacity to non-0.
* compositing/backing/no-backing-for-opacity-0-child-expected.txt: Added.
* compositing/backing/no-backing-for-opacity-0-child.html: Added.
* compositing/backing/toggle-opacity-0-child-expected.txt: Added.
* compositing/backing/toggle-opacity-0-child.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (175655 => 175656)
--- trunk/LayoutTests/ChangeLog 2014-11-06 02:21:14 UTC (rev 175655)
+++ trunk/LayoutTests/ChangeLog 2014-11-06 02:21:51 UTC (rev 175656)
@@ -1,3 +1,18 @@
+2014-11-05 Simon Fraser <simon.fra...@apple.com>
+
+ Avoid backing store for opacity:0 descendant layers
+ https://bugs.webkit.org/show_bug.cgi?id=138448
+
+ Reviewed by Dean Jackson.
+
+ Test for no backing store with opacity:0 child, and that we get backing
+ store when dynamically changing the opacity to non-0.
+
+ * compositing/backing/no-backing-for-opacity-0-child-expected.txt: Added.
+ * compositing/backing/no-backing-for-opacity-0-child.html: Added.
+ * compositing/backing/toggle-opacity-0-child-expected.txt: Added.
+ * compositing/backing/toggle-opacity-0-child.html: Added.
+
2014-11-05 Chris Fleizach <cfleiz...@apple.com>
AX: add "alt" as an overriding synonym of "-webkit-alt" (now in the CSS4 spec)
Added: trunk/LayoutTests/compositing/backing/no-backing-for-opacity-0-child-expected.txt (0 => 175656)
--- trunk/LayoutTests/compositing/backing/no-backing-for-opacity-0-child-expected.txt (rev 0)
+++ trunk/LayoutTests/compositing/backing/no-backing-for-opacity-0-child-expected.txt 2014-11-06 02:21:51 UTC (rev 175656)
@@ -0,0 +1,18 @@
+(GraphicsLayer
+ (anchor 0.00 0.00)
+ (bounds 800.00 600.00)
+ (children 1
+ (GraphicsLayer
+ (bounds 800.00 600.00)
+ (contentsOpaque 1)
+ (children 1
+ (GraphicsLayer
+ (position 18.00 10.00)
+ (anchor 0.40 0.40)
+ (bounds 125.00 125.00)
+ )
+ )
+ )
+ )
+)
+
Added: trunk/LayoutTests/compositing/backing/no-backing-for-opacity-0-child.html (0 => 175656)
--- trunk/LayoutTests/compositing/backing/no-backing-for-opacity-0-child.html (rev 0)
+++ trunk/LayoutTests/compositing/backing/no-backing-for-opacity-0-child.html 2014-11-06 02:21:51 UTC (rev 175656)
@@ -0,0 +1,70 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+ <style>
+ .container {
+ position: relative;
+ height: 100px;
+ width: 100px;
+ margin: 10px;
+ left: 0;
+ top: 0;
+ }
+
+ .clipping {
+ position: absolute;
+ overflow: hidden;
+ left: 20px;
+ top: 20px;
+ height: 100px;
+ width: 300px;
+ z-index: 0;
+ background-color: green;
+ }
+
+ .box {
+ position: absolute;
+ top: 75px;
+ left: 75px;
+ width: 50px;
+ height: 50px;
+ background-color: black;
+ }
+
+ .child {
+ opacity: 0;
+ }
+
+ .composited {
+ -webkit-transform: translateZ(0);
+ }
+ </style>
+
+ <script>
+ if (window.testRunner)
+ testRunner.dumpAsText();
+
+ function dumpLayers()
+ {
+ var layersResult = document.getElementById('layers');
+ if (window.testRunner)
+ layersResult.innerText = window.internals.layerTreeAsText(document);
+ }
+
+ window.addEventListener('load', dumpLayers, false)
+ </script>
+
+</head>
+<body>
+
+ <div class="composited container">
+ <div class="child box">
+ </div>
+ </div>
+ </div>
+
+<pre id="layers">Layer tree goes here in DRT</pre>
+
+</body>
+</html>
Added: trunk/LayoutTests/compositing/backing/toggle-opacity-0-child-expected.txt (0 => 175656)
--- trunk/LayoutTests/compositing/backing/toggle-opacity-0-child-expected.txt (rev 0)
+++ trunk/LayoutTests/compositing/backing/toggle-opacity-0-child-expected.txt 2014-11-06 02:21:51 UTC (rev 175656)
@@ -0,0 +1,19 @@
+(GraphicsLayer
+ (anchor 0.00 0.00)
+ (bounds 800.00 600.00)
+ (children 1
+ (GraphicsLayer
+ (bounds 800.00 600.00)
+ (contentsOpaque 1)
+ (children 1
+ (GraphicsLayer
+ (position 18.00 10.00)
+ (anchor 0.40 0.40)
+ (bounds 125.00 125.00)
+ (drawsContent 1)
+ )
+ )
+ )
+ )
+)
+
Added: trunk/LayoutTests/compositing/backing/toggle-opacity-0-child.html (0 => 175656)
--- trunk/LayoutTests/compositing/backing/toggle-opacity-0-child.html (rev 0)
+++ trunk/LayoutTests/compositing/backing/toggle-opacity-0-child.html 2014-11-06 02:21:51 UTC (rev 175656)
@@ -0,0 +1,84 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+ <style>
+ .container {
+ position: relative;
+ height: 100px;
+ width: 100px;
+ margin: 10px;
+ left: 0;
+ top: 0;
+ }
+
+ .clipping {
+ position: absolute;
+ overflow: hidden;
+ left: 20px;
+ top: 20px;
+ height: 100px;
+ width: 300px;
+ z-index: 0;
+ background-color: green;
+ }
+
+ .box {
+ position: absolute;
+ top: 75px;
+ left: 75px;
+ width: 50px;
+ height: 50px;
+ background-color: black;
+ }
+
+ .child {
+ opacity: 0;
+ }
+
+ .child.changed {
+ opacity: 0.5;
+ }
+
+ .composited {
+ -webkit-transform: translateZ(0);
+ }
+ </style>
+
+ <script>
+ if (window.testRunner) {
+ testRunner.dumpAsText();
+ testRunner.waitUntilDone();
+ }
+
+ function doTest()
+ {
+ document.getElementById('child').classList.add('changed');
+ dumpLayers();
+ if (window.testRunner)
+ testRunner.notifyDone();
+ }
+
+ function dumpLayers()
+ {
+ var layersResult = document.getElementById('layers');
+ if (window.testRunner)
+ layersResult.innerText = window.internals.layerTreeAsText(document);
+ }
+
+ window.addEventListener('load', doTest, false)
+ </script>
+
+</head>
+<body>
+
+ <div class="composited container">
+ <div id="child" class="child box">
+ </div>
+ </div>
+ </div>
+
+<pre id="layers">Layer tree goes here in DRT</pre>
+
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (175655 => 175656)
--- trunk/Source/WebCore/ChangeLog 2014-11-06 02:21:14 UTC (rev 175655)
+++ trunk/Source/WebCore/ChangeLog 2014-11-06 02:21:51 UTC (rev 175656)
@@ -1,3 +1,26 @@
+2014-11-05 Simon Fraser <simon.fra...@apple.com>
+
+ Avoid backing store for opacity:0 descendant layers
+ https://bugs.webkit.org/show_bug.cgi?id=138448
+
+ Reviewed by Dean Jackson.
+
+ If a composited layer has no rendered content but a painting zero-opacity descendant
+ layer, than we can avoid making backing store.
+
+ When the opacity on such a child changes, we need to trigger a tree rebuild
+ to force the backing store to come back (this could be optimized later).
+
+ Tests: compositing/backing/no-backing-for-opacity-0-child.html
+ compositing/backing/toggle-opacity-0-child.html
+
+ * rendering/RenderLayer.cpp:
+ (WebCore::RenderLayer::calculateClipRects):
+ * rendering/RenderLayerCompositor.cpp:
+ (WebCore::styleChangeRequiresLayerRebuild):
+ * rendering/RenderObject.cpp:
+ (WebCore::RenderObject::containerForRepaint):
+
2014-11-05 Chris Dumez <cdu...@apple.com>
Assertion hit DOMTimer::updateTimerIntervalIfNecessary()
Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (175655 => 175656)
--- trunk/Source/WebCore/rendering/RenderLayer.cpp 2014-11-06 02:21:14 UTC (rev 175655)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp 2014-11-06 02:21:51 UTC (rev 175656)
@@ -6328,7 +6328,7 @@
{
ASSERT(!m_visibleDescendantStatusDirty);
- if (!hasVisibleContent())
+ if (!hasVisibleContent() || !renderer().style().opacity())
return false;
if (renderer().isRenderReplaced() || hasOverflowControls())
Modified: trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp (175655 => 175656)
--- trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp 2014-11-06 02:21:14 UTC (rev 175655)
+++ trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp 2014-11-06 02:21:51 UTC (rev 175656)
@@ -881,6 +881,15 @@
if (oldStyle.clip() != newStyle.clip() || oldStyle.hasClip() != newStyle.hasClip())
return true;
+ // FIXME: need to check everything that we consult to avoid backing store here: webkit.org/b/138383
+ if (!oldStyle.opacity() != !newStyle.opacity()) {
+ RenderLayerModelObject* repaintContainer = layer.renderer().containerForRepaint();
+ if (RenderLayerBacking* ancestorBacking = repaintContainer->layer()->backing()) {
+ if (newStyle.opacity() != ancestorBacking->graphicsLayer()->drawsContent())
+ return true;
+ }
+ }
+
// When overflow changes, composited layers may need to update their ancestorClipping layers.
if (!layer.isComposited() && (oldStyle.overflowX() != newStyle.overflowX() || oldStyle.overflowY() != newStyle.overflowY()) && layer.stackingContainer()->hasCompositingDescendant())
return true;
Modified: trunk/Source/WebCore/rendering/RenderObject.cpp (175655 => 175656)
--- trunk/Source/WebCore/rendering/RenderObject.cpp 2014-11-06 02:21:14 UTC (rev 175655)
+++ trunk/Source/WebCore/rendering/RenderObject.cpp 2014-11-06 02:21:51 UTC (rev 175656)
@@ -1195,7 +1195,7 @@
RenderLayerModelObject* RenderObject::containerForRepaint() const
{
- RenderLayerModelObject* repaintContainer = 0;
+ RenderLayerModelObject* repaintContainer = nullptr;
if (view().usesCompositing()) {
if (RenderLayer* parentLayer = enclosingLayer()) {