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 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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_null() || 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_); | |
427 current_surface_size_ = surface_size; | 426 current_surface_size_ = surface_size; |
428 | 427 |
429 // manager must outlive compositors using it. | 428 // manager must outlive compositors using it. |
430 cc::SurfaceManager* surface_manager = | 429 cc::SurfaceManager* surface_manager = |
431 GetEmbedderDeps()->GetSurfaceManager(); | 430 GetEmbedderDeps()->GetSurfaceManager(); |
432 scoped_refptr<cc::SurfaceLayer> content_layer = cc::SurfaceLayer::Create( | 431 scoped_refptr<cc::SurfaceLayer> content_layer = cc::SurfaceLayer::Create( |
433 base::Bind(&SatisfyCallback, base::Unretained(surface_manager)), | 432 base::Bind(&SatisfyCallback, base::Unretained(surface_manager)), |
434 base::Bind(&RequireCallback, base::Unretained(surface_manager))); | 433 base::Bind(&RequireCallback, base::Unretained(surface_manager))); |
435 content_layer->SetSurfaceId( | 434 content_layer->SetSurfaceId( |
436 cc::SurfaceId(surface_factory_->frame_sink_id(), local_frame_id_), 1.f, | 435 cc::SurfaceId(surface_factory_->frame_sink_id(), local_frame_id_), 1.f, |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 return compositor_dependencies_->GetEmbedderDependencies(); | 513 return compositor_dependencies_->GetEmbedderDependencies(); |
515 } | 514 } |
516 | 515 |
517 void BlimpCompositor::DestroyDelegatedContent() { | 516 void BlimpCompositor::DestroyDelegatedContent() { |
518 if (local_frame_id_.is_null()) | 517 if (local_frame_id_.is_null()) |
519 return; | 518 return; |
520 | 519 |
521 // Remove any references for the surface layer that uses this | 520 // Remove any references for the surface layer that uses this |
522 // |local_frame_id_|. | 521 // |local_frame_id_|. |
523 layer_->RemoveAllChildren(); | 522 layer_->RemoveAllChildren(); |
524 surface_factory_->Destroy(local_frame_id_); | |
525 local_frame_id_ = cc::LocalFrameId(); | 523 local_frame_id_ = cc::LocalFrameId(); |
526 } | 524 } |
527 | 525 |
528 std::unique_ptr<cc::LayerTreeHostInProcess> | 526 std::unique_ptr<cc::LayerTreeHostInProcess> |
529 BlimpCompositor::CreateLayerTreeHost() { | 527 BlimpCompositor::CreateLayerTreeHost() { |
530 DCHECK(animation_host_); | 528 DCHECK(animation_host_); |
531 std::unique_ptr<cc::LayerTreeHostInProcess> host; | 529 std::unique_ptr<cc::LayerTreeHostInProcess> host; |
532 | 530 |
533 cc::LayerTreeHostInProcess::InitParams params; | 531 cc::LayerTreeHostInProcess::InitParams params; |
534 params.client = this; | 532 params.client = this; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
571 // Cancel any outstanding CompositorFrameSink requests. That way if we get an | 569 // Cancel any outstanding CompositorFrameSink requests. That way if we get an |
572 // async callback related to the old request we know to drop it. | 570 // async callback related to the old request we know to drop it. |
573 compositor_frame_sink_request_pending_ = false; | 571 compositor_frame_sink_request_pending_ = false; |
574 | 572 |
575 // Make sure we don't have a receiver at this point. | 573 // Make sure we don't have a receiver at this point. |
576 DCHECK(!remote_proto_channel_receiver_); | 574 DCHECK(!remote_proto_channel_receiver_); |
577 } | 575 } |
578 | 576 |
579 } // namespace client | 577 } // namespace client |
580 } // namespace blimp | 578 } // namespace blimp |
OLD | NEW |