mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-27 22:20:24 +00:00
Merge branch 'matthiasc/for-master' into 'master'
Fix memorytexture float conversion See merge request GNOME/gtk!3957
This commit is contained in:
commit
7c2be93a56
@ -603,7 +603,7 @@ convert_rgba16_to_float (float *dest, const guchar *src_data)
|
||||
dest[0] = src[0] / 65535.f;
|
||||
dest[1] = src[1] / 65535.f;
|
||||
dest[2] = src[2] / 65535.f;
|
||||
dest[3] = 1.0;
|
||||
dest[3] = src[3] / 65535.f;
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
@ -197,9 +197,10 @@ gsk_ngl_command_queue_capture_png (GskNglCommandQueue *self,
|
||||
guint height,
|
||||
gboolean flip_y)
|
||||
{
|
||||
cairo_surface_t *surface;
|
||||
guint8 *data;
|
||||
guint stride;
|
||||
guint8 *data;
|
||||
GBytes *bytes;
|
||||
GdkTexture *texture;
|
||||
|
||||
g_assert (GSK_IS_NGL_COMMAND_QUEUE (self));
|
||||
g_assert (filename != NULL);
|
||||
@ -222,11 +223,12 @@ gsk_ngl_command_queue_capture_png (GskNglCommandQueue *self,
|
||||
data = flipped;
|
||||
}
|
||||
|
||||
surface = cairo_image_surface_create_for_data (data, CAIRO_FORMAT_ARGB32, width, height, stride);
|
||||
cairo_surface_write_to_png (surface, filename);
|
||||
bytes = g_bytes_new_take (data, height * stride);
|
||||
texture = gdk_memory_texture_new (width, height, GDK_MEMORY_DEFAULT, bytes, stride);
|
||||
g_bytes_unref (bytes);
|
||||
|
||||
cairo_surface_destroy (surface);
|
||||
g_free (data);
|
||||
gdk_texture_save_to_png (texture, filename);
|
||||
g_object_unref (texture);
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
|
@ -1131,20 +1131,18 @@ gsk_ngl_driver_lookup_shader (GskNglDriver *self,
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
static void
|
||||
write_atlas_to_png (GskNglTextureAtlas *atlas,
|
||||
write_atlas_to_png (GskNglDriver *driver,
|
||||
GskNglTextureAtlas *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;
|
||||
GdkTexture *texture;
|
||||
|
||||
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);
|
||||
texture = gdk_gl_texture_new (gsk_ngl_driver_get_context (driver),
|
||||
atlas->texture_id,
|
||||
atlas->width, atlas->height,
|
||||
NULL, NULL);
|
||||
gdk_texture_save_to_png (texture, filename);
|
||||
g_object_unref (texture);
|
||||
}
|
||||
|
||||
void
|
||||
@ -1164,7 +1162,7 @@ gsk_ngl_driver_save_atlases_to_png (GskNglDriver *self,
|
||||
G_DIR_SEPARATOR_S,
|
||||
(int)self->current_frame_id,
|
||||
atlas->texture_id);
|
||||
write_atlas_to_png (atlas, filename);
|
||||
write_atlas_to_png (self, atlas, filename);
|
||||
g_free (filename);
|
||||
}
|
||||
}
|
||||
|
@ -204,25 +204,22 @@ gsk_ngl_shadow_library_lookup (GskNglShadowLibrary *self,
|
||||
|
||||
#if 0
|
||||
static void
|
||||
write_shadow_to_png (const Shadow *shadow)
|
||||
write_shadow_to_png (GskNglDriver *driver,
|
||||
const Shadow *shadow)
|
||||
{
|
||||
int width = shadow->outline.bounds.size.width + (shadow->outline.bounds.origin.x * 2);
|
||||
int height = shadow->outline.bounds.size.height + (shadow->outline.bounds.origin.y * 2);
|
||||
int stride = cairo_format_stride_for_width (CAIRO_FORMAT_ARGB32, width);
|
||||
guchar *data = g_malloc (height * stride);
|
||||
cairo_surface_t *s;
|
||||
char *filename = g_strdup_printf ("shadow_cache_%d_%d_%d.png",
|
||||
width, height, shadow->texture_id);
|
||||
GdkTexture *texture;
|
||||
|
||||
glBindTexture (GL_TEXTURE_2D, shadow->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,
|
||||
width, height,
|
||||
stride);
|
||||
cairo_surface_write_to_png (s, filename);
|
||||
texture = gdk_gl_texture_new (gsk_ngl_driver_get_context (driver),
|
||||
shadow->texture_id,
|
||||
width, height,
|
||||
NULL, NULL);
|
||||
gdk_texture_save_to_png (texture, filename);
|
||||
|
||||
cairo_surface_destroy (s);
|
||||
g_free (data);
|
||||
g_object_unref (texture);
|
||||
g_free (filename);
|
||||
}
|
||||
#endif
|
||||
@ -240,7 +237,7 @@ gsk_ngl_shadow_library_begin_frame (GskNglShadowLibrary *self)
|
||||
for (i = 0, p = self->shadows->len; i < p; i++)
|
||||
{
|
||||
const Shadow *shadow = &g_array_index (self->shadows, Shadow, i);
|
||||
write_shadow_to_png (shadow);
|
||||
write_shadow_to_png (self->driver, shadow);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user