1
0
Fork 0

clutter/frame-clock: Merge states DISPATCHING and PENDING_PRESENTED

Chronologically they already overlap in time as presentation may
complete in the middle of the dispatch function, otherwise they are
contiguous in time. And most switch statements treated the two states
the same already so they're easy to merge into a single `DISPATCHED`
state.

Having fewer states now will make life easier when we add more states
later.

(cherry picked from commit a83535e24aecb9148f334b3d5cef9537709dc52a)
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1441>
Signed-off-by: Mingi Sung <sungmg@saltyming.net>
This commit is contained in:
Daniel van Vugt 2020-07-24 14:13:11 +08:00 committed by Mingi Sung
parent 1c1ff4aab1
commit 04421c2648
Signed by: sungmg
GPG key ID: 41BAFD6FFD8036C5
2 changed files with 16 additions and 27 deletions

View file

@ -70,8 +70,7 @@ typedef enum _ClutterFrameClockState
CLUTTER_FRAME_CLOCK_STATE_IDLE,
CLUTTER_FRAME_CLOCK_STATE_SCHEDULED,
CLUTTER_FRAME_CLOCK_STATE_SCHEDULED_NOW,
CLUTTER_FRAME_CLOCK_STATE_DISPATCHING,
CLUTTER_FRAME_CLOCK_STATE_PENDING_PRESENTED,
CLUTTER_FRAME_CLOCK_STATE_DISPATCHED,
} ClutterFrameClockState;
typedef struct _Frame
@ -476,8 +475,7 @@ clutter_frame_clock_notify_presented (ClutterFrameClock *frame_clock,
case CLUTTER_FRAME_CLOCK_STATE_SCHEDULED_NOW:
g_warn_if_reached ();
break;
case CLUTTER_FRAME_CLOCK_STATE_DISPATCHING:
case CLUTTER_FRAME_CLOCK_STATE_PENDING_PRESENTED:
case CLUTTER_FRAME_CLOCK_STATE_DISPATCHED:
frame_clock->state = CLUTTER_FRAME_CLOCK_STATE_IDLE;
maybe_reschedule_update (frame_clock);
break;
@ -500,8 +498,7 @@ clutter_frame_clock_notify_ready (ClutterFrameClock *frame_clock)
case CLUTTER_FRAME_CLOCK_STATE_SCHEDULED_NOW:
g_warn_if_reached ();
break;
case CLUTTER_FRAME_CLOCK_STATE_DISPATCHING:
case CLUTTER_FRAME_CLOCK_STATE_PENDING_PRESENTED:
case CLUTTER_FRAME_CLOCK_STATE_DISPATCHED:
frame_clock->state = CLUTTER_FRAME_CLOCK_STATE_IDLE;
maybe_reschedule_update (frame_clock);
break;
@ -806,8 +803,7 @@ clutter_frame_clock_inhibit (ClutterFrameClock *frame_clock)
frame_clock->pending_reschedule_now = TRUE;
frame_clock->state = CLUTTER_FRAME_CLOCK_STATE_IDLE;
break;
case CLUTTER_FRAME_CLOCK_STATE_DISPATCHING:
case CLUTTER_FRAME_CLOCK_STATE_PENDING_PRESENTED:
case CLUTTER_FRAME_CLOCK_STATE_DISPATCHED:
break;
}
@ -846,8 +842,7 @@ clutter_frame_clock_schedule_update_now (ClutterFrameClock *frame_clock)
break;
case CLUTTER_FRAME_CLOCK_STATE_SCHEDULED_NOW:
return;
case CLUTTER_FRAME_CLOCK_STATE_DISPATCHING:
case CLUTTER_FRAME_CLOCK_STATE_PENDING_PRESENTED:
case CLUTTER_FRAME_CLOCK_STATE_DISPATCHED:
frame_clock->pending_reschedule = TRUE;
frame_clock->pending_reschedule_now = TRUE;
return;
@ -902,8 +897,7 @@ clutter_frame_clock_schedule_update (ClutterFrameClock *frame_clock)
case CLUTTER_FRAME_CLOCK_STATE_SCHEDULED:
case CLUTTER_FRAME_CLOCK_STATE_SCHEDULED_NOW:
return;
case CLUTTER_FRAME_CLOCK_STATE_DISPATCHING:
case CLUTTER_FRAME_CLOCK_STATE_PENDING_PRESENTED:
case CLUTTER_FRAME_CLOCK_STATE_DISPATCHED:
frame_clock->pending_reschedule = TRUE;
return;
}
@ -958,8 +952,7 @@ clutter_frame_clock_set_mode (ClutterFrameClock *frame_clock,
frame_clock->pending_reschedule_now = TRUE;
frame_clock->state = CLUTTER_FRAME_CLOCK_STATE_IDLE;
break;
case CLUTTER_FRAME_CLOCK_STATE_DISPATCHING:
case CLUTTER_FRAME_CLOCK_STATE_PENDING_PRESENTED:
case CLUTTER_FRAME_CLOCK_STATE_DISPATCHED:
break;
}
@ -1041,7 +1034,7 @@ clutter_frame_clock_dispatch (ClutterFrameClock *frame_clock,
this_dispatch->dispatch_time_us = time_us;
g_source_set_ready_time (frame_clock->source, -1);
frame_clock->state = CLUTTER_FRAME_CLOCK_STATE_DISPATCHING;
frame_clock->state = CLUTTER_FRAME_CLOCK_STATE_DISPATCHED;
frame_count = frame_clock->frame_count++;
@ -1075,20 +1068,20 @@ clutter_frame_clock_dispatch (ClutterFrameClock *frame_clock,
switch (frame_clock->state)
{
case CLUTTER_FRAME_CLOCK_STATE_INIT:
case CLUTTER_FRAME_CLOCK_STATE_PENDING_PRESENTED:
g_warn_if_reached ();
break;
case CLUTTER_FRAME_CLOCK_STATE_IDLE:
/* Presentation completed synchronously in the above listener */
case CLUTTER_FRAME_CLOCK_STATE_SCHEDULED:
case CLUTTER_FRAME_CLOCK_STATE_SCHEDULED_NOW:
break;
case CLUTTER_FRAME_CLOCK_STATE_DISPATCHING:
case CLUTTER_FRAME_CLOCK_STATE_DISPATCHED:
switch (result)
{
case CLUTTER_FRAME_RESULT_PENDING_PRESENTED:
frame_clock->state = CLUTTER_FRAME_CLOCK_STATE_PENDING_PRESENTED;
break;
case CLUTTER_FRAME_RESULT_IDLE:
/* The frame was aborted; nothing to paint/present */
clutter_frame_clock_notify_ready (frame_clock);
break;
}
@ -1307,8 +1300,6 @@ clutter_frame_clock_dispose (GObject *object)
{
ClutterFrameClock *frame_clock = CLUTTER_FRAME_CLOCK (object);
g_warn_if_fail (frame_clock->state != CLUTTER_FRAME_CLOCK_STATE_DISPATCHING);
if (frame_clock->source)
{
g_signal_emit (frame_clock, signals[DESTROY], 0);

View file

@ -4,11 +4,9 @@
```mermaid
stateDiagram
Init --> Scheduled/ScheduledNow : schedule update() -> now
Idle --> Scheduled/ScheduledNow : schedule update() -> given presentation time
Scheduled/ScheduledNow --> Dispatching : target time hit
Dispatching --> PendingPresented : queued page flip
Dispatching --> Idle : no queued page flip
PendingPresented --> Scheduled/ScheduledNow : page flipped, if recent schedule update
PendingPresented --> Idle : page flipped
INIT --> SCHEDULED/SCHEDULED_NOW : start first frame immediately
IDLE --> SCHEDULED/SCHEDULED_NOW : given presentation time
SCHEDULED/SCHEDULED_NOW --> IDLE : frame clock inhibited or mode changed
SCHEDULED/SCHEDULED_NOW --> DISPATCHED : start a frame
DISPATCHED --> IDLE : frame presented or aborted with nothing to draw
```