diff --git a/mobile/android/base/GeckoApp.java b/mobile/android/base/GeckoApp.java index 647966726d9d..26e2e7e7e471 100644 --- a/mobile/android/base/GeckoApp.java +++ b/mobile/android/base/GeckoApp.java @@ -1198,7 +1198,7 @@ abstract public class GeckoApp getAndProcessThumbnailForTab(tab); if (Tabs.getInstance().isSelectedTab(tab)) { GeckoAppShell.sendEventToGecko(GeckoEvent.createStartPaintListentingEvent(tab.getId())); - GeckoAppShell.screenshotWholePage(tab); + ScreenshotHandler.screenshotWholePage(tab); } } diff --git a/mobile/android/base/GeckoAppShell.java b/mobile/android/base/GeckoAppShell.java index 9b10e470799c..2af1b29f8dae 100644 --- a/mobile/android/base/GeckoAppShell.java +++ b/mobile/android/base/GeckoAppShell.java @@ -592,14 +592,6 @@ public class GeckoAppShell mInputConnection.notifyIMEChange(text, start, end, newEnd); } - // Called by AndroidBridge using JNI - public static void notifyScreenShot(final ByteBuffer data, final int tabId, - final int left, final int top, - final int right, final int bottom, - final int bufferWidth, final int bufferHeight, final int token) { - ScreenshotHandler.notifyScreenShot(data, tabId, left, top, right, bottom, bufferWidth, bufferHeight, token); - } - private static CountDownLatch sGeckoPendingAcks = null; // Block the current thread until the Gecko event loop is caught up @@ -2266,15 +2258,6 @@ public class GeckoAppShell } } - public static void screenshotWholePage(Tab tab) { - ScreenshotHandler.screenshotWholePage(tab); - } - - // Called by AndroidBridge using JNI - public static void notifyPaintedRect(float top, float left, float bottom, float right) { - ScreenshotHandler.notifyPaintedRect(top, left, bottom, right); - } - public static void notifyWakeLockChanged(String topic, String state) { GeckoApp.mAppContext.notifyWakeLockChanged(topic, state); } diff --git a/mobile/android/base/ScreenshotHandler.java b/mobile/android/base/ScreenshotHandler.java index af485a8b4056..7431d8c2c913 100644 --- a/mobile/android/base/ScreenshotHandler.java +++ b/mobile/android/base/ScreenshotHandler.java @@ -23,7 +23,7 @@ import java.util.Iterator; import java.util.LinkedList; import java.util.Queue; -class ScreenshotHandler implements Runnable { +public final class ScreenshotHandler implements Runnable { public static final int SCREENSHOT_THUMBNAIL = 0; public static final int SCREENSHOT_CHECKERBOARD = 1; @@ -138,6 +138,7 @@ class ScreenshotHandler implements Runnable { return Math.max(Math.min(max, val), min); } + // Called from native code by JNI public static void notifyPaintedRect(float top, float left, float bottom, float right) { if (sDisableScreenshot) { return; @@ -264,6 +265,7 @@ class ScreenshotHandler implements Runnable { } } + // Called from native code by JNI public static void notifyScreenShot(final ByteBuffer data, final int tabId, final int left, final int top, final int right, final int bottom, diff --git a/mobile/android/base/gfx/GeckoLayerClient.java b/mobile/android/base/gfx/GeckoLayerClient.java index b3e4f8ab4a2f..5ecf5d049961 100644 --- a/mobile/android/base/gfx/GeckoLayerClient.java +++ b/mobile/android/base/gfx/GeckoLayerClient.java @@ -7,6 +7,7 @@ package org.mozilla.gecko.gfx; import org.mozilla.gecko.GeckoAppShell; import org.mozilla.gecko.GeckoEvent; +import org.mozilla.gecko.ScreenshotHandler; import org.mozilla.gecko.Tab; import org.mozilla.gecko.Tabs; import org.mozilla.gecko.ZoomConstraints; @@ -428,7 +429,7 @@ public class GeckoLayerClient DisplayPortCalculator.resetPageState(); mDrawTimingQueue.reset(); mView.getRenderer().resetCheckerboard(); - GeckoAppShell.screenshotWholePage(Tabs.getInstance().getSelectedTab()); + ScreenshotHandler.screenshotWholePage(Tabs.getInstance().getSelectedTab()); } /** This function is invoked by Gecko via JNI; be careful when modifying signature. diff --git a/widget/android/AndroidBridge.cpp b/widget/android/AndroidBridge.cpp index f88a987a5f14..2a86a834805c 100644 --- a/widget/android/AndroidBridge.cpp +++ b/widget/android/AndroidBridge.cpp @@ -101,7 +101,6 @@ AndroidBridge::Init(JNIEnv *jEnv, jNotifyIME = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "notifyIME", "(II)V"); jNotifyIMEEnabled = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "notifyIMEEnabled", "(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;Z)V"); jNotifyIMEChange = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "notifyIMEChange", "(Ljava/lang/String;III)V"); - jNotifyScreenShot = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "notifyScreenShot", "(Ljava/nio/ByteBuffer;IIIIIIII)V"); jAcknowledgeEventSync = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "acknowledgeEventSync", "()V"); jEnableLocation = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "enableLocation", "(Z)V"); @@ -151,7 +150,6 @@ AndroidBridge::Init(JNIEnv *jEnv, jEnableBatteryNotifications = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "enableBatteryNotifications", "()V"); jDisableBatteryNotifications = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "disableBatteryNotifications", "()V"); jGetCurrentBatteryInformation = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "getCurrentBatteryInformation", "()[D"); - jNotifyPaintedRect = jEnv->GetStaticMethodID(jGeckoAppShellClass, "notifyPaintedRect", "(FFFF)V"); jHandleGeckoMessage = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "handleGeckoMessage", "(Ljava/lang/String;)Ljava/lang/String;"); jCheckUriVisited = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "checkUriVisited", "(Ljava/lang/String;)V"); @@ -176,6 +174,10 @@ AndroidBridge::Init(JNIEnv *jEnv, jLockScreenOrientation = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "lockScreenOrientation", "(I)V"); jUnlockScreenOrientation = (jmethodID) jEnv->GetStaticMethodID(jGeckoAppShellClass, "unlockScreenOrientation", "()V"); + jScreenshotHandlerClass = (jclass) jEnv->NewGlobalRef(jEnv->FindClass("org/mozilla/gecko/ScreenshotHandler")); + jNotifyScreenShot = jEnv->GetStaticMethodID(jScreenshotHandlerClass, "notifyScreenShot", "(Ljava/nio/ByteBuffer;IIIIIIII)V"); + jNotifyPaintedRect = jEnv->GetStaticMethodID(jScreenshotHandlerClass, "notifyPaintedRect", "(FFFF)V"); + jEGLContextClass = (jclass) jEnv->NewGlobalRef(jEnv->FindClass("javax/microedition/khronos/egl/EGLContext")); jEGL10Class = (jclass) jEnv->NewGlobalRef(jEnv->FindClass("javax/microedition/khronos/egl/EGL10")); jEGLSurfaceImplClass = (jclass) jEnv->NewGlobalRef(jEnv->FindClass("com/google/android/gles_jni/EGLSurfaceImpl")); @@ -2523,8 +2525,11 @@ nsresult AndroidBridge::TakeScreenshot(nsIDOMWindow *window, int32_t srcX, int32 context->Scale(scale * dstW / srcW, scale * dstH / srcH); rv = presShell->RenderDocument(r, renderDocFlags, bgColor, context); NS_ENSURE_SUCCESS(rv, rv); - env->CallStaticVoidMethod(AndroidBridge::Bridge()->mGeckoAppShellClass, AndroidBridge::Bridge()->jNotifyScreenShot, - buffer, tabId, dstX, dstY, dstX + dstW, dstY + dstH, bufW, bufH, token); + env->CallStaticVoidMethod(AndroidBridge::Bridge()->jScreenshotHandlerClass, + AndroidBridge::Bridge()->jNotifyScreenShot, + buffer, tabId, + dstX, dstY, dstX + dstW, dstY + dstH, + bufW, bufH, token); return NS_OK; } @@ -2536,7 +2541,9 @@ AndroidBridge::NotifyPaintedRect(float top, float left, float bottom, float righ return; AutoLocalJNIFrame jniFrame(env, 0); - env->CallStaticVoidMethod(AndroidBridge::Bridge()->mGeckoAppShellClass, AndroidBridge::Bridge()->jNotifyPaintedRect, top, left, bottom, right); + env->CallStaticVoidMethod(AndroidBridge::Bridge()->jScreenshotHandlerClass, + AndroidBridge::Bridge()->jNotifyPaintedRect, + top, left, bottom, right); } extern "C" { diff --git a/widget/android/AndroidBridge.h b/widget/android/AndroidBridge.h index 5f0a578721d0..2e8afb8eb972 100644 --- a/widget/android/AndroidBridge.h +++ b/widget/android/AndroidBridge.h @@ -402,7 +402,6 @@ protected: jmethodID jNotifyIME; jmethodID jNotifyIMEEnabled; jmethodID jNotifyIMEChange; - jmethodID jNotifyScreenShot; jmethodID jAcknowledgeEventSync; jmethodID jEnableLocation; jmethodID jEnableLocationHighAccuracy; @@ -463,8 +462,6 @@ protected: jmethodID jHideSurface; jmethodID jDestroySurface; - jmethodID jNotifyPaintedRect; - jmethodID jNumberOfMessages; jmethodID jSendMessage; jmethodID jSaveSentMessage; @@ -488,6 +485,10 @@ protected: jmethodID jRegisterSurfaceTextureFrameListener; jmethodID jUnregisterSurfaceTextureFrameListener; + jclass jScreenshotHandlerClass; + jmethodID jNotifyScreenShot; + jmethodID jNotifyPaintedRect; + // for GfxInfo (gfx feature detection and blacklisting) jmethodID jGetGfxInfoData;