Drawing from secondary thread erases resize corner in window?
Drawing from secondary thread erases resize corner in window?
- Subject: Drawing from secondary thread erases resize corner in window?
- From: Hank Heijink <email@hidden>
- Date: Wed, 27 Feb 2008 14:40:40 -0500
Hi list,
I have a window with a custom view that occupies the entire window, so
the little resize corner in the lower right is within the bounds of
the view. I noticed that when I draw into the window from the main
thread (i.e. the usual way) that resize corner is redrawn when the
view is redrawn. However, when I update the view from another thread,
that doesn't happen. What am I missing?
I made a test app that just draws a black background in a custom view
(MyCustomView) to show the problem. Here's the relevant code in the
custom view:
- (void)drawFromSecondaryThread:(NSRect)rect
{
[NSGraphicsContext saveGraphicsState];
NSRectClip(rect);
[[NSColor blackColor] set];
NSRectFill(rect);
[NSGraphicsContext restoreGraphicsState];
}
And in the object that has the view as an instance variable
(MyCustomView *view). The method updateView is called from a repeating
NSTimer that's attached to the run loop of the secondary thread.
- (void)updateView
{
if (useSecondaryThread) {
if ([view lockFocusIfCanDraw]) {
[view drawFromSecondaryThread:view.bounds];
[[view window] flushWindow];
[view unlockFocus];
}
} else {
[view setNeedsDisplay:YES];
}
}
Thanks for any help!
Hank
Hank Heijink
email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden