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

Unified 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, 3 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 | « no previous file | remoting/client/frame_consumer.h » ('j') | 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/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..98169703d0080c961925d9db59dce9183f6a8be7 100644
--- a/remoting/android/java/src/org/chromium/chromoting/jni/JniInterface.java
+++ b/remoting/android/java/src/org/chromium/chromoting/jni/JniInterface.java
@@ -142,6 +142,9 @@ public class JniInterface {
/** Screen height of the video feed. */
private static int sHeight = 0;
+ /** Bitmap holding the latest screen image. */
+ private static Bitmap sBitmap = null;
+
/** Buffer holding the video feed. */
private static ByteBuffer sBuffer = null;
@@ -310,12 +313,19 @@ public class JniInterface {
return null;
}
- int[] frame = new int[sWidth * sHeight];
-
- sBuffer.order(ByteOrder.LITTLE_ENDIAN);
- sBuffer.asIntBuffer().get(frame, 0, frame.length);
+ // This is synchronized only to silence a findbugs warning about incorrect initialization of
+ // |sBitmap|.
+ // TODO(lambroslambrou): Annotate this class as @NotThreadSafe to prevent similar warnings
+ // in future.
+ synchronized (JniInterface.class) {
+ if (sBitmap == null || sBitmap.getWidth() != sWidth || sBitmap.getHeight() != sHeight) {
+ sBitmap = Bitmap.createBitmap(sWidth, sHeight, Bitmap.Config.ARGB_8888);
+ }
+ }
- return Bitmap.createBitmap(frame, 0, sWidth, sWidth, sHeight, Bitmap.Config.ARGB_8888);
+ sBuffer.rewind();
+ sBitmap.copyPixelsFromBuffer(sBuffer);
+ return sBitmap;
}
/**
« 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