From patchwork Mon Apr 13 16:48:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Wood X-Patchwork-Id: 6210541 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 7526ABF4A6 for ; Mon, 13 Apr 2015 16:48:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 69689202FE for ; Mon, 13 Apr 2015 16:48:45 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id D76BF202DD for ; Mon, 13 Apr 2015 16:48:43 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 50E076E5BA; Mon, 13 Apr 2015 09:48:43 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wi0-f172.google.com (mail-wi0-f172.google.com [209.85.212.172]) by gabe.freedesktop.org (Postfix) with ESMTP id D347C6E56A for ; Mon, 13 Apr 2015 09:48:40 -0700 (PDT) Received: by widdi4 with SMTP id di4so59589159wid.0 for ; Mon, 13 Apr 2015 09:48:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=1uvtodLvs5Ew+fYPbPLDhmfdBkASt+kzW5U3wnPOgeQ=; b=XvuMJdy+onFPuVJo3xcWpIOtjCluteeAmLhrr+eirR4M6ydre7kQcD0xcQS723uffF pYnoysMb/qsuz1HH00pHywV/b/a98N7K9JBnAYDlkAnOwFaLVc8otWM/kN0LlbjRWLex CC5DAzEIiB5ywFeXBzgYSJPYqEKS0IKwHDvZqZBq/H5gwaQ7i7SHJQHxKVYRjxzvoYd3 GKfHDNXJZDrwx/qt37DdGl0TUki/RU+o09OUyLvbxNF61wr/yDH4vTB89mkEREudFm8D TdMeFz1gHTWm78KQyuM6tobVwv4zNTfsJ9QcDAL7vCjBroGRJKLXksYmRFghBAeiQGy0 JNzQ== X-Gm-Message-State: ALoCoQlMoEEtJm7aSoyi3IqYhR/pLXCJZnafmeZ72XdufoordJP45SODU99wQavUfUYfTUs+QVs4 X-Received: by 10.180.109.134 with SMTP id hs6mr23215614wib.14.1428943719895; Mon, 13 Apr 2015 09:48:39 -0700 (PDT) Received: from pistachio.icx.intel.com ([83.217.123.106]) by mx.google.com with ESMTPSA id di9sm13525995wib.16.2015.04.13.09.48.38 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 Apr 2015 09:48:39 -0700 (PDT) From: Thomas Wood To: intel-gfx@lists.freedesktop.org Date: Mon, 13 Apr 2015 17:48:36 +0100 Message-Id: <1428943716-19775-2-git-send-email-thomas.wood@intel.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1428943716-19775-1-git-send-email-thomas.wood@intel.com> References: <1428943716-19775-1-git-send-email-thomas.wood@intel.com> Subject: [Intel-gfx] [PATCH i-g-t 2/2] lib: load images from the data directory in igt_paint_image X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Update igt_paint_image so that it can read images from the package data directory. Signed-off-by: Thomas Wood --- lib/Android.mk | 2 +- lib/Makefile.am | 3 ++- lib/igt_fb.c | 23 +++++++++++++++++------ tests/testdisplay.c | 35 ++--------------------------------- 4 files changed, 22 insertions(+), 41 deletions(-) diff --git a/lib/Android.mk b/lib/Android.mk index 2251c15..1a7cf33 100644 --- a/lib/Android.mk +++ b/lib/Android.mk @@ -35,7 +35,7 @@ LOCAL_SHARED_LIBRARIES := libpciaccess \ ifeq ("${ANDROID_HAS_CAIRO}", "1") skip_lib_list := LOCAL_C_INCLUDES += $(ANDROID_BUILD_TOP)/external/cairo-1.12.16/src - LOCAL_CFLAGS += -DANDROID_HAS_CAIRO=1 -DIGT_DATADIR=\".\" + LOCAL_CFLAGS += -DANDROID_HAS_CAIRO=1 -DIGT_DATADIR=\".\" -DIGT_SRCDIR=\".\" else skip_lib_list := \ igt_kms.c \ diff --git a/lib/Makefile.am b/lib/Makefile.am index 870b1a1..c74e211 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -10,7 +10,8 @@ noinst_HEADERS = check-ndebug.h AM_CPPFLAGS = -I$(top_srcdir) AM_CFLAGS = $(DRM_CFLAGS) $(CWARNFLAGS) $(LIBUNWIND_CFLAGS) $(DEBUG_CFLAGS) \ - -DIGT_DATADIR=\""$(abs_top_srcdir)/tests"\" \ + -DIGT_SRCDIR=\""$(abs_top_srcdir)/tests"\" \ + -DIGT_DATADIR=\""$(pkgdatadir)"\" \ -DIGT_LOG_DOMAIN=\""$(subst _,-,$*)"\" \ -pthread diff --git a/lib/igt_fb.c b/lib/igt_fb.c index ce5a102..6dc22bb 100644 --- a/lib/igt_fb.c +++ b/lib/igt_fb.c @@ -338,6 +338,15 @@ void igt_paint_test_pattern(cairo_t *cr, int width, int height) igt_assert(!cairo_status(cr)); } +static cairo_status_t +stdio_read_func(void *closure, unsigned char* data, unsigned int size) +{ + if (fread(data, 1, size, (FILE*)closure) != size) + return CAIRO_STATUS_READ_ERROR; + + return CAIRO_STATUS_SUCCESS; +} + /** * igt_paint_image: * @cr: cairo drawing context @@ -347,9 +356,8 @@ void igt_paint_test_pattern(cairo_t *cr, int width, int height) * @dst_width: width of the destination rectangle * @dst_height: height of the destination rectangle * - * This function can be used to draw a scaled version of the supplied png image. - * This is currently only used by the CR-code based testing in the "testdisplay" - * testcase. + * This function can be used to draw a scaled version of the supplied png image, + * which is loaded from the package data directory. */ void igt_paint_image(cairo_t *cr, const char *filename, int dst_x, int dst_y, int dst_width, int dst_height) @@ -357,8 +365,11 @@ void igt_paint_image(cairo_t *cr, const char *filename, cairo_surface_t *image; int img_width, img_height; double scale_x, scale_y; + FILE* f; + + f = igt_fopen_data(filename); - image = cairo_image_surface_create_from_png(filename); + image = cairo_image_surface_create_from_png_stream(&stdio_read_func, f); igt_assert(cairo_surface_status(image) == CAIRO_STATUS_SUCCESS); img_width = cairo_image_surface_get_width(image); @@ -605,10 +616,10 @@ unsigned int igt_create_stereo_fb(int drm_fd, drmModeModeInfo *mode, tiling, &fb); cr = igt_get_cairo_ctx(drm_fd, &fb); - igt_paint_image(cr, IGT_DATADIR"/1080p-left.png", + igt_paint_image(cr, "1080p-left.png", layout.left.x, layout.left.y, layout.left.width, layout.left.height); - igt_paint_image(cr, IGT_DATADIR"/1080p-right.png", + igt_paint_image(cr, "1080p-right.png", layout.right.x, layout.right.y, layout.right.width, layout.right.height); diff --git a/tests/testdisplay.c b/tests/testdisplay.c index 58f56a3..9068a95 100644 --- a/tests/testdisplay.c +++ b/tests/testdisplay.c @@ -239,21 +239,9 @@ paint_color_key(struct igt_fb *fb_info) munmap(fb_ptr, fb_info->size); } -static cairo_status_t -stdio_read_func(void* closure, unsigned char* data, unsigned int size) -{ - if (fread (data, 1, size, (FILE*)closure) != size) - return CAIRO_STATUS_READ_ERROR; - return CAIRO_STATUS_SUCCESS; -} - static void paint_image(cairo_t *cr, const char *file) { - int img_x, img_y, img_w, img_h, img_w_o, img_h_o; - double img_w_scale, img_h_scale; - - cairo_surface_t *image; - FILE* fp; + int img_x, img_y, img_w, img_h; img_y = height * (0.10 ); img_h = height * 0.08 * 4; @@ -261,26 +249,7 @@ static void paint_image(cairo_t *cr, const char *file) img_x = (width / 2) - (img_w / 2); - fp = igt_fopen_data(file); - if (!fp) - return; - image = cairo_image_surface_create_from_png_stream(&stdio_read_func, - (void*)fp); - - img_w_o = cairo_image_surface_get_width(image); - img_h_o = cairo_image_surface_get_height(image); - - cairo_translate(cr, img_x, img_y); - - img_w_scale = (double)img_w / (double)img_w_o; - img_h_scale = (double)img_h / (double)img_h_o; - cairo_scale(cr, img_w_scale, img_h_scale); - - cairo_set_source_surface(cr, image, 0, 0); - cairo_scale(cr, 1, 1); - - cairo_paint(cr); - cairo_surface_destroy(image); + igt_paint_image(cr, file, img_x, img_y, img_h, img_w); } static void paint_output_info(struct connector *c, struct igt_fb *fb)