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
+
+ 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
+
+ rt->y_scroll = (rt->stereo_mode & PR_STEREO_FLIP) ?
+ pr->height - pr->vis_height - pr->y_scroll
: pr->y_scroll;
}
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);
return draw;
}
-static void rt_tile_get_region(gboolean has_alpha,
+static void rt_tile_get_region(gboolean has_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,
pb_w, pb_h,
dest,
pb_x, pb_y);
- }
+ }
else
{
- gdk_pixbuf_scale(src, dest,
+ gdk_pixbuf_scale(src, dest,
pb_x, pb_y, pb_w, pb_h,
offset_x,
offset_y,
}
else
{
- gdk_pixbuf_composite_color(src, dest,
+ gdk_pixbuf_composite_color(src, dest,
pb_x, pb_y, pb_w, pb_h,
offset_x,
offset_y,
else if ((pr->zoom == 1.0 || pr->scale == 1.0) &&
pr->aspect_ratio == 1.0 &&
!has_alpha &&
- orientation == EXIF_ORIENTATION_TOP_LEFT &&
+ orientation == EXIF_ORIENTATION_TOP_LEFT &&
!(pr->func_post_process && !(pr->post_process_slow && fast)) &&
!(rt->stereo_mode & PR_STEREO_ANAGLYPH))
{
/* nothing to do */
break;
}
-
+
/* HACK: The pixbuf scalers get kinda buggy(crash) with extremely
* small sizes for anything but GDK_INTERP_NEAREST
*/
scale_x, scale_y,
(fast) ? GDK_INTERP_NEAREST : pr->zoom_quality,
it->x + pb_x, it->y + pb_y);
- if (rt->stereo_mode & PR_STEREO_ANAGLYPH &&
+ 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);
}
if (it->x + x + w > rt->x_scroll + pr->vis_width)
{
- w = rt->x_scroll + pr->vis_width - it->x - x;
+ w = rt->x_scroll + pr->vis_width - it->x - x;
}
if (w < 1) return;
if (it->y + y < rt->y_scroll)
}
if (it->y + y + h > rt->y_scroll + pr->vis_height)
{
- h = rt->y_scroll + pr->vis_height - it->y - y;
+ h = rt->y_scroll + pr->vis_height - it->y - y;
}
if (h < 1) return;
static gint rt_get_queued_area(GList *work)
{
gint area = 0;
-
- while (work)
+
+ while (work)
{
QueueData *qd = work->data;
area += qd->w * qd->h;
PixbufRenderer *pr = rt->pr;
gfloat percent;
gint visible_area = pr->vis_width * pr->vis_height;
-
+
if (!pr->loading)
{
- /* 2pass prio */
+ /* 2pass prio */
DEBUG_2("redraw priority: 2pass");
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)
{
rt_sync_scroll(rt);
if (rt->stereo_mode & PR_STEREO_MIRROR) x_off = -x_off;
- if (rt->stereo_mode & PR_STEREO_FLIP) y_off = -y_off;
+ if (rt->stereo_mode & PR_STEREO_FLIP) y_off = -y_off;
gint w = pr->vis_width - abs(x_off);
gint h = pr->vis_height - abs(y_off);
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_RIGHT)
{
- if (rt->stereo_mode & PR_STEREO_HORIZ)
+ if (rt->stereo_mode & PR_STEREO_HORIZ)
{
rt->stereo_off_x = rt->pr->viewport_width;
}
- else if (rt->stereo_mode & PR_STEREO_VERT)
+ else if (rt->stereo_mode & PR_STEREO_VERT)
{
rt->stereo_off_y = rt->pr->viewport_height;
}
- else if (rt->stereo_mode & PR_STEREO_FIXED)
+ else if (rt->stereo_mode & PR_STEREO_FIXED)
{
rt->stereo_off_x = rt->pr->stereo_fixed_x_right;
rt->stereo_off_y = rt->pr->stereo_fixed_y_right;
}
else
{
- if (rt->stereo_mode & PR_STEREO_FIXED)
+ if (rt->stereo_mode & PR_STEREO_FIXED)
{
rt->stereo_off_x = rt->pr->stereo_fixed_x_left;
rt->stereo_off_y = rt->pr->stereo_fixed_y_left;
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;