| 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.content.Context; |
| 7 import android.graphics.Bitmap; | 8 import android.graphics.Bitmap; |
| 8 import android.graphics.Point; | 9 import android.graphics.Point; |
| 9 import android.os.Looper; | 10 import android.os.Looper; |
| 10 | 11 |
| 11 import org.chromium.base.Log; | 12 import org.chromium.base.Log; |
| 12 import org.chromium.base.annotations.CalledByNative; | 13 import org.chromium.base.annotations.CalledByNative; |
| 13 import org.chromium.base.annotations.JNINamespace; | 14 import org.chromium.base.annotations.JNINamespace; |
| 15 import org.chromium.chromoting.DesktopView; |
| 16 import org.chromium.chromoting.DesktopViewFactory; |
| 17 import org.chromium.chromoting.DesktopViewInterface; |
| 14 | 18 |
| 15 import java.nio.ByteBuffer; | 19 import java.nio.ByteBuffer; |
| 16 import java.nio.ByteOrder; | 20 import java.nio.ByteOrder; |
| 17 | 21 |
| 18 /** | 22 /** |
| 19 * This class is for drawing the desktop on the canvas and controlling the lifet
ime of the | 23 * This class is for drawing the desktop on the canvas and controlling the lifet
ime of the |
| 20 * corresponding C++ object. It only draws the desktop on the graphics (=display
) thread but also | 24 * corresponding C++ object. It only draws the desktop on the graphics (=display
) thread but also |
| 21 * has functions accessible on UI thread. | 25 * has functions accessible on UI thread. |
| 22 */ | 26 */ |
| 23 @JNINamespace("remoting") | 27 @JNINamespace("remoting") |
| 24 public class Display { | 28 public class Display implements DesktopViewFactory { |
| 25 private static final String TAG = "Chromoting"; | 29 private static final String TAG = "Chromoting"; |
| 26 | 30 |
| 27 // Pointer to the C++ object. Casted to |long|. | 31 // Pointer to the C++ object. Casted to |long|. |
| 28 private long mNativeJniDisplayHandler; | 32 private long mNativeJniDisplayHandler; |
| 29 | 33 |
| 30 /** | 34 /** |
| 31 * Callback invoked on the graphics thread to repaint the desktop. Read on t
he UI and | 35 * Callback invoked on the graphics thread to repaint the desktop. Read on t
he UI and |
| 32 * graphics threads. Write only on the UI thread. | 36 * graphics threads. Write only on the UI thread. |
| 33 */ | 37 */ |
| 34 private Runnable mRedrawCallback; | 38 private Runnable mRedrawCallback; |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 return mCursorBitmap; | 176 return mCursorBitmap; |
| 173 } | 177 } |
| 174 | 178 |
| 175 @CalledByNative | 179 @CalledByNative |
| 176 private static Display createJavaDisplayObject(long nativeDisplayHandler) { | 180 private static Display createJavaDisplayObject(long nativeDisplayHandler) { |
| 177 return new Display(nativeDisplayHandler); | 181 return new Display(nativeDisplayHandler); |
| 178 } | 182 } |
| 179 | 183 |
| 180 /** Schedules a redraw on the native graphics thread. */ | 184 /** Schedules a redraw on the native graphics thread. */ |
| 181 private native void nativeScheduleRedraw(long nativeJniDisplayHandler); | 185 private native void nativeScheduleRedraw(long nativeJniDisplayHandler); |
| 186 |
| 187 @Override |
| 188 public DesktopViewInterface createDesktopView(Context context) { |
| 189 return new DesktopView(context); |
| 190 } |
| 182 } | 191 } |
| OLD | NEW |