Remove Bitmap#getSkBitmap

Change-Id: Ifb9047b426122d3e5a445eb7a0eb3fce38dedf27
diff --git a/libs/hwui/DisplayListCanvas.cpp b/libs/hwui/DisplayListCanvas.cpp
index a7784b6..cbb6fd5 100644
--- a/libs/hwui/DisplayListCanvas.cpp
+++ b/libs/hwui/DisplayListCanvas.cpp
@@ -218,7 +218,7 @@
 }
 
 void DisplayListCanvas::drawBitmap(const SkBitmap* bitmap, const SkPaint* paint) {
-    bitmap = refBitmap(bitmap);
+    bitmap = refBitmap(*bitmap);
     paint = refPaint(paint);
 
     addDrawOp(new (alloc()) DrawBitmapOp(bitmap, paint));
@@ -284,7 +284,7 @@
                 dstRight = srcRight - srcLeft;
                 dstBottom = srcBottom - srcTop;
 
-                addDrawOp(new (alloc()) DrawBitmapRectOp(refBitmap(&bitmap),
+                addDrawOp(new (alloc()) DrawBitmapRectOp(refBitmap(bitmap),
                         srcLeft, srcTop, srcRight, srcBottom,
                         dstLeft, dstTop, dstRight, dstBottom, paint));
                 restore();
@@ -292,7 +292,7 @@
             }
         }
 
-        addDrawOp(new (alloc()) DrawBitmapRectOp(refBitmap(&bitmap),
+        addDrawOp(new (alloc()) DrawBitmapRectOp(refBitmap(bitmap),
                 srcLeft, srcTop, srcRight, srcBottom,
                 dstLeft, dstTop, dstRight, dstBottom, paint));
     }
@@ -305,17 +305,17 @@
     paint = refPaint(paint);
     colors = refBuffer<int>(colors, vertexCount); // 1 color per vertex
 
-    addDrawOp(new (alloc()) DrawBitmapMeshOp(refBitmap(&bitmap), meshWidth, meshHeight,
+    addDrawOp(new (alloc()) DrawBitmapMeshOp(refBitmap(bitmap), meshWidth, meshHeight,
            vertices, colors, paint));
 }
 
-void DisplayListCanvas::drawPatch(const SkBitmap* bitmap, const Res_png_9patch* patch,
+void DisplayListCanvas::drawPatch(const SkBitmap& bitmap, const Res_png_9patch* patch,
         float left, float top, float right, float bottom, const SkPaint* paint) {
-    bitmap = refBitmap(bitmap);
+    const SkBitmap* bitmapPtr = refBitmap(bitmap);
     patch = refPatch(patch);
     paint = refPaint(paint);
 
-    addDrawOp(new (alloc()) DrawPatchOp(bitmap, patch, left, top, right, bottom, paint));
+    addDrawOp(new (alloc()) DrawPatchOp(bitmapPtr, patch, left, top, right, bottom, paint));
 }
 
 void DisplayListCanvas::drawColor(int color, SkXfermode::Mode mode) {
diff --git a/libs/hwui/DisplayListCanvas.h b/libs/hwui/DisplayListCanvas.h
index fa4b2b4..0064236 100644
--- a/libs/hwui/DisplayListCanvas.h
+++ b/libs/hwui/DisplayListCanvas.h
@@ -98,7 +98,7 @@
     // Bitmap-based
     void drawBitmap(const SkBitmap* bitmap, const SkPaint* paint);
     // TODO: move drawPatch() to Canvas.h
-    void drawPatch(const SkBitmap* bitmap, const Res_png_9patch* patch,
+    void drawPatch(const SkBitmap& bitmap, const Res_png_9patch* patch,
             float left, float top, float right, float bottom, const SkPaint* paint);
 
     // Shapes
@@ -345,7 +345,7 @@
         return cachedRegion;
     }
 
-    inline const SkBitmap* refBitmap(const SkBitmap* bitmap) {
+    inline const SkBitmap* refBitmap(const SkBitmap& bitmap) {
         // Note that this assumes the bitmap is immutable. There are cases this won't handle
         // correctly, such as creating the bitmap from scratch, drawing with it, changing its
         // contents, and drawing again. The only fix would be to always copy it the first time,
diff --git a/libs/hwui/ResourceCache.cpp b/libs/hwui/ResourceCache.cpp
index d3b8d70..454fedc 100644
--- a/libs/hwui/ResourceCache.cpp
+++ b/libs/hwui/ResourceCache.cpp
@@ -59,13 +59,13 @@
     mLock.unlock();
 }
 
-const SkBitmap* ResourceCache::insert(const SkBitmap* bitmapResource) {
+const SkBitmap* ResourceCache::insert(const SkBitmap& bitmapResource) {
     Mutex::Autolock _l(mLock);
 
     BitmapKey bitmapKey(bitmapResource);
     ssize_t index = mBitmapCache.indexOfKey(bitmapKey);
     if (index == NAME_NOT_FOUND) {
-        SkBitmap* cachedBitmap = new SkBitmap(*bitmapResource);
+        SkBitmap* cachedBitmap = new SkBitmap(bitmapResource);
         index = mBitmapCache.add(bitmapKey, cachedBitmap);
         return cachedBitmap;
     }
@@ -121,7 +121,7 @@
 }
 
 void ResourceCache::decrementRefcountLocked(const SkBitmap* bitmapResource) {
-    BitmapKey bitmapKey(bitmapResource);
+    BitmapKey bitmapKey(*bitmapResource);
     ssize_t index = mBitmapCache.indexOfKey(bitmapKey);
 
     LOG_ALWAYS_FATAL_IF(index == NAME_NOT_FOUND,
diff --git a/libs/hwui/ResourceCache.h b/libs/hwui/ResourceCache.h
index fae55d1..6c483fa 100644
--- a/libs/hwui/ResourceCache.h
+++ b/libs/hwui/ResourceCache.h
@@ -53,11 +53,11 @@
 
 class BitmapKey {
 public:
-    BitmapKey(const SkBitmap* bitmap)
+    BitmapKey(const SkBitmap& bitmap)
         : mRefCount(1)
-        , mBitmapDimensions(bitmap->dimensions())
-        , mPixelRefOrigin(bitmap->pixelRefOrigin())
-        , mPixelRefStableID(bitmap->pixelRef()->getStableID()) { }
+        , mBitmapDimensions(bitmap.dimensions())
+        , mPixelRefOrigin(bitmap.pixelRefOrigin())
+        , mPixelRefStableID(bitmap.pixelRef()->getStableID()) { }
 
     void operator=(const BitmapKey& other);
     bool operator==(const BitmapKey& other) const;
@@ -101,7 +101,7 @@
      * The cache stores a copy of the provided resource or refs an existing resource
      * if the bitmap has previously been inserted and returns the cached copy.
      */
-    const SkBitmap* insert(const SkBitmap* resource);
+    const SkBitmap* insert(const SkBitmap& resource);
 
     void incrementRefcount(const Res_png_9patch* resource);