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

Side by Side Diff: services/fake_surfaces/fake_surfaces_service_application.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/fake_surfaces/fake_surfaces_service_application.h" 5 #include "services/fake_surfaces/fake_surfaces_service_application.h"
6 6
7 #include "mojo/application/application_runner_chromium.h" 7 #include "mojo/application/application_runner_chromium.h"
8 #include "mojo/common/tracing_impl.h" 8 #include "mojo/common/tracing_impl.h"
9 #include "mojo/public/c/system/main.h" 9 #include "mojo/public/c/system/main.h"
10 #include "mojo/public/cpp/application/application_connection.h" 10 #include "mojo/public/cpp/application/application_connection.h"
11 #include "mojo/services/surfaces/public/interfaces/surfaces.mojom.h" 11 #include "mojo/services/surfaces/public/interfaces/surfaces.mojom.h"
12 12
13 using mojo::InterfaceRequest; 13 using mojo::InterfaceRequest;
14 14
15 namespace fake_surfaces { 15 namespace fake_surfaces {
16 16
17 class FakeSurfaceImpl : public mojo::Surface { 17 class FakeSurfaceImpl : public mojo::Surface {
18 public: 18 public:
19 FakeSurfaceImpl(uint32_t id_namespace, 19 FakeSurfaceImpl(uint32_t id_namespace,
20 mojo::InterfaceRequest<mojo::Surface> request) 20 mojo::InterfaceRequest<mojo::Surface> request)
21 : binding_(this, request.Pass()) { 21 : id_namespace_(id_namespace), binding_(this, request.Pass()) {}
22 binding_.client()->SetIdNamespace(id_namespace);
23 }
24 ~FakeSurfaceImpl() override {} 22 ~FakeSurfaceImpl() override {}
25 23
26 // mojo::Surface implementation. 24 // mojo::Surface implementation.
25 void GetIdNamespace(
26 const Surface::GetIdNamespaceCallback& callback) override {
27 callback.Run(id_namespace_);
28 }
29
30 void SetResourceReturner(mojo::ResourceReturnerPtr returner) override {
31 returner_ = returner.Pass();
32 }
33
27 void CreateSurface(uint32_t local_id) override {} 34 void CreateSurface(uint32_t local_id) override {}
28 35
29 void SubmitFrame(uint32_t local_id, 36 void SubmitFrame(uint32_t local_id,
30 mojo::FramePtr frame, 37 mojo::FramePtr frame,
31 const mojo::Closure& callback) override { 38 const mojo::Closure& callback) override {
32 callback.Run(); 39 callback.Run();
33 if (frame->resources.size() == 0u) 40 if (frame->resources.size() == 0u || !returner_)
34 return; 41 return;
35 mojo::Array<mojo::ReturnedResourcePtr> returned; 42 mojo::Array<mojo::ReturnedResourcePtr> returned;
36 returned.resize(frame->resources.size()); 43 returned.resize(frame->resources.size());
37 for (size_t i = 0; i < frame->resources.size(); ++i) { 44 for (size_t i = 0; i < frame->resources.size(); ++i) {
38 auto ret = mojo::ReturnedResource::New(); 45 auto ret = mojo::ReturnedResource::New();
39 ret->id = frame->resources[i]->id; 46 ret->id = frame->resources[i]->id;
40 ret->sync_point = 0u; 47 ret->sync_point = 0u;
41 ret->count = 1; 48 ret->count = 1;
42 ret->lost = false; 49 ret->lost = false;
43 returned[i] = ret.Pass(); 50 returned[i] = ret.Pass();
44 } 51 }
45 binding_.client()->ReturnResources(returned.Pass()); 52 returner_->ReturnResources(returned.Pass());
46 } 53 }
47 54
48 void DestroySurface(uint32_t local_id) override {} 55 void DestroySurface(uint32_t local_id) override {}
49 56
50 void CreateGLES2BoundSurface( 57 void CreateGLES2BoundSurface(
51 mojo::CommandBufferPtr gles2_client, 58 mojo::CommandBufferPtr gles2_client,
52 uint32_t local_id, 59 uint32_t local_id,
53 mojo::SizePtr size, 60 mojo::SizePtr size,
54 mojo::InterfaceRequest<mojo::ViewportParameterListener> listener_request) 61 mojo::InterfaceRequest<mojo::ViewportParameterListener> listener_request)
55 override {} 62 override {}
56 63
57 private: 64 private:
65 uint32_t id_namespace_;
sky 2015/01/31 01:25:28 nit: const.
66 mojo::ResourceReturnerPtr returner_;
58 mojo::StrongBinding<mojo::Surface> binding_; 67 mojo::StrongBinding<mojo::Surface> binding_;
59 68
60 DISALLOW_COPY_AND_ASSIGN(FakeSurfaceImpl); 69 DISALLOW_COPY_AND_ASSIGN(FakeSurfaceImpl);
61 }; 70 };
62 71
63 FakeSurfacesServiceApplication::FakeSurfacesServiceApplication() 72 FakeSurfacesServiceApplication::FakeSurfacesServiceApplication()
64 : next_id_namespace_(1u) { 73 : next_id_namespace_(1u) {
65 } 74 }
66 75
67 FakeSurfacesServiceApplication::~FakeSurfacesServiceApplication() { 76 FakeSurfacesServiceApplication::~FakeSurfacesServiceApplication() {
(...skipping 15 matching lines...) Expand all
83 new FakeSurfaceImpl(next_id_namespace_++, request.Pass()); 92 new FakeSurfaceImpl(next_id_namespace_++, request.Pass());
84 } 93 }
85 94
86 } // namespace fake_surfaces 95 } // namespace fake_surfaces
87 96
88 MojoResult MojoMain(MojoHandle shell_handle) { 97 MojoResult MojoMain(MojoHandle shell_handle) {
89 mojo::ApplicationRunnerChromium runner( 98 mojo::ApplicationRunnerChromium runner(
90 new fake_surfaces::FakeSurfacesServiceApplication); 99 new fake_surfaces::FakeSurfacesServiceApplication);
91 return runner.Run(shell_handle); 100 return runner.Run(shell_handle);
92 } 101 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698