Commit fab25749 authored by Vikas Soni's avatar Vikas Soni Committed by Commit Bot

Cache SurfaceControls for the lifetime of SurfaceView.

Cache SurfaceControls for the lifetime of SurfaceView. This is to avoid
creating/destroying a surface each time the video scrolls off the screen.

Bug: 1102623
Change-Id: Idb02923e6d71109be983ea879f4c8b7fa23121f7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2360488
Commit-Queue: vikas soni <vikassoni@chromium.org>
Reviewed-by: default avatarKhushal <khushalsagar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#800124}
parent 12a85885
...@@ -223,10 +223,11 @@ void GLSurfaceEGLSurfaceControl::CommitPendingTransaction( ...@@ -223,10 +223,11 @@ void GLSurfaceEGLSurfaceControl::CommitPendingTransaction(
// the next transaction. // the next transaction.
DCHECK_LE(pending_surfaces_count_, surface_list_.size()); DCHECK_LE(pending_surfaces_count_, surface_list_.size());
for (size_t i = pending_surfaces_count_; i < surface_list_.size(); ++i) { for (size_t i = pending_surfaces_count_; i < surface_list_.size(); ++i) {
const auto& surface_state = surface_list_[i]; auto& surface_state = surface_list_[i];
pending_transaction_->SetBuffer(*surface_state.surface, nullptr, pending_transaction_->SetBuffer(*surface_state.surface, nullptr,
base::ScopedFD()); base::ScopedFD());
pending_transaction_->SetVisibility(*surface_state.surface, false); pending_transaction_->SetVisibility(*surface_state.surface, false);
surface_state.visibility = false;
} }
// TODO(khushalsagar): Consider using the SetDamageRect API for partial // TODO(khushalsagar): Consider using the SetDamageRect API for partial
...@@ -250,11 +251,6 @@ void GLSurfaceEGLSurfaceControl::CommitPendingTransaction( ...@@ -250,11 +251,6 @@ void GLSurfaceEGLSurfaceControl::CommitPendingTransaction(
std::move(primary_plane_fences_)); std::move(primary_plane_fences_));
primary_plane_fences_.reset(); primary_plane_fences_.reset();
pending_transaction_->SetOnCompleteCb(std::move(callback), gpu_task_runner_); pending_transaction_->SetOnCompleteCb(std::move(callback), gpu_task_runner_);
// Cache only those surfaces which were used in this transaction. The surfaces
// removed here are persisted in |resources_to_release| so we can release
// them after receiving read fences from the framework.
surface_list_.resize(pending_surfaces_count_);
pending_surfaces_count_ = 0u; pending_surfaces_count_ = 0u;
frame_rate_update_pending_ = false; frame_rate_update_pending_ = false;
...@@ -307,6 +303,12 @@ bool GLSurfaceEGLSurfaceControl::ScheduleOverlayPlane( ...@@ -307,6 +303,12 @@ bool GLSurfaceEGLSurfaceControl::ScheduleOverlayPlane(
pending_surfaces_count_++; pending_surfaces_count_++;
auto& surface_state = surface_list_.at(pending_surfaces_count_ - 1); auto& surface_state = surface_list_.at(pending_surfaces_count_ - 1);
// Make the surface visible if its hidden or uninitialized..
if (uninitialized || !surface_state.visibility) {
pending_transaction_->SetVisibility(*surface_state.surface, true);
surface_state.visibility = true;
}
if (uninitialized || surface_state.z_order != z_order) { if (uninitialized || surface_state.z_order != z_order) {
surface_state.z_order = z_order; surface_state.z_order = z_order;
pending_transaction_->SetZOrder(*surface_state.surface, z_order); pending_transaction_->SetZOrder(*surface_state.surface, z_order);
......
...@@ -110,6 +110,8 @@ class GL_EXPORT GLSurfaceEGLSurfaceControl : public GLSurfaceEGL { ...@@ -110,6 +110,8 @@ class GL_EXPORT GLSurfaceEGLSurfaceControl : public GLSurfaceEGL {
// one pending. // one pending.
bool buffer_updated_in_pending_transaction = true; bool buffer_updated_in_pending_transaction = true;
// Indicates whether the |surface| will be visible or hidden.
bool visibility = true;
scoped_refptr<SurfaceControl::Surface> surface; scoped_refptr<SurfaceControl::Surface> surface;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment