drm_hwcomposer: have DrmDisplayCompositor do its own OpenGL composition

To accomplish this a few things changed:
- DrmComposition::GetRemainingLayers always returns the number of planes needed
- DrmComposition::AddLayer succeeds even if no DrmPlane was found for it
- DrmDisplayComposition::AddLayer has overload that imports the given buffer
- GLWorkerCompositor has a function to finish its composite before returning

Put together this change makes DrmComposition always accepts all layers given to
it even if it means some of those layers are assigned a NULL DrmPlane. The
DrmDisplayCompositor will scan its given layers for any that are missing planes.
In such a case, a DrmPlane is stolen from the last layer to receive a plane.
Then all layers in the DrmDisplayComposition that have no planes (including the
one stolen from) are composited synchronously using a GLWorkerCompositor and a
new layer is generated from the results. That layer is added to the
DrmDisplayComposition using the new import AddLayer function and the stolen
DrmPlane. DrmDisplayCompostior then continues as usual.

Change-Id: Ia6477c210c8f1307a4e537bec46889110d79ca18
diff --git a/drmcomposition.cpp b/drmcomposition.cpp
index 805fd26..f4e8d9d 100644
--- a/drmcomposition.cpp
+++ b/drmcomposition.cpp
@@ -63,26 +63,9 @@
   return 0;
 }
 
-unsigned DrmComposition::GetRemainingLayers(int display,
+unsigned DrmComposition::GetRemainingLayers(int /*display*/,
                                             unsigned num_needed) const {
-  DrmCrtc *crtc = drm_->GetCrtcForDisplay(display);
-  if (!crtc) {
-    ALOGE("Failed to find crtc for display %d", display);
-    return 0;
-  }
-
-  unsigned num_planes = 0;
-  for (std::vector<DrmPlane *>::const_iterator iter = primary_planes_.begin();
-       iter != primary_planes_.end(); ++iter) {
-    if ((*iter)->GetCrtcSupported(*crtc))
-      ++num_planes;
-  }
-  for (std::vector<DrmPlane *>::const_iterator iter = overlay_planes_.begin();
-       iter != overlay_planes_.end(); ++iter) {
-    if ((*iter)->GetCrtcSupported(*crtc))
-      ++num_planes;
-  }
-  return std::min(num_planes, num_needed);
+  return num_needed;
 }
 
 int DrmComposition::AddLayer(int display, hwc_layer_1_t *layer,
@@ -111,10 +94,6 @@
       break;
     }
   }
-  if (!plane) {
-    ALOGE("Failed to find plane for display %d", display);
-    return -ENOENT;
-  }
   return composition_map_[display]->AddLayer(layer, bo, crtc, plane);
 }