CE: Use distinct source and destination clip rectangles
The existing logic used a single clip rectangle, which was passed to
RenderEngine as both DisplaySettings.physicalDisplay and
DisplaySettings.clip. In at least the GLES backend, the first is used to
set the GL viewport, and the later is used to set the clip rectangle.
However if an Output is set up to render an arbitrary subrectangle of
a larger physical display space, distinct values need to be used --
typically the viewport (destination clip) is set to (0, 0, w, h), while
the source clip is set to some (x0, y0, x0 + w, y0 + w).
Note that in particular we still need to both rectangles to the same (0,
y0, w, y0 + h) rectangle when the goal is to hide a notch on a physical
device, so the rectangle settings must be obtained from code outside of
libcompositionengine.
Test: go/wm-smoke on crosshatch, checking notch-hiding
Test: atest libcompositionengine_test
Test: CtsColorModeTestCases
Test: CtsDisplayTestCases
Test: CtsGraphicsTestCases
Test: CtsUiRenderingTestCases
Test: CtsViewTestCases
Test: android.media.cts.EncodeVirtualDisplayWithCompositionTest
Bug: 144116549
Change-Id: Ic7218da2457f2645af180a1b4eed3dd6896db7d1
diff --git a/services/surfaceflinger/DisplayDevice.h b/services/surfaceflinger/DisplayDevice.h
index ff48ecd..75c709e 100644
--- a/services/surfaceflinger/DisplayDevice.h
+++ b/services/surfaceflinger/DisplayDevice.h
@@ -96,7 +96,7 @@
const ui::Transform& getTransform() const;
const Rect& getViewport() const;
const Rect& getFrame() const;
- const Rect& getScissor() const;
+ const Rect& getSourceClip() const;
bool needsFiltering() const;
uint32_t getLayerStack() const;
@@ -271,7 +271,7 @@
Rect getSourceCrop() const override {
// use the projected display viewport by default.
if (mSourceCrop.isEmpty()) {
- return mDisplay->getScissor();
+ return mDisplay->getSourceClip();
}
// Recompute the device transformation for the source crop.
@@ -280,14 +280,14 @@
ui::Transform translateLogical;
ui::Transform scale;
const Rect& viewport = mDisplay->getViewport();
- const Rect& scissor = mDisplay->getScissor();
+ const Rect& sourceClip = mDisplay->getSourceClip();
const Rect& frame = mDisplay->getFrame();
const auto flags = ui::Transform::toRotationFlags(mDisplay->getPhysicalOrientation());
rotation.set(flags, getWidth(), getHeight());
translateLogical.set(-viewport.left, -viewport.top);
- translatePhysical.set(scissor.left, scissor.top);
+ translatePhysical.set(sourceClip.left, sourceClip.top);
scale.set(frame.getWidth() / float(viewport.getWidth()), 0, 0,
frame.getHeight() / float(viewport.getHeight()));
const ui::Transform finalTransform =