Commit Graph

229 Commits

Author SHA1 Message Date
Alexander Larsson
5f9e6ec2dc GdkGL: Fix up GL_ARB_texture_rectangle support
This broke when gdk_gl_texture_quad moved to shaders. We need
a specialized shader for the rectangle case.
2014-11-06 12:24:43 +01: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
Alexander Larsson
e417b18373 gdk_gl_texture_quad: Use shaders to texture things
This is the modern way OpenGL works, and using it will let us
switch to a core context for the paint context, and work on
OpenGL ES 2.0.
2014-11-06 12:24:43 +01:00
Alexander Larsson
10a44e8f7a Add gdk_gl_texture_quad() helper
Right now this just centralizes the glBegin/glEnd code, but
this will be replaced with buffer objects later.
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
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
Alexander Larsson
ceeed1c48d Add internal gdk_cairo_region_from_clip helper
This extract the current cairo clip region if possible and
returns it as a cairo_region_T. It will be needed by later code.
2014-10-13 10:43:31 -04: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
Alexander Larsson
53dab9240d GdkWindow: Remove unused fields
clip_region_with_children and layered_region is not used any more,
remove them.
2014-09-05 09:44:28 +02:00
Owen W. Taylor
fc6e2cc4b2 Handle resolution changes in the GDK backend code
gdk_x11_display_set_window_scale() affects the interpretation of the
Xft/DPI XSETTING - it is substituted inside GDK with the value of
Gdk/UnscaledDPI xsetting. However, this change is not propagated to
GTK+ and from GTK+ back to gdk_screen_set_resolution() until the
main loop is run.

Fix this by handling the screen resolution directly in gdk/x11.
This requires duplication of code between GDK and GTK+ since we still
have to handle DPI in GTK+ in the case that GdkSettings:gtk-xft-dpi
is set by the application.

https://bugzilla.gnome.org/show_bug.cgi?id=733076
2014-07-13 15:35:23 -04:00
Jasper St. Pierre
b99dc9eede gdkwindow: Make gdk_window_add_damage more private 2014-06-23 15:00:01 -04:00
Jasper St. Pierre
be30e440c3 gdkwindow: Remove the ability to call begin_paint_region more than once
Previously, each begin_paint_region added to a stack of current paints,
and when end_paint was called, the paint was popped off of the stack and
the surface was composited into the parent paint surface.

However, the code was broken in the case of a backend like Wayland which
didn't keep track of nested calls and simply wiped and returned the
native impl backing surface every time.

Since this feature is flat out unused by GTK+ and we don't want to
really support tricksy things like these for other clients, just remove
the feature. If somebody does call begin_paint_region more than once,
warn and return without doing anything.
2014-06-20 20:41:55 -04:00
Jasper St. Pierre
d48adf9cee gdkwindow: Remove the internal cairo_surface used for out-of-band painting
Traditionally, the way painting was done in GTK+ was with the
"expose-event" handler, where you'd use GDK methods to do drawing on
your surface. In GTK+ 2.24, we added cairo support with gdk_cairo_create,
so you could paint your graphics with cairo.

Since then, we've added client-side windows, double buffering, the paint
clock, and various other enhancements, and the modern way to do drawing
is to connect to the "draw" signal on GtkWidget, which hands you a
cairo_t. To do double-buffering, the cairo_t we hand you is actually on
a secret surface, not the actual backing store of the window, and when
the draw handler completes we blit it into the main backing store
atomically.

The code to do this is with the APIs gdk_window_begin_paint_region,
which creates the temporary surface, and gdk_window_end_paint which
blits it back into the backing store. GTK+'s implementation of the
"draw" signal uses these APIs.

We've always sort-of supported people calling gdk_cairo_create
"outside" of a begin_paint / end_paint like old times, but then you're
not getting the benefit of double-buffering, and it's harder for GDK to
optimize.

Additionally, newer backends like Mir and Wayland can't actually support
this model, since they're based on double-buffering and swapping buffers
at various points in time. If we hand you a random cairo_t, we have no
idea when is a good time to swap.

Remove support for this.

This is technically a GDK API break: a warning is added in cases where
gdk_cairo_create is called outside of a paint cycle, and the returned
surface is a dummy that won't ever be composited back onto the main
surface. Testing with complex applications like Ardour didn't produce
any warnings.
2014-06-20 20:41:54 -04:00
Jasper St. Pierre
c1efc4ad7b gdk: Add new _gdk_set_window_state
Wayland's mechanism tells us all of our new states, rather than
telling us which ones were added and removed. Add a new private
interface so that we can simply specify the new states as a
bitfield directly rather than having to compute which ones were
added and removed.
2014-05-13 02:39:59 -04:00
Jasper St. Pierre
5ac2346862 Remove gdk_synthesize_window_state from gdkinternals.h
It's already in gdkprivate.h
2014-04-12 08:20:33 -07:00
Matthias Clasen
5657b805d7 Some struct repacking
Save a few bytes here and there.
2014-01-12 22:25:19 -05:00
Owen W. Taylor
f50a3af1b7 Handle recursion from motion event handlers
If a motion event handler (or other handler running from the flush-events
phase of the frame clock) recursed the main loop then flushing wouldn't
complete until after the recursed main loop returned, and various aspects
of the state would get out of sync.

