mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-11-28 09:22:03 +00:00
Merge pull request #1990 from spebbe/cpanimation_frame_rate
CPAnimation frame rate fixes.
This commit is contained in:
commit
985db21ed9
2 files changed
+50
-1
No files matched your search
@@ -236,7 +236,9 @@ ACTUAL_FRAME_RATE = 0;
|
||||
ACTUAL_FRAME_RATE = 0;
|
||||
_lastTime = new Date();
|
||||
|
||||
_timer = [CPTimer scheduledTimerWithTimeInterval:0.0 target:self selector:@selector(animationTimerDidFire:) userInfo:nil repeats:YES];
|
||||
var timerInterval = _frameRate <= 0.0 ? 0.0001 : 1.0/_frameRate;
|
||||
|
||||
_timer = [CPTimer scheduledTimerWithTimeInterval:timerInterval target:self selector:@selector(animationTimerDidFire:) userInfo:nil repeats:YES];
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
@import <AppKit/CPApplication.j>
|
||||
@import <AppKit/CPAnimation.j>
|
||||
|
||||
[CPApplication sharedApplication];
|
||||
|
||||
@implementation CPAnimation (TestMethods)
|
||||
{
|
||||
}
|
||||
|
||||
- (CPTimer)timer
|
||||
{
|
||||
return _timer;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation CPAnimationTest : OJTestCase
|
||||
{
|
||||
}
|
||||
|
||||
- (void)testScheduleTimerWithIntervalBasedOnDefaultFrameRate
|
||||
{
|
||||
var animation = [[CPAnimation alloc] initWithDuration:0.1 animationCurve:CPAnimationLinear];
|
||||
[animation startAnimation];
|
||||
|
||||
[self assert:1.0/60.0 equals:[[animation timer] timeInterval]];
|
||||
}
|
||||
|
||||
- (void)testScheduleTimerWithIntervalBasedOnCustomFrameRate
|
||||
{
|
||||
var animation = [[CPAnimation alloc] initWithDuration:0.1 animationCurve:CPAnimationLinear];
|
||||
[animation setFrameRate:30];
|
||||
[animation startAnimation];
|
||||
|
||||
[self assert:1.0/30.0 equals:[[animation timer] timeInterval]];
|
||||
}
|
||||
|
||||
- (void)testScheduleTimerWithIntervalBasedOnAsFastAsPossibleFrameRate
|
||||
{
|
||||
var animation = [[CPAnimation alloc] initWithDuration:0.1 animationCurve:CPAnimationLinear];
|
||||
[animation setFrameRate:0];
|
||||
[animation startAnimation];
|
||||
|
||||
[self assert:0.0001 equals:[[animation timer] timeInterval]];
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in new issue
Block a user