Chromium Code Reviews| Index: remoting/android/java/src/org/chromium/chromoting/jni/JniInterface.java |
| diff --git a/remoting/android/java/src/org/chromium/chromoting/jni/JniInterface.java b/remoting/android/java/src/org/chromium/chromoting/jni/JniInterface.java |
| index bd2a25e9eb34fea296f997ea7f8d8e204213c5dd..de9f92d3bc8a592485ba0ca462c6f4644814b906 100644 |
| --- a/remoting/android/java/src/org/chromium/chromoting/jni/JniInterface.java |
| +++ b/remoting/android/java/src/org/chromium/chromoting/jni/JniInterface.java |
| @@ -136,14 +136,8 @@ public class JniInterface { |
| /** Callback to signal whenever we need to redraw. */ |
| private static Runnable sRedrawCallback = null; |
| - /** Screen width of the video feed. */ |
| - private static int sWidth = 0; |
| - |
| - /** Screen height of the video feed. */ |
| - private static int sHeight = 0; |
| - |
| - /** Buffer holding the video feed. */ |
| - private static ByteBuffer sBuffer = null; |
| + /** Bitmap holding a copy of the latest video frame. */ |
| + private static Bitmap sFrameBitmap = null; |
| /** Position of cursor hot-spot. */ |
| private static Point sCursorHotspot = new Point(); |
| @@ -298,10 +292,10 @@ public class JniInterface { |
| } |
| /** |
| - * Obtains the image buffer. |
| - * This should not be called from the UI thread. (We prefer the native graphics thread.) |
| + * Returns a bitmap of the latest video frame. Called on the native graphics thread when |
| + * DesktopView is repainted. |
| */ |
| - public static Bitmap retrieveVideoFrame() { |
| + public static Bitmap getVideoFrame() { |
| if (Looper.myLooper() == Looper.getMainLooper()) { |
| Log.w("jniiface", "Canvas being redrawn on UI thread"); |
| } |
| @@ -310,12 +304,21 @@ public class JniInterface { |
| return null; |
| } |
| - int[] frame = new int[sWidth * sHeight]; |
| + return sFrameBitmap; |
| + } |
| - sBuffer.order(ByteOrder.LITTLE_ENDIAN); |
| - sBuffer.asIntBuffer().get(frame, 0, frame.length); |
| + /** |
| + * Sets a new video frame. Called from native code on the native graphics thread whenever a new |
| + * frame has been decoded. |
| + */ |
| + private static void setVideoFrame(int width, int height, ByteBuffer buffer) { |
| + int[] frame = new int[width * height]; |
|
garykac
2013/09/23 19:47:43
Can you add a check here to ensure that this is be
Lambros
2013/09/25 23:15:11
Done.
|
| + |
| + buffer.order(ByteOrder.LITTLE_ENDIAN); |
| + buffer.asIntBuffer().get(frame, 0, frame.length); |
|
Sergey Ulanov
2013/09/25 23:32:08
This copies content of the buffer. I think we can
solb
2013/09/26 14:21:36
If I understand the patches correctly, https://cod
Lambros
2013/09/26 22:29:37
Yes - with these two CLs landed, there will only b
|
| - return Bitmap.createBitmap(frame, 0, sWidth, sWidth, sHeight, Bitmap.Config.ARGB_8888); |
| + sFrameBitmap = Bitmap.createBitmap(frame, width, height, Bitmap.Config.ARGB_8888); |
| + redrawGraphicsInternal(); |
| } |
| /** |