Index: src/image/SkImage_Raster.cpp |
diff --git a/src/image/SkImage_Raster.cpp b/src/image/SkImage_Raster.cpp |
index e4768af0ac17865da8e8bbd22881e57a6660439e..4841dae25c2a1c64b077fe4361cc29878f46698d 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& bitmap) |
+ :INHERITED(bitmap.width(), bitmap.height()) |
reed1
2014/08/12 13:36:09
tiny nit: space after :
|
+ , fBitmap(bitmap) { } |
+ |
private: |
SkImage_Raster() : INHERITED(0, 0) {} |
@@ -206,3 +211,17 @@ SkImage* SkNewImageFromPixelRef(const SkImageInfo& info, SkPixelRef* pr, |
SkPixelRef* SkBitmapImageGetPixelRef(SkImage* image) { |
return ((SkImage_Raster*)image)->getPixelRef(); |
} |
+ |
+SkImage* SkImage::NewEncodedData(SkData* data) { |
+ if (NULL == data) { |
+ return NULL; |
+ } |
+ SkBitmap bitmap; |
+ if (!SkInstallDiscardablePixelRef( |
+ SkDecodingImageGenerator::Create( |
+ data, SkDecodingImageGenerator::Options()), |
+ &bitmap)) { |
+ return NULL; |
+ } |
+ return SkNEW_ARGS(SkImage_Raster, (bitmap)); |
+} |