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

Side by Side Diff: sky/compositor/surface_holder.cc

Issue 807733002: Split surface id and simplify connecting to surfaces service (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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
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 "sky/compositor/surface_holder.h" 5 #include "sky/compositor/surface_holder.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "mojo/converters/geometry/geometry_type_converters.h" 9 #include "mojo/converters/geometry/geometry_type_converters.h"
10 #include "mojo/public/cpp/application/connect.h" 10 #include "mojo/public/cpp/application/connect.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 void SurfaceHolder::SetSize(const gfx::Size& size) { 44 void SurfaceHolder::SetSize(const gfx::Size& size) {
45 if (surface_id_ && size_ == size) 45 if (surface_id_ && size_ == size)
46 return; 46 return;
47 47
48 if (surface_id_) { 48 if (surface_id_) {
49 surface_->DestroySurface(surface_id_.Clone()); 49 surface_->DestroySurface(surface_id_.Clone());
50 } else { 50 } else {
51 surface_id_ = mojo::SurfaceId::New(); 51 surface_id_ = mojo::SurfaceId::New();
52 } 52 }
53 53
54 surface_id_->id = surface_allocator_->CreateSurfaceId(); 54 surface_id_ = surface_allocator_->CreateSurfaceId();
55 surface_->CreateSurface(surface_id_.Clone(), mojo::Size::From(size)); 55 surface_->CreateSurface(surface_id_.Clone());
56 size_ = size; 56 size_ = size;
57 57
58 client_->OnSurfaceIdAvailable(surface_id_.Clone()); 58 client_->OnSurfaceIdAvailable(surface_id_.Clone());
59 } 59 }
60 60
61 void SurfaceHolder::SetIdNamespace(uint32_t id_namespace) {
62 }
63
61 void SurfaceHolder::ReturnResources( 64 void SurfaceHolder::ReturnResources(
62 mojo::Array<mojo::ReturnedResourcePtr> resources) { 65 mojo::Array<mojo::ReturnedResourcePtr> resources) {
63 // TODO(abarth): The surface service shouldn't spam us with empty calls. 66 // TODO(abarth): The surface service shouldn't spam us with empty calls.
64 if (!resources.size()) 67 if (!resources.size())
65 return; 68 return;
66 client_->ReturnResources(resources.Pass()); 69 client_->ReturnResources(resources.Pass());
67 } 70 }
68 71
69 void SurfaceHolder::OnSurfaceConnectionCreated(mojo::SurfacePtr surface, 72 void SurfaceHolder::OnSurfaceConnectionCreated(mojo::SurfacePtr surface,
70 uint32_t id_namespace) { 73 uint32_t id_namespace) {
71 surface_ = surface.Pass(); 74 surface_ = surface.Pass();
72 surface_.set_client(this); 75 surface_.set_client(this);
73 surface_allocator_.reset(new SurfaceAllocator(id_namespace)); 76 surface_allocator_.reset(new SurfaceAllocator(id_namespace));
74 client_->OnSurfaceConnectionCreated(); 77 client_->OnSurfaceConnectionCreated();
75 } 78 }
76 79
77 } // namespace sky 80 } // namespace sky
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698