Bug 993475 - Consolidate masking code in BasicCompositor and BasicLayersImpl. r=mattwoodrow
This commit is contained in:
@@ -60,16 +60,15 @@ FillRectWithMask(DrawTarget* aDT,
|
||||
const Rect& aRect,
|
||||
const Color& aColor,
|
||||
const DrawOptions& aOptions,
|
||||
Layer* aMaskLayer)
|
||||
SourceSurface* aMaskSource,
|
||||
const Matrix* aMaskTransform)
|
||||
{
|
||||
AutoMoz2DMaskData mask;
|
||||
if (GetMaskData(aMaskLayer, &mask)) {
|
||||
if (aMaskSource && aMaskTransform) {
|
||||
aDT->PushClipRect(aRect);
|
||||
Matrix oldTransform = aDT->GetTransform();
|
||||
|
||||
aDT->SetTransform(mask.GetTransform());
|
||||
aDT->MaskSurface(ColorPattern(aColor), mask.GetSurface(),
|
||||
Point(0, 0), aOptions);
|
||||
aDT->SetTransform(*aMaskTransform);
|
||||
aDT->MaskSurface(ColorPattern(aColor), aMaskSource, Point(), aOptions);
|
||||
aDT->SetTransform(oldTransform);
|
||||
aDT->PopClip();
|
||||
return;
|
||||
@@ -77,6 +76,60 @@ FillRectWithMask(DrawTarget* aDT,
|
||||
|
||||
aDT->FillRect(aRect, ColorPattern(aColor), aOptions);
|
||||
}
|
||||
void
|
||||
FillRectWithMask(DrawTarget* aDT,
|
||||
const Rect& aRect,
|
||||
const Color& aColor,
|
||||
const DrawOptions& aOptions,
|
||||
Layer* aMaskLayer)
|
||||
{
|
||||
AutoMoz2DMaskData mask;
|
||||
if (GetMaskData(aMaskLayer, &mask)) {
|
||||
const Matrix& maskTransform = mask.GetTransform();
|
||||
FillRectWithMask(aDT, aRect, aColor, aOptions, mask.GetSurface(), &maskTransform);
|
||||
return;
|
||||
}
|
||||
|
||||
FillRectWithMask(aDT, aRect, aColor, aOptions);
|
||||
}
|
||||
|
||||
void
|
||||
FillRectWithMask(DrawTarget* aDT,
|
||||
const Rect& aRect,
|
||||
SourceSurface* aSurface,
|
||||
Filter aFilter,
|
||||
const DrawOptions& aOptions,
|
||||
ExtendMode aExtendMode,
|
||||
SourceSurface* aMaskSource,
|
||||
const Matrix* aMaskTransform,
|
||||
const Matrix* aSurfaceTransform)
|
||||
{
|
||||
if (aMaskSource && aMaskTransform) {
|
||||
aDT->PushClipRect(aRect);
|
||||
Matrix oldTransform = aDT->GetTransform();
|
||||
|
||||
Matrix inverseMask = *aMaskTransform;
|
||||
inverseMask.Invert();
|
||||
|
||||
Matrix transform = inverseMask * oldTransform;
|
||||
if (aSurfaceTransform) {
|
||||
transform = transform * (*aSurfaceTransform);
|
||||
}
|
||||
|
||||
SurfacePattern source(aSurface, aExtendMode, transform, aFilter);
|
||||
|
||||
aDT->SetTransform(*aMaskTransform);
|
||||
aDT->MaskSurface(source, aMaskSource, Point(0, 0), aOptions);
|
||||
aDT->SetTransform(oldTransform);
|
||||
aDT->PopClip();
|
||||
return;
|
||||
}
|
||||
|
||||
aDT->FillRect(aRect,
|
||||
SurfacePattern(aSurface, aExtendMode,
|
||||
aSurfaceTransform ? (*aSurfaceTransform) : Matrix(),
|
||||
aFilter), aOptions);
|
||||
}
|
||||
|
||||
void
|
||||
FillRectWithMask(DrawTarget* aDT,
|
||||
@@ -88,25 +141,13 @@ FillRectWithMask(DrawTarget* aDT,
|
||||
{
|
||||
AutoMoz2DMaskData mask;
|
||||
if (GetMaskData(aMaskLayer, &mask)) {
|
||||
aDT->PushClipRect(aRect);
|
||||
Matrix oldTransform = aDT->GetTransform();
|
||||
Matrix transform = oldTransform;
|
||||
|
||||
Matrix inverseMask = mask.GetTransform();
|
||||
inverseMask.Invert();
|
||||
|
||||
transform *= inverseMask;
|
||||
|
||||
SurfacePattern source(aSurface, ExtendMode::CLAMP, transform, aFilter);
|
||||
|
||||
aDT->SetTransform(mask.GetTransform());
|
||||
aDT->MaskSurface(source, mask.GetSurface(), Point(0, 0), aOptions);
|
||||
aDT->SetTransform(oldTransform);
|
||||
aDT->PopClip();
|
||||
const Matrix& maskTransform = mask.GetTransform();
|
||||
FillRectWithMask(aDT, aRect, aSurface, aFilter, aOptions, ExtendMode::CLAMP,
|
||||
mask.GetSurface(), &maskTransform);
|
||||
return;
|
||||
}
|
||||
|
||||
aDT->FillRect(aRect, SurfacePattern(aSurface, ExtendMode::CLAMP, Matrix(), aFilter), aOptions);
|
||||
FillRectWithMask(aDT, aRect, aSurface, aFilter, aOptions, ExtendMode::CLAMP);
|
||||
}
|
||||
|
||||
BasicImplData*
|
||||
|
||||
Reference in New Issue
Block a user