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

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

Issue 2282783003: [Remoting Android] Create Interfaces for GlDisplay (Closed)
Patch Set: Reviewer's Feedback 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
(Empty)
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
3 // found in the LICENSE file.
4
5 package org.chromium.chromoting;
6
7 import android.graphics.Matrix;
8 import android.graphics.PointF;
9
10 /**
11 * Interface with a set of functions to control the behavior of the remote host renderer.
12 */
13 public interface RenderStub {
14 /** Used to define the animation feedback shown when a user touches the scre en. */
15 enum InputFeedbackType {
16 NONE,
17 SHORT_TOUCH_ANIMATION,
18 LONG_TOUCH_ANIMATION,
19 LONG_TRACKPAD_ANIMATION
20 }
21
22 /**
23 * Initializes the stub with |view|. The stub should avoid holding strong re ference to |view|.
24 */
25 void setDesktopView(DesktopView view);
26
27 /** Triggers a brief animation to indicate the existence and location of an input event. */
28 void showInputFeedback(InputFeedbackType feedbackToShow, PointF pos);
29
30 /**
31 * Informs the stub that its transformation matrix (for rendering the remote desktop bitmap)
32 * has been changed, which requires repainting.
33 */
34 void setTransformation(Matrix matrix);
35
36 /**
37 * Informs the stub that the cursor position has been moved, which requires repainting.
38 */
39 void moveCursor(PointF pos);
40
41 /**
42 * Informs the stub that the cursor visibility has been changed (for differe nt input mode),
43 * which requires repainting.
44 */
45 void setCursorVisibility(boolean visible);
46
47 /** An {@link Event} triggered when the client size is changed. */
48 Event<SizeChangedEventParameter> onClientSizeChanged();
Hzj_jie 2016/08/30 23:15:03 According to the following implementation, I belie
Yuwei 2016/08/31 00:15:56 In the future I will have surfaceHolder.addCallbac
Hzj_jie 2016/08/31 00:31:57 Any benefit for this change? SurfaceHolder can onl
Yuwei 2016/08/31 00:47:40 GlDisplay needs to be notified when the surface is
Hzj_jie 2016/08/31 00:59:21 My only concern is SurfaceHolder has a same lifeti
49
50 /**
51 * An {@link Event} triggered when the size of the host desktop is changed.
52 */
53 Event<SizeChangedEventParameter> onHostSizeChanged();
54
55 /**
56 * An {@link} triggered when a frame has been rendered.
57 */
58 Event<Void> onCanvasRendered();
59
60 /**
61 * Helper class for mapping a feedback type to the max radius of the feedbac k animation.
62 */
63 final class InputFeedbackRadiusMapper {
64 private final int mTinyFeedbackPixelRadius;
65 private final int mSmallFeedbackPixelRadius;
66 private final int mLargeFeedbackPixelRadius;
67
68 public InputFeedbackRadiusMapper(DesktopView view) {
69 mTinyFeedbackPixelRadius = view.getResources()
70 .getDimensionPixelSize(R.dimen.feedback_animation_radius_tin y);
71
72 mSmallFeedbackPixelRadius = view.getResources()
73 .getDimensionPixelSize(R.dimen.feedback_animation_radius_sma ll);
74
75 mLargeFeedbackPixelRadius = view.getResources()
76 .getDimensionPixelSize(R.dimen.feedback_animation_radius_lar ge);
77 }
78
79 /**
80 * Returns the radius of the given feedback type.
81 * 0.0f will be returned if no feedback should be shown.
82 */
83 public float getFeedbackRadius(InputFeedbackType feedbackToShow,
84 float scaleFactor) {
85 switch (feedbackToShow) {
86 case NONE:
87 return 0.0f;
88 case SHORT_TOUCH_ANIMATION:
89 return mSmallFeedbackPixelRadius / scaleFactor;
90 case LONG_TOUCH_ANIMATION:
91 return mLargeFeedbackPixelRadius / scaleFactor;
92 case LONG_TRACKPAD_ANIMATION:
93 // The size of the longpress trackpad animation is supposed to be close to the
94 // size of the cursor so it doesn't need to be normalized an d should be scaled
95 // with the canvas.
96 return mTinyFeedbackPixelRadius;
97 default:
98 // Unreachable, but required by Google Java style and findbu gs.
99 assert false : "Unreached";
100 return 0.0f;
101 }
102 }
103 }
104 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698