michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: // vim:set ts=2 sts=2 sw=2 et cin: michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef nsSurfaceTexture_h__ michael@0: #define nsSurfaceTexture_h__ michael@0: #ifdef MOZ_WIDGET_ANDROID michael@0: michael@0: #include michael@0: #include "nsIRunnable.h" michael@0: #include "gfxPlatform.h" michael@0: #include "GLDefs.h" michael@0: michael@0: namespace mozilla { michael@0: namespace gfx { michael@0: class Matrix4x4; michael@0: } michael@0: } michael@0: michael@0: /** michael@0: * This class is a wrapper around Android's SurfaceTexture class. michael@0: * Usage is pretty much exactly like the Java class, so see michael@0: * the Android documentation for details. michael@0: */ michael@0: class nsSurfaceTexture MOZ_FINAL { michael@0: NS_INLINE_DECL_THREADSAFE_REFCOUNTING(nsSurfaceTexture) michael@0: michael@0: public: michael@0: static nsSurfaceTexture* Create(GLuint aTexture); michael@0: static nsSurfaceTexture* Find(int id); michael@0: michael@0: // Returns with reasonable certainty whether or not we'll michael@0: // be able to create and use a SurfaceTexture michael@0: static bool Check(); michael@0: michael@0: // This is an ANativeWindow. Use AndroidBridge::LockWindow and michael@0: // friends for manipulating it. michael@0: void* GetNativeWindow(); michael@0: michael@0: // This attaches the updated data to the TEXTURE_EXTERNAL target michael@0: void UpdateTexImage(); michael@0: michael@0: bool GetTransformMatrix(mozilla::gfx::Matrix4x4& aMatrix); michael@0: int ID() { return mID; } michael@0: michael@0: // The callback is guaranteed to be called on the main thread even michael@0: // if the upstream callback is received on a different thread michael@0: void SetFrameAvailableCallback(nsIRunnable* aRunnable); michael@0: michael@0: // Only should be called by AndroidJNI when we get a michael@0: // callback from the underlying SurfaceTexture instance michael@0: void NotifyFrameAvailable(); michael@0: private: michael@0: nsSurfaceTexture(); michael@0: michael@0: // Private destructor, to discourage deletion outside of Release(): michael@0: ~nsSurfaceTexture(); michael@0: michael@0: bool Init(GLuint aTexture); michael@0: michael@0: jobject mSurfaceTexture; michael@0: void* mNativeWindow; michael@0: int mID; michael@0: nsRefPtr mFrameAvailableCallback; michael@0: }; michael@0: michael@0: #endif michael@0: #endif