11 messages in net.java.dev.jna.usersRe: shaped windows using images - per...
FromSent OnAttachments
Timothy WallMay 24, 2007 7:12 am 
Christopher DeckersMay 29, 2007 2:21 am 
Christopher DeckersMay 29, 2007 3:29 am 
Wayne MeissnerMay 29, 2007 3:53 am 
Christopher DeckersMay 29, 2007 7:10 am 
Wayne MeissnerMay 29, 2007 7:43 am 
Timothy WallMay 29, 2007 11:04 am 
Olivier ChafikMay 29, 2007 6:19 pm 
Christopher DeckersMay 29, 2007 11:56 pm 
Timothy WallMay 30, 2007 5:19 am 
Christopher DeckersMay 30, 2007 6:10 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: shaped windows using images - performanceActions...
From:Timothy Wall (twal@dev.java.net)
Date:May 24, 2007 7:12:01 am
List:net.java.dev.jna.users

(redirecting to JNA users list)

On May 24, 2007, at 9:46 AM, Christopher Deckers wrote:

I am trying JNA and the shaped windows in conjunction with some JavaFX stuff. One of my goals is to load an FX script and set the shape of the window to the shape that is defined by the FX script. I found that it takes quite long to apply an image as a mask: a small-size image takes about 1s, but it goes up to 40s when the image is 400% the size of my original small image.

Have you got any hints as to what should be done or what can help boost applying an image as a mask? Note that I am on Windows XP and I turned off ddraw for opacity to work.

I believe the primary reason setting of the window mask is so slow (although I haven't profiled it myself) is the generation of the mask one bit at a time, which is going to increase according to the area of your window.

Here is a message from Olivier Chafik which addresses the issue, although you should probably fire up netbeans and do a little profiling yourself. This message should still be in the archives, albeit in digest form.

Hello,

First, congratulations and many thanks for your library, I really feel like it is one of the most needed addition to Java (I just can't stand JNI).

I wrote a small post on my blog with a new example that leverages JNA, to get the user's last input time (Windows only). It is available here : http://ochafik.free.fr/blog/?p=98

I also tried to optimize a bit the masked windows implementation in WindowUtil, doing the following changes : - reuse GDI ranges - avoid raster data copy for most useful image types (TYPE_BINARY_BYTE and TYPE_INT_*) - pack ranges of non transparent pixels along rows (treating 8 columns at a time in the case of TYPE_BINARY_BYTE rasters), instead of adding pixels one at a time. I used common raster-to-ranges decomposition methods for Win32 and Mac implementations, in the class RasterRangesUtils. - no need to fill freshly created images with black (they are already supposed to be black by default, aren't they ?) - separate class for special content pane in mac implementation (as hinted in existing TODO)

The code has been tested on Mac OS and, very quickly, on Windows.

I have put the modified WindowUtils.java and the new RasterRangesUtils.java here : http://ochafik.free.fr/Java/src/jna/ Changes on WindowUtils were made against the CVS revision 1.1.2.5)

I also made a small demo that features a simple shape that changes over time (hence requiring faster window shaping) : http://ochafik.free.fr/Java/src/jna/morphingwindow.jar (source is included in the JAR, but the example is really crappy code I wish I had never written) It works well on Mac OS (with extra fading alpha effect), but the refresh looks bad on Windows (delay between the reshaping and the redraw by swing)

Feel free to give me some feedback on this code (good or bad), and should you want it I can sign a JCA to contribute officially to the project.

Cheers