Add image->bitmap
BUG=skia:
patch from issue 1212163012 at patchset 1 (http://crrev.com/1212163012#ps1)
Review URL: https://codereview.chromium.org/1208993017
diff --git a/src/image/SkImage_Raster.cpp b/src/image/SkImage_Raster.cpp
index 250e362..489685b 100644
--- a/src/image/SkImage_Raster.cpp
+++ b/src/image/SkImage_Raster.cpp
@@ -79,6 +79,7 @@
const SkMatrix* localMatrix) const override;
bool isOpaque() const override;
+ bool onAsLegacyBitmap(SkBitmap*, LegacyBitmapMode) const override;
SkImage_Raster(const SkBitmap& bm, const SkSurfaceProps* props)
: INHERITED(bm.width(), bm.height(), props)
@@ -262,3 +263,17 @@
return fBitmap.isOpaque();
}
+bool SkImage_Raster::onAsLegacyBitmap(SkBitmap* bitmap, LegacyBitmapMode mode) const {
+ if (kRO_LegacyBitmapMode == mode) {
+ // When we're a snapshot from a surface, our bitmap may not be marked immutable
+ // even though logically always we are, but in that case we can't physically share our
+ // pixelref since the caller might call setImmutable() themselves
+ // (thus changing our state).
+ if (fBitmap.isImmutable()) {
+ bitmap->setInfo(fBitmap.info());
+ bitmap->setPixelRef(fBitmap.pixelRef(), fBitmap.pixelRefOrigin());
+ return true;
+ }
+ }
+ return this->INHERITED::onAsLegacyBitmap(bitmap, mode);
+}