Bug 947781 - Part 3: Do not transmit layer types that are unshadowed over the IPDL protocol. r=nical
authorBas Schouten <bschouten@mozilla.com>
Wed, 30 Jul 2014 15:38:47 +0200
changeset 196982 881f358bc39e7393294295f9677f07c54eff93eb
parent 196981 6346e96ceac008d657c8e071ec102a7c2a8b1d0d
child 196983 9b44cf686aba2f238b892f90a0954937ce1b8663
push id27228
push usercbook@mozilla.com
push dateThu, 31 Jul 2014 10:58:52 +0000
treeherdermozilla-central@aa176fcc56b8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnical
bugs947781
milestone34.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 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();