Merge "Fix issue with SkPaint references being out of date."
diff --git a/include/core/SkBitmap.h b/include/core/SkBitmap.h
index 1c16b78..1def198 100644
--- a/include/core/SkBitmap.h
+++ b/include/core/SkBitmap.h
@@ -396,10 +396,15 @@
     int extractMipLevel(SkBitmap* dst, SkFixed sx, SkFixed sy);
 
     void extractAlpha(SkBitmap* dst) const {
-        this->extractAlpha(dst, NULL, NULL);
+        this->extractAlpha(dst, NULL, NULL, NULL);
     }
 
     void extractAlpha(SkBitmap* dst, const SkPaint* paint,
+                      SkIPoint* offset) const {
+        this->extractAlpha(dst, paint, NULL, offset);
+    }
+
+    void extractAlpha(SkBitmap* dst, const SkPaint* paint, Allocator* allocator,
                       SkIPoint* offset) const;
 
     void flatten(SkFlattenableWriteBuffer&) const;
diff --git a/include/core/SkMallocPixelRef.h b/include/core/SkMallocPixelRef.h
index b6a013d..1c36b74 100644
--- a/include/core/SkMallocPixelRef.h
+++ b/include/core/SkMallocPixelRef.h
@@ -49,8 +49,9 @@
 
     SkMallocPixelRef(SkFlattenableReadBuffer& buffer);
 
-private:
     void*           fStorage;
+
+private:
     size_t          fSize;
     SkColorTable*   fCTable;
 
diff --git a/include/core/SkPixelRef.h b/include/core/SkPixelRef.h
index 82e5ca7..fceef4d 100644
--- a/include/core/SkPixelRef.h
+++ b/include/core/SkPixelRef.h
@@ -112,6 +112,18 @@
     virtual Factory getFactory() const { return NULL; }
     virtual void flatten(SkFlattenableWriteBuffer&) const;
 
+    /** Acquire a "global" ref on this object.
+    * The default implementation just calls ref(), but subclasses can override
+    * this method to implement additional behavior.
+    */
+    virtual void globalRef();
+
+    /** Release a "global" ref on this object.
+    * The default implementation just calls unref(), but subclasses can override
+    * this method to implement additional behavior.
+    */
+    virtual void globalUnref();
+
     static Factory NameToFactory(const char name[]);
     static const char* FactoryToName(Factory);
     static void Register(const char name[], Factory);
diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp
index 0276897..e7d9537 100644
--- a/src/core/SkBitmap.cpp
+++ b/src/core/SkBitmap.cpp
@@ -1114,7 +1114,7 @@
 #include "SkMatrix.h"
 
 void SkBitmap::extractAlpha(SkBitmap* dst, const SkPaint* paint,
-                            SkIPoint* offset) const {
+                            Allocator *allocator, SkIPoint* offset) const {
     SkDEBUGCODE(this->validate();)
 
     SkMatrix    identity;
@@ -1138,7 +1138,7 @@
     NO_FILTER_CASE:
         dst->setConfig(SkBitmap::kA8_Config, this->width(), this->height(),
                        srcM.fRowBytes);
-        dst->allocPixels();
+        dst->allocPixels(allocator, NULL);
         GetBitmapAlpha(*this, dst->getAddr8(0, 0), srcM.fRowBytes);
         if (offset) {
             offset->set(0, 0);
@@ -1157,7 +1157,7 @@
 
     dst->setConfig(SkBitmap::kA8_Config, dstM.fBounds.width(),
                    dstM.fBounds.height(), dstM.fRowBytes);
-    dst->allocPixels();
+    dst->allocPixels(allocator, NULL);
     memcpy(dst->getPixels(), dstM.fImage, dstM.computeImageSize());
     if (offset) {
         offset->set(dstM.fBounds.fLeft, dstM.fBounds.fTop);
diff --git a/src/core/SkPixelRef.cpp b/src/core/SkPixelRef.cpp
index e096d63..3decdb4 100644
--- a/src/core/SkPixelRef.cpp
+++ b/src/core/SkPixelRef.cpp
@@ -128,3 +128,10 @@
     return NULL;
 }
 
+void SkPixelRef::globalRef() {
+    ref();
+}
+
+void SkPixelRef::globalUnref() {
+    unref();
+}