Commit Graph

48488 Commits

Author SHA1 Message Date
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
Emmanuele Bassi
841ca89956 gsk: Fix pre-condition check
We warn if the node is marked as not mutable.
2016-10-17 16:21:54 +01:00
Emmanuele Bassi
509a219fcb gsk: Flip mutability on GskRenderNode.finalize
We use the public API when removing children nodes, so we need to mark
the node as mutable while we destroy it.
2016-10-17 16:21:54 +01:00
Emmanuele Bassi
5313aa28d6 gsk: Add specific debug type for shaders
So that we don't lose GskShaderBuilder debugging messages in the stream
of GskGLRenderer ones.
2016-10-17 16:21:54 +01:00
Emmanuele Bassi
984e205ddb gsk: Add GskGLDriver
We can move the caching and management of textures, VAOs, and state of
the GL machinery into a single object, GskGLDriver.
2016-10-17 16:21:54 +01:00
Emmanuele Bassi
e3bf255d2f gsk: Use the right pointer to the parent RenderItem
We copy the local RenderItem into the render items array, so we need to
use the copy in the array in order to get the correct reference.
2016-10-17 16:21:54 +01:00
Emmanuele Bassi
07d823e9ff Ensure that render nodes are translated
The clip rectangle may have non-zero offsets, so we need to ensure that
the GskRenderNode associated to the rendered area is translated by those
same offsets.
2016-10-17 16:21:53 +01:00
Emmanuele Bassi
3bf8f49ead gsk: Add fundamental type annotations for GskRenderNode
We need to annotate the GskRenderNode so that the introspection
machinery can find the functions for managing reference counting
and GValues.
2016-10-17 16:21:53 +01:00
Emmanuele Bassi
ea982b5564 gsk: Add 'blit' program
For the root node we do not need to use blending, as it does not have
any backdrop to blend into. We can use a simpler 'blit' program that
only takes the content of the source and fills the texture quad with
it.
2016-10-17 16:21:53 +01:00
Emmanuele Bassi
d0c6c6251e gsk: Consolidate program creation and storage
We should use ShaderBuilder to create and store programs for the GL
renderer. This allows us to simplify the creation of programs (by moving
the compilation phase into the ShaderBuilder::create_program() method),
and move towards the ability to create multiple programs and just keep a
reference to the program id.
2016-10-17 16:21:53 +01:00
Emmanuele Bassi
c04db84c48 docs: Add more GSK documentation 2016-10-17 16:21:53 +01:00
Emmanuele Bassi
9155bbaafb gsk: Add more modes to the blend shader
Use the compositing CSS spec at:

  https://www.w3.org/TR/compositing-1/#blending

For the implementation.
2016-10-17 16:21:53 +01:00
Emmanuele Bassi
8420dc7682 gsk: Don't store the uniform and attribute location twice
We should keep the ShaderBuilder around and use it to query the various
uniform and attribute locations when needed, instead of storing those
offsets into the Renderer instance, and copying them. This allows a bit
more flexibility, once we have more than one program built into the
renderer.
2016-10-17 16:21:53 +01:00
Emmanuele Bassi
9dde2ebf67 gsk: Add getter for program id in ShaderBuilder
Since we store it into the ShaderBuilder instance we should also allow
getting the program id.
2016-10-17 16:21:53 +01:00
Emmanuele Bassi
999db0f9c8 gsk: Add debugging notes to ShaderBuilder
Print out the generated shader and the list of available uniforms and
attributes.
2016-10-17 16:21:53 +01:00
Emmanuele Bassi
34a5eb01e3 gsk: Rework how GLSL shaders are built
The GL renderer should build the GLSL shaders using GskShaderBuilder.
This allows us to separate the common parts into separate files, and
assemble them as necessary, instead of shipping one big shader per type
of GL API (GL3, GL legacy, and GLES).
2016-10-17 16:21:53 +01:00
Emmanuele Bassi
cf76f81409 gsk: Add ShaderBuilder
GskShaderBuilder is an ancillary, private type that deals with the
internals of taking GLSL shaders from resources and building them,
with the additional feature of being able to compose shaders from a
common preamble, as well as adding conditional defines (useful for
enabling debugging code in the shaders themselves).
2016-10-17 16:21:53 +01:00
Emmanuele Bassi
c4a2f3b5fb gsk: Add rendering debug mode for shaders
It's going to be useful to inject debugging data into the shaders used
by GSK.
2016-10-17 16:21:53 +01:00
Emmanuele Bassi
7a98ef45e1 gdk: Add more GDK_GL_ERROR error ids
We're going to use them in other locations.
2016-10-17 16:21:53 +01:00
Emmanuele Bassi
907fc8d21e gsk: Use the node's blend mode in the GL renderer 2016-10-17 16:21:52 +01:00
Emmanuele Bassi
51b889bf8f gsk: Store blend mode in the render node 2016-10-17 16:21:52 +01:00
Emmanuele Bassi
d1d2ae6c25 gsk: Make GskBlendMode enumeration public 2016-10-17 16:21:52 +01:00
Emmanuele Bassi
53cbbf8cf2 gsk: Allow sampling between parent and child nodes 2016-10-17 16:21:52 +01:00
Emmanuele Bassi
145e45db26 gsk: Group render state attributes 2016-10-17 16:21:52 +01:00
Emmanuele Bassi
4e2f35fdf2 gsk: Turn GskRenderNode into a pure GTypeInstance
Using GObject as the base type for a transient tree may prove to be too
intensive, especially when creating a lot of node instances. Since we
don't need properties or signals, and we don't need complex destruction
semantics, we can use GTypeInstance directly as the base type for
GskRenderNode.
2016-10-17 16:21:52 +01:00
Emmanuele Bassi
81377767a2 gtk: Use GskRenderNode to render widgets
We need a virtual function to retrieve the GskRenderNode for each
widget, which is supposed to attach its own children's GskRenderNodes.
Additionally, we want to maintain the existing GtkWidget::draw mechanism
for widgets that do not implement get_render_node() — as well as widgets
that have handlers connected to the ::draw signal.
2016-10-17 16:21:52 +01:00
Emmanuele Bassi
6aed0210a4 gtk: Add a GskRenderer to GtkWindow
Each top-level should have its own GskRenderer, to be used when drawing
the render node tree.
2016-10-17 16:21:52 +01:00
Emmanuele Bassi
9992e35c59 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-17 16:21:52 +01:00
Emmanuele Bassi
79a9f700c4 gsk: Flush the GL render items cache
Whenever the render tree changes we want to drop the RenderItem arrays,
as each item contains a pointer to the GskRenderNode which becomes
dangling once the root node changed.
2016-10-17 16:21:52 +01:00
Emmanuele Bassi
ea95e22a75 gsk: Add GskRenderer::clear_tree
We need a way to clear eventual caches inside GskRenderer subclasses if
the root node has changed.
2016-10-17 16:21:52 +01:00
Emmanuele Bassi
625e930222 gsk: Port GskGLRenderer to GLES
Use the appropriate API and shaders if the GdkGLContext was created for
OpenGL ES instead of OpenGL.
2016-10-17 16:21:52 +01:00
Emmanuele Bassi
0eaf85704b gsk: Use surface-to-texture utility function
Now that we have it.
2016-10-17 16:21:51 +01:00
Emmanuele Bassi
55d2522fb0 gsk: Rename shaders for OpenGL 2016-10-17 16:21:51 +01:00
Emmanuele Bassi
0f57ab4a54 gdk: Add utility for uploading Cairo surfaces to GL
The surface-to-GL upload logic has become more complicated with the
addition of the GLES code paths; it's more logical to have a public
utility function that can be called from GDK users, instead of copy
pasting the whole thing multiple times.
2016-10-17 16:21:51 +01:00
Emmanuele Bassi
ae8d209e50 build: Add GSK deps to GTK 2016-10-17 16:21:51 +01:00
Emmanuele Bassi
a422f45544 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-17 16:21:51 +01:00
Emmanuele Bassi
2378965e92 gsk: Initial commit / build environment 2016-10-17 16:21:51 +01:00
Benjamin Otte
dbeeaf7de6 cssprovider: Remove GError out argument from load functions
People should use the GtkCssProvider::parsing-error signal instead.
2016-10-17 16:52:05 +02:00
Ben Iofel
55e599c561 textbufferserialize: declare set_error as G_GNUC_PRINTF
And fix a missing format argument
2016-10-17 10:36:26 -04:00
Ben Iofel
84739239ce colorscale: modify loop variables in loop body 2016-10-17 15:17:28 +01:00
Emmanuele Bassi
7b73bc3572 build: Use correct compiler flag
The name is -Wformat-nonliteral.
2016-10-17 15:13:09 +01:00
Garrett Regier
7173df1dd1 gtk+: Fix GI warnings about missing parameters
These were removed for GTK+ 4.
2016-10-17 07:07:20 -07:00
Emmanuele Bassi
a0aa1d963a broadway: Remove redundant declaration 2016-10-17 14:56:38 +01:00
Emmanuele Bassi
2332ac444c gtk/utils: Include stdio.h
We need it because of the declaration using FILE*.
2016-10-17 14:51:16 +01:00
Ignacio Casal Quinteiro
a12b691b76 gtkicontheme: check if the context quark string is not null
On windows you might not have a theme installed by default which
means that when trying to create the context quark it will fail.
If then we try to replace a NULL key in the hash table it will crash.

https://bugzilla.gnome.org/show_bug.cgi?id=769859
2016-10-17 13:04:31 +02:00
Emmanuele Bassi
857d241e22 Remove redundant variable declaration
The inner `var` declaration is shadowing the outer one.
2016-10-17 11:52:00 +01:00
Emmanuele Bassi
20b2e479f8 build: Add various compiler warnings and errors
Just like GLib, GTK+ would benefit from getting warnings and errors from
the compilers.

We check various, common warnings, especially for a future use of C99;
additionally, we promote some warnings to errors, in order to ensure
that simple mistakes are caught during the development phase, before
they are submitted to the code repository.
2016-10-17 11:44:11 +01:00
Emmanuele Bassi
6a9be60a16 notebook: Remove redundant variable declarations
We're already declaring notebook and priv at the top of the function,
and assigning them to the same values.
2016-10-17 11:44:11 +01:00
Emmanuele Bassi
39e848c0eb icontheme: Drop unnecessary allocation
Use a static array for the known icon sizes, now that we don't allow
registering custom icon sizes any more. This allows us to cut a one-off
allocation that makes Valgrind sad.
2016-10-17 11:44:11 +01:00
Emmanuele Bassi
5563ba96bc Avoid variable shadowing in GtkShortcutsSection 2016-10-17 11:44:11 +01:00