Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(544)

Side by Side Diff: remoting/android/java/src/org/chromium/chromoting/GlDesktopView.java

Issue 2297073002: [Remoting Android] Move feedback type to radius logic out of DesktopView (Closed)
Patch Set: Add mapper Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 20
21 private Object mOnHostSizeChangedListenerKey; 21 private Object mOnHostSizeChangedListenerKey;
22 private Object mOnCanvasRenderedListenerKey; 22 private Object mOnCanvasRenderedListenerKey;
23 23
24 private Event.ParameterRunnable<Void> mProcessAnimationRunnable; 24 private Event.ParameterRunnable<Void> mProcessAnimationRunnable;
25 25
26 private float mScaleFactor; 26 private final InputFeedbackRadiusMapper mMapper;
27
28 private float mScaleFactor = 0;
Hzj_jie 2016/08/31 01:31:59 I believe usually you do not need to actively init
Yuwei 2016/08/31 01:36:13 I think you are right... Remove this?
Hzj_jie 2016/08/31 01:38:43 Yes, I suggest to do so to keep consistent. And I
Yuwei 2016/08/31 18:25:34 Done.
27 29
28 public GlDesktopView(GlDisplay display, Desktop desktop, Client client) { 30 public GlDesktopView(GlDisplay display, Desktop desktop, Client client) {
29 super(desktop, client); 31 super(desktop, client);
30 Preconditions.notNull(display); 32 Preconditions.notNull(display);
31 mDisplay = display; 33 mDisplay = display;
32 34
33 mProcessAnimationRunnable = new Event.ParameterRunnable<Void>() { 35 mProcessAnimationRunnable = new Event.ParameterRunnable<Void>() {
34 @Override 36 @Override
35 public void run(Void p) { 37 public void run(Void p) {
36 mInputHandler.processAnimation(); 38 mInputHandler.processAnimation();
37 } 39 }
38 }; 40 };
39 41
40 mScaleFactor = 0; 42 mMapper = new InputFeedbackRadiusMapper(this);
41 43
42 getHolder().addCallback(this); 44 getHolder().addCallback(this);
43 } 45 }
44 46
45 @Override 47 @Override
46 public void showInputFeedback(InputFeedbackType feedbackToShow, PointF pos) { 48 public void showInputFeedback(InputFeedbackType feedbackToShow, PointF pos) {
47 float diameter = getFeedbackRadius(feedbackToShow, mScaleFactor) * 2.0f; 49 float diameter = mMapper.getFeedbackRadius(feedbackToShow, mScaleFactor) * 2.0f;
48 if (diameter <= 0.0f) { 50 if (diameter <= 0.0f) {
49 return; 51 return;
50 } 52 }
51 mDisplay.showCursorInputFeedback(pos.x, pos.y, diameter); 53 mDisplay.showCursorInputFeedback(pos.x, pos.y, diameter);
52 } 54 }
53 55
54 @Override 56 @Override
55 public void transformationChanged(Matrix matrix) { 57 public void transformationChanged(Matrix matrix) {
56 float[] matrixArray = new float[9]; 58 float[] matrixArray = new float[9];
57 matrix.getValues(matrixArray); 59 matrix.getValues(matrixArray);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 // the listeners when the surface is about to be destroyed. 109 // the listeners when the surface is about to be destroyed.
108 if (mOnHostSizeChangedListenerKey != null) { 110 if (mOnHostSizeChangedListenerKey != null) {
109 mDisplay.onHostSizeChanged().remove(mOnHostSizeChangedListenerKey); 111 mDisplay.onHostSizeChanged().remove(mOnHostSizeChangedListenerKey);
110 } 112 }
111 if (mOnCanvasRenderedListenerKey != null) { 113 if (mOnCanvasRenderedListenerKey != null) {
112 mDisplay.onCanvasRendered().remove(mOnCanvasRenderedListenerKey); 114 mDisplay.onCanvasRendered().remove(mOnCanvasRenderedListenerKey);
113 } 115 }
114 mDisplay.surfaceDestroyed(); 116 mDisplay.surfaceDestroyed();
115 } 117 }
116 } 118 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698