Bug 1182665 - Use a direct JNI call to determine screen size in nsScreenManagerAndroid r=jchen

This commit is contained in:
James Willcox 2015-08-26 15:25:40 -05:00
Родитель 9932c21923
Коммит 45564cbbb2
7 изменённых файлов: 46 добавлений и 8 удалений

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

@ -84,6 +84,7 @@ import android.graphics.RectF;
import android.graphics.SurfaceTexture;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.hardware.display.DisplayManager;
import android.hardware.Sensor;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
@ -110,6 +111,7 @@ import android.util.Base64;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.ContextThemeWrapper;
import android.view.Display;
import android.view.HapticFeedbackConstants;
import android.view.Surface;
import android.view.SurfaceView;
@ -2740,4 +2742,10 @@ public class GeckoAppShell
}
return 0;
}
@WrapForJNI
static Rect getScreenSize() {
Display disp = getGeckoInterface().getActivity().getWindowManager().getDefaultDisplay();
return new Rect(0, 0, disp.getWidth(), disp.getHeight());
}
}

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

@ -393,6 +393,14 @@ auto GeckoAppShell::GetScreenOrientationWrapper() -> int16_t
return mozilla::jni::Method<GetScreenOrientationWrapper_t>::Call(nullptr, nullptr);
}
constexpr char GeckoAppShell::GetScreenSize_t::name[];
constexpr char GeckoAppShell::GetScreenSize_t::signature[];
auto GeckoAppShell::GetScreenSize() -> mozilla::jni::Object::LocalRef
{
return mozilla::jni::Method<GetScreenSize_t>::Call(nullptr, nullptr);
}
constexpr char GeckoAppShell::GetShowPasswordSetting_t::name[];
constexpr char GeckoAppShell::GetShowPasswordSetting_t::signature[];

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

@ -944,6 +944,23 @@ public:
static auto GetScreenOrientationWrapper() -> int16_t;
public:
struct GetScreenSize_t {
typedef GeckoAppShell Owner;
typedef mozilla::jni::Object::LocalRef ReturnType;
typedef mozilla::jni::Object::Param SetterType;
typedef mozilla::jni::Args<> Args;
static constexpr char name[] = "getScreenSize";
static constexpr char signature[] =
"()Landroid/graphics/Rect;";
static const bool isStatic = true;
static const bool isMultithreaded = false;
static const mozilla::jni::ExceptionMode exceptionMode =
mozilla::jni::ExceptionMode::ABORT;
};
static auto GetScreenSize() -> mozilla::jni::Object::LocalRef;
public:
struct GetShowPasswordSetting_t {
typedef GeckoAppShell Owner;

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

@ -0,0 +1,2 @@
android.graphics.Rect
android.graphics.RectF

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

@ -24,6 +24,7 @@ sdk_processor := \
# We'd like these to be defined in a future GENERATED_EXPORTS list.
bindings_exports_FILES := \
AndroidRect.h \
Bundle.h \
MediaCodec.h \
SurfaceTexture.h \

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

@ -7,9 +7,10 @@
# List of stems to generate .cpp and .h files for. To add a stem, add it to
# this list and ensure that $(stem)-classes.txt exists in this directory.
generated = [
'AndroidRect',
'Bundle',
'MediaCodec',
'SurfaceTexture',
'SurfaceTexture'
]
SOURCES += ['!%s.cpp' % stem for stem in generated]

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

@ -8,6 +8,9 @@
#include "nsScreenManagerAndroid.h"
#include "nsWindow.h"
#include "AndroidBridge.h"
#include "GeneratedJNIWrappers.h"
#include "AndroidRect.h"
#include <mozilla/jni/Refs.h>
using namespace mozilla;
@ -29,13 +32,11 @@ nsScreenAndroid::GetId(uint32_t *outId)
NS_IMETHODIMP
nsScreenAndroid::GetRect(int32_t *outLeft, int32_t *outTop, int32_t *outWidth, int32_t *outHeight)
{
gfx::IntSize sz = nsWindow::GetAndroidScreenBounds();
*outLeft = 0;
*outTop = 0;
*outWidth = sz.width;
*outHeight = sz.height;
widget::sdk::Rect::LocalRef rect = widget::GeckoAppShell::GetScreenSize();
rect->Left(outLeft);
rect->Top(outTop);
rect->Width(outWidth);
rect->Height(outHeight);
return NS_OK;
}