[gtk/wip/chergert/glproto] next: make atlas saving a debug build feature
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/chergert/glproto] next: make atlas saving a debug build feature
- Date: Tue, 23 Feb 2021 20:05:58 +0000 (UTC)
commit e75b4408c456f99dcefc11145f181ffb42a623e4
Author: Christian Hergert <chergert redhat com>
Date: Tue Feb 23 12:05:38 2021 -0800
next: make atlas saving a debug build feature
gsk/next/gskgldriver.c | 36 +++++++++++++++++++-----------------
gsk/next/gskgldriverprivate.h | 5 ++++-
2 files changed, 23 insertions(+), 18 deletions(-)
---
diff --git a/gsk/next/gskgldriver.c b/gsk/next/gskgldriver.c
index f32ebbffd8..8c6223e4f0 100644
--- a/gsk/next/gskgldriver.c
+++ b/gsk/next/gskgldriver.c
@@ -74,23 +74,6 @@ texture_key_equal (gconstpointer v1, gconstpointer v2)
(!k1->pointer_is_child || memcmp (&k1->parent_rect, &k2->parent_rect, sizeof k1->parent_rect) == 0);
}
-static inline void
-write_atlas_to_png (GskGLTextureAtlas *atlas,
- const char *filename)
-{
- int stride = cairo_format_stride_for_width (CAIRO_FORMAT_ARGB32, atlas->width);
- guchar *data = g_malloc (atlas->height * stride);
- cairo_surface_t *s;
-
- glBindTexture (GL_TEXTURE_2D, atlas->texture_id);
- glGetTexImage (GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, data);
- s = cairo_image_surface_create_for_data (data, CAIRO_FORMAT_ARGB32, atlas->width, atlas->height, stride);
- cairo_surface_write_to_png (s, filename);
-
- cairo_surface_destroy (s);
- g_free (data);
-}
-
static void
remove_texture_key_for_id (GskNextDriver *self,
guint texture_id)
@@ -1152,6 +1135,24 @@ gsk_next_driver_lookup_shader (GskNextDriver *self,
return program;
}
+#ifdef G_ENABLE_DEBUG
+static void
+write_atlas_to_png (GskGLTextureAtlas *atlas,
+ const char *filename)
+{
+ int stride = cairo_format_stride_for_width (CAIRO_FORMAT_ARGB32, atlas->width);
+ guchar *data = g_malloc (atlas->height * stride);
+ cairo_surface_t *s;
+
+ glBindTexture (GL_TEXTURE_2D, atlas->texture_id);
+ glGetTexImage (GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, data);
+ s = cairo_image_surface_create_for_data (data, CAIRO_FORMAT_ARGB32, atlas->width, atlas->height, stride);
+ cairo_surface_write_to_png (s, filename);
+
+ cairo_surface_destroy (s);
+ g_free (data);
+}
+
void
gsk_next_driver_save_atlases_to_png (GskNextDriver *self,
const char *directory)
@@ -1173,6 +1174,7 @@ gsk_next_driver_save_atlases_to_png (GskNextDriver *self,
g_free (filename);
}
}
+#endif
GskGLCommandQueue *
gsk_next_driver_create_command_queue (GskNextDriver *self,
diff --git a/gsk/next/gskgldriverprivate.h b/gsk/next/gskgldriverprivate.h
index 6531fc9c6c..dd97265538 100644
--- a/gsk/next/gskgldriverprivate.h
+++ b/gsk/next/gskgldriverprivate.h
@@ -173,8 +173,11 @@ GskGLProgram *gsk_next_driver_lookup_shader (GskNextDriver *
GskGLShader *shader,
GError **error);
GskGLTextureAtlas *gsk_next_driver_create_atlas (GskNextDriver *self);
-void gsk_next_driver_save_atlases_to_png (GskNextDriver *self,
+
+#ifdef G_ENABLE_DEBUG
+void gsk_next_driver_save_atlases_to_png (GskNextDriver *self,
const char *directory);
+#endif
static inline GskGLTexture *
gsk_next_driver_get_texture_by_id (GskNextDriver *self,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]