Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(235)

Side by Side Diff: components/mus/server_view.cc

Issue 1344573002: Mandoline: Rename components/view_manager to components/mus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/mus/server_view.h ('k') | components/mus/server_view_delegate.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "components/view_manager/server_view.h" 5 #include "components/mus/server_view.h"
6 6
7 #include <inttypes.h> 7 #include <inttypes.h>
8 8
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "components/view_manager/server_view_delegate.h" 10 #include "components/mus/server_view_delegate.h"
11 #include "components/view_manager/server_view_observer.h" 11 #include "components/mus/server_view_observer.h"
12 #include "components/view_manager/surfaces/surfaces_state.h" 12 #include "components/mus/surfaces/surfaces_state.h"
13 #include "mojo/converters/geometry/geometry_type_converters.h" 13 #include "mojo/converters/geometry/geometry_type_converters.h"
14 #include "mojo/converters/surfaces/surfaces_type_converters.h" 14 #include "mojo/converters/surfaces/surfaces_type_converters.h"
15 15
16 namespace view_manager { 16 namespace view_manager {
17 17
18 namespace { 18 namespace {
19 19
20 void CallCallback(const mojo::Closure& callback, cc::SurfaceDrawStatus status) { 20 void CallCallback(const mojo::Closure& callback, cc::SurfaceDrawStatus status) {
21 callback.Run(); 21 callback.Run();
22 } 22 }
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 void ServerView::SubmitCompositorFrame( 249 void ServerView::SubmitCompositorFrame(
250 mojo::CompositorFramePtr frame, 250 mojo::CompositorFramePtr frame,
251 const SubmitCompositorFrameCallback& callback) { 251 const SubmitCompositorFrameCallback& callback) {
252 gfx::Size frame_size = frame->passes[0]->output_rect.To<gfx::Rect>().size(); 252 gfx::Size frame_size = frame->passes[0]->output_rect.To<gfx::Rect>().size();
253 // Create Surfaces state on demand. 253 // Create Surfaces state on demand.
254 if (!surface_factory_) { 254 if (!surface_factory_) {
255 surface_factory_.reset( 255 surface_factory_.reset(
256 new cc::SurfaceFactory(delegate_->GetSurfacesState()->manager(), this)); 256 new cc::SurfaceFactory(delegate_->GetSurfacesState()->manager(), this));
257 } 257 }
258 if (!surface_id_allocator_) { 258 if (!surface_id_allocator_) {
259 surface_id_allocator_.reset( 259 surface_id_allocator_.reset(new cc::SurfaceIdAllocator(
260 new cc::SurfaceIdAllocator( 260 delegate_->GetSurfacesState()->next_id_namespace()));
261 delegate_->GetSurfacesState()->next_id_namespace()));
262 } 261 }
263 if (surface_id().is_null()) { 262 if (surface_id().is_null()) {
264 // Create a Surface ID for the first time for this view. 263 // Create a Surface ID for the first time for this view.
265 cc::SurfaceId surface_id(surface_id_allocator_->GenerateId()); 264 cc::SurfaceId surface_id(surface_id_allocator_->GenerateId());
266 surface_factory_->Create(surface_id); 265 surface_factory_->Create(surface_id);
267 SetSurfaceId(surface_id); 266 SetSurfaceId(surface_id);
268 } else { 267 } else {
269 // If the size of the CompostiorFrame has changed then destroy the existing 268 // If the size of the CompostiorFrame has changed then destroy the existing
270 // Surface and create a new one of the appropriate size. 269 // Surface and create a new one of the appropriate size.
271 if (frame_size != last_submitted_frame_size()) { 270 if (frame_size != last_submitted_frame_size()) {
272 surface_factory_->Destroy(surface_id()); 271 surface_factory_->Destroy(surface_id());
273 cc::SurfaceId surface_id(surface_id_allocator_->GenerateId()); 272 cc::SurfaceId surface_id(surface_id_allocator_->GenerateId());
274 surface_factory_->Create(surface_id); 273 surface_factory_->Create(surface_id);
275 SetSurfaceId(surface_id); 274 SetSurfaceId(surface_id);
276 } 275 }
277 } 276 }
278 surface_factory_->SubmitCompositorFrame( 277 surface_factory_->SubmitCompositorFrame(
279 surface_id(), 278 surface_id(), delegate_->UpdateViewTreeFromCompositorFrame(frame),
280 delegate_->UpdateViewTreeFromCompositorFrame(frame),
281 base::Bind(&CallCallback, callback)); 279 base::Bind(&CallCallback, callback));
282 delegate_->GetSurfacesState()->scheduler()->SetNeedsDraw(); 280 delegate_->GetSurfacesState()->scheduler()->SetNeedsDraw();
283 last_submitted_frame_size_ = frame_size; 281 last_submitted_frame_size_ = frame_size;
284 } 282 }
285 283
286 #if !defined(NDEBUG) 284 #if !defined(NDEBUG)
287 std::string ServerView::GetDebugWindowHierarchy() const { 285 std::string ServerView::GetDebugWindowHierarchy() const {
288 std::string result; 286 std::string result;
289 BuildDebugInfo(std::string(), &result); 287 BuildDebugInfo(std::string(), &result);
290 return result; 288 return result;
291 } 289 }
292 290
293 void ServerView::BuildDebugInfo(const std::string& depth, 291 void ServerView::BuildDebugInfo(const std::string& depth,
294 std::string* result) const { 292 std::string* result) const {
295 *result += base::StringPrintf( 293 *result += base::StringPrintf(
296 "%sid=%d,%d visible=%s bounds=%d,%d %dx%d surface_id=%" PRIu64 "\n", 294 "%sid=%d,%d visible=%s bounds=%d,%d %dx%d surface_id=%" PRIu64 "\n",
297 depth.c_str(), static_cast<int>(id_.connection_id), 295 depth.c_str(), static_cast<int>(id_.connection_id),
298 static_cast<int>(id_.view_id), visible_ ? "true" : "false", bounds_.x(), 296 static_cast<int>(id_.view_id), visible_ ? "true" : "false", bounds_.x(),
299 bounds_.y(), bounds_.width(), bounds_.height(), surface_id_.id); 297 bounds_.y(), bounds_.width(), bounds_.height(), surface_id_.id);
300 for (const ServerView* child : children_) 298 for (const ServerView* child : children_)
301 child->BuildDebugInfo(depth + " ", result); 299 child->BuildDebugInfo(depth + " ", result);
302 } 300 }
303 #endif 301 #endif
304 302
305 void ServerView::ReturnResources( 303 void ServerView::ReturnResources(const cc::ReturnedResourceArray& resources) {
306 const cc::ReturnedResourceArray& resources) {
307 if (!client_) 304 if (!client_)
308 return; 305 return;
309 client_->ReturnResources( 306 client_->ReturnResources(
310 mojo::Array<mojo::ReturnedResourcePtr>::From(resources)); 307 mojo::Array<mojo::ReturnedResourcePtr>::From(resources));
311 } 308 }
312 309
313 void ServerView::RemoveImpl(ServerView* view) { 310 void ServerView::RemoveImpl(ServerView* view) {
314 view->parent_ = NULL; 311 view->parent_ = NULL;
315 children_.erase(std::find(children_.begin(), children_.end(), view)); 312 children_.erase(std::find(children_.begin(), children_.end(), view));
316 } 313 }
317 314
318 } // namespace view_manager 315 } // namespace view_manager
OLDNEW
« no previous file with comments | « components/mus/server_view.h ('k') | components/mus/server_view_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698