drm_hwcomposer: Really fail on CreateComposition failures

The current logic in Validate assumes that if CreateComposition()
fails, it was due to overlay planes as sets the avail_planes to 1.

With most multi-plane compositions, this will then cause the
avil_planes to be later decremented to zero (to reserve the client
composited plane), resulting in all the layers to be set as
client composited.

However, in the case where there is only one layer, such as with
the Android BootAnimation, if CreateComposition fails, we set
avail_planes to one, and since there is only one layer, we don't
decrement it further, resulting in the layer to be validated as
a Device rendered layer, as if CreateComposition succeeded.

This adds an extra flag we don't mix up a single layer failure
as a success.

On HiKey/HiKey960, this patch fixes the issue where the
BootAnimation wouldn't display.

Change-Id: I58bf5f332667a46e8e997d1743b73dd4a768657f
Signed-off-by: John Stultz <john.stultz@linaro.org>
diff --git a/drmhwctwo.cpp b/drmhwctwo.cpp
index 6bab17b..3ee9f8e 100644
--- a/drmhwctwo.cpp
+++ b/drmhwctwo.cpp
@@ -697,6 +697,7 @@
   *num_types = 0;
   *num_requests = 0;
   size_t avail_planes = primary_planes_.size() + overlay_planes_.size();
+  bool comp_failed = false;
 
   HWC2::Error ret;
 
@@ -705,8 +706,7 @@
 
   ret = CreateComposition(true);
   if (ret != HWC2::Error::None)
-    // Assume the test failed due to overlay planes
-    avail_planes = 1;
+    comp_failed = true;
 
   std::map<uint32_t, DrmHwcTwo::HwcLayer *, std::greater<int>> z_map;
   for (std::pair<const hwc2_layer_t, DrmHwcTwo::HwcLayer> &l : layers_) {
@@ -722,7 +722,7 @@
     avail_planes--;
 
   for (std::pair<const uint32_t, DrmHwcTwo::HwcLayer *> &l : z_map) {
-    if (!avail_planes--)
+    if (comp_failed || !avail_planes--)
       break;
     l.second->set_validated_type(HWC2::Composition::Device);
   }