Commit Graph

937 Commits

Author SHA1 Message Date
Matthias Clasen
d9b02ea4a3 gdk: Make debug-updates a per-display setting
Add private API to set this per-display, and make the existing
gdk_window_set_debug_update function set a global default.
2014-11-10 15:23:14 -05:00
Matthias Clasen
8338b7e4cd Move rendering mode into GdkDisplay
This is in preparation for making it runtime-settable in the
inspector.
2014-11-10 14:28:43 -05:00
Javier Jardón
710f332082 configure.ac: Depend on cairo 1.14.0
This is needed for cairo_set_device_scale()
2014-11-10 15:12:17 +00:00
Alexander Larsson
90555e06be gdk_window_end_paint: Flush destination surface after paint
It seems in cairo 1.14 we need this after having painted an image surface
to a X11 window surface (i.e. with GDK_RENDERING=image).
2014-11-10 15:25:31 +01:00
Emmanuele Bassi
cdcd3ca359 Hide GdkWindow libgtk_only API in the private vtable
These are the last two global GDK symbols that have a libgtk_only
suffix.

https://bugzilla.gnome.org/show_bug.cgi?id=739781
2014-11-08 00:20:15 -05:00
Emmanuele Bassi
585af218a3 Move GDK GL flags accessors to the private vtable
This allows us to use the GDK_PRIVATE_CALL macro inside gtk.

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
41bf293efd GdkWindow: Drop gl matrix setup which is not needed anymore. 2014-11-06 20:37:24 +01:00
Alexander Larsson
1f3f933edf GdkX11GLContext: Use bitblit for swap if no buffer age support
If buffer age is undefined and the updated area is not the whole
window then we use bit-blits instead of swap-buffers to end the
frame.

This allows us to not repaint the entire window unnecessarily if
buffer_age is not supported, like e.g. with DRI2.
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
Alexander Larsson
9372cbdbf8 GdkWindow: Try to use a Core 3.2 GL profile for the paint context
If this is supported we avoid a lot of legacy baggage which we don't
need.
2014-11-06 12:24:43 +01:00
Alexander Larsson
5f14630b76 GdkWindow: destroy paint gl context on destroy 2014-10-30 12:43:03 +01:00
Matthias Clasen
3f1dc87188 Plug another memory leak
Also found by valgrind.
2014-10-28 16:07:57 -04:00
Matthias Clasen
b673490a1b Document Wayland opacity handling 2014-10-28 10:48:49 -04:00
Matthias Clasen
4c69dabb6e Don't return GDK_GRAB_SUCCESS on failure
That seems ... counterproductive.
2014-10-28 00:51:32 -04:00
Matthias Clasen
d1dcac85f3 Mention the 'same display' requirement in the docs too 2014-10-28 00:44:33 -04:00
Jasper St. Pierre
52e3b88382 gdkwindow: Specify some invariants for cursors
Cursors should not be on a different display than their window /
device, as that would break Wayland.
2014-10-27 21:22:31 -07:00
Alexander Larsson
08d44648ea opengl: Use proper blend function for premultiplied alpha 2014-10-27 21:17:08 +01:00
Alexander Larsson
3013997e23 Rename gdk_gl_context_flush_buffer to gdk_gl_context_end_frame
This makes a lot more sense.
2014-10-27 16:33:37 +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
Matthias Clasen
f99cbdf49f Plug a memory leak
We were leaking cairo regions every time we draw.
2014-10-14 22:46:26 -04:00
Matthias Clasen
7a80c3b004 Correct Since tags 2014-10-13 10:43:32 -04:00
Alexander Larsson
fdeb4f8c16 gl: Make gdk_gl_context_make_current() return void
Its not really reasonable to handle failures to make_current, it
basically only happens if you pass invalid arguments to it, and
thats not something we trap on similar things on the X drawing side.

If GL is not supported that should be handled by the context creation
failing, and anything going wrong after that is essentially a critical
(or an async X error).
2014-10-13 10:43:32 -04:00
Alexander Larsson
236d08c3c5 gl: Make all user GdkGLContexts not attached to any window
We make user facing gl contexts not attached to a surface if possible,
or attached to dummy surfaces. This means nothing can accidentally
read/write to the toplevel back buffer.
2014-10-13 10:43:31 -04:00
Alexander Larsson
87970ea2d0 Add GDK_ALWAYS_USE_GL debug hack
If this is set we always use GL to render each window, even
if there are no GL widgets in the window.
2014-10-13 10:43:31 -04: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
Alexander Larsson
d0147a6f2c Add gdk_window_mark_paint_from_clip and call from widget drawing
This is a new function that gets called every time we're drawing
some area in the Gtk paint machinery. It is a no-op right now, but
it will be required later to keep track of what areas which
we previously rendered with GL was overwritten with cairo contents.
2014-10-13 10:43:31 -04:00
Alexander Larsson
a8f11835c5 Change the way the update area is tracked during paint
First of all we track the current update area during an
update in window->active_update_area. This will be used later
in end_paint to know the damaged area.

Secondly we keep track of old update areas for the last 2
frames. This will later allow us to reuse old framebuffer
contents in double or tripple buffer setups, only painting
what has changed since then.
2014-10-13 10:43:31 -04:00
Benjamin Otte
508d31fe70 gdk: Deprecate compositing support
We might want to remove support for it completely and always return
FALSE.
2014-10-12 04:54:35 +02:00
Jasper St. Pierre
1914e65591 gdkwindow: Fix small typo 2014-10-06 13:36:59 -07:00
Benjamin Otte
f3bd78a3cf gdk: Fix gdk_cairo_create() without begin_paint()
We were translating the clip region twice in that case.

