| 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_WS_SERVER_WINDOW_SURFACE_H_ | 5 #ifndef COMPONENTS_MUS_WS_SERVER_WINDOW_SURFACE_H_ |
| 6 #define COMPONENTS_MUS_WS_SERVER_WINDOW_SURFACE_H_ | 6 #define COMPONENTS_MUS_WS_SERVER_WINDOW_SURFACE_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "cc/surfaces/surface_factory.h" | 11 #include "cc/surfaces/surface_factory.h" |
| 12 #include "cc/surfaces/surface_factory_client.h" | 12 #include "cc/surfaces/surface_factory_client.h" |
| 13 #include "cc/surfaces/surface_id.h" | 13 #include "cc/surfaces/surface_id.h" |
| 14 #include "cc/surfaces/surface_id_allocator.h" | 14 #include "cc/surfaces/surface_id_allocator.h" |
| 15 #include "components/mus/public/cpp/surfaces/custom_surface_converter.h" | |
| 16 #include "components/mus/public/interfaces/compositor_frame.mojom.h" | 15 #include "components/mus/public/interfaces/compositor_frame.mojom.h" |
| 17 #include "components/mus/public/interfaces/window_tree.mojom.h" | 16 #include "components/mus/public/interfaces/window_tree.mojom.h" |
| 18 #include "components/mus/ws/ids.h" | 17 #include "components/mus/ws/ids.h" |
| 19 #include "mojo/public/cpp/bindings/binding.h" | 18 #include "mojo/public/cpp/bindings/binding.h" |
| 20 | 19 |
| 21 namespace mus { | 20 namespace mus { |
| 22 | 21 |
| 23 class SurfacesState; | 22 class SurfacesState; |
| 24 | 23 |
| 25 namespace ws { | 24 namespace ws { |
| 26 | 25 |
| 27 class ServerWindow; | 26 class ServerWindow; |
| 28 class ServerWindowSurfaceManager; | 27 class ServerWindowSurfaceManager; |
| 29 | 28 |
| 30 // Server side representation of a WindowSurface. | 29 // Server side representation of a WindowSurface. |
| 31 class ServerWindowSurface : public mojom::Surface, | 30 class ServerWindowSurface : public mojom::Surface, |
| 32 public cc::SurfaceFactoryClient, | 31 public cc::SurfaceFactoryClient { |
| 33 public mojo::CustomSurfaceConverter { | |
| 34 public: | 32 public: |
| 35 ServerWindowSurface(ServerWindowSurfaceManager* manager, | 33 ServerWindowSurface(ServerWindowSurfaceManager* manager, |
| 36 mojo::InterfaceRequest<mojom::Surface> request, | 34 mojo::InterfaceRequest<mojom::Surface> request, |
| 37 mojom::SurfaceClientPtr client); | 35 mojom::SurfaceClientPtr client); |
| 38 | 36 |
| 39 ~ServerWindowSurface() override; | 37 ~ServerWindowSurface() override; |
| 40 | 38 |
| 41 const gfx::Size& last_submitted_frame_size() const { | 39 const gfx::Size& last_submitted_frame_size() const { |
| 42 return last_submitted_frame_size_; | 40 return last_submitted_frame_size_; |
| 43 } | 41 } |
| 44 | 42 |
| 45 // mojom::Surface: | 43 // mojom::Surface: |
| 46 void SubmitCompositorFrame( | 44 void SubmitCompositorFrame( |
| 47 mojom::CompositorFramePtr frame, | 45 mojom::CompositorFramePtr frame, |
| 48 const SubmitCompositorFrameCallback& callback) override; | 46 const SubmitCompositorFrameCallback& callback) override; |
| 49 | 47 |
| 50 // Returns the set of windows referenced by the last CompositorFrame submitted | |
| 51 // to this window. | |
| 52 const std::set<WindowId>& referenced_window_ids() const { | |
| 53 return referenced_window_ids_; | |
| 54 } | |
| 55 | |
| 56 const cc::SurfaceId& id() const { return surface_id_; } | 48 const cc::SurfaceId& id() const { return surface_id_; } |
| 57 | 49 |
| 58 // Destroys old surfaces that have been outdated by a new surface. | 50 // Destroys old surfaces that have been outdated by a new surface. |
| 59 void DestroySurfacesScheduledForDestruction(); | 51 void DestroySurfacesScheduledForDestruction(); |
| 60 | 52 |
| 61 // Registers this with the SurfaceManager | 53 // Registers this with the SurfaceManager |
| 62 void RegisterForBeginFrames(); | 54 void RegisterForBeginFrames(); |
| 63 | 55 |
| 64 private: | 56 private: |
| 65 ServerWindow* window(); | 57 ServerWindow* window(); |
| 66 | 58 |
| 67 // Takes a mojom::CompositorFrame |input|, and converts it into a | |
| 68 // cc::CompositorFrame. Along the way, this conversion ensures that a | |
| 69 // CompositorFrame of this window can only refer to windows within its | |
| 70 // subtree. Windows referenced in |input| are stored in | |
| 71 // |referenced_window_ids_|. | |
| 72 std::unique_ptr<cc::CompositorFrame> ConvertCompositorFrame( | |
| 73 const mojom::CompositorFramePtr& input); | |
| 74 | |
| 75 // Overriden from CustomSurfaceConverter: | |
| 76 bool ConvertSurfaceDrawQuad(const cc::mojom::DrawQuadPtr& input, | |
| 77 const cc::CompositorFrameMetadata& metadata, | |
| 78 cc::SharedQuadState* sqs, | |
| 79 cc::RenderPass* render_pass) override; | |
| 80 | |
| 81 // SurfaceFactoryClient implementation. | 59 // SurfaceFactoryClient implementation. |
| 82 void ReturnResources(const cc::ReturnedResourceArray& resources) override; | 60 void ReturnResources(const cc::ReturnedResourceArray& resources) override; |
| 83 void SetBeginFrameSource(cc::BeginFrameSource* begin_frame_source) override; | 61 void SetBeginFrameSource(cc::BeginFrameSource* begin_frame_source) override; |
| 84 | 62 |
| 85 ServerWindowSurfaceManager* manager_; // Owns this. | 63 ServerWindowSurfaceManager* manager_; // Owns this. |
| 86 | 64 |
| 87 // The set of Windows referenced in the last submitted CompositorFrame. | |
| 88 std::set<WindowId> referenced_window_ids_; | |
| 89 gfx::Size last_submitted_frame_size_; | 65 gfx::Size last_submitted_frame_size_; |
| 90 | 66 |
| 91 cc::SurfaceId surface_id_; | 67 cc::SurfaceId surface_id_; |
| 92 cc::SurfaceFactory surface_factory_; | 68 cc::SurfaceFactory surface_factory_; |
| 93 | 69 |
| 94 mojom::SurfaceClientPtr client_; | 70 mojom::SurfaceClientPtr client_; |
| 95 mojo::Binding<Surface> binding_; | 71 mojo::Binding<Surface> binding_; |
| 96 | 72 |
| 97 // Set of surface ids that need to be destroyed. | 73 // Set of surface ids that need to be destroyed. |
| 98 std::set<cc::SurfaceId> surfaces_scheduled_for_destruction_; | 74 std::set<cc::SurfaceId> surfaces_scheduled_for_destruction_; |
| 99 | 75 |
| 100 bool registered_surface_factory_client_; | 76 bool registered_surface_factory_client_; |
| 101 | 77 |
| 102 DISALLOW_COPY_AND_ASSIGN(ServerWindowSurface); | 78 DISALLOW_COPY_AND_ASSIGN(ServerWindowSurface); |
| 103 }; | 79 }; |
| 104 | 80 |
| 105 } // namespace ws | 81 } // namespace ws |
| 106 | 82 |
| 107 } // namespace mus | 83 } // namespace mus |
| 108 | 84 |
| 109 #endif // COMPONENTS_MUS_WS_SERVER_WINDOW_SURFACE_H_ | 85 #endif // COMPONENTS_MUS_WS_SERVER_WINDOW_SURFACE_H_ |
| OLD | NEW |