diff options
author | Chun-wei Fan <fanchunwei@src.gnome.org> | 2018-07-31 18:11:26 +0800 |
---|---|---|
committer | Chun-wei Fan <fanchunwei@src.gnome.org> | 2018-08-03 16:00:19 +0800 |
commit | 471e50ebd208c3e112b0ec45ea0626d363458c90 (patch) | |
tree | a46bcc3b61406794fc7aa37af9de6cfd9bbb1ad8 /gdk/win32/gdksurface-win32.c | |
parent | 693af75687a2dafed7580915522ec4de1c019c9a (diff) | |
download | gtk+-471e50ebd208c3e112b0ec45ea0626d363458c90.tar.gz |
Add a EGL renderer (via ANGLE) for Windows
This is for adding a EGL-based renderer which is done via the ANGLE
project, which translate EGL calls to Direct3D 9/11. This is done as a
possible solution to issue #105, especially for cases where the needed
full GL extensions to map OpenGL to Direc3D is unavailable or
unreliable, or when the OpenGL implementation from the graphics drivers
are problematic.
To enable this, do the following:
-Build ANGLE and ensure the ANGLE libEGL.dll and libGLESv2.dll are
available. A sufficiently-recent ANGLE is needed for things to
work correctly--note that the copy of ANGLE that is included in
qtbase-5.10.1 is sufficient. ANGLE is licensed under a BSD 3-clause
license.
-Build libepoxy on Windows with EGL support enabled.
-Currently, prior to running GTK+ programs, the GDK_DEBUG envvar needs
to be set with gl-gles as at least one of the flags.
Known issues:
-Only OpenGL ES 3 is supported, ANGLE's ES 2 does not support the needed
extensions, notably GL_OES_vertex_array_object, but its ES 3 support is
sufficient.
-There is no autodetection or fallback mechanism to enable using
EGL/Angle automatically yet. There are no plans to do this in this
commit.
Diffstat (limited to 'gdk/win32/gdksurface-win32.c')
-rw-r--r-- | gdk/win32/gdksurface-win32.c | 66 |
1 files changed, 60 insertions, 6 deletions
diff --git a/gdk/win32/gdksurface-win32.c b/gdk/win32/gdksurface-win32.c index d47d67bfdb..a7900d2035 100644 --- a/gdk/win32/gdksurface-win32.c +++ b/gdk/win32/gdksurface-win32.c @@ -750,6 +750,7 @@ gdk_win32_surface_destroy (GdkSurface *window, { GdkSurfaceImplWin32 *surface_impl = GDK_SURFACE_IMPL_WIN32 (window->impl); GSList *tmp; + GdkWin32Display *display = NULL; g_return_if_fail (GDK_IS_SURFACE (window)); @@ -766,6 +767,22 @@ gdk_win32_surface_destroy (GdkSurface *window, gdk_surface_set_transient_for (child, NULL); } +#ifdef GDK_WIN32_ENABLE_EGL + display = GDK_WIN32_DISPLAY (gdk_surface_get_display (window)); + + /* Get rid of any EGLSurfaces that we might have created */ + if (surface_impl->egl_surface != EGL_NO_SURFACE) + { + eglDestroySurface (display->egl_disp, surface_impl->egl_surface); + surface_impl->egl_surface = EGL_NO_SURFACE; + } + if (surface_impl->egl_dummy_surface != EGL_NO_SURFACE) + { + eglDestroySurface (display->egl_disp, surface_impl->egl_dummy_surface); + surface_impl->egl_dummy_surface = EGL_NO_SURFACE; + } +#endif + /* Remove ourself from our transient owner */ if (surface_impl->transient_owner != NULL) { @@ -1349,14 +1366,15 @@ gdk_win32_surface_move_resize (GdkSurface *window, } else { + _gdk_win32_surface_invalidate_egl_framebuffer (window); if (with_move) - { - gdk_win32_surface_move_resize_internal (window, x, y, width, height); - } + { + gdk_win32_surface_move_resize_internal (window, x, y, width, height); + } else - { - gdk_win32_surface_resize (window, width, height); - } + { + gdk_win32_surface_resize (window, width, height); + } } out: @@ -4182,6 +4200,9 @@ gdk_win32_surface_end_move_resize_drag (GdkSurface *window) { GdkSurfaceImplWin32 *impl = GDK_SURFACE_IMPL_WIN32 (window->impl); GdkW32DragMoveResizeContext *context = &impl->drag_move_resize_context; + + if (context->op == GDK_WIN32_DRAGOP_RESIZE) + _gdk_win32_surface_invalidate_egl_framebuffer (window); context->op = GDK_WIN32_DRAGOP_NONE; @@ -4711,6 +4732,8 @@ gdk_win32_surface_unmaximize (GdkSurface *window) GDK_SURFACE_HWND (window), _gdk_win32_surface_state_to_string (window->state))); + _gdk_win32_surface_invalidate_egl_framebuffer (window); + if (GDK_SURFACE_IS_MAPPED (window)) GtkShowWindow (window, SW_RESTORE); else @@ -5388,3 +5411,34 @@ gdk_win32_surface_get_handle (GdkSurface *window) return GDK_SURFACE_HWND (window); } + +#ifdef GDK_WIN32_ENABLE_EGL +EGLSurface +_gdk_win32_surface_get_egl_surface (GdkSurface *surface, + EGLConfig config, + gboolean is_dummy) +{ + GdkWin32Display *display = GDK_WIN32_DISPLAY (gdk_surface_get_display (surface)); + GdkSurfaceImplWin32 *impl = GDK_SURFACE_IMPL_WIN32 (surface->impl); + + if (is_dummy) + { + if (impl->egl_dummy_surface == EGL_NO_SURFACE) + { + EGLint attribs[] = {EGL_WIDTH, 1, EGL_WIDTH, 1, EGL_NONE}; + impl->egl_dummy_surface = eglCreatePbufferSurface (display->egl_disp, + config, + attribs); + } + return impl->egl_dummy_surface; + } + else + { + if (impl->egl_surface == EGL_NO_SURFACE) + impl->egl_surface = eglCreateWindowSurface (display->egl_disp, config, display->gl_hwnd, NULL); + + return impl->egl_surface; + } + +} +#endif |