OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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.Point; | 7 import android.graphics.PointF; |
8 import android.view.SurfaceHolder; | 8 import android.view.SurfaceHolder; |
9 | 9 |
10 import org.chromium.chromoting.jni.Client; | 10 import org.chromium.chromoting.jni.Client; |
11 import org.chromium.chromoting.jni.GlDisplay; | 11 import org.chromium.chromoting.jni.GlDisplay; |
12 | 12 |
13 /** | 13 /** |
14 * The user interface for viewing and interacting with a specific remote host. U
ses OpenGL to draw | 14 * The user interface for viewing and interacting with a specific remote host. U
ses OpenGL to draw |
15 * the desktop and cursor. Should be used entirely on the UI thread. | 15 * the desktop and cursor. Should be used entirely on the UI thread. |
16 */ | 16 */ |
17 public class GlDesktopView extends AbstractDesktopView implements SurfaceHolder.
Callback { | 17 public class GlDesktopView extends AbstractDesktopView implements SurfaceHolder.
Callback { |
(...skipping 13 matching lines...) Expand all Loading... |
31 @Override | 31 @Override |
32 public void run(Void p) { | 32 public void run(Void p) { |
33 mInputHandler.processAnimation(); | 33 mInputHandler.processAnimation(); |
34 } | 34 } |
35 }; | 35 }; |
36 | 36 |
37 getHolder().addCallback(this); | 37 getHolder().addCallback(this); |
38 } | 38 } |
39 | 39 |
40 @Override | 40 @Override |
41 public void showInputFeedback(InputFeedbackType feedbackToShow, Point pos) { | 41 public void showInputFeedback(InputFeedbackType feedbackToShow, PointF pos)
{ |
42 float diameter = getFeedbackRadius(feedbackToShow) * 2.0f; | 42 float diameter = getFeedbackRadius(feedbackToShow) * 2.0f; |
43 if (diameter <= 0.0f) { | 43 if (diameter <= 0.0f) { |
44 return; | 44 return; |
45 } | 45 } |
46 float scaleFactor = mRenderData.transform.mapRadius(1); | 46 float scaleFactor = mRenderData.transform.mapRadius(1); |
47 mDisplay.showCursorInputFeedback(pos.x, pos.y, diameter / scaleFactor); | 47 mDisplay.showCursorInputFeedback(pos.x, pos.y, diameter / scaleFactor); |
48 } | 48 } |
49 | 49 |
50 @Override | 50 @Override |
51 public void transformationChanged() { | 51 public void transformationChanged() { |
52 if (mRenderData.imageHeight == 0 || mRenderData.imageWidth == 0 | 52 if (mRenderData.imageHeight == 0 || mRenderData.imageWidth == 0 |
53 || mRenderData.screenHeight == 0 || mRenderData.screenWidth == 0
) { | 53 || mRenderData.screenHeight == 0 || mRenderData.screenWidth == 0
) { |
54 return; | 54 return; |
55 } | 55 } |
56 float[] matrix = new float[9]; | 56 float[] matrix = new float[9]; |
57 mRenderData.transform.getValues(matrix); | 57 mRenderData.transform.getValues(matrix); |
58 mDisplay.pixelTransformationChanged(matrix); | 58 mDisplay.pixelTransformationChanged(matrix); |
59 } | 59 } |
60 | 60 |
61 @Override | 61 @Override |
62 public void cursorMoved() { | 62 public void cursorMoved() { |
63 Point cursorPosition = mRenderData.getCursorPosition(); | 63 PointF cursorPosition = mRenderData.getCursorPosition(); |
64 mDisplay.cursorPixelPositionChanged(cursorPosition.x, cursorPosition.y); | 64 mDisplay.cursorPixelPositionChanged(cursorPosition.x, cursorPosition.y); |
65 } | 65 } |
66 | 66 |
67 @Override | 67 @Override |
68 public void cursorVisibilityChanged() { | 68 public void cursorVisibilityChanged() { |
69 mDisplay.cursorVisibilityChanged(mRenderData.drawCursor); | 69 mDisplay.cursorVisibilityChanged(mRenderData.drawCursor); |
70 } | 70 } |
71 | 71 |
72 @Override | 72 @Override |
73 public void setAnimationEnabled(boolean enabled) { | 73 public void setAnimationEnabled(boolean enabled) { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 // the listeners when the surface is about to be destroyed. | 116 // the listeners when the surface is about to be destroyed. |
117 if (mOnHostSizeChangedListenerKey != null) { | 117 if (mOnHostSizeChangedListenerKey != null) { |
118 mDisplay.onHostSizeChanged().remove(mOnHostSizeChangedListenerKey); | 118 mDisplay.onHostSizeChanged().remove(mOnHostSizeChangedListenerKey); |
119 } | 119 } |
120 if (mOnCanvasRenderedListenerKey != null) { | 120 if (mOnCanvasRenderedListenerKey != null) { |
121 mDisplay.onCanvasRendered().remove(mOnCanvasRenderedListenerKey); | 121 mDisplay.onCanvasRendered().remove(mOnCanvasRenderedListenerKey); |
122 } | 122 } |
123 mDisplay.surfaceDestroyed(); | 123 mDisplay.surfaceDestroyed(); |
124 } | 124 } |
125 } | 125 } |
OLD | NEW |