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

Unified Diff: src/codec/SkSwizzler.cpp

Issue 1075243003: Implementing filling for SkBmpCodec (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Sharing code in static helper 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/codec/SkSwizzler.h ('k') | tests/SwizzlerTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/codec/SkSwizzler.cpp
diff --git a/src/codec/SkSwizzler.cpp b/src/codec/SkSwizzler.cpp
index 754b08883544928f7066456b409420d52a596e84..791363381f52a243ac39a2266d99154c0a1a7db5 100644
--- a/src/codec/SkSwizzler.cpp
+++ b/src/codec/SkSwizzler.cpp
@@ -422,17 +422,13 @@ SkSwizzler::ResultAlpha SkSwizzler::next(const uint8_t* SK_RESTRICT src,
fColorTable);
}
-void SkSwizzler::Fill(void* dst, const SkImageInfo& dstInfo, size_t dstRowBytes, uint32_t y,
- uint32_t colorOrIndex, SkPMColor* colorTable) {
- SkASSERT(dst != NULL);
- SkASSERT(y < (uint32_t) dstInfo.height());
+void SkSwizzler::Fill(void* dstStartRow, const SkImageInfo& dstInfo, size_t dstRowBytes,
+ uint32_t numRows, uint32_t colorOrIndex, const SkPMColor* colorTable) {
+ SkASSERT(dstStartRow != NULL);
+ SkASSERT(numRows <= (uint32_t) dstInfo.height());
- // Get dst start row
- void* dstRow = SkTAddOffset<void*>(dst, y * dstRowBytes);
-
- // Calculate remaining bytes. This is tricky since the final row may not be padded.
- const size_t totalBytes = dstInfo.getSafeSize(dstRowBytes);
- const size_t remainingBytes = totalBytes - y * dstRowBytes;
+ // Calculate bytes to fill. We use getSafeSize since the last row may not be padded.
+ const size_t bytesToFill = dstInfo.makeWH(dstInfo.width(), numRows).getSafeSize(dstRowBytes);
// Use the proper memset routine to fill the remaining bytes
switch(dstInfo.colorType()) {
@@ -448,25 +444,25 @@ void SkSwizzler::Fill(void* dst, const SkImageInfo& dstInfo, size_t dstRowBytes,
}
// We must fill row by row in the case of unaligned row bytes
- if (SkIsAlign4((size_t) dstRow) && SkIsAlign4(dstRowBytes)) {
- sk_memset32((uint32_t*) dstRow, color,
- (uint32_t) remainingBytes / sizeof(SkPMColor));
+ if (SkIsAlign4((size_t) dstStartRow) && SkIsAlign4(dstRowBytes)) {
+ sk_memset32((uint32_t*) dstStartRow, color,
+ (uint32_t) bytesToFill / sizeof(SkPMColor));
} else {
// This is an unlikely, slow case
SkCodecPrintf("Warning: Strange number of row bytes, fill will be slow.\n");
- for (int32_t row = y; row < dstInfo.height(); row++) {
- uint32_t* dstPtr = (uint32_t*) dstRow;
+ uint32_t* dstRow = (uint32_t*) dstStartRow;
+ for (uint32_t row = 0; row < numRows; row++) {
for (int32_t col = 0; col < dstInfo.width(); col++) {
- dstPtr[col] = color;
+ dstRow[col] = color;
}
- dstRow = SkTAddOffset<void*>(dstRow, dstRowBytes);
+ dstRow = SkTAddOffset<uint32_t>(dstRow, dstRowBytes);
}
}
break;
// On an index destination color type, always assume the input is an index
case kIndex_8_SkColorType:
SkASSERT(colorOrIndex == (uint8_t) colorOrIndex);
- memset(dstRow, colorOrIndex, remainingBytes);
+ memset(dstStartRow, colorOrIndex, bytesToFill);
break;
default:
SkCodecPrintf("Error: Unsupported dst color type for fill(). Doing nothing.\n");
« no previous file with comments | « src/codec/SkSwizzler.h ('k') | tests/SwizzlerTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698