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

Unified Diff: remoting/client/jni/jni_frame_consumer.h

Issue 24072012: Hold video frame in Bitmap instead of keeping a ByteBuffer reference. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments 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 side-by-side diff with in-line comments
Download patch
Index: remoting/client/jni/jni_frame_consumer.h
diff --git a/remoting/client/jni/jni_frame_consumer.h b/remoting/client/jni/jni_frame_consumer.h
index 1509720a739da6059fb476110db9fd598ef705ae..f4a1dcdba286c001a6c83f38a3e0e4f96e573568 100644
--- a/remoting/client/jni/jni_frame_consumer.h
+++ b/remoting/client/jni/jni_frame_consumer.h
@@ -7,9 +7,15 @@
#include "remoting/client/frame_consumer.h"
+#include "base/android/scoped_java_ref.h"
#include "base/compiler_specific.h"
+#include "base/memory/scoped_ptr.h"
#include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h"
+namespace gfx {
+class JavaBitmap;
+} // namespace gfx
+
namespace webrtc {
class DesktopFrame;
} // namespace webrtc
@@ -40,12 +46,17 @@ class JniFrameConsumer : public FrameConsumer {
virtual PixelFormat GetPixelFormat() OVERRIDE;
private:
+ // If not called from the destructor, allocates a new buffer of |view_size_|,
+ // informs Java about it, and tells the producer to draw onto it. Otherwise,
+ // this is a no-op.
+ void AllocateBuffer();
+
// Variables are to be used from the display thread.
// Used to obtain task runner references and make calls to Java methods.
ChromotingJniRuntime* jni_runtime_;
- // Whether we're currently in the constructor, and should deallocate the
+ // Whether we're currently in the destructor, and should deallocate the
// buffer instead of passing it back to the producer.
bool in_dtor_;
@@ -53,9 +64,15 @@ class JniFrameConsumer : public FrameConsumer {
webrtc::DesktopSize view_size_;
webrtc::DesktopRect clip_area_;
- // If |provide_buffer_|, allocates a new buffer of |view_size_|, informs
- // Java about it, and tells the producer to draw onto it. Otherwise, no-op.
- void AllocateBuffer();
+ // This global reference is required, instead of a local reference, so it
+ // remains valid for the lifetime of |bitmap_| - gfx::JavaBitmap does not
+ // create its own global reference internally. And this global ref must be
+ // destroyed (released) after |bitmap_| is destroyed.
+ base::android::ScopedJavaGlobalRef<jobject> bitmap_global_ref_;
+
+ // Reference to the frame bitmap that is passed to Java when the frame is
+ // allocated. This provides easy access to the underlying pixels.
+ scoped_ptr<gfx::JavaBitmap> bitmap_;
DISALLOW_COPY_AND_ASSIGN(JniFrameConsumer);
};

Powered by Google App Engine
This is Rietveld 408576698