Bug 1767121 - Change the type of StackingContextHelper::mScale to MatrixScales. r=botond

Fix a minor typo while at it: "Inherrited" -> "Inherited".

Differential Revision: https://phabricator.services.mozilla.com/D146298
This commit is contained in:
Razvan Cojocaru
2022-05-19 01:45:52 +00:00
parent 47ae815793
commit 31f93c6a79
9 changed files with 92 additions and 84 deletions

View File

@@ -200,6 +200,10 @@ class BaseMatrix {
return BaseMatrix<T>(aScaleX, 0.0f, 0.0f, aScaleY, 0.0f, 0.0f); return BaseMatrix<T>(aScaleX, 0.0f, 0.0f, aScaleY, 0.0f, 0.0f);
} }
static BaseMatrix<T> Scaling(const BaseMatrixScales<T>& scale) {
return Scaling(scale.xScale, scale.yScale);
}
/** /**
* Similar to PreTranslate, but applies a scale instead of a translation. * Similar to PreTranslate, but applies a scale instead of a translation.
*/ */
@@ -212,6 +216,10 @@ class BaseMatrix {
return *this; return *this;
} }
BaseMatrix<T>& PreScale(const BaseMatrixScales<T>& scale) {
return PreScale(scale.xScale, scale.yScale);
}
/** /**
* Similar to PostTranslate, but applies a scale instead of a translation. * Similar to PostTranslate, but applies a scale instead of a translation.
*/ */

View File

@@ -163,6 +163,11 @@ struct BaseScaleFactors2D {
const ScaleFactor<Other, Dst>& aA, const BaseScaleFactors2D& aB) { const ScaleFactor<Other, Dst>& aA, const BaseScaleFactors2D& aB) {
return BaseScaleFactors2D<Other, Src, T>(aA) / aB; return BaseScaleFactors2D<Other, Src, T>(aA) / aB;
} }
static BaseScaleFactors2D<Src, Dst, T> FromUnknownScale(
const BaseScaleFactors2D<UnknownUnits, UnknownUnits, T>& scale) {
return BaseScaleFactors2D<Src, Dst, T>(scale.xScale, scale.yScale);
}
}; };
template <class Src, class Dst> template <class Src, class Dst>

View File

