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

Unified Diff: src/image/SkImage_Raster.cpp

Issue 1266143003: lock pixels in image when bitmap is immutable and not-lazy (Closed) Base URL: https://skia.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 7b5cf9bb1ba10caf2e82bfda8fa70d0e5c679355..60c2eb0ca7e7a8c3839001473aa6c56861be7ad9 100644
--- a/src/image/SkImage_Raster.cpp
+++ b/src/image/SkImage_Raster.cpp
@@ -81,10 +81,13 @@ public:
bool isOpaque() const override;
bool onAsLegacyBitmap(SkBitmap*, LegacyBitmapMode) const override;
- SkImage_Raster(const SkBitmap& bm, const SkSurfaceProps* props, bool lockPixels = false)
+ SkImage_Raster(const SkBitmap& bm, const SkSurfaceProps* props)
: INHERITED(bm.width(), bm.height(), bm.getGenerationID(), props)
- , fBitmap(bm) {
- if (lockPixels) {
+ , fBitmap(bm)
+ {
+ if (bm.pixelRef()->isPreLocked()) {
+ // we only preemptively lock if there is no chance of triggering something expensive
+ // like a lazy decode or imagegenerator. PreLocked means it is flat pixels already.
fBitmap.lockPixels();
}
SkASSERT(fBitmap.isImmutable());
@@ -237,7 +240,7 @@ SkImage* SkNewImageFromPixelRef(const SkImageInfo& info, SkPixelRef* pr,
}
SkImage* SkNewImageFromRasterBitmap(const SkBitmap& bm, const SkSurfaceProps* props,
- SharedPixelRefMode mode, ForceCopyMode forceCopy) {
+ ForceCopyMode forceCopy) {
SkASSERT(NULL == bm.getTexture());
if (!SkImage_Raster::ValidArgs(bm.info(), bm.rowBytes(), NULL, NULL)) {
@@ -258,7 +261,7 @@ SkImage* SkNewImageFromRasterBitmap(const SkBitmap& bm, const SkSurfaceProps* pr
as_IB(image)->initWithProps(*props);
}
} else {
- image = SkNEW_ARGS(SkImage_Raster, (bm, props, kLocked_SharedPixelRefMode == mode));
+ image = SkNEW_ARGS(SkImage_Raster, (bm, props));
}
return image;
}

Powered by Google App Engine
This is Rietveld 408576698