drm_hwcomposer: Use a vector for composition source_layers

Instead of a 1:1 mapping of layer:plane, use a vector to store
source layers for a composition plane. This will allow us to
represent squash compositions more easily by adding all source
layers to the vector.

This should also facilitate hardware which allows multiple fbs per plane.

BUG=b/28117135
TEST=Tested on ryu

Signed-off-by: Sean Paul <seanpaul@chromium.org>
Change-Id: I5d4bfc6e9da022eaab047f948cc874d6a8a25746
diff --git a/drmdisplaycomposition.h b/drmdisplaycomposition.h
index 0362404..768ccfb 100644
--- a/drmdisplaycomposition.h
+++ b/drmdisplaycomposition.h
@@ -53,11 +53,51 @@
   kSquash,
 };
 
-struct DrmCompositionPlane {
-  DrmCompositionPlaneType type;
-  DrmPlane *plane;
-  DrmCrtc *crtc;
-  int source_layer;
+class DrmCompositionPlane {
+ public:
+  DrmCompositionPlane() = default;
+  DrmCompositionPlane(DrmCompositionPlane &&rhs) = default;
+  DrmCompositionPlane &operator=(DrmCompositionPlane &&other) = default;
+  DrmCompositionPlane(DrmCompositionPlaneType type, DrmPlane *plane,
+                      DrmCrtc *crtc)
+      : type_(type), plane_(plane), crtc_(crtc) {
+  }
+  DrmCompositionPlane(DrmCompositionPlaneType type, DrmPlane *plane,
+                      DrmCrtc *crtc, size_t source_layer)
+      : type_(type),
+        plane_(plane),
+        crtc_(crtc),
+        source_layers_(1, source_layer) {
+  }
+
+  DrmCompositionPlaneType type() const {
+    return type_;
+  }
+
+  DrmPlane *plane() const {
+    return plane_;
+  }
+  void set_plane(DrmPlane *plane) {
+    plane_ = plane;
+  }
+
+  DrmCrtc *crtc() const {
+    return crtc_;
+  }
+
+  std::vector<size_t> &source_layers() {
+    return source_layers_;
+  }
+
+  const std::vector<size_t> &source_layers() const {
+    return source_layers_;
+  }
+
+ private:
+  DrmCompositionPlaneType type_ = DrmCompositionPlaneType::kDisable;
+  DrmPlane *plane_ = NULL;
+  DrmCrtc *crtc_ = NULL;
+  std::vector<size_t> source_layers_;
 };
 
 class DrmDisplayComposition {
@@ -139,7 +179,10 @@
 
   int IncreaseTimelineToPoint(int point);
 
-  void EmplaceCompositionPlane(DrmCompositionPlaneType type, int source_layer,
+  void EmplaceCompositionPlane(DrmCompositionPlaneType type,
+                               std::vector<DrmPlane *> *primary_planes,
+                               std::vector<DrmPlane *> *overlay_planes);
+  void EmplaceCompositionPlane(size_t source_layer,
                                std::vector<DrmPlane *> *primary_planes,
                                std::vector<DrmPlane *> *overlay_planes);
   int CreateAndAssignReleaseFences();