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 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 DCHECK(bound_to_proxy_); | 318 DCHECK(bound_to_proxy_); |
319 | 319 |
320 cc::RenderPass* root_pass = frame.render_pass_list.back().get(); | 320 cc::RenderPass* root_pass = frame.render_pass_list.back().get(); |
321 gfx::Size surface_size = root_pass->output_rect.size(); | 321 gfx::Size surface_size = root_pass->output_rect.size(); |
322 | 322 |
323 if (!local_frame_id_.is_valid() || current_surface_size_ != surface_size) { | 323 if (!local_frame_id_.is_valid() || current_surface_size_ != surface_size) { |
324 DestroyDelegatedContent(); | 324 DestroyDelegatedContent(); |
325 DCHECK(layer_->children().empty()); | 325 DCHECK(layer_->children().empty()); |
326 | 326 |
327 local_frame_id_ = surface_id_allocator_->GenerateId(); | 327 local_frame_id_ = surface_id_allocator_->GenerateId(); |
328 surface_factory_->Create(local_frame_id_); | |
329 current_surface_size_ = surface_size; | 328 current_surface_size_ = surface_size; |
330 | 329 |
331 // manager must outlive compositors using it. | 330 // manager must outlive compositors using it. |
332 cc::SurfaceManager* surface_manager = | 331 cc::SurfaceManager* surface_manager = |
333 GetEmbedderDeps()->GetSurfaceManager(); | 332 GetEmbedderDeps()->GetSurfaceManager(); |
334 scoped_refptr<cc::SurfaceLayer> content_layer = cc::SurfaceLayer::Create( | 333 scoped_refptr<cc::SurfaceLayer> content_layer = cc::SurfaceLayer::Create( |
335 base::Bind(&SatisfyCallback, base::Unretained(surface_manager)), | 334 base::Bind(&SatisfyCallback, base::Unretained(surface_manager)), |
336 base::Bind(&RequireCallback, base::Unretained(surface_manager))); | 335 base::Bind(&RequireCallback, base::Unretained(surface_manager))); |
337 content_layer->SetSurfaceId( | 336 content_layer->SetSurfaceId( |
338 cc::SurfaceId(surface_factory_->frame_sink_id(), local_frame_id_), 1.f, | 337 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... |
416 return compositor_dependencies_->GetEmbedderDependencies(); | 415 return compositor_dependencies_->GetEmbedderDependencies(); |
417 } | 416 } |
418 | 417 |
419 void BlimpCompositor::DestroyDelegatedContent() { | 418 void BlimpCompositor::DestroyDelegatedContent() { |
420 if (!local_frame_id_.is_valid()) | 419 if (!local_frame_id_.is_valid()) |
421 return; | 420 return; |
422 | 421 |
423 // Remove any references for the surface layer that uses this | 422 // Remove any references for the surface layer that uses this |
424 // |local_frame_id_|. | 423 // |local_frame_id_|. |
425 layer_->RemoveAllChildren(); | 424 layer_->RemoveAllChildren(); |
426 surface_factory_->Destroy(local_frame_id_); | |
427 local_frame_id_ = cc::LocalFrameId(); | 425 local_frame_id_ = cc::LocalFrameId(); |
428 } | 426 } |
429 | 427 |
430 std::unique_ptr<cc::LayerTreeHostInProcess> | 428 std::unique_ptr<cc::LayerTreeHostInProcess> |
431 BlimpCompositor::CreateLayerTreeHost() { | 429 BlimpCompositor::CreateLayerTreeHost() { |
432 DCHECK(animation_host_); | 430 DCHECK(animation_host_); |
433 std::unique_ptr<cc::LayerTreeHostInProcess> host; | 431 std::unique_ptr<cc::LayerTreeHostInProcess> host; |
434 | 432 |
435 cc::LayerTreeHostInProcess::InitParams params; | 433 cc::LayerTreeHostInProcess::InitParams params; |
436 params.client = this; | 434 params.client = this; |
(...skipping 26 matching lines...) Expand all Loading... |
463 // Destroy the old LayerTreeHost state. | 461 // Destroy the old LayerTreeHost state. |
464 host_.reset(); | 462 host_.reset(); |
465 | 463 |
466 // Cancel any outstanding CompositorFrameSink requests. That way if we get an | 464 // Cancel any outstanding CompositorFrameSink requests. That way if we get an |
467 // async callback related to the old request we know to drop it. | 465 // async callback related to the old request we know to drop it. |
468 compositor_frame_sink_request_pending_ = false; | 466 compositor_frame_sink_request_pending_ = false; |
469 } | 467 } |
470 | 468 |
471 } // namespace client | 469 } // namespace client |
472 } // namespace blimp | 470 } // namespace blimp |
OLD | NEW |