Commit Graph

56 Commits

Author SHA1 Message Date
Matthias Clasen
ed265f6a7e gdk: Deprecated some pixbuf apis
These are already documented as 'don't use
in new apis'. Lets make it official and
deprecate them properly.
2023-05-15 18:22:37 -04:00
Emmanuele Bassi
9d68bebdd1 Minimize the amount of inclusions in public headers
Public headers should mainly include gdktypes.h, which already include
the symbol visibility and versioning macros; we can also modify
gdktypes.h to include the enumerations.
2023-05-09 17:36:59 +01:00
Matthias Clasen
383c404792 Drop the gdk/gdkversionmacros.h header
It was just added to avoid touching too many files.
Touching them now.
2023-05-09 16:43:35 +01:00
Matthias Clasen
a1c5a806b3 Convert headers to #pragma once
The conversion was done by guard2one.
2023-03-31 15:11:10 -04: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
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
Benjamin Otte
3078b180fe Replace "gdouble" with "double" 2020-07-25 00:47:36 +02:00
Benjamin Otte
052d0f6e60 gdk: Remove gdk_cairo_get_clip_rectangle()
The function is fundamentally broken for unbounded surfaces.
If a surface is unbounded, we cannot represent this as a
cairo_rectangle_int_t, and using the return value doesn't work because
it's already used for something else.

In GTK3, unbounded surfaces aren't a problem, but GTK4 uses recording
surfaces.

So better remove that function before we keep using it and using it
wrong.
2020-02-13 07:36:38 +01:00
Benjamin Otte
7e8d8218b9 Revert "Break out cairo color matrix recoloring to gdk_cairo_image_surface_recolor()"
We're not in the business of adding Cairo APIs. That's Cairo's job.

Also, we don't need this API anywhere like the original commit claimed,
so there's no need to make it available in any way.

This reverts commit afa6cc2369.
2020-02-04 16:43:59 +01:00
Alexander Larsson
5f8c2b52c6 indentation: fix various alignment issues
Most of these stem from the GtkIconInfo -> GtkIcon rename
2020-01-30 12:27:15 +01:00
Alexander Larsson
afa6cc2369 Break out cairo color matrix recoloring to gdk_cairo_image_surface_recolor()
This is useful in some parts of the icon theme APIs.
2020-01-29 19:06:16 +01:00
Emmanuele Bassi
def700739d Use a single compilation symbol
We use a compilation symbol in our build to allow the inclusion of
specific headers while building GTK, to avoid the need to include only
the global header.

Each namespace has its own compilation symbol because we used to have
different libraries, and strict symbol visibility between libraries;
now that we have a single library, and we can use private symbols across
namespaces while building GTK, we should have a single compilation
symbol, and simplify the build rules.
2019-11-27 13:33:43 +00:00
Benjamin Otte
48fc18c37b gdk: Get rid of GdkDrawingContext
All information is kept in GdkDrawContext these days, so use that one.
2018-04-24 23:16:58 +02:00
Benjamin Otte
7ef8696a7d gdk: Remove gdk_cairo_surface_create_from_pixbuf()
It's unused and people should use textures and snapshots anyway.
2018-04-12 14:04:20 +02:00
Benjamin Otte
3a1c69dce6 gdk: Remove gdk_cairo_get_drawing_context()
It's unused.
2018-04-12 14:03:40 +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
Benjamin Otte
e62a4d8eea API: gdk: Remove ability to render window contents
The functions gdk_pixbuf_get_from_window() and
gdk_cairo_set_source_window() are unreliable and depend on the windowing
system (they work great on X11 and Win32, less so on Quartz and Wayland).

With the switch to new drawing API and OpenGL, we can definitely no
longer support a generic way to snapshot windows.

