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,
RenderOpBuilder *builder)
{
const int n_color_stops = MIN (8, 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);
const int n_color_stops = gsk_linear_gradient_node_get_n_color_stops (node);
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);
if (n_color_stops < GL_MAX_GRADIENT_STOPS)
{
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);
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
@ -1197,25 +1205,33 @@ render_radial_gradient_node (GskGLRenderer *self,
GskRenderNode *node,
RenderOpBuilder *builder)
{
const float scale = ops_get_scale (builder);
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);
const int n_color_stops = gsk_radial_gradient_node_get_n_color_stops (node);
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 * scale, vradius * scale);
if (n_color_stops < GL_MAX_GRADIENT_STOPS)
{
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);
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
@ -1332,17 +1348,18 @@ render_clipped_child (GskGLRenderer *self,
else
{
/* 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;
TextureRegion region;
GskRoundedRect scaled_clip;
memset (&scaled_clip, 0, sizeof (GskRoundedRect));
scaled_clip.bounds.origin.x = clip->origin.x * scale;
scaled_clip.bounds.origin.y = clip->origin.y * scale;
scaled_clip.bounds.size.width = clip->size.width * scale;
scaled_clip.bounds.size.height = clip->size.height * scale;
scaled_clip.bounds.origin.x = clip->origin.x * scale_x;
scaled_clip.bounds.origin.y = clip->origin.y * scale_y;
scaled_clip.bounds.size.width = clip->size.width * scale_x;
scaled_clip.bounds.size.height = clip->size.height * scale_y;
ops_push_clip (builder, &scaled_clip);
if (!add_offscreen_ops (self, builder, &child->bounds,
@ -1375,7 +1392,8 @@ render_rounded_clip_node (GskGLRenderer *self,
GskRenderNode *node,
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);
GskRenderNode *child = gsk_rounded_clip_node_get_child (node);
GskRoundedRect transformed_clip;
@ -1388,8 +1406,8 @@ render_rounded_clip_node (GskGLRenderer *self,
ops_transform_bounds_modelview (builder, &clip->bounds, &transformed_clip.bounds);
for (i = 0; i < 4; i ++)
{
transformed_clip.corner[i].width = clip->corner[i].width * scale;
transformed_clip.corner[i].height = clip->corner[i].height * scale;
transformed_clip.corner[i].width = clip->corner[i].width * scale_x;
transformed_clip.corner[i].height = clip->corner[i].height * scale_y;
}
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.
*/
scaled_clip.bounds.origin.x = clip->bounds.origin.x * scale;
scaled_clip.bounds.origin.y = clip->bounds.origin.y * scale;
scaled_clip.bounds.size.width = clip->bounds.size.width * scale;
scaled_clip.bounds.size.height = clip->bounds.size.height * scale;
scaled_clip.bounds.origin.x = clip->bounds.origin.x * scale_x;
scaled_clip.bounds.origin.y = clip->bounds.origin.y * scale_y;
scaled_clip.bounds.size.width = clip->bounds.size.width * scale_x;
scaled_clip.bounds.size.height = clip->bounds.size.height * scale_y;
/* Increase corner radius size by scale factor */
for (i = 0; i < 4; i ++)
{
scaled_clip.corner[i].width = clip->corner[i].width * scale;
scaled_clip.corner[i].height = clip->corner[i].height * scale;
scaled_clip.corner[i].width = clip->corner[i].width * scale_x;
scaled_clip.corner[i].height = clip->corner[i].height * scale_y;
}
ops_push_clip (builder, &scaled_clip);
@ -3089,7 +3107,7 @@ gsk_gl_renderer_create_programs (GskGLRenderer *self,
out:
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,
"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);
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);
@ -972,7 +972,7 @@ ops_set_radial_gradient (RenderOpBuilder *self,
float hradius,
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;
/* TODO: State tracking? */

View File

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

View File

@ -1,7 +1,7 @@
// VERTEX_SHADER
uniform vec2 u_start_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;
_OUT_ vec2 startPoint;

View File

@ -1,7 +1,7 @@
// VERTEX_SHADER
uniform float u_start;
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 vec2 u_radius;
uniform vec2 u_center;

View File

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

View File

@ -310,6 +310,7 @@ gtk_text_buffer_deserialize_text_plain_finish (GObject *source,
GtkTextIter start, end;
GError *error = NULL;
gssize written;
char *data;
written = g_output_stream_splice_finish (stream, result, &error);
if (written < 0)
@ -318,15 +319,19 @@ gtk_text_buffer_deserialize_text_plain_finish (GObject *source,
return;
}
buffer = g_value_get_object (gdk_content_deserializer_get_value (deserializer));
gtk_text_buffer_get_end_iter (buffer, &end);
gtk_text_buffer_insert (buffer,
&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_select_range (buffer, &start, &end);
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));
gtk_text_buffer_get_end_iter (buffer, &end);
gtk_text_buffer_insert (buffer, &end, data, -1);
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);
}

View File

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