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 "services/ui/ws/server_window_compositor_frame_sink_manager.h" | 5 #include "services/ui/ws/server_window_compositor_frame_sink_manager.h" |
6 | 6 |
7 #include "cc/ipc/display_compositor.mojom.h" | 7 #include "cc/ipc/display_compositor.mojom.h" |
8 #include "mojo/public/cpp/bindings/strong_binding.h" | 8 #include "mojo/public/cpp/bindings/strong_binding.h" |
9 #include "services/ui/ws/ids.h" | 9 #include "services/ui/ws/ids.h" |
10 #include "services/ui/ws/server_window.h" | 10 #include "services/ui/ws/server_window.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
66 data.pending_compositor_frame_sink_request = | 66 data.pending_compositor_frame_sink_request = |
67 mojo::GetProxy(&data.compositor_frame_sink); | 67 mojo::GetProxy(&data.compositor_frame_sink); |
68 data.compositor_frame_sink->AddChildFrameSink(frame_sink_id); | 68 data.compositor_frame_sink->AddChildFrameSink(frame_sink_id); |
69 } | 69 } |
70 | 70 |
71 void ServerWindowCompositorFrameSinkManager::RemoveChildFrameSinkId( | 71 void ServerWindowCompositorFrameSinkManager::RemoveChildFrameSinkId( |
72 mojom::CompositorFrameSinkType compositor_frame_sink_type, | 72 mojom::CompositorFrameSinkType compositor_frame_sink_type, |
73 const cc::FrameSinkId& frame_sink_id) { | 73 const cc::FrameSinkId& frame_sink_id) { |
74 auto it = type_to_compositor_frame_sink_map_.find(compositor_frame_sink_type); | 74 auto it = type_to_compositor_frame_sink_map_.find(compositor_frame_sink_type); |
75 DCHECK(it != type_to_compositor_frame_sink_map_.end()); | 75 DCHECK(it != type_to_compositor_frame_sink_map_.end()); |
76 it->second.compositor_frame_sink->AddChildFrameSink(frame_sink_id); | 76 it->second.compositor_frame_sink->RemoveChildFrameSink(frame_sink_id); |
77 } | 77 } |
78 | 78 |
79 bool ServerWindowCompositorFrameSinkManager::HasCompositorFrameSinkOfType( | 79 bool ServerWindowCompositorFrameSinkManager::HasCompositorFrameSinkOfType( |
80 mojom::CompositorFrameSinkType type) const { | 80 mojom::CompositorFrameSinkType type) const { |
81 return type_to_compositor_frame_sink_map_.count(type) > 0; | 81 return type_to_compositor_frame_sink_map_.count(type) > 0; |
82 } | 82 } |
83 | 83 |
84 bool ServerWindowCompositorFrameSinkManager::HasAnyCompositorFrameSink() const { | 84 bool ServerWindowCompositorFrameSinkManager::HasAnyCompositorFrameSink() const { |
85 return HasCompositorFrameSinkOfType( | 85 return HasCompositorFrameSinkOfType( |
86 mojom::CompositorFrameSinkType::DEFAULT) || | 86 mojom::CompositorFrameSinkType::DEFAULT) || |
(...skipping 20 matching lines...) Expand all Loading... | |
107 | 107 |
108 void ServerWindowCompositorFrameSinkManager::SetLatestSurfaceInfo( | 108 void ServerWindowCompositorFrameSinkManager::SetLatestSurfaceInfo( |
109 mojom::CompositorFrameSinkType type, | 109 mojom::CompositorFrameSinkType type, |
110 const cc::SurfaceId& surface_id, | 110 const cc::SurfaceId& surface_id, |
111 const gfx::Size& frame_size) { | 111 const gfx::Size& frame_size) { |
112 CompositorFrameSinkData& data = type_to_compositor_frame_sink_map_[type]; | 112 CompositorFrameSinkData& data = type_to_compositor_frame_sink_map_[type]; |
113 data.latest_submitted_surface_id = surface_id; | 113 data.latest_submitted_surface_id = surface_id; |
114 data.latest_submitted_frame_size = frame_size; | 114 data.latest_submitted_frame_size = frame_size; |
115 } | 115 } |
116 | 116 |
117 void ServerWindowCompositorFrameSinkManager::OnRootChanged( | |
118 ServerWindow* old_root, | |
119 ServerWindow* new_root) { | |
120 for (const auto& pair : type_to_compositor_frame_sink_map_) { | |
121 if (old_root) { | |
122 old_root->GetOrCreateCompositorFrameSinkManager()->RemoveChildFrameSinkId( | |
123 pair.first, pair.second.frame_sink_id); | |
124 } | |
125 if (new_root) { | |
126 new_root->GetOrCreateCompositorFrameSinkManager()->AddChildFrameSinkId( | |
127 pair.first, pair.second.frame_sink_id); | |
128 } | |
129 } | |
130 } | |
131 | |
117 bool ServerWindowCompositorFrameSinkManager:: | 132 bool ServerWindowCompositorFrameSinkManager:: |
118 IsCompositorFrameSinkReadyAndNonEmpty( | 133 IsCompositorFrameSinkReadyAndNonEmpty( |
119 mojom::CompositorFrameSinkType type) const { | 134 mojom::CompositorFrameSinkType type) const { |
120 auto iter = type_to_compositor_frame_sink_map_.find(type); | 135 auto iter = type_to_compositor_frame_sink_map_.find(type); |
121 if (iter == type_to_compositor_frame_sink_map_.end()) | 136 if (iter == type_to_compositor_frame_sink_map_.end()) |
122 return false; | 137 return false; |
123 if (iter->second.latest_submitted_frame_size.IsEmpty()) | 138 if (iter->second.latest_submitted_frame_size.IsEmpty()) |
124 return false; | 139 return false; |
125 const gfx::Size& latest_submitted_frame_size = | 140 const gfx::Size& latest_submitted_frame_size = |
126 iter->second.latest_submitted_frame_size; | 141 iter->second.latest_submitted_frame_size; |
127 return latest_submitted_frame_size.width() >= window_->bounds().width() && | 142 return latest_submitted_frame_size.width() >= window_->bounds().width() && |
128 latest_submitted_frame_size.height() >= window_->bounds().height(); | 143 latest_submitted_frame_size.height() >= window_->bounds().height(); |
129 } | 144 } |
130 | 145 |
131 void ServerWindowCompositorFrameSinkManager::CreateCompositorFrameSinkInternal( | 146 void ServerWindowCompositorFrameSinkManager::CreateCompositorFrameSinkInternal( |
132 mojom::CompositorFrameSinkType compositor_frame_sink_type, | 147 mojom::CompositorFrameSinkType compositor_frame_sink_type, |
133 gfx::AcceleratedWidget widget, | 148 gfx::AcceleratedWidget widget, |
134 cc::mojom::MojoCompositorFrameSinkRequest request, | 149 cc::mojom::MojoCompositorFrameSinkRequest request, |
135 cc::mojom::MojoCompositorFrameSinkClientPtr client) { | 150 cc::mojom::MojoCompositorFrameSinkClientPtr client) { |
136 cc::FrameSinkId frame_sink_id( | 151 cc::FrameSinkId frame_sink_id( |
137 WindowIdToTransportId(window_->id()), | 152 WindowIdToTransportId(window_->id()), |
138 static_cast<uint32_t>(compositor_frame_sink_type)); | 153 static_cast<uint32_t>(compositor_frame_sink_type)); |
139 CompositorFrameSinkData& data = | 154 CompositorFrameSinkData& data = |
140 type_to_compositor_frame_sink_map_[compositor_frame_sink_type]; | 155 type_to_compositor_frame_sink_map_[compositor_frame_sink_type]; |
156 data.frame_sink_id = frame_sink_id; | |
141 cc::mojom::MojoCompositorFrameSinkPrivateRequest private_request; | 157 cc::mojom::MojoCompositorFrameSinkPrivateRequest private_request; |
142 if (data.pending_compositor_frame_sink_request.is_pending()) { | 158 if (data.pending_compositor_frame_sink_request.is_pending()) { |
143 private_request = std::move(data.pending_compositor_frame_sink_request); | 159 private_request = std::move(data.pending_compositor_frame_sink_request); |
144 } else { | 160 } else { |
145 private_request = mojo::GetProxy(&data.compositor_frame_sink); | 161 private_request = mojo::GetProxy(&data.compositor_frame_sink); |
146 } | 162 } |
147 | 163 |
148 if (widget != gfx::kNullAcceleratedWidget) { | 164 if (widget != gfx::kNullAcceleratedWidget) { |
149 // TODO(fsamuel): AcceleratedWidget cannot be transported over IPC for Mac | 165 // TODO(fsamuel): AcceleratedWidget cannot be transported over IPC for Mac |
150 // or Android. We should instead use GpuSurfaceTracker here on those | 166 // or Android. We should instead use GpuSurfaceTracker here on those |
151 // platforms. | 167 // platforms. |
152 window_->delegate() | 168 window_->delegate() |
153 ->GetDisplayCompositor() | 169 ->GetDisplayCompositor() |
154 ->CreateDisplayCompositorFrameSink( | 170 ->CreateDisplayCompositorFrameSink( |
155 frame_sink_id, widget, std::move(request), | 171 frame_sink_id, widget, std::move(request), |
156 std::move(private_request), std::move(client)); | 172 std::move(private_request), std::move(client)); |
157 } else { | 173 } else { |
158 window_->delegate() | 174 window_->delegate() |
159 ->GetDisplayCompositor() | 175 ->GetDisplayCompositor() |
160 ->CreateOffscreenCompositorFrameSink(frame_sink_id, std::move(request), | 176 ->CreateOffscreenCompositorFrameSink(frame_sink_id, std::move(request), |
161 std::move(private_request), | 177 std::move(private_request), |
162 std::move(client)); | 178 std::move(client)); |
163 } | 179 } |
164 | 180 |
165 if (window_->parent()) { | 181 if (window_->parent()) { |
Fady Samuel
2016/12/16 16:59:49
This check seems redundant then if we're checking
sky
2016/12/16 17:07:06
If we don't check the parent it means if a frame s
| |
166 window_->delegate() | 182 ServerWindow* root_window = window_->GetRoot(); |
167 ->GetRootWindow(window_) | 183 if (root_window) { |
168 ->GetOrCreateCompositorFrameSinkManager() | 184 root_window->GetOrCreateCompositorFrameSinkManager()->AddChildFrameSinkId( |
169 ->AddChildFrameSinkId(mojom::CompositorFrameSinkType::DEFAULT, | 185 mojom::CompositorFrameSinkType::DEFAULT, frame_sink_id); |
170 frame_sink_id); | 186 } |
171 } | 187 } |
172 } | 188 } |
173 | 189 |
174 CompositorFrameSinkData::CompositorFrameSinkData() {} | 190 CompositorFrameSinkData::CompositorFrameSinkData() {} |
175 | 191 |
176 CompositorFrameSinkData::~CompositorFrameSinkData() {} | 192 CompositorFrameSinkData::~CompositorFrameSinkData() {} |
177 | 193 |
178 CompositorFrameSinkData::CompositorFrameSinkData( | 194 CompositorFrameSinkData::CompositorFrameSinkData( |
179 CompositorFrameSinkData&& other) | 195 CompositorFrameSinkData&& other) |
180 : latest_submitted_surface_id(other.latest_submitted_surface_id), | 196 : latest_submitted_surface_id(other.latest_submitted_surface_id), |
181 compositor_frame_sink(std::move(other.compositor_frame_sink)) {} | 197 compositor_frame_sink(std::move(other.compositor_frame_sink)) {} |
182 | 198 |
183 CompositorFrameSinkData& CompositorFrameSinkData::operator=( | 199 CompositorFrameSinkData& CompositorFrameSinkData::operator=( |
184 CompositorFrameSinkData&& other) { | 200 CompositorFrameSinkData&& other) { |
185 latest_submitted_surface_id = other.latest_submitted_surface_id; | 201 latest_submitted_surface_id = other.latest_submitted_surface_id; |
186 compositor_frame_sink = std::move(other.compositor_frame_sink); | 202 compositor_frame_sink = std::move(other.compositor_frame_sink); |
187 return *this; | 203 return *this; |
188 } | 204 } |
189 | 205 |
190 } // namespace ws | 206 } // namespace ws |
191 } // namespace ui | 207 } // namespace ui |
OLD | NEW |