| 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_SURFACE_MANAGER_H_ | 5 #ifndef SERVICES_UI_WS_SERVER_WINDOW_SURFACE_MANAGER_H_ |
| 6 #define SERVICES_UI_WS_SERVER_WINDOW_SURFACE_MANAGER_H_ | 6 #define SERVICES_UI_WS_SERVER_WINDOW_SURFACE_MANAGER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "cc/ipc/compositor_frame.mojom.h" | 11 #include "cc/ipc/compositor_frame.mojom.h" |
| 12 #include "cc/surfaces/surface_factory.h" | 12 #include "cc/surfaces/surface_factory.h" |
| 13 #include "cc/surfaces/surface_id.h" | 13 #include "cc/surfaces/surface_id.h" |
| 14 #include "cc/surfaces/surface_sequence_generator.h" |
| 14 #include "mojo/public/cpp/bindings/binding.h" | 15 #include "mojo/public/cpp/bindings/binding.h" |
| 15 #include "services/ui/public/interfaces/window_tree.mojom.h" | 16 #include "services/ui/public/interfaces/window_tree.mojom.h" |
| 16 | 17 |
| 17 namespace ui { | 18 namespace ui { |
| 18 namespace ws { | 19 namespace ws { |
| 19 | 20 |
| 20 class ServerWindow; | 21 class ServerWindow; |
| 21 class ServerWindowCompositorFrameSink; | 22 class ServerWindowCompositorFrameSink; |
| 22 class ServerWindowCompositorFrameSinkManagerTestApi; | 23 class ServerWindowCompositorFrameSinkManagerTestApi; |
| 23 | 24 |
| 25 struct CompositorFrameSinkData { |
| 26 CompositorFrameSinkData(); |
| 27 CompositorFrameSinkData(CompositorFrameSinkData&& other); |
| 28 ~CompositorFrameSinkData(); |
| 29 |
| 30 CompositorFrameSinkData& operator=(CompositorFrameSinkData&& other); |
| 31 |
| 32 cc::SurfaceId latest_submitted_surface_id; |
| 33 gfx::Size latest_submitted_frame_size; |
| 34 cc::SurfaceSequenceGenerator surface_sequence_generator; |
| 35 // TODO(fsamuel): This should be a mojo interface. |
| 36 std::unique_ptr<ServerWindowCompositorFrameSink> compositor_frame_sink; |
| 37 }; |
| 38 |
| 24 // ServerWindowCompositorFrameSinkManager tracks the surfaces associated with a | 39 // ServerWindowCompositorFrameSinkManager tracks the surfaces associated with a |
| 25 // ServerWindow. | 40 // ServerWindow. |
| 26 class ServerWindowCompositorFrameSinkManager { | 41 class ServerWindowCompositorFrameSinkManager { |
| 27 public: | 42 public: |
| 28 explicit ServerWindowCompositorFrameSinkManager(ServerWindow* window); | 43 explicit ServerWindowCompositorFrameSinkManager(ServerWindow* window); |
| 29 ~ServerWindowCompositorFrameSinkManager(); | 44 ~ServerWindowCompositorFrameSinkManager(); |
| 30 | 45 |
| 31 // Returns true if the surfaces from this manager should be drawn. | 46 // Returns true if the surfaces from this manager should be drawn. |
| 32 bool ShouldDraw(); | 47 bool ShouldDraw(); |
| 33 | 48 |
| 34 // Creates a new surface of the specified type, replacing the existing one of | 49 // Creates a new surface of the specified type, replacing the existing one of |
| 35 // the specified type. | 50 // the specified type. |
| 36 void CreateCompositorFrameSink( | 51 void CreateCompositorFrameSink( |
| 37 mojom::CompositorFrameSinkType surface_type, | 52 mojom::CompositorFrameSinkType surface_type, |
| 38 mojo::InterfaceRequest<cc::mojom::MojoCompositorFrameSink> request, | 53 mojo::InterfaceRequest<cc::mojom::MojoCompositorFrameSink> request, |
| 39 cc::mojom::MojoCompositorFrameSinkClientPtr client); | 54 cc::mojom::MojoCompositorFrameSinkClientPtr client); |
| 40 | 55 |
| 41 ServerWindow* window() { return window_; } | 56 ServerWindow* window() { return window_; } |
| 42 | 57 |
| 43 ServerWindowCompositorFrameSink* GetDefaultCompositorFrameSink() const; | 58 ServerWindowCompositorFrameSink* GetDefaultCompositorFrameSink() const; |
| 44 ServerWindowCompositorFrameSink* GetUnderlayCompositorFrameSink() const; | 59 ServerWindowCompositorFrameSink* GetUnderlayCompositorFrameSink() const; |
| 45 ServerWindowCompositorFrameSink* GetCompositorFrameSinkByType( | 60 ServerWindowCompositorFrameSink* GetCompositorFrameSinkByType( |
| 46 mojom::CompositorFrameSinkType type) const; | 61 mojom::CompositorFrameSinkType type) const; |
| 47 bool HasCompositorFrameSinkOfType(mojom::CompositorFrameSinkType type) const; | 62 bool HasCompositorFrameSinkOfType(mojom::CompositorFrameSinkType type) const; |
| 48 bool HasAnyCompositorFrameSink() const; | 63 bool HasAnyCompositorFrameSink() const; |
| 49 | 64 |
| 65 // Creates a surface dependency token that expires when the |
| 66 // CompositorFrameSink of type |type| goes away associated with this window. |
| 67 cc::SurfaceSequence CreateSurfaceSequence( |
| 68 mojom::CompositorFrameSinkType type); |
| 69 gfx::Size GetLatestFrameSize(mojom::CompositorFrameSinkType type) const; |
| 70 cc::SurfaceId GetLatestSurfaceId(mojom::CompositorFrameSinkType type) const; |
| 71 void SetLatestSurfaceInfo(mojom::CompositorFrameSinkType type, |
| 72 const cc::SurfaceId& surface_id, |
| 73 const gfx::Size& frame_size); |
| 74 |
| 50 cc::SurfaceManager* GetCompositorFrameSinkManager(); | 75 cc::SurfaceManager* GetCompositorFrameSinkManager(); |
| 51 | 76 |
| 52 private: | 77 private: |
| 53 friend class ServerWindowCompositorFrameSinkManagerTestApi; | 78 friend class ServerWindowCompositorFrameSinkManagerTestApi; |
| 54 friend class ServerWindowCompositorFrameSink; | 79 friend class ServerWindowCompositorFrameSink; |
| 55 | 80 |
| 56 // Returns true if a CompositorFrameSink of |type| has been set and has | 81 // Returns true if a CompositorFrameSink of |type| has been set and has |
| 57 // received a frame that is greater than the size of the window. | 82 // received a frame that is greater than the size of the window. |
| 58 bool IsCompositorFrameSinkReadyAndNonEmpty( | 83 bool IsCompositorFrameSinkReadyAndNonEmpty( |
| 59 mojom::CompositorFrameSinkType type) const; | 84 mojom::CompositorFrameSinkType type) const; |
| 60 | 85 |
| 61 ServerWindow* window_; | 86 ServerWindow* window_; |
| 62 | 87 |
| 63 using TypeToCompositorFrameSinkMap = | 88 using TypeToCompositorFrameSinkMap = |
| 64 std::map<mojom::CompositorFrameSinkType, | 89 std::map<mojom::CompositorFrameSinkType, CompositorFrameSinkData>; |
| 65 std::unique_ptr<ServerWindowCompositorFrameSink>>; | |
| 66 | 90 |
| 67 TypeToCompositorFrameSinkMap type_to_compositor_frame_sink_map_; | 91 TypeToCompositorFrameSinkMap type_to_compositor_frame_sink_map_; |
| 68 | 92 |
| 69 // While true the window is not drawn. This is initially true if the window | 93 // While true the window is not drawn. This is initially true if the window |
| 70 // has the property |kWaitForUnderlay_Property|. This is set to false once | 94 // has the property |kWaitForUnderlay_Property|. This is set to false once |
| 71 // the underlay and default surface have been set *and* their size is at | 95 // the underlay and default surface have been set *and* their size is at |
| 72 // least that of the window. Ideally we would wait for sizes to match, but | 96 // least that of the window. Ideally we would wait for sizes to match, but |
| 73 // the underlay is not necessarily as big as the window. | 97 // the underlay is not necessarily as big as the window. |
| 74 bool waiting_for_initial_frames_; | 98 bool waiting_for_initial_frames_; |
| 75 | 99 |
| 76 DISALLOW_COPY_AND_ASSIGN(ServerWindowCompositorFrameSinkManager); | 100 DISALLOW_COPY_AND_ASSIGN(ServerWindowCompositorFrameSinkManager); |
| 77 }; | 101 }; |
| 78 | 102 |
| 79 } // namespace ws | 103 } // namespace ws |
| 80 } // namespace ui | 104 } // namespace ui |
| 81 | 105 |
| 82 #endif // SERVICES_UI_WS_SERVER_WINDOW_SURFACE_MANAGER_H_ | 106 #endif // SERVICES_UI_WS_SERVER_WINDOW_SURFACE_MANAGER_H_ |
| OLD | NEW |