summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2015-06-30 05:15:34 +0200
committerBenjamin Otte <otte@redhat.com>2015-07-01 06:00:49 +0200
commit84144393bcf403a5645bd5a92a2feea63894c59d (patch)
tree6cc3d390e355879b17e5ae37c11d3e70fc13f004
parentb8accdcd0ac35b1bd36f5049fd6ecafc9c409e61 (diff)
downloadgtk+-84144393bcf403a5645bd5a92a2feea63894c59d.tar.gz
inspector: Handle border rendering in snapshots
-rw-r--r--gtk/inspector/Makefile.inc14
-rw-r--r--gtk/inspector/gtkrenderoperationborder.c127
-rw-r--r--gtk/inspector/gtkrenderoperationborder.h69
-rw-r--r--gtk/inspector/recordingrenderops.c26
4 files changed, 229 insertions, 7 deletions
diff --git a/gtk/inspector/Makefile.inc b/gtk/inspector/Makefile.inc
index fff61880ad..9407306bd4 100644
--- a/gtk/inspector/Makefile.inc
+++ b/gtk/inspector/Makefile.inc
@@ -10,9 +10,10 @@ inspector_c_sources = \
inspector/gestures.c \
inspector/graphdata.c \
inspector/gtkrenderoperation.c \
- inspector/gtkrenderoperationbackground.c \
- inspector/gtkrenderoperationcairo.c \
- inspector/gtkrenderoperationwidget.c \
+ inspector/gtkrenderoperationbackground.c \
+ inspector/gtkrenderoperationborder.c \
+ inspector/gtkrenderoperationcairo.c \
+ inspector/gtkrenderoperationwidget.c \
inspector/gtktreemodelcssnode.c \
inspector/init.c \
inspector/inspect-button.c \
@@ -47,9 +48,10 @@ inspector_h_sources = \
inspector/gestures.h \
inspector/graphdata.h \
inspector/gtkrenderoperation.h \
- inspector/gtkrenderoperationbackground.h \
- inspector/gtkrenderoperationcairo.h \
- inspector/gtkrenderoperationwidget.h \
+ inspector/gtkrenderoperationbackground.h \
+ inspector/gtkrenderoperationborder.h \
+ inspector/gtkrenderoperationcairo.h \
+ inspector/gtkrenderoperationwidget.h \
inspector/gtktreemodelcssnode.h \
inspector/init.h \
inspector/magnifier.h \
diff --git a/gtk/inspector/gtkrenderoperationborder.c b/gtk/inspector/gtkrenderoperationborder.c
new file mode 100644
index 0000000000..e6cad084d4
--- /dev/null
+++ b/gtk/inspector/gtkrenderoperationborder.c
@@ -0,0 +1,127 @@
+/*
+ * Copyright © 2015 Benjamin Otte <otte@gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors: Benjamin Otte <otte@gnome.org>
+ */
+
+#include "config.h"
+
+#include "gtkrenderoperationborder.h"
+
+#include <math.h>
+
+#include "gtkcssstyleprivate.h"
+#include "gtkrenderborderprivate.h"
+
+G_DEFINE_TYPE (GtkRenderOperationBorder, gtk_render_operation_border, GTK_TYPE_RENDER_OPERATION)
+
+static void
+gtk_render_operation_border_get_clip (GtkRenderOperation *operation,
+ cairo_rectangle_int_t *clip)
+{
+ GtkRenderOperationBorder *oper = GTK_RENDER_OPERATION_BORDER (operation);
+
+ clip->x = 0;
+ clip->y = 0;
+ clip->width = ceil (oper->width);
+ clip->height = ceil (oper->height);
+}
+
+static void
+gtk_render_operation_border_get_matrix (GtkRenderOperation *operation,
+ cairo_matrix_t *matrix)
+{
+ GtkRenderOperationBorder *oper = GTK_RENDER_OPERATION_BORDER (operation);
+
+ cairo_matrix_init_translate (matrix, oper->x, oper->y);
+}
+
+static char *
+gtk_render_operation_border_describe (GtkRenderOperation *operation)
+{
+ return g_strdup ("CSS border");
+}
+
+static void
+gtk_render_operation_border_draw (GtkRenderOperation *operation,
+ cairo_t *cr)
+{
+ GtkRenderOperationBorder *oper = GTK_RENDER_OPERATION_BORDER (operation);
+
+ gtk_css_style_render_border (oper->style,
+ cr,
+ 0, 0,
+ oper->width,
+ oper->height,
+ oper->hidden_side,
+ oper->junction);
+}
+
+static void
+gtk_render_operation_border_finalize (GObject *object)
+{
+ GtkRenderOperationBorder *oper = GTK_RENDER_OPERATION_BORDER (object);
+
+ g_object_unref (oper->style);
+
+ G_OBJECT_CLASS (gtk_render_operation_border_parent_class)->finalize (object);
+}
+
+static void
+gtk_render_operation_border_class_init (GtkRenderOperationBorderClass *klass)
+{
+ GtkRenderOperationClass *operation_class = GTK_RENDER_OPERATION_CLASS (klass);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = gtk_render_operation_border_finalize;
+
+ operation_class->get_clip = gtk_render_operation_border_get_clip;
+ operation_class->get_matrix = gtk_render_operation_border_get_matrix;
+ operation_class->describe = gtk_render_operation_border_describe;
+ operation_class->draw = gtk_render_operation_border_draw;
+}
+
+static void
+gtk_render_operation_border_init (GtkRenderOperationBorder *image)
+{
+}
+
+GtkRenderOperation *
+gtk_render_operation_border_new (GtkCssStyle *style,
+ double x,
+ double y,
+ double width,
+ double height,
+ guint hidden_side,
+ GtkJunctionSides junction)
+{
+ GtkRenderOperationBorder *result;
+
+ g_return_val_if_fail (GTK_IS_CSS_STYLE (style), NULL);
+
+ result = g_object_new (GTK_TYPE_RENDER_OPERATION_BORDER, NULL);
+
+ result->style = g_object_ref (style);
+ result->x = x;
+ result->y = y;
+ result->width = width;
+ result->height = height;
+ result->hidden_side = hidden_side;
+ result->junction = junction;
+
+ return GTK_RENDER_OPERATION (result);
+}
+
diff --git a/gtk/inspector/gtkrenderoperationborder.h b/gtk/inspector/gtkrenderoperationborder.h
new file mode 100644
index 0000000000..da1b301a51
--- /dev/null
+++ b/gtk/inspector/gtkrenderoperationborder.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright © 2015 Red Hat Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors: Benjamin Otte <otte@gnome.org>
+ */
+
+#ifndef __GTK_RENDER_OPERATION_BORDER_PRIVATE_H__
+#define __GTK_RENDER_OPERATION_BORDER_PRIVATE_H__
+
+#include "gtkrenderoperation.h"
+
+#include "gtkcsstypesprivate.h"
+
+G_BEGIN_DECLS
+
+#define GTK_TYPE_RENDER_OPERATION_BORDER (gtk_render_operation_border_get_type ())
+#define GTK_RENDER_OPERATION_BORDER(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj, GTK_TYPE_RENDER_OPERATION_BORDER, GtkRenderOperationBorder))
+#define GTK_RENDER_OPERATION_BORDER_CLASS(cls) (G_TYPE_CHECK_CLASS_CAST (cls, GTK_TYPE_RENDER_OPERATION_BORDER, GtkRenderOperationBorderClass))
+#define GTK_IS_RENDER_OPERATION_BORDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, GTK_TYPE_RENDER_OPERATION_BORDER))
+#define GTK_IS_RENDER_OPERATION_BORDER_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE (obj, GTK_TYPE_RENDER_OPERATION_BORDER))
+#define GTK_RENDER_OPERATION_BORDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_RENDER_OPERATION_BORDER, GtkRenderOperationBorderClass))
+
+typedef struct _GtkRenderOperationBorder GtkRenderOperationBorder;
+typedef struct _GtkRenderOperationBorderClass GtkRenderOperationBorderClass;
+
+struct _GtkRenderOperationBorder
+{
+ GtkRenderOperation parent;
+
+ GtkCssStyle *style;
+ double x;
+ double y;
+ double width;
+ double height;
+ guint hidden_side;
+ GtkJunctionSides junction;
+};
+
+struct _GtkRenderOperationBorderClass
+{
+ GtkRenderOperationClass parent_class;
+};
+
+GType gtk_render_operation_border_get_type (void) G_GNUC_CONST;
+
+GtkRenderOperation * gtk_render_operation_border_new (GtkCssStyle *style,
+ double x,
+ double y,
+ double width,
+ double height,
+ guint hidden_side,
+ GtkJunctionSides junction);
+
+G_END_DECLS
+
+#endif /* __GTK_RENDER_OPERATION_BORDER_PRIVATE_H__ */
diff --git a/gtk/inspector/recordingrenderops.c b/gtk/inspector/recordingrenderops.c
index d3ad89875b..3bf8e9c47a 100644
--- a/gtk/inspector/recordingrenderops.c
+++ b/gtk/inspector/recordingrenderops.c
@@ -22,6 +22,7 @@
#include "recordingrenderops.h"
#include "gtkrenderoperationbackground.h"
+#include "gtkrenderoperationborder.h"
#include "gtkrenderoperationcairo.h"
#include "gtkrenderoperationwidget.h"
#include "gtkwidget.h"
@@ -120,6 +121,27 @@ gtk_recording_render_ops_draw_background (GtkRenderOps *ops,
g_object_unref (oper);
}
+static void
+gtk_recording_render_ops_draw_border (GtkRenderOps *ops,
+ GtkCssStyle *style,
+ cairo_t *cr,
+ gdouble x,
+ gdouble y,
+ gdouble width,
+ gdouble height,
+ guint hidden_side,
+ GtkJunctionSides junction)
+{
+ GtkRecordingRenderOps *record = GTK_RECORDING_RENDER_OPS (ops);
+ GtkRenderOperation *oper;
+
+ gtk_recording_render_ops_save_snapshot (record, cr);
+
+ oper = gtk_render_operation_border_new (style, x, y, width, height, hidden_side, junction);
+ gtk_render_operation_widget_add_operation (record->widgets->data, oper);
+ g_object_unref (oper);
+}
+
static cairo_t *
gtk_recording_render_ops_begin_draw_widget (GtkRenderOps *ops,
GtkWidget *widget,
@@ -129,7 +151,8 @@ gtk_recording_render_ops_begin_draw_widget (GtkRenderOps *ops,
GtkRenderOperation *oper;
cairo_matrix_t matrix;
- gtk_recording_render_ops_save_snapshot (record, cr);
+ if (record->widgets)
+ gtk_recording_render_ops_save_snapshot (record, cr);
g_print ("begin drawing widget %s\n", gtk_widget_get_name (widget));
@@ -173,6 +196,7 @@ gtk_recording_render_ops_class_init (GtkRecordingRenderOpsClass *klass)
ops_class->begin_draw_widget = gtk_recording_render_ops_begin_draw_widget;
ops_class->end_draw_widget = gtk_recording_render_ops_end_draw_widget;
ops_class->draw_background = gtk_recording_render_ops_draw_background;
+ ops_class->draw_border = gtk_recording_render_ops_draw_border;
}
static void