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 #ifndef SERVICES_UI_WS_FRAME_GENERATOR_H_ | 5 #ifndef SERVICES_UI_WS_FRAME_GENERATOR_H_ |
6 #define SERVICES_UI_WS_FRAME_GENERATOR_H_ | 6 #define SERVICES_UI_WS_FRAME_GENERATOR_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/timer/timer.h" | 11 #include "base/timer/timer.h" |
12 #include "ui/gfx/geometry/rect.h" | 12 #include "ui/gfx/geometry/rect.h" |
13 #include "ui/gfx/native_widget_types.h" | 13 #include "ui/gfx/native_widget_types.h" |
14 | 14 |
15 namespace cc { | 15 namespace cc { |
16 class CompositorFrame; | 16 class CompositorFrame; |
17 class CopyOutputRequest; | 17 class CopyOutputRequest; |
18 class RenderPass; | 18 class RenderPass; |
19 enum class SurfaceDrawStatus; | 19 enum class SurfaceDrawStatus; |
20 } | 20 } |
21 | 21 |
22 namespace ui { | 22 namespace ui { |
23 | 23 |
24 class DisplayCompositor; | 24 class DisplayCompositor; |
25 class GpuState; | 25 class GpuState; |
26 class SurfacesState; | 26 class SurfacesState; |
27 | 27 |
28 namespace ws { | 28 namespace ws { |
29 | 29 |
| 30 namespace test { |
| 31 class FrameGeneratorTest; |
| 32 } |
| 33 |
30 class FrameGeneratorDelegate; | 34 class FrameGeneratorDelegate; |
31 class ServerWindow; | 35 class ServerWindow; |
32 | 36 |
33 // Responsible for redrawing the display in response to the redraw requests by | 37 // Responsible for redrawing the display in response to the redraw requests by |
34 // submitting CompositorFrames to the owned DisplayCompositor. | 38 // submitting CompositorFrames to the owned DisplayCompositor. |
35 class FrameGenerator { | 39 class FrameGenerator { |
36 public: | 40 public: |
37 FrameGenerator(FrameGeneratorDelegate* delegate, | 41 FrameGenerator(FrameGeneratorDelegate* delegate, |
38 scoped_refptr<GpuState> gpu_state, | 42 scoped_refptr<GpuState> gpu_state, |
39 scoped_refptr<SurfacesState> surfaces_state); | 43 scoped_refptr<SurfacesState> surfaces_state); |
40 virtual ~FrameGenerator(); | 44 virtual ~FrameGenerator(); |
41 | 45 |
42 // Schedules a redraw for the provided region. | 46 // Schedules a redraw for the provided region. |
43 void RequestRedraw(const gfx::Rect& redraw_region); | 47 void RequestRedraw(const gfx::Rect& redraw_region); |
44 void OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget); | 48 void OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget); |
45 void RequestCopyOfOutput( | 49 void RequestCopyOfOutput( |
46 std::unique_ptr<cc::CopyOutputRequest> output_request); | 50 std::unique_ptr<cc::CopyOutputRequest> output_request); |
47 | 51 |
48 bool is_frame_pending() { return frame_pending_; } | 52 bool is_frame_pending() { return frame_pending_; } |
49 | 53 |
50 private: | 54 private: |
| 55 friend class ui::ws::test::FrameGeneratorTest; |
| 56 |
51 void WantToDraw(); | 57 void WantToDraw(); |
52 | 58 |
53 // This method initiates a top level redraw of the display. | 59 // This method initiates a top level redraw of the display. |
54 // TODO(fsamuel): This should use vblank as a signal rather than a timer | 60 // TODO(fsamuel): This should use vblank as a signal rather than a timer |
55 // http://crbug.com/533042 | 61 // http://crbug.com/533042 |
56 void Draw(); | 62 void Draw(); |
57 | 63 |
58 // This is called after the DisplayCompositor has completed generating a new | 64 // This is called after the DisplayCompositor has completed generating a new |
59 // frame for the display. TODO(fsamuel): Idle time processing should happen | 65 // frame for the display. TODO(fsamuel): Idle time processing should happen |
60 // here if there is budget for it. | 66 // here if there is budget for it. |
(...skipping 24 matching lines...) Expand all Loading... |
85 base::WeakPtrFactory<FrameGenerator> weak_factory_; | 91 base::WeakPtrFactory<FrameGenerator> weak_factory_; |
86 | 92 |
87 DISALLOW_COPY_AND_ASSIGN(FrameGenerator); | 93 DISALLOW_COPY_AND_ASSIGN(FrameGenerator); |
88 }; | 94 }; |
89 | 95 |
90 } // namespace ws | 96 } // namespace ws |
91 | 97 |
92 } // namespace ui | 98 } // namespace ui |
93 | 99 |
94 #endif // SERVICES_UI_WS_FRAME_GENERATOR_H_ | 100 #endif // SERVICES_UI_WS_FRAME_GENERATOR_H_ |
OLD | NEW |