Commit Graph

59 Commits

Author SHA1 Message Date
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
Matthias Clasen
ba21a7764b gsk: Reorganize env vars
Get rid of GSK_RENDERING_MODE and add the flags to GSK_DEBUG,
following the same pattern we use in gdk now.
2018-01-14 17:05:04 -05:00
Matthias Clasen
c56419818f gsk: make logging per-renderer
Add a setter for per-renderer debug flags, and use
them where possible. Some places don't have easy access
to a renderer, so this is not complete.
Also, use g_message instead of g_print throughout.
2018-01-14 17:05:04 -05:00
Matthias Clasen
55585aec73 gsk: Clarify a debug message
We are printing a window type, not a display.
2018-01-14 17:05:04 -05:00
Matthias Clasen
3771c95c72 gsk: Move Vulkan sources to a subdirectory
Following what was already done for GL.
2018-01-06 09:36:55 -05:00
Timm Bäder
823369f275 gsk: Move all gskgl* files into gl/ 2017-12-21 19:12:30 +01:00
Timm Bäder
b488329104 GskRenderer: Remove viewport property 2017-12-21 18:25:52 +01:00
Alexander Larsson
23845a57a9 broadway: Add GskBroadwayRenderer
This is a custom renderer for broadway windows, although at the
moment it doesn't really do anything other than the old cairo
fallbacks.
2017-11-23 10:46:47 +01:00
Benjamin Otte
bd287ba3cf renderer: Assert having been unrealized in dispose
We cannot unrealize a renderer in the dispose function, because that
would cause this chain to happen:
  gsk_gl_renderer_dispose
  gsk_renderer_dispose
  gsk_renderer_unrealize
  gsk_gl_renderer_unrealize
So we would call into thje GL renderers unrealize when it has already
(partially) disposed itself and ause accesses to dead variables.
2017-11-04 15:22:25 +01:00
Benjamin Otte
ca3c23662c GskTexture => GdkTexture
We want this thing to replace GdkPixbuf, so it has to live in GDK.
2017-11-04 00:07:13 +01:00
Matthias Clasen
dc0570cc17 gsk: Drop the GskRenderer::scale-factor property
This is can always be obtained from the window that is already
associated with the renderer, no need to maintain a separate
property for it.
2017-10-28 11:49:39 -04:00
Matthias Clasen
b9b03cf570 gskrenderer: Make the window property not construct
We never set this, since it is assigned as a side-effect
of realizing the renderer. Make this a plain readonly property.
2017-10-06 19:29:42 -04:00
Benjamin Otte
43c212ac28 build: Enable -Wswitch-enum and -Wswitch-default
This patch makes that work using 1 of 2 options:

1. Add all missing enums to the switch statement
  or
2. Cast the switch argument to a uint to avoid having to do that (mostly
   for GdkEventType).

I even found a bug while doing that: clearing a GtkImage with a surface
did not notify thae surface property.

The reason for enabling this flag even though it is tedious at times is
that it is very useful when adding values to an enum, because it makes
GTK immediately warn about all the switch statements where this enum is
relevant.
And I expect changes to enums to be frequent during the GTK4 development
cycle.
2017-10-06 21:23:39 +02:00
Matthias Clasen
72d043d51f gsk: Change the profiler setup
Move away from the idea of intra-frame sampling, since we only
push samples once per frame, anyway. Instead, make the profiler
keep a rolling average of the last n frames.
2017-09-28 10:26:01 -04:00
Matthias Clasen
f6626a9e0e gsk: Documentation additions
Document newly added apis, and ensure that all public apis
are listed in the docs.
2017-09-24 22:26:39 -04:00
Daniel Boles
3d11edf1bc GSK: Fix a bunch of warnings from the GIR scanner
arising from conflicting argument names, missing annotations, etc.
2017-03-27 20:22:07 +01:00
Timm Bäder
6637b20b4c GdkRenderer: Fix a compiler warning 2017-03-19 15:44:15 +01:00
Tim-Philipp Müller
37b99ed671 vulkan: fix compilation 2017-03-18 12:23:39 +00:00
Alexander Larsson
1fe4b13871 Allow custom renderer for the inspector
If you set GTK_INSPECTOR_RENDERER to the same type of
values that GSK_RENDERER takes this can change the renderer
used for the inspector. This is useful if you're debugging
one renderer and don't want to affect the inspector.
2017-03-17 16:12:45 +01:00
Benjamin Otte
68b39a4727 gsk: Add GSK_RENDERING_MODE=full-redraw
Forces a full redraw every frame.
This is done generically, so it's supported on every renderer.

