Commit Graph

259 Commits

Author SHA1 Message Date
Emmanuele Bassi
105f1c9fd3 Control legacy GL context via environment variable
For testing purposes, we may want to force the creation of legacy GL
contexts via an environment variable.

https://bugzilla.gnome.org/show_bug.cgi?id=756142
2015-10-07 16:21:57 +01:00
Lars Uebernickel
a8e5cacb91 Allow overriding WM_CLASS from the command line
Even when the program itself calls gdk_set_program_class(). There's
currently no way for this function to be called without breaking gdk's
--class command line option, because you cannot call it before
gtk_init().

https://bugzilla.gnome.org/show_bug.cgi?id=747634
2015-05-10 22:40:37 -04:00
Emmanuele Bassi
eedbec2066 Make global GDK libgtk_only functions more private
The current way of exposing GDK API that should be considered internal
to GTK+ is to append a 'libgtk_only' suffix to the function name; this
is not really safe.

GLib has been using a slightly different approach: a private table of
function pointers, and a macro that allows accessing the desired symbol
inside that vtable.

We can copy the approach, and deprecate the 'libgtk_only' symbols in
lieu of outright removal.

https://bugzilla.gnome.org/show_bug.cgi?id=739781
2014-11-08 00:20:15 -05:00
Matthias Clasen
5d0d1e524e Export API to set GL flags
This will be used in the inspector.
2014-11-06 23:29:16 -05:00
Alexander Larsson
650c9f3b7e Add support for GDK_GL=texture-rectangles
This allows us to test our support for GL_ARB_texture_rectangle
2014-11-06 12:24:43 +01:00
Alexander Larsson
90a5fa80af Add GDK_GL env var and GdkGLFlags
This moves the GDK_ALWAYS_USE_GL env var to GDK_GL=always.
It also changes GDK_DEBUG=nogl to GDK_GL=disable, as GDK_DEBUG
is really only about debug loggin.

It also adds some completely new flags:

 software-draw-gl:
   Always use software fallback for drawing gl content to a cairo_t.
   This disables the fastpaths that exist for drawing directly to
   a window and instead reads back the pixels into a cairo image
   surface.

 software-draw-surface:
   Always use software fallback for drawing cairo surfaces onto a
   gl-using window.  This disables e.g. texture-from-pixmap on X11.

 software-draw:
   Enables both the above.
2014-11-06 12:24:43 +01:00
Benjamin Otte
672a67d0af gdk: Add GDK_DEBUG=nogl
This is mostly useful for fallback testing.

I suppose if people want finer grained GL ability testing, they can use
Mesa environment variables to tune things.
2014-10-16 03:33:15 +02: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
Emmanuele Bassi
79c3ff3c4e threads: Do not release the GDK lock if it hasn't been acquired yet
Since GLib ≥ 2.41, attempting to release an unlocked mutex will abort(),
as it happens on most systems already.

Given the lack of proper documentation on how to use GDK with threads,
there is code in the wild that does:

    gdk_threads_init ();
    gdk_init ();

    ...

    gtk_main ();

instead of the idiomatically correct:

    gdk_threads_init ();
    gdk_threads_enter ();

    gtk_init ();

    ...

    gtk_main ();

    ...

    gdk_threads_leave ();

Which means that gtk_main() will try to release the GDK lock, and thus
trigger an error from GLib.

we cannot really fix all the wrong code everywhere, and since it does
not cost us anything, we can work around the issue inside GDK itself, by
trying to acquire the GDK lock inside gdk_threads_leave() with
trylock().

https://bugzilla.gnome.org/show_bug.cgi?id=735428
2014-08-26 20:07:33 -04:00
Evan Nemerson
38d2458f53 gdk: add many missing (nullable) return value annotations
https://bugzilla.gnome.org/show_bug.cgi?id=729834
2014-05-11 11:48:32 -04:00
Matthias Clasen
f66e239fe4 Drop unneeded deprecation suppression
Removing this did not produce any deprecation warnings.
2014-05-02 18:50:52 -04:00
William Jon McCann
469d333aa2 docs: use Returns: consistently
Instead of Return value:
2014-02-19 18:56:05 -05:00
Matthias Clasen
c779b42476 Docs: use // for comments in examples
Without sgml mode, we can't escape /* as /* anymore,
so just switch to // for comments in examples.
2014-02-14 23:34:22 -05:00
Jasper St. Pierre
1859d7631b gdkthreads: Update documentation 2014-02-07 18:01:16 -05:00
William Jon McCann
13998c55e7 docs: use proper quotations instead of '*' 2014-02-07 14:22:39 -05:00
William Jon McCann
e34bd4137d docs: use apostrophes in *n't 2014-02-07 13:32:47 -05:00
William Jon McCann
47469eb296 Use proper quotes in gdk 2014-02-05 15:08:42 -05:00
William Jon McCann
a22358c0c0 docs: use ` instead of <literal> 2014-02-04 18:24:29 -05:00
William Jon McCann
2dcbe27a06 docs: don't use <option> 2014-02-04 17:48:33 -05:00
William Jon McCann
a479ee5de5 docs: use markdown for <envar> tags 2014-02-04 16:58:53 -05:00
William Jon McCann
4c8bd8e7cf docs: Identify examples that are C code
https://bugzilla.gnome.org/show_bug.cgi?id=723119
2014-01-29 12:45:49 -05:00
William Jon McCann
768bc44081 docs: use |[ ]| instead of <programlisting></programlisting>
https://bugzilla.gnome.org/show_bug.cgi?id=723119
2014-01-29 12:45:49 -05:00
William Jon McCann
2d003553e8 docs: don't use <emphasis>
It is a little heavy handed. The text can speak for itself.
2014-01-28 02:02:05 -05:00
William Jon McCann
dc8439ee79 docs: add missing docs for GDK_WINDOWING_WAYLAND 2014-01-20 13:42:57 -05:00
Volker Sobek
a4d69e7f14 docs/comments: Fix spelling of 'explicitly'
This replaces all occurrences of 'explicitely' with 'explicitly'. Only
code comments and gtk-doc statements are affected.

https://bugzilla.gnome.org/show_bug.cgi?id=722429
2014-01-18 03:47:46 +01:00
Jasper St. Pierre
ddb4034e8e Fix GI warnings 2013-10-09 14:19:54 -04: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
John Ralls
3ca0a39fa9 Bug 606378 - gdk doesn't handle non-main thread rendering on Quartz
Document that the restrictions on Win32 apply also to Quartz.
2013-05-03 16:45:03 -07:00
Benjamin Otte
01c810b4d7 gdk: Remove new gdk_display_manager_peek() API
It's not necessary anymore because gdk_display_manager_get() always
succeeds and the value is independant of when it was called as it's no
longer backend specific.
2013-05-02 16:27:47 +02:00
Benjamin Otte
f73bf26df0 Deprecate gdk_get_display() 2013-04-01 14:20:47 +02:00
Benjamin Otte
cb2c47597e gdk: Shuffle code around
Make implementation, header and documentation be at the correct place.
2013-04-01 14:20:46 +02:00
Matthias Clasen
48d8af85d0 Make gdk_display_open_default_libgtk_only more robust
Make this function return NULL if GDK could not be
initialized. We check this by seeing if there is a
display manager singleton.
2013-03-23 19:40:16 -04:00
Thomas Wood
3a9de35a6c gdk: Implement GInitable on GdkDisplayManager
Add GInitable interface with a default implementation that always
succeeds. This allows backends to override the GInitable implementation
and add their own checks to determine if the backend can be loaded.  If
a backend cannot be loaded, GDK can attempt to load the next available
backend.

Since backends may need to read any relevant options (such as the
display flag) to determine if they can be created successfully, this
patch also removes calls that attempt to create the display manager
before the options have been parsed.

https://bugzilla.gnome.org/show_bug.cgi?id=694465
2013-03-22 22:23:39 -04:00
Benjamin Otte
8857766b5a gdk: Add a debug category for settings 2013-02-19 14:33:36 +01:00
Owen W. Taylor
8855bf052d Add GDK_DEBUG=frames
Add a debug option to print out detailed statistics about each frame drawn.

https://bugzilla.gnome.org/show_bug.cgi?id=685460
2013-02-14 17:19:51 -05:00
Matthias Clasen
9ebeb4e68a Bump GLib dependency to 2.35
And drop deprecated g_type_init() calls.
2012-11-04 13:01:38 -05:00
Matthias Clasen
8f55b2775a Expand the thread deprecation documentation
The story is slightly different for applications vs libraries;
make it clear that libraries should continue using the lock so
we don't break applications that haven't been ported to the
'single thread' model yet.
2012-08-01 10:26:17 +02:00
Matthias Clasen
b936666b52 Improve threading documentation
This commit just adds a small section to the threading documentation
about the deprecation. More is needed here, including a migration
example.
2012-07-30 18:01:47 +02:00
Matthias Clasen
0ac56e9dcc gdk: Deprecate thread functions
This commit deprecates gdk_threads_init, gdk_threads_enter,
gdk_threads_leave and gdk_threads_set_lock_functions. Using GTK+
from multiple threads does not work at all on Windows, and is
problematic on other platforms as well. We want to move to a world
where all GTK+ calls are made from the main thread.
Use g_main_context_invoke, g_idle_add and related functions if you
need to schedule GTK+ calls from other threads.

http://bugzilla.gnome.org/show_bug.cgi?id=680754
2012-07-30 18:01:47 +02:00
Matthias Clasen
144a5687c9 gdk: Don't use GDK_THREADS_ENTER/LEAVE macros internally
These are just wrappers for the functions, and we want to
deprecate them. Stopping to use them internally is a good
first step.
2012-07-30 18:01:47 +02:00
Javier Jardón
9d0febc9a6 Change FSF Address 2012-02-27 17:06:11 +00:00
Matthias Clasen
f6d8c8a717 Add some documentation around deprecations 2012-02-27 07:56:29 -05:00
Matthias Clasen
585a6652d5 Use G_SOURCE_CONTINUE/REMOVE
Now that GLib provides these macros, we should use them
to make the code more readable.
2012-01-30 19:12:27 -05:00
Matthias Clasen
b6ae763e25 Drop references to g_thread_init()
We are already requiring GLib 2.31, so g_thread_init() is never
needed anymore.
2011-11-09 18:36:35 -05:00
Matthias Clasen
c3d2df4eab GDK: Adapt to GLib thread api changes 2011-11-01 21:11:04 -04:00
Javier Jardón
7c688cb8a6 gdk: Use const instead G_CONST_RETURN 2011-06-10 13:07:54 +01:00
Benjamin Otte
2a2ad8523f gdk: Add GDK_RENDERING environment variable
It's useful for debugging rendering issues, both correctness and
performance wise.

See the added documentation for what it does and how it works.
2011-03-11 02:10:47 +01:00
Alexander Larsson
a3b2840cae Remove support for GDK_NATIVE_WINDOWS
GDK_NATIVE_WINDOWS was a way to keep some old apps running that did weird
things in gtk2. We should not have to carry this forwards in gtk 3.x.

We do however keep a g_warning() call reminding people of this fact to
ease debugging when they try to port their applications.

https://bugzilla.gnome.org/show_bug.cgi?id=644119
2011-03-08 23:13:39 +01:00
Matthias Clasen
1f4bb70bac Give the GDK docs some love
Reorganize some sections, drop the largely redundant multihead
section, add some more information about multiple backends.
2011-02-09 01:32:24 -05:00
Benjamin Otte
ec750bed0c gdk: Remove colormap debug category
We don't have colormaps anymore.
2011-01-21 02:54:09 +01:00