To fix this, change flushing of the event queue to simply mark events as
ready to flush, and let normal event delivery handle the rest.

https://bugzilla.gnome.org/show_bug.cgi?id=705176
2013-11-11 23:17:14 -05:00
Daniel Sabo
80dd1a851a Add an event_compression setting to GdkWindow
Setting event compression to false will allow inter-frame
mouse motion events to be delivered, which are necessary
for painting applications to produce smooth strokes.

https://bugzilla.gnome.org/show_bug.cgi?id=702392
2013-11-09 00:01:05 -05:00
Alexander Larsson
e8b38fedbd gdk: Convert mouse position to doubles, add new getters
We've long had double precision mouse coordinates on wayland (e.g.
when rotating a window) but with the new scaling we even have it on
X (and, its also in Xinput2), so convert all the internal mouse/device
position getters to use doubles and add new accessors for the
public APIs that take doubles instead of ints.
2013-07-03 14:39:25 +02:00
Alexander Larsson
a60ccd3672 GdkWindow: Fix shape handling for native windows
We don't track the full clip for each window anymore, as this
is not useful when no windows are opaque. However, we still
need the full clip for the shape, so its calculated manually.

However, it was previously only recalculated when the clip changes
which doesn't correctly handle the case of a sibling geometry changing.

So, instead of doing this directly when geometry changes we just
set a bit in the toplevel whenever some window geometry changes, and
we then handle this in process_updates, updating the shape for all
native windows. This should be ok performance-wise because we don't
expect a lot of native children.
2013-05-15 11:08:35 +02:00
Alexander Larsson
8306d26714 GdkWindow: Track all native windows of native windows
We keep a list of all native children of a native window. This means
we don't have to recurse over the entire hierarchy to find any
native children.
2013-05-15 11:08:35 +02:00
Alexander Larsson
3610005191 gdkwindow: Avoid some unnecessary typechecks
This removes the typechecks in GDK_WINDOW_TYPE and GDK_WINDOW_DESTROYED. These
are only used internally in gdkwindow.c and gdkdisplay.c anyway,  and these
functions check for typesafety of arguments on function entry.
2013-05-07 16:40:24 +02:00
Alexander Larsson
e13fb1d3e0 Add gdk_window_set_invalidate_handler
This lets you register callbacks for when child widgets invalidate
areas of the window read it and/or change it.

For instance, this lets you do rendering effects and keeping offscreen
caches uptodate.
2013-05-07 16:34:04 +02:00
Alexander Larsson
6115961175 gdkwindow: Make GdkPaintable normal GdkWindowImpl vfuncs
There is no need for this to be a separate interface, its just looking
weird.
2013-05-07 16:33:01 +02:00
Alexander Larsson
fe0982818d gdkwindow: Remove implicit paints
We now only do one expose event per native window, so there will
only be one begin/end_paint() call. This means all the work with
implicit paints to combine the paints on a single double buffer
surface is unnecessary, so we can just delete it.
2013-05-07 16:33:01 +02:00
Alexander Larsson
da2a1eac1b gdkwindow: Remove outstanding_moves stuff
Since we now never move regions directly on the window we can
remove all the stuff that track outstanding moves and flushes then.
2013-05-07 16:33:00 +02:00
Benjamin Otte
a489f69e00 gdk: Remove unused function 2013-04-15 15:43:27 +02:00
Benjamin Otte
8857766b5a gdk: Add a debug category for settings 2013-02-19 14:33:36 +01:00
Owen W. Taylor
d5edf9c072 GdkFrameTimings: strip down to a minimal public API
Since we're not exporting the ability to create your own frame
clock for now, remove the setters for GdkFrameTimings fields.
Also remove all setters and getters for fields that are more
about implementation than about quantities that are meaningful
to the applcation and just access the fields directly within
GDK.
2013-02-14 17:19:52 -05:00
Owen W. Taylor
515e5f74aa Merge GdkFrameHistory into GdkFrameClock
Now that GdkFrameClock is a  class, not interface, there's no real advantage
to splitting the frame history into an aggregate object, so directly
merge it into GdkFrameClock.
2013-02-14 17:19:52 -05: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
Owen W. Taylor
a69285da08 Compress motion synchronized with the paint cycle
When we have pending motion events, instead of delivering them
directly, request the new FLUSH_EVENTS phase of the frame clock.
This allows us to compress repeated motion events sent to the
same window.

