Bug 593604. Part 8: Add SetAllowUseAsSource API for better diagnostics. r=jrmuizel,a=blocking

This commit is contained in:
Robert O'Callahan 2011-01-03 14:48:09 +13:00
parent 03b628b846
commit ac7bd36fb0
2 changed files with 12 additions and 1 deletions

View File

@ -220,8 +220,17 @@ public:
virtual PRBool SupportsSelfCopy() { return PR_TRUE; }
/**
* Mark the surface as being allowed/not allowed to be used as a source.
* This currently has no effect other than triggering assertions in some
* cases.
*/
void SetAllowUseAsSource(PRBool aAllow) { mAllowUseAsSource = aAllow; }
PRBool GetAllowUseAsSource() { return mAllowUseAsSource; }
protected:
gfxASurface() : mSurface(nsnull), mFloatingRefs(0), mBytesRecorded(0), mSurfaceValid(PR_FALSE)
gfxASurface() : mSurface(nsnull), mFloatingRefs(0), mBytesRecorded(0),
mSurfaceValid(PR_FALSE), mAllowUseAsSource(PR_TRUE)
{
MOZ_COUNT_CTOR(gfxASurface);
}
@ -249,6 +258,7 @@ private:
protected:
PRPackedBool mSurfaceValid;
PRPackedBool mAllowUseAsSource;
};
/**

View File

@ -692,6 +692,7 @@ gfxContext::GetDeviceColor(gfxRGBA& c)
void
gfxContext::SetSource(gfxASurface *surface, const gfxPoint& offset)
{
NS_ASSERTION(surface->GetAllowUseAsSource(), "Surface not allowed to be used as source!");
cairo_set_source_surface(mCairo, surface->CairoSurface(), offset.x, offset.y);
}