Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Unified Diff: src/image/SkImage_Raster.cpp

Issue 1208993017: Add image->bitmap (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add check for immutable Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/image/SkImage_Base.h ('k') | tests/SurfaceTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/image/SkImage_Raster.cpp
diff --git a/src/image/SkImage_Raster.cpp b/src/image/SkImage_Raster.cpp
index 250e3624eaefeb8f0fc0a27d43ac5295d9e7b976..489685b2fc5bcfad3aa90dcf284fa2ebad2c019b 100644
--- a/src/image/SkImage_Raster.cpp
+++ b/src/image/SkImage_Raster.cpp
@@ -79,6 +79,7 @@ public:
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 @@ bool SkImage_Raster::isOpaque() const {
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);
+}
« no previous file with comments | « src/image/SkImage_Base.h ('k') | tests/SurfaceTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698