OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/frame_generator.h" | 5 #include "services/ui/ws/frame_generator.h" |
6 | 6 |
7 #include "base/containers/adapters.h" | 7 #include "base/containers/adapters.h" |
8 #include "cc/output/compositor_frame.h" | 8 #include "cc/output/compositor_frame.h" |
9 #include "cc/quads/render_pass.h" | 9 #include "cc/quads/render_pass.h" |
10 #include "cc/quads/render_pass_draw_quad.h" | 10 #include "cc/quads/render_pass_draw_quad.h" |
11 #include "cc/quads/shared_quad_state.h" | 11 #include "cc/quads/shared_quad_state.h" |
12 #include "cc/quads/surface_draw_quad.h" | 12 #include "cc/quads/surface_draw_quad.h" |
13 #include "cc/surfaces/surface_id.h" | 13 #include "cc/surfaces/surface_id.h" |
14 #include "gpu/ipc/client/gpu_channel_host.h" | 14 #include "gpu/ipc/client/gpu_channel_host.h" |
15 #include "services/ui/surfaces/compositor_frame_sink.h" | 15 #include "services/ui/surfaces/compositor_frame_sink.h" |
16 #include "services/ui/ws/frame_generator_delegate.h" | 16 #include "services/ui/ws/frame_generator_delegate.h" |
17 #include "services/ui/ws/server_window.h" | 17 #include "services/ui/ws/server_window.h" |
18 #include "services/ui/ws/server_window_surface.h" | 18 #include "services/ui/ws/server_window_compositor_frame_sink.h" |
19 #include "services/ui/ws/server_window_surface_manager.h" | 19 #include "services/ui/ws/server_window_compositor_frame_sink_manager.h" |
20 | 20 |
21 namespace ui { | 21 namespace ui { |
22 | 22 |
23 namespace ws { | 23 namespace ws { |
24 | 24 |
25 FrameGenerator::FrameGenerator( | 25 FrameGenerator::FrameGenerator( |
26 FrameGeneratorDelegate* delegate, | 26 FrameGeneratorDelegate* delegate, |
27 scoped_refptr<DisplayCompositor> display_compositor) | 27 scoped_refptr<DisplayCompositor> display_compositor) |
28 : delegate_(delegate), | 28 : delegate_(delegate), |
29 display_compositor_(display_compositor), | 29 display_compositor_(display_compositor), |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
158 | 158 |
159 void FrameGenerator::DrawWindowTree( | 159 void FrameGenerator::DrawWindowTree( |
160 cc::RenderPass* pass, | 160 cc::RenderPass* pass, |
161 ServerWindow* window, | 161 ServerWindow* window, |
162 const gfx::Vector2d& parent_to_root_origin_offset, | 162 const gfx::Vector2d& parent_to_root_origin_offset, |
163 float opacity, | 163 float opacity, |
164 bool* may_contain_video) { | 164 bool* may_contain_video) { |
165 if (!window->visible()) | 165 if (!window->visible()) |
166 return; | 166 return; |
167 | 167 |
168 ServerWindowSurface* default_surface = | 168 ServerWindowCompositorFrameSink* default_compositor_frame_sink = |
169 window->surface_manager() ? window->surface_manager()->GetDefaultSurface() | 169 window->compositor_frame_sink_manager() |
170 : nullptr; | 170 ? window->compositor_frame_sink_manager() |
171 ->GetDefaultCompositorFrameSink() | |
172 : nullptr; | |
171 | 173 |
172 const gfx::Rect absolute_bounds = | 174 const gfx::Rect absolute_bounds = |
173 window->bounds() + parent_to_root_origin_offset; | 175 window->bounds() + parent_to_root_origin_offset; |
174 const ServerWindow::Windows& children = window->children(); | 176 const ServerWindow::Windows& children = window->children(); |
175 const float combined_opacity = opacity * window->opacity(); | 177 const float combined_opacity = opacity * window->opacity(); |
176 for (ServerWindow* child : base::Reversed(children)) { | 178 for (ServerWindow* child : base::Reversed(children)) { |
177 DrawWindowTree(pass, child, absolute_bounds.OffsetFromOrigin(), | 179 DrawWindowTree(pass, child, absolute_bounds.OffsetFromOrigin(), |
178 combined_opacity, may_contain_video); | 180 combined_opacity, may_contain_video); |
179 } | 181 } |
180 | 182 |
181 if (!window->surface_manager() || !window->surface_manager()->ShouldDraw()) | 183 if (!window->compositor_frame_sink_manager() || |
184 !window->compositor_frame_sink_manager()->ShouldDraw()) | |
182 return; | 185 return; |
183 | 186 |
184 ServerWindowSurface* underlay_surface = | 187 ServerWindowCompositorFrameSink* underlay_compositor_frame_sink = |
rjkroege
2016/10/20 22:22:18
this code is all suppose to go away yes?
Fady Samuel
2016/10/21 20:53:27
Yes, it is.
| |
185 window->surface_manager()->GetUnderlaySurface(); | 188 window->compositor_frame_sink_manager()->GetUnderlayCompositorFrameSink(); |
186 if (!default_surface && !underlay_surface) | 189 if (!default_compositor_frame_sink && !underlay_compositor_frame_sink) |
187 return; | 190 return; |
188 | 191 |
189 if (default_surface) { | 192 if (default_compositor_frame_sink) { |
190 gfx::Transform quad_to_target_transform; | 193 gfx::Transform quad_to_target_transform; |
191 quad_to_target_transform.Translate(absolute_bounds.x(), | 194 quad_to_target_transform.Translate(absolute_bounds.x(), |
192 absolute_bounds.y()); | 195 absolute_bounds.y()); |
193 | 196 |
194 cc::SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); | 197 cc::SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); |
195 | 198 |
196 const gfx::Rect bounds_at_origin(window->bounds().size()); | 199 const gfx::Rect bounds_at_origin(window->bounds().size()); |
197 // TODO(fsamuel): These clipping and visible rects are incorrect. They need | 200 // TODO(fsamuel): These clipping and visible rects are incorrect. They need |
198 // to be populated from CompositorFrame structs. | 201 // to be populated from CompositorFrame structs. |
199 sqs->SetAll(quad_to_target_transform, | 202 sqs->SetAll(quad_to_target_transform, |
200 bounds_at_origin.size() /* layer_bounds */, | 203 bounds_at_origin.size() /* layer_bounds */, |
201 bounds_at_origin /* visible_layer_bounds */, | 204 bounds_at_origin /* visible_layer_bounds */, |
202 bounds_at_origin /* clip_rect */, false /* is_clipped */, | 205 bounds_at_origin /* clip_rect */, false /* is_clipped */, |
203 combined_opacity, SkXfermode::kSrcOver_Mode, | 206 combined_opacity, SkXfermode::kSrcOver_Mode, |
204 0 /* sorting-context_id */); | 207 0 /* sorting-context_id */); |
205 auto* quad = pass->CreateAndAppendDrawQuad<cc::SurfaceDrawQuad>(); | 208 auto* quad = pass->CreateAndAppendDrawQuad<cc::SurfaceDrawQuad>(); |
206 AddOrUpdateSurfaceReference(default_surface); | 209 AddOrUpdateSurfaceReference(default_compositor_frame_sink); |
207 quad->SetAll(sqs, bounds_at_origin /* rect */, | 210 quad->SetAll(sqs, bounds_at_origin /* rect */, |
208 gfx::Rect() /* opaque_rect */, | 211 gfx::Rect() /* opaque_rect */, |
209 bounds_at_origin /* visible_rect */, true /* needs_blending*/, | 212 bounds_at_origin /* visible_rect */, true /* needs_blending*/, |
210 default_surface->GetSurfaceId()); | 213 default_compositor_frame_sink->GetSurfaceId()); |
211 if (default_surface->may_contain_video()) | 214 if (default_compositor_frame_sink->may_contain_video()) |
212 *may_contain_video = true; | 215 *may_contain_video = true; |
213 } | 216 } |
214 if (underlay_surface) { | 217 if (underlay_compositor_frame_sink) { |
215 const gfx::Rect underlay_absolute_bounds = | 218 const gfx::Rect underlay_absolute_bounds = |
216 absolute_bounds - window->underlay_offset(); | 219 absolute_bounds - window->underlay_offset(); |
217 gfx::Transform quad_to_target_transform; | 220 gfx::Transform quad_to_target_transform; |
218 quad_to_target_transform.Translate(underlay_absolute_bounds.x(), | 221 quad_to_target_transform.Translate(underlay_absolute_bounds.x(), |
219 underlay_absolute_bounds.y()); | 222 underlay_absolute_bounds.y()); |
220 cc::SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); | 223 cc::SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); |
221 const gfx::Rect bounds_at_origin( | 224 const gfx::Rect bounds_at_origin( |
222 underlay_surface->last_submitted_frame_size()); | 225 underlay_compositor_frame_sink->last_submitted_frame_size()); |
223 sqs->SetAll(quad_to_target_transform, | 226 sqs->SetAll(quad_to_target_transform, |
224 bounds_at_origin.size() /* layer_bounds */, | 227 bounds_at_origin.size() /* layer_bounds */, |
225 bounds_at_origin /* visible_layer_bounds */, | 228 bounds_at_origin /* visible_layer_bounds */, |
226 bounds_at_origin /* clip_rect */, false /* is_clipped */, | 229 bounds_at_origin /* clip_rect */, false /* is_clipped */, |
227 combined_opacity, SkXfermode::kSrcOver_Mode, | 230 combined_opacity, SkXfermode::kSrcOver_Mode, |
228 0 /* sorting-context_id */); | 231 0 /* sorting-context_id */); |
229 | 232 |
230 auto* quad = pass->CreateAndAppendDrawQuad<cc::SurfaceDrawQuad>(); | 233 auto* quad = pass->CreateAndAppendDrawQuad<cc::SurfaceDrawQuad>(); |
231 AddOrUpdateSurfaceReference(underlay_surface); | 234 AddOrUpdateSurfaceReference(underlay_compositor_frame_sink); |
232 quad->SetAll(sqs, bounds_at_origin /* rect */, | 235 quad->SetAll(sqs, bounds_at_origin /* rect */, |
233 gfx::Rect() /* opaque_rect */, | 236 gfx::Rect() /* opaque_rect */, |
234 bounds_at_origin /* visible_rect */, true /* needs_blending*/, | 237 bounds_at_origin /* visible_rect */, true /* needs_blending*/, |
235 underlay_surface->GetSurfaceId()); | 238 underlay_compositor_frame_sink->GetSurfaceId()); |
236 DCHECK(!underlay_surface->may_contain_video()); | 239 DCHECK(!underlay_compositor_frame_sink->may_contain_video()); |
237 } | 240 } |
238 } | 241 } |
239 | 242 |
240 void FrameGenerator::AddOrUpdateSurfaceReference( | 243 void FrameGenerator::AddOrUpdateSurfaceReference( |
241 ServerWindowSurface* window_surface) { | 244 ServerWindowCompositorFrameSink* window_surface) { |
242 if (!window_surface->has_frame()) | 245 if (!window_surface->has_frame()) |
243 return; | 246 return; |
244 cc::SurfaceId surface_id = window_surface->GetSurfaceId(); | 247 cc::SurfaceId surface_id = window_surface->GetSurfaceId(); |
245 cc::SurfaceManager* surface_manager = display_compositor_->manager(); | 248 cc::SurfaceManager* surface_manager = display_compositor_->manager(); |
246 auto it = dependencies_.find(surface_id.frame_sink_id()); | 249 auto it = dependencies_.find(surface_id.frame_sink_id()); |
247 if (it == dependencies_.end()) { | 250 if (it == dependencies_.end()) { |
248 cc::Surface* surface = surface_manager->GetSurfaceForId(surface_id); | 251 cc::Surface* surface = surface_manager->GetSurfaceForId(surface_id); |
249 if (!surface) { | 252 if (!surface) { |
250 LOG(ERROR) << "Attempting to add dependency to nonexistent surface " | 253 LOG(ERROR) << "Attempting to add dependency to nonexistent surface " |
251 << surface_id.ToString(); | 254 << surface_id.ToString(); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
298 cc::SurfaceManager* surface_manager = display_compositor_->manager(); | 301 cc::SurfaceManager* surface_manager = display_compositor_->manager(); |
299 std::vector<uint32_t> sequences; | 302 std::vector<uint32_t> sequences; |
300 for (auto& dependency : dependencies_) | 303 for (auto& dependency : dependencies_) |
301 sequences.push_back(dependency.second.sequence.sequence); | 304 sequences.push_back(dependency.second.sequence.sequence); |
302 surface_manager->DidSatisfySequences(frame_sink_id_, &sequences); | 305 surface_manager->DidSatisfySequences(frame_sink_id_, &sequences); |
303 dependencies_.clear(); | 306 dependencies_.clear(); |
304 } | 307 } |
305 | 308 |
306 void FrameGenerator::OnWindowDestroying(ServerWindow* window) { | 309 void FrameGenerator::OnWindowDestroying(ServerWindow* window) { |
307 window->RemoveObserver(this); | 310 window->RemoveObserver(this); |
308 ServerWindowSurfaceManager* surface_manager = window->surface_manager(); | 311 ServerWindowCompositorFrameSinkManager* surface_manager = |
312 window->compositor_frame_sink_manager(); | |
309 // If FrameGenerator was observing |window|, then that means it had a surface | 313 // If FrameGenerator was observing |window|, then that means it had a surface |
310 // at some point in time and should have a ServerWindowSurfaceManager. | 314 // at some point in time and should have a |
315 // ServerWindowCompositorFrameSinkManager. | |
311 DCHECK(surface_manager); | 316 DCHECK(surface_manager); |
312 ServerWindowSurface* default_surface = surface_manager->GetDefaultSurface(); | 317 ServerWindowCompositorFrameSink* default_compositor_frame_sink = |
313 if (default_surface) | 318 surface_manager->GetDefaultCompositorFrameSink(); |
314 ReleaseFrameSinkReference(default_surface->frame_sink_id()); | 319 if (default_compositor_frame_sink) |
315 ServerWindowSurface* underlay_surface = surface_manager->GetUnderlaySurface(); | 320 ReleaseFrameSinkReference(default_compositor_frame_sink->frame_sink_id()); |
316 if (underlay_surface) | 321 ServerWindowCompositorFrameSink* underlay_compositor_frame_sink = |
317 ReleaseFrameSinkReference(underlay_surface->frame_sink_id()); | 322 surface_manager->GetUnderlayCompositorFrameSink(); |
323 if (underlay_compositor_frame_sink) | |
324 ReleaseFrameSinkReference(underlay_compositor_frame_sink->frame_sink_id()); | |
318 } | 325 } |
319 | 326 |
320 } // namespace ws | 327 } // namespace ws |
321 | 328 |
322 } // namespace ui | 329 } // namespace ui |
OLD | NEW |