Bug 1733313 - Change EffectsInfo::mScaleX/Y into a Scale2D and rename to mRasterScale. r=botond

Differential Revision: https://phabricator.services.mozilla.com/D144274
This commit is contained in:
Razvan Cojocaru 2022-04-26 03:12:38 +00:00
Родитель d6b4fc6e92
Коммит 9788952c5a
6 изменённых файлов: 22 добавлений и 27 удалений

Просмотреть файл

@ -22,18 +22,17 @@ class EffectsInfo {
EffectsInfo() { *this = EffectsInfo::FullyHidden(); }
static EffectsInfo VisibleWithinRect(
const nsRect& aVisibleRect, float aScaleX, float aScaleY,
const nsRect& aVisibleRect, const Scale2D& aRasterScale,
const ParentLayerToScreenScale2D& aTransformToAncestorScale) {
return EffectsInfo{aVisibleRect, aScaleX, aScaleY,
aTransformToAncestorScale};
return EffectsInfo{aVisibleRect, aRasterScale, aTransformToAncestorScale};
}
static EffectsInfo FullyHidden() {
return EffectsInfo{nsRect(), 1.0f, 1.0f, ParentLayerToScreenScale2D()};
return EffectsInfo{nsRect(), Scale2D(), ParentLayerToScreenScale2D()};
}
bool operator==(const EffectsInfo& aOther) {
return mVisibleRect == aOther.mVisibleRect && mScaleX == aOther.mScaleX &&
mScaleY == aOther.mScaleY &&
return mVisibleRect == aOther.mVisibleRect &&
mRasterScale == aOther.mRasterScale &&
mTransformToAncestorScale == aOther.mTransformToAncestorScale;
}
bool operator!=(const EffectsInfo& aOther) { return !(*this == aOther); }
@ -46,8 +45,7 @@ class EffectsInfo {
// The desired scale factors to apply to rasterized content to match
// transforms applied in ancestor browsers. This gets propagated into the
// scale in StackingContextHelper.
float mScaleX;
float mScaleY;
Scale2D mRasterScale;
// TransformToAncestorScale to be set on FrameMetrics. It includes CSS
// transform scales and cumulative presshell resolution.
ParentLayerToScreenScale2D mTransformToAncestorScale;
@ -62,11 +60,10 @@ class EffectsInfo {
// TabMessageUtils.
private:
EffectsInfo(const nsRect& aVisibleRect, float aScaleX, float aScaleY,
EffectsInfo(const nsRect& aVisibleRect, const Scale2D& aRasterScale,
const ParentLayerToScreenScale2D& aTransformToAncestorScale)
: mVisibleRect(aVisibleRect),
mScaleX(aScaleX),
mScaleY(aScaleY),
mRasterScale(aRasterScale),
mTransformToAncestorScale(aTransformToAncestorScale) {}
};

Просмотреть файл

@ -66,15 +66,13 @@ struct ParamTraits<mozilla::dom::EffectsInfo> {
static void Write(MessageWriter* aWriter, const paramType& aParam) {
WriteParam(aWriter, aParam.mVisibleRect);
WriteParam(aWriter, aParam.mScaleX);
WriteParam(aWriter, aParam.mScaleY);
WriteParam(aWriter, aParam.mRasterScale);
WriteParam(aWriter, aParam.mTransformToAncestorScale);
}
static bool Read(MessageReader* aReader, paramType* aResult) {
return ReadParam(aReader, &aResult->mVisibleRect) &&
ReadParam(aReader, &aResult->mScaleX) &&
ReadParam(aReader, &aResult->mScaleY) &&
ReadParam(aReader, &aResult->mRasterScale) &&
ReadParam(aReader, &aResult->mTransformToAncestorScale);
}
};

Просмотреть файл

@ -185,22 +185,21 @@ StackingContextHelper::StackingContextHelper(
} else if (!aAsr && !aContainerFrame && !aContainerItem &&
aParams.mRootReferenceFrame) {
// this is the root stacking context helper
float resolutionX = 1.f;
float resolutionY = 1.f;
Scale2D resolution;
// If we are in a remote browser, then apply scaling from ancestor browsers
if (mozilla::dom::BrowserChild* browserChild =
mozilla::dom::BrowserChild::GetFrom(
aParams.mRootReferenceFrame->PresShell())) {
resolutionX *= browserChild->GetEffectsInfo().mScaleX;
resolutionY *= browserChild->GetEffectsInfo().mScaleY;
resolution = browserChild->GetEffectsInfo().mRasterScale;
}
gfx::Matrix transform = gfx::Matrix::Scaling(resolutionX, resolutionY);
gfx::Matrix transform =
gfx::Matrix::Scaling(resolution.xScale, resolution.yScale);
mInheritedTransform = transform * aParentSC.mInheritedTransform;
mScale = gfx::Size(aParentSC.mScale.width * resolutionX,
aParentSC.mScale.height * resolutionY);
mScale = gfx::Size(aParentSC.mScale.width * resolution.xScale,
aParentSC.mScale.height * resolution.yScale);
MOZ_ASSERT(!aParams.mAnimated);
mSnappingSurfaceTransform = transform * aParentSC.mSnappingSurfaceTransform;

Просмотреть файл

@ -1086,8 +1086,10 @@ void nsImageFrame::MaybeDecodeForPredictedSize() {
// If we are in a remote browser, then apply scaling from ancestor browsers
if (BrowserChild* browserChild = BrowserChild::GetFrom(presShell)) {
resolutionToScreen.xScale *= browserChild->GetEffectsInfo().mScaleX;
resolutionToScreen.yScale *= browserChild->GetEffectsInfo().mScaleY;
resolutionToScreen.xScale *=
browserChild->GetEffectsInfo().mRasterScale.xScale;
resolutionToScreen.yScale *=
browserChild->GetEffectsInfo().mRasterScale.yScale;
}
// ...and this frame's content box...

Просмотреть файл

@ -1371,7 +1371,7 @@ bool nsDisplayRemote::CreateWebRenderCommands(
aDisplayListBuilder->AddEffectUpdate(
remoteBrowser,
EffectsInfo::VisibleWithinRect(visibleRect, scale.width, scale.height,
EffectsInfo::VisibleWithinRect(visibleRect, {scale.width, scale.height},
transformToAncestorScale));
// Create a WebRenderRemoteData to notify the RemoteBrowser when it is no

Просмотреть файл

@ -775,8 +775,7 @@ void nsDisplayListBuilder::AddEffectUpdate(dom::RemoteBrowser* aBrowser,
Maybe<dom::EffectsInfo> existing = mEffectsUpdates.MaybeGet(aBrowser);
if (existing.isSome()) {
// Only the visible rect should differ, the scales should match.
MOZ_ASSERT(existing->mScaleX == aUpdate.mScaleX &&
existing->mScaleY == aUpdate.mScaleY &&
MOZ_ASSERT(existing->mRasterScale == aUpdate.mRasterScale &&
existing->mTransformToAncestorScale ==
aUpdate.mTransformToAncestorScale);
update.mVisibleRect = update.mVisibleRect.Union(existing->mVisibleRect);