SkXPS: use correct drawBitmapRect logic for !bitmap.bounds().contains(*src)

Change-Id: I768b01d1a9afce99f09a0aaa793ba8ebfdefb41e
Reviewed-on: https://skia-review.googlesource.com/9867
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Hal Canary <halcanary@google.com>
This commit is contained in:
Hal Canary 2017-03-17 15:16:21 -04:00 committed by Skia Commit-Bot
parent 6ab59baa84
commit 7da8d646a2

View File

@ -2256,10 +2256,18 @@ void SkXPSDevice::drawBitmapRect(const SkBitmap& bitmap,
const SkRect& dst,
const SkPaint& paint,
SkCanvas::SrcRectConstraint constraint) {
// TODO(halcanary): more closely use correct logic for src > bitmap.bounds().
SkRect srcBounds = src ? *src : SkRect::Make(bitmap.bounds());
SkRect bitmapBounds = SkRect::Make(bitmap.bounds());
SkRect srcBounds = src ? *src : bitmapBounds;
SkMatrix matrix = SkMatrix::MakeRectToRect(srcBounds, dst, SkMatrix::kFill_ScaleToFit);
SkRect actualDst;
if (!src || bitmapBounds.contains(*src)) {
actualDst = dst;
} else {
if (!srcBounds.intersect(bitmapBounds)) {
return;
}
matrix.mapRect(&actualDst, srcBounds);
}
auto bitmapShader = SkMakeBitmapShader(bitmap, SkShader::kClamp_TileMode,
SkShader::kClamp_TileMode, &matrix,
kNever_SkCopyPixelsMode);
@ -2268,6 +2276,6 @@ void SkXPSDevice::drawBitmapRect(const SkBitmap& bitmap,
SkPaint paintWithShader(paint);
paintWithShader.setStyle(SkPaint::kFill_Style);
paintWithShader.setShader(std::move(bitmapShader));
this->drawRect(dst, paintWithShader);
this->drawRect(actualDst, paintWithShader);
}
#endif//defined(SK_BUILD_FOR_WIN32)