mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-24 20:51:10 +00:00
gpu: Add support for cross-fades
This commit is contained in:
parent
0876089f8f
commit
e01311a565
@ -1006,6 +1006,47 @@ gsk_gpu_node_processor_create_conic_gradient_pattern (GskGpuPatternWriter *self,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gsk_gpu_node_processor_create_cross_fade_pattern (GskGpuPatternWriter *self,
|
||||
GskRenderNode *node)
|
||||
{
|
||||
GskRenderNode *start_child, *end_child;
|
||||
|
||||
start_child = gsk_cross_fade_node_get_start_child (node);
|
||||
end_child = gsk_cross_fade_node_get_end_child (node);
|
||||
|
||||
if (!gsk_gpu_node_processor_create_node_pattern (self, start_child))
|
||||
return FALSE;
|
||||
if (!gsk_rect_contains_rect (&start_child->bounds, &node->bounds))
|
||||
{
|
||||
gsk_gpu_buffer_writer_append_uint (&self->writer, GSK_GPU_PATTERN_CLIP);
|
||||
gsk_gpu_buffer_writer_append_rect (&self->writer, &start_child->bounds, &self->offset);
|
||||
}
|
||||
|
||||
gsk_gpu_buffer_writer_append_uint (&self->writer, GSK_GPU_PATTERN_PUSH_COLOR);
|
||||
|
||||
if (!gsk_gpu_pattern_writer_push_stack (self))
|
||||
return FALSE;
|
||||
|
||||
if (!gsk_gpu_node_processor_create_node_pattern (self, end_child))
|
||||
{
|
||||
gsk_gpu_pattern_writer_pop_stack (self);
|
||||
return FALSE;
|
||||
}
|
||||
if (!gsk_rect_contains_rect (&end_child->bounds, &node->bounds))
|
||||
{
|
||||
gsk_gpu_buffer_writer_append_uint (&self->writer, GSK_GPU_PATTERN_CLIP);
|
||||
gsk_gpu_buffer_writer_append_rect (&self->writer, &end_child->bounds, &self->offset);
|
||||
}
|
||||
|
||||
gsk_gpu_buffer_writer_append_uint (&self->writer, GSK_GPU_PATTERN_POP_CROSS_FADE);
|
||||
gsk_gpu_buffer_writer_append_float (&self->writer, gsk_cross_fade_node_get_progress (node));
|
||||
|
||||
gsk_gpu_pattern_writer_pop_stack (self);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gsk_gpu_node_processor_add_glyph_node (GskGpuNodeProcessor *self,
|
||||
GskRenderNode *node)
|
||||
@ -1377,8 +1418,8 @@ static const struct
|
||||
},
|
||||
[GSK_CROSS_FADE_NODE] = {
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
gsk_gpu_node_processor_add_node_as_pattern,
|
||||
gsk_gpu_node_processor_create_cross_fade_pattern,
|
||||
},
|
||||
[GSK_TEXT_NODE] = {
|
||||
0,
|
||||
|
@ -45,5 +45,7 @@ typedef enum {
|
||||
GSK_GPU_PATTERN_ROUNDED_CLIP,
|
||||
GSK_GPU_PATTERN_REPEAT_PUSH,
|
||||
GSK_GPU_PATTERN_POSITION_POP,
|
||||
GSK_GPU_PATTERN_PUSH_COLOR,
|
||||
GSK_GPU_PATTERN_POP_CROSS_FADE,
|
||||
} GskGpuPatternType;
|
||||
|
||||
|
@ -22,6 +22,8 @@
|
||||
#define GSK_GPU_PATTERN_ROUNDED_CLIP 12u
|
||||
#define GSK_GPU_PATTERN_REPEAT_PUSH 13u
|
||||
#define GSK_GPU_PATTERN_POSITION_POP 14u
|
||||
#define GSK_GPU_PATTERN_PUSH_COLOR 15u
|
||||
#define GSK_GPU_PATTERN_POP_CROSS_FADE 16u
|
||||
|
||||
#define TOP 0u
|
||||
#define RIGHT 1u
|
||||
|
@ -140,6 +140,16 @@ position_pop_pattern (inout uint reader,
|
||||
pos = stack_pop ().xy;
|
||||
}
|
||||
|
||||
void
|
||||
cross_fade_pattern (inout uint reader,
|
||||
inout vec4 color)
|
||||
{
|
||||
vec4 start = stack_pop ();
|
||||
float progress = read_float (reader);
|
||||
|
||||
color = mix (start, color, progress);
|
||||
}
|
||||
|
||||
vec4
|
||||
glyphs_pattern (inout uint reader,
|
||||
vec2 pos)
|
||||
@ -294,6 +304,13 @@ pattern (uint reader,
|
||||
case GSK_GPU_PATTERN_POSITION_POP:
|
||||
position_pop_pattern (reader, pos);
|
||||
break;
|
||||
case GSK_GPU_PATTERN_PUSH_COLOR:
|
||||
stack_push (color);
|
||||
color = vec4 (0.0);
|
||||
break;
|
||||
case GSK_GPU_PATTERN_POP_CROSS_FADE:
|
||||
cross_fade_pattern (reader, color);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user