@@ -43,10 +43,12 @@ static nsSize ComputeDesiredDisplaySizeForAnimation(nsIFrame* aContainerFrame) {
} }
/* static */ /* static */
Size ChooseScale(nsIFrame* aContainerFrame, nsDisplayItem* aContainerItem, MatrixScales ChooseScale(nsIFrame* aContainerFrame,
const nsRect& aVisibleRect, float aXScale, float aYScale, nsDisplayItem* aContainerItem,
const Matrix& aTransform2d, bool aCanDraw2D) { const nsRect& aVisibleRect, float aXScale,
Size scale; float aYScale, const Matrix& aTransform2d,
bool aCanDraw2D) {
MatrixScales scale;
// XXX Should we do something for 3D transforms? // XXX Should we do something for 3D transforms?
if (aCanDraw2D && !aContainerFrame->Combines3DTransformWithAncestors() && if (aCanDraw2D && !aContainerFrame->Combines3DTransformWithAncestors() &&
!aContainerFrame->HasPerspective()) { !aContainerFrame->HasPerspective()) {
@@ -65,17 +67,17 @@ Size ChooseScale(nsIFrame* aContainerFrame, nsDisplayItem* aContainerItem,
// to account // to account
nsSize scaledVisibleSize = nsSize(aVisibleRect.Width() * aXScale, nsSize scaledVisibleSize = nsSize(aVisibleRect.Width() * aXScale,
aVisibleRect.Height() * aYScale); aVisibleRect.Height() * aYScale);
scale = nsLayoutUtils::ComputeSuitableScaleForAnimation( Size size = nsLayoutUtils::ComputeSuitableScaleForAnimation(
aContainerFrame, scaledVisibleSize, displaySize); aContainerFrame, scaledVisibleSize, displaySize);
scale = MatrixScales(size.width, size.height);
// multiply by the scale inherited from ancestors--we use a uniform // multiply by the scale inherited from ancestors--we use a uniform
// scale factor to prevent blurring when the layer is rotated. // scale factor to prevent blurring when the layer is rotated.
float incomingScale = std::max(aXScale, aYScale); float incomingScale = std::max(aXScale, aYScale);
scale.width *= incomingScale; scale = scale * ScaleFactor<UnknownUnits, UnknownUnits>(incomingScale);
scale.height *= incomingScale;
} else { } else {
// Scale factors are normalized to a power of 2 to reduce the number of // Scale factors are normalized to a power of 2 to reduce the number of
// resolution changes // resolution changes
scale = aTransform2d.ScaleFactors().ToSize(); scale = aTransform2d.ScaleFactors();
// For frames with a changing scale transform round scale factors up to // For frames with a changing scale transform round scale factors up to
// nearest power-of-2 boundary so that we don't keep having to redraw // nearest power-of-2 boundary so that we don't keep having to redraw
// the content as it scales up and down. Rounding up to nearest // the content as it scales up and down. Rounding up to nearest
@@ -84,8 +86,8 @@ Size ChooseScale(nsIFrame* aContainerFrame, nsDisplayItem* aContainerItem,
// 2, avoiding bad downscaling quality. // 2, avoiding bad downscaling quality.
Matrix frameTransform; Matrix frameTransform;
if (ActiveLayerTracker::IsScaleSubjectToAnimation(aContainerFrame)) { if (ActiveLayerTracker::IsScaleSubjectToAnimation(aContainerFrame)) {
scale.width = gfxUtils::ClampToScaleFactor(scale.width); scale.xScale = gfxUtils::ClampToScaleFactor(scale.xScale);
scale.height = gfxUtils::ClampToScaleFactor(scale.height); scale.yScale = gfxUtils::ClampToScaleFactor(scale.yScale);
// Limit animated scale factors to not grow excessively beyond the // Limit animated scale factors to not grow excessively beyond the
// display size. // display size.
@@ -95,11 +97,11 @@ Size ChooseScale(nsIFrame* aContainerFrame, nsDisplayItem* aContainerItem,
ComputeDesiredDisplaySizeForAnimation(aContainerFrame); ComputeDesiredDisplaySizeForAnimation(aContainerFrame);
maxScale = Max(maxScale, displaySize / aVisibleRect.Size()); maxScale = Max(maxScale, displaySize / aVisibleRect.Size());
} }
if (scale.width > maxScale.width) { if (scale.xScale > maxScale.width) {
scale.width = gfxUtils::ClampToScaleFactor(maxScale.width, true); scale.xScale = gfxUtils::ClampToScaleFactor(maxScale.width, true);
} }
if (scale.height > maxScale.height) { if (scale.yScale > maxScale.height) {
scale.height = gfxUtils::ClampToScaleFactor(maxScale.height, true); scale.yScale = gfxUtils::ClampToScaleFactor(maxScale.height, true);
} }
} else { } else {
// XXX Do we need to move nearly-integer values to integers here? // XXX Do we need to move nearly-integer values to integers here?
@@ -107,11 +109,11 @@ Size ChooseScale(nsIFrame* aContainerFrame, nsDisplayItem* aContainerItem,
} }
// If the scale factors are too small, just use 1.0. The content is being // If the scale factors are too small, just use 1.0. The content is being
// scaled out of sight anyway. // scaled out of sight anyway.
if (fabs(scale.width) < 1e-8 || fabs(scale.height) < 1e-8) { if (fabs(scale.xScale) < 1e-8 || fabs(scale.yScale) < 1e-8) {
scale = Size(1.0, 1.0); scale = MatrixScales(1.0, 1.0);
} }
} else { } else {
scale = Size(1.0, 1.0); scale = MatrixScales(1.0, 1.0);
} }
// Prevent the scale from getting too large, to avoid excessive memory // Prevent the scale from getting too large, to avoid excessive memory
@@ -119,10 +121,8 @@ Size ChooseScale(nsIFrame* aContainerFrame, nsDisplayItem* aContainerItem,
// which should be restricted to the display port. But at very large scales // which should be restricted to the display port. But at very large scales
// the visible region itself can become excessive due to rounding errors. // the visible region itself can become excessive due to rounding errors.
// Clamping the scale here prevents that. // Clamping the scale here prevents that.
scale = return MatrixScales(std::min(scale.xScale, 32768.0f),
Size(std::min(scale.width, 32768.0f), std::min(scale.height, 32768.0f)); std::min(scale.yScale, 32768.0f));
return scale;
} }
StackingContextHelper::StackingContextHelper( StackingContextHelper::StackingContextHelper(
@@ -152,17 +152,16 @@ StackingContextHelper::StackingContextHelper(
int32_t apd = aContainerFrame->PresContext()->AppUnitsPerDevPixel(); int32_t apd = aContainerFrame->PresContext()->AppUnitsPerDevPixel();
nsRect r = LayoutDevicePixel::ToAppUnits(aBounds, apd); nsRect r = LayoutDevicePixel::ToAppUnits(aBounds, apd);
mScale = ChooseScale(aContainerFrame, aContainerItem, r, mScale = ChooseScale(aContainerFrame, aContainerItem, r,
aParentSC.mScale.width, aParentSC.mScale.height, aParentSC.mScale.xScale, aParentSC.mScale.yScale,
mInheritedTransform, mInheritedTransform,
/* aCanDraw2D = */ true); /* aCanDraw2D = */ true);
} else { } else {
mScale = gfx::Size(1.0f, 1.0f); mScale = gfx::MatrixScales(1.0f, 1.0f);
mInheritedTransform = gfx::Matrix::Scaling(1.f, 1.f); mInheritedTransform = gfx::Matrix::Scaling(1.f, 1.f);
} }
if (aParams.mAnimated) { if (aParams.mAnimated) {
mSnappingSurfaceTransform = mSnappingSurfaceTransform = gfx::Matrix::Scaling(mScale);
gfx::Matrix::Scaling(mScale.width, mScale.height);
} else { } else {
mSnappingSurfaceTransform = mSnappingSurfaceTransform =
transform2d * aParentSC.mSnappingSurfaceTransform; transform2d * aParentSC.mSnappingSurfaceTransform;
@@ -173,11 +172,12 @@ StackingContextHelper::StackingContextHelper(
aContainerItem && aContainerItem &&
aContainerItem->GetType() == DisplayItemType::TYPE_ASYNC_ZOOM && aContainerItem->GetType() == DisplayItemType::TYPE_ASYNC_ZOOM &&
aContainerItem->Frame()) { aContainerItem->Frame()) {
double resolution = aContainerItem->Frame()->PresShell()->GetResolution(); float resolution = aContainerItem->Frame()->PresShell()->GetResolution();
gfx::Matrix transform = gfx::Matrix::Scaling(resolution, resolution); gfx::Matrix transform = gfx::Matrix::Scaling(resolution, resolution);
mInheritedTransform = transform * aParentSC.mInheritedTransform; mInheritedTransform = transform * aParentSC.mInheritedTransform;
mScale = resolution * aParentSC.mScale; mScale =
ScaleFactor<UnknownUnits, UnknownUnits>(resolution) * aParentSC.mScale;
MOZ_ASSERT(!aParams.mAnimated); MOZ_ASSERT(!aParams.mAnimated);
mSnappingSurfaceTransform = transform * aParentSC.mSnappingSurfaceTransform; mSnappingSurfaceTransform = transform * aParentSC.mSnappingSurfaceTransform;
@@ -198,8 +198,7 @@ StackingContextHelper::StackingContextHelper(
gfx::Matrix::Scaling(resolution.xScale, resolution.yScale); gfx::Matrix::Scaling(resolution.xScale, resolution.yScale);
mInheritedTransform = transform * aParentSC.mInheritedTransform; mInheritedTransform = transform * aParentSC.mInheritedTransform;
mScale = gfx::Size(aParentSC.mScale.width * resolution.xScale, mScale = aParentSC.mScale * resolution;
aParentSC.mScale.height * resolution.yScale);
MOZ_ASSERT(!aParams.mAnimated); MOZ_ASSERT(!aParams.mAnimated);
mSnappingSurfaceTransform = transform * aParentSC.mSnappingSurfaceTransform; mSnappingSurfaceTransform = transform * aParentSC.mSnappingSurfaceTransform;
@@ -211,7 +210,7 @@ StackingContextHelper::StackingContextHelper(
auto rasterSpace = auto rasterSpace =
mRasterizeLocally mRasterizeLocally
? wr::RasterSpace::Local(std::max(mScale.width, mScale.height)) ? wr::RasterSpace::Local(std::max(mScale.xScale, mScale.yScale))
: wr::RasterSpace::Screen(); : wr::RasterSpace::Screen();
MOZ_ASSERT(!aParams.clip.IsNone()); MOZ_ASSERT(!aParams.clip.IsNone());

View File

@@ -44,7 +44,7 @@ class MOZ_RAII StackingContextHelper {
~StackingContextHelper(); ~StackingContextHelper();
// Export the inherited scale // Export the inherited scale
gfx::Size GetInheritedScale() const { return mScale; } gfx::MatrixScales GetInheritedScale() const { return mScale; }
const gfx::Matrix& GetInheritedTransform() const { const gfx::Matrix& GetInheritedTransform() const {
return mInheritedTransform; return mInheritedTransform;
@@ -64,7 +64,7 @@ class MOZ_RAII StackingContextHelper {
private: private:
wr::DisplayListBuilder* mBuilder; wr::DisplayListBuilder* mBuilder;
gfx::Size mScale; gfx::MatrixScales mScale;
gfx::Matrix mInheritedTransform; gfx::Matrix mInheritedTransform;
LayoutDevicePoint mOrigin; LayoutDevicePoint mOrigin;

View File

@@ -306,7 +306,7 @@ struct DIGroup {
LayerIntRect mHitTestBounds; LayerIntRect mHitTestBounds;
LayerIntRect mActualBounds; LayerIntRect mActualBounds;
int32_t mAppUnitsPerDevPixel; int32_t mAppUnitsPerDevPixel;
gfx::Size mScale; gfx::MatrixScales mScale;
ScrollableLayerGuid::ViewID mScrollId; ScrollableLayerGuid::ViewID mScrollId;
CompositorHitTestInfo mHitInfo; CompositorHitTestInfo mHitInfo;
LayerPoint mResidualOffset; LayerPoint mResidualOffset;
@@ -565,7 +565,7 @@ struct DIGroup {
GP("\n\n"); GP("\n\n");
GP("Begin EndGroup\n"); GP("Begin EndGroup\n");
LayoutDeviceToLayerScale2D scale(mScale.width, mScale.height); auto scale = LayoutDeviceToLayerScale2D::FromUnknownScale(mScale);
auto hitTestRect = mVisibleRect.Intersect(ViewAs<LayerPixel>( auto hitTestRect = mVisibleRect.Intersect(ViewAs<LayerPixel>(
mHitTestBounds, PixelCastJustification::LayerIsImage)); mHitTestBounds, PixelCastJustification::LayerIsImage));
@@ -648,9 +648,8 @@ struct DIGroup {
recorder, dummyDt, mLayerBounds.ToUnknownRect()); recorder, dummyDt, mLayerBounds.ToUnknownRect());
// Setup the gfxContext // Setup the gfxContext
RefPtr<gfxContext> context = gfxContext::CreateOrNull(dt); RefPtr<gfxContext> context = gfxContext::CreateOrNull(dt);
context->SetMatrix( context->SetMatrix(Matrix::Scaling(mScale).PostTranslate(
Matrix::Scaling(mScale.width, mScale.height) mResidualOffset.x, mResidualOffset.y));
.PostTranslate(mResidualOffset.x, mResidualOffset.y));
GP("mInvalidRect: %d %d %d %d\n", mInvalidRect.x, mInvalidRect.y, GP("mInvalidRect: %d %d %d %d\n", mInvalidRect.x, mInvalidRect.y,
mInvalidRect.width, mInvalidRect.height); mInvalidRect.width, mInvalidRect.height);
@@ -1298,7 +1297,7 @@ void Grouper::ConstructGroups(nsDisplayListBuilder* aDisplayListBuilder,
// WebRender's anti-aliasing approximation is not very good under // WebRender's anti-aliasing approximation is not very good under
// non-uniform scales. // non-uniform scales.
bool uniformlyScaled = bool uniformlyScaled =
fabs(aGroup->mScale.width - aGroup->mScale.height) < 0.1; fabs(aGroup->mScale.xScale - aGroup->mScale.yScale) < 0.1;
auto activity = IsItemProbablyActive( auto activity = IsItemProbablyActive(
item, aBuilder, aResources, aSc, manager, mDisplayListBuilder, item, aBuilder, aResources, aSc, manager, mDisplayListBuilder,
@@ -1605,8 +1604,8 @@ void WebRenderCommandBuilder::DoGroupingForDisplayList(
aWrappingItem->GetUntransformedBounds(aDisplayListBuilder, &snapped); aWrappingItem->GetUntransformedBounds(aDisplayListBuilder, &snapped);
DIGroup& group = groupData->mSubGroup; DIGroup& group = groupData->mSubGroup;
gfx::Size scale = aSc.GetInheritedScale(); auto scale = aSc.GetInheritedScale();
GP("Inherrited scale %f %f\n", scale.width, scale.height); GP("Inherited scale %f %f\n", scale.xScale, scale.yScale);
auto trans = auto trans =
ViewAs<LayerPixel>(aSc.GetSnappingSurfaceTransform().GetTranslation()); ViewAs<LayerPixel>(aSc.GetSnappingSurfaceTransform().GetTranslation());
@@ -1614,14 +1613,14 @@ void WebRenderCommandBuilder::DoGroupingForDisplayList(
LayerPoint residualOffset = trans - snappedTrans; LayerPoint residualOffset = trans - snappedTrans;
auto layerBounds = auto layerBounds =
ScaleToOutsidePixelsOffset(groupBounds, scale.width, scale.height, ScaleToOutsidePixelsOffset(groupBounds, scale.xScale, scale.yScale,
appUnitsPerDevPixel, residualOffset); appUnitsPerDevPixel, residualOffset);
const nsRect& untransformedPaintRect = const nsRect& untransformedPaintRect =
aWrappingItem->GetUntransformedPaintRect(); aWrappingItem->GetUntransformedPaintRect();
auto visibleRect = ScaleToOutsidePixelsOffset( auto visibleRect = ScaleToOutsidePixelsOffset(
untransformedPaintRect, scale.width, scale.height, untransformedPaintRect, scale.xScale, scale.yScale,
appUnitsPerDevPixel, residualOffset) appUnitsPerDevPixel, residualOffset)
.Intersect(layerBounds); .Intersect(layerBounds);
@@ -1630,7 +1629,7 @@ void WebRenderCommandBuilder::DoGroupingForDisplayList(
GP("VisibleRect: %d %d %d %d\n", visibleRect.x, visibleRect.y, GP("VisibleRect: %d %d %d %d\n", visibleRect.x, visibleRect.y,
visibleRect.width, visibleRect.height); visibleRect.width, visibleRect.height);
GP("Inherrited scale %f %f\n", scale.width, scale.height); GP("Inherited scale %f %f\n", scale.xScale, scale.yScale);
group.mInvalidRect.SetEmpty(); group.mInvalidRect.SetEmpty();
if (group.mAppUnitsPerDevPixel != appUnitsPerDevPixel || if (group.mAppUnitsPerDevPixel != appUnitsPerDevPixel ||
@@ -1643,8 +1642,8 @@ void WebRenderCommandBuilder::DoGroupingForDisplayList(
} }
if (group.mScale != scale) { if (group.mScale != scale) {
GP(" Scale %f %f -> %f %f\n", group.mScale.width, group.mScale.height, GP(" Scale %f %f -> %f %f\n", group.mScale.xScale, group.mScale.yScale,
scale.width, scale.height); scale.xScale, scale.yScale);
} }
if (group.mResidualOffset != residualOffset) { if (group.mResidualOffset != residualOffset) {
@@ -1671,8 +1670,8 @@ void WebRenderCommandBuilder::DoGroupingForDisplayList(
group.mAppUnitsPerDevPixel = appUnitsPerDevPixel; group.mAppUnitsPerDevPixel = appUnitsPerDevPixel;
group.mClippedImageBounds = layerBounds; group.mClippedImageBounds = layerBounds;
g.mTransform = Matrix::Scaling(scale.width, scale.height) g.mTransform =
.PostTranslate(residualOffset.x, residualOffset.y); Matrix::Scaling(scale).PostTranslate(residualOffset.x, residualOffset.y);
group.mScale = scale; group.mScale = scale;
group.mScrollId = scrollId; group.mScrollId = scrollId;
g.ConstructGroups(aDisplayListBuilder, this, aBuilder, aResources, &group, g.ConstructGroups(aDisplayListBuilder, this, aBuilder, aResources, &group,
@@ -2282,7 +2281,7 @@ static void PaintItemByDrawTarget(nsDisplayItem* aItem, gfx::DrawTarget* aDT,
const LayoutDevicePoint& aOffset, const LayoutDevicePoint& aOffset,
const IntRect& visibleRect, const IntRect& visibleRect,
nsDisplayListBuilder* aDisplayListBuilder, nsDisplayListBuilder* aDisplayListBuilder,
const gfx::Size& aScale, const gfx::MatrixScales& aScale,
Maybe<gfx::DeviceColor>& aHighlight) { Maybe<gfx::DeviceColor>& aHighlight) {
MOZ_ASSERT(aDT); MOZ_ASSERT(aDT);
@@ -2303,9 +2302,8 @@ static void PaintItemByDrawTarget(nsDisplayItem* aItem, gfx::DrawTarget* aDT,
break; break;
} }
context->SetMatrix(context->CurrentMatrix() context->SetMatrix(context->CurrentMatrix().PreScale(aScale).PreTranslate(
.PreScale(aScale.width, aScale.height) -aOffset.x, -aOffset.y));
.PreTranslate(-aOffset.x, -aOffset.y));
if (aDisplayListBuilder->IsPaintingToWindow()) { if (aDisplayListBuilder->IsPaintingToWindow()) {
aItem->Frame()->AddStateBits(NS_FRAME_PAINTED_THEBES); aItem->Frame()->AddStateBits(NS_FRAME_PAINTED_THEBES);
} }
@@ -2430,14 +2428,14 @@ WebRenderCommandBuilder::GenerateFallbackData(
return nullptr; return nullptr;
} }
gfx::Size scale = aSc.GetInheritedScale(); MatrixScales scale = aSc.GetInheritedScale();
gfx::Size oldScale = fallbackData->mScale; MatrixScales oldScale = fallbackData->mScale;
// We tolerate slight changes in scale so that we don't, for example, // We tolerate slight changes in scale so that we don't, for example,
// rerasterize on MotionMark // rerasterize on MotionMark
bool differentScale = gfx::FuzzyEqual(scale.width, oldScale.width, 1e-6f) && bool differentScale = gfx::FuzzyEqual(scale.xScale, oldScale.xScale, 1e-6f) &&
gfx::FuzzyEqual(scale.height, oldScale.height, 1e-6f); gfx::FuzzyEqual(scale.yScale, oldScale.yScale, 1e-6f);
LayoutDeviceToLayerScale2D layerScale(scale.width, scale.height); auto layerScale = LayoutDeviceToLayerScale2D::FromUnknownScale(scale);
auto trans = auto trans =
ViewAs<LayerPixel>(aSc.GetSnappingSurfaceTransform().GetTranslation()); ViewAs<LayerPixel>(aSc.GetSnappingSurfaceTransform().GetTranslation());
@@ -2460,20 +2458,20 @@ WebRenderCommandBuilder::GenerateFallbackData(
if (aBuilder.GetInheritedOpacity() == 1.0f && if (aBuilder.GetInheritedOpacity() == 1.0f &&
opacity == wr::OpacityType::Opaque && snap) { opacity == wr::OpacityType::Opaque && snap) {
dtRect = LayerIntRect::FromUnknownRect( dtRect = LayerIntRect::FromUnknownRect(
ScaleToNearestPixelsOffset(paintBounds, scale.width, scale.height, ScaleToNearestPixelsOffset(paintBounds, scale.xScale, scale.yScale,
appUnitsPerDevPixel, residualOffset)); appUnitsPerDevPixel, residualOffset));
visibleRect = visibleRect =
LayerIntRect::FromUnknownRect( LayerIntRect::FromUnknownRect(
ScaleToNearestPixelsOffset(buildingRect, scale.width, scale.height, ScaleToNearestPixelsOffset(buildingRect, scale.xScale, scale.yScale,
appUnitsPerDevPixel, residualOffset)) appUnitsPerDevPixel, residualOffset))
.Intersect(dtRect); .Intersect(dtRect);
} else { } else {
dtRect = ScaleToOutsidePixelsOffset(paintBounds, scale.width, scale.height, dtRect = ScaleToOutsidePixelsOffset(paintBounds, scale.xScale, scale.yScale,
appUnitsPerDevPixel, residualOffset); appUnitsPerDevPixel, residualOffset);
visibleRect = visibleRect =
ScaleToOutsidePixelsOffset(buildingRect, scale.width, scale.height, ScaleToOutsidePixelsOffset(buildingRect, scale.xScale, scale.yScale,
appUnitsPerDevPixel, residualOffset) appUnitsPerDevPixel, residualOffset)
.Intersect(dtRect); .Intersect(dtRect);
} }
@@ -2701,30 +2699,30 @@ Maybe<wr::ImageMask> WebRenderCommandBuilder::BuildWrMaskImage(
const int32_t appUnitsPerDevPixel = const int32_t appUnitsPerDevPixel =
aMaskItem->Frame()->PresContext()->AppUnitsPerDevPixel(); aMaskItem->Frame()->PresContext()->AppUnitsPerDevPixel();
Size scale = aSc.GetInheritedScale(); MatrixScales scale = aSc.GetInheritedScale();
Size oldScale = maskData->mScale; MatrixScales oldScale = maskData->mScale;
// This scale determination should probably be done using // This scale determination should probably be done using
// ChooseScaleAndSetTransform but for now we just fake it. // ChooseScaleAndSetTransform but for now we just fake it.
// We tolerate slight changes in scale so that we don't, for example, // We tolerate slight changes in scale so that we don't, for example,
// rerasterize on MotionMark // rerasterize on MotionMark
bool sameScale = FuzzyEqual(scale.width, oldScale.width, 1e-6f) && bool sameScale = FuzzyEqual(scale.xScale, oldScale.xScale, 1e-6f) &&
FuzzyEqual(scale.height, oldScale.height, 1e-6f); FuzzyEqual(scale.yScale, oldScale.yScale, 1e-6f);
LayerIntRect itemRect = LayerIntRect itemRect =
LayerIntRect::FromUnknownRect(bounds.ScaleToOutsidePixels( LayerIntRect::FromUnknownRect(bounds.ScaleToOutsidePixels(
scale.width, scale.height, appUnitsPerDevPixel)); scale.xScale, scale.yScale, appUnitsPerDevPixel));
LayerIntRect visibleRect = LayerIntRect visibleRect =
LayerIntRect::FromUnknownRect( LayerIntRect::FromUnknownRect(
aMaskItem->GetBuildingRect().ScaleToOutsidePixels( aMaskItem->GetBuildingRect().ScaleToOutsidePixels(
scale.width, scale.height, appUnitsPerDevPixel)) scale.xScale, scale.yScale, appUnitsPerDevPixel))
.SafeIntersect(itemRect); .SafeIntersect(itemRect);
if (visibleRect.IsEmpty()) { if (visibleRect.IsEmpty()) {
return Nothing(); return Nothing();
} }
LayoutDeviceToLayerScale2D layerScale(scale.width, scale.height); LayoutDeviceToLayerScale2D layerScale(scale.xScale, scale.yScale);
LayoutDeviceRect imageRect = LayerRect(visibleRect) / layerScale; LayoutDeviceRect imageRect = LayerRect(visibleRect) / layerScale;
nsPoint maskOffset = aMaskItem->ToReferenceFrame() - bounds.TopLeft(); nsPoint maskOffset = aMaskItem->ToReferenceFrame() - bounds.TopLeft();
@@ -2779,7 +2777,7 @@ Maybe<wr::ImageMask> WebRenderCommandBuilder::BuildWrMaskImage(
context->SetMatrix(context->CurrentMatrix() context->SetMatrix(context->CurrentMatrix()
.PreTranslate(-itemRect.x, -itemRect.y) .PreTranslate(-itemRect.x, -itemRect.y)
.PreScale(scale.width, scale.height)); .PreScale(scale));
bool maskPainted = false; bool maskPainted = false;
bool maskIsComplete = aMaskItem->PaintMask( bool maskIsComplete = aMaskItem->PaintMask(

View File

@@ -113,7 +113,8 @@ bool WebRenderLayerManager::Initialize(
if (textureFactoryIdentifier.mParentBackend == LayersBackend::LAYERS_NONE || if (textureFactoryIdentifier.mParentBackend == LayersBackend::LAYERS_NONE ||
idNamespace.isNothing()) { idNamespace.isNothing()) {
gfxCriticalNote << "Failed to connect WebRenderBridgeChild. isParent=" << XRE_IsParentProcess(); gfxCriticalNote << "Failed to connect WebRenderBridgeChild. isParent="
<< XRE_IsParentProcess();
aError.Append(hasInitialized ? "_POST"_ns : "_FIRST"_ns); aError.Append(hasInitialized ? "_POST"_ns : "_FIRST"_ns);
return false; return false;
} }

View File

@@ -269,7 +269,7 @@ class WebRenderFallbackData : public WebRenderUserData {
DisplayItemClip mClip; DisplayItemClip mClip;
nsRect mBounds; nsRect mBounds;
nsRect mBuildingRect; nsRect mBuildingRect;
gfx::Size mScale; gfx::MatrixScales mScale;
float mOpacity; float mOpacity;
protected: protected:
@@ -376,7 +376,7 @@ class WebRenderMaskData : public WebRenderUserData {
LayerIntRect mItemRect; LayerIntRect mItemRect;
nsPoint mMaskOffset; nsPoint mMaskOffset;
nsStyleImageLayers mMaskStyle; nsStyleImageLayers mMaskStyle;
gfx::Size mScale; gfx::MatrixScales mScale;
bool mShouldHandleOpacity; bool mShouldHandleOpacity;
}; };

View File

@@ -6507,9 +6507,9 @@ CSSIntSize nsLayoutUtils::ComputeSizeForDrawingWithFallback(
return imageSize; return imageSize;
} }
/* static */ LayerIntRect SnapRectForImage(const gfx::Matrix& aTransform, /* static */ LayerIntRect SnapRectForImage(
const gfx::Size& aScaleFactors, const gfx::Matrix& aTransform, const gfx::MatrixScales& aScaleFactors,
const LayoutDeviceRect& aRect) { const LayoutDeviceRect& aRect) {
// Attempt to snap pixels, the same as ComputeSnappedImageDrawingParameters. // Attempt to snap pixels, the same as ComputeSnappedImageDrawingParameters.
// Any changes to the algorithm here will need to be reflected there. // Any changes to the algorithm here will need to be reflected there.
bool snapped = false; bool snapped = false;
@@ -6543,10 +6543,8 @@ CSSIntSize nsLayoutUtils::ComputeSizeForDrawingWithFallback(
if (!snapped) { if (!snapped) {
// If we couldn't snap directly with the transform, we need to go best // If we couldn't snap directly with the transform, we need to go best
// effort in layer pixels. // effort in layer pixels.
snapRect = RoundedToInt(LayerRect(aRect.X() * aScaleFactors.width, snapRect = RoundedToInt(
aRect.Y() * aScaleFactors.height, aRect * LayoutDeviceToLayerScale2D::FromUnknownScale(aScaleFactors));
aRect.Width() * aScaleFactors.width,
aRect.Height() * aScaleFactors.height));
} }
// An empty size is unacceptable so we ensure our suggested size is at least // An empty size is unacceptable so we ensure our suggested size is at least
@@ -6569,14 +6567,14 @@ IntSize nsLayoutUtils::ComputeImageContainerDrawingParameters(
MOZ_ASSERT(aImage); MOZ_ASSERT(aImage);
MOZ_ASSERT(aForFrame); MOZ_ASSERT(aForFrame);
gfx::Size scaleFactors = aSc.GetInheritedScale(); MatrixScales scaleFactors = aSc.GetInheritedScale();
SamplingFilter samplingFilter = SamplingFilter samplingFilter =
nsLayoutUtils::GetSamplingFilterForFrame(aForFrame); nsLayoutUtils::GetSamplingFilterForFrame(aForFrame);
// Compute our SVG context parameters, if any. Don't replace the viewport // Compute our SVG context parameters, if any. Don't replace the viewport
// size if it was already set, prefer what the caller gave. // size if it was already set, prefer what the caller gave.
SVGImageContext::MaybeStoreContextPaint(aSVGContext, aForFrame, aImage); SVGImageContext::MaybeStoreContextPaint(aSVGContext, aForFrame, aImage);
if ((scaleFactors.width != 1.0 || scaleFactors.height != 1.0) && if ((scaleFactors.xScale != 1.0 || scaleFactors.yScale != 1.0) &&
aImage->GetType() == imgIContainer::TYPE_VECTOR && aImage->GetType() == imgIContainer::TYPE_VECTOR &&
(!aSVGContext || !aSVGContext->GetViewportSize())) { (!aSVGContext || !aSVGContext->GetViewportSize())) {
gfxSize gfxDestSize(aDestRect.Width(), aDestRect.Height()); gfxSize gfxDestSize(aDestRect.Width(), aDestRect.Height());

View File

@@ -1360,7 +1360,7 @@ bool nsDisplayRemote::CreateWebRenderCommands(
visibleRect -= destRect.TopLeft(); visibleRect -= destRect.TopLeft();
// Generate an effects update notifying the browser it is visible // Generate an effects update notifying the browser it is visible
gfx::Size scale = aSc.GetInheritedScale(); MatrixScales scale = aSc.GetInheritedScale();
ParentLayerToScreenScale2D transformToAncestorScale = ParentLayerToScreenScale2D transformToAncestorScale =
ParentLayerToParentLayerScale( ParentLayerToParentLayerScale(
@@ -1370,9 +1370,8 @@ bool nsDisplayRemote::CreateWebRenderCommands(
mFrame); mFrame);
aDisplayListBuilder->AddEffectUpdate( aDisplayListBuilder->AddEffectUpdate(
remoteBrowser, remoteBrowser, EffectsInfo::VisibleWithinRect(
EffectsInfo::VisibleWithinRect(visibleRect, {scale.width, scale.height}, visibleRect, scale, transformToAncestorScale));
transformToAncestorScale));
// Create a WebRenderRemoteData to notify the RemoteBrowser when it is no // Create a WebRenderRemoteData to notify the RemoteBrowser when it is no
// longer visible // longer visible