forked from AuroraMiddleware/gtk
gsk: Add gsk_cairo_node_new()
Split off Cairo drawn content nodes and require you to allocate them using this new function.
This commit is contained in:
parent
d1b80a6baa
commit
52d2faef88
@ -49,13 +49,14 @@ gsk_render_node_set_transform
|
||||
gsk_render_node_set_opacity
|
||||
gsk_render_node_set_opaque
|
||||
gsk_render_node_is_opaque
|
||||
gsk_render_node_get_draw_context
|
||||
GskBlendMode
|
||||
gsk_render_node_set_blend_mode
|
||||
GskScalingFilter
|
||||
gsk_render_node_set_scaling_filters
|
||||
gsk_render_node_set_name
|
||||
gsk_texture_node_new
|
||||
gsk_cairo_node_new
|
||||
gsk_cairo_node_get_draw_context
|
||||
<SUBSECTION Standard>
|
||||
GSK_IS_RENDER_NODE
|
||||
GSK_RENDER_NODE
|
||||
|
@ -94,8 +94,7 @@ gsk_cairo_renderer_render_node (GskCairoRenderer *self,
|
||||
pop_group = TRUE;
|
||||
}
|
||||
|
||||
GSK_NOTE (CAIRO, g_print ("Rendering surface %p for node %s[%p] at %g, %g\n",
|
||||
gsk_render_node_get_surface (node),
|
||||
GSK_NOTE (CAIRO, g_print ("Rendering node %s[%p] at %g, %g\n",
|
||||
node->name,
|
||||
node,
|
||||
frame.origin.x, frame.origin.y));
|
||||
@ -110,7 +109,7 @@ gsk_cairo_renderer_render_node (GskCairoRenderer *self,
|
||||
}
|
||||
else
|
||||
{
|
||||
cairo_set_source_surface (cr, gsk_render_node_get_surface (node), frame.origin.x, frame.origin.y);
|
||||
cairo_set_source_surface (cr, gsk_cairo_node_get_surface (node), frame.origin.x, frame.origin.y);
|
||||
cairo_paint (cr);
|
||||
}
|
||||
|
||||
|
@ -733,7 +733,7 @@ gsk_gl_renderer_add_render_item (GskGLRenderer *self,
|
||||
}
|
||||
else if (gsk_render_node_has_surface (node))
|
||||
{
|
||||
cairo_surface_t *surface = gsk_render_node_get_surface (node);
|
||||
cairo_surface_t *surface = gsk_cairo_node_get_surface (node);
|
||||
int gl_min_filter = GL_NEAREST, gl_mag_filter = GL_NEAREST;
|
||||
|
||||
get_gl_scaling_filters (node, &gl_min_filter, &gl_mag_filter);
|
||||
|
@ -1080,7 +1080,7 @@ gsk_texture_node_new (GskTexture *texture,
|
||||
}
|
||||
|
||||
/*< private >
|
||||
* gsk_render_node_get_surface:
|
||||
* gsk_cairo_node_get_surface:
|
||||
* @node: a #GskRenderNode
|
||||
*
|
||||
* Retrieves the surface set using gsk_render_node_set_surface().
|
||||
@ -1088,9 +1088,10 @@ gsk_texture_node_new (GskTexture *texture,
|
||||
* Returns: (transfer none) (nullable): a Cairo surface
|
||||
*/
|
||||
cairo_surface_t *
|
||||
gsk_render_node_get_surface (GskRenderNode *node)
|
||||
gsk_cairo_node_get_surface (GskRenderNode *node)
|
||||
{
|
||||
g_return_val_if_fail (GSK_IS_RENDER_NODE (node), NULL);
|
||||
g_return_val_if_fail (node->type == GSK_CAIRO_NODE, NULL);
|
||||
|
||||
return node->surface;
|
||||
}
|
||||
@ -1218,8 +1219,34 @@ gsk_render_node_get_blend_mode (GskRenderNode *node)
|
||||
}
|
||||
|
||||
/**
|
||||
* gsk_render_node_get_draw_context:
|
||||
* @node: a #GskRenderNode
|
||||
* gsk_cairo_node_new:
|
||||
* @bounds: the rectangle to render the to
|
||||
*
|
||||
* Creates a #GskRenderNode that will render a cairo surface
|
||||
* into the area given by @bounds. You can draw to the cairo
|
||||
* surface using gsk_cairo_node_get_draw_context()
|
||||
*
|
||||
* Returns: A new #GskRenderNode
|
||||
*
|
||||
* Since: 3.90
|
||||
*/
|
||||
GskRenderNode *
|
||||
gsk_cairo_node_new (const graphene_rect_t *bounds)
|
||||
{
|
||||
GskRenderNode *node;
|
||||
|
||||
g_return_val_if_fail (bounds != NULL, NULL);
|
||||
|
||||
node = gsk_render_node_new (GSK_CAIRO_NODE);
|
||||
|
||||
graphene_rect_init_from_rect (&node->bounds, bounds);
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
/**
|
||||
* gsk_cairo_node_get_draw_context:
|
||||
* @node: a cairo #GskRenderNode
|
||||
* @renderer: (nullable): Renderer to optimize for or %NULL for any
|
||||
*
|
||||
* Creates a Cairo context for drawing using the surface associated
|
||||
@ -1233,13 +1260,14 @@ gsk_render_node_get_blend_mode (GskRenderNode *node)
|
||||
* Since: 3.90
|
||||
*/
|
||||
cairo_t *
|
||||
gsk_render_node_get_draw_context (GskRenderNode *node,
|
||||
GskRenderer *renderer)
|
||||
gsk_cairo_node_get_draw_context (GskRenderNode *node,
|
||||
GskRenderer *renderer)
|
||||
{
|
||||
int width, height;
|
||||
cairo_t *res;
|
||||
|
||||
g_return_val_if_fail (GSK_IS_RENDER_NODE (node), NULL);
|
||||
g_return_val_if_fail (node->type == GSK_CAIRO_NODE, NULL);
|
||||
g_return_val_if_fail (node->is_mutable, NULL);
|
||||
g_return_val_if_fail (renderer == NULL || GSK_IS_RENDERER (renderer), NULL);
|
||||
|
||||
|
@ -48,6 +48,12 @@ GDK_AVAILABLE_IN_3_90
|
||||
GskRenderNode * gsk_texture_node_new (GskTexture *texture,
|
||||
const graphene_rect_t *bounds);
|
||||
|
||||
GDK_AVAILABLE_IN_3_90
|
||||
GskRenderNode * gsk_cairo_node_new (const graphene_rect_t *bounds);
|
||||
GDK_AVAILABLE_IN_3_90
|
||||
cairo_t * gsk_cairo_node_get_draw_context (GskRenderNode *node,
|
||||
GskRenderer *renderer);
|
||||
|
||||
GDK_AVAILABLE_IN_3_90
|
||||
GskRenderNode * gsk_render_node_get_parent (GskRenderNode *node);
|
||||
GDK_AVAILABLE_IN_3_90
|
||||
@ -107,9 +113,6 @@ void gsk_render_node_set_opaque (GskRenderNode *
|
||||
gboolean opaque);
|
||||
GDK_AVAILABLE_IN_3_90
|
||||
gboolean gsk_render_node_is_opaque (GskRenderNode *node);
|
||||
GDK_AVAILABLE_IN_3_90
|
||||
cairo_t * gsk_render_node_get_draw_context (GskRenderNode *node,
|
||||
GskRenderer *renderer);
|
||||
|
||||
GDK_AVAILABLE_IN_3_90
|
||||
void gsk_render_node_set_blend_mode (GskRenderNode *node,
|
||||
|
@ -69,7 +69,7 @@ void gsk_render_node_get_transform (GskRenderNode *node,
|
||||
graphene_matrix_t *mv);
|
||||
double gsk_render_node_get_opacity (GskRenderNode *node);
|
||||
|
||||
cairo_surface_t *gsk_render_node_get_surface (GskRenderNode *node);
|
||||
cairo_surface_t *gsk_cairo_node_get_surface (GskRenderNode *node);
|
||||
|
||||
GskTexture *gsk_texture_node_get_texture (GskRenderNode *node);
|
||||
|
||||
|
@ -154,7 +154,7 @@ gsk_vulkan_render_pass_upload (GskVulkanRenderPass *self,
|
||||
|
||||
case GSK_VULKAN_OP_SURFACE:
|
||||
{
|
||||
cairo_surface_t *surface = gsk_render_node_get_surface (op->node);
|
||||
cairo_surface_t *surface = gsk_cairo_node_get_surface (op->node);
|
||||
op->source = gsk_vulkan_image_new_from_data (self->vulkan,
|
||||
command_buffer,
|
||||
cairo_image_surface_get_data (surface),
|
||||
|
@ -409,8 +409,7 @@ gtk_snapshot_append_cairo_node (GtkSnapshot *snapshot,
|
||||
g_return_val_if_fail (snapshot != NULL, NULL);
|
||||
g_return_val_if_fail (bounds != NULL, NULL);
|
||||
|
||||
node = gsk_renderer_create_render_node (snapshot->renderer);
|
||||
gsk_render_node_set_bounds (node, bounds);
|
||||
node = gsk_cairo_node_new (bounds);
|
||||
|
||||
if (name)
|
||||
{
|
||||
@ -429,7 +428,7 @@ gtk_snapshot_append_cairo_node (GtkSnapshot *snapshot,
|
||||
gtk_snapshot_append_node (snapshot, node);
|
||||
gsk_render_node_unref (node);
|
||||
|
||||
return gsk_render_node_get_draw_context (node, snapshot->renderer);
|
||||
return gsk_cairo_node_get_draw_context (node, snapshot->renderer);
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user