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

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

Issue 2797453002: Rename DisplayCompositor to MojoFrameSinkManager. (Closed)
Patch Set: Rebase. Created 3 years, 8 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
« no previous file with comments | « services/ui/surfaces/display_compositor.h ('k') | services/ui/surfaces/display_provider.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "services/ui/surfaces/display_compositor.h"
6
7 #include <utility>
8
9 #include "base/command_line.h"
10 #include "base/memory/ptr_util.h"
11 #include "cc/base/switches.h"
12 #include "cc/scheduler/begin_frame_source.h"
13 #include "cc/surfaces/display.h"
14 #include "cc/surfaces/surface_dependency_tracker.h"
15 #include "components/display_compositor/gpu_compositor_frame_sink.h"
16 #include "components/display_compositor/gpu_root_compositor_frame_sink.h"
17 #include "services/ui/surfaces/display_provider.h"
18
19 namespace ui {
20
21 DisplayCompositor::DisplayCompositor(
22 DisplayProvider* display_provider,
23 cc::mojom::DisplayCompositorRequest request,
24 cc::mojom::DisplayCompositorClientPtr client)
25 : manager_(cc::SurfaceManager::LifetimeType::REFERENCES),
26 display_provider_(display_provider),
27 client_(std::move(client)),
28 binding_(this, std::move(request)) {
29 manager_.AddObserver(this);
30 }
31
32 DisplayCompositor::~DisplayCompositor() {
33 DCHECK(thread_checker_.CalledOnValidThread());
34 manager_.RemoveObserver(this);
35 }
36
37 void DisplayCompositor::CreateRootCompositorFrameSink(
38 const cc::FrameSinkId& frame_sink_id,
39 gpu::SurfaceHandle surface_handle,
40 cc::mojom::MojoCompositorFrameSinkAssociatedRequest request,
41 cc::mojom::MojoCompositorFrameSinkPrivateRequest private_request,
42 cc::mojom::MojoCompositorFrameSinkClientPtr client,
43 cc::mojom::DisplayPrivateAssociatedRequest display_private_request) {
44 DCHECK(thread_checker_.CalledOnValidThread());
45 DCHECK_NE(surface_handle, gpu::kNullSurfaceHandle);
46 DCHECK_EQ(0u, compositor_frame_sinks_.count(frame_sink_id));
47 DCHECK(display_provider_);
48
49 std::unique_ptr<cc::BeginFrameSource> begin_frame_source;
50 std::unique_ptr<cc::Display> display = display_provider_->CreateDisplay(
51 frame_sink_id, surface_handle, &begin_frame_source);
52
53 // Lazily inject a SurfaceDependencyTracker into SurfaceManager if surface
54 // synchronization is enabled.
55 if (!manager_.dependency_tracker() &&
56 base::CommandLine::ForCurrentProcess()->HasSwitch(
57 cc::switches::kEnableSurfaceSynchronization)) {
58 std::unique_ptr<cc::SurfaceDependencyTracker> dependency_tracker(
59 new cc::SurfaceDependencyTracker(&manager_, begin_frame_source.get()));
60 manager_.SetDependencyTracker(std::move(dependency_tracker));
61 }
62
63 compositor_frame_sinks_[frame_sink_id] =
64 base::MakeUnique<display_compositor::GpuRootCompositorFrameSink>(
65 this, &manager_, frame_sink_id, std::move(display),
66 std::move(begin_frame_source), std::move(request),
67 std::move(private_request), std::move(client),
68 std::move(display_private_request));
69 }
70
71 void DisplayCompositor::CreateCompositorFrameSink(
72 const cc::FrameSinkId& frame_sink_id,
73 cc::mojom::MojoCompositorFrameSinkRequest request,
74 cc::mojom::MojoCompositorFrameSinkPrivateRequest private_request,
75 cc::mojom::MojoCompositorFrameSinkClientPtr client) {
76 DCHECK(thread_checker_.CalledOnValidThread());
77 DCHECK_EQ(0u, compositor_frame_sinks_.count(frame_sink_id));
78
79 compositor_frame_sinks_[frame_sink_id] =
80 base::MakeUnique<display_compositor::GpuCompositorFrameSink>(
81 this, &manager_, frame_sink_id, std::move(request),
82 std::move(private_request), std::move(client));
83 }
84
85 void DisplayCompositor::RegisterFrameSinkHierarchy(
86 const cc::FrameSinkId& parent_frame_sink_id,
87 const cc::FrameSinkId& child_frame_sink_id) {
88 manager_.RegisterFrameSinkHierarchy(parent_frame_sink_id,
89 child_frame_sink_id);
90 }
91
92 void DisplayCompositor::UnregisterFrameSinkHierarchy(
93 const cc::FrameSinkId& parent_frame_sink_id,
94 const cc::FrameSinkId& child_frame_sink_id) {
95 manager_.UnregisterFrameSinkHierarchy(parent_frame_sink_id,
96 child_frame_sink_id);
97 }
98
99 void DisplayCompositor::DropTemporaryReference(
100 const cc::SurfaceId& surface_id) {
101 manager_.DropTemporaryReference(surface_id);
102 }
103
104 void DisplayCompositor::DestroyCompositorFrameSink(cc::FrameSinkId sink_id) {
105 compositor_frame_sinks_.erase(sink_id);
106 }
107
108 void DisplayCompositor::OnSurfaceCreated(const cc::SurfaceInfo& surface_info) {
109 DCHECK(thread_checker_.CalledOnValidThread());
110 DCHECK_GT(surface_info.device_scale_factor(), 0.0f);
111
112 // TODO(kylechar): |client_| will try to find an owner for the temporary
113 // reference to the new surface. With surface synchronization this might not
114 // be necessary, because a surface reference might already exist and no
115 // temporary reference was created. It could be useful to let |client_| know
116 // if it should find an owner.
117 if (client_)
118 client_->OnSurfaceCreated(surface_info);
119 }
120
121 void DisplayCompositor::OnSurfaceDamaged(const cc::SurfaceId& surface_id,
122 bool* changed) {}
123
124 void DisplayCompositor::OnClientConnectionLost(
125 const cc::FrameSinkId& frame_sink_id,
126 bool destroy_compositor_frame_sink) {
127 DCHECK(thread_checker_.CalledOnValidThread());
128 if (destroy_compositor_frame_sink)
129 DestroyCompositorFrameSink(frame_sink_id);
130 // TODO(fsamuel): Tell the display compositor host that the client connection
131 // has been lost so that it can drop its private connection and allow a new
132 // client instance to create a new CompositorFrameSink.
133 }
134
135 void DisplayCompositor::OnPrivateConnectionLost(
136 const cc::FrameSinkId& frame_sink_id,
137 bool destroy_compositor_frame_sink) {
138 DCHECK(thread_checker_.CalledOnValidThread());
139 if (destroy_compositor_frame_sink)
140 DestroyCompositorFrameSink(frame_sink_id);
141 }
142
143 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/surfaces/display_compositor.h ('k') | services/ui/surfaces/display_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698