Bug 725095 - Address review comments in the widget code. r=blassey

- Rip out a lot of unused code in AndroidFlexViewWrapper.*
- Simplify the GetViewTransform JNI code
- Move the references to CompositorParent and CompositorThread from AndroidBridge to nsWindow
- Remove a bunch of logging and add some assertions and comments
This commit is contained in:
Kartikaya Gupta 2012-03-14 00:15:11 -04:00
parent fb9607dbb7
commit e15c94493b
11 changed files with 101 additions and 324 deletions

View File

@ -1066,7 +1066,7 @@ void
AndroidBridge::RegisterCompositor()
{
ALOG_BRIDGE("AndroidBridge::RegisterCompositor");
JNIEnv *env = GetJNIForThread();
JNIEnv *env = GetJNIForThread(); // called on the compositor thread
if (!env)
return;
@ -1078,7 +1078,6 @@ AndroidBridge::RegisterCompositor()
sController.Acquire(env, glController);
sController.SetGLVersion(2);
__android_log_print(ANDROID_LOG_ERROR, "Gecko", "Registered Compositor");
}
EGLSurface
@ -1853,32 +1852,7 @@ void
AndroidBridge::SetCompositorParent(mozilla::layers::CompositorParent* aCompositorParent,
::base::Thread* aCompositorThread)
{
mCompositorParent = aCompositorParent;
mCompositorThread = aCompositorThread;
}
void
AndroidBridge::ScheduleComposite()
{
if (mCompositorParent) {
mCompositorParent->ScheduleRenderOnCompositorThread();
}
}
void
AndroidBridge::SchedulePauseComposition()
{
if (mCompositorParent) {
mCompositorParent->SchedulePauseOnCompositorThread();
}
}
void
AndroidBridge::ScheduleResumeComposition()
{
if (mCompositorParent) {
mCompositorParent->ScheduleResumeOnCompositorThread();
}
nsWindow::SetCompositorParent(aCompositorParent, aCompositorThread);
}
void
@ -1901,23 +1875,18 @@ AndroidBridge::SetPageSize(float aZoom, float aPageWidth, float aPageHeight)
client->SetPageSize(aZoom, aPageWidth, aPageHeight);
}
void
AndroidBridge::SetViewTransformGetter(AndroidViewTransformGetter& aViewTransformGetter)
{
mViewTransformGetter = &aViewTransformGetter;
}
void
AndroidBridge::GetViewTransform(nsIntPoint& aScrollOffset, float& aScaleX, float& aScaleY)
{
if (mViewTransformGetter) {
(*mViewTransformGetter)(aScrollOffset, aScaleX, aScaleY);
}
AndroidGeckoLayerClient *client = mLayerClient;
if (!client)
return;
client->GetViewTransform(aScrollOffset, aScaleX, aScaleY);
}
AndroidBridge::AndroidBridge()
: mLayerClient(NULL)
, mViewTransformGetter(NULL)
{
}

View File

@ -406,12 +406,8 @@ public:
void SetCompositorParent(mozilla::layers::CompositorParent* aCompositorParent,
base::Thread* aCompositorThread);
void ScheduleComposite();
void SchedulePauseComposition();
void ScheduleResumeComposition();
void SetFirstPaintViewport(float aOffsetX, float aOffsetY, float aZoom, float aPageWidth, float aPageHeight);
void SetPageSize(float aZoom, float aPageWidth, float aPageHeight);
void SetViewTransformGetter(AndroidViewTransformGetter& aViewTransformGetter);
void GetViewTransform(nsIntPoint& aScrollOffset, float& aScaleX, float& aScaleY);
jobject CreateSurface();
@ -434,10 +430,6 @@ protected:
AndroidGeckoLayerClient *mLayerClient;
nsRefPtr<mozilla::layers::CompositorParent> mCompositorParent;
base::Thread *mCompositorThread;
AndroidViewTransformGetter *mViewTransformGetter;
// the GeckoAppShell java class
jclass mGeckoAppShellClass;

View File

