mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-07-02 17:03:26 +00:00
app, pdb: allow rendering font previews with theme colors.
This also depends on the same settings to render brushes with theme colors, because this is data, not user interface. Therefore following theme colors is not necessarily what creators would expect.
This commit is contained in:
parent
e41776ef39
commit
7262faed16
34 changed files with 329 additions and 106 deletions
|
@ -80,7 +80,8 @@ static GimpTempBuf * gimp_brush_get_new_preview (GimpViewable *vie
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color);
|
||||
GeglColor *color,
|
||||
GeglColor *background);
|
||||
static gchar * gimp_brush_get_description (GimpViewable *viewable,
|
||||
gchar **tooltip);
|
||||
|
||||
|
@ -274,7 +275,8 @@ gimp_brush_get_new_preview (GimpViewable *viewable,
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color)
|
||||
GeglColor *color,
|
||||
GeglColor *background)
|
||||
{
|
||||
GimpBrush *brush = GIMP_BRUSH (viewable);
|
||||
const GimpTempBuf *mask_buf = brush->priv->mask;
|
||||
|
|
|
@ -62,12 +62,14 @@ static GimpTempBuf * gimp_buffer_get_new_preview (GimpViewable *viewable,
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color);
|
||||
GeglColor *color,
|
||||
GeglColor *background);
|
||||
static GdkPixbuf * gimp_buffer_get_new_pixbuf (GimpViewable *viewable,
|
||||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color);
|
||||
GeglColor *color,
|
||||
GeglColor *background);
|
||||
static gchar * gimp_buffer_get_description (GimpViewable *viewable,
|
||||
gchar **tooltip);
|
||||
|
||||
|
@ -227,7 +229,8 @@ gimp_buffer_get_new_preview (GimpViewable *viewable,
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color G_GNUC_UNUSED)
|
||||
GeglColor *color G_GNUC_UNUSED,
|
||||
GeglColor *background G_GNUC_UNUSED)
|
||||
{
|
||||
GimpBuffer *buffer = GIMP_BUFFER (viewable);
|
||||
const Babl *format = gimp_buffer_get_format (buffer);
|
||||
|
@ -262,7 +265,8 @@ gimp_buffer_get_new_pixbuf (GimpViewable *viewable,
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color G_GNUC_UNUSED)
|
||||
GeglColor *color G_GNUC_UNUSED,
|
||||
GeglColor *background G_GNUC_UNUSED)
|
||||
{
|
||||
GimpBuffer *buffer = GIMP_BUFFER (viewable);
|
||||
GdkPixbuf *pixbuf;
|
||||
|
|
|
@ -87,7 +87,8 @@ static GimpTempBuf * gimp_curve_get_new_preview (GimpViewable *viewable,
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color);
|
||||
GeglColor *color,
|
||||
GeglColor *background);
|
||||
static gchar * gimp_curve_get_description (GimpViewable *viewable,
|
||||
gchar **tooltip);
|
||||
|
||||
|
@ -523,7 +524,8 @@ gimp_curve_get_new_preview (GimpViewable *viewable,
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color G_GNUC_UNUSED)
|
||||
GeglColor *color G_GNUC_UNUSED,
|
||||
GeglColor *background G_GNUC_UNUSED)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -113,7 +113,8 @@ gimp_drawable_get_new_preview (GimpViewable *viewable,
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color G_GNUC_UNUSED)
|
||||
GeglColor *color G_GNUC_UNUSED,
|
||||
GeglColor *background G_GNUC_UNUSED)
|
||||
{
|
||||
GimpItem *item = GIMP_ITEM (viewable);
|
||||
GimpImage *image = gimp_item_get_image (item);
|
||||
|
@ -134,7 +135,8 @@ gimp_drawable_get_new_pixbuf (GimpViewable *viewable,
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color G_GNUC_UNUSED)
|
||||
GeglColor *color G_GNUC_UNUSED,
|
||||
GeglColor *background G_GNUC_UNUSED)
|
||||
{
|
||||
GimpItem *item = GIMP_ITEM (viewable);
|
||||
GimpImage *image = gimp_item_get_image (item);
|
||||
|
|
|
@ -26,12 +26,14 @@ GimpTempBuf * gimp_drawable_get_new_preview (GimpViewable *viewable,
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color);
|
||||
GeglColor *color,
|
||||
GeglColor *background);
|
||||
GdkPixbuf * gimp_drawable_get_new_pixbuf (GimpViewable *viewable,
|
||||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color);
|
||||
GeglColor *color,
|
||||
GeglColor *background);
|
||||
|
||||
/*
|
||||
* normal functions (no virtuals)
|
||||
|
|
|
@ -61,7 +61,8 @@ static GimpTempBuf * gimp_gradient_get_new_preview (GimpViewable *viewa
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color);
|
||||
GeglColor *color,
|
||||
GeglColor *background);
|
||||
|
||||
static const gchar * gimp_gradient_get_extension (GimpData *data);
|
||||
static void gimp_gradient_copy (GimpData *data,
|
||||
|
@ -215,7 +216,8 @@ gimp_gradient_get_new_preview (GimpViewable *viewable,
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color G_GNUC_UNUSED)
|
||||
GeglColor *color G_GNUC_UNUSED,
|
||||
GeglColor *background G_GNUC_UNUSED)
|
||||
{
|
||||
GimpGradient *gradient = GIMP_GRADIENT (viewable);
|
||||
GimpGradientSegment *seg = NULL;
|
||||
|
|
|
@ -122,7 +122,8 @@ gimp_image_get_new_preview (GimpViewable *viewable,
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color G_GNUC_UNUSED)
|
||||
GeglColor *color G_GNUC_UNUSED,
|
||||
GeglColor *background G_GNUC_UNUSED)
|
||||
{
|
||||
GimpImage *image = GIMP_IMAGE (viewable);
|
||||
const Babl *format;
|
||||
|
@ -152,7 +153,8 @@ gimp_image_get_new_pixbuf (GimpViewable *viewable,
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color G_GNUC_UNUSED)
|
||||
GeglColor *color G_GNUC_UNUSED,
|
||||
GeglColor *background G_GNUC_UNUSED)
|
||||
{
|
||||
GimpImage *image = GIMP_IMAGE (viewable);
|
||||
GdkPixbuf *pixbuf;
|
||||
|
|
|
@ -42,12 +42,14 @@ GimpTempBuf * gimp_image_get_new_preview (GimpViewable *viewable,
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color);
|
||||
GeglColor *color,
|
||||
GeglColor *background);
|
||||
GdkPixbuf * gimp_image_get_new_pixbuf (GimpViewable *viewable,
|
||||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color);
|
||||
GeglColor *color,
|
||||
GeglColor *background);
|
||||
|
||||
|
||||
#endif /* __GIMP_IMAGE_PREVIEW_H__ */
|
||||
|
|
|
@ -85,7 +85,8 @@ static GdkPixbuf * gimp_imagefile_get_new_pixbuf (GimpViewable *viewable,
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color);
|
||||
GeglColor *color,
|
||||
GeglColor *background);
|
||||
static gchar * gimp_imagefile_get_description (GimpViewable *viewable,
|
||||
gchar **tooltip);
|
||||
|
||||
|
@ -226,7 +227,8 @@ gimp_imagefile_get_new_pixbuf (GimpViewable *viewable,
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color G_GNUC_UNUSED)
|
||||
GeglColor *color G_GNUC_UNUSED,
|
||||
GeglColor *background G_GNUC_UNUSED)
|
||||
{
|
||||
GimpImagefile *imagefile = GIMP_IMAGEFILE (viewable);
|
||||
|
||||
|
@ -1063,7 +1065,7 @@ gimp_imagefile_save_thumb (GimpImagefile *imagefile,
|
|||
pixbuf = gimp_viewable_get_new_pixbuf (GIMP_VIEWABLE (image),
|
||||
/* random context, unused */
|
||||
gimp_get_user_context (image->gimp),
|
||||
width, height, NULL);
|
||||
width, height, NULL, NULL);
|
||||
|
||||
/* when layer previews are disabled, we won't get a pixbuf */
|
||||
if (! pixbuf)
|
||||
|
|
|
@ -94,12 +94,14 @@ static GimpTempBuf * gimp_image_proxy_get_new_preview (GimpViewabl
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color);
|
||||
GeglColor *color,
|
||||
GeglColor *background);
|
||||
static GdkPixbuf * gimp_image_proxy_get_new_pixbuf (GimpViewable *viewable,
|
||||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color);
|
||||
GeglColor *color,
|
||||
GeglColor *background);
|
||||
static gchar * gimp_image_proxy_get_description (GimpViewable *viewable,
|
||||
gchar **tooltip);
|
||||
|
||||
|
@ -376,7 +378,8 @@ gimp_image_proxy_get_new_preview (GimpViewable *viewable,
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color G_GNUC_UNUSED)
|
||||
GeglColor *color G_GNUC_UNUSED,
|
||||
GeglColor *background G_GNUC_UNUSED)
|
||||
{
|
||||
GimpImageProxy *image_proxy = GIMP_IMAGE_PROXY (viewable);
|
||||
GimpImage *image = image_proxy->priv->image;
|
||||
|
@ -418,7 +421,8 @@ gimp_image_proxy_get_new_pixbuf (GimpViewable *viewable,
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color G_GNUC_UNUSED)
|
||||
GeglColor *color G_GNUC_UNUSED,
|
||||
GeglColor *background G_GNUC_UNUSED)
|
||||
{
|
||||
GimpImageProxy *image_proxy = GIMP_IMAGE_PROXY (viewable);
|
||||
GimpImage *image = image_proxy->priv->image;
|
||||
|
|
|
@ -76,7 +76,8 @@ static GimpTempBuf * gimp_palette_get_new_preview (GimpViewable *vie
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color);
|
||||
GeglColor *color,
|
||||
GeglColor *background);
|
||||
static gchar * gimp_palette_get_description (GimpViewable *viewable,
|
||||
gchar **tooltip);
|
||||
static const gchar * gimp_palette_get_extension (GimpData *data);
|
||||
|
@ -241,7 +242,8 @@ gimp_palette_get_new_preview (GimpViewable *viewable,
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color G_GNUC_UNUSED)
|
||||
GeglColor *color G_GNUC_UNUSED,
|
||||
GeglColor *background G_GNUC_UNUSED)
|
||||
{
|
||||
GimpPalette *palette = GIMP_PALETTE (viewable);
|
||||
GimpTempBuf *temp_buf;
|
||||
|
|
|
@ -50,7 +50,8 @@ static GimpTempBuf * gimp_pattern_get_new_preview (GimpViewable *viewa
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color);
|
||||
GeglColor *color,
|
||||
GeglColor *background);
|
||||
static gchar * gimp_pattern_get_description (GimpViewable *viewable,
|
||||
gchar **tooltip);
|
||||
|
||||
|
@ -143,7 +144,8 @@ gimp_pattern_get_new_preview (GimpViewable *viewable,
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color G_GNUC_UNUSED)
|
||||
GeglColor *color G_GNUC_UNUSED,
|
||||
GeglColor *background G_GNUC_UNUSED)
|
||||
{
|
||||
GimpPattern *pattern = GIMP_PATTERN (viewable);
|
||||
GimpTempBuf *temp_buf;
|
||||
|
|
|
@ -83,7 +83,8 @@ static GimpTempBuf * gimp_undo_get_new_preview (GimpViewable *viewabl
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color);
|
||||
GeglColor *color,
|
||||
GeglColor *background);
|
||||
|
||||
static void gimp_undo_real_pop (GimpUndo *undo,
|
||||
GimpUndoMode undo_mode,
|
||||
|
@ -303,7 +304,8 @@ gimp_undo_get_new_preview (GimpViewable *viewable,
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color)
|
||||
GeglColor *color G_GNUC_UNUSED,
|
||||
GeglColor *background G_GNUC_UNUSED)
|
||||
{
|
||||
GimpUndo *undo = GIMP_UNDO (viewable);
|
||||
|
||||
|
@ -493,7 +495,7 @@ gimp_undo_create_preview_private (GimpUndo *undo,
|
|||
}
|
||||
|
||||
undo->preview = gimp_viewable_get_new_preview (preview_viewable, context,
|
||||
width, height, NULL);
|
||||
width, height, NULL, NULL);
|
||||
|
||||
gimp_viewable_invalidate_preview (GIMP_VIEWABLE (undo));
|
||||
}
|
||||
|
|
|
@ -74,6 +74,10 @@ struct _GimpViewablePrivate
|
|||
|
||||
GimpTempBuf *preview_temp_buf;
|
||||
GdkPixbuf *preview_pixbuf;
|
||||
GeglColor *preview_pixbuf_color;
|
||||
GeglColor *preview_pixbuf_background;
|
||||
GeglColor *preview_temp_buf_color;
|
||||
GeglColor *preview_temp_buf_background;
|
||||
};
|
||||
|
||||
#define GET_PRIVATE(viewable) ((GimpViewablePrivate *) gimp_viewable_get_instance_private ((GimpViewable *) (viewable)))
|
||||
|
@ -101,7 +105,8 @@ static GdkPixbuf * gimp_viewable_real_get_new_pixbuf (GimpViewable *viewable,
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color);
|
||||
GeglColor *color,
|
||||
GeglColor *background);
|
||||
static void gimp_viewable_real_get_preview_size (GimpViewable *viewable,
|
||||
gint size,
|
||||
gboolean popup,
|
||||
|
@ -249,6 +254,10 @@ gimp_viewable_finalize (GObject *object)
|
|||
g_clear_object (&private->icon_pixbuf);
|
||||
g_clear_pointer (&private->preview_temp_buf, gimp_temp_buf_unref);
|
||||
g_clear_object (&private->preview_pixbuf);
|
||||
g_clear_object (&private->preview_pixbuf_color);
|
||||
g_clear_object (&private->preview_pixbuf_background);
|
||||
g_clear_object (&private->preview_temp_buf_color);
|
||||
g_clear_object (&private->preview_temp_buf_background);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
@ -335,6 +344,10 @@ gimp_viewable_real_invalidate_preview (GimpViewable *viewable)
|
|||
|
||||
g_clear_pointer (&private->preview_temp_buf, gimp_temp_buf_unref);
|
||||
g_clear_object (&private->preview_pixbuf);
|
||||
g_clear_object (&private->preview_pixbuf_color);
|
||||
g_clear_object (&private->preview_pixbuf_background);
|
||||
g_clear_object (&private->preview_temp_buf_color);
|
||||
g_clear_object (&private->preview_temp_buf_background);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -404,13 +417,14 @@ gimp_viewable_real_get_new_pixbuf (GimpViewable *viewable,
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color)
|
||||
GeglColor *color,
|
||||
GeglColor *background)
|
||||
{
|
||||
GimpViewablePrivate *private = GET_PRIVATE (viewable);
|
||||
GdkPixbuf *pixbuf = NULL;
|
||||
GimpTempBuf *temp_buf;
|
||||
|
||||
temp_buf = gimp_viewable_get_preview (viewable, context, width, height, color);
|
||||
temp_buf = gimp_viewable_get_preview (viewable, context, width, height, color, background);
|
||||
|
||||
if (temp_buf)
|
||||
{
|
||||
|
@ -831,6 +845,8 @@ gimp_viewable_get_popup_size (GimpViewable *viewable,
|
|||
* @height: desired height for the preview
|
||||
* @color: desired foreground color for the preview when the type of
|
||||
* @viewable support recolorization.
|
||||
* @background: desired background color for the preview when the type
|
||||
* of @viewable supports recolorization.
|
||||
*
|
||||
* Gets a preview for a viewable object, by running through a variety
|
||||
* of methods until it finds one that works. First, if an
|
||||
|
@ -856,7 +872,8 @@ gimp_viewable_get_preview (GimpViewable *viewable,
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color)
|
||||
GeglColor *color,
|
||||
GeglColor *background)
|
||||
{
|
||||
GimpViewablePrivate *private = GET_PRIVATE (viewable);
|
||||
GimpViewableClass *viewable_class;
|
||||
|
@ -866,6 +883,8 @@ gimp_viewable_get_preview (GimpViewable *viewable,
|
|||
g_return_val_if_fail (context == NULL || GIMP_IS_CONTEXT (context), NULL);
|
||||
g_return_val_if_fail (width > 0, NULL);
|
||||
g_return_val_if_fail (height > 0, NULL);
|
||||
g_return_val_if_fail ((color == NULL && background == NULL) ||
|
||||
(color != NULL && background != NULL), NULL);
|
||||
|
||||
if (G_UNLIKELY (context == NULL))
|
||||
g_warning ("%s: context is NULL", G_STRFUNC);
|
||||
|
@ -873,27 +892,58 @@ gimp_viewable_get_preview (GimpViewable *viewable,
|
|||
viewable_class = GIMP_VIEWABLE_GET_CLASS (viewable);
|
||||
|
||||
if (viewable_class->get_preview)
|
||||
temp_buf = viewable_class->get_preview (viewable, context, width, height, color);
|
||||
temp_buf = viewable_class->get_preview (viewable, context, width, height, color, background);
|
||||
|
||||
if (temp_buf)
|
||||
return temp_buf;
|
||||
|
||||
if (private->preview_temp_buf)
|
||||
if (private->preview_temp_buf &&
|
||||
((color == NULL && private->preview_temp_buf_color == NULL) ||
|
||||
(color != NULL && private->preview_temp_buf_color != NULL)))
|
||||
{
|
||||
if (gimp_temp_buf_get_width (private->preview_temp_buf) == width &&
|
||||
gimp_temp_buf_get_height (private->preview_temp_buf) == height)
|
||||
{
|
||||
return private->preview_temp_buf;
|
||||
}
|
||||
gboolean same_colors = TRUE;
|
||||
|
||||
g_clear_pointer (&private->preview_temp_buf, gimp_temp_buf_unref);
|
||||
if (color != NULL)
|
||||
{
|
||||
gdouble r1, g1, b1, a1;
|
||||
gdouble r2, g2, b2, a2;
|
||||
|
||||
/* Don't use gimp_color_is_perceptually_identical(). Exact
|
||||
* comparison is fine for this use case.
|
||||
*/
|
||||
gegl_color_get_rgba (color, &r1, &g1, &b1, &a1);
|
||||
gegl_color_get_rgba (private->preview_temp_buf_color, &r2, &g2, &b2, &a2);
|
||||
|
||||
same_colors = (r1 == r2 && g1 == g2 && b1 == b2 && a1 == a2);
|
||||
|
||||
if (same_colors)
|
||||
{
|
||||
gegl_color_get_rgba (background, &r1, &g1, &b1, &a1);
|
||||
gegl_color_get_rgba (private->preview_temp_buf_background, &r2, &g2, &b2, &a2);
|
||||
|
||||
same_colors = (r1 == r2 && g1 == g2 && b1 == b2 && a1 == a2);
|
||||
}
|
||||
}
|
||||
|
||||
if (same_colors)
|
||||
return private->preview_temp_buf;
|
||||
}
|
||||
}
|
||||
|
||||
g_clear_pointer (&private->preview_temp_buf, gimp_temp_buf_unref);
|
||||
g_clear_object (&private->preview_temp_buf_color);
|
||||
g_clear_object (&private->preview_temp_buf_background);
|
||||
|
||||
if (viewable_class->get_new_preview)
|
||||
temp_buf = viewable_class->get_new_preview (viewable, context,
|
||||
width, height, color);
|
||||
width, height, color, background);
|
||||
|
||||
private->preview_temp_buf = temp_buf;
|
||||
private->preview_temp_buf = temp_buf;
|
||||
private->preview_temp_buf_color = color ? gegl_color_duplicate (color) : NULL;
|
||||
private->preview_temp_buf_background = background ? gegl_color_duplicate (background) : NULL;
|
||||
|
||||
return temp_buf;
|
||||
}
|
||||
|
@ -905,6 +955,8 @@ gimp_viewable_get_preview (GimpViewable *viewable,
|
|||
* @height: desired height for the preview
|
||||
* @color: desired foreground color for the preview when the type of
|
||||
* @viewable support recolorization.
|
||||
* @background: desired background color for the preview when the type
|
||||
* of @viewable supports recolorization.
|
||||
*
|
||||
* Gets a new preview for a viewable object. Similar to
|
||||
* gimp_viewable_get_preview(), except that it tries things in a
|
||||
|
@ -920,7 +972,8 @@ gimp_viewable_get_new_preview (GimpViewable *viewable,
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color)
|
||||
GeglColor *color,
|
||||
GeglColor *background)
|
||||
{
|
||||
GimpViewableClass *viewable_class;
|
||||
GimpTempBuf *temp_buf = NULL;
|
||||
|
@ -937,14 +990,14 @@ gimp_viewable_get_new_preview (GimpViewable *viewable,
|
|||
|
||||
if (viewable_class->get_new_preview)
|
||||
temp_buf = viewable_class->get_new_preview (viewable, context,
|
||||
width, height, color);
|
||||
width, height, color, background);
|
||||
|
||||
if (temp_buf)
|
||||
return temp_buf;
|
||||
|
||||
if (viewable_class->get_preview)
|
||||
temp_buf = viewable_class->get_preview (viewable, context,
|
||||
width, height, color);
|
||||
width, height, color, background);
|
||||
|
||||
if (temp_buf)
|
||||
return gimp_temp_buf_copy (temp_buf);
|
||||
|
@ -997,7 +1050,9 @@ gimp_viewable_get_dummy_preview (GimpViewable *viewable,
|
|||
* @width: desired width for the preview
|
||||
* @height: desired height for the preview
|
||||
* @color: desired foreground color for the preview when the type of
|
||||
* @viewable support recolorization.
|
||||
* @viewable supports recolorization.
|
||||
* @background: desired background color for the preview when the type
|
||||
* of @viewable supports recolorization.
|
||||
*
|
||||
* Gets a preview for a viewable object, by running through a variety
|
||||
* of methods until it finds one that works. First, if an
|
||||
|
@ -1017,7 +1072,8 @@ gimp_viewable_get_pixbuf (GimpViewable *viewable,
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color)
|
||||
GeglColor *color,
|
||||
GeglColor *background)
|
||||
{
|
||||
GimpViewablePrivate *private = GET_PRIVATE (viewable);
|
||||
GimpViewableClass *viewable_class;
|
||||
|
@ -1027,6 +1083,8 @@ gimp_viewable_get_pixbuf (GimpViewable *viewable,
|
|||
g_return_val_if_fail (context == NULL || GIMP_IS_CONTEXT (context), NULL);
|
||||
g_return_val_if_fail (width > 0, NULL);
|
||||
g_return_val_if_fail (height > 0, NULL);
|
||||
g_return_val_if_fail ((color == NULL && background == NULL) ||
|
||||
(color != NULL && background != NULL), NULL);
|
||||
|
||||
if (G_UNLIKELY (context == NULL))
|
||||
g_warning ("%s: context is NULL", G_STRFUNC);
|
||||
|
@ -1034,26 +1092,57 @@ gimp_viewable_get_pixbuf (GimpViewable *viewable,
|
|||
viewable_class = GIMP_VIEWABLE_GET_CLASS (viewable);
|
||||
|
||||
if (viewable_class->get_pixbuf)
|
||||
pixbuf = viewable_class->get_pixbuf (viewable, context, width, height, color);
|
||||
pixbuf = viewable_class->get_pixbuf (viewable, context, width, height, color, background);
|
||||
|
||||
if (pixbuf)
|
||||
return pixbuf;
|
||||
|
||||
if (private->preview_pixbuf)
|
||||
if (private->preview_pixbuf &&
|
||||
((color == NULL && private->preview_pixbuf_color == NULL) ||
|
||||
(color != NULL && private->preview_pixbuf_color != NULL)))
|
||||
{
|
||||
if (gdk_pixbuf_get_width (private->preview_pixbuf) == width &&
|
||||
gdk_pixbuf_get_height (private->preview_pixbuf) == height)
|
||||
{
|
||||
return private->preview_pixbuf;
|
||||
}
|
||||
gboolean same_colors = TRUE;
|
||||
|
||||
g_clear_object (&private->preview_pixbuf);
|
||||
if (color != NULL)
|
||||
{
|
||||
gdouble r1, g1, b1, a1;
|
||||
gdouble r2, g2, b2, a2;
|
||||
|
||||
/* Don't use gimp_color_is_perceptually_identical(). Exact
|
||||
* comparison is fine for this use case.
|
||||
*/
|
||||
gegl_color_get_rgba (color, &r1, &g1, &b1, &a1);
|
||||
gegl_color_get_rgba (private->preview_pixbuf_color, &r2, &g2, &b2, &a2);
|
||||
|
||||
same_colors = (r1 == r2 && g1 == g2 && b1 == b2 && a1 == a2);
|
||||
|
||||
if (same_colors)
|
||||
{
|
||||
gegl_color_get_rgba (background, &r1, &g1, &b1, &a1);
|
||||
gegl_color_get_rgba (private->preview_pixbuf_background, &r2, &g2, &b2, &a2);
|
||||
|
||||
same_colors = (r1 == r2 && g1 == g2 && b1 == b2 && a1 == a2);
|
||||
}
|
||||
}
|
||||
|
||||
if (same_colors)
|
||||
return private->preview_pixbuf;
|
||||
}
|
||||
}
|
||||
|
||||
if (viewable_class->get_new_pixbuf)
|
||||
pixbuf = viewable_class->get_new_pixbuf (viewable, context, width, height, color);
|
||||
g_clear_object (&private->preview_pixbuf);
|
||||
g_clear_object (&private->preview_pixbuf_color);
|
||||
g_clear_object (&private->preview_pixbuf_background);
|
||||
|
||||
private->preview_pixbuf = pixbuf;
|
||||
if (viewable_class->get_new_pixbuf)
|
||||
pixbuf = viewable_class->get_new_pixbuf (viewable, context, width, height, color, background);
|
||||
|
||||
private->preview_pixbuf = pixbuf;
|
||||
private->preview_pixbuf_color = color ? gegl_color_duplicate (color) : NULL;
|
||||
private->preview_pixbuf_background = background ? gegl_color_duplicate (background) : NULL;
|
||||
|
||||
return pixbuf;
|
||||
}
|
||||
|
@ -1081,7 +1170,8 @@ gimp_viewable_get_new_pixbuf (GimpViewable *viewable,
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color)
|
||||
GeglColor *color,
|
||||
GeglColor *background)
|
||||
{
|
||||
GimpViewableClass *viewable_class;
|
||||
GdkPixbuf *pixbuf = NULL;
|
||||
|
@ -1097,13 +1187,13 @@ gimp_viewable_get_new_pixbuf (GimpViewable *viewable,
|
|||
viewable_class = GIMP_VIEWABLE_GET_CLASS (viewable);
|
||||
|
||||
if (viewable_class->get_new_pixbuf)
|
||||
pixbuf = viewable_class->get_new_pixbuf (viewable, context, width, height, color);
|
||||
pixbuf = viewable_class->get_new_pixbuf (viewable, context, width, height, color, background);
|
||||
|
||||
if (pixbuf)
|
||||
return pixbuf;
|
||||
|
||||
if (viewable_class->get_pixbuf)
|
||||
pixbuf = viewable_class->get_pixbuf (viewable, context, width, height, color);
|
||||
pixbuf = viewable_class->get_pixbuf (viewable, context, width, height, color, background);
|
||||
|
||||
if (pixbuf)
|
||||
return gdk_pixbuf_copy (pixbuf);
|
||||
|
|
|
@ -80,22 +80,26 @@ struct _GimpViewableClass
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *fg_color);
|
||||
GeglColor *fg_color,
|
||||
GeglColor *background);
|
||||
GimpTempBuf * (* get_new_preview) (GimpViewable *viewable,
|
||||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *fg_color);
|
||||
GeglColor *fg_color,
|
||||
GeglColor *background);
|
||||
GdkPixbuf * (* get_pixbuf) (GimpViewable *viewable,
|
||||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *fg_color);
|
||||
GeglColor *fg_color,
|
||||
GeglColor *background);
|
||||
GdkPixbuf * (* get_new_pixbuf) (GimpViewable *viewable,
|
||||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *fg_color);
|
||||
GeglColor *fg_color,
|
||||
GeglColor *background);
|
||||
gchar * (* get_description) (GimpViewable *viewable,
|
||||
gchar **tooltip);
|
||||
|
||||
|
@ -149,12 +153,14 @@ GimpTempBuf * gimp_viewable_get_preview (GimpViewable *viewable,
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *fg_color);
|
||||
GeglColor *fg_color,
|
||||
GeglColor *bg_color);
|
||||
GimpTempBuf * gimp_viewable_get_new_preview (GimpViewable *viewable,
|
||||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *fg_color);
|
||||
GeglColor *fg_color,
|
||||
GeglColor *bg_color);
|
||||
|
||||
GimpTempBuf * gimp_viewable_get_dummy_preview (GimpViewable *viewable,
|
||||
gint width,
|
||||
|
@ -165,12 +171,14 @@ GdkPixbuf * gimp_viewable_get_pixbuf (GimpViewable *viewable,
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color);
|
||||
GeglColor *color,
|
||||
GeglColor *background);
|
||||
GdkPixbuf * gimp_viewable_get_new_pixbuf (GimpViewable *viewable,
|
||||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color);
|
||||
GeglColor *color,
|
||||
GeglColor *background);
|
||||
|
||||
GdkPixbuf * gimp_viewable_get_dummy_pixbuf (GimpViewable *viewable,
|
||||
gint width,
|
||||
|
|
|
@ -163,7 +163,7 @@ gimp_image_metadata_rotate_dialog (GimpImage *image,
|
|||
|
||||
gimp_pickable_flush (GIMP_PICKABLE (image));
|
||||
pixbuf = gimp_viewable_get_pixbuf (GIMP_VIEWABLE (image), context,
|
||||
width, height, NULL);
|
||||
width, height, NULL, NULL);
|
||||
if (pixbuf)
|
||||
{
|
||||
GdkPixbuf *rotated;
|
||||
|
|
|
@ -429,7 +429,7 @@ resize_dialog_new (GimpViewable *viewable,
|
|||
|
||||
gimp_viewable_get_preview_size (viewable, 200, TRUE, TRUE, &width, &height);
|
||||
pixbuf = gimp_viewable_get_pixbuf (viewable, context,
|
||||
width, height, NULL);
|
||||
width, height, NULL, NULL);
|
||||
|
||||
if (pixbuf)
|
||||
gimp_offset_area_set_pixbuf (GIMP_OFFSET_AREA (private->area), pixbuf);
|
||||
|
|
|
@ -980,7 +980,7 @@ drawable_thumbnail_invoker (GimpProcedure *procedure,
|
|||
|
||||
if (image->gimp->config->layer_previews)
|
||||
buf = gimp_viewable_get_new_preview (GIMP_VIEWABLE (drawable), context,
|
||||
width, height, NULL);
|
||||
width, height, NULL, NULL);
|
||||
else
|
||||
buf = gimp_viewable_get_dummy_preview (GIMP_VIEWABLE (drawable),
|
||||
width, height,
|
||||
|
|
|
@ -1849,7 +1849,7 @@ image_thumbnail_invoker (GimpProcedure *procedure,
|
|||
gimp_pickable_flush (GIMP_PICKABLE (image));
|
||||
|
||||
buf = gimp_viewable_get_new_preview (GIMP_VIEWABLE (image), context,
|
||||
width, height, NULL);
|
||||
width, height, NULL, NULL);
|
||||
|
||||
if (buf)
|
||||
{
|
||||
|
|
|
@ -134,7 +134,8 @@ static GimpTempBuf * gimp_font_get_new_preview (GimpViewable *viewab
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color);
|
||||
GeglColor *color,
|
||||
GeglColor *background);
|
||||
|
||||
static void gimp_font_config_iface_init (GimpConfigInterface *iface);
|
||||
static gboolean gimp_font_serialize (GimpConfig *config,
|
||||
|
@ -712,7 +713,8 @@ gimp_font_get_new_preview (GimpViewable *viewable,
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color)
|
||||
GeglColor *color,
|
||||
GeglColor *background)
|
||||
{
|
||||
GimpFont *font = GIMP_FONT (viewable);
|
||||
PangoContext *pango_context;
|
||||
|
@ -726,6 +728,7 @@ gimp_font_get_new_preview (GimpViewable *viewable,
|
|||
GimpTempBuf *temp_buf;
|
||||
cairo_t *cr;
|
||||
cairo_surface_t *surface;
|
||||
gint stride;
|
||||
|
||||
pango_context = gimp_font_factory_get_pango_context (GIMP_FONT_CLASS (g_type_class_peek (GIMP_TYPE_FONT))->font_factory);
|
||||
|
||||
|
@ -763,14 +766,26 @@ gimp_font_get_new_preview (GimpViewable *viewable,
|
|||
layout = g_object_ref (font->popup_layout);
|
||||
}
|
||||
|
||||
width = cairo_format_stride_for_width (CAIRO_FORMAT_A8, width);
|
||||
stride = cairo_format_stride_for_width (CAIRO_FORMAT_ARGB32, width);
|
||||
|
||||
temp_buf = gimp_temp_buf_new (width, height, babl_format ("Y' u8"));
|
||||
memset (gimp_temp_buf_get_data (temp_buf), 255, width * height);
|
||||
temp_buf = gimp_temp_buf_new (width, height, babl_format ("cairo-ARGB32"));
|
||||
if (background)
|
||||
{
|
||||
guint32 *data = (guint32 *) gimp_temp_buf_get_data (temp_buf);
|
||||
guint32 argb;
|
||||
|
||||
gegl_color_get_pixel (background, babl_format ("cairo-ARGB32"), &argb);
|
||||
for (gint i = 0; i < width * height; i++)
|
||||
data[i] = argb;
|
||||
}
|
||||
else
|
||||
{
|
||||
memset (gimp_temp_buf_get_data (temp_buf), 255, width * height * 4);
|
||||
}
|
||||
|
||||
surface = cairo_image_surface_create_for_data (gimp_temp_buf_get_data (temp_buf),
|
||||
CAIRO_FORMAT_A8,
|
||||
width, height, width);
|
||||
CAIRO_FORMAT_ARGB32,
|
||||
width, height, stride);
|
||||
|
||||
pango_layout_get_pixel_extents (layout, &ink, &logical);
|
||||
|
||||
|
@ -789,7 +804,18 @@ gimp_font_get_new_preview (GimpViewable *viewable,
|
|||
cr = cairo_create (surface);
|
||||
|
||||
cairo_translate (cr, layout_x, layout_y);
|
||||
cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
|
||||
cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
|
||||
if (color)
|
||||
{
|
||||
gfloat rgb[3];
|
||||
|
||||
gegl_color_get_pixel (color, babl_format ("R'G'B' float"), rgb);
|
||||
cairo_set_source_rgb (cr, rgb[0], rgb[1], rgb[2]);
|
||||
}
|
||||
else
|
||||
{
|
||||
cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
|
||||
}
|
||||
pango_cairo_show_layout (cr, layout);
|
||||
|
||||
cairo_destroy (cr);
|
||||
|
|
|
@ -41,7 +41,8 @@ gimp_path_get_new_preview (GimpViewable *viewable,
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color)
|
||||
GeglColor *color G_GNUC_UNUSED,
|
||||
GeglColor *background G_GNUC_UNUSED)
|
||||
{
|
||||
GimpPath *path;
|
||||
GimpItem *item;
|
||||
|
|
|
@ -27,7 +27,8 @@ GimpTempBuf * gimp_path_get_new_preview (GimpViewable *viewable,
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GeglColor *color);
|
||||
GeglColor *color,
|
||||
GeglColor *background);
|
||||
|
||||
|
||||
#endif /* __GIMP_PATH_PREVIEW_H__ */
|
||||
|
|
|
@ -1172,7 +1172,7 @@ gimp_clipboard_send_image (GtkClipboard *clipboard,
|
|||
gimp_get_user_context (gimp),
|
||||
gimp_image_get_width (gimp_clip->image),
|
||||
gimp_image_get_height (gimp_clip->image),
|
||||
NULL);
|
||||
NULL, NULL);
|
||||
|
||||
if (pixbuf)
|
||||
{
|
||||
|
@ -1218,7 +1218,7 @@ gimp_clipboard_send_buffer (GtkClipboard *clipboard,
|
|||
gimp_get_user_context (gimp),
|
||||
gimp_buffer_get_width (gimp_clip->buffer),
|
||||
gimp_buffer_get_height (gimp_clip->buffer),
|
||||
NULL);
|
||||
NULL, NULL);
|
||||
|
||||
if (pixbuf)
|
||||
{
|
||||
|
|
|
@ -811,7 +811,8 @@ gimp_container_icon_view_drag_pixbuf (GtkWidget *widget,
|
|||
|
||||
if (renderer && gimp_viewable_get_size (renderer->viewable, &width, &height))
|
||||
{
|
||||
GeglColor *color = NULL;
|
||||
GeglColor *color = NULL;
|
||||
GeglColor *background = NULL;
|
||||
GdkPixbuf *pixbuf;
|
||||
|
||||
if (renderer->context)
|
||||
|
@ -825,27 +826,36 @@ gimp_container_icon_view_drag_pixbuf (GtkWidget *widget,
|
|||
{
|
||||
GtkStyleContext *style;
|
||||
GdkRGBA *fg_color = NULL;
|
||||
GdkRGBA *bg_color = NULL;
|
||||
|
||||
style = gtk_widget_get_style_context (widget);
|
||||
gtk_style_context_get (style, gtk_style_context_get_state (style),
|
||||
GTK_STYLE_PROPERTY_COLOR, &fg_color,
|
||||
GTK_STYLE_PROPERTY_COLOR, &fg_color,
|
||||
GTK_STYLE_PROPERTY_BACKGROUND_COLOR, &bg_color,
|
||||
NULL);
|
||||
if (fg_color)
|
||||
if (fg_color && bg_color)
|
||||
{
|
||||
color = gegl_color_new (NULL);
|
||||
gegl_color_set_rgba_with_space (color,
|
||||
fg_color->red, fg_color->green, fg_color->blue, 1.0,
|
||||
NULL);
|
||||
|
||||
background = gegl_color_new (NULL);
|
||||
gegl_color_set_rgba_with_space (background,
|
||||
bg_color->red, bg_color->green, bg_color->blue, 1.0,
|
||||
NULL);
|
||||
}
|
||||
g_clear_pointer (&fg_color, gdk_rgba_free);
|
||||
g_clear_pointer (&bg_color, gdk_rgba_free);
|
||||
}
|
||||
}
|
||||
|
||||
pixbuf = gimp_viewable_get_new_pixbuf (renderer->viewable,
|
||||
renderer->context,
|
||||
width, height, color);
|
||||
width, height, color, background);
|
||||
|
||||
g_clear_object (&color);
|
||||
g_clear_object (&background);
|
||||
|
||||
return pixbuf;
|
||||
}
|
||||
|
|
|
@ -1827,7 +1827,7 @@ gimp_container_tree_view_drag_pixbuf (GtkWidget *widget,
|
|||
if (renderer && gimp_viewable_get_size (renderer->viewable, &width, &height))
|
||||
return gimp_viewable_get_new_pixbuf (renderer->viewable,
|
||||
renderer->context,
|
||||
width, height, NULL);
|
||||
width, height, NULL, NULL);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -55,6 +55,7 @@ gimp_font_factory_view_class_init (GimpFontFactoryViewClass *klass)
|
|||
static void
|
||||
gimp_font_factory_view_init (GimpFontFactoryView *view)
|
||||
{
|
||||
gimp_data_factory_view_show_follow_theme_toggle (GIMP_DATA_FACTORY_VIEW (view), TRUE);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
|
|
|
@ -848,7 +848,7 @@ gimp_view_drag_pixbuf (GtkWidget *widget,
|
|||
|
||||
if (viewable && gimp_viewable_get_size (viewable, &width, &height))
|
||||
return gimp_viewable_get_new_pixbuf (viewable, view->renderer->context,
|
||||
width, height, NULL);
|
||||
width, height, NULL, NULL);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -234,7 +234,7 @@ gimp_view_renderer_get_frame_pixbuf (GimpViewRenderer *renderer,
|
|||
{
|
||||
pixbuf = gimp_viewable_get_pixbuf (renderer->viewable,
|
||||
renderer->context,
|
||||
w, h, NULL);
|
||||
w, h, NULL, NULL);
|
||||
if (!pixbuf)
|
||||
return NULL;
|
||||
|
||||
|
@ -252,7 +252,7 @@ gimp_view_renderer_get_frame_pixbuf (GimpViewRenderer *renderer,
|
|||
pixbuf = gimp_viewable_get_pixbuf (renderer->viewable,
|
||||
renderer->context,
|
||||
width - 2, height - 2,
|
||||
NULL);
|
||||
NULL, NULL);
|
||||
if (!pixbuf)
|
||||
return NULL;
|
||||
|
||||
|
|
|
@ -114,6 +114,8 @@ static cairo_pattern_t *
|
|||
gimp_view_renderer_create_background (GimpViewRenderer *renderer,
|
||||
GtkWidget *widget);
|
||||
|
||||
static void gimp_view_renderer_redraw (GimpViewRenderer *renderer);
|
||||
|
||||
|
||||
G_DEFINE_TYPE_WITH_PRIVATE (GimpViewRenderer, gimp_view_renderer, G_TYPE_OBJECT)
|
||||
|
||||
|
@ -285,8 +287,26 @@ gimp_view_renderer_set_context (GimpViewRenderer *renderer,
|
|||
|
||||
if (context != renderer->context)
|
||||
{
|
||||
GIMP_VIEW_RENDERER_GET_CLASS (renderer)->set_context (renderer,
|
||||
context);
|
||||
if (renderer->context)
|
||||
{
|
||||
g_signal_handlers_disconnect_by_func (renderer->context->gimp->config,
|
||||
G_CALLBACK (gimp_view_renderer_redraw),
|
||||
renderer);
|
||||
}
|
||||
|
||||
GIMP_VIEW_RENDERER_GET_CLASS (renderer)->set_context (renderer, context);
|
||||
|
||||
if (renderer->context)
|
||||
{
|
||||
g_signal_connect_object (renderer->context->gimp->config,
|
||||
"notify::viewables-follow-theme",
|
||||
G_CALLBACK (gimp_view_renderer_redraw),
|
||||
renderer, G_CONNECT_SWAPPED);
|
||||
g_signal_connect_object (renderer->context->gimp->config,
|
||||
"notify::theme-color-scheme",
|
||||
G_CALLBACK (gimp_view_renderer_redraw),
|
||||
renderer, G_CONNECT_SWAPPED);
|
||||
}
|
||||
|
||||
if (renderer->viewable)
|
||||
gimp_view_renderer_invalidate (renderer);
|
||||
|
@ -805,6 +825,7 @@ gimp_view_renderer_real_render (GimpViewRenderer *renderer,
|
|||
GimpTempBuf *temp_buf;
|
||||
const gchar *icon_name;
|
||||
GeglColor *color = NULL;
|
||||
GeglColor *background = NULL;
|
||||
gint scale_factor = gtk_widget_get_scale_factor (widget);
|
||||
|
||||
if (renderer->context)
|
||||
|
@ -818,19 +839,27 @@ gimp_view_renderer_real_render (GimpViewRenderer *renderer,
|
|||
{
|
||||
GtkStyleContext *style;
|
||||
GdkRGBA *fg_color = NULL;
|
||||
GdkRGBA *bg_color = NULL;
|
||||
|
||||
style = gtk_widget_get_style_context (widget);
|
||||
gtk_style_context_get (style, gtk_style_context_get_state (style),
|
||||
GTK_STYLE_PROPERTY_COLOR, &fg_color,
|
||||
GTK_STYLE_PROPERTY_COLOR, &fg_color,
|
||||
GTK_STYLE_PROPERTY_BACKGROUND_COLOR, &bg_color,
|
||||
NULL);
|
||||
if (fg_color)
|
||||
if (fg_color && bg_color)
|
||||
{
|
||||
color = gegl_color_new (NULL);
|
||||
gegl_color_set_rgba_with_space (color,
|
||||
fg_color->red, fg_color->green, fg_color->blue, 1.0,
|
||||
NULL);
|
||||
|
||||
background = gegl_color_new (NULL);
|
||||
gegl_color_set_rgba_with_space (background,
|
||||
bg_color->red, bg_color->green, bg_color->blue, 1.0,
|
||||
NULL);
|
||||
}
|
||||
g_clear_pointer (&fg_color, gdk_rgba_free);
|
||||
g_clear_pointer (&bg_color, gdk_rgba_free);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -838,10 +867,12 @@ gimp_view_renderer_real_render (GimpViewRenderer *renderer,
|
|||
renderer->context,
|
||||
renderer->width * scale_factor,
|
||||
renderer->height * scale_factor,
|
||||
color);
|
||||
color, background);
|
||||
if (pixbuf)
|
||||
{
|
||||
gimp_view_renderer_render_pixbuf (renderer, widget, pixbuf);
|
||||
g_clear_object (&color);
|
||||
g_clear_object (&background);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -849,7 +880,7 @@ gimp_view_renderer_real_render (GimpViewRenderer *renderer,
|
|||
renderer->context,
|
||||
renderer->width,
|
||||
renderer->height,
|
||||
color);
|
||||
color, background);
|
||||
if (temp_buf)
|
||||
{
|
||||
gimp_view_renderer_render_temp_buf_simple (renderer, widget, temp_buf);
|
||||
|
@ -860,6 +891,7 @@ gimp_view_renderer_real_render (GimpViewRenderer *renderer,
|
|||
gimp_view_renderer_render_icon (renderer, widget, icon_name);
|
||||
|
||||
g_clear_object (&color);
|
||||
g_clear_object (&background);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1459,3 +1491,10 @@ gimp_view_renderer_create_background (GimpViewRenderer *renderer,
|
|||
|
||||
return pattern;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_view_renderer_redraw (GimpViewRenderer *renderer)
|
||||
{
|
||||
gimp_view_renderer_invalidate (renderer);
|
||||
gimp_view_renderer_update (renderer);
|
||||
}
|
||||
|
|
|
@ -122,6 +122,7 @@ gimp_view_renderer_brush_render (GimpViewRenderer *renderer,
|
|||
GimpViewRendererBrush *renderbrush = GIMP_VIEW_RENDERER_BRUSH (renderer);
|
||||
GimpTempBuf *temp_buf;
|
||||
GeglColor *color = NULL;
|
||||
GeglColor *background = NULL;
|
||||
gboolean follow_theme = FALSE;
|
||||
GimpViewBG view_bg_style = GIMP_VIEW_BG_WHITE;
|
||||
gint temp_buf_x = 0;
|
||||
|
@ -142,10 +143,12 @@ gimp_view_renderer_brush_render (GimpViewRenderer *renderer,
|
|||
{
|
||||
GtkStyleContext *style;
|
||||
GdkRGBA *fg_color = NULL;
|
||||
GdkRGBA *bg_color = NULL;
|
||||
|
||||
style = gtk_widget_get_style_context (widget);
|
||||
gtk_style_context_get (style, gtk_style_context_get_state (style),
|
||||
GTK_STYLE_PROPERTY_COLOR, &fg_color,
|
||||
GTK_STYLE_PROPERTY_COLOR, &fg_color,
|
||||
GTK_STYLE_PROPERTY_BACKGROUND_COLOR, &bg_color,
|
||||
NULL);
|
||||
if (fg_color)
|
||||
{
|
||||
|
@ -153,14 +156,21 @@ gimp_view_renderer_brush_render (GimpViewRenderer *renderer,
|
|||
gegl_color_set_rgba_with_space (color,
|
||||
fg_color->red, fg_color->green, fg_color->blue, 1.0,
|
||||
NULL);
|
||||
|
||||
background = gegl_color_new (NULL);
|
||||
gegl_color_set_rgba_with_space (background,
|
||||
bg_color->red, bg_color->green, bg_color->blue, 1.0,
|
||||
NULL);
|
||||
view_bg_style = GIMP_VIEW_BG_USE_STYLE;
|
||||
}
|
||||
g_clear_pointer (&fg_color, gdk_rgba_free);
|
||||
g_clear_pointer (&bg_color, gdk_rgba_free);
|
||||
}
|
||||
|
||||
temp_buf = gimp_viewable_get_new_preview (renderer->viewable, renderer->context,
|
||||
renderer->width, renderer->height, color);
|
||||
renderer->width, renderer->height, color, background);
|
||||
g_clear_object (&color);
|
||||
g_clear_object (&background);
|
||||
|
||||
temp_buf_width = gimp_temp_buf_get_width (temp_buf);
|
||||
temp_buf_height = gimp_temp_buf_get_height (temp_buf);
|
||||
|
@ -211,6 +221,7 @@ gimp_view_renderer_brush_render_timeout (gpointer data)
|
|||
GimpBrush *brush;
|
||||
GimpTempBuf *temp_buf;
|
||||
GeglColor *color = NULL;
|
||||
GeglColor *background = NULL;
|
||||
gboolean follow_theme = FALSE;
|
||||
GimpViewBG view_bg_style = GIMP_VIEW_BG_WHITE;
|
||||
gint temp_buf_x = 0;
|
||||
|
@ -248,6 +259,11 @@ gimp_view_renderer_brush_render_timeout (gpointer data)
|
|||
gegl_color_set_rgba_with_space (color,
|
||||
fg_color->red, fg_color->green, fg_color->blue, 1.0,
|
||||
NULL);
|
||||
|
||||
background = gegl_color_new (NULL);
|
||||
gegl_color_set_rgba_with_space (background,
|
||||
bg_color->red, bg_color->green, bg_color->blue, 1.0,
|
||||
NULL);
|
||||
view_bg_style = GIMP_VIEW_BG_USE_STYLE;
|
||||
}
|
||||
g_clear_pointer (&fg_color, gdk_rgba_free);
|
||||
|
@ -266,8 +282,9 @@ gimp_view_renderer_brush_render_timeout (gpointer data)
|
|||
renderer->context,
|
||||
renderer->width,
|
||||
renderer->height,
|
||||
color);
|
||||
color, background);
|
||||
g_clear_object (&color);
|
||||
g_clear_object (&background);
|
||||
|
||||
temp_buf_width = gimp_temp_buf_get_width (temp_buf);
|
||||
temp_buf_height = gimp_temp_buf_get_height (temp_buf);
|
||||
|
|
|
@ -85,7 +85,7 @@ gimp_view_renderer_buffer_render (GimpViewRenderer *renderer,
|
|||
temp_buf = gimp_viewable_get_new_preview (renderer->viewable,
|
||||
renderer->context,
|
||||
buffer_width, buffer_height,
|
||||
NULL);
|
||||
NULL, NULL);
|
||||
|
||||
if (temp_buf)
|
||||
{
|
||||
|
@ -99,7 +99,7 @@ gimp_view_renderer_buffer_render (GimpViewRenderer *renderer,
|
|||
render_buf = gimp_viewable_get_new_preview (renderer->viewable,
|
||||
renderer->context,
|
||||
view_width, view_height,
|
||||
NULL);
|
||||
NULL, NULL);
|
||||
}
|
||||
|
||||
if (render_buf)
|
||||
|
|
|
@ -118,7 +118,7 @@ gimp_view_renderer_image_render (GimpViewRenderer *renderer,
|
|||
|
||||
temp_buf = gimp_viewable_get_new_preview (renderer->viewable,
|
||||
renderer->context,
|
||||
width, height, NULL);
|
||||
width, height, NULL, NULL);
|
||||
|
||||
if (temp_buf)
|
||||
{
|
||||
|
@ -132,7 +132,7 @@ gimp_view_renderer_image_render (GimpViewRenderer *renderer,
|
|||
render_buf = gimp_viewable_get_new_preview (renderer->viewable,
|
||||
renderer->context,
|
||||
view_width,
|
||||
view_height, NULL);
|
||||
view_height, NULL, NULL);
|
||||
}
|
||||
|
||||
if (render_buf)
|
||||
|
|
|
@ -983,7 +983,7 @@ HELP
|
|||
|
||||
if (image->gimp->config->layer_previews)
|
||||
buf = gimp_viewable_get_new_preview (GIMP_VIEWABLE (drawable), context,
|
||||
width, height, NULL);
|
||||
width, height, NULL, NULL);
|
||||
else
|
||||
buf = gimp_viewable_get_dummy_preview (GIMP_VIEWABLE (drawable),
|
||||
width, height,
|
||||
|
|
|
@ -3154,7 +3154,7 @@ HELP
|
|||
gimp_pickable_flush (GIMP_PICKABLE (image));
|
||||
|
||||
buf = gimp_viewable_get_new_preview (GIMP_VIEWABLE (image), context,
|
||||
width, height, NULL);
|
||||
width, height, NULL, NULL);
|
||||
|
||||
if (buf)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue