Commit Graph

48537 Commits

Author SHA1 Message Date
Matthias Clasen
82166f8d72 button: Restore focus
The custom gadget draw function has the side effect of informing
the gadget machinery wether to draw focus or not. Bring the
draw function back, just for its boolean return value. We may
want to find a better solution for this.
2016-10-17 16:21:58 +01:00
Matthias Clasen
cf96e92b8b Allow selective debug spew
I don't think this should stay in the code long-term, but it
is useful for debugging. It helped me track down some suspicious
placements of render nodes.
2016-10-17 16:21:58 +01:00
Matthias Clasen
1140c20309 Add details to css render nodes
Give all nodes the same detail about the owner widget.
This reveals that every GtkCssCustomGadget gets a
DrawGadgetContents node, even if their draw_func is NULL.
We may want to come up with a better solution for that.
2016-10-17 16:21:58 +01:00
Matthias Clasen
5228506b6f Some debug help
Make the bounds of drawing surfaces created by render nodes visible.

Trigger with GSK_DEBUG=surface.
2016-10-17 16:21:58 +01:00
Matthias Clasen
6fd807ae0d Drop an unused variable 2016-10-17 16:21:58 +01:00
Emmanuele Bassi
cd78d1a69a gtk: Clean up render fallback node creation in GtkWidget 2016-10-17 16:21:58 +01:00
Emmanuele Bassi
fe590578f9 gtk: Port GtkHeaderBar to render nodes 2016-10-17 16:21:58 +01:00
Emmanuele Bassi
ae4e72d944 gtk: Port GtkActionBar to render nodes 2016-10-17 16:21:58 +01:00
Emmanuele Bassi
00d4b62dce gtk: Attempt at handling CSS coordinates
When creating the GskRenderNodes for the gadgets we should not translate
the coordinates inside the Cairo context, but we should tweak the
coordinates of the anchor point.

This is still not enough to get an appropriate rendering, as the result
is still slightly offset to the left.
2016-10-17 16:21:58 +01:00
Emmanuele Bassi
c0cd978311 gsk: Pass the appropriate value for the n_quads argument
Instead of passing the size of the buffer, we should pass the number of
quads; we know what the size of a single quad structure is, so we can do
the multiplication internally when creating the VAO.

This allows us to print the quads for debugging purposes.
2016-10-17 16:21:57 +01:00
Matthias Clasen
cd14236dfe GtkFrame: Convert to indirect rendering
Create a GskRenderNode for the contents of the frame.
2016-10-17 16:21:57 +01:00
Emmanuele Bassi
fb9413d464 gtk: Add convenience function for creating render nodes
GtkWidget.create_render_node() sets up a GskRenderNode appropriate for
rendering the contents of a widget, including its bounds,
transformation, and anchor point.
2016-10-17 16:21:57 +01:00
Emmanuele Bassi
7f22c023de gsk: Rename set_offset() to set_anchor_point()
The naming is consistent with other scene graph libraries, as it
represents an additional translation transformation applied on top of
the provided transformation matrices.

