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 |
11 #include "../private/SkTemplates.h" | 11 #include "../private/SkTemplates.h" |
12 #include "SkColor.h" | 12 #include "SkColor.h" |
13 #include "SkEncodedFormat.h" | 13 #include "SkEncodedFormat.h" |
| 14 #include "SkEncodedInfo.h" |
14 #include "SkImageInfo.h" | 15 #include "SkImageInfo.h" |
15 #include "SkSize.h" | 16 #include "SkSize.h" |
16 #include "SkStream.h" | 17 #include "SkStream.h" |
17 #include "SkTypes.h" | 18 #include "SkTypes.h" |
18 #include "SkYUVSizeInfo.h" | 19 #include "SkYUVSizeInfo.h" |
19 | 20 |
20 class SkColorSpace; | 21 class SkColorSpace; |
21 class SkData; | 22 class SkData; |
22 class SkPngChunkReader; | 23 class SkPngChunkReader; |
23 class SkSampler; | 24 class SkSampler; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 */ | 94 */ |
94 static SkCodec* NewFromData(SkData*, SkPngChunkReader* = NULL); | 95 static SkCodec* NewFromData(SkData*, SkPngChunkReader* = NULL); |
95 | 96 |
96 virtual ~SkCodec(); | 97 virtual ~SkCodec(); |
97 | 98 |
98 /** | 99 /** |
99 * Return the ImageInfo associated with this codec. | 100 * Return the ImageInfo associated with this codec. |
100 */ | 101 */ |
101 const SkImageInfo& getInfo() const { return fSrcInfo; } | 102 const SkImageInfo& getInfo() const { return fSrcInfo; } |
102 | 103 |
| 104 const SkEncodedInfo& getEncodedInfo() const { return fEncodedInfo; } |
| 105 |
103 /** | 106 /** |
104 * Returns the color space associated with the codec. | 107 * Returns the color space associated with the codec. |
105 * Does not affect ownership. | 108 * Does not affect ownership. |
106 * Might be NULL. | 109 * Might be NULL. |
107 */ | 110 */ |
108 SkColorSpace* getColorSpace() const { return fColorSpace.get(); } | 111 SkColorSpace* getColorSpace() const { return fColorSpace.get(); } |
109 | 112 |
110 enum Origin { | 113 enum Origin { |
111 kTopLeft_Origin = 1, // Default | 114 kTopLeft_Origin = 1, // Default |
112 kTopRight_Origin = 2, // Reflected across y-axis | 115 kTopRight_Origin = 2, // Reflected across y-axis |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 * | 507 * |
505 * This will equal inputScanline, except in the case of strangely | 508 * This will equal inputScanline, except in the case of strangely |
506 * encoded image types (bottom-up bmps, interlaced gifs). | 509 * encoded image types (bottom-up bmps, interlaced gifs). |
507 */ | 510 */ |
508 int outputScanline(int inputScanline) const; | 511 int outputScanline(int inputScanline) const; |
509 | 512 |
510 protected: | 513 protected: |
511 /** | 514 /** |
512 * Takes ownership of SkStream* | 515 * Takes ownership of SkStream* |
513 */ | 516 */ |
514 SkCodec(const SkImageInfo&, | 517 SkCodec(const SkEncodedInfo&, |
515 SkStream*, | 518 SkStream*, |
516 sk_sp<SkColorSpace> = nullptr, | 519 sk_sp<SkColorSpace> = nullptr, |
517 Origin = kTopLeft_Origin); | 520 Origin = kTopLeft_Origin); |
518 | 521 |
519 virtual SkISize onGetScaledDimensions(float /*desiredScale*/) const { | 522 virtual SkISize onGetScaledDimensions(float /*desiredScale*/) const { |
520 // By default, scaling is not supported. | 523 // By default, scaling is not supported. |
521 return this->getInfo().dimensions(); | 524 return this->getInfo().dimensions(); |
522 } | 525 } |
523 | 526 |
524 // FIXME: What to do about subsets?? | 527 // FIXME: What to do about subsets?? |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
635 * Returns the number of scanlines that have been decoded so far. | 638 * Returns the number of scanlines that have been decoded so far. |
636 * This is unaffected by the SkScanlineOrder. | 639 * This is unaffected by the SkScanlineOrder. |
637 * | 640 * |
638 * Returns -1 if we have not started a scanline decode. | 641 * Returns -1 if we have not started a scanline decode. |
639 */ | 642 */ |
640 int currScanline() const { return fCurrScanline; } | 643 int currScanline() const { return fCurrScanline; } |
641 | 644 |
642 virtual int onOutputScanline(int inputScanline) const; | 645 virtual int onOutputScanline(int inputScanline) const; |
643 | 646 |
644 private: | 647 private: |
| 648 const SkEncodedInfo fEncodedInfo; |
645 const SkImageInfo fSrcInfo; | 649 const SkImageInfo fSrcInfo; |
646 SkAutoTDelete<SkStream> fStream; | 650 SkAutoTDelete<SkStream> fStream; |
647 bool fNeedsRewind; | 651 bool fNeedsRewind; |
648 sk_sp<SkColorSpace> fColorSpace; | 652 sk_sp<SkColorSpace> fColorSpace; |
649 const Origin fOrigin; | 653 const Origin fOrigin; |
650 | 654 |
651 // These fields are only meaningful during scanline decodes. | 655 // These fields are only meaningful during scanline decodes. |
652 SkImageInfo fDstInfo; | 656 SkImageInfo fDstInfo; |
653 SkCodec::Options fOptions; | 657 SkCodec::Options fOptions; |
654 int fCurrScanline; | 658 int fCurrScanline; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
700 * not affect ownership. | 704 * not affect ownership. |
701 * | 705 * |
702 * Only valid during scanline decoding. | 706 * Only valid during scanline decoding. |
703 */ | 707 */ |
704 virtual SkSampler* getSampler(bool /*createIfNecessary*/) { return nullptr;
} | 708 virtual SkSampler* getSampler(bool /*createIfNecessary*/) { return nullptr;
} |
705 | 709 |
706 friend class SkSampledCodec; | 710 friend class SkSampledCodec; |
707 friend class SkIcoCodec; | 711 friend class SkIcoCodec; |
708 }; | 712 }; |
709 #endif // SkCodec_DEFINED | 713 #endif // SkCodec_DEFINED |
OLD | NEW |