aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2021-11-26 22:34:53 +0100
committerPřemysl Eric Janouch <p@janouch.name>2021-11-26 22:35:29 +0100
commitbae65a61f70436d711badd7326de768aef80e6e9 (patch)
tree5ee4e7bea653f9dbeac93ae7fbf0535f5189591c
parent174896d3e607ce893d752449b83c4505b28dafac (diff)
downloadfiv-bae65a61f70436d711badd7326de768aef80e6e9.tar.gz
fiv-bae65a61f70436d711badd7326de768aef80e6e9.tar.xz
fiv-bae65a61f70436d711badd7326de768aef80e6e9.zip
Add an option to turn off filtering
-rw-r--r--fastiv-view.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/fastiv-view.c b/fastiv-view.c
index 1573ff9..1747266 100644
--- a/fastiv-view.c
+++ b/fastiv-view.c
@@ -34,6 +34,7 @@ struct _FastivView {
cairo_surface_t *surface; ///< The loaded image (sequence)
cairo_surface_t *frame; ///< Current frame within, unreferenced
FastivIoOrientation orientation; ///< Current orientation
+ bool filter;
bool scale_to_fit;
double scale;
};
@@ -350,8 +351,12 @@ fastiv_view_draw(GtkWidget *widget, cairo_t *cr)
cairo_pattern_t *pattern = cairo_get_source(cr);
cairo_pattern_set_matrix(pattern, &matrix);
cairo_pattern_set_extend(pattern, CAIRO_EXTEND_PAD);
+
// TODO(p): Prescale it ourselves to an off-screen bitmap, gamma-correctly.
- cairo_pattern_set_filter(pattern, CAIRO_FILTER_GOOD);
+ if (self->filter)
+ cairo_pattern_set_filter(pattern, CAIRO_FILTER_GOOD);
+ else
+ cairo_pattern_set_filter(pattern, CAIRO_FILTER_NEAREST);
#ifdef GDK_WINDOWING_QUARTZ
// Not supported there. Acts a bit like repeating, but weirdly offset.
@@ -439,6 +444,11 @@ fastiv_view_key_press_event(GtkWidget *widget, GdkEventKey *event)
case GDK_KEY_F:
return set_scale_to_fit(self, !self->scale_to_fit);
+ case GDK_KEY_i:
+ self->filter = !self->filter;
+ gtk_widget_queue_draw(widget);
+ return TRUE;
+
case GDK_KEY_less:
self->orientation = view_left[self->orientation];
gtk_widget_queue_resize(widget);
@@ -504,6 +514,7 @@ fastiv_view_init(FastivView *self)
{
gtk_widget_set_can_focus(GTK_WIDGET(self), TRUE);
+ self->filter = true;
self->scale = 1.0;
}