From patchwork Wed Feb 25 17:27:33 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 5882051 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 E2469BF440 for ; Wed, 25 Feb 2015 17:27:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F3CB62015E for ; Wed, 25 Feb 2015 17:27:40 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 0C0F32020F for ; Wed, 25 Feb 2015 17:27:39 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A7B946E19F; Wed, 25 Feb 2015 09:27:38 -0800 (PST) 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 4B06C6E19F for ; Wed, 25 Feb 2015 09:27:37 -0800 (PST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 25 Feb 2015 09:23:16 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,646,1418112000"; d="scan'208";a="690676794" Received: from tursulin-linux.isw.intel.com ([10.102.226.48]) by orsmga002.jf.intel.com with ESMTP; 25 Feb 2015 09:27:36 -0800 From: Tvrtko Ursulin To: Intel-gfx@lists.freedesktop.org Date: Wed, 25 Feb 2015 17:27:33 +0000 Message-Id: <1424885253-20355-1-git-send-email-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.3.0 In-Reply-To: <1424707075-27605-1-git-send-email-tvrtko.ursulin@linux.intel.com> References: <1424707075-27605-1-git-send-email-tvrtko.ursulin@linux.intel.com> Subject: [Intel-gfx] [PATCH v2 02/12] lib: Extract igt_buf_write_to_png() from gem_render_copy 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=-3.2 required=5.0 tests=BAYES_00,HK_RANDOM_FROM, 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 From: Damien Lespiau Now that the Android build has cairo, we can put cairo-dependant code back into lib/ v2: Document image format. (Daniel Vetter) Signed-off-by: Damien Lespiau --- lib/intel_batchbuffer.c | 26 ++++++++++++++++++++++++++ lib/intel_batchbuffer.h | 2 ++ tests/gem_render_copy.c | 24 +++--------------------- 3 files changed, 31 insertions(+), 21 deletions(-) diff --git a/lib/intel_batchbuffer.c b/lib/intel_batchbuffer.c index c70f6d8..d3efc1e 100644 --- a/lib/intel_batchbuffer.c +++ b/lib/intel_batchbuffer.c @@ -31,6 +31,8 @@ #include #include +#include + #include "drm.h" #include "drmtest.h" #include "intel_batchbuffer.h" @@ -458,6 +460,30 @@ unsigned igt_buf_height(struct igt_buf *buf) } /** + * igt_buf_write_to_png: + * @buf: an i-g-t buffer object + * + * Writes the content of @buf as a PNG file. + * Buffer is interpreted as in RGBX format. + */ +void igt_buf_write_to_png(struct igt_buf *buf, const char *filename) +{ + cairo_surface_t *surface; + cairo_status_t ret; + + drm_intel_bo_map(buf->bo, 0); + surface = cairo_image_surface_create_for_data(buf->bo->virtual, + CAIRO_FORMAT_RGB24, + igt_buf_width(buf), + igt_buf_height(buf), + buf->stride); + ret = cairo_surface_write_to_png(surface, filename); + igt_assert(ret == CAIRO_STATUS_SUCCESS); + cairo_surface_destroy(surface); + drm_intel_bo_unmap(buf->bo); +} + +/** * igt_get_render_copyfunc: * @devid: pci device id * diff --git a/lib/intel_batchbuffer.h b/lib/intel_batchbuffer.h index 12f7be1..e2afc3b 100644 --- a/lib/intel_batchbuffer.h +++ b/lib/intel_batchbuffer.h @@ -210,6 +210,8 @@ struct igt_buf { unsigned igt_buf_width(struct igt_buf *buf); unsigned igt_buf_height(struct igt_buf *buf); +void igt_buf_write_to_png(struct igt_buf *buf, const char *filename); + /** * igt_render_copyfunc_t: * @batch: batchbuffer object diff --git a/tests/gem_render_copy.c b/tests/gem_render_copy.c index 6348eee..6aa9e0d 100644 --- a/tests/gem_render_copy.c +++ b/tests/gem_render_copy.c @@ -31,7 +31,6 @@ #include #include -#include #include #include #include @@ -71,23 +70,6 @@ typedef struct { static int opt_dump_png = false; static int check_all_pixels = false; -static void scratch_buf_write_to_png(struct igt_buf *buf, const char *filename) -{ - cairo_surface_t *surface; - cairo_status_t ret; - - drm_intel_bo_map(buf->bo, 0); - surface = cairo_image_surface_create_for_data(buf->bo->virtual, - CAIRO_FORMAT_RGB24, - igt_buf_width(buf), - igt_buf_height(buf), - buf->stride); - ret = cairo_surface_write_to_png(surface, filename); - igt_assert(ret == CAIRO_STATUS_SUCCESS); - cairo_surface_destroy(surface); - drm_intel_bo_unmap(buf->bo); -} - static void scratch_buf_init(data_t *data, struct igt_buf *buf, int width, int height, int stride, uint32_t color) { @@ -165,8 +147,8 @@ int main(int argc, char **argv) scratch_buf_check(&data, &dst, WIDTH / 2, HEIGHT / 2, DST_COLOR); if (opt_dump_png) { - scratch_buf_write_to_png(&src, "source.png"); - scratch_buf_write_to_png(&dst, "destination.png"); + igt_buf_write_to_png(&src, "source.png"); + igt_buf_write_to_png(&dst, "destination.png"); } if (opt_dump_aub) { @@ -188,7 +170,7 @@ int main(int argc, char **argv) &dst, WIDTH / 2, HEIGHT / 2); if (opt_dump_png) - scratch_buf_write_to_png(&dst, "result.png"); + igt_buf_write_to_png(&dst, "result.png"); if (opt_dump_aub) { drm_intel_gem_bo_aub_dump_bmp(dst.bo,