drm_hwcomposer: Use Planner interface to provision planes

Use the new Planner interface to handle the layer->plane mapping.
This allows us to simplify the Plan() function by offloading the
plane provisioning to the platform specific code.

BUG=b/28117135
TEST=Tested on ryu with a variety of window layouts/workloads

Signed-off-by: Sean Paul <seanpaul@chromium.org>
Change-Id: I75a0c5d87a9096e7a83ecbc848c75fee42ee1131
diff --git a/drmdisplaycomposition.h b/drmdisplaycomposition.h
index 4f48b52..13da19d 100644
--- a/drmdisplaycomposition.h
+++ b/drmdisplaycomposition.h
@@ -32,6 +32,7 @@
 namespace android {
 
 class Importer;
+class Planner;
 class SquashState;
 
 enum DrmCompositionType {
@@ -106,7 +107,7 @@
   ~DrmDisplayComposition();
 
   int Init(DrmResources *drm, DrmCrtc *crtc, Importer *importer,
-           uint64_t frame_no);
+           Planner *planner, uint64_t frame_no);
 
   int SetLayers(DrmHwcLayer *layers, size_t num_layers, bool geometry_changed);
   int AddPlaneComposition(DrmCompositionPlane plane);
@@ -174,6 +175,10 @@
     return importer_;
   }
 
+  Planner *planner() const {
+    return planner_;
+  }
+
   void Dump(std::ostringstream *out) const;
 
  private:
@@ -181,19 +186,15 @@
 
   int IncreaseTimelineToPoint(int point);
 
-  void EmplaceCompositionPlane(DrmCompositionPlane::Type 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);
-  void SeparateLayers(size_t *used_layers, size_t num_used_layers,
-                      DrmHwcRect<int> *exclude_rects, size_t num_exclude_rects);
+  int FinalizeComposition(DrmHwcRect<int> *exclude_rects,
+                          size_t num_exclude_rects);
+  void SeparateLayers(DrmHwcRect<int> *exclude_rects, size_t num_exclude_rects);
   int CreateAndAssignReleaseFences();
 
   DrmResources *drm_ = NULL;
   DrmCrtc *crtc_ = NULL;
   Importer *importer_ = NULL;
+  Planner *planner_ = NULL;
 
   DrmCompositionType type_ = DRM_COMPOSITION_TYPE_EMPTY;
   uint32_t dpms_mode_ = DRM_MODE_DPMS_ON;