1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/thebes/nsSurfaceTexture.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,70 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +// vim:set ts=2 sts=2 sw=2 et cin: 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#ifndef nsSurfaceTexture_h__ 1.11 +#define nsSurfaceTexture_h__ 1.12 +#ifdef MOZ_WIDGET_ANDROID 1.13 + 1.14 +#include <jni.h> 1.15 +#include "nsIRunnable.h" 1.16 +#include "gfxPlatform.h" 1.17 +#include "GLDefs.h" 1.18 + 1.19 +namespace mozilla { 1.20 +namespace gfx { 1.21 +class Matrix4x4; 1.22 +} 1.23 +} 1.24 + 1.25 +/** 1.26 + * This class is a wrapper around Android's SurfaceTexture class. 1.27 + * Usage is pretty much exactly like the Java class, so see 1.28 + * the Android documentation for details. 1.29 + */ 1.30 +class nsSurfaceTexture MOZ_FINAL { 1.31 + NS_INLINE_DECL_THREADSAFE_REFCOUNTING(nsSurfaceTexture) 1.32 + 1.33 +public: 1.34 + static nsSurfaceTexture* Create(GLuint aTexture); 1.35 + static nsSurfaceTexture* Find(int id); 1.36 + 1.37 + // Returns with reasonable certainty whether or not we'll 1.38 + // be able to create and use a SurfaceTexture 1.39 + static bool Check(); 1.40 + 1.41 + // This is an ANativeWindow. Use AndroidBridge::LockWindow and 1.42 + // friends for manipulating it. 1.43 + void* GetNativeWindow(); 1.44 + 1.45 + // This attaches the updated data to the TEXTURE_EXTERNAL target 1.46 + void UpdateTexImage(); 1.47 + 1.48 + bool GetTransformMatrix(mozilla::gfx::Matrix4x4& aMatrix); 1.49 + int ID() { return mID; } 1.50 + 1.51 + // The callback is guaranteed to be called on the main thread even 1.52 + // if the upstream callback is received on a different thread 1.53 + void SetFrameAvailableCallback(nsIRunnable* aRunnable); 1.54 + 1.55 + // Only should be called by AndroidJNI when we get a 1.56 + // callback from the underlying SurfaceTexture instance 1.57 + void NotifyFrameAvailable(); 1.58 +private: 1.59 + nsSurfaceTexture(); 1.60 + 1.61 + // Private destructor, to discourage deletion outside of Release(): 1.62 + ~nsSurfaceTexture(); 1.63 + 1.64 + bool Init(GLuint aTexture); 1.65 + 1.66 + jobject mSurfaceTexture; 1.67 + void* mNativeWindow; 1.68 + int mID; 1.69 + nsRefPtr<nsIRunnable> mFrameAvailableCallback; 1.70 +}; 1.71 + 1.72 +#endif 1.73 +#endif