1
0
Fork 0

drm_hwcomposer: Check cursor layer compatibility

With the cursor layer's LayerData already populated before entering the
Backend, the Backend can check whether the cursor layer is compatible
with the drm cursor plane before attempting the composition.

Change-Id: I2725f411913b5f998b9549bfc0537d0d9886a569
Signed-off-by: Drew Davenport <ddavenport@google.com>
This commit is contained in:
Drew Davenport 2025-04-04 14:39:36 -06:00
parent e83714e737
commit 571eb6af58

View file

@ -27,10 +27,16 @@ namespace android {
namespace {
bool HasCursorLayer(const std::vector<HwcLayer *> &layers) {
return std::find_if(layers.begin(), layers.end(), [&](auto *layer) -> bool {
return layer->GetSfType() == HWC2::Composition::Cursor;
}) != layers.end();
HwcLayer *GetCursorLayer(const std::vector<HwcLayer *> &layers) {
auto it = std::find_if(layers.begin(), layers.end(),
[&](auto *layer) -> bool {
return layer->GetSfType() ==
HWC2::Composition::Cursor;
});
if (it == layers.end()) {
return nullptr;
}
return *it;
}
} // namespace
@ -60,9 +66,12 @@ HWC2::Error Backend::ValidateDisplay(HwcDisplay *display, uint32_t *num_types,
int client_start = -1;
size_t client_size = 0;
bool use_cursor_plane = HasCursorLayer(layers) &&
display->GetPipe().GetUsablePlanes().second !=
nullptr;
auto *cursor_layer = GetCursorLayer(layers);
auto cursor_plane = display->GetPipe().GetUsablePlanes().second;
bool use_cursor_plane = cursor_layer != nullptr && cursor_plane != nullptr &&
!IsClientLayer(display, cursor_layer) &&
cursor_plane->Get()->IsValidForLayer(
&cursor_layer->GetLayerData());
// Validates layers and creates a test composition, returning whether it
// succeeded.