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 |