From b087db35bd0e7fdf7d4e6311d5acd37acda8793e Mon Sep 17 00:00:00 2001 From: Nicolas Capens Date: Tue, 23 Mar 2021 20:19:57 -0400 Subject: Check if the buffer is actually being scaled instead of only checking scaling mode BufferStateLayers have a default scale to window scaling mode which means the layers would be set use texture filtering regardless of the buffer size. This was breaking some pixel by pixel screenshot comparison tests. Instead check if the buffer size, after applying any buffer transforms, matches the layer size. This is a cherry pick of ag/12947725, preparing for a subsequent change to apply the same logic to BufferLayer. Bug: b/182584062 Test: android.view.inputmethod.cts.FocusHandlingTest#testNonFocusablePopupWindowDoesNotAffectImeVisibility Merged-In: I90b05187a2e22834a99d3690095293fa37118734 Change-Id: I8a64ad96c82b65abf5d1312447ff76915c61f5d5 --- services/surfaceflinger/BufferStateLayer.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'services/surfaceflinger/BufferStateLayer.cpp') diff --git a/services/surfaceflinger/BufferStateLayer.cpp b/services/surfaceflinger/BufferStateLayer.cpp index 790f2ece77..ad2620cd91 100644 --- a/services/surfaceflinger/BufferStateLayer.cpp +++ b/services/surfaceflinger/BufferStateLayer.cpp @@ -760,6 +760,31 @@ Layer::RoundedCornerState BufferStateLayer::getRoundedCornerState() const { static_cast(s.active.transform.ty() + s.active.h)), radius); } + +bool BufferStateLayer::bufferNeedsFiltering() const { + const State& s(getDrawingState()); + if (!s.buffer) { + return false; + } + + uint32_t bufferWidth = s.buffer->width; + uint32_t bufferHeight = s.buffer->height; + + // Undo any transformations on the buffer and return the result. + if (s.transform & ui::Transform::ROT_90) { + std::swap(bufferWidth, bufferHeight); + } + + if (s.transformToDisplayInverse) { + uint32_t invTransform = DisplayDevice::getPrimaryDisplayRotationFlags(); + if (invTransform & ui::Transform::ROT_90) { + std::swap(bufferWidth, bufferHeight); + } + } + + const Rect layerSize{getBounds()}; + return layerSize.width() != bufferWidth || layerSize.height() != bufferHeight; +} } // namespace android // TODO(b/129481165): remove the #pragma below and fix conversion issues -- cgit v1.2.3-59-g8ed1b