Back out 59d8d92f9f3c (bug 713803) for Android C1 permaorange

This commit is contained in:
Phil Ringnalda
2012-01-29 00:49:02 -08:00
parent 410c9dff0e
commit 562c4194c6
12 changed files with 392 additions and 723 deletions

View File

@@ -124,6 +124,8 @@ jmethodID AndroidGeckoSurfaceView::jGetSoftwareDrawBufferMethod = 0;
jmethodID AndroidGeckoSurfaceView::jGetSurfaceMethod = 0;
jmethodID AndroidGeckoSurfaceView::jGetHolderMethod = 0;
#define JNI() (AndroidBridge::JNI())
#define initInit() jclass jClass
// note that this also sets jClass
@@ -606,68 +608,43 @@ AndroidGeckoSurfaceView::BeginDrawing()
{
NS_ASSERTION(!isNull(), "BeginDrawing called on null surfaceview!");
JNIEnv *env = AndroidBridge::GetJNIEnv();
if (!env)
return 0;
return env->CallIntMethod(wrapped_obj, jBeginDrawingMethod);
return JNI()->CallIntMethod(wrapped_obj, jBeginDrawingMethod);
}
void
AndroidGeckoSurfaceView::EndDrawing()
{
JNIEnv *env = AndroidBridge::GetJNIEnv();
if (!env)
return;
env->CallVoidMethod(wrapped_obj, jEndDrawingMethod);
JNI()->CallVoidMethod(wrapped_obj, jEndDrawingMethod);
}
void
AndroidGeckoSurfaceView::Draw2D(jobject bitmap, int width, int height)
{
JNIEnv *env = AndroidBridge::GetJNIEnv();
if (!env)
return;
env->CallVoidMethod(wrapped_obj, jDraw2DBitmapMethod, bitmap, width, height);
JNI()->CallVoidMethod(wrapped_obj, jDraw2DBitmapMethod, bitmap, width, height);
}
void
AndroidGeckoSurfaceView::Draw2D(jobject buffer, int stride)
{
JNIEnv *env = AndroidBridge::GetJNIEnv();
if (!env)
return;
env->CallVoidMethod(wrapped_obj, jDraw2DBufferMethod, buffer, stride);
JNI()->CallVoidMethod(wrapped_obj, jDraw2DBufferMethod, buffer, stride);
}
jobject
AndroidGeckoSoftwareLayerClient::LockBuffer()
{
NS_ASSERTION(!isNull(), "LockBuffer() called on null software layer client!");
JNIEnv *env = AndroidBridge::GetJNIEnv();
if (!env)
return nsnull;
AndroidBridge::AutoLocalJNIFrame(env, 1);
return env->CallObjectMethod(wrapped_obj, jLockBufferMethod);
AndroidBridge::AutoLocalJNIFrame(1);
return JNI()->CallObjectMethod(wrapped_obj, jLockBufferMethod);
}
unsigned char *
AndroidGeckoSoftwareLayerClient::LockBufferBits()
{
JNIEnv *env = AndroidBridge::GetJNIEnv();
if (!env)
return nsnull;
AndroidBridge::AutoLocalJNIFrame(env, 1);
AndroidBridge::AutoLocalJNIFrame(1);
jobject bufferObject = LockBuffer();
if (bufferObject != nsnull)
return reinterpret_cast<unsigned char *>(env->GetDirectBufferAddress(bufferObject));
return reinterpret_cast<unsigned char *>(JNI()->GetDirectBufferAddress(bufferObject));
return nsnull;
}
@@ -676,22 +653,14 @@ void
AndroidGeckoSoftwareLayerClient::UnlockBuffer()
{
NS_ASSERTION(!isNull(), "UnlockBuffer() called on null software layer client!");
JNIEnv *env = AndroidBridge::GetJNIEnv();
if (!env)
return;
AndroidBridge::AutoLocalJNIFrame(env, 1);
env->CallVoidMethod(wrapped_obj, jUnlockBufferMethod);
AndroidBridge::AutoLocalJNIFrame(1);
JNI()->CallVoidMethod(wrapped_obj, jUnlockBufferMethod);
}
void
AndroidGeckoSoftwareLayerClient::GetRenderOffset(nsIntPoint &aOffset)
{
JNIEnv *env = AndroidBridge::GetJNIEnv();
if (!env)
return;
AndroidPoint offset(env, env->CallObjectMethod(wrapped_obj, jGetRenderOffsetMethod));
AndroidPoint offset(JNI(), JNI()->CallObjectMethod(wrapped_obj, jGetRenderOffsetMethod));
aOffset.x = offset.X();
aOffset.y = offset.Y();
}
@@ -700,65 +669,41 @@ bool
AndroidGeckoSoftwareLayerClient::BeginDrawing(int aWidth, int aHeight, int aTileWidth, int aTileHeight, const nsAString &aMetadata, bool aHasDirectTexture)
{
NS_ASSERTION(!isNull(), "BeginDrawing() called on null software layer client!");
JNIEnv *env = AndroidBridge::GetJNIEnv();
if (!env)
return false;
AndroidBridge::AutoLocalJNIFrame(env, 1);
jstring jMetadata = env->NewString(nsPromiseFlatString(aMetadata).get(), aMetadata.Length());
return env->CallBooleanMethod(wrapped_obj, jBeginDrawingMethod, aWidth, aHeight, aTileWidth, aTileHeight, jMetadata, aHasDirectTexture);
AndroidBridge::AutoLocalJNIFrame(1);
jstring jMetadata = JNI()->NewString(nsPromiseFlatString(aMetadata).get(), aMetadata.Length());
return JNI()->CallBooleanMethod(wrapped_obj, jBeginDrawingMethod, aWidth, aHeight, aTileWidth, aTileHeight, jMetadata, aHasDirectTexture);
}
void
AndroidGeckoSoftwareLayerClient::EndDrawing(const nsIntRect &aRect)
{
NS_ASSERTION(!isNull(), "EndDrawing() called on null software layer client!");
JNIEnv *env = AndroidBridge::GetJNIEnv();
if (!env)
return;
AndroidBridge::AutoLocalJNIFrame(env, 1);
return env->CallVoidMethod(wrapped_obj, jEndDrawingMethod, aRect.x, aRect.y, aRect.width, aRect.height);
AndroidBridge::AutoLocalJNIFrame(1);
return JNI()->CallVoidMethod(wrapped_obj, jEndDrawingMethod, aRect.x, aRect.y, aRect.width, aRect.height);
}
jobject
AndroidGeckoSurfaceView::GetSoftwareDrawBitmap()
{
JNIEnv *env = AndroidBridge::GetJNIEnv();
if (!env)
return nsnull;
return env->CallObjectMethod(wrapped_obj, jGetSoftwareDrawBitmapMethod);
return JNI()->CallObjectMethod(wrapped_obj, jGetSoftwareDrawBitmapMethod);
}
jobject
AndroidGeckoSurfaceView::GetSoftwareDrawBuffer()
{
JNIEnv *env = AndroidBridge::GetJNIEnv();
if (!env)
return nsnull;
return env->CallObjectMethod(wrapped_obj, jGetSoftwareDrawBufferMethod);
return JNI()->CallObjectMethod(wrapped_obj, jGetSoftwareDrawBufferMethod);
}
jobject
AndroidGeckoSurfaceView::GetSurface()
{
JNIEnv *env = AndroidBridge::GetJNIEnv();
if (!env)
return nsnull;
return env->CallObjectMethod(wrapped_obj, jGetSurfaceMethod);
return JNI()->CallObjectMethod(wrapped_obj, jGetSurfaceMethod);
}
jobject
AndroidGeckoSurfaceView::GetSurfaceHolder()
{
JNIEnv *env = AndroidBridge::GetJNIEnv();
if (!env)
return nsnull;
return env->CallObjectMethod(wrapped_obj, jGetHolderMethod);
return JNI()->CallObjectMethod(wrapped_obj, jGetHolderMethod);
}
void
@@ -789,7 +734,7 @@ nsJNIString::nsJNIString(jstring jstr, JNIEnv *jenv)
}
JNIEnv *jni = jenv;
if (!jni)
jni = AndroidBridge::GetJNIEnv();
jni = JNI();
const jchar* jCharPtr = jni->GetStringChars(jstr, NULL);
if (!jCharPtr) {