| 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 } | 19 } |
| 20 | 20 |
| 21 namespace gpu { |
| 22 class GpuChannelHost; |
| 23 } |
| 24 |
| 21 namespace ui { | 25 namespace ui { |
| 22 | 26 |
| 23 class DisplayCompositor; | 27 class DisplayCompositor; |
| 24 class SurfacesState; | 28 class SurfacesState; |
| 25 | 29 |
| 26 namespace ws { | 30 namespace ws { |
| 27 | 31 |
| 28 namespace test { | 32 namespace test { |
| 29 class FrameGeneratorTest; | 33 class FrameGeneratorTest; |
| 30 } | 34 } |
| 31 | 35 |
| 32 class FrameGeneratorDelegate; | 36 class FrameGeneratorDelegate; |
| 33 class ServerWindow; | 37 class ServerWindow; |
| 34 | 38 |
| 35 // Responsible for redrawing the display in response to the redraw requests by | 39 // Responsible for redrawing the display in response to the redraw requests by |
| 36 // submitting CompositorFrames to the owned DisplayCompositor. | 40 // submitting CompositorFrames to the owned DisplayCompositor. |
| 37 class FrameGenerator { | 41 class FrameGenerator { |
| 38 public: | 42 public: |
| 39 FrameGenerator(FrameGeneratorDelegate* delegate, | 43 FrameGenerator(FrameGeneratorDelegate* delegate, |
| 40 scoped_refptr<SurfacesState> surfaces_state); | 44 scoped_refptr<SurfacesState> surfaces_state); |
| 41 virtual ~FrameGenerator(); | 45 virtual ~FrameGenerator(); |
| 42 | 46 |
| 47 void OnGpuChannelEstablished(scoped_refptr<gpu::GpuChannelHost> gpu_channel); |
| 48 |
| 43 // Schedules a redraw for the provided region. | 49 // Schedules a redraw for the provided region. |
| 44 void RequestRedraw(const gfx::Rect& redraw_region); | 50 void RequestRedraw(const gfx::Rect& redraw_region); |
| 45 void OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget); | 51 void OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget); |
| 46 void RequestCopyOfOutput( | 52 void RequestCopyOfOutput( |
| 47 std::unique_ptr<cc::CopyOutputRequest> output_request); | 53 std::unique_ptr<cc::CopyOutputRequest> output_request); |
| 48 | 54 |
| 49 bool is_frame_pending() { return frame_pending_; } | 55 bool is_frame_pending() { return frame_pending_; } |
| 50 | 56 |
| 51 private: | 57 private: |
| 52 friend class ui::ws::test::FrameGeneratorTest; | 58 friend class ui::ws::test::FrameGeneratorTest; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 70 // DrawWindowTree recursively visits ServerWindows, creating a SurfaceDrawQuad | 76 // DrawWindowTree recursively visits ServerWindows, creating a SurfaceDrawQuad |
| 71 // for each that lacks one. | 77 // for each that lacks one. |
| 72 void DrawWindowTree(cc::RenderPass* pass, | 78 void DrawWindowTree(cc::RenderPass* pass, |
| 73 ServerWindow* window, | 79 ServerWindow* window, |
| 74 const gfx::Vector2d& parent_to_root_origin_offset, | 80 const gfx::Vector2d& parent_to_root_origin_offset, |
| 75 float opacity, | 81 float opacity, |
| 76 bool* may_contain_video) const; | 82 bool* may_contain_video) const; |
| 77 | 83 |
| 78 FrameGeneratorDelegate* delegate_; | 84 FrameGeneratorDelegate* delegate_; |
| 79 scoped_refptr<SurfacesState> surfaces_state_; | 85 scoped_refptr<SurfacesState> surfaces_state_; |
| 86 scoped_refptr<gpu::GpuChannelHost> gpu_channel_; |
| 80 | 87 |
| 81 std::unique_ptr<DisplayCompositor> display_compositor_; | 88 std::unique_ptr<DisplayCompositor> display_compositor_; |
| 89 gfx::AcceleratedWidget widget_ = gfx::kNullAcceleratedWidget; |
| 82 | 90 |
| 83 // The region that needs to be redrawn next time the compositor frame is | 91 // The region that needs to be redrawn next time the compositor frame is |
| 84 // generated. | 92 // generated. |
| 85 gfx::Rect dirty_rect_; | 93 gfx::Rect dirty_rect_; |
| 86 base::Timer draw_timer_; | 94 base::Timer draw_timer_; |
| 87 bool frame_pending_ = false; | 95 bool frame_pending_ = false; |
| 88 bool may_contain_video_ = false; | 96 bool may_contain_video_ = false; |
| 89 | 97 |
| 90 base::WeakPtrFactory<FrameGenerator> weak_factory_; | 98 base::WeakPtrFactory<FrameGenerator> weak_factory_; |
| 91 | 99 |
| 92 DISALLOW_COPY_AND_ASSIGN(FrameGenerator); | 100 DISALLOW_COPY_AND_ASSIGN(FrameGenerator); |
| 93 }; | 101 }; |
| 94 | 102 |
| 95 } // namespace ws | 103 } // namespace ws |
| 96 | 104 |
| 97 } // namespace ui | 105 } // namespace ui |
| 98 | 106 |
| 99 #endif // SERVICES_UI_WS_FRAME_GENERATOR_H_ | 107 #endif // SERVICES_UI_WS_FRAME_GENERATOR_H_ |
| OLD | NEW |