Commit Graph

10178 Commits

Author SHA1 Message Date
Matthias Clasen
14280b5f5b contentdeserializer: Use our on jpeg loader 2021-09-17 02:02:51 +02:00
Matthias Clasen
e720f9d35d Add code to save jpegs 2021-09-17 02:02:51 +02:00
Benjamin Otte
679c93e843 texture: Add private can_load() function
... and use it to load textures in gtk_picture_set_from_file().
2021-09-17 00:25:22 +02:00
Benjamin Otte
2d3de8608c texture: Split out type detection
This way, the code using it becomes clearer and we can use it in
multiple places without accidentally doing it wrong (hint: see next
commit).
2021-09-17 00:25:22 +02:00
Benjamin Otte
100b0bf7d9 texture: Remove declaration for nonexisting function 2021-09-17 00:25:22 +02:00
Matthias Clasen
f2ca9ebbd7 texture: Avoid pixbufs when loading resources
We can just use our own loaders here now.
2021-09-17 00:25:22 +02:00
Benjamin Otte
b1bb7c3258 texture: Add gdk_texture_save_to_tiff_bytes() 2021-09-17 00:25:22 +02:00
Matthias Clasen
d27bc74481 Use our own loaders for content (de)serialization
Use our own loader to (de)serialiaze textures
to and from png and tiff.

We still fall back to gdk-pixbuf for handling all
the other image formats, and for pixbufs.
2021-09-17 00:25:22 +02:00
Matthias Clasen
daf29e174f Load jpegs without gdk-pixbuf
Use our own loader for jpeg files.
2021-09-17 00:25:22 +02:00
Matthias Clasen
729ba8111a Add code to load jpegs
This lets us avoid gdk-pixbuf for loading
textures from the common image formats.

As a consequence, we are now linking against libjpeg.
2021-09-17 00:25:22 +02:00
Matthias Clasen
d30a029689 Add gdk_texture_save_to_tiff
This is a companion to gdk_texture_save_to_png, using
the tiff format, which will let us avoid lossy conversion
of HDR data, since we can store floating point data.
2021-09-17 00:25:22 +02:00
Matthias Clasen
f925e12e1d Load tiffs without gdk-pixbuf
This will let us load floating point data, in
the future.
2021-09-17 00:25:22 +02:00
Matthias Clasen
a03594df52 Add code to load and save tiff files
Add support for the tiff format, which is flexible
enough to handle all our memory texture formats
without loss.

As a consequence, we are now linking against libtiff.
2021-09-17 00:25:22 +02:00
Matthias Clasen
d7c8f92733 Add gdk_texture_save_to_png_bytes
Just expose what we already have available
internally, so e.g. tests can use it without
static linking.
2021-09-17 00:25:22 +02:00
Matthias Clasen
7949aaabb7 Save pngs without cairo
Use our own loader for pngs, which will allow
us to save e.g. 16-bit data in the future.
2021-09-17 00:25:22 +02:00
Matthias Clasen
a71877bf99 Load pngs without gdk-pixbuf
Use our own loader for pngs, which will allow
us to get e.g. 16-bit data in the future.
2021-09-17 00:25:22 +02:00
Matthias Clasen
f51f7f85eb Add code to load and save pngs
Using libpng instead of the lowest-common-denominator
gdk-pixbuf loader. This will allow us to load >8bit data,
and apply gamma and color correction in the future.
For now, this still just provides RGBA8 data.

As a consequence, we are now linking against libpng.
2021-09-17 00:25:22 +02:00
Matthias Clasen
66031fd00b texture: Add error enum 2021-09-17 00:25:22 +02:00
Benjamin Otte
75dfb4d63b API: Add gdk_texture_new_from_filename()
There are quite a few places where we can make use of it, in particular
in the testsuite and icontheme.
2021-09-16 23:59:37 +02:00
Benjamin Otte
551f76ea69 gltexture: Fallback in download_float()
GLES only allows downloading float if the texture matches specific
criteria and I'm too lazy to determine them, so always fall back.

