Bug 1287015 - Part 1. Remove SurfaceBits and getSurfaceBits. r?snorp
MozReview-Commit-ID: 2dFvgwxavgx
--- a/mobile/android/base/geckoview.ddf
+++ b/mobile/android/base/geckoview.ddf
@@ -34,17 +34,16 @@ show allResults
org.mozilla.gecko.GeckoView \
org.mozilla.gecko.GlobalHistory \
org.mozilla.gecko.InputMethods \
org.mozilla.gecko.NSSBridge \
org.mozilla.gecko.NotificationClient \
org.mozilla.gecko.NotificationHandler \
org.mozilla.gecko.PrefsHelper \
org.mozilla.gecko.SmsManager \
- org.mozilla.gecko.SurfaceBits \
org.mozilla.gecko.SysInfo \
org.mozilla.gecko.TouchEventInterceptor \
org.mozilla.gecko.ZoomConstraints
[middle] = \
org.mozilla.gecko.prompts.* \
org.mozilla.gecko.FormAssistPopup \
org.mozilla.gecko.GeckoActivity \
--- a/mobile/android/base/java/org/mozilla/gecko/GeckoAppShell.java
+++ b/mobile/android/base/java/org/mozilla/gecko/GeckoAppShell.java
@@ -253,18 +253,16 @@ public class GeckoAppShell
public static native void notifyUriVisited(String uri);
public static native void notifyBatteryChange(double aLevel, boolean aCharging, double aRemainingTime);
public static native void invalidateAndScheduleComposite();
public static native float computeRenderIntegrity();
- public static native SurfaceBits getSurfaceBits(Surface surface);
-
public static native void addPresentationSurface(Surface surface);
public static native void removePresentationSurface(Surface surface);
public static native void onFullScreenPluginHidden(View view);
private static LayerView sLayerView;
private static Rect sScreenSize;
deleted file mode 100644
--- a/mobile/android/base/java/org/mozilla/gecko/SurfaceBits.java
+++ /dev/null
@@ -1,17 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-package org.mozilla.gecko;
-
-import org.mozilla.gecko.annotation.WrapForJNI;
-
-import java.nio.ByteBuffer;
-
-@WrapForJNI
-public class SurfaceBits {
- public int width;
- public int height;
- public int format;
- public ByteBuffer buffer;
-}
--- a/mobile/android/base/moz.build
+++ b/mobile/android/base/moz.build
@@ -566,17 +566,16 @@ gbjar.sources += ['java/org/mozilla/geck
'SiteIdentity.java',
'SmsManager.java',
'SnackbarHelper.java',
'sqlite/ByteBufferInputStream.java',
'sqlite/MatrixBlobCursor.java',
'sqlite/SQLiteBridge.java',
'sqlite/SQLiteBridgeException.java',
'SuggestClient.java',
- 'SurfaceBits.java',
'Tab.java',
'tabqueue/TabQueueHelper.java',
'tabqueue/TabQueuePrompt.java',
'tabqueue/TabQueueService.java',
'tabqueue/TabReceivedService.java',
'Tabs.java',
'tabs/PrivateTabsPanel.java',
'tabs/TabCurve.java',
--- a/mozglue/android/jni-stubs.inc
+++ b/mozglue/android/jni-stubs.inc
@@ -148,35 +148,16 @@ Java_org_mozilla_gecko_GeckoAppShell_com
#endif
#ifdef JNI_BINDINGS
xul_dlsym("Java_org_mozilla_gecko_GeckoAppShell_computeRenderIntegrity", &f_Java_org_mozilla_gecko_GeckoAppShell_computeRenderIntegrity);
#endif
#ifdef JNI_STUBS
-typedef jobject (*Java_org_mozilla_gecko_GeckoAppShell_getSurfaceBits_t)(JNIEnv *, jclass, jobject);
-static Java_org_mozilla_gecko_GeckoAppShell_getSurfaceBits_t f_Java_org_mozilla_gecko_GeckoAppShell_getSurfaceBits;
-extern "C" NS_EXPORT jobject MOZ_JNICALL
-Java_org_mozilla_gecko_GeckoAppShell_getSurfaceBits(JNIEnv * arg0, jclass arg1, jobject arg2) {
- if (!f_Java_org_mozilla_gecko_GeckoAppShell_getSurfaceBits) {
- arg0->ThrowNew(arg0->FindClass("java/lang/UnsupportedOperationException"),
- "JNI Function called before it was loaded");
- return nullptr;
- }
- return f_Java_org_mozilla_gecko_GeckoAppShell_getSurfaceBits(arg0, arg1, arg2);
-}
-#endif
-
-#ifdef JNI_BINDINGS
- xul_dlsym("Java_org_mozilla_gecko_GeckoAppShell_getSurfaceBits", &f_Java_org_mozilla_gecko_GeckoAppShell_getSurfaceBits);
-#endif
-
-#ifdef JNI_STUBS
-
typedef void (*Java_org_mozilla_gecko_GeckoAppShell_addPresentationSurface_t)(JNIEnv *, jclass, jobject);
static Java_org_mozilla_gecko_GeckoAppShell_addPresentationSurface_t f_Java_org_mozilla_gecko_GeckoAppShell_addPresentationSurface;
extern "C" NS_EXPORT void MOZ_JNICALL
Java_org_mozilla_gecko_GeckoAppShell_addPresentationSurface(JNIEnv * arg0, jclass arg1, jobject arg2) {
if (!f_Java_org_mozilla_gecko_GeckoAppShell_addPresentationSurface) {
arg0->ThrowNew(arg0->FindClass("java/lang/UnsupportedOperationException"),
"JNI Function called before it was loaded");
return ;
--- a/widget/android/AndroidJNI.cpp
+++ b/widget/android/AndroidJNI.cpp
@@ -124,107 +124,16 @@ Java_org_mozilla_gecko_GeckoAppShell_inv
}
NS_EXPORT float JNICALL
Java_org_mozilla_gecko_GeckoAppShell_computeRenderIntegrity(JNIEnv*, jclass)
{
return nsWindow::ComputeRenderIntegrity();
}
-#define MAX_LOCK_ATTEMPTS 10
-
-static bool LockWindowWithRetry(void* window, unsigned char** bits, int* width, int* height, int* format, int* stride)
-{
- int count = 0;
-
- while (count < MAX_LOCK_ATTEMPTS) {
- if (AndroidBridge::Bridge()->LockWindow(window, bits, width, height, format, stride))
- return true;
-
- count++;
- usleep(500);
- }
-
- return false;
-}
-
-NS_EXPORT jobject JNICALL
-Java_org_mozilla_gecko_GeckoAppShell_getSurfaceBits(JNIEnv* jenv, jclass, jobject surface)
-{
- static jclass jSurfaceBitsClass = nullptr;
- static jmethodID jSurfaceBitsCtor = 0;
- static jfieldID jSurfaceBitsWidth, jSurfaceBitsHeight, jSurfaceBitsFormat, jSurfaceBitsBuffer;
-
- jobject surfaceBits = nullptr;
- unsigned char* bitsCopy = nullptr;
- int dstWidth, dstHeight, dstSize;
-
- void* window = AndroidBridge::Bridge()->AcquireNativeWindow(jenv, surface);
- if (!window)
- return nullptr;
-
- unsigned char* bits;
- int srcWidth, srcHeight, format, srcStride;
-
- // So we lock/unlock once here in order to get whatever is currently the front buffer. It sucks.
- if (!LockWindowWithRetry(window, &bits, &srcWidth, &srcHeight, &format, &srcStride))
- return nullptr;
-
- AndroidBridge::Bridge()->UnlockWindow(window);
-
- // This is lock will result in the front buffer, since the last unlock rotated it to the back. Probably.
- if (!LockWindowWithRetry(window, &bits, &srcWidth, &srcHeight, &format, &srcStride))
- return nullptr;
-
- // These are from android.graphics.PixelFormat
- int bpp;
- switch (format) {
- case 1: // RGBA_8888
- bpp = 4;
- break;
- case 4: // RGB_565
- bpp = 2;
- break;
- default:
- goto cleanup;
- }
-
- dstWidth = mozilla::RoundUpPow2(srcWidth);
- dstHeight = mozilla::RoundUpPow2(srcHeight);
- dstSize = dstWidth * dstHeight * bpp;
-
- bitsCopy = (unsigned char*)malloc(dstSize);
- bzero(bitsCopy, dstSize);
- for (int i = 0; i < srcHeight; i++) {
- memcpy(bitsCopy + ((dstHeight - i - 1) * dstWidth * bpp), bits + (i * srcStride * bpp), srcStride * bpp);
- }
-
- if (!jSurfaceBitsClass) {
- jSurfaceBitsClass = (jclass)jenv->NewGlobalRef(jenv->FindClass("org/mozilla/gecko/SurfaceBits"));
- jSurfaceBitsCtor = jenv->GetMethodID(jSurfaceBitsClass, "<init>", "()V");
-
- jSurfaceBitsWidth = jenv->GetFieldID(jSurfaceBitsClass, "width", "I");
- jSurfaceBitsHeight = jenv->GetFieldID(jSurfaceBitsClass, "height", "I");
- jSurfaceBitsFormat = jenv->GetFieldID(jSurfaceBitsClass, "format", "I");
- jSurfaceBitsBuffer = jenv->GetFieldID(jSurfaceBitsClass, "buffer", "Ljava/nio/ByteBuffer;");
- }
-
- surfaceBits = jenv->NewObject(jSurfaceBitsClass, jSurfaceBitsCtor);
- jenv->SetIntField(surfaceBits, jSurfaceBitsWidth, dstWidth);
- jenv->SetIntField(surfaceBits, jSurfaceBitsHeight, dstHeight);
- jenv->SetIntField(surfaceBits, jSurfaceBitsFormat, format);
- jenv->SetObjectField(surfaceBits, jSurfaceBitsBuffer, jenv->NewDirectByteBuffer(bitsCopy, dstSize));
-
-cleanup:
- AndroidBridge::Bridge()->UnlockWindow(window);
- AndroidBridge::Bridge()->ReleaseNativeWindow(window);
-
- return surfaceBits;
-}
-
NS_EXPORT void JNICALL
Java_org_mozilla_gecko_GeckoAppShell_addPresentationSurface(JNIEnv* jenv, jclass, jobject surface)
{
if (surface != NULL) {
void* window = AndroidBridge::Bridge()->AcquireNativeWindow(jenv, surface);
if (window) {
AndroidBridge::Bridge()->SetPresentationWindow(window);
}
--- a/widget/android/GeneratedJNIWrappers.cpp
+++ b/widget/android/GeneratedJNIWrappers.cpp
@@ -1149,79 +1149,16 @@ constexpr char PrefsHelper::SetPref_t::s
constexpr char PrefsHelper::OnPrefChange_t::name[];
constexpr char PrefsHelper::OnPrefChange_t::signature[];
auto PrefsHelper::OnPrefChange(mozilla::jni::String::Param a0, int32_t a1, bool a2, int32_t a3, mozilla::jni::String::Param a4) -> void
{
return mozilla::jni::Method<OnPrefChange_t>::Call(PrefsHelper::Context(), nullptr, a0, a1, a2, a3, a4);
}
-const char SurfaceBits::name[] =
- "org/mozilla/gecko/SurfaceBits";
-
-constexpr char SurfaceBits::New_t::name[];
-constexpr char SurfaceBits::New_t::signature[];
-
-auto SurfaceBits::New() -> SurfaceBits::LocalRef
-{
- return mozilla::jni::Constructor<New_t>::Call(SurfaceBits::Context(), nullptr);
-}
-
-constexpr char SurfaceBits::Buffer_t::name[];
-constexpr char SurfaceBits::Buffer_t::signature[];
-
-auto SurfaceBits::Buffer() const -> mozilla::jni::Object::LocalRef
-{
- return mozilla::jni::Field<Buffer_t>::Get(SurfaceBits::mCtx, nullptr);
-}
-
-auto SurfaceBits::Buffer(mozilla::jni::Object::Param a0) const -> void
-{
- return mozilla::jni::Field<Buffer_t>::Set(SurfaceBits::mCtx, nullptr, a0);
-}
-
-constexpr char SurfaceBits::Format_t::name[];
-constexpr char SurfaceBits::Format_t::signature[];
-
-auto SurfaceBits::Format() const -> int32_t
-{
- return mozilla::jni::Field<Format_t>::Get(SurfaceBits::mCtx, nullptr);
-}
-
-auto SurfaceBits::Format(int32_t a0) const -> void
-{
- return mozilla::jni::Field<Format_t>::Set(SurfaceBits::mCtx, nullptr, a0);
-}
-
-constexpr char SurfaceBits::Height_t::name[];
-constexpr char SurfaceBits::Height_t::signature[];
-
-auto SurfaceBits::Height() const -> int32_t
-{
- return mozilla::jni::Field<Height_t>::Get(SurfaceBits::mCtx, nullptr);
-}
-
-auto SurfaceBits::Height(int32_t a0) const -> void
-{
- return mozilla::jni::Field<Height_t>::Set(SurfaceBits::mCtx, nullptr, a0);
-}
-
-constexpr char SurfaceBits::Width_t::name[];
-constexpr char SurfaceBits::Width_t::signature[];
-
-auto SurfaceBits::Width() const -> int32_t
-{
- return mozilla::jni::Field<Width_t>::Get(SurfaceBits::mCtx, nullptr);
-}
-
-auto SurfaceBits::Width(int32_t a0) const -> void
-{
- return mozilla::jni::Field<Width_t>::Set(SurfaceBits::mCtx, nullptr, a0);
-}
-
const char ThumbnailHelper::name[] =
"org/mozilla/gecko/ThumbnailHelper";
constexpr char ThumbnailHelper::SendThumbnail_t::name[];
constexpr char ThumbnailHelper::SendThumbnail_t::signature[];
auto ThumbnailHelper::SendThumbnail(mozilla::jni::Object::Param a0, int32_t a1, bool a2, bool a3) -> void
{
--- a/widget/android/GeneratedJNIWrappers.h
+++ b/widget/android/GeneratedJNIWrappers.h
@@ -2847,110 +2847,16 @@ public:
static const int32_t PREF_STRING = 3;
static const bool isMultithreaded = false;
template<class Impl> class Natives;
};
-class SurfaceBits : public mozilla::jni::ObjectBase<SurfaceBits, jobject>
-{
-public:
- static const char name[];
-
- explicit SurfaceBits(const Context& ctx) : ObjectBase<SurfaceBits, jobject>(ctx) {}
-
- struct New_t {
- typedef SurfaceBits Owner;
- typedef SurfaceBits::LocalRef ReturnType;
- typedef SurfaceBits::Param SetterType;
- typedef mozilla::jni::Args<> Args;
- static constexpr char name[] = "<init>";
- static constexpr char signature[] =
- "()V";
- static const bool isStatic = false;
- static const mozilla::jni::ExceptionMode exceptionMode =
- mozilla::jni::ExceptionMode::ABORT;
- };
-
- static auto New() -> SurfaceBits::LocalRef;
-
- struct Buffer_t {
- typedef SurfaceBits Owner;
- typedef mozilla::jni::Object::LocalRef ReturnType;
- typedef mozilla::jni::Object::Param SetterType;
- typedef mozilla::jni::Args<> Args;
- static constexpr char name[] = "buffer";
- static constexpr char signature[] =
- "Ljava/nio/ByteBuffer;";
- static const bool isStatic = false;
- static const mozilla::jni::ExceptionMode exceptionMode =
- mozilla::jni::ExceptionMode::ABORT;
- };
-
- auto Buffer() const -> mozilla::jni::Object::LocalRef;
-
- auto Buffer(mozilla::jni::Object::Param) const -> void;
-
- struct Format_t {
- typedef SurfaceBits Owner;
- typedef int32_t ReturnType;
- typedef int32_t SetterType;
- typedef mozilla::jni::Args<> Args;
- static constexpr char name[] = "format";
- static constexpr char signature[] =
- "I";
- static const bool isStatic = false;
- static const mozilla::jni::ExceptionMode exceptionMode =
- mozilla::jni::ExceptionMode::ABORT;
- };
-
- auto Format() const -> int32_t;
-
- auto Format(int32_t) const -> void;
-
- struct Height_t {
- typedef SurfaceBits Owner;
- typedef int32_t ReturnType;
- typedef int32_t SetterType;
- typedef mozilla::jni::Args<> Args;
- static constexpr char name[] = "height";
- static constexpr char signature[] =
- "I";
- static const bool isStatic = false;
- static const mozilla::jni::ExceptionMode exceptionMode =
- mozilla::jni::ExceptionMode::ABORT;
- };
-
- auto Height() const -> int32_t;
-
- auto Height(int32_t) const -> void;
-
- struct Width_t {
- typedef SurfaceBits Owner;
- typedef int32_t ReturnType;
- typedef int32_t SetterType;
- typedef mozilla::jni::Args<> Args;
- static constexpr char name[] = "width";
- static constexpr char signature[] =
- "I";
- static const bool isStatic = false;
- static const mozilla::jni::ExceptionMode exceptionMode =
- mozilla::jni::ExceptionMode::ABORT;
- };
-
- auto Width() const -> int32_t;
-
- auto Width(int32_t) const -> void;
-
- static const bool isMultithreaded = true;
-
-};
-
class ThumbnailHelper : public mozilla::jni::ObjectBase<ThumbnailHelper, jobject>
{
public:
static const char name[];
explicit ThumbnailHelper(const Context& ctx) : ObjectBase<ThumbnailHelper, jobject>(ctx) {}
struct SendThumbnail_t {