From: Damien Lespiau Subject: [PATCH 1/5] lib: Add a function to dump a scratch buf into a png Date: Wed, 23 Oct 2013 16:05:12 +0100 Message-ID: <1382540716-32711-2-git-send-email-damien.lespiau@intel.com> References: <1382540716-32711-1-git-send-email-damien.lespiau@intel.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1858784787==" Return-path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTP id 96167E6EC7 for ; Wed, 23 Oct 2013 08:05:22 -0700 (PDT) In-Reply-To: <1382540716-32711-1-git-send-email-damien.lespiau@intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: intel-gfx-bounces+gcfxdi-intel-gfx=m.gmane.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+gcfxdi-intel-gfx=m.gmane.org@lists.freedesktop.org To: intel-gfx@lists.freedesktop.org List-Id: intel-gfx@lists.freedesktop.org --===============1858784787== Content-Type: text/plain; charset=y Content-Transfer-Encoding: quoted-printable Signed-off-by: Damien Lespiau --- lib/Makefile.am | 1 + lib/rendercopy.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ lib/rendercopy.h | 2 ++ 3 files changed, 52 insertions(+) create mode 100644 lib/rendercopy.c diff --git a/lib/Makefile.am b/lib/Makefile.am index 431fd93..d7f4275 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -32,6 +32,7 @@ libintel_tools_la_SOURCES =3D \ rendercopy_gen6.c \ rendercopy_gen7.c \ rendercopy.h \ + rendercopy.c \ intel_reg_map.c \ intel_dpio.c \ intel_iosf.c \ diff --git a/lib/rendercopy.c b/lib/rendercopy.c new file mode 100644 index 0000000..2c1684d --- /dev/null +++ b/lib/rendercopy.c @@ -0,0 +1,49 @@ +/* + * Copyright =C2=A9 2013 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining= a + * copy of this software and associated documentation files (the "Softwa= re"), + * to deal in the Software without restriction, including without limita= tion + * the rights to use, copy, modify, merge, publish, distribute, sublicen= se, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the = next + * paragraph) shall be included in all copies or substantial portions of= the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRE= SS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILI= TY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SH= ALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR = OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISI= NG + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER D= EALINGS + * IN THE SOFTWARE. + * + * Authors: + * Damien Lespiau + */ + +#include + +#include "rendercopy.h" + +void scratch_buf_write_to_png(struct scratch_buf *buf, const char *filen= ame) +{ + cairo_surface_t *surface; + cairo_status_t ret; + + drm_intel_bo_map(buf->bo, 0); + surface =3D cairo_image_surface_create_for_data(buf->bo->virtual, + CAIRO_FORMAT_RGB24, + buf_width(buf), + buf_height(buf), + buf->stride); + ret =3D cairo_surface_write_to_png(surface, filename); + if (ret !=3D CAIRO_STATUS_SUCCESS) { + fprintf(stderr, "%s: %s\n", __func__, + cairo_status_to_string(ret)); + } + cairo_surface_destroy(surface); + drm_intel_bo_unmap(buf->bo); +} diff --git a/lib/rendercopy.h b/lib/rendercopy.h index 8fd9222..ace4392 100644 --- a/lib/rendercopy.h +++ b/lib/rendercopy.h @@ -85,4 +85,6 @@ void gen2_render_copyfunc(struct intel_batchbuffer *bat= ch, unsigned width, unsigned height, struct scratch_buf *dst, unsigned dst_x, unsigned dst_y); =20 +void scratch_buf_write_to_png(struct scratch_buf *buf, const char *filen= ame); + #endif /* RENDERCOPY_H */ --=20 1.8.3.1 --===============1858784787== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/intel-gfx --===============1858784787==--