> On Apr 17, 2015, at 2:38 AM, Eric Matecki <eml...@wanadoo.fr> wrote:
> 
> Hi,
> 
> (I know this is not 100% Cocoa, but it isn't 100% CoreGraphics either...)
> 
> I'm drawing to an NSWindow with CoreGraphics, and each time there is a leaked 
> CGContext, CGContextDelegate, CGColorTransform, NSBitmapGraphicsContext, and 
> NSFocusStack (one of each).
> 
> 
> Here is how I do it :
> 
>    CGDataProviderDirectCallbacks callbacks = {
>        0,
>        &MyProviderGetBytePointer,
>        &MyProviderReleaseBytePointer,
>        &MyProviderGetBytesAtPosition,
>        &MyProviderReleaseInfo
>    };
> 
>    MyProviderStruct  mps = { mBlock, mDirtyRect.X(), mDirtyRect.Y() };
> 
>    CGDataProviderRef  provider = CGDataProviderCreateDirect( &mps, 
> sizeof(mps), &callbacks );
> 
>    NSWindow*  window = (NSWindow*)Window();

What does this line do?

>    CGImageRef  image = CGImageCreate( size_t(mDirtyRect.W()), 
> size_t(mDirtyRect.H()), 8, 32, size_t(mBlock->Width()*4),
>                                       [[window colorSpace] CGColorSpace], 
> kCGBitmapByteOrder32Big | kCGImageAlphaNoneSkipFirst,
>                                       provider, NULL, false, 
> kCGRenderingIntentRelativeColorimetric );
> 
>    CGContextRef  myContext = (CGContextRef)[[NSGraphicsContext 
> currentContext] graphicsPort];
> 
>    CGContextDrawImage( myContext, CGRectMake( mDirtyRect.X(), geom.H() - 
> mDirtyRect.Y() - mDirtyRect.H(),
>                                               mDirtyRect.W(), mDirtyRect.H() 
> ), image );
> 
>    CGContextFlush( myContext );
>    CGImageRelease( image );
>    CGDataProviderRelease( provider );
> 
> 
> I don't release the CGContextRef because I don't 'create' it.
> If I release it, the app doesn't crash but doesn't draw anything anymore 
> after the first one.
> 
> My data provider just copy bytes from a legacy data structure.
> 
> What am I doing wrong ?
> Or maybe there is a better way of doing this ?
> 
> Thanks for any help !
> 
> -- 
> Keep intel OUTSIDE my Mac !
> Hiii !!! I can see Intel chips creeping around my G5 !
> 
> Eric M.
> _______________________________________________
> 
> 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:
> https://lists.apple.com/mailman/options/cocoa-dev/david.duncan%40apple.com
> 
> This email sent to david.dun...@apple.com

--
David Duncan


_______________________________________________

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

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

Reply via email to