/*
- * Geeqie
- * (C) 2006 John Ellis
- * Copyright (C) 2008 - 2012 The Geeqie Team
+ * Copyright (C) 2006 John Ellis
+ * Copyright (C) 2008 - 2021 The Geeqie Team
*
* Author: John Ellis
- * Author: Vladimir Nadvornik
*
- * This software is released under the GNU General Public License (GNU GPL).
- * Please read the included file COPYING for more information.
- * This software comes with no warranty of any kind, use at your own risk!
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <stdio.h>
} ExifOrientationType;
#endif
-
-/* size to use when breaking up image pane for rendering */
-#define PR_TILE_SIZE 128
-
typedef struct _ImageTile ImageTile;
typedef struct _QueueData QueueData;
RendererFuncs f;
PixbufRenderer *pr;
- gint tile_cache_max; /* max mb to use for offscreen buffer */
+ gint tile_cache_max; /* max MiB to use for offscreen buffer */
gint tile_width;
gint tile_height;
GList *overlay_list;
cairo_surface_t *overlay_buffer;
+ cairo_surface_t *surface;
guint draw_idle_id; /* event source id */
gint x_scroll; /* allow local adjustment and mirroring */
gint y_scroll;
+ gint hidpi_scale;
};
if (!window) return;
+#if GTK_CHECK_VERSION(3,0,0)
+ cr = cairo_create(rt->surface);
+#else
cr = gdk_cairo_create(window);
-
+#endif
if (!pr->pixbuf && !pr->source_tiles_enabled)
{
pr->viewport_width, pr->viewport_height,
&rx, &ry, &rw, &rh))
{
- cairo_set_source_rgb(cr, 0, 0, 0);
+ cairo_set_source_rgb(cr, (double)pr->color.red/65535, (double)pr->color.green/65535, (double)pr->color.blue/65535);
cairo_rectangle(cr, rx + rt->stereo_off_x, ry + rt->stereo_off_y, rw, rh);
cairo_fill(cr);
- cairo_destroy(cr);
rt_overlay_draw(rt, rx, ry, rw, rh, NULL);
}
+ cairo_destroy(cr);
return;
}
pr->x_offset, pr->viewport_height,
&rx, &ry, &rw, &rh))
{
- cairo_set_source_rgb(cr, 0, 0, 0);
+ cairo_set_source_rgb(cr, (double)pr->color.red/65535, (double)pr->color.green/65535, (double)pr->color.blue/65535);
cairo_rectangle(cr, rx + rt->stereo_off_x, ry + rt->stereo_off_y, rw, rh);
cairo_fill(cr);
rt_overlay_draw(rt, rx, ry, rw, rh, NULL);
pr->viewport_width - pr->vis_width - pr->x_offset, pr->viewport_height,
&rx, &ry, &rw, &rh))
{
- cairo_set_source_rgb(cr, 0, 0, 0);
+ cairo_set_source_rgb(cr, (double)pr->color.red/65535, (double)pr->color.green/65535, (double)pr->color.blue/65535);
cairo_rectangle(cr, rx + rt->stereo_off_x, ry + rt->stereo_off_y, rw, rh);
cairo_fill(cr);
rt_overlay_draw(rt, rx, ry, rw, rh, NULL);
pr->vis_width, pr->y_offset,
&rx, &ry, &rw, &rh))
{
- cairo_set_source_rgb(cr, 0, 0, 0);
+ cairo_set_source_rgb(cr, (double)pr->color.red/65535, (double)pr->color.green/65535, (double)pr->color.blue/65535);
cairo_rectangle(cr, rx + rt->stereo_off_x, ry + rt->stereo_off_y, rw, rh);
cairo_fill(cr);
rt_overlay_draw(rt, rx, ry, rw, rh, NULL);
pr->vis_width, pr->viewport_height - pr->vis_height - pr->y_offset,
&rx, &ry, &rw, &rh))
{
- cairo_set_source_rgb(cr, 0, 0, 0);
+ cairo_set_source_rgb(cr, (double)pr->color.red/65535, (double)pr->color.green/65535, (double)pr->color.blue/65535);
cairo_rectangle(cr, rx + rt->stereo_off_x, ry + rt->stereo_off_y, rw, rh);
cairo_fill(cr);
rt_overlay_draw(rt, rx, ry, rw, rh, NULL);
// d = gdk_drawable_get_depth(pixmap);
// gdk_drawable_get_size(pixmap, &w, &h);
- return PR_TILE_SIZE * PR_TILE_SIZE * 4 / 8;
+ return options->image.tile_size * options->image.tile_size * 4 / 8;
+}
+
+static void rt_hidpi_aware_draw(
+ RendererTiles *rt,
+ cairo_t *cr,
+ GdkPixbuf *pixbuf,
+ double x,
+ double y)
+{
+#if GTK_CHECK_VERSION(3, 10, 0)
+ cairo_surface_t *surface;
+ surface = gdk_cairo_surface_create_from_pixbuf(pixbuf, rt->hidpi_scale, NULL);
+ cairo_set_source_surface(cr, surface, x, y);
+ cairo_fill(cr);
+ cairo_surface_destroy(surface);
+#else
+ gdk_cairo_set_source_pixbuf(cr, pixbuf, x, y);
+ cairo_fill(cr);
+#endif
}
static void rt_tile_prepare(RendererTiles *rt, ImageTile *it)
CAIRO_CONTENT_COLOR,
rt->tile_width, rt->tile_height);
- size = pixmap_calc_size(surface);
+ size = pixmap_calc_size(surface) * rt->hidpi_scale * rt->hidpi_scale;
rt_tile_free_space(rt, size, it);
it->surface = surface;
{
GdkPixbuf *pixbuf;
guint size;
- pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8, rt->tile_width, rt->tile_height);
+ pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8, rt->hidpi_scale * rt->tile_width, rt->hidpi_scale * rt->tile_height);
- size = gdk_pixbuf_get_rowstride(pixbuf) * rt->tile_height;
+ size = gdk_pixbuf_get_rowstride(pixbuf) * rt->tile_height * rt->hidpi_scale;
rt_tile_free_space(rt, size, it);
it->pixbuf = pixbuf;
od->window = gdk_window_new(gtk_widget_get_window(GTK_WIDGET(pr)), &attributes, attributes_mask);
gdk_window_set_user_data(od->window, pr);
gdk_window_move(od->window, px + rt->stereo_off_x, py + rt->stereo_off_y);
+#if !GTK_CHECK_VERSION(3,0,0)
gdk_window_show(od->window);
+#endif
}
static void rt_overlay_draw(RendererTiles *rt, gint x, gint y, gint w, gint h,
cairo_fill_preserve(cr);
gdk_cairo_set_source_pixbuf(cr, od->pixbuf, px - rx, py - ry);
- cairo_fill (cr);
+ cairo_fill(cr);
cairo_destroy (cr);
cr = gdk_cairo_create(od->window);
rt->overlay_list = g_list_append(rt->overlay_list, od);
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_queue_draw(GTK_WIDGET(rt->pr));
+#else
rt_overlay_queue_draw(rt, od, 0, 0, 0, 0);
+#endif
return od->id;
}
}
}
+#if GTK_CHECK_VERSION(3,0,0)
+void renderer_tiles_overlay_set(void *renderer, gint id, GdkPixbuf *pixbuf, gint x, gint y)
+{
+ RendererTiles *rc = (RendererTiles *)renderer;
+ PixbufRenderer *pr = rc->pr;
+ OverlayData *od;
+
+ g_return_if_fail(IS_PIXBUF_RENDERER(pr));
+
+ od = rt_overlay_find(rc, id);
+ if (!od) return;
+
+ if (pixbuf)
+ {
+ g_object_ref(G_OBJECT(pixbuf));
+ g_object_unref(G_OBJECT(od->pixbuf));
+ od->pixbuf = pixbuf;
+ }
+ else
+ {
+ rt_overlay_free(rc, od);
+ }
+
+ gtk_widget_queue_draw(GTK_WIDGET(rc->pr));
+}
+#else
void renderer_tiles_overlay_set(void *renderer, gint id, GdkPixbuf *pixbuf, gint x, gint y)
{
RendererTiles *rt = (RendererTiles *) renderer;
rt_overlay_free(rt, od);
}
}
+#endif
gboolean renderer_tiles_overlay_get(void *renderer, gint id, GdkPixbuf **pixbuf, gint *x, gint *y)
{
static GdkPixbuf *rt_get_spare_tile(RendererTiles *rt)
{
- if (!rt->spare_tile) rt->spare_tile = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8, rt->tile_width, rt->tile_height);
+ if (!rt->spare_tile) rt->spare_tile = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8, rt->tile_width * rt->hidpi_scale, rt->tile_height * rt->hidpi_scale);
return rt->spare_tile;
}
guchar *sp, *dp;
guchar *ip, *spi, *dpi;
gint i, j;
- gint tw = rt->tile_width;
+ gint tw = rt->tile_width * rt->hidpi_scale;
srs = gdk_pixbuf_get_rowstride(src);
s_pix = gdk_pixbuf_get_pixels(src);
guchar *sp, *dp;
guchar *ip, *spi, *dpi;
gint i, j;
- gint th = rt->tile_height;
+ gint th = rt->tile_height * rt->hidpi_scale;
srs = gdk_pixbuf_get_rowstride(src);
s_pix = gdk_pixbuf_get_pixels(src);
guchar *spi, *dpi;
gint i, j;
- gint tw = rt->tile_width;
+ gint tw = rt->tile_width * rt->hidpi_scale;
srs = gdk_pixbuf_get_rowstride(src);
s_pix = gdk_pixbuf_get_pixels(src);
guchar *sp, *dp;
guchar *dpi;
gint i, j;
- gint tw = rt->tile_width;
- gint th = rt->tile_height;
+ gint tw = rt->tile_width * rt->hidpi_scale;
+ gint th = rt->tile_height * rt->hidpi_scale;
srs = gdk_pixbuf_get_rowstride(src);
s_pix = gdk_pixbuf_get_pixels(src);
guchar *sp, *dp;
guchar *spi, *dpi;
gint i;
- gint th = rt->tile_height;
+ gint th = rt->tile_height * rt->hidpi_scale;
srs = gdk_pixbuf_get_rowstride(src);
s_pix = gdk_pixbuf_get_pixels(src);
if (st->blank)
{
cairo_set_source_rgb(cr, 0, 0, 0);
+ cairo_fill (cr);
}
else /* (pr->zoom == 1.0 || pr->scale == 1.0) */
{
- gdk_cairo_set_source_pixbuf(cr, st->pixbuf, -it->x + st->x, -it->y + st->y);
+ rt_hidpi_aware_draw(rt, cr, st->pixbuf, -it->x + st->x, -it->y + st->y);
}
- cairo_fill (cr);
cairo_destroy (cr);
}
}
return draw;
}
-static void rt_tile_get_region(gboolean has_alpha,
+/**
+ * @brief
+ * @param has_alpha
+ * @param ignore_alpha
+ * @param src
+ * @param dest
+ * @param pb_x
+ * @param pb_y
+ * @param pb_w
+ * @param pb_h
+ * @param offset_x
+ * @param offset_y
+ * @param scale_x
+ * @param scale_y
+ * @param interp_type
+ * @param check_x
+ * @param check_y
+ * @param wide_image Used as a work-around for a GdkPixbuf problem. Set when image width is > 32767. Problem exhibited with gdk_pixbuf_copy_area() and GDK_INTERP_NEAREST. See #772 on GitHub Geeqie
+ *
+ *
+ */
+static void rt_tile_get_region(gboolean has_alpha, gboolean ignore_alpha,
const GdkPixbuf *src, GdkPixbuf *dest,
int pb_x, int pb_y, int pb_w, int pb_h,
double offset_x, double offset_y, double scale_x, double scale_y,
GdkInterpType interp_type,
- int check_x, int check_y)
+ int check_x, int check_y, gboolean wide_image)
{
+ GdkPixbuf* tmppixbuf;
+ gint srs;
+ gint drs;
+ gint x;
+ gint y;
+ gint c;
+ guchar *psrc;
+ guchar *pdst;
+
if (!has_alpha)
{
if (scale_x == 1.0 && scale_y == 1.0)
{
- gdk_pixbuf_copy_area(src,
- -offset_x + pb_x, -offset_y + pb_y,
- pb_w, pb_h,
- dest,
- pb_x, pb_y);
+ if (wide_image)
+ {
+ srs = gdk_pixbuf_get_rowstride(src);
+ drs = gdk_pixbuf_get_rowstride(dest);
+ psrc = gdk_pixbuf_get_pixels(src);
+ pdst = gdk_pixbuf_get_pixels(dest);
+ for (y = 0; y < pb_h; y++)
+ {
+ for (x = 0; x < pb_w; x++)
+ {
+ for (c = 0; c < 3; c++)
+ {
+ pdst[(y * drs) + x*3 + c] = psrc[(-(int)offset_y + pb_y + y) * srs + (-(int)offset_x + pb_x+x)*3 + c];
+ }
+ }
+ }
+ }
+ else
+ {
+ gdk_pixbuf_copy_area(src,
+ -offset_x + pb_x, -offset_y + pb_y,
+ pb_w, pb_h,
+ dest,
+ pb_x, pb_y);
+ }
}
else
{
gdk_pixbuf_scale(src, dest,
- pb_x, pb_y, pb_w, pb_h,
- offset_x,
- offset_y,
- scale_x, scale_y,
- interp_type);
+ pb_x, pb_y, pb_w, pb_h,
+ offset_x,
+ offset_y,
+ scale_x, scale_y,
+ (wide_image && interp_type == GDK_INTERP_NEAREST) ? GDK_INTERP_TILES : interp_type);
}
}
else
{
- gdk_pixbuf_composite_color(src, dest,
- pb_x, pb_y, pb_w, pb_h,
- offset_x,
- offset_y,
- scale_x, scale_y,
- interp_type,
- 255, check_x, check_y,
- PR_ALPHA_CHECK_SIZE, PR_ALPHA_CHECK1, PR_ALPHA_CHECK2);
+ if (ignore_alpha)
+ {
+ tmppixbuf = gdk_pixbuf_add_alpha(src, FALSE, 0, 0, 0);
+
+ pixbuf_ignore_alpha_rect(tmppixbuf, 0, 0, gdk_pixbuf_get_width(src), gdk_pixbuf_get_height(src));
+
+ gdk_pixbuf_composite_color(tmppixbuf, dest,
+ pb_x, pb_y, pb_w, pb_h,
+ offset_x,
+ offset_y,
+ scale_x, scale_y,
+ (scale_x == 1.0 && scale_y == 1.0) ? GDK_INTERP_NEAREST : interp_type,
+ 255, check_x, check_y,
+ PR_ALPHA_CHECK_SIZE,
+ ((options->image.alpha_color_1.red << 8 & 0x00FF0000) +
+ (options->image.alpha_color_1.green & 0x00FF00) +
+ (options->image.alpha_color_1.blue >> 8 & 0x00FF)),
+ ((options->image.alpha_color_2.red << 8 & 0x00FF0000) +
+ (options->image.alpha_color_2.green & 0x00FF00) +
+ (options->image.alpha_color_2.blue >> 8 & 0x00FF)));
+ g_object_unref(tmppixbuf);
+ }
+ else
+ {
+ gdk_pixbuf_composite_color(src, dest,
+ pb_x, pb_y, pb_w, pb_h,
+ offset_x,
+ offset_y,
+ scale_x, scale_y,
+ (scale_x == 1.0 && scale_y == 1.0) ? GDK_INTERP_NEAREST : interp_type,
+ 255, check_x, check_y,
+ PR_ALPHA_CHECK_SIZE,
+ ((options->image.alpha_color_1.red << 8 & 0x00FF0000) +
+ (options->image.alpha_color_1.green & 0x00FF00) +
+ (options->image.alpha_color_1.blue >> 8 & 0x00FF)),
+ ((options->image.alpha_color_2.red << 8 & 0x00FF0000) +
+ (options->image.alpha_color_2.green & 0x00FF00) +
+ (options->image.alpha_color_2.blue >> 8 & 0x00FF)));
+ }
}
}
gboolean has_alpha;
gboolean draw = FALSE;
gint orientation = rt_get_orientation(rt);
+ gboolean wide_image = FALSE;
if (it->render_todo == TILE_RENDER_NONE && it->surface && !new_data) return;
rt_tile_prepare(rt, it);
has_alpha = (pr->pixbuf && gdk_pixbuf_get_has_alpha(pr->pixbuf));
- /* FIXME checker colors for alpha should be configurable,
+ /** @FIXME checker colors for alpha should be configurable,
* also should be drawn for blank = TRUE
*/
if (pr->image_width == 0 || pr->image_height == 0) return;
- scale_x = (gdouble)pr->width / pr->image_width;
- scale_y = (gdouble)pr->height / pr->image_height;
+ scale_x = rt->hidpi_scale * (gdouble)pr->width / pr->image_width;
+ scale_y = rt->hidpi_scale * (gdouble)pr->height / pr->image_height;
pr_tile_coords_map_orientation(orientation, it->x, it->y,
pr->width, pr->height,
&pb_x, &pb_y,
&pb_w, &pb_h);
+ src_x *= rt->hidpi_scale;
+ src_y *= rt->hidpi_scale;
+ pb_x *= rt->hidpi_scale;
+ pb_y *= rt->hidpi_scale;
+ pb_w *= rt->hidpi_scale;
+ pb_h *= rt->hidpi_scale;
+
switch (orientation)
{
gdouble tmp;
* small sizes for anything but GDK_INTERP_NEAREST
*/
if (pr->width < PR_MIN_SCALE_SIZE || pr->height < PR_MIN_SCALE_SIZE) fast = TRUE;
+ if (pr->image_width > 32767) wide_image = TRUE;
- rt_tile_get_region(has_alpha,
+ rt_tile_get_region(has_alpha, pr->ignore_alpha,
pr->pixbuf, it->pixbuf, pb_x, pb_y, pb_w, pb_h,
(gdouble) 0.0 - src_x - GET_RIGHT_PIXBUF_OFFSET(rt) * scale_x,
(gdouble) 0.0 - src_y,
scale_x, scale_y,
(fast) ? GDK_INTERP_NEAREST : pr->zoom_quality,
- it->x + pb_x, it->y + pb_y);
+ it->x + pb_x, it->y + pb_y, wide_image);
if (rt->stereo_mode & PR_STEREO_ANAGLYPH &&
(pr->stereo_pixbuf_offset_right > 0 || pr->stereo_pixbuf_offset_left > 0))
{
GdkPixbuf *right_pb = rt_get_spare_tile(rt);
- rt_tile_get_region(has_alpha,
+ rt_tile_get_region(has_alpha, pr->ignore_alpha,
pr->pixbuf, right_pb, pb_x, pb_y, pb_w, pb_h,
(gdouble) 0.0 - src_x - GET_LEFT_PIXBUF_OFFSET(rt) * scale_x,
(gdouble) 0.0 - src_y,
scale_x, scale_y,
(fast) ? GDK_INTERP_NEAREST : pr->zoom_quality,
- it->x + pb_x, it->y + pb_y);
+ it->x + pb_x, it->y + pb_y, wide_image);
pr_create_anaglyph(rt->stereo_mode, it->pixbuf, right_pb, pb_x, pb_y, pb_w, pb_h);
/* do not care about freeing spare_tile, it will be reused */
}
cr = cairo_create(it->surface);
cairo_rectangle (cr, x, y, w, h);
- gdk_cairo_set_source_pixbuf(cr, it->pixbuf, 0, 0);
- cairo_fill (cr);
+ rt_hidpi_aware_draw(rt, cr, it->pixbuf, 0, 0);
cairo_destroy (cr);
}
}
box = GTK_WIDGET(pr);
window = gtk_widget_get_window(box);
+#if GTK_CHECK_VERSION(3,0,0)
+ cr = cairo_create(rt->surface);
+#else
cr = gdk_cairo_create(window);
+#endif
cairo_set_source_surface(cr, it->surface, pr->x_offset + (it->x - rt->x_scroll) + rt->stereo_off_x, pr->y_offset + (it->y - rt->y_scroll) + rt->stereo_off_y);
cairo_rectangle (cr, pr->x_offset + (it->x - rt->x_scroll) + x + rt->stereo_off_x, pr->y_offset + (it->y - rt->y_scroll) + y + rt->stereo_off_y, w, h);
cairo_fill (cr);
w, h,
it);
}
+
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_queue_draw(GTK_WIDGET(rt->pr));
+#endif
}
{
gint x1, y1;
gint x2, y2;
- GtkWidget *box;
- GdkWindow *window;
cairo_t *cr;
cairo_surface_t *surface;
y2 = abs(y_off);
}
+#if GTK_CHECK_VERSION(3,0,0)
+ cr = cairo_create(rt->surface);
+ surface = rt->surface;
+#else
+ GtkWidget *box;
+ GdkWindow *window;
+
box = GTK_WIDGET(pr);
window = gtk_widget_get_window(box);
cr = gdk_cairo_create(window);
surface = cairo_get_target(cr);
+#endif
/* clipping restricts the intermediate surface's size, so it's a good idea
* to use it. */
cairo_rectangle(cr, x1 + pr->x_offset + rt->stereo_off_x, y1 + pr->y_offset + rt->stereo_off_y, w, h);
}
if (h > 0)
{
- /* FIXME, to optimize this, remove overlap */
+ /** @FIXME to optimize this, remove overlap */
rt_queue(rt,
rt->x_scroll, y_off > 0 ? rt->y_scroll + (pr->vis_height - h) : rt->y_scroll,
pr->vis_width, h, TRUE, TILE_RENDER_ALL, FALSE, FALSE);
}
#if GTK_CHECK_VERSION(3,0,0)
+static gboolean rt_realize_cb(GtkWidget *widget, gpointer data)
+{
+ RendererTiles *rt = (RendererTiles *)data;
+ cairo_t *cr;
+
+ if (!rt->surface)
+ {
+ rt->surface = gdk_window_create_similar_surface(gtk_widget_get_window(widget), CAIRO_CONTENT_COLOR, gtk_widget_get_allocated_width(widget), gtk_widget_get_allocated_height(widget));
+
+ cr = cairo_create(rt->surface);
+ cairo_set_source_rgb(cr, (gdouble)options->image.border_color.red /65535, (gdouble)options->image.border_color.green / 65535, (gdouble)options->image.border_color.blue / 65535);
+ cairo_paint(cr);
+ cairo_destroy(cr);
+ }
+
+ return FALSE;
+}
+
+static gboolean rt_size_allocate_cb(GtkWidget *widget, GdkRectangle *allocation, gpointer data)
+{
+ RendererTiles *rt = data;
+ cairo_t *cr;
+ cairo_surface_t *old_surface;
+
+ if (gtk_widget_get_realized(GTK_WIDGET(rt->pr)))
+ {
+ old_surface = rt->surface;
+ rt->surface = gdk_window_create_similar_surface(gtk_widget_get_window(widget), CAIRO_CONTENT_COLOR, allocation->width, allocation->height);
+
+ cr = cairo_create(rt->surface);
+
+ cairo_set_source_rgb(cr, (gdouble)options->image.border_color.red / 65535, (gdouble)options->image.border_color.green / 65535, (gdouble)options->image.border_color.blue / 65535);
+ cairo_paint(cr);
+ cairo_set_source_surface(cr, old_surface, 0, 0);
+ cairo_paint(cr);
+ cairo_destroy(cr);
+ cairo_surface_destroy(old_surface);
+
+ renderer_redraw(rt, allocation->x, allocation->y, allocation->width, allocation->height, FALSE, TILE_RENDER_ALL, FALSE, FALSE);
+ }
+
+ return FALSE;
+}
static gboolean rt_draw_cb(GtkWidget *widget, cairo_t *cr, gpointer data)
{
RendererTiles *rt = (RendererTiles *)data;
- if (gtk_widget_is_drawable(widget))
+ GList *work;
+ OverlayData *od;
+
+ if (rt->stereo_mode & (PR_STEREO_HORIZ | PR_STEREO_VERT))
{
- if (gtk_widget_get_has_window(widget))
+ cairo_push_group(cr);
+ cairo_set_source_rgb(cr, (double)rt->pr->color.red / 65535, (double)rt->pr->color.green / 65535, (double)rt->pr->color.blue / 65535);
+
+ if (rt->stereo_mode & PR_STEREO_HORIZ)
{
- GdkRectangle area;
- if (gdk_cairo_get_clip_rectangle(cr, &area))
- {
- renderer_redraw(rt, area.x, area.y, area.width, area.height,
- FALSE, TILE_RENDER_ALL, FALSE, FALSE);
- }
+ cairo_rectangle(cr, rt->stereo_off_x, 0, rt->pr->viewport_width, rt->pr->viewport_height);
+ }
+ else
+ {
+ cairo_rectangle(cr, 0, rt->stereo_off_y, rt->pr->viewport_width, rt->pr->viewport_height);
+ }
+ cairo_clip(cr);
+ cairo_paint(cr);
+
+ cairo_rectangle(cr, rt->pr->x_offset + rt->stereo_off_x, rt->pr->y_offset + rt->stereo_off_y, rt->pr->vis_width, rt->pr->vis_height);
+ cairo_clip(cr);
+ cairo_set_source_surface(cr, rt->surface, 0, 0);
+ cairo_paint(cr);
+
+ cairo_pop_group_to_source(cr);
+ cairo_paint(cr);
+ }
+ else
+ {
+ cairo_set_source_surface(cr, rt->surface, 0, 0);
+ cairo_paint(cr);
+ }
+
+ work = rt->overlay_list;
+ while (work)
+ {
+ od = work->data;
+ gint px, py, pw, ph;
+ pw = gdk_pixbuf_get_width(od->pixbuf);
+ ph = gdk_pixbuf_get_height(od->pixbuf);
+ px = od->x;
+ py = od->y;
+
+ if (od->flags & OVL_RELATIVE)
+ {
+ if (px < 0) px = rt->pr->viewport_width - pw + px;
+ if (py < 0) py = rt->pr->viewport_height - ph + py;
}
+
+ gdk_cairo_set_source_pixbuf(cr, od->pixbuf, px, py);
+ cairo_paint(cr);
+ work = work->next;
}
return FALSE;
rt->f.stereo_set = renderer_stereo_set;
- rt->tile_width = PR_TILE_SIZE;
- rt->tile_height = PR_TILE_SIZE;
+ rt->tile_width = options->image.tile_size;
+ rt->tile_height = options->image.tile_size;
rt->tiles = NULL;
rt->tile_cache_size = 0;
rt->stereo_off_x = 0;
rt->stereo_off_y = 0;
+#if GTK_CHECK_VERSION(3, 10, 0)
+ rt->hidpi_scale = gtk_widget_get_scale_factor(GTK_WIDGET(rt->pr));
+#else
+ rt->hidpi_scale = 1;
+#endif
+
g_signal_connect(G_OBJECT(pr), "hierarchy-changed",
G_CALLBACK(rt_hierarchy_changed_cb), rt);
#if GTK_CHECK_VERSION(3,0,0)
g_signal_connect(G_OBJECT(pr), "draw",
G_CALLBACK(rt_draw_cb), rt);
+ g_signal_connect(G_OBJECT(pr), "realize", G_CALLBACK(rt_realize_cb), rt);
+ g_signal_connect(G_OBJECT(pr), "size-allocate", G_CALLBACK(rt_size_allocate_cb), rt);
#else
g_signal_connect(G_OBJECT(pr), "expose_event",
G_CALLBACK(rt_expose_cb), rt);
#endif
+
return (RendererFuncs *) rt;
}