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