User option to set tile size
authorColin Clark <colin.clark@cclark.uk>
Thu, 2 Sep 2021 11:55:20 +0000 (12:55 +0100)
committerColin Clark <colin.clark@cclark.uk>
Thu, 2 Sep 2021 11:55:20 +0000 (12:55 +0100)
Additional user option in Edit/Preferences/Image to set the tile size.

doc/docbook/GuideOptionsImage.xml
src/options.c
src/options.h
src/preferences.c
src/rcfile.c
src/renderer-tiles.c

index ed44bea..446e312 100644 (file)
       </varlistentry>\r
     </variablelist>\r
   </section>\r
+  <section id="TileSize">\r
+    <title>Tile Size</title>\r
+    <variablelist>\r
+      <varlistentry>\r
+        <term>\r
+          <guilabel>Tile size in pixels</guilabel>\r
+        </term>\r
+        <listitem>\r
+          <para>\r
+            This option is only available when GPU acceleration is not selected. It sets the size in pixels that large images are split into during rendering. Setting a larger value will reduce the tiling effect seen as the image is displayed, but will also slightly increase the delay until the first part of the image is seen.\r
+          </para>\r
+        </listitem>\r
+      </varlistentry>\r
+    </variablelist>\r
+  </section>\r
   <section id="Appearance">\r
     <title>Appearance</title>\r
     <variablelist>\r
index 8f9cb7c..c4fca52 100644 (file)
@@ -123,6 +123,7 @@ ConfOptions *init_options(ConfOptions *options)
        options->image.zoom_mode = ZOOM_RESET_NONE;
        options->image.zoom_quality = GDK_INTERP_BILINEAR;
        options->image.zoom_to_fit_allow_expand = FALSE;
+       options->image.tile_size = 128;
 
        options->image_overlay.template_string = NULL;
        options->image_overlay.x = 10;
index 5ba51dd..c9623d9 100644 (file)
@@ -153,6 +153,8 @@ struct _ConfOptions
                GdkColor border_color;
                GdkColor alpha_color_1;
                GdkColor alpha_color_2;
+
+               gint tile_size;
        } image;
 
        /* thumbnails */
index 4546b1d..65cf4d6 100644 (file)
@@ -286,6 +286,7 @@ static void config_window_apply(void)
        options->image.max_autofit_size = c_options->image.max_autofit_size;
        options->image.max_enlargement_size = c_options->image.max_enlargement_size;
        options->image.use_clutter_renderer = c_options->image.use_clutter_renderer;
+       options->image.tile_size = c_options->image.tile_size;
        options->progressive_key_scrolling = c_options->progressive_key_scrolling;
        options->keyboard_scroll_step = c_options->keyboard_scroll_step;
 
@@ -2286,6 +2287,15 @@ static void config_tab_image(GtkWidget *notebook)
        pref_checkbox_link_sensitivity(ct_button, spin);
        gtk_widget_set_tooltip_text(GTK_WIDGET(hbox), _("This value will set the virtual size of the window when \"Fit image to window\" is set. Instead of using the actual size of the window, the specified percentage of the window will be used. It allows one to keep a border around the image (values lower than 100%) or to auto zoom the image (values greater than 100%). It affects fullscreen mode too."));
 
+       group = pref_group_new(vbox, FALSE, _("Tile size"), GTK_ORIENTATION_VERTICAL);
+       gtk_widget_set_sensitive(group, !options->image.use_clutter_renderer);
+
+       hbox = pref_box_new(group, FALSE, GTK_ORIENTATION_HORIZONTAL, PREF_PAD_SPACE);
+       spin = pref_spin_new_int(hbox, _("Pixels"), _("(Requires restart)"),
+                                128, 4096, 128,
+                                options->image.tile_size, &c_options->image.tile_size);
+       gtk_widget_set_tooltip_text(GTK_WIDGET(hbox), _("This value changes the size of the tiles large images are split into. Increasing the size of the tiles will reduce the tiling effect seen on image changes, but will also slightly increase the delay before the first part of a large image is seen."));
+
        group = pref_group_new(vbox, FALSE, _("Appearance"), GTK_ORIENTATION_VERTICAL);
 
        pref_checkbox_new_int(group, _("Use custom border color in window mode"),
index feaca6e..aeb949a 100644 (file)
@@ -399,6 +399,7 @@ static void write_global_attributes(GString *outstr, gint indent)
        WRITE_NL(); WRITE_COLOR(*options, image.alpha_color_1);
        WRITE_NL(); WRITE_COLOR(*options, image.alpha_color_2);
        WRITE_NL(); WRITE_BOOL(*options, image.use_clutter_renderer);
+       WRITE_NL(); WRITE_INT(*options, image.tile_size);
 
        /* Thumbnails Options */
        WRITE_NL(); WRITE_INT(*options, thumbnails.max_width);
@@ -882,6 +883,7 @@ static gboolean load_global_params(const gchar **attribute_names, const gchar **
                if (READ_COLOR(*options, image.alpha_color_1)) continue;
                if (READ_COLOR(*options, image.alpha_color_2)) continue;
                if (READ_BOOL(*options, image.use_clutter_renderer)) continue;
+               if (READ_INT(*options, image.tile_size)) continue;
 
                /* Thumbnails options */
                if (READ_INT_CLAMP(*options, thumbnails.max_width, 16, 512)) continue;
index e993896..9b67175 100644 (file)
@@ -58,10 +58,6 @@ typedef enum {
 } 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;
 
@@ -501,7 +497,7 @@ static gint pixmap_calc_size(cairo_surface_t *surface)
 
 //     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(
@@ -2359,8 +2355,8 @@ RendererFuncs *renderer_tiles_new(PixbufRenderer *pr)
 
        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;