| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "blimp/client/core/compositor/blimp_compositor.h" | 5 #include "blimp/client/core/compositor/blimp_compositor.h" |
| 6 | 6 |
| 7 #include "base/bind_helpers.h" | 7 #include "base/bind_helpers.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 return; | 196 return; |
| 197 } | 197 } |
| 198 | 198 |
| 199 if (flush_pending_update) { | 199 if (flush_pending_update) { |
| 200 // Always request a commit when queuing the promise to make sure that any | 200 // Always request a commit when queuing the promise to make sure that any |
| 201 // frames pending draws are cleared from the pipeline. | 201 // frames pending draws are cleared from the pipeline. |
| 202 host_->QueueSwapPromise(base::MakeUnique<FrameTrackingSwapPromise>( | 202 host_->QueueSwapPromise(base::MakeUnique<FrameTrackingSwapPromise>( |
| 203 std::move(copy_request), weak_ptr_factory_.GetWeakPtr(), | 203 std::move(copy_request), weak_ptr_factory_.GetWeakPtr(), |
| 204 base::ThreadTaskRunnerHandle::Get())); | 204 base::ThreadTaskRunnerHandle::Get())); |
| 205 host_->SetNeedsCommit(); | 205 host_->SetNeedsCommit(); |
| 206 } else if (!local_frame_id_.is_null()) { | 206 } else if (local_frame_id_.is_valid()) { |
| 207 // Make a copy request for the surface directly. | 207 // Make a copy request for the surface directly. |
| 208 surface_factory_->RequestCopyOfSurface(local_frame_id_, | 208 surface_factory_->RequestCopyOfSurface(local_frame_id_, |
| 209 std::move(copy_request)); | 209 std::move(copy_request)); |
| 210 } | 210 } |
| 211 } | 211 } |
| 212 | 212 |
| 213 void BlimpCompositor::RequestCopyOfOutputDeprecated( | 213 void BlimpCompositor::RequestCopyOfOutputDeprecated( |
| 214 std::unique_ptr<cc::CopyOutputRequest> copy_request) { | 214 std::unique_ptr<cc::CopyOutputRequest> copy_request) { |
| 215 DCHECK(!use_threaded_layer_tree_host_); | 215 DCHECK(!use_threaded_layer_tree_host_); |
| 216 | 216 |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 proxy_client_ = proxy_client; | 411 proxy_client_ = proxy_client; |
| 412 } | 412 } |
| 413 | 413 |
| 414 void BlimpCompositor::SubmitCompositorFrame(cc::CompositorFrame frame) { | 414 void BlimpCompositor::SubmitCompositorFrame(cc::CompositorFrame frame) { |
| 415 DCHECK(thread_checker_.CalledOnValidThread()); | 415 DCHECK(thread_checker_.CalledOnValidThread()); |
| 416 DCHECK(bound_to_proxy_); | 416 DCHECK(bound_to_proxy_); |
| 417 | 417 |
| 418 cc::RenderPass* root_pass = frame.render_pass_list.back().get(); | 418 cc::RenderPass* root_pass = frame.render_pass_list.back().get(); |
| 419 gfx::Size surface_size = root_pass->output_rect.size(); | 419 gfx::Size surface_size = root_pass->output_rect.size(); |
| 420 | 420 |
| 421 if (local_frame_id_.is_null() || current_surface_size_ != surface_size) { | 421 if (!local_frame_id_.is_valid() || current_surface_size_ != surface_size) { |
| 422 DestroyDelegatedContent(); | 422 DestroyDelegatedContent(); |
| 423 DCHECK(layer_->children().empty()); | 423 DCHECK(layer_->children().empty()); |
| 424 | 424 |
| 425 local_frame_id_ = surface_id_allocator_->GenerateId(); | 425 local_frame_id_ = surface_id_allocator_->GenerateId(); |
| 426 surface_factory_->Create(local_frame_id_); | 426 surface_factory_->Create(local_frame_id_); |
| 427 current_surface_size_ = surface_size; | 427 current_surface_size_ = surface_size; |
| 428 | 428 |
| 429 // manager must outlive compositors using it. | 429 // manager must outlive compositors using it. |
| 430 cc::SurfaceManager* surface_manager = | 430 cc::SurfaceManager* surface_manager = |
| 431 GetEmbedderDeps()->GetSurfaceManager(); | 431 GetEmbedderDeps()->GetSurfaceManager(); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 508 client_state_dirty_ = false; | 508 client_state_dirty_ = false; |
| 509 client_state_update_ack_pending_ = true; | 509 client_state_update_ack_pending_ = true; |
| 510 client_->SendCompositorMessage(message); | 510 client_->SendCompositorMessage(message); |
| 511 } | 511 } |
| 512 | 512 |
| 513 CompositorDependencies* BlimpCompositor::GetEmbedderDeps() { | 513 CompositorDependencies* BlimpCompositor::GetEmbedderDeps() { |
| 514 return compositor_dependencies_->GetEmbedderDependencies(); | 514 return compositor_dependencies_->GetEmbedderDependencies(); |
| 515 } | 515 } |
| 516 | 516 |
| 517 void BlimpCompositor::DestroyDelegatedContent() { | 517 void BlimpCompositor::DestroyDelegatedContent() { |
| 518 if (local_frame_id_.is_null()) | 518 if (!local_frame_id_.is_valid()) |
| 519 return; | 519 return; |
| 520 | 520 |
| 521 // Remove any references for the surface layer that uses this | 521 // Remove any references for the surface layer that uses this |
| 522 // |local_frame_id_|. | 522 // |local_frame_id_|. |
| 523 layer_->RemoveAllChildren(); | 523 layer_->RemoveAllChildren(); |
| 524 surface_factory_->Destroy(local_frame_id_); | 524 surface_factory_->Destroy(local_frame_id_); |
| 525 local_frame_id_ = cc::LocalFrameId(); | 525 local_frame_id_ = cc::LocalFrameId(); |
| 526 } | 526 } |
| 527 | 527 |
| 528 std::unique_ptr<cc::LayerTreeHostInProcess> | 528 std::unique_ptr<cc::LayerTreeHostInProcess> |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 // Cancel any outstanding CompositorFrameSink requests. That way if we get an | 571 // Cancel any outstanding CompositorFrameSink requests. That way if we get an |
| 572 // async callback related to the old request we know to drop it. | 572 // async callback related to the old request we know to drop it. |
| 573 compositor_frame_sink_request_pending_ = false; | 573 compositor_frame_sink_request_pending_ = false; |
| 574 | 574 |
| 575 // Make sure we don't have a receiver at this point. | 575 // Make sure we don't have a receiver at this point. |
| 576 DCHECK(!remote_proto_channel_receiver_); | 576 DCHECK(!remote_proto_channel_receiver_); |
| 577 } | 577 } |
| 578 | 578 |
| 579 } // namespace client | 579 } // namespace client |
| 580 } // namespace blimp | 580 } // namespace blimp |
| OLD | NEW |