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