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" |
(...skipping 13 matching lines...) Expand all Loading... |
24 // Server side representation of a view. Delegate is informed of interesting | 24 // Server side representation of a view. Delegate is informed of interesting |
25 // events. | 25 // events. |
26 // | 26 // |
27 // It is assumed that all functions that mutate the tree have validated the | 27 // 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 | 28 // mutation is possible before hand. For example, Reorder() assumes the supplied |
29 // view is a child and not already in position. | 29 // view is a child and not already in position. |
30 // | 30 // |
31 // ServerViews do not own their children. If you delete a view that has children | 31 // 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 | 32 // 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. | 33 // view is deleted the deleted view is implicitly removed from the parent. |
34 class ServerView { | 34 class ServerView : public mojo::CompositorFrameReceiver { |
35 public: | 35 public: |
36 ServerView(ServerViewDelegate* delegate, const ViewId& id); | 36 ServerView(ServerViewDelegate* delegate, const ViewId& id); |
37 virtual ~ServerView(); | 37 ~ServerView() override; |
38 | 38 |
39 void AddObserver(ServerViewObserver* observer); | 39 void AddObserver(ServerViewObserver* observer); |
40 void RemoveObserver(ServerViewObserver* observer); | 40 void RemoveObserver(ServerViewObserver* observer); |
41 | 41 |
| 42 void Bind(mojo::InterfaceRequest<CompositorFrameReceiver> request); |
| 43 |
42 const ViewId& id() const { return id_; } | 44 const ViewId& id() const { return id_; } |
43 | 45 |
44 void Add(ServerView* child); | 46 void Add(ServerView* child); |
45 void Remove(ServerView* child); | 47 void Remove(ServerView* child); |
46 void Reorder(ServerView* child, | 48 void Reorder(ServerView* child, |
47 ServerView* relative, | 49 ServerView* relative, |
48 mojo::OrderDirection direction); | 50 mojo::OrderDirection direction); |
49 | 51 |
50 const gfx::Rect& bounds() const { return bounds_; } | 52 const gfx::Rect& bounds() const { return bounds_; } |
51 void SetBounds(const gfx::Rect& bounds); | 53 void SetBounds(const gfx::Rect& bounds); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 return text_input_state_; | 88 return text_input_state_; |
87 } | 89 } |
88 | 90 |
89 // Returns true if this view is attached to a root and all ancestors are | 91 // Returns true if this view is attached to a root and all ancestors are |
90 // visible. | 92 // visible. |
91 bool IsDrawn() const; | 93 bool IsDrawn() const; |
92 | 94 |
93 void SetSurfaceId(cc::SurfaceId surface_id); | 95 void SetSurfaceId(cc::SurfaceId surface_id); |
94 const cc::SurfaceId& surface_id() const { return surface_id_; } | 96 const cc::SurfaceId& surface_id() const { return surface_id_; } |
95 | 97 |
| 98 const gfx::Size& last_submitted_frame_size() { |
| 99 return last_submitted_frame_size_; |
| 100 } |
| 101 |
96 // See mojom for for details. | 102 // See mojom for for details. |
97 void set_allows_reembed(bool value) { allows_reembed_ = value; } | 103 void set_allows_reembed(bool value) { allows_reembed_ = value; } |
98 bool allows_reembed() const { return allows_reembed_; } | 104 bool allows_reembed() const { return allows_reembed_; } |
99 | 105 |
| 106 // mojo::CompositorFrameReceiver: |
| 107 void SubmitCompositorFrame( |
| 108 mojo::CompositorFramePtr frame, |
| 109 const SubmitCompositorFrameCallback& callback) override; |
| 110 |
100 #if !defined(NDEBUG) | 111 #if !defined(NDEBUG) |
101 std::string GetDebugWindowHierarchy() const; | 112 std::string GetDebugWindowHierarchy() const; |
102 void BuildDebugInfo(const std::string& depth, std::string* result) const; | 113 void BuildDebugInfo(const std::string& depth, std::string* result) const; |
103 #endif | 114 #endif |
104 | 115 |
105 private: | 116 private: |
106 typedef std::vector<ServerView*> Views; | 117 typedef std::vector<ServerView*> Views; |
107 | 118 |
108 // Implementation of removing a view. Doesn't send any notification. | 119 // Implementation of removing a view. Doesn't send any notification. |
109 void RemoveImpl(ServerView* view); | 120 void RemoveImpl(ServerView* view); |
110 | 121 |
111 ServerViewDelegate* delegate_; | 122 ServerViewDelegate* delegate_; |
112 const ViewId id_; | 123 const ViewId id_; |
113 ServerView* parent_; | 124 ServerView* parent_; |
114 Views children_; | 125 Views children_; |
115 bool visible_; | 126 bool visible_; |
116 gfx::Rect bounds_; | 127 gfx::Rect bounds_; |
117 cc::SurfaceId surface_id_; | 128 cc::SurfaceId surface_id_; |
118 float opacity_; | 129 float opacity_; |
119 gfx::Transform transform_; | 130 gfx::Transform transform_; |
120 bool allows_reembed_; | 131 bool allows_reembed_; |
121 ui::TextInputState text_input_state_; | 132 ui::TextInputState text_input_state_; |
| 133 gfx::Size last_submitted_frame_size_; |
122 | 134 |
123 std::map<std::string, std::vector<uint8_t>> properties_; | 135 std::map<std::string, std::vector<uint8_t>> properties_; |
124 | 136 |
125 base::ObserverList<ServerViewObserver> observers_; | 137 base::ObserverList<ServerViewObserver> observers_; |
| 138 mojo::Binding<CompositorFrameReceiver> binding_; |
126 | 139 |
127 DISALLOW_COPY_AND_ASSIGN(ServerView); | 140 DISALLOW_COPY_AND_ASSIGN(ServerView); |
128 }; | 141 }; |
129 | 142 |
130 } // namespace view_manager | 143 } // namespace view_manager |
131 | 144 |
132 #endif // COMPONENTS_VIEW_MANAGER_SERVER_VIEW_H_ | 145 #endif // COMPONENTS_VIEW_MANAGER_SERVER_VIEW_H_ |
OLD | NEW |