| 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 "mojo/public/cpp/bindings/binding.h" | 14 #include "mojo/public/cpp/bindings/binding.h" |
| 15 #include "services/ui/public/interfaces/window_tree.mojom.h" | 15 #include "services/ui/public/interfaces/window_tree.mojom.h" |
| 16 | 16 |
| 17 namespace ui { | 17 namespace ui { |
| 18 namespace ws { | 18 namespace ws { |
| 19 | 19 |
| 20 class ServerWindow; | 20 class ServerWindow; |
| 21 class ServerWindowSurface; | 21 class ServerWindowCompositorFrameSink; |
| 22 class ServerWindowSurfaceManagerTestApi; | 22 class ServerWindowCompositorFrameSinkManagerTestApi; |
| 23 | 23 |
| 24 // ServerWindowSurfaceManager tracks the surfaces associated with a | 24 // ServerWindowCompositorFrameSinkManager tracks the surfaces associated with a |
| 25 // ServerWindow. | 25 // ServerWindow. |
| 26 class ServerWindowSurfaceManager { | 26 class ServerWindowCompositorFrameSinkManager { |
| 27 public: | 27 public: |
| 28 explicit ServerWindowSurfaceManager(ServerWindow* window); | 28 explicit ServerWindowCompositorFrameSinkManager(ServerWindow* window); |
| 29 ~ServerWindowSurfaceManager(); | 29 ~ServerWindowCompositorFrameSinkManager(); |
| 30 | 30 |
| 31 // Returns true if the surfaces from this manager should be drawn. | 31 // Returns true if the surfaces from this manager should be drawn. |
| 32 bool ShouldDraw(); | 32 bool ShouldDraw(); |
| 33 | 33 |
| 34 // Creates a new surface of the specified type, replacing the existing one of | 34 // Creates a new surface of the specified type, replacing the existing one of |
| 35 // the specified type. | 35 // the specified type. |
| 36 void CreateSurface( | 36 void CreateCompositorFrameSink( |
| 37 mojom::SurfaceType surface_type, | 37 mojom::CompositorFrameSinkType surface_type, |
| 38 mojo::InterfaceRequest<cc::mojom::MojoCompositorFrameSink> request, | 38 mojo::InterfaceRequest<cc::mojom::MojoCompositorFrameSink> request, |
| 39 cc::mojom::MojoCompositorFrameSinkClientPtr client); | 39 cc::mojom::MojoCompositorFrameSinkClientPtr client); |
| 40 | 40 |
| 41 ServerWindow* window() { return window_; } | 41 ServerWindow* window() { return window_; } |
| 42 | 42 |
| 43 ServerWindowSurface* GetDefaultSurface() const; | 43 ServerWindowCompositorFrameSink* GetDefaultCompositorFrameSink() const; |
| 44 ServerWindowSurface* GetUnderlaySurface() const; | 44 ServerWindowCompositorFrameSink* GetUnderlayCompositorFrameSink() const; |
| 45 ServerWindowSurface* GetSurfaceByType(mojom::SurfaceType type) const; | 45 ServerWindowCompositorFrameSink* GetCompositorFrameSinkByType( |
| 46 bool HasSurfaceOfType(mojom::SurfaceType type) const; | 46 mojom::CompositorFrameSinkType type) const; |
| 47 bool HasAnySurface() const; | 47 bool HasCompositorFrameSinkOfType(mojom::CompositorFrameSinkType type) const; |
| 48 bool HasAnyCompositorFrameSink() const; |
| 48 | 49 |
| 49 cc::SurfaceManager* GetSurfaceManager(); | 50 cc::SurfaceManager* GetCompositorFrameSinkManager(); |
| 50 | 51 |
| 51 private: | 52 private: |
| 52 friend class ServerWindowSurfaceManagerTestApi; | 53 friend class ServerWindowCompositorFrameSinkManagerTestApi; |
| 53 friend class ServerWindowSurface; | 54 friend class ServerWindowCompositorFrameSink; |
| 54 | 55 |
| 55 // Returns true if a surface of |type| has been set and its size is greater | 56 // Returns true if a CompositorFrameSink of |type| has been set and has |
| 56 // than the size of the window. | 57 // received a frame that is greater than the size of the window. |
| 57 bool IsSurfaceReadyAndNonEmpty(mojom::SurfaceType type) const; | 58 bool IsCompositorFrameSinkReadyAndNonEmpty( |
| 59 mojom::CompositorFrameSinkType type) const; |
| 58 | 60 |
| 59 ServerWindow* window_; | 61 ServerWindow* window_; |
| 60 | 62 |
| 61 using TypeToSurfaceMap = | 63 using TypeToCompositorFrameSinkMap = |
| 62 std::map<mojom::SurfaceType, std::unique_ptr<ServerWindowSurface>>; | 64 std::map<mojom::CompositorFrameSinkType, |
| 65 std::unique_ptr<ServerWindowCompositorFrameSink>>; |
| 63 | 66 |
| 64 TypeToSurfaceMap type_to_surface_map_; | 67 TypeToCompositorFrameSinkMap type_to_compositor_frame_sink_map_; |
| 65 | 68 |
| 66 // While true the window is not drawn. This is initially true if the window | 69 // While true the window is not drawn. This is initially true if the window |
| 67 // has the property |kWaitForUnderlay_Property|. This is set to false once | 70 // has the property |kWaitForUnderlay_Property|. This is set to false once |
| 68 // the underlay and default surface have been set *and* their size is at | 71 // the underlay and default surface have been set *and* their size is at |
| 69 // least that of the window. Ideally we would wait for sizes to match, but | 72 // least that of the window. Ideally we would wait for sizes to match, but |
| 70 // the underlay is not necessarily as big as the window. | 73 // the underlay is not necessarily as big as the window. |
| 71 bool waiting_for_initial_frames_; | 74 bool waiting_for_initial_frames_; |
| 72 | 75 |
| 73 DISALLOW_COPY_AND_ASSIGN(ServerWindowSurfaceManager); | 76 DISALLOW_COPY_AND_ASSIGN(ServerWindowCompositorFrameSinkManager); |
| 74 }; | 77 }; |
| 75 | 78 |
| 76 } // namespace ws | 79 } // namespace ws |
| 77 } // namespace ui | 80 } // namespace ui |
| 78 | 81 |
| 79 #endif // SERVICES_UI_WS_SERVER_WINDOW_SURFACE_MANAGER_H_ | 82 #endif // SERVICES_UI_WS_SERVER_WINDOW_SURFACE_MANAGER_H_ |
| OLD | NEW |