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 "services/ui/surfaces/display_compositor.h" | 13 #include "services/ui/surfaces/display_compositor.h" |
14 #include "services/ui/ws/frame_generator_delegate.h" | 14 #include "services/ui/ws/frame_generator_delegate.h" |
15 #include "services/ui/ws/server_window.h" | 15 #include "services/ui/ws/server_window.h" |
16 #include "services/ui/ws/server_window_surface.h" | 16 #include "services/ui/ws/server_window_surface.h" |
17 #include "services/ui/ws/server_window_surface_manager.h" | 17 #include "services/ui/ws/server_window_surface_manager.h" |
18 | 18 |
19 namespace ui { | 19 namespace ui { |
20 | 20 |
21 namespace ws { | 21 namespace ws { |
22 | 22 |
23 FrameGenerator::FrameGenerator(FrameGeneratorDelegate* delegate, | 23 FrameGenerator::FrameGenerator(FrameGeneratorDelegate* delegate, |
| 24 scoped_refptr<GpuState> gpu_state, |
24 scoped_refptr<SurfacesState> surfaces_state) | 25 scoped_refptr<SurfacesState> surfaces_state) |
25 : delegate_(delegate), | 26 : delegate_(delegate), |
| 27 gpu_state_(gpu_state), |
26 surfaces_state_(surfaces_state), | 28 surfaces_state_(surfaces_state), |
27 draw_timer_(false, false), | 29 draw_timer_(false, false), |
28 weak_factory_(this) { | 30 weak_factory_(this) { |
29 DCHECK(delegate_); | 31 DCHECK(delegate_); |
30 } | 32 } |
31 | 33 |
32 FrameGenerator::~FrameGenerator() { | 34 FrameGenerator::~FrameGenerator() { |
33 // Invalidate WeakPtrs now to avoid callbacks back into the | 35 // Invalidate WeakPtrs now to avoid callbacks back into the |
34 // FrameGenerator during destruction of |display_compositor_|. | 36 // FrameGenerator during destruction of |display_compositor_|. |
35 weak_factory_.InvalidateWeakPtrs(); | 37 weak_factory_.InvalidateWeakPtrs(); |
36 display_compositor_.reset(); | 38 display_compositor_.reset(); |
37 } | 39 } |
38 | 40 |
39 void FrameGenerator::RequestRedraw(const gfx::Rect& redraw_region) { | 41 void FrameGenerator::RequestRedraw(const gfx::Rect& redraw_region) { |
40 dirty_rect_.Union(redraw_region); | 42 dirty_rect_.Union(redraw_region); |
41 WantToDraw(); | 43 WantToDraw(); |
42 } | 44 } |
43 | 45 |
44 void FrameGenerator::OnAcceleratedWidgetAvailable( | 46 void FrameGenerator::OnAcceleratedWidgetAvailable( |
45 gfx::AcceleratedWidget widget) { | 47 gfx::AcceleratedWidget widget) { |
46 if (widget != gfx::kNullAcceleratedWidget) { | 48 if (widget != gfx::kNullAcceleratedWidget) { |
47 display_compositor_.reset(new DisplayCompositor( | 49 display_compositor_.reset( |
48 base::ThreadTaskRunnerHandle::Get(), widget, surfaces_state_)); | 50 new DisplayCompositor(base::ThreadTaskRunnerHandle::Get(), widget, |
| 51 gpu_state_, surfaces_state_)); |
49 } | 52 } |
50 } | 53 } |
51 | 54 |
52 void FrameGenerator::RequestCopyOfOutput( | 55 void FrameGenerator::RequestCopyOfOutput( |
53 std::unique_ptr<cc::CopyOutputRequest> output_request) { | 56 std::unique_ptr<cc::CopyOutputRequest> output_request) { |
54 if (display_compositor_) | 57 if (display_compositor_) |
55 display_compositor_->RequestCopyOfOutput(std::move(output_request)); | 58 display_compositor_->RequestCopyOfOutput(std::move(output_request)); |
56 } | 59 } |
57 | 60 |
58 void FrameGenerator::WantToDraw() { | 61 void FrameGenerator::WantToDraw() { |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 quad->SetAll(sqs, bounds_at_origin /* rect */, | 200 quad->SetAll(sqs, bounds_at_origin /* rect */, |
198 gfx::Rect() /* opaque_rect */, | 201 gfx::Rect() /* opaque_rect */, |
199 bounds_at_origin /* visible_rect */, true /* needs_blending*/, | 202 bounds_at_origin /* visible_rect */, true /* needs_blending*/, |
200 underlay_surface->id()); | 203 underlay_surface->id()); |
201 } | 204 } |
202 } | 205 } |
203 | 206 |
204 } // namespace ws | 207 } // namespace ws |
205 | 208 |
206 } // namespace ui | 209 } // namespace ui |
OLD | NEW |