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

Unified Diff: src/images/SkImageDecoder_FactoryRegistrar.cpp

Issue 14363003: Updates to skimage tool to use it for testing. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Fix a potential crash in SkImageDecoder_CG. Created 7 years, 8 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
Index: src/images/SkImageDecoder_FactoryRegistrar.cpp
diff --git a/src/images/SkImageDecoder_FactoryRegistrar.cpp b/src/images/SkImageDecoder_FactoryRegistrar.cpp
index 6cc417a46f599f7c2e5264b99c5780f0e45bb416..032c354ef0be757de4f777da626c7d1752b3e8e4 100644
--- a/src/images/SkImageDecoder_FactoryRegistrar.cpp
+++ b/src/images/SkImageDecoder_FactoryRegistrar.cpp
@@ -5,6 +5,7 @@
* found in the LICENSE file.
*/
+#include "SkErrorInternals.h"
#include "SkImageDecoder.h"
#include "SkStream.h"
#include "SkTRegistry.h"
@@ -45,3 +46,24 @@ SkImageDecoder* image_decoder_from_stream(SkStream* stream) {
}
return NULL;
}
+
+typedef SkTRegistry<SkImageDecoder::Format, SkStream*> FormatReg;
+
+template FormatReg* SkTRegistry<SkImageDecoder::Format, SkStream*>::gHead;
+
+SkImageDecoder::Format SkImageDecoder::GetFormat(SkStream* stream) {
+ const FormatReg* curr = FormatReg::Head();
+ while (curr != NULL) {
+ Format format = curr->factory()(stream);
+ if (!stream->rewind()) {
+ SkErrorInternals::SetError(kInvalidOperation_SkError,
+ "Unable to rewind the image stream\n");
+ return kUnknown_Format;
+ }
+ if (format != kUnknown_Format) {
+ return format;
+ }
+ curr = curr->next();
+ }
+ return kUnknown_Format;
+}

Powered by Google App Engine
This is Rietveld 408576698