Merge branch 'wip/baedert/for-master' into 'master'

Wip/baedert/for master

See merge request GNOME/gtk!2617
This commit is contained in:
Timm Bäder 2020-09-25 13:35:20 +00:00
commit 09564a5798
8 changed files with 106 additions and 70 deletions

View File

@ -1175,21 +1175,29 @@ render_linear_gradient_node (GskGLRenderer *self,
GskRenderNode *node, GskRenderNode *node,
RenderOpBuilder *builder) RenderOpBuilder *builder)
{ {
const int n_color_stops = MIN (8, gsk_linear_gradient_node_get_n_color_stops (node)); const int n_color_stops = gsk_linear_gradient_node_get_n_color_stops (node);
const GskColorStop *stops = gsk_linear_gradient_node_peek_color_stops (node, NULL);
const graphene_point_t *start = gsk_linear_gradient_node_peek_start (node);
const graphene_point_t *end = gsk_linear_gradient_node_peek_end (node);
ops_set_program (builder, &self->programs->linear_gradient_program); if (n_color_stops < GL_MAX_GRADIENT_STOPS)
ops_set_linear_gradient (builder, {
n_color_stops, const GskColorStop *stops = gsk_linear_gradient_node_peek_color_stops (node, NULL);
stops, const graphene_point_t *start = gsk_linear_gradient_node_peek_start (node);
builder->dx + start->x, const graphene_point_t *end = gsk_linear_gradient_node_peek_end (node);
builder->dy + start->y,
builder->dx + end->x,
builder->dy + end->y);
load_vertex_data (ops_draw (builder, NULL), node, builder); ops_set_program (builder, &self->programs->linear_gradient_program);
ops_set_linear_gradient (builder,
n_color_stops,
stops,
builder->dx + start->x,
builder->dy + start->y,
builder->dx + end->x,
builder->dy + end->y);
load_vertex_data (ops_draw (builder, NULL), node, builder);
}
else
{
render_fallback_node (self, node, builder);
}
} }
static inline void static inline void
@ -1197,25 +1205,33 @@ render_radial_gradient_node (GskGLRenderer *self,
GskRenderNode *node, GskRenderNode *node,
RenderOpBuilder *builder) RenderOpBuilder *builder)
{ {
const float scale = ops_get_scale (builder); const int n_color_stops = gsk_radial_gradient_node_get_n_color_stops (node);
const int n_color_stops = MIN (8, gsk_radial_gradient_node_get_n_color_stops (node));
const GskColorStop *stops = gsk_radial_gradient_node_peek_color_stops (node, NULL);
const graphene_point_t *center = gsk_radial_gradient_node_peek_center (node);
const float start = gsk_radial_gradient_node_get_start (node);
const float end = gsk_radial_gradient_node_get_end (node);
const float hradius = gsk_radial_gradient_node_get_hradius (node);
const float vradius = gsk_radial_gradient_node_get_vradius (node);
ops_set_program (builder, &self->programs->radial_gradient_program); if (n_color_stops < GL_MAX_GRADIENT_STOPS)
ops_set_radial_gradient (builder, {
n_color_stops, const GskColorStop *stops = gsk_radial_gradient_node_peek_color_stops (node, NULL);
stops, const graphene_point_t *center = gsk_radial_gradient_node_peek_center (node);
builder->dx + center->x, const float start = gsk_radial_gradient_node_get_start (node);
builder->dy + center->y, const float end = gsk_radial_gradient_node_get_end (node);
start, end, const float hradius = gsk_radial_gradient_node_get_hradius (node);
hradius * scale, vradius * scale); const float vradius = gsk_radial_gradient_node_get_vradius (node);
load_vertex_data (ops_draw (builder, NULL), node, builder); ops_set_program (builder, &self->programs->radial_gradient_program);
ops_set_radial_gradient (builder,
n_color_stops,
stops,
builder->dx + center->x,
builder->dy + center->y,
start, end,
hradius * builder->scale_x,
vradius * builder->scale_y);
load_vertex_data (ops_draw (builder, NULL), node, builder);
}
else
{
render_fallback_node (self, node, builder);
}
} }
static inline gboolean static inline gboolean
@ -1332,17 +1348,18 @@ render_clipped_child (GskGLRenderer *self,
else else
{ {
/* well fuck */ /* well fuck */
const float scale = ops_get_scale (builder); const float scale_x = builder->scale_x;
const float scale_y = builder->scale_y;
gboolean is_offscreen; gboolean is_offscreen;
TextureRegion region; TextureRegion region;
GskRoundedRect scaled_clip; GskRoundedRect scaled_clip;
memset (&scaled_clip, 0, sizeof (GskRoundedRect)); memset (&scaled_clip, 0, sizeof (GskRoundedRect));
scaled_clip.bounds.origin.x = clip->origin.x * scale; scaled_clip.bounds.origin.x = clip->origin.x * scale_x;
scaled_clip.bounds.origin.y = clip->origin.y * scale; scaled_clip.bounds.origin.y = clip->origin.y * scale_y;
scaled_clip.bounds.size.width = clip->size.width * scale; scaled_clip.bounds.size.width = clip->size.width * scale_x;
scaled_clip.bounds.size.height = clip->size.height * scale; scaled_clip.bounds.size.height = clip->size.height * scale_y;
ops_push_clip (builder, &scaled_clip); ops_push_clip (builder, &scaled_clip);
if (!add_offscreen_ops (self, builder, &child->bounds, if (!add_offscreen_ops (self, builder, &child->bounds,
@ -1375,7 +1392,8 @@ render_rounded_clip_node (GskGLRenderer *self,
GskRenderNode *node, GskRenderNode *node,
RenderOpBuilder *builder) RenderOpBuilder *builder)
{ {
const float scale = ops_get_scale (builder); const float scale_x = builder->scale_x;
const float scale_y = builder->scale_y;
const GskRoundedRect *clip = gsk_rounded_clip_node_peek_clip (node); const GskRoundedRect *clip = gsk_rounded_clip_node_peek_clip (node);
GskRenderNode *child = gsk_rounded_clip_node_get_child (node); GskRenderNode *child = gsk_rounded_clip_node_get_child (node);
GskRoundedRect transformed_clip; GskRoundedRect transformed_clip;
@ -1388,8 +1406,8 @@ render_rounded_clip_node (GskGLRenderer *self,
ops_transform_bounds_modelview (builder, &clip->bounds, &transformed_clip.bounds); ops_transform_bounds_modelview (builder, &clip->bounds, &transformed_clip.bounds);
for (i = 0; i < 4; i ++) for (i = 0; i < 4; i ++)
{ {
transformed_clip.corner[i].width = clip->corner[i].width * scale; transformed_clip.corner[i].width = clip->corner[i].width * scale_x;
transformed_clip.corner[i].height = clip->corner[i].height * scale; transformed_clip.corner[i].height = clip->corner[i].height * scale_y;
} }
if (builder->clip_is_rectilinear) if (builder->clip_is_rectilinear)
@ -1447,16 +1465,16 @@ render_rounded_clip_node (GskGLRenderer *self,
* *
* We do, however, apply the scale factor to the child clip of course. * We do, however, apply the scale factor to the child clip of course.
*/ */
scaled_clip.bounds.origin.x = clip->bounds.origin.x * scale; scaled_clip.bounds.origin.x = clip->bounds.origin.x * scale_x;
scaled_clip.bounds.origin.y = clip->bounds.origin.y * scale; scaled_clip.bounds.origin.y = clip->bounds.origin.y * scale_y;
scaled_clip.bounds.size.width = clip->bounds.size.width * scale; scaled_clip.bounds.size.width = clip->bounds.size.width * scale_x;
scaled_clip.bounds.size.height = clip->bounds.size.height * scale; scaled_clip.bounds.size.height = clip->bounds.size.height * scale_y;
/* Increase corner radius size by scale factor */ /* Increase corner radius size by scale factor */
for (i = 0; i < 4; i ++) for (i = 0; i < 4; i ++)
{ {
scaled_clip.corner[i].width = clip->corner[i].width * scale; scaled_clip.corner[i].width = clip->corner[i].width * scale_x;
scaled_clip.corner[i].height = clip->corner[i].height * scale; scaled_clip.corner[i].height = clip->corner[i].height * scale_y;
} }
ops_push_clip (builder, &scaled_clip); ops_push_clip (builder, &scaled_clip);
@ -3089,7 +3107,7 @@ gsk_gl_renderer_create_programs (GskGLRenderer *self,
out: out:
gsk_gl_shader_builder_finish (&shader_builder); gsk_gl_shader_builder_finish (&shader_builder);
if (error && !(*error)) if (error && !(*error) && !programs)
g_set_error (error, GDK_GL_ERROR, GDK_GL_ERROR_COMPILATION_FAILED, g_set_error (error, GDK_GL_ERROR, GDK_GL_ERROR_COMPILATION_FAILED,
"Failed to compile all shader programs"); /* Probably, eh. */ "Failed to compile all shader programs"); /* Probably, eh. */

View File

@ -909,7 +909,7 @@ ops_set_linear_gradient (RenderOpBuilder *self,
{ {
ProgramState *current_program_state = get_current_program_state (self); ProgramState *current_program_state = get_current_program_state (self);
OpLinearGradient *op; OpLinearGradient *op;
const guint real_n_color_stops = MIN (MAX_GRADIENT_STOPS, n_color_stops); const guint real_n_color_stops = MIN (GL_MAX_GRADIENT_STOPS, n_color_stops);
g_assert (current_program_state); g_assert (current_program_state);
@ -972,7 +972,7 @@ ops_set_radial_gradient (RenderOpBuilder *self,
float hradius, float hradius,
float vradius) float vradius)
{ {
const guint real_n_color_stops = MIN (MAX_GRADIENT_STOPS, n_color_stops); const guint real_n_color_stops = MIN (GL_MAX_GRADIENT_STOPS, n_color_stops);
OpRadialGradient *op; OpRadialGradient *op;
/* TODO: State tracking? */ /* TODO: State tracking? */

View File

@ -14,7 +14,7 @@
#define GL_N_VERTICES 6 #define GL_N_VERTICES 6
#define GL_N_PROGRAMS 14 #define GL_N_PROGRAMS 14
#define MAX_GRADIENT_STOPS 8 #define GL_MAX_GRADIENT_STOPS 6
typedef struct typedef struct
{ {
@ -147,13 +147,13 @@ typedef struct
} unblurred_outset_shadow; } unblurred_outset_shadow;
struct { struct {
int n_color_stops; int n_color_stops;
GskColorStop color_stops[MAX_GRADIENT_STOPS]; GskColorStop color_stops[GL_MAX_GRADIENT_STOPS];
float start_point[2]; float start_point[2];
float end_point[2]; float end_point[2];
} linear_gradient; } linear_gradient;
struct { struct {
int n_color_stops; int n_color_stops;
GskColorStop color_stops[MAX_GRADIENT_STOPS]; GskColorStop color_stops[GL_MAX_GRADIENT_STOPS];
float center[2]; float center[2];
float start; float start;
float end; float end;

View File

@ -1,7 +1,7 @@
// VERTEX_SHADER // VERTEX_SHADER
uniform vec2 u_start_point; uniform vec2 u_start_point;
uniform vec2 u_end_point; uniform vec2 u_end_point;
uniform float u_color_stops[8 * 5]; uniform float u_color_stops[6 * 5];
uniform int u_num_color_stops; uniform int u_num_color_stops;
_OUT_ vec2 startPoint; _OUT_ vec2 startPoint;

View File

@ -1,7 +1,7 @@
// VERTEX_SHADER // VERTEX_SHADER
uniform float u_start; uniform float u_start;
uniform float u_end; uniform float u_end;
uniform float u_color_stops[8 * 5]; uniform float u_color_stops[6 * 5];
uniform int u_num_color_stops; uniform int u_num_color_stops;
uniform vec2 u_radius; uniform vec2 u_radius;
uniform vec2 u_center; uniform vec2 u_center;

View File

@ -149,10 +149,10 @@ gtk_css_image_fallback_compute (GtkCssImage *image,
if (fallback->color) if (fallback->color)
computed_color= _gtk_css_value_compute (fallback->color, computed_color= _gtk_css_value_compute (fallback->color,
property_id, property_id,
provider, provider,
style, style,
parent_style); parent_style);
/* image($color) that didn't change */ /* image($color) that didn't change */
if (computed_color && !fallback->images && if (computed_color && !fallback->images &&
@ -209,6 +209,9 @@ gtk_css_image_fallback_parse_arg (GtkCssParser *parser,
if (image == NULL) if (image == NULL)
return 0; return 0;
if (!data->images)
data->images = g_ptr_array_new_with_free_func (g_object_unref);
g_ptr_array_add (data->images, image); g_ptr_array_add (data->images, image);
return 1; return 1;
} }
@ -235,18 +238,25 @@ gtk_css_image_fallback_parse (GtkCssImage *image,
return FALSE; return FALSE;
} }
data.images = g_ptr_array_new_with_free_func (g_object_unref);
if (!gtk_css_parser_consume_function (parser, 1, G_MAXUINT, gtk_css_image_fallback_parse_arg, &data)) if (!gtk_css_parser_consume_function (parser, 1, G_MAXUINT, gtk_css_image_fallback_parse_arg, &data))
{ {
g_clear_pointer (&data.color, _gtk_css_value_unref); g_clear_pointer (&data.color, _gtk_css_value_unref);
g_ptr_array_free (data.images, TRUE); if (data.images)
g_ptr_array_free (data.images, TRUE);
return FALSE; return FALSE;
} }
self->color = data.color; self->color = data.color;
self->n_images = data.images->len; if (data.images)
self->images = (GtkCssImage **) g_ptr_array_free (data.images, FALSE); {
self->n_images = data.images->len;
self->images = (GtkCssImage **) g_ptr_array_free (data.images, FALSE);
}
else
{
self->n_images = 0;
self->images = NULL;
}
return TRUE; return TRUE;
} }

View File

@ -310,6 +310,7 @@ gtk_text_buffer_deserialize_text_plain_finish (GObject *source,
GtkTextIter start, end; GtkTextIter start, end;
GError *error = NULL; GError *error = NULL;
gssize written; gssize written;
char *data;
written = g_output_stream_splice_finish (stream, result, &error); written = g_output_stream_splice_finish (stream, result, &error);
if (written < 0) if (written < 0)
@ -318,15 +319,19 @@ gtk_text_buffer_deserialize_text_plain_finish (GObject *source,
return; return;
} }
buffer = g_value_get_object (gdk_content_deserializer_get_value (deserializer)); data = g_memory_output_stream_steal_data (G_MEMORY_OUTPUT_STREAM (
gtk_text_buffer_get_end_iter (buffer, &end); g_filter_output_stream_get_base_stream (G_FILTER_OUTPUT_STREAM (stream))));
gtk_text_buffer_insert (buffer,
&end, if (data)
g_memory_output_stream_steal_data (G_MEMORY_OUTPUT_STREAM ( {
g_filter_output_stream_get_base_stream (G_FILTER_OUTPUT_STREAM (stream)))), buffer = g_value_get_object (gdk_content_deserializer_get_value (deserializer));
-1); gtk_text_buffer_get_end_iter (buffer, &end);
gtk_text_buffer_get_bounds (buffer, &start, &end); gtk_text_buffer_insert (buffer, &end, data, -1);
gtk_text_buffer_select_range (buffer, &start, &end); gtk_text_buffer_get_bounds (buffer, &start, &end);
gtk_text_buffer_select_range (buffer, &start, &end);
g_free (data);
}
gdk_content_deserializer_return_success (deserializer); gdk_content_deserializer_return_success (deserializer);
} }

View File

@ -3255,6 +3255,9 @@ calendar {
background: none; background: none;
border-radius: 0; border-radius: 0;
} }
> button:backdrop {
background: none;
}
} }
> grid { > grid {