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

Unified Diff: dm/DMSrcSink.cpp

Issue 1010903003: Add scanline decoding to SkCodec. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Cleanups 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 | « no previous file | include/codec/SkCodec.h » ('j') | include/codec/SkCodec.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dm/DMSrcSink.cpp
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp
index 5ca66c50e207c4809f41396e907d354d4d78a17d..3de6e06ed9428345b458dab00e536f070233c5f7 100644
--- a/dm/DMSrcSink.cpp
+++ b/dm/DMSrcSink.cpp
@@ -9,11 +9,12 @@
#include "SkOSFile.h"
#include "SkPictureRecorder.h"
#include "SkRandom.h"
-#include "SkSVGCanvas.h"
+#include "SkScanlineDecoder.h"
#include "SkStream.h"
+#include "SkSVGCanvas.h"
#include "SkXMLWriter.h"
-DEFINE_bool(codec, false, "Use SkCodec instead of SkImageDecoder");
+DEFINE_bool(codec, true, "Use SkCodec instead of SkImageDecoder");
namespace DM {
@@ -68,19 +69,29 @@ Error ImageSrc::draw(SkCanvas* canvas) const {
info.width(), info.height());
}
SkAutoLockPixels alp(bitmap);
- const SkImageGenerator::Result result = codec->getPixels(info, bitmap.getPixels(),
- bitmap.rowBytes());
- switch (result) {
- case SkImageGenerator::kSuccess:
- // We consider incomplete to be valid, since we should still decode what is
- // available.
- case SkImageGenerator::kIncompleteInput:
- break;
- case SkImageGenerator::kInvalidConversion:
- return Error::Nonfatal("Incompatible colortype conversion");
- default:
- // Everything else is considered a failure.
- return SkStringPrintf("Couldn't getPixels %s.", fPath.c_str());
+ SkAutoTDelete<SkScanlineDecoder> scanlineDecoder(codec->getScanlineDecoder(info));
+ if (NULL == scanlineDecoder) {
+ return Error::Nonfatal("Cannot use scanline decoder for all images");
+ }
+
+ for (int y = 0; y < info.height(); ++y) {
+ const SkImageGenerator::Result result =
+ scanlineDecoder->getNextScanline(bitmap.getAddr(0, y));
+ switch (result) {
+ case SkImageGenerator::kSuccess:
+ // We consider incomplete to be valid, since we should still decode what is
+ // available.
+ case SkImageGenerator::kIncompleteInput:
+ break;
+ default:
+ // Everything else is considered a failure.
+ return SkStringPrintf("Couldn't getPixels %s.", fPath.c_str());
+ }
+ }
+
+ const SkImageGenerator::Result result = scanlineDecoder->finish();
+ if (result != SkImageGenerator::kSuccess) {
+ return SkStringPrintf("failed in finish!");
}
} else {
if (!SkImageDecoder::DecodeMemory(encoded->data(), encoded->size(), &bitmap,
« no previous file with comments | « no previous file | include/codec/SkCodec.h » ('j') | include/codec/SkCodec.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698