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 package org.chromium.chromoting.jni; | 5 package org.chromium.chromoting.jni; |
6 | 6 |
7 import android.app.Activity; | 7 import android.app.Activity; |
8 import android.app.AlertDialog; | 8 import android.app.AlertDialog; |
9 import android.content.Context; | 9 import android.content.Context; |
10 import android.content.DialogInterface; | 10 import android.content.DialogInterface; |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 if (sRedrawCallback != null) | 191 if (sRedrawCallback != null) |
192 sRedrawCallback.run(); | 192 sRedrawCallback.run(); |
193 } | 193 } |
194 | 194 |
195 /** | 195 /** |
196 * Obtains the image buffer. | 196 * Obtains the image buffer. |
197 * This should not be called from the UI thread. (We prefer the native graph
ics thread.) | 197 * This should not be called from the UI thread. (We prefer the native graph
ics thread.) |
198 */ | 198 */ |
199 public static Bitmap retrieveVideoFrame() { | 199 public static Bitmap retrieveVideoFrame() { |
200 if (Looper.myLooper() == Looper.getMainLooper()) { | 200 if (Looper.myLooper() == Looper.getMainLooper()) { |
201 Log.w("deskview", "Canvas being redrawn on UI thread"); | 201 Log.w("jniiface", "Canvas being redrawn on UI thread"); |
202 } | 202 } |
203 | 203 |
204 if (!sConnected) { | 204 if (!sConnected) { |
205 return null; | 205 return null; |
206 } | 206 } |
207 | 207 |
208 int[] frame = new int[sWidth * sHeight]; | 208 int[] frame = new int[sWidth * sHeight]; |
209 | 209 |
210 sBuffer.order(ByteOrder.LITTLE_ENDIAN); | 210 sBuffer.order(ByteOrder.LITTLE_ENDIAN); |
211 sBuffer.asIntBuffer().get(frame, 0, frame.length); | 211 sBuffer.asIntBuffer().get(frame, 0, frame.length); |
212 | 212 |
213 return Bitmap.createBitmap(frame, 0, sWidth, sWidth, sHeight, Bitmap.Con
fig.ARGB_8888); | 213 return Bitmap.createBitmap(frame, 0, sWidth, sWidth, sHeight, Bitmap.Con
fig.ARGB_8888); |
214 } | 214 } |
215 | 215 |
216 /** Moves the mouse cursor, possibly while clicking. */ | 216 /** Moves the mouse cursor, possibly while clicking the specified (nonnegati
ve) button. */ |
217 public static void mouseAction(int x, int y, int whichButton, boolean button
Down) { | 217 public static void mouseAction(int x, int y, int whichButton, boolean button
Down) { |
218 if (!sConnected) { | 218 if (!sConnected) { |
219 return; | 219 return; |
220 } | 220 } |
221 | 221 |
222 mouseActionNative(x, y, whichButton, buttonDown); | 222 mouseActionNative(x, y, whichButton, buttonDown); |
223 } | 223 } |
224 | 224 |
225 /** Presses and releases the specified key. */ | 225 /** Presses and releases the specified (nonnegative) key. */ |
226 public static void keyboardAction(int keyCode, boolean keyDown) { | 226 public static void keyboardAction(int keyCode, boolean keyDown) { |
227 if (!sConnected) { | 227 if (!sConnected) { |
228 return; | 228 return; |
229 } | 229 } |
230 | 230 |
231 keyboardActionNative(keyCode, keyDown); | 231 keyboardActionNative(keyCode, keyDown); |
232 } | 232 } |
233 | 233 |
234 /** Performs the native response to the user's PIN. */ | 234 /** Performs the native response to the user's PIN. */ |
235 private static native void authenticationResponse(String pin); | 235 private static native void authenticationResponse(String pin); |
236 | 236 |
237 /** Schedules a redraw on the native graphics thread. */ | 237 /** Schedules a redraw on the native graphics thread. */ |
238 private static native void scheduleRedrawNative(); | 238 private static native void scheduleRedrawNative(); |
239 | 239 |
240 /** Passes mouse information to the native handling code. */ | 240 /** Passes mouse information to the native handling code. */ |
241 private static native void mouseActionNative(int x, int y, int whichButton,
boolean buttonDown); | 241 private static native void mouseActionNative(int x, int y, int whichButton,
boolean buttonDown); |
242 | 242 |
243 /** Passes key press information to the native handling code. */ | 243 /** Passes key press information to the native handling code. */ |
244 private static native void keyboardActionNative(int keyCode, boolean keyDown
); | 244 private static native void keyboardActionNative(int keyCode, boolean keyDown
); |
245 } | 245 } |
OLD | NEW |