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

Unified Diff: src/codec/SkCodec.cpp

Issue 1472863003: Revert of Add SkPngChunkReader. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 1 month 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/core/SkPngChunkReader.h ('k') | src/codec/SkCodec_libpng.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 11eb1f98479461b7307695ac49d44cde6f85cecb..071a4b837121301a34edce31dc51f96bd05e30bc 100644
--- a/src/codec/SkCodec.cpp
+++ b/src/codec/SkCodec.cpp
@@ -25,6 +25,7 @@
};
static const DecoderProc gDecoderProcs[] = {
+ { SkPngCodec::IsPng, SkPngCodec::NewFromStream },
#if !defined(GOOGLE3)
{ SkJpegCodec::IsJpeg, SkJpegCodec::NewFromStream },
#endif
@@ -35,8 +36,7 @@
{ SkWbmpCodec::IsWbmp, SkWbmpCodec::NewFromStream }
};
-SkCodec* SkCodec::NewFromStream(SkStream* stream,
- SkPngChunkReader* chunkReader) {
+SkCodec* SkCodec::NewFromStream(SkStream* stream) {
if (!stream) {
return nullptr;
}
@@ -44,24 +44,15 @@
SkAutoTDelete<SkStream> streamDeleter(stream);
SkAutoTDelete<SkCodec> codec(nullptr);
- // PNG is special, since we want to be able to supply an SkPngChunkReader.
- // But this code follows the same pattern as the loop.
- const bool isPng = SkPngCodec::IsPng(stream);
- if (!stream->rewind()) {
- return NULL;
- }
- if (isPng) {
- codec.reset(SkPngCodec::NewFromStream(streamDeleter.detach(), chunkReader));
- } else {
- for (DecoderProc proc : gDecoderProcs) {
- const bool correctFormat = proc.IsFormat(stream);
- if (!stream->rewind()) {
- return nullptr;
- }
- if (correctFormat) {
- codec.reset(proc.NewFromStream(streamDeleter.detach()));
- break;
- }
+ for (uint32_t i = 0; i < SK_ARRAY_COUNT(gDecoderProcs); i++) {
+ DecoderProc proc = gDecoderProcs[i];
+ const bool correctFormat = proc.IsFormat(stream);
+ if (!stream->rewind()) {
+ return nullptr;
+ }
+ if (correctFormat) {
+ codec.reset(proc.NewFromStream(streamDeleter.detach()));
+ break;
}
}
@@ -77,11 +68,11 @@
}
}
-SkCodec* SkCodec::NewFromData(SkData* data, SkPngChunkReader* reader) {
+SkCodec* SkCodec::NewFromData(SkData* data) {
if (!data) {
return nullptr;
}
- return NewFromStream(new SkMemoryStream(data), reader);
+ return NewFromStream(new SkMemoryStream(data));
}
SkCodec::SkCodec(const SkImageInfo& info, SkStream* stream)
« no previous file with comments | « include/core/SkPngChunkReader.h ('k') | src/codec/SkCodec_libpng.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698