Skip to content

Commit

Permalink
Assume soft reset when getting stream state
Browse files Browse the repository at this point in the history
Because the server always does this before asking us to start a streamed
reset, so we now rely on that assumption to avoid rolling back the local
fork twice.
  • Loading branch information
askmeaboutlo0m committed Aug 30, 2024
1 parent 4cba11e commit e44cc40
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 17 deletions.
22 changes: 8 additions & 14 deletions src/drawdance/libengine/dpengine/canvas_history.c
Original file line number Diff line number Diff line change
Expand Up @@ -896,23 +896,17 @@ void DP_canvas_history_soft_reset(DP_CanvasHistory *ch, DP_DrawContext *dc,
}
}

DP_CanvasState *DP_canvas_history_stream_start_state_inc(DP_CanvasHistory *ch,
DP_DrawContext *dc)
DP_CanvasState *DP_canvas_history_stream_start_state_inc(DP_CanvasHistory *ch)
{
DP_ASSERT(ch);
bool have_fork = have_local_fork(ch);
if (have_fork) {
search_and_replay_from(ch, dc, ch->fork.start - ch->offset, false);
}

DP_CanvasState *cs = DP_canvas_state_incref(ch->current_state);

if (have_fork) {
finish_replay(ch, replay_fork_dec(ch, DP_canvas_state_incref(cs), dc),
dc);
int used = ch->used;
for (int i = 0; i < used; ++i) {
DP_CanvasState *cs = ch->entries->state;
if (cs) {
return DP_canvas_state_incref(cs);
}
}

return cs;
DP_UNREACHABLE();
}

int DP_canvas_history_undo_depth_limit(DP_CanvasHistory *ch)
Expand Down
4 changes: 2 additions & 2 deletions src/drawdance/libengine/dpengine/canvas_history.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ void DP_canvas_history_soft_reset(DP_CanvasHistory *ch, DP_DrawContext *dc,
unsigned int context_id,
DP_CanvasHistorySoftResetFn fn, void *user);

DP_CanvasState *DP_canvas_history_stream_start_state_inc(DP_CanvasHistory *ch,
DP_DrawContext *dc);
// This must have had a soft reset right before it to return the correct state.
DP_CanvasState *DP_canvas_history_stream_start_state_inc(DP_CanvasHistory *ch);

int DP_canvas_history_undo_depth_limit(DP_CanvasHistory *ch);

Expand Down
2 changes: 1 addition & 1 deletion src/drawdance/libengine/dpengine/paint_engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ static void handle_internal(DP_PaintEngine *pe, DP_DrawContext *dc,
mi, &correlator_length);
stream_reset_start_fn(
pe->stream_reset.user,
DP_canvas_history_stream_start_state_inc(pe->ch, dc),
DP_canvas_history_stream_start_state_inc(pe->ch),
correlator_length, correlator);
}
else {
Expand Down

0 comments on commit e44cc40

Please sign in to comment.