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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/containers/adapters.h" | 9 #include "base/containers/adapters.h" |
10 #include "cc/output/compositor_frame.h" | 10 #include "cc/output/compositor_frame.h" |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 } | 152 } |
153 frame.metadata.device_scale_factor = device_scale_factor_; | 153 frame.metadata.device_scale_factor = device_scale_factor_; |
154 | 154 |
155 return frame; | 155 return frame; |
156 } | 156 } |
157 | 157 |
158 void FrameGenerator::DrawWindow(cc::RenderPass* pass, ServerWindow* window) { | 158 void FrameGenerator::DrawWindow(cc::RenderPass* pass, ServerWindow* window) { |
159 if (!window || !window->visible()) | 159 if (!window || !window->visible()) |
160 return; | 160 return; |
161 | 161 |
162 if (!window->compositor_frame_sink_manager() || | 162 if (!window->compositor_frame_sink_manager()) |
163 !window->compositor_frame_sink_manager()->ShouldDraw()) | |
164 return; | 163 return; |
165 | 164 |
166 cc::SurfaceId default_surface_id = | 165 cc::SurfaceId default_surface_id = |
167 window->compositor_frame_sink_manager()->GetLatestSurfaceId( | 166 window->compositor_frame_sink_manager()->GetLatestSurfaceId(); |
168 mojom::CompositorFrameSinkType::DEFAULT); | |
169 | 167 |
170 if (!default_surface_id.is_valid()) | 168 if (!default_surface_id.is_valid()) |
171 return; | 169 return; |
172 | 170 |
173 gfx::Transform quad_to_target_transform; | 171 gfx::Transform quad_to_target_transform; |
174 quad_to_target_transform.Translate(window->bounds().x(), | 172 quad_to_target_transform.Translate(window->bounds().x(), |
175 window->bounds().y()); | 173 window->bounds().y()); |
176 | 174 |
177 cc::SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); | 175 cc::SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); |
178 | 176 |
(...skipping 12 matching lines...) Expand all Loading... |
191 default_surface_id); | 189 default_surface_id); |
192 } | 190 } |
193 | 191 |
194 cc::SurfaceId FrameGenerator::FindParentSurfaceId(ServerWindow* window) { | 192 cc::SurfaceId FrameGenerator::FindParentSurfaceId(ServerWindow* window) { |
195 if (window == root_window_) | 193 if (window == root_window_) |
196 return root_window_->delegate()->GetRootSurfaceId(); | 194 return root_window_->delegate()->GetRootSurfaceId(); |
197 | 195 |
198 // The root window holds the parent SurfaceId. This SurfaceId will have an | 196 // The root window holds the parent SurfaceId. This SurfaceId will have an |
199 // invalid LocalFrameId before FrameGenerator has submitted a CompositorFrame. | 197 // invalid LocalFrameId before FrameGenerator has submitted a CompositorFrame. |
200 // After the first frame is submitted it will always be a valid SurfaceId. | 198 // After the first frame is submitted it will always be a valid SurfaceId. |
201 return root_window_->compositor_frame_sink_manager()->GetLatestSurfaceId( | 199 return root_window_->compositor_frame_sink_manager()->GetLatestSurfaceId(); |
202 mojom::CompositorFrameSinkType::DEFAULT); | |
203 } | 200 } |
204 | 201 |
205 void FrameGenerator::AddSurfaceReference(const cc::SurfaceId& parent_id, | 202 void FrameGenerator::AddSurfaceReference(const cc::SurfaceId& parent_id, |
206 const cc::SurfaceId& child_id) { | 203 const cc::SurfaceId& child_id) { |
207 DCHECK_NE(parent_id, child_id); | 204 DCHECK_NE(parent_id, child_id); |
208 | 205 |
209 // Add new reference from parent to surface and record reference. | 206 // Add new reference from parent to surface and record reference. |
210 cc::SurfaceReference ref(parent_id, child_id); | 207 cc::SurfaceReference ref(parent_id, child_id); |
211 active_references_[child_id.frame_sink_id()] = ref; | 208 active_references_[child_id.frame_sink_id()] = ref; |
212 references_to_add_.push_back(ref); | 209 references_to_add_.push_back(ref); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 | 283 |
287 void FrameGenerator::OnWindowDestroying(ServerWindow* window) { | 284 void FrameGenerator::OnWindowDestroying(ServerWindow* window) { |
288 Remove(window); | 285 Remove(window); |
289 ServerWindowCompositorFrameSinkManager* compositor_frame_sink_manager = | 286 ServerWindowCompositorFrameSinkManager* compositor_frame_sink_manager = |
290 window->compositor_frame_sink_manager(); | 287 window->compositor_frame_sink_manager(); |
291 // If FrameGenerator was observing |window|, then that means it had a | 288 // If FrameGenerator was observing |window|, then that means it had a |
292 // CompositorFrame at some point in time and should have a | 289 // CompositorFrame at some point in time and should have a |
293 // ServerWindowCompositorFrameSinkManager. | 290 // ServerWindowCompositorFrameSinkManager. |
294 DCHECK(compositor_frame_sink_manager); | 291 DCHECK(compositor_frame_sink_manager); |
295 | 292 |
296 cc::SurfaceId default_surface_id = | 293 cc::SurfaceId surface_id = |
297 window->compositor_frame_sink_manager()->GetLatestSurfaceId( | 294 window->compositor_frame_sink_manager()->GetLatestSurfaceId(); |
298 mojom::CompositorFrameSinkType::DEFAULT); | 295 if (surface_id.is_valid()) |
299 if (default_surface_id.is_valid()) | 296 RemoveFrameSinkReference(surface_id.frame_sink_id()); |
300 RemoveFrameSinkReference(default_surface_id.frame_sink_id()); | |
301 | |
302 cc::SurfaceId underlay_surface_id = | |
303 window->compositor_frame_sink_manager()->GetLatestSurfaceId( | |
304 mojom::CompositorFrameSinkType::UNDERLAY); | |
305 if (underlay_surface_id.is_valid()) | |
306 RemoveFrameSinkReference(underlay_surface_id.frame_sink_id()); | |
307 } | 297 } |
308 | 298 |
309 } // namespace ws | 299 } // namespace ws |
310 | 300 |
311 } // namespace ui | 301 } // namespace ui |
OLD | NEW |