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

Side by Side Diff: src/codec/SkWebpAdapterCodec.cpp

Issue 1518743002: Add reallyHasAlpha() to SkAndroidCodec (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Change comment on onReallyHasAlpha Created 5 years 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 unified diff | Download patch
« no previous file with comments | « src/codec/SkWebpAdapterCodec.h ('k') | src/codec/SkWebpCodec.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkCodec.h" 8 #include "SkCodec.h"
9 #include "SkCodecPriv.h" 9 #include "SkCodecPriv.h"
10 #include "SkWebpAdapterCodec.h" 10 #include "SkWebpAdapterCodec.h"
11 11
12 SkWebpAdapterCodec::SkWebpAdapterCodec(SkWebpCodec* codec) 12 SkWebpAdapterCodec::SkWebpAdapterCodec(SkWebpCodec* codec)
13 : INHERITED(codec->getInfo()) 13 : INHERITED(codec)
14 , fCodec(codec)
15 {} 14 {}
16 15
17 SkISize SkWebpAdapterCodec::onGetSampledDimensions(int sampleSize) const { 16 SkISize SkWebpAdapterCodec::onGetSampledDimensions(int sampleSize) const {
18 float scale = get_scale_from_sample_size(sampleSize); 17 float scale = get_scale_from_sample_size(sampleSize);
19 return fCodec->getScaledDimensions(scale); 18 return this->codec()->getScaledDimensions(scale);
20 } 19 }
21 20
22 bool SkWebpAdapterCodec::onGetSupportedSubset(SkIRect* desiredSubset) const { 21 bool SkWebpAdapterCodec::onGetSupportedSubset(SkIRect* desiredSubset) const {
23 return fCodec->getValidSubset(desiredSubset); 22 return this->codec()->getValidSubset(desiredSubset);
24 } 23 }
25 24
26 SkCodec::Result SkWebpAdapterCodec::onGetAndroidPixels(const SkImageInfo& info, void* pixels, 25 SkCodec::Result SkWebpAdapterCodec::onGetAndroidPixels(const SkImageInfo& info, void* pixels,
27 size_t rowBytes, const AndroidOptions& options) { 26 size_t rowBytes, const AndroidOptions& options) {
28 // SkWebpCodec will support pretty much any dimensions that we provide, but we want 27 // SkWebpCodec will support pretty much any dimensions that we provide, but we want
29 // to be stricter about the type of scaling that we allow, so we will add an extra 28 // to be stricter about the type of scaling that we allow, so we will add an extra
30 // check here. 29 // check here.
31 SkISize supportedSize; 30 SkISize supportedSize;
32 if (!options.fSubset) { 31 if (!options.fSubset) {
33 supportedSize = this->onGetSampledDimensions(options.fSampleSize); 32 supportedSize = this->onGetSampledDimensions(options.fSampleSize);
34 } else { 33 } else {
35 supportedSize = this->getSampledSubsetDimensions(options.fSampleSize, *o ptions.fSubset); 34 supportedSize = this->getSampledSubsetDimensions(options.fSampleSize, *o ptions.fSubset);
36 } 35 }
37 if (supportedSize != info.dimensions()) { 36 if (supportedSize != info.dimensions()) {
38 return SkCodec::kInvalidParameters; 37 return SkCodec::kInvalidParameters;
39 } 38 }
40 39
41 SkCodec::Options codecOptions; 40 SkCodec::Options codecOptions;
42 codecOptions.fZeroInitialized = options.fZeroInitialized; 41 codecOptions.fZeroInitialized = options.fZeroInitialized;
43 codecOptions.fSubset = options.fSubset; 42 codecOptions.fSubset = options.fSubset;
44 return fCodec->getPixels(info, pixels, rowBytes, &codecOptions, options.fCol orPtr, 43 return this->codec()->getPixels(info, pixels, rowBytes, &codecOptions, optio ns.fColorPtr,
45 options.fColorCount); 44 options.fColorCount);
46 } 45 }
OLDNEW
« no previous file with comments | « src/codec/SkWebpAdapterCodec.h ('k') | src/codec/SkWebpCodec.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698