https://bugzilla.gnome.org/show_bug.cgi?id=737825
2014-10-06 22:24:28 +02:00
Benjamin Otte
5e4672092a gdk: Deprecate static gravities
... and remove all implementations. The API allows to not work "if the
server doesn't support it. So from now on, no server does!
2014-10-06 02:38:40 +02:00
Benjamin Otte
66be6a018c gdk: Remove overeager checks
Parent is guaranteed to not be NULL. It can only ever be NULL for root
windows and root windows cannot be created with gdk_window_new() and
gdk_window_ensure_native() will exit early because they already are
native.

Also, both functions would crash a few lines below where parent gets
dereferenced.
2014-10-05 11:25:05 +02:00
Carlos Garnacho
f96437317b gdkwindow: check grab window and children on get_pointer_window()
If !owner_events, the pointer window has been usually set to NULL if
the pointer fell outside the grabbing widget, but it was not being
checked that the pointer_window is actually a child of the grab
window, in which case it should be obtained as if ungrabbed.

https://bugzilla.gnome.org/show_bug.cgi?id=735749
2014-09-22 20:30:12 -04:00
Alexander Larsson
6243c7122c gdkwindow: Fix update area calculations for native subwindows
When recursing the update area down into native subwindows we forgot
to apply the native window position. This caused us to repaint the
wrong thing in certain cases. I noticed this when playing with the
wip/gdk-gl branch, because it was triggering unnecessary repaints
of the (native window) gl widgets.
2014-09-02 17:14:59 +02:00
Ikey Doherty
6e1ef76480 Cleanup invalid comments (duplication of words)
https://bugzilla.gnome.org/show_bug.cgi?id=735301

Signed-off-by: Ikey Doherty <michael.i.doherty@intel.com>
2014-08-26 19:55:38 -04:00
Carlos Garnacho
84414f0381 gdk: Add GDK_WINDOW_SUBSURFACE window type
This window type can only be used on wayland so far, so NULL is returned
if it's attempted to be used on any other windowing backend.

https://bugzilla.gnome.org/show_bug.cgi?id=729215
2014-08-26 12:58:13 +02:00
Jasper St. Pierre
3878519449 window: Use CAIRO_OPERATOR_SOURCE to clear to background
Some windows, like GtkWindow and some other apps, set a transparent
background. The guarantee for begin_paint_region is that there should
be a full clear to the specified background color, not a composite
against what was there before.

This fixes repaint artifacts in Wayland and Weston in a better way than
76922c169f.
2014-07-14 19:14:40 -04:00
Jasper St. Pierre
b5eddb0aa1 gdkwindow: Don't queue a redraw when calling gdk_window_raise with no effect
The resize grip code in GTK+ likes to call gdk_window_raise a lot. The
unfortunate side effect of gdk_window_raise is that it queues an
invalidation on the entire window, even if it's already the topmost
child.

Add a return value to gdk_window_raise_internal, and only queue the
invalidation if the raise had an effect.
2014-07-03 11:54:27 -04:00
Jasper St. Pierre
ec140a8f07 gdkwindow: Apply the 0x0 size bump to 1x1 before checking for the bail
Otherwise, a user that calls gdk_window_resize (window, 0, 0); over and
over won't properly fizzle out, and will queue a redraw. Clipped, but
still. These redraws can be chatty on some platforms like Wayland, and
there's no good reason to not avoid them.

This was the case for resize grips.
2014-07-03 11:51:54 -04:00
Jasper St. Pierre
5740434137 gdkwindow: Fix an accidental code out-of-ordering
There's no semantics change, it just makes things clearer.
2014-06-29 20:27:45 -04:00
Colomban Wendling
de071768ae gdkwindow: Don't leak the surface in gdk_cairo_create() 2014-06-23 21:52:57 -04:00
Jasper St. Pierre
24b9e91f47 Revert "gtkwidget: Widgets are now always double-buffered"
This reverts commit b875572f2a.

Apps like Abiword, gnumeric and gnome-chess, and toolkits like
ClutterGTK were all using this for various purposes, and this made them
break. Bring back this feature for now.

It still won't work under Wayland.
2014-06-23 17:50:01 -04:00
Jasper St. Pierre
984e811c16 gdkwindow: Allow calling gdk_cairo_create outside of a "paint"
Apps had quite a bit of difficulty getting used to the new rules.
While we weren't expecting anything too deadly, it seemed that
gnumeric and Abiword both used gdk_cairo_create like this.
2014-06-23 17:50:00 -04:00
Jasper St. Pierre
e67e8ebb30 gdkwindow: Remove extra arguments from process_updates_recurse_helper
These can easily be calculated inside the function.
2014-06-23 16:44:09 -04:00
Jasper St. Pierre
70fe57703b gdkwindow: Don't do some extra work
We can do an early return in some specific cases before we need to
create and clip a cairo region.
2014-06-23 16:43:32 -04:00
Jasper St. Pierre
a9759c7756 gdkwindow: Remove an unused variable 2014-06-23 16:43:15 -04:00
Jasper St. Pierre
8eb092ea14 gdkwindow: Make the precondition of gdk_window_add_damage clearer 2014-06-23 15:00:01 -04:00
Jasper St. Pierre
06cfaea553 gdkwindow: Simplify check for damaging offscreen windows
If a window both has an impl and its impl_window is of type offscreen,
that must mean that it is the offscreen window, and the impl window is
itself. We can reduce the indirection here and make it more clear.
2014-06-23 15:00:01 -04:00
Jasper St. Pierre
b99dc9eede gdkwindow: Make gdk_window_add_damage more private 2014-06-23 15:00:01 -04:00