For widget-factory first page (with the spinner spinning and progressbar
pulsing), I get these numbers per frame:

action                  clipped         full redraw
snapshot                   0ms           7-10ms
cairo rendering            0ms          10-15ms
Vulkan rendering         3-5ms          18-20ms
Vulkan expected *          0ms            1-2ms
GL rendering            unsupported     55-62ms

* expected means disabling rendering of unsupported render nodes,
instead of doing fallback drawing. So it overestimates the performance,
because borders and box-shadows are disabled.
2016-12-27 00:48:00 +01:00
Benjamin Otte
6c56793147 gsk: Add gsk_texture_download() API
Now users can download pixels and make everything slooooooow.
2016-12-23 08:11:01 +01:00
Benjamin Otte
373e08d6d4 gsk: Add gsk_renderer_render_texture()
... and implement it for the Cairo renderer.

It's an API that instructs a renderer to render to a texture.
So far this is mostly meant to be used for testing, but I could imagine
it being useful for rendering DND icons.
2016-12-23 08:11:01 +01:00
Alexander Larsson
2d4b46f4f9 gsk: Drop gsk_render_node_make_immutable, nodes are always immutable 2016-12-21 14:01:34 +01:00
Benjamin Otte
e6d423e0e2 gsk: Remove gsk_renderer_create_fallback()
Use gsk_render_node_draw() instead.
2016-12-20 18:01:10 +01:00
Benjamin Otte
a97b819b81 gsk: Add gsk_container_node_new()
It replaces gsk_renderer_create_render_node() which was doing the eact
same thing, only taking an unused extra argument.
2016-12-20 18:01:09 +01:00
Benjamin Otte
f16d523cb2 gsk: Introduce GskRenderNodeClass
This is modeled after GtkCssValueClass. So far it doesn't do anything.
2016-12-20 18:01:09 +01:00
Benjamin Otte
ac5e277a71 gsk: Add GskRenderNodeType
For now, this is unused.
2016-12-20 18:01:09 +01:00
Matthias Clasen
438ad208e7 Use the new defines
It is no longer GDK_WINDOWING_VULKAN.
2016-12-09 15:51:58 -05:00
Benjamin Otte
2faad03f2f gsk: Improve GSK_RENDERER env var handling
- Recognize "gl" as well as "opengl" for the GL renderer
- GSK_RENDERER=help now works
- g_warning() for an unrecognized renderer (typo detection!)
- g_print() the actual renderer that is used (and error messages when
  selecting) when a GSK_RENDERER is given, so you'll notice if your
  renderer isn't taken.
2016-12-09 21:27:55 +01:00
Benjamin Otte
a753f047df gsk: Add skeleton for Vulkan renderer
The renderer itself obviously doesn't do anything.
2016-12-09 18:35:51 +01:00
Benjamin Otte
ca78f5d3cb gdk: Make gdk_window_begin_draw_frame() take a draw context
... instead of a gl context.

This requires some refactoring in the way we mark the shared context as
drawing: We now call begin_frame/end_frame() on it and ignore the call
on the main context.
Unfortunately we need to do this check in all vfuncs, which sucks. But I
haven't found a better way.
2016-12-05 15:02:47 +01:00
Benjamin Otte
60567db486 gskrenderer: Add gsk_renderer_begin_draw_frame()
This way, we can hijack the begin/end draw process and do out own
processing before passing it on to GDK.
2016-12-05 15:02:47 +01:00
Benjamin Otte
da8d886b17 gsk: Change GSK_USE_SOFTWARE env var to GSK_RENDERER
This way, we can use the variable as more than a boolean flag.

This will be useful for Vulkan or D3D renderers.
2016-12-05 15:02:47 +01:00
Benjamin Otte
e42e27304a gskrenderer: Store the GL context
And use it to create the drawing context with it.

Note that this doesn't yet have any effect and is all infrastructure
preparation work.
2016-12-05 15:02:47 +01:00
Benjamin Otte
318e19f570 gskrenderer: Add GError argument to gsk_renderer_realize()
This way, we don't spam criticals when GL is not available. Instead, we
print a useful debug message to stderr and continue with the Cairo renderer.

Signed-off-by: Emmanuele Bassi <ebassi@gnome.org>
2016-11-30 15:58:07 +01:00
Benjamin Otte
5563841603 gsk: Add gsk_renderer_new_for_window()
and remove gsk_renderer_get_for_display().

This new function returns a realized renderer. Because of that, GSK can
catch failures to realize, destroy the renderer and try another one.

