Actually use texture bounds in CachedSet::getTextureBounds
Virtual displays may be projected onto a display area that is a
subrectangle of the display size. Because the flattened buffer for a
CachedSet is display-size, we need to use the display size as the
display frame instead of the framebuffer output rectangle. Otherwise, we
would be blitting the contents of the display-sized texture onto a
smaller area, which causes an unintended scale.
Bug: 191328868
Test: Simulating secondary displays does not squash the content.
Test: libcompositionengine_test
Change-Id: I79d56a998e4f7fc030191fed50002354c3c18561
diff --git a/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/planner/CachedSet.h b/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/planner/CachedSet.h
index 2bf931c..2e7a377 100644
--- a/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/planner/CachedSet.h
+++ b/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/planner/CachedSet.h
@@ -65,7 +65,9 @@
size_t getLayerCount() const { return mLayers.size(); }
const Layer& getFirstLayer() const { return mLayers[0]; }
const Rect& getBounds() const { return mBounds; }
- Rect getTextureBounds() const { return mOutputSpace.content; }
+ Rect getTextureBounds() const {
+ return mTexture ? mTexture->get()->getBuffer()->getBounds() : Rect::INVALID_RECT;
+ }
const Region& getVisibleRegion() const { return mVisibleRegion; }
size_t getAge() const { return mAge; }
std::shared_ptr<renderengine::ExternalTexture> getBuffer() const {
diff --git a/services/surfaceflinger/CompositionEngine/tests/planner/CachedSetTest.cpp b/services/surfaceflinger/CompositionEngine/tests/planner/CachedSetTest.cpp
index 7f0e186..b05a594 100644
--- a/services/surfaceflinger/CompositionEngine/tests/planner/CachedSetTest.cpp
+++ b/services/surfaceflinger/CompositionEngine/tests/planner/CachedSetTest.cpp
@@ -355,7 +355,7 @@
expectReadyBuffer(cachedSet);
EXPECT_EQ(mOutputState.framebufferSpace, cachedSet.getOutputSpace());
- EXPECT_EQ(mOutputState.framebufferSpace.content, cachedSet.getTextureBounds());
+ EXPECT_EQ(Rect(kOutputSize.width, kOutputSize.height), cachedSet.getTextureBounds());
// Now check that appending a new cached set properly cleans up RenderEngine resources.
CachedSet::Layer& layer3 = *mTestLayers[2]->cachedSetLayer.get();