OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_COMMON_ANDROID_SURFACE_TEXTURE_BRIDGE_H_ |
| 6 #define CONTENT_COMMON_ANDROID_SURFACE_TEXTURE_BRIDGE_H_ |
| 7 #pragma once |
| 8 |
| 9 #include <jni.h> |
| 10 |
| 11 #include "base/android/scoped_java_ref.h" |
| 12 #include "base/callback.h" |
| 13 |
| 14 namespace content { |
| 15 |
| 16 // This class serves as a bridge for native code to call java functions inside |
| 17 // android SurfaceTexture class. |
| 18 class SurfaceTextureBridge { |
| 19 public: |
| 20 explicit SurfaceTextureBridge(int texture_id); |
| 21 ~SurfaceTextureBridge(); |
| 22 |
| 23 // Set the listener callback, which will be invoked on the same thread that |
| 24 // is being called from here for registration. |
| 25 // Note: Since callbacks come in from Java objects that might outlive objects |
| 26 // being referenced from the callback, the only robust way here is to create |
| 27 // the callback from a weak pointer to your object. |
| 28 void SetFrameAvailableCallback(const base::Closure& callback); |
| 29 |
| 30 // Update the texture image to the most recent frame from the image stream. |
| 31 void UpdateTexImage(); |
| 32 |
| 33 // Retrieve the 4x4 texture coordinate transform matrix associated with the |
| 34 // texture image set by the most recent call to updateTexImage. |
| 35 void GetTransformMatrix(float mtx[16]); |
| 36 |
| 37 // Set the default size of the image buffers. |
| 38 void SetDefaultBufferSize(int width, int height); |
| 39 |
| 40 int texture_id() const { |
| 41 return texture_id_; |
| 42 } |
| 43 |
| 44 const base::android::JavaRef<jobject>& j_surface_texture() const { |
| 45 return j_surface_texture_; |
| 46 } |
| 47 |
| 48 private: |
| 49 const int texture_id_; |
| 50 |
| 51 // Java SurfaceTexture class and instance. |
| 52 base::android::ScopedJavaGlobalRef<jclass> j_class_; |
| 53 base::android::ScopedJavaGlobalRef<jobject> j_surface_texture_; |
| 54 |
| 55 DISALLOW_COPY_AND_ASSIGN(SurfaceTextureBridge); |
| 56 }; |
| 57 |
| 58 } // namespace content |
| 59 |
| 60 #endif // CONTENT_COMMON_ANDROID_SURFACE_TEXTURE_BRIDGE_H_ |
OLD | NEW |