[gtk+/wip/ebassi/gsk-renderer: 125/135] Convert GtkFlowBox to indirect rendering
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/ebassi/gsk-renderer: 125/135] Convert GtkFlowBox to indirect rendering
- Date: Mon, 17 Oct 2016 16:32:24 +0000 (UTC)
commit 59f95e1e1feea1f98b604df18da27d03abf7e95a
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Aug 18 02:39:08 2016 -0400
Convert GtkFlowBox to indirect rendering
gtk/gtkflowbox.c | 90 ++++++++++++++++++++++++------------------------------
1 files changed, 40 insertions(+), 50 deletions(-)
---
diff --git a/gtk/gtkflowbox.c b/gtk/gtkflowbox.c
index b3a914b..16dac76 100644
--- a/gtk/gtkflowbox.c
+++ b/gtk/gtkflowbox.c
@@ -382,31 +382,21 @@ gtk_flow_box_child_activate (GtkFlowBoxChild *child)
gtk_flow_box_select_and_activate (box, child);
}
-static gboolean
-gtk_flow_box_child_draw (GtkWidget *widget,
- cairo_t *cr)
+static GskRenderNode *
+gtk_flow_box_child_get_render_node (GtkWidget *widget,
+ GskRenderer *renderer)
{
- gtk_css_gadget_draw (CHILD_PRIV (GTK_FLOW_BOX_CHILD (widget))->gadget, cr);
-
- return FALSE;
-}
+ GtkFlowBoxChildPrivate *priv = CHILD_PRIV (widget);
+ GskRenderNode *res = gtk_css_gadget_get_render_node (priv->gadget,
+ renderer,
+ gtk_widget_has_visible_focus (widget));
-static gboolean
-gtk_flow_box_child_render (GtkCssGadget *gadget,
- cairo_t *cr,
- int x,
- int y,
- int width,
- int height,
- gpointer data)
-{
- GtkWidget *widget;
-
- widget = gtk_css_gadget_get_owner (gadget);
+ if (res == NULL)
+ return NULL;
- GTK_WIDGET_CLASS (gtk_flow_box_child_parent_class)->draw (widget, cr);
+ gtk_container_propagate_render_node (GTK_CONTAINER (widget), renderer, res);
- return gtk_widget_has_visible_focus (widget);
+ return res;
}
/* Size allocation {{{3 */
@@ -595,7 +585,7 @@ gtk_flow_box_child_class_init (GtkFlowBoxChildClass *class)
object_class->finalize = gtk_flow_box_child_finalize;
- widget_class->draw = gtk_flow_box_child_draw;
+ widget_class->get_render_node = gtk_flow_box_child_get_render_node;
widget_class->get_request_mode = gtk_flow_box_child_get_request_mode;
widget_class->get_preferred_height = gtk_flow_box_child_get_preferred_height;
widget_class->get_preferred_height_for_width = gtk_flow_box_child_get_preferred_height_for_width;
@@ -642,7 +632,7 @@ gtk_flow_box_child_init (GtkFlowBoxChild *child)
GTK_WIDGET (child),
gtk_flow_box_child_measure,
gtk_flow_box_child_allocate,
- gtk_flow_box_child_render,
+ NULL,
NULL,
NULL);
}
@@ -2627,43 +2617,36 @@ gtk_flow_box_measure (GtkCssGadget *gadget,
/* Drawing {{{3 */
-static gboolean
-gtk_flow_box_draw (GtkWidget *widget,
- cairo_t *cr)
-{
- gtk_css_gadget_draw (BOX_PRIV (widget)->gadget, cr);
-
- return FALSE;
-}
-
-static gboolean
-gtk_flow_box_render (GtkCssGadget *gadget,
- cairo_t *cr,
- int x,
- int y,
- int width,
- int height,
- gpointer data)
+static GskRenderNode *
+gtk_flow_box_get_render_node (GtkWidget *widget,
+ GskRenderer *renderer)
{
- GtkWidget *widget = gtk_css_gadget_get_owner (gadget);
GtkFlowBox *box = GTK_FLOW_BOX (widget);
GtkFlowBoxPrivate *priv = BOX_PRIV (box);
+ GskRenderNode *res = gtk_css_gadget_get_render_node (priv->gadget,
+ renderer,
+ gtk_widget_has_visible_focus (widget));
- GTK_WIDGET_CLASS (gtk_flow_box_parent_class)->draw (widget, cr);
+ if (res == NULL)
+ return NULL;
+
+ gtk_container_propagate_render_node (GTK_CONTAINER (widget), renderer, res);
if (priv->rubberband_first && priv->rubberband_last)
{
+ GskRenderNode *node;
+ cairo_t *cr;
GtkStyleContext *context;
GSequenceIter *iter, *iter1, *iter2;
GdkRectangle line_rect, rect;
GArray *lines;
gboolean vertical;
- context = gtk_widget_get_style_context (GTK_WIDGET (box));
+ node = gtk_widget_create_render_node (widget, renderer, "FlowBox RubberBand");
- vertical = priv->orientation == GTK_ORIENTATION_VERTICAL;
+ cr = gsk_render_node_get_draw_context (node);
- cairo_save (cr);
+ vertical = priv->orientation == GTK_ORIENTATION_VERTICAL;
context = gtk_widget_get_style_context (widget);
gtk_style_context_save_to_node (context, priv->rubberband_node);
@@ -2728,7 +2711,10 @@ gtk_flow_box_render (GtkCssGadget *gadget,
cairo_save (cr);
cairo_clip (cr);
- gtk_render_background (context, cr, x, y, width, height);
+ gtk_render_background (context, cr,
+ 0, 0,
+ gtk_widget_get_allocated_width (widget),
+ gtk_widget_get_allocated_height (widget));
cairo_restore (cr);
cairo_append_path (cr, path);
@@ -2746,10 +2732,14 @@ G_GNUC_END_IGNORE_DEPRECATIONS
g_array_free (lines, TRUE);
gtk_style_context_restore (context);
- cairo_restore (cr);
+
+ cairo_destroy (cr);
+
+ gsk_render_node_append_child (res, node);
+ gsk_render_node_unref (node);
}
- return gtk_widget_has_visible_focus (widget);
+ return res;
}
/* Autoscrolling {{{3 */
@@ -3786,7 +3776,7 @@ gtk_flow_box_class_init (GtkFlowBoxClass *class)
widget_class->realize = gtk_flow_box_realize;
widget_class->unmap = gtk_flow_box_unmap;
widget_class->focus = gtk_flow_box_focus;
- widget_class->draw = gtk_flow_box_draw;
+ widget_class->get_render_node = gtk_flow_box_get_render_node;
widget_class->key_press_event = gtk_flow_box_key_press_event;
widget_class->get_request_mode = gtk_flow_box_get_request_mode;
widget_class->get_preferred_width = gtk_flow_box_get_preferred_width;
@@ -4148,7 +4138,7 @@ gtk_flow_box_init (GtkFlowBox *box)
GTK_WIDGET (box),
gtk_flow_box_measure,
gtk_flow_box_allocate,
- gtk_flow_box_render,
+ NULL,
NULL,
NULL);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]