People should either write windowsystem-specific code or draw their
widgets directly - like with gtk_widget_draw() - if they need to get a
rendering.
2016-11-20 11:47:44 +01:00
Matthias Clasen
7a2537866b Drop GdkColor
It is deprecated and no longer used.
2016-11-01 13:58:11 -04:00
Rico Tzschichholz
7630c86468 gdk: Remove deprecated gdk_cairo_set_source_color 2016-10-24 10:36:55 +02: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
Benjamin Otte
a65a4de38d gdk: Remove old code to create drawing context
You now have to use a GdkDrawingContext
2016-10-16 18:18:58 +02:00
Emmanuele Bassi
ad78daaf80 gdk: Deprecate gdk_cairo_create()
We have GdkDrawingContext, now, which is in charge of creating Cairo
contexts for drawing on a GdkWindow.

https://bugzilla.gnome.org/show_bug.cgi?id=766675
2016-06-09 17:45:40 +01:00
Emmanuele Bassi
dda6a0d385 Associate the drawing context to the Cairo context
Instead of associating the GdkWindow that created the GdkDrawingContext
we can directly bind the Cairo context to the GDK drawing context.

Cairo contexts created via gdk_cairo_create() go back to not having a
GdkWindow associated to them, like they did before we introduced the
gdk_window_begin_draw_frame() API.

https://bugzilla.gnome.org/show_bug.cgi?id=766675
2016-06-09 17:45:40 +01:00
Emmanuele Bassi
fc569f1ac6 Add frame drawing API to GdkWindow
Existing code drawing on a GDK window has to handle the direct drawing
and the buffered drawing by itself, by checking the window type and
whether or not the window is backed by a native windowing surface. After
that, the calling code has to create a Cairo context from the window and
keep an association between the context and the window itself.

This is completely unnecessary: GDK can determine whether or not it
should use a backing store to draw on a GdkWindow as well as create a
Cairo context, and keep track of it.

This allows to simplify the calling code, and enforce some of the
drawing behavior we want to guarantee to users.

https://bugzilla.gnome.org/show_bug.cgi?id=766675
2016-06-09 17:45:40 +01:00
Alexander Larsson
038aac6275 gdk: Add support for OpenGL
This adds the new type GdkGLContext that wraps an OpenGL context for a
particular native window. It also adds support for the gdk paint
machinery to use OpenGL to draw everything. As soon as anyone creates
a GL context for a native window we create a "paint context" for that
GdkWindow and switch to using GL for painting it.

This commit contains only an implementation for X11 (using GLX).

The way painting works is that all client gl contexts draw into
offscreen buffers rather than directly to the back buffer, and the
way something gets onto the window is by using gdk_cairo_draw_from_gl()
to draw part of that buffer onto the draw cairo context.

As a fallback (if we're doing redirected drawing or some effect like a
cairo_push_group()) we read back the gl buffer into memory and composite
using cairo. This means that GL rendering works in all cases, including
rendering to a PDF. However, this is not particularly fast.

In the *typical* case, where we're drawing directly to the window in
the regular paint loop we hit the fast path. The fast path uses opengl
to draw the buffer to the window back buffer, either by blitting or
texturing. Then we track the region that was drawn, and when the draw
ends we paint the normal cairo surface to the window (using
texture-from-pixmap in the X11 case, or texture from cairo image
otherwise) in the regions where there is no gl painted.

There are some complexities wrt layering of gl and cairo areas though:
* We track via gdk_window_mark_paint_from_clip() whenever gtk is
  painting over a region we previously rendered with opengl
  (flushed_region). This area (needs_blend_region) is blended
  rather than copied at the end of the frame.
* If we're drawing a gl texture with alpha we first copy the current
  cairo_surface inside the target region to the back buffer before
  we blend over it.

