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

Side by Side Diff: ui/gl/android/surface_texture.h

Issue 191933002: This is initial API support required for enabling SurfaceTexture backed zero-copy for Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove unused code Created 6 years, 9 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
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 #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 static scoped_refptr<SurfaceTexture> Create(int texture_id);
25
26 static scoped_refptr<SurfaceTexture> CreateSingleBuffered(int texture_id);
25 27
26 // Set the listener callback, which will be invoked on the same thread that 28 // Set the listener callback, which will be invoked on the same thread that
27 // is being called from here for registration. 29 // is being called from here for registration.
28 // Note: Since callbacks come in from Java objects that might outlive objects 30 // 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 31 // being referenced from the callback, the only robust way here is to create
30 // the callback from a weak pointer to your object. 32 // the callback from a weak pointer to your object.
31 void SetFrameAvailableCallback(const base::Closure& callback); 33 void SetFrameAvailableCallback(const base::Closure& callback);
32 34
33 // Update the texture image to the most recent frame from the image stream. 35 // Update the texture image to the most recent frame from the image stream.
34 void UpdateTexImage(); 36 void UpdateTexImage();
35 37
38 // Release the texture content. This is needed, and supported only in single
39 // buffered mode to allow the image content producer to take ownership
40 // of the image buffer.
bulach 2014/03/11 16:13:17 nit: I'd be even more explicit: this is *only* sup
41 void ReleaseTexImage();
42
36 // Retrieve the 4x4 texture coordinate transform matrix associated with the 43 // Retrieve the 4x4 texture coordinate transform matrix associated with the
37 // texture image set by the most recent call to updateTexImage. 44 // texture image set by the most recent call to updateTexImage.
38 void GetTransformMatrix(float mtx[16]); 45 void GetTransformMatrix(float mtx[16]);
39 46
40 // Set the default size of the image buffers. 47 // Set the default size of the image buffers.
41 void SetDefaultBufferSize(int width, int height); 48 void SetDefaultBufferSize(int width, int height);
42 49
43 // Attach the SurfaceTexture to the texture currently bound to 50 // Attach the SurfaceTexture to the texture currently bound to
44 // GL_TEXTURE_EXTERNAL_OES. 51 // GL_TEXTURE_EXTERNAL_OES.
45 void AttachToGLContext(); 52 void AttachToGLContext();
46 53
47 // Detaches the SurfaceTexture from the context that owns its current GL 54 // Detaches the SurfaceTexture from the context that owns its current GL
48 // texture. Must be called with that context current on the calling thread. 55 // texture. Must be called with that context current on the calling thread.
49 void DetachFromGLContext(); 56 void DetachFromGLContext();
50 57
51 // Creates a native render surface for this surface texture. 58 // Creates a native render surface for this surface texture.
52 // The caller must release the underlying reference when done with the handle 59 // The caller must release the underlying reference when done with the handle
53 // by calling ANativeWindow_release(). 60 // by calling ANativeWindow_release().
54 ANativeWindow* CreateSurface(); 61 ANativeWindow* CreateSurface();
55 62
56 const base::android::JavaRef<jobject>& j_surface_texture() const { 63 const base::android::JavaRef<jobject>& j_surface_texture() const {
57 return j_surface_texture_; 64 return j_surface_texture_;
58 } 65 }
59 66
67 static bool IsSingleBufferModeSupported();
bulach 2014/03/11 16:13:17 nit: hmm... do we need a non-static method too? I
68
60 static bool RegisterSurfaceTexture(JNIEnv* env); 69 static bool RegisterSurfaceTexture(JNIEnv* env);
61 70
71 protected:
72 explicit SurfaceTexture(
73 const base::android::ScopedJavaLocalRef<jobject>& j_surface_texture);
74
62 private: 75 private:
63 friend class base::RefCountedThreadSafe<SurfaceTexture>; 76 friend class base::RefCountedThreadSafe<SurfaceTexture>;
64 ~SurfaceTexture(); 77 ~SurfaceTexture();
65 78
66 // Java SurfaceTexture instance. 79 // Java SurfaceTexture instance.
67 base::android::ScopedJavaGlobalRef<jobject> j_surface_texture_; 80 base::android::ScopedJavaGlobalRef<jobject> j_surface_texture_;
68 81
69 DISALLOW_COPY_AND_ASSIGN(SurfaceTexture); 82 DISALLOW_COPY_AND_ASSIGN(SurfaceTexture);
70 }; 83 };
71 84
72 } // namespace gfx 85 } // namespace gfx
73 86
74 #endif // UI_GL_ANDROID_SURFACE_TEXTURE_H_ 87 #endif // UI_GL_ANDROID_SURFACE_TEXTURE_H_
OLDNEW
« no previous file with comments | « ui/android/java/src/org/chromium/ui/gl/SurfaceTexturePlatformWrapper.java ('k') | ui/gl/android/surface_texture.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698