[SF] Make sure destination clip is contained in display bounds
When we render on a framebuffer with smaller size than the
currently active mode the destination clip can get outside
of the display bounds. For examlple, if the currently
active display mode is 4K, but we render on a 1080p framebuffer,
dest clip = 4k, but display bounds =1080p. As a result of that
only the top left quarter of the image is visible on screen.
Bug: 153991408
Test: manually make sure the image is properly displayed on sreen
1. boot device
2. turn off HWC with adb shell service call SurfaceFlinger 1008 i32 1
3. turn on HWC with adb shell service call SurfaceFlinger 1008 i32 1
4. start a youtube video and repeat 2 and 3.
Test: take a screenshot and check it's correctly displayed
Test: atest libsurfaceflinger_unittest librenderengine_test
Change-Id: Ia7b6ebd311c1b751c1966a34a9294b9b85a2aa0b
diff --git a/services/surfaceflinger/DisplayDevice.cpp b/services/surfaceflinger/DisplayDevice.cpp
index 2cebecb..45e6047 100644
--- a/services/surfaceflinger/DisplayDevice.cpp
+++ b/services/surfaceflinger/DisplayDevice.cpp
@@ -231,6 +231,8 @@
if (destinationClip.isEmpty()) {
destinationClip = displayBounds;
}
+ // Make sure the destination clip is contained in the display bounds
+ destinationClip.intersect(displayBounds, &destinationClip);
uint32_t transformOrientation;