Skip to content

Commit

Permalink
[ios] change displaylink settings and native eaglLayer.drawableProper…
Browse files Browse the repository at this point in the history
…ties to save cpu/gpu bandwidth, no visual artifacts seen with this change but cpu useage drops by 10-20 percent
  • Loading branch information
davilla committed Apr 30, 2011
1 parent 0243477 commit f70236b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 33 deletions.
20 changes: 5 additions & 15 deletions xbmc/osx/atv2/XBMCEAGLView.mm
Expand Up @@ -73,8 +73,8 @@ - (id)initWithFrame:(CGRect)frame
eaglLayer.opaque = TRUE;
eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:FALSE], kEAGLDrawablePropertyRetainedBacking,
//kEAGLColorFormatRGB565, kEAGLDrawablePropertyColorFormat,
kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat,
kEAGLColorFormatRGB565, kEAGLDrawablePropertyColorFormat,
//kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat,
nil];

EAGLContext *aContext = [[EAGLContext alloc]
Expand Down Expand Up @@ -321,18 +321,8 @@ - (void) runAnimation:(id) arg
- (void) runDisplayLink;
{
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
/*
static CFTimeInterval oldtimestamp;
CFTimeInterval frameInterval, timestamp, duration;

duration = [displayLink duration];
timestamp = [displayLink timestamp];
frameInterval = [displayLink frameInterval];
NSLog(@"%s:duration(%f), delta(%f), timestamp(%f)", __PRETTY_FUNCTION__,
duration, timestamp-oldtimestamp, timestamp);
oldtimestamp = timestamp;
*/
displayFPS = 1.0 / [displayLink duration];
displayFPS = 1.0 / ([displayLink duration] * [displayLink frameInterval]);
if (animationThread && [animationThread isExecuting] == YES)
{
if (g_VideoReferenceClock)
Expand All @@ -347,9 +337,9 @@ - (void) initDisplayLink
displayLink = [NSClassFromString(@"CADisplayLink")
displayLinkWithTarget:self
selector:@selector(runDisplayLink)];
[displayLink setFrameInterval:1];
[displayLink setFrameInterval:2];
[displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
displayFPS = 60;
displayFPS = 1.0 / ([displayLink duration] * [displayLink frameInterval]);
}
//--------------------------------------------------------------
- (void) deinitDisplayLink
Expand Down
23 changes: 5 additions & 18 deletions xbmc/osx/ios/XBMCEAGLView.mm
Expand Up @@ -74,8 +74,8 @@ - (id)initWithFrame:(CGRect)frame
eaglLayer.opaque = TRUE;
eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:NO], kEAGLDrawablePropertyRetainedBacking,
//kEAGLColorFormatRGB565, kEAGLDrawablePropertyColorFormat,
kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat,
kEAGLColorFormatRGB565, kEAGLDrawablePropertyColorFormat,
//kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat,
nil];

EAGLContext *aContext = [[EAGLContext alloc]
Expand Down Expand Up @@ -342,18 +342,8 @@ - (void) runAnimation:(id) arg
- (void) runDisplayLink;
{
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
/*
static CFTimeInterval oldtimestamp;
CFTimeInterval frameInterval, timestamp, duration;

duration = [displayLink duration];
timestamp = [displayLink timestamp];
frameInterval = [displayLink frameInterval];
NSLog(@"%s:duration(%f), delta(%f), timestamp(%f)", __PRETTY_FUNCTION__,
duration, timestamp-oldtimestamp, timestamp);
oldtimestamp = timestamp;
*/
displayFPS = 1.0 / [displayLink duration];
displayFPS = 1.0 / ([displayLink duration] * [displayLink frameInterval]);
if (animationThread && [animationThread isExecuting] == YES)
{
if (g_VideoReferenceClock)
Expand All @@ -364,25 +354,22 @@ - (void) runDisplayLink;
//--------------------------------------------------------------
- (void) initDisplayLink
{
//NSLog(@"%s", __PRETTY_FUNCTION__);
displayLink = [NSClassFromString(@"CADisplayLink")
displayLinkWithTarget:self
selector:@selector(runDisplayLink)];
[displayLink setFrameInterval:1];
[displayLink setFrameInterval:2];
[displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
displayFPS = 60;
displayFPS = 1.0 / ([displayLink duration] * [displayLink frameInterval]);
}
//--------------------------------------------------------------
- (void) deinitDisplayLink
{
//NSLog(@"%s", __PRETTY_FUNCTION__);
[displayLink invalidate];
displayLink = nil;
}
//--------------------------------------------------------------
- (double) getDisplayLinkFPS;
{
//NSLog(@"%s:displayFPS(%f)", __PRETTY_FUNCTION__, displayFPS);
return displayFPS;
}
//--------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions xbmc/video/VideoReferenceClock.cpp
Expand Up @@ -880,6 +880,7 @@ void CVideoReferenceClock::VblankHandler(int64_t nowtime, double fps)
SingleLock.Leave();

SendVblankSignal();
UpdateRefreshrate();
}
#endif

Expand Down

0 comments on commit f70236b

Please sign in to comment.