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 void Bind(mojo::InterfaceRequest<Surface> request, |
| 48 mojo::SurfaceClientPtr client); |
| 49 |
42 const ViewId& id() const { return id_; } | 50 const ViewId& id() const { return id_; } |
43 | 51 |
44 void Add(ServerView* child); | 52 void Add(ServerView* child); |
45 void Remove(ServerView* child); | 53 void Remove(ServerView* child); |
46 void Reorder(ServerView* child, | 54 void Reorder(ServerView* child, |
47 ServerView* relative, | 55 ServerView* relative, |
48 mojo::OrderDirection direction); | 56 mojo::OrderDirection direction); |
49 | 57 |
50 const gfx::Rect& bounds() const { return bounds_; } | 58 const gfx::Rect& bounds() const { return bounds_; } |
51 void SetBounds(const gfx::Rect& bounds); | 59 void SetBounds(const gfx::Rect& bounds); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 return text_input_state_; | 94 return text_input_state_; |
87 } | 95 } |
88 | 96 |
89 // Returns true if this view is attached to a root and all ancestors are | 97 // Returns true if this view is attached to a root and all ancestors are |
90 // visible. | 98 // visible. |
91 bool IsDrawn() const; | 99 bool IsDrawn() const; |
92 | 100 |
93 void SetSurfaceId(cc::SurfaceId surface_id); | 101 void SetSurfaceId(cc::SurfaceId surface_id); |
94 const cc::SurfaceId& surface_id() const { return surface_id_; } | 102 const cc::SurfaceId& surface_id() const { return surface_id_; } |
95 | 103 |
| 104 const gfx::Size& last_submitted_frame_size() { |
| 105 return last_submitted_frame_size_; |
| 106 } |
| 107 |
96 // See mojom for for details. | 108 // See mojom for for details. |
97 void set_allows_reembed(bool value) { allows_reembed_ = value; } | 109 void set_allows_reembed(bool value) { allows_reembed_ = value; } |
98 bool allows_reembed() const { return allows_reembed_; } | 110 bool allows_reembed() const { return allows_reembed_; } |
99 | 111 |
| 112 // mojo::Surface: |
| 113 void SubmitCompositorFrame( |
| 114 mojo::CompositorFramePtr frame, |
| 115 const SubmitCompositorFrameCallback& callback) override; |
| 116 |
100 #if !defined(NDEBUG) | 117 #if !defined(NDEBUG) |
101 std::string GetDebugWindowHierarchy() const; | 118 std::string GetDebugWindowHierarchy() const; |
102 void BuildDebugInfo(const std::string& depth, std::string* result) const; | 119 void BuildDebugInfo(const std::string& depth, std::string* result) const; |
103 #endif | 120 #endif |
104 | 121 |
105 private: | 122 private: |
106 typedef std::vector<ServerView*> Views; | 123 typedef std::vector<ServerView*> Views; |
107 | 124 |
| 125 // SurfaceFactoryClient implementation. |
| 126 void ReturnResources(const cc::ReturnedResourceArray& resources) override; |
| 127 |
108 // Implementation of removing a view. Doesn't send any notification. | 128 // Implementation of removing a view. Doesn't send any notification. |
109 void RemoveImpl(ServerView* view); | 129 void RemoveImpl(ServerView* view); |
110 | 130 |
111 ServerViewDelegate* delegate_; | 131 ServerViewDelegate* delegate_; |
112 const ViewId id_; | 132 const ViewId id_; |
113 ServerView* parent_; | 133 ServerView* parent_; |
114 Views children_; | 134 Views children_; |
115 bool visible_; | 135 bool visible_; |
116 gfx::Rect bounds_; | 136 gfx::Rect bounds_; |
117 cc::SurfaceId surface_id_; | 137 cc::SurfaceId surface_id_; |
| 138 scoped_ptr<cc::SurfaceIdAllocator> surface_id_allocator_; |
| 139 scoped_ptr<cc::SurfaceFactory> surface_factory_; |
118 float opacity_; | 140 float opacity_; |
119 gfx::Transform transform_; | 141 gfx::Transform transform_; |
120 bool allows_reembed_; | 142 bool allows_reembed_; |
121 ui::TextInputState text_input_state_; | 143 ui::TextInputState text_input_state_; |
| 144 gfx::Size last_submitted_frame_size_; |
122 | 145 |
123 std::map<std::string, std::vector<uint8_t>> properties_; | 146 std::map<std::string, std::vector<uint8_t>> properties_; |
124 | 147 |
125 base::ObserverList<ServerViewObserver> observers_; | 148 base::ObserverList<ServerViewObserver> observers_; |
| 149 mojo::SurfaceClientPtr client_; |
| 150 mojo::Binding<Surface> binding_; |
126 | 151 |
127 DISALLOW_COPY_AND_ASSIGN(ServerView); | 152 DISALLOW_COPY_AND_ASSIGN(ServerView); |
128 }; | 153 }; |
129 | 154 |
130 } // namespace view_manager | 155 } // namespace view_manager |
131 | 156 |
132 #endif // COMPONENTS_VIEW_MANAGER_SERVER_VIEW_H_ | 157 #endif // COMPONENTS_VIEW_MANAGER_SERVER_VIEW_H_ |
OLD | NEW |