Merge m-c to inbound.
[gecko.git] / gfx / thebes / nsSurfaceTexture.h
blob10d9e390251ee6d1d59c188076a53c31d9d0c890
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/. */
7 #ifndef nsSurfaceTexture_h__
8 #define nsSurfaceTexture_h__
9 #ifdef MOZ_WIDGET_ANDROID
11 #include <jni.h>
12 #include "nsIRunnable.h"
13 #include "gfxPlatform.h"
14 #include "gfx3DMatrix.h"
15 #include "GLDefs.h"
17 class gfxASurface;
19 /**
20 * This class is a wrapper around Android's SurfaceTexture class.
21 * Usage is pretty much exactly like the Java class, so see
22 * the Android documentation for details.
24 class nsSurfaceTexture {
25 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(nsSurfaceTexture)
27 public:
28 static nsSurfaceTexture* Create(GLuint aTexture);
29 static nsSurfaceTexture* Find(int id);
31 // Returns with reasonable certainty whether or not we'll
32 // be able to create and use a SurfaceTexture
33 static bool Check();
35 ~nsSurfaceTexture();
37 // This is an ANativeWindow. Use AndroidBridge::LockWindow and
38 // friends for manipulating it.
39 void* GetNativeWindow();
41 // This attaches the updated data to the TEXTURE_EXTERNAL target
42 void UpdateTexImage();
44 bool GetTransformMatrix(gfx3DMatrix& aMatrix);
45 int ID() { return mID; }
47 // The callback is guaranteed to be called on the main thread even
48 // if the upstream callback is received on a different thread
49 void SetFrameAvailableCallback(nsIRunnable* aRunnable);
51 // Only should be called by AndroidJNI when we get a
52 // callback from the underlying SurfaceTexture instance
53 void NotifyFrameAvailable();
54 private:
55 nsSurfaceTexture();
57 bool Init(GLuint aTexture);
59 jobject mSurfaceTexture;
60 void* mNativeWindow;
61 int mID;
62 nsRefPtr<nsIRunnable> mFrameAvailableCallback;
65 #endif
66 #endif