OLD | NEW |
---|---|
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 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
271 Result getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, con st Options*, | 271 Result getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, con st Options*, |
272 SkPMColor ctable[], int* ctableCount); | 272 SkPMColor ctable[], int* ctableCount); |
273 | 273 |
274 /** | 274 /** |
275 * Simplified version of getPixels() that asserts that info is NOT kIndex8_ SkColorType and | 275 * Simplified version of getPixels() that asserts that info is NOT kIndex8_ SkColorType and |
276 * uses the default Options. | 276 * uses the default Options. |
277 */ | 277 */ |
278 Result getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes); | 278 Result getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes); |
279 | 279 |
280 /** | 280 /** |
281 * If decoding to YUV is supported, this returns true and populates "sizes" with | |
282 * the appropriate sizes of the Y, U, and V planes. | |
283 */ | |
284 bool getYUV8Sizes(SkISize sizes[3]) const { | |
scroggo
2016/01/04 18:29:15
crrev.com/863053002 proposed suggesting both a log
msarett
2016/01/04 21:46:46
I think this is the hard question for this API. I
msarett
2016/01/12 14:25:27
I have invented "widthBytes" which almost means th
| |
285 if (nullptr == sizes) { | |
286 return false; | |
287 } | |
288 | |
289 return this->onGetYUV8Sizes(sizes); | |
290 } | |
291 | |
292 /** | |
scroggo
2016/01/04 18:29:15
nit: Typically the first line will describe genera
msarett
2016/01/12 14:25:27
Done.
| |
293 * @param sizes Sizes of each of the Y, U, and V planes | |
294 * @param pixels Memory for each of the Y, U, and V planes | |
scroggo
2016/01/04 18:29:15
Maybe this is just due to my lack of knowledge abo
msarett
2016/01/04 21:46:46
Will add comments. Each Y, U, or V sample is a si
msarett
2016/01/12 14:25:27
Added more detail.
| |
295 * @param rowBytes Row bytes for each of the Y, U, and V planes | |
296 * @param colorSpace If nullptr, this parameter is ignored. Otherwise, | |
scroggo
2016/01/04 18:29:15
Do we need this here? In https://codereview.chromi
msarett
2016/01/04 21:46:46
Happy to add this to the query step.
What is this
| |
297 * if the decode is successful, this will bet set to | |
298 * kJPEG_SkYUVColorSpace (JPEG is currently the only | |
299 * format that supports YUV). | |
300 * | |
301 * Returns kSuccess, or another value explaining the type of failure. | |
302 * This always attempts to perform a full decode. If the client only | |
303 * wants size, it should call getYUV8Sizes(). | |
304 */ | |
305 Result getYUV8Planes(SkISize sizes[3], void* pixels[3], size_t rowBytes[3], | |
reed1
2016/01/04 15:50:55
can sizes[] be const? Seems much simplier if they
scroggo
2016/01/04 18:29:15
Looks like rowBytes can also be const?
Alternativ
msarett
2016/01/04 21:46:46
Depends on how we choose to deal with AllocatedSiz
msarett
2016/01/12 14:25:27
Using structs now.
"sizes" and "widthBytes" are c
| |
306 SkYUVColorSpace* colorSpace) { | |
307 if (nullptr == sizes || nullptr == pixels || nullptr == pixels[0] || | |
308 nullptr == pixels[1] || nullptr == pixels[2] || nullptr == rowBy tes) { | |
309 return kInvalidInput; | |
310 } | |
311 | |
312 if (!this->rewindIfNeeded()) { | |
313 return kCouldNotRewind; | |
314 } | |
315 | |
316 return this->onGetYUV8Planes(sizes, pixels, rowBytes, colorSpace); | |
317 } | |
318 | |
319 /** | |
281 * Some images may initially report that they have alpha due to the format | 320 * Some images may initially report that they have alpha due to the format |
282 * of the encoded data, but then never use any colors which have alpha | 321 * of the encoded data, but then never use any colors which have alpha |
283 * less than 100%. This function can be called *after* decoding to | 322 * less than 100%. This function can be called *after* decoding to |
284 * determine if such an image truly had alpha. Calling it before decoding | 323 * determine if such an image truly had alpha. Calling it before decoding |
285 * is undefined. | 324 * is undefined. |
286 * FIXME: see skbug.com/3582. | 325 * FIXME: see skbug.com/3582. |
287 */ | 326 */ |
288 bool reallyHasAlpha() const { | 327 bool reallyHasAlpha() const { |
289 return kOpaque_SkAlphaType != this->getInfo().alphaType() && this->onRea llyHasAlpha(); | 328 return kOpaque_SkAlphaType != this->getInfo().alphaType() && this->onRea llyHasAlpha(); |
290 } | 329 } |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
447 * is located in the encoded data. | 486 * is located in the encoded data. |
448 * | 487 * |
449 * This will equal inputScanline, except in the case of strangely | 488 * This will equal inputScanline, except in the case of strangely |
450 * encoded image types (bottom-up bmps, interlaced gifs). | 489 * encoded image types (bottom-up bmps, interlaced gifs). |
451 */ | 490 */ |
452 int outputScanline(int inputScanline) const; | 491 int outputScanline(int inputScanline) const; |
453 | 492 |
454 protected: | 493 protected: |
455 SkCodec(const SkImageInfo&, SkStream*); | 494 SkCodec(const SkImageInfo&, SkStream*); |
456 | 495 |
457 virtual SkISize onGetScaledDimensions(float /* desiredScale */) const { | 496 virtual SkISize onGetScaledDimensions(float /*desiredScale*/) const { |
458 // By default, scaling is not supported. | 497 // By default, scaling is not supported. |
459 return this->getInfo().dimensions(); | 498 return this->getInfo().dimensions(); |
460 } | 499 } |
461 | 500 |
462 // FIXME: What to do about subsets?? | 501 // FIXME: What to do about subsets?? |
463 /** | 502 /** |
464 * Subclasses should override if they support dimensions other than the | 503 * Subclasses should override if they support dimensions other than the |
465 * srcInfo's. | 504 * srcInfo's. |
466 */ | 505 */ |
467 virtual bool onDimensionsSupported(const SkISize&) { | 506 virtual bool onDimensionsSupported(const SkISize&) { |
468 return false; | 507 return false; |
469 } | 508 } |
470 | 509 |
471 virtual SkEncodedFormat onGetEncodedFormat() const = 0; | 510 virtual SkEncodedFormat onGetEncodedFormat() const = 0; |
472 | 511 |
473 /** | 512 /** |
474 * @param rowsDecoded When the encoded image stream is incomplete, this func tion | 513 * @param rowsDecoded When the encoded image stream is incomplete, this func tion |
475 * will return kIncompleteInput and rowsDecoded will be s et to | 514 * will return kIncompleteInput and rowsDecoded will be s et to |
476 * the number of scanlines that were successfully decoded . | 515 * the number of scanlines that were successfully decoded . |
477 * This will allow getPixels() to fill the uninitialized memory. | 516 * This will allow getPixels() to fill the uninitialized memory. |
478 */ | 517 */ |
479 virtual Result onGetPixels(const SkImageInfo& info, | 518 virtual Result onGetPixels(const SkImageInfo& info, |
480 void* pixels, size_t rowBytes, const Options&, | 519 void* pixels, size_t rowBytes, const Options&, |
481 SkPMColor ctable[], int* ctableCount, | 520 SkPMColor ctable[], int* ctableCount, |
482 int* rowsDecoded) = 0; | 521 int* rowsDecoded) = 0; |
483 | 522 |
484 virtual bool onGetValidSubset(SkIRect* /* desiredSubset */) const { | 523 virtual bool onGetYUV8Sizes(SkISize* /*sizes*/) const { |
524 return false; | |
525 } | |
526 | |
527 virtual Result onGetYUV8Planes(SkISize* /*sizes*/, void** /*pixels*/, size_t * /*rowBytes*/, | |
scroggo
2016/01/04 18:29:15
Why does this use different notations from getYUV8
| |
528 SkYUVColorSpace* /*colorSpace*/) { | |
529 return kUnimplemented; | |
530 } | |
531 | |
532 virtual bool onGetValidSubset(SkIRect* /*desiredSubset*/) const { | |
485 // By default, subsets are not supported. | 533 // By default, subsets are not supported. |
486 return false; | 534 return false; |
487 } | 535 } |
488 | 536 |
489 /** | 537 /** |
490 * This is only called if the image indicates that it is not opaque. | 538 * This is only called if the image indicates that it is not opaque. |
491 * By default we will assume that the image is in fact non-opaque. | 539 * By default we will assume that the image is in fact non-opaque. |
492 * Subclasses may override this function if they intend to verify | 540 * Subclasses may override this function if they intend to verify |
493 * that the image actually has alpha. | 541 * that the image actually has alpha. |
494 */ | 542 */ |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
649 * not affect ownership. | 697 * not affect ownership. |
650 * | 698 * |
651 * Only valid during scanline decoding. | 699 * Only valid during scanline decoding. |
652 */ | 700 */ |
653 virtual SkSampler* getSampler(bool /*createIfNecessary*/) { return nullptr; } | 701 virtual SkSampler* getSampler(bool /*createIfNecessary*/) { return nullptr; } |
654 | 702 |
655 friend class SkSampledCodec; | 703 friend class SkSampledCodec; |
656 friend class SkIcoCodec; | 704 friend class SkIcoCodec; |
657 }; | 705 }; |
658 #endif // SkCodec_DEFINED | 706 #endif // SkCodec_DEFINED |
OLD | NEW |