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

Unified Diff: remoting/android/java/src/org/chromium/chromoting/jni/GlDisplay.java

Issue 2282783003: [Remoting Android] Create Interfaces for GlDisplay (Closed)
Patch Set: Merge ToT again Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/android/java/src/org/chromium/chromoting/TrackpadInputStrategy.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/android/java/src/org/chromium/chromoting/jni/GlDisplay.java
diff --git a/remoting/android/java/src/org/chromium/chromoting/jni/GlDisplay.java b/remoting/android/java/src/org/chromium/chromoting/jni/GlDisplay.java
index 3cb12eae226cfba263a6d1b38bf1f5753b9205c7..dedbbb4e0361a6c33121c0b22a15f8cd5dc2cdb8 100644
--- a/remoting/android/java/src/org/chromium/chromoting/jni/GlDisplay.java
+++ b/remoting/android/java/src/org/chromium/chromoting/jni/GlDisplay.java
@@ -4,7 +4,10 @@
package org.chromium.chromoting.jni;
+import android.graphics.Matrix;
+import android.graphics.PointF;
import android.view.Surface;
+import android.view.SurfaceHolder;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace;
@@ -13,6 +16,8 @@ import org.chromium.chromoting.DesktopView;
import org.chromium.chromoting.DesktopViewFactory;
import org.chromium.chromoting.Event;
import org.chromium.chromoting.GlDesktopView;
+import org.chromium.chromoting.InputFeedbackRadiusMapper;
+import org.chromium.chromoting.RenderStub;
import org.chromium.chromoting.SizeChangedEventParameter;
/**
@@ -24,12 +29,16 @@ import org.chromium.chromoting.SizeChangedEventParameter;
* Events will only be triggered on UI.
*/
@JNINamespace("remoting")
-public class GlDisplay {
+public class GlDisplay implements SurfaceHolder.Callback, RenderStub {
private volatile long mNativeJniGlDisplay;
+ private final Event.Raisable<SizeChangedEventParameter> mOnClientSizeChanged =
+ new Event.Raisable<>();
private final Event.Raisable<SizeChangedEventParameter> mOnHostSizeChanged =
new Event.Raisable<>();
private final Event.Raisable<Void> mOnCanvasRendered =
new Event.Raisable<>();
+ private InputFeedbackRadiusMapper mFeedbackRadiusMapper;
+ private float mScaleFactor = 0;
private GlDisplay(long nativeJniGlDisplay) {
mNativeJniGlDisplay = nativeJniGlDisplay;
@@ -46,11 +55,12 @@ public class GlDisplay {
/**
* Notifies the OpenGL renderer that a surface for OpenGL to draw is created.
- * @param surface the surface to be drawn on
+ * @param holder the surface holder that holds the surface.
*/
- public void surfaceCreated(Surface surface) {
+ @Override
+ public void surfaceCreated(SurfaceHolder holder) {
if (mNativeJniGlDisplay != 0) {
- nativeOnSurfaceCreated(mNativeJniGlDisplay, surface);
+ nativeOnSurfaceCreated(mNativeJniGlDisplay, holder.getSurface());
}
}
@@ -60,7 +70,9 @@ public class GlDisplay {
* @param width the width of the surface
* @param height the height of the surface
*/
- public void surfaceChanged(int width, int height) {
+ @Override
+ public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
+ mOnClientSizeChanged.raise(new SizeChangedEventParameter(width, height));
if (mNativeJniGlDisplay != 0) {
nativeOnSurfaceChanged(mNativeJniGlDisplay, width, height);
}
@@ -69,39 +81,83 @@ public class GlDisplay {
/**
* Notifies the OpenGL renderer that the current surface being used is about to be destroyed.
*/
- public void surfaceDestroyed() {
+ @Override
+ public void surfaceDestroyed(SurfaceHolder holder) {
if (mNativeJniGlDisplay != 0) {
nativeOnSurfaceDestroyed(mNativeJniGlDisplay);
}
}
+ @Override
+ public void setDesktopView(DesktopView view) {
+ mFeedbackRadiusMapper = new InputFeedbackRadiusMapper(view);
+ }
+
/**
* Sets the transformation matrix (in pixel coordinates).
* @param matrix the transformation matrix
*/
- public void pixelTransformationChanged(float[] matrix) {
+ @Override
+ public void setTransformation(Matrix matrix) {
if (mNativeJniGlDisplay != 0) {
- nativeOnPixelTransformationChanged(mNativeJniGlDisplay, matrix);
+ float[] matrixArray = new float[9];
+ matrix.getValues(matrixArray);
+ nativeOnPixelTransformationChanged(mNativeJniGlDisplay, matrixArray);
+ mScaleFactor = matrix.mapRadius(1);
}
}
/** Moves the cursor to the corresponding location on the desktop. */
- public void cursorPixelPositionChanged(float x, float y) {
+ @Override
+ public void moveCursor(PointF position) {
if (mNativeJniGlDisplay != 0) {
- nativeOnCursorPixelPositionChanged(mNativeJniGlDisplay, x, y);
+ nativeOnCursorPixelPositionChanged(mNativeJniGlDisplay, position.x, position.y);
}
}
/**
* Decides whether the cursor should be shown on the canvas.
*/
- public void cursorVisibilityChanged(boolean visible) {
+ @Override
+ public void setCursorVisibility(boolean visible) {
if (mNativeJniGlDisplay != 0) {
nativeOnCursorVisibilityChanged(mNativeJniGlDisplay, visible);
}
}
/**
+ * Shows the cursor input feedback animation with the given diameter at the given desktop
+ * location.
+ */
+ @Override
+ public void showInputFeedback(InputFeedbackType feedbackToShow, PointF pos) {
+ if (mNativeJniGlDisplay == 0 || feedbackToShow.equals(InputFeedbackType.NONE)) {
+ return;
+ }
+ float diameter = mFeedbackRadiusMapper
+ .getFeedbackRadius(feedbackToShow, mScaleFactor) * 2.0f;
+ if (diameter <= 0.0f) {
+ return;
+ }
+ nativeOnCursorInputFeedback(mNativeJniGlDisplay, pos.x, pos.y, diameter);
+ }
+
+ @Override
+ public Event<SizeChangedEventParameter> onClientSizeChanged() {
+ return mOnClientSizeChanged;
+ }
+
+ @Override
+ public Event<SizeChangedEventParameter> onHostSizeChanged() {
+ return mOnHostSizeChanged;
+ }
+
+ @Override
+ public Event<Void> onCanvasRendered() {
+ return mOnCanvasRendered;
+ }
+
+ /**
* Called by native code to notify GlDisplay that the size of the canvas (=size of desktop) has
* changed.
* @param width width of the canvas
@@ -113,13 +169,6 @@ public class GlDisplay {
}
/**
- * An {@link Event} triggered when the size of the host desktop is changed.
- */
- public Event<SizeChangedEventParameter> onHostSizeChanged() {
- return mOnHostSizeChanged;
- }
-
- /**
* Called by native code when a render request has been done by the OpenGL renderer. This
* will only be called when the render event callback is enabled.
*/
@@ -128,24 +177,6 @@ public class GlDisplay {
mOnCanvasRendered.raise(null);
}
- /**
- * An {@link} triggered when render event callback is enabled and a render request has been done
- * by the OpenGL renderer.
- */
- public Event<Void> onCanvasRendered() {
- return mOnCanvasRendered;
- }
-
- /**
- * Shows the cursor input feedback animation with the given diameter at the given desktop
- * location.
- */
- public void showCursorInputFeedback(float x, float y, float diameter) {
- if (mNativeJniGlDisplay != 0) {
- nativeOnCursorInputFeedback(mNativeJniGlDisplay, x, y, diameter);
- }
- }
-
@CalledByNative
private void initializeClient(Client client) {
client.setDesktopViewFactory(new DesktopViewFactory() {
« no previous file with comments | « remoting/android/java/src/org/chromium/chromoting/TrackpadInputStrategy.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698