Merge "Avoid sampling outside BQ crop rect" into sc-dev

This commit is contained in:
TreeHugger Robot
2021-07-14 22:09:13 +00:00
committed by Android (Google) Code Review

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)) {