Bug 1363998 - Part1. Correct the coordinate space of webrender mask layer. r=kats
authorEthan Lin <ethlin@mozilla.com>
Thu, 18 May 2017 17:40:18 +0800
changeset 359331 4a6a63235aab20c5c2d65cc9abf01ed53a7c9234
parent 359330 afdc70d42052ec3b061ecc0378e4d3b0b32a6263
child 359332 b821901e8fad581f5714362c7a480b96c5384381
push id31852
push userkwierso@gmail.com
push dateFri, 19 May 2017 21:47:27 +0000
treeherdermozilla-central@979f11deabd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs1363998
milestone55.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 1363998 - Part1. Correct the coordinate space of webrender mask layer. r=kats
gfx/layers/wr/StackingContextHelper.cpp
gfx/layers/wr/StackingContextHelper.h
gfx/layers/wr/WebRenderLayer.cpp
--- a/gfx/layers/wr/StackingContextHelper.cpp
+++ b/gfx/layers/wr/StackingContextHelper.cpp
@@ -19,18 +19,16 @@ StackingContextHelper::StackingContextHe
 
 StackingContextHelper::StackingContextHelper(const StackingContextHelper& aParentSC,
                                              wr::DisplayListBuilder& aBuilder,
                                              WebRenderLayer* aLayer,
                                              const Maybe<gfx::Matrix4x4>& aTransform)
   : mBuilder(&aBuilder)
 {
   WrRect scBounds = aParentSC.ToRelativeWrRect(aLayer->BoundsForStackingContext());
-  mOffsetToParent.x = scBounds.x;
-  mOffsetToParent.y = scBounds.y;
   Layer* layer = aLayer->GetLayer();
   mTransform = aTransform.valueOr(layer->GetTransform());
   mBuilder->PushStackingContext(scBounds,
                                 1.0f,
                                 mTransform,
                                 wr::ToWrMixBlendMode(layer->GetMixBlendMode()));
   mOrigin = aLayer->Bounds().TopLeft();
 }
@@ -39,18 +37,16 @@ StackingContextHelper::StackingContextHe
                                              wr::DisplayListBuilder& aBuilder,
                                              WebRenderLayer* aLayer,
                                              uint64_t aAnimationsId,
                                              float* aOpacityPtr,
                                              gfx::Matrix4x4* aTransformPtr)
   : mBuilder(&aBuilder)
 {
   WrRect scBounds = aParentSC.ToRelativeWrRect(aLayer->BoundsForStackingContext());
-  mOffsetToParent.x = scBounds.x;
-  mOffsetToParent.y = scBounds.y;
   if (aTransformPtr) {
     mTransform = *aTransformPtr;
   }
   mBuilder->PushStackingContext(scBounds,
                                 aAnimationsId,
                                 aOpacityPtr,
                                 aTransformPtr,
                                 wr::ToWrMixBlendMode(aLayer->GetLayer()->GetMixBlendMode()));
@@ -84,17 +80,17 @@ StackingContextHelper::ToRelativeWrPoint
 
 WrRect
 StackingContextHelper::ToRelativeWrRectRounded(const LayoutDeviceRect& aRect) const
 {
   return wr::ToWrRect(RoundedToInt(ViewAs<LayerPixel>(aRect, PixelCastJustification::WebRenderHasUnitResolution) - mOrigin));
 }
 
 gfx::Matrix4x4
-StackingContextHelper::TransformToParentSC() const
+StackingContextHelper::TransformToRoot() const
 {
   gfx::Matrix4x4 inv = mTransform.Inverse();
-  inv.PostTranslate(-mOffsetToParent.x, -mOffsetToParent.y, 0);
+  inv.PostTranslate(-mOrigin.x, -mOrigin.y, 0);
   return inv;
 }
 
 } // namespace layers
 } // namespace mozilla
--- a/gfx/layers/wr/StackingContextHelper.h
+++ b/gfx/layers/wr/StackingContextHelper.h
@@ -60,22 +60,21 @@ public:
   WrRect ToRelativeWrRect(const LayerRect& aRect) const;
   WrRect ToRelativeWrRect(const LayoutDeviceRect& aRect) const;
   // Same but for points
   WrPoint ToRelativeWrPoint(const LayerPoint& aPoint) const;
   // Same but rounds the rectangle to ints after transforming.
   WrRect ToRelativeWrRectRounded(const LayoutDeviceRect& aRect) const;
 
   // Produce a transform that converts points from the coordinate space of this
-  // stacking context to the coordinate space of the parent stacking context.
-  gfx::Matrix4x4 TransformToParentSC() const;
+  // stacking context to the coordinate space of the root of the layer tree.
+  gfx::Matrix4x4 TransformToRoot() const;
 
 private:
   wr::DisplayListBuilder* mBuilder;
   LayerPoint mOrigin;
-  WrPoint mOffsetToParent;
   gfx::Matrix4x4 mTransform;
 };
 
 } // namespace layers
 } // namespace mozilla
 
 #endif /* GFX_STACKINGCONTEXTHELPER_H */
--- a/gfx/layers/wr/WebRenderLayer.cpp
+++ b/gfx/layers/wr/WebRenderLayer.cpp
@@ -47,17 +47,17 @@ WebRenderLayer::BuildWrMaskLayer(const S
     WebRenderLayer* maskLayer = ToWebRenderLayer(GetLayer()->GetMaskLayer());
 
     // If |this| layer is pushing a stacking context, that should be passed in
     // as |aUnapplySc|. We need to unapply the transform from that stacking
     // context because the mask layer (according to WR) is outside that stacking
     // context.
     gfx::Matrix4x4 transform = maskLayer->GetLayer()->GetTransform();
     if (aUnapplySc) {
-      transform = transform * aUnapplySc->TransformToParentSC();
+      transform = transform * aUnapplySc->TransformToRoot();
     }
 
     return maskLayer->RenderMaskLayer(transform);
   }
 
   return Nothing();
 }