Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #ifndef UI_GL_ANDROID_SURFACE_TEXTURE_H_ | 5 #ifndef UI_GL_ANDROID_SURFACE_TEXTURE_H_ |
| 6 #define UI_GL_ANDROID_SURFACE_TEXTURE_H_ | 6 #define UI_GL_ANDROID_SURFACE_TEXTURE_H_ |
| 7 | 7 |
| 8 #include <jni.h> | 8 #include <jni.h> |
| 9 | 9 |
| 10 #include "base/android/scoped_java_ref.h" | 10 #include "base/android/scoped_java_ref.h" |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "ui/gl/gl_export.h" | 13 #include "ui/gl/gl_export.h" |
| 14 | 14 |
| 15 struct ANativeWindow; | 15 struct ANativeWindow; |
| 16 | 16 |
| 17 namespace gfx { | 17 namespace gfx { |
| 18 | 18 |
| 19 // This class serves as a bridge for native code to call java functions inside | 19 // This class serves as a bridge for native code to call java functions inside |
| 20 // android SurfaceTexture class. | 20 // android SurfaceTexture class. |
| 21 class GL_EXPORT SurfaceTexture | 21 class GL_EXPORT SurfaceTexture |
| 22 : public base::RefCountedThreadSafe<SurfaceTexture>{ | 22 : public base::RefCountedThreadSafe<SurfaceTexture>{ |
| 23 public: | 23 public: |
| 24 explicit SurfaceTexture(int texture_id); | 24 SurfaceTexture(int texture_id, bool single_buffer_mode); |
| 25 | 25 |
| 26 // Set the listener callback, which will be invoked on the same thread that | 26 // Set the listener callback, which will be invoked on the same thread that |
| 27 // is being called from here for registration. | 27 // is being called from here for registration. |
| 28 // Note: Since callbacks come in from Java objects that might outlive objects | 28 // Note: Since callbacks come in from Java objects that might outlive objects |
| 29 // being referenced from the callback, the only robust way here is to create | 29 // being referenced from the callback, the only robust way here is to create |
| 30 // the callback from a weak pointer to your object. | 30 // the callback from a weak pointer to your object. |
| 31 void SetFrameAvailableCallback(const base::Closure& callback); | 31 void SetFrameAvailableCallback(const base::Closure& callback); |
| 32 | 32 |
| 33 // Update the texture image to the most recent frame from the image stream. | 33 // Update the texture image to the most recent frame from the image stream. |
| 34 void UpdateTexImage(); | 34 void UpdateTexImage(); |
| 35 | 35 |
| 36 // Release the texture content. This is needed in single buffered mode | |
| 37 // to allow the image content producer to take ownership of the image buffer. | |
|
bulach
2014/03/10 12:32:31
should we comment that this is only available sinc
reveman
2014/03/10 13:33:05
I don't think so. We can add a comment about this
| |
| 38 void ReleaseTexImage(); | |
| 39 | |
| 36 // Retrieve the 4x4 texture coordinate transform matrix associated with the | 40 // Retrieve the 4x4 texture coordinate transform matrix associated with the |
| 37 // texture image set by the most recent call to updateTexImage. | 41 // texture image set by the most recent call to updateTexImage. |
| 38 void GetTransformMatrix(float mtx[16]); | 42 void GetTransformMatrix(float mtx[16]); |
| 39 | 43 |
| 40 // Set the default size of the image buffers. | 44 // Set the default size of the image buffers. |
| 41 void SetDefaultBufferSize(int width, int height); | 45 void SetDefaultBufferSize(int width, int height); |
| 42 | 46 |
| 43 // Attach the SurfaceTexture to the texture currently bound to | 47 // Attach the SurfaceTexture to the texture currently bound to |
| 44 // GL_TEXTURE_EXTERNAL_OES. | 48 // GL_TEXTURE_EXTERNAL_OES. |
| 45 void AttachToGLContext(); | 49 void AttachToGLContext(); |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 65 | 69 |
| 66 // Java SurfaceTexture instance. | 70 // Java SurfaceTexture instance. |
| 67 base::android::ScopedJavaGlobalRef<jobject> j_surface_texture_; | 71 base::android::ScopedJavaGlobalRef<jobject> j_surface_texture_; |
| 68 | 72 |
| 69 DISALLOW_COPY_AND_ASSIGN(SurfaceTexture); | 73 DISALLOW_COPY_AND_ASSIGN(SurfaceTexture); |
| 70 }; | 74 }; |
| 71 | 75 |
| 72 } // namespace gfx | 76 } // namespace gfx |
| 73 | 77 |
| 74 #endif // UI_GL_ANDROID_SURFACE_TEXTURE_H_ | 78 #endif // UI_GL_ANDROID_SURFACE_TEXTURE_H_ |
| OLD | NEW |