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:
parent
1c1ff4aab1
commit
04421c2648
2 changed files with 16 additions and 27 deletions
|
@ -70,8 +70,7 @@ typedef enum _ClutterFrameClockState
|
||||||
CLUTTER_FRAME_CLOCK_STATE_IDLE,
|
CLUTTER_FRAME_CLOCK_STATE_IDLE,
|
||||||
CLUTTER_FRAME_CLOCK_STATE_SCHEDULED,
|
CLUTTER_FRAME_CLOCK_STATE_SCHEDULED,
|
||||||
CLUTTER_FRAME_CLOCK_STATE_SCHEDULED_NOW,
|
CLUTTER_FRAME_CLOCK_STATE_SCHEDULED_NOW,
|
||||||
CLUTTER_FRAME_CLOCK_STATE_DISPATCHING,
|
CLUTTER_FRAME_CLOCK_STATE_DISPATCHED,
|
||||||
CLUTTER_FRAME_CLOCK_STATE_PENDING_PRESENTED,
|
|
||||||
} ClutterFrameClockState;
|
} ClutterFrameClockState;
|
||||||
|
|
||||||
typedef struct _Frame
|
typedef struct _Frame
|
||||||
|
@ -476,8 +475,7 @@ clutter_frame_clock_notify_presented (ClutterFrameClock *frame_clock,
|
||||||
case CLUTTER_FRAME_CLOCK_STATE_SCHEDULED_NOW:
|
case CLUTTER_FRAME_CLOCK_STATE_SCHEDULED_NOW:
|
||||||
g_warn_if_reached ();
|
g_warn_if_reached ();
|
||||||
break;
|
break;
|
||||||
case CLUTTER_FRAME_CLOCK_STATE_DISPATCHING:
|
case CLUTTER_FRAME_CLOCK_STATE_DISPATCHED:
|
||||||
case CLUTTER_FRAME_CLOCK_STATE_PENDING_PRESENTED:
|
|
||||||
frame_clock->state = CLUTTER_FRAME_CLOCK_STATE_IDLE;
|
frame_clock->state = CLUTTER_FRAME_CLOCK_STATE_IDLE;
|
||||||
maybe_reschedule_update (frame_clock);
|
maybe_reschedule_update (frame_clock);
|
||||||
break;
|
break;
|
||||||
|
@ -500,8 +498,7 @@ clutter_frame_clock_notify_ready (ClutterFrameClock *frame_clock)
|
||||||
case CLUTTER_FRAME_CLOCK_STATE_SCHEDULED_NOW:
|
case CLUTTER_FRAME_CLOCK_STATE_SCHEDULED_NOW:
|
||||||
g_warn_if_reached ();
|
g_warn_if_reached ();
|
||||||
break;
|
break;
|
||||||
case CLUTTER_FRAME_CLOCK_STATE_DISPATCHING:
|
case CLUTTER_FRAME_CLOCK_STATE_DISPATCHED:
|
||||||
case CLUTTER_FRAME_CLOCK_STATE_PENDING_PRESENTED:
|
|
||||||
frame_clock->state = CLUTTER_FRAME_CLOCK_STATE_IDLE;
|
frame_clock->state = CLUTTER_FRAME_CLOCK_STATE_IDLE;
|
||||||
maybe_reschedule_update (frame_clock);
|
maybe_reschedule_update (frame_clock);
|
||||||
break;
|
break;
|
||||||
|
@ -806,8 +803,7 @@ clutter_frame_clock_inhibit (ClutterFrameClock *frame_clock)
|
||||||
frame_clock->pending_reschedule_now = TRUE;
|
frame_clock->pending_reschedule_now = TRUE;
|
||||||
frame_clock->state = CLUTTER_FRAME_CLOCK_STATE_IDLE;
|
frame_clock->state = CLUTTER_FRAME_CLOCK_STATE_IDLE;
|
||||||
break;
|
break;
|
||||||
case CLUTTER_FRAME_CLOCK_STATE_DISPATCHING:
|
case CLUTTER_FRAME_CLOCK_STATE_DISPATCHED:
|
||||||
case CLUTTER_FRAME_CLOCK_STATE_PENDING_PRESENTED:
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -846,8 +842,7 @@ clutter_frame_clock_schedule_update_now (ClutterFrameClock *frame_clock)
|
||||||
break;
|
break;
|
||||||
case CLUTTER_FRAME_CLOCK_STATE_SCHEDULED_NOW:
|
case CLUTTER_FRAME_CLOCK_STATE_SCHEDULED_NOW:
|
||||||
return;
|
return;
|
||||||
case CLUTTER_FRAME_CLOCK_STATE_DISPATCHING:
|
case CLUTTER_FRAME_CLOCK_STATE_DISPATCHED:
|
||||||
case CLUTTER_FRAME_CLOCK_STATE_PENDING_PRESENTED:
|
|
||||||
frame_clock->pending_reschedule = TRUE;
|
frame_clock->pending_reschedule = TRUE;
|
||||||
frame_clock->pending_reschedule_now = TRUE;
|
frame_clock->pending_reschedule_now = TRUE;
|
||||||
return;
|
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:
|
||||||
case CLUTTER_FRAME_CLOCK_STATE_SCHEDULED_NOW:
|
case CLUTTER_FRAME_CLOCK_STATE_SCHEDULED_NOW:
|
||||||
return;
|
return;
|
||||||
case CLUTTER_FRAME_CLOCK_STATE_DISPATCHING:
|
case CLUTTER_FRAME_CLOCK_STATE_DISPATCHED:
|
||||||
case CLUTTER_FRAME_CLOCK_STATE_PENDING_PRESENTED:
|
|
||||||
frame_clock->pending_reschedule = TRUE;
|
frame_clock->pending_reschedule = TRUE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -958,8 +952,7 @@ clutter_frame_clock_set_mode (ClutterFrameClock *frame_clock,
|
||||||
frame_clock->pending_reschedule_now = TRUE;
|
frame_clock->pending_reschedule_now = TRUE;
|
||||||
frame_clock->state = CLUTTER_FRAME_CLOCK_STATE_IDLE;
|
frame_clock->state = CLUTTER_FRAME_CLOCK_STATE_IDLE;
|
||||||
break;
|
break;
|
||||||
case CLUTTER_FRAME_CLOCK_STATE_DISPATCHING:
|
case CLUTTER_FRAME_CLOCK_STATE_DISPATCHED:
|
||||||
case CLUTTER_FRAME_CLOCK_STATE_PENDING_PRESENTED:
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1041,7 +1034,7 @@ clutter_frame_clock_dispatch (ClutterFrameClock *frame_clock,
|
||||||
this_dispatch->dispatch_time_us = time_us;
|
this_dispatch->dispatch_time_us = time_us;
|
||||||
g_source_set_ready_time (frame_clock->source, -1);
|
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++;
|
frame_count = frame_clock->frame_count++;
|
||||||
|
|
||||||
|
@ -1075,20 +1068,20 @@ clutter_frame_clock_dispatch (ClutterFrameClock *frame_clock,
|
||||||
switch (frame_clock->state)
|
switch (frame_clock->state)
|
||||||
{
|
{
|
||||||
case CLUTTER_FRAME_CLOCK_STATE_INIT:
|
case CLUTTER_FRAME_CLOCK_STATE_INIT:
|
||||||
case CLUTTER_FRAME_CLOCK_STATE_PENDING_PRESENTED:
|
|
||||||
g_warn_if_reached ();
|
g_warn_if_reached ();
|
||||||
break;
|
break;
|
||||||
case CLUTTER_FRAME_CLOCK_STATE_IDLE:
|
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:
|
||||||
case CLUTTER_FRAME_CLOCK_STATE_SCHEDULED_NOW:
|
case CLUTTER_FRAME_CLOCK_STATE_SCHEDULED_NOW:
|
||||||
break;
|
break;
|
||||||
case CLUTTER_FRAME_CLOCK_STATE_DISPATCHING:
|
case CLUTTER_FRAME_CLOCK_STATE_DISPATCHED:
|
||||||
switch (result)
|
switch (result)
|
||||||
{
|
{
|
||||||
case CLUTTER_FRAME_RESULT_PENDING_PRESENTED:
|
case CLUTTER_FRAME_RESULT_PENDING_PRESENTED:
|
||||||
frame_clock->state = CLUTTER_FRAME_CLOCK_STATE_PENDING_PRESENTED;
|
|
||||||
break;
|
break;
|
||||||
case CLUTTER_FRAME_RESULT_IDLE:
|
case CLUTTER_FRAME_RESULT_IDLE:
|
||||||
|
/* The frame was aborted; nothing to paint/present */
|
||||||
clutter_frame_clock_notify_ready (frame_clock);
|
clutter_frame_clock_notify_ready (frame_clock);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1307,8 +1300,6 @@ clutter_frame_clock_dispose (GObject *object)
|
||||||
{
|
{
|
||||||
ClutterFrameClock *frame_clock = CLUTTER_FRAME_CLOCK (object);
|
ClutterFrameClock *frame_clock = CLUTTER_FRAME_CLOCK (object);
|
||||||
|
|
||||||
g_warn_if_fail (frame_clock->state != CLUTTER_FRAME_CLOCK_STATE_DISPATCHING);
|
|
||||||
|
|
||||||
if (frame_clock->source)
|
if (frame_clock->source)
|
||||||
{
|
{
|
||||||
g_signal_emit (frame_clock, signals[DESTROY], 0);
|
g_signal_emit (frame_clock, signals[DESTROY], 0);
|
||||||
|
|
|
@ -4,11 +4,9 @@
|
||||||
|
|
||||||
```mermaid
|
```mermaid
|
||||||
stateDiagram
|
stateDiagram
|
||||||
Init --> Scheduled/ScheduledNow : schedule update() -> now
|
INIT --> SCHEDULED/SCHEDULED_NOW : start first frame immediately
|
||||||
Idle --> Scheduled/ScheduledNow : schedule update() -> given presentation time
|
IDLE --> SCHEDULED/SCHEDULED_NOW : given presentation time
|
||||||
Scheduled/ScheduledNow --> Dispatching : target time hit
|
SCHEDULED/SCHEDULED_NOW --> IDLE : frame clock inhibited or mode changed
|
||||||
Dispatching --> PendingPresented : queued page flip
|
SCHEDULED/SCHEDULED_NOW --> DISPATCHED : start a frame
|
||||||
Dispatching --> Idle : no queued page flip
|
DISPATCHED --> IDLE : frame presented or aborted with nothing to draw
|
||||||
PendingPresented --> Scheduled/ScheduledNow : page flipped, if recent schedule update
|
|
||||||
PendingPresented --> Idle : page flipped
|
|
||||||
```
|
```
|
||||||
|
|
Loading…
Reference in a new issue