forked from gogpu/gogpu
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlifecycle.go
More file actions
43 lines (39 loc) · 1.4 KB
/
Copy pathlifecycle.go
File metadata and controls
43 lines (39 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package gogpu
// AppLifecycle represents the application lifecycle state (ADR-026).
//
// Desktop apps transition: AppIdle → AppRunning → (exit).
// Mobile apps cycle through all states as the OS suspends/resumes.
// Web apps use Suspended/Resumed for page visibility.
//
// The lifecycle is universal — same API on all platforms. Desktop is the
// trivial case where Suspending/Suspended/Resuming never occur.
type AppLifecycle int
const (
AppIdle AppLifecycle = iota // App not started yet
AppRunning // Normal execution, surfaces available
AppSuspending // Grace period: drop GPU surfaces before suspend
AppSuspended // Backgrounded, no rendering, surfaces may be gone
AppResuming // Grace period: recreate surfaces after resume
)
// IsActive reports whether the app should process frames.
// True for Running, Suspending, and Resuming (grace periods allow one last/first frame).
func (s AppLifecycle) IsActive() bool {
return s == AppRunning || s == AppSuspending || s == AppResuming
}
// String returns the lifecycle state name.
func (s AppLifecycle) String() string {
switch s {
case AppIdle:
return "Idle"
case AppRunning:
return "Running"
case AppSuspending:
return "Suspending"
case AppSuspended:
return "Suspended"
case AppResuming:
return "Resuming"
default:
return "Unknown lifecycle"
}
}