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; | 5 package org.chromium.chromoting; |
6 | 6 |
7 import android.graphics.Matrix; | 7 import android.graphics.Matrix; |
8 import android.graphics.Point; | 8 import android.graphics.Point; |
| 9 import android.graphics.PointF; |
9 | 10 |
10 /** | 11 /** |
11 * This class stores data that needs to be accessed on both the display thread a
nd the | 12 * This class stores data that needs to be accessed on both the display thread a
nd the |
12 * event-processing thread. | 13 * event-processing thread. |
13 */ | 14 */ |
14 public class RenderData { | 15 public class RenderData { |
15 /** Stores pan and zoom configuration and converts image coordinates to scre
en coordinates. */ | 16 /** Stores pan and zoom configuration and converts image coordinates to scre
en coordinates. */ |
16 public Matrix transform = new Matrix(); | 17 public Matrix transform = new Matrix(); |
17 | 18 |
18 public int screenWidth = 0; | 19 public int screenWidth = 0; |
19 public int screenHeight = 0; | 20 public int screenHeight = 0; |
20 public int imageWidth = 0; | 21 public int imageWidth = 0; |
21 public int imageHeight = 0; | 22 public int imageHeight = 0; |
22 | 23 |
23 /** Determines whether the local cursor should be drawn. */ | 24 /** Determines whether the local cursor should be drawn. */ |
24 public boolean drawCursor = false; | 25 public boolean drawCursor = false; |
25 | 26 |
26 /** | 27 /** |
27 * Specifies the position, in image coordinates, at which the cursor image w
ill be drawn. | 28 * Specifies the position, in image coordinates, at which the cursor image w
ill be drawn. |
28 * This will normally be at the location of the most recently injected motio
n event. | 29 * This will normally be at the location of the most recently injected motio
n event. |
29 */ | 30 */ |
30 private Point mCursorPosition = new Point(); | 31 private PointF mCursorPosition = new PointF(); |
31 | 32 |
32 /** | 33 /** |
33 * Returns the position of the rendered cursor. | 34 * Returns the position of the rendered cursor. |
34 * | 35 * |
35 * @return A point representing the current position. | 36 * @return A point representing the current position. |
36 */ | 37 */ |
37 public Point getCursorPosition() { | 38 public PointF getCursorPosition() { |
38 return new Point(mCursorPosition); | 39 return new PointF(mCursorPosition.x, mCursorPosition.y); |
39 } | 40 } |
40 | 41 |
41 /** | 42 /** |
| 43 * Returns the position of the rendered cursor. The values are casted to int
eger. |
| 44 * |
| 45 * @return A point representing the current position. |
| 46 */ |
| 47 public Point getIntegerCursorPosition() { |
| 48 return new Point((int) mCursorPosition.x, (int) mCursorPosition.y); |
| 49 } |
| 50 |
| 51 /** |
42 * Sets the position of the cursor which is used for rendering. | 52 * Sets the position of the cursor which is used for rendering. |
43 * | 53 * |
44 * @param newX The new value of the x coordinate. | 54 * @param newX The new value of the x coordinate. |
45 * @param newY The new value of the y coordinate | 55 * @param newY The new value of the y coordinate |
46 * @return True if the cursor position has changed. | 56 * @return True if the cursor position has changed. |
47 */ | 57 */ |
48 public boolean setCursorPosition(int newX, int newY) { | 58 public boolean setCursorPosition(float newX, float newY) { |
49 boolean cursorMoved = false; | 59 boolean cursorMoved = false; |
50 if (newX != mCursorPosition.x) { | 60 if (newX != mCursorPosition.x) { |
51 mCursorPosition.x = newX; | 61 mCursorPosition.x = newX; |
52 cursorMoved = true; | 62 cursorMoved = true; |
53 } | 63 } |
54 if (newY != mCursorPosition.y) { | 64 if (newY != mCursorPosition.y) { |
55 mCursorPosition.y = newY; | 65 mCursorPosition.y = newY; |
56 cursorMoved = true; | 66 cursorMoved = true; |
57 } | 67 } |
58 | 68 |
59 return cursorMoved; | 69 return cursorMoved; |
60 } | 70 } |
61 } | 71 } |
OLD | NEW |