mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1227719 - Autogenerate LayerRenderer.Frame; r=snorp
This patch adds auto-generated bindings for LayerRenderer.Frame, and uses the new bindings in nsWindow, in place of the old manual bindings in AndroidJavaWrappers.
This commit is contained in:
parent
1c8060a29f
commit
c3cf1e06c6
@ -29,7 +29,7 @@ import android.opengl.GLES20;
|
||||
import android.os.SystemClock;
|
||||
import android.util.Log;
|
||||
|
||||
import org.mozilla.gecko.annotation.JNITarget;
|
||||
import org.mozilla.gecko.annotation.WrapForJNI;
|
||||
import org.mozilla.gecko.util.ThreadUtils;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
@ -463,7 +463,7 @@ public class LayerRenderer implements Tabs.OnTabsChangedListener {
|
||||
}
|
||||
|
||||
/** This function is invoked via JNI; be careful when modifying signature. */
|
||||
@JNITarget
|
||||
@WrapForJNI(allowMultithread = true)
|
||||
public void beginDrawing() {
|
||||
mFrameStartTime = System.nanoTime();
|
||||
|
||||
@ -522,7 +522,7 @@ public class LayerRenderer implements Tabs.OnTabsChangedListener {
|
||||
}
|
||||
|
||||
/** This function is invoked via JNI; be careful when modifying signature. */
|
||||
@JNITarget
|
||||
@WrapForJNI(allowMultithread = true)
|
||||
public void drawBackground() {
|
||||
// Any GL state which is changed here must be restored in
|
||||
// restoreState(...)
|
||||
@ -536,7 +536,7 @@ public class LayerRenderer implements Tabs.OnTabsChangedListener {
|
||||
clear(mBackgroundColor);
|
||||
}
|
||||
|
||||
@JNITarget
|
||||
@WrapForJNI(allowMultithread = true)
|
||||
public void drawForeground() {
|
||||
// Any GL state which is changed here must be restored in
|
||||
// restoreState(...)
|
||||
@ -620,7 +620,7 @@ public class LayerRenderer implements Tabs.OnTabsChangedListener {
|
||||
}
|
||||
|
||||
/** This function is invoked via JNI; be careful when modifying signature. */
|
||||
@JNITarget
|
||||
@WrapForJNI(allowMultithread = true)
|
||||
public void endDrawing() {
|
||||
// If a layer update requires further work, schedule another redraw
|
||||
if (!mUpdated)
|
||||
|
@ -80,12 +80,6 @@ jmethodID AndroidLocation::jGetBearingMethod = 0;
|
||||
jmethodID AndroidLocation::jGetSpeedMethod = 0;
|
||||
jmethodID AndroidLocation::jGetTimeMethod = 0;
|
||||
|
||||
jclass AndroidLayerRendererFrame::jLayerRendererFrameClass = 0;
|
||||
jmethodID AndroidLayerRendererFrame::jBeginDrawingMethod = 0;
|
||||
jmethodID AndroidLayerRendererFrame::jDrawBackgroundMethod = 0;
|
||||
jmethodID AndroidLayerRendererFrame::jDrawForegroundMethod = 0;
|
||||
jmethodID AndroidLayerRendererFrame::jEndDrawingMethod = 0;
|
||||
|
||||
RefCountedJavaObject::~RefCountedJavaObject() {
|
||||
if (mObject)
|
||||
GetEnvForThread()->DeleteGlobalRef(mObject);
|
||||
@ -100,7 +94,6 @@ mozilla::InitAndroidJavaWrappers(JNIEnv *jEnv)
|
||||
AndroidLocation::InitLocationClass(jEnv);
|
||||
AndroidRect::InitRectClass(jEnv);
|
||||
AndroidRectF::InitRectFClass(jEnv);
|
||||
AndroidLayerRendererFrame::InitLayerRendererFrameClass(jEnv);
|
||||
}
|
||||
|
||||
void
|
||||
@ -222,18 +215,6 @@ AndroidRectF::InitRectFClass(JNIEnv *jEnv)
|
||||
jRightField = rect.getField("right", "F");
|
||||
}
|
||||
|
||||
void
|
||||
AndroidLayerRendererFrame::InitLayerRendererFrameClass(JNIEnv *jEnv)
|
||||
{
|
||||
AutoJNIClass layerRendererFrame(jEnv, "org/mozilla/gecko/gfx/LayerRenderer$Frame");
|
||||
jLayerRendererFrameClass = layerRendererFrame.getGlobalRef();
|
||||
|
||||
jBeginDrawingMethod = layerRendererFrame.getMethod("beginDrawing", "()V");
|
||||
jDrawBackgroundMethod = layerRendererFrame.getMethod("drawBackground", "()V");
|
||||
jDrawForegroundMethod = layerRendererFrame.getMethod("drawForeground", "()V");
|
||||
jEndDrawingMethod = layerRendererFrame.getMethod("endDrawing", "()V");
|
||||
}
|
||||
|
||||
void
|
||||
AndroidGeckoEvent::ReadPointArray(nsTArray<nsIntPoint> &points,
|
||||
JNIEnv *jenv,
|
||||
@ -824,81 +805,8 @@ AndroidPoint::Init(JNIEnv *jenv, jobject jobj)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
AndroidLayerRendererFrame::Init(JNIEnv *env, jobject jobj)
|
||||
{
|
||||
if (!isNull()) {
|
||||
Dispose(env);
|
||||
}
|
||||
|
||||
wrapped_obj = env->NewGlobalRef(jobj);
|
||||
}
|
||||
|
||||
void
|
||||
AndroidLayerRendererFrame::Dispose(JNIEnv *env)
|
||||
{
|
||||
if (isNull()) {
|
||||
return;
|
||||
}
|
||||
|
||||
env->DeleteGlobalRef(wrapped_obj);
|
||||
wrapped_obj = 0;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsAndroidDisplayport, nsIAndroidDisplayport)
|
||||
|
||||
bool
|
||||
AndroidLayerRendererFrame::BeginDrawing(AutoLocalJNIFrame *jniFrame)
|
||||
{
|
||||
if (!jniFrame || !jniFrame->GetEnv())
|
||||
return false;
|
||||
|
||||
jniFrame->GetEnv()->CallVoidMethod(wrapped_obj, jBeginDrawingMethod);
|
||||
if (jniFrame->CheckForException())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
AndroidLayerRendererFrame::DrawBackground(AutoLocalJNIFrame *jniFrame)
|
||||
{
|
||||
if (!jniFrame || !jniFrame->GetEnv())
|
||||
return false;
|
||||
|
||||
jniFrame->GetEnv()->CallVoidMethod(wrapped_obj, jDrawBackgroundMethod);
|
||||
if (jniFrame->CheckForException())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
AndroidLayerRendererFrame::DrawForeground(AutoLocalJNIFrame *jniFrame)
|
||||
{
|
||||
if (!jniFrame || !jniFrame->GetEnv())
|
||||
return false;
|
||||
|
||||
jniFrame->GetEnv()->CallVoidMethod(wrapped_obj, jDrawForegroundMethod);
|
||||
if (jniFrame->CheckForException())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
AndroidLayerRendererFrame::EndDrawing(AutoLocalJNIFrame *jniFrame)
|
||||
{
|
||||
if (!jniFrame || !jniFrame->GetEnv())
|
||||
return false;
|
||||
|
||||
jniFrame->GetEnv()->CallVoidMethod(wrapped_obj, jEndDrawingMethod);
|
||||
if (jniFrame->CheckForException())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
AndroidRect::Init(JNIEnv *jenv, jobject jobj)
|
||||
{
|
||||
|
@ -210,26 +210,6 @@ protected:
|
||||
static jfieldID jTopField;
|
||||
};
|
||||
|
||||
class AndroidLayerRendererFrame : public WrappedJavaObject {
|
||||
public:
|
||||
static void InitLayerRendererFrameClass(JNIEnv *jEnv);
|
||||
|
||||
void Init(JNIEnv *env, jobject jobj);
|
||||
void Dispose(JNIEnv *env);
|
||||
|
||||
bool BeginDrawing(AutoLocalJNIFrame *jniFrame);
|
||||
bool DrawBackground(AutoLocalJNIFrame *jniFrame);
|
||||
bool DrawForeground(AutoLocalJNIFrame *jniFrame);
|
||||
bool EndDrawing(AutoLocalJNIFrame *jniFrame);
|
||||
|
||||
private:
|
||||
static jclass jLayerRendererFrameClass;
|
||||
static jmethodID jBeginDrawingMethod;
|
||||
static jmethodID jDrawBackgroundMethod;
|
||||
static jmethodID jDrawForegroundMethod;
|
||||
static jmethodID jEndDrawingMethod;
|
||||
};
|
||||
|
||||
enum {
|
||||
// These keycode masks are not defined in android/keycodes.h:
|
||||
#if __ANDROID_API__ < 13
|
||||
|
@ -1342,6 +1342,42 @@ auto ImmutableViewportMetrics::New(float a0, float a1, float a2, float a3, float
|
||||
return mozilla::jni::Constructor<New_t>::Call(nullptr, nullptr, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12);
|
||||
}
|
||||
|
||||
constexpr char LayerRenderer::name[];
|
||||
|
||||
constexpr char LayerRenderer::Frame::name[];
|
||||
|
||||
constexpr char LayerRenderer::Frame::BeginDrawing_t::name[];
|
||||
constexpr char LayerRenderer::Frame::BeginDrawing_t::signature[];
|
||||
|
||||
auto LayerRenderer::Frame::BeginDrawing() const -> void
|
||||
{
|
||||
return mozilla::jni::Method<BeginDrawing_t>::Call(this, nullptr);
|
||||
}
|
||||
|
||||
constexpr char LayerRenderer::Frame::DrawBackground_t::name[];
|
||||
constexpr char LayerRenderer::Frame::DrawBackground_t::signature[];
|
||||
|
||||
auto LayerRenderer::Frame::DrawBackground() const -> void
|
||||
{
|
||||
return mozilla::jni::Method<DrawBackground_t>::Call(this, nullptr);
|
||||
}
|
||||
|
||||
constexpr char LayerRenderer::Frame::DrawForeground_t::name[];
|
||||
constexpr char LayerRenderer::Frame::DrawForeground_t::signature[];
|
||||
|
||||
auto LayerRenderer::Frame::DrawForeground() const -> void
|
||||
{
|
||||
return mozilla::jni::Method<DrawForeground_t>::Call(this, nullptr);
|
||||
}
|
||||
|
||||
constexpr char LayerRenderer::Frame::EndDrawing_t::name[];
|
||||
constexpr char LayerRenderer::Frame::EndDrawing_t::signature[];
|
||||
|
||||
auto LayerRenderer::Frame::EndDrawing() const -> void
|
||||
{
|
||||
return mozilla::jni::Method<EndDrawing_t>::Call(this, nullptr);
|
||||
}
|
||||
|
||||
constexpr char LayerView::name[];
|
||||
|
||||
constexpr char LayerView::RegisterCompositorWrapper_t::name[];
|
||||
|
@ -3647,6 +3647,109 @@ public:
|
||||
|
||||
};
|
||||
|
||||
class LayerRenderer : public mozilla::jni::Class<LayerRenderer>
|
||||
{
|
||||
public:
|
||||
typedef mozilla::jni::Ref<LayerRenderer> Ref;
|
||||
typedef mozilla::jni::LocalRef<LayerRenderer> LocalRef;
|
||||
typedef mozilla::jni::GlobalRef<LayerRenderer> GlobalRef;
|
||||
typedef const mozilla::jni::Param<LayerRenderer>& Param;
|
||||
|
||||
static constexpr char name[] =
|
||||
"org/mozilla/gecko/gfx/LayerRenderer";
|
||||
|
||||
protected:
|
||||
LayerRenderer(jobject instance) : Class(instance) {}
|
||||
|
||||
public:
|
||||
class Frame;
|
||||
|
||||
};
|
||||
|
||||
class LayerRenderer::Frame : public mozilla::jni::Class<Frame>
|
||||
{
|
||||
public:
|
||||
typedef mozilla::jni::Ref<Frame> Ref;
|
||||
typedef mozilla::jni::LocalRef<Frame> LocalRef;
|
||||
typedef mozilla::jni::GlobalRef<Frame> GlobalRef;
|
||||
typedef const mozilla::jni::Param<Frame>& Param;
|
||||
|
||||
static constexpr char name[] =
|
||||
"org/mozilla/gecko/gfx/LayerRenderer$Frame";
|
||||
|
||||
protected:
|
||||
Frame(jobject instance) : Class(instance) {}
|
||||
|
||||
public:
|
||||
struct BeginDrawing_t {
|
||||
typedef Frame Owner;
|
||||
typedef void ReturnType;
|
||||
typedef void SetterType;
|
||||
typedef mozilla::jni::Args<> Args;
|
||||
static constexpr char name[] = "beginDrawing";
|
||||
static constexpr char signature[] =
|
||||
"()V";
|
||||
static const bool isStatic = false;
|
||||
static const bool isMultithreaded = true;
|
||||
static const mozilla::jni::ExceptionMode exceptionMode =
|
||||
mozilla::jni::ExceptionMode::ABORT;
|
||||
};
|
||||
|
||||
auto BeginDrawing() const -> void;
|
||||
|
||||
public:
|
||||
struct DrawBackground_t {
|
||||
typedef Frame Owner;
|
||||
typedef void ReturnType;
|
||||
typedef void SetterType;
|
||||
typedef mozilla::jni::Args<> Args;
|
||||
static constexpr char name[] = "drawBackground";
|
||||
static constexpr char signature[] =
|
||||
"()V";
|
||||
static const bool isStatic = false;
|
||||
static const bool isMultithreaded = true;
|
||||
static const mozilla::jni::ExceptionMode exceptionMode =
|
||||
mozilla::jni::ExceptionMode::ABORT;
|
||||
};
|
||||
|
||||
auto DrawBackground() const -> void;
|
||||
|
||||
public:
|
||||
struct DrawForeground_t {
|
||||
typedef Frame Owner;
|
||||
typedef void ReturnType;
|
||||
typedef void SetterType;
|
||||
typedef mozilla::jni::Args<> Args;
|
||||
static constexpr char name[] = "drawForeground";
|
||||
static constexpr char signature[] =
|
||||
"()V";
|
||||
static const bool isStatic = false;
|
||||
static const bool isMultithreaded = true;
|
||||
static const mozilla::jni::ExceptionMode exceptionMode =
|
||||
mozilla::jni::ExceptionMode::ABORT;
|
||||
};
|
||||
|
||||
auto DrawForeground() const -> void;
|
||||
|
||||
public:
|
||||
struct EndDrawing_t {
|
||||
typedef Frame Owner;
|
||||
typedef void ReturnType;
|
||||
typedef void SetterType;
|
||||
typedef mozilla::jni::Args<> Args;
|
||||
static constexpr char name[] = "endDrawing";
|
||||
static constexpr char signature[] =
|
||||
"()V";
|
||||
static const bool isStatic = false;
|
||||
static const bool isMultithreaded = true;
|
||||
static const mozilla::jni::ExceptionMode exceptionMode =
|
||||
mozilla::jni::ExceptionMode::ABORT;
|
||||
};
|
||||
|
||||
auto EndDrawing() const -> void;
|
||||
|
||||
};
|
||||
|
||||
class LayerView : public mozilla::jni::Class<LayerView>
|
||||
{
|
||||
public:
|
||||
|
@ -2653,19 +2653,14 @@ nsWindow::DrawWindowUnderlay(LayerManagerComposite* aManager,
|
||||
LayoutDeviceIntRect aRect)
|
||||
{
|
||||
GeckoLayerClient::LocalRef client = AndroidBridge::Bridge()->GetLayerClient();
|
||||
if (!client) {
|
||||
ALOG_BRIDGE("Exceptional Exit: %s", __PRETTY_FUNCTION__);
|
||||
MOZ_ASSERT(client);
|
||||
|
||||
LayerRenderer::Frame::LocalRef frame = client->CreateFrame();
|
||||
mLayerRendererFrame = frame;
|
||||
if (NS_WARN_IF(!mLayerRendererFrame)) {
|
||||
return;
|
||||
}
|
||||
|
||||
AutoLocalJNIFrame jniFrame(client.Env());
|
||||
auto frameObj = client->CreateFrame();
|
||||
if (!frameObj) {
|
||||
NS_WARNING("Warning: unable to obtain a LayerRenderer frame; aborting window underlay draw");
|
||||
return;
|
||||
}
|
||||
|
||||
mLayerRendererFrame.Init(client.Env(), frameObj.Get());
|
||||
if (!WidgetPaintsBackground()) {
|
||||
return;
|
||||
}
|
||||
@ -2678,8 +2673,8 @@ nsWindow::DrawWindowUnderlay(LayerManagerComposite* aManager,
|
||||
gl->fGetIntegerv(LOCAL_GL_SCISSOR_BOX, scissorRect);
|
||||
|
||||
client->ActivateProgram();
|
||||
if (!mLayerRendererFrame.BeginDrawing(&jniFrame)) return;
|
||||
if (!mLayerRendererFrame.DrawBackground(&jniFrame)) return;
|
||||
frame->BeginDrawing();
|
||||
frame->DrawBackground();
|
||||
client->DeactivateProgramAndRestoreState(scissorEnabled,
|
||||
scissorRect[0], scissorRect[1], scissorRect[2], scissorRect[3]);
|
||||
}
|
||||
@ -2691,14 +2686,10 @@ nsWindow::DrawWindowOverlay(LayerManagerComposite* aManager,
|
||||
PROFILER_LABEL("nsWindow", "DrawWindowOverlay",
|
||||
js::ProfileEntry::Category::GRAPHICS);
|
||||
|
||||
if (mLayerRendererFrame.isNull()) {
|
||||
NS_WARNING("Warning: do not have a LayerRenderer frame; aborting window overlay draw");
|
||||
if (NS_WARN_IF(!mLayerRendererFrame)) {
|
||||
return;
|
||||
}
|
||||
|
||||
GeckoLayerClient::LocalRef client = AndroidBridge::Bridge()->GetLayerClient();
|
||||
|
||||
AutoLocalJNIFrame jniFrame(client.Env());
|
||||
CompositorOGL *compositor = static_cast<CompositorOGL*>(aManager->GetCompositor());
|
||||
compositor->ResetProgram();
|
||||
gl::GLContext* gl = compositor->gl();
|
||||
@ -2706,12 +2697,15 @@ nsWindow::DrawWindowOverlay(LayerManagerComposite* aManager,
|
||||
GLint scissorRect[4];
|
||||
gl->fGetIntegerv(LOCAL_GL_SCISSOR_BOX, scissorRect);
|
||||
|
||||
GeckoLayerClient::LocalRef client = AndroidBridge::Bridge()->GetLayerClient();
|
||||
MOZ_ASSERT(client);
|
||||
|
||||
client->ActivateProgram();
|
||||
if (!mLayerRendererFrame.DrawForeground(&jniFrame)) return;
|
||||
if (!mLayerRendererFrame.EndDrawing(&jniFrame)) return;
|
||||
mLayerRendererFrame->DrawForeground();
|
||||
mLayerRendererFrame->EndDrawing();
|
||||
client->DeactivateProgramAndRestoreState(scissorEnabled,
|
||||
scissorRect[0], scissorRect[1], scissorRect[2], scissorRect[3]);
|
||||
mLayerRendererFrame.Dispose(client.Env());
|
||||
mLayerRendererFrame = nullptr;
|
||||
}
|
||||
|
||||
// off-main-thread compositor fields and functions
|
||||
|
@ -219,7 +219,7 @@ private:
|
||||
void CreateLayerManager(int aCompositorWidth, int aCompositorHeight);
|
||||
void RedrawAll();
|
||||
|
||||
mozilla::AndroidLayerRendererFrame mLayerRendererFrame;
|
||||
mozilla::widget::LayerRenderer::Frame::GlobalRef mLayerRendererFrame;
|
||||
|
||||
static mozilla::StaticRefPtr<mozilla::layers::APZCTreeManager> sApzcTreeManager;
|
||||
static mozilla::StaticRefPtr<mozilla::layers::LayerManager> sLayerManager;
|
||||
|
Loading…
Reference in New Issue
Block a user