ngl: Set color as vertex attribute

Instead of using uniforms for color used in multiple
programs, pass it as vertex attributes. This will let
us batch more draw calls, since we don't have to change
uniforms so often. In particular, for syntax-highlighted
text.
This commit is contained in:
Matthias Clasen 2021-03-11 19:46:15 -05:00
parent 3252f1e301
commit 06d5c8e72d
20 changed files with 185 additions and 239 deletions

View File

@ -1096,6 +1096,12 @@ gsk_ngl_command_queue_execute (GskNglCommandQueue *self,
sizeof (GskNglDrawVertex), sizeof (GskNglDrawVertex),
(void *) G_STRUCT_OFFSET (GskNglDrawVertex, uv)); (void *) G_STRUCT_OFFSET (GskNglDrawVertex, uv));
/* 2 = color location */
glEnableVertexAttribArray (2);
glVertexAttribPointer (2, 4, GL_FLOAT, GL_FALSE,
sizeof (GskNglDrawVertex),
(void *) G_STRUCT_OFFSET (GskNglDrawVertex, color));
/* Setup initial scissor clip */ /* Setup initial scissor clip */
if (scissor != NULL) if (scissor != NULL)
{ {

View File

@ -347,6 +347,7 @@ gsk_ngl_driver_load_programs (GskNglDriver *self,
/* Setup attributes that are provided via VBO */ /* Setup attributes that are provided via VBO */
gsk_ngl_compiler_bind_attribute (compiler, "aPosition", 0); gsk_ngl_compiler_bind_attribute (compiler, "aPosition", 0);
gsk_ngl_compiler_bind_attribute (compiler, "aUv", 1); gsk_ngl_compiler_bind_attribute (compiler, "aUv", 1);
gsk_ngl_compiler_bind_attribute (compiler, "aColor", 2);
/* Use XMacros to register all of our programs and their uniforms */ /* Use XMacros to register all of our programs and their uniforms */
#define GSK_NGL_NO_UNIFORMS #define GSK_NGL_NO_UNIFORMS
@ -376,7 +377,6 @@ gsk_ngl_driver_load_programs (GskNglDriver *self,
uniforms \ uniforms \
\ \
gsk_ngl_program_uniforms_added (program, have_source); \ gsk_ngl_program_uniforms_added (program, have_source); \
\
if (have_alpha) \ if (have_alpha) \
gsk_ngl_program_set_uniform1f (program, UNIFORM_SHARED_ALPHA, 0, 1.0f); \ gsk_ngl_program_set_uniform1f (program, UNIFORM_SHARED_ALPHA, 0, 1.0f); \
\ \
@ -1045,6 +1045,7 @@ gsk_ngl_driver_lookup_shader (GskNglDriver *self,
/* Setup attributes that are provided via VBO */ /* Setup attributes that are provided via VBO */
gsk_ngl_compiler_bind_attribute (compiler, "aPosition", 0); gsk_ngl_compiler_bind_attribute (compiler, "aPosition", 0);
gsk_ngl_compiler_bind_attribute (compiler, "aUv", 1); gsk_ngl_compiler_bind_attribute (compiler, "aUv", 1);
gsk_ngl_compiler_bind_attribute (compiler, "aColor", 2);
if ((program = gsk_ngl_compiler_compile (compiler, NULL, "", error))) if ((program = gsk_ngl_compiler_compile (compiler, NULL, "", error)))
{ {

View File

@ -58,13 +58,17 @@ typedef struct {
graphene_rect_t parent_rect; /* Valid when pointer_is_child */ graphene_rect_t parent_rect; /* Valid when pointer_is_child */
} GskTextureKey; } GskTextureKey;
#define GSL_GK_NO_UNIFORMS UNIFORM_INVALID_##__COUNTER__ #define GSK_NGL_NO_UNIFORMS CONCAT_EXPANDED(UNIFORM_INVALID_,__COUNTER__)
#define CONCAT_EXPANDED(a,b) CONCAT_EXPANDED2(a,b)
#define CONCAT_EXPANDED2(a,b) a##b
#define GSK_NGL_ADD_UNIFORM(pos, KEY, name) UNIFORM_##KEY = UNIFORM_SHARED_LAST + pos, #define GSK_NGL_ADD_UNIFORM(pos, KEY, name) UNIFORM_##KEY = UNIFORM_SHARED_LAST + pos,
#define GSK_NGL_DEFINE_PROGRAM(name, resource, uniforms) enum { uniforms }; #define GSK_NGL_DEFINE_PROGRAM(name, resource, uniforms) enum { uniforms };
# include "gsknglprograms.defs" # include "gsknglprograms.defs"
#undef GSK_NGL_DEFINE_PROGRAM #undef GSK_NGL_DEFINE_PROGRAM
#undef GSK_NGL_ADD_UNIFORM #undef GSK_NGL_ADD_UNIFORM
#undef GSL_GK_NO_UNIFORMS #undef GSK_NGL_NO_UNIFORMS
#undef CONCAT_EXPANDED
#undef CONCAT_EXPANDED2
#define GSK_TYPE_NGL_DRIVER (gsk_ngl_driver_get_type()) #define GSK_TYPE_NGL_DRIVER (gsk_ngl_driver_get_type())

View File

@ -15,17 +15,16 @@ GSK_NGL_DEFINE_PROGRAM (blur,
GSK_NGL_DEFINE_PROGRAM (border, GSK_NGL_DEFINE_PROGRAM (border,
"/org/gtk/libgsk/ngl/border.glsl", "/org/gtk/libgsk/ngl/border.glsl",
GSK_NGL_ADD_UNIFORM (1, BORDER_COLOR, u_color)
GSK_NGL_ADD_UNIFORM (2, BORDER_WIDTHS, u_widths) GSK_NGL_ADD_UNIFORM (2, BORDER_WIDTHS, u_widths)
GSK_NGL_ADD_UNIFORM (3, BORDER_OUTLINE_RECT, u_outline_rect)) GSK_NGL_ADD_UNIFORM (3, BORDER_OUTLINE_RECT, u_outline_rect))
GSK_NGL_DEFINE_PROGRAM (color, GSK_NGL_DEFINE_PROGRAM (color,
"/org/gtk/libgsk/ngl/color.glsl", "/org/gtk/libgsk/ngl/color.glsl",
GSK_NGL_ADD_UNIFORM (1, COLOR_COLOR, u_color)) GSK_NGL_NO_UNIFORMS)
GSK_NGL_DEFINE_PROGRAM (coloring, GSK_NGL_DEFINE_PROGRAM (coloring,
"/org/gtk/libgsk/ngl/coloring.glsl", "/org/gtk/libgsk/ngl/coloring.glsl",
GSK_NGL_ADD_UNIFORM (1, COLORING_COLOR, u_color)) GSK_NGL_NO_UNIFORMS)
GSK_NGL_DEFINE_PROGRAM (color_matrix, GSK_NGL_DEFINE_PROGRAM (color_matrix,
"/org/gtk/libgsk/ngl/color_matrix.glsl", "/org/gtk/libgsk/ngl/color_matrix.glsl",
@ -45,7 +44,6 @@ GSK_NGL_DEFINE_PROGRAM (cross_fade,
GSK_NGL_DEFINE_PROGRAM (inset_shadow, GSK_NGL_DEFINE_PROGRAM (inset_shadow,
"/org/gtk/libgsk/ngl/inset_shadow.glsl", "/org/gtk/libgsk/ngl/inset_shadow.glsl",
GSK_NGL_ADD_UNIFORM (1, INSET_SHADOW_COLOR, u_color)
GSK_NGL_ADD_UNIFORM (2, INSET_SHADOW_SPREAD, u_spread) GSK_NGL_ADD_UNIFORM (2, INSET_SHADOW_SPREAD, u_spread)
GSK_NGL_ADD_UNIFORM (3, INSET_SHADOW_OFFSET, u_offset) GSK_NGL_ADD_UNIFORM (3, INSET_SHADOW_OFFSET, u_offset)
GSK_NGL_ADD_UNIFORM (4, INSET_SHADOW_OUTLINE_RECT, u_outline_rect)) GSK_NGL_ADD_UNIFORM (4, INSET_SHADOW_OUTLINE_RECT, u_outline_rect))
@ -59,7 +57,6 @@ GSK_NGL_DEFINE_PROGRAM (linear_gradient,
GSK_NGL_DEFINE_PROGRAM (outset_shadow, GSK_NGL_DEFINE_PROGRAM (outset_shadow,
"/org/gtk/libgsk/ngl/outset_shadow.glsl", "/org/gtk/libgsk/ngl/outset_shadow.glsl",
GSK_NGL_ADD_UNIFORM (1, OUTSET_SHADOW_COLOR, u_color)
GSK_NGL_ADD_UNIFORM (2, OUTSET_SHADOW_OUTLINE_RECT, u_outline_rect)) GSK_NGL_ADD_UNIFORM (2, OUTSET_SHADOW_OUTLINE_RECT, u_outline_rect))
GSK_NGL_DEFINE_PROGRAM (radial_gradient, GSK_NGL_DEFINE_PROGRAM (radial_gradient,
@ -77,7 +74,6 @@ GSK_NGL_DEFINE_PROGRAM (repeat,
GSK_NGL_DEFINE_PROGRAM (unblurred_outset_shadow, GSK_NGL_DEFINE_PROGRAM (unblurred_outset_shadow,
"/org/gtk/libgsk/ngl/unblurred_outset_shadow.glsl", "/org/gtk/libgsk/ngl/unblurred_outset_shadow.glsl",
GSK_NGL_ADD_UNIFORM (1, UNBLURRED_OUTSET_SHADOW_COLOR, u_color)
GSK_NGL_ADD_UNIFORM (2, UNBLURRED_OUTSET_SHADOW_SPREAD, u_spread) GSK_NGL_ADD_UNIFORM (2, UNBLURRED_OUTSET_SHADOW_SPREAD, u_spread)
GSK_NGL_ADD_UNIFORM (3, UNBLURRED_OUTSET_SHADOW_OFFSET, u_offset) GSK_NGL_ADD_UNIFORM (3, UNBLURRED_OUTSET_SHADOW_OFFSET, u_offset)
GSK_NGL_ADD_UNIFORM (4, UNBLURRED_OUTSET_SHADOW_OUTLINE_RECT, u_outline_rect)) GSK_NGL_ADD_UNIFORM (4, UNBLURRED_OUTSET_SHADOW_OUTLINE_RECT, u_outline_rect))

View File

@ -142,6 +142,9 @@ struct _GskNglRenderJob
/* Our current alpha state as we process nodes */ /* Our current alpha state as we process nodes */
float alpha; float alpha;
/* Our current color state as we process nodes */
GdkRGBA color;
/* Offset (delta x,y) as we process nodes. Occasionally this is merged into /* Offset (delta x,y) as we process nodes. Occasionally this is merged into
* a transform that is referenced from child transform nodes. * a transform that is referenced from child transform nodes.
*/ */
@ -395,6 +398,13 @@ gsk_ngl_render_job_set_alpha (GskNglRenderJob *job,
return alpha; return alpha;
} }
static inline void
gsk_ngl_render_job_set_color (GskNglRenderJob *job,
const GdkRGBA *color)
{
job->color = *color;
}
static void static void
extract_matrix_metadata (GskNglRenderModelview *modelview) extract_matrix_metadata (GskNglRenderModelview *modelview)
{ {
@ -874,13 +884,81 @@ gsk_ngl_render_job_update_clip (GskNglRenderJob *job,
return TRUE; return TRUE;
} }
/* fill_vertex_data */
static void
gsk_ngl_render_job_draw_coords (GskNglRenderJob *job,
float min_x,
float min_y,
float max_x,
float max_y,
float min_u,
float min_v,
float max_u,
float max_v)
{
GskNglDrawVertex *vertices = gsk_ngl_command_queue_add_vertices (job->command_queue);
vertices[0].position[0] = min_x;
vertices[0].position[1] = min_y;
vertices[0].uv[0] = min_u;
vertices[0].uv[1] = min_v;
vertices[0].color[0] = job->color.red;
vertices[0].color[1] = job->color.green;
vertices[0].color[2] = job->color.blue;
vertices[0].color[3] = job->color.alpha;
vertices[1].position[0] = min_x;
vertices[1].position[1] = max_y;
vertices[1].uv[0] = min_u;
vertices[1].uv[1] = max_v;
vertices[1].color[0] = job->color.red;
vertices[1].color[1] = job->color.green;
vertices[1].color[2] = job->color.blue;
vertices[1].color[3] = job->color.alpha;
vertices[2].position[0] = max_x;
vertices[2].position[1] = min_y;
vertices[2].uv[0] = max_u;
vertices[2].uv[1] = min_v;
vertices[2].color[0] = job->color.red;
vertices[2].color[1] = job->color.green;
vertices[2].color[2] = job->color.blue;
vertices[2].color[3] = job->color.alpha;
vertices[3].position[0] = max_x;
vertices[3].position[1] = max_y;
vertices[3].uv[0] = max_u;
vertices[3].uv[1] = max_v;
vertices[3].color[0] = job->color.red;
vertices[3].color[1] = job->color.green;
vertices[3].color[2] = job->color.blue;
vertices[3].color[3] = job->color.alpha;
vertices[4].position[0] = min_x;
vertices[4].position[1] = max_y;
vertices[4].uv[0] = min_u;
vertices[4].uv[1] = max_v;
vertices[4].color[0] = job->color.red;
vertices[4].color[1] = job->color.green;
vertices[4].color[2] = job->color.blue;
vertices[4].color[3] = job->color.alpha;
vertices[5].position[0] = max_x;
vertices[5].position[1] = min_y;
vertices[5].uv[0] = max_u;
vertices[5].uv[1] = min_v;
vertices[5].color[0] = job->color.red;
vertices[5].color[1] = job->color.green;
vertices[5].color[2] = job->color.blue;
vertices[5].color[3] = job->color.alpha;
}
/* load_vertex_data_with_region */ /* load_vertex_data_with_region */
static inline void static inline void
gsk_ngl_render_job_load_vertices_from_offscreen (GskNglRenderJob *job, gsk_ngl_render_job_load_vertices_from_offscreen (GskNglRenderJob *job,
const graphene_rect_t *bounds, const graphene_rect_t *bounds,
const GskNglRenderOffscreen *offscreen) const GskNglRenderOffscreen *offscreen)
{ {
GskNglDrawVertex *vertices = gsk_ngl_command_queue_add_vertices (job->command_queue);
float min_x = job->offset_x + bounds->origin.x; float min_x = job->offset_x + bounds->origin.x;
float min_y = job->offset_y + bounds->origin.y; float min_y = job->offset_y + bounds->origin.y;
float max_x = min_x + bounds->size.width; float max_x = min_x + bounds->size.width;
@ -888,35 +966,9 @@ gsk_ngl_render_job_load_vertices_from_offscreen (GskNglRenderJob *jo
float y1 = offscreen->was_offscreen ? offscreen->area.y2 : offscreen->area.y; float y1 = offscreen->was_offscreen ? offscreen->area.y2 : offscreen->area.y;
float y2 = offscreen->was_offscreen ? offscreen->area.y : offscreen->area.y2; float y2 = offscreen->was_offscreen ? offscreen->area.y : offscreen->area.y2;
vertices[0].position[0] = min_x; gsk_ngl_render_job_draw_coords (job,
vertices[0].position[1] = min_y; min_x, min_y, max_x, max_y,
vertices[0].uv[0] = offscreen->area.x; offscreen->area.x, y1, offscreen->area.x2, y2);
vertices[0].uv[1] = y1;
vertices[1].position[0] = min_x;
vertices[1].position[1] = max_y;
vertices[1].uv[0] = offscreen->area.x;
vertices[1].uv[1] = y2;
vertices[2].position[0] = max_x;
vertices[2].position[1] = min_y;
vertices[2].uv[0] = offscreen->area.x2;
vertices[2].uv[1] = y1;
vertices[3].position[0] = max_x;
vertices[3].position[1] = max_y;
vertices[3].uv[0] = offscreen->area.x2;
vertices[3].uv[1] = y2;
vertices[4].position[0] = min_x;
vertices[4].position[1] = max_y;
vertices[4].uv[0] = offscreen->area.x;
vertices[4].uv[1] = y2;
vertices[5].position[0] = max_x;
vertices[5].position[1] = min_y;
vertices[5].uv[0] = offscreen->area.x2;
vertices[5].uv[1] = y1;
} }
/* load_float_vertex_data */ /* load_float_vertex_data */
@ -927,41 +979,12 @@ gsk_ngl_render_job_draw (GskNglRenderJob *job,
float width, float width,
float height) float height)
{ {
GskNglDrawVertex *vertices = gsk_ngl_command_queue_add_vertices (job->command_queue);
float min_x = job->offset_x + x; float min_x = job->offset_x + x;
float min_y = job->offset_y + y; float min_y = job->offset_y + y;
float max_x = min_x + width; float max_x = min_x + width;
float max_y = min_y + height; float max_y = min_y + height;
vertices[0].position[0] = min_x; gsk_ngl_render_job_draw_coords (job, min_x, min_y, max_x, max_y, 0, 0, 1, 1);
vertices[0].position[1] = min_y;
vertices[0].uv[0] = 0;
vertices[0].uv[1] = 0;
vertices[1].position[0] = min_x;
vertices[1].position[1] = max_y;
vertices[1].uv[0] = 0;
vertices[1].uv[1] = 1;
vertices[2].position[0] = max_x;
vertices[2].position[1] = min_y;
vertices[2].uv[0] = 1;
vertices[2].uv[1] = 0;
vertices[3].position[0] = max_x;
vertices[3].position[1] = max_y;
vertices[3].uv[0] = 1;
vertices[3].uv[1] = 1;
vertices[4].position[0] = min_x;
vertices[4].position[1] = max_y;
vertices[4].uv[0] = 0;
vertices[4].uv[1] = 1;
vertices[5].position[0] = max_x;
vertices[5].position[1] = min_y;
vertices[5].uv[0] = 1;
vertices[5].uv[1] = 0;
} }
/* load_vertex_data */ /* load_vertex_data */
@ -976,47 +999,6 @@ gsk_ngl_render_job_draw_rect (GskNglRenderJob *job,
bounds->size.height); bounds->size.height);
} }
/* fill_vertex_data */
static void
gsk_ngl_render_job_draw_coords (GskNglRenderJob *job,
float min_x,
float min_y,
float max_x,
float max_y)
{
GskNglDrawVertex *vertices = gsk_ngl_command_queue_add_vertices (job->command_queue);
vertices[0].position[0] = min_x;
vertices[0].position[1] = min_y;
vertices[0].uv[0] = 0;
vertices[0].uv[1] = 1;
vertices[1].position[0] = min_x;
vertices[1].position[1] = max_y;
vertices[1].uv[0] = 0;
vertices[1].uv[1] = 0;
vertices[2].position[0] = max_x;
vertices[2].position[1] = min_y;
vertices[2].uv[0] = 1;
vertices[2].uv[1] = 1;
vertices[3].position[0] = max_x;
vertices[3].position[1] = max_y;
vertices[3].uv[0] = 1;
vertices[3].uv[1] = 0;
vertices[4].position[0] = min_x;
vertices[4].position[1] = max_y;
vertices[4].uv[0] = 0;
vertices[4].uv[1] = 0;
vertices[5].position[0] = max_x;
vertices[5].position[1] = min_y;
vertices[5].uv[0] = 1;
vertices[5].uv[1] = 1;
}
/* load_offscreen_vertex_data */ /* load_offscreen_vertex_data */
static inline void static inline void
gsk_ngl_render_job_draw_offscreen_rect (GskNglRenderJob *job, gsk_ngl_render_job_draw_offscreen_rect (GskNglRenderJob *job,
@ -1027,7 +1009,7 @@ gsk_ngl_render_job_draw_offscreen_rect (GskNglRenderJob *job,
float max_x = min_x + bounds->size.width; float max_x = min_x + bounds->size.width;
float max_y = min_y + bounds->size.height; float max_y = min_y + bounds->size.height;
gsk_ngl_render_job_draw_coords (job, min_x, min_y, max_x, max_y); gsk_ngl_render_job_draw_coords (job, min_x, min_y, max_x, max_y, 0, 1, 1, 0);
} }
static inline void static inline void
@ -1283,7 +1265,7 @@ blur_offscreen (GskNglRenderJob *job,
gsk_ngl_program_set_uniform2f (job->current_program, gsk_ngl_program_set_uniform2f (job->current_program,
UNIFORM_BLUR_DIR, 0, UNIFORM_BLUR_DIR, 0,
1, 0); 1, 0);
gsk_ngl_render_job_draw_coords (job, 0, 0, texture_to_blur_width, texture_to_blur_height); gsk_ngl_render_job_draw_coords (job, 0, 0, texture_to_blur_width, texture_to_blur_height, 0, 1, 1, 0);
gsk_ngl_render_job_end_draw (job); gsk_ngl_render_job_end_draw (job);
/* Bind second pass framebuffer and clear it */ /* Bind second pass framebuffer and clear it */
@ -1307,7 +1289,7 @@ blur_offscreen (GskNglRenderJob *job,
gsk_ngl_program_set_uniform2f (job->current_program, gsk_ngl_program_set_uniform2f (job->current_program,
UNIFORM_BLUR_DIR, 0, UNIFORM_BLUR_DIR, 0,
0, 1); 0, 1);
gsk_ngl_render_job_draw_coords (job, 0, 0, texture_to_blur_width, texture_to_blur_height); gsk_ngl_render_job_draw_coords (job, 0, 0, texture_to_blur_width, texture_to_blur_height, 0, 1, 1, 0);
gsk_ngl_render_job_end_draw (job); gsk_ngl_render_job_end_draw (job);
gsk_ngl_render_job_pop_modelview (job); gsk_ngl_render_job_pop_modelview (job);
@ -1381,9 +1363,7 @@ gsk_ngl_render_job_visit_color_node (GskNglRenderJob *job,
const GskRenderNode *node) const GskRenderNode *node)
{ {
gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, color)); gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, color));
gsk_ngl_program_set_uniform_color (job->current_program, gsk_ngl_render_job_set_color (job, gsk_color_node_get_color (node));
UNIFORM_COLOR_COLOR, 0,
gsk_color_node_get_color (node));
gsk_ngl_render_job_draw_rect (job, &node->bounds); gsk_ngl_render_job_draw_rect (job, &node->bounds);
gsk_ngl_render_job_end_draw (job); gsk_ngl_render_job_end_draw (job);
} }
@ -1694,9 +1674,7 @@ gsk_ngl_render_job_visit_rect_border_node (GskNglRenderJob *job,
gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, color)); gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, color));
gsk_ngl_program_set_uniform_color (job->current_program, gsk_ngl_render_job_set_color (job, &colors[0]);
UNIFORM_COLOR_COLOR, 0,
&colors[0]);
gsk_ngl_render_job_draw_rect (job, gsk_ngl_render_job_draw_rect (job,
&GRAPHENE_RECT_INIT (origin->x, &GRAPHENE_RECT_INIT (origin->x,
@ -1737,12 +1715,10 @@ gsk_ngl_render_job_visit_uniform_border_node (GskNglRenderJob *job,
gsk_ngl_render_job_transform_rounded_rect (job, rounded_outline, &outline); gsk_ngl_render_job_transform_rounded_rect (job, rounded_outline, &outline);
gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, inset_shadow)); gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, inset_shadow));
gsk_ngl_render_job_set_color (job, &colors[0]);
gsk_ngl_program_set_uniform_rounded_rect (job->current_program, gsk_ngl_program_set_uniform_rounded_rect (job->current_program,
UNIFORM_INSET_SHADOW_OUTLINE_RECT, 0, UNIFORM_INSET_SHADOW_OUTLINE_RECT, 0,
&outline); &outline);
gsk_ngl_program_set_uniform_color (job->current_program,
UNIFORM_INSET_SHADOW_COLOR, 0,
&colors[0]);
gsk_ngl_program_set_uniform1f (job->current_program, gsk_ngl_program_set_uniform1f (job->current_program,
UNIFORM_INSET_SHADOW_SPREAD, 0, UNIFORM_INSET_SHADOW_SPREAD, 0,
widths[0]); widths[0]);
@ -1758,7 +1734,7 @@ gsk_ngl_render_job_visit_border_node (GskNglRenderJob *job,
const GskRenderNode *node) const GskRenderNode *node)
{ {
const GskRoundedRect *rounded_outline = gsk_border_node_get_outline (node); const GskRoundedRect *rounded_outline = gsk_border_node_get_outline (node);
const GdkRGBA *colors = gsk_border_node_get_colors (node); const GdkRGBA *c = gsk_border_node_get_colors (node);
const float *widths = gsk_border_node_get_widths (node); const float *widths = gsk_border_node_get_widths (node);
struct { struct {
float w; float w;
@ -1818,52 +1794,48 @@ gsk_ngl_render_job_visit_border_node (GskNglRenderJob *job,
const GskNglDrawVertex side_data[4][6] = { const GskNglDrawVertex side_data[4][6] = {
/* Top */ /* Top */
{ {
{ { min_x, min_y }, { 0, 1 }, }, /* Upper left */ { { min_x, min_y }, { 0, 1 }, { c[0].red, c[0].green, c[0].blue, c[0].alpha } }, /* Upper left */
{ { min_x + sizes[0].w, min_y + sizes[0].h }, { 0, 0 }, }, /* Lower left */ { { min_x + sizes[0].w, min_y + sizes[0].h }, { 0, 0 }, { c[0].red, c[0].green, c[0].blue, c[0].alpha } }, /* Lower left */
{ { max_x, min_y }, { 1, 1 }, }, /* Upper right */ { { max_x, min_y }, { 1, 1 }, { c[0].red, c[0].green, c[0].blue, c[0].alpha } }, /* Upper right */
{ { max_x - sizes[1].w, min_y + sizes[1].h }, { 1, 0 }, }, /* Lower right */ { { max_x - sizes[1].w, min_y + sizes[1].h }, { 1, 0 }, { c[0].red, c[0].green, c[0].blue, c[0].alpha } }, /* Lower right */
{ { min_x + sizes[0].w, min_y + sizes[0].h }, { 0, 0 }, }, /* Lower left */ { { min_x + sizes[0].w, min_y + sizes[0].h }, { 0, 0 }, { c[0].red, c[0].green, c[0].blue, c[0].alpha } }, /* Lower left */
{ { max_x, min_y }, { 1, 1 }, }, /* Upper right */ { { max_x, min_y }, { 1, 1 }, { c[0].red, c[0].green, c[0].blue, c[0].alpha } }, /* Upper right */
}, },
/* Right */ /* Right */
{ {
{ { max_x - sizes[1].w, min_y + sizes[1].h }, { 0, 1 }, }, /* Upper left */ { { max_x - sizes[1].w, min_y + sizes[1].h }, { 0, 1 }, { c[1].red, c[1].green, c[1].blue, c[1].alpha } }, /* Upper left */
{ { max_x - sizes[2].w, max_y - sizes[2].h }, { 0, 0 }, }, /* Lower left */ { { max_x - sizes[2].w, max_y - sizes[2].h }, { 0, 0 }, { c[1].red, c[1].green, c[1].blue, c[1].alpha } }, /* Lower left */
{ { max_x, min_y }, { 1, 1 }, }, /* Upper right */ { { max_x, min_y }, { 1, 1 }, { c[1].red, c[1].green, c[1].blue, c[1].alpha } }, /* Upper right */
{ { max_x, max_y }, { 1, 0 }, }, /* Lower right */ { { max_x, max_y }, { 1, 0 }, { c[1].red, c[1].green, c[1].blue, c[1].alpha } }, /* Lower right */
{ { max_x - sizes[2].w, max_y - sizes[2].h }, { 0, 0 }, }, /* Lower left */ { { max_x - sizes[2].w, max_y - sizes[2].h }, { 0, 0 }, { c[1].red, c[1].green, c[1].blue, c[1].alpha } }, /* Lower left */
{ { max_x, min_y }, { 1, 1 }, }, /* Upper right */ { { max_x, min_y }, { 1, 1 }, { c[1].red, c[1].green, c[1].blue, c[1].alpha } }, /* Upper right */
}, },
/* Bottom */ /* Bottom */
{ {
{ { min_x + sizes[3].w, max_y - sizes[3].h }, { 0, 1 }, }, /* Upper left */ { { min_x + sizes[3].w, max_y - sizes[3].h }, { 0, 1 }, { c[2].red, c[2].green, c[2].blue, c[2].alpha } }, /* Upper left */
{ { min_x, max_y }, { 0, 0 }, }, /* Lower left */ { { min_x, max_y }, { 0, 0 }, { c[2].red, c[2].green, c[2].blue, c[2].alpha } }, /* Lower left */
{ { max_x - sizes[2].w, max_y - sizes[2].h }, { 1, 1 }, }, /* Upper right */ { { max_x - sizes[2].w, max_y - sizes[2].h }, { 1, 1 }, { c[2].red, c[2].green, c[2].blue, c[2].alpha } }, /* Upper right */
{ { max_x, max_y }, { 1, 0 }, }, /* Lower right */ { { max_x, max_y }, { 1, 0 }, { c[2].red, c[2].green, c[2].blue, c[2].alpha } }, /* Lower right */
{ { min_x , max_y }, { 0, 0 }, }, /* Lower left */ { { min_x , max_y }, { 0, 0 }, { c[2].red, c[2].green, c[2].blue, c[2].alpha } }, /* Lower left */
{ { max_x - sizes[2].w, max_y - sizes[2].h }, { 1, 1 }, }, /* Upper right */ { { max_x - sizes[2].w, max_y - sizes[2].h }, { 1, 1 }, { c[2].red, c[2].green, c[2].blue, c[2].alpha } }, /* Upper right */
}, },
/* Left */ /* Left */
{ {
{ { min_x, min_y }, { 0, 1 }, }, /* Upper left */ { { min_x, min_y }, { 0, 1 }, { c[3].red, c[3].green, c[3].blue, c[3].alpha } }, /* Upper left */
{ { min_x, max_y }, { 0, 0 }, }, /* Lower left */ { { min_x, max_y }, { 0, 0 }, { c[3].red, c[3].green, c[3].blue, c[3].alpha } }, /* Lower left */
{ { min_x + sizes[0].w, min_y + sizes[0].h }, { 1, 1 }, }, /* Upper right */ { { min_x + sizes[0].w, min_y + sizes[0].h }, { 1, 1 }, { c[3].red, c[3].green, c[3].blue, c[3].alpha } }, /* Upper right */
{ { min_x + sizes[3].w, max_y - sizes[3].h }, { 1, 0 }, }, /* Lower right */ { { min_x + sizes[3].w, max_y - sizes[3].h }, { 1, 0 }, { c[3].red, c[3].green, c[3].blue, c[3].alpha } }, /* Lower right */
{ { min_x, max_y }, { 0, 0 }, }, /* Lower left */ { { min_x, max_y }, { 0, 0 }, { c[3].red, c[3].green, c[3].blue, c[3].alpha } }, /* Lower left */
{ { min_x + sizes[0].w, min_y + sizes[0].h }, { 1, 1 }, }, /* Upper right */ { { min_x + sizes[0].w, min_y + sizes[0].h }, { 1, 1 }, { c[3].red, c[3].green, c[3].blue, c[3].alpha } }, /* Upper right */
} }
}; };
int indices[4] = { 0, 1, 2, 3 };
GskRoundedRect outline; GskRoundedRect outline;
GskNglProgram *program; GskNglProgram *program;
/* We sort them by color */
sort_border_sides (colors, indices);
/* Prepare outline */ /* Prepare outline */
gsk_ngl_render_job_transform_rounded_rect (job, rounded_outline, &outline); gsk_ngl_render_job_transform_rounded_rect (job, rounded_outline, &outline);
@ -1881,16 +1853,12 @@ gsk_ngl_render_job_visit_border_node (GskNglRenderJob *job,
{ {
GskNglDrawVertex *vertices; GskNglDrawVertex *vertices;
if (widths[indices[i]] <= 0) if (widths[i] <= 0)
continue; continue;
gsk_ngl_render_job_begin_draw (job, program); gsk_ngl_render_job_begin_draw (job, program);
gsk_ngl_program_set_uniform4fv (job->current_program,
UNIFORM_BORDER_COLOR, 0,
1,
(const float *)&colors[indices[i]]);
vertices = gsk_ngl_command_queue_add_vertices (job->command_queue); vertices = gsk_ngl_command_queue_add_vertices (job->command_queue);
memcpy (vertices, side_data[indices[i]], sizeof (GskNglDrawVertex) * GSK_NGL_N_VERTICES); memcpy (vertices, side_data[i], sizeof (GskNglDrawVertex) * GSK_NGL_N_VERTICES);
gsk_ngl_render_job_end_draw (job); gsk_ngl_render_job_end_draw (job);
} }
} }
@ -2019,12 +1987,10 @@ gsk_ngl_render_job_visit_unblurred_inset_shadow_node (GskNglRenderJob *job,
gsk_ngl_render_job_transform_rounded_rect (job, outline, &transformed_outline); gsk_ngl_render_job_transform_rounded_rect (job, outline, &transformed_outline);
gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, inset_shadow)); gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, inset_shadow));
gsk_ngl_render_job_set_color (job, gsk_inset_shadow_node_get_color (node));
gsk_ngl_program_set_uniform_rounded_rect (job->current_program, gsk_ngl_program_set_uniform_rounded_rect (job->current_program,
UNIFORM_INSET_SHADOW_OUTLINE_RECT, 0, UNIFORM_INSET_SHADOW_OUTLINE_RECT, 0,
&transformed_outline); &transformed_outline);
gsk_ngl_program_set_uniform_color (job->current_program,
UNIFORM_INSET_SHADOW_COLOR, 0,
gsk_inset_shadow_node_get_color (node));
gsk_ngl_program_set_uniform1f (job->current_program, gsk_ngl_program_set_uniform1f (job->current_program,
UNIFORM_INSET_SHADOW_SPREAD, 0, UNIFORM_INSET_SHADOW_SPREAD, 0,
gsk_inset_shadow_node_get_spread (node)); gsk_inset_shadow_node_get_spread (node));
@ -2122,12 +2088,10 @@ gsk_ngl_render_job_visit_blurred_inset_shadow_node (GskNglRenderJob *job,
/* Actual inset shadow outline drawing */ /* Actual inset shadow outline drawing */
gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, inset_shadow)); gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, inset_shadow));
gsk_ngl_render_job_set_color (job, gsk_inset_shadow_node_get_color (node));
gsk_ngl_program_set_uniform_rounded_rect (job->current_program, gsk_ngl_program_set_uniform_rounded_rect (job->current_program,
UNIFORM_INSET_SHADOW_OUTLINE_RECT, 0, UNIFORM_INSET_SHADOW_OUTLINE_RECT, 0,
&transformed_outline); &transformed_outline);
gsk_ngl_program_set_uniform_color (job->current_program,
UNIFORM_INSET_SHADOW_COLOR, 0,
gsk_inset_shadow_node_get_color (node));
gsk_ngl_program_set_uniform1f (job->current_program, gsk_ngl_program_set_uniform1f (job->current_program,
UNIFORM_INSET_SHADOW_SPREAD, 0, UNIFORM_INSET_SHADOW_SPREAD, 0,
spread * MAX (scale_x, scale_y)); spread * MAX (scale_x, scale_y));
@ -2231,12 +2195,10 @@ gsk_ngl_render_job_visit_unblurred_outset_shadow_node (GskNglRenderJob *job,
gsk_ngl_render_job_transform_rounded_rect (job, outline, &transformed_outline); gsk_ngl_render_job_transform_rounded_rect (job, outline, &transformed_outline);
gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, unblurred_outset_shadow)); gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, unblurred_outset_shadow));
gsk_ngl_render_job_set_color (job, gsk_outset_shadow_node_get_color (node));
gsk_ngl_program_set_uniform_rounded_rect (job->current_program, gsk_ngl_program_set_uniform_rounded_rect (job->current_program,
UNIFORM_UNBLURRED_OUTSET_SHADOW_OUTLINE_RECT, 0, UNIFORM_UNBLURRED_OUTSET_SHADOW_OUTLINE_RECT, 0,
&transformed_outline); &transformed_outline);
gsk_ngl_program_set_uniform_color (job->current_program,
UNIFORM_UNBLURRED_OUTSET_SHADOW_COLOR, 0,
gsk_outset_shadow_node_get_color (node));
gsk_ngl_program_set_uniform1f (job->current_program, gsk_ngl_program_set_uniform1f (job->current_program,
UNIFORM_UNBLURRED_OUTSET_SHADOW_SPREAD, 0, UNIFORM_UNBLURRED_OUTSET_SHADOW_SPREAD, 0,
spread); spread);
@ -2387,9 +2349,7 @@ gsk_ngl_render_job_visit_blurred_outset_shadow_node (GskNglRenderJob *job,
/* Draw the outline using color program */ /* Draw the outline using color program */
gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, color)); gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, color));
gsk_ngl_program_set_uniform_color (job->current_program, gsk_ngl_render_job_set_color (job, &white);
UNIFORM_COLOR_COLOR, 0,
&white);
gsk_ngl_render_job_draw (job, 0, 0, texture_width, texture_height); gsk_ngl_render_job_draw (job, 0, 0, texture_width, texture_height);
gsk_ngl_render_job_end_draw (job); gsk_ngl_render_job_end_draw (job);
@ -2433,9 +2393,7 @@ gsk_ngl_render_job_visit_blurred_outset_shadow_node (GskNglRenderJob *job,
init_full_texture_region (&offscreen); init_full_texture_region (&offscreen);
gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, outset_shadow)); gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, outset_shadow));
gsk_ngl_program_set_uniform_color (job->current_program, gsk_ngl_render_job_set_color (job, color);
UNIFORM_OUTSET_SHADOW_COLOR, 0,
color);
gsk_ngl_program_set_uniform_texture (job->current_program, gsk_ngl_program_set_uniform_texture (job->current_program,
UNIFORM_SHARED_SOURCE, 0, UNIFORM_SHARED_SOURCE, 0,
GL_TEXTURE_2D, GL_TEXTURE_2D,
@ -2456,9 +2414,7 @@ gsk_ngl_render_job_visit_blurred_outset_shadow_node (GskNglRenderJob *job,
} }
gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, outset_shadow)); gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, outset_shadow));
gsk_ngl_program_set_uniform_color (job->current_program, gsk_ngl_render_job_set_color (job, color);
UNIFORM_OUTSET_SHADOW_COLOR, 0,
color);
gsk_ngl_program_set_uniform_texture (job->current_program, gsk_ngl_program_set_uniform_texture (job->current_program,
UNIFORM_SHARED_SOURCE, 0, UNIFORM_SHARED_SOURCE, 0,
GL_TEXTURE_2D, GL_TEXTURE_2D,
@ -2753,14 +2709,9 @@ gsk_ngl_render_job_visit_text_node (GskNglRenderJob *job,
/* If the font has color glyphs, we don't need to recolor anything */ /* If the font has color glyphs, we don't need to recolor anything */
if (!force_color && gsk_text_node_has_color_glyphs (node)) if (!force_color && gsk_text_node_has_color_glyphs (node))
{
program = CHOOSE_PROGRAM (job, blit); program = CHOOSE_PROGRAM (job, blit);
}
else else
{
program = CHOOSE_PROGRAM (job, coloring); program = CHOOSE_PROGRAM (job, coloring);
gsk_ngl_program_set_uniform_color (program, UNIFORM_COLORING_COLOR, 0, color);
}
lookup.font = (PangoFont *)font; lookup.font = (PangoFont *)font;
lookup.scale = (guint) (text_scale * 1024); lookup.scale = (guint) (text_scale * 1024);
@ -2835,31 +2786,55 @@ gsk_ngl_render_job_visit_text_node (GskNglRenderJob *job,
vertices[base+0].position[1] = glyph_y; vertices[base+0].position[1] = glyph_y;
vertices[base+0].uv[0] = tx; vertices[base+0].uv[0] = tx;
vertices[base+0].uv[1] = ty; vertices[base+0].uv[1] = ty;
vertices[base+0].color[0] = color->red;
vertices[base+0].color[1] = color->green;
vertices[base+0].color[2] = color->blue;
vertices[base+0].color[3] = color->alpha;
vertices[base+1].position[0] = glyph_x; vertices[base+1].position[0] = glyph_x;
vertices[base+1].position[1] = glyph_y2; vertices[base+1].position[1] = glyph_y2;
vertices[base+1].uv[0] = tx; vertices[base+1].uv[0] = tx;
vertices[base+1].uv[1] = ty2; vertices[base+1].uv[1] = ty2;
vertices[base+1].color[0] = color->red;
vertices[base+1].color[1] = color->green;
vertices[base+1].color[2] = color->blue;
vertices[base+1].color[3] = color->alpha;
vertices[base+2].position[0] = glyph_x2; vertices[base+2].position[0] = glyph_x2;
vertices[base+2].position[1] = glyph_y; vertices[base+2].position[1] = glyph_y;
vertices[base+2].uv[0] = tx2; vertices[base+2].uv[0] = tx2;
vertices[base+2].uv[1] = ty; vertices[base+2].uv[1] = ty;
vertices[base+2].color[0] = color->red;
vertices[base+2].color[1] = color->green;
vertices[base+2].color[2] = color->blue;
vertices[base+2].color[3] = color->alpha;
vertices[base+3].position[0] = glyph_x2; vertices[base+3].position[0] = glyph_x2;
vertices[base+3].position[1] = glyph_y2; vertices[base+3].position[1] = glyph_y2;
vertices[base+3].uv[0] = tx2; vertices[base+3].uv[0] = tx2;
vertices[base+3].uv[1] = ty2; vertices[base+3].uv[1] = ty2;
vertices[base+3].color[0] = color->red;
vertices[base+3].color[1] = color->green;
vertices[base+3].color[2] = color->blue;
vertices[base+3].color[3] = color->alpha;
vertices[base+4].position[0] = glyph_x; vertices[base+4].position[0] = glyph_x;
vertices[base+4].position[1] = glyph_y2; vertices[base+4].position[1] = glyph_y2;
vertices[base+4].uv[0] = tx; vertices[base+4].uv[0] = tx;
vertices[base+4].uv[1] = ty2; vertices[base+4].uv[1] = ty2;
vertices[base+4].color[0] = color->red;
vertices[base+4].color[1] = color->green;
vertices[base+4].color[2] = color->blue;
vertices[base+4].color[3] = color->alpha;
vertices[base+5].position[0] = glyph_x2; vertices[base+5].position[0] = glyph_x2;
vertices[base+5].position[1] = glyph_y; vertices[base+5].position[1] = glyph_y;
vertices[base+5].uv[0] = tx2; vertices[base+5].uv[0] = tx2;
vertices[base+5].uv[1] = ty; vertices[base+5].uv[1] = ty;
vertices[base+5].color[0] = color->red;
vertices[base+5].color[1] = color->green;
vertices[base+5].color[2] = color->blue;
vertices[base+5].color[3] = color->alpha;
batch->draw.vbo_count += GSK_NGL_N_VERTICES; batch->draw.vbo_count += GSK_NGL_N_VERTICES;
used++; used++;
@ -2952,14 +2927,12 @@ gsk_ngl_render_job_visit_shadow_node (GskNglRenderJob *job,
gsk_ngl_render_job_offset (job, dx, dy); gsk_ngl_render_job_offset (job, dx, dy);
gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, coloring)); gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, coloring));
gsk_ngl_render_job_set_color (job, &shadow->color);
gsk_ngl_program_set_uniform_texture (job->current_program, gsk_ngl_program_set_uniform_texture (job->current_program,
UNIFORM_SHARED_SOURCE, 0, UNIFORM_SHARED_SOURCE, 0,
GL_TEXTURE_2D, GL_TEXTURE_2D,
GL_TEXTURE0, GL_TEXTURE0,
offscreen.texture_id); offscreen.texture_id);
gsk_ngl_program_set_uniform_color (job->current_program,
UNIFORM_COLORING_COLOR, 0,
&shadow->color);
gsk_ngl_render_job_load_vertices_from_offscreen (job, &bounds, &offscreen); gsk_ngl_render_job_load_vertices_from_offscreen (job, &bounds, &offscreen);
gsk_ngl_render_job_end_draw (job); gsk_ngl_render_job_end_draw (job);
gsk_ngl_render_job_offset (job, -dx, -dy); gsk_ngl_render_job_offset (job, -dx, -dy);
@ -3014,7 +2987,7 @@ gsk_ngl_render_job_visit_blur_node (GskNglRenderJob *job,
GL_TEXTURE_2D, GL_TEXTURE_2D,
GL_TEXTURE0, GL_TEXTURE0,
offscreen.texture_id); offscreen.texture_id);
gsk_ngl_render_job_draw_coords (job, min_x, min_y, max_x, max_y); gsk_ngl_render_job_draw_coords (job, min_x, min_y, max_x, max_y, 0, 1, 1, 0);
gsk_ngl_render_job_end_draw (job); gsk_ngl_render_job_end_draw (job);
} }
@ -3123,9 +3096,7 @@ gsk_ngl_render_job_visit_gl_shader_node_fallback (GskNglRenderJob *job,
static const GdkRGBA pink = { 255 / 255., 105 / 255., 180 / 255., 1.0 }; static const GdkRGBA pink = { 255 / 255., 105 / 255., 180 / 255., 1.0 };
gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, color)); gsk_ngl_render_job_begin_draw (job, CHOOSE_PROGRAM (job, color));
gsk_ngl_program_set_uniform_color (job->current_program, gsk_ngl_render_job_set_color (job, &pink);
UNIFORM_COLOR_COLOR, 0,
&pink);
gsk_ngl_render_job_draw_rect (job, &node->bounds); gsk_ngl_render_job_draw_rect (job, &node->bounds);
gsk_ngl_render_job_end_draw (job); gsk_ngl_render_job_end_draw (job);
} }
@ -3317,7 +3288,6 @@ gsk_ngl_render_job_visit_texture_node (GskNglRenderJob *job,
for (guint i = 0; i < n_slices; i ++) for (guint i = 0; i < n_slices; i ++)
{ {
GskNglDrawVertex *vertices;
const GskNglTextureSlice *slice = &slices[i]; const GskNglTextureSlice *slice = &slices[i];
float x1, x2, y1, y2; float x1, x2, y1, y2;
@ -3333,37 +3303,8 @@ gsk_ngl_render_job_visit_texture_node (GskNglRenderJob *job,
GL_TEXTURE_2D, GL_TEXTURE_2D,
GL_TEXTURE0, GL_TEXTURE0,
slice->texture_id); slice->texture_id);
vertices = gsk_ngl_command_queue_add_vertices (job->command_queue);
vertices[0].position[0] = x1; gsk_ngl_render_job_draw_coords (job, x1, y1, x2, y2, 0, 0, 1, 1);
vertices[0].position[1] = y1;
vertices[0].uv[0] = 0;
vertices[0].uv[1] = 0;
vertices[1].position[0] = x1;
vertices[1].position[1] = y2;
vertices[1].uv[0] = 0;
vertices[1].uv[1] = 1;
vertices[2].position[0] = x2;
vertices[2].position[1] = y1;
vertices[2].uv[0] = 1;
vertices[2].uv[1] = 0;
vertices[3].position[0] = x2;
vertices[3].position[1] = y2;
vertices[3].uv[0] = 1;
vertices[3].uv[1] = 1;
vertices[4].position[0] = x1;
vertices[4].position[1] = y2;
vertices[4].uv[0] = 0;
vertices[4].uv[1] = 1;
vertices[5].position[0] = x2;
vertices[5].position[1] = y1;
vertices[5].uv[0] = 1;
vertices[5].uv[1] = 0;
} }
gsk_ngl_render_job_end_draw (job); gsk_ngl_render_job_end_draw (job);
@ -3900,6 +3841,7 @@ gsk_ngl_render_job_new (GskNglDriver *driver,
job->viewport = *viewport; job->viewport = *viewport;
gsk_ngl_render_job_set_alpha (job, 1.0); gsk_ngl_render_job_set_alpha (job, 1.0);
gsk_ngl_render_job_set_color (job, &(GdkRGBA){ 0.f, 0.f, 0.f, 0.f });
gsk_ngl_render_job_set_projection_from_rect (job, viewport, NULL); gsk_ngl_render_job_set_projection_from_rect (job, viewport, NULL);
gsk_ngl_render_job_set_modelview (job, gsk_transform_scale (NULL, scale_factor, scale_factor)); gsk_ngl_render_job_set_modelview (job, gsk_transform_scale (NULL, scale_factor, scale_factor));

View File

@ -55,6 +55,7 @@ struct _GskNglDrawVertex
{ {
float position[2]; float position[2];
float uv[2]; float uv[2];
float color[4];
}; };
G_END_DECLS G_END_DECLS

View File

@ -1,4 +1,5 @@
// VERTEX_SHADER: // VERTEX_SHADER:
void main() { void main() {
gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0); gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);

View File

@ -1,4 +1,5 @@
// VERTEX_SHADER: // VERTEX_SHADER:
void main() { void main() {
gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0); gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);

View File

@ -1,5 +1,4 @@
// VERTEX_SHADER: // VERTEX_SHADER:
uniform vec4 u_color;
uniform vec4 u_widths; uniform vec4 u_widths;
uniform vec4[3] u_outline_rect; uniform vec4[3] u_outline_rect;
@ -10,7 +9,7 @@ _OUT_ _GSK_ROUNDED_RECT_UNIFORM_ transformed_inside_outline;
void main() { void main() {
gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0); gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
final_color = gsk_premultiply(u_color) * u_alpha; final_color = gsk_premultiply(aColor) * u_alpha;
GskRoundedRect outside = gsk_create_rect(u_outline_rect); GskRoundedRect outside = gsk_create_rect(u_outline_rect);
GskRoundedRect inside = gsk_rounded_rect_shrink (outside, u_widths); GskRoundedRect inside = gsk_rounded_rect_shrink (outside, u_widths);

View File

@ -1,12 +1,10 @@
// VERTEX_SHADER: // VERTEX_SHADER:
uniform vec4 u_color;
_OUT_ vec4 final_color; _OUT_ vec4 final_color;
void main() { void main() {
gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0); gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
final_color = gsk_premultiply(u_color) * u_alpha; final_color = gsk_premultiply(aColor) * u_alpha;
} }
// FRAGMENT_SHADER: // FRAGMENT_SHADER:

View File

@ -1,4 +1,5 @@
// VERTEX_SHADER: // VERTEX_SHADER:
void main() { void main() {
gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0); gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);

View File

@ -1,6 +1,4 @@
// VERTEX_SHADER: // VERTEX_SHADER:
uniform vec4 u_color;
_OUT_ vec4 final_color; _OUT_ vec4 final_color;
void main() { void main() {
@ -8,7 +6,7 @@ void main() {
vUv = vec2(aUv.x, aUv.y); vUv = vec2(aUv.x, aUv.y);
final_color = gsk_premultiply(u_color) * u_alpha; final_color = gsk_premultiply(aColor) * u_alpha;
} }
// FRAGMENT_SHADER: // FRAGMENT_SHADER:

View File

@ -10,8 +10,7 @@ void main() {
vec2 mv1 = u_modelview[1].xy; vec2 mv1 = u_modelview[1].xy;
vec2 offset = aPosition - u_geometry.xy; vec2 offset = aPosition - u_geometry.xy;
coord = vec2(dot(mv0, offset), coord = vec2(dot(mv0, offset), dot(mv1, offset));
dot(mv1, offset));
} }
// FRAGMENT_SHADER: // FRAGMENT_SHADER:

View File

@ -1,4 +1,5 @@
// VERTEX_SHADER: // VERTEX_SHADER:
void main() { void main() {
gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0); gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);

View File

@ -1,5 +1,4 @@
// VERTEX_SHADER: // VERTEX_SHADER:
uniform vec4 u_color;
uniform float u_spread; uniform float u_spread;
uniform vec2 u_offset; uniform vec2 u_offset;
uniform vec4[3] u_outline_rect; uniform vec4[3] u_outline_rect;
@ -11,7 +10,7 @@ _OUT_ _GSK_ROUNDED_RECT_UNIFORM_ transformed_inside_outline;
void main() { void main() {
gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0); gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
final_color = gsk_premultiply(u_color) * u_alpha; final_color = gsk_premultiply(aColor) * u_alpha;
GskRoundedRect outside = gsk_create_rect(u_outline_rect); GskRoundedRect outside = gsk_create_rect(u_outline_rect);
GskRoundedRect inside = gsk_rounded_rect_shrink(outside, vec4(u_spread)); GskRoundedRect inside = gsk_rounded_rect_shrink(outside, vec4(u_spread));

View File

@ -1,5 +1,4 @@
// VERTEX_SHADER: // VERTEX_SHADER:
uniform vec4 u_color;
uniform vec4[3] u_outline_rect; uniform vec4[3] u_outline_rect;
_OUT_ vec4 final_color; _OUT_ vec4 final_color;
@ -10,7 +9,7 @@ void main() {
vUv = vec2(aUv.x, aUv.y); vUv = vec2(aUv.x, aUv.y);
final_color = gsk_premultiply(u_color) * u_alpha; final_color = gsk_premultiply(aColor) * u_alpha;
GskRoundedRect outline = gsk_create_rect(u_outline_rect); GskRoundedRect outline = gsk_create_rect(u_outline_rect);
gsk_rounded_rect_transform(outline, u_modelview); gsk_rounded_rect_transform(outline, u_modelview);

View File

@ -1,7 +1,7 @@
uniform sampler2D u_source; uniform sampler2D u_source;
uniform mat4 u_projection; uniform mat4 u_projection;
uniform mat4 u_modelview; uniform mat4 u_modelview;
uniform float u_alpha;// = 1.0; uniform float u_alpha;
uniform vec4 u_viewport; uniform vec4 u_viewport;
uniform vec4[3] u_clip_rect; uniform vec4[3] u_clip_rect;
@ -14,7 +14,6 @@ _OUT_ vec4 outputColor;
_IN_ vec2 vUv; _IN_ vec2 vUv;
GskRoundedRect gsk_decode_rect(_GSK_ROUNDED_RECT_UNIFORM_ r) GskRoundedRect gsk_decode_rect(_GSK_ROUNDED_RECT_UNIFORM_ r)
{ {
#if defined(GSK_GLES) || defined(GSK_LEGACY) #if defined(GSK_GLES) || defined(GSK_LEGACY)

View File

@ -5,10 +5,12 @@ uniform float u_alpha;
#if defined(GSK_GLES) || defined(GSK_LEGACY) #if defined(GSK_GLES) || defined(GSK_LEGACY)
attribute vec2 aPosition; attribute vec2 aPosition;
attribute vec2 aUv; attribute vec2 aUv;
attribute vec4 aColor;
_OUT_ vec2 vUv; _OUT_ vec2 vUv;
#else #else
_IN_ vec2 aPosition; _IN_ vec2 aPosition;
_IN_ vec2 aUv; _IN_ vec2 aUv;
_IN_ vec4 aColor;
_OUT_ vec2 vUv; _OUT_ vec2 vUv;
#endif #endif

View File

@ -1,4 +1,5 @@
// VERTEX_SHADER: // VERTEX_SHADER:
void main() { void main() {
gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0); gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
@ -9,7 +10,6 @@ void main() {
uniform vec4 u_child_bounds; uniform vec4 u_child_bounds;
uniform vec4 u_texture_rect; uniform vec4 u_texture_rect;
float wrap(float f, float wrap_for) { float wrap(float f, float wrap_for) {
return mod(f, wrap_for); return mod(f, wrap_for);
} }

View File

@ -1,5 +1,4 @@
// VERTEX_SHADER: // VERTEX_SHADER:
uniform vec4 u_color;
uniform float u_spread; uniform float u_spread;
uniform vec2 u_offset; uniform vec2 u_offset;
uniform vec4[3] u_outline_rect; uniform vec4[3] u_outline_rect;
@ -11,7 +10,7 @@ _OUT_ _GSK_ROUNDED_RECT_UNIFORM_ transformed_inside_outline;
void main() { void main() {
gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0); gl_Position = u_projection * u_modelview * vec4(aPosition, 0.0, 1.0);
final_color = gsk_premultiply(u_color) * u_alpha; final_color = gsk_premultiply(aColor) * u_alpha;
GskRoundedRect inside = gsk_create_rect(u_outline_rect); GskRoundedRect inside = gsk_create_rect(u_outline_rect);
GskRoundedRect outside = gsk_rounded_rect_shrink(inside, vec4(- u_spread)); GskRoundedRect outside = gsk_rounded_rect_shrink(inside, vec4(- u_spread));