OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "blimp/client/android/blimp_view.h" | 5 #include "blimp/client/android/blimp_view.h" |
6 | 6 |
7 #include <android/native_window_jni.h> | 7 #include <android/native_window_jni.h> |
8 | 8 |
9 #include "blimp/client/compositor/blimp_compositor_android.h" | 9 #include "blimp/client/compositor/blimp_compositor_android.h" |
10 #include "jni/BlimpView_jni.h" | 10 #include "jni/BlimpView_jni.h" |
11 #include "ui/events/android/motion_event_android.h" | |
11 #include "ui/gfx/geometry/size.h" | 12 #include "ui/gfx/geometry/size.h" |
12 | 13 |
13 namespace blimp { | 14 namespace blimp { |
14 | 15 |
15 // static | 16 // static |
16 static jlong Init(JNIEnv* env, | 17 static jlong Init(JNIEnv* env, |
17 const JavaParamRef<jobject>& jobj, | 18 const JavaParamRef<jobject>& jobj, |
18 jint real_width, | 19 jint real_width, |
19 jint real_height, | 20 jint real_height, |
20 jint width, | 21 jint width, |
21 jint height, | 22 jint height, |
22 jfloat dp_to_px) { | 23 jfloat dp_to_px) { |
23 return reinterpret_cast<intptr_t>( | 24 return reinterpret_cast<intptr_t>( |
24 new BlimpView(env, jobj, gfx::Size(real_width, real_height), | 25 new BlimpView(env, jobj, gfx::Size(real_width, real_height), |
25 gfx::Size(width, height), dp_to_px)); | 26 gfx::Size(width, height), dp_to_px)); |
26 } | 27 } |
27 | 28 |
28 // static | 29 // static |
29 bool BlimpView::RegisterJni(JNIEnv* env) { | 30 bool BlimpView::RegisterJni(JNIEnv* env) { |
30 return RegisterNativesImpl(env); | 31 return RegisterNativesImpl(env); |
31 } | 32 } |
32 | 33 |
33 BlimpView::BlimpView(JNIEnv* env, | 34 BlimpView::BlimpView(JNIEnv* env, |
34 const JavaParamRef<jobject>& jobj, | 35 const JavaParamRef<jobject>& jobj, |
35 const gfx::Size& real_size, | 36 const gfx::Size& real_size, |
36 const gfx::Size& size, | 37 const gfx::Size& size, |
37 float dp_to_px) | 38 float dp_to_px) |
38 : compositor_(BlimpCompositorAndroid::Create(real_size, size, dp_to_px)), | 39 : device_scale_factor_(dp_to_px), |
40 compositor_(BlimpCompositorAndroid::Create(real_size, size, dp_to_px)), | |
39 current_surface_format_(0), | 41 current_surface_format_(0), |
40 window_(gfx::kNullAcceleratedWidget) { | 42 window_(gfx::kNullAcceleratedWidget) { |
41 java_obj_.Reset(env, jobj); | 43 java_obj_.Reset(env, jobj); |
42 } | 44 } |
43 | 45 |
44 BlimpView::~BlimpView() { | 46 BlimpView::~BlimpView() { |
45 ReleaseAcceleratedWidget(); | 47 ReleaseAcceleratedWidget(); |
46 } | 48 } |
47 | 49 |
48 void BlimpView::Destroy(JNIEnv* env, jobject jobj) { | 50 void BlimpView::Destroy(JNIEnv* env, jobject jobj) { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
87 | 89 |
88 void BlimpView::ReleaseAcceleratedWidget() { | 90 void BlimpView::ReleaseAcceleratedWidget() { |
89 if (window_ == gfx::kNullAcceleratedWidget) | 91 if (window_ == gfx::kNullAcceleratedWidget) |
90 return; | 92 return; |
91 | 93 |
92 compositor_->ReleaseAcceleratedWidget(); | 94 compositor_->ReleaseAcceleratedWidget(); |
93 ANativeWindow_release(window_); | 95 ANativeWindow_release(window_); |
94 window_ = gfx::kNullAcceleratedWidget; | 96 window_ = gfx::kNullAcceleratedWidget; |
95 } | 97 } |
96 | 98 |
99 jboolean BlimpView::OnTouchEvent(JNIEnv* env, | |
100 jobject obj, | |
101 jobject motion_event, | |
102 jlong time_ms, | |
103 jint android_action, | |
104 jint pointer_count, | |
105 jint history_size, | |
106 jint action_index, | |
107 jfloat pos_x_0, | |
108 jfloat pos_y_0, | |
109 jfloat pos_x_1, | |
110 jfloat pos_y_1, | |
111 jint pointer_id_0, | |
112 jint pointer_id_1, | |
113 jfloat touch_major_0, | |
114 jfloat touch_major_1, | |
115 jfloat touch_minor_0, | |
116 jfloat touch_minor_1, | |
117 jfloat orientation_0, | |
118 jfloat orientation_1, | |
119 jfloat tilt_0, | |
120 jfloat tilt_1, | |
121 jfloat raw_pos_x, | |
122 jfloat raw_pos_y, | |
123 jint android_tool_type_0, | |
124 jint android_tool_type_1, | |
125 jint android_button_state, | |
126 jint android_meta_state) { | |
127 ui::MotionEventAndroid::Pointer pointer0(pointer_id_0, | |
nyquist
2015/12/08 22:24:24
Seems like you're hitting an issue here:
../../bl
Khushal
2015/12/09 00:40:44
Thanks. Needed a deps fix.
| |
128 pos_x_0, | |
129 pos_y_0, | |
130 touch_major_0, | |
131 touch_minor_0, | |
132 orientation_0, | |
133 tilt_0, | |
134 android_tool_type_0); | |
135 ui::MotionEventAndroid::Pointer pointer1(pointer_id_1, | |
136 pos_x_1, | |
137 pos_y_1, | |
138 touch_major_1, | |
139 touch_minor_1, | |
140 orientation_1, | |
141 tilt_1, | |
142 android_tool_type_1); | |
143 ui::MotionEventAndroid event(1.f / device_scale_factor_, | |
144 env, | |
145 motion_event, | |
146 time_ms, | |
147 android_action, | |
148 pointer_count, | |
149 history_size, | |
150 action_index, | |
151 android_button_state, | |
152 android_meta_state, | |
153 raw_pos_x - pos_x_0, | |
154 raw_pos_y - pos_y_0, | |
155 pointer0, | |
156 pointer1); | |
157 | |
158 return compositor_->OnTouchEvent(event); | |
159 } | |
160 | |
97 } // namespace blimp | 161 } // namespace blimp |
OLD | NEW |