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

Side by Side Diff: remoting/android/java/src/org/chromium/chromoting/jni/JniInterface.java

Issue 23677011: Byte-swap the video frame pixels before passing them to Java. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Narrow the synchronization block Created 7 years, 2 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 unified diff | Download patch
« no previous file with comments | « no previous file | remoting/client/frame_consumer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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.app.Activity; 7 import android.app.Activity;
8 import android.app.AlertDialog; 8 import android.app.AlertDialog;
9 import android.app.ProgressDialog; 9 import android.app.ProgressDialog;
10 import android.content.Context; 10 import android.content.Context;
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 */ 135 */
136 /** Callback to signal whenever we need to redraw. */ 136 /** Callback to signal whenever we need to redraw. */
137 private static Runnable sRedrawCallback = null; 137 private static Runnable sRedrawCallback = null;
138 138
139 /** Screen width of the video feed. */ 139 /** Screen width of the video feed. */
140 private static int sWidth = 0; 140 private static int sWidth = 0;
141 141
142 /** Screen height of the video feed. */ 142 /** Screen height of the video feed. */
143 private static int sHeight = 0; 143 private static int sHeight = 0;
144 144
145 /** Bitmap holding the latest screen image. */
146 private static Bitmap sBitmap = null;
147
145 /** Buffer holding the video feed. */ 148 /** Buffer holding the video feed. */
146 private static ByteBuffer sBuffer = null; 149 private static ByteBuffer sBuffer = null;
147 150
148 /** Position of cursor hot-spot. */ 151 /** Position of cursor hot-spot. */
149 private static Point sCursorHotspot = new Point(); 152 private static Point sCursorHotspot = new Point();
150 153
151 /** Bitmap holding the cursor shape. */ 154 /** Bitmap holding the cursor shape. */
152 private static Bitmap sCursorBitmap = null; 155 private static Bitmap sCursorBitmap = null;
153 156
154 /** Reports whenever the connection status changes. */ 157 /** Reports whenever the connection status changes. */
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 */ 306 */
304 public static Bitmap retrieveVideoFrame() { 307 public static Bitmap retrieveVideoFrame() {
305 if (Looper.myLooper() == Looper.getMainLooper()) { 308 if (Looper.myLooper() == Looper.getMainLooper()) {
306 Log.w("jniiface", "Canvas being redrawn on UI thread"); 309 Log.w("jniiface", "Canvas being redrawn on UI thread");
307 } 310 }
308 311
309 if (!sConnected) { 312 if (!sConnected) {
310 return null; 313 return null;
311 } 314 }
312 315
313 int[] frame = new int[sWidth * sHeight]; 316 // This is synchronized only to silence a findbugs warning about incorre ct initialization of
317 // |sBitmap|.
318 // TODO(lambroslambrou): Annotate this class as @NotThreadSafe to preven t similar warnings
319 // in future.
320 synchronized (JniInterface.class) {
321 if (sBitmap == null || sBitmap.getWidth() != sWidth || sBitmap.getHe ight() != sHeight) {
322 sBitmap = Bitmap.createBitmap(sWidth, sHeight, Bitmap.Config.ARG B_8888);
323 }
324 }
314 325
315 sBuffer.order(ByteOrder.LITTLE_ENDIAN); 326 sBuffer.rewind();
316 sBuffer.asIntBuffer().get(frame, 0, frame.length); 327 sBitmap.copyPixelsFromBuffer(sBuffer);
317 328 return sBitmap;
318 return Bitmap.createBitmap(frame, 0, sWidth, sWidth, sHeight, Bitmap.Con fig.ARGB_8888);
319 } 329 }
320 330
321 /** 331 /**
322 * Updates the cursor shape. This is called from native code on the graphics thread when 332 * Updates the cursor shape. This is called from native code on the graphics thread when
323 * receiving a new cursor shape from the host. 333 * receiving a new cursor shape from the host.
324 */ 334 */
325 public static void updateCursorShape(int width, int height, int hotspotX, in t hotspotY, 335 public static void updateCursorShape(int width, int height, int hotspotX, in t hotspotY,
326 ByteBuffer buffer) { 336 ByteBuffer buffer) {
327 sCursorHotspot = new Point(hotspotX, hotspotY); 337 sCursorHotspot = new Point(hotspotX, hotspotY);
328 338
(...skipping 26 matching lines...) Expand all
355 365
356 /** Schedules a redraw on the native graphics thread. */ 366 /** Schedules a redraw on the native graphics thread. */
357 private static native void scheduleRedrawNative(); 367 private static native void scheduleRedrawNative();
358 368
359 /** Passes mouse information to the native handling code. */ 369 /** Passes mouse information to the native handling code. */
360 private static native void mouseActionNative(int x, int y, int whichButton, boolean buttonDown); 370 private static native void mouseActionNative(int x, int y, int whichButton, boolean buttonDown);
361 371
362 /** Passes key press information to the native handling code. */ 372 /** Passes key press information to the native handling code. */
363 private static native void keyboardActionNative(int keyCode, boolean keyDown ); 373 private static native void keyboardActionNative(int keyCode, boolean keyDown );
364 } 374 }
OLDNEW
« no previous file with comments | « no previous file | remoting/client/frame_consumer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698