diff mbox

[i-g-t,12/16] plot: Add a way to draw debug hints to help layouting

Message ID 1436186144-19665-13-git-send-email-damien.lespiau@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Lespiau, Damien July 6, 2015, 12:35 p.m. UTC
Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
---
 lib/igt_plot.c | 16 +++++++++++++++-
 lib/igt_plot.h |  1 +
 2 files changed, 16 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/lib/igt_plot.c b/lib/igt_plot.c
index 2ca005e..763c000 100644
--- a/lib/igt_plot.c
+++ b/lib/igt_plot.c
@@ -443,7 +443,12 @@  static double plot_length(igt_plot_t *plot, double percent)
 static void
 igt_plot_draw_text(igt_plot_t *plot, double x, double y, igt_label_t *label)
 {
-	/* XXX: bearings? */
+	if (plot->debug) {
+		cairo_set_source_rgb(plot->cr, 1.0, 0.0, 0.0);
+		cairo_move_to(plot->cr, x, y);
+		cairo_arc(plot->cr, x, y, 2.0, 0, 2 * M_PI);
+		cairo_fill(plot->cr);
+	}
 
 	switch (label->halign) {
 	case IGT_ALIGN_LEFT:
@@ -469,6 +474,15 @@  igt_plot_draw_text(igt_plot_t *plot, double x, double y, igt_label_t *label)
 		break;
 	}
 
+	if (plot->debug) {
+		cairo_set_source_rgb(plot->cr, 1.0, 0.0, 0.0);
+		cairo_move_to(plot->cr, x, y);
+		cairo_rectangle(plot->cr, x, y,
+				label->extents.width, -label->extents.height);
+		cairo_stroke(plot->cr);
+	}
+
+	cairo_set_source_rgb(plot->cr, 0.0, 0.0, 0.0);
 	cairo_move_to(plot->cr, x, y);
 	cairo_show_text(plot->cr, label->text);
 }
diff --git a/lib/igt_plot.h b/lib/igt_plot.h
index cca498a..49d5819 100644
--- a/lib/igt_plot.h
+++ b/lib/igt_plot.h
@@ -102,6 +102,7 @@  typedef struct {
 	cairo_t *cr;
 
 	/* plot-wide states */
+	int debug;
 	unsigned int width, height;
 	char *title;
 	igt_trbl_t margin;