Bug 1346777 - Transform layer geometry properly when intermediate surface is used. r=mattwoodrow, a=gchang
authorMiko Mynttinen <mikokm@gmail.com>
Thu, 16 Mar 2017 21:51:54 +0100
changeset 379307 da3f76b1a1a1a242bd9f06dc2871fb7feb669a3e
parent 379306 6f8b65d518c4061bceefa58c480cff4db0661a91
child 379308 c2a6c623f608de84e0904796e366cc60f83a12ed
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow, gchang
bugs1346777
milestone53.0
Bug 1346777 - Transform layer geometry properly when intermediate surface is used. r=mattwoodrow, a=gchang 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;
   }
 
@@ -441,22 +437,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 @@ fuzzy(1,10000) == opacity-preserve3d-4.h
 == mask-layer-2.html mask-layer-ref.html
 == mask-layer-3.html mask-layer-ref.html
 fails-if(winWidget&&layersGPUAccelerated) == split-intersect1.html split-intersect1-ref.html # Bug 1323791: implement DirectX compositor polygon support
 fuzzy(255,150) fails-if(winWidget&&layersGPUAccelerated) == split-intersect2.html split-intersect2-ref.html # Bug 1323791
 fuzzy(255,100) fails-if(winWidget&&layersGPUAccelerated) == split-non-ortho1.html split-non-ortho1-ref.html # Bug 1323791
 fuzzy-if(winWidget,150,120) == component-alpha-1.html component-alpha-1-ref.html
 == nested-transform-1.html nested-transform-1-ref.html
 == transform-geometry-1.html transform-geometry-1-ref.html
+== intermediate-1.html intermediate-1-ref.html