Bug 947781 - Part 3: Do not transmit layer types that are unshadowed over the IPDL protocol. r=nical
☠☠ backed out by ba00ca45db46 ☠ ☠
authorBas Schouten <bschouten@mozilla.com>
Wed, 30 Jul 2014 15:38:47 +0200
changeset 196853 c378df3604697cd38115698e128fd6dc3cef6359
parent 196852 c4ecea1452e96da0fab861f690b68e3c996d5b06
child 196854 96379f1784859959c1805f3e3b7ebb0990680180
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersnical
bugs947781
milestone34.0a1
Bug 947781 - Part 3: Do not transmit layer types that are unshadowed over the IPDL protocol. r=nical
gfx/layers/ipc/ShadowLayers.cpp
--- a/gfx/layers/ipc/ShadowLayers.cpp
+++ b/gfx/layers/ipc/ShadowLayers.cpp
@@ -248,39 +248,60 @@ ShadowLayerForwarder::SetRoot(Shadowable
 {
   mTxn->AddEdit(OpSetRoot(nullptr, Shadow(aRoot)));
 }
 void
 ShadowLayerForwarder::InsertAfter(ShadowableLayer* aContainer,
                                   ShadowableLayer* aChild,
                                   ShadowableLayer* aAfter)
 {
-  if (aAfter)
+  if (!aChild->HasShadow()) {
+    return;
+  }
+
+  while (aAfter && !aAfter->HasShadow()) {
+    aAfter = aAfter->AsLayer()->GetPrevSibling() ? aAfter->AsLayer()->GetPrevSibling()->AsShadowableLayer() : nullptr;
+  }
+
+  if (aAfter) {
     mTxn->AddEdit(OpInsertAfter(nullptr, Shadow(aContainer),
                                 nullptr, Shadow(aChild),
                                 nullptr, Shadow(aAfter)));
-  else
+  } else {
     mTxn->AddEdit(OpPrependChild(nullptr, Shadow(aContainer),
                                  nullptr, Shadow(aChild)));
+  }
 }
 void
 ShadowLayerForwarder::RemoveChild(ShadowableLayer* aContainer,
                                   ShadowableLayer* aChild)
 {
   MOZ_LAYERS_LOG(("[LayersForwarder] OpRemoveChild container=%p child=%p\n",
                   aContainer->AsLayer(), aChild->AsLayer()));
 
+  if (!aChild->HasShadow()) {
+    return;
+  }
+
   mTxn->AddEdit(OpRemoveChild(nullptr, Shadow(aContainer),
                               nullptr, Shadow(aChild)));
 }
 void
 ShadowLayerForwarder::RepositionChild(ShadowableLayer* aContainer,
                                       ShadowableLayer* aChild,
                                       ShadowableLayer* aAfter)
 {
+  if (!aChild->HasShadow()) {
+    return;
+  }
+
+  while (aAfter && !aAfter->HasShadow()) {
+    aAfter = aAfter->AsLayer()->GetPrevSibling() ? aAfter->AsLayer()->GetPrevSibling()->AsShadowableLayer() : nullptr;
+  }
+
   if (aAfter) {
     MOZ_LAYERS_LOG(("[LayersForwarder] OpRepositionChild container=%p child=%p after=%p",
                    aContainer->AsLayer(), aChild->AsLayer(), aAfter->AsLayer()));
     mTxn->AddEdit(OpRepositionChild(nullptr, Shadow(aContainer),
                                     nullptr, Shadow(aChild),
                                     nullptr, Shadow(aAfter)));
   } else {
     MOZ_LAYERS_LOG(("[LayersForwarder] OpRaiseToTopChild container=%p child=%p",
@@ -499,16 +520,20 @@ ShadowLayerForwarder::EndTransaction(Inf
   // We purposely add attribute-change ops to the final changeset
   // before we add paint ops.  This allows layers to record the
   // attribute changes before new pixels arrive, which can be useful
   // for setting up back/front buffers.
   RenderTraceScope rendertrace2("Foward Transaction", "000092");
   for (ShadowableLayerSet::const_iterator it = mTxn->mMutants.begin();
        it != mTxn->mMutants.end(); ++it) {
     ShadowableLayer* shadow = *it;
+
+    if (!shadow->HasShadow()) {
+      continue;
+    }
     Layer* mutant = shadow->AsLayer();
     NS_ABORT_IF_FALSE(!!mutant, "unshadowable layer?");
 
     LayerAttributes attrs;
     CommonLayerAttributes& common = attrs.common();
     common.visibleRegion() = mutant->GetVisibleRegion();
     common.eventRegions() = mutant->GetEventRegions();
     common.postXScale() = mutant->GetPostXScale();