Index: src/ports/SkImageDecoder_CG.cpp |
diff --git a/src/ports/SkImageDecoder_CG.cpp b/src/ports/SkImageDecoder_CG.cpp |
index f8ec10842920440065b6d2b0d5a9ba992ba4a3e7..9fc49a445f264ffab1f2431dbb9bc6ca43a6af37 100644 |
--- a/src/ports/SkImageDecoder_CG.cpp |
+++ b/src/ports/SkImageDecoder_CG.cpp |
@@ -110,8 +110,16 @@ bool SkImageDecoder_CG::onDecode(SkStream* stream, SkBitmap* bm, Mode mode) { |
/////////////////////////////////////////////////////////////////////////////// |
+extern SkImageDecoder* image_decoder_from_stream(SkStream*); |
+ |
SkImageDecoder* SkImageDecoder::Factory(SkStream* stream) { |
- return SkNEW(SkImageDecoder_CG); |
+ SkImageDecoder* decoder = image_decoder_from_stream(stream); |
+ if (NULL == decoder) { |
+ // If no image decoder specific to the stream exists, use SkImageDecoder_CG. |
+ return SkNEW(SkImageDecoder_CG); |
+ } else { |
+ return decoder; |
+ } |
} |
///////////////////////////////////////////////////////////////////////// |
@@ -174,6 +182,15 @@ bool SkImageEncoder_CG::onEncode(SkWStream* stream, const SkBitmap& bm, |
CFStringRef type; |
switch (fType) { |
+ case kICO_Type: |
+ type = kUTTypeICO; |
+ break; |
+ case kBMP_Type: |
+ type = kUTTypeBMP; |
+ break; |
+ case kGIF_Type: |
+ type = kUTTypeGIF; |
+ break; |
case kJPEG_Type: |
type = kUTTypeJPEG; |
break; |
@@ -209,13 +226,22 @@ bool SkImageEncoder_CG::onEncode(SkWStream* stream, const SkBitmap& bm, |
return CGImageDestinationFinalize(dst); |
} |
-SkImageEncoder* SkImageEncoder::Create(Type t) { |
+/////////////////////////////////////////////////////////////////////////////// |
+ |
+#include "SkTRegistry.h" |
+ |
+static SkImageEncoder* sk_imageencoder_cg_factory(SkImageEncoder::Type t) { |
switch (t) { |
- case kJPEG_Type: |
- case kPNG_Type: |
+ case SkImageEncoder::kICO_Type: |
+ case SkImageEncoder::kBMP_Type: |
+ case SkImageEncoder::kGIF_Type: |
+ case SkImageEncoder::kJPEG_Type: |
+ case SkImageEncoder::kPNG_Type: |
break; |
default: |
return NULL; |
} |
return SkNEW_ARGS(SkImageEncoder_CG, (t)); |
} |
+ |
+static SkTRegistry<SkImageEncoder*, SkImageEncoder::Type> gEReg(sk_imageencoder_cg_factory); |