hwc: Use number of app layers from the hwc context.

Current frame count is not valid in cases where MDP
composition is not doable. This could lead to clearing
the flags for the wrong number of layers.

Bug: 7643563
Change-Id: I1f506a4a0a8f706d02e954bd6c12e354c0fb5fe9
Signed-off-by: Naseer Ahmed <naseer@codeaurora.org>
Signed-off-by: Iliyan Malchev <malchev@google.com>
diff --git a/libhwcomposer/hwc_mdpcomp.cpp b/libhwcomposer/hwc_mdpcomp.cpp
index fcbbc28..6f15c21 100644
--- a/libhwcomposer/hwc_mdpcomp.cpp
+++ b/libhwcomposer/hwc_mdpcomp.cpp
@@ -424,7 +424,8 @@
 {
     LayerProp *layerProp = ctx->layerProp[HWC_DISPLAY_PRIMARY];
 
-    for (int index = 0 ; index < sCurrentFrame.count; index++) {
+    for (int index = 0 ;
+         index < ctx->listStats[HWC_DISPLAY_PRIMARY].numAppLayers; index++) {
         if(layerProp[index].mFlags & HWC_MDPCOMP) {
             layerProp[index].mFlags &= ~HWC_MDPCOMP;
         }