DO NOT MERGE: drm_hwcomposer: Move DrmCompositionPlaneType into DrmCompositionPlane

Now that DrmCompositionPlane is classified, move the type into it
as a subclass.

BUG=b/28117135
TEST=Tested on ryu

Signed-off-by: Sean Paul <seanpaul@chromium.org>
Change-Id: I774f477e75b3a2e2916c5d98931730dac46d3877
diff --git a/drmdisplaycomposition.cpp b/drmdisplaycomposition.cpp
index 2af9d5a..3880a26 100644
--- a/drmdisplaycomposition.cpp
+++ b/drmdisplaycomposition.cpp
@@ -113,7 +113,7 @@
 }
 
 int DrmDisplayComposition::AddPlaneDisable(DrmPlane *plane) {
-  composition_planes_.emplace_back(DrmCompositionPlaneType::kDisable, plane,
+  composition_planes_.emplace_back(DrmCompositionPlane::Type::kDisable, plane,
                                    crtc_);
   return 0;
 }
@@ -150,7 +150,7 @@
 }
 
 void DrmDisplayComposition::EmplaceCompositionPlane(
-    DrmCompositionPlaneType type, std::vector<DrmPlane *> *primary_planes,
+    DrmCompositionPlane::Type type, std::vector<DrmPlane *> *primary_planes,
     std::vector<DrmPlane *> *overlay_planes) {
   DrmPlane *plane = TakePlane(crtc_, primary_planes, overlay_planes);
   if (plane == NULL) {
@@ -172,7 +172,7 @@
         "remaining");
     return;
   }
-  composition_planes_.emplace_back(DrmCompositionPlaneType::kLayer, plane,
+  composition_planes_.emplace_back(DrmCompositionPlane::Type::kLayer, plane,
                                    crtc_, source_layer);
 }
 
