Chromium Code Reviews| Index: remoting/android/java/src/org/chromium/chromoting/RenderStub.java |
| diff --git a/remoting/android/java/src/org/chromium/chromoting/RenderStub.java b/remoting/android/java/src/org/chromium/chromoting/RenderStub.java |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..f85648874feb7cc1c5f278c7fffa4bfb6482ef27 |
| --- /dev/null |
| +++ b/remoting/android/java/src/org/chromium/chromoting/RenderStub.java |
| @@ -0,0 +1,104 @@ |
| +// Copyright 2016 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.PointF; |
| + |
| +/** |
| + * Interface with a set of functions to control the behavior of the remote host renderer. |
| + */ |
| +public interface RenderStub { |
| + /** Used to define the animation feedback shown when a user touches the screen. */ |
| + enum InputFeedbackType { |
| + NONE, |
| + SHORT_TOUCH_ANIMATION, |
| + LONG_TOUCH_ANIMATION, |
| + LONG_TRACKPAD_ANIMATION |
| + } |
| + |
| + /** |
| + * Initializes the stub with |view|. The stub should avoid holding strong reference to |view|. |
| + */ |
| + void setDesktopView(DesktopView view); |
| + |
| + /** Triggers a brief animation to indicate the existence and location of an input event. */ |
| + void showInputFeedback(InputFeedbackType feedbackToShow, PointF pos); |
| + |
| + /** |
| + * Informs the stub that its transformation matrix (for rendering the remote desktop bitmap) |
| + * has been changed, which requires repainting. |
| + */ |
| + void setTransformation(Matrix matrix); |
| + |
| + /** |
| + * Informs the stub that the cursor position has been moved, which requires repainting. |
| + */ |
| + void moveCursor(PointF pos); |
| + |
| + /** |
| + * Informs the stub that the cursor visibility has been changed (for different input mode), |
| + * which requires repainting. |
| + */ |
| + void setCursorVisibility(boolean visible); |
| + |
| + /** An {@link Event} triggered when the client size is changed. */ |
| + 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
|
| + |
| + /** |
| + * An {@link Event} triggered when the size of the host desktop is changed. |
| + */ |
| + Event<SizeChangedEventParameter> onHostSizeChanged(); |
| + |
| + /** |
| + * An {@link} triggered when a frame has been rendered. |
| + */ |
| + Event<Void> onCanvasRendered(); |
| + |
| + /** |
| + * Helper class for mapping a feedback type to the max radius of the feedback animation. |
| + */ |
| + final class InputFeedbackRadiusMapper { |
| + private final int mTinyFeedbackPixelRadius; |
| + private final int mSmallFeedbackPixelRadius; |
| + private final int mLargeFeedbackPixelRadius; |
| + |
| + public InputFeedbackRadiusMapper(DesktopView view) { |
| + mTinyFeedbackPixelRadius = view.getResources() |
| + .getDimensionPixelSize(R.dimen.feedback_animation_radius_tiny); |
| + |
| + mSmallFeedbackPixelRadius = view.getResources() |
| + .getDimensionPixelSize(R.dimen.feedback_animation_radius_small); |
| + |
| + mLargeFeedbackPixelRadius = view.getResources() |
| + .getDimensionPixelSize(R.dimen.feedback_animation_radius_large); |
| + } |
| + |
| + /** |
| + * Returns the radius of the given feedback type. |
| + * 0.0f will be returned if no feedback should be shown. |
| + */ |
| + public float getFeedbackRadius(InputFeedbackType feedbackToShow, |
| + float scaleFactor) { |
| + switch (feedbackToShow) { |
| + case NONE: |
| + return 0.0f; |
| + case SHORT_TOUCH_ANIMATION: |
| + return mSmallFeedbackPixelRadius / scaleFactor; |
| + case LONG_TOUCH_ANIMATION: |
| + return mLargeFeedbackPixelRadius / scaleFactor; |
| + case LONG_TRACKPAD_ANIMATION: |
| + // The size of the longpress trackpad animation is supposed to be close to the |
| + // size of the cursor so it doesn't need to be normalized and should be scaled |
| + // with the canvas. |
| + return mTinyFeedbackPixelRadius; |
| + default: |
| + // Unreachable, but required by Google Java style and findbugs. |
| + assert false : "Unreached"; |
| + return 0.0f; |
| + } |
| + } |
| + } |
| +} |