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

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

Issue 1260673002: SkScaledCodec class (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: remove setSampleX(), move IsInterlaced() to scanlineDecoder Created 5 years, 4 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
« src/codec/SkSwizzler.h ('K') | « src/codec/SkSwizzler.h ('k') | no next file » | 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 #include "SkCodecPriv.h" 8 #include "SkCodecPriv.h"
9 #include "SkColorPriv.h" 9 #include "SkColorPriv.h"
10 #include "SkSwizzler.h" 10 #include "SkSwizzler.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 x++; 65 x++;
66 } 66 }
67 } 67 }
68 return COMPUTE_RESULT_ALPHA; 68 return COMPUTE_RESULT_ALPHA;
69 } 69 }
70 70
71 // kIndex 71 // kIndex
72 72
73 static SkSwizzler::ResultAlpha swizzle_index_to_index( 73 static SkSwizzler::ResultAlpha swizzle_index_to_index(
74 void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int width, 74 void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int width,
75 int bytesPerPixel, int y, const SkPMColor ctable[]) { 75 int deltaSrc, int y, const SkPMColor ctable[]) {
76 76
77 uint8_t* SK_RESTRICT dst = (uint8_t*) dstRow; 77 uint8_t* SK_RESTRICT dst = (uint8_t*) dstRow;
78 memcpy(dst, src, width); 78 if (1 == deltaSrc) {
79 memcpy(dst, src, width);
80 } else {
81 for (int x = 0; x < width; x++) {
82 dst[x] = src[0];
83 src += deltaSrc;
84 }
85 }
79 // TODO (msarett): Should we skip the loop here and guess that the row is op aque/not opaque? 86 // TODO (msarett): Should we skip the loop here and guess that the row is op aque/not opaque?
80 // SkScaledBitmap sampler just guesses that it is opaque. T his is dangerous 87 // SkScaledBitmap sampler just guesses that it is opaque. T his is dangerous
81 // and probably wrong since gif and bmp (rarely) may have al pha. 88 // and probably wrong since gif and bmp (rarely) may have al pha.
82 INIT_RESULT_ALPHA; 89 INIT_RESULT_ALPHA;
83 for (int x = 0; x < width; x++) { 90 for (int x = 0; x < width; x++) {
84 UPDATE_RESULT_ALPHA(ctable[src[x]] >> SK_A32_SHIFT); 91 UPDATE_RESULT_ALPHA(ctable[src[x]] >> SK_A32_SHIFT);
85 } 92 }
86 return COMPUTE_RESULT_ALPHA; 93 return COMPUTE_RESULT_ALPHA;
87 } 94 }
88 95
89 static SkSwizzler::ResultAlpha swizzle_index_to_n32( 96 static SkSwizzler::ResultAlpha swizzle_index_to_n32(
90 void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int width, 97 void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int width,
91 int bytesPerPixel, int y, const SkPMColor ctable[]) { 98 int deltaSrc, int y, const SkPMColor ctable[]) {
92 99
93 SkPMColor* SK_RESTRICT dst = (SkPMColor*)dstRow; 100 SkPMColor* SK_RESTRICT dst = (SkPMColor*)dstRow;
94 INIT_RESULT_ALPHA; 101 INIT_RESULT_ALPHA;
95 for (int x = 0; x < width; x++) { 102 for (int x = 0; x < width; x++) {
96 SkPMColor c = ctable[src[x]]; 103 SkPMColor c = ctable[*src];
97 UPDATE_RESULT_ALPHA(c >> SK_A32_SHIFT); 104 UPDATE_RESULT_ALPHA(c >> SK_A32_SHIFT);
98 dst[x] = c; 105 dst[x] = c;
106 src += deltaSrc;
99 } 107 }
100 return COMPUTE_RESULT_ALPHA; 108 return COMPUTE_RESULT_ALPHA;
101 } 109 }
102 110
103 static SkSwizzler::ResultAlpha swizzle_index_to_n32_skipZ( 111 static SkSwizzler::ResultAlpha swizzle_index_to_n32_skipZ(
104 void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int width, 112 void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int width,
105 int bytesPerPixel, int y, const SkPMColor ctable[]) { 113 int deltaSrc, int y, const SkPMColor ctable[]) {
106 114
107 SkPMColor* SK_RESTRICT dst = (SkPMColor*)dstRow; 115 SkPMColor* SK_RESTRICT dst = (SkPMColor*)dstRow;
108 INIT_RESULT_ALPHA; 116 INIT_RESULT_ALPHA;
109 for (int x = 0; x < width; x++) { 117 for (int x = 0; x < width; x++) {
110 SkPMColor c = ctable[src[x]]; 118 SkPMColor c = ctable[*src];
111 UPDATE_RESULT_ALPHA(c >> SK_A32_SHIFT); 119 UPDATE_RESULT_ALPHA(c >> SK_A32_SHIFT);
112 if (c != 0) { 120 if (c != 0) {
113 dst[x] = c; 121 dst[x] = c;
114 } 122 }
123 src += deltaSrc;
115 } 124 }
116 return COMPUTE_RESULT_ALPHA; 125 return COMPUTE_RESULT_ALPHA;
117 } 126 }
118 127
119 #undef A32_MASK_IN_PLACE 128 #undef A32_MASK_IN_PLACE
120 129
121 // kGray 130 // kGray
122 131
123 static SkSwizzler::ResultAlpha swizzle_gray_to_n32( 132 static SkSwizzler::ResultAlpha swizzle_gray_to_n32(
124 void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int width, 133 void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int width,
125 int bytesPerPixel, int y, const SkPMColor ctable[]) { 134 int deltaSrc, int y, const SkPMColor ctable[]) {
126 135
127 SkPMColor* SK_RESTRICT dst = (SkPMColor*)dstRow; 136 SkPMColor* SK_RESTRICT dst = (SkPMColor*)dstRow;
128 for (int x = 0; x < width; x++) { 137 for (int x = 0; x < width; x++) {
129 dst[x] = SkPackARGB32NoCheck(0xFF, src[x], src[x], src[x]); 138 dst[x] = SkPackARGB32NoCheck(0xFF, *src, *src, *src);
139 src += deltaSrc;
130 } 140 }
131 return SkSwizzler::kOpaque_ResultAlpha; 141 return SkSwizzler::kOpaque_ResultAlpha;
132 } 142 }
133 143
134 static SkSwizzler::ResultAlpha swizzle_gray_to_gray( 144 static SkSwizzler::ResultAlpha swizzle_gray_to_gray(
135 void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int width, 145 void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int width,
136 int bytesPerPixel, int y, const SkPMColor ctable[]) { 146 int deltaSrc, int y, const SkPMColor ctable[]) {
137 memcpy(dstRow, src, width); 147
148 uint8_t* SK_RESTRICT dst = (uint8_t*) dstRow;
149 if (1 == deltaSrc) {
150 memcpy(dstRow, src, width);
151 } else {
152 for (int x = 0; x < width; x++) {
153 dst[x] = src[0];
154 src += deltaSrc;
155 }
156 }
138 return SkSwizzler::kOpaque_ResultAlpha; 157 return SkSwizzler::kOpaque_ResultAlpha;
139 } 158 }
140 159
141 // kBGRX 160 // kBGRX
142 161
143 static SkSwizzler::ResultAlpha swizzle_bgrx_to_n32( 162 static SkSwizzler::ResultAlpha swizzle_bgrx_to_n32(
144 void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int width, 163 void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int width,
145 int bytesPerPixel, int y, const SkPMColor ctable[]) { 164 int deltaSrc, int y, const SkPMColor ctable[]) {
146 165
147 SkPMColor* SK_RESTRICT dst = (SkPMColor*)dstRow; 166 SkPMColor* SK_RESTRICT dst = (SkPMColor*)dstRow;
148 for (int x = 0; x < width; x++) { 167 for (int x = 0; x < width; x++) {
149 dst[x] = SkPackARGB32NoCheck(0xFF, src[2], src[1], src[0]); 168 dst[x] = SkPackARGB32NoCheck(0xFF, src[2], src[1], src[0]);
150 src += bytesPerPixel; 169 src += deltaSrc;
151 } 170 }
152 return SkSwizzler::kOpaque_ResultAlpha; 171 return SkSwizzler::kOpaque_ResultAlpha;
153 } 172 }
154 173
155 // kBGRA 174 // kBGRA
156 175
157 static SkSwizzler::ResultAlpha swizzle_bgra_to_n32_unpremul( 176 static SkSwizzler::ResultAlpha swizzle_bgra_to_n32_unpremul(
158 void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int width, 177 void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int width,
159 int bytesPerPixel, int y, const SkPMColor ctable[]) { 178 int deltaSrc, int y, const SkPMColor ctable[]) {
160 179
161 SkPMColor* SK_RESTRICT dst = (SkPMColor*)dstRow; 180 SkPMColor* SK_RESTRICT dst = (SkPMColor*)dstRow;
162 INIT_RESULT_ALPHA; 181 INIT_RESULT_ALPHA;
163 for (int x = 0; x < width; x++) { 182 for (int x = 0; x < width; x++) {
164 uint8_t alpha = src[3]; 183 uint8_t alpha = src[3];
165 UPDATE_RESULT_ALPHA(alpha); 184 UPDATE_RESULT_ALPHA(alpha);
166 dst[x] = SkPackARGB32NoCheck(alpha, src[2], src[1], src[0]); 185 dst[x] = SkPackARGB32NoCheck(alpha, src[2], src[1], src[0]);
167 src += bytesPerPixel; 186 src += deltaSrc;
168 } 187 }
169 return COMPUTE_RESULT_ALPHA; 188 return COMPUTE_RESULT_ALPHA;
170 } 189 }
171 190
172 static SkSwizzler::ResultAlpha swizzle_bgra_to_n32_premul( 191 static SkSwizzler::ResultAlpha swizzle_bgra_to_n32_premul(
173 void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int width, 192 void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int width,
174 int bytesPerPixel, int y, const SkPMColor ctable[]) { 193 int deltaSrc, int y, const SkPMColor ctable[]) {
175 194
176 SkPMColor* SK_RESTRICT dst = (SkPMColor*)dstRow; 195 SkPMColor* SK_RESTRICT dst = (SkPMColor*)dstRow;
177 INIT_RESULT_ALPHA; 196 INIT_RESULT_ALPHA;
178 for (int x = 0; x < width; x++) { 197 for (int x = 0; x < width; x++) {
179 uint8_t alpha = src[3]; 198 uint8_t alpha = src[3];
180 UPDATE_RESULT_ALPHA(alpha); 199 UPDATE_RESULT_ALPHA(alpha);
181 dst[x] = SkPreMultiplyARGB(alpha, src[2], src[1], src[0]); 200 dst[x] = SkPreMultiplyARGB(alpha, src[2], src[1], src[0]);
182 src += bytesPerPixel; 201 src += deltaSrc;
183 } 202 }
184 return COMPUTE_RESULT_ALPHA; 203 return COMPUTE_RESULT_ALPHA;
185 } 204 }
186 205
187 // n32 206 // n32
188 static SkSwizzler::ResultAlpha swizzle_rgbx_to_n32( 207 static SkSwizzler::ResultAlpha swizzle_rgbx_to_n32(
189 void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int width, 208 void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int width,
190 int bytesPerPixel, int y, const SkPMColor ctable[]) { 209 int deltaSrc, int y, const SkPMColor ctable[]) {
191 210
192 SkPMColor* SK_RESTRICT dst = (SkPMColor*)dstRow; 211 SkPMColor* SK_RESTRICT dst = (SkPMColor*)dstRow;
193 for (int x = 0; x < width; x++) { 212 for (int x = 0; x < width; x++) {
194 dst[x] = SkPackARGB32(0xFF, src[0], src[1], src[2]); 213 dst[x] = SkPackARGB32(0xFF, src[0], src[1], src[2]);
195 src += bytesPerPixel; 214 src += deltaSrc;
196 } 215 }
197 return SkSwizzler::kOpaque_ResultAlpha; 216 return SkSwizzler::kOpaque_ResultAlpha;
198 } 217 }
199 218
200 static SkSwizzler::ResultAlpha swizzle_rgba_to_n32_premul( 219 static SkSwizzler::ResultAlpha swizzle_rgba_to_n32_premul(
201 void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int width, 220 void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int width,
202 int bytesPerPixel, int y, const SkPMColor ctable[]) { 221 int deltaSrc, int y, const SkPMColor ctable[]) {
203 222
204 SkPMColor* SK_RESTRICT dst = (SkPMColor*)dstRow; 223 SkPMColor* SK_RESTRICT dst = (SkPMColor*)dstRow;
205 INIT_RESULT_ALPHA; 224 INIT_RESULT_ALPHA;
206 for (int x = 0; x < width; x++) { 225 for (int x = 0; x < width; x++) {
207 unsigned alpha = src[3]; 226 unsigned alpha = src[3];
208 UPDATE_RESULT_ALPHA(alpha); 227 UPDATE_RESULT_ALPHA(alpha);
209 dst[x] = SkPreMultiplyARGB(alpha, src[0], src[1], src[2]); 228 dst[x] = SkPreMultiplyARGB(alpha, src[0], src[1], src[2]);
210 src += bytesPerPixel; 229 src += deltaSrc;
211 } 230 }
212 return COMPUTE_RESULT_ALPHA; 231 return COMPUTE_RESULT_ALPHA;
213 } 232 }
214 233
215 static SkSwizzler::ResultAlpha swizzle_rgba_to_n32_unpremul( 234 static SkSwizzler::ResultAlpha swizzle_rgba_to_n32_unpremul(
216 void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int width, 235 void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int width,
217 int bytesPerPixel, int y, const SkPMColor ctable[]) { 236 int deltaSrc, int y, const SkPMColor ctable[]) {
218 237
219 uint32_t* SK_RESTRICT dst = reinterpret_cast<uint32_t*>(dstRow); 238 uint32_t* SK_RESTRICT dst = reinterpret_cast<uint32_t*>(dstRow);
220 INIT_RESULT_ALPHA; 239 INIT_RESULT_ALPHA;
221 for (int x = 0; x < width; x++) { 240 for (int x = 0; x < width; x++) {
222 unsigned alpha = src[3]; 241 unsigned alpha = src[3];
223 UPDATE_RESULT_ALPHA(alpha); 242 UPDATE_RESULT_ALPHA(alpha);
224 dst[x] = SkPackARGB32NoCheck(alpha, src[0], src[1], src[2]); 243 dst[x] = SkPackARGB32NoCheck(alpha, src[0], src[1], src[2]);
225 src += bytesPerPixel; 244 src += deltaSrc;
226 } 245 }
227 return COMPUTE_RESULT_ALPHA; 246 return COMPUTE_RESULT_ALPHA;
228 } 247 }
229 248
230 static SkSwizzler::ResultAlpha swizzle_rgba_to_n32_premul_skipZ( 249 static SkSwizzler::ResultAlpha swizzle_rgba_to_n32_premul_skipZ(
231 void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int width, 250 void* SK_RESTRICT dstRow, const uint8_t* SK_RESTRICT src, int width,
232 int bytesPerPixel, int y, const SkPMColor ctable[]) { 251 int deltaSrc, int y, const SkPMColor ctable[]) {
233 252
234 SkPMColor* SK_RESTRICT dst = (SkPMColor*)dstRow; 253 SkPMColor* SK_RESTRICT dst = (SkPMColor*)dstRow;
235 INIT_RESULT_ALPHA; 254 INIT_RESULT_ALPHA;
236 for (int x = 0; x < width; x++) { 255 for (int x = 0; x < width; x++) {
237 unsigned alpha = src[3]; 256 unsigned alpha = src[3];
238 UPDATE_RESULT_ALPHA(alpha); 257 UPDATE_RESULT_ALPHA(alpha);
239 if (0 != alpha) { 258 if (0 != alpha) {
240 dst[x] = SkPreMultiplyARGB(alpha, src[0], src[1], src[2]); 259 dst[x] = SkPreMultiplyARGB(alpha, src[0], src[1], src[2]);
241 } 260 }
242 src += bytesPerPixel; 261 src += deltaSrc;
243 } 262 }
244 return COMPUTE_RESULT_ALPHA; 263 return COMPUTE_RESULT_ALPHA;
245 } 264 }
246 265
247 /** 266 /**
248 FIXME: This was my idea to cheat in order to continue taking advantage of sk ipping zeroes. 267 FIXME: This was my idea to cheat in order to continue taking advantage of sk ipping zeroes.
249 This would be fine for drawing normally, but not for drawing with transfer m odes. Being 268 This would be fine for drawing normally, but not for drawing with transfer m odes. Being
250 honest means we can draw correctly with transfer modes, with the cost of not being able 269 honest means we can draw correctly with transfer modes, with the cost of not being able
251 to take advantage of Android's free unwritten pages. Something to keep in mi nd when we 270 to take advantage of Android's free unwritten pages. Something to keep in mi nd when we
252 decide whether to switch to unpremul default. 271 decide whether to switch to unpremul default.
(...skipping 15 matching lines...) Expand all
268 alphaMask &= alpha; 287 alphaMask &= alpha;
269 } 288 }
270 return alphaMask != 0xFF; 289 return alphaMask != 0xFF;
271 } 290 }
272 */ 291 */
273 292
274 SkSwizzler* SkSwizzler::CreateSwizzler(SkSwizzler::SrcConfig sc, 293 SkSwizzler* SkSwizzler::CreateSwizzler(SkSwizzler::SrcConfig sc,
275 const SkPMColor* ctable, 294 const SkPMColor* ctable,
276 const SkImageInfo& info, void* dst, 295 const SkImageInfo& info, void* dst,
277 size_t dstRowBytes, 296 size_t dstRowBytes,
278 SkCodec::ZeroInitialized zeroInit) { 297 SkCodec::ZeroInitialized zeroInit, int sa mpleX) {
279 if (info.colorType() == kUnknown_SkColorType || kUnknown == sc) { 298 if (info.colorType() == kUnknown_SkColorType || kUnknown == sc) {
280 return NULL; 299 return NULL;
281 } 300 }
282 if (info.minRowBytes() > dstRowBytes) { 301 if (info.minRowBytes() > dstRowBytes) {
283 return NULL; 302 return NULL;
284 } 303 }
285 if ((kIndex == sc || kIndex4 == sc || kIndex2 == sc || kIndex1 == sc) 304 if ((kIndex == sc || kIndex4 == sc || kIndex2 == sc || kIndex1 == sc)
286 && NULL == ctable) { 305 && NULL == ctable) {
287 return NULL; 306 return NULL;
288 } 307 }
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 break; 420 break;
402 } 421 }
403 if (NULL == proc) { 422 if (NULL == proc) {
404 return NULL; 423 return NULL;
405 } 424 }
406 425
407 // Store deltaSrc in bytes if it is an even multiple, otherwise use bits 426 // Store deltaSrc in bytes if it is an even multiple, otherwise use bits
408 int deltaSrc = SkIsAlign8(BitsPerPixel(sc)) ? BytesPerPixel(sc) : 427 int deltaSrc = SkIsAlign8(BitsPerPixel(sc)) ? BytesPerPixel(sc) :
409 BitsPerPixel(sc); 428 BitsPerPixel(sc);
410 return SkNEW_ARGS(SkSwizzler, (proc, ctable, deltaSrc, info, dst, 429 return SkNEW_ARGS(SkSwizzler, (proc, ctable, deltaSrc, info, dst,
411 dstRowBytes)); 430 dstRowBytes, sampleX));
412 } 431 }
413 432
414 SkSwizzler::SkSwizzler(RowProc proc, const SkPMColor* ctable, 433 SkSwizzler::SkSwizzler(RowProc proc, const SkPMColor* ctable,
415 int deltaSrc, const SkImageInfo& info, void* dst, 434 int deltaSrc, const SkImageInfo& info, void* dst,
416 size_t rowBytes) 435 size_t rowBytes, int sampleX)
417 : fRowProc(proc) 436 : fRowProc(proc)
418 , fColorTable(ctable) 437 , fColorTable(ctable)
419 , fDeltaSrc(deltaSrc) 438 , fDeltaSrc(deltaSrc)
420 , fDstInfo(info) 439 , fDstInfo(info)
421 , fDstRow(dst) 440 , fDstRow(dst)
422 , fDstRowBytes(rowBytes) 441 , fDstRowBytes(rowBytes)
423 , fCurrY(0) 442 , fCurrY(0)
443 , fSampleX(sampleX)
424 { 444 {
445 if (1 == sampleX) {
446 fX0 = 0;
447 } else {
448 // offset first x pixel for more even sampling
449 fX0 = fSampleX >> 1;
450 }
451 // check that fX0 is less than original width
452 SkASSERT(fX0 >= 0 && fX0 < fDstInfo.width() * fSampleX);
425 SkDEBUGCODE(fNextMode = kUninitialized_NextMode); 453 SkDEBUGCODE(fNextMode = kUninitialized_NextMode);
426 } 454 }
427 455
428 SkSwizzler::ResultAlpha SkSwizzler::next(const uint8_t* SK_RESTRICT src) { 456 SkSwizzler::ResultAlpha SkSwizzler::next(const uint8_t* SK_RESTRICT src) {
429 SkASSERT(0 <= fCurrY && fCurrY < fDstInfo.height()); 457 SkASSERT(0 <= fCurrY && fCurrY < fDstInfo.height());
430 SkASSERT(fDstRow != NULL); 458 SkASSERT(fDstRow != NULL);
431 SkASSERT(kDesignateRow_NextMode != fNextMode); 459 SkASSERT(kDesignateRow_NextMode != fNextMode);
432 SkDEBUGCODE(fNextMode = kConsecutive_NextMode); 460 SkDEBUGCODE(fNextMode = kConsecutive_NextMode);
433 461
434 // Decode a row 462 // Decode a row
435 const ResultAlpha result = fRowProc(fDstRow, src, fDstInfo.width(), 463 const ResultAlpha result = fRowProc(fDstRow, src + fX0 * fDeltaSrc, fDstInf o.width(),
436 fDeltaSrc, fCurrY, fColorTable); 464 fSampleX * fDeltaSrc, fCurrY, fColorTable);
437 465
438 // Move to the next row and return the result 466 // Move to the next row and return the result
439 fCurrY++; 467 fCurrY++;
440 fDstRow = SkTAddOffset<void>(fDstRow, fDstRowBytes); 468 fDstRow = SkTAddOffset<void>(fDstRow, fDstRowBytes);
441 return result; 469 return result;
442 } 470 }
443 471
444 SkSwizzler::ResultAlpha SkSwizzler::next(const uint8_t* SK_RESTRICT src, 472 SkSwizzler::ResultAlpha SkSwizzler::next(const uint8_t* SK_RESTRICT src,
445 int y) { 473 int y) {
446 SkASSERT(0 <= y && y < fDstInfo.height()); 474 SkASSERT(0 <= y && y < fDstInfo.height());
447 SkASSERT(kConsecutive_NextMode != fNextMode); 475 SkASSERT(kConsecutive_NextMode != fNextMode);
448 SkDEBUGCODE(fNextMode = kDesignateRow_NextMode); 476 SkDEBUGCODE(fNextMode = kDesignateRow_NextMode);
449 477
450 // Choose the row 478 // Choose the row
451 void* row = SkTAddOffset<void>(fDstRow, y*fDstRowBytes); 479 void* row = SkTAddOffset<void>(fDstRow, y*fDstRowBytes);
452 480
453 // Decode the row 481 // Decode the row
454 return fRowProc(row, src, fDstInfo.width(), fDeltaSrc, fCurrY, 482 return fRowProc(row, src + fX0 * fDeltaSrc, fDstInfo.width(), fSampleX * fDe ltaSrc, fCurrY,
455 fColorTable); 483 fColorTable);
456 } 484 }
457 485
458 void SkSwizzler::Fill(void* dstStartRow, const SkImageInfo& dstInfo, size_t dstR owBytes, 486 void SkSwizzler::Fill(void* dstStartRow, const SkImageInfo& dstInfo, size_t dstR owBytes,
459 uint32_t numRows, uint32_t colorOrIndex, const SkPMColor* colorTable) { 487 uint32_t numRows, uint32_t colorOrIndex, const SkPMColor* colorTable) {
460 SkASSERT(dstStartRow != NULL); 488 SkASSERT(dstStartRow != NULL);
461 SkASSERT(numRows <= (uint32_t) dstInfo.height()); 489 SkASSERT(numRows <= (uint32_t) dstInfo.height());
462 490
463 // Calculate bytes to fill. We use getSafeSize since the last row may not b e padded. 491 // Calculate bytes to fill. We use getSafeSize since the last row may not b e padded.
464 const size_t bytesToFill = dstInfo.makeWH(dstInfo.width(), numRows).getSafeS ize(dstRowBytes); 492 const size_t bytesToFill = dstInfo.makeWH(dstInfo.width(), numRows).getSafeS ize(dstRowBytes);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 // bits of SK_ColorBLACK are identical to the grayscale representati on 533 // bits of SK_ColorBLACK are identical to the grayscale representati on
506 // for black. 534 // for black.
507 memset(dstStartRow, (uint8_t) colorOrIndex, bytesToFill); 535 memset(dstStartRow, (uint8_t) colorOrIndex, bytesToFill);
508 break; 536 break;
509 default: 537 default:
510 SkCodecPrintf("Error: Unsupported dst color type for fill(). Doing nothing.\n"); 538 SkCodecPrintf("Error: Unsupported dst color type for fill(). Doing nothing.\n");
511 SkASSERT(false); 539 SkASSERT(false);
512 break; 540 break;
513 } 541 }
514 } 542 }
OLDNEW
« src/codec/SkSwizzler.h ('K') | « src/codec/SkSwizzler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698