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.cpp b/services/surfaceflinger/DisplayDevice.cpp
index 4ae6dad..f3fe159 100644
--- a/services/surfaceflinger/DisplayDevice.cpp
+++ b/services/surfaceflinger/DisplayDevice.cpp
@@ -222,10 +222,13 @@
const bool needsFiltering =
(!globalTransform.preserveRects() || (type >= ui::Transform::SCALE));
- Rect scissor = globalTransform.transform(viewport);
- if (scissor.isEmpty()) {
- scissor = displayBounds;
+ Rect sourceClip = globalTransform.transform(viewport);
+ if (sourceClip.isEmpty()) {
+ sourceClip = displayBounds;
}
+ // For normal display use we always set the source and destination clip
+ // rectangles to the same values.
+ const Rect& destinationClip = sourceClip;
uint32_t transformOrientation;
@@ -236,8 +239,8 @@
transformOrientation = ui::Transform::toRotationFlags(orientation);
}
- getCompositionDisplay()->setProjection(globalTransform, transformOrientation,
- frame, viewport, scissor, needsFiltering);
+ getCompositionDisplay()->setProjection(globalTransform, transformOrientation, frame, viewport,
+ sourceClip, destinationClip, needsFiltering);
}
ui::Transform::RotationFlags DisplayDevice::getPrimaryDisplayRotationFlags() {
@@ -302,8 +305,8 @@
return mCompositionDisplay->getState().frame;
}
-const Rect& DisplayDevice::getScissor() const {
- return mCompositionDisplay->getState().scissor;
+const Rect& DisplayDevice::getSourceClip() const {
+ return mCompositionDisplay->getState().sourceClip;
}
bool DisplayDevice::hasWideColorGamut() const {