Index: content/browser/compositor/delegated_frame_host.cc |
diff --git a/content/browser/compositor/delegated_frame_host.cc b/content/browser/compositor/delegated_frame_host.cc |
index 09b1c27ff62deed054900d045005952664b4b0fe..cc531bb841cdd59aeef139e18fd331e5db11a39a 100644 |
--- a/content/browser/compositor/delegated_frame_host.cc |
+++ b/content/browser/compositor/delegated_frame_host.cc |
@@ -343,9 +343,11 @@ void DelegatedFrameHost::SwapDelegatedFrame( |
} |
last_output_surface_id_ = output_surface_id; |
} |
+ bool modified_layers = false; |
if (frame_size.IsEmpty()) { |
DCHECK(frame_data->resource_list.empty()); |
EvictDelegatedFrame(); |
+ modified_layers = true; |
} else { |
if (use_surfaces_) { |
if (!surface_factory_) { |
@@ -358,11 +360,12 @@ void DelegatedFrameHost::SwapDelegatedFrame( |
if (surface_id_.is_null() || frame_size != current_surface_size_ || |
frame_size_in_dip != current_frame_size_in_dip_) { |
if (!surface_id_.is_null()) |
- surface_factory_->Destroy(surface_id_); |
+ surfaces_to_destroy_after_commit_.push_back(surface_id_); |
surface_id_ = id_allocator_->GenerateId(); |
surface_factory_->Create(surface_id_, frame_size); |
client_->GetLayer()->SetShowSurface(surface_id_, frame_size_in_dip); |
current_surface_size_ = frame_size; |
+ modified_layers = true; |
} |
scoped_ptr<cc::CompositorFrame> compositor_frame = |
make_scoped_ptr(new cc::CompositorFrame()); |
@@ -388,18 +391,23 @@ void DelegatedFrameHost::SwapDelegatedFrame( |
} else { |
frame_provider_->SetFrameData(frame_data.Pass()); |
} |
+ modified_layers = true; |
} |
} |
released_front_lock_ = NULL; |
current_frame_size_in_dip_ = frame_size_in_dip; |
CheckResizeLock(); |
- client_->SchedulePaintInRect(damage_rect_in_dip); |
+ if (modified_layers) { |
+ // TODO(jbauman): Need to always tell the window observer about the |
+ // damage. |
+ client_->SchedulePaintInRect(damage_rect_in_dip); |
+ } |
pending_delegated_ack_count_++; |
ui::Compositor* compositor = client_->GetCompositor(); |
- if (!compositor) { |
+ if (!compositor || !modified_layers) { |
SendDelegatedFrameAck(output_surface_id); |
} else { |
std::vector<ui::LatencyInfo>::const_iterator it; |
@@ -479,7 +487,7 @@ void DelegatedFrameHost::EvictDelegatedFrame() { |
client_->GetLayer()->SetShowPaintedContent(); |
frame_provider_ = NULL; |
if (!surface_id_.is_null()) { |
- surface_factory_->Destroy(surface_id_); |
+ surfaces_to_destroy_after_commit_.push_back(surface_id_); |
surface_id_ = cc::SurfaceId(); |
} |
delegated_frame_evictor_->DiscardedFrame(); |
@@ -767,6 +775,10 @@ void DelegatedFrameHost::CopyFromCompositingSurfaceHasResultForVideo( |
void DelegatedFrameHost::OnCompositingDidCommit( |
ui::Compositor* compositor) { |
+ std::copy(surfaces_to_destroy_after_commit_.begin(), |
+ surfaces_to_destroy_after_commit_.end(), |
+ std::back_inserter(surfaces_to_destroy_after_swap_)); |
+ surfaces_to_destroy_after_commit_.clear(); |
RenderWidgetHostImpl* host = client_->GetHost(); |
if (can_lock_compositor_ == NO_PENDING_COMMIT) { |
can_lock_compositor_ = YES_CAN_LOCK; |
@@ -792,6 +804,13 @@ void DelegatedFrameHost::OnCompositingStarted( |
void DelegatedFrameHost::OnCompositingEnded( |
ui::Compositor* compositor) { |
+ for (std::vector<cc::SurfaceId>::iterator it = |
+ surfaces_to_destroy_after_swap_.begin(); |
+ it != surfaces_to_destroy_after_swap_.end(); |
+ ++it) { |
+ surface_factory_->Destroy(*it); |
+ } |
+ surfaces_to_destroy_after_swap_.clear(); |
} |
void DelegatedFrameHost::OnCompositingAborted(ui::Compositor* compositor) { |
@@ -837,6 +856,20 @@ DelegatedFrameHost::~DelegatedFrameHost() { |
if (!surface_id_.is_null()) |
surface_factory_->Destroy(surface_id_); |
+ for (std::vector<cc::SurfaceId>::iterator it = |
+ surfaces_to_destroy_after_commit_.begin(); |
+ it != surfaces_to_destroy_after_commit_.end(); |
+ ++it) { |
+ surface_factory_->Destroy(*it); |
+ } |
+ surfaces_to_destroy_after_commit_.clear(); |
+ for (std::vector<cc::SurfaceId>::iterator it = |
+ surfaces_to_destroy_after_swap_.begin(); |
+ it != surfaces_to_destroy_after_swap_.end(); |
+ ++it) { |
+ surface_factory_->Destroy(*it); |
+ } |
+ surfaces_to_destroy_after_swap_.clear(); |
if (resource_collection_.get()) |
resource_collection_->SetClient(NULL); |