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 12 matching lines...) Expand all Loading... |
23 #include "cc/blimp/compositor_state_deserializer.h" | 23 #include "cc/blimp/compositor_state_deserializer.h" |
24 #include "cc/blimp/image_serialization_processor.h" | 24 #include "cc/blimp/image_serialization_processor.h" |
25 #include "cc/layers/layer.h" | 25 #include "cc/layers/layer.h" |
26 #include "cc/layers/surface_layer.h" | 26 #include "cc/layers/surface_layer.h" |
27 #include "cc/output/compositor_frame_sink.h" | 27 #include "cc/output/compositor_frame_sink.h" |
28 #include "cc/proto/compositor_message.pb.h" | 28 #include "cc/proto/compositor_message.pb.h" |
29 #include "cc/surfaces/surface.h" | 29 #include "cc/surfaces/surface.h" |
30 #include "cc/surfaces/surface_factory.h" | 30 #include "cc/surfaces/surface_factory.h" |
31 #include "cc/surfaces/surface_id_allocator.h" | 31 #include "cc/surfaces/surface_id_allocator.h" |
32 #include "cc/surfaces/surface_manager.h" | 32 #include "cc/surfaces/surface_manager.h" |
| 33 #include "cc/surfaces/surface_ref_base.h" |
33 #include "cc/trees/layer_tree_host_in_process.h" | 34 #include "cc/trees/layer_tree_host_in_process.h" |
34 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" | 35 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" |
35 #include "net/base/net_errors.h" | 36 #include "net/base/net_errors.h" |
36 #include "ui/gl/gl_surface.h" | 37 #include "ui/gl/gl_surface.h" |
37 | 38 |
38 namespace blimp { | 39 namespace blimp { |
39 namespace client { | 40 namespace client { |
40 | 41 |
41 namespace { | |
42 | |
43 void SatisfyCallback(cc::SurfaceManager* manager, | |
44 const cc::SurfaceSequence& sequence) { | |
45 std::vector<uint32_t> sequences; | |
46 sequences.push_back(sequence.sequence); | |
47 manager->DidSatisfySequences(sequence.frame_sink_id, &sequences); | |
48 } | |
49 | |
50 void RequireCallback(cc::SurfaceManager* manager, | |
51 const cc::SurfaceId& id, | |
52 const cc::SurfaceSequence& sequence) { | |
53 cc::Surface* surface = manager->GetSurfaceForId(id); | |
54 if (!surface) { | |
55 LOG(ERROR) << "Attempting to require callback on nonexistent surface"; | |
56 return; | |
57 } | |
58 surface->AddDestructionDependency(sequence); | |
59 } | |
60 | |
61 } // namespace | |
62 | |
63 class BlimpCompositor::FrameTrackingSwapPromise : public cc::SwapPromise { | 42 class BlimpCompositor::FrameTrackingSwapPromise : public cc::SwapPromise { |
64 public: | 43 public: |
65 FrameTrackingSwapPromise( | 44 FrameTrackingSwapPromise( |
66 std::unique_ptr<cc::CopyOutputRequest> copy_request, | 45 std::unique_ptr<cc::CopyOutputRequest> copy_request, |
67 base::WeakPtr<BlimpCompositor> compositor, | 46 base::WeakPtr<BlimpCompositor> compositor, |
68 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner) | 47 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner) |
69 : copy_request_(std::move(copy_request)), | 48 : copy_request_(std::move(copy_request)), |
70 compositor_weak_ptr_(compositor), | 49 compositor_weak_ptr_(compositor), |
71 main_task_runner_(std::move(main_task_runner)) {} | 50 main_task_runner_(std::move(main_task_runner)) {} |
72 ~FrameTrackingSwapPromise() override = default; | 51 ~FrameTrackingSwapPromise() override = default; |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 gfx::Size surface_size = root_pass->output_rect.size(); | 299 gfx::Size surface_size = root_pass->output_rect.size(); |
321 | 300 |
322 if (!local_frame_id_.is_valid() || current_surface_size_ != surface_size) { | 301 if (!local_frame_id_.is_valid() || current_surface_size_ != surface_size) { |
323 DestroyDelegatedContent(); | 302 DestroyDelegatedContent(); |
324 DCHECK(layer_->children().empty()); | 303 DCHECK(layer_->children().empty()); |
325 | 304 |
326 local_frame_id_ = surface_id_allocator_->GenerateId(); | 305 local_frame_id_ = surface_id_allocator_->GenerateId(); |
327 current_surface_size_ = surface_size; | 306 current_surface_size_ = surface_size; |
328 | 307 |
329 // manager must outlive compositors using it. | 308 // manager must outlive compositors using it. |
| 309 cc::SurfaceId surface_id(surface_factory_->frame_sink_id(), |
| 310 local_frame_id_); |
330 cc::SurfaceManager* surface_manager = | 311 cc::SurfaceManager* surface_manager = |
331 GetEmbedderDeps()->GetSurfaceManager(); | 312 GetEmbedderDeps()->GetSurfaceManager(); |
332 scoped_refptr<cc::SurfaceLayer> content_layer = cc::SurfaceLayer::Create( | 313 scoped_refptr<cc::SurfaceLayer> content_layer = cc::SurfaceLayer::Create( |
333 base::Bind(&SatisfyCallback, base::Unretained(surface_manager)), | 314 surface_manager->NewSurfaceRef(surface_id, 1.f, surface_size)); |
334 base::Bind(&RequireCallback, base::Unretained(surface_manager))); | |
335 content_layer->SetSurfaceId( | |
336 cc::SurfaceId(surface_factory_->frame_sink_id(), local_frame_id_), 1.f, | |
337 surface_size); | |
338 content_layer->SetBounds(current_surface_size_); | 315 content_layer->SetBounds(current_surface_size_); |
339 content_layer->SetIsDrawable(true); | 316 content_layer->SetIsDrawable(true); |
340 content_layer->SetContentsOpaque(true); | 317 content_layer->SetContentsOpaque(true); |
341 | 318 |
342 layer_->AddChild(content_layer); | 319 layer_->AddChild(content_layer); |
343 } | 320 } |
344 | 321 |
345 surface_factory_->SubmitCompositorFrame( | 322 surface_factory_->SubmitCompositorFrame( |
346 local_frame_id_, std::move(frame), | 323 local_frame_id_, std::move(frame), |
347 base::Bind(&BlimpCompositor::SubmitCompositorFrameAck, | 324 base::Bind(&BlimpCompositor::SubmitCompositorFrameAck, |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 // Destroy the old LayerTreeHost state. | 437 // Destroy the old LayerTreeHost state. |
461 host_.reset(); | 438 host_.reset(); |
462 | 439 |
463 // Cancel any outstanding CompositorFrameSink requests. That way if we get an | 440 // Cancel any outstanding CompositorFrameSink requests. That way if we get an |
464 // async callback related to the old request we know to drop it. | 441 // async callback related to the old request we know to drop it. |
465 compositor_frame_sink_request_pending_ = false; | 442 compositor_frame_sink_request_pending_ = false; |
466 } | 443 } |
467 | 444 |
468 } // namespace client | 445 } // namespace client |
469 } // namespace blimp | 446 } // namespace blimp |
OLD | NEW |