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 "mojo/examples/sample_app/gles2_client_impl.h" | 8 #include "mojo/examples/sample_app/gles2_client_impl.h" |
9 #include "mojo/public/bindings/lib/bindings_support.h" | 9 #include "mojo/public/bindings/lib/bindings_support.h" |
10 #include "mojo/public/bindings/lib/remote_ptr.h" | 10 #include "mojo/public/bindings/lib/remote_ptr.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 gles2_client_.reset(new GLES2ClientImpl(pipe.handle0.Pass())); | 55 gles2_client_.reset(new GLES2ClientImpl(pipe.handle0.Pass())); |
56 viewport_->CreateGLES2Context(pipe.handle1.Pass()); | 56 viewport_->CreateGLES2Context(pipe.handle1.Pass()); |
57 } | 57 } |
58 | 58 |
59 virtual ~NativeViewportClientImpl() {} | 59 virtual ~NativeViewportClientImpl() {} |
60 | 60 |
61 virtual void OnCreated() MOJO_OVERRIDE { | 61 virtual void OnCreated() MOJO_OVERRIDE { |
62 } | 62 } |
63 | 63 |
64 virtual void OnDestroyed() MOJO_OVERRIDE { | 64 virtual void OnDestroyed() MOJO_OVERRIDE { |
65 utility::RunLoop::current()->Quit(); | 65 RunLoop::current()->Quit(); |
66 } | 66 } |
67 | 67 |
68 virtual void OnEvent(const Event& event) MOJO_OVERRIDE { | 68 virtual void OnEvent(const Event& event) MOJO_OVERRIDE { |
69 if (!event.location().is_null()) { | 69 if (!event.location().is_null()) { |
70 gles2_client_->HandleInputEvent(event); | 70 gles2_client_->HandleInputEvent(event); |
71 viewport_->AckEvent(event); | 71 viewport_->AckEvent(event); |
72 } | 72 } |
73 } | 73 } |
74 | 74 |
75 private: | 75 private: |
76 scoped_ptr<GLES2ClientImpl> gles2_client_; | 76 scoped_ptr<GLES2ClientImpl> gles2_client_; |
77 RemotePtr<NativeViewport> viewport_; | 77 RemotePtr<NativeViewport> viewport_; |
78 }; | 78 }; |
79 mojo::RemotePtr<Shell> shell_; | 79 mojo::RemotePtr<Shell> shell_; |
80 scoped_ptr<NativeViewportClientImpl> native_viewport_client_; | 80 scoped_ptr<NativeViewportClientImpl> native_viewport_client_; |
81 }; | 81 }; |
82 | 82 |
83 } // namespace examples | 83 } // namespace examples |
84 } // namespace mojo | 84 } // namespace mojo |
85 | 85 |
86 extern "C" SAMPLE_APP_EXPORT MojoResult CDECL MojoMain( | 86 extern "C" SAMPLE_APP_EXPORT MojoResult CDECL MojoMain( |
87 MojoHandle shell_handle) { | 87 MojoHandle shell_handle) { |
88 mojo::utility::Environment env; | 88 mojo::Environment env; |
89 mojo::utility::RunLoop loop; | 89 mojo::RunLoop loop; |
90 MojoGLES2Initialize(); | 90 MojoGLES2Initialize(); |
91 | 91 |
92 mojo::examples::SampleApp app( | 92 mojo::examples::SampleApp app( |
93 mojo::MakeScopedHandle(mojo::MessagePipeHandle(shell_handle)).Pass()); | 93 mojo::MakeScopedHandle(mojo::MessagePipeHandle(shell_handle)).Pass()); |
94 loop.Run(); | 94 loop.Run(); |
95 | 95 |
96 MojoGLES2Terminate(); | 96 MojoGLES2Terminate(); |
97 mojo::BindingsSupport::Set(NULL); | 97 mojo::BindingsSupport::Set(NULL); |
98 return MOJO_RESULT_OK; | 98 return MOJO_RESULT_OK; |
99 } | 99 } |
OLD | NEW |