Commit df28f921 authored by Matthias Clasen's avatar Matthias Clasen Committed by Emmanuele Bassi

Convert GtkLabel to indirect rendering

Warning! This breaks GtkAccelLabel. It will be fixed in the next
parent 59f95e1e
...@@ -414,11 +414,12 @@ static void gtk_label_size_allocate (GtkWidget *widget, ...@@ -414,11 +414,12 @@ static void gtk_label_size_allocate (GtkWidget *widget,
static void gtk_label_state_flags_changed (GtkWidget *widget, static void gtk_label_state_flags_changed (GtkWidget *widget,
GtkStateFlags prev_state); GtkStateFlags prev_state);
static void gtk_label_style_updated (GtkWidget *widget); static void gtk_label_style_updated (GtkWidget *widget);
static gboolean gtk_label_draw (GtkWidget *widget,
cairo_t *cr);
static gboolean gtk_label_focus (GtkWidget *widget, static gboolean gtk_label_focus (GtkWidget *widget,
GtkDirectionType direction); GtkDirectionType direction);
static GskRenderNode *gtk_label_get_render_node (GtkWidget *label,
GskRenderer *renderer);
static void gtk_label_realize (GtkWidget *widget); static void gtk_label_realize (GtkWidget *widget);
static void gtk_label_unrealize (GtkWidget *widget); static void gtk_label_unrealize (GtkWidget *widget);
static void gtk_label_map (GtkWidget *widget); static void gtk_label_map (GtkWidget *widget);
...@@ -577,13 +578,6 @@ static void gtk_label_measure (GtkCssGadget *gadget, ...@@ -577,13 +578,6 @@ static void gtk_label_measure (GtkCssGadget *gadget,
int *minimum_baseline, int *minimum_baseline,
int *natural_baseline, int *natural_baseline,
gpointer unused); gpointer unused);
static gboolean gtk_label_render (GtkCssGadget *gadget,
cairo_t *cr,
int x,
int y,
int width,
int height,
gpointer data);
static GtkBuildableIface *buildable_parent_iface = NULL; static GtkBuildableIface *buildable_parent_iface = NULL;
...@@ -631,7 +625,7 @@ gtk_label_class_init (GtkLabelClass *class) ...@@ -631,7 +625,7 @@ gtk_label_class_init (GtkLabelClass *class)
widget_class->state_flags_changed = gtk_label_state_flags_changed; widget_class->state_flags_changed = gtk_label_state_flags_changed;
widget_class->style_updated = gtk_label_style_updated; widget_class->style_updated = gtk_label_style_updated;
widget_class->query_tooltip = gtk_label_query_tooltip; widget_class->query_tooltip = gtk_label_query_tooltip;
widget_class->draw = gtk_label_draw; widget_class->get_render_node = gtk_label_get_render_node;
widget_class->realize = gtk_label_realize; widget_class->realize = gtk_label_realize;
widget_class->unrealize = gtk_label_unrealize; widget_class->unrealize = gtk_label_unrealize;
widget_class->map = gtk_label_map; widget_class->map = gtk_label_map;
...@@ -1393,7 +1387,7 @@ gtk_label_init (GtkLabel *label) ...@@ -1393,7 +1387,7 @@ gtk_label_init (GtkLabel *label)
GTK_WIDGET (label), GTK_WIDGET (label),
gtk_label_measure, gtk_label_measure,
gtk_label_render, NULL,
} }
...@@ -4234,39 +4228,41 @@ gtk_label_get_focus_link (GtkLabel *label) ...@@ -4234,39 +4228,41 @@ gtk_label_get_focus_link (GtkLabel *label)
return NULL; return NULL;
} }
static gboolean
gtk_label_draw (GtkWidget *widget,
cairo_t *cr)
gtk_css_gadget_draw (GTK_LABEL (widget)->priv->gadget, cr);
return FALSE;
static void layout_to_window_coords (GtkLabel *label, static void layout_to_window_coords (GtkLabel *label,
gint *x, gint *x,
gint *y); gint *y);
static gboolean static GskRenderNode *
gtk_label_render (GtkCssGadget *gadget, gtk_label_get_render_node (GtkWidget *widget,
cairo_t *cr, GskRenderer *renderer)
int x,
int y,
int width,
int height,
gpointer data)
{ {
GtkWidget *widget; GtkLabel *label = GTK_LABEL (widget);
GtkLabel *label; GtkLabelPrivate *priv = label->priv;
GtkLabelPrivate *priv; GtkLabelSelectionInfo *info = priv->select_info;
GtkLabelSelectionInfo *info;
GtkStyleContext *context; GtkStyleContext *context;
gint x, y, width, height;
gint lx, ly; gint lx, ly;
cairo_t *cr;
GtkAllocation alloc, clip;
GskRenderNode *node;
GskRenderNode *res;
widget = gtk_css_gadget_get_owner (gadget); res = gtk_css_gadget_get_render_node (priv->gadget, renderer, FALSE);
label = GTK_LABEL (widget);
priv = label->priv; if (res == NULL)
info = priv->select_info; return NULL;
node = gtk_widget_create_render_node (widget, renderer, "Label Content");
gtk_widget_get_clip (widget, &clip);
_gtk_widget_get_allocation (widget, &alloc);
cr = gsk_render_node_get_draw_context (node);
cairo_translate (cr, alloc.x - clip.x, alloc.y - clip.y);
x = 0;
y = 0;
width = alloc.width;
height = alloc.height;
gtk_label_ensure_layout (label); gtk_label_ensure_layout (label);
...@@ -4377,7 +4373,12 @@ gtk_label_render (GtkCssGadget *gadget, ...@@ -4377,7 +4373,12 @@ gtk_label_render (GtkCssGadget *gadget,
} }
} }
return FALSE; cairo_destroy (cr);
gsk_render_node_append_child (res, node);
gsk_render_node_unref (node);
return res;
} }
static gboolean static gboolean
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment