Re: [NSImage] Bug in System Preferences? [solved]
Re: [NSImage] Bug in System Preferences? [solved]
- Subject: Re: [NSImage] Bug in System Preferences? [solved]
- From: Ken Ferry <email@hidden>
- Date: Fri, 22 Oct 2010 17:41:33 -0700
On Oct 22, 2010, at 4:07 PM, Iceberg-Dev <email@hidden> wrote:
> On Oct 22, 2010, at 12:48 AM, Iceberg-Dev wrote:
>
>> 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.
>>
> [...]
>
>> QUESTION:
>> ---------
>>
>> What can be done to address this behavioral incoherence in System Preferences?
>
> I solved the issue on Mac OS X 10.6 by calling lockFocusOnRepresentation: and unlockFocus before and after I refresh the bitmap buffer.
>
> Funnily enough, this bug also exists with the CoreGraphics API.
Hi-
This isn't a bug, and your workaround could break under you at any time.
If you think about what has to happen, you'll realize you cannot just have permanent direct access to the backing store. The image has to be colormatched and possibly uploaded to the graphics card, for example. How are the frameworks to know if you toggled a bit and that work must be redone? The basic CG model for an image is that it's immutable.
When working with NSBitmapImageRep, calling -bitmapData is a signal that you may be editing the data. It is not repackaged until the bitmap is drawn, or somesuch. It's illegal to just stash a pointer to the data and use it arbitrarily later - that won't necessarily be the same data as now backs the image. This is described in the 10.6 AppKit release notes.
In CG, you may be interested in the relationship of CGBitmapContext to CGBitmapContextCreateImage. The latter makes a copy-on-write vm copy of the data from bitmap context. So it's cheap until real copying is forced by a write to the context data.
-ken
Cocoa Frameworks
>
> CopyBits, I miss you.
>
>
> _______________________________________________
>
> 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
_______________________________________________
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