| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <stdio.h> | 5 #include <stdio.h> |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "mojo/common/bindings_support_impl.h" | 9 #include "mojo/common/bindings_support_impl.h" |
| 10 #include "mojo/examples/sample_app/gles2_client_impl.h" | 10 #include "mojo/examples/sample_app/gles2_client_impl.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #endif | 22 #endif |
| 23 #define SAMPLE_APP_EXPORT __declspec(dllexport) | 23 #define SAMPLE_APP_EXPORT __declspec(dllexport) |
| 24 #else | 24 #else |
| 25 #define CDECL | 25 #define CDECL |
| 26 #define SAMPLE_APP_EXPORT __attribute__((visibility("default"))) | 26 #define SAMPLE_APP_EXPORT __attribute__((visibility("default"))) |
| 27 #endif | 27 #endif |
| 28 | 28 |
| 29 namespace mojo { | 29 namespace mojo { |
| 30 namespace examples { | 30 namespace examples { |
| 31 | 31 |
| 32 class SampleApp : public ShellClientStub { | 32 class SampleApp : public ShellClient { |
| 33 public: | 33 public: |
| 34 explicit SampleApp(ScopedMessagePipeHandle shell_handle) | 34 explicit SampleApp(ScopedMessagePipeHandle shell_handle) |
| 35 : shell_(shell_handle.Pass()) { | 35 : shell_(shell_handle.Pass(), this) { |
| 36 shell_.SetPeer(this); | |
| 37 | 36 |
| 38 MessagePipe pipe; | 37 MessagePipe pipe; |
| 39 native_viewport_client_.reset( | 38 native_viewport_client_.reset( |
| 40 new NativeViewportClientImpl(pipe.handle0.Pass())); | 39 new NativeViewportClientImpl(pipe.handle0.Pass())); |
| 41 mojo::AllocationScope scope; | 40 mojo::AllocationScope scope; |
| 42 shell_->Connect("mojo:mojo_native_viewport_service", pipe.handle1.Pass()); | 41 shell_->Connect("mojo:mojo_native_viewport_service", pipe.handle1.Pass()); |
| 43 } | 42 } |
| 44 | 43 |
| 45 virtual void AcceptConnection(ScopedMessagePipeHandle handle) MOJO_OVERRIDE { | 44 virtual void AcceptConnection(ScopedMessagePipeHandle handle) MOJO_OVERRIDE { |
| 46 NOTREACHED() << "SampleApp can't be connected to."; | 45 NOTREACHED() << "SampleApp can't be connected to."; |
| 47 } | 46 } |
| 48 | 47 |
| 49 private: | 48 private: |
| 50 class NativeViewportClientImpl : public mojo::NativeViewportClientStub { | 49 class NativeViewportClientImpl : public mojo::NativeViewportClient { |
| 51 public: | 50 public: |
| 52 explicit NativeViewportClientImpl(ScopedMessagePipeHandle viewport_handle) | 51 explicit NativeViewportClientImpl(ScopedMessagePipeHandle viewport_handle) |
| 53 : viewport_(viewport_handle.Pass()) { | 52 : viewport_(viewport_handle.Pass(), this) { |
| 54 viewport_.SetPeer(this); | |
| 55 viewport_->Open(); | 53 viewport_->Open(); |
| 56 | 54 |
| 57 MessagePipe pipe; | 55 MessagePipe pipe; |
| 58 gles2_client_.reset(new GLES2ClientImpl(pipe.handle0.Pass())); | 56 gles2_client_.reset(new GLES2ClientImpl(pipe.handle0.Pass())); |
| 59 viewport_->CreateGLES2Context(pipe.handle1.Pass()); | 57 viewport_->CreateGLES2Context(pipe.handle1.Pass()); |
| 60 } | 58 } |
| 61 | 59 |
| 62 virtual ~NativeViewportClientImpl() {} | 60 virtual ~NativeViewportClientImpl() {} |
| 63 | 61 |
| 64 virtual void OnCreated() MOJO_OVERRIDE { | 62 virtual void OnCreated() MOJO_OVERRIDE { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 94 MojoGLES2Initialize(); | 92 MojoGLES2Initialize(); |
| 95 | 93 |
| 96 mojo::examples::SampleApp app( | 94 mojo::examples::SampleApp app( |
| 97 mojo::MakeScopedHandle(mojo::MessagePipeHandle(shell_handle)).Pass()); | 95 mojo::MakeScopedHandle(mojo::MessagePipeHandle(shell_handle)).Pass()); |
| 98 loop.Run(); | 96 loop.Run(); |
| 99 | 97 |
| 100 MojoGLES2Terminate(); | 98 MojoGLES2Terminate(); |
| 101 mojo::BindingsSupport::Set(NULL); | 99 mojo::BindingsSupport::Set(NULL); |
| 102 return MOJO_RESULT_OK; | 100 return MOJO_RESULT_OK; |
| 103 } | 101 } |
| OLD | NEW |