drm_hwcomposer: Presentation to cursor plane
This change adds support for presenting to the cursor plane.
Logic is added to match cursor layers with cursor planes during
composition, plus additional test commit logic with backoff
behavior. Prior to this change, cursor planes were never
considered during composition. After this change, cursor
planes are available to be matched with compatible layers and
then used for presentation.
Change-Id: I3acd131cd210de46ff19af5a8960b07a82f462b2
Signed-off-by: Andrew Wolfers <aswolfers@google.com>
diff --git a/hwc2_device/HwcDisplay.cpp b/hwc2_device/HwcDisplay.cpp
index a438263..82f826b 100644
--- a/hwc2_device/HwcDisplay.cpp
+++ b/hwc2_device/HwcDisplay.cpp
@@ -740,11 +740,21 @@
bool use_client_layer = false;
uint32_t client_z_order = UINT32_MAX;
std::map<uint32_t, HwcLayer *> z_map;
+ std::optional<LayerData> cursor_layer = std::nullopt;
for (auto &[_, layer] : layers_) {
switch (layer.GetValidatedType()) {
case HWC2::Composition::Device:
z_map.emplace(layer.GetZOrder(), &layer);
break;
+ case HWC2::Composition::Cursor:
+ if (!cursor_layer.has_value()) {
+ layer.PopulateLayerData();
+ cursor_layer = layer.GetLayerData();
+ } else {
+ ALOGW("Detected multiple cursor layers");
+ z_map.emplace(layer.GetZOrder(), &layer);
+ }
+ break;
case HWC2::Composition::Client:
// Place it at the z_order of the lowest client layer
use_client_layer = true;
@@ -794,7 +804,8 @@
* in between of ValidateDisplay() and PresentDisplay() calls
*/
current_plan_ = DrmKmsPlan::CreateDrmKmsPlan(GetPipe(),
- std::move(composition_layers));
+ std::move(composition_layers),
+ cursor_layer);
if (type_ == HWC2::DisplayType::Virtual) {
writeback_layer_->PopulateLayerData();
@@ -1035,6 +1046,12 @@
std::sort(std::begin(ordered_layers), std::end(ordered_layers),
[](const HwcLayer *lhs, const HwcLayer *rhs) {
+ // Cursor layers should always have highest zpos.
+ if ((lhs->GetSfType() == HWC2::Composition::Cursor) !=
+ (rhs->GetSfType() == HWC2::Composition::Cursor)) {
+ return rhs->GetSfType() == HWC2::Composition::Cursor;
+ }
+
return lhs->GetZOrder() < rhs->GetZOrder();
});