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

Unified Diff: dm/DMSrcSink.cpp

Issue 1010903003: Add scanline decoding to SkCodec. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Small 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 638f6708343ec6c8b24dcb5d35cde124cbfc5452..29c6800505026254c18d403a6f4b595c1d265db3 100644
--- a/dm/DMSrcSink.cpp
+++ b/dm/DMSrcSink.cpp
@@ -10,8 +10,9 @@
#include "SkPictureData.h"
#include "SkPictureRecorder.h"
#include "SkRandom.h"
-#include "SkSVGCanvas.h"
+#include "SkScanlineDecoder.h"
#include "SkStream.h"
+#include "SkSVGCanvas.h"
#include "SkXMLWriter.h"
namespace DM {
@@ -70,19 +71,32 @@ Error CodecSrc::draw(SkCanvas* canvas) const {
}
SkAutoLockPixels alp(bitmap);
- switch (codec->getPixels(decodeInfo, bitmap.getPixels(), bitmap.rowBytes())) {
- case SkImageGenerator::kSuccess:
- // We consider incomplete to be valid, since we should still decode what is
- // available.
- case SkImageGenerator::kIncompleteInput:
- canvas->drawBitmap(bitmap, 0, 0);
- return "";
- 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());
+ SkScanlineDecoder* scanlineDecoder = codec->getScanlineDecoder(decodeInfo);
+ if (NULL == scanlineDecoder) {
+ return Error::Nonfatal("Cannot use scanline decoder for all images");
+ }
+
+ for (int y = 0; y < decodeInfo.height(); ++y) {
+ const SkImageGenerator::Result result =
+ scanlineDecoder->getScanlines(bitmap.getAddr(0, y), 1, 0);
+ 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!");
+ }
+ canvas->drawBitmap(bitmap, 0, 0);
+ return "";
}
SkISize CodecSrc::size() const {
« 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