We can also simplify the implementation by applying the translation when
we compute the world matrix.
2016-10-17 16:21:57 +01:00
Emmanuele Bassi
bda1701301 gsk: Recycle textures across frames
We keep the textures used inside a frame around until the end of the
following frame; whenever we need a texture with the same size, and
it's not marked in use, then we just reuse the existing texture.
2016-10-17 16:21:57 +01:00
Matthias Clasen
399a03f475 Fix fallback render nodes
We were allocating a surface thats big enough for the clip, and
we were setting the transform for that, but then GtkContainer
was overriding the transform with the one for the allocation.
Also, we were drawing at the clip position, not the allocation
position.
2016-10-17 16:21:57 +01:00
Matthias Clasen
8f75be4647 Add an offset to render nodes
This will let us account for the difference between
clip and allocation.
2016-10-17 16:21:57 +01:00
Matthias Clasen
daec615286 gsk: Split of debug spew for transforms
This was overwhelming other useful debug output, so make it
opt-in. We print the render items for both opengl and transforms,
since the matrices bleed into each other, otherwise.
2016-10-17 16:21:57 +01:00
Matthias Clasen
2695f32eb3 gsk: Add debug macros that trigger on two conditions
This will be useful in the following commits.
2016-10-17 16:21:57 +01:00
Matthias Clasen
9ec2875543 gsk: Add a debug flag for transforms 2016-10-17 16:21:57 +01:00
Matthias Clasen
5b735cff00 gsk: Improve debug output a bit
Indent render node debug spew to make the tree structure obvious.
2016-10-17 16:21:57 +01:00
Matthias Clasen
ae10683e95 button: Convert to indirect rendering
WARNING! This commit breaks GtkButton subclasses.
2016-10-17 16:21:56 +01:00
Matthias Clasen
0c39051cbe Convert GtkGrid to indirect rendering
Following the example of GtkBox.
2016-10-17 16:21:56 +01:00
Emmanuele Bassi
1cd7d4f7cd gsk: Add GskProfiler to GskRenderer
The profiler instance is per-renderer, and is accesible to
implementations.
2016-10-17 16:21:56 +01:00
Emmanuele Bassi
34b6993d15 gsk: Add profiler object
The GskProfiler holds counters and timers, and will be used by the
renderer implementations to acquire frame timings.
2016-10-17 16:21:56 +01:00
Emmanuele Bassi
c99536c752 box: Port from immediate to deferred rendering
Drop the ::draw() vfunc implementation in favour of the
::get_render_node() vfunc.
2016-10-17 16:21:56 +01:00
Emmanuele Bassi
2e70e041f1 Integrate CSS gadget with GSK render nodes
First stab at an internal API that generates render nodes when drawing a
CSS gadget.
2016-10-17 16:21:56 +01:00
Emmanuele Bassi
aed3ab1e85 gtk: Update the coordinates when propagating render nodes
Just like gtk_container_propagate_draw() does for the immediate mode
rendering.
2016-10-17 16:21:56 +01:00
Emmanuele Bassi
6c08ea6283 Use the projection to flip around the content
Since we use an FBO to render the contents of the render node tree, the
coordinate space is going to be flipped in GL. We can undo the flip by
using an appropriate projection matrix, instead of changing the sampling
coordinates in the shaders and updating all our coordinates at render
time.
2016-10-17 16:21:56 +01:00
Emmanuele Bassi
4c986971fd widget: Fix compatibility fallbacks 2016-10-17 16:21:56 +01:00
Emmanuele Bassi
9b9141fea9 gsk: Add texture size to debug message 2016-10-17 16:21:56 +01:00
Emmanuele Bassi
8471405b7f gsk: Take into account the scaling factor
We need to apply a scaling factor whenever we deal with user-supplied
coordinates, like:

 - when creating textures
 - when setting up the viewport
 - when submitting the scene
2016-10-17 16:21:56 +01:00
Emmanuele Bassi
c77cc127ea gsk: Tie render nodes to renderers
Render nodes need access to rendering information like scaling factors.
If we keep render nodes separate from renderers until we submit a nodes
tree for rendering we're going to have to duplicate all that information
in a way that makes the API more complicated and fuzzier on its
semantics.

By having GskRenderer create GskRenderNode instances we can tie nodes
and renderers together; since higher layers will also have access to
the renderer instance, this does not add any burden to callers.