In the FLUSH_EVENTS phase, which occur at priority GDK_PRIORITY_EVENTS + 1,
we deliver any pending motion events then turn off event delivery
until the end of the next frame. Turning off event delivery means
that we'll reliably paint the compressed motion events even if more
have arrived.

Add a motion-compression test case which demonstrates behavior when
an application takes too long handle motion events. It is unusable
without this patch but behaves fine with the patch.

https://bugzilla.gnome.org/show_bug.cgi?id=685460
2013-02-14 17:19:49 -05:00
Owen W. Taylor
77bac0d6ae Add GdkFrameClock
Add an object GdkFrameClock that we associate with a GdkWindow.
This tracks when the window needs to be repainted, and will also
be used for other operations in the future like relayout and
updating animations.

Based on a patch from Havoc Pennington:

 https://mail.gnome.org/archives/gtk-devel-list/2010-October/msg00004.html

https://bugzilla.gnome.org/show_bug.cgi?id=685460
2013-02-14 17:19:47 -05:00
Alexander Larsson
4d3c77f920 gdkwindow: Allow gdk_window_set_opacity on non-native children
We now store the current opacity for all windows. For native windows
we just call into the native implementation whenever the opacity changes.
However, for non-native windows we implement opacity by pushing a
second implicit paint that "stacks" on the existing one, acting as
an opacity group while rendering the window and its children.

This works well in general, although any native child windows will of
course not be opaque. However, there is no way to implement
implicit paint flushing (i.e. draw the currently drawn double buffer
to the window in order to allow direct drawing to the window).
We can't flush in the stacked implicit paint case because there
is no way to get the right drawing behaviour when drawing directly
to the window. We *must* draw to the opacity group to get the right
behaviour.

We currently flush if:
* A widget disables double buffering
* You call move/resize/scroll a window and it has non-native children
  during the expose handler

In case this happens we warn and flush the outermost group, so there may
be drawing errors.

https://bugzilla.gnome.org/show_bug.cgi?id=687842
2013-02-07 11:11:37 +01:00
Alexander Larsson
ada6d81247 gdkwindow: Store the implicit paint in a list
This changes nothing, but lets us later have multiple
implicit paints

https://bugzilla.gnome.org/show_bug.cgi?id=687842
2013-02-07 11:11:37 +01:00
Olivier Fourdan
54dc823d67 gdk: add gdk_window_set_fullscreen_mode()
and gdk_window_get_fullscreen_mode() API to allow
applications to specify if a fullscreen window should
span across all monitors in a multi-monitor setup or
remain on the current monitor where the window is
placed.

Fullscreen mode can be either GDK_FULLSCREEN_ON_ALL_MONITORS
or GDK_FULLSCREEN_ON_CURRENT_MONITOR.

https://bugzilla.gnome.org/show_bug.cgi?id=691856
2013-01-25 13:16:56 +01:00
Alexander Larsson
7430559736 win32: Remove some unused input stuff to make win32 build again
Input events doesn't quite seem to work though, so it needs some fixing.
2012-03-06 12:04:36 +01:00
Carlos Garnacho
a490d2ebda gdk: Add internal API to set "pointer emulated" flag on events
This flag will be used for non-pointer events that are emulated
from eg. touch events, or pointer events being emulated.
2012-03-01 16:25:19 -05:00
Javier Jardón
9d0febc9a6 Change FSF Address 2012-02-27 17:06:11 +00:00
Alexander Larsson
68843a3e93 gdk: Remove unused _gdk_window_calculate_full_clip_region 2011-12-05 10:59:07 +01:00
Alexander Larsson
46d5b89830 gdk: Track the layered area
We track the areas that have alpha coverage so that we can
avoid using these as sources when copying window contents.
We also don't remove such areas from the clipping regions so
that they are painted both by parent and child.
2011-12-01 22:06:44 +01:00
Alexander Larsson
f51482e283 gdk: Track wether windows have alpha in the background
This will let us handle such windows differently in the
drawing machinery
2011-12-01 22:03:51 +01:00
Alexander Larsson
45df163e9d gdk: Remove now unused region tags completely 2011-12-01 13:38:04 +01:00
Matthias Clasen
220ba87ec0 GdkWindow: Struct packing improvements 2011-04-12 12:13:55 -04: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
Benjamin Otte
ec750bed0c gdk: Remove colormap debug category
We don't have colormaps anymore.
2011-01-21 02:54:09 +01:00
Matthias Clasen
32e3dcfb47 drop dead function 2010-12-21 12:07:01 -05:00