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

Unified Diff: src/codec/SkCodec.cpp

Issue 1372973002: Move all knowledge of X sampling into SkScaledCodec (Closed) Base URL: https://skia.googlesource.com/skia.git@codecSDmerge
Patch Set: Fix ico, sampling Created 5 years, 3 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
Index: src/codec/SkCodec.cpp
diff --git a/src/codec/SkCodec.cpp b/src/codec/SkCodec.cpp
index cabcadcccda5c872b69834daa18bbe1701be82fd..54d529d20e143d4727c2ddb56b36ddb4c13b5ed2 100644
--- a/src/codec/SkCodec.cpp
+++ b/src/codec/SkCodec.cpp
@@ -152,7 +152,21 @@ SkCodec::Result SkCodec::getPixels(const SkImageInfo& info, void* pixels, size_t
Options optsStorage;
if (nullptr == options) {
options = &optsStorage;
+ } else if (options->fSubset) {
msarett 2015/10/01 19:34:33 I'm guessing that, for some reason (maybe the kSub
scroggo 2015/10/01 21:16:57 That is correct. I don't think this is best long t
+ SkIRect subset(*options->fSubset);
+ if (!this->onGetValidSubset(&subset) || subset != *options->fSubset) {
+ // FIXME: How to differentiate between not supporting subset at all
+ // and not supporting this particular subset?
+ return kUnimplemented;
+ }
+ }
+
+ // FIXME: Support subsets somehow? Note that this works for SkWebpCodec
msarett 2015/10/01 19:34:33 There's a couple ways we could go about this, I do
scroggo 2015/10/01 21:16:57 Yeah, I considered that. I decided to punt that un
msarett 2015/10/01 22:53:07 That makes perfect sense.
+ // because it supports arbitrary scaling/subset combinations.
+ if (!this->dimensionsSupported(info.dimensions())) {
+ return kInvalidScale;
}
+
const Result result = this->onGetPixels(info, pixels, rowBytes, *options, ctable, ctableCount);
if ((kIncompleteInput == result || kSuccess == result) && ctableCount) {
@@ -190,6 +204,18 @@ SkCodec::Result SkCodec::startScanlineDecode(const SkImageInfo& dstInfo,
Options optsStorage;
if (nullptr == options) {
options = &optsStorage;
+ } else if (options->fSubset) {
+ SkIRect subset(*options->fSubset);
+ if (!this->onGetValidSubset(&subset) || subset != *options->fSubset) {
+ // FIXME: How to differentiate between not supporting subset at all
+ // and not supporting this particular subset?
+ return kUnimplemented;
+ }
+ }
+
+ // FIXME: Support subsets somehow?
+ if (!this->dimensionsSupported(dstInfo.dimensions())) {
+ return kInvalidScale;
}
const Result result = this->onStartScanlineDecode(dstInfo, *options, ctable, ctableCount);
@@ -213,8 +239,14 @@ SkCodec::Result SkCodec::getScanlines(void* dst, int countLines, size_t rowBytes
}
SkASSERT(!fDstInfo.isEmpty());
- if ((rowBytes < fDstInfo.minRowBytes() && countLines > 1 ) || countLines <= 0
- || fCurrScanline + countLines > fDstInfo.height()) {
+
+ if (rowBytes < fDstInfo.minRowBytes() && countLines > 1) {
+ // FIXME: This check breaks down when we sample without letting SkCodec
scroggo 2015/10/01 15:33:14 The problem shows up when we want to scale down an
msarett 2015/10/01 19:34:33 I've deleted this check in my scaled subsetting CL
scroggo 2015/10/01 21:16:57 Done.
+ // know about it.
+ // return kInvalidParameters;
+ }
+
+ if (countLines <= 0 || fCurrScanline + countLines > fDstInfo.height()) {
return kInvalidParameters;
}

Powered by Google App Engine
This is Rietveld 408576698