Bug 1461849. Snapping surface transform. r=mstange
Capture a snapping surface transform. This is used
by svg/blob code to compute an fractional offset
to the nearest intermediate surface.
MozReview-Commit-ID: 6EFNvluvzvA
--- a/gfx/layers/wr/StackingContextHelper.cpp
+++ b/gfx/layers/wr/StackingContextHelper.cpp
@@ -46,16 +46,21 @@ StackingContextHelper::StackingContextHe
// Compute scale for fallback rendering. We don't try to guess a scale for 3d
// transformed items
gfx::Matrix transform2d;
if (aBoundTransform && aBoundTransform->CanDraw2D(&transform2d)
&& !aPerspectivePtr
&& !aParentSC.mIsPreserve3D) {
mInheritedTransform = transform2d * aParentSC.mInheritedTransform;
mScale = mInheritedTransform.ScaleFactors(true);
+ if (aAnimation) {
+ mSnappingSurfaceTransform = gfx::Matrix::Scaling(mScale.width, mScale.height);
+ } else {
+ mSnappingSurfaceTransform = transform2d * aParentSC.mSnappingSurfaceTransform;
+ }
} else {
mInheritedTransform = aParentSC.mInheritedTransform;
mScale = aParentSC.mScale;
}
auto rasterSpace = mRasterizeLocally
? wr::GlyphRasterSpace::Local(std::max(mScale.width, mScale.height))
: wr::GlyphRasterSpace::Screen();
--- a/gfx/layers/wr/StackingContextHelper.h
+++ b/gfx/layers/wr/StackingContextHelper.h
@@ -54,25 +54,37 @@ public:
// Export the inherited scale
gfx::Size GetInheritedScale() const { return mScale; }
const gfx::Matrix& GetInheritedTransform() const
{
return mInheritedTransform;
}
+ const gfx::Matrix& GetSnappingSurfaceTransform() const
+ {
+ return mSnappingSurfaceTransform;
+ }
+
const Maybe<gfx::Matrix4x4>& GetTransformForScrollData() const;
bool AffectsClipPositioning() const { return mAffectsClipPositioning; }
Maybe<wr::WrClipId> ReferenceFrameId() const { return mReferenceFrameId; }
private:
wr::DisplayListBuilder* mBuilder;
gfx::Size mScale;
gfx::Matrix mInheritedTransform;
+
+ // The "snapping surface" defines the space that we want to snap in.
+ // You can think of it as the nearest physical surface.
+ // Animated transforms create a new snapping surface, so that changes to their transform don't affect the snapping of their contents.
+ // Non-animated transforms do *not* create a new snapping surface,
+ // so that for example the existence of a non-animated identity transform does not affect snapping.
+ gfx::Matrix mSnappingSurfaceTransform;
bool mAffectsClipPositioning;
Maybe<wr::WrClipId> mReferenceFrameId;
Maybe<gfx::Matrix4x4> mTransformForScrollData;
bool mIsPreserve3D;
bool mRasterizeLocally;
};
} // namespace layers