[gtk+/wip/otte/rendernode] gsk: Add fallback code to renderers
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/otte/rendernode] gsk: Add fallback code to renderers
- Date: Tue, 13 Dec 2016 04:52:33 +0000 (UTC)
commit f2411e08f7c2caf9fdbe0a9838a350f1047f7dbf
Author: Benjamin Otte <otte redhat com>
Date: Tue Dec 13 04:20:04 2016 +0100
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.
gsk/gskglrenderer.c | 32 +++++++++++++++++++++++++++++++-
gsk/gskvulkanrenderpass.c | 6 +++++-
2 files changed, 36 insertions(+), 2 deletions(-)
---
diff --git a/gsk/gskglrenderer.c b/gsk/gskglrenderer.c
index 5cbb0a0..829e50a 100644
--- a/gsk/gskglrenderer.c
+++ b/gsk/gskglrenderer.c
@@ -760,8 +760,38 @@ gsk_gl_renderer_add_render_item (GskGLRenderer *self,
return;
case GSK_NOT_A_RENDER_NODE:
- default:
+ g_assert_not_reached ();
return;
+
+ default:
+ {
+ graphene_rect_t bounds;
+ cairo_surface_t *surface;
+ cairo_t *cr;
+
+ gsk_render_node_get_bounds (node, &bounds);
+
+ surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
+ ceil (bounds.size.width),
+ ceil (bounds.size.height));
+ cr = cairo_create (surface);
+ cairo_translate (cr, bounds.origin.x, bounds.origin.y);
+
+ gsk_render_node_draw (node, cr);
+
+ cairo_destroy (cr);
+
+ /* Upload the Cairo surface to a GL texture */
+ item.render_data.texture_id = gsk_gl_driver_create_texture (self->gl_driver,
+ item.size.width,
+ item.size.height);
+ gsk_gl_driver_bind_source_texture (self->gl_driver, item.render_data.texture_id);
+ gsk_gl_driver_init_texture_with_surface (self->gl_driver,
+ item.render_data.texture_id,
+ surface,
+ GL_NEAREST, GL_NEAREST);
+ }
+ break;
}
/* Create the vertex buffers holding the geometry of the quad */
diff --git a/gsk/gskvulkanrenderpass.c b/gsk/gskvulkanrenderpass.c
index 62af7e3..7df4421 100644
--- a/gsk/gskvulkanrenderpass.c
+++ b/gsk/gskvulkanrenderpass.c
@@ -72,10 +72,14 @@ gsk_vulkan_render_pass_add_node (GskVulkanRenderPass *self,
switch (gsk_render_node_get_node_type (node))
{
case GSK_NOT_A_RENDER_NODE:
- default:
g_assert_not_reached ();
break;
+ default:
+ op.type = GSK_VULKAN_OP_FALLBACK;
+ g_array_append_val (self->render_ops, op);
+ break;
+
case GSK_CAIRO_NODE:
op.type = GSK_VULKAN_OP_SURFACE;
g_array_append_val (self->render_ops, op);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]