diff mbox

[i-g-t,10/16] plot: Make sure to have a color in the background

Message ID 1436186144-19665-11-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
Until now we had transparent black.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
---
 lib/igt_plot.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/lib/igt_plot.c b/lib/igt_plot.c
index c8d6dcb..afe4a1c 100644
--- a/lib/igt_plot.c
+++ b/lib/igt_plot.c
@@ -452,6 +452,24 @@  igt_plot_draw_text(igt_plot_t *plot, double x, double y, igt_label_t *label)
 	cairo_show_text(plot->cr, label->text);
 }
 
+static void igt_plot_draw_background(igt_plot_t *plot, flush_t *flush)
+{
+	igt_box_t *area = &flush->plot_area;
+	double area_width, area_height;
+
+	area_width = area->x2 - area->x1;
+	area_height = area->y2 - area->y1;
+
+	cairo_set_source_rgb(plot->cr, 1.0, 1.0, 1.0);
+	cairo_rectangle(plot->cr, 0.0, 0.0, plot->width, plot->height);
+	cairo_fill(plot->cr);
+
+	cairo_set_source_rgb(plot->cr, 0.99, 0.99, 0.99);
+	cairo_rectangle(plot->cr, SNAP(area->x1), SNAP(area->y1),
+			area_width, area_height);
+	cairo_fill(plot->cr);
+}
+
 static void igt_plot_draw_grid(igt_plot_t *plot, flush_t *flush)
 {
 	unsigned int i, n_ticks;
@@ -701,8 +719,8 @@  void igt_plot_write(igt_plot_t *plot, const char *filename)
 
 	igt_plot_layout(plot, &flush);
 
+	igt_plot_draw_background(plot, &flush);
 	igt_plot_draw_axis(plot, &flush);
-
 	for (i = 0; i < plot->n_valid_contexts; i++)
 		igt_plot_draw_one(plot, &plot->contexts[i], &flush);