All of lore.kernel.org
 help / color / mirror / Atom feed
From: Imre Deak <imre.deak@intel.com>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH v2 3/6] lib: use kmstest_cairo_printf_line in paint_marker
Date: Wed,  5 Jun 2013 22:25:25 +0300	[thread overview]
Message-ID: <1370460328-635-4-git-send-email-imre.deak@intel.com> (raw)
In-Reply-To: <1370460328-635-1-git-send-email-imre.deak@intel.com>

Signed-off-by: Imre Deak <imre.deak@intel.com>
---
 lib/drmtest.c | 64 +++++++++++++----------------------------------------------
 1 file changed, 14 insertions(+), 50 deletions(-)

diff --git a/lib/drmtest.c b/lib/drmtest.c
index 71dd06b..3ad77a8 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -951,46 +951,12 @@ int kmstest_cairo_printf_line(cairo_t *cr, enum kmstest_text_align align,
 	return extents.width;
 }
 
-enum corner {
-	topleft,
-	topright,
-	bottomleft,
-	bottomright,
-};
-
 static void
-paint_marker(cairo_t *cr, int x, int y, char *str, enum corner text_location)
+paint_marker(cairo_t *cr, int x, int y)
 {
-	cairo_text_extents_t extents;
+	enum kmstest_text_align align;
 	int xoff, yoff;
 
-	cairo_set_font_size(cr, 18);
-	cairo_text_extents(cr, str, &extents);
-
-	switch (text_location) {
-	case topleft:
-		xoff = -20;
-		xoff -= extents.width;
-		yoff = -20;
-		break;
-	case topright:
-		xoff = 20;
-		yoff = -20;
-		break;
-	case bottomleft:
-		xoff = -20;
-		xoff -= extents.width;
-		yoff = 20;
-		break;
-	case bottomright:
-		xoff = 20;
-		yoff = 20;
-		break;
-	default:
-		xoff = 0;
-		yoff = 0;
-	}
-
 	cairo_move_to(cr, x, y - 20);
 	cairo_line_to(cr, x, y + 20);
 	cairo_move_to(cr, x - 20, y);
@@ -1004,12 +970,15 @@ paint_marker(cairo_t *cr, int x, int y, char *str, enum corner text_location)
 	cairo_set_line_width(cr, 2);
 	cairo_stroke(cr);
 
+	xoff = x ? -20 : 20;
+	align = x ? align_right : align_left;
+
+	yoff = y ? -20 : 20;
+	align |= y ? align_bottom : align_top;
+
 	cairo_move_to(cr, x + xoff, y + yoff);
-	cairo_text_path(cr, str);
-	cairo_set_source_rgb(cr, 0, 0, 0);
-	cairo_stroke_preserve(cr);
-	cairo_set_source_rgb(cr, 1, 1, 1);
-	cairo_fill(cr);
+	cairo_set_font_size(cr, 18);
+	kmstest_cairo_printf_line(cr, align, 0, "(%d, %d)", x, y);
 }
 
 unsigned int kmstest_create_fb(int fd, int width, int height, int bpp,
@@ -1021,7 +990,6 @@ unsigned int kmstest_create_fb(int fd, int width, int height, int bpp,
 	cairo_surface_t *surface;
 	cairo_status_t status;
 	cairo_t *cr;
-	char buf[128];
 	unsigned int fb_id;
 
 	surface = paint_allocate_surface(fd, width, height, depth, bpp,
@@ -1035,14 +1003,10 @@ unsigned int kmstest_create_fb(int fd, int width, int height, int bpp,
 	cairo_set_line_cap(cr, CAIRO_LINE_CAP_SQUARE);
 
 	/* Paint corner markers */
-	snprintf(buf, sizeof buf, "(%d, %d)", 0, 0);
-	paint_marker(cr, 0, 0, buf, bottomright);
-	snprintf(buf, sizeof buf, "(%d, %d)", width, 0);
-	paint_marker(cr, width, 0, buf, bottomleft);
-	snprintf(buf, sizeof buf, "(%d, %d)", 0, height);
-	paint_marker(cr, 0, height, buf, topright);
-	snprintf(buf, sizeof buf, "(%d, %d)", width, height);
-	paint_marker(cr, width, height, buf, topleft);
+	paint_marker(cr, 0, 0);
+	paint_marker(cr, width, 0);
+	paint_marker(cr, 0, height);
+	paint_marker(cr, width, height);
 
 	if (paint_func)
 		paint_func(cr, width, height, func_arg);
-- 
1.8.1.2

  parent reply	other threads:[~2013-06-05 19:25 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-31  9:23 [igt PATCH 1/5] lib: move connector_type_str and co to drmtest Imre Deak
2013-05-31  9:23 ` [igt PATCH 2/5] lib: add kmstest_cairo_printf_line Imre Deak
2013-06-05 17:44   ` Rodrigo Vivi
2013-06-05 19:01     ` Imre Deak
2013-05-31  9:23 ` [igt PATCH 3/5] lib: add kmstest_get_connector_config Imre Deak
2013-06-05 18:00   ` Rodrigo Vivi
2013-05-31  9:23 ` [igt PATCH 4/5] lib: refactor kmstest_create_fb Imre Deak
2013-06-05 18:21   ` Rodrigo Vivi
2013-05-31  9:23 ` [igt PATCH 5/5] tests: add kms_render Imre Deak
2013-06-05 18:28   ` Rodrigo Vivi
2013-06-06 10:19     ` Imre Deak
2013-06-05 19:25   ` [PATCH v2 0/6] tests: add tests for front buffer rendering Imre Deak
2013-06-05 19:25     ` [PATCH v2 1/6] lib: move connector_type_str and co to drmtest Imre Deak
2013-06-05 19:25     ` [PATCH v2 2/6] lib: add kmstest_cairo_printf_line Imre Deak
2013-06-05 19:27       ` Rodrigo Vivi
2013-06-05 20:04       ` [PATCH v3 " Imre Deak
2013-06-05 19:25     ` Imre Deak [this message]
2013-06-05 19:29       ` [PATCH v2 3/6] lib: use kmstest_cairo_printf_line in paint_marker Rodrigo Vivi
2013-06-05 19:25     ` [PATCH v2 4/6] lib: add kmstest_get_connector_config Imre Deak
2013-06-05 19:25     ` [PATCH v2 5/6] lib: refactor kmstest_create_fb Imre Deak
2013-06-05 19:25     ` [PATCH v2 6/6] tests: add kms_render Imre Deak
2013-06-05 17:40 ` [igt PATCH 1/5] lib: move connector_type_str and co to drmtest Rodrigo Vivi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1370460328-635-4-git-send-email-imre.deak@intel.com \
    --to=imre.deak@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.