ScreenSaverView/Opaque/Update issue
ScreenSaverView/Opaque/Update issue
- Subject: ScreenSaverView/Opaque/Update issue
- From: "Andy O'Meara" <email@hidden>
- Date: Tue, 31 May 2005 21:12:06 -0400
I've already searched the archives and spent a long time on this, so I'm
really hoping someone has some insight on this seemingly simple
ScreenSaverView issue...
I currently create each output frame in an off-screen GWorld, and when tone
is done, I call CopyBits() to a NSQuickDrawView that's inside my
ScreenSaverView. This is very similar to the method used in Apple's
"MungSaver".
So everything is working well with my ScreenSaverView, with the exception of
a nasty flicker that happens after the first frame is drawn... After
investigating, it seems that that since NSView::isOpaque returns NO by
default, the "Desktop & Screen Saver" window went to draw the superview
before drawing the frame (accounting for the nasty initial flicker). No
problem, I say, I'll just override isOpaque to return YES... The good news
is that the initial flicker is of course gone, but the baffling issue is
that now new frames only seem to appear when the host window changes layers
or needs to get refreshed. Otherwise, the frame is never updated. My logs
clearly show that *both* animateOneFrame and drawRect are firing, yet the
the ScreenSaverView rect is only ever visibly updated when I activate any
window in the OS. It's as if the window store wasn't getting flushed to
screen despite the fact setNeedsDisplay is set to YES (keep in mind:
changing isOpaque() to always return NO makes this problem go away with no
other changes to the code).
I've already tried things like putting a shotgun of lockFocus and
unlockFocus calls everywhere, and sticking in flush and update calls, but no
go. Below are the relevant snippets...
Thanks in advance,
Andy O'Meara
- (id)initWithFrame:(NSRect)frame isPreview:(BOOL)isPreview
{
...
// Make the NSQuickDrawView
mQDView = [[NSQuickDrawView alloc] initWithFrame:NSZeroRect];
// make sure the subview resizes
[ self setAutoresizesSubviews:YES ];
[ self addSubview:mQDView ];
[ mQDView release ];
...
}
- (void)startAnimation
{
[super startAnimation];
...
// the first time lockFocus is called on the NSQuickDrawView
// it creates a valid qdPort - we need this to draw into and
// before this is done, qdPort is NULL
if ( [mQDView qdPort] == NULL ) {
[mQDView lockFocus];
[mQDView unlockFocus];
}
...
}
- (void)animateOneFrame
{
[self setNeedsDisplay: YES];
}
- (void)drawRect:(NSRect)rect
{
...
CopyBits( ... , [mQDView qdPort], ... );
...
}
// end snippets
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden