Chromium Code Reviews| 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.jni; | 5 package org.chromium.chromoting.jni; |
| 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.Surface; | 9 import android.view.Surface; |
| 10 import android.view.SurfaceHolder; | 10 import android.view.SurfaceHolder; |
| 11 | 11 |
| 12 import org.chromium.base.annotations.CalledByNative; | 12 import org.chromium.base.annotations.CalledByNative; |
| 13 import org.chromium.base.annotations.JNINamespace; | 13 import org.chromium.base.annotations.JNINamespace; |
| 14 import org.chromium.chromoting.DesktopView; | 14 import org.chromium.chromoting.DesktopView; |
| 15 import org.chromium.chromoting.Event; | 15 import org.chromium.chromoting.Event; |
| 16 import org.chromium.chromoting.InputFeedbackRadiusMapper; | 16 import org.chromium.chromoting.InputFeedbackRadiusMapper; |
| 17 import org.chromium.chromoting.RenderStub; | 17 import org.chromium.chromoting.RenderStub; |
| 18 import org.chromium.chromoting.SizeChangedEventParameter; | 18 import org.chromium.chromoting.SizeChangedEventParameter; |
| 19 | 19 |
| 20 /** | 20 /** |
| 21 * This class is a RenderStub implementation that uses the OpenGL renderer in na tive code to render | 21 * This class is a RenderStub implementation that uses the OpenGL renderer in na tive code to render |
| 22 * the remote desktop. The lifetime of this class is managed by the native JniGl DisplayHandler. | 22 * the remote desktop. The lifetime of this class is managed by the native JniGl DisplayHandler. |
| 23 * | 23 * |
| 24 * This class works entirely on the UI thread: | 24 * This class works entirely on the UI thread: |
| 25 * Functions should all be called on UI. | 25 * Functions should all be called on UI. |
| 26 * Events will only be triggered on UI. | 26 * Callbacks by native counterpart are called on UI. |
|
Sergey Ulanov
2016/09/20 18:09:34
s/UI/the UI thread/
Or maybe rephrase the whole co
Yuwei
2016/09/20 19:20:37
Done.
| |
| 27 */ | 27 */ |
| 28 @JNINamespace("remoting") | 28 @JNINamespace("remoting") |
| 29 public class GlDisplay implements SurfaceHolder.Callback, RenderStub { | 29 public class GlDisplay implements SurfaceHolder.Callback, RenderStub { |
| 30 private final Event.Raisable<SizeChangedEventParameter> mOnClientSizeChanged = | 30 private final Event.Raisable<SizeChangedEventParameter> mOnClientSizeChanged = |
| 31 new Event.Raisable<>(); | 31 new Event.Raisable<>(); |
| 32 private final Event.Raisable<SizeChangedEventParameter> mOnHostSizeChanged = | 32 private final Event.Raisable<SizeChangedEventParameter> mOnHostSizeChanged = |
| 33 new Event.Raisable<>(); | 33 new Event.Raisable<>(); |
| 34 private final Event.Raisable<Void> mOnCanvasRendered = new Event.Raisable<>( ); | 34 private final Event.Raisable<Void> mOnCanvasRendered = new Event.Raisable<>( ); |
| 35 | 35 |
| 36 private volatile long mNativeJniGlDisplay; | 36 private long mNativeJniGlDisplay; |
| 37 private InputFeedbackRadiusMapper mFeedbackRadiusMapper; | 37 private InputFeedbackRadiusMapper mFeedbackRadiusMapper; |
| 38 private float mScaleFactor = 0; | 38 private float mScaleFactor = 0; |
| 39 | 39 |
| 40 private GlDisplay(long nativeJniGlDisplay) { | 40 private GlDisplay(long nativeJniGlDisplay) { |
| 41 mNativeJniGlDisplay = nativeJniGlDisplay; | 41 mNativeJniGlDisplay = nativeJniGlDisplay; |
| 42 } | 42 } |
| 43 | 43 |
| 44 /** | 44 /** |
| 45 * Invalidates this object and disconnects from the native display handler. Called on the | 45 * Invalidates this object and disconnects from the native display handler. |
| 46 * display thread by the native code. | |
| 47 */ | 46 */ |
| 48 @CalledByNative | 47 @CalledByNative |
| 49 private void invalidate() { | 48 private void invalidate() { |
| 50 mNativeJniGlDisplay = 0; | 49 mNativeJniGlDisplay = 0; |
| 51 } | 50 } |
| 52 | 51 |
| 53 /** | 52 /** |
| 54 * Notifies the OpenGL renderer that a surface for OpenGL to draw is created . | 53 * Notifies the OpenGL renderer that a surface for OpenGL to draw is created . |
| 55 * @param holder the surface holder that holds the surface. | 54 * @param holder the surface holder that holds the surface. |
| 56 */ | 55 */ |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 191 private native void nativeOnSurfaceDestroyed(long nativeJniGlDisplayHandler) ; | 190 private native void nativeOnSurfaceDestroyed(long nativeJniGlDisplayHandler) ; |
| 192 private native void nativeOnPixelTransformationChanged(long nativeJniGlDispl ayHandler, | 191 private native void nativeOnPixelTransformationChanged(long nativeJniGlDispl ayHandler, |
| 193 float[] matrix); | 192 float[] matrix); |
| 194 private native void nativeOnCursorPixelPositionChanged(long nativeJniGlDispl ayHandler, | 193 private native void nativeOnCursorPixelPositionChanged(long nativeJniGlDispl ayHandler, |
| 195 float x, float y); | 194 float x, float y); |
| 196 private native void nativeOnCursorInputFeedback(long nativeJniGlDisplayHandl er, | 195 private native void nativeOnCursorInputFeedback(long nativeJniGlDisplayHandl er, |
| 197 float x, float y, float diam eter); | 196 float x, float y, float diam eter); |
| 198 private native void nativeOnCursorVisibilityChanged(long nativeJniGlDisplayH andler, | 197 private native void nativeOnCursorVisibilityChanged(long nativeJniGlDisplayH andler, |
| 199 boolean visible); | 198 boolean visible); |
| 200 } | 199 } |
| OLD | NEW |