Fix uninitialized memory on kIndex8 divisor tests in Gold
Turns out bitmap.eraseColor() does nothing if the bitmap is kIndex8. We need a more reliable way to initialize all of the pixels that we look at in Gold. The input SkCanvas* is always zero initialized, so let's only draw pixels to the canvas if we have initialized them. BUG=skia: Review URL: https://codereview.chromium.org/1418913002
This commit is contained in:
parent
4d5de04559
commit
fa23a9ec4e
@ -684,9 +684,9 @@ Error AndroidCodecSrc::draw(SkCanvas* canvas) const {
|
||||
return Error::Nonfatal("Divisor is larger than image dimension.\n");
|
||||
}
|
||||
|
||||
// Rounding the size of the subsets may leave some pixels uninitialized on the bottom
|
||||
// and right edges of the bitmap.
|
||||
bitmap.eraseColor(0);
|
||||
// Keep track of the final decoded dimensions.
|
||||
int finalScaledWidth = 0;
|
||||
int finalScaledHeight = 0;
|
||||
for (int x = 0; x < divisor; x++) {
|
||||
for (int y = 0; y < divisor; y++) {
|
||||
// Calculate the subset dimensions
|
||||
@ -704,13 +704,19 @@ Error AndroidCodecSrc::draw(SkCanvas* canvas) const {
|
||||
return "Could not get supported subset to decode.\n";
|
||||
}
|
||||
options.fSubset = ⊂
|
||||
void* pixels = bitmap.getAddr(subset.left() / fSampleSize,
|
||||
subset.top() / fSampleSize);
|
||||
const int scaledWidthOffset = subset.left() / fSampleSize;
|
||||
const int scaledHeightOffset = subset.top() / fSampleSize;
|
||||
void* pixels = bitmap.getAddr(scaledWidthOffset, scaledHeightOffset);
|
||||
SkISize scaledSubsetSize = codec->getSampledSubsetDimensions(fSampleSize,
|
||||
subset);
|
||||
SkImageInfo subsetDecodeInfo = decodeInfo.makeWH(scaledSubsetSize.width(),
|
||||
scaledSubsetSize.height());
|
||||
|
||||
if (x + 1 == divisor && y + 1 == divisor) {
|
||||
finalScaledWidth = scaledWidthOffset + scaledSubsetSize.width();
|
||||
finalScaledHeight = scaledHeightOffset + scaledSubsetSize.height();
|
||||
}
|
||||
|
||||
switch (codec->getAndroidPixels(subsetDecodeInfo, pixels, bitmap.rowBytes(),
|
||||
&options)) {
|
||||
case SkCodec::kSuccess:
|
||||
@ -723,7 +729,10 @@ Error AndroidCodecSrc::draw(SkCanvas* canvas) const {
|
||||
}
|
||||
}
|
||||
}
|
||||
canvas->drawBitmap(bitmap, 0, 0);
|
||||
|
||||
SkRect rect = SkRect::MakeXYWH(0, 0, (SkScalar) finalScaledWidth,
|
||||
(SkScalar) finalScaledHeight);
|
||||
canvas->drawBitmapRect(bitmap, rect, rect, nullptr);
|
||||
return "";
|
||||
}
|
||||
default:
|
||||
|
Loading…
Reference in New Issue
Block a user