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

Side by Side Diff: src/codec/SkSwizzler.h

Issue 1055743003: Swizzler changes Index8 and 565 (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Enabled kIndex8 testing in dm, Created a test for SkSwizzler::Fill() 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
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 SkSwizzler_DEFINED 8 #ifndef SkSwizzler_DEFINED
9 #define SkSwizzler_DEFINED 9 #define SkSwizzler_DEFINED
10 10
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 54
55 /* 55 /*
56 * 56 *
57 * Checks if the result of decoding a row indicates that the row was 57 * Checks if the result of decoding a row indicates that the row was
58 * opaque. 58 * opaque.
59 * 59 *
60 */ 60 */
61 static bool IsOpaque(ResultAlpha r) { 61 static bool IsOpaque(ResultAlpha r) {
62 return kOpaque_ResultAlpha == r; 62 return kOpaque_ResultAlpha == r;
63 } 63 }
64 64
65 /* 65 /*
66 * 66 *
67 * Constructs the proper result code based on accumulated alpha masks 67 * Constructs the proper result code based on accumulated alpha masks
68 * 68 *
69 */ 69 */
70 static ResultAlpha GetResult(uint8_t zeroAlpha, uint8_t maxAlpha); 70 static ResultAlpha GetResult(uint8_t zeroAlpha, uint8_t maxAlpha);
71 71
72 /* 72 /*
73 * 73 *
74 * Returns bits per pixel for source config 74 * Returns bits per pixel for source config
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 * @param dstRowBytes rowBytes for dst. 121 * @param dstRowBytes rowBytes for dst.
122 * @param ZeroInitialized Whether dst is zero-initialized. The 122 * @param ZeroInitialized Whether dst is zero-initialized. The
123 implementation may choose to skip writing zeroes 123 implementation may choose to skip writing zeroes
124 * if set to kYes_ZeroInitialized. 124 * if set to kYes_ZeroInitialized.
125 * @return A new SkSwizzler or NULL on failure. 125 * @return A new SkSwizzler or NULL on failure.
126 */ 126 */
127 static SkSwizzler* CreateSwizzler(SrcConfig, const SkPMColor* ctable, 127 static SkSwizzler* CreateSwizzler(SrcConfig, const SkPMColor* ctable,
128 const SkImageInfo&, void* dst, 128 const SkImageInfo&, void* dst,
129 size_t dstRowBytes, 129 size_t dstRowBytes,
130 SkImageGenerator::ZeroInitialized); 130 SkImageGenerator::ZeroInitialized);
131
132 /**
133 * Fill the remainder of the destination with a single color
134 * @param y The starting row for the fill.
135 * @param input The value to fill with - may be a color or an index.
136 * It will be an index in the case where the encoded ima ge was
137 * stored in an indexed format. If we are decoding to k Index8
138 * we will fill with the index directly. If we are deco ding to
139 * kN32, we will use the index to look up the color that we are
140 * to fill with. If the input is an index, it will be t reated
141 * as a uint8_t.
142 * We recognize that the input is not an index if we are
143 * decoding to kN32 and the input color table is NULL. In this
144 * case, we assume the input is an SkPMColor and fill wi th it
145 * directly.
146 * @param colorTable a non-NULL colorTable indicates that the input is an index
147 * even if the dst color type is not an index type
148 */
149 static void Fill(void* dst, const SkImageInfo& dstInfo, size_t dstRowBytes, uint32_t y,
150 uint32_t input, SkPMColor* colorTable);
151
131 /** 152 /**
132 * Swizzle the next line. Call height times, once for each row of source. 153 * Swizzle the next line. Call height times, once for each row of source.
133 * @param src The next row of the source data. 154 * @param src The next row of the source data.
134 * @return A result code describing if the row was fully opaque, fully 155 * @return A result code describing if the row was fully opaque, fully
135 * transparent, or neither 156 * transparent, or neither
136 */ 157 */
137 ResultAlpha next(const uint8_t* SK_RESTRICT src); 158 ResultAlpha next(const uint8_t* SK_RESTRICT src);
138 159
139 /** 160 /**
140 * 161 *
141 * Alternate version of next that allows the caller to specify the row. 162 * Alternate version of next that allows the caller to specify the row.
142 * It is very important to only use one version of next. Since the other 163 * It is very important to only use one version of next. Since the other
143 * version modifies the dst pointer, it will change the behavior of this 164 * version modifies the dst pointer, it will change the behavior of this
144 * function. We will check this in Debug mode. 165 * function. We will check this in Debug mode.
145 * 166 *
146 */ 167 */
147 ResultAlpha next(const uint8_t* SK_RESTRICT src, int y); 168 ResultAlpha next(const uint8_t* SK_RESTRICT src, int y);
148 169
149 /** 170 /**
150 * Update the destination row. 171 * Update the destination row.
151 * 172 *
152 * Typically this is done by next, but for a client that wants to manually 173 * Typically this is done by next, but for a client that wants to manually
153 * modify the destination row (for example, for decoding scanline one at a 174 * modify the destination row (for example, for decoding scanline one at a
154 * time) they can call this before each call to next. 175 * time) they can call this before each call to next.
155 * TODO: Maybe replace this with a version of next which allows supplying t he 176 * TODO: Maybe replace this with a version of next which allows supplying t he
156 * destination? 177 * destination?
157 */ 178 */
158 void setDstRow(void* dst) { fDstRow = dst; } 179 void setDstRow(void* dst) { fDstRow = dst; }
180
159 private: 181 private:
160 182
161 #ifdef SK_DEBUG 183 #ifdef SK_DEBUG
162 /* 184 /*
163 * 185 *
164 * Keep track of which version of next the caller is using 186 * Keep track of which version of next the caller is using
165 * 187 *
166 */ 188 */
167 enum NextMode { 189 enum NextMode {
168 kUninitialized_NextMode, 190 kUninitialized_NextMode,
(...skipping 28 matching lines...) Expand all
197 const SkImageInfo fDstInfo; 219 const SkImageInfo fDstInfo;
198 void* fDstRow; 220 void* fDstRow;
199 const size_t fDstRowBytes; 221 const size_t fDstRowBytes;
200 int fCurrY; 222 int fCurrY;
201 223
202 SkSwizzler(RowProc proc, const SkPMColor* ctable, int deltaSrc, 224 SkSwizzler(RowProc proc, const SkPMColor* ctable, int deltaSrc,
203 const SkImageInfo& info, void* dst, size_t rowBytes); 225 const SkImageInfo& info, void* dst, size_t rowBytes);
204 226
205 }; 227 };
206 #endif // SkSwizzler_DEFINED 228 #endif // SkSwizzler_DEFINED
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698