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 #include "mojo/services/view_manager/server_view.h" | 5 #include "mojo/services/view_manager/server_view.h" |
6 | 6 |
| 7 #include "base/strings/stringprintf.h" |
7 #include "mojo/services/view_manager/server_view_delegate.h" | 8 #include "mojo/services/view_manager/server_view_delegate.h" |
8 | 9 |
9 namespace mojo { | 10 namespace mojo { |
10 namespace service { | 11 namespace service { |
11 | 12 |
12 ServerView::ServerView(ServerViewDelegate* delegate, const ViewId& id) | 13 ServerView::ServerView(ServerViewDelegate* delegate, const ViewId& id) |
13 : delegate_(delegate), id_(id), parent_(NULL), visible_(true), opacity_(1) { | 14 : delegate_(delegate), |
| 15 id_(id), |
| 16 parent_(nullptr), |
| 17 visible_(false), |
| 18 opacity_(1) { |
14 DCHECK(delegate); // Must provide a delegate. | 19 DCHECK(delegate); // Must provide a delegate. |
15 } | 20 } |
16 | 21 |
17 ServerView::~ServerView() { | 22 ServerView::~ServerView() { |
18 delegate_->OnWillDestroyView(this); | 23 delegate_->OnWillDestroyView(this); |
19 | 24 |
20 while (!children_.empty()) | 25 while (!children_.empty()) |
21 children_.front()->parent()->Remove(children_.front()); | 26 children_.front()->parent()->Remove(children_.front()); |
22 | 27 |
23 if (parent_) | 28 if (parent_) |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 while (view && view != root && view->visible_) | 163 while (view && view != root && view->visible_) |
159 view = view->parent_; | 164 view = view->parent_; |
160 return view == root; | 165 return view == root; |
161 } | 166 } |
162 | 167 |
163 void ServerView::SetSurfaceId(cc::SurfaceId surface_id) { | 168 void ServerView::SetSurfaceId(cc::SurfaceId surface_id) { |
164 surface_id_ = surface_id; | 169 surface_id_ = surface_id; |
165 delegate_->OnViewSurfaceIdChanged(this); | 170 delegate_->OnViewSurfaceIdChanged(this); |
166 } | 171 } |
167 | 172 |
| 173 #if !defined(NDEBUG) |
| 174 std::string ServerView::GetDebugWindowHierarchy() const { |
| 175 std::string result; |
| 176 BuildDebugInfo(std::string(), &result); |
| 177 return result; |
| 178 } |
| 179 |
| 180 void ServerView::BuildDebugInfo(const std::string& depth, |
| 181 std::string* result) const { |
| 182 *result += base::StringPrintf( |
| 183 "%sid=%d,%d visible=%s bounds=%d,%d %dx%d surface_id=%ld\n", |
| 184 depth.c_str(), static_cast<int>(id_.connection_id), |
| 185 static_cast<int>(id_.view_id), visible_ ? "true" : "false", bounds_.x(), |
| 186 bounds_.y(), bounds_.width(), bounds_.height(), surface_id_.id); |
| 187 for (const ServerView* child : children_) |
| 188 child->BuildDebugInfo(depth + " ", result); |
| 189 } |
| 190 #endif |
| 191 |
168 void ServerView::RemoveImpl(ServerView* view) { | 192 void ServerView::RemoveImpl(ServerView* view) { |
169 view->parent_ = NULL; | 193 view->parent_ = NULL; |
170 children_.erase(std::find(children_.begin(), children_.end(), view)); | 194 children_.erase(std::find(children_.begin(), children_.end(), view)); |
171 } | 195 } |
172 | 196 |
173 } // namespace service | 197 } // namespace service |
174 } // namespace mojo | 198 } // namespace mojo |
OLD | NEW |