Re: Full screen transparent window
Re: Full screen transparent window
- Subject: Re: Full screen transparent window
- From: Renaud Boisjoly <email@hidden>
- Date: Thu, 17 Feb 2005 08:22:44 -0500
Hi Ricky, thanks for the tips, I'll look into all this.
To clarify, The window is not moving, but I'm trying to draw a
crosshair from the screen's edge to where the pointer is, so I'm
guessing a large part of the screen must be redraw, although It's just
a horizontal and a vertical line which are being redrawn constantly.
I'm using an NSTimer to go through this redraw process, and everytime
through I call my window's "display" to update it... and it's drawRect
simply draw's the lines, basically two lines of code plus one line to
get the mouse coordinates. My drawRect does a few things, it checks to
see if I'm in the right "mode", if yes, it gets the current bounds of
the view and the current location. I have yet to transform the
coordinates to match the pointer's hot spot and I do not want it to
cover the Dock or Menu bar. Perhaps I should be doing some of this
(bounds and line color) outside of drawRect, but could this really be
affecting performance so much?
I'm just wondering if there is a faster way to update the graphic in
this window without taking up so much performance. I'll investigate
your suggestions to find out. Thanks!
Here is my drawRect method:
-(void)drawRect:(NSRect)rect {
if (crosshairMode == NO) {
[cursorImage compositeToPoint:NSZeroPoint
operation:NSCompositeSourceOver];
[hotpointImage compositeToPoint:hotpointOffset
operation:NSCompositeDestinationOut];
[[self window] update];
} else {
//Draw the lines...
NSRect myBounds = [self bounds];
NSPoint currentLocation = [NSEvent mouseLocation];
[[NSColor lightGrayColor] set];
[NSBezierPath strokeLineFromPoint: NSMakePoint(0,currentLocation.y)
toPoint NSMakePoint(myBounds.size.width,currentLocation.y) ];
[NSBezierPath strokeLineFromPoint: NSMakePoint(currentLocation.x,0)
toPoint:NSMakePoint(currentLocation.x,myBounds.size.height) ];
}
}
On Feb 17, 2005, at 7:10 AM, Ricky Sharp wrote:
On Wednesday, February 16, 2005, at 08:45PM, Renaud Boisjoly
<email@hidden> wrote:
Hi all!
What would be a preferred way to optimize performance when drawing in
a
full-screen transparent window which sits above all others?
Right now, I'm using an NSView subclass in my transparent window, set
optimized drawing in the window, removed shadows, made it transparent
etc.
in my view, I use NSBezierPath to draw a few lines (nothing
complicated) but it seems both my app and the WindowServer are taxed a
lot when moving around the screen...
I'm a bit confused here when you say moving around the screen. Is
your window moving? Or just other app windows underneath it?
Any tips? I searched the list but did not find much relevant to this
topic.
Initially, a quick "overhead" test could be to have your drawRect: in
your view be a NOP. Is it that method that's slowing things down, or
do you already have a high overhead in just having the full-screen
transparent window in place?
Also, run Shark to see if there is anything you can speed up in your
drawing. For example, if your paths are static, you may get some
performance gain by caching them; all depends on what Shark tells you.
You can also run Quartz Debug to see exactly what parts of the screen
you're updating. Perhaps you can use needsDisplayInRect: to isolate
updates to smaller areas.
--
Rick Sharp
Instant Interactive(tm)
_______________________________________________
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