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

Unified Diff: src/core/SkSpecialImage.cpp

Issue 2183483003: lock special-raster while the caller's bitmap is in-scope (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: undo flag Created 4 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkSpecialImage.cpp
diff --git a/src/core/SkSpecialImage.cpp b/src/core/SkSpecialImage.cpp
index fa7cbc6f6e112d9f44122c7a681ffdf1a27cb98e..c10e88e0ca99f6203eb66d6f711039302839f1a9 100644
--- a/src/core/SkSpecialImage.cpp
+++ b/src/core/SkSpecialImage.cpp
@@ -209,12 +209,15 @@ class SkSpecialImage_Raster : public SkSpecialImage_Base {
public:
SkSpecialImage_Raster(const SkIRect& subset, const SkBitmap& bm, const SkSurfaceProps* props)
: INHERITED(subset, bm.getGenerationID(), props)
- , fBitmap(bm) {
- if (bm.pixelRef() && 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();
- }
+ , fBitmap(bm)
+ {
+ SkASSERT(bm.pixelRef());
+
+ // We have to lock now, while bm is still in scope, since it may have come from our
+ // cache, which means we need to keep it locked until we (the special) are done, since
+ // we cannot re-generate the cache entry (if bm came from a generator).
+ fBitmap.lockPixels();
+ SkASSERT(fBitmap.getPixels());
}
bool isOpaque() const override { return fBitmap.isOpaque(); }
@@ -292,6 +295,10 @@ sk_sp<SkSpecialImage> SkSpecialImage::MakeFromRaster(const SkIRect& subset,
const SkSurfaceProps* props) {
SkASSERT(rect_fits(subset, bm.width(), bm.height()));
+ if (!bm.pixelRef()) {
+ return nullptr;
+ }
+
const SkBitmap* srcBM = &bm;
SkBitmap tmpStorage;
// ImageFilters only handle N32 at the moment, so force our src to be that
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698