Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: correctly resizing view w/ QCRenderer [Solved]



Hi folks,

After my earlier posts, I kept digging at the issue and came up with my own solution. I would however, appreciate feedback on the validity of my fix.

The problem is this... when the window is resized we'll receive the frame change notification. In Performer, the code updates the glContext for the new location and dimensions. However, Performer omits an important task... it should immediately render a frame to the context, otherwise there might be garbage there for a short amount of time before the next display link is called. So to do this, I added a direct call to "renderAtTime:" just passing nil for the time:

- (void) updateRenderView:(NSNotification*)notification
{
bool running = CVDisplayLinkIsRunning(_displayLink);
NSRect frame = [renderView frame];
CGLContextObj cgl_ctx = [_glContext CGLContextObj]; //By using CGLMacro.h there's no need to set the current OpenGL context

//We have to stop rendering to prevent the Core Video Display Link thread from accessing the OpenGL context at the same time
if(running)
CVDisplayLinkStop(_displayLink);

//Notify the OpenGL context its rendering view has changed
[_glContext update];

//Update the OpenGL viewport
glViewport(0, 0, frame.size.width, frame.size.height);

#if RESIZE_FLICKER_FIX
[self renderAtTime: nil];
#endif


	//We can safely restart rendering now
	if(running)
	CVDisplayLinkStart(_displayLink);
}

The above is not complete because "renderAtTime:" doesn't know how to handle a nil value for the time. I'm not sure what the best solution is, so I decided to simply ignore the incoming time value entirely. In renderAtTime:, here is what I changed:

#if RESIZE_FLICKER_FIX
videoTime = [NSDate timeIntervalSinceReferenceDate];
#else
if(time->flags & kCVTimeStampVideoTimeValid)
videoTime = (NSTimeInterval)time->videoTime / (NSTimeInterval)time- >videoTimeScale;
else
videoTime = 0; //Not sure what the best thing to do is
#endif


You'll also need to apply the same patch in to "copyImageForTime:" in CompositionSource.m. With these patches, you can run Performer and it will resize perfectly!

Now, my only question is... is this the best solution? While it generally seems to work, I'm now ignoring the timestamp requested by the displayLink. I sure which I knew how QCView handled this internally. Can someone recomment a better solution?

thanks,
Chris


On Jul 11, 2007, at 1:28 PM, Chris Silverberg wrote:

As a quick followup to my previous message, take a look at Apple's "Performer" sample code. If you run that application and start resizing the window, you'll start to see lots of visible flicker in the composition. This is exactly the problem that I have (not surprising since my code is based on Performer.) So does someone know how to fix Performer so that it doesn't have this flicker?

thanks!
Chris


On Jul 11, 2007, at 1:09 PM, Chris Silverberg wrote:

My view is working well, with one issue. When I resize my window (and thus my view), I either see excessive flicker or rendering artifacts. This suggests to me that I'm not handling resize events properly. Unfortunately, there's not a lot of sample code out there that uses QCRenderer... Apple's samples that do either don't handle resizing at all or have the same resize issues that I have.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartzcomposer-dev mailing list (Quartzcomposer- email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quartzcomposer-dev/chris% 40silverberg.net


This email sent to email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. Quartzcomposer-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/quartzcomposer-dev/email@hidden

This email sent to email@hidden
References: 
 >correctly resizing view w/ QCRenderer (From: Chris Silverberg <email@hidden>)
 >Re: correctly resizing view w/ QCRenderer (From: Chris Silverberg <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.