Commit Graph

26 Commits

Author SHA1 Message Date
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
Benjamin Otte
98086014d8 gskcairo: Don't store the viewport in the global struct
Just query it locally.
2016-12-23 08:11:01 +01:00
Benjamin Otte
d2622d93ad gsk: Don't overdraw with transparent
That code doesn't do anything.

And what the code should be doing (clearing the abckground) isn't
necessary as cairo drawing is guaranteed to clear the surface.
2016-12-23 08:11:01 +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
e82d02432e gsk: Add gsk_render_node_draw()
Draws a node to a given cairo_t. This is mostly intended for fallback
usage.
2016-12-20 18:01:10 +01:00
Benjamin Otte
67fb129ed7 gsk: gsk_render_node_set_transform() => GskTransformNode
Instead of having a setter for the transform, have a GskTransformNode.

Most of the oprations that GTK does do not require a transform, so it
doesn't make sense to have it as a primary attribute.

Also, changing the transform requires updating the uniforms of the GL
renderer, so we're happy if we can avoid that.
2016-12-20 18:01:10 +01:00
Benjamin Otte
19753062c4 gsK: Move children handling to GskContainerNode 2016-12-20 18:01:09 +01:00
Benjamin Otte
a8f2b3e75e gsk: Remove world matrix support
Use the real transform and compute it manually.
2016-12-20 18:01:09 +01:00
Benjamin Otte
e4ee65fd19 gsk: Remove gsk_render_node_set_opaque()
If we ever feel, we need this function again, we can readd it later.

But nobody is using it other than for overriding opactiy. And you can
just override opacity directly if you care.
2016-12-20 18:01:09 +01:00
Benjamin Otte
abd184efc9 gsk: Remove gsk_render_node_is_surface/texture()
Use gsk_render_node_get_node_type() instead.
2016-12-20 18:01:09 +01:00
Benjamin Otte
52d2faef88 gsk: Add gsk_cairo_node_new()
Split off Cairo drawn content nodes and require you to allocate them
using this new function.
2016-12-20 18:01:09 +01:00
Benjamin Otte
8c8691b469 gsk: Add gsk_texture_node_new()
Start the transition into the different node types.
2016-12-20 18:01:09 +01:00
Benjamin Otte
f258af9cce gsk: Remove GskRenderNodeIter 2016-12-20 18:01:09 +01:00
Benjamin Otte
ff884385c0 gsk: Remove GskRenderNode::hidden
If you want to hide something, don't render it.
2016-12-20 18:01:09 +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
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
39bf2ba96f cairorenderer: Record cpu time in the profiler 2016-11-20 05:28:52 +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
09359197a7 gsk: Implement textures for the Cairo renderer 2016-11-08 20:31:34 +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
a9bbb020aa gsk: Update Cairo renderer
The Cairo renderer has been lagging behind a series of changes inside
GskRenderer, like surface-less nodes, so it needs to be updated.
2016-10-18 11:49:15 +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
074c77e7ac gsk: Rework GskRenderer and GskRenderNode semantics
This commit changes the way GskRenderer and GskRenderNode interact and
are meant to be used.

GskRenderNode should represent a transient tree of rendering nodes,
which are submitted to the GskRenderer at render time; this allows the
renderer to take ownership of the render tree. Once the toolkit and
application code have finished assembling it, the render tree ownership
is transferred to the renderer.
2016-10-18 11:29:34 +01:00
Emmanuele Bassi
7afdd3fdb5 Initial implementation of GSK rendering pipeline
GSK is conceptually split into two scene graphs:

 * a simple rendering tree of operations
 * a complex set of logical layers

The latter is built on the former, and adds convenience and high level
API for application developers.

The lower layer, though, is what gets transformed into the rendering
pipeline, as it's simple and thus can be transformed into appropriate
rendering commands with minimal state changes.

The lower layer is also suitable for reuse from more complex higher
layers, like the CSS machinery in GTK, without necessarily port those
layers to the GSK high level API.

This lower layer is based on GskRenderNode instances, which represent
the tree of rendering operations; and a GskRenderer instance, which
takes the render nodes and submits them (after potentially reordering
and transforming them to a more appropriate representation) to the
underlying graphic system.
2016-10-18 11:29:34 +01:00