OSDN Git Service

Ensure final combination is tested before doing actual commit.
authorKalyan Kondapally <kalyan.kondapally@intel.com>
Wed, 15 Feb 2017 05:09:58 +0000 (21:09 -0800)
committerKalyan Kondapally <kalyan.kondapally@intel.com>
Wed, 15 Feb 2017 17:53:17 +0000 (09:53 -0800)
While validating layer combinations, we always continue using the
first layer tested with the given plane. We might add other layers
needing GPU composition for the plane which might change the overall
Display Rect. Now, we ensure that once initial validation is done
the overall combination will infact work otherwise just fall
back to GPU for all layers.

Jira: None.
Test: No regression on Linux and Android.

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

index dec7ef7..6047a42 100644 (file)
@@ -249,7 +249,7 @@ std::tuple<bool, DisplayPlaneStateList> DisplayPlaneManager::ValidateLayers(
   }
 
   if (render_layers) {
-    ValidateFinalLayers(composition);
+    ValidateFinalLayers(composition, layers);
   }
 
   return std::make_tuple(render_layers, std::move(composition));
@@ -404,7 +404,7 @@ void DisplayPlaneManager::EnsureOffScreenTarget(DisplayPlaneState &plane) {
 }
 
 void DisplayPlaneManager::ValidateFinalLayers(
-    DisplayPlaneStateList &composition) {
+    DisplayPlaneStateList &composition, std::vector<OverlayLayer> &layers) {
   for (DisplayPlaneState &plane : composition) {
     if (plane.GetCompositionState() == DisplayPlaneState::State::kRender) {
       EnsureOffScreenTarget(plane);
@@ -414,6 +414,34 @@ void DisplayPlaneManager::ValidateFinalLayers(
   for (auto &fb : in_flight_surfaces_) {
     fb->ResetInFlightMode();
   }
+
+  std::vector<OverlayPlane> commit_planes;
+  for (DisplayPlaneState &plane : composition) {
+    commit_planes.emplace_back(
+        OverlayPlane(plane.plane(), plane.GetOverlayLayer()));
+  }
+
+  // If this combination fails just fall back to 3D for all layers.
+  if (!TestCommit(commit_planes)) {
+    std::vector<NativeSurface *>().swap(in_flight_surfaces_);
+    // We start off with Primary plane.
+    DisplayPlane *current_plane = primary_plane_.get();
+    DisplayPlaneStateList().swap(composition);
+    auto layer_begin = layers.begin();
+    OverlayLayer *primary_layer = &(*(layer_begin));
+    commit_planes.emplace_back(OverlayPlane(current_plane, primary_layer));
+    composition.emplace_back(current_plane, primary_layer,
+                             primary_layer->GetIndex());
+    DisplayPlaneState &last_plane = composition.back();
+    last_plane.ForceGPURendering();
+    ++layer_begin;
+
+    for (auto i = layer_begin; i != layers.end(); ++i) {
+      last_plane.AddLayer(i->GetIndex(), i->GetDisplayFrame());
+    }
+
+    EnsureOffScreenTarget(last_plane);
+  }
 }
 
 bool DisplayPlaneManager::FallbacktoGPU(
index 4769e05..094265e 100644 (file)
@@ -79,7 +79,8 @@ class DisplayPlaneManager {
                      const std::vector<OverlayPlane> &commit_planes) const;
 
   void EnsureOffScreenTarget(DisplayPlaneState &plane);
-  void ValidateFinalLayers(DisplayPlaneStateList &list);
+  void ValidateFinalLayers(DisplayPlaneStateList &list,
+                           std::vector<OverlayLayer> &layers);
 
   NativeBufferHandler *buffer_handler_;
   std::vector<std::unique_ptr<NativeSurface>> surfaces_;