Commit Graph

80 Commits

Author SHA1 Message Date
Benjamin Otte
64f10eff20 gdk: Remove unused gdk_gl_texture_quads() function
That function carried a lot of baggage.
2021-10-06 03:44:36 +02:00
Benjamin Otte
111c2769a5 cairo-gl: Don't leak framebuffers
The framebufffer was cached, but never deleted. And because this
function is deprecated and nobody should ever use it: Don't bother with
caching now.
2021-10-06 03:44:36 +02:00
Benjamin Otte
a29474567a gdk: Remove gdkinternals.h 2021-09-24 22:50:29 +02:00
Benjamin Otte
cbe6d0da76 gdk: Deprecate gdk_cairo_draw_from_gl()
It's broken with various pixel formats and OpenGL ES, it's hard to
understand what everything does, and gdk_texture_download() can be used
instead.
2021-09-12 05:54:37 +02:00
Matthias Clasen
fff2b3c710 gdk: Clean up docs syntax
Replace leftover gtk-doc syntax (#Type) with backquotes.
2021-05-22 17:25:26 -04:00
Matthias Clasen
a9dd352986 gdk: Some more tweaks of the docs 2021-03-11 16:37:31 +00:00
xndcn
34ffdc6e3f gl: Fix implicit leaking of shader object
According to OpenGL spec, a shader object will only be flagged
for deletion unless it has been detached; when a program object
is deleted, those shader objects attached to it will be detached
but not deleted unless they have already been flagged for deletion.

So we shall detach a shader object before it is deleted, and delete
it before the program object is deleted best.
2020-12-29 23:50:45 +08:00
Timm Bäder
9698cd67a1 gdkgl: Remove flipping when downloading GL texture
This fix is correct and fixes:

  1) GL textures being upside down in the inspector. They are getting
     downloaded because they've been created in a different GL context
  2) GL textures being upside down in the cairo renderer (same reason)

However, it breaks the testsuite. We do the flipping via the projection
matrix, but most of the shaders don't care about that.
2020-10-14 15:06:12 -04:00
Timm Bäder
d4efb5b738 gdkgl: Stop getting the clip region from cairo
Unused
2020-10-14 15:06:12 -04:00
Timm Bäder
904772c719 gdkgl: Rename function
This returns the name of the shader type.
2020-10-14 15:06:12 -04:00
Timm Bäder
9f574a596f gdkgl: Remove unused cairo_get_matrix() call 2020-10-14 15:06:12 -04:00
Alexander Larsson
a299bbfc58 Drop gdk_cairo_surface_upload_to_gl() helper
There is nothing really special about this code, its just a helper for
uploading pixel data to opengl, and we're not really in the business
of doing opengl-specific helper functions.
2020-09-25 15:00:07 +02:00
Alexander Larsson
1001995d49 Correctly upload textures for GLES
GLES doesn't support the GL_BGRA +  GL_UNSIGNED_INT_24_8 hack that
we use on desktop OpenGL to upload textures directly in the cairo
pixel format. This adds the required conversions to all the places
that currently need it.

We also add a data_format to the internal gdk_gl_context_upload_texture()
function to make it clearer what the format are. Currently it is always
the cairo image surface format, but eventually we want to support other
formats so that we can avoid some of the unnecessary conversions we do.

Also, the current gdk_gl_context_upload_texture() code always converts
to a cairo format and uploads that like we did before. Later commits
will allow this to use other upload formats that gl supports to avoid
conversions.
2020-09-25 09:31:43 +02:00
Chun-wei Fan
cf0175ffce OpenGL/ES: Fix 'R' and 'B' bits inverted on Windows
We need to use GL_BGRA instead of GL_RGBA when doing glReadPixels() on
EGL on Windows (ANGLE) so that the red and blue bits won't be displayed
inverted.

Also fix the logic where we determine whether to bit blit or redraw
everything.
2020-07-30 14:30:13 +08:00
Emmanuel Gil Peyrot
404d79153e Switch to GL_ARB_framebuffer_object
GTK 4.0 was currently using GL_EXT_framebuffer_object, which is
deprecated as the ARB version has been merged into OpenGL 3.0 as well as
OpenGL ES 2.0, and provides laxer requirements.

