Bug 923434 - Use DrawSurface in ThebesLayerBuffer instead of FillRect. r=Bas

This commit is contained in:
Matt Woodrow 2013-11-05 17:50:57 +13:00
parent 2b4a1c6957
commit cd67756e2e
2 changed files with 42 additions and 13 deletions

View File

@ -50,6 +50,27 @@ RotatedBuffer::GetQuadrantRectangle(XSide aXSide, YSide aYSide) const
return mBufferRect + quadrantTranslation;
}
Rect
RotatedBuffer::GetSourceRectangle(XSide aXSide, YSide aYSide) const
{
Rect result;
if (aXSide == LEFT) {
result.x = 0;
result.width = mBufferRotation.x;
} else {
result.x = mBufferRotation.x;
result.width = mBufferRect.width - mBufferRotation.x;
}
if (aYSide == TOP) {
result.y = 0;
result.height = mBufferRotation.y;
} else {
result.y = mBufferRotation.y;
result.height = mBufferRect.height - mBufferRotation.y;
}
return result;
}
/**
* @param aXSide LEFT means we draw from the left side of the buffer (which
* is drawn on the right side of mBufferRect). RIGHT means we draw from
@ -199,16 +220,6 @@ RotatedBuffer::DrawBufferQuadrant(gfx::DrawTarget* aTarget,
snapshot = mDTBufferOnWhite->Snapshot();
}
// Transform from user -> buffer space.
Matrix transform;
transform.Translate(quadrantTranslation.x, quadrantTranslation.y);
#ifdef MOZ_GFX_OPTIMIZE_MOBILE
SurfacePattern source(snapshot, EXTEND_CLAMP, transform, FILTER_POINT);
#else
SurfacePattern source(snapshot, EXTEND_CLAMP, transform);
#endif
if (aOperator == OP_SOURCE) {
// OP_SOURCE is unbounded in Azure, and we really don't want that behaviour here.
// We also can't do a ClearRect+FillRect since we need the drawing to happen
@ -218,14 +229,30 @@ RotatedBuffer::DrawBufferQuadrant(gfx::DrawTarget* aTarget,
}
if (aMask) {
// Transform from user -> buffer space.
Matrix transform;
transform.Translate(quadrantTranslation.x, quadrantTranslation.y);
#ifdef MOZ_GFX_OPTIMIZE_MOBILE
SurfacePattern source(snapshot, EXTEND_CLAMP, transform, FILTER_POINT);
#else
SurfacePattern source(snapshot, EXTEND_CLAMP, transform);
#endif
Matrix oldTransform = aTarget->GetTransform();
aTarget->SetTransform(*aMaskTransform);
aTarget->MaskSurface(source, aMask, Point(0, 0), DrawOptions(aOpacity, aOperator));
aTarget->SetTransform(oldTransform);
} else {
aTarget->FillRect(gfx::Rect(fillRect.x, fillRect.y,
fillRect.width, fillRect.height),
source, DrawOptions(aOpacity, aOperator));
#ifdef MOZ_GFX_OPTIMIZE_MOBILE
DrawSurfaceOptions options(FILTER_POINT);
#else
DrawSurfaceOptions options;
#endif
aTarget->DrawSurface(snapshot, ToRect(fillRect),
GetSourceRectangle(aXSide, aYSide),
options,
DrawOptions(aOpacity, aOperator));
}
if (aOperator == OP_SOURCE) {

View File

@ -112,6 +112,8 @@ protected:
};
nsIntRect GetQuadrantRectangle(XSide aXSide, YSide aYSide) const;
gfx::Rect GetSourceRectangle(XSide aXSide, YSide aYSide) const;
/*
* If aMask is non-null, then it is used as an alpha mask for rendering this
* buffer. aMaskTransform must be non-null if aMask is non-null, and is used