diff options
author | Damien Lespiau <damien.lespiau@intel.com> | 2013-10-22 14:18:26 +0100 |
---|---|---|
committer | Damien Lespiau <damien.lespiau@intel.com> | 2013-10-24 13:44:32 +0100 |
commit | c3707ab387500b534224dd563297a7bbb26aeb83 (patch) | |
tree | db3b0351c35bbfac5228ca2c68f35d248c181e18 | |
parent | 13ebe3c01410c2dc0d90a4a1c33cbf143c51056c (diff) |
lib: Add a function to dump a scratch buf into a png
Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
-rw-r--r-- | lib/Makefile.am | 1 | ||||
-rw-r--r-- | lib/rendercopy.c | 49 | ||||
-rw-r--r-- | lib/rendercopy.h | 2 |
3 files changed, 52 insertions, 0 deletions
diff --git a/lib/Makefile.am b/lib/Makefile.am index 431fd932..d7f42752 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -32,6 +32,7 @@ libintel_tools_la_SOURCES = \ 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 00000000..2c1684dd --- /dev/null +++ b/lib/rendercopy.c @@ -0,0 +1,49 @@ +/* + * Copyright © 2013 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * 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, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + * + * Authors: + * Damien Lespiau <damien.lespiau@intel.com> + */ + +#include <cairo.h> + +#include "rendercopy.h" + +void scratch_buf_write_to_png(struct scratch_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, + buf_width(buf), + buf_height(buf), + buf->stride); + ret = cairo_surface_write_to_png(surface, filename); + if (ret != 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 8fd9222b..ace43923 100644 --- a/lib/rendercopy.h +++ b/lib/rendercopy.h @@ -85,4 +85,6 @@ void gen2_render_copyfunc(struct intel_batchbuffer *batch, unsigned width, unsigned height, struct scratch_buf *dst, unsigned dst_x, unsigned dst_y); +void scratch_buf_write_to_png(struct scratch_buf *buf, const char *filename); + #endif /* RENDERCOPY_H */ |