From patchwork Wed Jun 5 19:25:25 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Imre Deak X-Patchwork-Id: 2673411 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork2.kernel.org (Postfix) with ESMTP id D996BDF264 for ; Wed, 5 Jun 2013 19:27:33 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C4E28E65C5 for ; Wed, 5 Jun 2013 12:27:33 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTP id 53FCCE65D9 for ; Wed, 5 Jun 2013 12:25:36 -0700 (PDT) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 05 Jun 2013 12:23:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.87,809,1363158000"; d="scan'208";a="348774910" Received: from intelbox.fi.intel.com (HELO localhost) ([10.237.72.70]) by orsmga002.jf.intel.com with ESMTP; 05 Jun 2013 12:25:34 -0700 From: Imre Deak To: intel-gfx@lists.freedesktop.org Date: Wed, 5 Jun 2013 22:25:25 +0300 Message-Id: <1370460328-635-4-git-send-email-imre.deak@intel.com> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1370460328-635-1-git-send-email-imre.deak@intel.com> References: <1369992192-957-5-git-send-email-imre.deak@intel.com> <1370460328-635-1-git-send-email-imre.deak@intel.com> Subject: [Intel-gfx] [PATCH v2 3/6] lib: use kmstest_cairo_printf_line in paint_marker X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Signed-off-by: Imre Deak Reviewed-by: Rodrigo Vivi --- 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);