OSDN Git Service

Avoid extra test commit checks.
authorKalyan Kondapally <kalyan.kondapally@intel.com>
Thu, 28 Dec 2017 00:56:59 +0000 (16:56 -0800)
committerKalyan Kondapally <kalyan.kondapally@intel.com>
Thu, 28 Dec 2017 07:45:42 +0000 (23:45 -0800)
We don't need to do this if we have already done while
validating the layers. Let's keep track of it and do
final validation if still needed.

Jira: None.
Test: No commit fails on Android.

Signed-off-by: Kalyan Kondapally <kalyan.kondapally@intel.com>
common/display/displayplanemanager.cpp
common/display/displayplanemanager.h

index 1904591..26a81ae 100644 (file)
@@ -73,10 +73,11 @@ bool DisplayPlaneManager::ValidateLayers(
         OverlayPlane(temp.GetDisplayPlane(), temp.GetOverlayLayer()));
   }
 
-  if (check_plane && add_index <= 0) {
+  if (check_plane && add_index == -1) {
+    bool temp;
     // We are only revalidating planes and can avoid full validation.
     return ReValidatePlanes(commit_planes, composition, layers, mark_later,
-                            recycle_resources);
+                            &temp, recycle_resources);
   }
 
   if (!previous_composition.empty() && add_index <= 0) {
@@ -136,6 +137,7 @@ bool DisplayPlaneManager::ValidateLayers(
   auto layer_begin = layers.begin();
   auto layer_end = layers.end();
   bool render_layers = false;
+  bool validate_final_layers = false;
   OverlayLayer *previous_layer = NULL;
 
   if (add_index > 0) {
@@ -187,6 +189,7 @@ bool DisplayPlaneManager::ValidateLayers(
         // If we are able to composite buffer with the given plane, lets use
         // it.
         bool fall_back = FallbacktoGPU(plane, layer, commit_planes);
+        validate_final_layers = false;
         if (!fall_back || prefer_seperate_plane) {
           composition.emplace_back(plane, layer, layer->GetZorder());
           plane->SetInUse(true);
@@ -197,6 +200,7 @@ bool DisplayPlaneManager::ValidateLayers(
 
           if (fall_back) {
             ResetPlaneTarget(last_plane, commit_planes.back());
+            validate_final_layers = true;
           }
           break;
         } else {
@@ -217,6 +221,7 @@ bool DisplayPlaneManager::ValidateLayers(
             last_plane.AddLayer(layer);
             if (!last_plane.GetOffScreenTarget()) {
               ResetPlaneTarget(last_plane, commit_planes.back());
+              validate_final_layers = true;
             }
           }
         }
@@ -244,21 +249,21 @@ bool DisplayPlaneManager::ValidateLayers(
       }
 
       if (last_plane.NeedsOffScreenComposition()) {
-        if (previous_layer) {
-          // In this case we need to fallback to 3Dcomposition till Media
-          // backend adds support for multiple layers.
-          bool force_buffer = false;
-          if (is_video && last_plane.GetSourceLayers().size() > 1 &&
-              last_plane.GetOffScreenTarget()) {
-            MarkSurfacesForRecycling(&last_plane, mark_later,
-                                     recycle_resources);
-            force_buffer = true;
-          }
+        // In this case we need to fallback to 3Dcomposition till Media
+        // backend adds support for multiple layers.
+        bool force_buffer = false;
+        if (is_video && last_plane.GetSourceLayers().size() > 1 &&
+            last_plane.GetOffScreenTarget()) {
+          MarkSurfacesForRecycling(&last_plane, mark_later, recycle_resources);
+          force_buffer = true;
+        }
 
-          if (!last_plane.GetOffScreenTarget() || force_buffer) {
-            ResetPlaneTarget(last_plane, commit_planes.back());
-          }
+        if (!last_plane.GetOffScreenTarget() || force_buffer) {
+          ResetPlaneTarget(last_plane, commit_planes.back());
+          validate_final_layers = true;
+        }
 
+        if (previous_layer) {
           ValidateForDisplayScaling(composition.back(), commit_planes,
                                     previous_layer);
         }
@@ -270,21 +275,28 @@ bool DisplayPlaneManager::ValidateLayers(
   }
 
   if (!cursor_layers.empty()) {
-    bool render_cursor_layer =
-        ValidateCursorLayer(commit_planes, cursor_layers, mark_later,
-                            composition, recycle_resources);
+    bool render_cursor_layer = ValidateCursorLayer(
+        commit_planes, cursor_layers, mark_later, composition,
+        &validate_final_layers, recycle_resources);
     if (!render_layers) {
       render_layers = render_cursor_layer;
     }
   }
 
-  if (render_layers) {
-    ValidateFinalLayers(commit_planes, composition, layers, mark_later,
-                        recycle_resources);
+  if (check_plane) {
+    // We are only revalidating planes and can avoid full validation.
+    bool status =
+        ReValidatePlanes(commit_planes, composition, layers, mark_later,
+                         &validate_final_layers, recycle_resources);
+    if (!render_layers) {
+      render_layers = status;
+    }
+  }
 
-    if (check_plane) {
-      render_layers = ReValidatePlanes(commit_planes, composition, layers,
-                                       mark_later, recycle_resources);
+  if (render_layers) {
+    if (validate_final_layers) {
+      ValidateFinalLayers(commit_planes, composition, layers, mark_later,
+                          recycle_resources);
     }
 
     for (DisplayPlaneState &plane : composition) {
@@ -356,7 +368,7 @@ DisplayPlaneState *DisplayPlaneManager::GetLastUsedOverlay(
 
 void DisplayPlaneManager::PreparePlaneForCursor(
     DisplayPlaneState *plane, std::vector<NativeSurface *> &mark_later,
-    bool reset_buffer, bool recycle_resources) {
+    bool *validate_final_layers, bool reset_buffer, bool recycle_resources) {
   NativeSurface *surface = NULL;
   if (reset_buffer) {
     MarkSurfacesForRecycling(plane, mark_later, recycle_resources);
@@ -367,6 +379,7 @@ void DisplayPlaneManager::PreparePlaneForCursor(
 
   if (!surface) {
     SetOffScreenPlaneTarget(*plane);
+    *validate_final_layers = true;
   } else {
     // If Last frame surface is re-cycled and surfaces are
     // less than 3, make sure we have the offscreen surface
@@ -385,7 +398,8 @@ bool DisplayPlaneManager::ValidateCursorLayer(
     std::vector<OverlayPlane> &commit_planes,
     std::vector<OverlayLayer *> &cursor_layers,
     std::vector<NativeSurface *> &mark_later,
-    DisplayPlaneStateList &composition, bool recycle_resources) {
+    DisplayPlaneStateList &composition, bool *validate_final_layers,
+    bool recycle_resources) {
   CTRACE();
   if (cursor_layers.empty()) {
     return false;
@@ -415,6 +429,11 @@ bool DisplayPlaneManager::ValidateCursorLayer(
     OverlayLayer *cursor_layer = cursor_layers.at(cursor_index);
     commit_planes.emplace_back(OverlayPlane(plane, cursor_layer));
     bool fall_back = FallbacktoGPU(plane, cursor_layer, commit_planes);
+    if (fall_back) {
+      status = true;
+    } else {
+      *validate_final_layers = false;
+    }
     // Lets ensure we fall back to GPU composition in case
     // cursor layer cannot be scanned out directly.
     if (fall_back && !is_video) {
@@ -428,8 +447,8 @@ bool DisplayPlaneManager::ValidateCursorLayer(
       if (!last_plane->GetOffScreenTarget() || is_video)
         reset_overlay = true;
 
-      PreparePlaneForCursor(last_plane, mark_later, is_video,
-                            recycle_resources);
+      PreparePlaneForCursor(last_plane, mark_later, validate_final_layers,
+                            is_video, recycle_resources);
 
       if (reset_overlay) {
         // Layer for the plane should have changed, reset commit planes.
@@ -442,7 +461,6 @@ bool DisplayPlaneManager::ValidateCursorLayer(
 
       ValidateForDisplayScaling(*last_plane, commit_planes, cursor_layer,
                                 false);
-      status = true;
     } else {
       composition.emplace_back(plane, cursor_layer, cursor_layer->GetZorder());
       plane->SetInUse(true);
@@ -477,7 +495,8 @@ bool DisplayPlaneManager::ValidateCursorLayer(
   }
 
   if (last_layer) {
-    PreparePlaneForCursor(last_plane, mark_later, is_video, recycle_resources);
+    PreparePlaneForCursor(last_plane, mark_later, validate_final_layers,
+                          is_video, recycle_resources);
     ValidateForDisplayScaling(*last_plane, commit_planes, last_layer, false);
   }
 
@@ -774,7 +793,8 @@ void DisplayPlaneManager::MarkSurfacesForRecycling(
 bool DisplayPlaneManager::ReValidatePlanes(
     std::vector<OverlayPlane> &commit_planes,
     DisplayPlaneStateList &composition, std::vector<OverlayLayer> &layers,
-    std::vector<NativeSurface *> &mark_later, bool recycle_resources) {
+    std::vector<NativeSurface *> &mark_later, bool *validate_final_layers,
+    bool recycle_resources) {
 #ifdef SURFACE_TRACING
   ISURFACETRACE("ReValidatePlanes called \n");
 #endif
@@ -805,6 +825,7 @@ bool DisplayPlaneManager::ReValidatePlanes(
         ISURFACETRACE("ReValidatePlanes called: moving to scan \n");
 #endif
         MarkSurfacesForRecycling(&last_plane, mark_later, recycle_resources);
+        *validate_final_layers = false;
       }
     }
 
index f37ad07..77e792d 100644 (file)
@@ -96,7 +96,8 @@ class DisplayPlaneManager {
 
   void PreparePlaneForCursor(DisplayPlaneState *plane,
                              std::vector<NativeSurface *> &mark_later,
-                             bool reset_buffer, bool recycle_resources);
+                             bool *validate_final_layers, bool reset_buffer,
+                             bool recycle_resources);
 
   void ValidateForDisplayScaling(DisplayPlaneState &last_plane,
                                  std::vector<OverlayPlane> &commit_planes,
@@ -116,13 +117,13 @@ class DisplayPlaneManager {
                            std::vector<OverlayLayer *> &cursor_layers,
                            std::vector<NativeSurface *> &mark_later,
                            DisplayPlaneStateList &composition,
-                           bool recycle_resources);
+                           bool *validate_final_layers, bool recycle_resources);
 
   bool ReValidatePlanes(std::vector<OverlayPlane> &commit_planes,
                         DisplayPlaneStateList &list,
                         std::vector<OverlayLayer> &layers,
                         std::vector<NativeSurface *> &mark_later,
-                        bool recycle_resources);
+                        bool *validate_final_layers, bool recycle_resources);
 
   DisplayPlaneHandler *plane_handler_;
   ResourceManager *resource_manager_;