|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 // vim:set ts=2 sts=2 sw=2 et cin: |
|
3 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
4 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
6 |
|
7 #ifndef nsSurfaceTexture_h__ |
|
8 #define nsSurfaceTexture_h__ |
|
9 #ifdef MOZ_WIDGET_ANDROID |
|
10 |
|
11 #include <jni.h> |
|
12 #include "nsIRunnable.h" |
|
13 #include "gfxPlatform.h" |
|
14 #include "GLDefs.h" |
|
15 |
|
16 namespace mozilla { |
|
17 namespace gfx { |
|
18 class Matrix4x4; |
|
19 } |
|
20 } |
|
21 |
|
22 /** |
|
23 * This class is a wrapper around Android's SurfaceTexture class. |
|
24 * Usage is pretty much exactly like the Java class, so see |
|
25 * the Android documentation for details. |
|
26 */ |
|
27 class nsSurfaceTexture MOZ_FINAL { |
|
28 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(nsSurfaceTexture) |
|
29 |
|
30 public: |
|
31 static nsSurfaceTexture* Create(GLuint aTexture); |
|
32 static nsSurfaceTexture* Find(int id); |
|
33 |
|
34 // Returns with reasonable certainty whether or not we'll |
|
35 // be able to create and use a SurfaceTexture |
|
36 static bool Check(); |
|
37 |
|
38 // This is an ANativeWindow. Use AndroidBridge::LockWindow and |
|
39 // friends for manipulating it. |
|
40 void* GetNativeWindow(); |
|
41 |
|
42 // This attaches the updated data to the TEXTURE_EXTERNAL target |
|
43 void UpdateTexImage(); |
|
44 |
|
45 bool GetTransformMatrix(mozilla::gfx::Matrix4x4& aMatrix); |
|
46 int ID() { return mID; } |
|
47 |
|
48 // The callback is guaranteed to be called on the main thread even |
|
49 // if the upstream callback is received on a different thread |
|
50 void SetFrameAvailableCallback(nsIRunnable* aRunnable); |
|
51 |
|
52 // Only should be called by AndroidJNI when we get a |
|
53 // callback from the underlying SurfaceTexture instance |
|
54 void NotifyFrameAvailable(); |
|
55 private: |
|
56 nsSurfaceTexture(); |
|
57 |
|
58 // Private destructor, to discourage deletion outside of Release(): |
|
59 ~nsSurfaceTexture(); |
|
60 |
|
61 bool Init(GLuint aTexture); |
|
62 |
|
63 jobject mSurfaceTexture; |
|
64 void* mNativeWindow; |
|
65 int mID; |
|
66 nsRefPtr<nsIRunnable> mFrameAvailableCallback; |
|
67 }; |
|
68 |
|
69 #endif |
|
70 #endif |