mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-13 12:20:10 +00:00
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.
This commit is contained in:
parent
03ab560fae
commit
8ac9127283
@ -99,8 +99,7 @@ struct _GskGLRenderer
|
|||||||
int blend_program_id;
|
int blend_program_id;
|
||||||
int blit_program_id;
|
int blit_program_id;
|
||||||
|
|
||||||
GArray *opaque_render_items;
|
GArray *render_items;
|
||||||
GArray *transparent_render_items;
|
|
||||||
|
|
||||||
gboolean has_buffers : 1;
|
gboolean has_buffers : 1;
|
||||||
};
|
};
|
||||||
@ -311,8 +310,7 @@ gsk_gl_renderer_unrealize (GskRenderer *renderer)
|
|||||||
/* We don't need to iterate to destroy the associated GL resources,
|
/* We don't need to iterate to destroy the associated GL resources,
|
||||||
* as they will be dropped when we finalize the GskGLDriver
|
* as they will be dropped when we finalize the GskGLDriver
|
||||||
*/
|
*/
|
||||||
g_clear_pointer (&self->opaque_render_items, g_array_unref);
|
g_clear_pointer (&self->render_items, g_array_unref);
|
||||||
g_clear_pointer (&self->transparent_render_items, g_array_unref);
|
|
||||||
|
|
||||||
gsk_gl_renderer_destroy_buffers (self);
|
gsk_gl_renderer_destroy_buffers (self);
|
||||||
gsk_gl_renderer_destroy_programs (self);
|
gsk_gl_renderer_destroy_programs (self);
|
||||||
@ -523,6 +521,12 @@ gsk_gl_renderer_add_render_item (GskGLRenderer *self,
|
|||||||
else
|
else
|
||||||
item.parent_data = NULL;
|
item.parent_data = NULL;
|
||||||
|
|
||||||
|
/* Select the render target */
|
||||||
|
if (parent != NULL)
|
||||||
|
item.render_data.render_target_id = parent->render_data.render_target_id;
|
||||||
|
else
|
||||||
|
item.render_data.render_target_id = self->texture_id;
|
||||||
|
|
||||||
/* Select the program to use */
|
/* Select the program to use */
|
||||||
if (parent != NULL)
|
if (parent != NULL)
|
||||||
program_id = self->blend_program_id;
|
program_id = self->blend_program_id;
|
||||||
@ -602,20 +606,10 @@ gsk_gl_renderer_add_render_item (GskGLRenderer *self,
|
|||||||
GSK_NOTE (OPENGL, g_print ("Adding node <%s>[%p] to render items\n",
|
GSK_NOTE (OPENGL, g_print ("Adding node <%s>[%p] to render items\n",
|
||||||
node->name != NULL ? node->name : "unnamed",
|
node->name != NULL ? node->name : "unnamed",
|
||||||
node));
|
node));
|
||||||
if (gsk_render_node_is_opaque (node) && gsk_render_node_get_opacity (node) == 1.f)
|
g_array_append_val (self->render_items, item);
|
||||||
{
|
ritem = &g_array_index (self->render_items,
|
||||||
g_array_append_val (self->opaque_render_items, item);
|
RenderItem,
|
||||||
ritem = &g_array_index (self->opaque_render_items,
|
self->render_items->len - 1);
|
||||||
RenderItem,
|
|
||||||
self->opaque_render_items->len - 1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
g_array_append_val (self->transparent_render_items, item);
|
|
||||||
ritem = &g_array_index (self->transparent_render_items,
|
|
||||||
RenderItem,
|
|
||||||
self->transparent_render_items->len - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
recurse_children:
|
recurse_children:
|
||||||
gsk_render_node_iter_init (&iter, node);
|
gsk_render_node_iter_init (&iter, node);
|
||||||
@ -639,19 +633,16 @@ gsk_gl_renderer_validate_tree (GskGLRenderer *self,
|
|||||||
|
|
||||||
gdk_gl_context_make_current (self->context);
|
gdk_gl_context_make_current (self->context);
|
||||||
|
|
||||||
self->opaque_render_items = g_array_sized_new (FALSE, FALSE, sizeof (RenderItem), n_nodes);
|
self->render_items = g_array_sized_new (FALSE, FALSE, sizeof (RenderItem), n_nodes);
|
||||||
self->transparent_render_items = g_array_sized_new (FALSE, FALSE, sizeof (RenderItem), n_nodes);
|
|
||||||
|
|
||||||
gsk_gl_driver_begin_frame (self->gl_driver);
|
gsk_gl_driver_begin_frame (self->gl_driver);
|
||||||
|
|
||||||
GSK_NOTE (OPENGL, g_print ("RenderNode -> RenderItem\n"));
|
GSK_NOTE (OPENGL, g_print ("RenderNode -> RenderItem\n"));
|
||||||
gsk_gl_renderer_add_render_item (self, root, NULL);
|
gsk_gl_renderer_add_render_item (self, root, NULL);
|
||||||
|
|
||||||
GSK_NOTE (OPENGL, g_print ("Total render items: %d of %d (opaque:%d, transparent:%d)\n",
|
GSK_NOTE (OPENGL, g_print ("Total render items: %d of max:%d\n",
|
||||||
self->opaque_render_items->len + self->transparent_render_items->len,
|
self->render_items->len,
|
||||||
n_nodes,
|
n_nodes));
|
||||||
self->opaque_render_items->len,
|
|
||||||
self->transparent_render_items->len));
|
|
||||||
|
|
||||||
gsk_gl_driver_end_frame (self->gl_driver);
|
gsk_gl_driver_end_frame (self->gl_driver);
|
||||||
|
|
||||||
@ -668,24 +659,15 @@ gsk_gl_renderer_clear_tree (GskGLRenderer *self)
|
|||||||
|
|
||||||
gdk_gl_context_make_current (self->context);
|
gdk_gl_context_make_current (self->context);
|
||||||
|
|
||||||
for (i = 0; i < self->opaque_render_items->len; i++)
|
for (i = 0; i < self->render_items->len; i++)
|
||||||
{
|
{
|
||||||
RenderItem *item = &g_array_index (self->opaque_render_items, RenderItem, i);
|
RenderItem *item = &g_array_index (self->render_items, RenderItem, i);
|
||||||
|
|
||||||
gsk_gl_driver_destroy_texture (self->gl_driver, item->render_data.texture_id);
|
gsk_gl_driver_destroy_texture (self->gl_driver, item->render_data.texture_id);
|
||||||
gsk_gl_driver_destroy_vao (self->gl_driver, item->render_data.vao_id);
|
gsk_gl_driver_destroy_vao (self->gl_driver, item->render_data.vao_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < self->transparent_render_items->len; i++)
|
g_clear_pointer (&self->render_items, g_array_unref);
|
||||||
{
|
|
||||||
RenderItem *item = &g_array_index (self->transparent_render_items, RenderItem, i);
|
|
||||||
|
|
||||||
gsk_gl_driver_destroy_texture (self->gl_driver, item->render_data.texture_id);
|
|
||||||
gsk_gl_driver_destroy_vao (self->gl_driver, item->render_data.vao_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_clear_pointer (&self->opaque_render_items, g_array_unref);
|
|
||||||
g_clear_pointer (&self->transparent_render_items, g_array_unref);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -737,20 +719,6 @@ gsk_gl_renderer_render (GskRenderer *renderer,
|
|||||||
|
|
||||||
gsk_gl_renderer_clear (self);
|
gsk_gl_renderer_clear (self);
|
||||||
|
|
||||||
glDisable (GL_BLEND);
|
|
||||||
|
|
||||||
glEnable (GL_DEPTH_TEST);
|
|
||||||
glDepthFunc (GL_LESS);
|
|
||||||
|
|
||||||
/* Opaque pass: front-to-back */
|
|
||||||
GSK_NOTE (OPENGL, g_print ("Rendering %u opaque items\n", self->opaque_render_items->len));
|
|
||||||
for (i = 0; i < self->opaque_render_items->len; i++)
|
|
||||||
{
|
|
||||||
RenderItem *item = &g_array_index (self->opaque_render_items, RenderItem, i);
|
|
||||||
|
|
||||||
render_item (self, item);
|
|
||||||
}
|
|
||||||
|
|
||||||
glEnable (GL_DEPTH_TEST);
|
glEnable (GL_DEPTH_TEST);
|
||||||
glDepthFunc (GL_LEQUAL);
|
glDepthFunc (GL_LEQUAL);
|
||||||
|
|
||||||
@ -759,10 +727,10 @@ gsk_gl_renderer_render (GskRenderer *renderer,
|
|||||||
glBlendEquation (GL_FUNC_ADD);
|
glBlendEquation (GL_FUNC_ADD);
|
||||||
|
|
||||||
/* Transparent pass: back-to-front */
|
/* Transparent pass: back-to-front */
|
||||||
GSK_NOTE (OPENGL, g_print ("Rendering %u transparent items\n", self->transparent_render_items->len));
|
GSK_NOTE (OPENGL, g_print ("Rendering %u items\n", self->render_items->len));
|
||||||
for (i = 0; i < self->transparent_render_items->len; i++)
|
for (i = 0; i < self->render_items->len; i++)
|
||||||
{
|
{
|
||||||
RenderItem *item = &g_array_index (self->transparent_render_items, RenderItem, i);
|
RenderItem *item = &g_array_index (self->render_items, RenderItem, i);
|
||||||
|
|
||||||
render_item (self, item);
|
render_item (self, item);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user