Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(549)

Side by Side Diff: include/codec/SkCodec.h

Issue 1061713007: Adding png scanline decoding to kIndex8 (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: ctableCount requirements Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « dm/DMSrcSink.cpp ('k') | src/codec/SkCodec.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 * This object is owned by the SkCodec, which will handle its lifetime. The 63 * This object is owned by the SkCodec, which will handle its lifetime. The
64 * returned object is only valid until the SkCodec is deleted or the next 64 * returned object is only valid until the SkCodec is deleted or the next
65 * call to getScanlineDecoder, whichever comes first. 65 * call to getScanlineDecoder, whichever comes first.
66 * 66 *
67 * Calling a second time will rewind and replace the existing one with a 67 * Calling a second time will rewind and replace the existing one with a
68 * new one. If the stream cannot be rewound, this will delete the existing 68 * new one. If the stream cannot be rewound, this will delete the existing
69 * one and return NULL. 69 * one and return NULL.
70 * 70 *
71 * @param dstInfo Info of the destination. If the dimensions do not match 71 * @param dstInfo Info of the destination. If the dimensions do not match
72 * those of getInfo, this implies a scale. 72 * those of getInfo, this implies a scale.
73 * @param options Contains decoding options, including if memory is zero
74 * initialized.
75 * @param ctable A pointer to a color table. When dstInfo.colorType() is
76 * kIndex8, this should be non-NULL and have enough storage for 256
77 * colors. The color table will be populated after decoding the palett e.
78 * @param ctableCount A pointer to the size of the color table. When
79 * dstInfo.colorType() is kIndex8, this should be non-NULL. It will
80 * be modified to the true size of the color table (<= 256) after
81 * decoding the palette.
73 * @return New SkScanlineDecoder, or NULL on failure. 82 * @return New SkScanlineDecoder, or NULL on failure.
74 * 83 *
75 * NOTE: If any rows were previously decoded, this requires rewinding the 84 * NOTE: If any rows were previously decoded, this requires rewinding the
76 * SkStream. 85 * SkStream.
77 * 86 *
78 * NOTE: The scanline decoder is owned by the SkCodec and will delete it 87 * NOTE: The scanline decoder is owned by the SkCodec and will delete it
79 * when the SkCodec is deleted. 88 * when the SkCodec is deleted.
80 */ 89 */
90 SkScanlineDecoder* getScanlineDecoder(const SkImageInfo& dstInfo, const Opti ons* options,
djsollen 2015/04/29 14:02:58 const* for options here and const& on the protecte
scroggo 2015/04/29 14:13:22 This follows a pattern I've used elsewhere in SkCo
91 SkPMColor ctable[], int* ctableCount);
92
93 /**
94 * Simplified version of getScanlineDecoder() that asserts that info is NOT
95 * kIndex8_SkColorType and uses the default Options.
96 */
81 SkScanlineDecoder* getScanlineDecoder(const SkImageInfo& dstInfo); 97 SkScanlineDecoder* getScanlineDecoder(const SkImageInfo& dstInfo);
82 98
83 /** 99 /**
84 * Some images may initially report that they have alpha due to the format 100 * Some images may initially report that they have alpha due to the format
85 * of the encoded data, but then never use any colors which have alpha 101 * of the encoded data, but then never use any colors which have alpha
86 * less than 100%. This function can be called *after* decoding to 102 * less than 100%. This function can be called *after* decoding to
87 * determine if such an image truly had alpha. Calling it before decoding 103 * determine if such an image truly had alpha. Calling it before decoding
88 * is undefined. 104 * is undefined.
89 * FIXME: see skbug.com/3582. 105 * FIXME: see skbug.com/3582.
90 */ 106 */
(...skipping 28 matching lines...) Expand all
119 virtual SkEncodedFormat onGetEncodedFormat() const = 0; 135 virtual SkEncodedFormat onGetEncodedFormat() const = 0;
120 136
121 /** 137 /**
122 * Override if your codec supports scanline decoding. 138 * Override if your codec supports scanline decoding.
123 * 139 *
124 * As in onGetPixels(), the implementation must call rewindIfNeeded() and 140 * As in onGetPixels(), the implementation must call rewindIfNeeded() and
125 * handle as appropriate. 141 * handle as appropriate.
126 * 142 *
127 * @param dstInfo Info of the destination. If the dimensions do not match 143 * @param dstInfo Info of the destination. If the dimensions do not match
128 * those of getInfo, this implies a scale. 144 * those of getInfo, this implies a scale.
145 * @param options Contains decoding options, including if memory is zero
146 * initialized.
147 * @param ctable A pointer to a color table. When dstInfo.colorType() is
148 * kIndex8, this should be non-NULL and have enough storage for 256
149 * colors. The color table will be populated after decoding the palett e.
150 * @param ctableCount A pointer to the size of the color table. When
151 * dstInfo.colorType() is kIndex8, this should be non-NULL. It will
152 * be modified to the true size of the color table (<= 256) after
153 * decoding the palette.
129 * @return New SkScanlineDecoder on success, NULL otherwise. The SkCodec 154 * @return New SkScanlineDecoder on success, NULL otherwise. The SkCodec
130 * will take ownership of the returned scanline decoder. 155 * will take ownership of the returned scanline decoder.
131 */ 156 */
132 virtual SkScanlineDecoder* onGetScanlineDecoder(const SkImageInfo& dstInfo) { 157 virtual SkScanlineDecoder* onGetScanlineDecoder(const SkImageInfo& dstInfo,
158 const Options& options,
159 SkPMColor ctable[],
160 int* ctableCount) {
133 return NULL; 161 return NULL;
134 } 162 }
135 163
136 virtual bool onReallyHasAlpha() const { return false; } 164 virtual bool onReallyHasAlpha() const { return false; }
137 165
138 enum RewindState { 166 enum RewindState {
139 kRewound_RewindState, 167 kRewound_RewindState,
140 kNoRewindNecessary_RewindState, 168 kNoRewindNecessary_RewindState,
141 kCouldNotRewind_RewindState 169 kCouldNotRewind_RewindState
142 }; 170 };
(...skipping 26 matching lines...) Expand all
169 #ifdef SK_SUPPORT_LEGACY_BOOL_ONGETINFO 197 #ifdef SK_SUPPORT_LEGACY_BOOL_ONGETINFO
170 const SkImageInfo fInfo; 198 const SkImageInfo fInfo;
171 #endif // SK_SUPPORT_LEGACY_BOOL_ONGETINFO 199 #endif // SK_SUPPORT_LEGACY_BOOL_ONGETINFO
172 SkAutoTDelete<SkStream> fStream; 200 SkAutoTDelete<SkStream> fStream;
173 bool fNeedsRewind; 201 bool fNeedsRewind;
174 SkAutoTDelete<SkScanlineDecoder> fScanlineDecoder; 202 SkAutoTDelete<SkScanlineDecoder> fScanlineDecoder;
175 203
176 typedef SkImageGenerator INHERITED; 204 typedef SkImageGenerator INHERITED;
177 }; 205 };
178 #endif // SkCodec_DEFINED 206 #endif // SkCodec_DEFINED
OLDNEW
« no previous file with comments | « dm/DMSrcSink.cpp ('k') | src/codec/SkCodec.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698