Bug 1676299 - Removed the xMajor parameter from BaseMatrix::ScaleFactors() r=botond

Differential Revision: https://phabricator.services.mozilla.com/D97449
This commit is contained in:
coderboncuk 2020-11-18 18:53:01 +00:00
parent 8d91ace438
commit c8b12f5aa2
11 changed files with 22 additions and 27 deletions

View File

@ -4524,7 +4524,7 @@ void CanvasRenderingContext2D::DrawImage(const CanvasImageSource& aImage,
// the image. Nearest sampling when down-scaling is rarely desirable and
// smoothing when down-scaling matches chromium's behavior.
// If any dimension is up-scaled, we consider the image as being up-scaled.
auto scale = mTarget->GetTransform().ScaleFactors(true);
auto scale = mTarget->GetTransform().ScaleFactors();
bool isDownScale =
aDw * Abs(scale.width) < aSw && aDh * Abs(scale.height) < aSh;
@ -4605,7 +4605,7 @@ void CanvasRenderingContext2D::DrawDirectlyToCanvas(
// for context shadow.
Matrix matrix = tempTarget->GetTransform();
gfxMatrix contextMatrix = ThebesMatrix(matrix);
gfxSize contextScale(contextMatrix.ScaleFactors(true));
gfxSize contextScale(contextMatrix.ScaleFactors());
// Scale the dest rect to include the context scale.
aDest.Scale(contextScale.width, contextScale.height);

View File

@ -444,14 +444,14 @@ class BaseMatrix {
* The xMajor parameter indicates if the larger scale is
* to be assumed to be in the X direction or not.
*/
MatrixSize ScaleFactors(bool xMajor) const {
MatrixSize ScaleFactors() const {
T det = Determinant();
if (det == 0.0) {
return MatrixSize(0.0, 0.0);
}
MatrixSize sz = xMajor ? MatrixSize(1.0, 0.0) : MatrixSize(0.0, 1.0);
MatrixSize sz = MatrixSize(1.0, 0.0);
sz = TransformSize(sz);
T major = sqrt(sz.width * sz.width + sz.height * sz.height);
@ -466,11 +466,7 @@ class BaseMatrix {
minor = det / major;
}
if (xMajor) {
return MatrixSize(major, minor);
}
return MatrixSize(minor, major);
return MatrixSize(major, minor);
}
};

View File

@ -421,7 +421,7 @@ static bool PrescaleAndTileDrawable(gfxDrawable* aDrawable,
const SamplingFilter aSamplingFilter,
const SurfaceFormat aFormat,
gfxFloat aOpacity, ExtendMode aExtendMode) {
Size scaleFactor = aContext->CurrentMatrix().ScaleFactors(true);
Size scaleFactor = aContext->CurrentMatrix().ScaleFactors();
Matrix scaleMatrix = Matrix::Scaling(scaleFactor.width, scaleFactor.height);
const float fuzzFactor = 0.01;

View File

@ -134,7 +134,7 @@ HDC gfxWindowsNativeDrawing::BeginNativeDrawing() {
(int32_t)ceil(mNativeRect.Height() + 1));
} else {
// figure out the scale factors
mScale = m.ScaleFactors(true);
mScale = m.ScaleFactors();
mWorldTransform.eM11 = (FLOAT)mScale.width;
mWorldTransform.eM12 = 0.0f;

View File

@ -2050,7 +2050,7 @@ gfxSize nsLayoutUtils::GetTransformToAncestorScale(nsIFrame* aFrame) {
RelativeTo{nsLayoutUtils::GetDisplayRootFrame(aFrame)});
Matrix transform2D;
if (transform.Is2D(&transform2D)) {
return ThebesMatrix(transform2D).ScaleFactors(true);
return ThebesMatrix(transform2D).ScaleFactors();
}
return gfxSize(1, 1);
}
@ -2086,7 +2086,7 @@ gfxSize nsLayoutUtils::GetTransformToAncestorScaleExcludingAnimated(
aFrame, nsLayoutUtils::GetDisplayRootFrame(aFrame));
Matrix transform2D;
if (transform.Is2D(&transform2D)) {
return ThebesMatrix(transform2D).ScaleFactors(true);
return ThebesMatrix(transform2D).ScaleFactors();
}
return gfxSize(1, 1);
}
@ -6005,7 +6005,7 @@ static SnappedImageDrawingParameters ComputeSnappedImageDrawingParameters(
// scale and has integer coordinates. If not, we need these properties to
// compute the optimal drawn image size, so compute |snappedDestSize| here.
gfxSize snappedDestSize = dest.Size();
gfxSize scaleFactors = currentMatrix.ScaleFactors(true);
gfxSize scaleFactors = currentMatrix.ScaleFactors();
if (!didSnap) {
snappedDestSize.Scale(scaleFactors.width, scaleFactors.height);
snappedDestSize.width = NS_round(snappedDestSize.width);
@ -6096,7 +6096,7 @@ static SnappedImageDrawingParameters ComputeSnappedImageDrawingParameters(
// follow the pattern that we take |currentMatrix| into account only if
// |didSnap| is true.
gfxSize unsnappedDestSize =
didSnap ? devPixelDest.Size() * currentMatrix.ScaleFactors(true)
didSnap ? devPixelDest.Size() * currentMatrix.ScaleFactors()
: devPixelDest.Size();
gfxRect anchoredDestRect(anchorPoint, unsnappedDestSize);
@ -8972,7 +8972,7 @@ static nsSize ComputeMaxSizeForPartialPrerender(nsIFrame* aFrame,
}
gfx::Rect result(0, 0, aMaxSize.width, aMaxSize.height);
gfx::Size scale = transform2D.ScaleFactors(true);
gfx::Size scale = transform2D.ScaleFactors();
if (scale.width != 0 && scale.height != 0) {
result.width /= scale.width;
result.height /= scale.height;
@ -9515,8 +9515,7 @@ bool nsLayoutUtils::FrameIsMostlyScrolledOutOfViewInCrossProcess(
MOZ_ASSERT(browserChild);
Size scale =
browserChild->GetChildToParentConversionMatrix().As2D().ScaleFactors(
true);
browserChild->GetChildToParentConversionMatrix().As2D().ScaleFactors();
ScreenSize margin(scale.width * CSSPixel::FromAppUnits(aMargin),
scale.height * CSSPixel::FromAppUnits(aMargin));

View File

@ -294,7 +294,7 @@ static void IncrementScaleRestyleCountIfNeeded(nsIFrame* aFrame,
return;
}
Size scale = transform2D.ScaleFactors(true);
Size scale = transform2D.ScaleFactors();
if (aActivity->mPreviousTransformScale == Some(scale)) {
return; // Nothing changed.
}

View File

@ -6048,7 +6048,7 @@ Size FrameLayerBuilder::ChooseScale(nsIFrame* aContainerFrame,
} else {
// Scale factors are normalized to a power of 2 to reduce the number of
// resolution changes
scale = aTransform2d.ScaleFactors(true);
scale = aTransform2d.ScaleFactors();
// 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
// the content as it scales up and down. Rounding up to nearest
@ -6506,7 +6506,7 @@ gfxSize FrameLayerBuilder::GetPaintedLayerScaleForFrame(nsIFrame* aFrame) {
Matrix transform2d;
if (transform.CanDraw2D(&transform2d)) {
return ThebesMatrix(transform2d).ScaleFactors(true);
return ThebesMatrix(transform2d).ScaleFactors();
}
return gfxSize(1.0, 1.0);

View File

@ -4865,7 +4865,7 @@ bool nsContextBoxBlur::InsetBoxBlur(
// input data to the blur. This way, we don't have to scale the min
// inset blur to the invert of the dest context, then rescale it back
// when we draw to the destination surface.
gfx::Size scale = aDestinationCtx->CurrentMatrix().ScaleFactors(true);
gfx::Size scale = aDestinationCtx->CurrentMatrix().ScaleFactors();
Matrix transform = aDestinationCtx->CurrentMatrix();
// XXX: we could probably handle negative scales but for now it's easier just

View File

@ -143,7 +143,7 @@ Size AnimationValue::GetScaleValue(const nsIFrame* aFrame) const {
if (!canDraw2D) {
return Size();
}
return transform2d.ScaleFactors(true);
return transform2d.ScaleFactors();
}
void AnimationValue::SerializeSpecifiedValue(nsCSSPropertyID aProperty,

View File

@ -281,7 +281,7 @@ Size CSSFilterInstance::BlurRadiusToFilterSpace(nscoord aRadiusInFrameSpace) {
Size radiusInFilterSpace(radiusInFrameSpaceInCSSPx,
radiusInFrameSpaceInCSSPx);
gfxSize frameSpaceInCSSPxToFilterSpaceScale =
mFrameSpaceInCSSPxToFilterSpaceTransform.ScaleFactors(true);
mFrameSpaceInCSSPxToFilterSpaceTransform.ScaleFactors();
radiusInFilterSpace.Scale(frameSpaceInCSSPxToFilterSpaceScale.width,
frameSpaceInCSSPxToFilterSpaceScale.height);
@ -310,7 +310,7 @@ IntPoint CSSFilterInstance::OffsetToFilterSpace(nscoord aXOffsetInFrameSpace,
// Convert the radius to filter space.
gfxSize frameSpaceInCSSPxToFilterSpaceScale =
mFrameSpaceInCSSPxToFilterSpaceTransform.ScaleFactors(true);
mFrameSpaceInCSSPxToFilterSpaceTransform.ScaleFactors();
offsetInFilterSpace.x *= frameSpaceInCSSPxToFilterSpaceScale.width;
offsetInFilterSpace.y *= frameSpaceInCSSPxToFilterSpaceScale.height;

View File

@ -70,7 +70,7 @@ void FilterInstance::PaintFilteredFrame(nsIFrame* aFilteredFrame,
UserSpaceMetricsForFrame(aFilteredFrame);
gfxContextMatrixAutoSaveRestore autoSR(aCtx);
gfxSize scaleFactors = aCtx->CurrentMatrixDouble().ScaleFactors(true);
gfxSize scaleFactors = aCtx->CurrentMatrixDouble().ScaleFactors();
if (scaleFactors.IsEmpty()) {
return;
}
@ -509,7 +509,7 @@ bool FilterInstance::ComputeTargetBBoxInFilterSpace() {
bool FilterInstance::ComputeUserSpaceToFilterSpaceScale() {
if (mTargetFrame) {
mUserSpaceToFilterSpaceScale = mPaintTransform.ScaleFactors(true);
mUserSpaceToFilterSpaceScale = mPaintTransform.ScaleFactors();
if (mUserSpaceToFilterSpaceScale.width <= 0.0f ||
mUserSpaceToFilterSpaceScale.height <= 0.0f) {
// Nothing should be rendered.