Chromium Code Reviews| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 63 // DelegatedFrameHost | 63 // DelegatedFrameHost |
| 64 | 64 |
| 65 DelegatedFrameHost::DelegatedFrameHost(DelegatedFrameHostClient* client) | 65 DelegatedFrameHost::DelegatedFrameHost(DelegatedFrameHostClient* client) |
| 66 : client_(client), | 66 : client_(client), |
| 67 compositor_(nullptr), | 67 compositor_(nullptr), |
| 68 use_surfaces_(UseSurfacesEnabled()), | 68 use_surfaces_(UseSurfacesEnabled()), |
| 69 tick_clock_(new base::DefaultTickClock()), | 69 tick_clock_(new base::DefaultTickClock()), |
| 70 last_output_surface_id_(0), | 70 last_output_surface_id_(0), |
| 71 pending_delegated_ack_count_(0), | 71 pending_delegated_ack_count_(0), |
| 72 skipped_frames_(false), | 72 skipped_frames_(false), |
| 73 force_commit_for_next_frame_(false), | |
| 73 current_scale_factor_(1.f), | 74 current_scale_factor_(1.f), |
| 74 can_lock_compositor_(YES_CAN_LOCK), | 75 can_lock_compositor_(YES_CAN_LOCK), |
| 75 delegated_frame_evictor_(new DelegatedFrameEvictor(this)) { | 76 delegated_frame_evictor_(new DelegatedFrameEvictor(this)) { |
| 76 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 77 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
| 77 factory->AddObserver(this); | 78 factory->AddObserver(this); |
| 78 id_allocator_ = factory->GetContextFactory()->CreateSurfaceIdAllocator(); | 79 id_allocator_ = factory->GetContextFactory()->CreateSurfaceIdAllocator(); |
| 79 } | 80 } |
| 80 | 81 |
| 81 void DelegatedFrameHost::WasShown(const ui::LatencyInfo& latency_info) { | 82 void DelegatedFrameHost::WasShown(const ui::LatencyInfo& latency_info) { |
| 82 delegated_frame_evictor_->SetVisible(true); | 83 delegated_frame_evictor_->SetVisible(true); |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 342 | 343 |
| 343 gfx::Size frame_size = root_pass->output_rect.size(); | 344 gfx::Size frame_size = root_pass->output_rect.size(); |
| 344 gfx::Size frame_size_in_dip = | 345 gfx::Size frame_size_in_dip = |
| 345 gfx::ConvertSizeToDIP(frame_device_scale_factor, frame_size); | 346 gfx::ConvertSizeToDIP(frame_device_scale_factor, frame_size); |
| 346 | 347 |
| 347 gfx::Rect damage_rect = root_pass->damage_rect; | 348 gfx::Rect damage_rect = root_pass->damage_rect; |
| 348 damage_rect.Intersect(gfx::Rect(frame_size)); | 349 damage_rect.Intersect(gfx::Rect(frame_size)); |
| 349 gfx::Rect damage_rect_in_dip = | 350 gfx::Rect damage_rect_in_dip = |
| 350 gfx::ConvertRectToDIP(frame_device_scale_factor, damage_rect); | 351 gfx::ConvertRectToDIP(frame_device_scale_factor, damage_rect); |
| 351 | 352 |
| 353 if (compositor_ && force_commit_for_next_frame_) { | |
| 354 force_commit_for_next_frame_ = false; | |
| 355 compositor_->ScheduleDraw(); | |
| 356 } | |
| 357 | |
| 352 if (ShouldSkipFrame(frame_size_in_dip)) { | 358 if (ShouldSkipFrame(frame_size_in_dip)) { |
| 353 cc::CompositorFrameAck ack; | 359 cc::CompositorFrameAck ack; |
| 354 cc::TransferableResource::ReturnResources(frame_data->resource_list, | 360 cc::TransferableResource::ReturnResources(frame_data->resource_list, |
| 355 &ack.resources); | 361 &ack.resources); |
| 356 | 362 |
| 357 skipped_latency_info_list_.insert(skipped_latency_info_list_.end(), | 363 skipped_latency_info_list_.insert(skipped_latency_info_list_.end(), |
| 358 frame->metadata.latency_info.begin(), | 364 frame->metadata.latency_info.begin(), |
| 359 frame->metadata.latency_info.end()); | 365 frame->metadata.latency_info.end()); |
| 360 | 366 |
| 361 client_->DelegatedFrameHostSendCompositorSwapAck(output_surface_id, ack); | 367 client_->DelegatedFrameHostSendCompositorSwapAck(output_surface_id, ack); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 462 resource_collection_.get(), std::move(frame->delegated_frame_data)); | 468 resource_collection_.get(), std::move(frame->delegated_frame_data)); |
| 463 client_->DelegatedFrameHostGetLayer()->SetShowDelegatedContent( | 469 client_->DelegatedFrameHostGetLayer()->SetShowDelegatedContent( |
| 464 frame_provider_.get(), frame_size_in_dip); | 470 frame_provider_.get(), frame_size_in_dip); |
| 465 } else { | 471 } else { |
| 466 frame_provider_->SetFrameData(std::move(frame->delegated_frame_data)); | 472 frame_provider_->SetFrameData(std::move(frame->delegated_frame_data)); |
| 467 } | 473 } |
| 468 } | 474 } |
| 469 } | 475 } |
| 470 released_front_lock_ = NULL; | 476 released_front_lock_ = NULL; |
| 471 current_frame_size_in_dip_ = frame_size_in_dip; | 477 current_frame_size_in_dip_ = frame_size_in_dip; |
| 478 | |
| 472 CheckResizeLock(); | 479 CheckResizeLock(); |
| 473 | 480 |
| 474 if (!damage_rect_in_dip.IsEmpty()) | 481 if (!damage_rect_in_dip.IsEmpty()) |
| 475 client_->DelegatedFrameHostGetLayer()->OnDelegatedFrameDamage( | 482 client_->DelegatedFrameHostGetLayer()->OnDelegatedFrameDamage( |
| 476 damage_rect_in_dip); | 483 damage_rect_in_dip); |
| 477 | 484 |
| 478 if (immediate_ack) { | 485 if (immediate_ack) { |
| 479 SendDelegatedFrameAck(output_surface_id); | 486 SendDelegatedFrameAck(output_surface_id); |
| 480 } else if (!use_surfaces_) { | 487 } else if (!use_surfaces_) { |
| 481 std::vector<ui::LatencyInfo>::const_iterator it; | 488 std::vector<ui::LatencyInfo>::const_iterator it; |
| (...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1026 DCHECK(frame_provider_.get() || !surface_id_.is_null()); | 1033 DCHECK(frame_provider_.get() || !surface_id_.is_null()); |
| 1027 delegated_frame_evictor_->LockFrame(); | 1034 delegated_frame_evictor_->LockFrame(); |
| 1028 } | 1035 } |
| 1029 | 1036 |
| 1030 void DelegatedFrameHost::RequestCopyOfOutput( | 1037 void DelegatedFrameHost::RequestCopyOfOutput( |
| 1031 scoped_ptr<cc::CopyOutputRequest> request) { | 1038 scoped_ptr<cc::CopyOutputRequest> request) { |
| 1032 if (!request_copy_of_output_callback_for_testing_.is_null()) | 1039 if (!request_copy_of_output_callback_for_testing_.is_null()) |
| 1033 request_copy_of_output_callback_for_testing_.Run(request.Pass()); | 1040 request_copy_of_output_callback_for_testing_.Run(request.Pass()); |
| 1034 else | 1041 else |
| 1035 client_->DelegatedFrameHostGetLayer()->RequestCopyOfOutput(request.Pass()); | 1042 client_->DelegatedFrameHostGetLayer()->RequestCopyOfOutput(request.Pass()); |
| 1043 | |
| 1044 force_commit_for_next_frame_ = true; | |
|
miu
2015/12/02 20:32:57
Idea: Should you also call compositor_->ScheduleDr
ccameron
2015/12/02 23:03:22
That would seem like a separate bug if we're not g
miu
2015/12/03 00:23:41
Acknowledged.
| |
| 1036 } | 1045 } |
| 1037 | 1046 |
| 1038 void DelegatedFrameHost::UnlockResources() { | 1047 void DelegatedFrameHost::UnlockResources() { |
| 1039 DCHECK(frame_provider_.get() || !surface_id_.is_null()); | 1048 DCHECK(frame_provider_.get() || !surface_id_.is_null()); |
| 1040 delegated_frame_evictor_->UnlockFrame(); | 1049 delegated_frame_evictor_->UnlockFrame(); |
| 1041 } | 1050 } |
| 1042 | 1051 |
| 1043 //////////////////////////////////////////////////////////////////////////////// | 1052 //////////////////////////////////////////////////////////////////////////////// |
| 1044 // DelegatedFrameHost, ui::LayerOwnerDelegate implementation: | 1053 // DelegatedFrameHost, ui::LayerOwnerDelegate implementation: |
| 1045 | 1054 |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 1057 cc::SurfaceManager* manager = factory->GetSurfaceManager(); | 1066 cc::SurfaceManager* manager = factory->GetSurfaceManager(); |
| 1058 new_layer->SetShowSurface( | 1067 new_layer->SetShowSurface( |
| 1059 surface_id_, base::Bind(&SatisfyCallback, base::Unretained(manager)), | 1068 surface_id_, base::Bind(&SatisfyCallback, base::Unretained(manager)), |
| 1060 base::Bind(&RequireCallback, base::Unretained(manager)), | 1069 base::Bind(&RequireCallback, base::Unretained(manager)), |
| 1061 current_surface_size_, current_scale_factor_, | 1070 current_surface_size_, current_scale_factor_, |
| 1062 current_frame_size_in_dip_); | 1071 current_frame_size_in_dip_); |
| 1063 } | 1072 } |
| 1064 } | 1073 } |
| 1065 | 1074 |
| 1066 } // namespace content | 1075 } // namespace content |
| OLD | NEW |