mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-10 19:00:08 +00:00
image: Don't handle surfaces anymore
Lots of special cases that are no longer needed because no code uses surfaces. Also remove the GdkCellRendererPixbuf:surface property.
This commit is contained in:
parent
01f996447e
commit
9e54c22c49
@ -1483,7 +1483,6 @@ GtkIconViewPrivate
|
||||
<TITLE>GtkImage</TITLE>
|
||||
GtkImage
|
||||
GtkImageType
|
||||
gtk_image_get_surface
|
||||
gtk_image_get_texture
|
||||
gtk_image_get_icon_name
|
||||
gtk_image_get_gicon
|
||||
@ -1493,14 +1492,12 @@ gtk_image_new_from_pixbuf
|
||||
gtk_image_new_from_icon_name
|
||||
gtk_image_new_from_gicon
|
||||
gtk_image_new_from_resource
|
||||
gtk_image_new_from_surface
|
||||
gtk_image_new_from_texture
|
||||
gtk_image_set_from_file
|
||||
gtk_image_set_from_pixbuf
|
||||
gtk_image_set_from_icon_name
|
||||
gtk_image_set_from_gicon
|
||||
gtk_image_set_from_resource
|
||||
gtk_image_set_from_surface
|
||||
gtk_image_set_from_texture
|
||||
gtk_image_clear
|
||||
gtk_image_new
|
||||
|
@ -80,7 +80,6 @@ enum {
|
||||
PROP_PIXBUF,
|
||||
PROP_PIXBUF_EXPANDER_OPEN,
|
||||
PROP_PIXBUF_EXPANDER_CLOSED,
|
||||
PROP_SURFACE,
|
||||
PROP_TEXTURE,
|
||||
PROP_ICON_SIZE,
|
||||
PROP_ICON_NAME,
|
||||
@ -163,16 +162,6 @@ gtk_cell_renderer_pixbuf_class_init (GtkCellRendererPixbufClass *class)
|
||||
P_("Pixbuf for closed expander"),
|
||||
GDK_TYPE_PIXBUF,
|
||||
GTK_PARAM_READWRITE));
|
||||
/**
|
||||
* GtkCellRendererPixbuf:surface:
|
||||
*/
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_SURFACE,
|
||||
g_param_spec_boxed ("surface",
|
||||
P_("surface"),
|
||||
P_("The surface to render"),
|
||||
CAIRO_GOBJECT_TYPE_SURFACE,
|
||||
GTK_PARAM_READWRITE));
|
||||
|
||||
/**
|
||||
* GtkCellRendererPixbuf:texture:
|
||||
@ -250,9 +239,6 @@ gtk_cell_renderer_pixbuf_get_property (GObject *object,
|
||||
case PROP_PIXBUF_EXPANDER_CLOSED:
|
||||
g_value_set_object (value, priv->pixbuf_expander_closed);
|
||||
break;
|
||||
case PROP_SURFACE:
|
||||
g_value_set_boxed (value, gtk_image_definition_get_surface (priv->image_def));
|
||||
break;
|
||||
case PROP_TEXTURE:
|
||||
g_value_set_object (value, gtk_image_definition_get_texture (priv->image_def));
|
||||
break;
|
||||
@ -277,9 +263,6 @@ notify_storage_type (GtkCellRendererPixbuf *cellpixbuf,
|
||||
{
|
||||
switch (storage_type)
|
||||
{
|
||||
case GTK_IMAGE_SURFACE:
|
||||
g_object_notify (G_OBJECT (cellpixbuf), "surface");
|
||||
break;
|
||||
case GTK_IMAGE_TEXTURE:
|
||||
g_object_notify (G_OBJECT (cellpixbuf), "texture");
|
||||
break;
|
||||
@ -352,7 +335,7 @@ gtk_cell_renderer_pixbuf_set_property (GObject *object,
|
||||
texture = gdk_texture_new_for_pixbuf (pixbuf);
|
||||
else
|
||||
texture = NULL;
|
||||
take_image_definition (cellpixbuf, gtk_image_definition_new_texture (texture, 1));
|
||||
take_image_definition (cellpixbuf, gtk_image_definition_new_texture (texture));
|
||||
break;
|
||||
case PROP_PIXBUF_EXPANDER_OPEN:
|
||||
if (priv->pixbuf_expander_open)
|
||||
@ -364,9 +347,6 @@ gtk_cell_renderer_pixbuf_set_property (GObject *object,
|
||||
g_object_unref (priv->pixbuf_expander_closed);
|
||||
priv->pixbuf_expander_closed = (GdkPixbuf*) g_value_dup_object (value);
|
||||
break;
|
||||
case PROP_SURFACE:
|
||||
take_image_definition (cellpixbuf, gtk_image_definition_new_surface (g_value_get_boxed (value)));
|
||||
break;
|
||||
case PROP_TEXTURE:
|
||||
take_image_definition (cellpixbuf, gtk_image_definition_new_texture (g_value_get_object (value)));
|
||||
break;
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include "gtkwindowprivate.h"
|
||||
|
||||
#include "gdk/gdkcontentformatsprivate.h"
|
||||
#include "gdk/gdktextureprivate.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
@ -1195,6 +1196,7 @@ gtk_drag_set_icon_surface (GdkDragContext *context,
|
||||
{
|
||||
GtkWidget *widget;
|
||||
double hot_x, hot_y;
|
||||
GdkTexture *texture;
|
||||
|
||||
g_return_if_fail (GDK_IS_DRAG_CONTEXT (context));
|
||||
g_return_if_fail (surface != NULL);
|
||||
@ -1202,7 +1204,9 @@ gtk_drag_set_icon_surface (GdkDragContext *context,
|
||||
cairo_surface_get_device_offset (surface, &hot_x, &hot_y);
|
||||
cairo_surface_set_device_offset (surface, 0, 0);
|
||||
|
||||
widget = gtk_image_new_from_surface (surface);
|
||||
texture = gdk_texture_new_for_surface (surface);
|
||||
widget = gtk_image_new_from_texture (texture);
|
||||
g_object_unref (texture);
|
||||
|
||||
gtk_drag_set_icon_widget_internal (context, widget, (int)hot_x, (int)hot_y, TRUE);
|
||||
}
|
||||
|
@ -6555,7 +6555,6 @@ gtk_entry_clear_icon (GtkEntry *entry,
|
||||
: PROP_GICON_SECONDARY]);
|
||||
break;
|
||||
|
||||
case GTK_IMAGE_SURFACE:
|
||||
case GTK_IMAGE_TEXTURE:
|
||||
case GTK_IMAGE_EMPTY:
|
||||
default:
|
||||
|
@ -213,82 +213,6 @@ get_icon_lookup_flags (GtkIconHelper *self,
|
||||
return flags;
|
||||
}
|
||||
|
||||
static void
|
||||
get_surface_size (cairo_surface_t *surface,
|
||||
int *width,
|
||||
int *height)
|
||||
{
|
||||
GdkRectangle clip;
|
||||
cairo_t *cr;
|
||||
|
||||
cr = cairo_create (surface);
|
||||
if (gdk_cairo_get_clip_rectangle (cr, &clip))
|
||||
{
|
||||
if (clip.x != 0 || clip.y != 0)
|
||||
{
|
||||
g_warning ("origin of surface is %d %d, not supported", clip.x, clip.y);
|
||||
}
|
||||
*width = clip.width;
|
||||
*height = clip.height;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning ("infinite surface size not supported");
|
||||
*width = 0;
|
||||
*height = 0;
|
||||
}
|
||||
|
||||
cairo_destroy (cr);
|
||||
}
|
||||
|
||||
static GdkPaintable *
|
||||
ensure_paintable_from_surface (GtkIconHelper *self,
|
||||
cairo_surface_t *orig_surface,
|
||||
int *scale_out)
|
||||
{
|
||||
cairo_surface_t *map;
|
||||
int width, height, scale;
|
||||
GdkTexture *texture;
|
||||
|
||||
scale = gtk_widget_get_scale_factor (self->owner);
|
||||
*scale_out = scale;
|
||||
_gtk_icon_helper_get_size (self, &width, &height);
|
||||
|
||||
map = cairo_surface_map_to_image (orig_surface,
|
||||
&(GdkRectangle) { 0, 0, width * scale, height * scale});
|
||||
|
||||
if (cairo_image_surface_get_format (map) == CAIRO_FORMAT_ARGB32)
|
||||
{
|
||||
texture = gdk_texture_new_for_data (cairo_image_surface_get_data (map),
|
||||
width * scale,
|
||||
height * scale,
|
||||
cairo_image_surface_get_stride (map));
|
||||
}
|
||||
else
|
||||
{
|
||||
cairo_surface_t *argb_surface;
|
||||
cairo_t *cr;
|
||||
|
||||
argb_surface = cairo_surface_create_similar_image (orig_surface,
|
||||
CAIRO_FORMAT_ARGB32,
|
||||
width * scale, height * scale);
|
||||
|
||||
cr = cairo_create (argb_surface);
|
||||
cairo_set_source_surface (cr, map, 0, 0);
|
||||
cairo_paint (cr);
|
||||
cairo_destroy (cr);
|
||||
texture = gdk_texture_new_for_data (cairo_image_surface_get_data (argb_surface),
|
||||
width * scale,
|
||||
height * scale,
|
||||
cairo_image_surface_get_stride (argb_surface));
|
||||
cairo_surface_destroy (argb_surface);
|
||||
}
|
||||
|
||||
cairo_surface_unmap_image (orig_surface, map);
|
||||
|
||||
return GDK_PAINTABLE (texture);
|
||||
}
|
||||
|
||||
static GdkPaintable *
|
||||
ensure_paintable_from_texture (GtkIconHelper *self,
|
||||
GdkTexture *texture,
|
||||
@ -357,11 +281,6 @@ gtk_icon_helper_load_paintable (GtkIconHelper *self,
|
||||
|
||||
switch (gtk_image_definition_get_storage_type (self->def))
|
||||
{
|
||||
case GTK_IMAGE_SURFACE:
|
||||
paintable = ensure_paintable_from_surface (self, gtk_image_definition_get_surface (self->def), &scale);
|
||||
symbolic = FALSE;
|
||||
break;
|
||||
|
||||
case GTK_IMAGE_TEXTURE:
|
||||
paintable = ensure_paintable_from_texture (self, gtk_image_definition_get_texture (self->def), &scale);
|
||||
symbolic = FALSE;
|
||||
@ -468,7 +387,6 @@ gtk_icon_helper_measure (GtkIconHelper *self,
|
||||
break;
|
||||
|
||||
case GTK_IMAGE_TEXTURE:
|
||||
case GTK_IMAGE_SURFACE:
|
||||
case GTK_IMAGE_ICON_NAME:
|
||||
case GTK_IMAGE_GICON:
|
||||
case GTK_IMAGE_EMPTY:
|
||||
@ -537,12 +455,6 @@ _gtk_icon_helper_get_size (GtkIconHelper *self,
|
||||
data for something that may not yet be visible */
|
||||
switch (gtk_image_definition_get_storage_type (self->def))
|
||||
{
|
||||
case GTK_IMAGE_SURFACE:
|
||||
get_surface_size (gtk_image_definition_get_surface (self->def),
|
||||
&width,
|
||||
&height);
|
||||
break;
|
||||
|
||||
case GTK_IMAGE_ICON_NAME:
|
||||
case GTK_IMAGE_GICON:
|
||||
if (self->pixel_size != -1 || self->force_scale_pixbuf)
|
||||
@ -570,7 +482,7 @@ _gtk_icon_helper_get_size (GtkIconHelper *self,
|
||||
break;
|
||||
}
|
||||
|
||||
/* Otherwise we load the surface to guarantee we get a size */
|
||||
/* Otherwise we load the paintable to guarantee we get a size */
|
||||
if (width == 0)
|
||||
{
|
||||
gtk_icon_helper_ensure_paintable (self);
|
||||
@ -615,13 +527,6 @@ _gtk_icon_helper_set_icon_name (GtkIconHelper *self,
|
||||
gtk_icon_helper_take_definition (self, gtk_image_definition_new_icon_name (icon_name));
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_icon_helper_set_surface (GtkIconHelper *self,
|
||||
cairo_surface_t *surface)
|
||||
{
|
||||
gtk_icon_helper_take_definition (self, gtk_image_definition_new_surface (surface));
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_icon_helper_set_texture (GtkIconHelper *self,
|
||||
GdkTexture *texture)
|
||||
@ -692,12 +597,6 @@ _gtk_icon_helper_peek_gicon (GtkIconHelper *self)
|
||||
return gtk_image_definition_get_gicon (self->def);
|
||||
}
|
||||
|
||||
cairo_surface_t *
|
||||
_gtk_icon_helper_peek_surface (GtkIconHelper *self)
|
||||
{
|
||||
return gtk_image_definition_get_surface (self->def);
|
||||
}
|
||||
|
||||
GdkTexture *
|
||||
_gtk_icon_helper_peek_texture (GtkIconHelper *self)
|
||||
{
|
||||
|
@ -46,8 +46,6 @@ void _gtk_icon_helper_set_gicon (GtkIconHelper *self,
|
||||
|
||||
void _gtk_icon_helper_set_icon_name (GtkIconHelper *self,
|
||||
const gchar *icon_name);
|
||||
void _gtk_icon_helper_set_surface (GtkIconHelper *self,
|
||||
cairo_surface_t *surface);
|
||||
void _gtk_icon_helper_set_texture (GtkIconHelper *self,
|
||||
GdkTexture *texture);
|
||||
void _gtk_icon_helper_set_paintable (GtkIconHelper *self,
|
||||
@ -63,7 +61,6 @@ gint _gtk_icon_helper_get_pixel_size (GtkIconHelper *self);
|
||||
gboolean _gtk_icon_helper_get_use_fallback (GtkIconHelper *self);
|
||||
|
||||
GIcon *_gtk_icon_helper_peek_gicon (GtkIconHelper *self);
|
||||
cairo_surface_t *_gtk_icon_helper_peek_surface (GtkIconHelper *self);
|
||||
GdkTexture *_gtk_icon_helper_peek_texture (GtkIconHelper *self);
|
||||
GdkPaintable *_gtk_icon_helper_peek_paintable (GtkIconHelper *self);
|
||||
|
||||
|
@ -119,7 +119,6 @@ static void gtk_image_get_property (GObject *object,
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_SURFACE,
|
||||
PROP_PAINTABLE,
|
||||
PROP_TEXTURE,
|
||||
PROP_FILE,
|
||||
@ -156,13 +155,6 @@ gtk_image_class_init (GtkImageClass *class)
|
||||
widget_class->unrealize = gtk_image_unrealize;
|
||||
widget_class->style_updated = gtk_image_style_updated;
|
||||
|
||||
image_props[PROP_SURFACE] =
|
||||
g_param_spec_boxed ("surface",
|
||||
P_("Surface"),
|
||||
P_("A cairo_surface_t to display"),
|
||||
CAIRO_GOBJECT_TYPE_SURFACE,
|
||||
GTK_PARAM_READWRITE);
|
||||
|
||||
image_props[PROP_PAINTABLE] =
|
||||
g_param_spec_object ("paintable",
|
||||
P_("Paintable"),
|
||||
@ -314,9 +306,6 @@ gtk_image_set_property (GObject *object,
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_SURFACE:
|
||||
gtk_image_set_from_surface (image, g_value_get_boxed (value));
|
||||
break;
|
||||
case PROP_PAINTABLE:
|
||||
gtk_image_set_from_paintable (image, g_value_get_object (value));
|
||||
break;
|
||||
@ -364,9 +353,6 @@ gtk_image_get_property (GObject *object,
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_SURFACE:
|
||||
g_value_set_boxed (value, _gtk_icon_helper_peek_surface (priv->icon_helper));
|
||||
break;
|
||||
case PROP_PAINTABLE:
|
||||
g_value_set_object (value, _gtk_icon_helper_peek_paintable (priv->icon_helper));
|
||||
break;
|
||||
@ -549,29 +535,6 @@ gtk_image_new_from_texture (GdkTexture *texture)
|
||||
return GTK_WIDGET (image);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_image_new_from_surface:
|
||||
* @surface: (allow-none): a #cairo_surface_t, or %NULL
|
||||
*
|
||||
* Creates a new #GtkImage displaying @surface.
|
||||
* The #GtkImage does not assume a reference to the
|
||||
* surface; you still need to unref it if you own references.
|
||||
* #GtkImage will add its own reference rather than adopting yours.
|
||||
*
|
||||
* Returns: a new #GtkImage
|
||||
**/
|
||||
GtkWidget*
|
||||
gtk_image_new_from_surface (cairo_surface_t *surface)
|
||||
{
|
||||
GtkImage *image;
|
||||
|
||||
image = g_object_new (GTK_TYPE_IMAGE, NULL);
|
||||
|
||||
gtk_image_set_from_surface (image, surface);
|
||||
|
||||
return GTK_WIDGET (image);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_image_new_from_icon_name:
|
||||
* @icon_name: (nullable): an icon name or %NULL
|
||||
@ -962,39 +925,6 @@ gtk_image_set_from_gicon (GtkImage *image,
|
||||
g_object_thaw_notify (G_OBJECT (image));
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_image_set_from_surface:
|
||||
* @image: a #GtkImage
|
||||
* @surface: (nullable): a cairo_surface_t or %NULL
|
||||
*
|
||||
* See gtk_image_new_from_surface() for details.
|
||||
**/
|
||||
void
|
||||
gtk_image_set_from_surface (GtkImage *image,
|
||||
cairo_surface_t *surface)
|
||||
{
|
||||
GtkImagePrivate *priv = gtk_image_get_instance_private (image);
|
||||
|
||||
g_return_if_fail (GTK_IS_IMAGE (image));
|
||||
|
||||
g_object_freeze_notify (G_OBJECT (image));
|
||||
|
||||
if (surface)
|
||||
cairo_surface_reference (surface);
|
||||
|
||||
gtk_image_clear (image);
|
||||
|
||||
if (surface)
|
||||
{
|
||||
_gtk_icon_helper_set_surface (priv->icon_helper, surface);
|
||||
cairo_surface_destroy (surface);
|
||||
}
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (image), image_props[PROP_SURFACE]);
|
||||
|
||||
g_object_thaw_notify (G_OBJECT (image));
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_image_paintable_invalidate_contents (GdkPaintable *paintable,
|
||||
GtkImage *image)
|
||||
@ -1107,29 +1037,6 @@ gtk_image_get_storage_type (GtkImage *image)
|
||||
return _gtk_icon_helper_get_storage_type (priv->icon_helper);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_image_get_surface:
|
||||
* @image: a #GtkImage
|
||||
*
|
||||
* Gets the image #cairo_surface_t being displayed by the #GtkImage.
|
||||
* The storage type of the image must be %GTK_IMAGE_EMPTY or
|
||||
* %GTK_IMAGE_SURFACE (see gtk_image_get_storage_type()).
|
||||
* The caller of this function does not own a reference to the
|
||||
* returned surface.
|
||||
*
|
||||
* Returns: (nullable) (transfer none): the displayed surface, or %NULL if
|
||||
* the image is empty
|
||||
**/
|
||||
cairo_surface_t *
|
||||
gtk_image_get_surface (GtkImage *image)
|
||||
{
|
||||
GtkImagePrivate *priv = gtk_image_get_instance_private (image);
|
||||
|
||||
g_return_val_if_fail (GTK_IS_IMAGE (image), NULL);
|
||||
|
||||
return _gtk_icon_helper_peek_surface (priv->icon_helper);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_image_get_paintable:
|
||||
* @image: a #GtkImage
|
||||
@ -1336,9 +1243,6 @@ gtk_image_notify_for_storage_type (GtkImage *image,
|
||||
case GTK_IMAGE_GICON:
|
||||
g_object_notify_by_pspec (G_OBJECT (image), image_props[PROP_GICON]);
|
||||
break;
|
||||
case GTK_IMAGE_SURFACE:
|
||||
g_object_notify_by_pspec (G_OBJECT (image), image_props[PROP_SURFACE]);
|
||||
break;
|
||||
case GTK_IMAGE_TEXTURE:
|
||||
g_object_notify_by_pspec (G_OBJECT (image), image_props[PROP_TEXTURE]);
|
||||
break;
|
||||
|
@ -55,8 +55,6 @@ typedef struct _GtkImageClass GtkImageClass;
|
||||
* This image type was added in GTK+ 2.6
|
||||
* @GTK_IMAGE_GICON: the widget contains a #GIcon.
|
||||
* This image type was added in GTK+ 2.14
|
||||
* @GTK_IMAGE_SURFACE: the widget contains a #cairo_surface_t.
|
||||
* This image type was added in GTK+ 3.10
|
||||
* @GTK_IMAGE_TEXTURE: the widget contains a #GdkTexture.
|
||||
* This image type was added in GTK+ 3.94
|
||||
* @GTK_IMAGE_PAINTABLE: the widget contains a #GdkPaintable.
|
||||
@ -65,8 +63,8 @@ typedef struct _GtkImageClass GtkImageClass;
|
||||
* Describes the image data representation used by a #GtkImage. If you
|
||||
* want to get the image from the widget, you can only get the
|
||||
* currently-stored representation. e.g. if the
|
||||
* gtk_image_get_storage_type() returns #GTK_IMAGE_SURFACE, then you can
|
||||
* call gtk_image_get_surface(). For empty images, you can request any
|
||||
* gtk_image_get_storage_type() returns #GTK_IMAGE_PAINTABLE, then you can
|
||||
* call gtk_image_get_paintable(). For empty images, you can request any
|
||||
* storage type (call any of the "get" functions), but they will all
|
||||
* return %NULL values.
|
||||
*/
|
||||
@ -75,7 +73,6 @@ typedef enum
|
||||
GTK_IMAGE_EMPTY,
|
||||
GTK_IMAGE_ICON_NAME,
|
||||
GTK_IMAGE_GICON,
|
||||
GTK_IMAGE_SURFACE,
|
||||
GTK_IMAGE_TEXTURE,
|
||||
GTK_IMAGE_PAINTABLE
|
||||
} GtkImageType;
|
||||
@ -121,8 +118,6 @@ GDK_AVAILABLE_IN_ALL
|
||||
GtkWidget* gtk_image_new_from_icon_name (const gchar *icon_name);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkWidget* gtk_image_new_from_gicon (GIcon *icon);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkWidget* gtk_image_new_from_surface (cairo_surface_t *surface);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_image_clear (GtkImage *image);
|
||||
@ -148,9 +143,6 @@ GDK_AVAILABLE_IN_ALL
|
||||
void gtk_image_set_from_gicon (GtkImage *image,
|
||||
GIcon *icon);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_image_set_from_surface (GtkImage *image,
|
||||
cairo_surface_t *surface);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_image_set_pixel_size (GtkImage *image,
|
||||
gint pixel_size);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
@ -160,8 +152,6 @@ void gtk_image_set_icon_size (GtkImage *image,
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkImageType gtk_image_get_storage_type (GtkImage *image);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
cairo_surface_t *gtk_image_get_surface (GtkImage *image);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkTexture *gtk_image_get_texture (GtkImage *image);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
|
@ -22,7 +22,6 @@
|
||||
typedef struct _GtkImageDefinitionEmpty GtkImageDefinitionEmpty;
|
||||
typedef struct _GtkImageDefinitionIconName GtkImageDefinitionIconName;
|
||||
typedef struct _GtkImageDefinitionGIcon GtkImageDefinitionGIcon;
|
||||
typedef struct _GtkImageDefinitionSurface GtkImageDefinitionSurface;
|
||||
typedef struct _GtkImageDefinitionTexture GtkImageDefinitionTexture;
|
||||
typedef struct _GtkImageDefinitionPaintable GtkImageDefinitionPaintable;
|
||||
|
||||
@ -45,13 +44,6 @@ struct _GtkImageDefinitionGIcon {
|
||||
GIcon *gicon;
|
||||
};
|
||||
|
||||
struct _GtkImageDefinitionSurface {
|
||||
GtkImageType type;
|
||||
gint ref_count;
|
||||
|
||||
cairo_surface_t *surface;
|
||||
};
|
||||
|
||||
struct _GtkImageDefinitionTexture {
|
||||
GtkImageType type;
|
||||
gint ref_count;
|
||||
@ -72,7 +64,6 @@ union _GtkImageDefinition
|
||||
GtkImageDefinitionEmpty empty;
|
||||
GtkImageDefinitionIconName icon_name;
|
||||
GtkImageDefinitionGIcon gicon;
|
||||
GtkImageDefinitionSurface surface;
|
||||
GtkImageDefinitionTexture texture;
|
||||
GtkImageDefinitionPaintable paintable;
|
||||
};
|
||||
@ -92,7 +83,6 @@ gtk_image_definition_alloc (GtkImageType type)
|
||||
sizeof (GtkImageDefinitionEmpty),
|
||||
sizeof (GtkImageDefinitionIconName),
|
||||
sizeof (GtkImageDefinitionGIcon),
|
||||
sizeof (GtkImageDefinitionSurface),
|
||||
sizeof (GtkImageDefinitionTexture),
|
||||
sizeof (GtkImageDefinitionPaintable)
|
||||
};
|
||||
@ -135,20 +125,6 @@ gtk_image_definition_new_gicon (GIcon *gicon)
|
||||
return def;
|
||||
}
|
||||
|
||||
GtkImageDefinition *
|
||||
gtk_image_definition_new_surface (cairo_surface_t *surface)
|
||||
{
|
||||
GtkImageDefinition *def;
|
||||
|
||||
if (surface == NULL)
|
||||
return NULL;
|
||||
|
||||
def = gtk_image_definition_alloc (GTK_IMAGE_SURFACE);
|
||||
def->surface.surface = cairo_surface_reference (surface);
|
||||
|
||||
return def;
|
||||
}
|
||||
|
||||
GtkImageDefinition *
|
||||
gtk_image_definition_new_texture (GdkTexture *texture)
|
||||
{
|
||||
@ -199,9 +175,6 @@ gtk_image_definition_unref (GtkImageDefinition *def)
|
||||
case GTK_IMAGE_EMPTY:
|
||||
g_assert_not_reached ();
|
||||
break;
|
||||
case GTK_IMAGE_SURFACE:
|
||||
cairo_surface_destroy (def->surface.surface);
|
||||
break;
|
||||
case GTK_IMAGE_TEXTURE:
|
||||
g_object_unref (def->texture.texture);
|
||||
break;
|
||||
@ -233,7 +206,6 @@ gtk_image_definition_get_scale (const GtkImageDefinition *def)
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
case GTK_IMAGE_EMPTY:
|
||||
case GTK_IMAGE_SURFACE:
|
||||
case GTK_IMAGE_PAINTABLE:
|
||||
case GTK_IMAGE_TEXTURE:
|
||||
case GTK_IMAGE_ICON_NAME:
|
||||
@ -260,15 +232,6 @@ gtk_image_definition_get_gicon (const GtkImageDefinition *def)
|
||||
return def->gicon.gicon;
|
||||
}
|
||||
|
||||
cairo_surface_t *
|
||||
gtk_image_definition_get_surface (const GtkImageDefinition *def)
|
||||
{
|
||||
if (def->type != GTK_IMAGE_SURFACE)
|
||||
return NULL;
|
||||
|
||||
return def->surface.surface;
|
||||
}
|
||||
|
||||
GdkTexture *
|
||||
gtk_image_definition_get_texture (const GtkImageDefinition *def)
|
||||
{
|
||||
|
@ -28,7 +28,6 @@ typedef union _GtkImageDefinition GtkImageDefinition;
|
||||
GtkImageDefinition * gtk_image_definition_new_empty (void);
|
||||
GtkImageDefinition * gtk_image_definition_new_icon_name (const char *icon_name);
|
||||
GtkImageDefinition * gtk_image_definition_new_gicon (GIcon *gicon);
|
||||
GtkImageDefinition * gtk_image_definition_new_surface (cairo_surface_t *surface);
|
||||
GtkImageDefinition * gtk_image_definition_new_texture (GdkTexture *texture);
|
||||
GtkImageDefinition * gtk_image_definition_new_paintable (GdkPaintable *paintable);
|
||||
|
||||
@ -39,7 +38,6 @@ GtkImageType gtk_image_definition_get_storage_type (const GtkImageD
|
||||
gint gtk_image_definition_get_scale (const GtkImageDefinition *def);
|
||||
const gchar * gtk_image_definition_get_icon_name (const GtkImageDefinition *def);
|
||||
GIcon * gtk_image_definition_get_gicon (const GtkImageDefinition *def);
|
||||
cairo_surface_t * gtk_image_definition_get_surface (const GtkImageDefinition *def);
|
||||
GdkTexture * gtk_image_definition_get_texture (const GtkImageDefinition *def);
|
||||
GdkPaintable * gtk_image_definition_get_paintable (const GtkImageDefinition *def);
|
||||
|
||||
|
@ -717,34 +717,6 @@ clone_image_menu_size (GtkImage *image)
|
||||
|
||||
return gtk_image_new_from_gicon (icon);
|
||||
}
|
||||
else if (storage_type == GTK_IMAGE_SURFACE)
|
||||
{
|
||||
int width, height;
|
||||
cairo_surface_t *src_surface, *dest_surface;
|
||||
GtkWidget *cloned_image;
|
||||
gint scale = gtk_widget_get_scale_factor (GTK_WIDGET (image));
|
||||
cairo_t *cr;
|
||||
|
||||
gtk_image_get_image_size (image, &width, &height);
|
||||
|
||||
src_surface = gtk_image_get_surface (image);
|
||||
dest_surface =
|
||||
gdk_window_create_similar_image_surface (gtk_widget_get_window (GTK_WIDGET (image)),
|
||||
CAIRO_FORMAT_ARGB32,
|
||||
width * scale, height * scale, scale);
|
||||
cr = cairo_create (dest_surface);
|
||||
cairo_set_source_surface (cr, src_surface, 0, 0);
|
||||
cairo_scale (cr,
|
||||
width / cairo_image_surface_get_width (src_surface),
|
||||
height / cairo_image_surface_get_height (src_surface));
|
||||
cairo_paint (cr);
|
||||
cairo_destroy (cr);
|
||||
|
||||
cloned_image = gtk_image_new_from_surface (dest_surface);
|
||||
cairo_surface_destroy (dest_surface);
|
||||
|
||||
return cloned_image;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user