@ -36,195 +36,61 @@
* ***** END LICENSE BLOCK ***** */
#include "AndroidFlexViewWrapper.h"
#include "nsDebug.h"
#define ASSERT_THREAD() \
NS_ASSERTION((void*)pthread_self() == mThread, "Something is calling AndroidGLController from the wrong thread!")
static AndroidGLController sController;
static const char *sEGLDisplayClassName = "com/google/android/gles_jni/EGLDisplayImpl";
static const char *sEGLDisplayPointerFieldName = "mEGLDisplay";
static jfieldID jEGLDisplayPointerField = 0;
static const char *sEGLConfigClassName = "com/google/android/gles_jni/EGLConfigImpl";
static const char *sEGLConfigPointerFieldName = "mEGLConfig";
static jfieldID jEGLConfigPointerField = 0;
static const char *sEGLContextClassName = "com/google/android/gles_jni/EGLContextImpl";
static const char *sEGLContextPointerFieldName = "mEGLContext";
static jfieldID jEGLContextPointerField = 0;
static const char *sEGLSurfaceClassName = "com/google/android/gles_jni/EGLSurfaceImpl";
static const char *sEGLSurfacePointerFieldName = "mEGLSurface";
static jfieldID jEGLSurfacePointerField = 0;
void AndroidEGLObject::Init(JNIEnv* aJEnv) {
jclass jClass;
jClass = reinterpret_cast<jclass>
(aJEnv->NewGlobalRef(aJEnv->FindClass(sEGLDisplayClassName)));
jEGLDisplayPointerField = aJEnv->GetFieldID(jClass, sEGLDisplayPointerFieldName, "I");
jClass = reinterpret_cast<jclass>
(aJEnv->NewGlobalRef(aJEnv->FindClass(sEGLConfigClassName)));
jEGLConfigPointerField = aJEnv->GetFieldID(jClass, sEGLConfigPointerFieldName, "I");
jClass = reinterpret_cast<jclass>
(aJEnv->NewGlobalRef(aJEnv->FindClass(sEGLContextClassName)));
jEGLContextPointerField = aJEnv->GetFieldID(jClass, sEGLContextPointerFieldName, "I");
jClass = reinterpret_cast<jclass>
(aJEnv->NewGlobalRef(aJEnv->FindClass(sEGLSurfaceClassName)));
jEGLSurfacePointerField = aJEnv->GetFieldID(jClass, sEGLSurfacePointerFieldName, "I");
(aJEnv->NewGlobalRef(aJEnv->FindClass("com/google/android/gles_jni/EGLSurfaceImpl")));
jEGLSurfacePointerField = aJEnv->GetFieldID(jClass, "mEGLSurface", "I");
}
jmethodID AndroidGLController::jSetGLVersionMethod = 0;
jmethodID AndroidGLController::jInitGLContextMethod = 0;
jmethodID AndroidGLController::jDisposeGLContextMethod = 0;
jmethodID AndroidGLController::jGetEGLDisplayMethod = 0;
jmethodID AndroidGLController::jGetEGLConfigMethod = 0;
jmethodID AndroidGLController::jGetEGLContextMethod = 0;
jmethodID AndroidGLController::jGetEGLSurfaceMethod = 0;
jmethodID AndroidGLController::jHasSurfaceMethod = 0;
jmethodID AndroidGLController::jSwapBuffersMethod = 0;
jmethodID AndroidGLController::jCheckForLostContextMethod = 0;
jmethodID AndroidGLController::jWaitForValidSurfaceMethod = 0;
jmethodID AndroidGLController::jGetWidthMethod = 0;
jmethodID AndroidGLController::jGetHeightMethod = 0;
jmethodID AndroidGLController::jProvideEGLSurfaceMethod = 0;
void
AndroidGLController::Init(JNIEnv *aJEnv)
{
const char *className = "org/mozilla/gecko/gfx/GLController";
jclass jClass = reinterpret_cast<jclass>(aJEnv->NewGlobalRef(aJEnv->FindClass(className)));
jclass jClass = reinterpret_cast<jclass>(aJEnv->NewGlobalRef(aJEnv->FindClass("org/mozilla/gecko/gfx/GLController")));
jSetGLVersionMethod = aJEnv->GetMethodID(jClass, "setGLVersion", "(I)V");
jInitGLContextMethod = aJEnv->GetMethodID(jClass, "initGLContext", "()V");
jDisposeGLContextMethod = aJEnv->GetMethodID(jClass, "disposeGLContext", "()V");
jGetEGLDisplayMethod = aJEnv->GetMethodID(jClass, "getEGLDisplay",
"()Ljavax/microedition/khronos/egl/EGLDisplay;");
jGetEGLConfigMethod = aJEnv->GetMethodID(jClass, "getEGLConfig",
"()Ljavax/microedition/khronos/egl/EGLConfig;");
jGetEGLContextMethod = aJEnv->GetMethodID(jClass, "getEGLContext",
"()Ljavax/microedition/khronos/egl/EGLContext;");
jGetEGLSurfaceMethod = aJEnv->GetMethodID(jClass, "getEGLSurface",
"()Ljavax/microedition/khronos/egl/EGLSurface;");
jProvideEGLSurfaceMethod = aJEnv->GetMethodID(jClass, "provideEGLSurface",
"()Ljavax/microedition/khronos/egl/EGLSurface;");
jHasSurfaceMethod = aJEnv->GetMethodID(jClass, "hasSurface", "()Z");
jSwapBuffersMethod = aJEnv->GetMethodID(jClass, "swapBuffers", "()Z");
jCheckForLostContextMethod = aJEnv->GetMethodID(jClass, "checkForLostContext", "()Z");
jWaitForValidSurfaceMethod = aJEnv->GetMethodID(jClass, "waitForValidSurface", "()V");
jGetWidthMethod = aJEnv->GetMethodID(jClass, "getWidth", "()I");
jGetHeightMethod = aJEnv->GetMethodID(jClass, "getHeight", "()I");
}
void
AndroidGLController::Acquire(JNIEnv* aJEnv, jobject aJObj)
{
mJEnv = aJEnv;
mThread = (void*)pthread_self();
mJObj = aJEnv->NewGlobalRef(aJObj);
}
void
AndroidGLController::Acquire(JNIEnv* aJEnv)
{
mJEnv = aJEnv;
}
void
AndroidGLController::Release()
{
if (mJObj) {
mJEnv->DeleteGlobalRef(mJObj);
mJObj = NULL;
}
mJEnv = NULL;
}
void
AndroidGLController::SetGLVersion(int aVersion)
{
ASSERT_THREAD();
mJEnv->CallVoidMethod(mJObj, jSetGLVersionMethod, aVersion);
}
void
AndroidGLController::InitGLContext()
{
mJEnv->CallVoidMethod(mJObj, jInitGLContextMethod);
}
void
AndroidGLController::DisposeGLContext()
{
mJEnv->CallVoidMethod(mJObj, jDisposeGLContextMethod);
}
EGLDisplay
AndroidGLController::GetEGLDisplay()
{
jobject jObj = mJEnv->CallObjectMethod(mJObj, jGetEGLDisplayMethod);
return reinterpret_cast<EGLDisplay>(mJEnv->GetIntField(jObj, jEGLDisplayPointerField));
}
EGLConfig
AndroidGLController::GetEGLConfig()
{
jobject jObj = mJEnv->CallObjectMethod(mJObj, jGetEGLConfigMethod);
return reinterpret_cast<EGLConfig>(mJEnv->GetIntField(jObj, jEGLConfigPointerField));
}
EGLContext
AndroidGLController::GetEGLContext()
{
jobject jObj = mJEnv->CallObjectMethod(mJObj, jGetEGLContextMethod);
return reinterpret_cast<EGLContext>(mJEnv->GetIntField(jObj, jEGLContextPointerField));
}
EGLSurface
AndroidGLController::GetEGLSurface()
{
jobject jObj = mJEnv->CallObjectMethod(mJObj, jGetEGLSurfaceMethod);
return reinterpret_cast<EGLSurface>(mJEnv->GetIntField(jObj, jEGLSurfacePointerField));
}
EGLSurface
AndroidGLController::ProvideEGLSurface()
{
ASSERT_THREAD();
jobject jObj = mJEnv->CallObjectMethod(mJObj, jProvideEGLSurfaceMethod);
return reinterpret_cast<EGLSurface>(mJEnv->GetIntField(jObj, jEGLSurfacePointerField));
}
bool
AndroidGLController::HasSurface()
{
return mJEnv->CallBooleanMethod(mJObj, jHasSurfaceMethod);
}
bool
AndroidGLController::SwapBuffers()
{
return mJEnv->CallBooleanMethod(mJObj, jSwapBuffersMethod);
}
bool
AndroidGLController::CheckForLostContext()
{
return mJEnv->CallBooleanMethod(mJObj, jCheckForLostContextMethod);
}
void
AndroidGLController::WaitForValidSurface()
{
ASSERT_THREAD();
mJEnv->CallVoidMethod(mJObj, jWaitForValidSurfaceMethod);
}
int
AndroidGLController::GetWidth()
{
return mJEnv->CallIntMethod(mJObj, jGetWidthMethod);
}
int
AndroidGLController::GetHeight()
{
return mJEnv->CallIntMethod(mJObj, jGetHeightMethod);
}

