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

Unified Diff: src/image/SkImage_Raster.cpp

Issue 1256993002: Make peekPixels() usable with raster surface snapshots (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: 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
Index: src/image/SkImage_Raster.cpp
diff --git a/src/image/SkImage_Raster.cpp b/src/image/SkImage_Raster.cpp
index aac4995cfba9deb91edf1470e6f6904677be0e2d..12c355a6b8761a29cb38a216f3ba961c7aa2fe41 100644
--- a/src/image/SkImage_Raster.cpp
+++ b/src/image/SkImage_Raster.cpp
@@ -81,9 +81,13 @@ public:
bool isOpaque() const override;
bool onAsLegacyBitmap(SkBitmap*, LegacyBitmapMode) const override;
- SkImage_Raster(const SkBitmap& bm, const SkSurfaceProps* props)
+ SkImage_Raster(const SkBitmap& bm, const SkSurfaceProps* props, bool lockPixels = false)
: INHERITED(bm.width(), bm.height(), props)
- , fBitmap(bm) {}
+ , fBitmap(bm) {
+ if (lockPixels) {
+ fBitmap.lockPixels();
+ }
+ }
private:
SkImage_Raster() : INHERITED(0, 0, NULL) {}
@@ -229,7 +233,7 @@ SkImage* SkNewImageFromPixelRef(const SkImageInfo& info, SkPixelRef* pr,
}
SkImage* SkNewImageFromRasterBitmap(const SkBitmap& bm, bool forceSharePixelRef,
- const SkSurfaceProps* props) {
+ const SkSurfaceProps* props, bool lockSharedPixelRef) {
SkASSERT(NULL == bm.getTexture());
if (!SkImage_Raster::ValidArgs(bm.info(), bm.rowBytes(), NULL, NULL)) {
@@ -238,7 +242,7 @@ SkImage* SkNewImageFromRasterBitmap(const SkBitmap& bm, bool forceSharePixelRef,
SkImage* image = NULL;
if (forceSharePixelRef || bm.isImmutable()) {
- image = SkNEW_ARGS(SkImage_Raster, (bm, props));
+ image = SkNEW_ARGS(SkImage_Raster, (bm, props, lockSharedPixelRef));
} else {
SkBitmap tmp(bm);
tmp.lockPixels();

Powered by Google App Engine
This is Rietveld 408576698