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 "SkColorSpace.h" | |
13 #include "SkEncodedFormat.h" | 14 #include "SkEncodedFormat.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 | 19 |
19 class SkData; | 20 class SkData; |
20 class SkPngChunkReader; | 21 class SkPngChunkReader; |
21 class SkSampler; | 22 class SkSampler; |
22 | 23 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
92 static SkCodec* NewFromData(SkData*, SkPngChunkReader* = NULL); | 93 static SkCodec* NewFromData(SkData*, SkPngChunkReader* = NULL); |
93 | 94 |
94 virtual ~SkCodec(); | 95 virtual ~SkCodec(); |
95 | 96 |
96 /** | 97 /** |
97 * Return the ImageInfo associated with this codec. | 98 * Return the ImageInfo associated with this codec. |
98 */ | 99 */ |
99 const SkImageInfo& getInfo() const { return fSrcInfo; } | 100 const SkImageInfo& getInfo() const { return fSrcInfo; } |
100 | 101 |
101 /** | 102 /** |
103 * Returns the color space associated with the codec. | |
scroggo
2016/02/24 13:58:12
Does not affect ownership
msarett
2016/02/24 17:32:35
Done.
| |
104 * Might be NULL. | |
105 */ | |
106 SkColorSpace* getColorSpace() const { return fColorSpace; } | |
107 | |
108 /** | |
102 * Return a size that approximately supports the desired scale factor. | 109 * Return a size that approximately supports the desired scale factor. |
103 * The codec may not be able to scale efficiently to the exact scale | 110 * The codec may not be able to scale efficiently to the exact scale |
104 * factor requested, so return a size that approximates that scale. | 111 * factor requested, so return a size that approximates that scale. |
105 * The returned value is the codec's suggestion for the closest valid | 112 * The returned value is the codec's suggestion for the closest valid |
106 * scale that it can natively support | 113 * scale that it can natively support |
107 */ | 114 */ |
108 SkISize getScaledDimensions(float desiredScale) const { | 115 SkISize getScaledDimensions(float desiredScale) const { |
109 // Negative and zero scales are errors. | 116 // Negative and zero scales are errors. |
110 SkASSERT(desiredScale > 0.0f); | 117 SkASSERT(desiredScale > 0.0f); |
111 if (desiredScale <= 0.0f) { | 118 if (desiredScale <= 0.0f) { |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
495 * Returns the output y-coordinate of the row that corresponds to an input | 502 * Returns the output y-coordinate of the row that corresponds to an input |
496 * y-coordinate. The input y-coordinate represents where the scanline | 503 * y-coordinate. The input y-coordinate represents where the scanline |
497 * is located in the encoded data. | 504 * is located in the encoded data. |
498 * | 505 * |
499 * This will equal inputScanline, except in the case of strangely | 506 * This will equal inputScanline, except in the case of strangely |
500 * encoded image types (bottom-up bmps, interlaced gifs). | 507 * encoded image types (bottom-up bmps, interlaced gifs). |
501 */ | 508 */ |
502 int outputScanline(int inputScanline) const; | 509 int outputScanline(int inputScanline) const; |
503 | 510 |
504 protected: | 511 protected: |
505 SkCodec(const SkImageInfo&, SkStream*); | 512 SkCodec(const SkImageInfo&, SkStream*, SkColorSpace* colorSpace = nullptr); |
scroggo
2016/02/24 13:58:12
Takes ownership (I guess it already does with SkSt
msarett
2016/02/24 17:32:35
I'm going with "Refs the SkColorSpace*". Done.
| |
506 | 513 |
507 virtual SkISize onGetScaledDimensions(float /*desiredScale*/) const { | 514 virtual SkISize onGetScaledDimensions(float /*desiredScale*/) const { |
508 // By default, scaling is not supported. | 515 // By default, scaling is not supported. |
509 return this->getInfo().dimensions(); | 516 return this->getInfo().dimensions(); |
510 } | 517 } |
511 | 518 |
512 // FIXME: What to do about subsets?? | 519 // FIXME: What to do about subsets?? |
513 /** | 520 /** |
514 * Subclasses should override if they support dimensions other than the | 521 * Subclasses should override if they support dimensions other than the |
515 * srcInfo's. | 522 * srcInfo's. |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
623 * Returns the number of scanlines that have been decoded so far. | 630 * Returns the number of scanlines that have been decoded so far. |
624 * This is unaffected by the SkScanlineOrder. | 631 * This is unaffected by the SkScanlineOrder. |
625 * | 632 * |
626 * Returns -1 if we have not started a scanline decode. | 633 * Returns -1 if we have not started a scanline decode. |
627 */ | 634 */ |
628 int currScanline() const { return fCurrScanline; } | 635 int currScanline() const { return fCurrScanline; } |
629 | 636 |
630 virtual int onOutputScanline(int inputScanline) const; | 637 virtual int onOutputScanline(int inputScanline) const; |
631 | 638 |
632 private: | 639 private: |
633 const SkImageInfo fSrcInfo; | 640 const SkImageInfo fSrcInfo; |
634 SkAutoTDelete<SkStream> fStream; | 641 SkAutoTDelete<SkStream> fStream; |
635 bool fNeedsRewind; | 642 bool fNeedsRewind; |
643 SkAutoTDelete<SkColorSpace> fColorSpace; | |
scroggo
2016/02/24 13:58:12
It looks like SkColorSpace is ref-counted, so this
msarett
2016/02/24 17:32:35
Yes I think you're right.
| |
644 | |
636 // These fields are only meaningful during scanline decodes. | 645 // These fields are only meaningful during scanline decodes. |
637 SkImageInfo fDstInfo; | 646 SkImageInfo fDstInfo; |
638 SkCodec::Options fOptions; | 647 SkCodec::Options fOptions; |
639 int fCurrScanline; | 648 int fCurrScanline; |
640 | 649 |
641 /** | 650 /** |
642 * Return whether these dimensions are supported as a scale. | 651 * Return whether these dimensions are supported as a scale. |
643 * | 652 * |
644 * The codec may choose to cache the information about scale and subset. | 653 * The codec may choose to cache the information about scale and subset. |
645 * Either way, the same information will be passed to onGetPixels/onStart | 654 * Either way, the same information will be passed to onGetPixels/onStart |
646 * on success. | 655 * on success. |
647 * | 656 * |
648 * This must return true for a size returned from getScaledDimensions. | 657 * This must return true for a size returned from getScaledDimensions. |
649 */ | 658 */ |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
685 * not affect ownership. | 694 * not affect ownership. |
686 * | 695 * |
687 * Only valid during scanline decoding. | 696 * Only valid during scanline decoding. |
688 */ | 697 */ |
689 virtual SkSampler* getSampler(bool /*createIfNecessary*/) { return nullptr; } | 698 virtual SkSampler* getSampler(bool /*createIfNecessary*/) { return nullptr; } |
690 | 699 |
691 friend class SkSampledCodec; | 700 friend class SkSampledCodec; |
692 friend class SkIcoCodec; | 701 friend class SkIcoCodec; |
693 }; | 702 }; |
694 #endif // SkCodec_DEFINED | 703 #endif // SkCodec_DEFINED |
OLD | NEW |