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

Unified Diff: dm/DMSrcSink.cpp

Issue 999173010: Test scanline decoding in DM. (Closed) Base URL: https://skia.googlesource.com/skia.git@scanlineDecoder3
Patch Set: Fix order of output 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 | « dm/DMSrcSink.h ('k') | no next file » | no next file with comments »
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 06e1fe746e148b035eb5bbcaba59e39646d49823..74258083cec3603e64ab81b0e2bc23d6b874ee1e 100644
--- a/dm/DMSrcSink.cpp
+++ b/dm/DMSrcSink.cpp
@@ -17,6 +17,7 @@
#include "SkPictureData.h"
#include "SkPictureRecorder.h"
#include "SkRandom.h"
+#include "SkScanlineDecoder.h"
#include "SkSVGCanvas.h"
#include "SkStream.h"
#include "SkXMLWriter.h"
@@ -44,7 +45,7 @@ Name GMSrc::name() const {
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-CodecSrc::CodecSrc(Path path) : fPath(path) {}
+CodecSrc::CodecSrc(Path path, Mode mode) : fPath(path), fMode(mode) {}
Error CodecSrc::draw(SkCanvas* canvas) const {
SkImageInfo canvasInfo;
@@ -76,20 +77,43 @@ Error CodecSrc::draw(SkCanvas* canvas) const {
decodeInfo.width(), decodeInfo.height());
}
- 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());
+ switch (fMode) {
+ case kNormal_Mode:
+ 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:
+ 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());
+ }
+ break;
+ case kScanline_Mode: {
+ 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:
+ case SkImageGenerator::kIncompleteInput:
+ break;
+ default:
+ return SkStringPrintf("%s failed after %d scanlines with error message %d",
+ fPath.c_str(), y-1, (int) result);
+ }
+ }
+ break;
+ }
}
+ canvas->drawBitmap(bitmap, 0, 0);
+ return "";
}
SkISize CodecSrc::size() const {
« no previous file with comments | « dm/DMSrcSink.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698