mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 952977: Switch ScaleAndTranslate to gfx::Matrix r=nical
This commit is contained in:
parent
953e1db85b
commit
4ff3f38e76
@ -21,6 +21,7 @@
|
||||
#include "nsSVGIntegrationUtils.h"
|
||||
#include "ImageContainer.h"
|
||||
#include "ActiveLayerTracker.h"
|
||||
#include "gfx2DGlue.h"
|
||||
|
||||
#include "GeckoProfiler.h"
|
||||
#include "mozilla/gfx/Tools.h"
|
||||
@ -3596,15 +3597,15 @@ FrameLayerBuilder::DumpRetainedLayerTree(LayerManager* aManager, FILE* aFile, bo
|
||||
}
|
||||
#endif
|
||||
|
||||
gfxRect
|
||||
gfx::Rect
|
||||
CalculateBounds(const nsTArray<DisplayItemClip::RoundedRect>& aRects, int32_t A2D)
|
||||
{
|
||||
nsRect bounds = aRects[0].mRect;
|
||||
for (uint32_t i = 1; i < aRects.Length(); ++i) {
|
||||
bounds.UnionRect(bounds, aRects[i].mRect);
|
||||
}
|
||||
|
||||
return nsLayoutUtils::RectToGfxRect(bounds, A2D);
|
||||
|
||||
return gfx::ToRect(nsLayoutUtils::RectToGfxRect(bounds, A2D));
|
||||
}
|
||||
|
||||
static void
|
||||
@ -3657,25 +3658,26 @@ ContainerState::SetupMaskLayer(Layer *aLayer, const DisplayItemClip& aClip,
|
||||
}
|
||||
|
||||
// calculate a more precise bounding rect
|
||||
gfxRect boundingRect = CalculateBounds(newData.mRoundedClipRects,
|
||||
newData.mAppUnitsPerDevPixel);
|
||||
gfx::Rect boundingRect = CalculateBounds(newData.mRoundedClipRects,
|
||||
newData.mAppUnitsPerDevPixel);
|
||||
boundingRect.Scale(mParameters.mXScale, mParameters.mYScale);
|
||||
|
||||
uint32_t maxSize = mManager->GetMaxTextureSize();
|
||||
NS_ASSERTION(maxSize > 0, "Invalid max texture size");
|
||||
gfxSize surfaceSize(std::min<float>(boundingRect.Width(), maxSize),
|
||||
std::min<float>(boundingRect.Height(), maxSize));
|
||||
gfx::Size surfaceSize(std::min<gfx::Float>(boundingRect.Width(), maxSize),
|
||||
std::min<gfx::Float>(boundingRect.Height(), maxSize));
|
||||
|
||||
// maskTransform is applied to the clip when it is painted into the mask (as a
|
||||
// component of imageTransform), and its inverse used when the mask is used for
|
||||
// masking.
|
||||
// It is the transform from the masked layer's space to mask space
|
||||
gfxMatrix maskTransform;
|
||||
gfx::Matrix maskTransform;
|
||||
maskTransform.Scale(surfaceSize.width/boundingRect.Width(),
|
||||
surfaceSize.height/boundingRect.Height());
|
||||
maskTransform.Translate(-boundingRect.TopLeft());
|
||||
gfx::Point p = boundingRect.TopLeft();
|
||||
maskTransform.Translate(-p.x, -p.y);
|
||||
// imageTransform is only used when the clip is painted to the mask
|
||||
gfxMatrix imageTransform = maskTransform;
|
||||
gfx::Matrix imageTransform = maskTransform;
|
||||
imageTransform.Scale(mParameters.mXScale, mParameters.mYScale);
|
||||
|
||||
nsAutoPtr<MaskLayerImageCache::MaskLayerImageKey> newKey(
|
||||
@ -3688,7 +3690,7 @@ ContainerState::SetupMaskLayer(Layer *aLayer, const DisplayItemClip& aClip,
|
||||
mContainerFrame->PresContext()));
|
||||
newKey->mRoundedClipRects[i].ScaleAndTranslate(imageTransform);
|
||||
}
|
||||
|
||||
|
||||
const MaskLayerImageCache::MaskLayerImageKey* lookupKey = newKey;
|
||||
|
||||
// check to see if we can reuse a mask image
|
||||
@ -3710,7 +3712,7 @@ ContainerState::SetupMaskLayer(Layer *aLayer, const DisplayItemClip& aClip,
|
||||
}
|
||||
|
||||
nsRefPtr<gfxContext> context = new gfxContext(surface);
|
||||
context->Multiply(imageTransform);
|
||||
context->Multiply(ThebesMatrix(imageTransform));
|
||||
|
||||
// paint the clipping rects with alpha to create the mask
|
||||
context->SetColor(gfxRGBA(1, 1, 1, 1));
|
||||
@ -3735,8 +3737,9 @@ ContainerState::SetupMaskLayer(Layer *aLayer, const DisplayItemClip& aClip,
|
||||
}
|
||||
|
||||
maskLayer->SetContainer(container);
|
||||
|
||||
gfx3DMatrix matrix = gfx3DMatrix::From2D(maskTransform.Invert());
|
||||
|
||||
maskTransform.Invert();
|
||||
gfx3DMatrix matrix = gfx3DMatrix::From2D(ThebesMatrix(maskTransform));
|
||||
matrix.Translate(gfxPoint3D(mParameters.mOffset.x, mParameters.mOffset.y, 0));
|
||||
maskLayer->SetBaseTransform(matrix);
|
||||
|
||||
|
@ -6,9 +6,9 @@
|
||||
#ifndef MASKLAYERIMAGECACHE_H_
|
||||
#define MASKLAYERIMAGECACHE_H_
|
||||
|
||||
#include "gfxMatrix.h"
|
||||
#include "DisplayItemClip.h"
|
||||
#include "nsPresContext.h"
|
||||
#include "mozilla/gfx/Matrix.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
@ -73,16 +73,16 @@ public:
|
||||
// Applies the scale and translate components of aTransform.
|
||||
// It is an error to pass a matrix which does more than just scale
|
||||
// and translate.
|
||||
void ScaleAndTranslate(const gfxMatrix& aTransform)
|
||||
void ScaleAndTranslate(const gfx::Matrix& aTransform)
|
||||
{
|
||||
NS_ASSERTION(aTransform.xy == 0 && aTransform.yx == 0,
|
||||
NS_ASSERTION(aTransform._12 == 0 && aTransform._21 == 0,
|
||||
"Transform has a component other than scale and translate");
|
||||
|
||||
mRect = aTransform.Transform(mRect);
|
||||
mRect = aTransform.TransformBounds(mRect);
|
||||
|
||||
for (size_t i = 0; i < ArrayLength(mRadii); i += 2) {
|
||||
mRadii[i] *= aTransform.xx;
|
||||
mRadii[i + 1] *= aTransform.yy;
|
||||
mRadii[i] *= aTransform._11;
|
||||
mRadii[i + 1] *= aTransform._22;
|
||||
}
|
||||
}
|
||||
|
||||
@ -111,7 +111,7 @@ public:
|
||||
return hash;
|
||||
}
|
||||
|
||||
gfxRect mRect;
|
||||
gfx::Rect mRect;
|
||||
// Indices into mRadii are the NS_CORNER_* constants in nsStyleConsts.h
|
||||
gfxFloat mRadii[8];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user