Backed out 11 changesets (bug 1322650) for media test failures on android. a=backout

Backed out changeset 31bd912fba54 (bug 1322650)
Backed out changeset 4d486c7469eb (bug 1322650)
Backed out changeset 4cf8f4d5064c (bug 1322650)
Backed out changeset 3cb108f7492f (bug 1322650)
Backed out changeset bd53533c108e (bug 1322650)
Backed out changeset 3522917d8f10 (bug 1322650)
Backed out changeset 2c2c1e33eccc (bug 1322650)
Backed out changeset 2f19977cd6ab (bug 1322650)
Backed out changeset 4519296a323e (bug 1322650)
Backed out changeset e56e5e1c8786 (bug 1322650)
Backed out changeset 96fe52231b57 (bug 1322650)
This commit is contained in:
Iris Hsiao
2017-05-12 10:21:14 +08:00
parent 2c6a00cb28
commit 3cea13a680
51 changed files with 480 additions and 1456 deletions

View File

@@ -1640,7 +1640,8 @@ MediaDecoder::IsWebMEnabled()
bool
MediaDecoder::IsAndroidMediaPluginEnabled()
{
return jni::GetAPIVersion() < 16
return AndroidBridge::Bridge()
&& AndroidBridge::Bridge()->GetAPIVersion() < 16
&& Preferences::GetBool("media.plugins.enabled");
}
#endif

View File

