diff options
author | John Reck <jreck@google.com> | 2021-10-04 16:45:17 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2021-10-04 16:45:17 +0000 |
commit | 44bfae1759939e03970b70ec942ab2d3e44a1982 (patch) | |
tree | ad2423a1eab13e63ccb7a6f0c357b4425d750c6b | |
parent | 5f4a5b87c8a9bf81008b94c086b09d023a6dd324 (diff) | |
parent | 06e16941d5902abe9dd8fa854e18ebfa99c9d3ab (diff) | |
download | base-44bfae1759939e03970b70ec942ab2d3e44a1982.tar.gz |
Merge "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." am: 06e16941d5
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1801770
Change-Id: I1e34d4b25af83a4761e7a2fc81bf5b79d7b2aa08
-rw-r--r-- | libs/hwui/Readback.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/libs/hwui/Readback.cpp b/libs/hwui/Readback.cpp index a743d30939d0..f8d6c07b980d 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 { @@ -64,6 +66,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); |