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

Unified Diff: src/codec/SkAndroidCodec.cpp

Issue 1417583009: Combine native sampling with sampling (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Work around missing initializer_list on mac 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 | « dm/DM.cpp ('k') | src/codec/SkSampledCodec.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/codec/SkAndroidCodec.cpp
diff --git a/src/codec/SkAndroidCodec.cpp b/src/codec/SkAndroidCodec.cpp
index 43ed90f6c0be67cea075f4c23f578065afae1b5e..086caf2d8129f30e00de197802e2358ff24a2a99 100644
--- a/src/codec/SkAndroidCodec.cpp
+++ b/src/codec/SkAndroidCodec.cpp
@@ -53,6 +53,11 @@ SkISize SkAndroidCodec::getSampledDimensions(int sampleSize) const {
return SkISize::Make(0, 0);
}
+ // Fast path for when we are not scaling.
+ if (1 == sampleSize) {
+ return fInfo.dimensions();
+ }
+
return this->onGetSampledDimensions(sampleSize);
}
@@ -77,9 +82,9 @@ SkISize SkAndroidCodec::getSampledSubsetDimensions(int sampleSize, const SkIRect
return SkISize::Make(0, 0);
}
- // If the subset is the entire image, for consistency, use onGetSampledDimensions().
+ // If the subset is the entire image, for consistency, use getSampledDimensions().
if (fInfo.dimensions() == subset.size()) {
- return onGetSampledDimensions(sampleSize);
+ return this->getSampledDimensions(sampleSize);
}
// This should perhaps call a virtual function, but currently both of our subclasses
@@ -104,6 +109,15 @@ SkCodec::Result SkAndroidCodec::getAndroidPixels(const SkImageInfo& info, void*
if (!is_valid_subset(*options->fSubset, fInfo.dimensions())) {
return SkCodec::kInvalidParameters;
}
+
+ if (SkIRect::MakeSize(fInfo.dimensions()) == *options->fSubset) {
+ // The caller wants the whole thing, rather than a subset. Modify
+ // the AndroidOptions passed to onGetAndroidPixels to not specify
+ // a subset.
+ defaultOptions = *options;
+ defaultOptions.fSubset = nullptr;
+ options = &defaultOptions;
+ }
}
return this->onGetAndroidPixels(info, pixels, rowBytes, *options);
« no previous file with comments | « dm/DM.cpp ('k') | src/codec/SkSampledCodec.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698