-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable CADisplayLink to run at a user-defined preferredFramesPerSecond
Just a draft for testing at the moment.. if we want to include the way to set `preferredFramesPerSecond`, might make sense to expose some kind of API on `RiveView` or `RiveViewModel` to set on `CADisplayLink` when we create it for the animation loop. In particular, the change to `Info.plist` below is what enables the display link to go to 120fps. One caveat is that in setting `.preferredFramesPerSecond`, this API is marked as deprecated by Apple.. and still need to understand what the alternative is https://developer.apple.com/documentation/quartzcore/cadisplaylink/1648421-preferredframespersecond Diffs= 97b7622bc Enable CADisplayLink to run at a user-defined preferredFramesPerSecond (#6111) Co-authored-by: Zachary Plata <[email protected]>
- Loading branch information
Showing
8 changed files
with
117 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
d65b239c5c6ce44c3b58cd71ff17721d874a4ab1 | ||
97b7622bcb0d99dc469706d9cf57cb03e34488de |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
03f784cccda96fd5eee541e31bed4681904c0ed8 | ||
e40af7f67eb7654000a156614e462c9a31f69bb9 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
Example-iOS/Source/Examples/SwiftUI/SwiftVariableFPS.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// | ||
// SwiftVariableFPS.swift | ||
// Example (iOS) | ||
// | ||
// Created by Zach Plata on 10/20/23. | ||
// Copyright © 2023 Rive. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
import RiveRuntime | ||
|
||
struct SwiftVariableFPS: DismissableView { | ||
var dismiss: () -> Void = {} | ||
|
||
private var stateChanger = RiveViewModel(fileName: "skills", stateMachineName: "Designer's Test") | ||
|
||
var body: some View { | ||
ScrollView{ | ||
VStack { | ||
stateChanger.view() | ||
.frame(height:200) | ||
|
||
HStack{ | ||
Button("Prefer 30 fps") { | ||
if #available(iOS 15.0, *) { | ||
stateChanger.setPreferredFrameRateRange(preferredFrameRateRange: CAFrameRateRange(minimum: 30, maximum: 120, preferred: 30)) | ||
} else { | ||
stateChanger.setPreferredFramesPerSecond(preferredFramesPerSecond: 30) | ||
} | ||
} | ||
Button("Prefer 60 fps") { | ||
if #available(iOS 15.0, *) { | ||
stateChanger.setPreferredFrameRateRange(preferredFrameRateRange: CAFrameRateRange(minimum: 30, maximum: 120, preferred: 60)) | ||
} else { | ||
stateChanger.setPreferredFramesPerSecond(preferredFramesPerSecond: 60) | ||
} | ||
} | ||
Button("Prefer 120 fps") { | ||
if #available(iOS 15.0, *) { | ||
stateChanger.setPreferredFrameRateRange(preferredFrameRateRange: CAFrameRateRange(minimum: 30, maximum: 120, preferred: 120)) | ||
} else { | ||
stateChanger.setPreferredFramesPerSecond(preferredFramesPerSecond: 120) | ||
} | ||
} | ||
} | ||
|
||
} | ||
}.onAppear() { | ||
if #available(iOS 15.0, *) { | ||
stateChanger.setPreferredFrameRateRange(preferredFrameRateRange: CAFrameRateRange(minimum: 30, maximum: 120, preferred: 120)) | ||
} else { | ||
stateChanger.setPreferredFramesPerSecond(preferredFramesPerSecond: 120) | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters