Skip to content

Commit

Permalink
Fix SkSampler::Fill/Gray_8 when width != stride
Browse files Browse the repository at this point in the history
Bug: skia:
Change-Id: I68296bc9902c008d30a0ef1e748f22edd8c56255
Reviewed-on: https://skia-review.googlesource.com/150780
Reviewed-by: Leon Scroggins <scroggo@google.com>
Commit-Queue: Leon Scroggins <scroggo@google.com>
  • Loading branch information
Nigel Tao authored and Skia Commit-Bot committed Sep 4, 2018
1 parent 6a1185a commit fddc6fa
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/codec/SkSampler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ void SkSampler::Fill(const SkImageInfo& info, void* dst, size_t rowBytes,
return;
}

// Calculate bytes to fill.
const size_t bytesToFill = info.computeByteSize(rowBytes);
const int width = info.width();
const int numRows = info.height();

Expand All @@ -29,26 +27,31 @@ void SkSampler::Fill(const SkImageInfo& info, void* dst, size_t rowBytes,
case kBGRA_8888_SkColorType: {
uint32_t* dstRow = (uint32_t*) dst;
for (int row = 0; row < numRows; row++) {
sk_memset32((uint32_t*) dstRow, 0, width);
sk_memset32(dstRow, 0, width);
dstRow = SkTAddOffset<uint32_t>(dstRow, rowBytes);
}
break;
}
case kRGB_565_SkColorType: {
uint16_t* dstRow = (uint16_t*) dst;
for (int row = 0; row < numRows; row++) {
sk_memset16((uint16_t*) dstRow, 0, width);
sk_memset16(dstRow, 0, width);
dstRow = SkTAddOffset<uint16_t>(dstRow, rowBytes);
}
break;
}
case kGray_8_SkColorType:
memset(dst, 0, bytesToFill);
case kGray_8_SkColorType: {
uint8_t* dstRow = (uint8_t*) dst;
for (int row = 0; row < numRows; row++) {
memset(dstRow, 0, width);
dstRow = SkTAddOffset<uint8_t>(dstRow, rowBytes);
}
break;
}
case kRGBA_F16_SkColorType: {
uint64_t* dstRow = (uint64_t*) dst;
for (int row = 0; row < numRows; row++) {
sk_memset64((uint64_t*) dstRow, 0, width);
sk_memset64(dstRow, 0, width);
dstRow = SkTAddOffset<uint64_t>(dstRow, rowBytes);
}
break;
Expand Down

0 comments on commit fddc6fa

Please sign in to comment.