Or in short: I can finally use GTK on Weston with the nvidia binary
drivers again.

Signed-off-by: Emmanuele Bassi <ebassi@gnome.org>
2016-11-30 15:56:00 +01:00
Benjamin Otte
ce98df881f gsk: Change gsk_renderer_realize()
Instead of having a gsk_renderer_set_window() call, pass the window to
realize(). This way, the realization can fail with the wrong window.

Signed-off-by: Emmanuele Bassi <ebassi@gnome.org>
2016-11-30 15:55:45 +01:00
Benjamin Otte
40565fb030 gsk: Rework GskTexture
We do no longer bind textures to a renderer, instead they are a way for
applications to provide texture data.

For now, that's it. We've reverted to uploading it from scratch every
frame.
2016-11-16 17:36:33 +01:00
Benjamin Otte
46eb2c1be9 gsk: Add GskTexture 2016-11-08 20:31:34 +01:00
Benjamin Otte
4129b70b96 rendernode: Remove the renderer from the rendernode 2016-11-01 16:32:26 +01:00
Emmanuele Bassi
50a5deb8e3 gsk: Add internal Renderer.create_cairo_surface()
We need an overridable entry point for GskRenderer to create Cairo
surfaces.

Implementations of GskRenderer can override create_cairo_surface() to
create efficient surfaces, possibly with zero copies involved, depending
on the GDK backend.
2016-10-31 16:26:50 +00:00
Emmanuele Bassi
14322b03ab gsk: Clear the profiler instance
When disposing the GskRenderer.
2016-10-18 16:49:21 +01:00
Emmanuele Bassi
69781c25da gsk: Bump up all version annotations
GSK is part of the 4.0 development cycle.
2016-10-18 11:49:16 +01:00
Emmanuele Bassi
dace0791a9 gsk: Add the ability to create fallback renderers
While porting GTK to GskRenderer we noticed that the current fallback
code for widgets using Cairo to draw is not enough to cover all the
possible cases.

For instance, if a container widget still uses GtkWidget::draw to render
its children, and at least one of them has been ported to using render
nodes instead, the container won't know how to draw it.

For this reason we want to provide to layers above GSK the ability to
create a "fallback" renderer instance, created using a "parent"
GskRenderer instance, but using a Cairo context as the rendering target
instead of a GdkDrawingContext.

GTK will use this inside the gtk_widget_draw() implementation, if a
widget implements GtkWidgetClass.get_render_node().
2016-10-18 11:49:16 +01:00
Emmanuele Bassi
6b3c0052fc gsk: Make GskRenderer.render() drawing context-agnostic
We're going to need to allow rendering on a specific cairo_t in order to
implement fallback code paths inside GTK; this means that there will be
times when we have a transient GskRenderer instance that does not have a
GdkDrawingContext to draw on.

Instead of adding a new render() implementation for those cases and then
decide which one to use, we can remove the drawing context argument from
the virtual function itself, and allow using a NULL GdkDrawingContext
when calling gsk_renderer_render(). A later commit will add a generic
function to create a transient GskRenderer with a cairo_t attached to
it.

Renderers inside GSK will have to check whether we have access to a
GdkDrawingContext, in which case we're going to use it; or if we have
access to a cairo_t and a window.
2016-10-18 11:49:15 +01:00
Emmanuele Bassi
7de49fb7b2 gsk: Remove GskRenderer:auto-clear
We control the clearing inside each GskRenderer implementation, and we
don't allow providing a target surface any more.
2016-10-18 11:49:15 +01:00
Emmanuele Bassi
f764d03cfd gsk: Remove :use-alpha from GskRenderer
It's unused, and we always assume we render with an alpha channel
enabled because it's 2016.
2016-10-18 11:49:14 +01:00
Emmanuele Bassi
387ed37f74 gsk: Move scaling filters to GskRenderNode
The renderer will always use nearest-neighbor filters because it renders
at 1:1 pixel to texel ratio.

On the other hand, render nodes may be scaled, so we need to offer a way
to control the minification and magnification filters.
2016-10-18 11:49:14 +01:00
Emmanuele Bassi
ce67336577 gsk: Drop modelview/projection from GskRenderer API
The details of the modelview and projection matrices are only useful for
the GL renderer; there's really no point in having those details
available in the generic API — especially as the Cairo fallback renderer
cannot really set up a complex modelview or a projection matrix.
2016-10-18 11:49:14 +01:00
Matthias Clasen
53266e7a15 Small documentation additions 2016-10-18 11:49:13 +01:00