This is a port of !2076 for 4.x.
2020-06-12 15:08:44 +02:00
Matthias Clasen
45f162fc50 gdk: Remove an unused texture api
gdk_gl_texture_from_surface wasn't used anywhere,
so lets drop it.
2020-05-26 20:43:47 -04:00
Emmanuele Bassi
62352dd1fc Fix compiler warnings in the release build
We have a bunch of debug-only variables that get set and never used
outside of debug code paths, and the compiler is not happy about it.
2020-02-11 13:39:52 +00:00
Matthias Clasen
397b8ee9d5 docs: Its just GTK now
Another round of + removal.
2019-02-24 13:33:36 -05:00
Benjamin Otte
a6553b0e20 gdk: Remove unused GL setting 2018-04-24 23:16:12 +02:00
Alexander Larsson
3dce0dcca7 GdkSurface: Rename lots of stuff from window->surface
Mostly these are internal things, but the major public change is
that event.window is now event.surface.
2018-03-20 15:14:10 +01:00
Alexander Larsson
9a7e721181 GdkSurface: Rename various functions and variables
This is an automatic rename of various things related
to the window->surface rename.

Public symbols changed by this is:
 GDK_MODE_WINDOW
 gdk_device_get_window_at_position
 gdk_device_get_window_at_position_double
 gdk_device_get_last_event_window
 gdk_display_get_monitor_at_window
 gdk_drag_context_get_source_window
 gdk_drag_context_get_dest_window
 gdk_drag_context_get_drag_window
 gdk_draw_context_get_window
 gdk_drawing_context_get_window
 gdk_gl_context_get_window
 gdk_synthesize_window_state
 gdk_surface_get_window_type
 gdk_x11_display_set_window_scale
 gsk_renderer_new_for_window
 gsk_renderer_get_window
 gtk_text_view_buffer_to_window_coords
 gtk_tree_view_convert_widget_to_bin_window_coords
 gtk_tree_view_convert_tree_to_bin_window_coords

The commands that generated this are:

git sed -f g "GDK window" "GDK surface"
git sed -f g window_impl surface_impl
(cd gdk; git sed -f g impl_window impl_surface)
git sed -f g WINDOW_IMPL SURFACE_IMPL
git sed -f g GDK_MODE_WINDOW GDK_MODE_SURFACE
git sed -f g gdk_draw_context_get_window gdk_draw_context_get_surface
git sed -f g gdk_drawing_context_get_window gdk_drawing_context_get_surface
git sed -f g gdk_gl_context_get_window gdk_gl_context_get_surface
git sed -f g gsk_renderer_get_window gsk_renderer_get_surface
git sed -f g gsk_renderer_new_for_window gsk_renderer_new_for_surface

(cd gdk; git sed -f g window_type surface_type)
git sed -f g gdk_surface_get_window_type gdk_surface_get_surface_type

git sed -f g window_at_position surface_at_position
git sed -f g event_window event_surface
git sed -f g window_coord surface_coord
git sed -f g window_state surface_state
git sed -f g window_cursor surface_cursor
git sed -f g window_scale surface_scale
git sed -f g window_events surface_events
git sed -f g monitor_at_window monitor_at_surface
git sed -f g window_under_pointer surface_under_pointer
(cd gdk; git sed -f g for_window for_surface)
git sed -f g window_anchor surface_anchor
git sed -f g WINDOW_IS_TOPLEVEL SURFACE_IS_TOPLEVEL
git sed -f g native_window native_surface
git sed -f g source_window source_surface
git sed -f g dest_window dest_surface
git sed -f g drag_window drag_surface
git sed -f g input_window input_surface

git checkout NEWS* po-properties po docs/reference/gtk/migrating-3to4.xml
2018-03-20 12:05:26 +01:00
Alexander Larsson
391727bd0d GdkWindow -> GdkSurface initial type rename
This renames the GdkWindow class and related classes (impl, backend
subclasses) to surface. Additionally it renames related types:
GdkWindowAttr, GdkWindowPaint, GdkWindowWindowClass, GdkWindowType,
GdkWindowTypeHint, GdkWindowHints, GdkWindowState, GdkWindowEdge

This is an automatic conversion using the below commands:

git sed -f g GdkWindowWindowClass GdkSurfaceSurfaceClass

git sed -f g GdkWindow GdkSurface
git sed -f g "gdk_window\([ _\(\),;]\|$\)" "gdk_surface\1" # Avoid hitting gdk_windowing
git sed -f g "GDK_WINDOW\([ _\(]\|$\)" "GDK_SURFACE\1" # Avoid hitting GDK_WINDOWING
git sed "GDK_\([A-Z]*\)IS_WINDOW\([_ (]\|$\)" "GDK_\1IS_SURFACE\2"
git sed GDK_TYPE_WINDOW GDK_TYPE_SURFACE
git sed -f g GdkPointerWindowInfo GdkPointerSurfaceInfo

