| 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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 return; | 163 return; |
| 164 | 164 |
| 165 cc::SurfaceId default_surface_id = | 165 cc::SurfaceId default_surface_id = |
| 166 window->compositor_frame_sink_manager()->GetLatestSurfaceId( | 166 window->compositor_frame_sink_manager()->GetLatestSurfaceId(); |
| 167 mojom::CompositorFrameSinkType::DEFAULT); | |
| 168 | 167 |
| 169 if (!default_surface_id.is_valid()) | 168 if (!default_surface_id.is_valid()) |
| 170 return; | 169 return; |
| 171 | 170 |
| 172 gfx::Transform quad_to_target_transform; | 171 gfx::Transform quad_to_target_transform; |
| 173 quad_to_target_transform.Translate(window->bounds().x(), | 172 quad_to_target_transform.Translate(window->bounds().x(), |
| 174 window->bounds().y()); | 173 window->bounds().y()); |
| 175 | 174 |
| 176 cc::SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); | 175 cc::SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); |
| 177 | 176 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 190 default_surface_id); | 189 default_surface_id); |
| 191 } | 190 } |
| 192 | 191 |
| 193 cc::SurfaceId FrameGenerator::FindParentSurfaceId(ServerWindow* window) { | 192 cc::SurfaceId FrameGenerator::FindParentSurfaceId(ServerWindow* window) { |
| 194 if (window == root_window_) | 193 if (window == root_window_) |
| 195 return root_window_->delegate()->GetRootSurfaceId(); | 194 return root_window_->delegate()->GetRootSurfaceId(); |
| 196 | 195 |
| 197 // 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 |
| 198 // invalid LocalFrameId before FrameGenerator has submitted a CompositorFrame. | 197 // invalid LocalFrameId before FrameGenerator has submitted a CompositorFrame. |
| 199 // 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. |
| 200 return root_window_->compositor_frame_sink_manager()->GetLatestSurfaceId( | 199 return root_window_->compositor_frame_sink_manager()->GetLatestSurfaceId(); |
| 201 mojom::CompositorFrameSinkType::DEFAULT); | |
| 202 } | 200 } |
| 203 | 201 |
| 204 void FrameGenerator::AddSurfaceReference(const cc::SurfaceId& parent_id, | 202 void FrameGenerator::AddSurfaceReference(const cc::SurfaceId& parent_id, |
| 205 const cc::SurfaceId& child_id) { | 203 const cc::SurfaceId& child_id) { |
| 206 DCHECK_NE(parent_id, child_id); | 204 DCHECK_NE(parent_id, child_id); |
| 207 | 205 |
| 208 // Add new reference from parent to surface and record reference. | 206 // Add new reference from parent to surface and record reference. |
| 209 cc::SurfaceReference ref(parent_id, child_id); | 207 cc::SurfaceReference ref(parent_id, child_id); |
| 210 active_references_[child_id.frame_sink_id()] = ref; | 208 active_references_[child_id.frame_sink_id()] = ref; |
| 211 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... |
| 285 | 283 |
| 286 void FrameGenerator::OnWindowDestroying(ServerWindow* window) { | 284 void FrameGenerator::OnWindowDestroying(ServerWindow* window) { |
| 287 Remove(window); | 285 Remove(window); |
| 288 ServerWindowCompositorFrameSinkManager* compositor_frame_sink_manager = | 286 ServerWindowCompositorFrameSinkManager* compositor_frame_sink_manager = |
| 289 window->compositor_frame_sink_manager(); | 287 window->compositor_frame_sink_manager(); |
| 290 // If FrameGenerator was observing |window|, then that means it had a | 288 // If FrameGenerator was observing |window|, then that means it had a |
| 291 // CompositorFrame at some point in time and should have a | 289 // CompositorFrame at some point in time and should have a |
| 292 // ServerWindowCompositorFrameSinkManager. | 290 // ServerWindowCompositorFrameSinkManager. |
| 293 DCHECK(compositor_frame_sink_manager); | 291 DCHECK(compositor_frame_sink_manager); |
| 294 | 292 |
| 295 cc::SurfaceId default_surface_id = | 293 cc::SurfaceId surface_id = |
| 296 window->compositor_frame_sink_manager()->GetLatestSurfaceId( | 294 window->compositor_frame_sink_manager()->GetLatestSurfaceId(); |
| 297 mojom::CompositorFrameSinkType::DEFAULT); | 295 if (surface_id.is_valid()) |
| 298 if (default_surface_id.is_valid()) | 296 RemoveFrameSinkReference(surface_id.frame_sink_id()); |
| 299 RemoveFrameSinkReference(default_surface_id.frame_sink_id()); | |
| 300 | |
| 301 cc::SurfaceId underlay_surface_id = | |
| 302 window->compositor_frame_sink_manager()->GetLatestSurfaceId( | |
| 303 mojom::CompositorFrameSinkType::UNDERLAY); | |
| 304 if (underlay_surface_id.is_valid()) | |
| 305 RemoveFrameSinkReference(underlay_surface_id.frame_sink_id()); | |
| 306 } | 297 } |
| 307 | 298 |
| 308 } // namespace ws | 299 } // namespace ws |
| 309 | 300 |
| 310 } // namespace ui | 301 } // namespace ui |
| OLD | NEW |