| 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 "cc/output/compositor_frame.h" |
| 12 #include "cc/ipc/display_compositor.mojom.h" | |
| 13 #include "cc/output/compositor_frame_sink_client.h" | 12 #include "cc/output/compositor_frame_sink_client.h" |
| 14 #include "cc/scheduler/begin_frame_source.h" | 13 #include "cc/scheduler/begin_frame_source.h" |
| 15 #include "cc/surfaces/frame_sink_id.h" | |
| 16 #include "cc/surfaces/local_surface_id_allocator.h" | |
| 17 #include "cc/surfaces/surface_id.h" | 14 #include "cc/surfaces/surface_id.h" |
| 18 #include "cc/surfaces/surface_reference.h" | 15 #include "cc/surfaces/surface_info.h" |
| 19 #include "services/ui/public/interfaces/window_tree_constants.mojom.h" | |
| 20 #include "ui/gfx/geometry/rect.h" | 16 #include "ui/gfx/geometry/rect.h" |
| 21 #include "ui/gfx/native_widget_types.h" | |
| 22 | 17 |
| 23 namespace cc { | 18 namespace cc { |
| 24 class CompositorFrameSink; | 19 class CompositorFrameSink; |
| 25 class RenderPass; | 20 class RenderPass; |
| 26 } | 21 } |
| 27 | 22 |
| 28 namespace ui { | 23 namespace ui { |
| 29 namespace ws { | 24 namespace ws { |
| 30 | 25 |
| 31 class ServerWindow; | |
| 32 | |
| 33 // Responsible for redrawing the display in response to the redraw requests by | 26 // Responsible for redrawing the display in response to the redraw requests by |
| 34 // submitting CompositorFrames to the owned CompositorFrameSink. | 27 // submitting CompositorFrames to the owned CompositorFrameSink. |
| 35 class FrameGenerator : public cc::CompositorFrameSinkClient, | 28 class FrameGenerator : public cc::CompositorFrameSinkClient, |
| 36 public cc::BeginFrameObserver { | 29 public cc::BeginFrameObserver { |
| 37 public: | 30 public: |
| 38 FrameGenerator( | 31 explicit FrameGenerator( |
| 39 ServerWindow* root_window, | |
| 40 std::unique_ptr<cc::CompositorFrameSink> compositor_frame_sink); | 32 std::unique_ptr<cc::CompositorFrameSink> compositor_frame_sink); |
| 41 ~FrameGenerator() override; | 33 ~FrameGenerator() override; |
| 42 | 34 |
| 43 void SetDeviceScaleFactor(float device_scale_factor); | 35 void SetDeviceScaleFactor(float device_scale_factor); |
| 44 void SetHighContrastMode(bool enabled); | 36 void SetHighContrastMode(bool enabled); |
| 45 | 37 |
| 46 // Updates the WindowManager's SurfaceInfo. | 38 // Updates the WindowManager's SurfaceInfo. |
| 47 void OnSurfaceCreated(const cc::SurfaceInfo& surface_info); | 39 void OnSurfaceCreated(const cc::SurfaceInfo& surface_info); |
| 48 | 40 |
| 49 void OnWindowDamaged(); | 41 void OnWindowDamaged(); |
| 42 void OnWindowSizeChanged(const gfx::Size& pixel_size); |
| 50 | 43 |
| 51 private: | 44 private: |
| 52 // cc::CompositorFrameSinkClient implementation: | 45 // cc::CompositorFrameSinkClient implementation: |
| 53 void SetBeginFrameSource(cc::BeginFrameSource* source) override; | 46 void SetBeginFrameSource(cc::BeginFrameSource* source) override; |
| 54 void ReclaimResources(const cc::ReturnedResourceArray& resources) override; | 47 void ReclaimResources(const cc::ReturnedResourceArray& resources) override; |
| 55 void SetTreeActivationCallback(const base::Closure& callback) override; | 48 void SetTreeActivationCallback(const base::Closure& callback) override; |
| 56 void DidReceiveCompositorFrameAck() override; | 49 void DidReceiveCompositorFrameAck() override; |
| 57 void DidLoseCompositorFrameSink() override; | 50 void DidLoseCompositorFrameSink() override; |
| 58 void OnDraw(const gfx::Transform& transform, | 51 void OnDraw(const gfx::Transform& transform, |
| 59 const gfx::Rect& viewport, | 52 const gfx::Rect& viewport, |
| 60 bool resourceless_software_draw) override; | 53 bool resourceless_software_draw) override; |
| 61 void SetMemoryPolicy(const cc::ManagedMemoryPolicy& policy) override; | 54 void SetMemoryPolicy(const cc::ManagedMemoryPolicy& policy) override; |
| 62 void SetExternalTilePriorityConstraints( | 55 void SetExternalTilePriorityConstraints( |
| 63 const gfx::Rect& viewport_rect, | 56 const gfx::Rect& viewport_rect, |
| 64 const gfx::Transform& transform) override; | 57 const gfx::Transform& transform) override; |
| 65 | 58 |
| 66 // cc::BeginFrameObserver implementation: | 59 // cc::BeginFrameObserver implementation: |
| 67 void OnBeginFrame(const cc::BeginFrameArgs& args) override; | 60 void OnBeginFrame(const cc::BeginFrameArgs& args) override; |
| 68 const cc::BeginFrameArgs& LastUsedBeginFrameArgs() const override; | 61 const cc::BeginFrameArgs& LastUsedBeginFrameArgs() const override; |
| 69 void OnBeginFrameSourcePausedChanged(bool paused) override; | 62 void OnBeginFrameSourcePausedChanged(bool paused) override; |
| 70 | 63 |
| 71 // Generates the CompositorFrame. | 64 // Generates the CompositorFrame. |
| 72 cc::CompositorFrame GenerateCompositorFrame(const gfx::Rect& output_rect); | 65 cc::CompositorFrame GenerateCompositorFrame(); |
| 73 | 66 |
| 74 // DrawWindow creates SurfaceDrawQuad for the window manager and appends it to | 67 // DrawWindow creates SurfaceDrawQuad for the window manager and appends it to |
| 75 // the provided cc::RenderPass. | 68 // the provided cc::RenderPass. |
| 76 void DrawWindow(cc::RenderPass* pass); | 69 void DrawWindow(cc::RenderPass* pass); |
| 77 | 70 |
| 78 // SetNeedsBeginFrame sets observing_begin_frames_ and add/remove | 71 // SetNeedsBeginFrame sets observing_begin_frames_ and add/remove |
| 79 // FrameGenerator as an observer to/from begin_frame_source_ accordingly. | 72 // FrameGenerator as an observer to/from begin_frame_source_ accordingly. |
| 80 void SetNeedsBeginFrame(bool needs_begin_frame); | 73 void SetNeedsBeginFrame(bool needs_begin_frame); |
| 81 | 74 |
| 82 ServerWindow* const root_window_; | |
| 83 float device_scale_factor_ = 1.f; | 75 float device_scale_factor_ = 1.f; |
| 76 gfx::Size pixel_size_; |
| 84 | 77 |
| 85 std::unique_ptr<cc::CompositorFrameSink> compositor_frame_sink_; | 78 std::unique_ptr<cc::CompositorFrameSink> compositor_frame_sink_; |
| 86 cc::BeginFrameArgs last_begin_frame_args_; | 79 cc::BeginFrameArgs last_begin_frame_args_; |
| 87 cc::BeginFrameAck current_begin_frame_ack_; | 80 cc::BeginFrameAck current_begin_frame_ack_; |
| 88 cc::BeginFrameSource* begin_frame_source_ = nullptr; | 81 cc::BeginFrameSource* begin_frame_source_ = nullptr; |
| 89 bool observing_begin_frames_ = false; | 82 bool observing_begin_frames_ = false; |
| 90 bool high_contrast_mode_enabled_ = false; | 83 bool high_contrast_mode_enabled_ = false; |
| 91 | 84 |
| 92 cc::SurfaceInfo window_manager_surface_info_; | 85 cc::SurfaceInfo window_manager_surface_info_; |
| 93 | 86 |
| 94 DISALLOW_COPY_AND_ASSIGN(FrameGenerator); | 87 DISALLOW_COPY_AND_ASSIGN(FrameGenerator); |
| 95 }; | 88 }; |
| 96 | 89 |
| 97 } // namespace ws | 90 } // namespace ws |
| 98 | 91 |
| 99 } // namespace ui | 92 } // namespace ui |
| 100 | 93 |
| 101 #endif // SERVICES_UI_WS_FRAME_GENERATOR_H_ | 94 #endif // SERVICES_UI_WS_FRAME_GENERATOR_H_ |
| OLD | NEW |