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

Wip/baedert/for master

See merge request GNOME/gtk!2162
This commit is contained in:
Matthias Clasen 2020-07-01 01:35:56 +00:00
commit 43b9fc6981
12 changed files with 89 additions and 180 deletions

View File

@ -2241,12 +2241,23 @@ render_cross_fade_node (GskGLRenderer *self,
{
GskRenderNode *start_node = gsk_cross_fade_node_get_start_child (node);
GskRenderNode *end_node = gsk_cross_fade_node_get_end_child (node);
float progress = gsk_cross_fade_node_get_progress (node);
const float progress = gsk_cross_fade_node_get_progress (node);
TextureRegion start_region;
TextureRegion end_region;
gboolean is_offscreen1, is_offscreen2;
OpCrossFade *op;
if (progress <= 0)
{
gsk_gl_renderer_add_render_ops (self, start_node, builder);
return;
}
else if (progress >= 1)
{
gsk_gl_renderer_add_render_ops (self, end_node, builder);
return;
}
/* TODO: We create 2 textures here as big as the cross-fade node, but both the
* start and the end node might be a lot smaller than that. */
@ -2266,11 +2277,10 @@ render_cross_fade_node (GskGLRenderer *self,
&end_region, &is_offscreen2,
FORCE_OFFSCREEN | RESET_CLIP | RESET_OPACITY))
{
load_vertex_data_with_region (ops_draw (builder, NULL),
node,
builder,
&start_region,
TRUE);
const float prev_opacity = ops_set_opacity (builder, builder->current_opacity * progress);
gsk_gl_renderer_add_render_ops (self, start_node, builder);
ops_set_opacity (builder, prev_opacity);
return;
}

View File

@ -104,7 +104,7 @@ gsk_color_node_peek_color (GskRenderNode *node)
}
/**
* gsk_color_node_new:
* gsk_color_node_new:
* @rgba: a #GdkRGBA specifying a color
* @bounds: the rectangle to render the color into
*
@ -216,7 +216,7 @@ gsk_linear_gradient_node_diff (GskRenderNode *node1,
return;
}
gsk_render_node_diff_impossible (node1, node2, region);
}
@ -1163,7 +1163,7 @@ gsk_inset_shadow_node_diff (GskRenderNode *node1,
}
/**
* gsk_inset_shadow_node_new:
* gsk_inset_shadow_node_new:
* @outline: outline of the region containing the shadow
* @color: color of the shadow
* @dx: horizontal offset of shadow
@ -1465,7 +1465,7 @@ gsk_outset_shadow_node_diff (GskRenderNode *node1,
}
/**
* gsk_outset_shadow_node_new:
* gsk_outset_shadow_node_new:
* @outline: outline of the region surrounded by shadow
* @color: color of the shadow
* @dx: horizontal offset of shadow
@ -1672,7 +1672,7 @@ gsk_cairo_node_peek_surface (GskRenderNode *node)
}
/**
* gsk_cairo_node_new:
* gsk_cairo_node_new:
* @bounds: the rectangle to render to
*
* Creates a #GskRenderNode that will render a cairo surface
@ -1982,7 +1982,7 @@ gsk_transform_node_draw (GskRenderNode *node,
ctm.xy, ctm.yy,
ctm.x0, ctm.y0));
cairo_transform (cr, &ctm);
gsk_render_node_draw (self->child, cr);
}
@ -2062,7 +2062,7 @@ gsk_transform_node_diff (GskRenderNode *node1,
}
/**
* gsk_transform_node_new:
* gsk_transform_node_new:
* @child: The node to transform
* @transform: (transfer none): The transform to apply
*
@ -2188,7 +2188,7 @@ gsk_opacity_node_diff (GskRenderNode *node1,
}
/**
* gsk_opacity_node_new:
* gsk_opacity_node_new:
* @child: The node to draw
* @opacity: The opacity to apply
*
@ -2380,7 +2380,7 @@ nope:
}
/**
* gsk_color_matrix_node_new:
* gsk_color_matrix_node_new:
* @child: The node to draw
* @color_matrix: The matrix to apply
* @color_offset: Values to add to the color
@ -2533,7 +2533,7 @@ gsk_repeat_node_draw (GskRenderNode *node,
}
/**
* gsk_repeat_node_new:
* gsk_repeat_node_new:
* @bounds: The bounds of the area to be painted
* @child: The child to repeat
* @child_bounds: (allow-none): The area of the child to repeat or %NULL to
@ -2670,7 +2670,7 @@ gsk_clip_node_diff (GskRenderNode *node1,
}
/**
* gsk_clip_node_new:
* gsk_clip_node_new:
* @child: The node to draw
* @clip: The clip to apply
*
@ -2800,7 +2800,7 @@ gsk_rounded_clip_node_diff (GskRenderNode *node1,
}
/**
* gsk_rounded_clip_node_new:
* gsk_rounded_clip_node_new:
* @child: The node to draw
* @clip: The clip to apply
*
@ -3013,7 +3013,7 @@ gsk_shadow_node_get_bounds (GskShadowNode *self,
}
/**
* gsk_shadow_node_new:
* gsk_shadow_node_new:
* @child: The node to draw
* @shadows: (array length=n_shadows): The shadows to apply
* @n_shadows: number of entries in the @shadows array
@ -3210,7 +3210,7 @@ gsk_blend_node_diff (GskRenderNode *node1,
}
/**
* gsk_blend_node_new:
* gsk_blend_node_new:
* @bottom: The bottom node to be drawn
* @top: The node to be blended onto the @bottom node
* @blend_mode: The blend mode to use
@ -3359,7 +3359,7 @@ gsk_cross_fade_node_diff (GskRenderNode *node1,
}
/**
* gsk_cross_fade_node_new:
* gsk_cross_fade_node_new:
* @start: The start node to be drawn
* @end: The node to be cross_fadeed onto the @start node
* @progress: How far the fade has progressed from start to end. The value will
@ -3549,7 +3549,7 @@ font_has_color_glyphs (const PangoFont *font)
}
/**
* gsk_text_node_new:
* gsk_text_node_new:
* @font: the #PangoFont containing the glyphs
* @glyphs: the #PangoGlyphString to render
* @color: the foreground color to render with
@ -3953,7 +3953,7 @@ gsk_blur_node_diff (GskRenderNode *node1,
}
/**
* gsk_blur_node_new:
* gsk_blur_node_new:
* @child: the child node to blur
* @radius: the blur radius
*
@ -4076,9 +4076,9 @@ gsk_debug_node_diff (GskRenderNode *node1,
}
/**
* gsk_debug_node_new:
* gsk_debug_node_new:
* @child: The child to add debug info for
* @message: (transfer full): The debug message
* @message: (transfer full): The debug message
*
* Creates a #GskRenderNode that will add debug information about
* the given @child.

View File

@ -1171,6 +1171,8 @@ gtk_grid_view_init (GtkGridView *self)
gtk_list_base_set_anchor_max_widgets (GTK_LIST_BASE (self),
self->max_columns * GTK_GRID_VIEW_MAX_VISIBLE_ROWS,
self->max_columns);
gtk_widget_add_css_class (GTK_WIDGET (self), "view");
}
/**

View File

@ -3573,12 +3573,15 @@ static void
gtk_label_unrealize (GtkWidget *widget)
{
GtkLabel *self = GTK_LABEL (widget);
GdkClipboard *clipboard;
clipboard = gtk_widget_get_primary_clipboard (widget);
if (self->select_info &&
gdk_clipboard_get_content (clipboard) == self->select_info->provider)
gdk_clipboard_set_content (clipboard, NULL);
self->select_info->provider)
{
GdkClipboard *clipboard = gtk_widget_get_primary_clipboard (widget);
if (gdk_clipboard_get_content (clipboard) == self->select_info->provider)
gdk_clipboard_set_content (clipboard, NULL);
}
GTK_WIDGET_CLASS (gtk_label_parent_class)->unrealize (widget);
}

View File

@ -925,6 +925,8 @@ gtk_list_view_init (GtkListView *self)
gtk_list_base_set_anchor_max_widgets (GTK_LIST_BASE (self),
GTK_LIST_VIEW_MAX_LIST_ITEMS,
GTK_LIST_VIEW_EXTRA_ITEMS);
gtk_widget_add_css_class (GTK_WIDGET (self), "view");
}
/**

View File

@ -250,16 +250,6 @@ G_DEFINE_TYPE_WITH_CODE (GtkRange, gtk_range, GTK_TYPE_WIDGET,
static guint signals[LAST_SIGNAL];
static GParamSpec *properties[LAST_PROP];
static void
gtk_range_snapshot (GtkWidget *widget,
GtkSnapshot *snapshot)
{
GtkRange *range = GTK_RANGE (widget);
GtkRangePrivate *priv = gtk_range_get_instance_private (range);
gtk_widget_snapshot_child (widget, priv->trough_widget, snapshot);
}
static void
gtk_range_class_init (GtkRangeClass *class)
{
@ -275,7 +265,6 @@ gtk_range_class_init (GtkRangeClass *class)
gobject_class->dispose = gtk_range_dispose;
widget_class->measure = gtk_range_measure;
widget_class->snapshot = gtk_range_snapshot;
widget_class->size_allocate = gtk_range_size_allocate;
widget_class->unmap = gtk_range_unmap;
widget_class->direction_changed = gtk_range_direction_changed;

View File

@ -47,14 +47,12 @@ static void
gtk_theming_background_snapshot_color (GtkCssBoxes *boxes,
GtkSnapshot *snapshot,
const GdkRGBA *bg_color,
const GtkCssValue *background_image)
guint n_bg_values)
{
const GskRoundedRect *box;
gint n_values;
GtkCssArea clip;
n_values = _gtk_css_array_value_get_n_values (background_image);
clip = _gtk_css_area_value_get (_gtk_css_array_value_get_nth (boxes->style->background->background_clip, n_values - 1));
clip = _gtk_css_area_value_get (_gtk_css_array_value_get_nth (boxes->style->background->background_clip, n_bg_values - 1));
box = gtk_css_boxes_get_box (boxes, clip);
if (gsk_rounded_rect_is_rectilinear (box))
@ -94,9 +92,6 @@ gtk_theming_background_snapshot_layer (GtkCssBoxes *bg,
pos = _gtk_css_array_value_get_nth (background->background_position, idx);
repeat = _gtk_css_array_value_get_nth (background->background_repeat, idx);
hrepeat = _gtk_css_background_repeat_value_get_x (repeat);
vrepeat = _gtk_css_background_repeat_value_get_y (repeat);
origin = gtk_css_boxes_get_box (bg,
_gtk_css_area_value_get (
@ -125,8 +120,13 @@ gtk_theming_background_snapshot_layer (GtkCssBoxes *bg,
/* optimization */
if (image_width == width)
hrepeat = GTK_CSS_REPEAT_STYLE_NO_REPEAT;
else
hrepeat = _gtk_css_background_repeat_value_get_x (repeat);
if (image_height == height)
vrepeat = GTK_CSS_REPEAT_STYLE_NO_REPEAT;
else
vrepeat = _gtk_css_background_repeat_value_get_y (repeat);
gtk_snapshot_push_debug (snapshot, "Layer %u", idx);
gtk_snapshot_push_rounded_clip (snapshot, clip);
@ -262,7 +262,8 @@ gtk_css_style_snapshot_background (GtkCssBoxes *boxes,
gboolean has_bg_color;
gboolean has_bg_image;
gboolean has_shadow;
gint idx;
int idx;
guint number_of_layers;
if (background->base.type == GTK_CSS_BACKGROUND_INITIAL_VALUES)
return;
@ -286,10 +287,11 @@ gtk_css_style_snapshot_background (GtkCssBoxes *boxes,
snapshot,
gtk_css_boxes_get_border_box (boxes));
number_of_layers = _gtk_css_array_value_get_n_values (background_image);
if (has_bg_image)
{
GtkCssValue *blend_modes = background->background_blend_mode;
const int number_of_layers = _gtk_css_array_value_get_n_values (background_image);
GskBlendMode *blend_mode_values = g_alloca (sizeof (GskBlendMode) * number_of_layers);
for (idx = number_of_layers - 1; idx >= 0; idx--)
@ -301,7 +303,7 @@ gtk_css_style_snapshot_background (GtkCssBoxes *boxes,
}
if (has_bg_color)
gtk_theming_background_snapshot_color (boxes, snapshot, bg_color, background_image);
gtk_theming_background_snapshot_color (boxes, snapshot, bg_color, number_of_layers);
for (idx = number_of_layers - 1; idx >= 0; idx--)
{
@ -319,7 +321,7 @@ gtk_css_style_snapshot_background (GtkCssBoxes *boxes,
}
else if (has_bg_color)
{
gtk_theming_background_snapshot_color (boxes, snapshot, bg_color, background_image);
gtk_theming_background_snapshot_color (boxes, snapshot, bg_color, number_of_layers);
}
if (has_shadow)

View File

@ -79,22 +79,23 @@
*
* |[<!-- language="plain" -->
* scale[.fine-tune][.marks-before][.marks-after]
* [value][.top][.right][.bottom][.left]
* marks.top
* mark
* [label]
* indicator
*
* mark
* [value][.top][.right][.bottom][.left]
* trough
* [fill]
* [highlight]
* slider
* marks.bottom
* mark
* indicator
* [label]
* mark
* marks.bottom
* mark
* indicator
* [label]
*
* mark
* trough
* [fill]
* [highlight]
* slider
* ]|
*
* GtkScale has a main CSS node with name scale and a subnode for its contents,
@ -197,8 +198,6 @@ static void gtk_scale_measure (GtkWidget *widget,
static void gtk_scale_get_range_border (GtkRange *range,
GtkBorder *border);
static void gtk_scale_finalize (GObject *object);
static void gtk_scale_snapshot (GtkWidget *widget,
GtkSnapshot *snapshot);
static void gtk_scale_real_get_layout_offsets (GtkScale *scale,
gint *x,
gint *y);
@ -661,7 +660,6 @@ gtk_scale_class_init (GtkScaleClass *class)
gobject_class->notify = gtk_scale_notify;
gobject_class->finalize = gtk_scale_finalize;
widget_class->snapshot = gtk_scale_snapshot;
widget_class->size_allocate = gtk_scale_size_allocate;
widget_class->measure = gtk_scale_measure;
widget_class->grab_focus = gtk_widget_grab_focus_self;
@ -1093,14 +1091,9 @@ gtk_scale_set_draw_value (GtkScale *scale,
"css-name", "value",
"label", txt,
NULL);
g_free (txt);
if (priv->value_pos == GTK_POS_TOP || priv->value_pos == GTK_POS_LEFT)
gtk_widget_insert_after (priv->value_widget, GTK_WIDGET (scale), NULL);
else
gtk_widget_insert_before (priv->value_widget, GTK_WIDGET (scale), NULL);
gtk_widget_insert_after (priv->value_widget, GTK_WIDGET (scale), NULL);
gtk_range_set_round_digits (GTK_RANGE (scale), priv->digits);
update_value_position (scale);
update_label_request (scale);
@ -1469,25 +1462,6 @@ gtk_scale_measure (GtkWidget *widget,
}
}
static void
gtk_scale_snapshot (GtkWidget *widget,
GtkSnapshot *snapshot)
{
GtkScale *scale = GTK_SCALE (widget);
GtkScalePrivate *priv = gtk_scale_get_instance_private (scale);
if (priv->top_marks_widget)
gtk_widget_snapshot_child (widget, priv->top_marks_widget, snapshot);
if (priv->bottom_marks_widget)
gtk_widget_snapshot_child (widget, priv->bottom_marks_widget, snapshot);
if (priv->value_widget)
gtk_widget_snapshot_child (widget, priv->value_widget, snapshot);
GTK_WIDGET_CLASS (gtk_scale_parent_class)->snapshot (widget, snapshot);
}
static void
gtk_scale_real_get_layout_offsets (GtkScale *scale,
gint *x,
@ -1722,9 +1696,7 @@ gtk_scale_add_mark (GtkScale *scale,
gtk_widget_insert_after (priv->top_marks_widget,
GTK_WIDGET (scale),
(priv->value_widget &&
(priv->value_pos == GTK_POS_TOP || priv->value_pos == GTK_POS_LEFT)) ?
priv->value_widget : NULL);
priv->value_widget);
gtk_widget_add_css_class (priv->top_marks_widget, GTK_STYLE_CLASS_TOP);
}
marks_widget = priv->top_marks_widget;
@ -1742,9 +1714,7 @@ gtk_scale_add_mark (GtkScale *scale,
gtk_widget_insert_before (priv->bottom_marks_widget,
GTK_WIDGET (scale),
(priv->value_widget &&
(priv->value_pos == GTK_POS_BOTTOM || priv->value_pos == GTK_POS_RIGHT)) ?
priv->value_widget: NULL);
gtk_range_get_trough_widget (GTK_RANGE (scale)));
gtk_widget_add_css_class (priv->bottom_marks_widget, GTK_STYLE_CLASS_BOTTOM);
}
marks_widget = priv->bottom_marks_widget;

View File

@ -143,7 +143,6 @@
#define SCREEN_HEIGHT(widget) text_window_get_height (GTK_TEXT_VIEW (widget)->priv->text_window)
#define SPACE_FOR_CURSOR 1
#define CURSOR_ASPECT_RATIO (0.04)
typedef struct _GtkTextWindow GtkTextWindow;
typedef struct _GtkTextPendingScroll GtkTextPendingScroll;

View File

@ -7377,14 +7377,14 @@ static void
gtk_widget_real_realize (GtkWidget *widget)
{
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
GdkFrameClock *frame_clock;
priv->realized = TRUE;
/* Connect frame clock */
frame_clock = gtk_widget_get_frame_clock (widget);
if (priv->tick_callbacks != NULL && !priv->clock_tick_id)
{
GdkFrameClock *frame_clock = gtk_widget_get_frame_clock (widget);
priv->clock_tick_id = g_signal_connect (frame_clock, "update",
G_CALLBACK (gtk_widget_on_frame_clock_update),
widget);

View File

@ -385,8 +385,6 @@ recordings_list_row_selected (GtkListBox *box,
(gpointer[1]) { paintable },
1);
g_object_unref (paintable);
g_print ("%u render nodes\n", g_list_model_get_n_items (G_LIST_MODEL (priv->render_node_model)));
}
else
{
@ -405,9 +403,9 @@ get_color_texture (const GdkRGBA *color)
guchar pixel[4];
guchar *data;
GBytes *bytes;
gint width = 30;
gint height = 30;
gint i;
int width = 30;
int height = 30;
int i;
pixel[0] = round (color->red * 255);
pixel[1] = round (color->green * 255);
@ -950,7 +948,7 @@ render_node_list_selection_changed (GtkListBox *list,
static void
render_node_save_response (GtkWidget *dialog,
gint response,
int response,
GskRenderNode *node)
{
gtk_widget_hide (dialog);
@ -1019,83 +1017,33 @@ render_node_save (GtkButton *button,
gtk_widget_show (dialog);
}
static char *
format_timespan (gint64 timespan)
{
if (ABS (timespan) < G_TIME_SPAN_MILLISECOND)
return g_strdup_printf ("%fus", (double) timespan);
else if (ABS (timespan) < 10 * G_TIME_SPAN_MILLISECOND)
return g_strdup_printf ("%.1fs", (double) timespan / G_TIME_SPAN_MILLISECOND);
else if (ABS (timespan) < G_TIME_SPAN_SECOND)
return g_strdup_printf ("%.0fms", (double) timespan / G_TIME_SPAN_MILLISECOND);
else if (ABS (timespan) < 10 * G_TIME_SPAN_SECOND)
return g_strdup_printf ("%.1fs", (double) timespan / G_TIME_SPAN_SECOND);
else
return g_strdup_printf ("%.0fs", (double) timespan / G_TIME_SPAN_SECOND);
}
static GtkWidget *
gtk_inspector_recorder_recordings_list_create_widget (gpointer item,
gpointer user_data)
{
GtkInspectorRecorder *recorder = GTK_INSPECTOR_RECORDER (user_data);
GtkInspectorRecorderPrivate *priv = gtk_inspector_recorder_get_instance_private (recorder);
GtkInspectorRecording *recording = GTK_INSPECTOR_RECORDING (item);
GtkWidget *widget;
if (GTK_INSPECTOR_IS_RENDER_RECORDING (recording))
{
GtkInspectorRecording *previous = NULL;
char *time_str, *str;
const char *render_str;
cairo_region_t *region;
GtkWidget *hbox, *label, *button;
guint i;
widget = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
gtk_box_append (GTK_BOX (widget), hbox);
for (i = 0; i < g_list_model_get_n_items (priv->recordings); i++)
{
GtkInspectorRecording *r = g_list_model_get_item (priv->recordings, i);
g_object_unref (r);
if (r == recording)
break;
if (GTK_INSPECTOR_IS_RENDER_RECORDING (r))
previous = r;
else if (GTK_INSPECTOR_IS_START_RECORDING (r))
previous = NULL;
}
region = cairo_region_create_rectangle (
gtk_inspector_render_recording_get_area (GTK_INSPECTOR_RENDER_RECORDING (recording)));
cairo_region_subtract (region,
gtk_inspector_render_recording_get_clip_region (GTK_INSPECTOR_RENDER_RECORDING (recording)));
if (cairo_region_is_empty (region))
render_str = "Full Render";
else
render_str = "Partial Render";
cairo_region_destroy (region);
if (previous)
{
time_str = format_timespan (gtk_inspector_recording_get_timestamp (recording) -
gtk_inspector_recording_get_timestamp (previous));
str = g_strdup_printf ("<b>%s</b>\n+%s", render_str, time_str);
g_free (time_str);
}
else
{
str = g_strdup_printf ("<b>%s</b>\n", render_str);
}
label = gtk_label_new (str);
label = gtk_label_new ("<b>Frame</b>");
gtk_label_set_xalign (GTK_LABEL (label), 0.0f);
gtk_widget_set_hexpand (label, TRUE);
gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
g_free (str);
gtk_box_append (GTK_BOX (hbox), label);
button = gtk_toggle_button_new ();
@ -1311,24 +1259,8 @@ gtk_inspector_recorder_add_recording (GtkInspectorRecorder *recorder,
GtkInspectorRecording *recording)
{
GtkInspectorRecorderPrivate *priv = gtk_inspector_recorder_get_instance_private (recorder);
guint count;
GtkListBoxRow *selected_row;
gboolean should_select_new_row;
count = g_list_model_get_n_items (priv->recordings);
selected_row = gtk_list_box_get_selected_row (GTK_LIST_BOX (priv->recordings_list));
if (count == 0 || selected_row == NULL)
should_select_new_row = TRUE;
else
should_select_new_row = (gtk_list_box_row_get_index (selected_row) == count - 1);
g_list_store_append (G_LIST_STORE (priv->recordings), recording);
if (should_select_new_row)
{
gtk_list_box_select_row (GTK_LIST_BOX (priv->recordings_list),
gtk_list_box_get_row_at_index (GTK_LIST_BOX (priv->recordings_list), count));
}
}
void

View File

@ -35,17 +35,14 @@ window.background:dir(ltr)
mark:dir(ltr)
label:dir(ltr)
indicator:dir(ltr)
trough:dir(ltr)
highlight.top:dir(ltr)
slider:dir(ltr)
marks.bottom:dir(ltr)
mark:dir(ltr)
indicator:dir(ltr)
label:dir(ltr)
trough:dir(ltr)
highlight.top:dir(ltr)
slider:dir(ltr)
scale.horizontal.marks-after:dir(ltr)
trough:dir(ltr)
highlight.top:dir(ltr)
slider:dir(ltr)
marks.bottom:dir(ltr)
mark:dir(ltr)
indicator:dir(ltr)
@ -53,3 +50,6 @@ window.background:dir(ltr)
mark:dir(ltr)
indicator:dir(ltr)
label:dir(ltr)
trough:dir(ltr)
highlight.top:dir(ltr)
slider:dir(ltr)