Avoid backing store on layers created for CoreAnimation plugins
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Aug 2012 22:17:34 +0000 (22:17 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Aug 2012 22:17:34 +0000 (22:17 +0000)
https://bugs.webkit.org/show_bug.cgi?id=93526
<rdar://problem/12052828>

Reviewed by Dean Jackson.

Source/WebCore:

We create a compositing layer for <embed> objects whose plug-in supports
the CoreAnimation rendering model. When the embed's renderer is not styled,
we can avoid allocating backing store for it.

Test: compositing/plugins/no-backing-store.html

* rendering/RenderLayerBacking.cpp:
(WebCore::isCompositedPlugin):
(WebCore::RenderLayerBacking::isSimpleContainerCompositingLayer):

LayoutTests:

Test for backing store on CoreAnimation-based plugins in various
configurations.

* compositing/plugins/no-backing-store-expected.txt: Added.
* compositing/plugins/no-backing-store.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@125101 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/compositing/plugins/no-backing-store-expected.txt [new file with mode: 0644]
LayoutTests/compositing/plugins/no-backing-store.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderLayerBacking.cpp

index f21fdf5..ed3509e 100644 (file)
@@ -1,3 +1,17 @@
+2012-08-08  Simon Fraser  <simon.fraser@apple.com>
+
+        Avoid backing store on layers created for CoreAnimation plugins
+        https://bugs.webkit.org/show_bug.cgi?id=93526
+        <rdar://problem/12052828>
+
+        Reviewed by Dean Jackson.
+
+        Test for backing store on CoreAnimation-based plugins in various
+        configurations.
+
+        * compositing/plugins/no-backing-store-expected.txt: Added.
+        * compositing/plugins/no-backing-store.html: Added.
+
 2012-08-08  Jeff Timanus  <twiz@chromium.org>
 
         [Chromium] Updating fast/canvas/webgl/gl-teximage.html to prevent valid variations in results from causing test failures.
diff --git a/LayoutTests/compositing/plugins/no-backing-store-expected.txt b/LayoutTests/compositing/plugins/no-backing-store-expected.txt
new file mode 100644 (file)
index 0000000..e7776d7
--- /dev/null
@@ -0,0 +1,26 @@
+      
+(GraphicsLayer
+  (bounds 800.00 600.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 800.00 600.00)
+      (children 3
+        (GraphicsLayer
+          (position 142.00 20.00)
+          (bounds 100.00 100.00)
+        )
+        (GraphicsLayer
+          (position 266.00 20.00)
+          (bounds 100.00 100.00)
+          (drawsContent 1)
+        )
+        (GraphicsLayer
+          (position 390.00 18.00)
+          (bounds 102.00 102.00)
+          (drawsContent 1)
+        )
+      )
+    )
+  )
+)
+
diff --git a/LayoutTests/compositing/plugins/no-backing-store.html b/LayoutTests/compositing/plugins/no-backing-store.html
new file mode 100644 (file)
index 0000000..da4e0de
--- /dev/null
@@ -0,0 +1,42 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <style type="text/css" media="screen">
+    embed {
+      margin: 10px;
+    }
+  </style>
+  <script type="text/javascript" charset="utf-8">
+    if (window.testRunner) {
+        testRunner.dumpAsText();
+        testRunner.waitUntilDone();
+    }
+
+    function doTest()
+    {
+        // Need to wait for compositing layers to be updated. FIXME remove.
+        window.setTimeout(function() {
+            if (window.testRunner) {
+                document.getElementById('layers').innerHTML = testRunner.layerTreeAsText();
+                testRunner.notifyDone();
+            }
+        }, 0)
+    }
+    window.addEventListener('load', doTest, false);
+  </script>
+</head>
+<body>
+  
+    <!-- Not layer-backed -->
+    <embed type="application/x-webkit-test-netscape" width="100" height="100">
+
+    <!-- Layer-backed, no need for backing store -->
+    <embed type="application/x-webkit-test-netscape" width="100" height="100" drawingmodel="coreanimation">
+
+    <!-- Both these need backing store -->
+    <embed style="background-color: blue;" type="application/x-webkit-test-netscape" width="100" height="100" drawingmodel="coreanimation">
+    <embed style="border: 1px solid black;" type="application/x-webkit-test-netscape" width="100" height="100" drawingmodel="coreanimation">
+
+    <pre id="layers">Layer tree appears here in DRT.</pre>
+</body>
+</html>
index eafcc47..0b9977c 100644 (file)
@@ -1,3 +1,21 @@
+2012-08-08  Simon Fraser  <simon.fraser@apple.com>
+
+        Avoid backing store on layers created for CoreAnimation plugins
+        https://bugs.webkit.org/show_bug.cgi?id=93526
+        <rdar://problem/12052828>
+
+        Reviewed by Dean Jackson.
+
+        We create a compositing layer for <embed> objects whose plug-in supports
+        the CoreAnimation rendering model. When the embed's renderer is not styled,
+        we can avoid allocating backing store for it.
+
+        Test: compositing/plugins/no-backing-store.html
+
+        * rendering/RenderLayerBacking.cpp:
+        (WebCore::isCompositedPlugin):
+        (WebCore::RenderLayerBacking::isSimpleContainerCompositingLayer):
+
 2012-08-08  Erik Arvidsson  <arv@chromium.org>
 
         DOM4: classList should be defined on Element and not on HTMLElement
index e110a4d..25e2745 100644 (file)
@@ -895,16 +895,23 @@ bool RenderLayerBacking::paintsChildren() const
     return false;
 }
 
+static bool isCompositedPlugin(RenderObject* renderer)
+{
+    return renderer->isEmbeddedObject() && toRenderEmbeddedObject(renderer)->allowsAcceleratedCompositing();
+}
+
 // A "simple container layer" is a RenderLayer which has no visible content to render.
 // It may have no children, or all its children may be themselves composited.
 // This is a useful optimization, because it allows us to avoid allocating backing store.
 bool RenderLayerBacking::isSimpleContainerCompositingLayer() const
 {
     RenderObject* renderObject = renderer();
-    if (renderObject->isReplaced() ||       // replaced objects are not containers
-        renderObject->hasMask())            // masks require special treatment
+    if (renderObject->hasMask()) // masks require special treatment
         return false;
 
+    if (renderObject->isReplaced() && !isCompositedPlugin(renderObject))
+            return false;
+    
     if (paintsBoxDecorations() || paintsChildren())
         return false;