| OLD | NEW |
| (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 "base/threading/platform_thread.h" | |
| 6 #include "mojo/examples/surfaces_app/child_gl_impl.h" | |
| 7 #include "mojo/public/cpp/application/application_connection.h" | |
| 8 #include "mojo/public/cpp/application/application_delegate.h" | |
| 9 #include "mojo/public/cpp/application/application_impl.h" | |
| 10 #include "mojo/public/cpp/bindings/string.h" | |
| 11 #include "mojo/services/public/interfaces/gpu/gpu.mojom.h" | |
| 12 | |
| 13 namespace mojo { | |
| 14 namespace examples { | |
| 15 | |
| 16 class ChildGLApp : public ApplicationDelegate, public InterfaceFactory<Child> { | |
| 17 public: | |
| 18 ChildGLApp() {} | |
| 19 virtual ~ChildGLApp() {} | |
| 20 | |
| 21 virtual void Initialize(ApplicationImpl* app) OVERRIDE { | |
| 22 surfaces_service_connection_ = | |
| 23 app->ConnectToApplication("mojo:mojo_surfaces_service"); | |
| 24 // TODO(jamesr): Should be mojo:mojo_gpu_service | |
| 25 app->ConnectToService("mojo:mojo_native_viewport_service", &gpu_service_); | |
| 26 } | |
| 27 | |
| 28 // ApplicationDelegate implementation. | |
| 29 virtual bool ConfigureIncomingConnection( | |
| 30 ApplicationConnection* connection) OVERRIDE { | |
| 31 connection->AddService(this); | |
| 32 return true; | |
| 33 } | |
| 34 | |
| 35 // InterfaceFactory<Child> implementation. | |
| 36 virtual void Create(ApplicationConnection* connection, | |
| 37 InterfaceRequest<Child> request) OVERRIDE { | |
| 38 CommandBufferPtr command_buffer; | |
| 39 gpu_service_->CreateOffscreenGLES2Context(Get(&command_buffer)); | |
| 40 BindToRequest( | |
| 41 new ChildGLImpl(surfaces_service_connection_, command_buffer.Pass()), | |
| 42 &request); | |
| 43 } | |
| 44 | |
| 45 private: | |
| 46 ApplicationConnection* surfaces_service_connection_; | |
| 47 GpuPtr gpu_service_; | |
| 48 | |
| 49 DISALLOW_COPY_AND_ASSIGN(ChildGLApp); | |
| 50 }; | |
| 51 | |
| 52 } // namespace examples | |
| 53 | |
| 54 // static | |
| 55 ApplicationDelegate* ApplicationDelegate::Create() { | |
| 56 return new examples::ChildGLApp(); | |
| 57 } | |
| 58 | |
| 59 } // namespace mojo | |
| OLD | NEW |