gdk: Add color state arg to gdk_texture_download_surface()

All callers set it to SRGB at the moment.
This commit is contained in:
Benjamin Otte 2024-07-02 03:09:44 +02:00
parent e1031ac5ad
commit ab7d969700
7 changed files with 31 additions and 13 deletions

View File

@ -885,22 +885,35 @@ gdk_texture_set_diff (GdkTexture *self,
}
cairo_surface_t *
gdk_texture_download_surface (GdkTexture *texture)
gdk_texture_download_surface (GdkTexture *texture,
GdkColorState *color_state)
{
cairo_surface_t *surface;
cairo_status_t surface_status;
guchar *data;
gsize stride;
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
texture->width, texture->height);
surface_status = cairo_surface_status (surface);
if (surface_status != CAIRO_STATUS_SUCCESS)
g_warning ("%s: surface error: %s", __FUNCTION__,
cairo_status_to_string (surface_status));
{
g_warning ("%s: surface error: %s", __FUNCTION__,
cairo_status_to_string (surface_status));
return surface;
}
gdk_texture_download (texture,
cairo_image_surface_get_data (surface),
cairo_image_surface_get_stride (surface));
data = cairo_image_surface_get_data (surface);
stride = cairo_image_surface_get_stride (surface);
gdk_texture_download (texture, data, stride);
gdk_memory_convert_color_state (data,
stride,
GDK_MEMORY_DEFAULT,
GDK_COLOR_STATE_SRGB,
color_state,
texture->width,
texture->height);
cairo_surface_mark_dirty (surface);
return surface;

View File

@ -55,7 +55,8 @@ struct _GdkTextureClass {
gboolean gdk_texture_can_load (GBytes *bytes);
GdkTexture * gdk_texture_new_for_surface (cairo_surface_t *surface);
cairo_surface_t * gdk_texture_download_surface (GdkTexture *texture);
cairo_surface_t * gdk_texture_download_surface (GdkTexture *texture,
GdkColorState *color_state);
GdkMemoryDepth gdk_texture_get_depth (GdkTexture *self);

View File

@ -22,6 +22,7 @@
#include "gdkwin32.h"
#include "gdktextureprivate.h"
#include "gdkcursorprivate.h"
#include "gdkcolorstateprivate.h"
#include "gdkdisplay-win32.h"
@ -905,7 +906,7 @@ _gdk_win32_create_hicon_for_texture (GdkTexture *texture,
int width, height;
HICON icon;
surface = gdk_texture_download_surface (texture);
surface = gdk_texture_download_surface (texture, GDK_COLOR_STATE_SRGB);
width = cairo_image_surface_get_width (surface);
height = cairo_image_surface_get_height (surface);

View File

@ -30,6 +30,7 @@
#include "gdksurfaceprivate.h"
#include "gdkpopupprivate.h"
#include "gdktoplevelprivate.h"
#include "gdkcolorstateprivate.h"
#include "gdkdragsurfaceprivate.h"
#include "gdkdeviceprivate.h"
#include "gdkdevice-xi2-private.h"
@ -3136,7 +3137,7 @@ gdk_surface_update_icon (GdkSurface *surface,
toplevel->icon_pixmap = gdk_x11_surface_create_pixmap_surface (surface, width, height);
cairo_surface = gdk_texture_download_surface (best_icon);
cairo_surface = gdk_texture_download_surface (best_icon, GDK_COLOR_STATE_SRGB);
cr = cairo_create (toplevel->icon_pixmap);
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);

View File

@ -8,6 +8,7 @@
#include "gsktransformprivate.h"
#include "gskrendererprivate.h"
#include "gskrendernodeprivate.h"
#include "gdk/gdkcolorstateprivate.h"
#include "gdk/gdktextureprivate.h"
/**
@ -484,7 +485,7 @@ get_colorized_texture (GdkTexture *texture,
return g_object_ref (colorized->texture);
}
surface = gdk_texture_download_surface (texture);
surface = gdk_texture_download_surface (texture, GDK_COLOR_STATE_SRGB);
image_surface = cairo_surface_map_to_image (surface, NULL);
data = cairo_image_surface_get_data (image_surface);
width = cairo_image_surface_get_width (image_surface);

View File

@ -1818,7 +1818,7 @@ gsk_texture_node_draw (GskRenderNode *node,
return;
}
surface = gdk_texture_download_surface (self->texture);
surface = gdk_texture_download_surface (self->texture, GDK_COLOR_STATE_SRGB);
pattern = cairo_pattern_create_for_surface (surface);
cairo_pattern_set_extend (pattern, CAIRO_EXTEND_PAD);
@ -1995,7 +1995,7 @@ gsk_texture_scale_node_draw (GskRenderNode *node,
cairo_surface_set_device_offset (surface2, -clip_rect.origin.x, -clip_rect.origin.y);
cr2 = cairo_create (surface2);
surface = gdk_texture_download_surface (self->texture);
surface = gdk_texture_download_surface (self->texture, GDK_COLOR_STATE_SRGB);
pattern = cairo_pattern_create_for_surface (surface);
cairo_pattern_set_extend (pattern, CAIRO_EXTEND_PAD);

View File

@ -32,6 +32,7 @@
#include "gskenumtypes.h"
#include "gskprivate.h"
#include "gdk/gdkcolorstateprivate.h"
#include "gdk/gdkrgbaprivate.h"
#include "gdk/gdktextureprivate.h"
#include "gdk/gdkmemoryformatprivate.h"
@ -2012,7 +2013,7 @@ parse_cairo_node (GtkCssParser *parser,
else if (pixels != NULL)
{
cairo_t *cr = gsk_cairo_node_get_draw_context (node);
surface = gdk_texture_download_surface (pixels);
surface = gdk_texture_download_surface (pixels, GDK_COLOR_STATE_SRGB);
cairo_set_source_surface (cr, surface, 0, 0);
cairo_paint (cr);
cairo_destroy (cr);