drm_hwcomposer: reorder source layers according to zorder

Precomp layers may be added to the back at different points which may
cause elements to be unsorted. Make sure that these are sorted after
provisioning planes to ensure right composition based on zorder.

Bug: 65587393
Change-Id: Ica6d12093818341eaeca6c63735c558511679f7b
Signed-off-by: Adrian Salido <salidoa@google.com>
diff --git a/drmdisplaycomposition.cpp b/drmdisplaycomposition.cpp
index 293160b..0f8084b 100644
--- a/drmdisplaycomposition.cpp
+++ b/drmdisplaycomposition.cpp
@@ -379,6 +379,9 @@
     if (!i.plane())
+    // make sure that source layers are ordered based on zorder
+    std::sort(i.source_layers().begin(), i.source_layers().end());
     std::vector<DrmPlane *> *container;
     if (i.plane()->type() == DRM_PLANE_TYPE_PRIMARY)
       container = primary_planes;