@@ -7,7 +7,7 @@
#define MEDIA_PREFS_H
#ifdef MOZ_WIDGET_ANDROID
#include "GeneratedJNIWrappers.h"
#include "AndroidBridge.h"
#endif
#include "mozilla/Atomics.h"
@@ -199,7 +199,8 @@ private:
static int32_t MediaDecoderLimitDefault()
{
#ifdef MOZ_WIDGET_ANDROID
if (jni::GetAPIVersion() < 18) {
if (AndroidBridge::Bridge() &&
AndroidBridge::Bridge()->GetAPIVersion() < 18) {
// Older Android versions have broken support for multiple simultaneous
// decoders, see bug 1278574.
return 1;

View File

@@ -2,7 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "GeneratedJNIWrappers.h"
#include "AndroidDecoderModule.h"
#include "AndroidBridge.h"
#include "MediaInfo.h"
#include "MediaPrefs.h"
#include "OpusDecoder.h"
@@ -127,7 +128,8 @@ AndroidDecoderModule::SupportsMimeType(
const nsACString& aMimeType,
DecoderDoctorDiagnostics* aDiagnostics) const
{
if (jni::GetAPIVersion() < 16) {
if (!AndroidBridge::Bridge() ||
AndroidBridge::Bridge()->GetAPIVersion() < 16) {
return false;
}

View File

@@ -4,6 +4,7 @@
#include "AndroidBridge.h"
#include "AndroidDecoderModule.h"
#include "AndroidSurfaceTexture.h"
#include "JavaCallbacksSupport.h"
#include "SimpleMap.h"
#include "GLImages.h"
@@ -133,7 +134,7 @@ public:
if (size > 0) {
RefPtr<layers::Image> img = new SurfaceTextureImage(
mDecoder->mSurfaceHandle, inputInfo.mImageSize, false /* NOT continuous */,
mDecoder->mSurfaceTexture.get(), inputInfo.mImageSize,
gl::OriginPos::BottomLeft);
RefPtr<VideoData> v = VideoData::CreateFromImage(
@@ -176,12 +177,18 @@ public:
RefPtr<InitPromise> Init() override
{
jni::Object::LocalRef surf = SurfaceAllocator::AcquireSurface(mConfig.mImage.width, mConfig.mImage.height, false);
if (!surf) {
return InitPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_FATAL_ERR, __func__);
mSurfaceTexture = AndroidSurfaceTexture::Create();
if (!mSurfaceTexture) {
NS_WARNING("Failed to create SurfaceTexture for video decode\n");
return InitPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_FATAL_ERR,
__func__);
}
mSurfaceHandle = GeckoSurface::LocalRef(GeckoSurface::Ref::From(surf))->GetHandle();
if (!jni::IsFennec()) {
NS_WARNING("Remote decoding not supported in non-Fennec environment\n");
return InitPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_FATAL_ERR,
__func__);
}
// Register native methods.
JavaCallbacksSupport::Init();
@@ -190,10 +197,9 @@ public:
JavaCallbacksSupport::AttachNative(
mJavaCallbacks, mozilla::MakeUnique<CallbacksSupport>(this));
auto surfRef = Surface::LocalRef(Surface::Ref::From(surf));
mJavaDecoder = CodecProxy::Create(false, // false indicates to create a decoder and true denotes encoder
mFormat,
surfRef,
mSurfaceTexture->JavaSurface(),
mJavaCallbacks,
mDrmStubId);
if (mJavaDecoder == nullptr) {
@@ -233,7 +239,7 @@ public:
private:
layers::ImageContainer* mImageContainer;
const VideoInfo mConfig;
AndroidSurfaceTextureHandle mSurfaceHandle;
RefPtr<AndroidSurfaceTexture> mSurfaceTexture;
SimpleMap<InputInfo> mInputInfos;
bool mIsCodecSupportAdaptivePlayback = false;
};
@@ -405,6 +411,7 @@ RemoteDataDecoder::CreateVideoDecoder(const CreateDecoderParams& aParams,
const nsString& aDrmStubId,
CDMProxy* aProxy)
{
const VideoInfo& config = aParams.VideoConfig();
MediaFormat::LocalRef format;
NS_ENSURE_SUCCESS(

View File

@@ -58,8 +58,6 @@ using namespace mozilla::dom;
#include "TexturePoolOGL.h"
#include "SurfaceTypes.h"
#include "EGLUtils.h"
#include "GeneratedJNIWrappers.h"
#include "GeneratedJNINatives.h"
using namespace mozilla;
using namespace mozilla::gl;
@@ -108,7 +106,7 @@ static bool EnsureGLContext()
static std::map<NPP, nsNPAPIPluginInstance*> sPluginNPPMap;
#endif // MOZ_WIDGET_ANDROID
#endif
using namespace mozilla;
using namespace mozilla::plugins::parent;
@@ -204,12 +202,14 @@ nsNPAPIPluginInstance::Destroy()
mAudioChannelAgent = nullptr;
#if MOZ_WIDGET_ANDROID
if (mContentSurface) {
java::SurfaceAllocator::DisposeSurface(mContentSurface);
}
if (mContentSurface)
mContentSurface->SetFrameAvailableCallback(nullptr);
mContentSurface = nullptr;
std::map<void*, VideoInfo*>::iterator it;
for (it = mVideos.begin(); it != mVideos.end(); it++) {
it->second->mSurfaceTexture->SetFrameAvailableCallback(nullptr);
delete it->second;
}
mVideos.clear();
@@ -858,50 +858,24 @@ GLContext* nsNPAPIPluginInstance::GLContext()
return sPluginContext;
}
class PluginTextureListener
: public java::SurfaceTextureListener::Natives<PluginTextureListener>
already_AddRefed<AndroidSurfaceTexture> nsNPAPIPluginInstance::CreateSurfaceTexture()
{
using Base = java::SurfaceTextureListener::Natives<PluginTextureListener>;
if (!EnsureGLContext())
return nullptr;
const nsCOMPtr<nsIRunnable> mCallback;
public:
using Base::AttachNative;
using Base::DisposeNative;
GLuint texture = TexturePoolOGL::AcquireTexture();
if (!texture)
return nullptr;
PluginTextureListener(nsIRunnable* aCallback) : mCallback(aCallback) {}
void OnFrameAvailable()
{
if (NS_IsMainThread()) {
mCallback->Run();
return;
}
NS_DispatchToMainThread(mCallback);
}
};
java::GeckoSurface::LocalRef nsNPAPIPluginInstance::CreateSurface()
{
java::GeckoSurface::LocalRef surf = java::SurfaceAllocator::AcquireSurface(0, 0, false);
if (!surf) {
RefPtr<AndroidSurfaceTexture> surface = AndroidSurfaceTexture::Create(TexturePoolOGL::GetGLContext(),
texture);
if (!surface) {
return nullptr;
}
nsCOMPtr<nsIRunnable> frameCallback = NewRunnableMethod(this, &nsNPAPIPluginInstance::OnSurfaceTextureFrameAvailable);
java::SurfaceTextureListener::LocalRef listener = java::SurfaceTextureListener::New();
PluginTextureListener::AttachNative(listener, MakeUnique<PluginTextureListener>(frameCallback.get()));
java::GeckoSurfaceTexture::LocalRef gst = java::GeckoSurfaceTexture::Lookup(surf->GetHandle());
if (!gst) {
return nullptr;
}
const auto& st = java::sdk::SurfaceTexture::Ref::From(gst);
st->SetOnFrameAvailableListener(listener);
return surf;
surface->SetFrameAvailableCallback(frameCallback);
return surface.forget();
}
void nsNPAPIPluginInstance::OnSurfaceTextureFrameAvailable()
@@ -912,29 +886,35 @@ void nsNPAPIPluginInstance::OnSurfaceTextureFrameAvailable()
void* nsNPAPIPluginInstance::AcquireContentWindow()
{
if (!mContentWindow.NativeWindow()) {
mContentSurface = CreateSurface();
if (!mContentSurface) {
mContentSurface = CreateSurfaceTexture();
if (!mContentSurface)
return nullptr;
}
return mContentSurface->NativeWindow();
}
AndroidSurfaceTexture*
nsNPAPIPluginInstance::AsSurfaceTexture()
{
if (!mContentSurface)
return nullptr;
mContentWindow = AndroidNativeWindow(mContentSurface);
}
return mContentWindow.NativeWindow();
}
java::GeckoSurface::Param
nsNPAPIPluginInstance::AsSurface()
{
return mContentSurface;
}
void* nsNPAPIPluginInstance::AcquireVideoWindow()
{
java::GeckoSurface::LocalRef surface = CreateSurface();
RefPtr<AndroidSurfaceTexture> surface = CreateSurfaceTexture();
if (!surface) {
return nullptr;
}
VideoInfo* info = new VideoInfo(surface);
void* window = info->mNativeWindow.NativeWindow();
void* window = info->mSurfaceTexture->NativeWindow();
mVideos.insert(std::pair<void*, VideoInfo*>(window, info));
return window;

View File

@@ -21,7 +21,7 @@
#ifdef MOZ_WIDGET_ANDROID
#include "nsIRunnable.h"
#include "GLContextTypes.h"
#include "AndroidNativeWindow.h"
#include "AndroidSurfaceTexture.h"
#include "AndroidBridge.h"
#include <map>
class PluginEventRunnable;
@@ -215,24 +215,22 @@ public:
// For ANPNativeWindow
void* AcquireContentWindow();
mozilla::java::GeckoSurface::Param AsSurface();
mozilla::gl::AndroidSurfaceTexture* AsSurfaceTexture();
// For ANPVideo
class VideoInfo {
public:
VideoInfo(mozilla::java::GeckoSurface::Param aSurface)
: mSurface(aSurface)
, mNativeWindow(aSurface)
VideoInfo(mozilla::gl::AndroidSurfaceTexture* aSurfaceTexture) :
mSurfaceTexture(aSurfaceTexture)
{
}
~VideoInfo()
{
mozilla::java::SurfaceAllocator::DisposeSurface(mSurface);
mSurfaceTexture = nullptr;
}
mozilla::java::GeckoSurface::GlobalRef mSurface;
mozilla::gl::AndroidNativeWindow mNativeWindow;
RefPtr<mozilla::gl::AndroidSurfaceTexture> mSurfaceTexture;
gfxRect mDimensions;
};
@@ -361,8 +359,7 @@ protected:
bool mFullScreen;
mozilla::gl::OriginPos mOriginPos;
mozilla::java::GeckoSurface::GlobalRef mContentSurface;
mozilla::gl::AndroidNativeWindow mContentWindow;
RefPtr<mozilla::gl::AndroidSurfaceTexture> mContentSurface;
#endif
enum {
@@ -412,7 +409,8 @@ private:
mozilla::TimeStamp mStopTime;
#ifdef MOZ_WIDGET_ANDROID
mozilla::java::GeckoSurface::LocalRef CreateSurface();
already_AddRefed<mozilla::gl::AndroidSurfaceTexture> CreateSurfaceTexture();
std::map<void*, VideoInfo*> mVideos;
bool mOnScreen;

View File

@@ -165,7 +165,7 @@ nsPluginInstanceOwner::NotifyPaintWaiter(nsDisplayListBuilder* aBuilder)
#if MOZ_WIDGET_ANDROID
static void
AttachToContainerAsSurface(ImageContainer* container,
AttachToContainerAsSurfaceTexture(ImageContainer* container,
nsNPAPIPluginInstance* instance,
const LayoutDeviceRect& rect,
RefPtr<Image>* out_image)
@@ -173,15 +173,14 @@ AttachToContainerAsSurface(ImageContainer* container,
MOZ_ASSERT(out_image);
MOZ_ASSERT(!*out_image);
java::GeckoSurface::LocalRef surface = instance->AsSurface();
if (!surface) {
mozilla::gl::AndroidSurfaceTexture* surfTex = instance->AsSurfaceTexture();
if (!surfTex) {
return;
}
RefPtr<Image> img = new SurfaceTextureImage(
surface->GetHandle(),
surfTex,
gfx::IntSize::Truncate(rect.width, rect.height),
true, // continuously update without a transaction
instance->OriginPos());
*out_image = img;
}
@@ -224,7 +223,7 @@ nsPluginInstanceOwner::GetImageContainer()
if (r.width && r.height) {
// Try to get it as an EGLImage first.
RefPtr<Image> img;
AttachToContainerAsSurface(container, mInstance, r, &img);
AttachToContainerAsSurfaceTexture(container, mInstance, r, &img);
if (img) {
container->SetCurrentImageInTransaction(img);
@@ -1586,9 +1585,8 @@ nsPluginInstanceOwner::GetImageContainerForVideo(nsNPAPIPluginInstance::VideoInf
if (aVideoInfo->mDimensions.width && aVideoInfo->mDimensions.height) {
RefPtr<Image> img = new SurfaceTextureImage(
aVideoInfo->mSurface->GetHandle(),
aVideoInfo->mSurfaceTexture,
gfx::IntSize::Truncate(aVideoInfo->mDimensions.width, aVideoInfo->mDimensions.height),
true, /* continuous */
gl::OriginPos::BottomLeft);
container->SetCurrentImageInTransaction(img);
}

View File

@@ -1,55 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
// vim:set ts=2 sts=2 sw=2 et cin:
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef AndroidNativeWindow_h__
#define AndroidNativeWindow_h__
#ifdef MOZ_WIDGET_ANDROID
#include <jni.h>
#include <android/native_window.h>
#include <android/native_window_jni.h>
#include "GeneratedJNIWrappers.h"
#include "SurfaceTexture.h"
namespace mozilla {
namespace gl {
class AndroidNativeWindow {
public:
AndroidNativeWindow() : mNativeWindow(nullptr) {
}
AndroidNativeWindow(java::sdk::Surface::Param aSurface) {
mNativeWindow = ANativeWindow_fromSurface(jni::GetEnvForThread(),
aSurface.Get());
}
AndroidNativeWindow(java::GeckoSurface::Param aSurface) {
auto surf = java::sdk::Surface::LocalRef(java::sdk::Surface::Ref::From(aSurface));
mNativeWindow = ANativeWindow_fromSurface(jni::GetEnvForThread(),
surf.Get());
}
~AndroidNativeWindow() {
if (mNativeWindow) {
ANativeWindow_release(mNativeWindow);
mNativeWindow = nullptr;
}
}
ANativeWindow* NativeWindow() const {
return mNativeWindow;
}
private:
ANativeWindow* mNativeWindow;
};
} // gl
} // mozilla
#endif // MOZ_WIDGET_ANDROID
#endif // AndroidNativeWindow_h__

View File

@@ -1,20 +1,204 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
// vim:set ts=2 sts=2 sw=2 et cin:
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifdef MOZ_WIDGET_ANDROID
#include <map>
#include <android/native_window_jni.h>
#include <android/log.h>
#include "AndroidSurfaceTexture.h"
#include "gfxImageSurface.h"
#include "gfxPrefs.h"
#include "AndroidBridge.h"
#include "nsThreadUtils.h"
#include "mozilla/gfx/Matrix.h"
#include "GeneratedJNINatives.h"
#include "GLContext.h"
using namespace mozilla;
namespace mozilla {
namespace gl {
class AndroidSurfaceTexture::Listener
: public java::SurfaceTextureListener::Natives<Listener>
{
using Base = java::SurfaceTextureListener::Natives<Listener>;
const nsCOMPtr<nsIRunnable> mCallback;
public:
using Base::AttachNative;
using Base::DisposeNative;
Listener(nsIRunnable* aCallback) : mCallback(aCallback) {}
void OnFrameAvailable()
{
if (NS_IsMainThread()) {
mCallback->Run();
return;
}
NS_DispatchToMainThread(mCallback);
}
};
already_AddRefed<AndroidSurfaceTexture>
AndroidSurfaceTexture::Create()
{
return Create(nullptr, 0);
}
already_AddRefed<AndroidSurfaceTexture>
AndroidSurfaceTexture::Create(GLContext* aContext, GLuint aTexture)
{
RefPtr<AndroidSurfaceTexture> st = new AndroidSurfaceTexture();
if (!st->Init(aContext, aTexture)) {
printf_stderr("Failed to initialize AndroidSurfaceTexture");
st = nullptr;
}
return st.forget();
}
nsresult
AndroidSurfaceTexture::Attach(GLContext* aContext, PRIntervalTime aTimeout)
{
MonitorAutoLock lock(mMonitor);
if (mAttachedContext == aContext) {
NS_WARNING("Tried to attach same GLContext to AndroidSurfaceTexture");
return NS_OK;
}
if (!CanDetach()) {
return NS_ERROR_NOT_AVAILABLE;
}
while (mAttachedContext) {
// Wait until it's detached (or we time out)
if (NS_FAILED(lock.Wait(aTimeout))) {
return NS_ERROR_NOT_AVAILABLE;
}
}
MOZ_ASSERT(aContext->IsOwningThreadCurrent(), "Trying to attach GLContext from different thread");
aContext->fGenTextures(1, &mTexture);
if (NS_FAILED(mSurfaceTexture->AttachToGLContext(mTexture))) {
return NS_ERROR_NOT_AVAILABLE;
}
mAttachedContext = aContext;
mAttachedContext->MakeCurrent();
return NS_OK;
}
nsresult
AndroidSurfaceTexture::Detach()
{
MonitorAutoLock lock(mMonitor);
if (!CanDetach() ||
!mAttachedContext ||
!mAttachedContext->IsOwningThreadCurrent())
{
return NS_ERROR_FAILURE;
}
mAttachedContext->MakeCurrent();
mSurfaceTexture->DetachFromGLContext();
mTexture = 0;
mAttachedContext = nullptr;
lock.NotifyAll();
return NS_OK;
}
bool
AndroidSurfaceTexture::CanDetach() const
{
// The API for attach/detach only exists on 16+, and PowerVR has some sort of
// fencing issue. Additionally, attach/detach seems to be busted on at least
// some Mali adapters (400MP2 for sure, bug 1131793)
return AndroidBridge::Bridge()->GetAPIVersion() >= 16 &&
(!mAttachedContext || mAttachedContext->Vendor() != GLVendor::Imagination) &&
(!mAttachedContext || mAttachedContext->Vendor() != GLVendor::ARM /* Mali */) &&
gfxPrefs::SurfaceTextureDetachEnabled();
}
bool
AndroidSurfaceTexture::Init(GLContext* aContext, GLuint aTexture)
{
if (!aTexture && !CanDetach()) {
// We have no texture and cannot initialize detached, bail out
return false;
}
if (NS_WARN_IF(NS_FAILED(
java::sdk::SurfaceTexture::New(aTexture, ReturnTo(&mSurfaceTexture))))) {
return false;
}
if (!aTexture) {
mSurfaceTexture->DetachFromGLContext();
}
mAttachedContext = aContext;
if (NS_WARN_IF(NS_FAILED(
java::sdk::Surface::New(mSurfaceTexture, ReturnTo(&mSurface))))) {
return false;
}
mNativeWindow = ANativeWindow_fromSurface(jni::GetEnvForThread(),
mSurface.Get());
MOZ_ASSERT(mNativeWindow, "Failed to create native window from surface");
return true;
}
AndroidSurfaceTexture::AndroidSurfaceTexture()
: mTexture(0)
, mSurfaceTexture()
, mSurface()
, mAttachedContext(nullptr)
, mMonitor("AndroidSurfaceTexture")
{
}
AndroidSurfaceTexture::~AndroidSurfaceTexture()
{
if (mSurfaceTexture) {
SetFrameAvailableCallback(nullptr);
mSurfaceTexture = nullptr;
}
if (mNativeWindow) {
ANativeWindow_release(mNativeWindow);
mNativeWindow = nullptr;
}
}
void
AndroidSurfaceTexture::GetTransformMatrix(java::sdk::SurfaceTexture::LocalRef aSurfaceTexture,
gfx::Matrix4x4& aMatrix)
AndroidSurfaceTexture::UpdateTexImage()
{
mSurfaceTexture->UpdateTexImage();
}
void
AndroidSurfaceTexture::GetTransformMatrix(gfx::Matrix4x4& aMatrix) const
{
JNIEnv* const env = jni::GetEnvForThread();
auto jarray = jni::FloatArray::LocalRef::Adopt(env, env->NewFloatArray(16));
aSurfaceTexture->GetTransformMatrix(jarray);
mSurfaceTexture->GetTransformMatrix(jarray);
jfloat* array = env->GetFloatArrayElements(jarray.Get(), nullptr);
@@ -41,6 +225,36 @@ AndroidSurfaceTexture::GetTransformMatrix(java::sdk::SurfaceTexture::LocalRef aS
env->ReleaseFloatArrayElements(jarray.Get(), array, 0);
}
void
AndroidSurfaceTexture::SetFrameAvailableCallback(nsIRunnable* aRunnable)
{
java::SurfaceTextureListener::LocalRef newListener;
if (aRunnable) {
newListener = java::SurfaceTextureListener::New();
Listener::AttachNative(newListener, MakeUnique<Listener>(aRunnable));
}
if (aRunnable || mListener) {
MOZ_ALWAYS_TRUE(NS_SUCCEEDED(
mSurfaceTexture->SetOnFrameAvailableListener(newListener)));
}
if (mListener) {
Listener::DisposeNative(java::SurfaceTextureListener::LocalRef(
newListener.Env(), mListener));
}
mListener = newListener;
}
void
AndroidSurfaceTexture::SetDefaultSize(mozilla::gfx::IntSize size)
{
mSurfaceTexture->SetDefaultBufferSize(size.width, size.height);
}
} // gl
} // mozilla
#endif // MOZ_WIDGET_ANDROID

View File

@@ -8,23 +8,100 @@
#define AndroidSurfaceTexture_h__
#ifdef MOZ_WIDGET_ANDROID
#include "mozilla/gfx/Matrix.h"
#include "SurfaceTexture.h"
#include <jni.h>
#include <android/native_window.h>
#include "nsIRunnable.h"
#include "gfxPlatform.h"
#include "GLDefs.h"
#include "mozilla/gfx/2D.h"
#include "mozilla/gfx/MatrixFwd.h"
#include "mozilla/Monitor.h"
typedef uint32_t AndroidSurfaceTextureHandle;
#include "GeneratedJNIWrappers.h"
#include "SurfaceTexture.h"
namespace mozilla {
namespace gl {
class AndroidSurfaceTexture {
public:
static void GetTransformMatrix(java::sdk::SurfaceTexture::LocalRef aSurfaceTexture,
mozilla::gfx::Matrix4x4& aMatrix);
class GLContext;
/**
* This class is a wrapper around Android's SurfaceTexture class.
* Usage is pretty much exactly like the Java class, so see
* the Android documentation for details.
*/
class AndroidSurfaceTexture {
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(AndroidSurfaceTexture)
public:
// The SurfaceTexture is created in an attached state. This method requires
// Android Ice Cream Sandwich.
static already_AddRefed<AndroidSurfaceTexture> Create(GLContext* aGLContext, GLuint aTexture);
// Here the SurfaceTexture will be created in a detached state. You must call
// Attach() with the GLContext you wish to composite with. It must be done
// on the thread where that GLContext is current. This method requires
// Android Jelly Bean.
static already_AddRefed<AndroidSurfaceTexture> Create();
// 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.
//
// Only one GLContext may be attached at any given time. If another is already
// attached, we try to wait for it to become detached.
nsresult Attach(GLContext* aContext, PRIntervalTime aTiemout = PR_INTERVAL_NO_TIMEOUT);
nsresult Detach();
// Ability to detach is based on API version (16+), and we also block PowerVR
// since it has some type of fencing problem. Bug 1100126.
bool CanDetach() const;
GLContext* AttachedContext() const { return mAttachedContext; }
ANativeWindow* NativeWindow() const {
return mNativeWindow;
}
// This attaches the updated data to the TEXTURE_EXTERNAL target
void UpdateTexImage();
void GetTransformMatrix(mozilla::gfx::Matrix4x4& aMatrix) const;
void SetDefaultSize(mozilla::gfx::IntSize size);
// The callback is guaranteed to be called on the main thread even
// if the upstream callback is received on a different thread
void SetFrameAvailableCallback(nsIRunnable* aRunnable);
GLuint Texture() const { return mTexture; }
const java::sdk::Surface::Ref& JavaSurface() const { return mSurface; }
private:
class Listener;
AndroidSurfaceTexture();
~AndroidSurfaceTexture();
bool Init(GLContext* aContext, GLuint aTexture);
GLuint mTexture;
java::sdk::SurfaceTexture::GlobalRef mSurfaceTexture;
java::sdk::Surface::GlobalRef mSurface;
java::SurfaceTextureListener::GlobalRef mListener;
GLContext* mAttachedContext;
ANativeWindow* mNativeWindow;
Monitor mMonitor;
};
} // gl
} // mozilla
}
}
#endif // MOZ_WIDGET_ANDROID
#endif // AndroidSurfaceTexture_h__
#endif
#endif

View File

@@ -684,8 +684,30 @@ GLBlitHelper::BindAndUploadEGLImage(EGLImage image, GLuint target)
bool
GLBlitHelper::BlitSurfaceTextureImage(layers::SurfaceTextureImage* stImage)
{
// FIXME
AndroidSurfaceTexture* surfaceTexture = stImage->GetSurfaceTexture();
ScopedBindTextureUnit boundTU(mGL, LOCAL_GL_TEXTURE0);
if (NS_FAILED(surfaceTexture->Attach(mGL, PR_MillisecondsToInterval(ATTACH_WAIT_MS))))
return false;
// UpdateTexImage() changes the EXTERNAL binding, so save it here
// so we can restore it after.
int oldBinding = 0;
mGL->fGetIntegerv(LOCAL_GL_TEXTURE_BINDING_EXTERNAL, &oldBinding);
surfaceTexture->UpdateTexImage();
gfx::Matrix4x4 transform;
surfaceTexture->GetTransformMatrix(transform);
mGL->fUniformMatrix4fv(mTextureTransformLoc, 1, false, &transform._11);
mGL->fDrawArrays(LOCAL_GL_TRIANGLE_STRIP, 0, 4);
surfaceTexture->Detach();
mGL->fBindTexture(LOCAL_GL_TEXTURE_EXTERNAL, oldBinding);
return true;
}
bool

View File

@@ -69,9 +69,6 @@ public:
virtual bool ReleaseTexImage() override;
void SetEGLSurfaceOverride(EGLSurface surf);
EGLSurface GetEGLSurfaceOverride() {
return mSurfaceOverride;
}
virtual bool MakeCurrentImpl(bool aForce) override;

View File

@@ -90,12 +90,6 @@ GLScreenBuffer::CreateFactory(GLContext* gl,
factory = SurfaceFactory_GLXDrawable::Create(gl, caps, ipcChannel, flags);
#elif defined(MOZ_WIDGET_UIKIT)
factory = MakeUnique<SurfaceFactory_GLTexture>(mGLContext, caps, ipcChannel, mFlags);
#elif defined(MOZ_WIDGET_ANDROID)
if (XRE_IsParentProcess()) {
factory = SurfaceFactory_EGLImage::Create(gl, caps, ipcChannel, flags);
} else {
factory = SurfaceFactory_SurfaceTexture::Create(gl, caps, ipcChannel, flags);
}
#else
if (gl->GetContextType() == GLContextType::EGL) {
if (XRE_IsParentProcess()) {

View File

@@ -96,10 +96,6 @@ public:
// Unlocking is harmless if we're already unlocked.
void UnlockProd();
// This surface has been moved to the front buffer and will not be locked again
// until it is recycled. Do any finalization steps here.
virtual void Commit(){}
protected:
virtual void LockProdImpl() = 0;
virtual void UnlockProdImpl() = 0;

View File

@@ -7,7 +7,6 @@
#include "GLBlitHelper.h"
#include "GLContextEGL.h"
#include "GLContextProvider.h"
#include "GLLibraryEGL.h"
#include "GLReadTexImageHelper.h"
#include "mozilla/layers/LayersSurfaces.h" // for SurfaceDescriptor, etc
@@ -101,6 +100,12 @@ SharedSurface_EGLImage::~SharedSurface_EGLImage()
mProdTex = 0;
}
layers::TextureFlags
SharedSurface_EGLImage::GetTextureFlags() const
{
return layers::TextureFlags::DEALLOCATE_CLIENT;
}
void
SharedSurface_EGLImage::ProducerReleaseImpl()
{
@@ -180,136 +185,6 @@ SurfaceFactory_EGLImage::Create(GLContext* prodGL, const SurfaceCaps& caps,
return Move(ret);
}
////////////////////////////////////////////////////////////////////////
#ifdef MOZ_WIDGET_ANDROID
/*static*/ UniquePtr<SharedSurface_SurfaceTexture>
SharedSurface_SurfaceTexture::Create(GLContext* prodGL,
const GLFormats& formats,
const gfx::IntSize& size,
bool hasAlpha,
java::GeckoSurface::Param surface)
{
MOZ_ASSERT(surface);
UniquePtr<SharedSurface_SurfaceTexture> ret;
AndroidNativeWindow window(surface);
EGLSurface eglSurface = GLContextProviderEGL::CreateEGLSurface(window.NativeWindow());
if (!eglSurface) {
return Move(ret);
}
ret.reset(new SharedSurface_SurfaceTexture(prodGL, size, hasAlpha,
formats, surface, eglSurface));
return Move(ret);
}
SharedSurface_SurfaceTexture::SharedSurface_SurfaceTexture(GLContext* gl,
const gfx::IntSize& size,
bool hasAlpha,
const GLFormats& formats,
java::GeckoSurface::Param surface,
EGLSurface eglSurface)
: SharedSurface(SharedSurfaceType::AndroidSurfaceTexture,
AttachmentType::Screen,
gl,
size,
hasAlpha,
true)
, mSurface(surface)
, mEglSurface(eglSurface)
{
}
SharedSurface_SurfaceTexture::~SharedSurface_SurfaceTexture()
{
GLContextProviderEGL::DestroyEGLSurface(mEglSurface);
java::SurfaceAllocator::DisposeSurface(mSurface);
}
void
SharedSurface_SurfaceTexture::LockProdImpl()
{
MOZ_RELEASE_ASSERT(mSurface->GetAvailable());
GLContextEGL *gl = GLContextEGL::Cast(mGL);
mOrigEglSurface = gl->GetEGLSurfaceOverride();
gl->SetEGLSurfaceOverride(mEglSurface);
}
void
SharedSurface_SurfaceTexture::UnlockProdImpl()
{
MOZ_RELEASE_ASSERT(mSurface->GetAvailable());
GLContextEGL *gl = GLContextEGL::Cast(mGL);
MOZ_ASSERT(gl->GetEGLSurfaceOverride() == mEglSurface);
gl->SetEGLSurfaceOverride(mOrigEglSurface);
mOrigEglSurface = nullptr;
}
void
SharedSurface_SurfaceTexture::Commit()
{
MOZ_RELEASE_ASSERT(mSurface->GetAvailable());
LockProdImpl();
mGL->SwapBuffers();
UnlockProdImpl();
mSurface->SetAvailable(false);
}
void
SharedSurface_SurfaceTexture::WaitForBufferOwnership()
{
MOZ_RELEASE_ASSERT(!mSurface->GetAvailable());
mSurface->SetAvailable(true);
}
bool
SharedSurface_SurfaceTexture::ToSurfaceDescriptor(layers::SurfaceDescriptor* const out_descriptor)
{
*out_descriptor = layers::SurfaceTextureDescriptor(mSurface->GetHandle(), mSize, false /* NOT continuous */);
return true;
}
////////////////////////////////////////////////////////////////////////
/*static*/ UniquePtr<SurfaceFactory_SurfaceTexture>
SurfaceFactory_SurfaceTexture::Create(GLContext* prodGL, const SurfaceCaps& caps,
const RefPtr<layers::LayersIPCChannel>& allocator,
const layers::TextureFlags& flags)
{
UniquePtr<SurfaceFactory_SurfaceTexture> ret(
new SurfaceFactory_SurfaceTexture(prodGL, caps, allocator, flags));
return Move(ret);
}
UniquePtr<SharedSurface>
SurfaceFactory_SurfaceTexture::CreateShared(const gfx::IntSize& size)
{
bool hasAlpha = mReadCaps.alpha;
jni::Object::LocalRef surface = java::SurfaceAllocator::AcquireSurface(size.width, size.height, true);
if (!surface) {
// Try multi-buffer mode
surface = java::SurfaceAllocator::AcquireSurface(size.width, size.height, false);
if (!surface) {
// Give up
NS_WARNING("Failed to allocate SurfaceTexture!");
return nullptr;
}
}
return SharedSurface_SurfaceTexture::Create(mGL, mFormats, size, hasAlpha,
java::GeckoSurface::Ref::From(surface));
}
#endif // MOZ_WIDGET_ANDROID
} // namespace gl
} /* namespace mozilla */

View File

@@ -10,11 +10,6 @@
#include "mozilla/Mutex.h"
#include "SharedSurface.h"
#ifdef MOZ_WIDGET_ANDROID
#include "GeneratedJNIWrappers.h"
#include "AndroidNativeWindow.h"
#endif
namespace mozilla {
namespace gl {
@@ -63,9 +58,7 @@ protected:
public:
virtual ~SharedSurface_EGLImage();
virtual layers::TextureFlags GetTextureFlags() const override {
return layers::TextureFlags::DEALLOCATE_CLIENT;
}
virtual layers::TextureFlags GetTextureFlags() const override;
virtual void LockProdImpl() override {}
virtual void UnlockProdImpl() override {}
@@ -117,90 +110,6 @@ public:
}
};
#ifdef MOZ_WIDGET_ANDROID
class SharedSurface_SurfaceTexture
: public SharedSurface
{
public:
static UniquePtr<SharedSurface_SurfaceTexture> Create(GLContext* prodGL,
const GLFormats& formats,
const gfx::IntSize& size,
bool hasAlpha,
java::GeckoSurface::Param surface);
static SharedSurface_SurfaceTexture* Cast(SharedSurface* surf) {
MOZ_ASSERT(surf->mType == SharedSurfaceType::AndroidSurfaceTexture);
return (SharedSurface_SurfaceTexture*)surf;
}
java::GeckoSurface::Param JavaSurface() { return mSurface; }
protected:
java::GeckoSurface::GlobalRef mSurface;
EGLSurface mEglSurface;
EGLSurface mOrigEglSurface;
SharedSurface_SurfaceTexture(GLContext* gl,
const gfx::IntSize& size,
bool hasAlpha,
const GLFormats& formats,
java::GeckoSurface::Param surface,
EGLSurface eglSurface);
public:
virtual ~SharedSurface_SurfaceTexture();
virtual layers::TextureFlags GetTextureFlags() const override {
return layers::TextureFlags::DEALLOCATE_CLIENT;
}
virtual void LockProdImpl() override;
virtual void UnlockProdImpl() override;
virtual void ProducerAcquireImpl() override {}
virtual void ProducerReleaseImpl() override {}
virtual void ProducerReadAcquireImpl() override {}
virtual void ProducerReadReleaseImpl() override {}
// Implementation-specific functions below:
// Returns texture and target
virtual bool ToSurfaceDescriptor(layers::SurfaceDescriptor* const out_descriptor) override;
virtual bool ReadbackBySharedHandle(gfx::DataSourceSurface* out_surface) override { return false; }
virtual void Commit() override;
virtual void WaitForBufferOwnership() override;
};
class SurfaceFactory_SurfaceTexture
: public SurfaceFactory
{
public:
// Fallible:
static UniquePtr<SurfaceFactory_SurfaceTexture> Create(GLContext* prodGL,
const SurfaceCaps& caps,
const RefPtr<layers::LayersIPCChannel>& allocator,
const layers::TextureFlags& flags);
protected:
SurfaceFactory_SurfaceTexture(GLContext* prodGL, const SurfaceCaps& caps,
const RefPtr<layers::LayersIPCChannel>& allocator,
const layers::TextureFlags& flags)
: SurfaceFactory(SharedSurfaceType::AndroidSurfaceTexture, prodGL, caps, allocator, flags)
{ }
public:
virtual UniquePtr<SharedSurface> CreateShared(const gfx::IntSize& size) override;
};
#endif // MOZ_WIDGET_ANDROID
} // namespace gl
} /* namespace mozilla */

View File

@@ -77,7 +77,6 @@ enum class SharedSurfaceType : uint8_t {
IOSurface,
GLXDrawable,
SharedGLTexture,
AndroidSurfaceTexture,
Max
};

View File

@@ -24,7 +24,6 @@ if CONFIG['MOZ_GL_PROVIDER']:
gl_provider = CONFIG['MOZ_GL_PROVIDER']
EXPORTS += [
'AndroidNativeWindow.h',
'AndroidSurfaceTexture.h',
'DecomposeIntoNoRepeatTriangles.h',
'EGLUtils.h',

View File

@@ -98,17 +98,14 @@ GLImage::GetAsSourceSurface()
}
#ifdef MOZ_WIDGET_ANDROID
SurfaceTextureImage::SurfaceTextureImage(AndroidSurfaceTextureHandle aHandle,
SurfaceTextureImage::SurfaceTextureImage(gl::AndroidSurfaceTexture* aSurfTex,
const gfx::IntSize& aSize,
bool aContinuous,
gl::OriginPos aOriginPos)
: GLImage(ImageFormat::SURFACE_TEXTURE),
mHandle(aHandle),
mSurfaceTexture(aSurfTex),
mSize(aSize),
mContinuous(aContinuous),
mOriginPos(aOriginPos)
{
MOZ_ASSERT(mHandle);
}
#endif

View File

@@ -64,17 +64,13 @@ private:
class SurfaceTextureImage : public GLImage {
public:
SurfaceTextureImage(AndroidSurfaceTextureHandle aHandle,
SurfaceTextureImage(gl::AndroidSurfaceTexture* aSurfTex,
const gfx::IntSize& aSize,
bool aContinuous,
gl::OriginPos aOriginPos);
gfx::IntSize GetSize() override { return mSize; }
AndroidSurfaceTextureHandle GetHandle() const {
return mHandle;
}
bool GetContinuous() const {
return mContinuous;
gl::AndroidSurfaceTexture* GetSurfaceTexture() const {
return mSurfaceTexture;
}
gl::OriginPos GetOriginPos() const {
return mOriginPos;
@@ -85,9 +81,8 @@ public:
}
private:
AndroidSurfaceTextureHandle mHandle;
RefPtr<gl::AndroidSurfaceTexture> mSurfaceTexture;
gfx::IntSize mSize;
bool mContinuous;
gl::OriginPos mOriginPos;
};

View File

@@ -461,8 +461,6 @@ CanvasClientSharedSurface::UpdateRenderer(gfx::IntSize aSize, Renderer& aRendere
mReadbackClient = nullptr;
}
surf->Commit();
if (asyncRenderer) {
// If surface type is Basic, above codes will readback
// the GLContext to mReadbackClient in order to send frame to

View File

@@ -132,7 +132,7 @@ ImageClient::CreateTextureClientForImage(Image* aImage, KnowsCompositor* aForwar
} else if (aImage->GetFormat() == ImageFormat::SURFACE_TEXTURE) {
SurfaceTextureImage* typedImage = aImage->AsSurfaceTextureImage();
texture = AndroidSurfaceTextureData::CreateTextureClient(
typedImage->GetHandle(), size, typedImage->GetContinuous(), typedImage->GetOriginPos(),
typedImage->GetSurfaceTexture(), size, typedImage->GetOriginPos(),
aForwarder->GetTextureForwarder(), TextureFlags::DEFAULT);
#endif
} else {

View File

@@ -601,7 +601,7 @@ protected:
/**
* Called when mCompositableCount becomes 0.
*/
virtual void NotifyNotUsed();
void NotifyNotUsed();
// for Compositor.
void CallNotifyNotUsed();

View File

@@ -60,9 +60,8 @@ struct SurfaceDescriptorMacIOSurface {
};
struct SurfaceTextureDescriptor {
uint64_t handle;
uintptr_t surfTex;
IntSize size;
bool continuous;
};
struct EGLImageDescriptor {

View File

@@ -79,31 +79,34 @@ EGLImageTextureData::Serialize(SurfaceDescriptor& aOutDescriptor)
#ifdef MOZ_WIDGET_ANDROID
already_AddRefed<TextureClient>
AndroidSurfaceTextureData::CreateTextureClient(AndroidSurfaceTextureHandle aHandle,
AndroidSurfaceTextureData::CreateTextureClient(AndroidSurfaceTexture* aSurfTex,
gfx::IntSize aSize,
bool aContinuous,
gl::OriginPos aOriginPos,
LayersIPCChannel* aAllocator,
TextureFlags aFlags)
{
MOZ_ASSERT(XRE_IsParentProcess(),
"Can't pass an android surfaces between processes.");
if (!aSurfTex || !XRE_IsParentProcess()) {
return nullptr;
}
if (aOriginPos == gl::OriginPos::BottomLeft) {
aFlags |= TextureFlags::ORIGIN_BOTTOM_LEFT;
}
return TextureClient::CreateWithData(
new AndroidSurfaceTextureData(aHandle, aSize, aContinuous),
new AndroidSurfaceTextureData(aSurfTex, aSize),
aFlags, aAllocator
);
}
AndroidSurfaceTextureData::AndroidSurfaceTextureData(AndroidSurfaceTextureHandle aHandle,
gfx::IntSize aSize, bool aContinuous)
: mHandle(aHandle)
AndroidSurfaceTextureData::AndroidSurfaceTextureData(AndroidSurfaceTexture* aSurfTex,
gfx::IntSize aSize)
: mSurfTex(aSurfTex)
, mSize(aSize)
, mContinuous(aContinuous)
{
MOZ_ASSERT(mHandle);
}
{}
AndroidSurfaceTextureData::~AndroidSurfaceTextureData()
{}
@@ -122,7 +125,8 @@ AndroidSurfaceTextureData::FillInfo(TextureData::Info& aInfo) const
bool
AndroidSurfaceTextureData::Serialize(SurfaceDescriptor& aOutDescriptor)
{
aOutDescriptor = SurfaceTextureDescriptor(mHandle, mSize, mContinuous);
aOutDescriptor = SurfaceTextureDescriptor((uintptr_t)mSurfTex.get(),
mSize);
return true;
}

View File

@@ -54,9 +54,8 @@ class AndroidSurfaceTextureData : public TextureData
{
public:
static already_AddRefed<TextureClient>
CreateTextureClient(AndroidSurfaceTextureHandle aHandle,
CreateTextureClient(gl::AndroidSurfaceTexture* aSurfTex,
gfx::IntSize aSize,
bool aContinuous,
gl::OriginPos aOriginPos,
LayersIPCChannel* aAllocator,
TextureFlags aFlags);
@@ -76,11 +75,10 @@ public:
virtual void Deallocate(LayersIPCChannel*) override {}
protected:
AndroidSurfaceTextureData(AndroidSurfaceTextureHandle aHandle, gfx::IntSize aSize, bool aContinuous);
AndroidSurfaceTextureData(gl::AndroidSurfaceTexture* aSurfTex, gfx::IntSize aSize);
const AndroidSurfaceTextureHandle mHandle;
const RefPtr<gl::AndroidSurfaceTexture> mSurfTex;
const gfx::IntSize mSize;
const bool mContinuous;
};
#endif // MOZ_WIDGET_ANDROID

View File

@@ -56,14 +56,9 @@ CreateTextureHostOGL(const SurfaceDescriptor& aDesc,
#ifdef MOZ_WIDGET_ANDROID
case SurfaceDescriptor::TSurfaceTextureDescriptor: {
const SurfaceTextureDescriptor& desc = aDesc.get_SurfaceTextureDescriptor();
java::GeckoSurfaceTexture::LocalRef surfaceTexture = java::GeckoSurfaceTexture::Lookup(desc.handle());
MOZ_RELEASE_ASSERT(surfaceTexture);
result = new SurfaceTextureHost(aFlags,
surfaceTexture,
desc.size(),
desc.continuous());
(AndroidSurfaceTexture*)desc.surfTex(),
desc.size());
break;
}
#endif
@@ -340,7 +335,7 @@ GLTextureSource::IsValid() const
#ifdef MOZ_WIDGET_ANDROID
SurfaceTextureSource::SurfaceTextureSource(TextureSourceProvider* aProvider,
mozilla::java::GeckoSurfaceTexture::Ref& aSurfTex,
AndroidSurfaceTexture* aSurfTex,
gfx::SurfaceFormat aFormat,
GLenum aTarget,
GLenum aWrapMode,
@@ -366,7 +361,12 @@ SurfaceTextureSource::BindTexture(GLenum aTextureUnit,
}
gl->fActiveTexture(aTextureUnit);
gl->fBindTexture(mTextureTarget, mSurfTex->GetTexName());
// SurfaceTexture spams us if there are any existing GL errors, so
// we'll clear them here in order to avoid that.
gl->FlushErrors();
mSurfTex->UpdateTexImage();
ApplySamplingFilterToBoundTexture(gl, aSamplingFilter, mTextureTarget);
}
@@ -395,9 +395,7 @@ SurfaceTextureSource::GetTextureTransform()
MOZ_ASSERT(mSurfTex);
gfx::Matrix4x4 ret;
const auto& surf = java::sdk::SurfaceTexture::LocalRef(java::sdk::SurfaceTexture::Ref::From(mSurfTex));
AndroidSurfaceTexture::GetTransformMatrix(surf, ret);
mSurfTex->GetTransformMatrix(ret);
return ret;
}
@@ -411,39 +409,18 @@ SurfaceTextureSource::DeallocateDeviceData()
////////////////////////////////////////////////////////////////////////
SurfaceTextureHost::SurfaceTextureHost(TextureFlags aFlags,
mozilla::java::GeckoSurfaceTexture::Ref& aSurfTex,
gfx::IntSize aSize,
bool aContinuousUpdate)
AndroidSurfaceTexture* aSurfTex,
gfx::IntSize aSize)
: TextureHost(aFlags)
, mSurfTex(aSurfTex)
, mSize(aSize)
, mContinuousUpdate(aContinuousUpdate)
{
// Continuous update makes no sense with single buffer mode
MOZ_ASSERT(!mSurfTex->IsSingleBuffer() || !mContinuousUpdate);
}
SurfaceTextureHost::~SurfaceTextureHost()
{
}
void
SurfaceTextureHost::PrepareTextureSource(CompositableTextureSourceRef& aTexture)
{
GLContext* gl = this->gl();
if (!gl || !gl->MakeCurrent()) {
return;
}
if (!mContinuousUpdate) {
// UpdateTexImage() advances the internal buffer queue, so we only want to call this
// once per transactionwhen we are not in continuous mode (as we are here). Otherwise,
// the SurfaceTexture content will be de-synced from the rest of the page in subsequent
// compositor passes.
mSurfTex->UpdateTexImage();
}
}
gl::GLContext*
SurfaceTextureHost::gl() const
{
@@ -459,13 +436,9 @@ SurfaceTextureHost::Lock()
return false;
}
if (mContinuousUpdate) {
mSurfTex->UpdateTexImage();
}
if (!mTextureSource) {
gfx::SurfaceFormat format = gfx::SurfaceFormat::R8G8B8A8;
GLenum target = LOCAL_GL_TEXTURE_EXTERNAL; // This is required by SurfaceTexture
GLenum target = LOCAL_GL_TEXTURE_EXTERNAL;
GLenum wrapMode = LOCAL_GL_CLAMP_TO_EDGE;
mTextureSource = new SurfaceTextureSource(mProvider,
mSurfTex,
@@ -475,7 +448,14 @@ SurfaceTextureHost::Lock()
mSize);
}
return true;
return NS_SUCCEEDED(mSurfTex->Attach(gl));
}
void
SurfaceTextureHost::Unlock()
{
MOZ_ASSERT(mSurfTex);
mSurfTex->Detach();
}
void
@@ -494,16 +474,6 @@ SurfaceTextureHost::SetTextureSourceProvider(TextureSourceProvider* aProvider)
}
}
void
SurfaceTextureHost::NotifyNotUsed()
{
if (mSurfTex->IsSingleBuffer()) {
mSurfTex->ReleaseTexImage();
}
TextureHost::NotifyNotUsed();
}
gfx::SurfaceFormat
SurfaceTextureHost::GetFormat() const
{

View File

@@ -31,16 +31,15 @@
#include "nsRegionFwd.h" // for nsIntRegion
#include "OGLShaderProgram.h" // for ShaderProgramType, etc
#ifdef MOZ_WIDGET_ANDROID
#include "GeneratedJNIWrappers.h"
#include "AndroidSurfaceTexture.h"
#endif
namespace mozilla {
namespace gfx {
class DataSourceSurface;
} // namespace gfx
namespace gl {
class AndroidSurfaceTexture;
} // namespace gl
namespace layers {
class Compositor;
@@ -342,7 +341,7 @@ class SurfaceTextureSource : public TextureSource
{
public:
SurfaceTextureSource(TextureSourceProvider* aProvider,
java::GeckoSurfaceTexture::Ref& aSurfTex,
mozilla::gl::AndroidSurfaceTexture* aSurfTex,
gfx::SurfaceFormat aFormat,
GLenum aTarget,
GLenum aWrapMode,
@@ -377,7 +376,7 @@ public:
protected:
RefPtr<gl::GLContext> mGL;
mozilla::java::GeckoSurfaceTexture::GlobalRef mSurfTex;
RefPtr<gl::AndroidSurfaceTexture> mSurfTex;
const gfx::SurfaceFormat mFormat;
const GLenum mTextureTarget;
const GLenum mWrapMode;
@@ -388,23 +387,20 @@ class SurfaceTextureHost : public TextureHost
{
public:
SurfaceTextureHost(TextureFlags aFlags,
mozilla::java::GeckoSurfaceTexture::Ref& aSurfTex,
gfx::IntSize aSize,
bool aContinuousUpdate);
mozilla::gl::AndroidSurfaceTexture* aSurfTex,
gfx::IntSize aSize);
virtual ~SurfaceTextureHost();
virtual void PrepareTextureSource(CompositableTextureSourceRef& aTexture) override;
virtual void DeallocateDeviceData() override;
virtual void SetTextureSourceProvider(TextureSourceProvider* aProvider) override;
virtual bool Lock() override;
virtual gfx::SurfaceFormat GetFormat() const override;
virtual void Unlock() override;
virtual void NotifyNotUsed() override;
virtual gfx::SurfaceFormat GetFormat() const override;
virtual bool BindTextureSource(CompositableTextureSourceRef& aTexture) override
{
@@ -424,9 +420,8 @@ public:
virtual const char* Name() override { return "SurfaceTextureHost"; }
protected:
mozilla::java::GeckoSurfaceTexture::GlobalRef mSurfTex;
RefPtr<gl::AndroidSurfaceTexture> mSurfTex;
const gfx::IntSize mSize;
bool mContinuousUpdate;
RefPtr<CompositorOGL> mCompositor;
RefPtr<SurfaceTextureSource> mTextureSource;
};

View File

@@ -10,10 +10,6 @@
#include "nsDebug.h" // for NS_ASSERTION, NS_ERROR, etc
#include "nsDeque.h" // for nsDeque
#ifdef MOZ_WIDGET_ANDROID
#include "GeneratedJNINatives.h"
#endif
#define TEXTURE_POOL_SIZE 10
namespace mozilla {
@@ -24,19 +20,6 @@ static GLContext* sActiveContext = nullptr;
static Monitor* sMonitor = nullptr;
static nsDeque* sTextures = nullptr;
#ifdef MOZ_WIDGET_ANDROID
class GeckoSurfaceTextureSupport final
: public java::GeckoSurfaceTexture::Natives<GeckoSurfaceTextureSupport>
{
public:
static int32_t NativeAcquireTexture() {
return TexturePoolOGL::AcquireTexture();
}
};
#endif // MOZ_WIDGET_ANDROID
GLuint TexturePoolOGL::AcquireTexture()
{
NS_ASSERTION(sMonitor, "not initialized");
@@ -128,12 +111,6 @@ void TexturePoolOGL::Init()
{
sMonitor = new Monitor("TexturePoolOGL.sMonitor");
sTextures = new nsDeque();
#ifdef MOZ_WIDGET_ANDROID
if (jni::IsAvailable()) {
GeckoSurfaceTextureSupport::Init();
}
#endif
}
void TexturePoolOGL::Shutdown()

View File

@@ -473,12 +473,5 @@
android:isolatedProcess="false">
</service>
<service
android:name="org.mozilla.gecko.gfx.SurfaceAllocatorService"
android:enabled="true"
android:exported="false"
android:isolatedProcess="false">
</service>
</application>
</manifest>

View File

@@ -547,7 +547,6 @@ libs:: classes.dex
GECKOVIEW_AIDLS = \
org/mozilla/gecko/IGeckoEditableChild.aidl \
org/mozilla/gecko/IGeckoEditableParent.aidl \
org/mozilla/gecko/gfx/ISurfaceAllocator.aidl \
org/mozilla/gecko/media/ICodec.aidl \
org/mozilla/gecko/media/ICodecCallbacks.aidl \
org/mozilla/gecko/media/IMediaDrmBridge.aidl \

View File

@@ -379,8 +379,6 @@ gvjar.sources += [geckoview_source_dir + 'java/org/mozilla/gecko/' + x
'gfx/FloatSize.java',
'gfx/FullScreenState.java',
'gfx/GeckoLayerClient.java',
'gfx/GeckoSurface.java',
'gfx/GeckoSurfaceTexture.java',
'gfx/ImmutableViewportMetrics.java',
'gfx/IntSize.java',
'gfx/LayerView.java',
@@ -393,8 +391,6 @@ gvjar.sources += [geckoview_source_dir + 'java/org/mozilla/gecko/' + x
'gfx/RectUtils.java',
'gfx/RenderTask.java',
'gfx/StackScroller.java',
'gfx/SurfaceAllocator.java',
'gfx/SurfaceAllocatorService.java',
'gfx/SurfaceTextureListener.java',
'gfx/ViewTransform.java',
'gfx/VsyncSource.java',
@@ -1266,7 +1262,6 @@ DEFINES['ANDROID_PACKAGE_NAME'] = CONFIG['ANDROID_PACKAGE_NAME']
FINAL_TARGET_PP_FILES += ['package-name.txt.in']
gvjar.sources += ['generated/org/mozilla/gecko/' + x for x in [
'gfx/ISurfaceAllocator.java',
'IGeckoEditableChild.java',
'IGeckoEditableParent.java',
'media/ICodec.java',

View File

@@ -38,14 +38,6 @@
<application>
<!-- New child services must also be added to the Fennec AndroidManifest.xml.in -->
<service
android:name="org.mozilla.gecko.media.MediaManager"
android:enabled="true"
android:exported="false"
android:process=":media"
android:isolatedProcess="false">
</service>
<service
android:name="org.mozilla.gecko.process.GeckoServiceChildProcess$geckomediaplugin"
android:enabled="true"
@@ -61,13 +53,6 @@
android:process=":tab"
android:isolatedProcess="false">
</service>
<service
android:name="org.mozilla.gecko.gfx.SurfaceAllocatorService"
android:enabled="true"
android:exported="false"
android:isolatedProcess="false">
</service>
</application>
</manifest>

View File

@@ -1,7 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.gecko.gfx;
parcelable GeckoSurface;

View File

@@ -1,12 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.gecko.gfx;
import org.mozilla.gecko.gfx.GeckoSurface;
interface ISurfaceAllocator {
GeckoSurface acquireSurface(in int width, in int height, in boolean singleBufferMode);
void releaseSurface(in int handle);
}

View File

@@ -13,7 +13,7 @@ import org.mozilla.gecko.media.Sample;
interface ICodec {
void setCallbacks(in ICodecCallbacks callbacks);
boolean configure(in FormatParam format, in Surface surface, int flags, in String drmStubId);
boolean configure(in FormatParam format, inout Surface surface, int flags, in String drmStubId);
boolean isAdaptivePlaybackSupported();
void start();
void stop();

View File

@@ -1,98 +0,0 @@
/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.gecko.gfx;
import android.graphics.SurfaceTexture;
import android.os.Parcel;
import android.os.Parcelable;
import android.view.Surface;
import android.util.Log;
import java.util.HashMap;
import org.mozilla.gecko.annotation.WrapForJNI;
import org.mozilla.gecko.AppConstants.Versions;
public final class GeckoSurface extends Surface {
private static final String LOGTAG = "GeckoSurface";
private static HashMap<Integer, GeckoSurfaceTexture> sSurfaceTextures = new HashMap<Integer, GeckoSurfaceTexture>();
private int mHandle;
private boolean mIsSingleBuffer;
private volatile boolean mIsAvailable;
private SurfaceTexture mDummySurfaceTexture;
@WrapForJNI(exceptionMode = "nsresult")
public GeckoSurface(GeckoSurfaceTexture gst) {
super(gst);
mHandle = gst.getHandle();
mIsSingleBuffer = gst.isSingleBuffer();
mIsAvailable = true;
}
public GeckoSurface(SurfaceTexture st) {
super(st);
mDummySurfaceTexture = st;
}
public GeckoSurface() {
// A no-arg constructor exists, but is hidden in the SDK. We need to create a dummy
// SurfaceTexture here in order to create the instance. This is used to transfer the
// GeckoSurface across binder.
super(new SurfaceTexture(0));
}
@Override
public void readFromParcel(Parcel p) {
super.readFromParcel(p);
mHandle = p.readInt();
mIsSingleBuffer = p.readByte() == 1 ? true : false;
mIsAvailable = (p.readByte() == 1 ? true : false);
if (mDummySurfaceTexture != null) {
mDummySurfaceTexture.release();
mDummySurfaceTexture = null;
}
}
public static final Parcelable.Creator<GeckoSurface> CREATOR = new Parcelable.Creator<GeckoSurface>() {
public GeckoSurface createFromParcel(Parcel p) {
GeckoSurface surf = new GeckoSurface();
surf.readFromParcel(p);
return surf;
}
public GeckoSurface[] newArray(int size) {
return new GeckoSurface[size];
}
};
@Override
public void writeToParcel(Parcel out, int flags) {
super.writeToParcel(out, flags);
out.writeInt(mHandle);
out.writeByte((byte) (mIsSingleBuffer ? 1 : 0));
out.writeByte((byte) (mIsAvailable ? 1 : 0));
}
@WrapForJNI
public int getHandle() {
return mHandle;
}
@WrapForJNI
public boolean getAvailable() {
return mIsAvailable;
}
@WrapForJNI
public void setAvailable(boolean available) {
mIsAvailable = available;
}
}

View File

@@ -1,140 +0,0 @@
/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.gecko.gfx;
import android.graphics.SurfaceTexture;
import android.util.Log;
import java.util.HashMap;
import org.mozilla.gecko.annotation.WrapForJNI;
import org.mozilla.gecko.AppConstants.Versions;
public final class GeckoSurfaceTexture extends SurfaceTexture {
private static final String LOGTAG = "GeckoSurfaceTexture";
private static volatile int sNextHandle = 1;
private static HashMap<Integer, GeckoSurfaceTexture> sSurfaceTextures = new HashMap<Integer, GeckoSurfaceTexture>();
private int mHandle;
private boolean mIsSingleBuffer;
private int mTexName;
private GeckoSurfaceTexture.Callbacks mListener;
@WrapForJNI(dispatchTo = "current")
private static native int nativeAcquireTexture();
private GeckoSurfaceTexture(int handle, int texName) {
super(texName);
mHandle = handle;
mIsSingleBuffer = false;
mTexName = texName;
}
private GeckoSurfaceTexture(int handle, int texName, boolean singleBufferMode) {
super(texName, singleBufferMode);
mHandle = handle;
mIsSingleBuffer = singleBufferMode;
mTexName = texName;
}
@WrapForJNI
public int getHandle() {
return mHandle;
}
@WrapForJNI
public int getTexName() {
return mTexName;
}
@WrapForJNI
public boolean isSingleBuffer() {
return mIsSingleBuffer;
}
@Override
@WrapForJNI
public synchronized void updateTexImage() {
super.updateTexImage();
if (mListener != null) {
mListener.onUpdateTexImage();
}
}
@Override
@WrapForJNI
public synchronized void releaseTexImage() {
if (!mIsSingleBuffer) {
return;
}
super.releaseTexImage();
if (mListener != null) {
mListener.onReleaseTexImage();
}
}
public synchronized void setListener(GeckoSurfaceTexture.Callbacks listener) {
mListener = listener;
}
@WrapForJNI
public static boolean isSingleBufferSupported() {
return Versions.feature19Plus;
}
public static GeckoSurfaceTexture acquire(boolean singleBufferMode) {
if (singleBufferMode && !isSingleBufferSupported()) {
throw new IllegalArgumentException("single buffer mode not supported on API version < 19");
}
int handle = sNextHandle++;
int texName = nativeAcquireTexture();
final GeckoSurfaceTexture gst;
if (isSingleBufferSupported()) {
gst = new GeckoSurfaceTexture(handle, texName, singleBufferMode);
} else {
gst = new GeckoSurfaceTexture(handle, texName);
}
synchronized (sSurfaceTextures) {
if (sSurfaceTextures.containsKey(handle)) {
gst.release();
throw new IllegalArgumentException("Already have a GeckoSurfaceTexture with that handle");
}
sSurfaceTextures.put(handle, gst);
}
return gst;
}
public static void dispose(int handle) {
final GeckoSurfaceTexture gst;
synchronized (sSurfaceTextures) {
gst = sSurfaceTextures.remove(handle);
}
if (gst != null) {
gst.setListener(null);
gst.release();
}
}
@WrapForJNI
public static GeckoSurfaceTexture lookup(int handle) {
synchronized (sSurfaceTextures) {
return sSurfaceTextures.get(handle);
}
}
public interface Callbacks {
void onUpdateTexImage();
void onReleaseTexImage();
}
}

View File

@@ -1,108 +0,0 @@
/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.gecko.gfx;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.graphics.SurfaceTexture;
import android.os.IBinder;
import android.os.Process;
import android.os.RemoteException;
import android.util.Log;
import android.view.Surface;
import org.mozilla.gecko.annotation.WrapForJNI;
import org.mozilla.gecko.GeckoAppShell;
public final class SurfaceAllocator {
private static final String LOGTAG = "SurfaceAllocator";
private static SurfaceAllocatorConnection sConnection;
private static synchronized void ensureConnection() throws Exception {
if (sConnection != null) {
return;
}
sConnection = new SurfaceAllocatorConnection();
Intent intent = new Intent();
intent.setClassName(GeckoAppShell.getApplicationContext(),
"org.mozilla.gecko.gfx.SurfaceAllocatorService");
// FIXME: may not want to auto create
if (!GeckoAppShell.getApplicationContext().bindService(intent, sConnection, Context.BIND_AUTO_CREATE)) {
throw new Exception("Failed to connect to surface allocator service!");
}
}
@WrapForJNI
public static GeckoSurface acquireSurface(int width, int height, boolean singleBufferMode) {
try {
ensureConnection();
if (singleBufferMode && !GeckoSurfaceTexture.isSingleBufferSupported()) {
return null;
}
return sConnection.getAllocator().acquireSurface(width, height, singleBufferMode);
} catch (Exception e) {
Log.w(LOGTAG, "Failed to acquire GeckoSurface", e);
return null;
}
}
@WrapForJNI
public static void disposeSurface(GeckoSurface surface) {
try {
ensureConnection();
} catch (Exception e) {
Log.w(LOGTAG, "Failed to dispose surface, no connection");
return;
}
// Release the SurfaceTexture on the other side
try {
sConnection.getAllocator().releaseSurface(surface.getHandle());
} catch (RemoteException e) {
Log.w(LOGTAG, "Failed to release surface texture", e);
}
// And now our Surface
try {
surface.release();
} catch (Exception e) {
Log.w(LOGTAG, "Failed to release surface", e);
}
}
private static final class SurfaceAllocatorConnection implements ServiceConnection {
private ISurfaceAllocator mAllocator;
public synchronized ISurfaceAllocator getAllocator() {
while (mAllocator == null) {
try {
this.wait();
} catch (InterruptedException e) { }
}
return mAllocator;
}
@Override
public synchronized void onServiceConnected(ComponentName name, IBinder service) {
mAllocator = ISurfaceAllocator.Stub.asInterface(service);
this.notifyAll();
}
@Override
public synchronized void onServiceDisconnected(ComponentName name) {
mAllocator = null;
}
}
}

View File

@@ -1,45 +0,0 @@
/* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil; -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.gecko.gfx;
import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;
public class SurfaceAllocatorService extends Service {
static private String LOGTAG = "SurfaceAllocatorService";
public int onStartCommand(final Intent intent, final int flags, final int startId) {
return Service.START_STICKY;
}
private Binder mBinder = new ISurfaceAllocator.Stub() {
public GeckoSurface acquireSurface(int width, int height, boolean singleBufferMode) {
GeckoSurfaceTexture gst = GeckoSurfaceTexture.acquire(singleBufferMode);
if (width > 0 && height > 0) {
gst.setDefaultBufferSize(width, height);
}
return new GeckoSurface(gst);
}
public void releaseSurface(int handle) {
GeckoSurfaceTexture.dispose(handle);
}
};
public IBinder onBind(final Intent intent) {
return mBinder;
}
public boolean onUnbind(Intent intent) {
return false;
}
}

View File

@@ -17,12 +17,10 @@ final class SurfaceTextureListener
private SurfaceTextureListener() {
}
@WrapForJNI(dispatchTo = "gecko") @Override // JNIObject
protected native void disposeNative();
@Override
protected void finalize() {
disposeNative();
protected void disposeNative() {
// SurfaceTextureListener is disposed inside AndroidSurfaceTexture.
throw new IllegalStateException("unreachable code");
}
@WrapForJNI(stubName = "OnFrameAvailable")

View File

@@ -7,10 +7,5 @@ public abstract class JNIObject
private long mHandle;
// Dispose of any reference to a native object.
//
// If the native instance is destroyed from the native side, this should never be
// called, so you should throw an UnsupportedOperationException. If instead you
// want to destroy the native side from the Java end, make override this with
// a native call, and the right thing will be done in the native code.
protected abstract void disposeNative();
}

View File

@@ -173,7 +173,9 @@ AndroidBridge::AndroidBridge()
AutoJNIClass string(jEnv, "java/lang/String");
jStringClass = string.getGlobalRef();
mAPIVersion = jni::GetAPIVersion();
if (!GetStaticIntField("android/os/Build$VERSION", "SDK_INT", &mAPIVersion, jEnv)) {
ALOG_BRIDGE("Failed to find API version");
}
AutoJNIClass channels(jEnv, "java/nio/channels/Channels");
jChannels = channels.getGlobalRef();

View File

@@ -336,36 +336,17 @@ template<class Impl>
class SurfaceTextureListener::Natives : public mozilla::jni::NativeImpl<SurfaceTextureListener, Impl>
{
public:
static const JNINativeMethod methods[2];
static const JNINativeMethod methods[1];
};
template<class Impl>
const JNINativeMethod SurfaceTextureListener::Natives<Impl>::methods[] = {
mozilla::jni::MakeNativeMethod<SurfaceTextureListener::DisposeNative_t>(
mozilla::jni::NativeStub<SurfaceTextureListener::DisposeNative_t, Impl>
::template Wrap<&Impl::DisposeNative>),
mozilla::jni::MakeNativeMethod<SurfaceTextureListener::OnFrameAvailable_t>(
mozilla::jni::NativeStub<SurfaceTextureListener::OnFrameAvailable_t, Impl>
::template Wrap<&Impl::OnFrameAvailable>)
};
template<class Impl>
class GeckoSurfaceTexture::Natives : public mozilla::jni::NativeImpl<GeckoSurfaceTexture, Impl>
{
public:
static const JNINativeMethod methods[1];
};
template<class Impl>
const JNINativeMethod GeckoSurfaceTexture::Natives<Impl>::methods[] = {
mozilla::jni::MakeNativeMethod<GeckoSurfaceTexture::NativeAcquireTexture_t>(
mozilla::jni::NativeStub<GeckoSurfaceTexture::NativeAcquireTexture_t, Impl>
::template Wrap<&Impl::NativeAcquireTexture>)
};
template<class Impl>
class LayerView::Compositor::Natives : public mozilla::jni::NativeImpl<Compositor, Impl>
{

View File

@@ -1063,9 +1063,6 @@ auto SurfaceTextureListener::New() -> SurfaceTextureListener::LocalRef
return mozilla::jni::Constructor<New_t>::Call(SurfaceTextureListener::Context(), nullptr);
}
constexpr char SurfaceTextureListener::DisposeNative_t::name[];
constexpr char SurfaceTextureListener::DisposeNative_t::signature[];
constexpr char SurfaceTextureListener::OnFrameAvailable_t::name[];
constexpr char SurfaceTextureListener::OnFrameAvailable_t::signature[];
@@ -1120,106 +1117,6 @@ auto GeckoLayerClient::UpdateRootFrameMetrics(float a0, float a1, float a2, floa
return mozilla::jni::Method<UpdateRootFrameMetrics_t>::Call(GeckoLayerClient::mCtx, nullptr, a0, a1, a2, a3, a4, a5, a6);
}
const char GeckoSurface::name[] =
"org/mozilla/gecko/gfx/GeckoSurface";
constexpr char GeckoSurface::New_t::name[];
constexpr char GeckoSurface::New_t::signature[];
auto GeckoSurface::New(mozilla::jni::Object::Param a0, GeckoSurface::LocalRef* a1) -> nsresult
{
MOZ_ASSERT(a1);
nsresult rv = NS_OK;
*a1 = mozilla::jni::Constructor<New_t>::Call(GeckoSurface::Context(), &rv, a0);
return rv;
}
constexpr char GeckoSurface::GetAvailable_t::name[];
constexpr char GeckoSurface::GetAvailable_t::signature[];
auto GeckoSurface::GetAvailable() const -> bool
{
return mozilla::jni::Method<GetAvailable_t>::Call(GeckoSurface::mCtx, nullptr);
}
constexpr char GeckoSurface::GetHandle_t::name[];
constexpr char GeckoSurface::GetHandle_t::signature[];
auto GeckoSurface::GetHandle() const -> int32_t
{
return mozilla::jni::Method<GetHandle_t>::Call(GeckoSurface::mCtx, nullptr);
}
constexpr char GeckoSurface::SetAvailable_t::name[];
constexpr char GeckoSurface::SetAvailable_t::signature[];
auto GeckoSurface::SetAvailable(bool a0) const -> void
{
return mozilla::jni::Method<SetAvailable_t>::Call(GeckoSurface::mCtx, nullptr, a0);
}
const char GeckoSurfaceTexture::name[] =
"org/mozilla/gecko/gfx/GeckoSurfaceTexture";
constexpr char GeckoSurfaceTexture::GetHandle_t::name[];
constexpr char GeckoSurfaceTexture::GetHandle_t::signature[];
auto GeckoSurfaceTexture::GetHandle() const -> int32_t
{
return mozilla::jni::Method<GetHandle_t>::Call(GeckoSurfaceTexture::mCtx, nullptr);
}
constexpr char GeckoSurfaceTexture::GetTexName_t::name[];
constexpr char GeckoSurfaceTexture::GetTexName_t::signature[];
auto GeckoSurfaceTexture::GetTexName() const -> int32_t
{
return mozilla::jni::Method<GetTexName_t>::Call(GeckoSurfaceTexture::mCtx, nullptr);
}
constexpr char GeckoSurfaceTexture::IsSingleBuffer_t::name[];
constexpr char GeckoSurfaceTexture::IsSingleBuffer_t::signature[];
auto GeckoSurfaceTexture::IsSingleBuffer() const -> bool
{
return mozilla::jni::Method<IsSingleBuffer_t>::Call(GeckoSurfaceTexture::mCtx, nullptr);
}
constexpr char GeckoSurfaceTexture::IsSingleBufferSupported_t::name[];
constexpr char GeckoSurfaceTexture::IsSingleBufferSupported_t::signature[];
auto GeckoSurfaceTexture::IsSingleBufferSupported() -> bool
{
return mozilla::jni::Method<IsSingleBufferSupported_t>::Call(GeckoSurfaceTexture::Context(), nullptr);
}
constexpr char GeckoSurfaceTexture::Lookup_t::name[];
constexpr char GeckoSurfaceTexture::Lookup_t::signature[];
auto GeckoSurfaceTexture::Lookup(int32_t a0) -> GeckoSurfaceTexture::LocalRef
{
return mozilla::jni::Method<Lookup_t>::Call(GeckoSurfaceTexture::Context(), nullptr, a0);
}
constexpr char GeckoSurfaceTexture::NativeAcquireTexture_t::name[];
constexpr char GeckoSurfaceTexture::NativeAcquireTexture_t::signature[];
constexpr char GeckoSurfaceTexture::ReleaseTexImage_t::name[];
constexpr char GeckoSurfaceTexture::ReleaseTexImage_t::signature[];
auto GeckoSurfaceTexture::ReleaseTexImage() const -> void
{
return mozilla::jni::Method<ReleaseTexImage_t>::Call(GeckoSurfaceTexture::mCtx, nullptr);
}
constexpr char GeckoSurfaceTexture::UpdateTexImage_t::name[];
constexpr char GeckoSurfaceTexture::UpdateTexImage_t::signature[];
auto GeckoSurfaceTexture::UpdateTexImage() const -> void
{
return mozilla::jni::Method<UpdateTexImage_t>::Call(GeckoSurfaceTexture::mCtx, nullptr);
}
const char ImmutableViewportMetrics::name[] =
"org/mozilla/gecko/gfx/ImmutableViewportMetrics";
@@ -1648,25 +1545,6 @@ auto StackScroller::SViscousFluidScale(float a0) -> nsresult
return rv;
}
const char SurfaceAllocator::name[] =
"org/mozilla/gecko/gfx/SurfaceAllocator";
constexpr char SurfaceAllocator::AcquireSurface_t::name[];
constexpr char SurfaceAllocator::AcquireSurface_t::signature[];
auto SurfaceAllocator::AcquireSurface(int32_t a0, int32_t a1, bool a2) -> mozilla::jni::Object::LocalRef
{
return mozilla::jni::Method<AcquireSurface_t>::Call(SurfaceAllocator::Context(), nullptr, a0, a1, a2);
}
constexpr char SurfaceAllocator::DisposeSurface_t::name[];
constexpr char SurfaceAllocator::DisposeSurface_t::signature[];
auto SurfaceAllocator::DisposeSurface(mozilla::jni::Object::Param a0) -> void
{
return mozilla::jni::Method<DisposeSurface_t>::Call(SurfaceAllocator::Context(), nullptr, a0);
}
const char ViewTransform::name[] =
"org/mozilla/gecko/gfx/ViewTransform";

View File

@@ -3308,23 +3308,6 @@ public:
static auto New() -> SurfaceTextureListener::LocalRef;
struct DisposeNative_t {
typedef SurfaceTextureListener Owner;
typedef void ReturnType;
typedef void SetterType;
typedef mozilla::jni::Args<> Args;
static constexpr char name[] = "disposeNative";
static constexpr char signature[] =
"()V";
static const bool isStatic = false;
static const mozilla::jni::ExceptionMode exceptionMode =
mozilla::jni::ExceptionMode::ABORT;
static const mozilla::jni::CallingThread callingThread =
mozilla::jni::CallingThread::ANY;
static const mozilla::jni::DispatchTarget dispatchTarget =
mozilla::jni::DispatchTarget::GECKO;
};
struct OnFrameAvailable_t {
typedef SurfaceTextureListener Owner;
typedef void ReturnType;
@@ -3490,260 +3473,6 @@ public:
};
class GeckoSurface : public mozilla::jni::ObjectBase<GeckoSurface>
{
public:
static const char name[];
explicit GeckoSurface(const Context& ctx) : ObjectBase<GeckoSurface>(ctx) {}
struct New_t {
typedef GeckoSurface Owner;
typedef GeckoSurface::LocalRef ReturnType;
typedef GeckoSurface::Param SetterType;
typedef mozilla::jni::Args<
mozilla::jni::Object::Param> Args;
static constexpr char name[] = "<init>";
static constexpr char signature[] =
"(Lorg/mozilla/gecko/gfx/GeckoSurfaceTexture;)V";
static const bool isStatic = false;
static const mozilla::jni::ExceptionMode exceptionMode =
mozilla::jni::ExceptionMode::NSRESULT;
static const mozilla::jni::CallingThread callingThread =
mozilla::jni::CallingThread::ANY;
static const mozilla::jni::DispatchTarget dispatchTarget =
mozilla::jni::DispatchTarget::CURRENT;
};
static auto New(mozilla::jni::Object::Param, GeckoSurface::LocalRef*) -> nsresult;
struct GetAvailable_t {
typedef GeckoSurface Owner;
typedef bool ReturnType;
typedef bool SetterType;
typedef mozilla::jni::Args<> Args;
static constexpr char name[] = "getAvailable";
static constexpr char signature[] =
"()Z";
static const bool isStatic = false;
static const mozilla::jni::ExceptionMode exceptionMode =
mozilla::jni::ExceptionMode::ABORT;
static const mozilla::jni::CallingThread callingThread =
mozilla::jni::CallingThread::ANY;
static const mozilla::jni::DispatchTarget dispatchTarget =
mozilla::jni::DispatchTarget::CURRENT;
};
auto GetAvailable() const -> bool;
struct GetHandle_t {
typedef GeckoSurface Owner;
typedef int32_t ReturnType;
typedef int32_t SetterType;
typedef mozilla::jni::Args<> Args;
static constexpr char name[] = "getHandle";
static constexpr char signature[] =
"()I";
static const bool isStatic = false;
static const mozilla::jni::ExceptionMode exceptionMode =
mozilla::jni::ExceptionMode::ABORT;
static const mozilla::jni::CallingThread callingThread =
mozilla::jni::CallingThread::ANY;
static const mozilla::jni::DispatchTarget dispatchTarget =
mozilla::jni::DispatchTarget::CURRENT;
};
auto GetHandle() const -> int32_t;
struct SetAvailable_t {
typedef GeckoSurface Owner;
typedef void ReturnType;
typedef void SetterType;
typedef mozilla::jni::Args<
bool> Args;
static constexpr char name[] = "setAvailable";
static constexpr char signature[] =
"(Z)V";
static const bool isStatic = false;
static const mozilla::jni::ExceptionMode exceptionMode =
mozilla::jni::ExceptionMode::ABORT;
static const mozilla::jni::CallingThread callingThread =
mozilla::jni::CallingThread::ANY;
static const mozilla::jni::DispatchTarget dispatchTarget =
mozilla::jni::DispatchTarget::CURRENT;
};
auto SetAvailable(bool) const -> void;
static const mozilla::jni::CallingThread callingThread =
mozilla::jni::CallingThread::ANY;
};
class GeckoSurfaceTexture : public mozilla::jni::ObjectBase<GeckoSurfaceTexture>
{
public:
static const char name[];
explicit GeckoSurfaceTexture(const Context& ctx) : ObjectBase<GeckoSurfaceTexture>(ctx) {}
struct GetHandle_t {
typedef GeckoSurfaceTexture Owner;
typedef int32_t ReturnType;
typedef int32_t SetterType;
typedef mozilla::jni::Args<> Args;
static constexpr char name[] = "getHandle";
static constexpr char signature[] =
"()I";
static const bool isStatic = false;
static const mozilla::jni::ExceptionMode exceptionMode =
mozilla::jni::ExceptionMode::ABORT;
static const mozilla::jni::CallingThread callingThread =
mozilla::jni::CallingThread::ANY;
static const mozilla::jni::DispatchTarget dispatchTarget =
mozilla::jni::DispatchTarget::CURRENT;
};
auto GetHandle() const -> int32_t;
struct GetTexName_t {
typedef GeckoSurfaceTexture Owner;
typedef int32_t ReturnType;
typedef int32_t SetterType;
typedef mozilla::jni::Args<> Args;
static constexpr char name[] = "getTexName";
static constexpr char signature[] =
"()I";
static const bool isStatic = false;
static const mozilla::jni::ExceptionMode exceptionMode =
mozilla::jni::ExceptionMode::ABORT;
static const mozilla::jni::CallingThread callingThread =
mozilla::jni::CallingThread::ANY;
static const mozilla::jni::DispatchTarget dispatchTarget =
mozilla::jni::DispatchTarget::CURRENT;
};
auto GetTexName() const -> int32_t;
struct IsSingleBuffer_t {
typedef GeckoSurfaceTexture Owner;
typedef bool ReturnType;
typedef bool SetterType;
typedef mozilla::jni::Args<> Args;
static constexpr char name[] = "isSingleBuffer";
static constexpr char signature[] =
"()Z";
static const bool isStatic = false;
static const mozilla::jni::ExceptionMode exceptionMode =
mozilla::jni::ExceptionMode::ABORT;
static const mozilla::jni::CallingThread callingThread =
mozilla::jni::CallingThread::ANY;
static const mozilla::jni::DispatchTarget dispatchTarget =
mozilla::jni::DispatchTarget::CURRENT;
};
auto IsSingleBuffer() const -> bool;
struct IsSingleBufferSupported_t {
typedef GeckoSurfaceTexture Owner;
typedef bool ReturnType;
typedef bool SetterType;
typedef mozilla::jni::Args<> Args;
static constexpr char name[] = "isSingleBufferSupported";
static constexpr char signature[] =
"()Z";
static const bool isStatic = true;
static const mozilla::jni::ExceptionMode exceptionMode =
mozilla::jni::ExceptionMode::ABORT;
static const mozilla::jni::CallingThread callingThread =
mozilla::jni::CallingThread::ANY;
static const mozilla::jni::DispatchTarget dispatchTarget =
mozilla::jni::DispatchTarget::CURRENT;
};
static auto IsSingleBufferSupported() -> bool;
struct Lookup_t {
typedef GeckoSurfaceTexture Owner;
typedef GeckoSurfaceTexture::LocalRef ReturnType;
typedef GeckoSurfaceTexture::Param SetterType;
typedef mozilla::jni::Args<
int32_t> Args;
static constexpr char name[] = "lookup";
static constexpr char signature[] =
"(I)Lorg/mozilla/gecko/gfx/GeckoSurfaceTexture;";
static const bool isStatic = true;
static const mozilla::jni::ExceptionMode exceptionMode =
mozilla::jni::ExceptionMode::ABORT;
static const mozilla::jni::CallingThread callingThread =
mozilla::jni::CallingThread::ANY;
static const mozilla::jni::DispatchTarget dispatchTarget =
mozilla::jni::DispatchTarget::CURRENT;
};
static auto Lookup(int32_t) -> GeckoSurfaceTexture::LocalRef;
struct NativeAcquireTexture_t {
typedef GeckoSurfaceTexture Owner;
typedef int32_t ReturnType;
typedef int32_t SetterType;
typedef mozilla::jni::Args<> Args;
static constexpr char name[] = "nativeAcquireTexture";
static constexpr char signature[] =
"()I";
static const bool isStatic = true;
static const mozilla::jni::ExceptionMode exceptionMode =
mozilla::jni::ExceptionMode::ABORT;
static const mozilla::jni::CallingThread callingThread =
mozilla::jni::CallingThread::ANY;
static const mozilla::jni::DispatchTarget dispatchTarget =
mozilla::jni::DispatchTarget::CURRENT;
};
struct ReleaseTexImage_t {
typedef GeckoSurfaceTexture Owner;
typedef void ReturnType;
typedef void SetterType;
typedef mozilla::jni::Args<> Args;
static constexpr char name[] = "releaseTexImage";
static constexpr char signature[] =
"()V";
static const bool isStatic = false;
static const mozilla::jni::ExceptionMode exceptionMode =
mozilla::jni::ExceptionMode::ABORT;
static const mozilla::jni::CallingThread callingThread =
mozilla::jni::CallingThread::ANY;
static const mozilla::jni::DispatchTarget dispatchTarget =
mozilla::jni::DispatchTarget::CURRENT;
};
auto ReleaseTexImage() const -> void;
struct UpdateTexImage_t {
typedef GeckoSurfaceTexture Owner;
typedef void ReturnType;
typedef void SetterType;
typedef mozilla::jni::Args<> Args;
static constexpr char name[] = "updateTexImage";
static constexpr char signature[] =
"()V";
static const bool isStatic = false;
static const mozilla::jni::ExceptionMode exceptionMode =
mozilla::jni::ExceptionMode::ABORT;
static const mozilla::jni::CallingThread callingThread =
mozilla::jni::CallingThread::ANY;
static const mozilla::jni::DispatchTarget dispatchTarget =
mozilla::jni::DispatchTarget::CURRENT;
};
auto UpdateTexImage() const -> void;
static const mozilla::jni::CallingThread callingThread =
mozilla::jni::CallingThread::ANY;
template<class Impl> class Natives;
};
class ImmutableViewportMetrics : public mozilla::jni::ObjectBase<ImmutableViewportMetrics>
{
public:
@@ -4883,60 +4612,6 @@ public:
};
class SurfaceAllocator : public mozilla::jni::ObjectBase<SurfaceAllocator>
{
public:
static const char name[];
explicit SurfaceAllocator(const Context& ctx) : ObjectBase<SurfaceAllocator>(ctx) {}
struct AcquireSurface_t {
typedef SurfaceAllocator Owner;
typedef mozilla::jni::Object::LocalRef ReturnType;
typedef mozilla::jni::Object::Param SetterType;
typedef mozilla::jni::Args<
int32_t,
int32_t,
bool> Args;
static constexpr char name[] = "acquireSurface";
static constexpr char signature[] =
"(IIZ)Lorg/mozilla/gecko/gfx/GeckoSurface;";
static const bool isStatic = true;
static const mozilla::jni::ExceptionMode exceptionMode =
mozilla::jni::ExceptionMode::ABORT;
static const mozilla::jni::CallingThread callingThread =
mozilla::jni::CallingThread::ANY;
static const mozilla::jni::DispatchTarget dispatchTarget =
mozilla::jni::DispatchTarget::CURRENT;
};
static auto AcquireSurface(int32_t, int32_t, bool) -> mozilla::jni::Object::LocalRef;
struct DisposeSurface_t {
typedef SurfaceAllocator Owner;
typedef void ReturnType;
typedef void SetterType;
typedef mozilla::jni::Args<
mozilla::jni::Object::Param> Args;
static constexpr char name[] = "disposeSurface";
static constexpr char signature[] =
"(Lorg/mozilla/gecko/gfx/GeckoSurface;)V";
static const bool isStatic = true;
static const mozilla::jni::ExceptionMode exceptionMode =
mozilla::jni::ExceptionMode::ABORT;
static const mozilla::jni::CallingThread callingThread =
mozilla::jni::CallingThread::ANY;
static const mozilla::jni::DispatchTarget dispatchTarget =
mozilla::jni::DispatchTarget::CURRENT;
};
static auto DisposeSurface(mozilla::jni::Object::Param) -> void;
static const mozilla::jni::CallingThread callingThread =
mozilla::jni::CallingThread::ANY;
};
class ViewTransform : public mozilla::jni::ObjectBase<ViewTransform>
{
public:

View File

@@ -1,2 +0,0 @@
[android.os.Build$VERSION]
<field> = noLiteral:true

View File

@@ -10,7 +10,6 @@ with Files("**"):
# List of stems to generate .cpp and .h files for. To add a stem, add it to
# this list and ensure that $(stem)-classes.txt exists in this directory.
generated = [
'AndroidBuild',
'AndroidRect',
'KeyEvent',
'MediaCodec',

View File

@@ -44,7 +44,7 @@ namespace jni {
*
* void AttachTo(const MyJavaClass::LocalRef& instance)
* {
* MyJavaClass::Natives<MyClass>::AttachNative(
* MyJavaClass::Natives<MyClass>::AttachInstance(
* instance, static_cast<SupportsWeakPtr<MyClass>*>(this));
*
* // "instance" does NOT own "this", so the C++ object
@@ -70,7 +70,7 @@ namespace jni {
*
* void AttachTo(const MyJavaClass::LocalRef& instance)
* {
* MyJavaClass::Natives<MyClass>::AttachNative(instance, this);
* MyJavaClass::Natives<MyClass>::AttachInstance(instance, this);
*
* // "instance" owns "this" through the RefPtr, so the C++ object
* // may be destroyed as soon as instance.disposeNative() is called.
@@ -91,7 +91,7 @@ namespace jni {
*
* static void AttachTo(const MyJavaClass::LocalRef& instance)
* {
* MyJavaClass::Natives<MyClass>::AttachNative(
* MyJavaClass::Natives<MyClass>::AttachInstance(
* instance, mozilla::MakeUnique<MyClass>());
*
* // "instance" owns the newly created C++ object, so the C++

View File

@@ -7,7 +7,6 @@
#include "mozilla/Assertions.h"
#include "GeneratedJNIWrappers.h"
#include "AndroidBuild.h"
#include "nsAppShell.h"
#ifdef MOZ_CRASHREPORTER
@@ -313,13 +312,5 @@ bool IsFennec()
return sIsFennec;
}
int GetAPIVersion() {
static int32_t apiVersion = 0;
if (!apiVersion && IsAvailable()) {
apiVersion = java::sdk::VERSION::SDK_INT();
}
return apiVersion;
}
} // jni
} // mozilla

View File

@@ -146,8 +146,6 @@ void DispatchToGeckoPriorityQueue(UniquePtr<AbstractCall>&& aCall);
*/
bool IsFennec();
int GetAPIVersion();
} // jni
} // mozilla