Chromium Code Reviews| 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 100 */ | 100 */ |
| 101 const SkImageInfo& getInfo() const { return fSrcInfo; } | 101 const SkImageInfo& getInfo() const { return fSrcInfo; } |
| 102 | 102 |
| 103 /** | 103 /** |
| 104 * Returns the color space associated with the codec. | 104 * Returns the color space associated with the codec. |
| 105 * Does not affect ownership. | 105 * Does not affect ownership. |
| 106 * Might be NULL. | 106 * Might be NULL. |
| 107 */ | 107 */ |
| 108 SkColorSpace* getColorSpace() const { return fColorSpace.get(); } | 108 SkColorSpace* getColorSpace() const { return fColorSpace.get(); } |
| 109 | 109 |
| 110 enum Orientation { | |
| 111 kOriginTopLeft_Orientation = 1, // Default | |
| 112 kOriginTopRight_Orientation = 2, // Reflected across y-axis | |
| 113 kOriginBottomRight_Orientation = 3, // Rotated 180 | |
| 114 kOriginBottomLeft_Orientation = 4, // Reflected across x-axis | |
| 115 kOriginLeftTop_Orientation = 5, // Reflected across x-axis, Rotated 90 CCW | |
| 116 kOriginRightTop_Orientation = 6, // Rotated 90 CW | |
| 117 kOriginRightBottom_Orientation = 7, // Reflected across x-axis, Rotated 90 CW | |
| 118 kOriginLeftBottom_Orientation = 8, // Rotated 90 CCW | |
| 119 kDefault_Orientation = kOriginTopLeft_Orientation, | |
| 120 kLast_Orientation = kOriginLeftBottom_Orientation, | |
| 121 }; | |
| 122 | |
| 123 /** | |
| 124 * Returns the image orientation stored in the EXIF data. | |
| 125 * If there is no EXIF data, or if we cannot read the EXIF data, returns kO riginTopLeft. | |
| 126 */ | |
| 127 Orientation getOrientation() const { return fOrientation; } | |
| 128 | |
| 110 /** | 129 /** |
| 111 * Return a size that approximately supports the desired scale factor. | 130 * Return a size that approximately supports the desired scale factor. |
| 112 * The codec may not be able to scale efficiently to the exact scale | 131 * The codec may not be able to scale efficiently to the exact scale |
| 113 * factor requested, so return a size that approximates that scale. | 132 * factor requested, so return a size that approximates that scale. |
| 114 * The returned value is the codec's suggestion for the closest valid | 133 * The returned value is the codec's suggestion for the closest valid |
| 115 * scale that it can natively support | 134 * scale that it can natively support |
| 116 */ | 135 */ |
| 117 SkISize getScaledDimensions(float desiredScale) const { | 136 SkISize getScaledDimensions(float desiredScale) const { |
| 118 // Negative and zero scales are errors. | 137 // Negative and zero scales are errors. |
| 119 SkASSERT(desiredScale > 0.0f); | 138 SkASSERT(desiredScale > 0.0f); |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 484 * is located in the encoded data. | 503 * is located in the encoded data. |
| 485 * | 504 * |
| 486 * This will equal inputScanline, except in the case of strangely | 505 * This will equal inputScanline, except in the case of strangely |
| 487 * encoded image types (bottom-up bmps, interlaced gifs). | 506 * encoded image types (bottom-up bmps, interlaced gifs). |
| 488 */ | 507 */ |
| 489 int outputScanline(int inputScanline) const; | 508 int outputScanline(int inputScanline) const; |
| 490 | 509 |
| 491 protected: | 510 protected: |
| 492 /** | 511 /** |
| 493 * Takes ownership of SkStream* | 512 * Takes ownership of SkStream* |
| 494 * Does not affect ownership of SkColorSpace* | 513 * Does not affect ownership of SkColorSpace* |
|
scroggo
2016/03/18 22:38:17
This comment can be removed, I think.
msarett
2016/03/21 14:28:45
Done.
| |
| 495 */ | 514 */ |
| 496 SkCodec(const SkImageInfo&, SkStream*, sk_sp<SkColorSpace> = nullptr); | 515 SkCodec(const SkImageInfo&, |
| 516 SkStream*, | |
| 517 sk_sp<SkColorSpace> = nullptr, | |
| 518 Orientation = kOriginTopLeft_Orientation); | |
| 497 | 519 |
| 498 virtual SkISize onGetScaledDimensions(float /*desiredScale*/) const { | 520 virtual SkISize onGetScaledDimensions(float /*desiredScale*/) const { |
| 499 // By default, scaling is not supported. | 521 // By default, scaling is not supported. |
| 500 return this->getInfo().dimensions(); | 522 return this->getInfo().dimensions(); |
| 501 } | 523 } |
| 502 | 524 |
| 503 // FIXME: What to do about subsets?? | 525 // FIXME: What to do about subsets?? |
| 504 /** | 526 /** |
| 505 * Subclasses should override if they support dimensions other than the | 527 * Subclasses should override if they support dimensions other than the |
| 506 * srcInfo's. | 528 * srcInfo's. |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 618 */ | 640 */ |
| 619 int currScanline() const { return fCurrScanline; } | 641 int currScanline() const { return fCurrScanline; } |
| 620 | 642 |
| 621 virtual int onOutputScanline(int inputScanline) const; | 643 virtual int onOutputScanline(int inputScanline) const; |
| 622 | 644 |
| 623 private: | 645 private: |
| 624 const SkImageInfo fSrcInfo; | 646 const SkImageInfo fSrcInfo; |
| 625 SkAutoTDelete<SkStream> fStream; | 647 SkAutoTDelete<SkStream> fStream; |
| 626 bool fNeedsRewind; | 648 bool fNeedsRewind; |
| 627 sk_sp<SkColorSpace> fColorSpace; | 649 sk_sp<SkColorSpace> fColorSpace; |
| 650 Orientation fOrientation; | |
|
scroggo
2016/03/18 22:38:17
Can this be const?
msarett
2016/03/21 14:28:45
Yes! Done.
| |
| 628 | 651 |
| 629 // These fields are only meaningful during scanline decodes. | 652 // These fields are only meaningful during scanline decodes. |
| 630 SkImageInfo fDstInfo; | 653 SkImageInfo fDstInfo; |
| 631 SkCodec::Options fOptions; | 654 SkCodec::Options fOptions; |
| 632 int fCurrScanline; | 655 int fCurrScanline; |
| 633 | 656 |
| 634 /** | 657 /** |
| 635 * Return whether these dimensions are supported as a scale. | 658 * Return whether these dimensions are supported as a scale. |
| 636 * | 659 * |
| 637 * The codec may choose to cache the information about scale and subset. | 660 * The codec may choose to cache the information about scale and subset. |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 678 * not affect ownership. | 701 * not affect ownership. |
| 679 * | 702 * |
| 680 * Only valid during scanline decoding. | 703 * Only valid during scanline decoding. |
| 681 */ | 704 */ |
| 682 virtual SkSampler* getSampler(bool /*createIfNecessary*/) { return nullptr; } | 705 virtual SkSampler* getSampler(bool /*createIfNecessary*/) { return nullptr; } |
| 683 | 706 |
| 684 friend class SkSampledCodec; | 707 friend class SkSampledCodec; |
| 685 friend class SkIcoCodec; | 708 friend class SkIcoCodec; |
| 686 }; | 709 }; |
| 687 #endif // SkCodec_DEFINED | 710 #endif // SkCodec_DEFINED |
| OLD | NEW |