зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1770289 - Change the return type of nsLayoutUtils::ComputeSuitableScaleForAnimation() to MatrixScales. r=botond
Differential Revision: https://phabricator.services.mozilla.com/D147835
This commit is contained in:
Родитель
0f3ed8ae5d
Коммит
dab093953c
|
@ -168,6 +168,18 @@ struct BaseScaleFactors2D {
|
|||
const BaseScaleFactors2D<UnknownUnits, UnknownUnits, T>& scale) {
|
||||
return BaseScaleFactors2D<Src, Dst, T>(scale.xScale, scale.yScale);
|
||||
}
|
||||
|
||||
friend BaseScaleFactors2D Min(const BaseScaleFactors2D& aA,
|
||||
const BaseScaleFactors2D& aB) {
|
||||
return BaseScaleFactors2D(std::min(aA.xScale, aB.xScale),
|
||||
std::min(aA.yScale, aB.yScale));
|
||||
}
|
||||
|
||||
friend BaseScaleFactors2D Max(const BaseScaleFactors2D& aA,
|
||||
const BaseScaleFactors2D& aB) {
|
||||
return BaseScaleFactors2D(std::max(aA.xScale, aB.xScale),
|
||||
std::max(aA.yScale, aB.yScale));
|
||||
}
|
||||
};
|
||||
|
||||
template <class Src, class Dst>
|
||||
|
|
|
@ -67,9 +67,8 @@ MatrixScales ChooseScale(nsIFrame* aContainerFrame,
|
|||
// to account
|
||||
nsSize scaledVisibleSize = nsSize(aVisibleRect.Width() * aXScale,
|
||||
aVisibleRect.Height() * aYScale);
|
||||
Size size = nsLayoutUtils::ComputeSuitableScaleForAnimation(
|
||||
scale = nsLayoutUtils::ComputeSuitableScaleForAnimation(
|
||||
aContainerFrame, scaledVisibleSize, displaySize);
|
||||
scale = MatrixScales(size.width, size.height);
|
||||
// multiply by the scale inherited from ancestors--we use a uniform
|
||||
// scale factor to prevent blurring when the layer is rotated.
|
||||
float incomingScale = std::max(aXScale, aYScale);
|
||||
|
|
|
@ -361,17 +361,17 @@ static float GetSuitableScale(float aMaxScale, float aMinScale,
|
|||
|
||||
// The first value in this pair is the min scale, and the second one is the max
|
||||
// scale.
|
||||
using MinAndMaxScale = std::pair<Size, Size>;
|
||||
using MinAndMaxScale = std::pair<MatrixScales, MatrixScales>;
|
||||
|
||||
static inline void UpdateMinMaxScale(const nsIFrame* aFrame,
|
||||
const AnimationValue& aValue,
|
||||
MinAndMaxScale& aMinAndMaxScale) {
|
||||
MatrixScales size = aValue.GetScaleValue(aFrame);
|
||||
Size& minScale = aMinAndMaxScale.first;
|
||||
Size& maxScale = aMinAndMaxScale.second;
|
||||
MatrixScales& minScale = aMinAndMaxScale.first;
|
||||
MatrixScales& maxScale = aMinAndMaxScale.second;
|
||||
|
||||
minScale = Min(minScale, {size.xScale, size.yScale});
|
||||
maxScale = Max(maxScale, {size.xScale, size.yScale});
|
||||
minScale = Min(minScale, size);
|
||||
maxScale = Max(maxScale, size);
|
||||
}
|
||||
|
||||
// The final transform matrix is calculated by merging the final results of each
|
||||
|
@ -394,10 +394,10 @@ static Array<MinAndMaxScale, 2> GetMinAndMaxScaleForAnimationProperty(
|
|||
// The first element in the array is for eCSSProperty_transform, and the
|
||||
// second one is for eCSSProperty_scale.
|
||||
const MinAndMaxScale defaultValue =
|
||||
std::make_pair(Size(std::numeric_limits<float>::max(),
|
||||
std::numeric_limits<float>::max()),
|
||||
Size(std::numeric_limits<float>::min(),
|
||||
std::numeric_limits<float>::min()));
|
||||
std::make_pair(MatrixScales(std::numeric_limits<float>::max(),
|
||||
std::numeric_limits<float>::max()),
|
||||
MatrixScales(std::numeric_limits<float>::min(),
|
||||
std::numeric_limits<float>::min()));
|
||||
Array<MinAndMaxScale, 2> minAndMaxScales(defaultValue, defaultValue);
|
||||
|
||||
for (dom::Animation* anim : aAnimations) {
|
||||
|
@ -445,7 +445,7 @@ static Array<MinAndMaxScale, 2> GetMinAndMaxScaleForAnimationProperty(
|
|||
return minAndMaxScales;
|
||||
}
|
||||
|
||||
Size nsLayoutUtils::ComputeSuitableScaleForAnimation(
|
||||
MatrixScales nsLayoutUtils::ComputeSuitableScaleForAnimation(
|
||||
const nsIFrame* aFrame, const nsSize& aVisibleSize,
|
||||
const nsSize& aDisplaySize) {
|
||||
const nsTArray<RefPtr<dom::Animation>> compositorAnimations =
|
||||
|
@ -454,7 +454,7 @@ Size nsLayoutUtils::ComputeSuitableScaleForAnimation(
|
|||
nsCSSPropertyIDSet{eCSSProperty_transform, eCSSProperty_scale});
|
||||
|
||||
if (compositorAnimations.IsEmpty()) {
|
||||
return Size(1.0, 1.0);
|
||||
return MatrixScales();
|
||||
}
|
||||
|
||||
const Array<MinAndMaxScale, 2> minAndMaxScales =
|
||||
|
@ -464,22 +464,22 @@ Size nsLayoutUtils::ComputeSuitableScaleForAnimation(
|
|||
// (or max()) as the scale value. However, in this case, we may render an
|
||||
// extreme small (or large) element, so this may not be a problem. If so,
|
||||
// please fix this.
|
||||
Size maxScale(std::numeric_limits<float>::min(),
|
||||
std::numeric_limits<float>::min());
|
||||
Size minScale(std::numeric_limits<float>::max(),
|
||||
std::numeric_limits<float>::max());
|
||||
MatrixScales maxScale(std::numeric_limits<float>::min(),
|
||||
std::numeric_limits<float>::min());
|
||||
MatrixScales minScale(std::numeric_limits<float>::max(),
|
||||
std::numeric_limits<float>::max());
|
||||
|
||||
auto isUnset = [](const Size& aMax, const Size& aMin) {
|
||||
return aMax.width == std::numeric_limits<float>::min() &&
|
||||
aMax.height == std::numeric_limits<float>::min() &&
|
||||
aMin.width == std::numeric_limits<float>::max() &&
|
||||
aMin.height == std::numeric_limits<float>::max();
|
||||
auto isUnset = [](const MatrixScales& aMax, const MatrixScales& aMin) {
|
||||
return aMax.xScale == std::numeric_limits<float>::min() &&
|
||||
aMax.yScale == std::numeric_limits<float>::min() &&
|
||||
aMin.xScale == std::numeric_limits<float>::max() &&
|
||||
aMin.yScale == std::numeric_limits<float>::max();
|
||||
};
|
||||
|
||||
// Iterate the slots to get the final scale value.
|
||||
for (const auto& pair : minAndMaxScales) {
|
||||
const Size& currMinScale = pair.first;
|
||||
const Size& currMaxScale = pair.second;
|
||||
const MatrixScales& currMinScale = pair.first;
|
||||
const MatrixScales& currMaxScale = pair.second;
|
||||
|
||||
if (isUnset(currMaxScale, currMinScale)) {
|
||||
// We don't have this animation property, so skip.
|
||||
|
@ -502,13 +502,14 @@ Size nsLayoutUtils::ComputeSuitableScaleForAnimation(
|
|||
|
||||
if (isUnset(maxScale, minScale)) {
|
||||
// We didn't encounter any transform-like property.
|
||||
return Size(1.0, 1.0);
|
||||
return MatrixScales();
|
||||
}
|
||||
|
||||
return Size(GetSuitableScale(maxScale.width, minScale.width,
|
||||
aVisibleSize.width, aDisplaySize.width),
|
||||
GetSuitableScale(maxScale.height, minScale.height,
|
||||
aVisibleSize.height, aDisplaySize.height));
|
||||
return MatrixScales(
|
||||
GetSuitableScale(maxScale.xScale, minScale.xScale, aVisibleSize.width,
|
||||
aDisplaySize.width),
|
||||
GetSuitableScale(maxScale.yScale, minScale.yScale, aVisibleSize.height,
|
||||
aDisplaySize.height));
|
||||
}
|
||||
|
||||
bool nsLayoutUtils::AreAsyncAnimationsEnabled() {
|
||||
|
|
|
@ -164,6 +164,7 @@ class nsLayoutUtils {
|
|||
typedef mozilla::gfx::Size Size;
|
||||
typedef mozilla::gfx::Matrix4x4 Matrix4x4;
|
||||
typedef mozilla::gfx::Matrix4x4Flagged Matrix4x4Flagged;
|
||||
typedef mozilla::gfx::MatrixScales MatrixScales;
|
||||
typedef mozilla::gfx::MatrixScalesDouble MatrixScalesDouble;
|
||||
typedef mozilla::gfx::RectCornerRadii RectCornerRadii;
|
||||
typedef mozilla::gfx::StrokeOptions StrokeOptions;
|
||||
|
@ -2420,9 +2421,9 @@ class nsLayoutUtils {
|
|||
* @param aVisibleSize is the size of the area we want to paint
|
||||
* @param aDisplaySize is the size of the display area of the pres context
|
||||
*/
|
||||
static Size ComputeSuitableScaleForAnimation(const nsIFrame* aFrame,
|
||||
const nsSize& aVisibleSize,
|
||||
const nsSize& aDisplaySize);
|
||||
static MatrixScales ComputeSuitableScaleForAnimation(
|
||||
const nsIFrame* aFrame, const nsSize& aVisibleSize,
|
||||
const nsSize& aDisplaySize);
|
||||
|
||||
/**
|
||||
* Checks whether we want to use the GPU to scale images when
|
||||
|
|
Загрузка…
Ссылка в новой задаче