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