mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 997336 - Account for the DrawTarget 'device offset' when drawing layers with a mask. r=Bas
This commit is contained in:
parent
03bb064768
commit
e42521f895
@ -21,7 +21,9 @@ namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
void
|
||||
BasicCanvasLayer::Paint(DrawTarget* aDT, Layer* aMaskLayer)
|
||||
BasicCanvasLayer::Paint(DrawTarget* aDT,
|
||||
const Point& aDeviceOffset,
|
||||
Layer* aMaskLayer)
|
||||
{
|
||||
if (IsHidden())
|
||||
return;
|
||||
@ -43,7 +45,7 @@ BasicCanvasLayer::Paint(DrawTarget* aDT, Layer* aMaskLayer)
|
||||
aDT->SetTransform(newTransform);
|
||||
}
|
||||
|
||||
FillRectWithMask(aDT,
|
||||
FillRectWithMask(aDT, aDeviceOffset,
|
||||
Rect(0, 0, mBounds.width, mBounds.height),
|
||||
mSurface, ToFilter(mFilter),
|
||||
DrawOptions(GetEffectiveOpacity(), GetEffectiveOperator(this)),
|
||||
|
@ -34,7 +34,9 @@ public:
|
||||
CanvasLayer::SetVisibleRegion(aRegion);
|
||||
}
|
||||
|
||||
virtual void Paint(gfx::DrawTarget* aDT, Layer* aMaskLayer) MOZ_OVERRIDE;
|
||||
virtual void Paint(gfx::DrawTarget* aDT,
|
||||
const gfx::Point& aDeviceOffset,
|
||||
Layer* aMaskLayer) MOZ_OVERRIDE;
|
||||
|
||||
protected:
|
||||
BasicLayerManager* BasicManager()
|
||||
|
@ -44,7 +44,9 @@ public:
|
||||
ColorLayer::SetVisibleRegion(aRegion);
|
||||
}
|
||||
|
||||
virtual void Paint(DrawTarget* aDT, Layer* aMaskLayer) MOZ_OVERRIDE
|
||||
virtual void Paint(DrawTarget* aDT,
|
||||
const gfx::Point& aDeviceOffset,
|
||||
Layer* aMaskLayer) MOZ_OVERRIDE
|
||||
{
|
||||
if (IsHidden()) {
|
||||
return;
|
||||
@ -57,7 +59,7 @@ public:
|
||||
snapped = mat.TransformBounds(snapped);
|
||||
}
|
||||
|
||||
FillRectWithMask(aDT, snapped, ToColor(mColor),
|
||||
FillRectWithMask(aDT, aDeviceOffset, snapped, ToColor(mColor),
|
||||
DrawOptions(GetEffectiveOpacity(), GetEffectiveOperator(this)),
|
||||
aMaskLayer);
|
||||
}
|
||||
|
@ -44,7 +44,9 @@ public:
|
||||
ImageLayer::SetVisibleRegion(aRegion);
|
||||
}
|
||||
|
||||
virtual void Paint(DrawTarget* aDT, Layer* aMaskLayer) MOZ_OVERRIDE;
|
||||
virtual void Paint(DrawTarget* aDT,
|
||||
const gfx::Point& aDeviceOffset,
|
||||
Layer* aMaskLayer) MOZ_OVERRIDE;
|
||||
|
||||
virtual TemporaryRef<SourceSurface> GetAsSourceSurface() MOZ_OVERRIDE;
|
||||
|
||||
@ -64,7 +66,9 @@ protected:
|
||||
};
|
||||
|
||||
void
|
||||
BasicImageLayer::Paint(DrawTarget* aDT, Layer* aMaskLayer)
|
||||
BasicImageLayer::Paint(DrawTarget* aDT,
|
||||
const gfx::Point& aDeviceOffset,
|
||||
Layer* aMaskLayer)
|
||||
{
|
||||
if (IsHidden() || !mContainer) {
|
||||
return;
|
||||
@ -81,7 +85,8 @@ BasicImageLayer::Paint(DrawTarget* aDT, Layer* aMaskLayer)
|
||||
return;
|
||||
}
|
||||
|
||||
FillRectWithMask(aDT, Rect(0, 0, size.width, size.height), surface, ToFilter(mFilter),
|
||||
FillRectWithMask(aDT, aDeviceOffset, Rect(0, 0, size.width, size.height),
|
||||
surface, ToFilter(mFilter),
|
||||
DrawOptions(GetEffectiveOpacity(), GetEffectiveOperator(this)),
|
||||
aMaskLayer);
|
||||
|
||||
|
@ -59,7 +59,9 @@ public:
|
||||
* set up to account for all the properties of the layer (transform,
|
||||
* opacity, etc).
|
||||
*/
|
||||
virtual void Paint(gfx::DrawTarget* aDT, Layer* aMaskLayer) {}
|
||||
virtual void Paint(gfx::DrawTarget* aDT,
|
||||
const gfx::Point& aDeviceOffset,
|
||||
Layer* aMaskLayer) {}
|
||||
|
||||
/**
|
||||
* Like Paint() but called for ThebesLayers with the additional parameters
|
||||
|
@ -835,6 +835,7 @@ BasicLayerManager::PaintSelfOrChildren(PaintLayerContext& aPaintContext,
|
||||
aPaintContext.mReadback);
|
||||
} else {
|
||||
data->Paint(aGroupTarget->GetDrawTarget(),
|
||||
aGroupTarget->GetDeviceOffset(),
|
||||
aPaintContext.mLayer->GetMaskLayer());
|
||||
}
|
||||
} else {
|
||||
|
@ -19,7 +19,9 @@ namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
bool
|
||||
GetMaskData(Layer* aMaskLayer, AutoMoz2DMaskData* aMaskData)
|
||||
GetMaskData(Layer* aMaskLayer,
|
||||
const Point& aDeviceOffset,
|
||||
AutoMoz2DMaskData* aMaskData)
|
||||
{
|
||||
if (aMaskLayer) {
|
||||
RefPtr<SourceSurface> surface =
|
||||
@ -29,6 +31,7 @@ GetMaskData(Layer* aMaskLayer, AutoMoz2DMaskData* aMaskData)
|
||||
Matrix4x4 effectiveTransform = aMaskLayer->GetEffectiveTransform();
|
||||
DebugOnly<bool> maskIs2D = effectiveTransform.CanDraw2D(&transform);
|
||||
NS_ASSERTION(maskIs2D, "How did we end up with a 3D transform here?!");
|
||||
transform.Translate(-aDeviceOffset.x, -aDeviceOffset.y);
|
||||
aMaskData->Construct(transform, surface);
|
||||
return true;
|
||||
}
|
||||
@ -40,7 +43,7 @@ void
|
||||
PaintWithMask(gfxContext* aContext, float aOpacity, Layer* aMaskLayer)
|
||||
{
|
||||
AutoMoz2DMaskData mask;
|
||||
if (GetMaskData(aMaskLayer, &mask)) {
|
||||
if (GetMaskData(aMaskLayer, Point(), &mask)) {
|
||||
if (aOpacity < 1.0) {
|
||||
aContext->PushGroup(gfxContentType::COLOR_ALPHA);
|
||||
aContext->Paint(aOpacity);
|
||||
@ -78,13 +81,14 @@ FillRectWithMask(DrawTarget* aDT,
|
||||
}
|
||||
void
|
||||
FillRectWithMask(DrawTarget* aDT,
|
||||
const gfx::Point& aDeviceOffset,
|
||||
const Rect& aRect,
|
||||
const Color& aColor,
|
||||
const DrawOptions& aOptions,
|
||||
Layer* aMaskLayer)
|
||||
{
|
||||
AutoMoz2DMaskData mask;
|
||||
if (GetMaskData(aMaskLayer, &mask)) {
|
||||
if (GetMaskData(aMaskLayer, aDeviceOffset, &mask)) {
|
||||
const Matrix& maskTransform = mask.GetTransform();
|
||||
FillRectWithMask(aDT, aRect, aColor, aOptions, mask.GetSurface(), &maskTransform);
|
||||
return;
|
||||
@ -133,6 +137,7 @@ FillRectWithMask(DrawTarget* aDT,
|
||||
|
||||
void
|
||||
FillRectWithMask(DrawTarget* aDT,
|
||||
const gfx::Point& aDeviceOffset,
|
||||
const Rect& aRect,
|
||||
SourceSurface* aSurface,
|
||||
Filter aFilter,
|
||||
@ -140,7 +145,7 @@ FillRectWithMask(DrawTarget* aDT,
|
||||
Layer* aMaskLayer)
|
||||
{
|
||||
AutoMoz2DMaskData mask;
|
||||
if (GetMaskData(aMaskLayer, &mask)) {
|
||||
if (GetMaskData(aMaskLayer, aDeviceOffset, &mask)) {
|
||||
const Matrix& maskTransform = mask.GetTransform();
|
||||
FillRectWithMask(aDT, aRect, aSurface, aFilter, aOptions, ExtendMode::CLAMP,
|
||||
mask.GetSurface(), &maskTransform);
|
||||
|
@ -82,7 +82,9 @@ protected:
|
||||
* The transform for the layer will be put in aMaskData
|
||||
*/
|
||||
bool
|
||||
GetMaskData(Layer* aMaskLayer, AutoMoz2DMaskData* aMaskData);
|
||||
GetMaskData(Layer* aMaskLayer,
|
||||
const gfx::Point& aDeviceOffset,
|
||||
AutoMoz2DMaskData* aMaskData);
|
||||
|
||||
// Paint the current source to a context using a mask, if present
|
||||
void
|
||||
@ -108,6 +110,7 @@ FillRectWithMask(gfx::DrawTarget* aDT,
|
||||
const gfx::Matrix* aSurfaceTransform = nullptr);
|
||||
void
|
||||
FillRectWithMask(gfx::DrawTarget* aDT,
|
||||
const gfx::Point& aDeviceOffset,
|
||||
const gfx::Rect& aRect,
|
||||
gfx::SourceSurface* aSurface,
|
||||
gfx::Filter aFilter,
|
||||
@ -115,6 +118,7 @@ FillRectWithMask(gfx::DrawTarget* aDT,
|
||||
Layer* aMaskLayer);
|
||||
void
|
||||
FillRectWithMask(gfx::DrawTarget* aDT,
|
||||
const gfx::Point& aDeviceOffset,
|
||||
const gfx::Rect& aRect,
|
||||
const gfx::Color& aColor,
|
||||
const gfx::DrawOptions& aOptions,
|
||||
|
@ -125,7 +125,7 @@ BasicThebesLayer::PaintThebes(gfxContext* aContext,
|
||||
AutoMoz2DMaskData mask;
|
||||
SourceSurface* maskSurface = nullptr;
|
||||
Matrix maskTransform;
|
||||
if (GetMaskData(aMaskLayer, &mask)) {
|
||||
if (GetMaskData(aMaskLayer, Point(), &mask)) {
|
||||
maskSurface = mask.GetSurface();
|
||||
maskTransform = mask.GetTransform();
|
||||
}
|
||||
|
@ -2242,6 +2242,12 @@ gfxContext::GetAzureDeviceSpaceClipBounds()
|
||||
return rect;
|
||||
}
|
||||
|
||||
Point
|
||||
gfxContext::GetDeviceOffset() const
|
||||
{
|
||||
return CurrentState().deviceOffset;
|
||||
}
|
||||
|
||||
Matrix
|
||||
gfxContext::GetDeviceTransform() const
|
||||
{
|
||||
|
@ -657,6 +657,8 @@ public:
|
||||
gfxRect GetUserFillExtent();
|
||||
gfxRect GetUserStrokeExtent();
|
||||
|
||||
mozilla::gfx::Point GetDeviceOffset() const;
|
||||
|
||||
/**
|
||||
** Flags
|
||||
**/
|
||||
|
Loading…
Reference in New Issue
Block a user