Bug 1346777 - Transform layer geometry properly when intermediate surface is used draft
authorMiko Mynttinen <mikokm@gmail.com>
Thu, 16 Mar 2017 21:51:54 +0100
changeset 500756 9419f0a473f8fb0b5c80a18a1fa08d1aa38019ce
parent 499288 48006b97073128922d1f36361bca3134afabe8fe
child 549698 c95388d8854a3fbba16d8dfa217aa004e245c668
push id49788
push userbmo:mikokm@gmail.com
push dateFri, 17 Mar 2017 16:19:53 +0000
bugs1346777
milestone55.0a1
Bug 1346777 - Transform layer geometry properly when intermediate surface is used MozReview-Commit-ID: H3YmadD8sFz
gfx/layers/composite/ContainerLayerComposite.cpp
layout/reftests/transform-3d/intermediate-1-ref.html
layout/reftests/transform-3d/intermediate-1.html
layout/reftests/transform-3d/reftest.list
--- a/gfx/layers/composite/ContainerLayerComposite.cpp
+++ b/gfx/layers/composite/ContainerLayerComposite.cpp
@@ -103,20 +103,16 @@ PrintUniformityInfo(Layer* aLayer)
 }
 
 static Maybe<gfx::Polygon>
 SelectLayerGeometry(const Maybe<gfx::Polygon>& aParentGeometry,
                     const Maybe<gfx::Polygon>& aChildGeometry)
 {
   // Both the parent and the child layer were split.
   if (aParentGeometry && aChildGeometry) {
-    // As we use intermediate surface in these cases, this branch should never
-    // get executed.
-    MOZ_ASSERT(false,
-               "Both parent and child geometry present in nested 3D context!");
     return Some(aParentGeometry->ClipPolygon(*aChildGeometry));
   }
 
   // The parent layer was split.
   if (aParentGeometry) {
     return aParentGeometry;
   }
 
@@ -448,22 +444,26 @@ RenderLayers(ContainerT* aContainer, Lay
       gfx::IntRect clearRect = layerToRender->GetClearRect();
       if (!clearRect.IsEmpty()) {
         // Clear layer's visible rect on FrameBuffer with transparent pixels
         gfx::Rect fbRect(clearRect.x, clearRect.y, clearRect.width, clearRect.height);
         compositor->ClearRect(fbRect);
         layerToRender->SetClearRect(gfx::IntRect(0, 0, 0, 0));
       }
     } else {
+      // Since we force an intermediate surface for nested 3D contexts,
+      // aGeometry and childGeometry are both in the same coordinate space.
       Maybe<gfx::Polygon> geometry =
         SelectLayerGeometry(aGeometry, childGeometry);
 
       // If we are dealing with a nested 3D context, we might need to transform
-      // the geometry to the coordinate space of the parent 3D context leaf.
-      const bool isLeafLayer = layer->AsContainerLayer() == nullptr;
+      // the geometry back to the coordinate space of the current layer before
+      // rendering the layer.
+      ContainerLayer* container = layer->AsContainerLayer();
+      const bool isLeafLayer = !container || container->UseIntermediateSurface();
 
       if (geometry && isLeafLayer) {
         TransformLayerGeometry(layer, geometry);
       }
 
       layerToRender->RenderLayer(clipRect, geometry);
     }
 
new file mode 100644
--- /dev/null
+++ b/layout/reftests/transform-3d/intermediate-1-ref.html
@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<html>
+
+<head>
+<meta charset="UTF-8">
+<style type="text/css">
+
+div {
+  position: absolute;
+  width: 100px;
+  height: 100px;
+}
+
+.opacity {
+  opacity: 0.99;
+}
+
+.green {
+  background-color: green;
+}
+
+.red {
+  width: 300px;
+  height: 100px;
+  background-color: red;
+}
+
+.translate {
+  transform: translateX(100px);
+}
+
+</style>
+</head>
+
+<body>
+<div class="red"></div>
+<div class="green">
+  <div class="translate opacity green">
+    <div class="translate green"></div>
+  </div>
+</div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/transform-3d/intermediate-1.html
@@ -0,0 +1,50 @@
+<!DOCTYPE html>
+<html>
+
+<head>
+<meta charset="UTF-8">
+<style type="text/css">
+
+div {
+  position: absolute;
+  width: 100px;
+  height: 100px;
+}
+
+.opacity {
+  opacity: 0.99;
+}
+
+.green {
+  transform-style: preserve-3d;
+  background-color: green;
+}
+
+.flat {
+  transform: translateZ(0px);
+}
+
+.red {
+  width: 300px;
+  height: 100px;
+  background-color: red;
+}
+
+.translate {
+  transform: translateX(100px);
+}
+
+</style>
+</head>
+
+<body>
+<div class="red"></div>
+<div class="green">
+  <div class="flat">
+    <div class="translate opacity green">
+      <div class="translate green"> </div>
+    </div>
+  </div>
+</div>
+</body>
+</html>
--- a/layout/reftests/transform-3d/reftest.list
+++ b/layout/reftests/transform-3d/reftest.list
@@ -83,8 +83,9 @@ fails-if(webrender) == mask-layer-1.html
 skip-if(webrender) == mask-layer-2.html mask-layer-ref.html
 skip-if(webrender) == mask-layer-3.html mask-layer-ref.html
 fails-if(webrender) == split-intersect1.html split-intersect1-ref.html
 fuzzy(255,150) fails-if(webrender) == split-intersect2.html split-intersect2-ref.html
 fuzzy(255,100) fails-if(webrender) == split-non-ortho1.html split-non-ortho1-ref.html
 fuzzy-if(winWidget,150,120) fails-if(webrender) == component-alpha-1.html component-alpha-1-ref.html
 fails-if(webrender) == nested-transform-1.html nested-transform-1-ref.html
 fails-if(webrender) == transform-geometry-1.html transform-geometry-1-ref.html
+== intermediate-1.html intermediate-1-ref.html