Skip to content

Commit

Permalink
perf(GUI): don't render frame thumbnails if disabled (synfig#3356)
Browse files Browse the repository at this point in the history
If thumbnail preview is disabled in Synfig Studio
settings, don't render them, instead of just hide them.

Related to synfig#1413 (6709d28)
  • Loading branch information
rodolforg authored May 12, 2024
1 parent 3c3b5b4 commit e832255
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions synfig-studio/src/gui/workarearenderer/renderer_canvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include <synfig/rendering/renderer.h>
#include <synfig/rendering/common/task/tasktransformation.h>

#include <gui/app.h>
#include <gui/canvasview.h>
#include <gui/localization.h>
#include <gui/timemodel.h>
Expand Down Expand Up @@ -361,7 +362,10 @@ Renderer_Canvas::build_onion_frames()
float fps = rend_desc.get_frame_rate();

current_frame = FrameId(base_time, w, h);
current_thumb = FrameId(base_time, thumb_w, thumb_h);
if (App::animation_thumbnail_preview)
current_thumb = FrameId(base_time, thumb_w, thumb_h);
else
current_thumb = FrameId();
frame_duration = Time(approximate_greater_lp(fps, 0.f) ? 1.0/(double)fps : 0.0);

// Set onion_frames
Expand Down Expand Up @@ -609,8 +613,9 @@ Renderer_Canvas::enqueue_render()

// generate rendering task for thumbnail
// do it first to be sure that thumbnails will always fully covered by the single tile
if (enqueue_render_frame(renderer, canvas, current_thumb.rect(), current_thumb))
++enqueued;
if (App::animation_thumbnail_preview)
if (enqueue_render_frame(renderer, canvas, current_thumb.rect(), current_thumb))
++enqueued;

// generate rendering tasks for visible areas
for(FrameList::const_iterator i = onion_frames.begin(); i != onion_frames.end(); ++i)
Expand Down Expand Up @@ -670,15 +675,17 @@ Renderer_Canvas::enqueue_render()

if(future_exists && (!past_exists || future_priority)) {
// queue future
if(enqueue_render_frame(renderer, canvas, current_thumb.rect(), current_thumb.with_time(future_time)))
++enqueued;
if (App::animation_thumbnail_preview)
if (enqueue_render_frame(renderer, canvas, current_thumb.rect(), current_thumb.with_time(future_time)))
++enqueued;
if(enqueue_render_frame(renderer, canvas, window_rect, current_frame.with_time(future_time)))
++enqueued;
++future;
} else {
// queue past
if(enqueue_render_frame(renderer, canvas, current_thumb.rect(), current_thumb.with_time(past_time)))
++enqueued;
if (App::animation_thumbnail_preview)
if (enqueue_render_frame(renderer, canvas, current_thumb.rect(), current_thumb.with_time(past_time)))
++enqueued;
if(enqueue_render_frame(renderer, canvas, window_rect, current_frame.with_time(past_time)))
++enqueued;
++past;
Expand Down Expand Up @@ -791,14 +798,16 @@ Renderer_Canvas::get_render_status(StatusMap &out_map)
out_map.clear();
for(TileMap::const_iterator i = tiles.begin(); i != tiles.end(); ++i)
if ( !i->second.empty()
&& ( (i->first.width == current_thumb.width && i->first.height == current_thumb.height)
&& ( (App::animation_thumbnail_preview && (i->first.width == current_thumb.width && i->first.height == current_thumb.height))
|| (i->first.width == current_frame.width && i->first.height == current_frame.height) ))
out_map[i->first.time] = FS_None;

for(StatusMap::iterator i = out_map.begin(); i != out_map.end(); ) {
i->second = merge_status(
calc_frame_status(current_frame.with_time(i->first), window_rect),
calc_frame_status(current_thumb.with_time(i->first), current_thumb.rect()) );
i->second = calc_frame_status(current_frame.with_time(i->first), window_rect);
if (App::animation_thumbnail_preview) {
FrameStatus thumb_status = calc_frame_status(current_thumb.with_time(i->first), current_thumb.rect());
i->second = merge_status(i->second, thumb_status);
}
if (i->second == FS_None) out_map.erase(i++); else ++i;
}
}
Expand Down

0 comments on commit e832255

Please sign in to comment.