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

Unified Diff: dm/DMSrcSink.cpp

Issue 1418913002: Fix uninitialized memory on kIndex8 divisor tests in Gold (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 2 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dm/DMSrcSink.cpp
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp
index 24ae2d6087ebd4da20775ca7710072190a42d8e3..253f8a69fb2b8d03011045597a0d1c618fd7fd92 100644
--- a/dm/DMSrcSink.cpp
+++ b/dm/DMSrcSink.cpp
@@ -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 = &subset;
- 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:
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698