summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Vishnu Nair <vishnun@google.com> 2020-10-29 14:45:03 -0700
committer Vishnu Nair <vishnun@google.com> 2020-10-29 14:45:03 -0700
commite7f79c51ec0d00bc79d9e4f017a56cdb627667bb (patch)
tree6e56b2749c59007401856ca41dd9299d9073e471
parentc88cf4a5a81f89894696623b0560954d162e5217 (diff)
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. Test: android.view.inputmethod.cts.FocusHandlingTest#testNonFocusablePopupWindowDoesNotAffectImeVisibility Change-Id: I90b05187a2e22834a99d3690095293fa37118734
-rw-r--r--services/surfaceflinger/BufferLayer.cpp8
-rw-r--r--services/surfaceflinger/BufferLayer.h4
-rw-r--r--services/surfaceflinger/BufferStateLayer.cpp25
-rw-r--r--services/surfaceflinger/BufferStateLayer.h2
4 files changed, 37 insertions, 2 deletions
diff --git a/services/surfaceflinger/BufferLayer.cpp b/services/surfaceflinger/BufferLayer.cpp
index 9c3fdbb405..d302f987b1 100644
--- a/services/surfaceflinger/BufferLayer.cpp
+++ b/services/surfaceflinger/BufferLayer.cpp
@@ -204,8 +204,8 @@ std::optional<compositionengine::LayerFE::LayerSettings> BufferLayer::prepareCli
layer.frameNumber = mCurrentFrameNumber;
layer.bufferId = mBufferInfo.mBuffer ? mBufferInfo.mBuffer->getId() : 0;
- // TODO: we could be more subtle with isFixedSize()
- const bool useFiltering = targetSettings.needsFiltering || mNeedsFiltering || isFixedSize();
+ const bool useFiltering =
+ targetSettings.needsFiltering || mNeedsFiltering || bufferNeedsFiltering();
// Query the texture matrix given our current filtering mode.
float textureMatrix[16];
@@ -822,6 +822,10 @@ void BufferLayer::setTransformHint(ui::Transform::RotationFlags displayTransform
}
}
+bool BufferLayer::bufferNeedsFiltering() const {
+ return isFixedSize();
+}
+
} // namespace android
#if defined(__gl_h_)
diff --git a/services/surfaceflinger/BufferLayer.h b/services/surfaceflinger/BufferLayer.h
index e6a0f81622..deaf8461e8 100644
--- a/services/surfaceflinger/BufferLayer.h
+++ b/services/surfaceflinger/BufferLayer.h
@@ -115,6 +115,10 @@ public:
ui::Transform::RotationFlags getTransformHint() const override { return mTransformHint; }
+ // Returns true if the transformed buffer size does not match the layer size and we need
+ // to apply filtering.
+ virtual bool bufferNeedsFiltering() const;
+
protected:
struct BufferInfo {
nsecs_t mDesiredPresentTime;
diff --git a/services/surfaceflinger/BufferStateLayer.cpp b/services/surfaceflinger/BufferStateLayer.cpp
index 6f344c721a..f85151449b 100644
--- a/services/surfaceflinger/BufferStateLayer.cpp
+++ b/services/surfaceflinger/BufferStateLayer.cpp
@@ -744,6 +744,31 @@ Layer::RoundedCornerState BufferStateLayer::getRoundedCornerState() const {
static_cast<float>(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
diff --git a/services/surfaceflinger/BufferStateLayer.h b/services/surfaceflinger/BufferStateLayer.h
index 4773286e44..104a13be71 100644
--- a/services/surfaceflinger/BufferStateLayer.h
+++ b/services/surfaceflinger/BufferStateLayer.h
@@ -143,6 +143,8 @@ private:
bool willPresentCurrentTransaction() const;
+ bool bufferNeedsFiltering() const override;
+
static const std::array<float, 16> IDENTITY_MATRIX;
std::unique_ptr<renderengine::Image> mTextureImage;