| 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 "base/macros.h" | 5 #include "base/macros.h" |
| 6 #include "base/memory/ref_counted.h" | 6 #include "base/memory/ref_counted.h" |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 #include "mojo/examples/pepper_container_app/mojo_ppapi_globals.h" | 10 #include "mojo/examples/pepper_container_app/mojo_ppapi_globals.h" |
| 11 #include "mojo/examples/pepper_container_app/plugin_instance.h" | 11 #include "mojo/examples/pepper_container_app/plugin_instance.h" |
| 12 #include "mojo/examples/pepper_container_app/plugin_module.h" | 12 #include "mojo/examples/pepper_container_app/plugin_module.h" |
| 13 #include "mojo/examples/pepper_container_app/type_converters.h" | 13 #include "mojo/examples/pepper_container_app/type_converters.h" |
| 14 #include "mojo/public/cpp/bindings/allocation_scope.h" | 14 #include "mojo/public/cpp/bindings/allocation_scope.h" |
| 15 #include "mojo/public/cpp/bindings/remote_ptr.h" | |
| 16 #include "mojo/public/cpp/environment/environment.h" | 15 #include "mojo/public/cpp/environment/environment.h" |
| 17 #include "mojo/public/cpp/gles2/gles2.h" | 16 #include "mojo/public/cpp/gles2/gles2.h" |
| 18 #include "mojo/public/cpp/shell/application.h" | 17 #include "mojo/public/cpp/shell/application.h" |
| 19 #include "mojo/public/cpp/system/core.h" | 18 #include "mojo/public/cpp/system/core.h" |
| 20 #include "mojo/public/interfaces/shell/shell.mojom.h" | 19 #include "mojo/public/interfaces/shell/shell.mojom.h" |
| 21 #include "mojo/services/native_viewport/native_viewport.mojom.h" | 20 #include "mojo/services/native_viewport/native_viewport.mojom.h" |
| 22 #include "ppapi/c/pp_rect.h" | 21 #include "ppapi/c/pp_rect.h" |
| 23 #include "ppapi/shared_impl/proxy_lock.h" | 22 #include "ppapi/shared_impl/proxy_lock.h" |
| 24 | 23 |
| 25 #if defined(OS_WIN) | 24 #if defined(OS_WIN) |
| (...skipping 10 matching lines...) Expand all Loading... |
| 36 namespace examples { | 35 namespace examples { |
| 37 | 36 |
| 38 class PepperContainerApp: public Application, | 37 class PepperContainerApp: public Application, |
| 39 public NativeViewportClient, | 38 public NativeViewportClient, |
| 40 public MojoPpapiGlobals::Delegate { | 39 public MojoPpapiGlobals::Delegate { |
| 41 public: | 40 public: |
| 42 explicit PepperContainerApp(MojoHandle shell_handle) | 41 explicit PepperContainerApp(MojoHandle shell_handle) |
| 43 : Application(shell_handle), | 42 : Application(shell_handle), |
| 44 ppapi_globals_(this), | 43 ppapi_globals_(this), |
| 45 plugin_module_(new PluginModule) { | 44 plugin_module_(new PluginModule) { |
| 46 InterfacePipe<NativeViewport, AnyInterface> viewport_pipe; | |
| 47 mojo::AllocationScope scope; | 45 mojo::AllocationScope scope; |
| 48 shell()->Connect("mojo:mojo_native_viewport_service", | 46 |
| 49 viewport_pipe.handle_to_peer.Pass()); | 47 ConnectTo("mojo:mojo_native_viewport_service", &viewport_); |
| 50 viewport_.reset(viewport_pipe.handle_to_self.Pass(), this); | 48 viewport_->SetClient(this); |
| 49 |
| 51 Rect::Builder rect; | 50 Rect::Builder rect; |
| 52 Point::Builder point; | 51 Point::Builder point; |
| 53 point.set_x(10); | 52 point.set_x(10); |
| 54 point.set_y(10); | 53 point.set_y(10); |
| 55 rect.set_position(point.Finish()); | 54 rect.set_position(point.Finish()); |
| 56 Size::Builder size; | 55 Size::Builder size; |
| 57 size.set_width(800); | 56 size.set_width(800); |
| 58 size.set_height(600); | 57 size.set_height(600); |
| 59 rect.set_size(size.Finish()); | 58 rect.set_size(size.Finish()); |
| 60 viewport_->Create(rect.Finish()); | 59 viewport_->Create(rect.Finish()); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 // MojoPpapiGlobals::Delegate implementation. | 102 // MojoPpapiGlobals::Delegate implementation. |
| 104 virtual ScopedMessagePipeHandle CreateGLES2Context() OVERRIDE { | 103 virtual ScopedMessagePipeHandle CreateGLES2Context() OVERRIDE { |
| 105 MessagePipe gles2_pipe; | 104 MessagePipe gles2_pipe; |
| 106 viewport_->CreateGLES2Context(gles2_pipe.handle1.Pass()); | 105 viewport_->CreateGLES2Context(gles2_pipe.handle1.Pass()); |
| 107 return gles2_pipe.handle0.Pass(); | 106 return gles2_pipe.handle0.Pass(); |
| 108 } | 107 } |
| 109 | 108 |
| 110 private: | 109 private: |
| 111 MojoPpapiGlobals ppapi_globals_; | 110 MojoPpapiGlobals ppapi_globals_; |
| 112 | 111 |
| 113 RemotePtr<NativeViewport> viewport_; | 112 NativeViewportPtr viewport_; |
| 114 scoped_refptr<PluginModule> plugin_module_; | 113 scoped_refptr<PluginModule> plugin_module_; |
| 115 scoped_ptr<PluginInstance> plugin_instance_; | 114 scoped_ptr<PluginInstance> plugin_instance_; |
| 116 | 115 |
| 117 DISALLOW_COPY_AND_ASSIGN(PepperContainerApp); | 116 DISALLOW_COPY_AND_ASSIGN(PepperContainerApp); |
| 118 }; | 117 }; |
| 119 | 118 |
| 120 } // namespace examples | 119 } // namespace examples |
| 121 } // namespace mojo | 120 } // namespace mojo |
| 122 | 121 |
| 123 extern "C" PEPPER_CONTAINER_APP_EXPORT MojoResult CDECL MojoMain( | 122 extern "C" PEPPER_CONTAINER_APP_EXPORT MojoResult CDECL MojoMain( |
| 124 MojoHandle shell_handle) { | 123 MojoHandle shell_handle) { |
| 125 mojo::Environment env; | 124 mojo::Environment env; |
| 126 mojo::GLES2Initializer gles2; | 125 mojo::GLES2Initializer gles2; |
| 127 base::MessageLoop run_loop; | 126 base::MessageLoop run_loop; |
| 128 mojo::examples::PepperContainerApp app(shell_handle); | 127 mojo::examples::PepperContainerApp app(shell_handle); |
| 129 | 128 |
| 130 run_loop.Run(); | 129 run_loop.Run(); |
| 131 return MOJO_RESULT_OK; | 130 return MOJO_RESULT_OK; |
| 132 } | 131 } |
| OLD | NEW |