Bug 1395501 - Part1. Store inherited scale in stacking context. r=jrmuizel,kats
MozReview-Commit-ID: 6LsTJa05uFV
--- a/gfx/layers/wr/StackingContextHelper.cpp
+++ b/gfx/layers/wr/StackingContextHelper.cpp
@@ -9,26 +9,28 @@
#include "UnitTransforms.h"
#include "nsDisplayList.h"
namespace mozilla {
namespace layers {
StackingContextHelper::StackingContextHelper()
: mBuilder(nullptr)
+ , mScale(1.0f, 1.0f)
{
// mOrigin remains at 0,0
}
StackingContextHelper::StackingContextHelper(const StackingContextHelper& aParentSC,
wr::DisplayListBuilder& aBuilder,
WebRenderLayer* aLayer,
const Maybe<gfx::Matrix4x4>& aTransform,
const nsTArray<wr::WrFilterOp>& aFilters)
: mBuilder(&aBuilder)
+ , mScale(1.0f, 1.0f)
{
wr::LayoutRect scBounds = aParentSC.ToRelativeLayoutRect(aLayer->BoundsForStackingContext());
Layer* layer = aLayer->GetLayer();
mTransform = aTransform.valueOr(layer->GetTransform());
float opacity = 1.0f;
mBuilder->PushStackingContext(scBounds, 0, &opacity,
mTransform.IsIdentity() ? nullptr : &mTransform,
@@ -43,16 +45,17 @@ StackingContextHelper::StackingContextHe
StackingContextHelper::StackingContextHelper(const StackingContextHelper& aParentSC,
wr::DisplayListBuilder& aBuilder,
WebRenderLayer* aLayer,
uint64_t aAnimationsId,
float* aOpacityPtr,
gfx::Matrix4x4* aTransformPtr,
const nsTArray<wr::WrFilterOp>& aFilters)
: mBuilder(&aBuilder)
+ , mScale(1.0f, 1.0f)
{
wr::LayoutRect scBounds = aParentSC.ToRelativeLayoutRect(aLayer->BoundsForStackingContext());
if (aTransformPtr) {
mTransform = *aTransformPtr;
}
mBuilder->PushStackingContext(scBounds,
aAnimationsId,
@@ -66,31 +69,38 @@ StackingContextHelper::StackingContextHe
mOrigin = aLayer->Bounds().TopLeft();
}
StackingContextHelper::StackingContextHelper(const StackingContextHelper& aParentSC,
wr::DisplayListBuilder& aBuilder,
nsDisplayListBuilder* aDisplayListBuilder,
nsDisplayItem* aItem,
nsDisplayList* aDisplayList,
- gfx::Matrix4x4Typed<LayerPixel, LayerPixel>* aBoundTransform,
+ const gfx::Matrix4x4* aBoundTransform,
uint64_t aAnimationsId,
float* aOpacityPtr,
gfx::Matrix4x4* aTransformPtr,
gfx::Matrix4x4* aPerspectivePtr,
const nsTArray<wr::WrFilterOp>& aFilters,
const gfx::CompositionOp& aMixBlendMode,
bool aBackfaceVisible)
: mBuilder(&aBuilder)
+ , mScale(1.0f, 1.0f)
{
bool is2d = !aTransformPtr || (aTransformPtr->Is2D() && !aPerspectivePtr);
if (aTransformPtr) {
mTransform = *aTransformPtr;
}
+ // Compute scale for fallback rendering.
+ Matrix transform2d;
+ if (aBoundTransform && aBoundTransform->CanDraw2D(&transform2d)) {
+ mScale = transform2d.ScaleFactors(true) * aParentSC.mScale;
+ }
+
mBuilder->PushStackingContext(wr::LayoutRect(),
aAnimationsId,
aOpacityPtr,
aTransformPtr,
is2d ? wr::TransformStyle::Flat : wr::TransformStyle::Preserve3D,
aPerspectivePtr,
wr::ToMixBlendMode(aMixBlendMode),
aFilters,
--- a/gfx/layers/wr/StackingContextHelper.h
+++ b/gfx/layers/wr/StackingContextHelper.h
@@ -47,17 +47,17 @@ public:
gfx::Matrix4x4* aTransformPtr,
const nsTArray<wr::WrFilterOp>& aFilters = nsTArray<wr::WrFilterOp>());
// The constructor for layers-free mode.
StackingContextHelper(const StackingContextHelper& aParentSC,
wr::DisplayListBuilder& aBuilder,
nsDisplayListBuilder* aDisplayListBuilder,
nsDisplayItem* aItem,
nsDisplayList* aDisplayList,
- gfx::Matrix4x4Typed<LayerPixel, LayerPixel>* aBoundTransform,
+ const gfx::Matrix4x4* aBoundTransform,
uint64_t aAnimationsId,
float* aOpacityPtr,
gfx::Matrix4x4* aTransformPtr,
gfx::Matrix4x4* aPerspectivePtr = nullptr,
const nsTArray<wr::WrFilterOp>& aFilters = nsTArray<wr::WrFilterOp>(),
const gfx::CompositionOp& aMixBlendMode = gfx::CompositionOp::OP_OVER,
bool aBackfaceVisible = true);
// This version of the constructor should only be used at the root level
@@ -81,20 +81,24 @@ public:
// same as the layer space. (TODO: try to make this more explicit somehow).
// We also round the rectangle to ints after transforming since the output
// is the final destination rect.
wr::LayoutRect ToRelativeLayoutRect(const LayerRect& aRect) const;
wr::LayoutRect ToRelativeLayoutRect(const LayoutDeviceRect& aRect) const;
// Same but for points
wr::LayoutPoint ToRelativeLayoutPoint(const LayerPoint& aPoint) const;
+ // Export the inherited scale
+ gfx::Size GetInheritedScale() const { return mScale; }
+
bool IsBackfaceVisible() const { return mTransform.IsBackfaceVisible(); }
private:
wr::DisplayListBuilder* mBuilder;
LayerPoint mOrigin;
gfx::Matrix4x4 mTransform;
+ gfx::Size mScale;
};
} // namespace layers
} // namespace mozilla
#endif /* GFX_STACKINGCONTEXTHELPER_H */
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -8058,25 +8058,23 @@ nsDisplayTransform::CreateWebRenderComma
transformForCompositor, void_t());
aManager->WrBridge()->AddWebRenderParentCommand(anim);
aManager->AddActiveCompositorAnimationId(animationsId);
} else if (animationsId) {
aManager->AddCompositorAnimationsIdForDiscard(animationsId);
animationsId = 0;
}
- gfx::Matrix4x4Typed<LayerPixel, LayerPixel> boundTransform = ViewAs<gfx::Matrix4x4Typed<LayerPixel, LayerPixel>>(newTransformMatrix);
-
nsTArray<mozilla::wr::WrFilterOp> filters;
StackingContextHelper sc(aSc,
aBuilder,
aDisplayListBuilder,
this,
mStoredList.GetChildren(),
- &boundTransform,
+ &newTransformMatrix,
animationsId,
nullptr,
transformForSC,
nullptr,
filters,
gfx::CompositionOp::OP_OVER,
!BackfaceIsHidden());