| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 ServerWindow* root_window, | 55 ServerWindow* root_window, |
| 56 scoped_refptr<DisplayCompositor> display_compositor); | 56 scoped_refptr<DisplayCompositor> display_compositor); |
| 57 ~FrameGenerator() override; | 57 ~FrameGenerator() override; |
| 58 | 58 |
| 59 void OnGpuChannelEstablished(scoped_refptr<gpu::GpuChannelHost> gpu_channel); | 59 void OnGpuChannelEstablished(scoped_refptr<gpu::GpuChannelHost> gpu_channel); |
| 60 | 60 |
| 61 // Schedules a redraw for the provided region. | 61 // Schedules a redraw for the provided region. |
| 62 void RequestRedraw(const gfx::Rect& redraw_region); | 62 void RequestRedraw(const gfx::Rect& redraw_region); |
| 63 void OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget); | 63 void OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget); |
| 64 | 64 |
| 65 bool is_frame_pending() { return frame_pending_; } | |
| 66 | |
| 67 private: | 65 private: |
| 68 friend class ui::ws::test::FrameGeneratorTest; | 66 friend class ui::ws::test::FrameGeneratorTest; |
| 69 | 67 |
| 70 // cc::mojom::MojoCompositorFrameSinkClient implementation: | 68 // cc::mojom::MojoCompositorFrameSinkClient implementation: |
| 71 void DidReceiveCompositorFrameAck() override; | 69 void DidReceiveCompositorFrameAck() override; |
| 70 void OnBeginFrame(const cc::BeginFrameArgs& begin_frame_arags) override; |
| 72 void ReclaimResources(const cc::ReturnedResourceArray& resources) override; | 71 void ReclaimResources(const cc::ReturnedResourceArray& resources) override; |
| 73 | 72 |
| 74 void WantToDraw(); | 73 // Generates the CompositorFrame. |
| 75 | |
| 76 // This method initiates a top level redraw of the display. | |
| 77 // TODO(fsamuel): In polliwog, this only gets called when the window manager | |
| 78 // changes. | |
| 79 void Draw(); | |
| 80 | |
| 81 // Generates the CompositorFrame for the current |dirty_rect_|. | |
| 82 cc::CompositorFrame GenerateCompositorFrame(const gfx::Rect& output_rect); | 74 cc::CompositorFrame GenerateCompositorFrame(const gfx::Rect& output_rect); |
| 83 | 75 |
| 84 // DrawWindowTree recursively visits ServerWindows, creating a SurfaceDrawQuad | 76 // DrawWindowTree recursively visits ServerWindows, creating a SurfaceDrawQuad |
| 85 // for each that lacks one. | 77 // for each that lacks one. |
| 86 void DrawWindowTree(cc::RenderPass* pass, | 78 void DrawWindowTree(cc::RenderPass* pass, |
| 87 ServerWindow* window, | 79 ServerWindow* window, |
| 88 const gfx::Vector2d& parent_to_root_origin_offset, | 80 const gfx::Vector2d& parent_to_root_origin_offset, |
| 89 float opacity); | 81 float opacity); |
| 90 | 82 |
| 91 // Adds a reference to the current cc::Surface of the provided | 83 // Adds a reference to the current cc::Surface of the provided |
| (...skipping 24 matching lines...) Expand all Loading... |
| 116 FrameGeneratorDelegate* delegate_; | 108 FrameGeneratorDelegate* delegate_; |
| 117 scoped_refptr<DisplayCompositor> display_compositor_; | 109 scoped_refptr<DisplayCompositor> display_compositor_; |
| 118 cc::FrameSinkId frame_sink_id_; | 110 cc::FrameSinkId frame_sink_id_; |
| 119 ServerWindow* const root_window_; | 111 ServerWindow* const root_window_; |
| 120 cc::SurfaceSequenceGenerator surface_sequence_generator_; | 112 cc::SurfaceSequenceGenerator surface_sequence_generator_; |
| 121 scoped_refptr<gpu::GpuChannelHost> gpu_channel_; | 113 scoped_refptr<gpu::GpuChannelHost> gpu_channel_; |
| 122 | 114 |
| 123 cc::mojom::MojoCompositorFrameSinkPtr compositor_frame_sink_; | 115 cc::mojom::MojoCompositorFrameSinkPtr compositor_frame_sink_; |
| 124 gfx::AcceleratedWidget widget_ = gfx::kNullAcceleratedWidget; | 116 gfx::AcceleratedWidget widget_ = gfx::kNullAcceleratedWidget; |
| 125 | 117 |
| 126 // The region that needs to be redrawn next time the compositor frame is | |
| 127 // generated. | |
| 128 gfx::Rect dirty_rect_; | |
| 129 base::Timer draw_timer_; | |
| 130 bool frame_pending_ = false; | |
| 131 struct SurfaceDependency { | 118 struct SurfaceDependency { |
| 132 cc::LocalFrameId local_frame_id; | 119 cc::LocalFrameId local_frame_id; |
| 133 cc::SurfaceSequence sequence; | 120 cc::SurfaceSequence sequence; |
| 134 }; | 121 }; |
| 135 std::unordered_map<cc::FrameSinkId, SurfaceDependency, cc::FrameSinkIdHash> | 122 std::unordered_map<cc::FrameSinkId, SurfaceDependency, cc::FrameSinkIdHash> |
| 136 dependencies_; | 123 dependencies_; |
| 137 | 124 |
| 138 mojo::Binding<cc::mojom::MojoCompositorFrameSinkClient> binding_; | 125 mojo::Binding<cc::mojom::MojoCompositorFrameSinkClient> binding_; |
| 139 | 126 |
| 140 base::WeakPtrFactory<FrameGenerator> weak_factory_; | 127 base::WeakPtrFactory<FrameGenerator> weak_factory_; |
| 141 | 128 |
| 142 DISALLOW_COPY_AND_ASSIGN(FrameGenerator); | 129 DISALLOW_COPY_AND_ASSIGN(FrameGenerator); |
| 143 }; | 130 }; |
| 144 | 131 |
| 145 } // namespace ws | 132 } // namespace ws |
| 146 | 133 |
| 147 } // namespace ui | 134 } // namespace ui |
| 148 | 135 |
| 149 #endif // SERVICES_UI_WS_FRAME_GENERATOR_H_ | 136 #endif // SERVICES_UI_WS_FRAME_GENERATOR_H_ |
| OLD | NEW |