| 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_VIEW_SURFACE_H_ | 5 #ifndef COMPONENTS_MUS_WS_SERVER_VIEW_SURFACE_H_ |
| 6 #define COMPONENTS_MUS_WS_SERVER_VIEW_SURFACE_H_ | 6 #define COMPONENTS_MUS_WS_SERVER_VIEW_SURFACE_H_ |
| 7 | 7 |
| 8 #include "cc/surfaces/surface_factory.h" | 8 #include "cc/surfaces/surface_factory.h" |
| 9 #include "cc/surfaces/surface_factory_client.h" | 9 #include "cc/surfaces/surface_factory_client.h" |
| 10 #include "cc/surfaces/surface_id.h" | 10 #include "cc/surfaces/surface_id.h" |
| 11 #include "cc/surfaces/surface_id_allocator.h" | 11 #include "cc/surfaces/surface_id_allocator.h" |
| 12 #include "components/mus/public/interfaces/compositor_frame.mojom.h" | 12 #include "components/mus/public/interfaces/compositor_frame.mojom.h" |
| 13 #include "components/mus/ws/ids.h" | 13 #include "components/mus/ws/ids.h" |
| 14 #include "mojo/converters/surfaces/custom_surface_converter.h" | 14 #include "mojo/converters/surfaces/custom_surface_converter.h" |
| 15 #include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h" | 15 #include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h" |
| 16 | 16 |
| 17 namespace mus { | 17 namespace mus { |
| 18 | 18 |
| 19 class ServerView; | 19 class ServerView; |
| 20 class SurfacesState; | 20 class SurfacesState; |
| 21 | 21 |
| 22 // Server side representation of a ViewSurface. | 22 // Server side representation of a ViewSurface. |
| 23 class ServerViewSurface : public mojo::Surface, | 23 class ServerViewSurface : public mojom::Surface, |
| 24 public cc::SurfaceFactoryClient, | 24 public cc::SurfaceFactoryClient, |
| 25 public mojo::CustomSurfaceConverter { | 25 public mojo::CustomSurfaceConverter { |
| 26 public: | 26 public: |
| 27 explicit ServerViewSurface(ServerView* view); | 27 explicit ServerViewSurface(ServerView* view); |
| 28 | 28 |
| 29 ~ServerViewSurface() override; | 29 ~ServerViewSurface() override; |
| 30 | 30 |
| 31 void Bind(mojo::InterfaceRequest<Surface> request, | 31 void Bind(mojo::InterfaceRequest<Surface> request, |
| 32 mojo::SurfaceClientPtr client); | 32 mojom::SurfaceClientPtr client); |
| 33 | 33 |
| 34 // mojo::Surface: | 34 // mojom::Surface: |
| 35 void SubmitCompositorFrame( | 35 void SubmitCompositorFrame( |
| 36 mojo::CompositorFramePtr frame, | 36 mojom::CompositorFramePtr frame, |
| 37 const SubmitCompositorFrameCallback& callback) override; | 37 const SubmitCompositorFrameCallback& callback) override; |
| 38 | 38 |
| 39 // Returns the set of views referenced by the last CompositorFrame submitted | 39 // Returns the set of views referenced by the last CompositorFrame submitted |
| 40 // to this view. | 40 // to this view. |
| 41 const std::set<ViewId>& referenced_view_ids() const { | 41 const std::set<ViewId>& referenced_view_ids() const { |
| 42 return referenced_view_ids_; | 42 return referenced_view_ids_; |
| 43 } | 43 } |
| 44 | 44 |
| 45 const cc::SurfaceId& id() const { return surface_id_; } | 45 const cc::SurfaceId& id() const { return surface_id_; } |
| 46 | 46 |
| 47 private: | 47 private: |
| 48 // Takes a mojo::CompositorFrame |input|, and converts it into a | 48 // Takes a mojom::CompositorFrame |input|, and converts it into a |
| 49 // cc::CompositorFrame. Along the way, this conversion ensures that a | 49 // cc::CompositorFrame. Along the way, this conversion ensures that a |
| 50 // CompositorFrame of this view can only refer to views within its subtree. | 50 // CompositorFrame of this view can only refer to views within its subtree. |
| 51 // Views referenced in |input| are stored in |referenced_view_ids_|. | 51 // Views referenced in |input| are stored in |referenced_view_ids_|. |
| 52 scoped_ptr<cc::CompositorFrame> ConvertCompositorFrame( | 52 scoped_ptr<cc::CompositorFrame> ConvertCompositorFrame( |
| 53 const mojo::CompositorFramePtr& input); | 53 const mojom::CompositorFramePtr& input); |
| 54 | 54 |
| 55 // Overriden from CustomSurfaceConverter: | 55 // Overriden from CustomSurfaceConverter: |
| 56 bool ConvertSurfaceDrawQuad(const mojo::QuadPtr& input, | 56 bool ConvertSurfaceDrawQuad(const mojom::QuadPtr& input, |
| 57 const mojo::CompositorFrameMetadataPtr& metadata, | 57 const mojom::CompositorFrameMetadataPtr& metadata, |
| 58 cc::SharedQuadState* sqs, | 58 cc::SharedQuadState* sqs, |
| 59 cc::RenderPass* render_pass) override; | 59 cc::RenderPass* render_pass) override; |
| 60 | 60 |
| 61 // SurfaceFactoryClient implementation. | 61 // SurfaceFactoryClient implementation. |
| 62 void ReturnResources(const cc::ReturnedResourceArray& resources) override; | 62 void ReturnResources(const cc::ReturnedResourceArray& resources) override; |
| 63 | 63 |
| 64 // |view_| owns |this|. | 64 // |view_| owns |this|. |
| 65 ServerView* const view_; | 65 ServerView* const view_; |
| 66 | 66 |
| 67 // The set of Views referenced in the last submitted CompositorFrame. | 67 // The set of Views referenced in the last submitted CompositorFrame. |
| 68 std::set<ViewId> referenced_view_ids_; | 68 std::set<ViewId> referenced_view_ids_; |
| 69 gfx::Size last_submitted_frame_size_; | 69 gfx::Size last_submitted_frame_size_; |
| 70 | 70 |
| 71 cc::SurfaceId surface_id_; | 71 cc::SurfaceId surface_id_; |
| 72 // TODO(fsamuel): As an optimization, we may want to move SurfaceIdAllocator | 72 // TODO(fsamuel): As an optimization, we may want to move SurfaceIdAllocator |
| 73 // and SurfaceFactory to a separate class so that we don't keep destroying | 73 // and SurfaceFactory to a separate class so that we don't keep destroying |
| 74 // them and creating new ones on navigation. | 74 // them and creating new ones on navigation. |
| 75 cc::SurfaceIdAllocator surface_id_allocator_; | 75 cc::SurfaceIdAllocator surface_id_allocator_; |
| 76 cc::SurfaceFactory surface_factory_; | 76 cc::SurfaceFactory surface_factory_; |
| 77 | 77 |
| 78 mojo::SurfaceClientPtr client_; | 78 mojom::SurfaceClientPtr client_; |
| 79 mojo::Binding<Surface> binding_; | 79 mojo::Binding<Surface> binding_; |
| 80 | 80 |
| 81 DISALLOW_COPY_AND_ASSIGN(ServerViewSurface); | 81 DISALLOW_COPY_AND_ASSIGN(ServerViewSurface); |
| 82 }; | 82 }; |
| 83 | 83 |
| 84 } // namespace mus | 84 } // namespace mus |
| 85 | 85 |
| 86 #endif // COMPONENTS_MUS_WS_SERVER_VIEW_SURFACE_H_ | 86 #endif // COMPONENTS_MUS_WS_SERVER_VIEW_SURFACE_H_ |
| OLD | NEW |