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 SkScanlineDecoder_DEFINED | 8 #ifndef SkScanlineDecoder_DEFINED |
9 #define SkScanlineDecoder_DEFINED | 9 #define SkScanlineDecoder_DEFINED |
10 | 10 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 * of the encoded data, but then never use any colors which have alpha | 68 * of the encoded data, but then never use any colors which have alpha |
69 * less than 100%. This function can be called *after* decoding to | 69 * less than 100%. This function can be called *after* decoding to |
70 * determine if such an image truly had alpha. Calling it before decoding | 70 * determine if such an image truly had alpha. Calling it before decoding |
71 * is undefined. | 71 * is undefined. |
72 * FIXME: see skbug.com/3582. | 72 * FIXME: see skbug.com/3582. |
73 */ | 73 */ |
74 bool reallyHasAlpha() const { | 74 bool reallyHasAlpha() const { |
75 return this->onReallyHasAlpha(); | 75 return this->onReallyHasAlpha(); |
76 } | 76 } |
77 | 77 |
| 78 /** |
| 79 * returns true if the image must be scaled, in the y direction, after readi
ng, not during. |
| 80 * To scale afterwards, we first decode every line and then sample the lines
we want afterwards. |
| 81 * An example is interlaced pngs, where calling getScanlines once (regardles
s of the count |
| 82 * used) needs to read the entire image, therefore it is inefficient to call |
| 83 * getScanlines more than once. Instead, it should only ever be called with
all the |
| 84 * rows needed. |
| 85 */ |
| 86 bool requiresPostYSampling() { |
| 87 return this->onRequiresPostYSampling(); |
| 88 } |
| 89 |
78 protected: | 90 protected: |
79 SkScanlineDecoder(const SkImageInfo& requested) | 91 SkScanlineDecoder(const SkImageInfo& requested) |
80 : fDstInfo(requested) | 92 : fDstInfo(requested) |
81 , fCurrScanline(0) {} | 93 , fCurrScanline(0) {} |
82 | 94 |
83 virtual bool onReallyHasAlpha() const { return false; } | 95 virtual bool onReallyHasAlpha() const { return false; } |
84 | 96 |
| 97 /** |
| 98 * returns true if the image type is hard to sample and must be scaled after
reading, not during |
| 99 * An example is interlaced pngs, where the entire image must be read for ea
ch decode |
| 100 */ |
| 101 virtual bool onRequiresPostYSampling() { return false; } |
| 102 |
85 const SkImageInfo& dstInfo() const { return fDstInfo; } | 103 const SkImageInfo& dstInfo() const { return fDstInfo; } |
86 | 104 |
87 private: | 105 private: |
88 const SkImageInfo fDstInfo; | 106 const SkImageInfo fDstInfo; |
89 int fCurrScanline; | 107 int fCurrScanline; |
90 | 108 |
91 // Naive default version just calls onGetScanlines on temp memory. | 109 // Naive default version just calls onGetScanlines on temp memory. |
92 virtual SkCodec::Result onSkipScanlines(int countLines) { | 110 virtual SkCodec::Result onSkipScanlines(int countLines) { |
93 SkAutoMalloc storage(fDstInfo.minRowBytes()); | 111 SkAutoMalloc storage(fDstInfo.minRowBytes()); |
94 // Note that we pass 0 to rowBytes so we continue to use the same memory
. | 112 // Note that we pass 0 to rowBytes so we continue to use the same memory
. |
95 // Also note that while getScanlines checks that rowBytes is big enough, | 113 // Also note that while getScanlines checks that rowBytes is big enough, |
96 // onGetScanlines bypasses that check. | 114 // onGetScanlines bypasses that check. |
97 // Calling the virtual method also means we do not double count | 115 // Calling the virtual method also means we do not double count |
98 // countLines. | 116 // countLines. |
99 return this->onGetScanlines(storage.get(), countLines, 0); | 117 return this->onGetScanlines(storage.get(), countLines, 0); |
100 } | 118 } |
101 | 119 |
102 virtual SkCodec::Result onGetScanlines(void* dst, int countLines, | 120 virtual SkCodec::Result onGetScanlines(void* dst, int countLines, |
103 size_t rowBytes) = 0; | 121 size_t rowBytes) = 0; |
104 | 122 |
105 }; | 123 }; |
106 #endif // SkScanlineDecoder_DEFINED | 124 #endif // SkScanlineDecoder_DEFINED |
OLD | NEW |