| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_VIEW_MANAGER_SERVER_VIEW_H_ | 5 #ifndef COMPONENTS_VIEW_MANAGER_SERVER_VIEW_H_ |
| 6 #define COMPONENTS_VIEW_MANAGER_SERVER_VIEW_H_ | 6 #define COMPONENTS_VIEW_MANAGER_SERVER_VIEW_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/observer_list.h" | 11 #include "base/observer_list.h" |
| 12 #include "cc/surfaces/surface_factory.h" |
| 13 #include "cc/surfaces/surface_factory_client.h" |
| 12 #include "cc/surfaces/surface_id.h" | 14 #include "cc/surfaces/surface_id.h" |
| 15 #include "cc/surfaces/surface_id_allocator.h" |
| 13 #include "components/view_manager/ids.h" | 16 #include "components/view_manager/ids.h" |
| 14 #include "components/view_manager/public/interfaces/view_tree.mojom.h" | 17 #include "components/view_manager/public/interfaces/view_tree.mojom.h" |
| 18 #include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h" |
| 15 #include "ui/gfx/geometry/rect.h" | 19 #include "ui/gfx/geometry/rect.h" |
| 16 #include "ui/gfx/transform.h" | 20 #include "ui/gfx/transform.h" |
| 17 #include "ui/platform_window/text_input_state.h" | 21 #include "ui/platform_window/text_input_state.h" |
| 18 | 22 |
| 19 namespace view_manager { | 23 namespace view_manager { |
| 20 | 24 |
| 21 class ServerViewDelegate; | 25 class ServerViewDelegate; |
| 22 class ServerViewObserver; | 26 class ServerViewObserver; |
| 23 | 27 |
| 24 // Server side representation of a view. Delegate is informed of interesting | 28 // Server side representation of a view. Delegate is informed of interesting |
| 25 // events. | 29 // events. |
| 26 // | 30 // |
| 27 // It is assumed that all functions that mutate the tree have validated the | 31 // It is assumed that all functions that mutate the tree have validated the |
| 28 // mutation is possible before hand. For example, Reorder() assumes the supplied | 32 // mutation is possible before hand. For example, Reorder() assumes the supplied |
| 29 // view is a child and not already in position. | 33 // view is a child and not already in position. |
| 30 // | 34 // |
| 31 // ServerViews do not own their children. If you delete a view that has children | 35 // ServerViews do not own their children. If you delete a view that has children |
| 32 // the children are implicitly removed. Similarly if a view has a parent and the | 36 // the children are implicitly removed. Similarly if a view has a parent and the |
| 33 // view is deleted the deleted view is implicitly removed from the parent. | 37 // view is deleted the deleted view is implicitly removed from the parent. |
| 34 class ServerView { | 38 class ServerView : public mojo::Surface, |
| 39 public cc::SurfaceFactoryClient { |
| 35 public: | 40 public: |
| 36 ServerView(ServerViewDelegate* delegate, const ViewId& id); | 41 ServerView(ServerViewDelegate* delegate, const ViewId& id); |
| 37 virtual ~ServerView(); | 42 ~ServerView() override; |
| 38 | 43 |
| 39 void AddObserver(ServerViewObserver* observer); | 44 void AddObserver(ServerViewObserver* observer); |
| 40 void RemoveObserver(ServerViewObserver* observer); | 45 void RemoveObserver(ServerViewObserver* observer); |
| 41 | 46 |
| 47 // Binds the provided |request| to |this| object. If an interface is already |
| 48 // bound to this ServerView then the old connection is closed first. |
| 49 void Bind(mojo::InterfaceRequest<Surface> request, |
| 50 mojo::SurfaceClientPtr client); |
| 51 |
| 42 const ViewId& id() const { return id_; } | 52 const ViewId& id() const { return id_; } |
| 43 | 53 |
| 44 void Add(ServerView* child); | 54 void Add(ServerView* child); |
| 45 void Remove(ServerView* child); | 55 void Remove(ServerView* child); |
| 46 void Reorder(ServerView* child, | 56 void Reorder(ServerView* child, |
| 47 ServerView* relative, | 57 ServerView* relative, |
| 48 mojo::OrderDirection direction); | 58 mojo::OrderDirection direction); |
| 49 | 59 |
| 50 const gfx::Rect& bounds() const { return bounds_; } | 60 const gfx::Rect& bounds() const { return bounds_; } |
| 51 void SetBounds(const gfx::Rect& bounds); | 61 void SetBounds(const gfx::Rect& bounds); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 return text_input_state_; | 96 return text_input_state_; |
| 87 } | 97 } |
| 88 | 98 |
| 89 // Returns true if this view is attached to a root and all ancestors are | 99 // Returns true if this view is attached to a root and all ancestors are |
| 90 // visible. | 100 // visible. |
| 91 bool IsDrawn() const; | 101 bool IsDrawn() const; |
| 92 | 102 |
| 93 void SetSurfaceId(cc::SurfaceId surface_id); | 103 void SetSurfaceId(cc::SurfaceId surface_id); |
| 94 const cc::SurfaceId& surface_id() const { return surface_id_; } | 104 const cc::SurfaceId& surface_id() const { return surface_id_; } |
| 95 | 105 |
| 106 const gfx::Size& last_submitted_frame_size() { |
| 107 return last_submitted_frame_size_; |
| 108 } |
| 109 |
| 96 // See mojom for for details. | 110 // See mojom for for details. |
| 97 void set_allows_reembed(bool value) { allows_reembed_ = value; } | 111 void set_allows_reembed(bool value) { allows_reembed_ = value; } |
| 98 bool allows_reembed() const { return allows_reembed_; } | 112 bool allows_reembed() const { return allows_reembed_; } |
| 99 | 113 |
| 114 // mojo::Surface: |
| 115 void SubmitCompositorFrame( |
| 116 mojo::CompositorFramePtr frame, |
| 117 const SubmitCompositorFrameCallback& callback) override; |
| 118 |
| 100 #if !defined(NDEBUG) | 119 #if !defined(NDEBUG) |
| 101 std::string GetDebugWindowHierarchy() const; | 120 std::string GetDebugWindowHierarchy() const; |
| 102 void BuildDebugInfo(const std::string& depth, std::string* result) const; | 121 void BuildDebugInfo(const std::string& depth, std::string* result) const; |
| 103 #endif | 122 #endif |
| 104 | 123 |
| 105 private: | 124 private: |
| 106 typedef std::vector<ServerView*> Views; | 125 typedef std::vector<ServerView*> Views; |
| 107 | 126 |
| 127 // SurfaceFactoryClient implementation. |
| 128 void ReturnResources(const cc::ReturnedResourceArray& resources) override; |
| 129 |
| 108 // Implementation of removing a view. Doesn't send any notification. | 130 // Implementation of removing a view. Doesn't send any notification. |
| 109 void RemoveImpl(ServerView* view); | 131 void RemoveImpl(ServerView* view); |
| 110 | 132 |
| 111 ServerViewDelegate* delegate_; | 133 ServerViewDelegate* delegate_; |
| 112 const ViewId id_; | 134 const ViewId id_; |
| 113 ServerView* parent_; | 135 ServerView* parent_; |
| 114 Views children_; | 136 Views children_; |
| 115 bool visible_; | 137 bool visible_; |
| 116 gfx::Rect bounds_; | 138 gfx::Rect bounds_; |
| 117 cc::SurfaceId surface_id_; | 139 cc::SurfaceId surface_id_; |
| 140 scoped_ptr<cc::SurfaceIdAllocator> surface_id_allocator_; |
| 141 scoped_ptr<cc::SurfaceFactory> surface_factory_; |
| 118 float opacity_; | 142 float opacity_; |
| 119 gfx::Transform transform_; | 143 gfx::Transform transform_; |
| 120 bool allows_reembed_; | 144 bool allows_reembed_; |
| 121 ui::TextInputState text_input_state_; | 145 ui::TextInputState text_input_state_; |
| 146 gfx::Size last_submitted_frame_size_; |
| 122 | 147 |
| 123 std::map<std::string, std::vector<uint8_t>> properties_; | 148 std::map<std::string, std::vector<uint8_t>> properties_; |
| 124 | 149 |
| 125 base::ObserverList<ServerViewObserver> observers_; | 150 base::ObserverList<ServerViewObserver> observers_; |
| 151 mojo::SurfaceClientPtr client_; |
| 152 mojo::Binding<Surface> binding_; |
| 126 | 153 |
| 127 DISALLOW_COPY_AND_ASSIGN(ServerView); | 154 DISALLOW_COPY_AND_ASSIGN(ServerView); |
| 128 }; | 155 }; |
| 129 | 156 |
| 130 } // namespace view_manager | 157 } // namespace view_manager |
| 131 | 158 |
| 132 #endif // COMPONENTS_VIEW_MANAGER_SERVER_VIEW_H_ | 159 #endif // COMPONENTS_VIEW_MANAGER_SERVER_VIEW_H_ |
| OLD | NEW |