Commit Graph

49556 Commits

Author SHA1 Message Date
Benjamin Otte
cf520b7a1f gsk: Add blend nodes
Implement blend mode support in GTK background compositing with it.
2016-12-20 18:01:11 +01:00
Benjamin Otte
3e26fadb24 css: Replace custom blend modes with GskBlendMode 2016-12-20 18:01:11 +01:00
Benjamin Otte
2118f394d2 gsk: Add missing blend modes
This brings GSK blend modes in line with the CSS spec.
2016-12-20 18:01:11 +01:00
Benjamin Otte
08a2a29c26 vulkan: Add infrastructure for multiple pipelines
And use it to draw solid colors with a 2nd pipeline.
2016-12-20 18:01:11 +01:00
Benjamin Otte
7d837a2ae6 vulkan: Split PipelineLayout into its own object
This way, we can share the layout between different pipelines.
2016-12-20 18:01:11 +01:00
Benjamin Otte
f4f0dba5c6 vulkan: Split render ops into seperate structs
This makes it a lot clearer which members are relevant for each
different operation.
2016-12-20 18:01:11 +01:00
Benjamin Otte
62eb9d42aa vulkan: Add infrastructure for push constants
THe code includes fragment push constants for colors, but that code is
so far unused.
2016-12-20 18:01:10 +01:00
Benjamin Otte
58b2c1d009 cssimage: Port a few more simple ones to snapshots 2016-12-20 18:01:10 +01:00
Benjamin Otte
cd68c93b4c render: Fall back later when rendering backgrounds
We can now render most backgrounds fine.
2016-12-20 18:01:10 +01:00
Benjamin Otte
3d5173d4ac gtk: Fix memleaks
It turns out, some simple getters - such as
gdk_drawing_context_get_clip() - love copying things before returning
them.

I guess somebody has to burn cycles...
2016-12-20 18:01:10 +01:00
Benjamin Otte
dd1cf1ac0f css: An opaque background does not allow omitting push_group
When the background-clip of the background is smaller than the
background-clip of blended images, not pushing a group is wrong.

Test testing exactly that included.
2016-12-20 18:01:10 +01:00
Benjamin Otte
23e35706b4 gsk: Add support for rounded clip rectangles
Also add support to GtkSnapshot, so people can push rounded clips.
2016-12-20 18:01:10 +01:00
Benjamin Otte
f96f16899d roundedbox: Remove _gtk_rounded_box_path()
Use gsk_rounded_rect_path() instead.

That's a private GSK function, be we can just include its header.
2016-12-20 18:01:10 +01:00
Benjamin Otte
fa9b0f9965 roundedbox: Remove _gtk_rounded_box_move()
Use gsk_rounded_rect_offset() instead.
2016-12-20 18:01:10 +01:00
Benjamin Otte
e26f84fca0 gtk: Remove GtkRoundedBox struct
Use GskRoundedRect instead.
2016-12-20 18:01:10 +01:00
Benjamin Otte
a2dfb1e93f roundedbox: typedef to GskRoundedRect 2016-12-20 18:01:10 +01:00
Benjamin Otte
c04bece131 roundedbox: Use a graphene_size_t for the corners
Obviously, I'm trying to port GtkRoundedBox to GskRoundedRect.

This is the second step on that path.
2016-12-20 18:01:10 +01:00
Benjamin Otte
6d012fb4ea gtk: Get rid of GtkCssCorner
We have GskCorner now which is identical.
2016-12-20 18:01:10 +01:00
Benjamin Otte
59d638a09f gsk: Add GskRoundedRect
It's essentially a port of GtkRoundedBox to graphene.
2016-12-20 18:01:10 +01:00
Benjamin Otte
0a0cbcdcb6 viewport: implement snapshot() 2016-12-20 18:01:10 +01:00
Benjamin Otte
b0175421f2 stack: Implement snapshot()
This uses the new push()/pop() mechanism to its fullest extent when
implementing transitions. It's fun to inspect the results in the
inspector.

Crossfades don't work yet, they continue using a Cairo fallback.

A side effect of the stack conversion is that widget-factory now uses
snapshots for a lot more things.
2016-12-20 18:01:10 +01:00
Benjamin Otte
1137483d15 snapshot: Work on pushing and popping again
It is now possible to call push() subfunctions for simple container
nodes with just a single child. So you can for example
gtk_snapshot_push_clip() a clip region that all the nodes that get
appended later will then obey.

gtk_snapshot_pop() will then not return a container node, but a clip
node containing the container node (and similar for the transform
example).

This is implemented internally by providing a "collect function" when
pushing that is called when popping to collects all the accumulated
nodes and combine them into the single node that gets returned.

