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 Origin { |
| 111 kTopLeft_Origin = 1, // Default |
| 112 kTopRight_Origin = 2, // Reflected across y-axis |
| 113 kBottomRight_Origin = 3, // Rotated 180 |
| 114 kBottomLeft_Origin = 4, // Reflected across x-axis |
| 115 kLeftTop_Origin = 5, // Reflected across x-axis, Rotated 90 CCW |
| 116 kRightTop_Origin = 6, // Rotated 90 CW |
| 117 kRightBottom_Origin = 7, // Reflected across x-axis, Rotated 90 CW |
| 118 kLeftBottom_Origin = 8, // Rotated 90 CCW |
| 119 kDefault_Origin = kTopLeft_Origin, |
| 120 kLast_Origin = kLeftBottom_Origin, |
| 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 kT
opLeft. |
| 126 */ |
| 127 Origin getOrigin() const { return fOrigin; } |
| 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* | |
495 */ | 513 */ |
496 SkCodec(const SkImageInfo&, SkStream*, sk_sp<SkColorSpace> = nullptr); | 514 SkCodec(const SkImageInfo&, |
| 515 SkStream*, |
| 516 sk_sp<SkColorSpace> = nullptr, |
| 517 Origin = kTopLeft_Origin); |
497 | 518 |
498 virtual SkISize onGetScaledDimensions(float /*desiredScale*/) const { | 519 virtual SkISize onGetScaledDimensions(float /*desiredScale*/) const { |
499 // By default, scaling is not supported. | 520 // By default, scaling is not supported. |
500 return this->getInfo().dimensions(); | 521 return this->getInfo().dimensions(); |
501 } | 522 } |
502 | 523 |
503 // FIXME: What to do about subsets?? | 524 // FIXME: What to do about subsets?? |
504 /** | 525 /** |
505 * Subclasses should override if they support dimensions other than the | 526 * Subclasses should override if they support dimensions other than the |
506 * srcInfo's. | 527 * srcInfo's. |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
618 */ | 639 */ |
619 int currScanline() const { return fCurrScanline; } | 640 int currScanline() const { return fCurrScanline; } |
620 | 641 |
621 virtual int onOutputScanline(int inputScanline) const; | 642 virtual int onOutputScanline(int inputScanline) const; |
622 | 643 |
623 private: | 644 private: |
624 const SkImageInfo fSrcInfo; | 645 const SkImageInfo fSrcInfo; |
625 SkAutoTDelete<SkStream> fStream; | 646 SkAutoTDelete<SkStream> fStream; |
626 bool fNeedsRewind; | 647 bool fNeedsRewind; |
627 sk_sp<SkColorSpace> fColorSpace; | 648 sk_sp<SkColorSpace> fColorSpace; |
| 649 const Origin fOrigin; |
628 | 650 |
629 // These fields are only meaningful during scanline decodes. | 651 // These fields are only meaningful during scanline decodes. |
630 SkImageInfo fDstInfo; | 652 SkImageInfo fDstInfo; |
631 SkCodec::Options fOptions; | 653 SkCodec::Options fOptions; |
632 int fCurrScanline; | 654 int fCurrScanline; |
633 | 655 |
634 /** | 656 /** |
635 * Return whether these dimensions are supported as a scale. | 657 * Return whether these dimensions are supported as a scale. |
636 * | 658 * |
637 * The codec may choose to cache the information about scale and subset. | 659 * 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. | 700 * not affect ownership. |
679 * | 701 * |
680 * Only valid during scanline decoding. | 702 * Only valid during scanline decoding. |
681 */ | 703 */ |
682 virtual SkSampler* getSampler(bool /*createIfNecessary*/) { return nullptr;
} | 704 virtual SkSampler* getSampler(bool /*createIfNecessary*/) { return nullptr;
} |
683 | 705 |
684 friend class SkSampledCodec; | 706 friend class SkSampledCodec; |
685 friend class SkIcoCodec; | 707 friend class SkIcoCodec; |
686 }; | 708 }; |
687 #endif // SkCodec_DEFINED | 709 #endif // SkCodec_DEFINED |
OLD | NEW |