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

Unified Diff: src/codec/SkCodec.cpp

Issue 1010813003: Revert of Bmp Image Decoding (Closed) Base URL: https://skia.googlesource.com/skia.git@decode-leon-3
Patch Set: Created 5 years, 9 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 | « include/codec/SkCodec.h ('k') | src/codec/SkCodecPriv.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/codec/SkCodec.cpp
diff --git a/src/codec/SkCodec.cpp b/src/codec/SkCodec.cpp
index ba1cf02c9e318f9baffb024e9a7c4dfcf00021fb..ec36bc75e94e00edd22b857b179a9033a95fe5c1 100644
--- a/src/codec/SkCodec.cpp
+++ b/src/codec/SkCodec.cpp
@@ -7,36 +7,24 @@
#include "SkCodec.h"
#include "SkData.h"
-#include "SkCodec_libbmp.h"
#include "SkCodec_libpng.h"
#include "SkStream.h"
-
-struct DecoderProc {
- bool (*IsFormat)(SkStream*);
- SkCodec* (*NewFromStream)(SkStream*);
-};
-
-static const uint32_t gNumDecoderProcs = 2;
-
-static const DecoderProc gDecoderProcs[] = {
- { SkPngCodec::IsPng, SkPngCodec::NewFromStream },
- { SkBmpCodec::IsBmp, SkBmpCodec::NewFromStream }
-};
SkCodec* SkCodec::NewFromStream(SkStream* stream) {
if (!stream) {
return NULL;
}
- for (uint32_t i = 0; i < gNumDecoderProcs; i++) {
- DecoderProc proc = gDecoderProcs[i];
- const bool correctFormat = proc.IsFormat(stream);
- if (!stream->rewind()) {
- return NULL;
- }
- if (correctFormat) {
- return proc.NewFromStream(stream);
- }
+ SkAutoTDelete<SkStream> streamDeleter(stream);
+ const bool isPng = SkPngCodec::IsPng(stream);
+ // TODO: Avoid rewinding.
+ if (!stream->rewind()) {
+ return NULL;
}
+ if (isPng) {
+ streamDeleter.detach();
+ return SkPngCodec::NewFromStream(stream);
+ }
+ // TODO: Check other image types.
return NULL;
}
« no previous file with comments | « include/codec/SkCodec.h ('k') | src/codec/SkCodecPriv.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698