Bug 728284 - Main container layer has siblings that are drawn in the background. r=bgirard
authorGeorge Wright <gwright@mozilla.com>
Thu, 29 Mar 2012 14:07:45 -0400
changeset 93954 c210ff20f3711e83eeb21122f60cde7d164b42c1
parent 93953 6cb9adc02c12a0079976b7514e18243bb455ab7f
child 93955 8ecff1c072e66279ef70659f30c2bc0d0a9aa5c7
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbgirard
bugs728284
milestone14.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 728284 - Main container layer has siblings that are drawn in the background. r=bgirard
gfx/layers/ipc/CompositorParent.cpp
--- a/gfx/layers/ipc/CompositorParent.cpp
+++ b/gfx/layers/ipc/CompositorParent.cpp
@@ -216,24 +216,56 @@ CompositorParent::Composite()
 #ifdef COMPOSITOR_PERFORMANCE_WARNING
   if (mExpectedComposeTime + TimeDuration::FromMilliseconds(15) < mozilla::TimeStamp::Now()) {
     printf_stderr("Compositor: Composite took %i ms.\n",
                   15 + (int)(mozilla::TimeStamp::Now() - mExpectedComposeTime).ToMilliseconds());
   }
 #endif
 }
 
+// Go down shadow layer tree, setting properties to match their non-shadow
+// counterparts.
+static void
+SetShadowProperties(Layer* aLayer)
+{
+  // FIXME: Bug 717688 -- Do these updates in ShadowLayersParent::RecvUpdate.
+  ShadowLayer* shadow = aLayer->AsShadowLayer();
+  shadow->SetShadowTransform(aLayer->GetTransform());
+  shadow->SetShadowVisibleRegion(aLayer->GetVisibleRegion());
+  shadow->SetShadowClipRect(aLayer->GetClipRect());
+
+  for (Layer* child = aLayer->GetFirstChild();
+      child; child = child->GetNextSibling()) {
+    SetShadowProperties(child);
+  }
+}
+
 #ifdef MOZ_WIDGET_ANDROID
 // Do a breadth-first search to find the first layer in the tree that is
 // scrollable.
 Layer*
 CompositorParent::GetPrimaryScrollableLayer()
 {
   Layer* root = mLayerManager->GetRoot();
 
+  // FIXME: We're currently getting passed layers that are not part of our content, but
+  // we are drawing them anyway. This is causing severe rendering corruption to our background
+  // and checkerboarding. The real fix here is to assert that we don't have any useless layers
+  // and ensure that layout isn't giving us any. This is being tracked in bug 728284.
+  // For now just clip them to the empty rect so we don't draw them.
+  Layer* discardLayer = root->GetFirstChild();
+
+  while (discardLayer) {
+    if (!discardLayer->AsContainerLayer()) {
+      discardLayer->IntersectClipRect(nsIntRect());
+      SetShadowProperties(discardLayer);
+    }
+    discardLayer = discardLayer->GetNextSibling();
+  }
+
   nsTArray<Layer*> queue;
   queue.AppendElement(root);
   while (queue.Length()) {
     ContainerLayer* containerLayer = queue[0]->AsContainerLayer();
     queue.RemoveElementAt(0);
     if (!containerLayer) {
       continue;
     }
@@ -249,33 +281,16 @@ CompositorParent::GetPrimaryScrollableLa
       child = child->GetNextSibling();
     }
   }
 
   return root;
 }
 #endif
 
-// Go down shadow layer tree, setting properties to match their non-shadow
-// counterparts.
-static void
-SetShadowProperties(Layer* aLayer)
-{
-  // FIXME: Bug 717688 -- Do these updates in ShadowLayersParent::RecvUpdate.
-  ShadowLayer* shadow = aLayer->AsShadowLayer();
-  shadow->SetShadowTransform(aLayer->GetTransform());
-  shadow->SetShadowVisibleRegion(aLayer->GetVisibleRegion());
-  shadow->SetShadowClipRect(aLayer->GetClipRect());
-
-  for (Layer* child = aLayer->GetFirstChild();
-      child; child = child->GetNextSibling()) {
-    SetShadowProperties(child);
-  }
-}
-
 void
 CompositorParent::TransformShadowTree()
 {
 #ifdef MOZ_WIDGET_ANDROID
   Layer* layer = GetPrimaryScrollableLayer();
   ShadowLayer* shadow = layer->AsShadowLayer();
   ContainerLayer* container = layer->AsContainerLayer();