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

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

Issue 1075243003: Implementing filling for SkBmpCodec (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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
« 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 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 416
417 // Choose the row 417 // Choose the row
418 void* row = SkTAddOffset<void>(fDstRow, y*fDstRowBytes); 418 void* row = SkTAddOffset<void>(fDstRow, y*fDstRowBytes);
419 419
420 // Decode the row 420 // Decode the row
421 return fRowProc(row, src, fDstInfo.width(), fDeltaSrc, fCurrY, 421 return fRowProc(row, src, fDstInfo.width(), fDeltaSrc, fCurrY,
422 fColorTable); 422 fColorTable);
423 } 423 }
424 424
425 void SkSwizzler::Fill(void* dst, const SkImageInfo& dstInfo, size_t dstRowBytes, uint32_t y, 425 void SkSwizzler::Fill(void* dst, const SkImageInfo& dstInfo, size_t dstRowBytes, uint32_t y,
426 uint32_t colorOrIndex, SkPMColor* colorTable) { 426 uint32_t colorOrIndex, const SkPMColor* colorTable, bool bottomUp) {
427 SkASSERT(dst != NULL); 427 SkASSERT(dst != NULL);
428 SkASSERT(y < (uint32_t) dstInfo.height()); 428 SkASSERT(y < (uint32_t) dstInfo.height());
429 429
430 // Get dst start row 430 // Get dst start row
431 void* dstRow = SkTAddOffset<void*>(dst, y * dstRowBytes); 431 void* dstRow;
432 if (bottomUp) {
433 dstRow = dst;
434 } else {
435 dstRow = SkTAddOffset<void*>(dst, y * dstRowBytes);
436 }
432 437
433 // Calculate remaining bytes. This is tricky since the final row may not be padded. 438 // Calculate remaining bytes. This is tricky since the final row may not be padded.
434 const size_t totalBytes = dstInfo.getSafeSize(dstRowBytes); 439 const size_t totalBytes = dstInfo.getSafeSize(dstRowBytes);
435 const size_t remainingBytes = totalBytes - y * dstRowBytes; 440 const size_t remainingBytes = totalBytes - y * dstRowBytes;
scroggo 2015/04/10 18:12:43 It seems like if (bottomUp), the remaining bytes w
msarett 2015/04/10 20:52:56 This is in fact correct as is, but quite confusing
436 441
437 // Use the proper memset routine to fill the remaining bytes 442 // Use the proper memset routine to fill the remaining bytes
438 switch(dstInfo.colorType()) { 443 switch(dstInfo.colorType()) {
439 case kN32_SkColorType: 444 case kN32_SkColorType:
440 // Assume input is an index if we have a color table 445 // Assume input is an index if we have a color table
441 uint32_t color; 446 uint32_t color;
442 if (NULL != colorTable) { 447 if (NULL != colorTable) {
443 SkASSERT(colorOrIndex == (uint8_t) colorOrIndex); 448 SkASSERT(colorOrIndex == (uint8_t) colorOrIndex);
444 color = colorTable[colorOrIndex]; 449 color = colorTable[colorOrIndex];
445 // Otherwise, assume the input is a color 450 // Otherwise, assume the input is a color
(...skipping 21 matching lines...) Expand all
467 case kIndex_8_SkColorType: 472 case kIndex_8_SkColorType:
468 SkASSERT(colorOrIndex == (uint8_t) colorOrIndex); 473 SkASSERT(colorOrIndex == (uint8_t) colorOrIndex);
469 memset(dstRow, colorOrIndex, remainingBytes); 474 memset(dstRow, colorOrIndex, remainingBytes);
470 break; 475 break;
471 default: 476 default:
472 SkCodecPrintf("Error: Unsupported dst color type for fill(). Doing nothing.\n"); 477 SkCodecPrintf("Error: Unsupported dst color type for fill(). Doing nothing.\n");
473 SkASSERT(false); 478 SkASSERT(false);
474 break; 479 break;
475 } 480 }
476 } 481 }
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