| 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) { |
| 55 if (!manager) |
| 56 return; |
| 53 cc::Surface* surface = manager->GetSurfaceForId(id); | 57 cc::Surface* surface = manager->GetSurfaceForId(id); |
| 54 if (!surface) { | 58 if (!surface) { |
| 55 LOG(ERROR) << "Attempting to require callback on nonexistent surface"; | 59 LOG(ERROR) << "Attempting to require callback on nonexistent surface"; |
| 56 return; | 60 return; |
| 57 } | 61 } |
| 58 surface->AddDestructionDependency(sequence); | 62 surface->AddDestructionDependency(sequence); |
| 59 } | 63 } |
| 60 | 64 |
| 61 } // namespace | 65 } // namespace |
| 62 | 66 |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 DestroyDelegatedContent(); | 327 DestroyDelegatedContent(); |
| 324 DCHECK(layer_->children().empty()); | 328 DCHECK(layer_->children().empty()); |
| 325 | 329 |
| 326 local_frame_id_ = surface_id_allocator_->GenerateId(); | 330 local_frame_id_ = surface_id_allocator_->GenerateId(); |
| 327 current_surface_size_ = surface_size; | 331 current_surface_size_ = surface_size; |
| 328 | 332 |
| 329 // manager must outlive compositors using it. | 333 // manager must outlive compositors using it. |
| 330 cc::SurfaceManager* surface_manager = | 334 cc::SurfaceManager* surface_manager = |
| 331 GetEmbedderDeps()->GetSurfaceManager(); | 335 GetEmbedderDeps()->GetSurfaceManager(); |
| 332 scoped_refptr<cc::SurfaceLayer> content_layer = cc::SurfaceLayer::Create( | 336 scoped_refptr<cc::SurfaceLayer> content_layer = cc::SurfaceLayer::Create( |
| 333 base::Bind(&SatisfyCallback, base::Unretained(surface_manager)), | 337 base::Bind(&SatisfyCallback, surface_manager->GetWeakPtr()), |
| 334 base::Bind(&RequireCallback, base::Unretained(surface_manager))); | 338 base::Bind(&RequireCallback, surface_manager->GetWeakPtr())); |
| 335 content_layer->SetSurfaceId( | 339 content_layer->SetSurfaceId( |
| 336 cc::SurfaceId(surface_factory_->frame_sink_id(), local_frame_id_), 1.f, | 340 cc::SurfaceId(surface_factory_->frame_sink_id(), local_frame_id_), 1.f, |
| 337 surface_size); | 341 surface_size); |
| 338 content_layer->SetBounds(current_surface_size_); | 342 content_layer->SetBounds(current_surface_size_); |
| 339 content_layer->SetIsDrawable(true); | 343 content_layer->SetIsDrawable(true); |
| 340 content_layer->SetContentsOpaque(true); | 344 content_layer->SetContentsOpaque(true); |
| 341 | 345 |
| 342 layer_->AddChild(content_layer); | 346 layer_->AddChild(content_layer); |
| 343 } | 347 } |
| 344 | 348 |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 // Destroy the old LayerTreeHost state. | 464 // Destroy the old LayerTreeHost state. |
| 461 host_.reset(); | 465 host_.reset(); |
| 462 | 466 |
| 463 // Cancel any outstanding CompositorFrameSink requests. That way if we get an | 467 // Cancel any outstanding CompositorFrameSink requests. That way if we get an |
| 464 // async callback related to the old request we know to drop it. | 468 // async callback related to the old request we know to drop it. |
| 465 compositor_frame_sink_request_pending_ = false; | 469 compositor_frame_sink_request_pending_ = false; |
| 466 } | 470 } |
| 467 | 471 |
| 468 } // namespace client | 472 } // namespace client |
| 469 } // namespace blimp | 473 } // namespace blimp |
| OLD | NEW |