From d2fe9469df95af7810f77abbab4c0e30907d7924 Mon Sep 17 00:00:00 2001 From: Geert-Johan Riemer Date: Sat, 16 Feb 2019 16:14:12 +0100 Subject: [PATCH] Add gl_proc_resolver to resolve GL procs within the GLFW context --- flutter/flutter_helper.c | 2 ++ flutter/flutter_proxy_glfw.go | 5 ++++ flutter/library/flutter_embedder.h | 38 ++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+) diff --git a/flutter/flutter_helper.c b/flutter/flutter_helper.c index 0dc26674..c9a99946 100644 --- a/flutter/flutter_helper.c +++ b/flutter/flutter_helper.c @@ -9,6 +9,7 @@ bool proxy_clear_current(void *v); bool proxy_present(void *v); uint32_t proxy_fbo_callback(void *v); bool proxy_make_resource_current(void *v); +void *proxy_gl_proc_resolver(void *v, const char *procname); bool proxy_on_platform_message(FlutterPlatformMessage *message, void *window); @@ -27,6 +28,7 @@ FlutterResult runFlutter(uintptr_t window, FlutterEngine *engine, FlutterProject config.open_gl.present = proxy_present; config.open_gl.fbo_callback = proxy_fbo_callback; config.open_gl.make_resource_current = proxy_make_resource_current; + config.open_gl.gl_proc_resolver = proxy_gl_proc_resolver; Args->command_line_argc = nVmAgrs; Args->command_line_argv = vmArgs; diff --git a/flutter/flutter_proxy_glfw.go b/flutter/flutter_proxy_glfw.go index c19fd675..53003a60 100644 --- a/flutter/flutter_proxy_glfw.go +++ b/flutter/flutter_proxy_glfw.go @@ -70,3 +70,8 @@ func proxy_make_resource_current(v unsafe.Pointer) C.bool { index := *(*C.int)(w.GetUserPointer()) return C.bool(flutterEngines[index].FMakeResourceCurrent(v)) } + +//export proxy_gl_proc_resolver +func proxy_gl_proc_resolver(v unsafe.Pointer, procname *C.char) unsafe.Pointer { + return glfw.GetProcAddress(C.GoString(procname)) +} diff --git a/flutter/library/flutter_embedder.h b/flutter/library/flutter_embedder.h index a4c6d7fa..6f14c42b 100644 --- a/flutter/library/flutter_embedder.h +++ b/flutter/library/flutter_embedder.h @@ -31,8 +31,31 @@ typedef enum { typedef struct _FlutterEngine* FlutterEngine; +typedef struct { + // horizontal scale factor + double scaleX; + // horizontal skew factor + double skewX; + // horizontal translation + double transX; + // vertical skew factor + double skewY; + // vertical scale factor + double scaleY; + // vertical translation + double transY; + // input x-axis perspective factor + double pers0; + // input y-axis perspective factor + double pers1; + // perspective scale factor + double pers2; +} FlutterTransformation; + typedef bool (*BoolCallback)(void* /* user data */); +typedef FlutterTransformation (*TransformationCallback)(void* /* user data */); typedef uint32_t (*UIntCallback)(void* /* user data */); +typedef void* (*ProcResolver)(void* /* user data */, const char* /* name */); typedef struct { // The size of this struct. Must be sizeof(FlutterOpenGLRendererConfig). @@ -41,7 +64,22 @@ typedef struct { BoolCallback clear_current; BoolCallback present; UIntCallback fbo_callback; + // This is an optional callback. Flutter will ask the emebdder to create a GL + // context current on a background thread. If the embedder is able to do so, + // Flutter will assume that this context is in the same sharegroup as the main + // rendering context and use this context for asynchronous texture uploads. + // Though optional, it is recommended that all embedders set this callback as + // it will lead to better performance in texture handling. BoolCallback make_resource_current; + // By default, the renderer config assumes that the FBO does not change for + // the duration of the engine run. If this argument is true, the + // engine will ask the embedder for an updated FBO target (via an fbo_callback + // invocation) after a present call. + bool fbo_reset_after_present; + // The transformation to apply to the render target before any rendering + // operations. This callback is optional. + TransformationCallback surface_transformation; + ProcResolver gl_proc_resolver; } FlutterOpenGLRendererConfig; typedef struct {