Fix kSubset_Mode tests on non-native swizzles
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1918813002
Review URL: https://codereview.chromium.org/1918813002
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp
index dcbd220..18ac6b4 100644
--- a/dm/DMSrcSink.cpp
+++ b/dm/DMSrcSink.cpp
@@ -585,11 +585,12 @@
// And scale
// FIXME: Should we have a version of getScaledDimensions that takes a subset
// into account?
- decodeInfo = decodeInfo.makeWH(
- SkTMax(1, SkScalarRoundToInt(preScaleW * fScale)),
- SkTMax(1, SkScalarRoundToInt(preScaleH * fScale)));
- size_t rowBytes = decodeInfo.minRowBytes();
- if (!subsetBm.installPixels(decodeInfo, pixels, rowBytes, colorTable.get(),
+ const int scaledW = SkTMax(1, SkScalarRoundToInt(preScaleW * fScale));
+ const int scaledH = SkTMax(1, SkScalarRoundToInt(preScaleH * fScale));
+ decodeInfo = decodeInfo.makeWH(scaledW, scaledH);
+ SkImageInfo subsetBitmapInfo = bitmapInfo.makeWH(scaledW, scaledH);
+ size_t rowBytes = subsetBitmapInfo.minRowBytes();
+ if (!subsetBm.installPixels(subsetBitmapInfo, pixels, rowBytes, colorTable.get(),
nullptr, nullptr)) {
return SkStringPrintf("could not install pixels for %s.", fPath.c_str());
}
@@ -606,7 +607,7 @@
fPath.c_str(), W, H, result);
}
premultiply_if_necessary(subsetBm);
- swap_rb_if_necessary(bitmap, fDstColorType);
+ swap_rb_if_necessary(subsetBm, fDstColorType);
canvas->drawBitmap(subsetBm, SkIntToScalar(left), SkIntToScalar(top));
// translate by the scaled height.
top += decodeInfo.height();