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