• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Thousands of leaked CGContext ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Thousands of leaked CGContext ?


  • Subject: Re: Thousands of leaked CGContext ?
  • From: Eric Matecki <email@hidden>
  • Date: Mon, 20 Apr 2015 09:05:28 +0200

Hi,

    CGDataProviderRef  provider = CGDataProviderCreateDirect( &mps, sizeof(mps), &callbacks );

    NSWindow*  window = (NSWindow*)Window();

What does this line do?

It's just a global function which returns the (only) window.
For crossplatform compatibility reasons (our app runs on MacOSX, Linux, Windows and Android) it returns a void*,
that's why the cast is needed.

This one :
>>     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 );
>>

It creates a CGImage which will use the CGDataProvider for a source of the pixels.

The size is the same as the 'dirty' rect to refresh, 8 bits/component, 32 bits/pixel, w*4 bytes/row,
the windows colorspace, the pixel 'description' (integer, no useful data in alpha channel),
my data provider, NULL(decode array), no interpolation (it's anyway a 1to1 mapping of the pixels), rendering intent.

The data provider just copies the pixels or returns a pointer to the correct byte :

struct MyProviderStruct
{
    ::nImage8::cRGBABlock*  mBlock;
    int  mX, mY;
};

static const void*
MyProviderGetBytePointer( void* iInfo )
{
    MyProviderStruct*  mps = (MyProviderStruct*) iInfo;
    return  mps->mBlock->Pixels( mps->mX, mps->mY );  // this returns a pointer to that pixel
}

static void MyProviderReleaseBytePointer( void* iInfo, const void* iPointer ) {}

static size_t
MyProviderGetBytesAtPosition( void* iInfo, void* oBuffer, off_t iPosition, size_t iCount )
{
    MyProviderStruct*  mps = (MyProviderStruct*) iInfo;
    ::nMemoryUtils::Copy( oBuffer, (uint8*)(mps->mBlock->Pixels()) + iPosition, uint32(iCount) );
    return  iCount;
}

static void MyProviderReleaseInfo( void* iInfo ) {}



Except for the leaked memory, it works as expected.

Thanks

--
Keep intel OUTSIDE my Mac !
Hiii !!! I can see Intel chips creeping around my G5 !

Eric M.
_______________________________________________

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


  • Follow-Ups:
    • Re: Thousands of leaked CGContext ?
      • From: David Duncan <email@hidden>
    • Re: Thousands of leaked CGContext ?
      • From: Uli Kusterer <email@hidden>
References: 
 >Thousands of leaked CGContext ? (From: Eric Matecki <email@hidden>)
 >Re: Thousands of leaked CGContext ? (From: David Duncan <email@hidden>)

  • Prev by Date: UIAlertView has zero bounds
  • Next by Date: Re: UIAlertView has zero bounds
  • Previous by thread: Re: Thousands of leaked CGContext ?
  • Next by thread: Re: Thousands of leaked CGContext ?
  • Index(es):
    • Date
    • Thread