To simplify things even more, gtk_snapshot_pop_and_append() has been
added, which pops the currently pushed node and appends it to the
parent.

The icon rendering code has been converted to this approach.
2016-12-20 18:01:10 +01:00
Benjamin Otte
1f988d8b05 gsk: Add gsk_clip_node_new()
The node is a simple clipping node: It does a rectangular clip of its
contents.
2016-12-20 18:01:10 +01:00
Benjamin Otte
68a54ae81f stack: Don't draw an extra background
The gadget draws a background for us, we don't need another one.
2016-12-20 18:01:10 +01:00
Benjamin Otte
07d39299ea gsk: Replace gsk_render_node_set_opacity()
... with gsk_opacity_node_new().

Also implement support for opacity in gtk_widget_snapshot() using this
new node.
2016-12-20 18:01:10 +01:00
Benjamin Otte
671d43b873 cssimage: Implement snapshot() in the fallback image 2016-12-20 18:01:10 +01:00
Benjamin Otte
ed6643cf69 cssimage: Use textures in GtkCssImageSurface
We now use textures instead of surfaces and implement the snapshot()
vfunc instead of draw().
2016-12-20 18:01:10 +01:00
Benjamin Otte
429346fa7e cssimage: Implement a fallback draw() vfunc
... that chains into snapshot. This way, we can stop implementing draw()
in GtkCssImage subclasses and focus on snapshot() instead.
2016-12-20 18:01:10 +01:00
Benjamin Otte
c258ee403a snapshot: Make gtk_snapshot_get_renderer() private
Public API doesn't need to be concerned with renderers. Worst case, they
can use NULL instead of the actual renderer.
2016-12-20 18:01:10 +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
b120075698 snapshot: Add API for colors and textures 2016-12-20 18:01:10 +01:00
Benjamin Otte
ee9aca882d gsk: Add fallback code to renderers
This code makes renderers fall back to Cairo rendering if they don't
know how to handle a render node's type.

This allows adding new render nodes with impunity.
2016-12-20 18:01:10 +01:00
Benjamin Otte
6129daf29b gsk: Add gsk_color_node_new() 2016-12-20 18:01:10 +01:00
Benjamin Otte
361e2cda27 Call gsk_render_node_draw() instead of creating fallback renderers 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
02131d590e snapshot: Change how gtk_snapshot_push/pop works
Instead of appending a container node and adding the nodes to it as they
come in, we now collect the nodes until gtk_snapshot_pop() is called and
then hand them out in a container node.

The caller of gtk_snapshot_push() is then responsible for doing whatever
he wants with the created node.

Another addigion is the keep_coordinates flag to gtk_snapshot_push()
which allows callers to keep the current offset and clip region or
discard it. Discarding is useful when doing transforms, keeping it is
useful when inserting effect nodes (like the ones I'm about to add).
2016-12-20 18:01:10 +01:00
Benjamin Otte
ca80e9decf snapshot: Handle clip region as part of the state
This is in preparation for further changes.
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
e2625f8649 gsk: Remove GskRenderNode::parent
... and all related APIs.
2016-12-20 18:01:09 +01:00
Benjamin Otte
d691dfc894 inspector: Prepare TreeModelRenderNode for brave new world
I'm about to move children handling to the container node, which means
the generic code can no longer assume children APIs existing.

So rewrite the treemodel to work without it.
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
3eb7c4719b gsk: Remove gsk_render_node_set_bounds()
gsk_render_node_get_bounds() still exists and is computed via vfunc
call:
- containers dynamically compute the bounds from their children
- surface and texture nodes get bounds passed on construction
2016-12-20 18:01:09 +01:00
Benjamin Otte
4d376c80f3 gsk: Remove gsk_render_node_get_size()
In the brave new world of refactored render nodes, this function doesn't
really make any sense anymore. We could turn it into a vfunc, but I
don't think it's useful.

Especially because even in the brave old world, this function was
causing a vastl overallocation of nodes when the GL renderer needed render
targets.
2016-12-20 18:01:09 +01:00
Benjamin Otte
d907f60843 gsk: Add GskRenderNodeClass.make_immutable() 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
684d25bd1a gsk: Add custom structs to RenderNode subclasses
So now we don't need to keep a texture pointer and a surface pointer and
so on in the base struct.
2016-12-20 18:01:09 +01:00
Benjamin Otte
be8b9406e5 gsk: Add GskRenderNodeClass.finalize() 2016-12-20 18:01:09 +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
8830a1a1ad gtk: Remove gtk_snapshot_append()
It does not make sense to append an empty container node. Those should
only be push()'d.
2016-12-20 18:01:09 +01:00