Additionally, if memory measurements indicate that we are spending too
much time in the allocation of new render nodes, we can now easily
implement a free-list or a renderer-specific allocator without breaking
the API.
2016-10-17 16:21:56 +01:00
Emmanuele Bassi
89500c5d84 gsk: Bind GL context to the GL profiler
Similarly to how we bind it to the GL driver object used by the GSK GL
renderer.
2016-10-17 16:21:55 +01:00
Emmanuele Bassi
e48cc71656 gtk: Port GtkWindow to render nodes
WARNING: BROKEN COMMIT
2016-10-17 16:21:55 +01:00
Emmanuele Bassi
db10f1ff64 gtk: Add GtkContainer API to gather render nodes
We cannot implement GtkWidgetClass.get_render_node() in GtkContainer
without breaking the fallback path that renders a widget to a single
render node rasterization. For GtkContainer subclasses we should provide
a simple API, similar to gtk_container_propagate_draw(), that gathers
all the render nodes for each child.
2016-10-17 16:21:55 +01:00
Emmanuele Bassi
020e4e5bfa gtk: Name GSK render nodes
For debugging purposes it's helpful to name the nodes.
2016-10-17 16:21:55 +01:00
Emmanuele Bassi
bbf11f749b gsk: Fix build without Wayland 2016-10-17 16:21:55 +01:00
Emmanuele Bassi
0ca16c5a7e gsk: Add redirection to FBOs for opacity groups
If a node is non-opaque and has a non-zero opacity we need to paint its
contents and children first to an off screen buffer, and then render the
resulting texture at the desired opacity — otherwise the opacities will
combine and result in the wrong rendering.
2016-10-17 16:21:55 +01:00
Emmanuele Bassi
11085dccae gsk: Drop opaque/transparent item split
We're not going to use separate rendering lists soon, and the way we
render items is less similar to a gaming engine and more similar to a
simpler compositor. This means we don't need to perform a two pass
rendering — opaque items first, transparent items later.
2016-10-17 16:21:55 +01:00
Emmanuele Bassi
f9ca3f0143 gsk: Rename uniforms and attributes in shaders
Use appropriate names, and annotate the names with the types — 'u' for
uniforms, 'a' for attributes. The common preambles for shaders are split
from the bodies, so we need some way to distinguish the uniforms and the
attributes just from their name.
2016-10-17 16:21:55 +01:00
Emmanuele Bassi
512cbcb6e0 gsk: Move resource handling inside GskGLDriver
We want the GL driver to cache as many resources as possible, so we can
always ensure that we're in a consistent state, and we can handle state
transitions more appropriately.
2016-10-17 16:21:55 +01:00
Emmanuele Bassi
78f320c01d gsk: Simplify buffer handling in GskGLRenderer
We don't have optional stencil and depth buffers, like GtkGLArea: we
always create both of them internally.
2016-10-17 16:21:55 +01:00
Emmanuele Bassi
f661d097a6 gsk: Drop render buffer code path from GskGLRenderer
We always use texturing, to preserve the alpha channel when blitting the
frame buffer object on the window surface.
2016-10-17 16:21:55 +01:00
Emmanuele Bassi
c481c01322 gsk: Rework surface -> texture API
Drop the texture parameters handling from the texture creation, and
associate them with the contents upload. Also, rename the function to
something more in line with what it does.
2016-10-17 16:21:55 +01:00
Emmanuele Bassi
2059da9967 gsk: Add GL driver API to create render targets
It's going to be used by the GL renderer to safely create and bind
FBOs when needed.
2016-10-17 16:21:54 +01:00
Emmanuele Bassi
cc6b7a5ea0 gsk: Turn texture cache into a hash table
We want to add the list of FBOs tied to a texture; this means we cannot
trivally copy the Texture structure when adding it to a GArray. We're
also going to have more textures than VAOs, so it makes more sense to
use a O(1) access data structure for them.
2016-10-17 16:21:54 +01:00
Emmanuele Bassi
66d16d19c1 gsk: Add GL profiler
We can use the GL_ARB_timer_query extension (available since OpenGL
3.2, and part of the OpenGL specification since version 3.3) to query
the time elapsed when drawing each frame. This allows us to gather
timing information on our use of the GPU.
2016-10-17 16:21:54 +01:00
Emmanuele Bassi
77dc24be86 gsk: Split surface upload from texture creation
We're going to need a method to create textures without a surface.
2016-10-17 16:21:54 +01:00
Emmanuele Bassi
829676c93d gsk: Enable depth testing
Use the appropriate depth testing function for transparent items.
2016-10-17 16:21:54 +01:00
Emmanuele Bassi
e02836f989 gsk: Use consistent naming for blend fragment shader
This should make it immediately clear if we're doing something wrong.
2016-10-17 16:21:54 +01:00