Fix filtering for screenshotting custom displays.
Previously, filtering was computed for screenshots by checking if filtering was required for the DisplayDevice itself. That's correct for rendering custom display sizes since we need to upsample to the physical panel, but it's wrong for screenshotting to an output buffer where the logical transform does not involve a scale. Instead, we want to compare the source crop with the destination buffer size when determining whether we need to apply linear filtering. As part of this, some of the rendering math is now simpler. Rather than setting DisplaySettings::physicalDisplay and DisplaySettings::clip to be the same and explicitly computing the transform matrix in RenderEngine, we instead set DisplaySettings::clip to be the logical viewport. Then the global transform is implicitly applied as part of mapping the output in glViewport. This is because if the logical display is smaller than the screen size, with the previous behavior applying the global transform will scale up the layer stack to the physical display size. But if we want pixel-accurate screenshots we will need to downsample back down to the logical display size, which may cause errors. The math simplification will avoid that scenario entirely. This also means that screenshot code needs to be adjusted - some callers pass in a cropping rectangle that assumes the display screenshot is captured in portrait orientation. Other callers pass in a cropping rectangle relative to a particular layer's coordinate space. For each of those paths, the cropping rectangle must be transformed to the logical display space. This has also discovered a bug in setting the background fill of the screenshot, which has now been fixed. Bug: 129101431 Test: adb shell screepcap Test: Modify wm size and density, and run SurfaceViewTests#testMovingWhiteSurfaceView Test: Capture screenshots through vysor Test: Capture screenshots on Pixel 3XL with notch hide Test: Physically capture screenshots Test: Display rotations Test: SurfaceFlinger_test Test: librenderengine_test Test: libsurfaceflinger_unittest Test: libcompositionengine_test Change-Id: I7f4e98d4c5aa53a995fd7da70078a2e5ea43b14f
Loading
Please register or sign in to comment