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

Unified Diff: src/image/SkImage_Raster.cpp

Issue 465823003: SkImage::NewFromGenerator(SkImageGenerator*), and a unit test. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix ARGB/AGBR byte order bug (edit) Created 6 years, 4 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 | « include/core/SkImage.h ('k') | tests/CachedDecodingPixelRefTest.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 e4768af0ac17865da8e8bbd22881e57a6660439e..a1cd602a0733c91c782186338acaf191c28f2fea 100644
--- a/src/image/SkImage_Raster.cpp
+++ b/src/image/SkImage_Raster.cpp
@@ -10,6 +10,7 @@
#include "SkBitmap.h"
#include "SkCanvas.h"
#include "SkData.h"
+#include "SkDecodingImageGenerator.h"
#include "SkMallocPixelRef.h"
class SkImage_Raster : public SkImage_Base {
@@ -69,6 +70,10 @@ public:
SkShader::TileMode,
const SkMatrix* localMatrix) const SK_OVERRIDE;
+ SkImage_Raster(const SkBitmap& bm)
+ : INHERITED(bm.width(), bm.height())
+ , fBitmap(bm) {}
+
private:
SkImage_Raster() : INHERITED(0, 0) {}
@@ -198,6 +203,14 @@ SkImage* SkImage::NewRasterData(const SkImageInfo& info, SkData* data, size_t ro
return SkNEW_ARGS(SkImage_Raster, (info, data, rowBytes));
}
+SkImage* SkImage::NewFromGenerator(SkImageGenerator* generator) {
+ SkBitmap bitmap;
+ if (!SkInstallDiscardablePixelRef(generator, &bitmap)) {
+ return NULL;
+ }
+ return SkNEW_ARGS(SkImage_Raster, (bitmap));
+}
+
SkImage* SkNewImageFromPixelRef(const SkImageInfo& info, SkPixelRef* pr,
size_t rowBytes) {
return SkNEW_ARGS(SkImage_Raster, (info, pr, rowBytes));
« no previous file with comments | « include/core/SkImage.h ('k') | tests/CachedDecodingPixelRefTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698