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

Unified Diff: src/image/SkImage_Raster.cpp

Issue 1217053003: add SkImage::NewFromBitmap (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
« no previous file with comments | « src/image/SkImage_Gpu.cpp ('k') | src/image/SkSurface_Raster.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 0316d53708aa13ecabd00c8ddc66e82b64d07daa..250e3624eaefeb8f0fc0a27d43ac5295d9e7b976 100644
--- a/src/image/SkImage_Raster.cpp
+++ b/src/image/SkImage_Raster.cpp
@@ -227,21 +227,24 @@ SkImage* SkNewImageFromPixelRef(const SkImageInfo& info, SkPixelRef* pr,
return SkNEW_ARGS(SkImage_Raster, (info, pr, pixelRefOrigin, rowBytes, props));
}
-SkImage* SkNewImageFromBitmap(const SkBitmap& bm, bool canSharePixelRef,
- const SkSurfaceProps* props) {
+SkImage* SkNewImageFromRasterBitmap(const SkBitmap& bm, bool forceSharePixelRef,
+ const SkSurfaceProps* props) {
+ SkASSERT(NULL == bm.getTexture());
+
if (!SkImage_Raster::ValidArgs(bm.info(), bm.rowBytes(), NULL, NULL)) {
return NULL;
}
SkImage* image = NULL;
- if (canSharePixelRef || bm.isImmutable()) {
+ if (forceSharePixelRef || bm.isImmutable()) {
image = SkNEW_ARGS(SkImage_Raster, (bm, props));
} else {
- bm.lockPixels();
- if (bm.getPixels()) {
- image = SkImage::NewRasterCopy(bm.info(), bm.getPixels(), bm.rowBytes());
+ SkBitmap tmp(bm);
+ tmp.lockPixels();
+ if (tmp.getPixels()) {
+ image = SkImage::NewRasterCopy(tmp.info(), tmp.getPixels(), tmp.rowBytes(),
+ tmp.getColorTable());
}
- bm.unlockPixels();
// we don't expose props to NewRasterCopy (need a private vers) so post-init it here
if (image && props) {
« no previous file with comments | « src/image/SkImage_Gpu.cpp ('k') | src/image/SkSurface_Raster.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698