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

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: GetFormat -> GetStreamFormat 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
« no previous file with comments | « src/images/SkImageDecoder.cpp ('k') | src/images/SkImageDecoder_libbmp.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/images/SkImageDecoder_FactoryRegistrar.cpp
diff --git a/src/images/SkImageDecoder_FactoryRegistrar.cpp b/src/images/SkImageDecoder_FactoryRegistrar.cpp
index 6cc417a46f599f7c2e5264b99c5780f0e45bb416..f1eca3d03afb3b0a1297a4bb262d81c0575fd456 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::GetStreamFormat(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;
+}
« no previous file with comments | « src/images/SkImageDecoder.cpp ('k') | src/images/SkImageDecoder_libbmp.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698