Use shared pixdata helper for drag cursors
Replace the deprecated gdk_pixbuf_new_from_inline() call used for GTK drag cursor pixbufs with the internal pixdata helper. Keep the existing embedded cursor data and lazy per-cursor pixbuf creation. The helper reads the embedded pixdata length from the stream header and then uses the shared validating decoder, avoiding extra per-cursor metadata or runtime resources.
This commit is contained in:
parent
3cf7eeb869
commit
c2db5954c4
3 changed files with 26 additions and 2 deletions
|
|
@ -45,6 +45,7 @@
|
|||
#include "gtkimage.h"
|
||||
#include "gtkinvisible.h"
|
||||
#include "gtkmain.h"
|
||||
#include "gtkpixdatautils.h"
|
||||
#include "gtkplug.h"
|
||||
#include "gtkstock.h"
|
||||
#include "gtktooltip.h"
|
||||
|
|
@ -743,8 +744,8 @@ gtk_drag_get_cursor (GdkDisplay *display,
|
|||
break;
|
||||
|
||||
if (drag_cursors[i].pixbuf == NULL)
|
||||
drag_cursors[i].pixbuf =
|
||||
gdk_pixbuf_new_from_inline (-1, drag_cursors[i].data, FALSE, NULL);
|
||||
drag_cursors[i].pixbuf =
|
||||
_gtk_pixbuf_new_from_inline_pixdata (drag_cursors[i].data, NULL);
|
||||
|
||||
if (drag_cursors[i].cursor != NULL)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -221,6 +221,26 @@ _gtk_pixbuf_new_from_pixdata_stream (const guint8 *stream,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
GdkPixbuf *
|
||||
_gtk_pixbuf_new_from_inline_pixdata (const guint8 *stream,
|
||||
GError **error)
|
||||
{
|
||||
guint32 length;
|
||||
|
||||
g_return_val_if_fail (stream != NULL, NULL);
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
||||
|
||||
if (memcmp (stream, GTK_PIXDATA_MAGIC, 4) != 0)
|
||||
{
|
||||
pixdata_set_error (error);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
length = pixdata_get_uint32 (stream + 4);
|
||||
|
||||
return _gtk_pixbuf_new_from_pixdata_stream (stream, length, error);
|
||||
}
|
||||
|
||||
guint8 *
|
||||
_gtk_pixdata_serialize_from_pixbuf (GdkPixbuf *pixbuf,
|
||||
gsize *length_p)
|
||||
|
|
|
|||
|
|
@ -9,6 +9,9 @@ GdkPixbuf *_gtk_pixbuf_new_from_pixdata_stream (const guint8 *stream,
|
|||
gsize stream_length,
|
||||
GError **error);
|
||||
|
||||
GdkPixbuf *_gtk_pixbuf_new_from_inline_pixdata (const guint8 *stream,
|
||||
GError **error);
|
||||
|
||||
guint8 *_gtk_pixdata_serialize_from_pixbuf (GdkPixbuf *pixbuf,
|
||||
gsize *length_p);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue