| 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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 | 185 |
| 186 if (flush_pending_update) { | 186 if (flush_pending_update) { |
| 187 // Always request a commit when queuing the promise to make sure that any | 187 // Always request a commit when queuing the promise to make sure that any |
| 188 // frames pending draws are cleared from the pipeline. | 188 // frames pending draws are cleared from the pipeline. |
| 189 host_->QueueSwapPromise(base::MakeUnique<FrameTrackingSwapPromise>( | 189 host_->QueueSwapPromise(base::MakeUnique<FrameTrackingSwapPromise>( |
| 190 std::move(copy_request), weak_ptr_factory_.GetWeakPtr(), | 190 std::move(copy_request), weak_ptr_factory_.GetWeakPtr(), |
| 191 base::ThreadTaskRunnerHandle::Get())); | 191 base::ThreadTaskRunnerHandle::Get())); |
| 192 host_->SetNeedsCommit(); | 192 host_->SetNeedsCommit(); |
| 193 } else if (local_frame_id_.is_valid()) { | 193 } else if (local_frame_id_.is_valid()) { |
| 194 // Make a copy request for the surface directly. | 194 // Make a copy request for the surface directly. |
| 195 surface_factory_->RequestCopyOfSurface(std::move(copy_request)); | 195 surface_factory_->RequestCopyOfSurface(local_frame_id_, |
| 196 std::move(copy_request)); |
| 196 } | 197 } |
| 197 } | 198 } |
| 198 | 199 |
| 199 void BlimpCompositor::UpdateLayerTreeHost() { | 200 void BlimpCompositor::UpdateLayerTreeHost() { |
| 200 // UpdateLayerTreeHost marks the end of reporting of any deltas from the impl | 201 // UpdateLayerTreeHost marks the end of reporting of any deltas from the impl |
| 201 // thread. So send a client state update if the local state was modified now. | 202 // thread. So send a client state update if the local state was modified now. |
| 202 FlushClientState(); | 203 FlushClientState(); |
| 203 | 204 |
| 204 if (pending_frame_update_) { | 205 if (pending_frame_update_) { |
| 205 compositor_state_deserializer_->DeserializeCompositorUpdate( | 206 compositor_state_deserializer_->DeserializeCompositorUpdate( |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 DCHECK(bound_to_proxy_); | 318 DCHECK(bound_to_proxy_); |
| 318 | 319 |
| 319 cc::RenderPass* root_pass = frame.render_pass_list.back().get(); | 320 cc::RenderPass* root_pass = frame.render_pass_list.back().get(); |
| 320 gfx::Size surface_size = root_pass->output_rect.size(); | 321 gfx::Size surface_size = root_pass->output_rect.size(); |
| 321 | 322 |
| 322 if (!local_frame_id_.is_valid() || current_surface_size_ != surface_size) { | 323 if (!local_frame_id_.is_valid() || current_surface_size_ != surface_size) { |
| 323 DestroyDelegatedContent(); | 324 DestroyDelegatedContent(); |
| 324 DCHECK(layer_->children().empty()); | 325 DCHECK(layer_->children().empty()); |
| 325 | 326 |
| 326 local_frame_id_ = surface_id_allocator_->GenerateId(); | 327 local_frame_id_ = surface_id_allocator_->GenerateId(); |
| 328 surface_factory_->Create(local_frame_id_); |
| 327 current_surface_size_ = surface_size; | 329 current_surface_size_ = surface_size; |
| 328 | 330 |
| 329 // manager must outlive compositors using it. | 331 // manager must outlive compositors using it. |
| 330 cc::SurfaceManager* surface_manager = | 332 cc::SurfaceManager* surface_manager = |
| 331 GetEmbedderDeps()->GetSurfaceManager(); | 333 GetEmbedderDeps()->GetSurfaceManager(); |
| 332 scoped_refptr<cc::SurfaceLayer> content_layer = cc::SurfaceLayer::Create( | 334 scoped_refptr<cc::SurfaceLayer> content_layer = cc::SurfaceLayer::Create( |
| 333 base::Bind(&SatisfyCallback, base::Unretained(surface_manager)), | 335 base::Bind(&SatisfyCallback, base::Unretained(surface_manager)), |
| 334 base::Bind(&RequireCallback, base::Unretained(surface_manager))); | 336 base::Bind(&RequireCallback, base::Unretained(surface_manager))); |
| 335 content_layer->SetSurfaceId( | 337 content_layer->SetSurfaceId( |
| 336 cc::SurfaceId(surface_factory_->frame_sink_id(), local_frame_id_), 1.f, | 338 cc::SurfaceId(surface_factory_->frame_sink_id(), local_frame_id_), 1.f, |
| 337 surface_size); | 339 surface_size); |
| 338 content_layer->SetBounds(current_surface_size_); | 340 content_layer->SetBounds(current_surface_size_); |
| 339 content_layer->SetIsDrawable(true); | 341 content_layer->SetIsDrawable(true); |
| 340 content_layer->SetContentsOpaque(true); | 342 content_layer->SetContentsOpaque(true); |
| 341 | 343 |
| 342 layer_->AddChild(content_layer); | 344 layer_->AddChild(content_layer); |
| 343 } | 345 } |
| 344 | 346 |
| 345 surface_factory_->SubmitCompositorFrame( | 347 surface_factory_->SubmitCompositorFrame( |
| 346 local_frame_id_, std::move(frame), | 348 local_frame_id_, std::move(frame), |
| 347 base::Bind(&BlimpCompositor::SubmitCompositorFrameAck, | 349 base::Bind(&BlimpCompositor::SubmitCompositorFrameAck, |
| 348 weak_ptr_factory_.GetWeakPtr())); | 350 weak_ptr_factory_.GetWeakPtr())); |
| 349 | 351 |
| 350 for (auto& copy_request : copy_requests_for_next_swap_) { | 352 for (auto& copy_request : copy_requests_for_next_swap_) { |
| 351 surface_factory_->RequestCopyOfSurface(std::move(copy_request)); | 353 surface_factory_->RequestCopyOfSurface(local_frame_id_, |
| 354 std::move(copy_request)); |
| 352 } | 355 } |
| 353 copy_requests_for_next_swap_.clear(); | 356 copy_requests_for_next_swap_.clear(); |
| 354 } | 357 } |
| 355 | 358 |
| 356 void BlimpCompositor::SubmitCompositorFrameAck() { | 359 void BlimpCompositor::SubmitCompositorFrameAck() { |
| 357 compositor_dependencies_->GetCompositorTaskRunner()->PostTask( | 360 compositor_dependencies_->GetCompositorTaskRunner()->PostTask( |
| 358 FROM_HERE, | 361 FROM_HERE, |
| 359 base::Bind(&BlimpCompositorFrameSinkProxyClient::SubmitCompositorFrameAck, | 362 base::Bind(&BlimpCompositorFrameSinkProxyClient::SubmitCompositorFrameAck, |
| 360 proxy_client_)); | 363 proxy_client_)); |
| 361 } | 364 } |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 return compositor_dependencies_->GetEmbedderDependencies(); | 416 return compositor_dependencies_->GetEmbedderDependencies(); |
| 414 } | 417 } |
| 415 | 418 |
| 416 void BlimpCompositor::DestroyDelegatedContent() { | 419 void BlimpCompositor::DestroyDelegatedContent() { |
| 417 if (!local_frame_id_.is_valid()) | 420 if (!local_frame_id_.is_valid()) |
| 418 return; | 421 return; |
| 419 | 422 |
| 420 // Remove any references for the surface layer that uses this | 423 // Remove any references for the surface layer that uses this |
| 421 // |local_frame_id_|. | 424 // |local_frame_id_|. |
| 422 layer_->RemoveAllChildren(); | 425 layer_->RemoveAllChildren(); |
| 423 surface_factory_->EvictSurface(); | 426 surface_factory_->Destroy(local_frame_id_); |
| 424 local_frame_id_ = cc::LocalFrameId(); | 427 local_frame_id_ = cc::LocalFrameId(); |
| 425 } | 428 } |
| 426 | 429 |
| 427 std::unique_ptr<cc::LayerTreeHostInProcess> | 430 std::unique_ptr<cc::LayerTreeHostInProcess> |
| 428 BlimpCompositor::CreateLayerTreeHost() { | 431 BlimpCompositor::CreateLayerTreeHost() { |
| 429 DCHECK(animation_host_); | 432 DCHECK(animation_host_); |
| 430 std::unique_ptr<cc::LayerTreeHostInProcess> host; | 433 std::unique_ptr<cc::LayerTreeHostInProcess> host; |
| 431 | 434 |
| 432 cc::LayerTreeHostInProcess::InitParams params; | 435 cc::LayerTreeHostInProcess::InitParams params; |
| 433 params.client = this; | 436 params.client = this; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 460 // Destroy the old LayerTreeHost state. | 463 // Destroy the old LayerTreeHost state. |
| 461 host_.reset(); | 464 host_.reset(); |
| 462 | 465 |
| 463 // Cancel any outstanding CompositorFrameSink requests. That way if we get an | 466 // Cancel any outstanding CompositorFrameSink requests. That way if we get an |
| 464 // async callback related to the old request we know to drop it. | 467 // async callback related to the old request we know to drop it. |
| 465 compositor_frame_sink_request_pending_ = false; | 468 compositor_frame_sink_request_pending_ = false; |
| 466 } | 469 } |
| 467 | 470 |
| 468 } // namespace client | 471 } // namespace client |
| 469 } // namespace blimp | 472 } // namespace blimp |
| OLD | NEW |