| 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.Matrix; | 7 import android.graphics.Matrix; |
| 8 import android.graphics.PointF; | 8 import android.graphics.PointF; |
| 9 import android.view.SurfaceHolder; | 9 import android.view.SurfaceHolder; |
| 10 | 10 |
| 11 import org.chromium.chromoting.jni.Client; | 11 import org.chromium.chromoting.jni.Client; |
| 12 import org.chromium.chromoting.jni.GlDisplay; | 12 import org.chromium.chromoting.jni.GlDisplay; |
| 13 | 13 |
| 14 /** | 14 /** |
| 15 * The user interface for viewing and interacting with a specific remote host. U
ses OpenGL to draw | 15 * The user interface for viewing and interacting with a specific remote host. U
ses OpenGL to draw |
| 16 * the desktop and cursor. Should be used entirely on the UI thread. | 16 * the desktop and cursor. Should be used entirely on the UI thread. |
| 17 */ | 17 */ |
| 18 public class GlDesktopView extends DesktopView implements SurfaceHolder.Callback
{ | 18 public class GlDesktopView extends DesktopView implements SurfaceHolder.Callback
{ |
| 19 private final GlDisplay mDisplay; | 19 private final GlDisplay mDisplay; |
| 20 private final InputFeedbackRadiusMapper mInputFeedbackMapper; |
| 20 | 21 |
| 21 private Object mOnHostSizeChangedListenerKey; | 22 private Object mOnHostSizeChangedListenerKey; |
| 22 private Object mOnCanvasRenderedListenerKey; | 23 private Object mOnCanvasRenderedListenerKey; |
| 23 | 24 |
| 24 private float mScaleFactor; | 25 private float mScaleFactor; |
| 25 | 26 |
| 26 public GlDesktopView(GlDisplay display, Desktop desktop, Client client) { | 27 public GlDesktopView(GlDisplay display, Desktop desktop, Client client) { |
| 27 super(desktop, client); | 28 super(desktop, client); |
| 28 Preconditions.notNull(display); | 29 Preconditions.notNull(display); |
| 29 mDisplay = display; | 30 mDisplay = display; |
| 30 | 31 |
| 31 mScaleFactor = 0; | 32 mInputFeedbackMapper = new InputFeedbackRadiusMapper(this); |
| 32 | 33 |
| 33 getHolder().addCallback(this); | 34 getHolder().addCallback(this); |
| 34 } | 35 } |
| 35 | 36 |
| 36 @Override | 37 @Override |
| 37 public void showInputFeedback(InputFeedbackType feedbackToShow, PointF pos)
{ | 38 public void showInputFeedback(InputFeedbackType feedbackToShow, PointF pos)
{ |
| 38 float diameter = getFeedbackRadius(feedbackToShow, mScaleFactor) * 2.0f; | 39 float diameter = |
| 40 mInputFeedbackMapper.getFeedbackRadius(feedbackToShow, mScaleFac
tor) * 2.0f; |
| 39 if (diameter <= 0.0f) { | 41 if (diameter <= 0.0f) { |
| 40 return; | 42 return; |
| 41 } | 43 } |
| 42 mDisplay.showCursorInputFeedback(pos.x, pos.y, diameter); | 44 mDisplay.showCursorInputFeedback(pos.x, pos.y, diameter); |
| 43 } | 45 } |
| 44 | 46 |
| 45 @Override | 47 @Override |
| 46 public void transformationChanged(Matrix matrix) { | 48 public void transformationChanged(Matrix matrix) { |
| 47 float[] matrixArray = new float[9]; | 49 float[] matrixArray = new float[9]; |
| 48 matrix.getValues(matrixArray); | 50 matrix.getValues(matrixArray); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 // the listeners when the surface is about to be destroyed. | 96 // the listeners when the surface is about to be destroyed. |
| 95 if (mOnHostSizeChangedListenerKey != null) { | 97 if (mOnHostSizeChangedListenerKey != null) { |
| 96 mDisplay.onHostSizeChanged().remove(mOnHostSizeChangedListenerKey); | 98 mDisplay.onHostSizeChanged().remove(mOnHostSizeChangedListenerKey); |
| 97 } | 99 } |
| 98 if (mOnCanvasRenderedListenerKey != null) { | 100 if (mOnCanvasRenderedListenerKey != null) { |
| 99 mDisplay.onCanvasRendered().remove(mOnCanvasRenderedListenerKey); | 101 mDisplay.onCanvasRendered().remove(mOnCanvasRenderedListenerKey); |
| 100 } | 102 } |
| 101 mDisplay.surfaceDestroyed(); | 103 mDisplay.surfaceDestroyed(); |
| 102 } | 104 } |
| 103 } | 105 } |
| OLD | NEW |