Bug 627661 - RGBA surface clear was broken in 593733 r=roc,mattwoodrow a=approval2.0
authorOleg Romashin <romaxa@gmail.com>
Mon, 24 Jan 2011 21:31:35 +0200
changeset 61181 19dc218c5da181323e1b0720d3457161dde6ee2f
parent 61180 ef150764ac976fcb8b17a40f43ce1f93e617297e
child 61182 99de13ffb4fef5d008781fff1aad06ae2e60720a
push idunknown
push userunknown
push dateunknown
reviewersroc, mattwoodrow, approval2
bugs627661, 593733
milestone2.0b10pre
Bug 627661 - RGBA surface clear was broken in 593733 r=roc,mattwoodrow a=approval2.0
gfx/layers/opengl/ThebesLayerOGL.cpp
gfx/thebes/GLContext.cpp
--- a/gfx/layers/opengl/ThebesLayerOGL.cpp
+++ b/gfx/layers/opengl/ThebesLayerOGL.cpp
@@ -590,16 +590,22 @@ BasicBufferOGL::BeginPaint(ContentType a
 
     // Using this surface as a source will likely go horribly wrong, since
     // only the onBlack surface will really be used, so alpha information will
     // be incorrect.
     surf->SetAllowUseAsSource(PR_FALSE);
     result.mContext = new gfxContext(surf);
   } else {
     result.mContext = new gfxContext(mTexImage->BeginUpdate(result.mRegionToDraw));
+    if (mTexImage->GetContentType() == gfxASurface::CONTENT_COLOR_ALPHA) {
+      gfxUtils::ClipToRegion(result.mContext, result.mRegionToDraw);
+      result.mContext->SetOperator(gfxContext::OPERATOR_CLEAR);
+      result.mContext->Fill();
+      result.mContext->SetOperator(gfxContext::OPERATOR_OVER);
+    }
   }
   if (!result.mContext) {
     NS_WARNING("unable to get context for update");
     return result;
   }
   result.mContext->Translate(-gfxPoint(quadrantRect.x, quadrantRect.y));
   // Move rgnToPaint back into position so that the thebes callback
   // gets the right coordintes.
--- a/gfx/thebes/GLContext.cpp
+++ b/gfx/thebes/GLContext.cpp
@@ -584,23 +584,16 @@ BasicTextureImage::BeginUpdate(nsIntRegi
 
     if (!mUpdateSurface || mUpdateSurface->CairoStatus()) {
         mUpdateSurface = NULL;
         return NULL;
     }
 
     mUpdateSurface->SetDeviceOffset(gfxPoint(-rgnSize.x, -rgnSize.y));
 
-    if (format == gfxASurface::ImageFormatARGB32) {
-      // Clear the returned surface because it might have been re-used.
-      nsRefPtr<gfxContext> ctx = new gfxContext(mUpdateSurface);
-      ctx->SetOperator(gfxContext::OPERATOR_CLEAR);
-      ctx->Paint();
-    }
-
     return mUpdateSurface;
 }
 
 void
 BasicTextureImage::EndUpdate()
 {
     NS_ASSERTION(!!mUpdateSurface, "EndUpdate() without BeginUpdate()?");