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

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

Issue 2579693004: GpuCompositorFrameSink implements cc::mojom::DisplayPrivate (Closed)
Patch Set: Address comments Created 3 years, 12 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 "cc/output/in_process_context_provider.h" 9 #include "cc/output/in_process_context_provider.h"
10 #include "cc/output/texture_mailbox_deleter.h" 10 #include "cc/output/texture_mailbox_deleter.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 86
87 void DisplayCompositor::OnCompositorFrameSinkPrivateConnectionLost( 87 void DisplayCompositor::OnCompositorFrameSinkPrivateConnectionLost(
88 const cc::FrameSinkId& frame_sink_id, 88 const cc::FrameSinkId& frame_sink_id,
89 bool destroy_compositor_frame_sink) { 89 bool destroy_compositor_frame_sink) {
90 DCHECK(thread_checker_.CalledOnValidThread()); 90 DCHECK(thread_checker_.CalledOnValidThread());
91 if (destroy_compositor_frame_sink) 91 if (destroy_compositor_frame_sink)
92 compositor_frame_sinks_.erase(frame_sink_id); 92 compositor_frame_sinks_.erase(frame_sink_id);
93 } 93 }
94 94
95 void DisplayCompositor::CreateDisplayCompositorFrameSink( 95 void DisplayCompositor::CreateDisplayCompositorFrameSink(
96 const cc::FrameSinkId& frame_sink_id, gpu::SurfaceHandle surface_handle, 96 const cc::FrameSinkId& frame_sink_id,
97 gpu::SurfaceHandle surface_handle,
97 cc::mojom::MojoCompositorFrameSinkRequest request, 98 cc::mojom::MojoCompositorFrameSinkRequest request,
98 cc::mojom::MojoCompositorFrameSinkPrivateRequest private_request, 99 cc::mojom::MojoCompositorFrameSinkPrivateRequest private_request,
99 cc::mojom::MojoCompositorFrameSinkClientPtr client) { 100 cc::mojom::MojoCompositorFrameSinkClientPtr client,
101 cc::mojom::DisplayPrivateRequest display_private_request) {
100 DCHECK(thread_checker_.CalledOnValidThread()); 102 DCHECK(thread_checker_.CalledOnValidThread());
101 DCHECK_NE(surface_handle, gpu::kNullSurfaceHandle); 103 DCHECK_NE(surface_handle, gpu::kNullSurfaceHandle);
102 std::unique_ptr<cc::SyntheticBeginFrameSource> begin_frame_source( 104 std::unique_ptr<cc::SyntheticBeginFrameSource> begin_frame_source(
103 new cc::DelayBasedBeginFrameSource( 105 new cc::DelayBasedBeginFrameSource(
104 base::MakeUnique<cc::DelayBasedTimeSource>(task_runner_.get()))); 106 base::MakeUnique<cc::DelayBasedTimeSource>(task_runner_.get())));
105 std::unique_ptr<cc::Display> display = 107 std::unique_ptr<cc::Display> display =
106 CreateDisplay(frame_sink_id, surface_handle, begin_frame_source.get()); 108 CreateDisplay(frame_sink_id, surface_handle, begin_frame_source.get());
107 CreateCompositorFrameSinkInternal( 109 CreateCompositorFrameSinkInternal(
108 frame_sink_id, surface_handle, std::move(display), 110 frame_sink_id, surface_handle, std::move(display),
109 std::move(begin_frame_source), std::move(request), 111 std::move(begin_frame_source), std::move(request),
110 std::move(private_request), std::move(client)); 112 std::move(private_request), std::move(client),
113 std::move(display_private_request));
111 } 114 }
112 115
113 void DisplayCompositor::CreateOffscreenCompositorFrameSink( 116 void DisplayCompositor::CreateOffscreenCompositorFrameSink(
114 const cc::FrameSinkId& frame_sink_id, 117 const cc::FrameSinkId& frame_sink_id,
115 cc::mojom::MojoCompositorFrameSinkRequest request, 118 cc::mojom::MojoCompositorFrameSinkRequest request,
116 cc::mojom::MojoCompositorFrameSinkPrivateRequest private_request, 119 cc::mojom::MojoCompositorFrameSinkPrivateRequest private_request,
117 cc::mojom::MojoCompositorFrameSinkClientPtr client) { 120 cc::mojom::MojoCompositorFrameSinkClientPtr client) {
118 CreateCompositorFrameSinkInternal( 121 CreateCompositorFrameSinkInternal(frame_sink_id, gpu::kNullSurfaceHandle,
119 frame_sink_id, gpu::kNullSurfaceHandle, nullptr, nullptr, 122 nullptr, nullptr, std::move(request),
120 std::move(request), std::move(private_request), std::move(client)); 123 std::move(private_request),
124 std::move(client), nullptr);
121 } 125 }
122 126
123 void DisplayCompositor::AddSurfaceReference(const cc::SurfaceReference& ref) { 127 void DisplayCompositor::AddSurfaceReference(const cc::SurfaceReference& ref) {
124 const cc::SurfaceId& parent_id = ref.parent_id(); 128 const cc::SurfaceId& parent_id = ref.parent_id();
125 const cc::SurfaceId& child_id = ref.child_id(); 129 const cc::SurfaceId& child_id = ref.child_id();
126 130
127 auto vector_iter = temp_references_.find(child_id.frame_sink_id()); 131 auto vector_iter = temp_references_.find(child_id.frame_sink_id());
128 132
129 // If there are no temporary references for the FrameSinkId then we can just 133 // If there are no temporary references for the FrameSinkId then we can just
130 // add reference and return. 134 // add reference and return.
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 new cc::DisplayScheduler(task_runner_.get(), max_frames_pending)); 217 new cc::DisplayScheduler(task_runner_.get(), max_frames_pending));
214 218
215 return base::MakeUnique<cc::Display>( 219 return base::MakeUnique<cc::Display>(
216 nullptr /* bitmap_manager */, gpu_memory_buffer_manager_.get(), 220 nullptr /* bitmap_manager */, gpu_memory_buffer_manager_.get(),
217 cc::RendererSettings(), frame_sink_id, begin_frame_source, 221 cc::RendererSettings(), frame_sink_id, begin_frame_source,
218 std::move(display_output_surface), std::move(scheduler), 222 std::move(display_output_surface), std::move(scheduler),
219 base::MakeUnique<cc::TextureMailboxDeleter>(task_runner_.get())); 223 base::MakeUnique<cc::TextureMailboxDeleter>(task_runner_.get()));
220 } 224 }
221 225
222 void DisplayCompositor::CreateCompositorFrameSinkInternal( 226 void DisplayCompositor::CreateCompositorFrameSinkInternal(
223 const cc::FrameSinkId& frame_sink_id, gpu::SurfaceHandle surface_handle, 227 const cc::FrameSinkId& frame_sink_id,
228 gpu::SurfaceHandle surface_handle,
224 std::unique_ptr<cc::Display> display, 229 std::unique_ptr<cc::Display> display,
225 std::unique_ptr<cc::SyntheticBeginFrameSource> begin_frame_source, 230 std::unique_ptr<cc::SyntheticBeginFrameSource> begin_frame_source,
226 cc::mojom::MojoCompositorFrameSinkRequest request, 231 cc::mojom::MojoCompositorFrameSinkRequest request,
227 cc::mojom::MojoCompositorFrameSinkPrivateRequest private_request, 232 cc::mojom::MojoCompositorFrameSinkPrivateRequest private_request,
228 cc::mojom::MojoCompositorFrameSinkClientPtr client) { 233 cc::mojom::MojoCompositorFrameSinkClientPtr client,
234 cc::mojom::DisplayPrivateRequest display_request) {
229 DCHECK(thread_checker_.CalledOnValidThread()); 235 DCHECK(thread_checker_.CalledOnValidThread());
230 // We cannot create more than one CompositorFrameSink with a given 236 // We cannot create more than one CompositorFrameSink with a given
231 // |frame_sink_id|. 237 // |frame_sink_id|.
232 DCHECK_EQ(0u, compositor_frame_sinks_.count(frame_sink_id)); 238 DCHECK_EQ(0u, compositor_frame_sinks_.count(frame_sink_id));
233 239
234 compositor_frame_sinks_[frame_sink_id] = 240 compositor_frame_sinks_[frame_sink_id] =
235 base::MakeUnique<GpuCompositorFrameSink>( 241 base::MakeUnique<GpuCompositorFrameSink>(
236 this, frame_sink_id, std::move(display), 242 this, frame_sink_id, std::move(display),
237 std::move(begin_frame_source), std::move(request), 243 std::move(begin_frame_source), std::move(request),
238 std::move(private_request), std::move(client)); 244 std::move(private_request), std::move(client),
245 std::move(display_request));
239 } 246 }
240 247
241 const cc::SurfaceId& DisplayCompositor::GetRootSurfaceId() const { 248 const cc::SurfaceId& DisplayCompositor::GetRootSurfaceId() const {
242 return reference_manager_->GetRootSurfaceId(); 249 return reference_manager_->GetRootSurfaceId();
243 } 250 }
244 251
245 void DisplayCompositor::OnSurfaceCreated(const cc::SurfaceId& surface_id, 252 void DisplayCompositor::OnSurfaceCreated(const cc::SurfaceId& surface_id,
246 const gfx::Size& frame_size, 253 const gfx::Size& frame_size,
247 float device_scale_factor) { 254 float device_scale_factor) {
248 DCHECK(thread_checker_.CalledOnValidThread()); 255 DCHECK(thread_checker_.CalledOnValidThread());
249 DCHECK_GT(device_scale_factor, 0.0f); 256 DCHECK_GT(device_scale_factor, 0.0f);
250 // We can get into a situation where multiple CompositorFrames arrive for a 257 // We can get into a situation where multiple CompositorFrames arrive for a
251 // CompositorFrameSink before the DisplayCompositorClient can add any 258 // CompositorFrameSink before the DisplayCompositorClient can add any
252 // references for the frame. When the second frame with a new size arrives, 259 // references for the frame. When the second frame with a new size arrives,
253 // the first will be destroyed and then if there are no references it will be 260 // the first will be destroyed and then if there are no references it will be
254 // deleted during surface GC. A temporary reference, removed when a real 261 // deleted during surface GC. A temporary reference, removed when a real
255 // reference is received, is added to prevent this from happening. 262 // reference is received, is added to prevent this from happening.
256 reference_manager_->AddSurfaceReference(GetRootSurfaceId(), surface_id); 263 reference_manager_->AddSurfaceReference(GetRootSurfaceId(), surface_id);
257 temp_references_[surface_id.frame_sink_id()].push_back( 264 temp_references_[surface_id.frame_sink_id()].push_back(
258 surface_id.local_frame_id()); 265 surface_id.local_frame_id());
259 266
260 if (client_) 267 if (client_)
261 client_->OnSurfaceCreated(surface_id, frame_size, device_scale_factor); 268 client_->OnSurfaceCreated(surface_id, frame_size, device_scale_factor);
262 } 269 }
263 270
264 void DisplayCompositor::OnSurfaceDamaged(const cc::SurfaceId& surface_id, 271 void DisplayCompositor::OnSurfaceDamaged(const cc::SurfaceId& surface_id,
265 bool* changed) {} 272 bool* changed) {}
266 273
267 } // namespace ui 274 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698