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,7 +1175,10 @@ 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);
if (n_color_stops < GL_MAX_GRADIENT_STOPS)
{
const GskColorStop *stops = gsk_linear_gradient_node_peek_color_stops (node, NULL); 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 *start = gsk_linear_gradient_node_peek_start (node);
const graphene_point_t *end = gsk_linear_gradient_node_peek_end (node); const graphene_point_t *end = gsk_linear_gradient_node_peek_end (node);
@ -1191,14 +1194,21 @@ render_linear_gradient_node (GskGLRenderer *self,
load_vertex_data (ops_draw (builder, NULL), node, builder); load_vertex_data (ops_draw (builder, NULL), node, builder);
} }
else
{
render_fallback_node (self, node, builder);
}
}
static inline void static inline void
render_radial_gradient_node (GskGLRenderer *self, 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));
if (n_color_stops < GL_MAX_GRADIENT_STOPS)
{
const GskColorStop *stops = gsk_radial_gradient_node_peek_color_stops (node, NULL); 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 graphene_point_t *center = gsk_radial_gradient_node_peek_center (node);
const float start = gsk_radial_gradient_node_get_start (node); const float start = gsk_radial_gradient_node_get_start (node);
@ -1213,10 +1223,16 @@ render_radial_gradient_node (GskGLRenderer *self,
builder->dx + center->x, builder->dx + center->x,
builder->dy + center->y, builder->dy + center->y,
start, end, start, end,
hradius * scale, vradius * scale); hradius * builder->scale_x,
vradius * builder->scale_y);
load_vertex_data (ops_draw (builder, NULL), node, builder); load_vertex_data (ops_draw (builder, NULL), node, builder);
} }
else
{
render_fallback_node (self, node, builder);
}
}
static inline gboolean static inline gboolean
rounded_inner_rect_contains_rect (const GskRoundedRect *rounded, rounded_inner_rect_contains_rect (const GskRoundedRect *rounded,
@ -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

@ -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);
if (data.images)
g_ptr_array_free (data.images, TRUE); g_ptr_array_free (data.images, TRUE);
return FALSE; return FALSE;
} }
self->color = data.color; self->color = data.color;
if (data.images)
{
self->n_images = data.images->len; self->n_images = data.images->len;
self->images = (GtkCssImage **) g_ptr_array_free (data.images, FALSE); 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,16 +319,20 @@ gtk_text_buffer_deserialize_text_plain_finish (GObject *source,
return; return;
} }
data = g_memory_output_stream_steal_data (G_MEMORY_OUTPUT_STREAM (
g_filter_output_stream_get_base_stream (G_FILTER_OUTPUT_STREAM (stream))));
if (data)
{
buffer = g_value_get_object (gdk_content_deserializer_get_value (deserializer)); buffer = g_value_get_object (gdk_content_deserializer_get_value (deserializer));
gtk_text_buffer_get_end_iter (buffer, &end); gtk_text_buffer_get_end_iter (buffer, &end);
gtk_text_buffer_insert (buffer, gtk_text_buffer_insert (buffer, &end, data, -1);
&end,
g_memory_output_stream_steal_data (G_MEMORY_OUTPUT_STREAM (
g_filter_output_stream_get_base_stream (G_FILTER_OUTPUT_STREAM (stream)))),
-1);
gtk_text_buffer_get_bounds (buffer, &start, &end); gtk_text_buffer_get_bounds (buffer, &start, &end);
gtk_text_buffer_select_range (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 {