forked from AuroraMiddleware/gtk
gsk: Add gsk_color_node_new()
This commit is contained in:
parent
361e2cda27
commit
6129daf29b
@ -35,6 +35,7 @@ gsk_render_node_set_blend_mode
|
||||
GskScalingFilter
|
||||
gsk_render_node_set_scaling_filters
|
||||
gsk_render_node_set_name
|
||||
gsk_color_node_new
|
||||
gsk_texture_node_new
|
||||
gsk_cairo_node_new
|
||||
gsk_cairo_node_get_draw_context
|
||||
|
@ -27,6 +27,7 @@
|
||||
* @GSK_NOT_A_RENDER_NODE: Error type. No node will ever have this type.
|
||||
* @GSK_CONTAINER_NODE: A node containing a stack of children
|
||||
* @GSK_CAIRO_NODE: A node drawing a #cairo_surface_t
|
||||
* @GSK_COLOR_NODE: A node drawing a single color rectangle
|
||||
* @GSK_TEXTURE_NODE: A node drawing a #GskTexture
|
||||
* @GSK_TRANSFORM_NODE: A node that renders its child after applying a
|
||||
* matrix transform
|
||||
@ -39,6 +40,7 @@ typedef enum {
|
||||
GSK_NOT_A_RENDER_NODE = 0,
|
||||
GSK_CONTAINER_NODE,
|
||||
GSK_CAIRO_NODE,
|
||||
GSK_COLOR_NODE,
|
||||
GSK_TEXTURE_NODE,
|
||||
GSK_TRANSFORM_NODE
|
||||
} GskRenderNodeType;
|
||||
|
@ -44,6 +44,10 @@ void gsk_render_node_unref (GskRenderNode *
|
||||
GDK_AVAILABLE_IN_3_90
|
||||
GskRenderNodeType gsk_render_node_get_node_type (GskRenderNode *node);
|
||||
|
||||
GDK_AVAILABLE_IN_3_90
|
||||
GskRenderNode * gsk_color_node_new (const GdkRGBA *rgba,
|
||||
const graphene_rect_t *bounds);
|
||||
|
||||
GDK_AVAILABLE_IN_3_90
|
||||
GskRenderNode * gsk_texture_node_new (GskTexture *texture,
|
||||
const graphene_rect_t *bounds);
|
||||
|
@ -22,6 +22,98 @@
|
||||
#include "gskrendererprivate.h"
|
||||
#include "gsktextureprivate.h"
|
||||
|
||||
/*** GSK_COLOR_NODE ***/
|
||||
|
||||
typedef struct _GskColorNode GskColorNode;
|
||||
|
||||
struct _GskColorNode
|
||||
{
|
||||
GskRenderNode render_node;
|
||||
|
||||
GdkRGBA color;
|
||||
graphene_rect_t bounds;
|
||||
};
|
||||
|
||||
static void
|
||||
gsk_color_node_finalize (GskRenderNode *node)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_color_node_make_immutable (GskRenderNode *node)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_color_node_draw (GskRenderNode *node,
|
||||
cairo_t *cr)
|
||||
{
|
||||
GskColorNode *self = (GskColorNode *) node;
|
||||
|
||||
gdk_cairo_set_source_rgba (cr, &self->color);
|
||||
|
||||
cairo_rectangle (cr,
|
||||
self->bounds.origin.x, self->bounds.origin.y,
|
||||
self->bounds.size.width, self->bounds.size.height);
|
||||
cairo_fill (cr);
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_color_node_get_bounds (GskRenderNode *node,
|
||||
graphene_rect_t *bounds)
|
||||
{
|
||||
GskColorNode *self = (GskColorNode *) node;
|
||||
|
||||
graphene_rect_init_from_rect (bounds, &self->bounds);
|
||||
}
|
||||
|
||||
static const GskRenderNodeClass GSK_COLOR_NODE_CLASS = {
|
||||
GSK_COLOR_NODE,
|
||||
sizeof (GskColorNode),
|
||||
"GskColorNode",
|
||||
gsk_color_node_finalize,
|
||||
gsk_color_node_make_immutable,
|
||||
gsk_color_node_draw,
|
||||
gsk_color_node_get_bounds
|
||||
};
|
||||
|
||||
const GdkRGBA *
|
||||
gsk_color_node_peek_color (GskRenderNode *node)
|
||||
{
|
||||
GskColorNode *self = (GskColorNode *) node;
|
||||
|
||||
return &self->color;
|
||||
}
|
||||
|
||||
/**
|
||||
* gsk_color_node_new:
|
||||
* @color: the #GskColor
|
||||
* @bounds: the rectangle to render the color into
|
||||
*
|
||||
* Creates a #GskRenderNode that will render the given
|
||||
* @color into the area given by @bounds.
|
||||
*
|
||||
* Returns: A new #GskRenderNode
|
||||
*
|
||||
* Since: 3.90
|
||||
*/
|
||||
GskRenderNode *
|
||||
gsk_color_node_new (const GdkRGBA *rgba,
|
||||
const graphene_rect_t *bounds)
|
||||
{
|
||||
GskColorNode *self;
|
||||
|
||||
g_return_val_if_fail (rgba != NULL, NULL);
|
||||
g_return_val_if_fail (bounds != NULL, NULL);
|
||||
|
||||
self = (GskColorNode *) gsk_render_node_new (&GSK_COLOR_NODE_CLASS);
|
||||
|
||||
self->color = *rgba;
|
||||
graphene_rect_init_from_rect (&self->bounds, bounds);
|
||||
|
||||
return &self->render_node;
|
||||
}
|
||||
|
||||
/*** GSK_TEXTURE_NODE ***/
|
||||
|
||||
typedef struct _GskTextureNode GskTextureNode;
|
||||
|
@ -58,6 +58,8 @@ cairo_surface_t *gsk_cairo_node_get_surface (GskRenderNode *node);
|
||||
|
||||
GskTexture *gsk_texture_node_get_texture (GskRenderNode *node);
|
||||
|
||||
const GdkRGBA *gsk_color_node_peek_color (GskRenderNode *node);
|
||||
|
||||
void gsk_transform_node_get_transform (GskRenderNode *node, graphene_matrix_t *transform);
|
||||
|
||||
GskBlendMode gsk_render_node_get_blend_mode (GskRenderNode *node);
|
||||
|
@ -522,6 +522,7 @@ append_node (GtkTreeModelRenderNode *nodemodel,
|
||||
|
||||
case GSK_CAIRO_NODE:
|
||||
case GSK_TEXTURE_NODE:
|
||||
case GSK_COLOR_NODE:
|
||||
/* no children */
|
||||
break;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user