View File

@ -39,37 +39,16 @@
#define AndroidFlexViewWrapper_h__
#include <jni.h>
//#include <GLES/gl.h>
//#include <GLES/glext.h>
#include <cassert>
#include <cstdlib>
#include <pthread.h>
#include <android/log.h>
typedef void *NativeType;
class AndroidEGLObject {
public:
AndroidEGLObject(JNIEnv* aJEnv, jobject aJObj)
: mPtr(reinterpret_cast<NativeType>(aJEnv->GetIntField(aJObj, jPointerField))) {}
static void Init(JNIEnv* aJEnv);
NativeType const& operator*() const {
return mPtr;
}
private:
static jfieldID jPointerField;
static const char* sClassName;
static const char* sPointerFieldName;
const NativeType mPtr;
};
typedef void *EGLConfig;
typedef void *EGLContext;
typedef void *EGLDisplay;
typedef void *EGLSurface;
class AndroidGLController {
@ -77,41 +56,18 @@ public:
static void Init(JNIEnv* aJEnv);
void Acquire(JNIEnv *aJEnv, jobject aJObj);
void Acquire(JNIEnv *aJEnv);
void Release();
void SetGLVersion(int aVersion);
void InitGLContext();
void DisposeGLContext();
EGLDisplay GetEGLDisplay();
EGLConfig GetEGLConfig();
EGLContext GetEGLContext();
EGLSurface GetEGLSurface();
EGLSurface ProvideEGLSurface();
bool HasSurface();
bool SwapBuffers();
bool CheckForLostContext();
void WaitForValidSurface();
int GetWidth();
int GetHeight();
private:
static jmethodID jSetGLVersionMethod;
static jmethodID jInitGLContextMethod;
static jmethodID jDisposeGLContextMethod;
static jmethodID jGetEGLDisplayMethod;
static jmethodID jGetEGLConfigMethod;
static jmethodID jGetEGLContextMethod;
static jmethodID jGetEGLSurfaceMethod;
static jmethodID jHasSurfaceMethod;
static jmethodID jSwapBuffersMethod;
static jmethodID jCheckForLostContextMethod;
static jmethodID jWaitForValidSurfaceMethod;
static jmethodID jGetWidthMethod;
static jmethodID jGetHeightMethod;
static jmethodID jProvideEGLSurfaceMethod;
// the JNIEnv for the compositor thread
JNIEnv *mJEnv;
void *mThread;
jobject mJObj;
};

