Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(113)

Side by Side Diff: services/ui/surfaces/display_compositor.cc

Issue 2654693003: Decouple GpuCompositorFrameSink from DisplayCompositor (Closed)
Patch Set: Fix vars Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "services/ui/surfaces/display_compositor.h" 5 #include "services/ui/surfaces/display_compositor.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/threading/thread_task_runner_handle.h" 10 #include "base/threading/thread_task_runner_handle.h"
(...skipping 26 matching lines...) Expand all
37 reference_manager_(&manager_), 37 reference_manager_(&manager_),
38 gpu_service_(std::move(gpu_service)), 38 gpu_service_(std::move(gpu_service)),
39 gpu_memory_buffer_manager_(std::move(gpu_memory_buffer_manager)), 39 gpu_memory_buffer_manager_(std::move(gpu_memory_buffer_manager)),
40 image_factory_(image_factory), 40 image_factory_(image_factory),
41 task_runner_(base::ThreadTaskRunnerHandle::Get()), 41 task_runner_(base::ThreadTaskRunnerHandle::Get()),
42 client_(std::move(client)), 42 client_(std::move(client)),
43 binding_(this, std::move(request)) { 43 binding_(this, std::move(request)) {
44 manager_.AddObserver(this); 44 manager_.AddObserver(this);
45 } 45 }
46 46
47 void DisplayCompositor::AddSurfaceReferences(
48 const std::vector<cc::SurfaceReference>& references) {
49 DCHECK(thread_checker_.CalledOnValidThread());
50 for (const auto& reference : references) {
51 reference_manager_->AddSurfaceReference(reference.parent_id(),
52 reference.child_id());
53 }
54 }
55
56 void DisplayCompositor::RemoveSurfaceReferences(
57 const std::vector<cc::SurfaceReference>& references) {
58 DCHECK(thread_checker_.CalledOnValidThread());
59
60 // TODO(kylechar): Each remove reference can trigger GC, it would be better if
61 // we GC only once if removing multiple references.
62 for (const auto& reference : references) {
63 reference_manager_->RemoveSurfaceReference(reference.parent_id(),
64 reference.child_id());
65 }
66 }
67
68 DisplayCompositor::~DisplayCompositor() { 47 DisplayCompositor::~DisplayCompositor() {
69 DCHECK(thread_checker_.CalledOnValidThread()); 48 DCHECK(thread_checker_.CalledOnValidThread());
70 manager_.RemoveObserver(this); 49 manager_.RemoveObserver(this);
71 } 50 }
72 51
73 void DisplayCompositor::OnCompositorFrameSinkClientConnectionLost( 52 void DisplayCompositor::OnClientConnectionLost(
74 const cc::FrameSinkId& frame_sink_id, 53 const cc::FrameSinkId& frame_sink_id,
75 bool destroy_compositor_frame_sink) { 54 bool destroy_compositor_frame_sink) {
76 DCHECK(thread_checker_.CalledOnValidThread()); 55 DCHECK(thread_checker_.CalledOnValidThread());
77 if (destroy_compositor_frame_sink) 56 if (destroy_compositor_frame_sink)
78 compositor_frame_sinks_.erase(frame_sink_id); 57 compositor_frame_sinks_.erase(frame_sink_id);
79 // TODO(fsamuel): Tell the display compositor host that the client connection 58 // TODO(fsamuel): Tell the display compositor host that the client connection
80 // has been lost so that it can drop its private connection and allow a new 59 // has been lost so that it can drop its private connection and allow a new
81 // client instance to create a new CompositorFrameSink. 60 // client instance to create a new CompositorFrameSink.
82 } 61 }
83 62
84 void DisplayCompositor::OnCompositorFrameSinkPrivateConnectionLost( 63 void DisplayCompositor::OnPrivateConnectionLost(
85 const cc::FrameSinkId& frame_sink_id, 64 const cc::FrameSinkId& frame_sink_id,
86 bool destroy_compositor_frame_sink) { 65 bool destroy_compositor_frame_sink) {
87 DCHECK(thread_checker_.CalledOnValidThread()); 66 DCHECK(thread_checker_.CalledOnValidThread());
88 if (destroy_compositor_frame_sink) 67 if (destroy_compositor_frame_sink)
89 compositor_frame_sinks_.erase(frame_sink_id); 68 compositor_frame_sinks_.erase(frame_sink_id);
90 } 69 }
91 70
92 void DisplayCompositor::CreateDisplayCompositorFrameSink( 71 void DisplayCompositor::CreateDisplayCompositorFrameSink(
93 const cc::FrameSinkId& frame_sink_id, 72 const cc::FrameSinkId& frame_sink_id,
94 gpu::SurfaceHandle surface_handle, 73 gpu::SurfaceHandle surface_handle,
95 cc::mojom::MojoCompositorFrameSinkAssociatedRequest request, 74 cc::mojom::MojoCompositorFrameSinkAssociatedRequest request,
96 cc::mojom::MojoCompositorFrameSinkPrivateRequest private_request, 75 cc::mojom::MojoCompositorFrameSinkPrivateRequest private_request,
97 cc::mojom::MojoCompositorFrameSinkClientPtr client, 76 cc::mojom::MojoCompositorFrameSinkClientPtr client,
98 cc::mojom::DisplayPrivateAssociatedRequest display_private_request) { 77 cc::mojom::DisplayPrivateAssociatedRequest display_private_request) {
99 DCHECK(thread_checker_.CalledOnValidThread()); 78 DCHECK(thread_checker_.CalledOnValidThread());
100 DCHECK_NE(surface_handle, gpu::kNullSurfaceHandle); 79 DCHECK_NE(surface_handle, gpu::kNullSurfaceHandle);
101 DCHECK_EQ(0u, compositor_frame_sinks_.count(frame_sink_id)); 80 DCHECK_EQ(0u, compositor_frame_sinks_.count(frame_sink_id));
102 81
103 std::unique_ptr<cc::SyntheticBeginFrameSource> begin_frame_source( 82 std::unique_ptr<cc::SyntheticBeginFrameSource> begin_frame_source(
104 new cc::DelayBasedBeginFrameSource( 83 new cc::DelayBasedBeginFrameSource(
105 base::MakeUnique<cc::DelayBasedTimeSource>(task_runner_.get()))); 84 base::MakeUnique<cc::DelayBasedTimeSource>(task_runner_.get())));
106 std::unique_ptr<cc::Display> display = 85 std::unique_ptr<cc::Display> display =
107 CreateDisplay(frame_sink_id, surface_handle, begin_frame_source.get()); 86 CreateDisplay(frame_sink_id, surface_handle, begin_frame_source.get());
108 87
109 compositor_frame_sinks_[frame_sink_id] = 88 compositor_frame_sinks_[frame_sink_id] =
110 base::MakeUnique<GpuDisplayCompositorFrameSink>( 89 base::MakeUnique<GpuDisplayCompositorFrameSink>(
111 this, frame_sink_id, std::move(display), 90 this, &manager_, frame_sink_id, std::move(display),
112 std::move(begin_frame_source), std::move(request), 91 std::move(begin_frame_source), std::move(request),
113 std::move(private_request), std::move(client), 92 std::move(private_request), std::move(client),
114 std::move(display_private_request)); 93 std::move(display_private_request));
115 } 94 }
116 95
117 void DisplayCompositor::CreateOffscreenCompositorFrameSink( 96 void DisplayCompositor::CreateOffscreenCompositorFrameSink(
118 const cc::FrameSinkId& frame_sink_id, 97 const cc::FrameSinkId& frame_sink_id,
119 cc::mojom::MojoCompositorFrameSinkRequest request, 98 cc::mojom::MojoCompositorFrameSinkRequest request,
120 cc::mojom::MojoCompositorFrameSinkPrivateRequest private_request, 99 cc::mojom::MojoCompositorFrameSinkPrivateRequest private_request,
121 cc::mojom::MojoCompositorFrameSinkClientPtr client) { 100 cc::mojom::MojoCompositorFrameSinkClientPtr client) {
122 DCHECK(thread_checker_.CalledOnValidThread()); 101 DCHECK(thread_checker_.CalledOnValidThread());
123 DCHECK_EQ(0u, compositor_frame_sinks_.count(frame_sink_id)); 102 DCHECK_EQ(0u, compositor_frame_sinks_.count(frame_sink_id));
124 103
125 compositor_frame_sinks_[frame_sink_id] = 104 compositor_frame_sinks_[frame_sink_id] =
126 base::MakeUnique<GpuOffscreenCompositorFrameSink>( 105 base::MakeUnique<GpuOffscreenCompositorFrameSink>(
127 this, frame_sink_id, std::move(request), std::move(private_request), 106 this, &manager_, frame_sink_id, std::move(request),
128 std::move(client)); 107 std::move(private_request), std::move(client));
129 } 108 }
130 109
131 std::unique_ptr<cc::Display> DisplayCompositor::CreateDisplay( 110 std::unique_ptr<cc::Display> DisplayCompositor::CreateDisplay(
132 const cc::FrameSinkId& frame_sink_id, 111 const cc::FrameSinkId& frame_sink_id,
133 gpu::SurfaceHandle surface_handle, 112 gpu::SurfaceHandle surface_handle,
134 cc::SyntheticBeginFrameSource* begin_frame_source) { 113 cc::SyntheticBeginFrameSource* begin_frame_source) {
135 scoped_refptr<cc::InProcessContextProvider> context_provider = 114 scoped_refptr<cc::InProcessContextProvider> context_provider =
136 new cc::InProcessContextProvider( 115 new cc::InProcessContextProvider(
137 gpu_service_, surface_handle, gpu_memory_buffer_manager_.get(), 116 gpu_service_, surface_handle, gpu_memory_buffer_manager_.get(),
138 image_factory_, gpu::SharedMemoryLimits(), 117 image_factory_, gpu::SharedMemoryLimits(),
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 DCHECK_GT(surface_info.device_scale_factor(), 0.0f); 158 DCHECK_GT(surface_info.device_scale_factor(), 0.0f);
180 159
181 if (client_) 160 if (client_)
182 client_->OnSurfaceCreated(surface_info); 161 client_->OnSurfaceCreated(surface_info);
183 } 162 }
184 163
185 void DisplayCompositor::OnSurfaceDamaged(const cc::SurfaceId& surface_id, 164 void DisplayCompositor::OnSurfaceDamaged(const cc::SurfaceId& surface_id,
186 bool* changed) {} 165 bool* changed) {}
187 166
188 } // namespace ui 167 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698