Index: content/browser/renderer_host/render_widget_host_view_aura.cc |
diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc |
index 3ad459b7d761b4c2aa2d435219342d0748b70b82..39a5a6335021114a099fb5585f4279200c538789 100644 |
--- a/content/browser/renderer_host/render_widget_host_view_aura.cc |
+++ b/content/browser/renderer_host/render_widget_host_view_aura.cc |
@@ -549,6 +549,38 @@ class RenderWidgetHostViewAura::TransientWindowObserver |
#endif |
+RenderWidgetHostViewAura::DelegatedFrameEvictionObserver:: |
+ DelegatedFrameEvictionObserver(RenderWidgetHostViewAura* view) |
+ : view_(view), has_frame_(false) {} |
+ |
+RenderWidgetHostViewAura::DelegatedFrameEvictionObserver:: |
+ ~DelegatedFrameEvictionObserver() { |
+ DiscardedFrame(); |
+} |
+ |
+void RenderWidgetHostViewAura::DelegatedFrameEvictionObserver::SwappedFrame( |
+ bool visible) { |
+ has_frame_ = true; |
+ RendererFrameManager::GetInstance()->AddFrame(this, visible); |
+} |
+ |
+void |
+RenderWidgetHostViewAura::DelegatedFrameEvictionObserver::DiscardedFrame() { |
+ RendererFrameManager::GetInstance()->RemoveFrame(this); |
+ has_frame_ = false; |
+} |
+ |
+void RenderWidgetHostViewAura::DelegatedFrameEvictionObserver::SetVisible( |
+ bool visible) { |
+ if (has_frame_) |
+ RendererFrameManager::GetInstance()->SetFrameVisibility(this, visible); |
+} |
+ |
+void |
+RenderWidgetHostViewAura::DelegatedFrameEvictionObserver::EvictCurrentFrame() { |
+ view_->EvictDelegatedFrame(); |
+} |
+ |
//////////////////////////////////////////////////////////////////////////////// |
// RenderWidgetHostViewAura, public: |
@@ -575,6 +607,7 @@ RenderWidgetHostViewAura::RenderWidgetHostViewAura(RenderWidgetHost* host) |
cursor_visibility_state_in_renderer_(UNKNOWN), |
paint_observer_(NULL), |
touch_editing_client_(NULL), |
+ delegated_frame_eviction_observer_(this), |
weak_ptr_factory_(this) { |
host_->SetView(this); |
window_observer_.reset(new WindowObserver(this)); |
@@ -673,6 +706,7 @@ void RenderWidgetHostViewAura::WasShown() { |
return; |
host_->WasShown(); |
software_frame_manager_->SetVisibility(true); |
+ delegated_frame_eviction_observer_.SetVisible(true); |
aura::Window* root = window_->GetRootWindow(); |
if (root) { |
@@ -701,6 +735,7 @@ void RenderWidgetHostViewAura::WasHidden() { |
return; |
host_->WasHidden(); |
software_frame_manager_->SetVisibility(false); |
+ delegated_frame_eviction_observer_.SetVisible(false); |
released_front_lock_ = NULL; |
#if defined(OS_WIN) |
@@ -1443,6 +1478,7 @@ void RenderWidgetHostViewAura::SwapDelegatedFrame( |
// the DelegatedRendererLayer. |
window_->layer()->SetShowPaintedContent(); |
frame_provider_ = NULL; |
+ delegated_frame_eviction_observer_.DiscardedFrame(); |
// Drop the cc::DelegatedFrameResourceCollection so that we will not return |
// any resources from the old output surface with the new output surface id. |
@@ -1460,6 +1496,7 @@ void RenderWidgetHostViewAura::SwapDelegatedFrame( |
DCHECK_EQ(0u, frame_data->resource_list.size()); |
window_->layer()->SetShowPaintedContent(); |
danakj
2013/10/28 21:39:21
Should this just call EvictDelegatedFrame() rather
piman
2013/10/28 22:08:38
Done, and above as well.
|
frame_provider_ = NULL; |
+ delegated_frame_eviction_observer_.DiscardedFrame(); |
} else { |
if (!resource_collection_) { |
resource_collection_ = new cc::DelegatedFrameResourceCollection; |
@@ -1495,6 +1532,9 @@ void RenderWidgetHostViewAura::SwapDelegatedFrame( |
output_surface_id)); |
} |
DidReceiveFrameFromRenderer(); |
+ if (frame_provider_.get()) |
+ delegated_frame_eviction_observer_.SwappedFrame(!host_->is_hidden()); |
+ // Note: the frame may have been evicted immediately. |
} |
void RenderWidgetHostViewAura::SendDelegatedFrameAck(uint32 output_surface_id) { |
@@ -1529,6 +1569,13 @@ void RenderWidgetHostViewAura::SendReturnedDelegatedResources( |
ack); |
} |
+void RenderWidgetHostViewAura::EvictDelegatedFrame() { |
+ DCHECK(frame_provider_.get()); |
+ window_->layer()->SetShowPaintedContent(); |
+ frame_provider_ = NULL; |
+ delegated_frame_eviction_observer_.DiscardedFrame(); |
+} |
+ |
void RenderWidgetHostViewAura::SwapSoftwareFrame( |
uint32 output_surface_id, |
scoped_ptr<cc::SoftwareFrameData> frame_data, |
@@ -1787,8 +1834,7 @@ void RenderWidgetHostViewAura::AcceleratedSurfaceRelease() { |
// We need to wait for a commit to clear to guarantee that all we |
// will not issue any more GL referencing the previous surface. |
AddOnCommitCallbackAndDisableLocks( |
- base::Bind(&RenderWidgetHostViewAura:: |
- SetSurfaceNotInUseByCompositor, |
+ base::Bind(&RenderWidgetHostViewAura::SetSurfaceNotInUseByCompositor, |
AsWeakPtr(), |
current_surface_)); // Hold a ref so the texture will not |
// get deleted until after commit. |