mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Stub untested gralloc support, disabled for now
This commit is contained in:
parent
b376c8db03
commit
ce3f178378
@ -67,6 +67,10 @@
|
||||
/* from widget */
|
||||
#if defined(MOZ_WIDGET_ANDROID)
|
||||
#include "AndroidBridge.h"
|
||||
#include "AndroidBackingSurface.h"
|
||||
|
||||
#define EGL_NATIVE_BUFFER_ANDROID 0x3140
|
||||
#define EGL_IMAGE_PRESERVED_KHR 0x30D2
|
||||
#endif
|
||||
#include <android/log.h>
|
||||
#endif
|
||||
@ -155,7 +159,7 @@ public:
|
||||
|
||||
#include "gfxCrashReporterUtils.h"
|
||||
|
||||
#ifdef MOZ_PLATFORM_MAEMO
|
||||
#if defined(MOZ_PLATFORM_MAEMO) || defined(MOZ_WIDGET_ANDROID)
|
||||
static bool gUseBackingSurface = true;
|
||||
#else
|
||||
static bool gUseBackingSurface = false;
|
||||
@ -1547,6 +1551,9 @@ public:
|
||||
, mTexture(aTexture)
|
||||
, mImageKHR(nsnull)
|
||||
, mTextureState(Created)
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
, mBuffer(nsnull)
|
||||
#endif
|
||||
, mBound(false)
|
||||
, mIsLocked(false)
|
||||
{
|
||||
@ -1881,6 +1888,12 @@ public:
|
||||
LOCAL_EGL_NONE
|
||||
};
|
||||
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
nsRefPtr<gfxImageSurface> surface = LockAndroidBackingBuffer(mBuffer, mSize);
|
||||
mIsLocked = true;
|
||||
return surface.forget();
|
||||
#else
|
||||
|
||||
sEGLLibrary.fLockSurfaceKHR(EGL_DISPLAY(), mSurface, lock_attribs);
|
||||
|
||||
mIsLocked = true;
|
||||
@ -1900,6 +1913,7 @@ public:
|
||||
mUpdateFormat);
|
||||
|
||||
return sharedImage.forget();
|
||||
#endif
|
||||
}
|
||||
|
||||
virtual void UnlockSurface()
|
||||
@ -1909,7 +1923,12 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
UnlockAndroidBackingBuffer(mBuffer);
|
||||
#else
|
||||
sEGLLibrary.fUnlockSurfaceKHR(EGL_DISPLAY(), mSurface);
|
||||
#endif
|
||||
|
||||
mIsLocked = false;
|
||||
}
|
||||
|
||||
@ -1965,7 +1984,18 @@ public:
|
||||
DestroyEGLSurface();
|
||||
mBackingSurface = nsnull;
|
||||
|
||||
#ifdef MOZ_X11
|
||||
#if defined(MOZ_WIDGET_ANDROID)
|
||||
CreateAndroidBackingSurface(aSize, mBackingSurface, mSurface, mBuffer);
|
||||
|
||||
const int eglImageAttributes[] = { EGL_IMAGE_PRESERVED_KHR, 1, 0, 0 };
|
||||
|
||||
mImageKHR = sEGLLibrary.fCreateImageKHR(EGL_DISPLAY(), EGL_NO_CONTEXT,
|
||||
EGL_NATIVE_BUFFER_ANDROID, mBuffer,
|
||||
eglImageAttributes);
|
||||
|
||||
mGLContext->fBindTexture(LOCAL_GL_TEXTURE_2D, mTexture);
|
||||
sEGLLibrary.fImageTargetTexture2DOES(LOCAL_GL_TEXTURE_2D, mImageKHR);
|
||||
#elif defined(MOZ_X11)
|
||||
Display* dpy = DefaultXDisplay();
|
||||
XRenderPictFormat* renderFMT =
|
||||
gfxXlibSurface::FindRenderFormat(dpy, mUpdateFormat);
|
||||
@ -2027,6 +2057,10 @@ protected:
|
||||
EGLImageKHR mImageKHR;
|
||||
TextureState mTextureState;
|
||||
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
EGLClientBuffer mBuffer;
|
||||
#endif
|
||||
|
||||
bool mBound;
|
||||
bool mIsLocked;
|
||||
|
||||
@ -2043,6 +2077,7 @@ GLContextEGL::CreateTextureImage(const nsIntSize& aSize,
|
||||
bool aUseNearestFilter)
|
||||
{
|
||||
nsRefPtr<TextureImage> t = new gl::TiledTextureImage(this, aSize, aContentType, aUseNearestFilter);
|
||||
//nsRefPtr<TextureImage> t = TileGenFunc(aSize, aContentType, aUseNearestFilter);
|
||||
return t.forget();
|
||||
};
|
||||
|
||||
|
@ -1636,6 +1636,24 @@ abstract public class GeckoApp
|
||||
}
|
||||
}
|
||||
|
||||
public void addSurfaceViewForBackingSurface(SurfaceView surfaceView, int width, int height) {
|
||||
DisplayMetrics metrics = new DisplayMetrics();
|
||||
getWindowManager().getDefaultDisplay().getMetrics(metrics);
|
||||
|
||||
int x = metrics.widthPixels - 16, y = metrics.heightPixels - 16;
|
||||
AbsoluteLayout.LayoutParams layoutParams =
|
||||
new AbsoluteLayout.LayoutParams(width, height, x, y);
|
||||
mPluginContainer.addView(surfaceView, layoutParams);
|
||||
}
|
||||
|
||||
public void removeSurfaceViewForBackingSurface(SurfaceView surfaceView) {
|
||||
mPluginContainer.removeView(surfaceView);
|
||||
}
|
||||
|
||||
public void moveSurfaceViewForBackingSurfaceOffScreen(SurfaceView surfaceView) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
public void setFullScreen(final boolean fullscreen) {
|
||||
mMainHandler.post(new Runnable() {
|
||||
public void run() {
|
||||
|
@ -37,6 +37,7 @@
|
||||
|
||||
package org.mozilla.gecko.gfx;
|
||||
|
||||
import org.mozilla.gecko.GeckoApp;
|
||||
import org.mozilla.gecko.GeckoAppShell;
|
||||
import org.mozilla.gecko.GeckoEvent;
|
||||
import android.content.Context;
|
||||
@ -46,15 +47,19 @@ import android.graphics.PointF;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.util.Log;
|
||||
import android.view.SurfaceHolder;
|
||||
import android.view.SurfaceView;
|
||||
import android.view.View;
|
||||
|
||||
public class GeckoGLLayerClient extends GeckoLayerClient {
|
||||
private static final String LOGTAG = "GeckoGLLayerClient";
|
||||
|
||||
private Context mContext;
|
||||
private boolean mLayerRendererInitialized;
|
||||
|
||||
public GeckoGLLayerClient(Context context) {
|
||||
super(context);
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
/** This function is invoked by Gecko via JNI; be careful when modifying signature. */
|
||||
@ -100,5 +105,50 @@ public class GeckoGLLayerClient extends GeckoLayerClient {
|
||||
public void deactivateProgram() {
|
||||
mLayerRenderer.deactivateProgram();
|
||||
}
|
||||
|
||||
/** This function is invoked by Gecko via JNI; be careful when modifying signature. */
|
||||
public SurfaceView createSurfaceViewForBackingSurface(final int width, final int height) {
|
||||
final SurfaceView[] surfaceViewResult = new SurfaceView[1];
|
||||
|
||||
mLayerController.getView().post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final SurfaceView surfaceView = new SurfaceView(mContext) {
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
setMeasuredDimension(width, height);
|
||||
}
|
||||
};
|
||||
|
||||
surfaceView.getHolder().addCallback(new SurfaceHolder.Callback() {
|
||||
public void surfaceChanged(SurfaceHolder holder, int format, int width,
|
||||
int height) {
|
||||
surfaceViewResult[0] = surfaceView;
|
||||
GeckoGLLayerClient.this.notifyAll();
|
||||
}
|
||||
|
||||
public void surfaceCreated(SurfaceHolder holder) {
|
||||
// no-op
|
||||
}
|
||||
|
||||
public void surfaceDestroyed(SurfaceHolder holder) {
|
||||
// no-op
|
||||
}
|
||||
});
|
||||
|
||||
GeckoApp.mAppContext.addSurfaceViewForBackingSurface(surfaceView, width, height);
|
||||
}
|
||||
});
|
||||
|
||||
while (surfaceViewResult[0] == null) {
|
||||
try {
|
||||
wait();
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
return surfaceViewResult[0];
|
||||
}
|
||||
}
|
||||
|
||||
|
283
widget/android/AndroidBackingSurface.cpp
Normal file
283
widget/android/AndroidBackingSurface.cpp
Normal file
@ -0,0 +1,283 @@
|
||||
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* the Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2012
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Patrick Walton <pcwalton@mozilla.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "AndroidBackingSurface.h"
|
||||
#include "AndroidBridge.h"
|
||||
#include "AndroidJavaWrappers.h"
|
||||
#include <EGL/egl.h>
|
||||
#include <EGL/eglext.h>
|
||||
#include <GLES/gl.h>
|
||||
#include <GLES/glext.h>
|
||||
#include <GLES2/gl2.h>
|
||||
#include <android/log.h>
|
||||
#include <dlfcn.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define LIBHARDWARE_NAME "libhardware.so"
|
||||
#define LIBHARDWARE_HW_GET_MODULE_SYMBOL "hw_get_module"
|
||||
|
||||
#define GRALLOC_MODULE_NAME "gralloc"
|
||||
|
||||
#define GRALLOC_USAGE_SW_READ_OFTEN 0x03
|
||||
#define GRALLOC_USAGE_SW_WRITE_OFTEN 0x30
|
||||
|
||||
// We can't just #include <EGL/egl.h> because that causes conflicts with types in GLContext.h.
|
||||
|
||||
typedef void* EGLClientBuffer;
|
||||
|
||||
extern "C" {
|
||||
|
||||
EGLImageKHR eglCreateImageKHR(EGLDisplay dpy, EGLContext ctx, int target, EGLClientBuffer buffer,
|
||||
const int *attrib_list);
|
||||
|
||||
}
|
||||
|
||||
// Private Android system stuff
|
||||
|
||||
typedef void* buffer_handle_t;
|
||||
struct hw_module_methods_t;
|
||||
|
||||
struct hw_module_t {
|
||||
uint32_t tag;
|
||||
uint16_t version_major;
|
||||
uint16_t version_minor;
|
||||
const char* id;
|
||||
const char* name;
|
||||
const char* author;
|
||||
hw_module_methods_t* methods;
|
||||
void* dso;
|
||||
uint32_t reserved[32 - 7];
|
||||
};
|
||||
|
||||
struct gralloc_module_t {
|
||||
hw_module_t common;
|
||||
|
||||
int (*registerBuffer)(gralloc_module_t const* module, buffer_handle_t handle);
|
||||
int (*unregisterBuffer)(gralloc_module_t const* module, buffer_handle_t handle);
|
||||
int (*lock)(gralloc_module_t const* module, buffer_handle_t handle, int usage, int l, int t,
|
||||
int w, int h, void** vaddr);
|
||||
int (*unlock)(gralloc_module_t const* module, buffer_handle_t handle);
|
||||
int (*perform)(gralloc_module_t const* module, int operation, ...);
|
||||
void* reserved_proc[7];
|
||||
};
|
||||
|
||||
struct android_native_base_t {
|
||||
int magic;
|
||||
int version; // The size of the native EGL type.
|
||||
void* reserved[4];
|
||||
void (*incRef)(android_native_base_t* base);
|
||||
void (*decRef)(android_native_base_t* base);
|
||||
};
|
||||
|
||||
struct android_native_buffer_t {
|
||||
android_native_base_t common;
|
||||
|
||||
int width;
|
||||
int height;
|
||||
int stride;
|
||||
int format;
|
||||
int usage;
|
||||
|
||||
void* reserved[2];
|
||||
|
||||
buffer_handle_t handle;
|
||||
|
||||
void* reserved_proc[8];
|
||||
};
|
||||
|
||||
struct ANativeWindow {
|
||||
android_native_base_t common;
|
||||
|
||||
const uint32_t flags;
|
||||
const int minSwapInterval;
|
||||
const int maxSwapInterval;
|
||||
const float xdpi;
|
||||
const float ydpi;
|
||||
intptr_t oem[4];
|
||||
int (*setSwapInterval)(ANativeWindow* window, int interval);
|
||||
int (*dequeueBuffer)(ANativeWindow* window, android_native_buffer_t** buffer);
|
||||
int (*lockBuffer)(ANativeWindow* window, android_native_buffer_t* buffer);
|
||||
int (*queueBuffer)(ANativeWindow* window, android_native_buffer_t* buffer);
|
||||
int (*query)(ANativeWindow* window, int what, int* value);
|
||||
int (*perform)(ANativeWindow* window, int operation, ...);
|
||||
int (*cancelBuffer)(ANativeWindow* window, android_native_buffer_t* buffer);
|
||||
void* reserved_proc[2];
|
||||
};
|
||||
|
||||
namespace {
|
||||
|
||||
// Wrappers for Android private APIs.
|
||||
|
||||
class AndroidPrivateFunctions {
|
||||
public:
|
||||
static AndroidPrivateFunctions* Get();
|
||||
|
||||
// libhardware functions
|
||||
typedef void (*pfn_hw_get_module)(const char* id, hw_module_t** module);
|
||||
|
||||
pfn_hw_get_module f_hw_get_module;
|
||||
|
||||
private:
|
||||
AndroidPrivateFunctions();
|
||||
static AndroidPrivateFunctions* sInstance;
|
||||
};
|
||||
|
||||
class AndroidGrallocModule {
|
||||
public:
|
||||
static AndroidGrallocModule* Get();
|
||||
|
||||
unsigned char* Lock(android_native_buffer_t* aBuffer, const gfxIntSize& aSize);
|
||||
void Unlock(android_native_buffer_t* aBuffer);
|
||||
|
||||
private:
|
||||
AndroidGrallocModule();
|
||||
|
||||
static AndroidGrallocModule* sInstance;
|
||||
gralloc_module_t* mModule;
|
||||
};
|
||||
|
||||
AndroidPrivateFunctions* AndroidPrivateFunctions::sInstance = NULL;
|
||||
AndroidGrallocModule* AndroidGrallocModule::sInstance = NULL;
|
||||
|
||||
AndroidPrivateFunctions::AndroidPrivateFunctions() {
|
||||
void* libhardware = dlopen("libhardware.so", RTLD_LAZY);
|
||||
NS_ABORT_IF_FALSE(libhardware, "Couldn't open libhardware.so!");
|
||||
f_hw_get_module = reinterpret_cast<pfn_hw_get_module>
|
||||
(dlsym(libhardware, LIBHARDWARE_HW_GET_MODULE_SYMBOL));
|
||||
}
|
||||
|
||||
AndroidPrivateFunctions*
|
||||
AndroidPrivateFunctions::Get() {
|
||||
if (!sInstance) {
|
||||
sInstance = new AndroidPrivateFunctions();
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
AndroidGrallocModule::AndroidGrallocModule() {
|
||||
hw_module_t** modulePtr = reinterpret_cast<hw_module_t**>(&mModule);
|
||||
AndroidPrivateFunctions::Get()->f_hw_get_module(GRALLOC_MODULE_NAME, modulePtr);
|
||||
NS_ABORT_IF_FALSE(mModule, "Couldn't get the module!");
|
||||
}
|
||||
|
||||
AndroidGrallocModule*
|
||||
AndroidGrallocModule::Get() {
|
||||
if (!sInstance) {
|
||||
sInstance = new AndroidGrallocModule();
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
unsigned char*
|
||||
AndroidGrallocModule::Lock(android_native_buffer_t* aBuffer, const gfxIntSize& aSize) {
|
||||
void* bits;
|
||||
mModule->lock(mModule, aBuffer->handle,
|
||||
GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN,
|
||||
0, 0, aSize.width, aSize.height, &bits);
|
||||
return reinterpret_cast<unsigned char*>(bits);
|
||||
}
|
||||
|
||||
void
|
||||
AndroidGrallocModule::Unlock(android_native_buffer_t* aBuffer) {
|
||||
mModule->unlock(mModule, aBuffer->handle);
|
||||
}
|
||||
|
||||
} // end anonymous namespace
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
// TODO: Investigate the functions in /usr/include/android/native_window.h -- they look like
|
||||
// public APIs.
|
||||
|
||||
void
|
||||
CreateAndroidBackingSurface(const gfxIntSize& aSize, nsRefPtr<gfxASurface>& aBackingSurface,
|
||||
EGLSurface& aSurface, EGLClientBuffer& aBuffer) {
|
||||
__android_log_print(ANDROID_LOG_ERROR, "GeckoAndroidBackingSurface",
|
||||
"### CreateAndroidBackingSurface");
|
||||
|
||||
AndroidBridge::AutoLocalJNIFrame jniFrame(GetJNIForThread());
|
||||
|
||||
AndroidGeckoLayerClient& client = AndroidBridge::Bridge()->GetLayerClient();
|
||||
AndroidGeckoGLLayerClient& glClient = static_cast<AndroidGeckoGLLayerClient&>(client);
|
||||
|
||||
AndroidSurfaceView surfaceView;
|
||||
glClient.CreateSurfaceViewForBackingSurface(surfaceView, aSize.width, aSize.height);
|
||||
ANativeWindow* nativeWindow = surfaceView.GetNativeWindow();
|
||||
|
||||
// Must increment the reference count on the native window to avoid crashes on Mali GPUs
|
||||
// (used in the Galaxy S II, et al).
|
||||
aSurface = reinterpret_cast<EGLSurface>(nativeWindow);
|
||||
nativeWindow->common.incRef(&nativeWindow->common);
|
||||
|
||||
android_native_buffer_t* nativeBuffer;
|
||||
nativeWindow->dequeueBuffer(nativeWindow, &nativeBuffer);
|
||||
nativeWindow->lockBuffer(nativeWindow, nativeBuffer);
|
||||
|
||||
// Increment the reference count on the buffer too, in order to be on the safe side.
|
||||
aBuffer = reinterpret_cast<EGLClientBuffer>(nativeBuffer);
|
||||
nativeBuffer->common.incRef(&nativeBuffer->common);
|
||||
|
||||
}
|
||||
|
||||
already_AddRefed<gfxImageSurface>
|
||||
LockAndroidBackingBuffer(EGLClientBuffer aBuffer, const gfxIntSize& aSize) {
|
||||
__android_log_print(ANDROID_LOG_ERROR, "GeckoAndroidBackingSurface",
|
||||
"### LockAndroidBackingBuffer");
|
||||
|
||||
AndroidBridge::AutoLocalJNIFrame jniFrame(GetJNIForThread());
|
||||
|
||||
android_native_buffer_t* nativeBuffer = reinterpret_cast<android_native_buffer_t*>(aBuffer);
|
||||
unsigned char* bits = AndroidGrallocModule::Get()->Lock(nativeBuffer, aSize);
|
||||
NS_ABORT_IF_FALSE(bits, "Couldn't lock the bits!");
|
||||
|
||||
return new gfxImageSurface(bits, gfxIntSize(aSize.width, aSize.height), aSize.width * 2,
|
||||
gfxASurface::ImageFormatRGB16_565);
|
||||
}
|
||||
|
||||
void
|
||||
UnlockAndroidBackingBuffer(EGLClientBuffer aBuffer) {
|
||||
__android_log_print(ANDROID_LOG_ERROR, "GeckoAndroidBackingSurface",
|
||||
"### UnlockAndroidBackingBuffer");
|
||||
|
||||
AndroidBridge::AutoLocalJNIFrame jniFrame(GetJNIForThread());
|
||||
|
||||
AndroidGrallocModule::Get()->Unlock(reinterpret_cast<android_native_buffer_t*>(aBuffer));
|
||||
}
|
||||
|
||||
} // end namespace mozilla
|
||||
|
60
widget/android/AndroidBackingSurface.h
Normal file
60
widget/android/AndroidBackingSurface.h
Normal file
@ -0,0 +1,60 @@
|
||||
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* the Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2012
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Patrick Walton <pcwalton@mozilla.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef AndroidBackingSurface_h__
|
||||
#define AndroidBackingSurface_h__
|
||||
|
||||
#include "gfxImageSurface.h"
|
||||
#include "gfxPoint.h"
|
||||
|
||||
typedef void* EGLClientBuffer;
|
||||
typedef void* EGLImage;
|
||||
typedef void* EGLSurface;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
void CreateAndroidBackingSurface(const gfxIntSize& aSize, nsRefPtr<gfxASurface>& aBackingSurface,
|
||||
EGLSurface& aSurface, EGLClientBuffer& aBuffer);
|
||||
already_AddRefed<gfxImageSurface> LockAndroidBackingBuffer(EGLClientBuffer aBuffer,
|
||||
const gfxIntSize& aSize);
|
||||
void UnlockAndroidBackingBuffer(EGLClientBuffer aBuffer);
|
||||
|
||||
} // end namespace mozilla
|
||||
|
||||
#endif
|
||||
|
@ -87,6 +87,9 @@ jfieldID AndroidRect::jLeftField = 0;
|
||||
jfieldID AndroidRect::jRightField = 0;
|
||||
jfieldID AndroidRect::jTopField = 0;
|
||||
|
||||
jclass AndroidSurfaceView::jSurfaceViewClass = 0;
|
||||
jfieldID AndroidSurfaceView::jNativeSurfaceField = 0;
|
||||
|
||||
jclass AndroidLocation::jLocationClass = 0;
|
||||
jmethodID AndroidLocation::jGetLatitudeMethod = 0;
|
||||
jmethodID AndroidLocation::jGetLongitudeMethod = 0;
|
||||
@ -118,6 +121,7 @@ jmethodID AndroidGeckoGLLayerClient::jGetViewTransformMethod = 0;
|
||||
jmethodID AndroidGeckoGLLayerClient::jCreateFrameMethod = 0;
|
||||
jmethodID AndroidGeckoGLLayerClient::jActivateProgramMethod = 0;
|
||||
jmethodID AndroidGeckoGLLayerClient::jDeactivateProgramMethod = 0;
|
||||
jmethodID AndroidGeckoGLLayerClient::jCreateSurfaceViewForBackingSurfaceMethod = 0;
|
||||
|
||||
jclass AndroidLayerRendererFrame::jLayerRendererFrameClass = 0;
|
||||
jmethodID AndroidLayerRendererFrame::jBeginDrawingMethod = 0;
|
||||
@ -339,6 +343,33 @@ AndroidRect::InitRectClass(JNIEnv *jEnv)
|
||||
jRightField = getField("right", "I");
|
||||
}
|
||||
|
||||
void
|
||||
AndroidSurfaceView::InitSurfaceViewClass(JNIEnv *jEnv)
|
||||
{
|
||||
initInit();
|
||||
|
||||
jSurfaceViewClass = getClassGlobalRef("android/view/SurfaceView");
|
||||
|
||||
jNativeSurfaceField = getField("mNativeSurface", "I");
|
||||
}
|
||||
|
||||
void
|
||||
AndroidSurfaceView::Init(JNIEnv *jEnv, jobject jobj)
|
||||
{
|
||||
NS_ABORT_IF_FALSE(!wrapped_obj, "Init called on non-null wrapped_obj!");
|
||||
NS_ABORT_IF_FALSE(!jobj, "Init called with null object!");
|
||||
|
||||
wrapped_obj = jobj;
|
||||
}
|
||||
|
||||
ANativeWindow*
|
||||
AndroidSurfaceView::GetNativeWindow()
|
||||
{
|
||||
JNIEnv *env = GetJNIForThread();
|
||||
NS_ABORT_IF_FALSE(env, "Couldn't get JNI environment at GetNativeWindow()!");
|
||||
return reinterpret_cast<ANativeWindow*>(env->GetIntField(wrapped_obj, jNativeSurfaceField));
|
||||
}
|
||||
|
||||
void
|
||||
AndroidGeckoLayerClient::InitGeckoLayerClientClass(JNIEnv *jEnv)
|
||||
{
|
||||
@ -365,6 +396,8 @@ AndroidGeckoGLLayerClient::InitGeckoGLLayerClientClass(JNIEnv *jEnv)
|
||||
jCreateFrameMethod = getMethod("createFrame", "()Lorg/mozilla/gecko/gfx/LayerRenderer$Frame;");
|
||||
jActivateProgramMethod = getMethod("activateProgram", "()V");
|
||||
jDeactivateProgramMethod = getMethod("deactivateProgram", "()V");
|
||||
jCreateSurfaceViewForBackingSurfaceMethod = getMethod("createSurfaceViewForBackingSurface",
|
||||
"(II)Landroid/view/SurfaceView;");
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -876,6 +909,23 @@ AndroidGeckoGLLayerClient::DeactivateProgram()
|
||||
env->CallVoidMethod(wrapped_obj, jDeactivateProgramMethod);
|
||||
}
|
||||
|
||||
void
|
||||
AndroidGeckoGLLayerClient::CreateSurfaceViewForBackingSurface(AndroidSurfaceView& aSurfaceView,
|
||||
int aWidth, int aHeight)
|
||||
{
|
||||
JNIEnv *env = GetJNIForThread();
|
||||
NS_ABORT_IF_FALSE(env, "No JNI environment at CreateSurfaceViewForBackingSurface()!");
|
||||
if (!env) {
|
||||
return;
|
||||
}
|
||||
|
||||
jobject result_jobj = env->CallObjectMethod(wrapped_obj,
|
||||
jCreateSurfaceViewForBackingSurfaceMethod,
|
||||
aWidth, aHeight);
|
||||
NS_ABORT_IF_FALSE(result_jobj, "No surface view returned!");
|
||||
aSurfaceView.Init(env, result_jobj);
|
||||
}
|
||||
|
||||
void
|
||||
AndroidLayerRendererFrame::BeginDrawing()
|
||||
{
|
||||
|
@ -56,6 +56,8 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
struct ANativeWindow;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class AndroidGeckoGLLayerClient;
|
||||
@ -153,6 +155,23 @@ protected:
|
||||
static jfieldID jTopField;
|
||||
};
|
||||
|
||||
class AndroidSurfaceView : public WrappedJavaObject {
|
||||
public:
|
||||
static void InitSurfaceViewClass(JNIEnv *jEnv);
|
||||
|
||||
AndroidSurfaceView() {}
|
||||
AndroidSurfaceView(JNIEnv *jEnv, jobject jobj) {
|
||||
Init(jEnv, jobj);
|
||||
}
|
||||
|
||||
void Init(JNIEnv *jEnv, jobject jobj);
|
||||
ANativeWindow* GetNativeWindow();
|
||||
|
||||
private:
|
||||
static jclass jSurfaceViewClass;
|
||||
static jfieldID jNativeSurfaceField;
|
||||
};
|
||||
|
||||
class AndroidGeckoLayerClient : public WrappedJavaObject {
|
||||
public:
|
||||
static void InitGeckoLayerClientClass(JNIEnv *jEnv);
|
||||
@ -248,6 +267,8 @@ public:
|
||||
void CreateFrame(AndroidLayerRendererFrame& aFrame);
|
||||
void ActivateProgram();
|
||||
void DeactivateProgram();
|
||||
void CreateSurfaceViewForBackingSurface(AndroidSurfaceView& aSurfaceView, int aWidth,
|
||||
int aHeight);
|
||||
|
||||
private:
|
||||
static jclass jGeckoGLLayerClientClass;
|
||||
@ -255,6 +276,7 @@ private:
|
||||
static jmethodID jCreateFrameMethod;
|
||||
static jmethodID jActivateProgramMethod;
|
||||
static jmethodID jDeactivateProgramMethod;
|
||||
static jmethodID jCreateSurfaceViewForBackingSurfaceMethod;
|
||||
|
||||
AndroidGeckoGLLayerClientViewTransformGetter mViewTransformGetter;
|
||||
};
|
||||
|
@ -68,6 +68,7 @@ CPPSRCS = \
|
||||
AndroidDirectTexture.cpp \
|
||||
AndroidFlexViewWrapper.cpp \
|
||||
AndroidGraphicBuffer.cpp \
|
||||
AndroidBackingSurface.cpp \
|
||||
AndroidJNI.cpp \
|
||||
AndroidMediaLayer.cpp \
|
||||
nsWindow.cpp \
|
||||
@ -96,7 +97,7 @@ XPIDLSRCS = \
|
||||
|
||||
SHARED_LIBRARY_LIBS = ../xpwidgets/libxpwidgets_s.a
|
||||
|
||||
EXPORTS = AndroidBridge.h AndroidJavaWrappers.h AndroidFlexViewWrapper.h
|
||||
EXPORTS = AndroidBridge.h AndroidJavaWrappers.h AndroidFlexViewWrapper.h AndroidBackingSurface.h
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user