| 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;
|
| +}
|
|
|