OSDN Git Service

Remove Composition state in displayplanestate.
authorKalyan Kondapally <kalyan.kondapally@intel.com>
Tue, 19 Dec 2017 03:20:23 +0000 (19:20 -0800)
committerKalyan Kondapally <kalyan.kondapally@intel.com>
Wed, 20 Dec 2017 23:19:47 +0000 (15:19 -0800)
We are now having too many combinations and will get bit more
complicated when we start adding under/over scaling support
completely. Let's hide all this different combination complexity
in DisplayPlaneState and add API to query if offscreen composition
is needed for displayplane.

Jira: None.
Test: No new regressions on Android.
Signed-off-by: Kalyan Kondapally <kalyan.kondapally@intel.com>
common/compositor/compositor.cpp
common/display/displayplanemanager.cpp
common/display/displayplanestate.h
common/display/displayqueue.cpp

index f2897f8..d0d54df 100644 (file)
@@ -81,8 +81,7 @@ bool Compositor::Draw(DisplayPlaneStateList &comp_planes,
       lock_.unlock();
       const OverlayLayer &layer = layers[plane.source_layers().at(0)];
       media_state.layer_ = &layer;
-    } else if (plane.GetCompositionState() ==
-               DisplayPlaneState::State::kRender) {
+    } else if (plane.NeedsOffScreenComposition()) {
       comp = &plane;
       std::vector<CompositionRegion> &comp_regions =
           plane.GetCompositionRegion();
index b0c5861..03f46c0 100644 (file)
@@ -138,9 +138,7 @@ bool DisplayPlaneManager::ValidateLayers(
 #endif
       DisplayPlaneState &last_plane = composition.back();
       OverlayLayer *previous_layer = NULL;
-      if (previous_layer &&
-          last_plane.GetCompositionState() ==
-              DisplayPlaneState::State::kRender) {
+      if (previous_layer && last_plane.NeedsOffScreenComposition()) {
         ValidateForDisplayScaling(composition.back(), commit_planes,
                                   previous_layer);
         render_layers = true;
@@ -197,7 +195,7 @@ bool DisplayPlaneManager::ValidateLayers(
       last_plane.AddLayer(previous_layer);
     }
 
-    if (last_plane.GetCompositionState() == DisplayPlaneState::State::kRender) {
+    if (last_plane.NeedsOffScreenComposition()) {
       if (previous_layer) {
         // In this case we need to fallback to 3Dcomposition till Media
         // backend adds support for multiple layers.
@@ -229,7 +227,7 @@ bool DisplayPlaneManager::ValidateLayers(
   if (render_layers) {
     ValidateFinalLayers(composition, layers);
     for (DisplayPlaneState &plane : composition) {
-      if (plane.GetCompositionState() == DisplayPlaneState::State::kRender) {
+      if (plane.NeedsOffScreenComposition()) {
         const std::vector<size_t> &source_layers = plane.source_layers();
         size_t layers_size = source_layers.size();
         bool useplanescalar = plane.IsUsingPlaneScalar();
@@ -268,7 +266,7 @@ bool DisplayPlaneManager::ReValidateLayers(std::vector<OverlayLayer> &layers,
   if (plane_handler_->TestCommit(commit_planes)) {
     *request_full_validation = false;
     for (DisplayPlaneState &plane : composition) {
-      if (plane.GetCompositionState() == DisplayPlaneState::State::kRender) {
+      if (plane.NeedsOffScreenComposition()) {
         render_layers = true;
         const std::vector<size_t> &source_layers = plane.source_layers();
         size_t layers_size = source_layers.size();
@@ -631,8 +629,7 @@ void DisplayPlaneManager::ValidateFinalLayers(
     DisplayPlaneStateList &composition, std::vector<OverlayLayer> &layers) {
   std::vector<OverlayPlane> commit_planes;
   for (DisplayPlaneState &plane : composition) {
-    if (plane.GetCompositionState() == DisplayPlaneState::State::kRender &&
-        !plane.GetOffScreenTarget()) {
+    if (plane.NeedsOffScreenComposition() && !plane.GetOffScreenTarget()) {
       EnsureOffScreenTarget(plane);
     }
 
@@ -645,7 +642,7 @@ void DisplayPlaneManager::ValidateFinalLayers(
     // We start off with Primary plane.
     DisplayPlane *current_plane = primary_plane_;
     for (DisplayPlaneState &plane : composition) {
-      if (plane.GetCompositionState() == DisplayPlaneState::State::kRender) {
+      if (plane.GetOffScreenTarget()) {
         plane.GetOffScreenTarget()->SetInUse(false);
       }
     }
index ede05c4..1534993 100644 (file)
@@ -36,12 +36,6 @@ typedef std::vector<DisplayPlaneState> DisplayPlaneStateList;
 
 class DisplayPlaneState {
  public:
-  enum class State : int32_t {
-    kScanout,  // Scanout the layer directly.
-    kRender,   // Needs to render the contents to
-               // layer before scanning out.
-  };
-
   DisplayPlaneState() = default;
   DisplayPlaneState(DisplayPlaneState &&rhs) = default;
   DisplayPlaneState &operator=(DisplayPlaneState &&other) = default;
@@ -70,10 +64,6 @@ class DisplayPlaneState {
     // should be determined in DisplayQueue for every frame.
   }
 
-  State GetCompositionState() const {
-    return state_;
-  }
-
   const HwcRect<int> &GetDisplayFrame() const {
     return display_frame_;
   }
@@ -179,7 +169,6 @@ class DisplayPlaneState {
   }
 
   void ReUseOffScreenTarget() {
-    state_ = State::kScanout;
     recycled_surface_ = true;
   }
 
@@ -331,12 +320,36 @@ class DisplayPlaneState {
     return state_ == State::kScanout;
   }
 
+  // Returns true if offscreen composition
+  // is needed for this plane.
+  bool NeedsOffScreenComposition() {
+    if (state_ == State::kRender)
+      return true;
+
+    if (recycled_surface_) {
+      return true;
+    }
+
+    if (apply_effects_) {
+      return true;
+    }
+
+    return false;
+  }
+
  private:
   enum class PlaneType : int32_t {
     kCursor,  // Plane is compositing only Cursor.
     kVideo,   // Plane is compositing only Media content.
     kNormal   // Plane is compositing different types of content.
   };
+
+  enum class State : int32_t {
+    kScanout,  // Scanout the layer directly.
+    kRender,   // Needs to render the contents to
+               // layer before scanning out.
+  };
+
   State state_ = State::kScanout;
   DisplayPlane *plane_ = NULL;
   const OverlayLayer *layer_ = NULL;
index 6e91340..3e3626a 100644 (file)
@@ -125,8 +125,6 @@ void DisplayQueue::GetCachedLayers(const std::vector<OverlayLayer>& layers,
   bool ignore_commit = !cursor_layer_removed;
   bool needs_revalidation = false;
   for (DisplayPlaneState& plane : previous_plane_state_) {
-    bool plane_state_render =
-        plane.GetCompositionState() == DisplayPlaneState::State::kRender;
     if (cursor_layer_removed && plane.IsCursorPlane()) {
       plane.plane()->SetInUse(false);
       continue;
@@ -138,7 +136,7 @@ void DisplayQueue::GetCachedLayers(const std::vector<OverlayLayer>& layers,
     last_plane.CopyState(plane);
     last_plane.AddLayers(plane.source_layers(), layers, cursor_layer_removed);
 
-    if (plane_state_render || plane.SurfaceRecycled() || plane.ApplyEffects()) {
+    if (plane.NeedsOffScreenComposition()) {
       bool content_changed = false;
       bool update_source_rect = false;
       const std::vector<size_t>& source_layers = last_plane.source_layers();