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/bind.h" | 8 #include "base/bind.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "examples/spinning_cube/gles2_client_impl.h" | 10 #include "examples/spinning_cube/gles2_client_impl.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 void OnMetricsChanged(mojo::ViewportMetricsPtr metrics) { | 55 void OnMetricsChanged(mojo::ViewportMetricsPtr metrics) { |
56 assert(metrics); | 56 assert(metrics); |
57 gles2_client_->SetSize(*metrics->size); | 57 gles2_client_->SetSize(*metrics->size); |
58 viewport_->RequestMetrics( | 58 viewport_->RequestMetrics( |
59 base::Bind(&SpinningCubeApp::OnMetricsChanged, base::Unretained(this))); | 59 base::Bind(&SpinningCubeApp::OnMetricsChanged, base::Unretained(this))); |
60 } | 60 } |
61 | 61 |
62 void OnEvent(mojo::EventPtr event, | 62 void OnEvent(mojo::EventPtr event, |
63 const mojo::Callback<void()>& callback) override { | 63 const mojo::Callback<void()>& callback) override { |
64 assert(event); | 64 assert(event); |
65 if (event->location_data && event->location_data->in_view_location) | 65 if (event->pointer_data.get()) |
66 gles2_client_->HandleInputEvent(*event); | 66 gles2_client_->HandleInputEvent(*event); |
67 callback.Run(); | 67 callback.Run(); |
68 } | 68 } |
69 | 69 |
70 private: | 70 private: |
71 void SetEventDispatcher() { | 71 void SetEventDispatcher() { |
72 mojo::NativeViewportEventDispatcherPtr ptr; | 72 mojo::NativeViewportEventDispatcherPtr ptr; |
73 dispatcher_binding_.Bind(GetProxy(&ptr)); | 73 dispatcher_binding_.Bind(GetProxy(&ptr)); |
74 viewport_->SetEventDispatcher(ptr.Pass()); | 74 viewport_->SetEventDispatcher(ptr.Pass()); |
75 } | 75 } |
76 | 76 |
77 // ErrorHandler implementation. | 77 // ErrorHandler implementation. |
78 void OnConnectionError() override { mojo::RunLoop::current()->Quit(); } | 78 void OnConnectionError() override { mojo::RunLoop::current()->Quit(); } |
79 | 79 |
80 scoped_ptr<GLES2ClientImpl> gles2_client_; | 80 scoped_ptr<GLES2ClientImpl> gles2_client_; |
81 mojo::NativeViewportPtr viewport_; | 81 mojo::NativeViewportPtr viewport_; |
82 mojo::ContextProviderPtr onscreen_context_provider_; | 82 mojo::ContextProviderPtr onscreen_context_provider_; |
83 mojo::Binding<NativeViewportEventDispatcher> dispatcher_binding_; | 83 mojo::Binding<NativeViewportEventDispatcher> dispatcher_binding_; |
84 | 84 |
85 DISALLOW_COPY_AND_ASSIGN(SpinningCubeApp); | 85 DISALLOW_COPY_AND_ASSIGN(SpinningCubeApp); |
86 }; | 86 }; |
87 | 87 |
88 } // namespace examples | 88 } // namespace examples |
89 | 89 |
90 MojoResult MojoMain(MojoHandle shell_handle) { | 90 MojoResult MojoMain(MojoHandle shell_handle) { |
91 mojo::ApplicationRunner runner(new examples::SpinningCubeApp); | 91 mojo::ApplicationRunner runner(new examples::SpinningCubeApp); |
92 return runner.Run(shell_handle); | 92 return runner.Run(shell_handle); |
93 } | 93 } |
OLD | NEW |