| 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 #include <unordered_map> | 9 #include <unordered_map> |
| 10 | 10 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 namespace test { | 41 namespace test { |
| 42 class FrameGeneratorTest; | 42 class FrameGeneratorTest; |
| 43 } | 43 } |
| 44 | 44 |
| 45 class FrameGeneratorDelegate; | 45 class FrameGeneratorDelegate; |
| 46 class ServerWindow; | 46 class ServerWindow; |
| 47 class ServerWindowCompositorFrameSink; | 47 class ServerWindowCompositorFrameSink; |
| 48 | 48 |
| 49 // Responsible for redrawing the display in response to the redraw requests by | 49 // Responsible for redrawing the display in response to the redraw requests by |
| 50 // submitting CompositorFrames to the owned CompositorFrameSink. | 50 // submitting CompositorFrames to the owned CompositorFrameSink. |
| 51 class FrameGenerator : public ServerWindowTracker { | 51 class FrameGenerator : public ServerWindowTracker, |
| 52 public cc::mojom::MojoCompositorFrameSinkClient { |
| 52 public: | 53 public: |
| 53 FrameGenerator(FrameGeneratorDelegate* delegate, | 54 FrameGenerator(FrameGeneratorDelegate* delegate, |
| 54 ServerWindow* root_window, | 55 ServerWindow* root_window, |
| 55 scoped_refptr<DisplayCompositor> display_compositor); | 56 scoped_refptr<DisplayCompositor> display_compositor); |
| 56 ~FrameGenerator() override; | 57 ~FrameGenerator() override; |
| 57 | 58 |
| 58 void OnGpuChannelEstablished(scoped_refptr<gpu::GpuChannelHost> gpu_channel); | 59 void OnGpuChannelEstablished(scoped_refptr<gpu::GpuChannelHost> gpu_channel); |
| 59 | 60 |
| 60 // Schedules a redraw for the provided region. | 61 // Schedules a redraw for the provided region. |
| 61 void RequestRedraw(const gfx::Rect& redraw_region); | 62 void RequestRedraw(const gfx::Rect& redraw_region); |
| 62 void OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget); | 63 void OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget); |
| 63 | 64 |
| 64 bool is_frame_pending() { return frame_pending_; } | 65 bool is_frame_pending() { return frame_pending_; } |
| 65 | 66 |
| 66 private: | 67 private: |
| 67 friend class ui::ws::test::FrameGeneratorTest; | 68 friend class ui::ws::test::FrameGeneratorTest; |
| 68 | 69 |
| 70 // cc::mojom::MojoCompositorFrameSinkClient implementation: |
| 71 void DidReceiveCompositorFrameAck() override; |
| 72 void ReclaimResources(const cc::ReturnedResourceArray& resources) override; |
| 73 |
| 69 void WantToDraw(); | 74 void WantToDraw(); |
| 70 | 75 |
| 71 // This method initiates a top level redraw of the display. | 76 // This method initiates a top level redraw of the display. |
| 72 // TODO(fsamuel): In polliwog, this only gets called when the window manager | 77 // TODO(fsamuel): In polliwog, this only gets called when the window manager |
| 73 // changes. | 78 // changes. |
| 74 void Draw(); | 79 void Draw(); |
| 75 | 80 |
| 76 // This is called after the CompositorFrameSink has completed generating a new | 81 // This is called after the CompositorFrameSink has completed generating a new |
| 77 // frame for the display. | 82 // frame for the display. |
| 78 void DidDraw(); | 83 void DidDraw(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 108 // TODO(fsamuel, kylechar): This will go away once we get surface lifetime | 113 // TODO(fsamuel, kylechar): This will go away once we get surface lifetime |
| 109 // management. | 114 // management. |
| 110 void ReleaseAllSurfaceReferences(); | 115 void ReleaseAllSurfaceReferences(); |
| 111 | 116 |
| 112 // ServerWindowObserver implementation. | 117 // ServerWindowObserver implementation. |
| 113 void OnWindowDestroying(ServerWindow* window) override; | 118 void OnWindowDestroying(ServerWindow* window) override; |
| 114 | 119 |
| 115 FrameGeneratorDelegate* delegate_; | 120 FrameGeneratorDelegate* delegate_; |
| 116 scoped_refptr<DisplayCompositor> display_compositor_; | 121 scoped_refptr<DisplayCompositor> display_compositor_; |
| 117 cc::FrameSinkId frame_sink_id_; | 122 cc::FrameSinkId frame_sink_id_; |
| 123 ServerWindow* const root_window_; |
| 118 cc::SurfaceSequenceGenerator surface_sequence_generator_; | 124 cc::SurfaceSequenceGenerator surface_sequence_generator_; |
| 119 scoped_refptr<gpu::GpuChannelHost> gpu_channel_; | 125 scoped_refptr<gpu::GpuChannelHost> gpu_channel_; |
| 120 | 126 |
| 121 std::unique_ptr<DisplayCompositorFrameSink> compositor_frame_sink_; | 127 cc::mojom::MojoCompositorFrameSinkPtr compositor_frame_sink_; |
| 122 gfx::AcceleratedWidget widget_ = gfx::kNullAcceleratedWidget; | 128 gfx::AcceleratedWidget widget_ = gfx::kNullAcceleratedWidget; |
| 123 | 129 |
| 124 // The region that needs to be redrawn next time the compositor frame is | 130 // The region that needs to be redrawn next time the compositor frame is |
| 125 // generated. | 131 // generated. |
| 126 gfx::Rect dirty_rect_; | 132 gfx::Rect dirty_rect_; |
| 127 base::Timer draw_timer_; | 133 base::Timer draw_timer_; |
| 128 bool frame_pending_ = false; | 134 bool frame_pending_ = false; |
| 129 struct SurfaceDependency { | 135 struct SurfaceDependency { |
| 130 cc::LocalFrameId local_frame_id; | 136 cc::LocalFrameId local_frame_id; |
| 131 cc::SurfaceSequence sequence; | 137 cc::SurfaceSequence sequence; |
| 132 }; | 138 }; |
| 133 std::unordered_map<cc::FrameSinkId, SurfaceDependency, cc::FrameSinkIdHash> | 139 std::unordered_map<cc::FrameSinkId, SurfaceDependency, cc::FrameSinkIdHash> |
| 134 dependencies_; | 140 dependencies_; |
| 135 | 141 |
| 142 mojo::Binding<cc::mojom::MojoCompositorFrameSinkClient> binding_; |
| 143 |
| 136 base::WeakPtrFactory<FrameGenerator> weak_factory_; | 144 base::WeakPtrFactory<FrameGenerator> weak_factory_; |
| 137 | 145 |
| 138 DISALLOW_COPY_AND_ASSIGN(FrameGenerator); | 146 DISALLOW_COPY_AND_ASSIGN(FrameGenerator); |
| 139 }; | 147 }; |
| 140 | 148 |
| 141 } // namespace ws | 149 } // namespace ws |
| 142 | 150 |
| 143 } // namespace ui | 151 } // namespace ui |
| 144 | 152 |
| 145 #endif // SERVICES_UI_WS_FRAME_GENERATOR_H_ | 153 #endif // SERVICES_UI_WS_FRAME_GENERATOR_H_ |
| OLD | NEW |