Diff
Modified: branches/safari-600.3-branch/LayoutTests/ChangeLog (176290 => 176291)
--- branches/safari-600.3-branch/LayoutTests/ChangeLog 2014-11-18 23:06:00 UTC (rev 176290)
+++ branches/safari-600.3-branch/LayoutTests/ChangeLog 2014-11-18 23:07:28 UTC (rev 176291)
@@ -1,3 +1,18 @@
+2014-11-05 Simon Fraser <[email protected]>
+
+ 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-18 Matthew Hanson <[email protected]>
Merge missing layout tests which were added to trunk in r175197.
Added: branches/safari-600.3-branch/LayoutTests/compositing/backing/no-backing-for-opacity-0-child-expected.txt (0 => 176291)
--- branches/safari-600.3-branch/LayoutTests/compositing/backing/no-backing-for-opacity-0-child-expected.txt (rev 0)
+++ branches/safari-600.3-branch/LayoutTests/compositing/backing/no-backing-for-opacity-0-child-expected.txt 2014-11-18 23:07:28 UTC (rev 176291)
@@ -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: branches/safari-600.3-branch/LayoutTests/compositing/backing/no-backing-for-opacity-0-child.html (0 => 176291)
--- branches/safari-600.3-branch/LayoutTests/compositing/backing/no-backing-for-opacity-0-child.html (rev 0)
+++ branches/safari-600.3-branch/LayoutTests/compositing/backing/no-backing-for-opacity-0-child.html 2014-11-18 23:07:28 UTC (rev 176291)
@@ -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: branches/safari-600.3-branch/LayoutTests/compositing/backing/toggle-opacity-0-child-expected.txt (0 => 176291)
--- branches/safari-600.3-branch/LayoutTests/compositing/backing/toggle-opacity-0-child-expected.txt (rev 0)
+++ branches/safari-600.3-branch/LayoutTests/compositing/backing/toggle-opacity-0-child-expected.txt 2014-11-18 23:07:28 UTC (rev 176291)
@@ -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: branches/safari-600.3-branch/LayoutTests/compositing/backing/toggle-opacity-0-child.html (0 => 176291)
--- branches/safari-600.3-branch/LayoutTests/compositing/backing/toggle-opacity-0-child.html (rev 0)
+++ branches/safari-600.3-branch/LayoutTests/compositing/backing/toggle-opacity-0-child.html 2014-11-18 23:07:28 UTC (rev 176291)
@@ -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: branches/safari-600.3-branch/Source/WebCore/ChangeLog (176290 => 176291)
--- branches/safari-600.3-branch/Source/WebCore/ChangeLog 2014-11-18 23:06:00 UTC (rev 176290)
+++ branches/safari-600.3-branch/Source/WebCore/ChangeLog 2014-11-18 23:07:28 UTC (rev 176291)
@@ -1,3 +1,26 @@
+2014-11-05 Simon Fraser <[email protected]>
+
+ 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-18 Dana Burkart <[email protected]>
Merge r176166. rdar://problem/18953982
Modified: branches/safari-600.3-branch/Source/WebCore/rendering/RenderLayer.cpp (176290 => 176291)
--- branches/safari-600.3-branch/Source/WebCore/rendering/RenderLayer.cpp 2014-11-18 23:06:00 UTC (rev 176290)
+++ branches/safari-600.3-branch/Source/WebCore/rendering/RenderLayer.cpp 2014-11-18 23:07:28 UTC (rev 176291)
@@ -6276,7 +6276,7 @@
{
ASSERT(!m_visibleDescendantStatusDirty);
- if (!hasVisibleContent())
+ if (!hasVisibleContent() || !renderer().style().opacity())
return false;
if (renderer().isRenderReplaced() || hasOverflowControls())
@@ -6421,6 +6421,21 @@
return !isComposited() && oldStyle && (oldStyle->overflowX() != newStyle->overflowX()) && stackingContainer()->hasCompositingDescendant();
}
+inline bool RenderLayer::needsCompositingLayersRebuiltForOpacity(const RenderStyle* oldStyle, const RenderStyle* newStyle) const
+{
+ if (!oldStyle || !newStyle)
+ return false;
+
+ if (!oldStyle->opacity() != !newStyle->opacity()) {
+ RenderLayerModelObject* repaintContainer = renderer().containerForRepaint();
+ if (RenderLayerBacking* ancestorBacking = repaintContainer->layer()->backing()) {
+ if (newStyle->opacity() != ancestorBacking->graphicsLayer()->drawsContent())
+ return true;
+ }
+ }
+ return false;
+}
+
void RenderLayer::styleChanged(StyleDifference diff, const RenderStyle* oldStyle)
{
bool isNormalFlowOnly = shouldBeNormalFlowOnly();
@@ -6480,7 +6495,8 @@
const RenderStyle& newStyle = renderer().style();
if (compositor().updateLayerCompositingState(*this)
|| needsCompositingLayersRebuiltForClip(oldStyle, &newStyle)
- || needsCompositingLayersRebuiltForOverflow(oldStyle, &newStyle))
+ || needsCompositingLayersRebuiltForOverflow(oldStyle, &newStyle)
+ || needsCompositingLayersRebuiltForOpacity(oldStyle, &newStyle))
compositor().setCompositingLayersNeedRebuild();
else if (isComposited()) {
// FIXME: updating geometry here is potentially harmful, because layout is not up-to-date.
Modified: branches/safari-600.3-branch/Source/WebCore/rendering/RenderLayer.h (176290 => 176291)
--- branches/safari-600.3-branch/Source/WebCore/rendering/RenderLayer.h 2014-11-18 23:06:00 UTC (rev 176290)
+++ branches/safari-600.3-branch/Source/WebCore/rendering/RenderLayer.h 2014-11-18 23:07:28 UTC (rev 176291)
@@ -831,6 +831,7 @@
bool needsCompositedScrolling() const;
bool needsCompositingLayersRebuiltForClip(const RenderStyle* oldStyle, const RenderStyle* newStyle) const;
bool needsCompositingLayersRebuiltForOverflow(const RenderStyle* oldStyle, const RenderStyle* newStyle) const;
+ bool needsCompositingLayersRebuiltForOpacity(const RenderStyle* oldStyle, const RenderStyle* newStyle) const;
bool paintsWithTransparency(PaintBehavior paintBehavior) const
{
Modified: branches/safari-600.3-branch/Source/WebCore/rendering/RenderObject.cpp (176290 => 176291)
--- branches/safari-600.3-branch/Source/WebCore/rendering/RenderObject.cpp 2014-11-18 23:06:00 UTC (rev 176290)
+++ branches/safari-600.3-branch/Source/WebCore/rendering/RenderObject.cpp 2014-11-18 23:07:28 UTC (rev 176291)
@@ -1227,7 +1227,7 @@
RenderLayerModelObject* RenderObject::containerForRepaint() const
{
- RenderLayerModelObject* repaintContainer = 0;
+ RenderLayerModelObject* repaintContainer = nullptr;
if (view().usesCompositing()) {
if (RenderLayer* parentLayer = enclosingLayer()) {