Avoid sampling outside BQ crop rect

The region outside of the BQ crop rect is potentially
garbage. Avoid sampling from it.

Fixes: 189656466
Test: CTS PixelCopyTests & DecodeAccuracyTest
Change-Id: I2910d93471f08aaf807ac9f87fdf84cf29cf4143
This commit is contained in:
John Reck
2021-07-14 14:24:51 -04:00
parent ab7b0e8991
commit 0f284da923

View File

@@ -183,8 +183,10 @@ CopyResult Readback::copySurfaceInto(ANativeWindow* window, const Rect& inSrcRec
SkPaint paint;
paint.setAlpha(255);
paint.setBlendMode(SkBlendMode::kSrc);
canvas->drawImageRect(image, imageSrcRect, imageDstRect, sampling, &paint,
SkCanvas::kFast_SrcRectConstraint);
const bool hasBufferCrop = cropRect.left < cropRect.right && cropRect.top < cropRect.bottom;
auto constraint =
hasBufferCrop ? SkCanvas::kStrict_SrcRectConstraint : SkCanvas::kFast_SrcRectConstraint;
canvas->drawImageRect(image, imageSrcRect, imageDstRect, sampling, &paint, constraint);
canvas->restore();
if (!tmpSurface->readPixels(*bitmap, 0, 0)) {