| 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 |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/timer/timer.h" | 12 #include "base/timer/timer.h" |
| 13 #include "cc/surfaces/frame_sink_id.h" | 13 #include "cc/surfaces/frame_sink_id.h" |
| 14 #include "cc/surfaces/local_frame_id.h" | 14 #include "cc/surfaces/local_frame_id.h" |
| 15 #include "cc/surfaces/surface_sequence.h" | 15 #include "cc/surfaces/surface_sequence.h" |
| 16 #include "cc/surfaces/surface_sequence_generator.h" | 16 #include "cc/surfaces/surface_sequence_generator.h" |
| 17 #include "gpu/ipc/common/surface_handle.h" |
| 17 #include "services/ui/ws/server_window_observer.h" | 18 #include "services/ui/ws/server_window_observer.h" |
| 18 #include "ui/gfx/geometry/rect.h" | 19 #include "ui/gfx/geometry/rect.h" |
| 19 #include "ui/gfx/native_widget_types.h" | 20 #include "ui/gfx/native_widget_types.h" |
| 20 | 21 |
| 21 namespace cc { | 22 namespace cc { |
| 22 class CompositorFrame; | 23 class CompositorFrame; |
| 23 class CopyOutputRequest; | 24 class CopyOutputRequest; |
| 24 class RenderPass; | 25 class RenderPass; |
| 25 class SurfaceId; | 26 class SurfaceId; |
| 26 } | 27 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 52 class FrameGenerator : public ServerWindowObserver { | 53 class FrameGenerator : public ServerWindowObserver { |
| 53 public: | 54 public: |
| 54 FrameGenerator(FrameGeneratorDelegate* delegate, | 55 FrameGenerator(FrameGeneratorDelegate* delegate, |
| 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(gpu::SurfaceHandle widget); |
| 63 void RequestCopyOfOutput( | 64 void RequestCopyOfOutput( |
| 64 std::unique_ptr<cc::CopyOutputRequest> output_request); | 65 std::unique_ptr<cc::CopyOutputRequest> output_request); |
| 65 | 66 |
| 66 bool is_frame_pending() { return frame_pending_; } | 67 bool is_frame_pending() { return frame_pending_; } |
| 67 | 68 |
| 68 private: | 69 private: |
| 69 friend class ui::ws::test::FrameGeneratorTest; | 70 friend class ui::ws::test::FrameGeneratorTest; |
| 70 | 71 |
| 71 void WantToDraw(); | 72 void WantToDraw(); |
| 72 | 73 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 // ServerWindowObserver implementation. | 115 // ServerWindowObserver implementation. |
| 115 void OnWindowDestroying(ServerWindow* window) override; | 116 void OnWindowDestroying(ServerWindow* window) override; |
| 116 | 117 |
| 117 FrameGeneratorDelegate* delegate_; | 118 FrameGeneratorDelegate* delegate_; |
| 118 scoped_refptr<DisplayCompositor> display_compositor_; | 119 scoped_refptr<DisplayCompositor> display_compositor_; |
| 119 cc::FrameSinkId frame_sink_id_; | 120 cc::FrameSinkId frame_sink_id_; |
| 120 cc::SurfaceSequenceGenerator surface_sequence_generator_; | 121 cc::SurfaceSequenceGenerator surface_sequence_generator_; |
| 121 scoped_refptr<gpu::GpuChannelHost> gpu_channel_; | 122 scoped_refptr<gpu::GpuChannelHost> gpu_channel_; |
| 122 | 123 |
| 123 std::unique_ptr<surfaces::CompositorFrameSink> compositor_frame_sink_; | 124 std::unique_ptr<surfaces::CompositorFrameSink> compositor_frame_sink_; |
| 124 gfx::AcceleratedWidget widget_ = gfx::kNullAcceleratedWidget; | 125 gpu::SurfaceHandle widget_ = gpu::kNullSurfaceHandle; |
| 125 | 126 |
| 126 // The region that needs to be redrawn next time the compositor frame is | 127 // The region that needs to be redrawn next time the compositor frame is |
| 127 // generated. | 128 // generated. |
| 128 gfx::Rect dirty_rect_; | 129 gfx::Rect dirty_rect_; |
| 129 base::Timer draw_timer_; | 130 base::Timer draw_timer_; |
| 130 bool frame_pending_ = false; | 131 bool frame_pending_ = false; |
| 131 bool may_contain_video_ = false; | 132 bool may_contain_video_ = false; |
| 132 struct SurfaceDependency { | 133 struct SurfaceDependency { |
| 133 cc::LocalFrameId local_frame_id; | 134 cc::LocalFrameId local_frame_id; |
| 134 cc::SurfaceSequence sequence; | 135 cc::SurfaceSequence sequence; |
| 135 }; | 136 }; |
| 136 std::unordered_map<cc::FrameSinkId, SurfaceDependency, cc::FrameSinkIdHash> | 137 std::unordered_map<cc::FrameSinkId, SurfaceDependency, cc::FrameSinkIdHash> |
| 137 dependencies_; | 138 dependencies_; |
| 138 | 139 |
| 139 base::WeakPtrFactory<FrameGenerator> weak_factory_; | 140 base::WeakPtrFactory<FrameGenerator> weak_factory_; |
| 140 | 141 |
| 141 DISALLOW_COPY_AND_ASSIGN(FrameGenerator); | 142 DISALLOW_COPY_AND_ASSIGN(FrameGenerator); |
| 142 }; | 143 }; |
| 143 | 144 |
| 144 } // namespace ws | 145 } // namespace ws |
| 145 | 146 |
| 146 } // namespace ui | 147 } // namespace ui |
| 147 | 148 |
| 148 #endif // SERVICES_UI_WS_FRAME_GENERATOR_H_ | 149 #endif // SERVICES_UI_WS_FRAME_GENERATOR_H_ |
| OLD | NEW |