/*
- * Geeqie
- * (C) 2006 John Ellis
- * Copyright (C) 2008 - 2012 The Geeqie Team
+ * Copyright (C) 2006 John Ellis
+ * Copyright (C) 2008 - 2016 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>
GList *overlay_list;
cairo_surface_t *overlay_buffer;
-
+
guint draw_idle_id; /* event source id */
GdkPixbuf *spare_tile;
-
+
gint stereo_mode;
gint stereo_off_x;
gint stereo_off_y;
-
+
gint x_scroll; /* allow local adjustment and mirroring */
gint y_scroll;
-
+
};
static void rt_sync_scroll(RendererTiles *rt)
{
PixbufRenderer *pr = rt->pr;
-
+
rt->x_scroll = (rt->stereo_mode & PR_STEREO_MIRROR) ?
pr->width - pr->vis_width - pr->x_scroll
: pr->x_scroll;
-
+
rt->y_scroll = (rt->stereo_mode & PR_STEREO_FLIP) ?
pr->height - pr->vis_height - pr->y_scroll
: pr->y_scroll;
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);
work = work->next;
if (!od->window) rt_overlay_init_window(rt, od);
-
+
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))
{
cairo_set_source_surface(cr, it->surface, (pr->x_offset + (it->x - rt->x_scroll)) - rx, (pr->y_offset + (it->y - rt->y_scroll)) - ry);
cairo_rectangle(cr, 0, 0, rw, rh);
cairo_fill_preserve(cr);
-
+
gdk_cairo_set_source_pixbuf(cr, od->pixbuf, px - rx, py - ry);
cairo_fill (cr);
cairo_destroy (cr);
-
+
cr = gdk_cairo_create(od->window);
cairo_set_source_surface(cr, rt->overlay_buffer, rx - px, ry - py);
cairo_rectangle (cr, rx - px, ry - py, rw, rh);
cairo_set_source_rgb(cr, 0, 0, 0);
cairo_rectangle(cr, 0, 0, sw, sh);
cairo_fill_preserve(cr);
-
+
gdk_cairo_set_source_pixbuf(cr, od->pixbuf, px - sx, py - sy);
cairo_fill (cr);
cairo_destroy (cr);
-
+
cr = gdk_cairo_create(od->window);
cairo_set_source_surface(cr, rt->overlay_buffer, sx - px, sy - py);
cairo_rectangle (cr, sx - px, sy - py, sw, sh);
gint x, y, w, h;
rt_overlay_get_position(rt, od, &x, &y, &w, &h);
-
+
/* add borders */
x -= x1;
y -= y1;
w += x1 + x2;
h += y1 + y2;
-
+
rt_queue(rt, rt->x_scroll - pr->x_offset + x,
rt->y_scroll - pr->y_offset + y,
w, h,
{
OverlayData *od = work->data;
work = work->next;
-
+
if (!od->window) rt_overlay_init_window(rt, od);
-
+
if (od->flags & OVL_RELATIVE)
{
gint x, y, w, h;
od->flags = flags;
rt_overlay_init_window(rt, od);
-
+
rt->overlay_list = g_list_append(rt->overlay_list, od);
rt_overlay_queue_draw(rt, od, 0, 0, 0, 0);
scale_x, scale_y,
interp_type,
255, check_x, check_y,
- PR_ALPHA_CHECK_SIZE, PR_ALPHA_CHECK1, PR_ALPHA_CHECK2);
+ 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)));
}
}
{
draw = rt_source_tile_render(rt, it, x, y, w, h, new_data, fast);
}
- else if ((pr->zoom == 1.0 || pr->scale == 1.0) &&
- pr->aspect_ratio == 1.0 &&
- !has_alpha &&
- orientation == EXIF_ORIENTATION_TOP_LEFT &&
- !(pr->func_post_process && !(pr->post_process_slow && fast)) &&
- !(rt->stereo_mode & PR_STEREO_ANAGLYPH))
- {
- /* special case: faster, simple, scale 1.0, base orientation, no postprocessing */
- cairo_t *cr;
- cr = cairo_create(it->surface);
- cairo_rectangle (cr, x, y, w, h);
- gdk_cairo_set_source_pixbuf(cr, pr->pixbuf, -it->x - GET_RIGHT_PIXBUF_OFFSET(rt), -it->y);
- cairo_fill (cr);
- cairo_destroy (cr);
- }
else
{
gdouble scale_x, scale_y;
/* nothing to do */
break;
}
-
+
/* HACK: The pixbuf scalers get kinda buggy(crash) with extremely
* small sizes for anything but GDK_INTERP_NEAREST
*/
static gint rt_get_queued_area(GList *work)
{
gint area = 0;
-
+
while (work)
{
QueueData *qd = work->data;
PixbufRenderer *pr = rt->pr;
gfloat percent;
gint visible_area = pr->vis_width * pr->vis_height;
-
+
if (!pr->loading)
{
/* 2pass prio */
rt->draw_idle_id = g_idle_add_full(G_PRIORITY_DEFAULT_IDLE, rt_queue_draw_idle_cb, rt, NULL);
return FALSE;
}
-
+
if (visible_area == 0)
{
/* not known yet */
{
percent = 100.0 * rt_get_queued_area(rt->draw_queue) / visible_area;
}
-
+
if (percent > 10.0)
{
/* we have enough data for starting intensive redrawing */
rt->draw_idle_id = g_idle_add_full(GDK_PRIORITY_REDRAW, rt_queue_draw_idle_cb, rt, NULL);
return FALSE;
}
-
+
if (percent < 1.0 || force_set)
{
/* queue is (almost) empty, wait 50 ms*/
rt->draw_idle_id = g_timeout_add_full(G_PRIORITY_DEFAULT_IDLE, 50, rt_queue_draw_idle_cb, rt, NULL);
return FALSE;
}
-
+
/* keep the same priority as before */
DEBUG_2("redraw priority: no change %.2f %%", percent);
return TRUE;
}
-
+
static gboolean rt_queue_draw_idle_cb(gpointer data)
{
x -= rt->stereo_off_x;
y -= rt->stereo_off_y;
-
+
rt_border_draw(rt, x, y, w, h);
x = MAX(0, x - pr->x_offset + pr->x_scroll);
rt->stereo_off_x = 0;
rt->stereo_off_y = 0;
-
+
if (rt->stereo_mode & PR_STEREO_RIGHT)
{
if (rt->stereo_mode & PR_STEREO_HORIZ)
RendererFuncs *renderer_tiles_new(PixbufRenderer *pr)
{
RendererTiles *rt = g_new0(RendererTiles, 1);
-
+
rt->pr = pr;
-
+
rt->f.area_changed = renderer_area_changed;
rt->f.update_pixbuf = renderer_update_pixbuf;
rt->f.free = renderer_free;
rt->f.overlay_get = renderer_tiles_overlay_get;
rt->f.stereo_set = renderer_stereo_set;
-
+
rt->tile_width = PR_TILE_SIZE;
rt->tile_height = PR_TILE_SIZE;
rt->tile_cache_max = PR_CACHE_SIZE_DEFAULT;
rt->draw_idle_id = 0;
-
+
rt->stereo_mode = 0;
rt->stereo_off_x = 0;
rt->stereo_off_y = 0;