git sed -f g "BROADWAY_WINDOW" "BROADWAY_SURFACE"
git sed -f g "broadway_window" "broadway_surface"
git sed -f g "BroadwayWindow" "BroadwaySurface"
git sed -f g "WAYLAND_WINDOW" "WAYLAND_SURFACE"
git sed -f g "wayland_window" "wayland_surface"
git sed -f g "WaylandWindow" "WaylandSurface"
git sed -f g "X11_WINDOW" "X11_SURFACE"
git sed -f g "x11_window" "x11_surface"
git sed -f g "X11Window" "X11Surface"
git sed -f g "WIN32_WINDOW" "WIN32_SURFACE"
git sed -f g "win32_window" "win32_surface"
git sed -f g "Win32Window" "Win32Surface"
git sed -f g "QUARTZ_WINDOW" "QUARTZ_SURFACE"
git sed -f g "quartz_window" "quartz_surface"
git sed -f g "QuartzWindow" "QuartzSurface"

git checkout NEWS* po-properties
2018-03-20 11:40:08 +01:00
Matthias Clasen
4c150d8eb5 The big versioning cleanup
Remove all the old 2.x and 3.x version annotations.
GTK+ 4 is a new start, and from the perspective of a
GTK+ 4 developer all these APIs have been around since
the beginning.
2018-02-06 01:16:32 -05:00
Matthias Clasen
e151058dff Make gdk logging per-display
As far as possible, use per-display debug flags.

This will minimize the debug spew that we get from
the inspector if it is running on a separate display.
2018-01-14 17:05:04 -05:00
Matthias Clasen
c5fc841285 gdk: Reorganize env vars
Drop GDK_GL, GDK_VULKAN and GDK_RENDERING_MODE.
Merge the useful bits into GDK_DEBUG.
Drop unused debug flags (CURSOR).
2018-01-14 17:05:04 -05:00
Matthias Clasen
4dbae1d4bf Drop unused GDK_GL values
And document the existing ones.
2018-01-10 00:02:23 -05:00
Benjamin Otte
43c212ac28 build: Enable -Wswitch-enum and -Wswitch-default
This patch makes that work using 1 of 2 options:

1. Add all missing enums to the switch statement
  or
2. Cast the switch argument to a uint to avoid having to do that (mostly
   for GdkEventType).

I even found a bug while doing that: clearing a GtkImage with a surface
did not notify thae surface property.

The reason for enabling this flag even though it is tedious at times is
that it is very useful when adding values to an enum, because it makes
GTK immediately warn about all the switch statements where this enum is
relevant.
And I expect changes to enums to be frequent during the GTK4 development
cycle.
2017-10-06 21:23:39 +02:00
Benjamin Otte
bddfd7bb41 gdk: Remove all code that only existed because of use_gl
Now that we don't use GL anymore, this code is unnecessary.
2016-12-05 15:02:47 +01:00
Benjamin Otte
c162b87ebd gdk: Fix a variable
The passed in surface is the current_paint surface, so I guess this
usage hasn't been noticed.
2016-11-17 22:11:33 +01:00
Benjamin Otte
3d8b00600e gdkgl: Change prototype of function
The function does not upload a cairo surface, it uploads pixel data.

So don't take a cairo surface as an argument, take pixel data.
2016-11-01 16:32:26 +01:00
Rico Tzschichholz
6fb8f61124 gdk: Fix Since tag of gdk_cairo_surface_upload_to_gl 2016-10-18 13:38:08 +02:00
Alexander Larsson
1c7c77bc94 gdk_cairo_surface_upload_to_gl: Don't apply device scale
The arguments to this function is the texture width/height, and these
are already scaled.
2016-10-18 11:49:14 +01:00
Emmanuele Bassi
b425cff689 gdk: Add utility for uploading Cairo surfaces to GL
The surface-to-GL upload logic has become more complicated with the
addition of the GLES code paths; it's more logical to have a public
utility function that can be called from GDK users, instead of copy
pasting the whole thing multiple times.
2016-10-18 11:29:34 +01:00
Emmanuele Bassi
f848450a70 gl: Use a uniform to flip R and B colors on GLES
This allows us to decide when the R and B color channels should be
flipped with a much better granularity.

For instance, when using GLX_EXT_texture_from_pixmap to create a GL
texture from a surface we don't need to swap the R and B channels, as
the internal representation of the texture data will already have the
appropriate colors.

