summaryrefslogtreecommitdiff
path: root/libs/hwui/Readback.cpp
diff options
context:
space:
mode:
author John Reck <jreck@google.com> 2021-10-01 16:30:11 -0400
committer John Reck <jreck@google.com> 2021-10-01 16:30:11 -0400
commitb48d4d10abfd1af41d8226939f12b6af5e243dff (patch)
treeee4a6a36d9b373018de28f2f8da019bc959dfaef /libs/hwui/Readback.cpp
parentcbe9af5ab5ce7814753608a15efeb69a49f82737 (diff)
CTS of CtsMediaTestCases#android.media.cts.DecodeAccuracyTest may fail when video is cropped.
When we use GPU to copy the data, rendering would choose filter. But we need add shrink in border to ensure the sampler not reach border like what GUI does. Change-Id: I2c59956f3d7a7052d8e4bee587360f252a6c5549 Signed-off-by: Chun Jiang <chun.jiang@mediatek.com> Bug: 197180327 Test: CTS PixelCopyTests & DecodeAccuracyTest
Diffstat (limited to 'libs/hwui/Readback.cpp')
-rw-r--r--libs/hwui/Readback.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/libs/hwui/Readback.cpp b/libs/hwui/Readback.cpp
index e08b99d52cdb..d897e94f969f 100644
--- a/libs/hwui/Readback.cpp
+++ b/libs/hwui/Readback.cpp
@@ -32,6 +32,8 @@
using namespace android::uirenderer::renderthread;
+static constexpr bool sEnableExtraCropInset = true;
+
namespace android {
namespace uirenderer {
@@ -71,6 +73,20 @@ CopyResult Readback::copySurfaceInto(ANativeWindow* window, const Rect& inSrcRec
ALOGW("Surface doesn't have any previously queued frames, nothing to readback from");
return CopyResult::SourceEmpty;
}
+
+ if (sEnableExtraCropInset &&
+ (cropRect.right - cropRect.left != bitmap->width() ||
+ cropRect.bottom - cropRect.top != bitmap->height())) {
+ /*
+ * When we need use filtering, we should also make border shrink here like gui.
+ * But we could not check format for YUV or RGB here... Just use 1 pix.
+ */
+ cropRect.left += 0.5f;
+ cropRect.top += 0.5f;
+ cropRect.right -= 0.5f;
+ cropRect.bottom -= 0.5f;
+ }
+
UniqueAHardwareBuffer sourceBuffer{rawSourceBuffer};
AHardwareBuffer_Desc description;
AHardwareBuffer_describe(sourceBuffer.get(), &description);