Bug 623852. gfxContext::PushGroupAndCopyBackground should not try to copy the background if the underlying surface cannot be used as a source. r=mstange,a=blocking
authorRobert O'Callahan <robert@ocallahan.org>
Sat, 15 Jan 2011 22:40:33 +1300
changeset 60644 4c3416fdc7b08f1c175c8dead07e68b7531395c6
parent 60643 7307131094a53697631409a97e4ade39f27f9452
child 60645 43a6717878fae85b927229a4b3150b736b7b39d5
push idunknown
push userunknown
push dateunknown
reviewersmstange, blocking
bugs623852
milestone2.0b10pre
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 623852. gfxContext::PushGroupAndCopyBackground should not try to copy the background if the underlying surface cannot be used as a source. r=mstange,a=blocking
gfx/thebes/gfxASurface.h
gfx/thebes/gfxContext.cpp
widget/src/cocoa/nsChildView.mm
--- a/gfx/thebes/gfxASurface.h
+++ b/gfx/thebes/gfxASurface.h
@@ -217,18 +217,16 @@ public:
         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), mAllowUseAsSource(PR_TRUE)
     {
--- a/gfx/thebes/gfxContext.cpp
+++ b/gfx/thebes/gfxContext.cpp
@@ -767,18 +767,19 @@ CopySurface(gfxASurface* aSrc, gfxASurfa
   cairo_destroy(cr);
 }
 
 void
 gfxContext::PushGroupAndCopyBackground(gfxASurface::gfxContentType content)
 {
     if (content == gfxASurface::CONTENT_COLOR_ALPHA) {
         nsRefPtr<gfxASurface> s = CurrentSurface();
-        if (s->GetContentType() == gfxASurface::CONTENT_COLOR ||
-            s->GetOpaqueRect().Contains(GetRoundOutDeviceClipExtents(this))) {
+        if ((s->GetAllowUseAsSource() || s->GetType() == gfxASurface::SurfaceTypeTee) &&
+            (s->GetContentType() == gfxASurface::CONTENT_COLOR ||
+             s->GetOpaqueRect().Contains(GetRoundOutDeviceClipExtents(this)))) {
             cairo_push_group_with_content(mCairo, CAIRO_CONTENT_COLOR);
             nsRefPtr<gfxASurface> d = CurrentSurface();
 
             if (d->GetType() == gfxASurface::SurfaceTypeTee) {
                 NS_ASSERTION(s->GetType() == gfxASurface::SurfaceTypeTee, "Mismatched types");
                 nsAutoTArray<nsRefPtr<gfxASurface>,2> ss;
                 nsAutoTArray<nsRefPtr<gfxASurface>,2> ds;
                 static_cast<gfxTeeSurface*>(s.get())->GetSurfaces(&ss);
--- a/widget/src/cocoa/nsChildView.mm
+++ b/widget/src/cocoa/nsChildView.mm
@@ -2731,16 +2731,17 @@ NSEvent* gLastDragMouseDownEvent = nil;
     mGeckoChild->DispatchWindowEvent(paintEvent);
     return;
   }
 
   // Create Cairo objects.
   NSSize bufferSize = [self bounds].size;
   nsRefPtr<gfxQuartzSurface> targetSurface =
     new gfxQuartzSurface(aContext, gfxSize(bufferSize.width, bufferSize.height));
+  targetSurface->SetAllowUseAsSource(PR_FALSE);
 
   nsRefPtr<gfxContext> targetContext = new gfxContext(targetSurface);
 
   // Set up the clip region.
   nsIntRegionRectIterator iter(paintEvent.region);
   targetContext->NewPath();
   for (;;) {
     const nsIntRect* r = iter.Next();