Bug 1359842 - Remove if/else branch in WebRenderContainerLayer so it goes through a single PushStackingContext call. r?nical draft
authorKartikaya Gupta <kgupta@mozilla.com>
Wed, 26 Apr 2017 16:37:16 -0400
changeset 568974 2a87c0e57690892498f96bd0543ae99870dcfa1d
parent 568973 fca7f45a1451d0bc8bea569642a1e144fbdb04f5
child 568975 d2ee3c4f7d03db2c63d3440ccfe627270c0ed916
push id56034
push userkgupta@mozilla.com
push dateWed, 26 Apr 2017 20:37:45 +0000
reviewersnical
bugs1359842
milestone55.0a1
Bug 1359842 - Remove if/else branch in WebRenderContainerLayer so it goes through a single PushStackingContext call. r?nical This is functionally equivalent since one variant of the PushStackingContext was already delegating to the other (in DisplayListBuilder). MozReview-Commit-ID: 8PfMm3bHeSZ
gfx/layers/wr/WebRenderContainerLayer.cpp
--- a/gfx/layers/wr/WebRenderContainerLayer.cpp
+++ b/gfx/layers/wr/WebRenderContainerLayer.cpp
@@ -15,17 +15,20 @@ namespace mozilla {
 namespace layers {
 
 void
 WebRenderContainerLayer::RenderLayer(wr::DisplayListBuilder& aBuilder)
 {
   nsTArray<LayerPolygon> children = SortChildrenBy3DZOrder(SortMode::WITHOUT_GEOMETRY);
 
   gfx::Matrix4x4 transform = GetTransform();
+  gfx::Matrix4x4* maybeTransform = &transform;
   float opacity = GetLocalOpacity();
+  float* maybeOpacity = &opacity;
+  uint64_t animationsId = 0;
   LayerRect relBounds = GetWrRelBounds();
   gfx::Rect clip(0, 0, relBounds.width, relBounds.height);
 
   Maybe<WrImageMask> mask = BuildWrMaskLayer(true);
 
   wr::MixBlendMode mixBlendMode = wr::ToWrMixBlendMode(GetMixBlendMode());
 
   if (gfxPrefs::LayersDump()) {
@@ -36,34 +39,34 @@ WebRenderContainerLayer::RenderLayer(wr:
                   Stringify(transform).c_str(),
                   Stringify(mixBlendMode).c_str());
   }
 
   if (gfxPrefs::WebRenderOMTAEnabled() &&
       GetAnimations().Length()) {
     MOZ_ASSERT(GetCompositorAnimationsId());
 
+    animationsId = GetCompositorAnimationsId();
     CompositorAnimations anim;
     anim.animations() = GetAnimations();
-    anim.id() = GetCompositorAnimationsId();
+    anim.id() = animationsId;
     WrBridge()->AddWebRenderParentCommand(OpAddCompositorAnimations(anim));
 
-    float* maybeOpacity = HasOpacityAnimation() ? nullptr : &opacity;
-    gfx::Matrix4x4* maybeTransform = HasTransformAnimation() ? nullptr : &transform;
-    aBuilder.PushStackingContext(wr::ToWrRect(relBounds),
-                                 GetCompositorAnimationsId(),
-                                 maybeOpacity,
-                                 maybeTransform,
-                                 mixBlendMode);
-  } else {
-    aBuilder.PushStackingContext(wr::ToWrRect(relBounds),
-                                 opacity,
-                                 transform,
-                                 mixBlendMode);
+    if (!HasOpacityAnimation()) {
+      maybeOpacity = nullptr;
+    }
+    if (!HasTransformAnimation()) {
+      maybeTransform = nullptr;
+    }
   }
+  aBuilder.PushStackingContext(wr::ToWrRect(relBounds),
+                               animationsId,
+                               maybeOpacity,
+                               maybeTransform,
+                               mixBlendMode);
 
   aBuilder.PushClip(wr::ToWrRect(clip),
                     mask.ptrOr(nullptr));
 
   for (LayerPolygon& child : children) {
     if (child.layer->IsBackfaceHidden()) {
       continue;
     }