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

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

Issue 1549473003: Add getYUV8Planes() API to SkCodec (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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 | resources/cropped_mandrill.jpg » ('j') | src/codec/SkJpegCodec.cpp » ('J')
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 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
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 {
285 if (nullptr == sizes) {
286 return false;
287 }
288
289 return this->onGetYUV8Sizes(sizes);
290 }
291
292 /**
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
295 * @param rowBytes Row bytes for each of the Y, U, and V planes
296 * @param colorSpace If nullptr, this parameter is ignored. Otherwise,
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],
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
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 {
msarett 2015/12/22 21:01:36 Just changing the comments here to be consistent w
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*/,
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
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
OLDNEW
« no previous file with comments | « no previous file | resources/cropped_mandrill.jpg » ('j') | src/codec/SkJpegCodec.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698