hwc: Reset stack invalidation state after Prepare

Currently stack invalidation state is reset in BuildLayerStack().
However, hw_layers_ are reset only in PrepareLayerStack(). If a
draw cycle with 0 app layers happens PrepareLayerStack() is not
called, this causes a mismatch in hw_layers_'s reference to layer
stack and actual layer stack. This change clears the stack
invalidation state only in PrepareLayerStack() and bails out of
dump(). Long-term stack duplication is necessary to avoid these
issues.

Change-Id: I2b630556515456317ca20079c3a5623f89c4033f
CRs-fixed: 2185297
diff --git a/sdm/libs/hwc2/hwc_display.cpp b/sdm/libs/hwc2/hwc_display.cpp
index 978c3bc..c09cade 100644
--- a/sdm/libs/hwc2/hwc_display.cpp
+++ b/sdm/libs/hwc2/hwc_display.cpp
@@ -634,8 +634,6 @@
   }
   // set secure display
   SetSecureDisplay(secure_display_active);
-
-  layer_stack_invalid_ = false;
 }
 
 void HWCDisplay::BuildSolidFillStack() {
@@ -1069,11 +1067,13 @@
   *out_num_types = UINT32(layer_changes_.size());
   *out_num_requests = UINT32(layer_requests_.size());
   skip_validate_ = false;
+  layer_stack_invalid_ = false;
+
   if (*out_num_types > 0) {
     return HWC2::Error::HasChanges;
-  } else {
-    return HWC2::Error::None;
   }
+
+  return HWC2::Error::None;
 }
 
 HWC2::Error HWCDisplay::AcceptDisplayChanges() {