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 22 matching lines...) Expand all Loading... |
33 #include "cc/trees/layer_tree_host_in_process.h" | 33 #include "cc/trees/layer_tree_host_in_process.h" |
34 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" | 34 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" |
35 #include "net/base/net_errors.h" | 35 #include "net/base/net_errors.h" |
36 #include "ui/gl/gl_surface.h" | 36 #include "ui/gl/gl_surface.h" |
37 | 37 |
38 namespace blimp { | 38 namespace blimp { |
39 namespace client { | 39 namespace client { |
40 | 40 |
41 namespace { | 41 namespace { |
42 | 42 |
43 void SatisfyCallback(cc::SurfaceManager* manager, | 43 void SatisfyCallback(base::WeakPtr<cc::SurfaceManager> manager, |
44 const cc::SurfaceSequence& sequence) { | 44 const cc::SurfaceSequence& sequence) { |
| 45 if (!manager) |
| 46 return; |
45 std::vector<uint32_t> sequences; | 47 std::vector<uint32_t> sequences; |
46 sequences.push_back(sequence.sequence); | 48 sequences.push_back(sequence.sequence); |
47 manager->DidSatisfySequences(sequence.frame_sink_id, &sequences); | 49 manager->DidSatisfySequences(sequence.frame_sink_id, &sequences); |
48 } | 50 } |
49 | 51 |
50 void RequireCallback(cc::SurfaceManager* manager, | 52 void RequireCallback(base::WeakPtr<cc::SurfaceManager> manager, |
51 const cc::SurfaceId& id, | 53 const cc::SurfaceId& id, |
52 const cc::SurfaceSequence& sequence) { | 54 const cc::SurfaceSequence& sequence) { |
53 cc::Surface* surface = manager->GetSurfaceForId(id); | 55 cc::Surface* surface = manager->GetSurfaceForId(id); |
54 if (!surface) { | 56 if (!surface) { |
55 LOG(ERROR) << "Attempting to require callback on nonexistent surface"; | 57 LOG(ERROR) << "Attempting to require callback on nonexistent surface"; |
56 return; | 58 return; |
57 } | 59 } |
58 surface->AddDestructionDependency(sequence); | 60 surface->AddDestructionDependency(sequence); |
59 } | 61 } |
60 | 62 |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 DestroyDelegatedContent(); | 325 DestroyDelegatedContent(); |
324 DCHECK(layer_->children().empty()); | 326 DCHECK(layer_->children().empty()); |
325 | 327 |
326 local_frame_id_ = surface_id_allocator_->GenerateId(); | 328 local_frame_id_ = surface_id_allocator_->GenerateId(); |
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, surface_manager->GetWeakPtr()), |
334 base::Bind(&RequireCallback, base::Unretained(surface_manager))); | 336 base::Bind(&RequireCallback, surface_manager->GetWeakPtr())); |
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, false /* strecth_content_to_fill_bounds */); | 339 surface_size, false /* strecth_content_to_fill_bounds */); |
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 |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 // Destroy the old LayerTreeHost state. | 462 // Destroy the old LayerTreeHost state. |
461 host_.reset(); | 463 host_.reset(); |
462 | 464 |
463 // Cancel any outstanding CompositorFrameSink requests. That way if we get an | 465 // Cancel any outstanding CompositorFrameSink requests. That way if we get an |
464 // async callback related to the old request we know to drop it. | 466 // async callback related to the old request we know to drop it. |
465 compositor_frame_sink_request_pending_ = false; | 467 compositor_frame_sink_request_pending_ = false; |
466 } | 468 } |
467 | 469 |
468 } // namespace client | 470 } // namespace client |
469 } // namespace blimp | 471 } // namespace blimp |
OLD | NEW |