Bug 1394308 - Pass perspective transform attribute to compositor for OMTA, r?kats
MozReview-Commit-ID: EjyuCfnswqu
--- a/gfx/layers/wr/StackingContextHelper.cpp
+++ b/gfx/layers/wr/StackingContextHelper.cpp
@@ -9,28 +9,30 @@
#include "UnitTransforms.h"
#include "nsDisplayList.h"
namespace mozilla {
namespace layers {
StackingContextHelper::StackingContextHelper()
: mBuilder(nullptr)
+ , mHasPerspectiveTransform(false)
, mXScale(1.0f)
, mYScale(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)
+ , mHasPerspectiveTransform(false)
, mXScale(1.0f)
, mYScale(1.0f)
{
wr::LayoutRect scBounds = aParentSC.ToRelativeLayoutRect(aLayer->BoundsForStackingContext());
Layer* layer = aLayer->GetLayer();
mTransform = aTransform.valueOr(layer->GetTransform());
float opacity = 1.0f;
@@ -46,16 +48,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)
+ , mHasPerspectiveTransform(false)
, mXScale(1.0f)
, mYScale(1.0f)
{
wr::LayoutRect scBounds = aParentSC.ToRelativeLayoutRect(aLayer->BoundsForStackingContext());
if (aTransformPtr) {
mTransform = *aTransformPtr;
}
@@ -78,25 +81,30 @@ StackingContextHelper::StackingContextHe
gfx::Matrix4x4Typed<LayerPixel, LayerPixel>* aBoundTransform,
uint64_t aAnimationsId,
float* aOpacityPtr,
gfx::Matrix4x4* aTransformPtr,
gfx::Matrix4x4* aPerspectivePtr,
const nsTArray<wr::WrFilterOp>& aFilters,
const gfx::CompositionOp& aMixBlendMode)
: mBuilder(&aBuilder)
+ , mHasPerspectiveTransform(false)
, mXScale(1.0f)
, mYScale(1.0f)
{
nsRect visibleRect;
if (aTransformPtr) {
mTransform = *aTransformPtr;
}
+ if (aPerspectivePtr) {
+ mHasPerspectiveTransform = true;
+ }
+
bool is2d = !aTransformPtr || (aTransformPtr->Is2D() && !aPerspectivePtr);
if (is2d) {
nsRect itemBounds = aDisplayList->GetClippedBoundsWithRespectToASR(aDisplayListBuilder, aItem->GetActiveScrolledRoot());
nsRect childrenVisible = aItem->GetVisibleRectForChildren();
visibleRect = itemBounds.Intersect(childrenVisible);
// Apply the inherited scale from parent
mTransform.PostScale(aParentSC.mXScale, aParentSC.mYScale, 1.0);
--- a/gfx/layers/wr/StackingContextHelper.h
+++ b/gfx/layers/wr/StackingContextHelper.h
@@ -91,22 +91,23 @@ public:
// Provide interface to setup the inherited scale to support
// special cases, like OMTA
void SetInheritedScale(const gfx::Size& aScale) {
mXScale = aScale.width;
mYScale = aScale.height;
}
bool IsBackfaceVisible() const { return mTransform.IsBackfaceVisible(); }
+ bool HasPerspectiveTransform() const { return mHasPerspectiveTransform; }
private:
wr::DisplayListBuilder* mBuilder;
LayerPoint mOrigin;
gfx::Matrix4x4 mTransform;
-
+ bool mHasPerspectiveTransform;
float mXScale;
float mYScale;
};
} // namespace layers
} // namespace mozilla
#endif /* GFX_STACKINGCONTEXTHELPER_H */
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -7822,16 +7822,17 @@ nsDisplayTransform::CreateWebRenderComma
// Get the inheritedScale from parent and pass the scale to compositor
// to get correct sampling result
gfx::Size scale = aSc.GetInheritedScale();
for (layers::Animation& animation : animationInfo.GetAnimations()) {
if (animation.property() == eCSSProperty_transform) {
TransformData& transformData = animation.data().get_TransformData();
transformData.inheritedXScale() = scale.width;
transformData.inheritedYScale() = scale.height;
+ transformData.hasPerspectiveParent() = aSc.HasPerspectiveTransform();
}
}
// Pass default transform to compositor in case gecko fails to
// get animated value after animation sampling.
OptionalTransform transformForCompositor = newTransformMatrix;
OpAddCompositorAnimations
anim(CompositorAnimations(animationInfo.GetAnimations(), animationsId),