Bug 593604. Part 8: Add SetAllowUseAsSource API for better diagnostics. r=jrmuizel,a=blocking
authorRobert O'Callahan <robert@ocallahan.org>
Mon, 03 Jan 2011 14:48:09 +1300
changeset 59772 27debc14ea67200b859a57c3649269b3696ac9f2
parent 59771 9fd3423cae84e2479a00ec4fc135e7c5184c6482
child 59773 431218b437ab386458d3e64f346d99124fa66e5b
push idunknown
push userunknown
push dateunknown
reviewersjrmuizel, blocking
bugs593604
milestone2.0b9pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 593604. Part 8: Add SetAllowUseAsSource API for better diagnostics. r=jrmuizel,a=blocking
gfx/thebes/gfxASurface.h
gfx/thebes/gfxContext.cpp
--- a/gfx/thebes/gfxASurface.h
+++ b/gfx/thebes/gfxASurface.h
@@ -215,18 +215,27 @@ public:
         if (mOpaqueRect)
             return *mOpaqueRect;
         static const gfxRect empty(0, 0, 0, 0);
         return empty;
     }
 
     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);
     }
 
     static gfxASurface* GetSurfaceWrapper(cairo_surface_t *csurf);
     static void SetSurfaceWrapper(cairo_surface_t *csurf, gfxASurface *asurf);
 
     void Init(cairo_surface_t *surface, PRBool existingSurface = PR_FALSE);
@@ -244,16 +253,17 @@ protected:
 private:
     static void SurfaceDestroyFunc(void *data);
 
     PRInt32 mFloatingRefs;
     PRInt32 mBytesRecorded;
 
 protected:
     PRPackedBool mSurfaceValid;
+    PRPackedBool mAllowUseAsSource;
 };
 
 /**
  * An Unknown surface; used to wrap unknown cairo_surface_t returns from cairo
  */
 class THEBES_API gfxUnknownSurface : public gfxASurface {
 public:
     gfxUnknownSurface(cairo_surface_t *surf) {
--- a/gfx/thebes/gfxContext.cpp
+++ b/gfx/thebes/gfxContext.cpp
@@ -687,16 +687,17 @@ gfxContext::GetDeviceColor(gfxRGBA& c)
                                   &c.g,
                                   &c.b,
                                   &c.a) == CAIRO_STATUS_SUCCESS;
 }
 
 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);
 }
 
 void
 gfxContext::SetPattern(gfxPattern *pattern)
 {
     cairo_set_source(mCairo, pattern->CairoPattern());
 }