summaryrefslogtreecommitdiffstats
path: root/remoting/android
diff options
context:
space:
mode:
authorjoedow <joedow@chromium.org>2015-12-09 14:41:57 -0800
committerCommit bot <commit-bot@chromium.org>2015-12-09 22:43:52 +0000
commit048b41c61d7e61dcf736142d3443ca84f2497fc6 (patch)
treef87736a34315c863578ca2e38cb9d863f4b237cf /remoting/android
parent7bf6418ec0afcb1a8a74ab9b8c288564b7180cf5 (diff)
downloadchromium_src-048b41c61d7e61dcf736142d3443ca84f2497fc6.zip
chromium_src-048b41c61d7e61dcf736142d3443ca84f2497fc6.tar.gz
chromium_src-048b41c61d7e61dcf736142d3443ca84f2497fc6.tar.bz2
Adding a flag for drawing the cursor to the RenderData class.
With the introduction of new input modes, we need to be able to figure out whether the current input strategy wants the local cursor bitmap to be rendered or not. I have added this attribute to the RenderData class which is set by the InputStrategy when it is instantiated and read by the DesktopView during each render loop. This change was pulled from a larger CL. The original impl had this flag in the DesktopView class instead with a suggestion of making it volatile or an AtomicBoolean. This flag will be changed a handful of times a session but read many thousands of times. Therefore I did not want to add overhead to the read operation that would come from the volatile/AtomicBoolean approach. Instead I want to use the mRenderData sync mechanism (which is already acquired within the render loop) so no overhead is added. BUG= Review URL: https://codereview.chromium.org/1514453006 Cr-Commit-Position: refs/heads/master@{#364182}
Diffstat (limited to 'remoting/android')
-rw-r--r--remoting/android/java/src/org/chromium/chromoting/DesktopView.java17
-rw-r--r--remoting/android/java/src/org/chromium/chromoting/RenderData.java3
-rw-r--r--remoting/android/java/src/org/chromium/chromoting/TrackpadInputStrategy.java4
3 files changed, 19 insertions, 5 deletions
diff --git a/remoting/android/java/src/org/chromium/chromoting/DesktopView.java b/remoting/android/java/src/org/chromium/chromoting/DesktopView.java
index 5d015e5..5d4e33d 100644
--- a/remoting/android/java/src/org/chromium/chromoting/DesktopView.java
+++ b/remoting/android/java/src/org/chromium/chromoting/DesktopView.java
@@ -233,6 +233,7 @@ public class DesktopView extends SurfaceView implements DesktopViewInterface,
Canvas canvas;
Point cursorPosition;
+ boolean drawCursor;
synchronized (mRenderData) {
mRepaintPending = false;
// Don't try to lock the canvas before it is ready, as the implementation of
@@ -247,6 +248,7 @@ public class DesktopView extends SurfaceView implements DesktopViewInterface,
return;
}
canvas.setMatrix(mRenderData.transform);
+ drawCursor = mRenderData.drawCursor;
cursorPosition = mRenderData.getCursorPosition();
}
@@ -263,11 +265,13 @@ public class DesktopView extends SurfaceView implements DesktopViewInterface,
mFeedbackAnimator.render(canvas, cursorPosition.x, cursorPosition.y, scaleFactor);
}
- Bitmap cursorBitmap = JniInterface.getCursorBitmap();
- if (cursorBitmap != null) {
- Point hotspot = JniInterface.getCursorHotspot();
- canvas.drawBitmap(cursorBitmap, cursorPosition.x - hotspot.x,
- cursorPosition.y - hotspot.y, new Paint());
+ if (drawCursor) {
+ Bitmap cursorBitmap = JniInterface.getCursorBitmap();
+ if (cursorBitmap != null) {
+ Point hotspot = JniInterface.getCursorHotspot();
+ canvas.drawBitmap(cursorBitmap, cursorPosition.x - hotspot.x,
+ cursorPosition.y - hotspot.y, new Paint());
+ }
}
getHolder().unlockCanvasAndPost(canvas);
@@ -427,5 +431,8 @@ public class DesktopView extends SurfaceView implements DesktopViewInterface,
// Unreachable, but required by Google Java style and findbugs.
assert false : "Unreached";
}
+
+ // Ensure the cursor state is updated appropriately.
+ requestRepaint();
}
}
diff --git a/remoting/android/java/src/org/chromium/chromoting/RenderData.java b/remoting/android/java/src/org/chromium/chromoting/RenderData.java
index 50d7217..8e21488 100644
--- a/remoting/android/java/src/org/chromium/chromoting/RenderData.java
+++ b/remoting/android/java/src/org/chromium/chromoting/RenderData.java
@@ -20,6 +20,9 @@ public class RenderData {
public int imageWidth = 0;
public int imageHeight = 0;
+ /** Determines whether the local cursor should be drawn. */
+ public boolean drawCursor = false;
+
/**
* 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.
diff --git a/remoting/android/java/src/org/chromium/chromoting/TrackpadInputStrategy.java b/remoting/android/java/src/org/chromium/chromoting/TrackpadInputStrategy.java
index b992124..326eff9 100644
--- a/remoting/android/java/src/org/chromium/chromoting/TrackpadInputStrategy.java
+++ b/remoting/android/java/src/org/chromium/chromoting/TrackpadInputStrategy.java
@@ -22,6 +22,10 @@ public class TrackpadInputStrategy implements InputStrategyInterface {
public TrackpadInputStrategy(RenderData renderData) {
mRenderData = renderData;
+
+ synchronized (mRenderData) {
+ mRenderData.drawCursor = true;
+ }
}
@Override