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

Unified Diff: remoting/android/java/src/org/chromium/chromoting/DesktopView.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
« no previous file with comments | « no previous file | remoting/android/java/src/org/chromium/chromoting/jni/JniInterface.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/android/java/src/org/chromium/chromoting/DesktopView.java
diff --git a/remoting/android/java/src/org/chromium/chromoting/DesktopView.java b/remoting/android/java/src/org/chromium/chromoting/DesktopView.java
index b1eac42633a5f3d16d6dc682c98d45519852a106..8e56fa6917fe553bbe13a4263e481932d639d439 100644
--- a/remoting/android/java/src/org/chromium/chromoting/DesktopView.java
+++ b/remoting/android/java/src/org/chromium/chromoting/DesktopView.java
@@ -11,6 +11,7 @@ import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Paint;
+import android.graphics.Point;
import android.os.Bundle;
import android.os.Looper;
import android.text.InputType;
@@ -67,6 +68,12 @@ public class DesktopView extends SurfaceView implements Runnable, SurfaceHolder.
private int mScreenWidth;
private int mScreenHeight;
+ /**
+ * Specifies the position, in image coordinates, at which the cursor image will be drawn.
+ * This will normally be at the location of the most recently injected motion event.
+ */
+ private Point mCursorPosition;
+
/** Specifies the dimension by which the zoom level is being lower-bounded. */
private Constraint mConstraint;
@@ -98,6 +105,7 @@ public class DesktopView extends SurfaceView implements Runnable, SurfaceHolder.
mTransform = new Matrix();
mScreenWidth = 0;
mScreenHeight = 0;
+ mCursorPosition = new Point();
mConstraint = Constraint.UNDEFINED;
mRecheckConstraint = false;
@@ -216,6 +224,12 @@ public class DesktopView extends SurfaceView implements Runnable, SurfaceHolder.
canvas.drawColor(Color.BLACK);
canvas.drawBitmap(image, 0, 0, new Paint());
+ Bitmap cursorBitmap = JniInterface.getCursorBitmap();
+ if (cursorBitmap != null) {
+ Point hotspot = JniInterface.getCursorHotspot();
+ canvas.drawBitmap(cursorBitmap, mCursorPosition.x - hotspot.x,
solb 2013/09/14 00:29:41 It might be good to synchronize this on mCursorPos
Lambros 2013/09/14 01:16:48 Good catch! Done.
+ mCursorPosition.y - hotspot.y, new Paint());
+ }
getHolder().unlockCanvasAndPost(canvas);
}
@@ -242,6 +256,8 @@ public class DesktopView extends SurfaceView implements Runnable, SurfaceHolder.
synchronized (mTransform) {
mScreenWidth = width;
mScreenHeight = height;
+ mCursorPosition.x = width / 2;
solb 2013/09/14 00:29:41 Synchronizing these on mTransform does no good, si
Lambros 2013/09/14 01:16:48 Done.
+ mCursorPosition.y = height / 2;
if (mRecheckConstraint) {
mConstraint = Constraint.UNDEFINED;
@@ -299,8 +315,15 @@ public class DesktopView extends SurfaceView implements Runnable, SurfaceHolder.
mTransform.invert(canvasToImage);
canvasToImage.mapPoints(coordinates);
+ mCursorPosition.x = (int)coordinates[0];
solb 2013/09/14 00:29:41 I think these two lines should also be synchronize
Lambros 2013/09/14 01:16:48 Done. I've also added a synchronize around mTransf
+ mCursorPosition.y = (int)coordinates[1];
+
// Coordinates are now relative to the image, so transmit them to the host.
- JniInterface.mouseAction((int)coordinates[0], (int)coordinates[1], button, pressed);
+ JniInterface.mouseAction(mCursorPosition.x, mCursorPosition.y, button, pressed);
+
+ // TODO(lambroslambrou): Optimize this to repaint only the areas covered by the old and new
+ // cursor positions.
+ JniInterface.redrawGraphics();
}
/**
« no previous file with comments | « no previous file | remoting/android/java/src/org/chromium/chromoting/jni/JniInterface.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698