OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "cc/surfaces/direct_compositor_frame_sink.h" | 5 #include "cc/surfaces/direct_compositor_frame_sink.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "cc/output/compositor_frame.h" | 8 #include "cc/output/compositor_frame.h" |
9 #include "cc/output/compositor_frame_sink_client.h" | 9 #include "cc/output/compositor_frame_sink_client.h" |
10 #include "cc/surfaces/display.h" | 10 #include "cc/surfaces/display.h" |
11 #include "cc/surfaces/frame_sink_id.h" | 11 #include "cc/surfaces/frame_sink_id.h" |
12 #include "cc/surfaces/framesink_manager.h" | |
12 #include "cc/surfaces/surface.h" | 13 #include "cc/surfaces/surface.h" |
13 #include "cc/surfaces/surface_id_allocator.h" | 14 #include "cc/surfaces/surface_id_allocator.h" |
14 #include "cc/surfaces/surface_manager.h" | 15 #include "cc/surfaces/surface_manager.h" |
15 | 16 |
16 namespace cc { | 17 namespace cc { |
17 | 18 |
18 DirectCompositorFrameSink::DirectCompositorFrameSink( | 19 DirectCompositorFrameSink::DirectCompositorFrameSink( |
19 const FrameSinkId& frame_sink_id, | 20 const FrameSinkId& frame_sink_id, |
20 SurfaceManager* surface_manager, | 21 SurfaceManager* surface_manager, |
22 FrameSinkManager* framesink_manager, | |
21 Display* display, | 23 Display* display, |
22 scoped_refptr<ContextProvider> context_provider, | 24 scoped_refptr<ContextProvider> context_provider, |
23 scoped_refptr<ContextProvider> worker_context_provider, | 25 scoped_refptr<ContextProvider> worker_context_provider, |
24 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 26 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
25 SharedBitmapManager* shared_bitmap_manager) | 27 SharedBitmapManager* shared_bitmap_manager) |
26 : CompositorFrameSink(std::move(context_provider), | 28 : CompositorFrameSink(std::move(context_provider), |
27 std::move(worker_context_provider), | 29 std::move(worker_context_provider), |
28 gpu_memory_buffer_manager, | 30 gpu_memory_buffer_manager, |
29 shared_bitmap_manager), | 31 shared_bitmap_manager), |
30 frame_sink_id_(frame_sink_id), | 32 frame_sink_id_(frame_sink_id), |
31 surface_manager_(surface_manager), | 33 surface_manager_(surface_manager), |
34 framesink_manager_(framesink_manager), | |
32 display_(display), | 35 display_(display), |
33 factory_(frame_sink_id, surface_manager, this) { | 36 factory_(frame_sink_id, surface_manager, this) { |
34 DCHECK(thread_checker_.CalledOnValidThread()); | 37 DCHECK(thread_checker_.CalledOnValidThread()); |
35 capabilities_.can_force_reclaim_resources = true; | 38 capabilities_.can_force_reclaim_resources = true; |
36 // Display and DirectCompositorFrameSink share a GL context, so sync | 39 // Display and DirectCompositorFrameSink share a GL context, so sync |
37 // points aren't needed when passing resources between them. | 40 // points aren't needed when passing resources between them. |
38 capabilities_.delegated_sync_points_required = false; | 41 capabilities_.delegated_sync_points_required = false; |
39 factory_.set_needs_sync_points(false); | 42 factory_.set_needs_sync_points(false); |
40 } | 43 } |
41 | 44 |
42 DirectCompositorFrameSink::DirectCompositorFrameSink( | 45 DirectCompositorFrameSink::DirectCompositorFrameSink( |
43 const FrameSinkId& frame_sink_id, | 46 const FrameSinkId& frame_sink_id, |
44 SurfaceManager* surface_manager, | 47 SurfaceManager* surface_manager, |
48 FrameSinkManager* framesink_manager, | |
45 Display* display, | 49 Display* display, |
46 scoped_refptr<VulkanContextProvider> vulkan_context_provider) | 50 scoped_refptr<VulkanContextProvider> vulkan_context_provider) |
47 : CompositorFrameSink(std::move(vulkan_context_provider)), | 51 : CompositorFrameSink(std::move(vulkan_context_provider)), |
48 frame_sink_id_(frame_sink_id), | 52 frame_sink_id_(frame_sink_id), |
49 surface_manager_(surface_manager), | 53 surface_manager_(surface_manager), |
54 framesink_manager_(framesink_manager), | |
50 display_(display), | 55 display_(display), |
51 factory_(frame_sink_id_, surface_manager, this) { | 56 factory_(frame_sink_id_, surface_manager, this) { |
52 DCHECK(thread_checker_.CalledOnValidThread()); | 57 DCHECK(thread_checker_.CalledOnValidThread()); |
53 capabilities_.can_force_reclaim_resources = true; | 58 capabilities_.can_force_reclaim_resources = true; |
54 } | 59 } |
55 | 60 |
56 DirectCompositorFrameSink::~DirectCompositorFrameSink() { | 61 DirectCompositorFrameSink::~DirectCompositorFrameSink() { |
57 DCHECK(thread_checker_.CalledOnValidThread()); | 62 DCHECK(thread_checker_.CalledOnValidThread()); |
58 } | 63 } |
59 | 64 |
60 bool DirectCompositorFrameSink::BindToClient( | 65 bool DirectCompositorFrameSink::BindToClient( |
61 CompositorFrameSinkClient* client) { | 66 CompositorFrameSinkClient* client) { |
62 DCHECK(thread_checker_.CalledOnValidThread()); | 67 DCHECK(thread_checker_.CalledOnValidThread()); |
63 | 68 |
64 if (!CompositorFrameSink::BindToClient(client)) | 69 if (!CompositorFrameSink::BindToClient(client)) |
65 return false; | 70 return false; |
66 | 71 |
67 surface_manager_->RegisterSurfaceFactoryClient(frame_sink_id_, this); | 72 framesink_manager_->RegisterSurfaceFactoryClient(frame_sink_id_, this); |
68 | 73 |
69 // We want the Display's output surface to hear about lost context, and since | 74 // We want the Display's output surface to hear about lost context, and since |
70 // this shares a context with it, we should not be listening for lost context | 75 // this shares a context with it, we should not be listening for lost context |
71 // callbacks on the context here. | 76 // callbacks on the context here. |
72 if (auto* cp = context_provider()) | 77 if (auto* cp = context_provider()) |
73 cp->SetLostContextCallback(base::Closure()); | 78 cp->SetLostContextCallback(base::Closure()); |
74 | 79 |
75 // Avoid initializing GL context here, as this should be sharing the | 80 // Avoid initializing GL context here, as this should be sharing the |
76 // Display's context. | 81 // Display's context. |
77 display_->Initialize(this, surface_manager_); | 82 display_->Initialize(this, surface_manager_, framesink_manager_); |
Fady Samuel
2017/02/12 19:04:07
Does Display do anything useful with SurfaceManage
k.devara
2017/02/13 06:47:34
surface_manager itself is used to get surface_id f
| |
78 return true; | 83 return true; |
79 } | 84 } |
80 | 85 |
81 void DirectCompositorFrameSink::DetachFromClient() { | 86 void DirectCompositorFrameSink::DetachFromClient() { |
82 // Unregister the SurfaceFactoryClient here instead of the dtor so that only | 87 // Unregister the SurfaceFactoryClient here instead of the dtor so that only |
83 // one client is alive for this namespace at any given time. | 88 // one client is alive for this namespace at any given time. |
84 surface_manager_->UnregisterSurfaceFactoryClient(frame_sink_id_); | 89 framesink_manager_->UnregisterSurfaceFactoryClient(frame_sink_id_); |
85 factory_.EvictSurface(); | 90 factory_.EvictSurface(); |
86 | 91 |
87 CompositorFrameSink::DetachFromClient(); | 92 CompositorFrameSink::DetachFromClient(); |
88 } | 93 } |
89 | 94 |
90 void DirectCompositorFrameSink::SubmitCompositorFrame(CompositorFrame frame) { | 95 void DirectCompositorFrameSink::SubmitCompositorFrame(CompositorFrame frame) { |
91 gfx::Size frame_size = frame.render_pass_list.back()->output_rect.size(); | 96 gfx::Size frame_size = frame.render_pass_list.back()->output_rect.size(); |
92 if (frame_size.IsEmpty() || frame_size != last_swap_frame_size_) { | 97 if (frame_size.IsEmpty() || frame_size != last_swap_frame_size_) { |
93 delegated_local_surface_id_ = surface_id_allocator_.GenerateId(); | 98 delegated_local_surface_id_ = surface_id_allocator_.GenerateId(); |
94 last_swap_frame_size_ = frame_size; | 99 last_swap_frame_size_ = frame_size; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
134 // This notification is not relevant to our client outside of tests. We | 139 // This notification is not relevant to our client outside of tests. We |
135 // unblock the client from DidDrawCallback() when the surface is going to | 140 // unblock the client from DidDrawCallback() when the surface is going to |
136 // be drawn. | 141 // be drawn. |
137 } | 142 } |
138 | 143 |
139 void DirectCompositorFrameSink::DidDrawCallback() { | 144 void DirectCompositorFrameSink::DidDrawCallback() { |
140 client_->DidReceiveCompositorFrameAck(); | 145 client_->DidReceiveCompositorFrameAck(); |
141 } | 146 } |
142 | 147 |
143 } // namespace cc | 148 } // namespace cc |
OLD | NEW |