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 SERVICES_UI_WS_SERVER_WINDOW_COMPOSITOR_FRAME_SINK_MANAGER_H_ | 5 #ifndef SERVICES_UI_WS_SERVER_WINDOW_COMPOSITOR_FRAME_SINK_MANAGER_H_ |
6 #define SERVICES_UI_WS_SERVER_WINDOW_COMPOSITOR_FRAME_SINK_MANAGER_H_ | 6 #define SERVICES_UI_WS_SERVER_WINDOW_COMPOSITOR_FRAME_SINK_MANAGER_H_ |
7 | 7 |
8 #include <map> | |
9 | |
10 #include "base/macros.h" | 8 #include "base/macros.h" |
11 #include "cc/ipc/compositor_frame.mojom.h" | 9 #include "cc/ipc/compositor_frame.mojom.h" |
12 #include "cc/ipc/display_compositor.mojom.h" | 10 #include "cc/ipc/display_compositor.mojom.h" |
13 #include "cc/output/context_provider.h" | 11 #include "cc/output/context_provider.h" |
14 #include "cc/surfaces/surface_id.h" | 12 #include "cc/surfaces/surface_id.h" |
15 #include "mojo/public/cpp/bindings/binding.h" | 13 #include "mojo/public/cpp/bindings/binding.h" |
16 #include "services/ui/public/interfaces/window_tree.mojom.h" | 14 #include "services/ui/public/interfaces/window_tree.mojom.h" |
17 | 15 |
18 namespace ui { | 16 namespace ui { |
19 namespace ws { | 17 namespace ws { |
(...skipping 11 matching lines...) Expand all Loading... |
31 | 29 |
32 cc::SurfaceInfo latest_submitted_surface_info; | 30 cc::SurfaceInfo latest_submitted_surface_info; |
33 cc::mojom::MojoCompositorFrameSinkPrivatePtr compositor_frame_sink; | 31 cc::mojom::MojoCompositorFrameSinkPrivatePtr compositor_frame_sink; |
34 cc::mojom::MojoCompositorFrameSinkPrivateRequest | 32 cc::mojom::MojoCompositorFrameSinkPrivateRequest |
35 pending_compositor_frame_sink_request; | 33 pending_compositor_frame_sink_request; |
36 cc::FrameSinkId frame_sink_id; | 34 cc::FrameSinkId frame_sink_id; |
37 }; | 35 }; |
38 | 36 |
39 // ServerWindowCompositorFrameSinkManager tracks the surfaces associated with a | 37 // ServerWindowCompositorFrameSinkManager tracks the surfaces associated with a |
40 // ServerWindow. | 38 // ServerWindow. |
41 // TODO(fsamuel): Delete this once window decorations are managed in the window | |
42 // manager. | |
43 class ServerWindowCompositorFrameSinkManager { | 39 class ServerWindowCompositorFrameSinkManager { |
44 public: | 40 public: |
45 explicit ServerWindowCompositorFrameSinkManager(ServerWindow* window); | 41 explicit ServerWindowCompositorFrameSinkManager(ServerWindow* window); |
46 ~ServerWindowCompositorFrameSinkManager(); | 42 ~ServerWindowCompositorFrameSinkManager(); |
47 | 43 |
48 // Creates a new CompositorFrameSink of the specified type, replacing the | 44 // Creates a new CompositorFrameSink of the specified type, replacing the |
49 // existing one of the specified type. | 45 // existing one of the specified type. |
50 void CreateDisplayCompositorFrameSink( | 46 void CreateDisplayCompositorFrameSink( |
51 gfx::AcceleratedWidget widget, | 47 gfx::AcceleratedWidget widget, |
52 cc::mojom::MojoCompositorFrameSinkRequest request, | 48 cc::mojom::MojoCompositorFrameSinkRequest request, |
53 cc::mojom::MojoCompositorFrameSinkClientPtr client, | 49 cc::mojom::MojoCompositorFrameSinkClientPtr client, |
54 cc::mojom::DisplayPrivateRequest display_private_request); | 50 cc::mojom::DisplayPrivateRequest display_private_request); |
| 51 |
55 void CreateOffscreenCompositorFrameSink( | 52 void CreateOffscreenCompositorFrameSink( |
56 mojom::CompositorFrameSinkType compositor_frame_sink_type, | |
57 cc::mojom::MojoCompositorFrameSinkRequest request, | 53 cc::mojom::MojoCompositorFrameSinkRequest request, |
58 cc::mojom::MojoCompositorFrameSinkClientPtr client); | 54 cc::mojom::MojoCompositorFrameSinkClientPtr client); |
59 | 55 |
60 // Adds the provided |frame_sink_id| to this ServerWindow's associated | 56 // Adds the provided |frame_sink_id| to this ServerWindow's associated |
61 // CompositorFrameSink if possible. If this ServerWindow does not have | 57 // CompositorFrameSink if possible. If this ServerWindow does not have |
62 // an associated CompositorFrameSink then this method will recursively | 58 // an associated CompositorFrameSink then this method will recursively |
63 // walk up the window hierarchy and register itself with the first ancestor | 59 // walk up the window hierarchy and register itself with the first ancestor |
64 // that has a CompositorFrameSink of the same type. This method returns | 60 // that has a CompositorFrameSink of the same type. This method returns |
65 // the FrameSinkId that is the first composited ancestor of the ServerWindow | 61 // the FrameSinkId that is the first composited ancestor of the ServerWindow |
66 // assocaited with the provided |frame_sink_id|. | 62 // assocaited with the provided |frame_sink_id|. |
67 void AddChildFrameSinkId( | 63 void AddChildFrameSinkId(const cc::FrameSinkId& frame_sink_id); |
68 mojom::CompositorFrameSinkType compositor_frame_sink_type, | 64 void RemoveChildFrameSinkId(const cc::FrameSinkId& frame_sink_id); |
69 const cc::FrameSinkId& frame_sink_id); | |
70 void RemoveChildFrameSinkId( | |
71 mojom::CompositorFrameSinkType compositor_frame_sink_type, | |
72 const cc::FrameSinkId& frame_sink_id); | |
73 | 65 |
74 ServerWindow* window() { return window_; } | 66 ServerWindow* window() { return window_; } |
75 | 67 |
76 bool HasCompositorFrameSinkOfType(mojom::CompositorFrameSinkType type) const; | 68 bool HasCompositorFrameSink() const; |
77 bool HasAnyCompositorFrameSink() const; | |
78 | 69 |
79 gfx::Size GetLatestFrameSize(mojom::CompositorFrameSinkType type) const; | 70 gfx::Size GetLatestFrameSize() const; |
80 cc::SurfaceId GetLatestSurfaceId(mojom::CompositorFrameSinkType type) const; | 71 cc::SurfaceId GetLatestSurfaceId() const; |
81 void SetLatestSurfaceInfo(mojom::CompositorFrameSinkType type, | 72 void SetLatestSurfaceInfo(const cc::SurfaceInfo& surface_info); |
82 const cc::SurfaceInfo& surface_info); | |
83 | 73 |
84 void OnRootChanged(ServerWindow* old_root, ServerWindow* new_root); | 74 void OnRootChanged(ServerWindow* old_root, ServerWindow* new_root); |
85 | 75 |
86 private: | 76 private: |
87 friend class ServerWindowCompositorFrameSinkManagerTestApi; | 77 friend class ServerWindowCompositorFrameSinkManagerTestApi; |
88 friend class ServerWindowCompositorFrameSink; | 78 friend class ServerWindowCompositorFrameSink; |
89 | 79 |
90 // Returns true if a CompositorFrameSink of |type| has been set and has | |
91 // received a frame that is greater than the size of the window. | |
92 bool IsCompositorFrameSinkReadyAndNonEmpty( | |
93 mojom::CompositorFrameSinkType type) const; | |
94 | |
95 void CreateCompositorFrameSinkInternal( | 80 void CreateCompositorFrameSinkInternal( |
96 mojom::CompositorFrameSinkType compositor_frame_sink_type, | |
97 gfx::AcceleratedWidget widget, | 81 gfx::AcceleratedWidget widget, |
98 cc::mojom::MojoCompositorFrameSinkRequest request, | 82 cc::mojom::MojoCompositorFrameSinkRequest request, |
99 cc::mojom::MojoCompositorFrameSinkClientPtr client, | 83 cc::mojom::MojoCompositorFrameSinkClientPtr client, |
100 cc::mojom::DisplayPrivateRequest display_private_request); | 84 cc::mojom::DisplayPrivateRequest display_private_request); |
101 | 85 |
102 ServerWindow* window_; | 86 ServerWindow* window_; |
103 | 87 |
104 using TypeToCompositorFrameSinkMap = | 88 std::unique_ptr<CompositorFrameSinkData> frame_sink_data_; |
105 std::map<mojom::CompositorFrameSinkType, CompositorFrameSinkData>; | |
106 | |
107 TypeToCompositorFrameSinkMap type_to_compositor_frame_sink_map_; | |
108 | 89 |
109 DISALLOW_COPY_AND_ASSIGN(ServerWindowCompositorFrameSinkManager); | 90 DISALLOW_COPY_AND_ASSIGN(ServerWindowCompositorFrameSinkManager); |
110 }; | 91 }; |
111 | 92 |
112 } // namespace ws | 93 } // namespace ws |
113 } // namespace ui | 94 } // namespace ui |
114 | 95 |
115 #endif // SERVICES_UI_WS_SERVER_WINDOW_COMPOSITOR_FRAME_SINK_MANAGER_H_ | 96 #endif // SERVICES_UI_WS_SERVER_WINDOW_COMPOSITOR_FRAME_SINK_MANAGER_H_ |
OLD | NEW |