OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 COMPONENTS_MUS_SURFACES_TOP_LEVEL_DISPLAY_CLIENT_H_ | 5 #ifndef COMPONENTS_MUS_SURFACES_TOP_LEVEL_DISPLAY_CLIENT_H_ |
6 #define COMPONENTS_MUS_SURFACES_TOP_LEVEL_DISPLAY_CLIENT_H_ | 6 #define COMPONENTS_MUS_SURFACES_TOP_LEVEL_DISPLAY_CLIENT_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "cc/surfaces/display_client.h" | 14 #include "cc/surfaces/display_client.h" |
15 #include "cc/surfaces/surface_factory.h" | 15 #include "cc/surfaces/surface_factory.h" |
16 #include "cc/surfaces/surface_factory_client.h" | 16 #include "cc/surfaces/surface_factory_client.h" |
17 #include "components/mus/gles2/gpu_state.h" | 17 #include "components/mus/gles2/gpu_state.h" |
18 #include "components/mus/public/interfaces/window_manager.mojom.h" | 18 #include "components/mus/public/interfaces/window_manager.mojom.h" |
19 #include "components/mus/surfaces/surfaces_context_provider.h" | |
20 #include "components/mus/surfaces/surfaces_context_provider_delegate.h" | |
21 #include "components/mus/surfaces/surfaces_state.h" | 19 #include "components/mus/surfaces/surfaces_state.h" |
22 #include "mojo/public/cpp/bindings/strong_binding.h" | 20 #include "mojo/public/cpp/bindings/strong_binding.h" |
23 #include "ui/gfx/native_widget_types.h" | 21 #include "ui/gfx/native_widget_types.h" |
24 | 22 |
25 namespace cc { | 23 namespace cc { |
26 class CopyOutputResult; | 24 class CopyOutputResult; |
27 class Display; | 25 class Display; |
28 class DisplayScheduler; | 26 class DisplayScheduler; |
29 class SurfaceFactory; | 27 class SurfaceFactory; |
30 class SyntheticBeginFrameSource; | |
31 } | 28 } |
32 | 29 |
33 namespace mus { | 30 namespace mus { |
34 | 31 |
35 class DisplayDelegate; | 32 class DisplayDelegate; |
36 class SurfacesState; | 33 class SurfacesState; |
37 | 34 |
38 // A TopLevelDisplayClient manages the top level surface that is rendered into a | 35 // A TopLevelDisplayClient manages the top level surface that is rendered into a |
39 // provided AcceleratedWidget. Frames are submitted here. New frames are | 36 // provided AcceleratedWidget. Frames are submitted here. New frames are |
40 // scheduled to be generated here based on VSync. | 37 // scheduled to be generated here based on VSync. |
41 class TopLevelDisplayClient : public cc::DisplayClient, | 38 class TopLevelDisplayClient : public cc::DisplayClient, |
42 public cc::SurfaceFactoryClient, | 39 public cc::SurfaceFactoryClient { |
43 public SurfacesContextProviderDelegate { | |
44 public: | 40 public: |
45 TopLevelDisplayClient(gfx::AcceleratedWidget widget, | 41 TopLevelDisplayClient(gfx::AcceleratedWidget widget, |
46 const scoped_refptr<GpuState>& gpu_state, | 42 const scoped_refptr<GpuState>& gpu_state, |
47 const scoped_refptr<SurfacesState>& surfaces_state); | 43 const scoped_refptr<SurfacesState>& surfaces_state); |
48 ~TopLevelDisplayClient() override; | 44 ~TopLevelDisplayClient() override; |
49 | 45 |
50 void SubmitCompositorFrame(std::unique_ptr<cc::CompositorFrame> frame, | 46 void SubmitCompositorFrame(std::unique_ptr<cc::CompositorFrame> frame, |
51 const base::Closure& callback); | 47 const base::Closure& callback); |
52 const cc::SurfaceId& surface_id() const { return cc_id_; } | 48 const cc::SurfaceId& surface_id() const { return cc_id_; } |
53 | 49 |
54 void RequestCopyOfOutput( | 50 void RequestCopyOfOutput( |
55 std::unique_ptr<cc::CopyOutputRequest> output_request); | 51 std::unique_ptr<cc::CopyOutputRequest> output_request); |
56 | 52 |
57 private: | 53 private: |
58 // DisplayClient implementation. | 54 // DisplayClient implementation. |
59 // TODO(rjkroege, fsamuel): This won't work correctly with multiple displays. | |
60 void CommitVSyncParameters(base::TimeTicks timebase, | |
61 base::TimeDelta interval) override; | |
62 void OutputSurfaceLost() override; | 55 void OutputSurfaceLost() override; |
63 void SetMemoryPolicy(const cc::ManagedMemoryPolicy& policy) override; | 56 void SetMemoryPolicy(const cc::ManagedMemoryPolicy& policy) override; |
64 | 57 |
65 // SurfacesContextProviderDelegate: | |
66 void OnVSyncParametersUpdated(int64_t timebase, int64_t interval) override; | |
67 | |
68 // SurfaceFactoryClient implementation. | 58 // SurfaceFactoryClient implementation. |
69 void ReturnResources(const cc::ReturnedResourceArray& resources) override; | 59 void ReturnResources(const cc::ReturnedResourceArray& resources) override; |
70 void SetBeginFrameSource(cc::BeginFrameSource* begin_frame_source) override; | 60 void SetBeginFrameSource(cc::BeginFrameSource* begin_frame_source) override; |
71 | 61 |
72 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 62 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
73 scoped_refptr<SurfacesState> surfaces_state_; | 63 scoped_refptr<SurfacesState> surfaces_state_; |
74 cc::SurfaceFactory factory_; | 64 cc::SurfaceFactory factory_; |
75 cc::SurfaceId cc_id_; | 65 cc::SurfaceId cc_id_; |
76 | 66 |
77 gfx::Size last_submitted_frame_size_; | 67 gfx::Size last_submitted_frame_size_; |
78 std::unique_ptr<cc::CompositorFrame> pending_frame_; | 68 std::unique_ptr<cc::CompositorFrame> pending_frame_; |
79 | 69 |
80 std::unique_ptr<cc::SyntheticBeginFrameSource> synthetic_frame_source_; | |
81 std::unique_ptr<cc::DisplayScheduler> scheduler_; | |
82 std::unique_ptr<cc::Display> display_; | 70 std::unique_ptr<cc::Display> display_; |
83 | 71 |
84 DISALLOW_COPY_AND_ASSIGN(TopLevelDisplayClient); | 72 DISALLOW_COPY_AND_ASSIGN(TopLevelDisplayClient); |
85 }; | 73 }; |
86 | 74 |
87 } // namespace mus | 75 } // namespace mus |
88 | 76 |
89 #endif // COMPONENTS_MUS_SURFACES_TOP_LEVEL_DISPLAY_CLIENT_H_ | 77 #endif // COMPONENTS_MUS_SURFACES_TOP_LEVEL_DISPLAY_CLIENT_H_ |
OLD | NEW |