From patchwork Wed Jul 12 14:50:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowki X-Patchwork-Id: 9836909 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E0BCB60363 for ; Wed, 12 Jul 2017 14:51:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D3E1B285AF for ; Wed, 12 Jul 2017 14:51:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C87AC285E8; Wed, 12 Jul 2017 14:51:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C279D2860C for ; Wed, 12 Jul 2017 14:51:09 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7EC2F6E41D; Wed, 12 Jul 2017 14:51:08 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3397C6E418 for ; Wed, 12 Jul 2017 14:51:07 +0000 (UTC) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga105.fm.intel.com with ESMTP; 12 Jul 2017 07:51:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,350,1496127600"; d="scan'208";a="992142212" Received: from linux.intel.com ([10.54.29.200]) by orsmga003.jf.intel.com with ESMTP; 12 Jul 2017 07:51:06 -0700 Received: from workstation.fi.intel.com (workstation.fi.intel.com [10.237.68.144]) by linux.intel.com (Postfix) with ESMTP id A00FD5804B7; Wed, 12 Jul 2017 07:51:04 -0700 (PDT) From: Paul Kocialkowski To: intel-gfx@lists.freedesktop.org Date: Wed, 12 Jul 2017 17:50:25 +0300 Message-Id: <20170712145031.3531-2-paul.kocialkowski@linux.intel.com> X-Mailer: git-send-email 2.13.2 In-Reply-To: <20170712145031.3531-1-paul.kocialkowski@linux.intel.com> References: <20170705080435.26789-1-paul.kocialkowski@linux.intel.com> <20170712145031.3531-1-paul.kocialkowski@linux.intel.com> Cc: Lyude Subject: [Intel-gfx] [PATCH i-g-t v4 1/7] lib/igt_fb: Export the cairo surface instead of writing to a png 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-Virus-Scanned: ClamAV using ClamSMTP This removes the igt_write_fb_to_png function (that was unused thus far) and exports the igt_get_cairo_surface function to grab the matching cairo surface. Writing to a png is now handled by the common frame handling code in lib/igt_frame. This also fixes how the surface is retreived in chamelium code, which avoids destroying it too early. Signed-off-by: Paul Kocialkowski --- lib/igt_chamelium.c | 7 +------ lib/igt_fb.c | 36 +++++++++++++----------------------- lib/igt_fb.h | 2 +- 3 files changed, 15 insertions(+), 30 deletions(-) diff --git a/lib/igt_chamelium.c b/lib/igt_chamelium.c index bff08c0e..93392af7 100644 --- a/lib/igt_chamelium.c +++ b/lib/igt_chamelium.c @@ -936,17 +936,13 @@ void chamelium_assert_frame_eq(const struct chamelium *chamelium, const struct chamelium_frame_dump *dump, struct igt_fb *fb) { - cairo_t *cr; cairo_surface_t *fb_surface; pixman_image_t *reference_src, *reference_bgr; int w = dump->width, h = dump->height; bool eq; /* Get the cairo surface for the framebuffer */ - cr = igt_get_cairo_ctx(chamelium->drm_fd, fb); - fb_surface = cairo_get_target(cr); - cairo_surface_reference(fb_surface); - cairo_destroy(cr); + fb_surface = igt_get_cairo_surface(chamelium->drm_fd, fb); /* * Convert the reference image into the same format as the chamelium @@ -964,7 +960,6 @@ void chamelium_assert_frame_eq(const struct chamelium *chamelium, dump->size) == 0; pixman_image_unref(reference_bgr); - cairo_surface_destroy(fb_surface); igt_fail_on_f(!eq, "Chamelium frame dump didn't match reference image\n"); diff --git a/lib/igt_fb.c b/lib/igt_fb.c index d2b7e9e3..93e21c17 100644 --- a/lib/igt_fb.c +++ b/lib/igt_fb.c @@ -1124,7 +1124,18 @@ static void create_cairo_surface__gtt(int fd, struct igt_fb *fb) fb, destroy_cairo_surface__gtt); } -static cairo_surface_t *get_cairo_surface(int fd, struct igt_fb *fb) +/** + * igt_get_cairo_surface: + * @fd: open drm file descriptor + * @fb: pointer to an #igt_fb structure + * + * This function stores the contents of the supplied framebuffer into a cairo + * surface and returns it. + * + * Returns: + * A pointer to a cairo surface with the contents of the framebuffer. + */ +cairo_surface_t *igt_get_cairo_surface(int fd, struct igt_fb *fb) { if (fb->cairo_surface == NULL) { if (fb->tiling == LOCAL_I915_FORMAT_MOD_Y_TILED || @@ -1160,7 +1171,7 @@ cairo_t *igt_get_cairo_ctx(int fd, struct igt_fb *fb) cairo_surface_t *surface; cairo_t *cr; - surface = get_cairo_surface(fd, fb); + surface = igt_get_cairo_surface(fd, fb); cr = cairo_create(surface); cairo_surface_destroy(surface); igt_assert(cairo_status(cr) == CAIRO_STATUS_SUCCESS); @@ -1173,27 +1184,6 @@ cairo_t *igt_get_cairo_ctx(int fd, struct igt_fb *fb) } /** - * igt_write_fb_to_png: - * @fd: open i915 drm file descriptor - * @fb: pointer to an #igt_fb structure - * @filename: target name for the png image - * - * This function stores the contents of the supplied framebuffer into a png - * image stored at @filename. - */ -void igt_write_fb_to_png(int fd, struct igt_fb *fb, const char *filename) -{ - cairo_surface_t *surface; - cairo_status_t status; - - surface = get_cairo_surface(fd, fb); - status = cairo_surface_write_to_png(surface, filename); - cairo_surface_destroy(surface); - - igt_assert(status == CAIRO_STATUS_SUCCESS); -} - -/** * igt_remove_fb: * @fd: open i915 drm file descriptor * @fb: pointer to an #igt_fb structure diff --git a/lib/igt_fb.h b/lib/igt_fb.h index 4a680cef..f8a845cc 100644 --- a/lib/igt_fb.h +++ b/lib/igt_fb.h @@ -132,6 +132,7 @@ int igt_create_bo_with_dimensions(int fd, int width, int height, uint32_t format uint64_t igt_fb_mod_to_tiling(uint64_t modifier); /* cairo-based painting */ +cairo_surface_t *igt_get_cairo_surface(int fd, struct igt_fb *fb); cairo_t *igt_get_cairo_ctx(int fd, struct igt_fb *fb); void igt_paint_color(cairo_t *cr, int x, int y, int w, int h, double r, double g, double b); @@ -145,7 +146,6 @@ void igt_paint_color_gradient_range(cairo_t *cr, int x, int y, int w, int h, void igt_paint_test_pattern(cairo_t *cr, int width, int height); void igt_paint_image(cairo_t *cr, const char *filename, int dst_x, int dst_y, int dst_width, int dst_height); -void igt_write_fb_to_png(int fd, struct igt_fb *fb, const char *filename); int igt_cairo_printf_line(cairo_t *cr, enum igt_text_align align, double yspacing, const char *fmt, ...) __attribute__((format (printf, 4, 5)));