Bug 1294481 - Rip out old Java code for AndroidSurfaceTexture; r=snorp

Rip out the old GeckoAppShell methods that implemented a
OnFrameAvailableListener callback system for AndroidSurfaceTexture.
This commit is contained in:
Jim Chen 2016-08-23 18:52:30 -04:00
parent 33f9ee19fb
commit abb40676c0
4 changed files with 0 additions and 117 deletions

View File

@ -27,58 +27,6 @@ using namespace mozilla::java::sdk;
namespace mozilla {
namespace gl {
// Maintains a mapping between AndroidSurfaceTexture instances and their
// unique numerical IDs. [thread-safe]
class InstanceMap
{
typedef AndroidSurfaceTexture* InstancePtr;
typedef std::map<int, InstancePtr> MapType;
public:
InstanceMap()
: mNextId(0)
, mMonitor("AndroidSurfaceTexture::InstanceMap::mMonitor")
{}
int Add(InstancePtr aInstance)
{
MonitorAutoLock lock(mMonitor);
mInstances.insert({++mNextId, aInstance});
return mNextId;
}
void Remove(int aId)
{
MonitorAutoLock lock(mMonitor);
mInstances.erase(aId);
}
InstancePtr Get(int aId) const
{
MonitorAutoLock lock(mMonitor);
auto it = mInstances.find(aId);
if (it == mInstances.end()) {
return nullptr;
}
return it->second;
}
private:
MapType mInstances;
int mNextId;
mutable Monitor mMonitor;
};
static InstanceMap sInstances;
AndroidSurfaceTexture*
AndroidSurfaceTexture::Find(int aId)
{
return sInstances.Get(aId);
}
static bool
IsSTSupported()
{
@ -204,8 +152,6 @@ AndroidSurfaceTexture::Init(GLContext* aContext, GLuint aTexture)
mSurface.Get());
MOZ_ASSERT(mNativeWindow, "Failed to create native window from surface");
mID = sInstances.Add(this);
return true;
}
@ -220,12 +166,7 @@ AndroidSurfaceTexture::AndroidSurfaceTexture()
AndroidSurfaceTexture::~AndroidSurfaceTexture()
{
sInstances.Remove(mID);
mFrameAvailableCallback = nullptr;
if (mSurfaceTexture) {
GeckoAppShell::UnregisterSurfaceTextureFrameListener(mSurfaceTexture);
mSurfaceTexture = nullptr;
}
@ -277,13 +218,6 @@ AndroidSurfaceTexture::GetTransformMatrix(gfx::Matrix4x4& aMatrix) const
void
AndroidSurfaceTexture::SetFrameAvailableCallback(nsIRunnable* aRunnable)
{
if (aRunnable) {
GeckoAppShell::RegisterSurfaceTextureFrameListener(mSurfaceTexture, mID);
} else {
GeckoAppShell::UnregisterSurfaceTextureFrameListener(mSurfaceTexture);
}
mFrameAvailableCallback = aRunnable;
}
void
@ -292,20 +226,6 @@ AndroidSurfaceTexture::SetDefaultSize(mozilla::gfx::IntSize size)
mSurfaceTexture->SetDefaultBufferSize(size.width, size.height);
}
void
AndroidSurfaceTexture::NotifyFrameAvailable()
{
if (mFrameAvailableCallback) {
// Proxy to main thread if we aren't on it
if (!NS_IsMainThread()) {
// Proxy to main thread
NS_DispatchToCurrentThread(NewRunnableMethod(this, &AndroidSurfaceTexture::NotifyFrameAvailable));
} else {
mFrameAvailableCallback->Run();
}
}
}
} // gl
} // mozilla

View File

@ -44,8 +44,6 @@ public:
// Android Jelly Bean.
static already_AddRefed<AndroidSurfaceTexture> Create();
static AndroidSurfaceTexture* Find(int aId);
// If we are on Jelly Bean, the SurfaceTexture can be detached and reattached
// to allow consumption from different GLContexts. It is recommended to only
// attach while you are consuming in order to allow this.
@ -70,7 +68,6 @@ public:
void UpdateTexImage();
void GetTransformMatrix(mozilla::gfx::Matrix4x4& aMatrix) const;
int ID() const { return mID; }
void SetDefaultSize(mozilla::gfx::IntSize size);
@ -78,10 +75,6 @@ public:
// if the upstream callback is received on a different thread
void SetFrameAvailableCallback(nsIRunnable* aRunnable);
// Only should be called by AndroidJNI when we get a
// callback from the underlying SurfaceTexture instance
void NotifyFrameAvailable();
GLuint Texture() const { return mTexture; }
const java::sdk::Surface::Ref& JavaSurface() const { return mSurface; }
@ -98,8 +91,6 @@ private:
GLContext* mAttachedContext;
ANativeWindow* mNativeWindow;
int mID;
nsCOMPtr<nsIRunnable> mFrameAvailableCallback;
mutable Monitor mMonitor;
};

View File

@ -238,8 +238,6 @@ public class GeckoAppShell
/* The Android-side API: API methods that Android calls */
// helper methods
public static native void onSurfaceTextureFrameAvailable(Object surfaceTexture, int id);
@WrapForJNI
private static native void reportJavaCrash(String stackTrace);
@ -2190,21 +2188,6 @@ public class GeckoAppShell
getGeckoInterface().notifyWakeLockChanged(topic, state);
}
@WrapForJNI
public static void registerSurfaceTextureFrameListener(Object surfaceTexture, final int id) {
((SurfaceTexture)surfaceTexture).setOnFrameAvailableListener(new SurfaceTexture.OnFrameAvailableListener() {
@Override
public void onFrameAvailable(SurfaceTexture surfaceTexture) {
GeckoAppShell.onSurfaceTextureFrameAvailable(surfaceTexture, id);
}
});
}
@WrapForJNI
public static void unregisterSurfaceTextureFrameListener(Object surfaceTexture) {
((SurfaceTexture)surfaceTexture).setOnFrameAvailableListener(null);
}
@WrapForJNI(calledFrom = "gecko")
public static boolean unlockProfile() {
// Try to kill any zombie Fennec's that might be running

View File

@ -43,16 +43,5 @@ extern "C" {
/*
* Incoming JNI methods
*/
NS_EXPORT void JNICALL
Java_org_mozilla_gecko_GeckoAppShell_onSurfaceTextureFrameAvailable(JNIEnv* jenv, jclass, jobject surfaceTexture, jint id)
{
mozilla::gl::AndroidSurfaceTexture* st = mozilla::gl::AndroidSurfaceTexture::Find(id);
if (!st) {
__android_log_print(ANDROID_LOG_ERROR, "GeckoJNI", "Failed to find AndroidSurfaceTexture with id %d", id);
return;
}
st->NotifyFrameAvailable();
}
}