Bug 928727 - Share code for getting the user-space clip bounds in DrawTargetCairo. r=jrmuizel

This commit is contained in:
Matt Woodrow 2013-10-22 12:11:30 +02:00
Родитель dae2e257aa
Коммит 5f2c6517be
2 изменённых файлов: 12 добавлений и 11 удалений

Просмотреть файл

@ -512,13 +512,10 @@ DrawTargetCairo::DrawSurface(SourceSurface *aSurface,
cairo_set_antialias(mContext, GfxAntialiasToCairoAntialias(aOptions.mAntialiasMode));
double clipX1, clipY1, clipX2, clipY2;
cairo_clip_extents(mContext, &clipX1, &clipY1, &clipX2, &clipY2);
Rect clip(clipX1, clipY1, clipX2 - clipX1, clipY2 - clipY1); // Narrowing of doubles to floats
// If the destination rect covers the entire clipped area, then unbounded and bounded
// operations are identical, and we don't need to push a group.
bool needsGroup = !IsOperatorBoundByMask(aOptions.mCompositionOp) &&
!aDest.Contains(clip);
!aDest.Contains(GetUserSpaceClip());
cairo_translate(mContext, aDest.X(), aDest.Y());
@ -682,13 +679,7 @@ DrawTargetCairo::FillRect(const Rect &aRect,
bool pathBoundsClip = false;
double cexts[4];
cairo_clip_extents(mContext, &cexts[0], &cexts[1], &cexts[2], &cexts[3]);
Rect clipRect(cexts[0], cexts[1], cexts[2] - cexts[0], cexts[3] - cexts[1]);
double pexts[4];
cairo_path_extents(mContext, &pexts[0], &pexts[1], &pexts[2], &pexts[3]);
Rect pathRect(pexts[0], pexts[1], pexts[2] - pexts[0], pexts[3] - pexts[1]);
if (pathRect.Contains(clipRect)) {
if (aRect.Contains(GetUserSpaceClip())) {
pathBoundsClip = true;
}
@ -1192,6 +1183,14 @@ DrawTargetCairo::SetTransform(const Matrix& aTransform)
cairo_set_matrix(mContext, &mat);
}
Rect
DrawTargetCairo::GetUserSpaceClip()
{
double clipX1, clipY1, clipX2, clipY2;
cairo_clip_extents(mContext, &clipX1, &clipY1, &clipX2, &clipY2);
return Rect(clipX1, clipY1, clipX2 - clipX1, clipY2 - clipY1); // Narrowing of doubles to floats
}
cairo_t*
BorrowedCairoContext::BorrowCairoContextFromDrawTarget(DrawTarget* aDT)
{

Просмотреть файл

@ -172,6 +172,8 @@ private: // methods
const IntRect& aSource,
const IntPoint& aDest);
Rect GetUserSpaceClip();
// Call before you make any changes to the backing surface with which this
// context is associated. Pass the path you're going to be using if you have
// one.