* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-
-#include "main.h"
#include "renderer-tiles.h"
+#include <cmath>
+#include <cstdlib>
+#include <cstring>
+#include <utility>
+
+#include <cairo.h>
+#include <gdk-pixbuf/gdk-pixbuf.h>
+#include <gdk/gdk.h>
+#include <glib-object.h>
+#include <glib.h>
+#include <gtk/gtk.h>
+
+#include "debug.h"
+#include "options.h"
+#include "pixbuf-renderer.h"
+#include "typedefs.h"
+
/* comment this out if not using this from within Geeqie
* defining GQ_BUILD does these things:
* - Sets the shift-click scroller pixbuf to a nice icon instead of a black box
#define GQ_BUILD 1
#ifdef GQ_BUILD
-#include "main.h"
-#include "pixbuf-util.h"
#include "exif.h"
+#include "pixbuf-util.h"
#else
enum ExifOrientationType {
EXIF_ORIENTATION_UNKNOWN = 0,
};
#endif
+namespace
+{
+
struct QueueData;
struct ImageTile
gint tile_width;
gint tile_height;
- gint tile_cols; /* count of tile columns */
GList *tiles; /* list of buffer tiles */
gint tile_cache_size; /* allocated size of pixmaps/pixbufs */
GList *draw_queue; /* list of areas to redraw */
gint hidpi_scale;
};
+constexpr size_t COLOR_BYTES = 3; /* rgb */
-static void rt_border_draw(RendererTiles *rt, gint x, gint y, gint w, gint h);
-static void rt_overlay_draw(RendererTiles *rt, gint x, gint y, gint w, gint h, ImageTile *it);
+inline gint get_right_pixbuf_offset(RendererTiles *rt)
+{
+ return (!!(rt->stereo_mode & PR_STEREO_RIGHT) != !!(rt->stereo_mode & PR_STEREO_SWAP)) ?
+ rt->pr->stereo_pixbuf_offset_right : rt->pr->stereo_pixbuf_offset_left;
+}
+inline gint get_left_pixbuf_offset(RendererTiles *rt)
+{
+ return (!!(rt->stereo_mode & PR_STEREO_RIGHT) == !!(rt->stereo_mode & PR_STEREO_SWAP)) ?
+ rt->pr->stereo_pixbuf_offset_right : rt->pr->stereo_pixbuf_offset_left;
+}
+
+} // namespace
+
+
+static void rt_overlay_draw(RendererTiles *rt, gint x, gint y, gint w, gint h, ImageTile *it);
-static void rt_tile_free_all(RendererTiles *rt);
-static void rt_tile_invalidate_region(RendererTiles *rt, gint x, gint y, gint w, gint h);
static gboolean rt_tile_is_visible(RendererTiles *rt, ImageTile *it);
-static void rt_queue_clear(RendererTiles *rt);
static void rt_queue_merge(QueueData *parent, QueueData *qd);
static void rt_queue(RendererTiles *rt, gint x, gint y, gint w, gint h,
gint clamp, ImageRenderType render, gboolean new_data, gboolean only_existing);
-static void rt_hierarchy_changed_cb(GtkWidget *widget, GtkWidget *previous_toplevel, gpointer data);
static gint rt_queue_draw_idle_cb(gpointer data);
-#define GET_RIGHT_PIXBUF_OFFSET(rt) \
- (( (rt->stereo_mode & PR_STEREO_RIGHT) && !(rt->stereo_mode & PR_STEREO_SWAP)) || \
- (!(rt->stereo_mode & PR_STEREO_RIGHT) && (rt->stereo_mode & PR_STEREO_SWAP)) ? \
- rt->pr->stereo_pixbuf_offset_right : rt->pr->stereo_pixbuf_offset_left )
-
-#define GET_LEFT_PIXBUF_OFFSET(rt) \
- ((!(rt->stereo_mode & PR_STEREO_RIGHT) && !(rt->stereo_mode & PR_STEREO_SWAP)) || \
- ( (rt->stereo_mode & PR_STEREO_RIGHT) && (rt->stereo_mode & PR_STEREO_SWAP)) ? \
- rt->pr->stereo_pixbuf_offset_right : rt->pr->stereo_pixbuf_offset_left )
-
static void rt_sync_scroll(RendererTiles *rt)
{
PixbufRenderer *pr = rt->pr;
GtkWidget *box;
GdkWindow *window;
- gint rx, ry, rw, rh;
+ gint rx;
+ gint ry;
+ gint rw;
+ gint rh;
cairo_t *cr;
box = GTK_WIDGET(pr);
cr = cairo_create(rt->surface);
+ auto draw = [rt, pr, cr](gint x, gint y, gint w, gint h)
+ {
+ cairo_set_source_rgb(cr, static_cast<double>(pr->color.red), static_cast<double>(pr->color.green), static_cast<double>(pr->color.blue));
+ cairo_rectangle(cr, x + rt->stereo_off_x, y + rt->stereo_off_y, w, h);
+ cairo_fill(cr);
+ rt_overlay_draw(rt, x, y, w, h, nullptr);
+ };
+
if (!pr->pixbuf && !pr->source_tiles_enabled)
{
if (pr_clip_region(x, y, w, h,
pr->viewport_width, pr->viewport_height,
&rx, &ry, &rw, &rh))
{
- cairo_set_source_rgb(cr, static_cast<double>(pr->color.red)/65535, static_cast<double>(pr->color.green)/65535, static_cast<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, nullptr);
+ draw(rx, ry, rw, rh);
}
cairo_destroy(cr);
return;
pr->x_offset, pr->viewport_height,
&rx, &ry, &rw, &rh))
{
- cairo_set_source_rgb(cr, static_cast<double>(pr->color.red)/65535, static_cast<double>(pr->color.green)/65535, static_cast<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, nullptr);
+ draw(rx, ry, rw, rh);
}
if (pr->viewport_width - pr->vis_width - pr->x_offset > 0 &&
pr_clip_region(x, y, w, h,
pr->viewport_width - pr->vis_width - pr->x_offset, pr->viewport_height,
&rx, &ry, &rw, &rh))
{
- cairo_set_source_rgb(cr, static_cast<double>(pr->color.red)/65535, static_cast<double>(pr->color.green)/65535, static_cast<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, nullptr);
+ draw(rx, ry, rw, rh);
}
}
if (pr->vis_height < pr->viewport_height)
pr->vis_width, pr->y_offset,
&rx, &ry, &rw, &rh))
{
- cairo_set_source_rgb(cr, static_cast<double>(pr->color.red)/65535, static_cast<double>(pr->color.green)/65535, static_cast<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, nullptr);
+ draw(rx, ry, rw, rh);
}
if (pr->viewport_height - pr->vis_height - pr->y_offset > 0 &&
pr_clip_region(x, y, w, h,
pr->vis_width, pr->viewport_height - pr->vis_height - pr->y_offset,
&rx, &ry, &rw, &rh))
{
- cairo_set_source_rgb(cr, static_cast<double>(pr->color.red)/65535, static_cast<double>(pr->color.green)/65535, static_cast<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, nullptr);
+ draw(rx, ry, rw, rh);
}
}
cairo_destroy(cr);
static ImageTile *rt_tile_new(gint x, gint y, gint width, gint height)
{
- ImageTile *it;
-
- it = g_new0(ImageTile, 1);
+ auto it = g_new0(ImageTile, 1);
it->x = x;
it->y = y;
static void rt_tile_free_all(RendererTiles *rt)
{
- GList *work;
-
- work = rt->tiles;
- while (work)
- {
- ImageTile *it;
-
- it = static_cast<ImageTile *>(work->data);
- work = work->next;
-
- rt_tile_free(it);
- }
-
- g_list_free(rt->tiles);
+ g_list_free_full(rt->tiles, reinterpret_cast<GDestroyNotify>(rt_tile_free));
rt->tiles = nullptr;
rt->tile_cache_size = 0;
}
static void rt_tile_invalidate_region(RendererTiles *rt, gint x, gint y, gint w, gint h)
{
- gint x1, x2;
- gint y1, y2;
+ gint x1;
+ gint x2;
+ gint y1;
+ gint y2;
GList *work;
x1 = ROUND_DOWN(x, rt->tile_width);
return rt_tile_add(rt, x, y);
}
-static gint pixmap_calc_size(cairo_surface_t *UNUSED(surface))
+static gint pixmap_calc_size(cairo_surface_t *)
{
-// gint w, h, d;
-
-// d = gdk_drawable_get_depth(pixmap);
-// gdk_drawable_get_size(pixmap, &w, &h);
return options->image.tile_size * options->image.tile_size * 4 / 8;
}
*-------------------------------------------------------------------
*/
-static void rt_overlay_get_position(RendererTiles *rt, OverlayData *od,
- gint *x, gint *y, gint *w, gint *h)
+static void rt_overlay_get_position(const RendererTiles *rt, const OverlayData *od,
+ gint &x, gint &y, gint &w, gint &h)
{
PixbufRenderer *pr = rt->pr;
- 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;
+ x = od->x;
+ y = od->y;
+ w = gdk_pixbuf_get_width(od->pixbuf);
+ h = gdk_pixbuf_get_height(od->pixbuf);
if (od->flags & OVL_RELATIVE)
{
- if (px < 0) px = pr->viewport_width - pw + px;
- if (py < 0) py = pr->viewport_height - ph + py;
+ if (x < 0) x = pr->viewport_width - w + x;
+ if (y < 0) y = pr->viewport_height - h + y;
}
-
- if (x) *x = px;
- if (y) *y = py;
- if (w) *w = pw;
- if (h) *h = ph;
}
static void rt_overlay_init_window(RendererTiles *rt, OverlayData *od)
{
PixbufRenderer *pr = rt->pr;
- gint px, py, pw, ph;
+ gint px;
+ gint py;
+ gint pw;
+ gint ph;
GdkWindowAttr attributes;
gint attributes_mask;
- rt_overlay_get_position(rt, od, &px, &py, &pw, &ph);
+ rt_overlay_get_position(rt, od, px, py, pw, ph);
attributes.window_type = GDK_WINDOW_CHILD;
attributes.wclass = GDK_INPUT_OUTPUT;
while (work)
{
OverlayData *od;
- gint px, py, pw, ph;
- gint rx, ry, rw, rh;
+ gint px;
+ gint py;
+ gint pw;
+ gint ph;
+ gint rx;
+ gint ry;
+ gint rw;
+ gint rh;
od = static_cast<OverlayData *>(work->data);
work = work->next;
if (!od->window) rt_overlay_init_window(rt, od);
- rt_overlay_get_position(rt, od, &px, &py, &pw, &ph);
+ rt_overlay_get_position(rt, od, px, py, pw, ph);
if (pr_clip_region(x, y, w, h, px, py, pw, ph, &rx, &ry, &rw, &rh))
{
if (!rt->overlay_buffer)
else
{
/* no ImageTile means region may be larger than our scratch buffer */
- gint sx, sy;
+ gint sx;
+ gint sy;
for (sx = rx; sx < rx + rw; sx += rt->tile_width)
for (sy = ry; sy < ry + rh; sy += rt->tile_height)
{
- gint sw, sh;
+ gint sw;
+ gint sh;
cairo_t *cr;
sw = MIN(rx + rw - sx, rt->tile_width);
static void rt_overlay_queue_draw(RendererTiles *rt, OverlayData *od, gint x1, gint y1, gint x2, gint y2)
{
PixbufRenderer *pr = rt->pr;
- gint x, y, w, h;
+ gint x;
+ gint y;
+ gint w;
+ gint h;
- rt_overlay_get_position(rt, od, &x, &y, &w, &h);
+ rt_overlay_get_position(rt, od, x, y, w, h);
/* add borders */
x -= x1;
if (od->flags & OVL_RELATIVE)
{
- gint x, y, w, h;
+ gint x;
+ gint y;
+ gint w;
+ gint h;
- rt_overlay_get_position(rt, od, &x, &y, &w, &h);
+ rt_overlay_get_position(rt, od, x, y, w, h);
gdk_window_move_resize(od->window, x + rt->stereo_off_x, y + rt->stereo_off_y, w, h);
}
}
{
auto rt = static_cast<RendererTiles *>(renderer);
PixbufRenderer *pr = rt->pr;
- OverlayData *od;
gint id;
g_return_val_if_fail(IS_PIXBUF_RENDERER(pr), -1);
id = 1;
while (rt_overlay_find(rt, id)) id++;
- od = g_new0(OverlayData, 1);
+ auto od = g_new0(OverlayData, 1);
od->id = id;
od->pixbuf = pixbuf;
g_object_ref(G_OBJECT(od->pixbuf));
{
while (rt->overlay_list)
{
- OverlayData *od;
-
- od = static_cast<OverlayData *>(rt->overlay_list->data);
+ auto od = static_cast<OverlayData *>(rt->overlay_list->data);
rt_overlay_free(rt, od);
}
}
}
}
-void renderer_tiles_overlay_set(void *renderer, gint id, GdkPixbuf *pixbuf, gint UNUSED(x), gint UNUSED(y))
+void renderer_tiles_overlay_set(void *renderer, gint id, GdkPixbuf *pixbuf, gint, gint)
{
auto rc = static_cast<RendererTiles *>(renderer);
PixbufRenderer *pr = rc->pr;
return TRUE;
}
-static void rt_hierarchy_changed_cb(GtkWidget *UNUSED(widget), GtkWidget *UNUSED(previous_toplevel), gpointer data)
+static void rt_hierarchy_changed_cb(GtkWidget *, GtkWidget *, gpointer data)
{
auto rt = static_cast<RendererTiles *>(data);
rt_overlay_list_reset_window(rt);
return rt->spare_tile;
}
-#define COLOR_BYTES 3 /* rgb */
-
static void rt_tile_rotate_90_clockwise(RendererTiles *rt, GdkPixbuf **tile, gint x, gint y, gint w, gint h)
{
GdkPixbuf *src = *tile;
GdkPixbuf *dest;
- gint srs, drs;
- guchar *s_pix, *d_pix;
- guchar *sp, *dp;
- guchar *ip, *spi, *dpi;
- gint i, j;
+ gint srs;
+ gint drs;
+ guchar *s_pix;
+ guchar *d_pix;
+ guchar *sp;
+ guchar *dp;
+ guchar *ip;
+ guchar *spi;
+ guchar *dpi;
+ gint i;
+ gint j;
gint tw = rt->tile_width * rt->hidpi_scale;
srs = gdk_pixbuf_get_rowstride(src);
{
GdkPixbuf *src = *tile;
GdkPixbuf *dest;
- gint srs, drs;
- guchar *s_pix, *d_pix;
- guchar *sp, *dp;
- guchar *ip, *spi, *dpi;
- gint i, j;
+ gint srs;
+ gint drs;
+ guchar *s_pix;
+ guchar *d_pix;
+ guchar *sp;
+ guchar *dp;
+ guchar *ip;
+ guchar *spi;
+ guchar *dpi;
+ gint i;
+ gint j;
gint th = rt->tile_height * rt->hidpi_scale;
srs = gdk_pixbuf_get_rowstride(src);
{
GdkPixbuf *src = *tile;
GdkPixbuf *dest;
- gint srs, drs;
- guchar *s_pix, *d_pix;
- guchar *sp, *dp;
- guchar *spi, *dpi;
- gint i, j;
+ gint srs;
+ gint drs;
+ guchar *s_pix;
+ guchar *d_pix;
+ guchar *sp;
+ guchar *dp;
+ guchar *spi;
+ guchar *dpi;
+ gint i;
+ gint j;
gint tw = rt->tile_width * rt->hidpi_scale;
{
GdkPixbuf *src = *tile;
GdkPixbuf *dest;
- gint srs, drs;
- guchar *s_pix, *d_pix;
- guchar *sp, *dp;
+ gint srs;
+ gint drs;
+ guchar *s_pix;
+ guchar *d_pix;
+ guchar *sp;
+ guchar *dp;
guchar *dpi;
- gint i, j;
+ gint i;
+ gint j;
gint tw = rt->tile_width * rt->hidpi_scale;
gint th = rt->tile_height * rt->hidpi_scale;
{
GdkPixbuf *src = *tile;
GdkPixbuf *dest;
- gint srs, drs;
- guchar *s_pix, *d_pix;
- guchar *sp, *dp;
- guchar *spi, *dpi;
+ gint srs;
+ gint drs;
+ guchar *s_pix;
+ guchar *d_pix;
+ guchar *sp;
+ guchar *dp;
+ guchar *spi;
+ guchar *dpi;
gint i;
gint th = rt->tile_height * rt->hidpi_scale;
static gboolean rt_source_tile_render(RendererTiles *rt, ImageTile *it,
gint x, gint y, gint w, gint h,
- gboolean UNUSED(new_data), gboolean fast)
+ gboolean, gboolean fast)
{
PixbufRenderer *pr = rt->pr;
GList *list;
while (work)
{
SourceTile *st;
- gint rx, ry, rw, rh;
+ gint rx;
+ gint ry;
+ gint rw;
+ gint rh;
st = static_cast<SourceTile *>(work->data);
work = work->next;
}
else
{
- gdouble scale_x, scale_y;
- gint sx, sy, sw, sh;
+ gdouble scale_x;
+ gdouble scale_y;
+ gint sx;
+ gint sy;
+ gint sw;
+ gint sh;
if (pr->image_width == 0 || pr->image_height == 0) return FALSE;
scale_x = static_cast<gdouble>(pr->width) / pr->image_width;
while (work)
{
SourceTile *st;
- gint rx, ry, rw, rh;
- gint stx, sty, stw, sth;
+ gint rx;
+ gint ry;
+ gint rw;
+ gint rh;
+ gint stx;
+ gint sty;
+ gint stw;
+ gint sth;
st = static_cast<SourceTile *>(work->data);
work = work->next;
gint c;
guchar *psrc;
guchar *pdst;
+ guint32 red_1;
+ guint32 green_1;
+ guint32 blue_1;
+ guint32 red_2;
+ guint32 green_2;
+ guint32 blue_2;
+ guint32 alpha_1;
+ guint32 alpha_2;
if (!has_alpha)
{
}
else
{
+ red_1=static_cast<guint32>(options->image.alpha_color_1.red * 255) << 16 & 0x00FF0000;
+ green_1=static_cast<guint32>(options->image.alpha_color_1.green * 255) << 8 & 0x0000FF00;
+ blue_1=static_cast<guint32>(options->image.alpha_color_1.blue * 255) & 0x000000FF;
+ red_2=static_cast<guint32>(options->image.alpha_color_2.red * 255) << 16 & 0x00FF0000;
+ green_2=static_cast<guint32>(options->image.alpha_color_2.green * 255) << 8 & 0x0000FF00;
+ blue_2=static_cast<guint32>(options->image.alpha_color_2.blue * 255) & 0x000000FF;
+ alpha_1 = red_1 + green_1 + blue_1;
+ alpha_2 = red_2 + green_2 + blue_2;
+
if (ignore_alpha)
{
tmppixbuf = gdk_pixbuf_add_alpha(src, FALSE, 0, 0, 0);
(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)));
+ alpha_1,
+ alpha_2);
g_object_unref(tmppixbuf);
}
else
(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)));
+ alpha_1,
+ alpha_2);
}
}
}
}
else
{
- gdouble scale_x, scale_y;
- gdouble src_x, src_y;
- gint pb_x, pb_y;
- gint pb_w, pb_h;
+ gdouble scale_x;
+ gdouble scale_y;
+ gdouble src_x;
+ gdouble src_y;
+ gint pb_x;
+ gint pb_y;
+ gint pb_w;
+ gint pb_h;
if (pr->image_width == 0 || pr->image_height == 0) return;
switch (orientation)
{
- gdouble tmp;
case EXIF_ORIENTATION_LEFT_TOP:
case EXIF_ORIENTATION_RIGHT_TOP:
case EXIF_ORIENTATION_RIGHT_BOTTOM:
case EXIF_ORIENTATION_LEFT_BOTTOM:
- tmp = scale_x;
- scale_x = scale_y;
- scale_y = tmp;
+ std::swap(scale_x, scale_y);
break;
default:
/* nothing to do */
if (pr->image_width > 32767) wide_image = TRUE;
rt_tile_get_region(has_alpha, pr->ignore_alpha,
- pr->pixbuf, it->pixbuf, pb_x, pb_y, pb_w, pb_h,
- static_cast<gdouble>(0.0) - src_x - GET_RIGHT_PIXBUF_OFFSET(rt) * scale_x,
- static_cast<gdouble>(0.0) - src_y,
- scale_x, scale_y,
- (fast) ? GDK_INTERP_NEAREST : pr->zoom_quality,
- it->x + pb_x, it->y + pb_y, wide_image);
+ pr->pixbuf, it->pixbuf, pb_x, pb_y, pb_w, pb_h,
+ static_cast<gdouble>(0.0) - src_x - get_right_pixbuf_offset(rt) * scale_x,
+ static_cast<gdouble>(0.0) - src_y,
+ scale_x, scale_y,
+ (fast) ? GDK_INTERP_NEAREST : pr->zoom_quality,
+ 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, pr->ignore_alpha,
- pr->pixbuf, right_pb, pb_x, pb_y, pb_w, pb_h,
- static_cast<gdouble>(0.0) - src_x - GET_LEFT_PIXBUF_OFFSET(rt) * scale_x,
- static_cast<gdouble>(0.0) - src_y,
- scale_x, scale_y,
- (fast) ? GDK_INTERP_NEAREST : pr->zoom_quality,
- it->x + pb_x, it->y + pb_y, wide_image);
+ pr->pixbuf, right_pb, pb_x, pb_y, pb_w, pb_h,
+ static_cast<gdouble>(0.0) - src_x - get_left_pixbuf_offset(rt) * scale_x,
+ static_cast<gdouble>(0.0) - src_y,
+ scale_x, scale_y,
+ (fast) ? GDK_INTERP_NEAREST : pr->zoom_quality,
+ 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 */
}
{
cairo_t *cr;
- if (pr->func_post_process && !(pr->post_process_slow && fast))
+ if (pr->func_post_process && (!pr->post_process_slow || !fast))
pr->func_post_process(pr, &it->pixbuf, x, y, w, h, pr->post_process_user_data);
cr = cairo_create(it->surface);
gboolean new_data, gboolean fast)
{
PixbufRenderer *pr = rt->pr;
- //~ GtkWidget *box;
- //~ GdkWindow *window;
cairo_t *cr;
/* clamp to visible */
rt_tile_render(rt, it, x, y, w, h, new_data, fast);
- //~ box = GTK_WIDGET(pr);
- //~ window = gtk_widget_get_window(box);
-
cr = cairo_create(rt->surface);
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);
return rt_queue_schedule_next_draw(rt, FALSE);
}
-static void rt_queue_list_free(GList *list)
+static void rt_queue_data_free(gpointer data)
{
- GList *work;
+ auto *qd = static_cast<QueueData *>(data);
- work = list;
- while (work)
- {
- QueueData *qd;
-
- qd = static_cast<QueueData *>(work->data);
- work = work->next;
-
- qd->it->qd = nullptr;
- qd->it->qd2 = nullptr;
- g_free(qd);
- }
-
- g_list_free(list);
+ qd->it->qd = nullptr;
+ qd->it->qd2 = nullptr;
+ g_free(qd);
}
static void rt_queue_clear(RendererTiles *rt)
{
- rt_queue_list_free(rt->draw_queue);
+ g_list_free_full(rt->draw_queue, rt_queue_data_free);
rt->draw_queue = nullptr;
- rt_queue_list_free(rt->draw_queue_2pass);
+ g_list_free_full(rt->draw_queue_2pass, rt_queue_data_free);
rt->draw_queue_2pass = nullptr;
if (rt->draw_idle_id)
static gboolean rt_clamp_to_visible(RendererTiles *rt, gint *x, gint *y, gint *w, gint *h)
{
PixbufRenderer *pr = rt->pr;
- gint nx, ny;
- gint nw, nh;
- gint vx, vy;
- gint vw, vh;
+ gint nx;
+ gint ny;
+ gint nw;
+ gint nh;
+ gint vx;
+ gint vy;
+ gint vw;
+ gint vh;
vw = pr->vis_width;
vh = pr->vis_height;
gboolean new_data, gboolean only_existing)
{
PixbufRenderer *pr = rt->pr;
- gint i, j;
- gint x1, x2;
- gint y1, y2;
+ gint i;
+ gint j;
+ gint x1;
+ gint x2;
+ gint y1;
+ gint y2;
if (clamp && !rt_clamp_to_visible(rt, &x, &y, &w, &h)) return FALSE;
j > rt->y_scroll + pr->vis_height)));
if (it)
{
- QueueData *qd;
-
if ((render == TILE_RENDER_ALL && it->render_done != TILE_RENDER_ALL) ||
(render == TILE_RENDER_AREA && it->render_todo != TILE_RENDER_ALL))
{
it->render_todo = render;
}
- qd = g_new(QueueData, 1);
+ auto qd = g_new(QueueData, 1);
qd->it = it;
qd->new_data = new_data;
gboolean new_data, gboolean only_existing)
{
PixbufRenderer *pr = rt->pr;
- gint nx, ny;
+ gint nx;
+ gint ny;
rt_sync_scroll(rt);
rt_queue(rt, 0, 0, pr->width, pr->height, TRUE, TILE_RENDER_ALL, FALSE, FALSE);
return;
}
- else
- {
- gint x1, y1;
- gint x2, y2;
+
+ gint x1;
+ gint y1;
+ gint x2;
+ gint y2;
cairo_t *cr;
cairo_surface_t *surface;
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);
}
- }
}
static void renderer_area_changed(void *renderer, gint src_x, gint src_y, gint src_w, gint src_h)
{
auto rt = static_cast<RendererTiles *>(renderer);
PixbufRenderer *pr = rt->pr;
- gint x, y, width, height, x1, y1, x2, y2;
+ gint x;
+ gint y;
+ gint width;
+ gint height;
+ gint x1;
+ gint y1;
+ gint x2;
+ gint y2;
gint orientation = rt_get_orientation(rt);
pr_coords_map_orientation_reverse(orientation,
- src_x - GET_RIGHT_PIXBUF_OFFSET(rt), src_y,
- pr->image_width, pr->image_height,
- src_w, src_h,
- &x, &y,
- &width, &height);
+ src_x - get_right_pixbuf_offset(rt), src_y,
+ pr->image_width, pr->image_height,
+ src_w, src_h,
+ &x, &y,
+ &width, &height);
if (pr->scale != 1.0 && pr->zoom_quality != GDK_INTERP_NEAREST)
{
clamp, render, new_data, only_existing);
}
-static void renderer_update_pixbuf(void *renderer, gboolean UNUSED(lazy))
+static void renderer_update_pixbuf(void *renderer, gboolean)
{
rt_queue_clear(static_cast<RendererTiles *>(renderer));
}
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, static_cast<gdouble>(rt->pr->color.red) / 65535, static_cast<gdouble>(rt->pr->color.green) / 65535, static_cast<gdouble>(rt->pr->color.blue) / 65535);
+ cairo_set_source_rgb(cr, static_cast<gdouble>(rt->pr->color.red), static_cast<gdouble>(rt->pr->color.green), static_cast<gdouble>(rt->pr->color.blue));
cairo_paint(cr);
cairo_destroy(cr);
}
cr = cairo_create(rt->surface);
- cairo_set_source_rgb(cr, static_cast<gdouble>(options->image.border_color.red) / 65535, static_cast<gdouble>(options->image.border_color.green) / 65535, static_cast<gdouble>(options->image.border_color.blue) / 65535);
+ cairo_set_source_rgb(cr, static_cast<gdouble>(options->image.border_color.red), static_cast<gdouble>(options->image.border_color.green), static_cast<gdouble>(options->image.border_color.blue));
cairo_paint(cr);
cairo_set_source_surface(cr, old_surface, 0, 0);
cairo_paint(cr);
return FALSE;
}
-static gboolean rt_draw_cb(GtkWidget *UNUSED(widget), cairo_t *cr, gpointer data)
+static gboolean rt_draw_cb(GtkWidget *, cairo_t *cr, gpointer data)
{
auto rt = static_cast<RendererTiles *>(data);
GList *work;
if (rt->stereo_mode & (PR_STEREO_HORIZ | PR_STEREO_VERT))
{
cairo_push_group(cr);
- cairo_set_source_rgb(cr, static_cast<double>(rt->pr->color.red) / 65535, static_cast<double>(rt->pr->color.green) / 65535, static_cast<double>(rt->pr->color.blue) / 65535);
+ cairo_set_source_rgb(cr, static_cast<double>(rt->pr->color.red), static_cast<double>(rt->pr->color.green), static_cast<double>(rt->pr->color.blue));
if (rt->stereo_mode & PR_STEREO_HORIZ)
{
while (work)
{
od = static_cast<OverlayData *>(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;
+ gint px;
+ gint py;
+ gint pw;
+ gint ph;
- 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;
- }
+ rt_overlay_get_position(rt, od, px, py, pw, ph);
gdk_cairo_set_source_pixbuf(cr, od->pixbuf, px, py);
cairo_paint(cr);