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

Side by Side Diff: include/codec/SkAndroidCodec.h

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 | « no previous file | include/codec/SkCodec.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 #ifndef SkAndroidCodec_DEFINED 8 #ifndef SkAndroidCodec_DEFINED
9 #define SkAndroidCodec_DEFINED 9 #define SkAndroidCodec_DEFINED
10 10
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 static SkAndroidCodec* NewFromData(SkData*, SkPngChunkReader* = NULL); 43 static SkAndroidCodec* NewFromData(SkData*, SkPngChunkReader* = NULL);
44 44
45 virtual ~SkAndroidCodec() {} 45 virtual ~SkAndroidCodec() {}
46 46
47 47
48 const SkImageInfo& getInfo() const { return fInfo; } 48 const SkImageInfo& getInfo() const { return fInfo; }
49 49
50 /** 50 /**
51 * Format of the encoded data. 51 * Format of the encoded data.
52 */ 52 */
53 SkEncodedFormat getEncodedFormat() const { return this->onGetEncodedFormat() ; } 53 SkEncodedFormat getEncodedFormat() const { return fCodec->getEncodedFormat() ; }
54 54
55 /** 55 /**
56 * Returns the dimensions of the scaled output image, for an input 56 * Returns the dimensions of the scaled output image, for an input
57 * sampleSize. 57 * sampleSize.
58 * 58 *
59 * When the sample size divides evenly into the original dimensions, the 59 * When the sample size divides evenly into the original dimensions, the
60 * scaled output dimensions will simply be equal to the original 60 * scaled output dimensions will simply be equal to the original
61 * dimensions divided by the sample size. 61 * dimensions divided by the sample size.
62 * 62 *
63 * When the sample size does not divide even into the original 63 * When the sample size does not divide even into the original
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 const AndroidOptions* options); 201 const AndroidOptions* options);
202 202
203 /** 203 /**
204 * Simplified version of getAndroidPixels() where we supply the default And roidOptions. 204 * Simplified version of getAndroidPixels() where we supply the default And roidOptions.
205 * 205 *
206 * This will return an error if the info is kIndex_8_SkColorType and also w ill not perform 206 * This will return an error if the info is kIndex_8_SkColorType and also w ill not perform
207 * any scaling or subsetting. 207 * any scaling or subsetting.
208 */ 208 */
209 SkCodec::Result getAndroidPixels(const SkImageInfo& info, void* pixels, size _t rowBytes); 209 SkCodec::Result getAndroidPixels(const SkImageInfo& info, void* pixels, size _t rowBytes);
210 210
211 /**
212 * Some images may initially report that they have alpha due to the format
213 * of the encoded data, but then never use any colors which have alpha
214 * less than 100%. This function can be called *after* decoding to
215 * determine if such an image truly had alpha. Calling it before decoding
216 * is undefined.
217 * FIXME: see skbug.com/3582.
218 */
219 bool reallyHasAlpha() const {
220 return fCodec->reallyHasAlpha();
221 }
222
211 protected: 223 protected:
212 224
213 SkAndroidCodec(const SkImageInfo&); 225 SkAndroidCodec(SkCodec*);
214 226
215 virtual SkEncodedFormat onGetEncodedFormat() const = 0; 227 SkCodec* codec() const { return fCodec.get(); }
216 228
217 virtual SkISize onGetSampledDimensions(int sampleSize) const = 0; 229 virtual SkISize onGetSampledDimensions(int sampleSize) const = 0;
218 230
219 virtual bool onGetSupportedSubset(SkIRect* desiredSubset) const = 0; 231 virtual bool onGetSupportedSubset(SkIRect* desiredSubset) const = 0;
220 232
221 virtual SkCodec::Result onGetAndroidPixels(const SkImageInfo& info, void* pi xels, 233 virtual SkCodec::Result onGetAndroidPixels(const SkImageInfo& info, void* pi xels,
222 size_t rowBytes, const AndroidOptions& options) = 0; 234 size_t rowBytes, const AndroidOptions& options) = 0;
223 235
224 private: 236 private:
225 237
226 // This will always be a reference to the info that is contained by the 238 // This will always be a reference to the info that is contained by the
227 // embedded SkCodec. 239 // embedded SkCodec.
228 const SkImageInfo& fInfo; 240 const SkImageInfo& fInfo;
241
242 SkAutoTDelete<SkCodec> fCodec;
229 }; 243 };
230 #endif // SkAndroidCodec_DEFINED 244 #endif // SkAndroidCodec_DEFINED
OLDNEW
« no previous file with comments | « no previous file | include/codec/SkCodec.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698