Respect buffer source crop in client composition.
Previously only the SurfaceControl crop was respected, which causes a
discrepancy with HWC, since HWC recevies a crop that is intersected with
the crop provided by BufferQueue.
Bug: 122171389
Change-Id: Ie83fd30369ddd93703027c9577292eeb6f3fe110
Test: adb screenrecord
Test: Repro steps in b/122171389 no longer repro.
Test: adb screencap
Test: 4k youtube playback, fullscreen + rotations
Test: virtual display simulation
diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h
index 2e75088..7bc7a82 100644
--- a/services/surfaceflinger/Layer.h
+++ b/services/surfaceflinger/Layer.h
@@ -671,12 +671,22 @@
uint32_t getEffectiveUsage(uint32_t usage) const;
- virtual FloatRect computeCrop(const sp<const DisplayDevice>& display) const;
+ // Computes the crop applied to this layer. windowBounds is the boundary of
+ // layer-stack space, so the cropping rectangle will be clipped to those
+ // bounds in that space. The crop rectangle is returned in buffer space. If
+ // windowBounds is invalid, then it is ignored.
+ virtual FloatRect computeCrop(const Rect& windowBounds) const;
+
+ // See the above method, but pulls the window boundaries from the display.
+ FloatRect computeCrop(const sp<const DisplayDevice>& display) const {
+ return computeCrop(display->getViewport());
+ }
// Compute the initial crop as specified by parent layers and the
// SurfaceControl for this layer. Does not include buffer crop from the
// IGraphicBufferProducer client, as that should not affect child clipping.
// Returns in screen space.
- Rect computeInitialCrop(const sp<const DisplayDevice>& display) const;
+ Rect computeInitialCrop(const Rect& windowBounds) const;
+
/**
* Setup rounded corners coordinates of this layer, taking into account the layer bounds and
* crop coordinates, transforming them into layer space.