Move registerCxxCompositor to FlexView

This commit is contained in:
Benoit Girard 2012-02-01 14:15:52 -05:00
Родитель 75e154812c
Коммит 4e100d2bce
6 изменённых файлов: 50 добавлений и 20 удалений

Просмотреть файл

@ -133,7 +133,6 @@ FENNEC_JAVA_FILES = \
gfx/TileLayer.java \
gfx/ViewportMetrics.java \
gfx/WidgetTileLayer.java \
gfx/layers/OGLSurfaceView.java \
ui/Axis.java \
ui/PanZoomController.java \
ui/SimpleScaleGestureDetector.java \

Просмотреть файл

@ -153,6 +153,40 @@ public class FlexibleGLSurfaceView extends SurfaceView implements SurfaceHolder.
}
}
// Called from the compositor thread
public static GLController registerCxxCompositor() {
System.out.println("register layer comp");
/*
synchronized (FlexibleGLSurfaceView.class) {
// Wait for the layer controller if by some miracle
// gecko beats the java thread here.
while (mLayerController == null) {
try {
OGLSurfaceView.class.wait();
} catch (InterruptedException e) {}
}
final LayerController controller = mLayerController;
GeckoApp.mAppContext.runOnUiThread(new Runnable() {
public void run() {
synchronized (OGLSurfaceView.class) {
OGLSurfaceView surfaceView =
new OGLSurfaceView(controller.getContext(), controller);
OGLSurfaceView.class.notifyAll();
}
}
});
// Wait for the compositor to be setup on the
// Java UI thread.
try {
OGLSurfaceView.class.wait();
} catch (InterruptedException e) {}
}
*/
return null;
}
public static class FlexibleGLSurfaceViewException extends RuntimeException {
public static final long serialVersionUID = 1L;

Просмотреть файл

@ -174,7 +174,7 @@ AndroidBridge::Init(JNIEnv *jEnv,
jEGLConfigImplClass = (jclass) jEnv->NewGlobalRef(jEnv->FindClass("com/google/android/gles_jni/EGLConfigImpl"));
jEGLDisplayImplClass = (jclass) jEnv->NewGlobalRef(jEnv->FindClass("com/google/android/gles_jni/EGLDisplayImpl"));
jOGLSurfaceView = (jclass) jEnv->NewGlobalRef(jEnv->FindClass("org/mozilla/gecko/gfx/layers/OGLSurfaceView"));
jFlexSurfaceView = (jclass) jEnv->NewGlobalRef(jEnv->FindClass("org/mozilla/gecko/gfx/FlexibleGLSurfaceView"));
InitAndroidJavaWrappers(jEnv);
@ -1024,11 +1024,14 @@ void
AndroidBridge::RegisterCompositor()
{
ALOG_BRIDGE("AndroidBridge::RegisterCompositor");
AutoLocalJNIFrame jniFrame(GetJNIForThread());
JNIEnv *env = GetJNIForThread();
if (!env)
return;
jmethodID registerCompositor = GetJNIForThread()->GetStaticMethodID(jOGLSurfaceView, "registerCompositor", "()V");
AutoLocalJNIFrame jniFrame(env, 3);
jmethodID registerCompositor = env->GetStaticMethodID(jFlexSurfaceView, "registerCxxCompositor", "()Lorg/mozilla/gecko/gfx/GLController;");
GetJNIForThread()->CallStaticVoidMethod(jOGLSurfaceView, registerCompositor);
jobject glController = env->CallStaticObjectMethod(jFlexSurfaceView, registerCompositor);
}
bool

Просмотреть файл

@ -486,7 +486,7 @@ protected:
jclass jEGLContextClass;
jclass jEGL10Class;
jclass jOGLSurfaceView;
jclass jFlexSurfaceView;
// calls we've dlopened from libjnigraphics.so
int (* AndroidBitmap_getInfo)(JNIEnv *env, jobject bitmap, void *info);

Просмотреть файл

@ -108,7 +108,6 @@ extern "C" {
NS_EXPORT void JNICALL Java_org_mozilla_gecko_GeckoAppShell_bindWidgetTexture(JNIEnv* jenv, jclass);
#endif
NS_EXPORT void JNICALL Java_org_mozilla_gfx_layers_OGLSurfaceView_setSurfaceView(JNIEnv *jenv, jclass, jobject sv);
}
@ -144,12 +143,6 @@ Java_org_mozilla_gecko_GeckoAppShell_setSurfaceView(JNIEnv *jenv, jclass, jobjec
AndroidBridge::Bridge()->SetSurfaceView(jenv->NewGlobalRef(obj));
}
NS_EXPORT void JNICALL
Java_org_mozilla_gfx_layers_OGLSurfaceView_setSurfaceView(JNIEnv *jenv, jclass, jobject obj)
{
AndroidBridge::Bridge()->SetSurfaceView(jenv->NewGlobalRef(obj));
}
NS_EXPORT void JNICALL
Java_org_mozilla_gecko_GeckoAppShell_setSoftwareLayerClient(JNIEnv *jenv, jclass, jobject obj)
{

Просмотреть файл

@ -770,6 +770,14 @@ nsWindow::GetLayerManager(PLayersChild*, LayersBackend, LayerManagerPersistence,
return mLayerManager;
}
bool useCompositor =
Preferences::GetBool("layers.offmainthreadcomposition.enabled", false);
if (useCompositor) {
CreateCompositor();
sFailedToCreateGLContext = !mLayerManager;
}
mUseAcceleratedRendering = GetShouldAccelerate();
if (!mUseAcceleratedRendering ||
@ -780,13 +788,6 @@ nsWindow::GetLayerManager(PLayersChild*, LayersBackend, LayerManagerPersistence,
return mLayerManager;
}
bool useCompositor =
Preferences::GetBool("layers.offmainthreadcomposition.enabled", false);
if (useCompositor) {
CreateCompositor();
}
if (!mLayerManager) {
if (!sGLContext) {
// the window we give doesn't matter here