Re: Full screen transparent window
Re: Full screen transparent window
- Subject: Re: Full screen transparent window
- From: Ryan Stevens <email@hidden>
- Date: Thu, 17 Feb 2005 12:14:29 -0800
I think Mouseposé is just redrawing the rect the light was/is in, where you're redrawing the entire window. Unless they're using
<x-tad-smaller>CGSSetWindowListBrightness </x-tad-smaller>like Quartz Debug does when it "pulses" windows. :/
On Feb 17, 2005, at 8:56 AM, Renaud Boisjoly wrote:
As I mentioned privately, I'll give this a try, I'm sure it will help.
but I was wondering... how do programs like Mouseposé take over the whole screen to lower the intensity of everything but one spot without hogging WindowServices... seems like trickery to me ;-) If I did it by superimposing my stuff over the whole screen... I'd get horrible performance they way I'm doing it now...
- arby
On Feb 17, 2005, at 10:34 AM, Ryan Stevens wrote:
I would use multiple windows instead of one large one. Make one as wide as the screen and one as tall. Then you're just moving them up and down or side to side. Make a subclass with +verticalLineWindow and +horizontalLineWindow...maybe. I would probably override -update to move the windows for me too, since "An NSWindow is automatically sent an <x-tad-bigger>update</x-tad-bigger> message on every pass through the event loop and before it’s displayed onscreen."..which could eliminate the timer.
On Feb 17, 2005, at 5:22 AM, Renaud Boisjoly wrote:
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