Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(125)

Unified Diff: remoting/android/java/src/org/chromium/chromoting/jni/JniInterface.java

Issue 23532072: Draw the mouse cursor in Chromoting Android client (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: remoting/android/java/src/org/chromium/chromoting/jni/JniInterface.java
diff --git a/remoting/android/java/src/org/chromium/chromoting/jni/JniInterface.java b/remoting/android/java/src/org/chromium/chromoting/jni/JniInterface.java
index 4508e58786b83612b510ae15dfb0403986ab1d01..673dbb2872b493092bd5bf8897cffa51ae3b29fc 100644
--- a/remoting/android/java/src/org/chromium/chromoting/jni/JniInterface.java
+++ b/remoting/android/java/src/org/chromium/chromoting/jni/JniInterface.java
@@ -11,6 +11,7 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
+import android.graphics.Point;
import android.os.Looper;
import android.text.InputType;
import android.util.Log;
@@ -123,6 +124,12 @@ public class JniInterface {
/** Performs the native portion of the cleanup. */
private static native void disconnectNative();
+ /** Position of cursor hotspot within cursor image. */
+ public static Point getCursorHotspot() { return sCursorHotspot; }
+
+ /** Returns the current cursor shape. */
+ public static Bitmap getCursorBitmap() { return sCursorBitmap; }
+
/*
* Entry points *from* the native code.
*/
@@ -138,6 +145,12 @@ public class JniInterface {
/** Buffer holding the video feed. */
private static ByteBuffer sBuffer = null;
+ /** Position of cursor hot-spot. */
+ private static Point sCursorHotspot = new Point();
+
+ /** Bitmap holding the cursor shape. */
+ private static Bitmap sCursorBitmap = null;
+
/** Reports whenever the connection status changes. */
private static void reportConnectionStatus(int state, int error) {
if (state < SUCCESSFUL_CONNECTION && error == 0) {
@@ -305,6 +318,21 @@ public class JniInterface {
return Bitmap.createBitmap(frame, 0, sWidth, sWidth, sHeight, Bitmap.Config.ARGB_8888);
}
+ /**
+ * Updates the cursor shape. This is called from native code on the graphics thread when
+ * receiving a new cursor shape from the host.
+ */
+ public static void updateCursorShape(int width, int height, int hotspotX, int hotspotY,
+ ByteBuffer buffer) {
+ sCursorHotspot.x = hotspotX;
+ sCursorHotspot.y = hotspotY;
+
+ int[] data = new int[width * height];
+ buffer.order(ByteOrder.LITTLE_ENDIAN);
+ buffer.asIntBuffer().get(data, 0, data.length);
+ sCursorBitmap = Bitmap.createBitmap(data, width, height, Bitmap.Config.ARGB_8888);
+ }
+
/** Moves the mouse cursor, possibly while clicking the specified (nonnegative) button. */
public static void mouseAction(int x, int y, int whichButton, boolean buttonDown) {
if (!sConnected) {

Powered by Google App Engine
This is Rietveld 408576698