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

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

Issue 1260673002: SkScaledCodec class (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 4 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 unified diff | Download patch
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 SkCodec_DEFINED 8 #ifndef SkCodec_DEFINED
9 #define SkCodec_DEFINED 9 #define SkCodec_DEFINED
10 10
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 kNo_ZeroInitialized, 142 kNo_ZeroInitialized,
143 }; 143 };
144 144
145 /** 145 /**
146 * Additional options to pass to getPixels. 146 * Additional options to pass to getPixels.
147 */ 147 */
148 struct Options { 148 struct Options {
149 Options() 149 Options()
150 : fZeroInitialized(kNo_ZeroInitialized) 150 : fZeroInitialized(kNo_ZeroInitialized)
151 , fSubset(NULL) 151 , fSubset(NULL)
152 , fScaled(0)
scroggo 2015/07/27 15:09:19 nit: false
emmaleer 2015/07/27 18:31:38 Acknowledged.
152 {} 153 {}
153 154
154 ZeroInitialized fZeroInitialized; 155 ZeroInitialized fZeroInitialized;
155 /** 156 /**
156 * If not NULL, represents a subset of the original image to decode. 157 * If not NULL, represents a subset of the original image to decode.
157 * 158 *
158 * Must be within the bounds returned by getInfo(). 159 * Must be within the bounds returned by getInfo().
159 * 160 *
160 * If the EncodedFormat is kWEBP_SkEncodedFormat (the only one which 161 * If the EncodedFormat is kWEBP_SkEncodedFormat (the only one which
161 * currently supports subsets), the top and left values must be even. 162 * currently supports subsets), the top and left values must be even.
162 */ 163 */
163 SkIRect* fSubset; 164 SkIRect* fSubset;
165 bool fScaled;
scroggo 2015/07/27 15:09:19 please add comments explaining how this is used (a
emmaleer 2015/07/27 18:31:38 Acknowledged.
164 }; 166 };
165 167
166 /** 168 /**
167 * Decode into the given pixels, a block of memory of size at 169 * Decode into the given pixels, a block of memory of size at
168 * least (info.fHeight - 1) * rowBytes + (info.fWidth * 170 * least (info.fHeight - 1) * rowBytes + (info.fWidth *
169 * bytesPerPixel) 171 * bytesPerPixel)
170 * 172 *
171 * Repeated calls to this function should give the same results, 173 * Repeated calls to this function should give the same results,
172 * allowing the PixelRef to be immutable. 174 * allowing the PixelRef to be immutable.
173 * 175 *
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 * of the encoded data, but then never use any colors which have alpha 239 * of the encoded data, but then never use any colors which have alpha
238 * less than 100%. This function can be called *after* decoding to 240 * less than 100%. This function can be called *after* decoding to
239 * determine if such an image truly had alpha. Calling it before decoding 241 * determine if such an image truly had alpha. Calling it before decoding
240 * is undefined. 242 * is undefined.
241 * FIXME: see skbug.com/3582. 243 * FIXME: see skbug.com/3582.
242 */ 244 */
243 bool reallyHasAlpha() const { 245 bool reallyHasAlpha() const {
244 return this->onReallyHasAlpha(); 246 return this->onReallyHasAlpha();
245 } 247 }
246 248
249 bool isInterlaced() {
scroggo 2015/07/27 15:09:19 Please add comments, here and on the virtual metho
emmaleer 2015/07/27 18:31:38 Acknowledged.
250 return this->onIsInterlaced();
251 }
252
247 protected: 253 protected:
248 SkCodec(const SkImageInfo&, SkStream*); 254 SkCodec(const SkImageInfo&, SkStream*);
249 255
250 virtual SkISize onGetScaledDimensions(float /* desiredScale */) const { 256 virtual SkISize onGetScaledDimensions(float /* desiredScale */) const {
251 // By default, scaling is not supported. 257 // By default, scaling is not supported.
252 return this->getInfo().dimensions(); 258 return this->getInfo().dimensions();
253 } 259 }
254 260
255 virtual SkEncodedFormat onGetEncodedFormat() const = 0; 261 virtual SkEncodedFormat onGetEncodedFormat() const = 0;
256 262
(...skipping 24 matching lines...) Expand all
281 * responsible for deleting the returned object. 287 * responsible for deleting the returned object.
282 */ 288 */
283 virtual SkScanlineDecoder* onGetScanlineDecoder(const SkImageInfo& dstInfo, 289 virtual SkScanlineDecoder* onGetScanlineDecoder(const SkImageInfo& dstInfo,
284 const Options& options, 290 const Options& options,
285 SkPMColor ctable[], 291 SkPMColor ctable[],
286 int* ctableCount) { 292 int* ctableCount) {
287 return NULL; 293 return NULL;
288 } 294 }
289 295
290 virtual bool onReallyHasAlpha() const { return false; } 296 virtual bool onReallyHasAlpha() const { return false; }
297 virtual bool onIsInterlaced() { return false; }
291 298
292 enum RewindState { 299 enum RewindState {
293 kRewound_RewindState, 300 kRewound_RewindState,
294 kNoRewindNecessary_RewindState, 301 kNoRewindNecessary_RewindState,
295 kCouldNotRewind_RewindState 302 kCouldNotRewind_RewindState
296 }; 303 };
297 /** 304 /**
298 * If the stream was previously read, attempt to rewind. 305 * If the stream was previously read, attempt to rewind.
299 * @returns: 306 * @returns:
300 * kRewound if the stream needed to be rewound, and the 307 * kRewound if the stream needed to be rewound, and the
(...skipping 15 matching lines...) Expand all
316 SkStream* stream() { 323 SkStream* stream() {
317 return fStream.get(); 324 return fStream.get();
318 } 325 }
319 326
320 private: 327 private:
321 const SkImageInfo fInfo; 328 const SkImageInfo fInfo;
322 SkAutoTDelete<SkStream> fStream; 329 SkAutoTDelete<SkStream> fStream;
323 bool fNeedsRewind; 330 bool fNeedsRewind;
324 }; 331 };
325 #endif // SkCodec_DEFINED 332 #endif // SkCodec_DEFINED
OLDNEW
« no previous file with comments | « gyp/codec.gyp ('k') | include/codec/SkScaledCodec.h » ('j') | include/codec/SkScaledCodec.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698