[gtk/matthiasc/color-profile-rebased: 34/66] gdk: Take a color space in gdk_memory_texture_from_texture
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/color-profile-rebased: 34/66] gdk: Take a color space in gdk_memory_texture_from_texture
- Date: Fri, 13 May 2022 04:00:02 +0000 (UTC)
commit 143a0189face234b2b278e8c0907ea80a11c5976
Author: Matthias Clasen <mclasen redhat com>
Date: Sun May 8 09:33:55 2022 -0400
gdk: Take a color space in gdk_memory_texture_from_texture
This will let us do profile conversions at the
same time.
Update all callers.
gdk/gdkgltexture.c | 3 ++-
gdk/gdkmemorytexture.c | 19 +++++++++++--------
gdk/gdkmemorytextureprivate.h | 3 ++-
gdk/gdkpixbuf-drawable.c | 3 ++-
gdk/loaders/gdkjpeg.c | 3 ++-
gdk/loaders/gdkpng.c | 4 ++--
gdk/loaders/gdktiff.c | 2 +-
gsk/gl/gskglcommandqueue.c | 2 +-
gsk/gl/gskgldriver.c | 11 ++++++++---
9 files changed, 31 insertions(+), 19 deletions(-)
---
diff --git a/gdk/gdkgltexture.c b/gdk/gdkgltexture.c
index f59673f415..7ab0f355e8 100644
--- a/gdk/gdkgltexture.c
+++ b/gdk/gdkgltexture.c
@@ -301,7 +301,8 @@ gdk_gl_texture_release (GdkGLTexture *self)
texture = GDK_TEXTURE (self);
self->saved = GDK_TEXTURE (gdk_memory_texture_from_texture (texture,
- gdk_texture_get_format (texture)));
+ gdk_texture_get_format (texture),
+ gdk_texture_get_color_space (texture)));
if (self->destroy)
{
diff --git a/gdk/gdkmemorytexture.c b/gdk/gdkmemorytexture.c
index dfdbfc2e21..8ddb6e0064 100644
--- a/gdk/gdkmemorytexture.c
+++ b/gdk/gdkmemorytexture.c
@@ -249,7 +249,8 @@ gdk_memory_texture_new_subtexture (GdkMemoryTexture *source,
GdkMemoryTexture *
gdk_memory_texture_from_texture (GdkTexture *texture,
- GdkMemoryFormat format)
+ GdkMemoryFormat format,
+ GdkColorSpace *color_space)
{
GdkTexture *result;
GBytes *bytes;
@@ -262,20 +263,22 @@ gdk_memory_texture_from_texture (GdkTexture *texture,
{
GdkMemoryTexture *memtex = GDK_MEMORY_TEXTURE (texture);
- if (gdk_texture_get_format (texture) == format)
+ if (gdk_texture_get_format (texture) == format &&
+ gdk_texture_get_color_space (texture) == color_space)
return g_object_ref (memtex);
}
stride = texture->width * gdk_memory_format_bytes_per_pixel (format);
data = g_malloc_n (stride, texture->height);
- gdk_texture_do_download (texture, format, gdk_color_space_get_srgb (), data, stride);
+ gdk_texture_do_download (texture, format, color_space, data, stride);
bytes = g_bytes_new_take (data, stride);
- result = gdk_memory_texture_new (texture->width,
- texture->height,
- format,
- bytes,
- stride);
+ result = gdk_memory_texture_new_with_color_space (texture->width,
+ texture->height,
+ format,
+ color_space,
+ bytes,
+ stride);
g_bytes_unref (bytes);
return GDK_MEMORY_TEXTURE (result);
diff --git a/gdk/gdkmemorytextureprivate.h b/gdk/gdkmemorytextureprivate.h
index 57dafd567b..e7175bf821 100644
--- a/gdk/gdkmemorytextureprivate.h
+++ b/gdk/gdkmemorytextureprivate.h
@@ -30,7 +30,8 @@ G_BEGIN_DECLS
#define GDK_MEMORY_GDK_PIXBUF_ALPHA GDK_MEMORY_R8G8B8A8
GdkMemoryTexture * gdk_memory_texture_from_texture (GdkTexture *texture,
- GdkMemoryFormat format);
+ GdkMemoryFormat format,
+ GdkColorSpace *color_space);
GdkTexture * gdk_memory_texture_new_subtexture (GdkMemoryTexture *texture,
int x,
int y,
diff --git a/gdk/gdkpixbuf-drawable.c b/gdk/gdkpixbuf-drawable.c
index 15b886357e..275cf75681 100644
--- a/gdk/gdkpixbuf-drawable.c
+++ b/gdk/gdkpixbuf-drawable.c
@@ -245,7 +245,8 @@ gdk_pixbuf_get_from_texture (GdkTexture *texture)
memtex = gdk_memory_texture_from_texture (texture,
alpha ? GDK_MEMORY_GDK_PIXBUF_ALPHA
- : GDK_MEMORY_GDK_PIXBUF_OPAQUE);
+ : GDK_MEMORY_GDK_PIXBUF_OPAQUE,
+ gdk_color_space_get_srgb ());
return gdk_pixbuf_new_from_data (gdk_memory_texture_get_data (memtex),
GDK_COLORSPACE_RGB,
diff --git a/gdk/loaders/gdkjpeg.c b/gdk/loaders/gdkjpeg.c
index 9ed883479a..5979e70da2 100644
--- a/gdk/loaders/gdkjpeg.c
+++ b/gdk/loaders/gdkjpeg.c
@@ -308,7 +308,8 @@ gdk_save_jpeg (GdkTexture *texture)
jpeg_mem_dest (&info, &data, &size);
memtex = gdk_memory_texture_from_texture (texture,
- GDK_MEMORY_R8G8B8);
+ GDK_MEMORY_R8G8B8,
+ gdk_color_space_get_srgb ());
texdata = gdk_memory_texture_get_data (memtex);
texstride = gdk_memory_texture_get_stride (memtex);
diff --git a/gdk/loaders/gdkpng.c b/gdk/loaders/gdkpng.c
index 20711210d0..01ca9fa0d6 100644
--- a/gdk/loaders/gdkpng.c
+++ b/gdk/loaders/gdkpng.c
@@ -128,7 +128,7 @@ png_simple_warning_callback (png_structp png,
}
/* }}} */
-/* {{{ Public API */
+/* {{{ Public API */
GdkTexture *
gdk_load_png (GBytes *bytes,
@@ -369,7 +369,7 @@ gdk_save_png (GdkTexture *texture)
return NULL;
}
- memtex = gdk_memory_texture_from_texture (texture, format);
+ memtex = gdk_memory_texture_from_texture (texture, format, gdk_color_space_get_srgb ());
if (sigsetjmp (png_jmpbuf (png), 1))
{
diff --git a/gdk/loaders/gdktiff.c b/gdk/loaders/gdktiff.c
index 724e4c3a81..0604116fa6 100644
--- a/gdk/loaders/gdktiff.c
+++ b/gdk/loaders/gdktiff.c
@@ -292,7 +292,7 @@ gdk_save_tiff (GdkTexture *texture)
TIFFSetField (tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
TIFFSetField (tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
- memtex = gdk_memory_texture_from_texture (texture, fdata->format);
+ memtex = gdk_memory_texture_from_texture (texture, fdata->format, gdk_color_space_get_srgb ());
data = gdk_memory_texture_get_data (memtex);
stride = gdk_memory_texture_get_stride (memtex);
diff --git a/gsk/gl/gskglcommandqueue.c b/gsk/gl/gskglcommandqueue.c
index 4d7ef4b3d3..7d4a369a8b 100644
--- a/gsk/gl/gskglcommandqueue.c
+++ b/gsk/gl/gskglcommandqueue.c
@@ -1391,7 +1391,7 @@ gsk_gl_command_queue_do_upload_texture (GskGLCommandQueue *self,
}
}
- memtex = gdk_memory_texture_from_texture (texture, data_format);
+ memtex = gdk_memory_texture_from_texture (texture, data_format, gdk_color_space_get_srgb ());
data = gdk_memory_texture_get_data (memtex);
stride = gdk_memory_texture_get_stride (memtex);
bpp = gdk_memory_format_bytes_per_pixel (data_format);
diff --git a/gsk/gl/gskgldriver.c b/gsk/gl/gskgldriver.c
index 179e870d80..9091a25dc5 100644
--- a/gsk/gl/gskgldriver.c
+++ b/gsk/gl/gskgldriver.c
@@ -741,7 +741,9 @@ gsk_gl_driver_load_texture (GskGLDriver *self,
}
else
{
- downloaded_texture = gdk_memory_texture_from_texture (texture, gdk_texture_get_format (texture));
+ downloaded_texture = gdk_memory_texture_from_texture (texture,
+ gdk_texture_get_format (texture),
+ gdk_texture_get_color_space (texture));
}
}
else
@@ -752,7 +754,9 @@ gsk_gl_driver_load_texture (GskGLDriver *self,
return t->texture_id;
}
- downloaded_texture = gdk_memory_texture_from_texture (texture, gdk_texture_get_format (texture));
+ downloaded_texture = gdk_memory_texture_from_texture (texture,
+ gdk_texture_get_format (texture),
+ gdk_texture_get_color_space (texture));
}
/* The download_texture() call may have switched the GL context. Make sure
@@ -1227,7 +1231,8 @@ gsk_gl_driver_add_texture_slices (GskGLDriver *self,
n_slices = cols * rows;
slices = g_new0 (GskGLTextureSlice, n_slices);
memtex = gdk_memory_texture_from_texture (texture,
- gdk_texture_get_format (texture));
+ gdk_texture_get_format (texture),
+ gdk_texture_get_color_space (texture));
for (guint col = 0; col < cols; col ++)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]