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

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

Issue 1260673002: SkScaledCodec class (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: use SkWebpCodec native scaling, update comments and spacing 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 , fSampled(false)
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 /**
166 * If true, the codec is being sampled
scroggo 2015/07/27 19:29:57 This could be more concise, e.g. Whether the code
167 * If false, the codec is not being sampled
168 * The default value is false
169 * Used to determine if dstDimensions can be different than srcDimension s
scroggo 2015/07/27 19:29:57 To be fair, dstDimensions can be different than sr
msarett 2015/07/27 20:42:17 +1 for some sort of int fSampleSize with 1 as the
scroggo 2015/07/27 20:47:24 We're in charge of the Android code, so we should
emmaleer 2015/07/28 14:19:16 I've change bool fSampled to int fSampleX. setSamp
170 */
171 bool fSampled;
164 }; 172 };
165 173
166 /** 174 /**
167 * Decode into the given pixels, a block of memory of size at 175 * Decode into the given pixels, a block of memory of size at
168 * least (info.fHeight - 1) * rowBytes + (info.fWidth * 176 * least (info.fHeight - 1) * rowBytes + (info.fWidth *
169 * bytesPerPixel) 177 * bytesPerPixel)
170 * 178 *
171 * Repeated calls to this function should give the same results, 179 * Repeated calls to this function should give the same results,
172 * allowing the PixelRef to be immutable. 180 * allowing the PixelRef to be immutable.
173 * 181 *
(...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 245 * 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 246 * less than 100%. This function can be called *after* decoding to
239 * determine if such an image truly had alpha. Calling it before decoding 247 * determine if such an image truly had alpha. Calling it before decoding
240 * is undefined. 248 * is undefined.
241 * FIXME: see skbug.com/3582. 249 * FIXME: see skbug.com/3582.
242 */ 250 */
243 bool reallyHasAlpha() const { 251 bool reallyHasAlpha() const {
244 return this->onReallyHasAlpha(); 252 return this->onReallyHasAlpha();
245 } 253 }
246 254
255 /**
256 * returns true if the image is interlaced
scroggo 2015/07/27 19:29:57 These two lines can be more concise, e.g. Retur
emmaleer 2015/07/28 14:19:16 Yes, I think it's good to explain how the entire i
257 * returns false if the image is not interlaced
258 */
259 bool isInterlaced() {
260 return this->onIsInterlaced();
261 }
262
247 protected: 263 protected:
248 SkCodec(const SkImageInfo&, SkStream*); 264 SkCodec(const SkImageInfo&, SkStream*);
249 265
250 virtual SkISize onGetScaledDimensions(float /* desiredScale */) const { 266 virtual SkISize onGetScaledDimensions(float /* desiredScale */) const {
251 // By default, scaling is not supported. 267 // By default, scaling is not supported.
252 return this->getInfo().dimensions(); 268 return this->getInfo().dimensions();
253 } 269 }
254 270
255 virtual SkEncodedFormat onGetEncodedFormat() const = 0; 271 virtual SkEncodedFormat onGetEncodedFormat() const = 0;
256 272
(...skipping 25 matching lines...) Expand all
282 */ 298 */
283 virtual SkScanlineDecoder* onGetScanlineDecoder(const SkImageInfo& dstInfo, 299 virtual SkScanlineDecoder* onGetScanlineDecoder(const SkImageInfo& dstInfo,
284 const Options& options, 300 const Options& options,
285 SkPMColor ctable[], 301 SkPMColor ctable[],
286 int* ctableCount) { 302 int* ctableCount) {
287 return NULL; 303 return NULL;
288 } 304 }
289 305
290 virtual bool onReallyHasAlpha() const { return false; } 306 virtual bool onReallyHasAlpha() const { return false; }
291 307
308 /**
309 * returns true if the image is interlaced
310 * returns false if the image is not interlaced
311 * only certain file types can have interlaced images, those of which overri de this function
312 */
313 virtual bool onIsInterlaced() { return false; }
314
292 enum RewindState { 315 enum RewindState {
293 kRewound_RewindState, 316 kRewound_RewindState,
294 kNoRewindNecessary_RewindState, 317 kNoRewindNecessary_RewindState,
295 kCouldNotRewind_RewindState 318 kCouldNotRewind_RewindState
296 }; 319 };
297 /** 320 /**
298 * If the stream was previously read, attempt to rewind. 321 * If the stream was previously read, attempt to rewind.
299 * @returns: 322 * @returns:
300 * kRewound if the stream needed to be rewound, and the 323 * kRewound if the stream needed to be rewound, and the
301 * rewind succeeded. 324 * rewind succeeded.
(...skipping 14 matching lines...) Expand all
316 SkStream* stream() { 339 SkStream* stream() {
317 return fStream.get(); 340 return fStream.get();
318 } 341 }
319 342
320 private: 343 private:
321 const SkImageInfo fInfo; 344 const SkImageInfo fInfo;
322 SkAutoTDelete<SkStream> fStream; 345 SkAutoTDelete<SkStream> fStream;
323 bool fNeedsRewind; 346 bool fNeedsRewind;
324 }; 347 };
325 #endif // SkCodec_DEFINED 348 #endif // SkCodec_DEFINED
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698