We also don't need to flip color channels when blitting from a texture.
2016-04-25 14:33:36 +01:00
Emmanuele Bassi
a942e96c8f gl: Use the appropriate formats when reading buffers on GLES
We cannot use GL_BGRA and GL_UNSIGNED_INT_8_8_8_8_REV when reading back
from the frame buffer in the software fallback path, as they do not
exist on OpenGL ES.

This will make the slow path a bit slower, because of the implicit
format conversion.
2016-04-25 12:29:37 +01:00
Emmanuele Bassi
1620b7bda7 gl: Add more OpenGL ES checks
Check for the appropriate extensions depending on which type of API
we're using.
2016-04-25 12:29:36 +01:00
Emmanuele Bassi
8bb4eb5544 gdk: Add GLES shaders
We cannot use GL shaders with GLES.
2016-04-25 12:29:36 +01:00
Emmanuele Bassi
55537cccbd gdk: Move GLSL shaders into GResource
Having the shaders inlined as C strings makes them harder to edit and
maintain.
2016-04-25 12:29:36 +01:00
Matthias Clasen
1c887b2287 gdk: Strip newlines from g_warning and g_error
g_logv adds one for us already.
2016-02-28 12:23:12 -05:00
Emmanuele Bassi
e636c316a6 gl: Use older GLSL shaders with legacy contexts
If we're using modern GLSL, then we should stop using deprecated
modifiers, like 'varying' and 'attribute', as well as deprecated global
variables, like 'gl_FragColor'.

On the other hand, with legacy contexts we should be using older GLSL
shaders, to maximize compatibility.

https://bugzilla.gnome.org/show_bug.cgi?id=756142
2015-10-07 16:21:57 +01:00
Matthias Clasen
fbbb3d1816 Fix some clang warnings
It complains about double const, and it is right.
2015-03-22 14:40:57 -04:00
Emmanuele Bassi
03f5d5a5e4 gl: Put shaders in static storage
We are not changing the shader code.

The compiler will hopefully put them in the .rodata section.
2015-02-10 03:33:02 +00:00
Niels Nesse
50187ae86d gdkgl should use shader version 1.50
Using version 1.20 with a forward compatible 3.2 core context is incorrect
since OpenGL 3.2 deprecates shader version 1.20 (See section E.2). The latest
fglrx drivers will not compile these shaders.

https://bugzilla.gnome.org/show_bug.cgi?id=744203
2015-02-10 03:30:09 +00:00
Emmanuele Bassi
843475bd2e gl: Drop GdkGLContextClass.upload_texture()
It's unnecessary to allow per-backend overrides.
2015-02-09 19:10:31 +00:00
Emmanuele Bassi
395125bcfb gl: Do not use the extension API for core GL
Since we are using a Core GL profile, we need to drop the
extension-based API.

https://bugzilla.gnome.org/show_bug.cgi?id=741946
2015-02-09 19:10:30 +00:00
Niels Nesse
27cf0fa34c Fix core context creation in GdkGLContext
- Specifically request GL version when creating context. Just specifying core
profile bit results in the requested version defaulting to 1.0 which causes
the core profile bit to be ignored and an arbitrary compatability context to be
returned.

- Fix GL painting by removing GL calls that have been depricated by the 3.2 core
profile.

- Additionally remove glInvalidateFramebuffer() call, it is not supported by 3.2
core.

https://bugzilla.gnome.org/show_bug.cgi?id=742953
2015-01-28 12:00:30 +00:00
Chun-wei Fan
9fd9f61b00 gdkgl: Use vfunc For Uploading Textures
As the alignments, strides and image formats may be different across
platforms, make the texture upload a vfunc to allow backends to override
the GL commands for uploading textures for the software implementation for
gdk_gl_texture_from_surface(), if necessary.

Suggested by Alex to avoid copying non-trivial portions of code which would
then add maintainenace burden.

https://bugzilla.gnome.org/show_bug.cgi?id=740795
2014-12-17 16:06:25 +08:00
Alexander Larsson
a1a01983f7 gdk: Fix scissoring with scaled windows
Make sure the window scale is always taken into acount when setting up
the scissor regions.
2014-12-15 22:31:48 +01:00
Alexander Larsson
2693496b56 gdk_gl_texture_from_surface - fix software fallback
We can't combine multiple draws into one for the software fallback,
because each quad has a different texture. And we generally don't
want to make a larger single texture because then we would have
to upload more data.
2014-12-15 21:57:02 +01:00
Alexander Larsson
4a4125bcfc gdk_cairo_draw_from_gl - fix drawing with alpha on window scale > 1
The scissoring needs to take into account the window scale.
2014-12-15 21:57:02 +01:00