I'm currently playing with a screen saver.

Problem:
--------

It draws correctly in fullscreen mode or in SaverLab but does not in the preview mode of the 'Desktop & Screen Saver' pane of the System Preferences.

Basically, in #fail mode, it draws the first frame and then does not refresh.

It works on Mac OS X 10.4 but does not on Mac OS X 10.5 and 10.6.

Details:
--------

An animation frame is drawn in - [ScreenSaverView animateOneFrame] by drawing a NSImage using the - drawInRect:fromRect:operation:fraction: method.

The NSImage contains one bitmap representation. I have access to the buffer of the bitmap representation and I update it for each new frame.

What I've checked:
------------------

o The problem is not with the size of the preview view, it works fine with this size, I tested it in SaverLab and in a custom Screen Saver testing app.

o The problem is not with the NSRect parameters passed to the drawInRect:fromRect:operation:fraction: method. I've traced their values in gdb.

o The problem is not with the bytes buffer not being updated, I checked in gdb that the values were correctly updated.

o The problem is not with the view not being refreshed. I draw a rectangle with an increasing lighter color (for testing purpose) before calling the drawInRect:... method and the rectangle color is correctly updated.

Where I think the problem lies:
-------------------------------

There must be some kind of (annoying here) optimization made by the Cocoa APIs. Since this works in fullscreen mode, it must be an optimization not enabled in fullscreen mode (and which was not in Mac OS X 10.4).

QUESTION:
---------

What can be done to address this behavioral incoherence in System Preferences?






Code snippet:
-------------

Here is how the NSImage and NSBitmapImageRep are created (self is a NSView subclass instance):

        imageRect_=[self bounds];

realWidth_=(((unsigned long) floor(imageRect_.size.width))/ DIVIDER)*DIVIDER;

        origin_=imageRect_.origin;

origin_.x=origin_.x+((unsigned long) (imageRect_.size.width- realWidth_))/2;

        imageRect_.size.width=realWidth_;

        pixelHeight_=imageRect_.size.height;

imageRep_ = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL pixelsWide: realWidth_ pixelsHigh: imageRect_.size.height
                                                        bitsPerSample:8
samplesPerPixel:4
                                                        hasAlpha:YES
                                                        isPlanar:NO
colorSpaceName:NSDeviceRGBColorSpace
                                                        bytesPerRow:0
                                                        bitsPerPixel:0
                                                        ];
        buffer_=[imageRep_ bitmapData];

        image_=[[NSImage alloc] initWithSize:imageRect_.size];

        [image_ addRepresentation:imageRep_];
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to