summaryrefslogtreecommitdiffstats
path: root/remoting/android/java/src/org/chromium/chromoting/RenderData.java
blob: 8e21488f30199551395da036f62673419f57de8a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

package org.chromium.chromoting;

import android.graphics.Matrix;
import android.graphics.Point;

/**
 * This class stores data that needs to be accessed on both the display thread and the
 * event-processing thread.
 */
public class RenderData {
    /** Stores pan and zoom configuration and converts image coordinates to screen coordinates. */
    public Matrix transform = new Matrix();

    public int screenWidth = 0;
    public int screenHeight = 0;
    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.
     */
    private Point mCursorPosition = new Point();

    /**
     * Returns the position of the rendered cursor.
     *
     * @return A point representing the current position.
     */
    public Point getCursorPosition() {
        return new Point(mCursorPosition);
    }

    /**
     * Sets the position of the cursor which is used for rendering.
     *
     * @param newX The new value of the x coordinate.
     * @param newY The new value of the y coordinate
     * @return True if the cursor position has changed.
     */
    public boolean setCursorPosition(int newX, int newY) {
        boolean cursorMoved = false;
        if (newX != mCursorPosition.x) {
            mCursorPosition.x = newX;
            cursorMoved = true;
        }
        if (newY != mCursorPosition.y) {
            mCursorPosition.y = newY;
            cursorMoved = true;
        }

        return cursorMoved;
    }
}