зеркало из https://github.com/mozilla/gecko-dev.git
Bug 579276. Part 11: Move ClipToRegion to gfxUtils. r=vlad
This commit is contained in:
Родитель
0a8fad86d1
Коммит
dc9e28789b
|
@ -39,23 +39,11 @@
|
|||
#include "Layers.h"
|
||||
#include "gfxContext.h"
|
||||
#include "gfxPlatform.h"
|
||||
#include "gfxUtils.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
/*static*/ void
|
||||
ThebesLayerBuffer::ClipToRegion(gfxContext* aContext,
|
||||
const nsIntRegion& aRegion)
|
||||
{
|
||||
aContext->NewPath();
|
||||
nsIntRegionRectIterator iter(aRegion);
|
||||
const nsIntRect* r;
|
||||
while ((r = iter.Next()) != nsnull) {
|
||||
aContext->Rectangle(gfxRect(r->x, r->y, r->width, r->height));
|
||||
}
|
||||
aContext->Clip();
|
||||
}
|
||||
|
||||
nsIntRect
|
||||
ThebesLayerBuffer::GetQuadrantRectangle(XSide aXSide, YSide aYSide)
|
||||
{
|
||||
|
@ -238,7 +226,7 @@ ThebesLayerBuffer::BeginPaint(ThebesLayer* aLayer, ContentType aContentType)
|
|||
NS_ASSERTION(quadrantRect.Contains(drawBounds), "Messed up quadrants");
|
||||
result.mContext->Translate(-gfxPoint(quadrantRect.x, quadrantRect.y));
|
||||
|
||||
ClipToRegion(result.mContext, result.mRegionToDraw);
|
||||
gfxUtils::ClipToRegion(result.mContext, result.mRegionToDraw);
|
||||
if (aContentType == gfxASurface::CONTENT_COLOR_ALPHA && !isClear) {
|
||||
result.mContext->SetOperator(gfxContext::OPERATOR_CLEAR);
|
||||
result.mContext->Paint();
|
||||
|
|
|
@ -140,9 +140,6 @@ public:
|
|||
gfxASurface* GetBuffer() { return mBuffer; }
|
||||
|
||||
protected:
|
||||
// XXX make me a general utility
|
||||
static void ClipToRegion(gfxContext* aContext, const nsIntRegion& aRegion);
|
||||
|
||||
enum XSide {
|
||||
LEFT, RIGHT
|
||||
};
|
||||
|
|
|
@ -454,7 +454,7 @@ BasicThebesLayerBuffer::DrawTo(ThebesLayer* aLayer,
|
|||
float aOpacity)
|
||||
{
|
||||
aTarget->Save();
|
||||
ClipToRegion(aTarget, aLayer->GetVisibleRegion());
|
||||
gfxUtils::ClipToRegion(aTarget, aLayer->GetVisibleRegion());
|
||||
if (aIsOpaqueContent) {
|
||||
aTarget->SetOperator(gfxContext::OPERATOR_SOURCE);
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include "gfxContext.h"
|
||||
#include "gfxPlatform.h"
|
||||
#include "gfxDrawable.h"
|
||||
#include "nsRegion.h"
|
||||
|
||||
#if defined(XP_WIN) || defined(WINCE)
|
||||
#include "gfxWindowsPlatform.h"
|
||||
|
@ -418,3 +419,27 @@ gfxUtils::DrawPixelSnapped(gfxContext* aContext,
|
|||
aContext->SetOperator(op);
|
||||
}
|
||||
|
||||
static void
|
||||
ClipToRegionInternal(gfxContext* aContext, const nsIntRegion& aRegion,
|
||||
PRBool aSnap)
|
||||
{
|
||||
aContext->NewPath();
|
||||
nsIntRegionRectIterator iter(aRegion);
|
||||
const nsIntRect* r;
|
||||
while ((r = iter.Next()) != nsnull) {
|
||||
aContext->Rectangle(gfxRect(r->x, r->y, r->width, r->height), aSnap);
|
||||
}
|
||||
aContext->Clip();
|
||||
}
|
||||
|
||||
/*static*/ void
|
||||
gfxUtils::ClipToRegion(gfxContext* aContext, const nsIntRegion& aRegion)
|
||||
{
|
||||
ClipToRegionInternal(aContext, aRegion, PR_FALSE);
|
||||
}
|
||||
|
||||
/*static*/ void
|
||||
gfxUtils::ClipToRegionSnapped(gfxContext* aContext, const nsIntRegion& aRegion)
|
||||
{
|
||||
ClipToRegionInternal(aContext, aRegion, PR_TRUE);
|
||||
}
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
#include "gfxImageSurface.h"
|
||||
|
||||
class gfxDrawable;
|
||||
class nsIntRegion;
|
||||
|
||||
class THEBES_API gfxUtils {
|
||||
public:
|
||||
|
@ -83,6 +84,16 @@ public:
|
|||
const gfxRect& aFill,
|
||||
const gfxImageSurface::gfxImageFormat aFormat,
|
||||
const gfxPattern::GraphicsFilter& aFilter);
|
||||
|
||||
/**
|
||||
* Clip aContext to the region aRegion.
|
||||
*/
|
||||
static void ClipToRegion(gfxContext* aContext, const nsIntRegion& aRegion);
|
||||
|
||||
/**
|
||||
* Clip aContext to the region aRegion, snapping the rectangles.
|
||||
*/
|
||||
static void ClipToRegionSnapped(gfxContext* aContext, const nsIntRegion& aRegion);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Загрузка…
Ссылка в новой задаче