Skip to content

Commit

Permalink
keyframes: some brush strokes fixes and optimisations
Browse files Browse the repository at this point in the history
  • Loading branch information
hanatos committed Dec 6, 2024
1 parent 9bc022c commit a36acf2
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/gui/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ dt_gui_dr_draw_position(
vx[v] = dt_draw_vertex(xi, yi, pressure * radius, opacity, hardness);
}
// trigger draw list upload and recomputation:
vkdt.graph_dev.runflags = s_graph_run_record_cmd_buf | s_graph_run_upload_source | s_graph_run_wait_done;
vkdt.graph_dev.runflags = s_graph_run_record_cmd_buf;
vkdt.graph_dev.module[vkdt.wstate.active_widget_modid].flags = s_module_request_read_source;
}
else
Expand Down
7 changes: 4 additions & 3 deletions src/gui/render_darkroom.c
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,8 @@ void render_darkroom()
vkdt.state.anim_frame = anim_frame;
vkdt.graph_dev.frame = vkdt.state.anim_frame;
vkdt.state.anim_no_keyframes = 0; // (re-)enable keyframes
vkdt.graph_dev.runflags = dt_graph_apply_keyframes(&vkdt.graph_dev); // rerun once
dt_graph_apply_keyframes(&vkdt.graph_dev); // rerun once
vkdt.graph_dev.runflags = s_graph_run_record_cmd_buf;
}
char text[50];
snprintf(text, sizeof(text), "frame %d/%d", vkdt.state.anim_frame, vkdt.state.anim_max_frame);
Expand Down Expand Up @@ -868,9 +869,9 @@ darkroom_process()
dt_log(s_log_snd, "frame drop warning, audio may stutter!");
vkdt.graph_dev.frame = vkdt.state.anim_frame;
if(!vkdt.state.anim_no_keyframes)
vkdt.graph_dev.runflags |= dt_graph_apply_keyframes(&vkdt.graph_dev);
dt_graph_apply_keyframes(&vkdt.graph_dev);
if(vkdt.graph_dev.frame_cnt == 0 || vkdt.state.anim_frame < vkdt.state.anim_max_frame+1)
vkdt.graph_dev.runflags |= s_graph_run_record_cmd_buf;
vkdt.graph_dev.runflags = s_graph_run_record_cmd_buf;
}
if(vkdt.state.anim_frame == vkdt.graph_dev.frame_cnt - 1)
dt_gui_dr_anim_stop(); // reached the end, stop.
Expand Down
2 changes: 1 addition & 1 deletion src/gui/widget_image.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ dt_image_events(struct nk_context *ctx, dt_image_widget_t *w, int hovered, int m
}
}
// trigger recomputation:
vkdt.graph_dev.runflags = s_graph_run_record_cmd_buf | s_graph_run_wait_done;
vkdt.graph_dev.runflags = s_graph_run_record_cmd_buf;
vkdt.graph_dev.module[vkdt.wstate.active_widget_modid].flags = s_module_request_read_source;
}
float yoff = ctx->input.mouse.scroll_delta.y;
Expand Down
3 changes: 2 additions & 1 deletion src/pipe/graph-run-nodes-upload.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ dt_graph_run_nodes_upload(
{
if(node->module->so->read_source)
{
int run_node = (node->flags & s_module_request_read_source) ||
int run_node = (node->module->flags & s_module_request_read_source) ||
(node->flags & s_module_request_read_source) ||
(run & s_graph_run_upload_source);
const int c = 0;
if(run_node || (dynamic_array && (node->connector[c].flags & s_conn_dynamic_array)))
Expand Down
11 changes: 5 additions & 6 deletions src/pipe/graph.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,10 @@ VkResult dt_graph_run(
dt_log(s_log_pipe|s_log_err, "too many nodes in graph!");
return VK_INCOMPLETE;
}
#define TRAVERSE_POST \
nodeid[cnt++] = curr;
#define TRAVERSE_POST {\
module_flags |= arr[curr].flags;\
nodeid[cnt++] = curr;\
}
#include "graph-traverse.inc"

if(cnt == 0)
Expand Down Expand Up @@ -607,11 +609,10 @@ void dt_graph_reset(dt_graph_t *g)
#endif
}

dt_graph_run_t
void
dt_graph_apply_keyframes(
dt_graph_t *g)
{
dt_graph_run_t ret = s_graph_run_record_cmd_buf;
for(int m=0;m<g->num_modules;m++)
{
if(g->module[m].name == 0) continue; // skip deleted modules
Expand Down Expand Up @@ -677,13 +678,11 @@ dt_graph_apply_keyframes(
if(src1[0] < src0[0]) for(int i=vcnt;i<dst[0];i++) vd[i] = v0[i];
vd[dst[0]-1] = dt_draw_endmarker();
g->module[m].flags = s_module_request_read_source; // make sure the draw list is updated
ret |= s_graph_run_upload_source;
}
else
{ // apply directly
memcpy(pdat, fdat + els*kf[ki].beg, els*(kf[ki].end-kf[ki].beg));
}
}
}
return ret;
}
3 changes: 1 addition & 2 deletions src/pipe/graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,7 @@ dt_graph_connector_image(

// apply all keyframes found in the module list and write to the modules parameters according to
// the current frame in the graph (g->frame). floating point parameters will be interpolated.
dt_graph_run_t // return required runflags on graph
dt_graph_apply_keyframes(
void dt_graph_apply_keyframes(
dt_graph_t *g);

static inline dt_token_t
Expand Down

0 comments on commit a36acf2

Please sign in to comment.