And the custom stride fallback code isn't necessary, because falling
back does exactly that step already.
2021-09-16 23:59:37 +02:00
Benjamin Otte
a4f3fbbda1 gltexture: Fix download() for GLES
GLES can't do glGetTexImage(), so implement a version that does
glReadPixels() on GLES.
2021-09-16 23:59:37 +02:00
Matthias Clasen
9f8d6ff29c texture: Mention download_float in the docs 2021-09-15 22:00:16 -04:00
Matthias Clasen
1230bce133 Add gdk_texture_new_from_bytes
Add this new api, and make gdk_texture_new_from_file
a wrapper around it.
2021-09-15 22:00:09 -04:00
Matthias Clasen
75b45aeabf Fix memorytexture float conversion
This was silently dropping the alpha in one case.
2021-09-15 21:14:59 -04:00
Matthias Clasen
38fce67a9b Annotate gdk_rgba_to_string as malloc 2021-09-14 16:38:08 -04:00
Matthias Clasen
04ef7055cd Annotate gdk_drag_action_is_unique as const 2021-09-14 16:38:08 -04:00
Matthias Clasen
ebca260f2d Annotate gdk_unichar_direction as const 2021-09-14 16:38:08 -04:00
Benjamin Otte
6785461c26 gltexture: Make sure downloading textures works in a different thread
This happens in the real world when using the inspector to look at a
node recording of a GStreamer video while the video is still playing.

GStreamer will use the GL context in a different thread while we are
busy trying to download it.

A test is included.
2021-09-13 01:40:03 +02:00
Benjamin Otte
719eafa60c gl: Implement uploading and downloading HDR formats
Also refactor the GL uploading so it does the fallback in a
GLES-compatible way, which means we only need one fallback.
2021-09-12 05:54:37 +02:00
Benjamin Otte
1759d27da9 memorytexture: Add support for HDR formats
Also sanitize the input bytes so the strides match alignment
requirements of the data types.
2021-09-12 05:54:37 +02:00
Benjamin Otte
53275481a5 texture: Add gdk_texture_download_float() 2021-09-12 05:54:37 +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
Benjamin Otte
c349ed9562 gltexture: Implement download() via glGetTexImage()
1. The download via gdk_cairo_draw_from_gl() was broken sometimes

2. We get easy conversion on fallback by chaining up and using
   download_texture().

3. One more place where Cairo is no longer necessary.
2021-09-12 05:22:21 +02:00
Benjamin Otte
74ce69a8a1 gltexture: Make release() use download_texture()
1. It avoids Cairo, and in particular conversion to Cairo.

2. Keeping a texture allows easy chaining in the vfuncs.

3. Using a texture means releasing will work for HDR formats
   too, once we add them.
2021-09-12 05:22:21 +02:00
Benjamin Otte
4f17f3ac24 texture: Add gdk_texture_download_texture()
A private vfunc that downloads a texture as a GdkMemoryTexture in
whatever format the texture deems best.

There are multiple reasons for this:

 * GLES cannot download the Cairo format. But it can download some
   format and then just delegate to the GdkMemoryTexture implementation.

 * All the other download vfuncs (including the ones still coming) can
   be implemented via download_texture() and delegation, making the
   interface easier.

 * We want to implement image loading and saving support. By using
   download_texture(), we can save in the actual format of the texture.

 * A potential GdkCompressedTexture could be implemented by just
   providing this one vfunc as a compress() step.
2021-09-12 05:22:21 +02:00
Benjamin Otte
9c8e464b04 texture: Add GdkMemoryConversion private enum
Now gdk_memory_convert() converts to one of these conversions instead of
re(ab)using parts of the GdkMemoryFormat enum.
2021-09-12 05:22:21 +02:00
Benjamin Otte
51d0d13a9e gltexture: release() to a texture, not a cairo_surface
This makes forwarding vfuncs a lot easier, because we can just call them
on the texture.
2021-09-12 05:22:21 +02:00
Benjamin Otte
0ee3b1c861 texture: Remove unused argument from vfunc 2021-09-12 05:22:21 +02:00
Benjamin Otte
9e11ea699c Merge branch 'hsl' into 'master'
gdk_rgba_parse: Support HSL colors