View File

@ -47,6 +47,8 @@
#define EGL_NATIVE_BUFFER_ANDROID 0x3140
#define EGL_IMAGE_PRESERVED_KHR 0x30D2
typedef void *EGLContext;
typedef void *EGLDisplay;
typedef PRUint32 EGLenum;
typedef PRInt32 EGLint;
typedef PRUint32 EGLBoolean;

View File

@ -894,19 +894,19 @@ Java_org_mozilla_gecko_GeckoAppShell_notifyReadingMessageListFailed(JNIEnv* jenv
NS_EXPORT void JNICALL
Java_org_mozilla_gecko_GeckoAppShell_scheduleComposite(JNIEnv*, jclass)
{
AndroidBridge::Bridge()->ScheduleComposite();
nsWindow::ScheduleComposite();
}
NS_EXPORT void JNICALL
Java_org_mozilla_gecko_GeckoAppShell_schedulePauseComposition(JNIEnv*, jclass)
{
AndroidBridge::Bridge()->SchedulePauseComposition();
nsWindow::SchedulePauseComposition();
}
NS_EXPORT void JNICALL
Java_org_mozilla_gecko_GeckoAppShell_scheduleResumeComposition(JNIEnv*, jclass)
{
AndroidBridge::Bridge()->ScheduleResumeComposition();
nsWindow::ScheduleResumeComposition();
}
#endif

View File

@ -660,9 +660,6 @@ AndroidGeckoLayerClient::Init(jobject jobj)
{
NS_ASSERTION(wrapped_obj == nsnull, "Init called on non-null wrapped_obj!");
wrapped_obj = jobj;
// Register the view transform getter.
AndroidBridge::Bridge()->SetViewTransformGetter(mViewTransformGetter);
}
void
@ -773,7 +770,7 @@ void
AndroidGeckoLayerClient::SetFirstPaintViewport(float aOffsetX, float aOffsetY, float aZoom, float aPageWidth, float aPageHeight)
{
NS_ASSERTION(!isNull(), "SetFirstPaintViewport called on null layer client!");
JNIEnv *env = GetJNIForThread();
JNIEnv *env = GetJNIForThread(); // this is called on the compositor thread
if (!env)
return;
@ -785,7 +782,7 @@ void
AndroidGeckoLayerClient::SetPageSize(float aZoom, float aPageWidth, float aPageHeight)
{
NS_ASSERTION(!isNull(), "SetPageSize called on null layer client!");
JNIEnv *env = GetJNIForThread();
JNIEnv *env = GetJNIForThread(); // this is called on the compositor thread
if (!env)
return;
@ -793,6 +790,25 @@ AndroidGeckoLayerClient::SetPageSize(float aZoom, float aPageWidth, float aPageH
return env->CallVoidMethod(wrapped_obj, jSetPageSize, aZoom, aPageWidth, aPageHeight);
}
void
AndroidGeckoLayerClient::GetViewTransform(nsIntPoint& aScrollOffset, float& aScaleX, float& aScaleY)
{
NS_ASSERTION(!isNull(), "GetViewTransform called on null layer client!");
JNIEnv *env = GetJNIForThread(); // this is called on the compositor thread
if (!env)
return;
AndroidViewTransform viewTransform;
AndroidBridge::AutoLocalJNIFrame jniFrame(env);
jobject viewTransformJObj = env->CallObjectMethod(wrapped_obj, jGetViewTransformMethod);
NS_ABORT_IF_FALSE(viewTransformJObj, "No view transform object!");
viewTransform.Init(viewTransformJObj);
aScrollOffset = nsIntPoint(viewTransform.GetX(), viewTransform.GetY());
aScaleX = aScaleY = viewTransform.GetScale();
}
jobject
AndroidGeckoSurfaceView::GetSoftwareDrawBitmap()
{
@ -829,20 +845,6 @@ AndroidGeckoSurfaceView::GetSurfaceHolder()
return GetJNIForThread()->CallObjectMethod(wrapped_obj, jGetHolderMethod);
}
void
AndroidGeckoLayerClient::GetViewTransform(AndroidViewTransform& aViewTransform)
{
JNIEnv *env = GetJNIForThread();
NS_ABORT_IF_FALSE(env, "No JNI environment at GetViewTransform()!");
if (!env) {
return;
}
jobject viewTransformJObj = env->CallObjectMethod(wrapped_obj, jGetViewTransformMethod);
NS_ABORT_IF_FALSE(viewTransformJObj, "No view transform object!");
aViewTransform.Init(viewTransformJObj);
}
void
AndroidGeckoLayerClient::CreateFrame(AndroidLayerRendererFrame& aFrame)
{
@ -956,19 +958,6 @@ AndroidViewTransform::GetScale()
return env->GetFloatField(wrapped_obj, jScaleField);
}
void
AndroidGeckoLayerClientViewTransformGetter::operator()(nsIntPoint& aScrollOffset, float& aScaleX,
float& aScaleY)
{
AndroidViewTransform viewTransform;
AndroidBridge::AutoLocalJNIFrame jniFrame(GetJNIForThread());
mLayerClient.GetViewTransform(viewTransform);
aScrollOffset = nsIntPoint(viewTransform.GetX(), viewTransform.GetY());
aScaleX = aScaleY = viewTransform.GetScale();
}
void
AndroidRect::Init(JNIEnv *jenv, jobject jobj)
{

View File

@ -153,25 +153,6 @@ protected:
static jfieldID jTopField;
};
/** A callback that retrieves the view transform. */
class AndroidViewTransformGetter
{
public:
virtual void operator()(nsIntPoint& aScrollOffset, float& aScaleX, float& aScaleY) = 0;
};
class AndroidGeckoLayerClientViewTransformGetter : public AndroidViewTransformGetter {
public:
AndroidGeckoLayerClientViewTransformGetter(AndroidGeckoLayerClient& aLayerClient)
: mLayerClient(aLayerClient) {}
virtual void operator()(nsIntPoint& aScrollOffset, float& aScaleX, float& aScaleY);
private:
AndroidGeckoLayerClient& mLayerClient;
};
class AndroidViewTransform : public WrappedJavaObject {
public:
static void InitViewTransformClass(JNIEnv *jEnv);
@ -218,17 +199,14 @@ public:
void Init(jobject jobj);
AndroidGeckoLayerClient()
: mViewTransformGetter(*this) {}
AndroidGeckoLayerClient(jobject jobj)
: mViewTransformGetter(*this) { Init(jobj); }
AndroidGeckoLayerClient() {}
AndroidGeckoLayerClient(jobject jobj) { Init(jobj); }
bool BeginDrawing(int aWidth, int aHeight, const nsAString &aMetadata);
void EndDrawing();
void SetFirstPaintViewport(float aOffsetX, float aOffsetY, float aZoom, float aPageWidth, float aPageHeight);
void SetPageSize(float aZoom, float aPageWidth, float aPageHeight);
void GetViewTransform(AndroidViewTransform& aViewTransform);
void GetViewTransform(nsIntPoint& aScrollOffset, float& aScaleX, float& aScaleY);
void CreateFrame(AndroidLayerRendererFrame& aFrame);
void ActivateProgram();
void DeactivateProgram();
@ -243,8 +221,6 @@ protected:
static jmethodID jCreateFrameMethod;
static jmethodID jActivateProgramMethod;
static jmethodID jDeactivateProgramMethod;
AndroidGeckoLayerClientViewTransformGetter mViewTransformGetter;
};
class AndroidGeckoSurfaceView : public WrappedJavaObject

View File

@ -464,7 +464,6 @@ nsAppShell::ProcessNextNativeEvent(bool mayWait)
break;
}
case AndroidGeckoEvent::VIEWPORT:
case AndroidGeckoEvent::BROADCAST: {

View File

@ -96,6 +96,8 @@ bool nsWindow::sAccessibilityEnabled = false;
#endif
#ifdef MOZ_JAVA_COMPOSITOR
#include "mozilla/layers/CompositorChild.h"
#include "mozilla/layers/CompositorParent.h"
#include "mozilla/Mutex.h"
#include "nsThreadUtils.h"
#endif
@ -765,9 +767,6 @@ nsWindow::GetLayerManager(PLayersChild*, LayersBackend, LayerManagerPersistence,
nsWindow *topWindow = TopWindow();
__android_log_print(ANDROID_LOG_ERROR, "Gecko", "### nsWindow::GetLayerManager this=%p "
"topWindow=%p", this, topWindow);
if (!topWindow) {
printf_stderr(" -- no topwindow\n");
mLayerManager = CreateBasicLayerManager();
@ -1138,8 +1137,6 @@ nsWindow::OnDraw(AndroidGeckoEvent *ae)
#ifdef MOZ_JAVA_COMPOSITOR
// We haven't been given a window-size yet, so do nothing
if (gAndroidBounds.width <= 0 || gAndroidBounds.height <= 0) {
__android_log_print(ANDROID_LOG_ERROR, "Gecko",
"### No window size yet -- skipping draw!");
return;
}
@ -1157,7 +1154,6 @@ nsWindow::OnDraw(AndroidGeckoEvent *ae)
metadataProvider->PaintingSuppressed(&paintingSuppressed);
}
if (paintingSuppressed) {
__android_log_print(ANDROID_LOG_ERROR, "Gecko", "### Painting suppressed!");
return;
}
layers::renderTraceEventEnd("Check supress", "424242");
@ -1169,13 +1165,6 @@ nsWindow::OnDraw(AndroidGeckoEvent *ae)
}
layers::renderTraceEventEnd("Get Drawable", "424343");
#if 0
// BEGIN HACK: gl layers
nsPaintEvent event(true, NS_PAINT, this);
nsIntRect tileRect(0, 0, gAndroidBounds.width, gAndroidBounds.height);
event.region = tileRect;
#endif
layers::renderTraceEventStart("Get surface", "424545");
static unsigned char bits2[32 * 32 * 2];
nsRefPtr<gfxImageSurface> targetSurface =
@ -1183,23 +1172,11 @@ nsWindow::OnDraw(AndroidGeckoEvent *ae)
gfxASurface::ImageFormatRGB16_565);
layers::renderTraceEventEnd("Get surface", "424545");
#if 0
nsRefPtr<gfxContext> ctx = new gfxContext(targetSurface);
AutoLayerManagerSetup setupLayerManager(this, ctx, BasicLayerManager::BUFFER_NONE);
nsEventStatus status;
status = DispatchEvent(&event);
return;
// END HACK: gl layers
#endif
layers::renderTraceEventStart("Check Bridge", "434444");
nsIntRect dirtyRect = ae->Rect().Intersect(nsIntRect(0, 0, gAndroidBounds.width, gAndroidBounds.height));
AndroidGeckoLayerClient &client = AndroidBridge::Bridge()->GetLayerClient();
if (!client.BeginDrawing(gAndroidBounds.width, gAndroidBounds.height, metadata)) {
__android_log_print(ANDROID_LOG_ERROR, "Gecko", "### BeginDrawing returned false!");
return;
}
layers::renderTraceEventEnd("Check Bridge", "434444");
@ -2311,5 +2288,43 @@ nsWindow::DrawWindowOverlay(LayerManager* aManager, nsIntRect aRect) {
mLayerRendererFrame.Dispose();
}
// off-main-thread compositor fields and functions
nsRefPtr<mozilla::layers::CompositorParent> nsWindow::sCompositorParent = 0;
base::Thread * nsWindow::sCompositorThread = 0;
void
nsWindow::SetCompositorParent(mozilla::layers::CompositorParent* aCompositorParent,
::base::Thread* aCompositorThread)
{
sCompositorParent = aCompositorParent;
sCompositorThread = aCompositorThread;
}
void
nsWindow::ScheduleComposite()
{
if (sCompositorParent) {
sCompositorParent->ScheduleRenderOnCompositorThread();
}
}
void
nsWindow::SchedulePauseComposition()
{
if (sCompositorParent) {
sCompositorParent->SchedulePauseOnCompositorThread();
}
}
void
nsWindow::ScheduleResumeComposition()
{
if (sCompositorParent) {
sCompositorParent->ScheduleResumeOnCompositorThread();
}
}
#endif

View File

@ -58,6 +58,10 @@ class nsIdleService;
namespace mozilla {
class AndroidGeckoEvent;
class AndroidKeyEvent;
namespace layers {
class CompositorParent;
}
}
class nsWindow :
@ -183,6 +187,12 @@ public:
#ifdef MOZ_JAVA_COMPOSITOR
virtual void DrawWindowUnderlay(LayerManager* aManager, nsIntRect aRect);
virtual void DrawWindowOverlay(LayerManager* aManager, nsIntRect aRect);
static void SetCompositorParent(mozilla::layers::CompositorParent* aCompositorParent,
::base::Thread* aCompositorThread);
static void ScheduleComposite();
static void SchedulePauseComposition();
static void ScheduleResumeComposition();
#endif
protected:
@ -253,6 +263,9 @@ private:
#ifdef MOZ_JAVA_COMPOSITOR
mozilla::AndroidLayerRendererFrame mLayerRendererFrame;
static nsRefPtr<mozilla::layers::CompositorParent> sCompositorParent;
static base::Thread *sCompositorThread;
#endif
};