@@ -281,7 +281,7 @@
   }
 
   for (const DrmCompositionPlane &plane : composition_planes_) {
-    if (plane.type() == DrmCompositionPlaneType::kLayer) {
+    if (plane.type() == DrmCompositionPlane::Type::kLayer) {
       for (auto i : plane.source_layers()) {
         DrmHwcLayer *source_layer = &layers_[i];
         comp_layers.emplace(source_layer);
@@ -459,7 +459,7 @@
                             overlay_planes);
 
   if (layers_remaining.size() > 0) {
-    EmplaceCompositionPlane(DrmCompositionPlaneType::kPrecomp, primary_planes,
+    EmplaceCompositionPlane(DrmCompositionPlane::Type::kPrecomp, primary_planes,
                             overlay_planes);
     SeparateLayers(layers_.data(), layers_remaining.data(),
                    layers_remaining.size(), protected_layers.data(),
@@ -468,7 +468,7 @@
   }
 
   if (use_squash_framebuffer) {
-    EmplaceCompositionPlane(DrmCompositionPlaneType::kSquash, primary_planes,
+    EmplaceCompositionPlane(DrmCompositionPlane::Type::kSquash, primary_planes,
                             overlay_planes);
   }
 
@@ -638,16 +638,16 @@
          << " plane=" << (comp_plane.plane() ? comp_plane.plane()->id() : -1)
          << " type=";
     switch (comp_plane.type()) {
-      case DrmCompositionPlaneType::kDisable:
+      case DrmCompositionPlane::Type::kDisable:
         *out << "DISABLE";
         break;
-      case DrmCompositionPlaneType::kLayer:
+      case DrmCompositionPlane::Type::kLayer:
         *out << "LAYER";
         break;
-      case DrmCompositionPlaneType::kPrecomp:
+      case DrmCompositionPlane::Type::kPrecomp:
         *out << "PRECOMP";
         break;
-      case DrmCompositionPlaneType::kSquash:
+      case DrmCompositionPlane::Type::kSquash:
         *out << "SQUASH";
         break;
       default:
diff --git a/drmdisplaycomposition.h b/drmdisplaycomposition.h
index 768ccfb..b2cfb9c 100644
--- a/drmdisplaycomposition.h
+++ b/drmdisplaycomposition.h
@@ -46,31 +46,30 @@
   std::vector<size_t> source_layers;
 };
 
-enum class DrmCompositionPlaneType : int32_t {
-  kDisable,
-  kLayer,
-  kPrecomp,
-  kSquash,
-};
-
 class DrmCompositionPlane {
  public:
+  enum class Type : int32_t {
+    kDisable,
+    kLayer,
+    kPrecomp,
+    kSquash,
+  };
+
   DrmCompositionPlane() = default;
   DrmCompositionPlane(DrmCompositionPlane &&rhs) = default;
   DrmCompositionPlane &operator=(DrmCompositionPlane &&other) = default;
-  DrmCompositionPlane(DrmCompositionPlaneType type, DrmPlane *plane,
-                      DrmCrtc *crtc)
+  DrmCompositionPlane(Type type, DrmPlane *plane, DrmCrtc *crtc)
       : type_(type), plane_(plane), crtc_(crtc) {
   }
-  DrmCompositionPlane(DrmCompositionPlaneType type, DrmPlane *plane,
-                      DrmCrtc *crtc, size_t source_layer)
+  DrmCompositionPlane(Type type, DrmPlane *plane, DrmCrtc *crtc,
+                      size_t source_layer)
       : type_(type),
         plane_(plane),
         crtc_(crtc),
         source_layers_(1, source_layer) {
   }
 
-  DrmCompositionPlaneType type() const {
+  Type type() const {
     return type_;
   }
 
@@ -94,7 +93,7 @@
   }
 
  private:
-  DrmCompositionPlaneType type_ = DrmCompositionPlaneType::kDisable;
+  Type type_ = Type::kDisable;
   DrmPlane *plane_ = NULL;
   DrmCrtc *crtc_ = NULL;
   std::vector<size_t> source_layers_;
@@ -179,7 +178,7 @@
 
   int IncreaseTimelineToPoint(int point);
 
-  void EmplaceCompositionPlane(DrmCompositionPlaneType type,
+  void EmplaceCompositionPlane(DrmCompositionPlane::Type type,
                                std::vector<DrmPlane *> *primary_planes,
                                std::vector<DrmPlane *> *overlay_planes);
   void EmplaceCompositionPlane(size_t source_layer,
diff --git a/drmdisplaycompositor.cpp b/drmdisplaycompositor.cpp
index fc040dc..acd5436 100644
--- a/drmdisplaycompositor.cpp
+++ b/drmdisplaycompositor.cpp
@@ -172,7 +172,7 @@
 static bool UsesSquash(const std::vector<DrmCompositionPlane> &comp_planes) {
   return std::any_of(comp_planes.begin(), comp_planes.end(),
                      [](const DrmCompositionPlane &plane) {
-    return plane.type() == DrmCompositionPlaneType::kSquash;
+    return plane.type() == DrmCompositionPlane::Type::kSquash;
   });
 }
 
@@ -574,13 +574,13 @@
   for (DrmCompositionPlane &comp_plane : comp_planes) {
     std::vector<size_t> &source_layers = comp_plane.source_layers();
     switch (comp_plane.type()) {
-      case DrmCompositionPlaneType::kSquash:
+      case DrmCompositionPlane::Type::kSquash:
         if (source_layers.size())
           ALOGE("Squash source_layers is expected to be empty (%zu/%d)",
                 source_layers[0], squash_layer_index);
         source_layers.push_back(squash_layer_index);
         break;
-      case DrmCompositionPlaneType::kPrecomp:
+      case DrmCompositionPlane::Type::kPrecomp:
         if (!do_pre_comp) {
           ALOGE(
               "Can not use pre composite framebuffer with no pre composite "
@@ -652,7 +652,7 @@
     uint64_t rotation = 0;
     uint64_t alpha = 0xFF;
 
-    if (comp_plane.type() != DrmCompositionPlaneType::kDisable) {
+    if (comp_plane.type() != DrmCompositionPlane::Type::kDisable) {
       if (source_layers.size() > 1) {
         ALOGE("Can't handle more than one source layer sz=%zu type=%d",
               source_layers.size(), comp_plane.type());
@@ -1041,7 +1041,7 @@
   // Make sure there is more than one layer to squash.
   size_t src_planes_with_layer = std::count_if(
       src_planes.begin(), src_planes.end(), [](DrmCompositionPlane &p) {
-        return p.type() == DrmCompositionPlaneType::kLayer;
+        return p.type() == DrmCompositionPlane::Type::kLayer;
       });
   if (src_planes_with_layer <= 1)
     return -EALREADY;
@@ -1065,7 +1065,7 @@
       goto move_layers_back;
     }
 
-    if (comp_plane.type() == DrmCompositionPlaneType::kDisable)
+    if (comp_plane.type() == DrmCompositionPlane::Type::kDisable)
       continue;
 
     for (auto i : comp_plane.source_layers()) {
@@ -1114,7 +1114,7 @@
   framebuffer_index_ = (framebuffer_index_ + 1) % DRM_DISPLAY_BUFFERS;
 
   for (DrmCompositionPlane &plane : dst->composition_planes()) {
-    if (plane.type() == DrmCompositionPlaneType::kPrecomp) {
+    if (plane.type() == DrmCompositionPlane::Type::kPrecomp) {
       // Replace source_layers with the output of the precomposite
       plane.source_layers().clear();
       plane.source_layers().push_back(pre_comp_layer_index);