| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/compositor/delegated_frame_host.h" | 5 #include "content/browser/compositor/delegated_frame_host.h" |
| 6 | 6 |
| 7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "cc/output/compositor_frame.h" | 9 #include "cc/output/compositor_frame.h" |
| 10 #include "cc/output/compositor_frame_ack.h" | 10 #include "cc/output/compositor_frame_ack.h" |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 } else { | 426 } else { |
| 427 frame_provider_->SetFrameData(frame_data.Pass()); | 427 frame_provider_->SetFrameData(frame_data.Pass()); |
| 428 } | 428 } |
| 429 modified_layers = true; | 429 modified_layers = true; |
| 430 } | 430 } |
| 431 } | 431 } |
| 432 released_front_lock_ = NULL; | 432 released_front_lock_ = NULL; |
| 433 current_frame_size_in_dip_ = frame_size_in_dip; | 433 current_frame_size_in_dip_ = frame_size_in_dip; |
| 434 CheckResizeLock(); | 434 CheckResizeLock(); |
| 435 | 435 |
| 436 if (modified_layers && !damage_rect_in_dip.IsEmpty()) { | 436 if (!damage_rect_in_dip.IsEmpty()) |
| 437 // TODO(jbauman): Need to always tell the window observer about the | |
| 438 // damage. | |
| 439 client_->GetLayer()->OnDelegatedFrameDamage(damage_rect_in_dip); | 437 client_->GetLayer()->OnDelegatedFrameDamage(damage_rect_in_dip); |
| 440 } | |
| 441 | 438 |
| 442 pending_delegated_ack_count_++; | 439 pending_delegated_ack_count_++; |
| 443 | 440 |
| 444 if (!compositor) { | 441 if (!compositor) { |
| 445 SendDelegatedFrameAck(output_surface_id); | 442 SendDelegatedFrameAck(output_surface_id); |
| 446 } else if (!use_surfaces_) { | 443 } else if (!use_surfaces_) { |
| 447 std::vector<ui::LatencyInfo>::const_iterator it; | 444 std::vector<ui::LatencyInfo>::const_iterator it; |
| 448 for (it = latency_info.begin(); it != latency_info.end(); ++it) | 445 for (it = latency_info.begin(); it != latency_info.end(); ++it) |
| 449 compositor->SetLatencyInfo(*it); | 446 compositor->SetLatencyInfo(*it); |
| 450 // If we've previously skipped any latency infos add them. | 447 // If we've previously skipped any latency infos add them. |
| 451 for (it = skipped_latency_info_list_.begin(); | 448 for (it = skipped_latency_info_list_.begin(); |
| 452 it != skipped_latency_info_list_.end(); | 449 it != skipped_latency_info_list_.end(); |
| 453 ++it) | 450 ++it) |
| 454 compositor->SetLatencyInfo(*it); | 451 compositor->SetLatencyInfo(*it); |
| 455 skipped_latency_info_list_.clear(); | 452 skipped_latency_info_list_.clear(); |
| 456 AddOnCommitCallbackAndDisableLocks( | 453 AddOnCommitCallbackAndDisableLocks( |
| 457 base::Bind(&DelegatedFrameHost::SendDelegatedFrameAck, | 454 base::Bind(&DelegatedFrameHost::SendDelegatedFrameAck, |
| 458 AsWeakPtr(), | 455 AsWeakPtr(), |
| 459 output_surface_id)); | 456 output_surface_id)); |
| 457 } else { |
| 458 AddOnCommitCallbackAndDisableLocks(base::Closure()); |
| 460 } | 459 } |
| 461 DidReceiveFrameFromRenderer(damage_rect); | 460 DidReceiveFrameFromRenderer(damage_rect); |
| 462 if (frame_provider_.get() || !surface_id_.is_null()) | 461 if (frame_provider_.get() || !surface_id_.is_null()) |
| 463 delegated_frame_evictor_->SwappedFrame(!host->is_hidden()); | 462 delegated_frame_evictor_->SwappedFrame(!host->is_hidden()); |
| 464 // Note: the frame may have been evicted immediately. | 463 // Note: the frame may have been evicted immediately. |
| 465 } | 464 } |
| 466 | 465 |
| 467 void DelegatedFrameHost::SendDelegatedFrameAck(uint32 output_surface_id) { | 466 void DelegatedFrameHost::SendDelegatedFrameAck(uint32 output_surface_id) { |
| 468 RenderWidgetHostImpl* host = client_->GetHost(); | 467 RenderWidgetHostImpl* host = client_->GetHost(); |
| 469 cc::CompositorFrameAck ack; | 468 cc::CompositorFrameAck ack; |
| (...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 932 | 931 |
| 933 void DelegatedFrameHost::AddOnCommitCallbackAndDisableLocks( | 932 void DelegatedFrameHost::AddOnCommitCallbackAndDisableLocks( |
| 934 const base::Closure& callback) { | 933 const base::Closure& callback) { |
| 935 ui::Compositor* compositor = client_->GetCompositor(); | 934 ui::Compositor* compositor = client_->GetCompositor(); |
| 936 DCHECK(compositor); | 935 DCHECK(compositor); |
| 937 | 936 |
| 938 if (!compositor->HasObserver(this)) | 937 if (!compositor->HasObserver(this)) |
| 939 compositor->AddObserver(this); | 938 compositor->AddObserver(this); |
| 940 | 939 |
| 941 can_lock_compositor_ = NO_PENDING_COMMIT; | 940 can_lock_compositor_ = NO_PENDING_COMMIT; |
| 942 on_compositing_did_commit_callbacks_.push_back(callback); | 941 if (!callback.is_null()) |
| 942 on_compositing_did_commit_callbacks_.push_back(callback); |
| 943 } | 943 } |
| 944 | 944 |
| 945 void DelegatedFrameHost::AddedToWindow() { | 945 void DelegatedFrameHost::AddedToWindow() { |
| 946 ui::Compositor* compositor = client_->GetCompositor(); | 946 ui::Compositor* compositor = client_->GetCompositor(); |
| 947 if (compositor) { | 947 if (compositor) { |
| 948 DCHECK(!vsync_manager_.get()); | 948 DCHECK(!vsync_manager_.get()); |
| 949 vsync_manager_ = compositor->vsync_manager(); | 949 vsync_manager_ = compositor->vsync_manager(); |
| 950 vsync_manager_->AddObserver(this); | 950 vsync_manager_->AddObserver(this); |
| 951 } | 951 } |
| 952 } | 952 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 986 if (frame_provider_.get()) { | 986 if (frame_provider_.get()) { |
| 987 new_layer->SetShowDelegatedContent(frame_provider_.get(), | 987 new_layer->SetShowDelegatedContent(frame_provider_.get(), |
| 988 current_frame_size_in_dip_); | 988 current_frame_size_in_dip_); |
| 989 } | 989 } |
| 990 if (!surface_id_.is_null()) { | 990 if (!surface_id_.is_null()) { |
| 991 new_layer->SetShowSurface(surface_id_, current_frame_size_in_dip_); | 991 new_layer->SetShowSurface(surface_id_, current_frame_size_in_dip_); |
| 992 } | 992 } |
| 993 } | 993 } |
| 994 | 994 |
| 995 } // namespace content | 995 } // namespace content |
| OLD | NEW |