From 79c48dbe5b36515576192dfd684c6b2ce48c74ef Mon Sep 17 00:00:00 2001 From: Kalyan Kondapally Date: Mon, 18 Dec 2017 15:41:07 -0800 Subject: [PATCH] Add a common function to reset queue state. We have bunch of state which needs to be re-initialized everytime queue is re started. We where now doing this in Exit and Initialize call. Instead let's have a helper function do this. Jira: None. Test: No new regressions in Linux tests and Android. Signed-off-by: Kalyan Kondapally --- common/display/displayqueue.cpp | 56 ++++++++++++++++++----------------------- common/display/displayqueue.h | 4 +++ 2 files changed, 28 insertions(+), 32 deletions(-) diff --git a/common/display/displayqueue.cpp b/common/display/displayqueue.cpp index 0cb8ef3..6e91340 100644 --- a/common/display/displayqueue.cpp +++ b/common/display/displayqueue.cpp @@ -65,21 +65,6 @@ DisplayQueue::~DisplayQueue() { bool DisplayQueue::Initialize(uint32_t pipe, uint32_t width, uint32_t height, DisplayPlaneHandler* plane_handler) { - total_cursor_layers_ = 0; - std::vector().swap(in_flight_layers_); - DisplayPlaneStateList().swap(previous_plane_state_); - bool ignore_updates = false; - if (idle_tracker_.state_ & FrameStateTracker::kIgnoreUpdates) { - ignore_updates = true; - } - idle_tracker_.state_ = 0; - idle_tracker_.idle_frames_ = 0; - if (ignore_updates) { - idle_tracker_.state_ |= FrameStateTracker::kIgnoreUpdates; - } - - compositor_.Reset(); - if (!resource_manager_) { ETRACE("Failed to construct hwc layer buffer manager"); return false; @@ -92,6 +77,7 @@ bool DisplayQueue::Initialize(uint32_t pipe, uint32_t width, uint32_t height, return false; } + ResetQueue(); vblank_handler_->SetPowerMode(kOff); vblank_handler_->Init(gpu_fd_, pipe); return true; @@ -720,21 +706,6 @@ void DisplayQueue::HandleExit() { display_->Disable(previous_plane_state_); } - std::vector().swap(in_flight_layers_); - DisplayPlaneStateList().swap(previous_plane_state_); - display_plane_manager_->ReleaseAllOffScreenTargets(); - total_cursor_layers_ = 0; - - bool ignore_updates = false; - if (idle_tracker_.state_ & FrameStateTracker::kIgnoreUpdates) { - ignore_updates = true; - } - idle_tracker_.state_ = 0; - idle_tracker_.idle_frames_ = 0; - if (ignore_updates) { - idle_tracker_.state_ |= FrameStateTracker::kIgnoreUpdates; - } - if (kms_fence_ > 0) { close(kms_fence_); kms_fence_ = 0; @@ -759,8 +730,7 @@ void DisplayQueue::HandleExit() { state_ |= kClonedMode; } - resource_manager_->PurgeBuffer(); - compositor_.Reset(); + ResetQueue(); } bool DisplayQueue::CheckPlaneFormat(uint32_t format) { @@ -923,4 +893,26 @@ void DisplayQueue::UpdateScalingRatio(uint32_t primary_width, state_ |= kConfigurationChanged; } +void DisplayQueue::ResetQueue() { + total_cursor_layers_ = 0; + applied_video_effect_ = false; + std::vector().swap(in_flight_layers_); + DisplayPlaneStateList().swap(previous_plane_state_); + if (display_plane_manager_->HasSurfaces()) + display_plane_manager_->ReleaseAllOffScreenTargets(); + + resource_manager_->PurgeBuffer(); + bool ignore_updates = false; + if (idle_tracker_.state_ & FrameStateTracker::kIgnoreUpdates) { + ignore_updates = true; + } + + idle_tracker_.state_ = 0; + idle_tracker_.idle_frames_ = 0; + if (ignore_updates) { + idle_tracker_.state_ |= FrameStateTracker::kIgnoreUpdates; + } + compositor_.Reset(); +} + } // namespace hwcomposer diff --git a/common/display/displayqueue.h b/common/display/displayqueue.h index 69de264..a73b5f8 100644 --- a/common/display/displayqueue.h +++ b/common/display/displayqueue.h @@ -238,6 +238,10 @@ class DisplayQueue { void ReleaseSurfaces(); void ReleaseSurfacesAsNeeded(bool layers_validated); + // Re-initialize all state. When we are hearing this means the + // queue is teraing down or re-started for some reason. + void ResetQueue(); + Compositor compositor_; uint32_t gpu_fd_; uint32_t brightness_; -- 2.11.0