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" |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 } | 93 } |
94 | 94 |
95 void FrameGenerator::DidReceiveCompositorFrameAck() {} | 95 void FrameGenerator::DidReceiveCompositorFrameAck() {} |
96 | 96 |
97 void FrameGenerator::OnBeginFrame(const cc::BeginFrameArgs& begin_frame_arags) { | 97 void FrameGenerator::OnBeginFrame(const cc::BeginFrameArgs& begin_frame_arags) { |
98 if (!root_window_->visible()) | 98 if (!root_window_->visible()) |
99 return; | 99 return; |
100 | 100 |
101 // TODO(fsamuel): We should add a trace for generating a top level frame. | 101 // TODO(fsamuel): We should add a trace for generating a top level frame. |
102 cc::CompositorFrame frame(GenerateCompositorFrame(root_window_->bounds())); | 102 cc::CompositorFrame frame(GenerateCompositorFrame(root_window_->bounds())); |
| 103 |
103 if (compositor_frame_sink_) { | 104 if (compositor_frame_sink_) { |
104 compositor_frame_sink_->SubmitCompositorFrame(std::move(frame)); | 105 gfx::Size frame_size = last_submitted_frame_size_; |
| 106 if (!frame.render_pass_list.empty()) |
| 107 frame_size = frame.render_pass_list[0]->output_rect.size(); |
| 108 if (!local_frame_id_.is_valid() || frame_size != last_submitted_frame_size_) |
| 109 local_frame_id_ = id_allocator_.GenerateId(); |
| 110 compositor_frame_sink_->SubmitCompositorFrame(local_frame_id_, |
| 111 std::move(frame)); |
| 112 last_submitted_frame_size_ = frame_size; |
105 | 113 |
106 // Remove dead references after we submit a frame. This has to happen after | 114 // Remove dead references after we submit a frame. This has to happen after |
107 // the frame is submitted otherwise we could end up deleting a surface that | 115 // the frame is submitted otherwise we could end up deleting a surface that |
108 // is still embedded in the last frame. | 116 // is still embedded in the last frame. |
109 // TODO(kylechar): This should be synchronized with SubmitCompositorFrame(). | 117 // TODO(kylechar): This should be synchronized with SubmitCompositorFrame(). |
110 RemoveDeadSurfaceReferences(); | 118 RemoveDeadSurfaceReferences(); |
111 } | 119 } |
112 } | 120 } |
113 | 121 |
114 void FrameGenerator::ReclaimResources( | 122 void FrameGenerator::ReclaimResources( |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 cc::SurfaceId underlay_surface_id = | 353 cc::SurfaceId underlay_surface_id = |
346 window->compositor_frame_sink_manager()->GetLatestSurfaceId( | 354 window->compositor_frame_sink_manager()->GetLatestSurfaceId( |
347 mojom::CompositorFrameSinkType::UNDERLAY); | 355 mojom::CompositorFrameSinkType::UNDERLAY); |
348 if (underlay_surface_id.is_valid()) | 356 if (underlay_surface_id.is_valid()) |
349 RemoveFrameSinkReference(underlay_surface_id.frame_sink_id()); | 357 RemoveFrameSinkReference(underlay_surface_id.frame_sink_id()); |
350 } | 358 } |
351 | 359 |
352 } // namespace ws | 360 } // namespace ws |
353 | 361 |
354 } // namespace ui | 362 } // namespace ui |
OLD | NEW |