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

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

Issue 361123002: Mojo surfaces service and example app (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "mojo/services/surfaces/surfaces_impl.h"
6
7 #include "cc/output/compositor_frame.h"
8 #include "cc/resources/returned_resource.h"
9 #include "cc/surfaces/display.h"
10 #include "cc/surfaces/surface_id_allocator.h"
11 #include "mojo/cc/context_provider_mojo.h"
12 #include "mojo/public/cpp/gles2/gles2.h"
13 #include "mojo/services/public/cpp/geometry/geometry_type_converters.h"
14 #include "mojo/services/public/cpp/surfaces/surfaces_type_converters.h"
15
16 namespace mojo {
17 namespace surfaces {
18
19 SurfacesImpl::SurfacesImpl(ApplicationConnection* app, Context* context)
20 : context_(context),
21 factory_(context_->Manager(), this),
22 id_namespace_(context->IdNamespace()) {
23 }
24
25 SurfacesImpl::~SurfacesImpl() {
26 }
27
28 void SurfacesImpl::OnConnectionEstablished() {
29 client()->SetIdNamespace(id_namespace_);
30 }
31
32 void SurfacesImpl::CreateSurface(SurfaceIdPtr id, mojo::SizePtr size) {
33 cc::SurfaceId cc_id = id.To<cc::SurfaceId>();
34 if (cc::SurfaceIdAllocator::NamespaceForId(cc_id) != id_namespace_) {
35 // Bad message, do something bad to the caller?
36 NOTREACHED();
37 return;
38 }
39 factory_.Create(id.To<cc::SurfaceId>(), size.To<gfx::Size>());
40 }
41
42 void SurfacesImpl::SubmitFrame(SurfaceIdPtr id, FramePtr frame_ptr) {
43 cc::SurfaceId cc_id = id.To<cc::SurfaceId>();
44 if (cc::SurfaceIdAllocator::NamespaceForId(cc_id) != id_namespace_) {
45 // Bad message, do something bad to the caller?
46 NOTREACHED();
47 return;
48 }
49 factory_.SubmitFrame(id.To<cc::SurfaceId>(), mojo::ConvertTo(frame_ptr));
50 context_->FrameSubmitted();
51 }
52
53 void SurfacesImpl::DestroySurface(SurfaceIdPtr id) {
54 cc::SurfaceId cc_id = id.To<cc::SurfaceId>();
55 if (cc::SurfaceIdAllocator::NamespaceForId(cc_id) != id_namespace_) {
56 // Bad message, do something bad to the caller?
57 NOTREACHED();
58 return;
59 }
60 factory_.Destroy(id.To<cc::SurfaceId>());
61 }
62
63 void SurfacesImpl::CreateGLES2BoundSurface(CommandBufferPtr gles2_client,
64 SurfaceIdPtr id,
65 mojo::SizePtr size) {
66 command_buffer_handle_ = gles2_client.PassMessagePipe();
67
68 cc::SurfaceId cc_id = id.To<cc::SurfaceId>();
69 if (cc::SurfaceIdAllocator::NamespaceForId(cc_id) != id_namespace_) {
70 // Bad message, do something bad to the caller?
71 NOTREACHED();
72 return;
73 }
74 if (!display_) {
75 display_.reset(new cc::Display(this, context_->Manager(), NULL));
76 context_->SetDisplay(display_.get());
Ben Goodger (Google) 2014/07/07 21:07:34 this means there can be only app connected to the
jamesr 2014/07/07 21:11:40 No - as the patch comments say the display hookup
77 }
78 factory_.Create(cc_id, size.To<gfx::Size>());
79 display_->Resize(cc_id, size.To<gfx::Size>());
80 }
81
82 void SurfacesImpl::ReturnResources(const cc::ReturnedResourceArray& resources) {
83 Array<ReturnedResourcePtr> ret(resources.size());
84 for (size_t i = 0; i < resources.size(); ++i) {
85 ret[i] = ReturnedResource::From(resources[i]);
86 }
87 client()->ReturnResources(ret.Pass());
88 }
89
90 scoped_ptr<cc::OutputSurface> SurfacesImpl::CreateOutputSurface() {
91 static GLES2Initializer* gles2 = new GLES2Initializer;
92 DCHECK(gles2);
93 return make_scoped_ptr(new cc::OutputSurface(
94 new ContextProviderMojo(command_buffer_handle_.Pass())));
95 }
96
97 } // namespace surfaces
98 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698