Now that all contexts do that, insist that they keep doing it.
And because they keep doing it, we can support querying the GL version
from gdk_gl_context_get_version() without requiring the context to be
made current.
The EGL spec states:
The context returned must be the specified version, or a later
version which is backwards compatible with that version.
Even if a later version is returned, the specified version
must correspond to a defined version of the client API.
GTK has so far been relying on EGL implementations returning a
later version, because that is what Mesa does.
But ANGLE does not do that and only provides the minimum version, which
means Windows EGL has been forced to use a lower EGL version for no
reason.
So fix this and try versions in order from highest to lowest.
... to backends.
That way, frame clocks can be constructed by the backends' surface
implementations and dont need to be passed in as construct arguments.
Also add an assertion that they are indeed constructed.
That way, it doesn't need a specific init function.
Also chain up last, so that the generic initialization code in
GdkSurface::constructed can access a fully initialized macos surface.
That way, it doesn't ned a specific init function.
Also chain up last, so that the generic initialization code can access a
fully initialized wayland surface.
[30/1038] Compiling C object gdk/win32/libgdk-win32.a.p/gdkmain-win32.c.obj
../gdk/win32/gdkmain-win32.c:146:1: warning: 'gdk_win32_finalize_ole' defined but not used [-Wunused-function]
146 | gdk_win32_finalize_ole (void)
| ^~~~~~~~~~~~~~~~~~~~~~
../gdk/win32/gdkmain-win32.c:113:1: warning: 'gdk_win32_finalize_com' defined but not used [-Wunused-function]
113 | gdk_win32_finalize_com (void)
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
A number of warnings are produced:
[23/1038] Compiling C object gdk/win32/libgdk-win32.a.p/gdkinput-dmanipulation.c.obj
../gdk/win32/gdkinput-dmanipulation.c: In function 'reset_viewport':
../gdk/win32/gdkinput-dmanipulation.c:354:11: warning: variable 'hr' set but not used [-Wunused-but-set-variable]
354 | HRESULT hr;
| ^~
Try to do something sensible instead.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
../gdk/win32/gdkclipdrop-win32.c: In function 'transmute_cf_shell_id_list_to_text_uri_list':
C:/msys64/ucrt64/include/glib-2.0/glib/gstring.h:72:5: warning: ignoring return value of 'g_string_free_and_steal' declared with attribute 'warn_unused_result' [-Wunused-result]
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
In file included from ../gdk/win32/gdkdrag-win32.c:201:
../gdk/win32/gdkprivate-win32.h:45: warning: "GDK_NOTE" redefined
45 | #define GDK_NOTE(type,action) \
|
../gdk/win32/gdkdrag-win32.c:40: note: this is the location of the previous definition
40 | #define GDK_NOTE(a,b)
Fixes: bc159207bd ("gdk: Drop old debug macros")
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
GLES 2.0 version is fine now with current gtk according to B. Otte.
Let's use the same minimum requirement for all implementations.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
When using GDK_DEBUG=gl-egl, we end up using GL, but that is not well supported:
Creating EGL context version 3.0 (debug:no, forward:no, legacy:yes, es:no)
Created EGL context[0000000000000004]
OpenGL version: 0.0 (legacy)
* GLSL version: (NULL)
* Max texture size: -1059701680
* Extensions checked:
- GL_KHR_debug: no
- GL_EXT_unpack_subimage: yes
- OES_vertex_half_float: no
** (gtk4-demo.exe:14324): WARNING **: 19:16:41.468: Compile failure in
vertex shader:
ERROR: 0:7: 'gl_Position' : undeclared identifier
---8<---
Use GLES when EGL implementation is ANGLE.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
X11 does add an extra reference to surfaces that gets released when the
DestroyNotify event arrives.
Wayland doesn't ave such an event, so that reference never gets
released.
This fixes a copy/paste error introduced in commit 590f3dfa1f.
We want to remove the event queue from the list of event queues, not the
surface.
Otherwise the freed queue stays in the list and the next time an event
comes in, we access invalid memory.
Fixes thinko introduced in commit 7fafa5133b.
Luckily, we leak all surfaces, so this problem never occured.
Check if the driver supports MAILBOX and prefer using it; in its
absense, checkif the driver supports IMMEDIATE and prefer using
it; finally, if neither of them are supported, use the guaranteed
to be supported FIFO mode.
We want to keep the wl_surface around, because surfaces create their
resources on construct and keep them until destroyed. See the HWND ond
Windows and the XWindow on X11.
This is relevant for graphics resources, where we want to have access
to the VkSurface and eglSurface while the GdkSurface is hidden.
We also want these surfaces to be permanent and not change during the
lifetime of the GdkSurface.
What we can - and must - destroy however are the xdg surfaces, because
those handle visibility on screen.
And we also need to ensure no buffer is attached, so that during the
next creation of the xdg surface we don't get a protocol error.
gdk_wayland_surface_maybe_resize() just calls
gdk_wayland_surface_update_size(), so make all callers call that one
instead.
The check that it does is done by the other function again.
This workaround - were it ever to trigger - is broken today. It destroys
the wl_surface and all associated structs but does not recreate the
xdg_popup or xdg_toplevel struct, so it would cause a hidden window.
The workaround looked a lot different when it was introduced in commit
83b54bab57, too - both in what it did and
in what the vfuncs did that it called.
Basically what GL does, but without any debug or feature flag
to gatekeep it, since the Vulkan backend itself is experimental
already.
Ceil surface sizes, and floor coordinates, to the fractional scale
value.
Fractional scaling with the GL renderer is
experimental for now, so we disable it unless
GDK_DEBUG=gl-fractional is set.
This will give us time to work out the kinks.
This commit combines changes in the Wayland backend,
the GL context frontend, and the GL renderer to switch
them all to use the fractional scale.
In the Wayland backend, we now use the fractional scale
to size the EGL window.
In the GL frontend code, we use the fractional scale to
scale the damage region and surface in begin/end_frame.
And in the GL renderer, we replace gdk_surface_get_scale_factor()
with gdk_surface_get_scale().
Cairo can do that, so just enable it:
* Create surfaces with the correct fractionally scaled size.
* Set the Cairo surface's device scale to that number.
Instead of setting the buffer scale via the buffer-scale command, set it
via the viewport.
This technically allows setting fractional scales, but we're not doing
that.
April fools!
No, really.
The fractional scale protocol is just a way to track the surface scale,
but not a way to draw fractional content.
This commit uses it for that, so tht we don't rely on tracking outputs.
This also allows magnifiers etc to send us a larger (integer) scale if
they would like that, that is not represented by the outputs.
The Lunarg validation layers seem to have been deprecated in favour
of the Khronos ones. There's no reason not to have both, to accept
loading both - simultaneously, even.
Instead of passing a single, potentially massive rectangle that is
just the extents of the damage rect, collect and pass all damage
rects individually.
Add a new flag to track whether buffer scale is dirty or not,
and centralize calling wl_surface_set_buffer_scale() in a single
place: gdk_wayland_surface_sync_buffer_scale().
gdk_wayland_surface_sync_buffer_scale() is only called by
gdk_wayland_surface_sync(), which itself is called by the GL,
Vulkan, and Cairo contexts, right before submitting a frame.
This ensure that each frame has an up-to-date buffer scale.
This mimics how opaque and input regions are tracked.