See merge request GNOME/gtk!3899
2021-09-11 12:57:25 +00:00
Matthias Clasen
c1c1d4431d Refactor gdk_gl_context_upload_texture slightly
Introduce a gl_internalformat variable. This will
let us handle more formats in a uniform way in
future commits.
2021-09-10 22:17:31 -04:00
James Westman
0782c8a051
gdk_rgba_parse: Support HSL colors 2021-09-10 16:56:42 -05:00
Matthias Clasen
a4f067481c gdk: Make GDK_DEBUG=default-settings unconditional
Our tests use this settings, so we should respect it
in non-debug builds as well.
2021-08-30 11:01:55 -04:00
Benjamin Otte
119458f13e contentdeserializer: Fix some API awkwardness
Allow uninitialized GValues to be passed. Makes life easier for the
inspector code I'm writing.
2021-08-30 06:02:16 +02:00
Benjamin Otte
3b15f32335 Merge branch 'wip/otte/symbolic-paintable' into 'master'
Add GtkSymbolicPaintable

See merge request GNOME/gtk!3895
2021-08-30 03:54:35 +00:00
Benjamin Otte
2f9a67b8a1 docs: Fix vfunc references
vfunc references should just use the object name, not the
class/interface/iface name.
2021-08-29 04:29:02 +02:00
Ian Douglas Scott
9e5a501c73 x11: Fix handling of RRScreenChangeNotify/RRNotify events
It seems these are sent with `xwindow` set to the root window, so this
was failing to find a surface and get the screen from that.

I'm not sure if there's a reason not to get the screen this way
elsewhere in the function, but it seems this should be correct.

This fixes the behavior of `gdk_x11_display_get_monitors()`, which
wasn't correctly changing when monitors were added or removed. For
instance, this python code was always showing the same number of
monitors when one was turned off and on, but updates correctly with this
change applied:

```python
import gi
gi.require_version("GLib", "2.0")
gi.require_version("Gdk", "4.0")
gi.require_version("Gtk", "4.0")
from gi.repository import GLib, Gdk, Gtk

def f():
    print(len(Gdk.Display.get_default().get_monitors()))
    return True
GLib.timeout_add_seconds(1, f)

GLib.MainLoop().run()
```
2021-08-27 18:07:39 -07:00
Matthias Clasen
e281bbbb55 Merge branch 'treeexpander-indent-property' into 'master'
GtkTreeExpander: indent-without-expander property

Closes #4175

See merge request GNOME/gtk!3858
2021-08-25 11:48:59 +00:00
Matthias Clasen
892bacee52 Merge branch '4195-include-gdkprivate-h' into 'master'
gdkmacoseventsource: Include "gdk-private.h"

Closes #4195

See merge request GNOME/gtk!3882
2021-08-25 11:48:11 +00:00
Peter Bloomfield
9eb8aa9a32 gdkmacoseventsource: Include "gdk-private.h"
_gdk_macos_event_source_new() calls g_source_set_static_name(), which
for GLib versions before 2.69.1 is a macro defined in gdk-private.h.

Fixes #4195

modified:   gdk/macos/gdkmacoseventsource.c
2021-08-24 16:55:52 -04:00
Benjamin Otte
95931a7e6c wayland: Better error on eglGetDisplay() failure
Goals:

1. Provide as much information as possible in the error message, so
   users can try to fix their system themselves.
2. Try to formulate the error message in a way that explains that this
   is not something GTK can fix, but a lower layer problem.

Related: #4193
2021-08-24 19:55:22 +00:00