These two operations allow us full stacking of transparent gl and cairo
regions.
2014-10-13 10:43:31 -04:00
Matthias Clasen
49cf5142ba Deprecate GdkColor
It has been replaced by GdkRGBA. Time to make it official.
http://bugzilla.gnome.org/show_bug.cgi?id=636695
2014-05-22 09:09:55 -04:00
Alexander Larsson
8524e0c150 gdk: Add gdk_cairo_surface_create_from_pixbuf 2013-07-03 14:34:13 +02:00
Matthias Clasen
ca81028901 Add GDK_AVAILABLE_IN_ALL annotations in gdk
This is in preparation to modernizing our handing
of exported symbols.
2013-05-05 15:38:46 -04:00
Matthias Clasen
5adecf183b Move single-include guards inside include guards
gcc has optimizations for include guards that only work
if they are outermost in the the header.
https://bugzilla.gnome.org/show_bug.cgi?id=689810
2012-12-28 09:57:56 -05:00
Javier Jardón
9d0febc9a6 Change FSF Address 2012-02-27 17:06:11 +00:00
Matthias Clasen
d36c10bc03 gdk: Use versioned deprecations
This patch changes all uses of GDK_DEPRECATED(_FOR) in gdk headers
by the versioned variants, GDK_DEPRECATED_IN_3_x(_FOR). At the same
time, we add GDK_AVAILABLE_IN_3_x annotations for all API additions
in 3.2 and 3.4.
2012-02-27 07:11:43 -05:00
Javier Jardón
a3abc18858 Deprecate all the public API that is using GdkColor struct 2011-12-22 02:59:39 +00:00
Matthias Clasen
251ee41d8d Revert "Clean up includes"
This reverts commit c5e4af761c.
2011-11-22 13:41:59 -05:00
Matthias Clasen
c5e4af761c Clean up includes
There's no sign of Pango in this header, so no need to include
pangocairo.h
2011-11-22 08:25:24 -05:00
Matthias Clasen
8291530abf More GDK documentation tweaks 2011-02-09 02:44:19 -05:00
Benjamin Berg
e8c103f652 Use cairo gobject support instead of a new boxed type. 2010-12-04 15:38:20 +01:00
Carlos Garnacho
02a30118c6 Add a boxed type for cairo_pattern_t. 2010-12-04 15:38:11 +01:00
Benjamin Otte
97e6e9d212 API: Make gdk_cairo_create() take a GdkWindow
This is not strictly an API change as GdkDrawable is typedeffed to
GdkWindow, but it changes the header, so I'm marking it as such.
gdk_cairo_create() can only be used with windows these days, so it makes
sense to pass a window. With that, we can alseo remove the
set_cairo_clip() vfunc from GdkDrawable and implement it inside
gdkwindow.c.
2010-12-02 20:17:28 +01:00
Benjamin Otte
65dde2f92f API: Remove gdk_cairo_reset_clip()
You should not ever ever ever call cairo_reset_clip(). If you do, your
code is broken and you deserve everything you get.
And we should definitely not support this insanity.
2010-12-02 20:17:28 +01:00
Carlos Garnacho
5a5f8081f0 Add GdkRGBA struct to supersede GdkColor
GdkRGBA is a boxed struct similar to GdkColor, with the difference
that it stores alpha information as well, and colors are stored in
[0..1] doubles, in the cairo spirit.

gdk_cairo_set_source_rgba() has been also added to allow easier handling
of this new type.
2010-10-22 20:14:56 +02:00
Benjamin Otte
d4f08efd57 API: add gdk_cairo_get_clip_rectangle() convenience API 2010-09-26 15:11:34 +02:00
Benjamin Otte
6607f2b794 API: Rename gdk_set_source_pixmap() to gdk_set_source_window()
That's what it's used for now.
2010-09-26 15:11:30 +02:00
Benjamin Otte
96b387599d API: Add gdk_cairo_region_create_from_surface()
The function converts the given surface into an alpha bitmap mask. This
is mostly useful for setting shape regions.

Also adds a new internal function _gdk_cairo_surface_extents() that
computes a surface's extents.
2010-09-26 15:02:59 +02:00
Benjamin Otte
300e6b84cd s/GdkRegion/cairo_region_t/ in all of gtk
https://bugzilla.gnome.org/show_bug.cgi?id=613284
2010-06-29 16:06:38 +02:00
Michael Natterer
5e29973773 Remove all traces of GDK_PIXBUF/GTK_DISABLE_SINGLE_INCLUDES
...and disallow inclusion of individual files unconditionally.
2010-05-03 01:51:18 +02:00
Matthias Clasen
d09d810261 Fix a typo 2009-09-04 23:27:37 -04:00
Alexander Larsson
45956aea21 Add gdk_cairo_reset_clip
This is required to get back the original drawable clip due to
non-native windows on a cairo_t.
2009-09-01 17:06:41 +02:00