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

Side by Side Diff: services/surfaces/surfaces_impl.cc

Issue 871373015: De-Client Surface interface (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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
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 "services/surfaces/surfaces_impl.h" 5 #include "services/surfaces/surfaces_impl.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "cc/output/compositor_frame.h" 8 #include "cc/output/compositor_frame.h"
9 #include "cc/resources/returned_resource.h" 9 #include "cc/resources/returned_resource.h"
10 #include "cc/surfaces/display.h" 10 #include "cc/surfaces/display.h"
(...skipping 12 matching lines...) Expand all
23 callback.Run(); 23 callback.Run();
24 } 24 }
25 } 25 }
26 26
27 SurfacesImpl::SurfacesImpl(cc::SurfaceManager* manager, 27 SurfacesImpl::SurfacesImpl(cc::SurfaceManager* manager,
28 uint32_t id_namespace, 28 uint32_t id_namespace,
29 Client* client, 29 Client* client,
30 mojo::InterfaceRequest<mojo::Surface> request) 30 mojo::InterfaceRequest<mojo::Surface> request)
31 : SurfacesImpl(manager, id_namespace, client) { 31 : SurfacesImpl(manager, id_namespace, client) {
32 binding_.Bind(request.Pass()); 32 binding_.Bind(request.Pass());
33 binding_.client()->SetIdNamespace(id_namespace);
34 } 33 }
35 34
36 SurfacesImpl::SurfacesImpl(cc::SurfaceManager* manager, 35 SurfacesImpl::SurfacesImpl(cc::SurfaceManager* manager,
37 uint32_t id_namespace, 36 uint32_t id_namespace,
38 Client* client, 37 Client* client,
39 mojo::SurfacePtr* surface) 38 mojo::SurfacePtr* surface)
40 : SurfacesImpl(manager, id_namespace, client) { 39 : SurfacesImpl(manager, id_namespace, client) {
41 binding_.Bind(surface); 40 binding_.Bind(surface);
42 binding_.client()->SetIdNamespace(id_namespace);
43 } 41 }
44 42
45 SurfacesImpl::~SurfacesImpl() { 43 SurfacesImpl::~SurfacesImpl() {
46 client_->OnDisplayBeingDestroyed(display_.get()); 44 client_->OnDisplayBeingDestroyed(display_.get());
47 factory_.DestroyAll(); 45 factory_.DestroyAll();
48 } 46 }
49 47
48 void SurfacesImpl::GetIdNamespace(
49 const Surface::GetIdNamespaceCallback& callback) {
50 callback.Run(id_namespace_);
51 }
52
53 void SurfacesImpl::SetResourceReturner(mojo::ResourceReturnerPtr returner) {
54 returner_ = returner.Pass();
55 }
56
50 void SurfacesImpl::CreateSurface(uint32_t local_id) { 57 void SurfacesImpl::CreateSurface(uint32_t local_id) {
51 factory_.Create(QualifyIdentifier(local_id)); 58 factory_.Create(QualifyIdentifier(local_id));
52 } 59 }
53 60
54 void SurfacesImpl::SubmitFrame(uint32_t local_id, 61 void SurfacesImpl::SubmitFrame(uint32_t local_id,
55 mojo::FramePtr frame, 62 mojo::FramePtr frame,
56 const mojo::Closure& callback) { 63 const mojo::Closure& callback) {
57 TRACE_EVENT0("mojo", "SurfacesImpl::SubmitFrame"); 64 TRACE_EVENT0("mojo", "SurfacesImpl::SubmitFrame");
58 factory_.SubmitFrame(QualifyIdentifier(local_id), 65 factory_.SubmitFrame(QualifyIdentifier(local_id),
59 frame.To<scoped_ptr<cc::CompositorFrame>>(), 66 frame.To<scoped_ptr<cc::CompositorFrame>>(),
(...skipping 20 matching lines...) Expand all
80 new mojo::ContextProviderMojo(command_buffer_handle_.Pass())))); 87 new mojo::ContextProviderMojo(command_buffer_handle_.Pass()))));
81 } 88 }
82 cc::SurfaceId cc_id = QualifyIdentifier(local_id); 89 cc::SurfaceId cc_id = QualifyIdentifier(local_id);
83 factory_.Create(cc_id); 90 factory_.Create(cc_id);
84 display_->SetSurfaceId(cc_id, 1.f); 91 display_->SetSurfaceId(cc_id, 1.f);
85 display_->Resize(size.To<gfx::Size>()); 92 display_->Resize(size.To<gfx::Size>());
86 parameter_listeners_.AddBinding(this, listener_request.Pass()); 93 parameter_listeners_.AddBinding(this, listener_request.Pass());
87 } 94 }
88 95
89 void SurfacesImpl::ReturnResources(const cc::ReturnedResourceArray& resources) { 96 void SurfacesImpl::ReturnResources(const cc::ReturnedResourceArray& resources) {
90 if (resources.empty()) 97 if (resources.empty() || !returner_)
91 return; 98 return;
92 mojo::Array<mojo::ReturnedResourcePtr> ret(resources.size()); 99 mojo::Array<mojo::ReturnedResourcePtr> ret(resources.size());
93 for (size_t i = 0; i < resources.size(); ++i) { 100 for (size_t i = 0; i < resources.size(); ++i) {
94 ret[i] = mojo::ReturnedResource::From(resources[i]); 101 ret[i] = mojo::ReturnedResource::From(resources[i]);
95 } 102 }
96 binding_.client()->ReturnResources(ret.Pass()); 103 returner_->ReturnResources(ret.Pass());
97 } 104 }
98 105
99 void SurfacesImpl::DisplayDamaged() { 106 void SurfacesImpl::DisplayDamaged() {
100 } 107 }
101 108
102 void SurfacesImpl::DidSwapBuffers() { 109 void SurfacesImpl::DidSwapBuffers() {
103 } 110 }
104 111
105 void SurfacesImpl::DidSwapBuffersComplete() { 112 void SurfacesImpl::DidSwapBuffersComplete() {
106 } 113 }
(...skipping 23 matching lines...) Expand all
130 id_namespace_(id_namespace), 137 id_namespace_(id_namespace),
131 client_(client), 138 client_(client),
132 binding_(this) { 139 binding_(this) {
133 } 140 }
134 141
135 cc::SurfaceId SurfacesImpl::QualifyIdentifier(uint32_t local_id) { 142 cc::SurfaceId SurfacesImpl::QualifyIdentifier(uint32_t local_id) {
136 return cc::SurfaceId(static_cast<uint64_t>(id_namespace_) << 32 | local_id); 143 return cc::SurfaceId(static_cast<uint64_t>(id_namespace_) << 32 | local_id);
137 } 144 }
138 145
139 } // namespace mojo 146 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698