Bug 739679 - Part 5: Remove memset for 565 surfaces. r=mwoodrow
authorBenoit Girard <b56girard@gmail.com>
Wed, 18 Apr 2012 20:40:08 -0400
changeset 92204 baffceac44f944700133e2e3cf72bb2eb6dcbaf2
parent 92203 a8f489c62eb06e32c7ae90918cbfd7477664ed29
child 92205 58736fb3b00105491a603ef24125d03aca182175
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersmwoodrow
bugs739679
milestone14.0a1
Bug 739679 - Part 5: Remove memset for 565 surfaces. r=mwoodrow
gfx/layers/basic/BasicTiledThebesLayer.cpp
gfx/thebes/gfxReusableSurfaceWrapper.cpp
--- a/gfx/layers/basic/BasicTiledThebesLayer.cpp
+++ b/gfx/layers/basic/BasicTiledThebesLayer.cpp
@@ -74,29 +74,32 @@ BasicTiledLayerBuffer::PaintThebes(Basic
   mThebesLayer = aLayer;
   mCallback = aCallback;
   mCallbackData = aCallbackData;
 
 #ifdef GFX_TILEDLAYER_PREF_WARNINGS
   long start = PR_IntervalNow();
 #endif
   if (UseSinglePaintBuffer()) {
-    SAMPLE_LABEL("BasicTiledLayerBuffer", "PaintThebesSingleBuffer");
     const nsIntRect bounds = aPaintRegion.GetBounds();
-    mSinglePaintBuffer = new gfxImageSurface(gfxIntSize(bounds.width, bounds.height), GetFormat());
-    mSinglePaintBufferOffset = nsIntPoint(bounds.x, bounds.y);
+    {
+      SAMPLE_LABEL("BasicTiledLayerBuffer", "PaintThebesSingleBufferAlloc");
+      mSinglePaintBuffer = new gfxImageSurface(gfxIntSize(bounds.width, bounds.height), GetFormat(), !aLayer->CanUseOpaqueSurface());
+      mSinglePaintBufferOffset = nsIntPoint(bounds.x, bounds.y);
+    }
     nsRefPtr<gfxContext> ctxt = new gfxContext(mSinglePaintBuffer);
     ctxt->NewPath();
     ctxt->Translate(gfxPoint(-bounds.x, -bounds.y));
 #ifdef GFX_TILEDLAYER_PREF_WARNINGS
     if (PR_IntervalNow() - start > 3) {
       printf_stderr("Slow alloc %i\n", PR_IntervalNow() - start);
     }
     start = PR_IntervalNow();
 #endif
+    SAMPLE_LABEL("BasicTiledLayerBuffer", "PaintThebesSingleBufferDraw");
     mCallback(mThebesLayer, ctxt, aPaintRegion, aPaintRegion, mCallbackData);
   }
 
 #ifdef GFX_TILEDLAYER_PREF_WARNINGS
   if (PR_IntervalNow() - start > 30) {
     const nsIntRect bounds = aPaintRegion.GetBounds();
     printf_stderr("Time to draw %i: %i, %i, %i, %i\n", PR_IntervalNow() - start, bounds.x, bounds.y, bounds.width, bounds.height);
     if (aPaintRegion.IsComplex()) {
@@ -128,17 +131,17 @@ BasicTiledLayerBuffer::PaintThebes(Basic
 
 BasicTiledLayerTile
 BasicTiledLayerBuffer::ValidateTileInternal(BasicTiledLayerTile aTile,
                                             const nsIntPoint& aTileOrigin,
                                             const nsIntRect& aDirtyRect)
 {
   if (aTile == GetPlaceholderTile()) {
     gfxImageSurface* tmpTile = new gfxImageSurface(gfxIntSize(GetTileLength(), GetTileLength()),
-                                                   GetFormat());
+                                                   GetFormat(), !mThebesLayer->CanUseOpaqueSurface());
     aTile = BasicTiledLayerTile(tmpTile);
   }
 
   gfxRect drawRect(aDirtyRect.x - aTileOrigin.x, aDirtyRect.y - aTileOrigin.y,
                    aDirtyRect.width, aDirtyRect.height);
 
   // Use the gfxReusableSurfaceWrapper, which will reuse the surface
   // if the compositor no longer has a read lock, otherwise the surface
--- a/gfx/thebes/gfxReusableSurfaceWrapper.cpp
+++ b/gfx/thebes/gfxReusableSurfaceWrapper.cpp
@@ -56,17 +56,17 @@ gfxReusableSurfaceWrapper::GetWritable(g
   NS_CheckThreadSafe(_mOwningThread.GetThread(), "Only the owner thread can call GetWritable");
 
   if (mReadCount == 0) {
     *aSurface = mSurface;
     return this;
   }
 
   // Something else is reading the surface, copy it
-  gfxImageSurface* copySurface = new gfxImageSurface(mSurface->GetSize(), mSurface->Format());
+  gfxImageSurface* copySurface = new gfxImageSurface(mSurface->GetSize(), mSurface->Format(), false);
   copySurface->CopyFrom(mSurface);
   *aSurface = copySurface;
 
   // We need to create a new wrapper since this wrapper has a read only lock.
   gfxReusableSurfaceWrapper* wrapper = new gfxReusableSurfaceWrapper(copySurface);
   return wrapper;
 }