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

Unified Diff: src/image/SkImage_Raster.cpp

Issue 2199813002: make an image from a mutable bitmap (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fixx mmy spilling 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 | « src/image/SkImagePriv.h ('k') | tests/ImageTest.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 a8ef21d1da90a747b403a5a459030ac4450810bc..df82c3f3028b363f8ef5f432bba8de284402fa5e 100644
--- a/src/image/SkImage_Raster.cpp
+++ b/src/image/SkImage_Raster.cpp
@@ -94,7 +94,7 @@ public:
bool isOpaque() const override;
bool onAsLegacyBitmap(SkBitmap*, LegacyBitmapMode) const override;
- SkImage_Raster(const SkBitmap& bm)
+ SkImage_Raster(const SkBitmap& bm, bool bitmapMayBeMutable = false)
: INHERITED(bm.width(), bm.height(),
is_not_subset(bm) ? bm.getGenerationID()
: (uint32_t)kNeedNewImageUniqueID)
@@ -105,7 +105,7 @@ public:
// like a lazy decode or imagegenerator. PreLocked means it is flat pixels already.
fBitmap.lockPixels();
}
- SkASSERT(fBitmap.isImmutable());
+ SkASSERT(bitmapMayBeMutable || fBitmap.isImmutable());
}
bool onIsLazyGenerated() const override {
@@ -264,7 +264,9 @@ sk_sp<SkImage> SkMakeImageFromRasterBitmap(const SkBitmap& bm, ForceCopyMode for
}
sk_sp<SkImage> image;
- if (kYes_ForceCopyMode == forceCopy || !bm.isImmutable()) {
+ if (kYes_ForceCopyMode == forceCopy ||
+ (!bm.isImmutable() && kNever_ForceCopyMode != forceCopy))
+ {
SkBitmap tmp(bm);
tmp.lockPixels();
SkPixmap pmap;
@@ -272,7 +274,7 @@ sk_sp<SkImage> SkMakeImageFromRasterBitmap(const SkBitmap& bm, ForceCopyMode for
image = SkImage::MakeRasterCopy(pmap);
}
} else {
- image = sk_make_sp<SkImage_Raster>(bm);
+ image = sk_make_sp<SkImage_Raster>(bm, kNever_ForceCopyMode == forceCopy);
}
return image;
}
« no previous file with comments | « src/image/SkImagePriv.h ('k') | tests/ImageTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698