Bug 802491 - Always transfer ownership of direct-allocation buffers to BufferedCairoImage. r=Cwiiis
authorKartikaya Gupta <kgupta@mozilla.com>
Wed, 17 Oct 2012 09:17:20 -0400
changeset 110535 078e92572b63194b219b2193ee8e398cdbf1894d
parent 110529 353c63026073619fd1fc624c033115669c57c0a5
child 110536 59c3444a049e1eb4acbd402b46fafe76343036d5
push id23700
push userryanvm@gmail.com
push dateThu, 18 Oct 2012 02:10:26 +0000
treeherdermozilla-central@5142bbd4da12 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersCwiiis
bugs802491
milestone19.0a1
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 802491 - Always transfer ownership of direct-allocation buffers to BufferedCairoImage. r=Cwiiis
mobile/android/base/gfx/BufferedCairoImage.java
--- a/mobile/android/base/gfx/BufferedCairoImage.java
+++ b/mobile/android/base/gfx/BufferedCairoImage.java
@@ -11,32 +11,29 @@ import android.graphics.Bitmap;
 
 import java.nio.ByteBuffer;
 
 /** A Cairo image that simply saves a buffer of pixel data. */
 public class BufferedCairoImage extends CairoImage {
     private ByteBuffer mBuffer;
     private IntSize mSize;
     private int mFormat;
-    private boolean mNeedToFreeBuffer;
 
     /** Creates a buffered Cairo image from a byte buffer. */
     public BufferedCairoImage(ByteBuffer inBuffer, int inWidth, int inHeight, int inFormat) {
         setBuffer(inBuffer, inWidth, inHeight, inFormat);
     }
 
     /** Creates a buffered Cairo image from an Android bitmap. */
     public BufferedCairoImage(Bitmap bitmap) {
         setBitmap(bitmap);
     }
 
     private void freeBuffer() {
-        if (mNeedToFreeBuffer)
-            DirectBufferAllocator.free(mBuffer);
-        mNeedToFreeBuffer = false;
+        DirectBufferAllocator.free(mBuffer);
         mBuffer = null;
     }
 
     protected void finalize() throws Throwable {
         try {
             freeBuffer();
         } finally {
             super.finalize();
@@ -56,15 +53,14 @@ public class BufferedCairoImage extends 
         mBuffer = buffer;
         mSize = new IntSize(width, height);
         mFormat = format;
     }
 
     public void setBitmap(Bitmap bitmap) {
         mFormat = CairoUtils.bitmapConfigToCairoFormat(bitmap.getConfig());
         mSize = new IntSize(bitmap.getWidth(), bitmap.getHeight());
-        mNeedToFreeBuffer = true;
 
         int bpp = CairoUtils.bitsPerPixelForCairoFormat(mFormat);
         mBuffer = DirectBufferAllocator.allocate(mSize.getArea() * bpp);
         bitmap.copyPixelsToBuffer(mBuffer.asIntBuffer());
     }
 }