have CGImage Support in all OSX builds

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@32509 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor 2005-03-01 05:31:37 +00:00
parent 7890a36c9c
commit 30e77b5c9f
5 changed files with 78 additions and 68 deletions

View File

@ -196,7 +196,7 @@ public:
// returns the 'native' implementation, a GWorldPtr for the content and one for the mask
WXHBITMAP GetHBITMAP( WXHBITMAP * mask = NULL ) const;
#if wxMAC_USE_CORE_GRAPHICS
#ifdef __WXMAC_OSX__
// returns a CGImageRef which must released after usage with CGImageRelease
WXCGIMAGEREF CGImageCreate() const ;
#endif

View File

@ -637,10 +637,14 @@ private:
wxBrush m_brush ;
} ;
#endif // wxMAC_USE_CORE_GRAPHICS
#ifdef __WXMAC_OSX__
CGColorSpaceRef wxMacGetGenericRGBColorSpace(void) ;
void wxMacMemoryBufferReleaseProc(void *info, const void *data, size_t size) ;
#endif // wxMAC_USE_CORE_GRAPHICS
#endif
class WXDLLEXPORT wxBitmapRefData: public wxGDIRefData
{
@ -678,7 +682,7 @@ public:
#endif // wxUSE_PALETTE
wxMask * m_bitmapMask; // Optional mask
#if wxMAC_USE_CORE_GRAPHICS
#ifdef __WXMAC_OSX__
CGImageRef CGImageCreate() const ;
#endif
@ -710,7 +714,7 @@ private :
wxMemoryBuffer m_memBuf ;
int m_rawAccessCount ;
bool m_ok;
#if wxMAC_USE_CORE_GRAPHICS
#ifdef __WXMAC_OSX__
mutable CGImageRef m_cgImageRef ;
#endif
IconRef m_iconRef ;

View File

@ -454,7 +454,7 @@ PicHandle wxBitmapRefData::GetPictHandle()
return m_pictHandle ;
}
#if wxMAC_USE_CORE_GRAPHICS
#ifdef __WXMAC_OSX__
void wxMacMemoryBufferReleaseProc(void *info, const void *data, size_t size)
{
wxMemoryBuffer* membuf = (wxMemoryBuffer*) info ;
@ -817,7 +817,7 @@ bool wxBitmap::CreateFromXpm(const char **bits)
return TRUE;
}
#if wxMAC_USE_CORE_GRAPHICS
#ifdef __WXMAC_OSX__
WXCGIMAGEREF wxBitmap::CGImageCreate() const
{
wxCHECK_MSG( Ok(), NULL , wxT("invalid bitmap") ) ;

View File

@ -467,68 +467,6 @@ void wxMacCGContext::SetBrush( const wxBrush &brush )
}
}
// snippets from Sketch Sample from Apple :
#define kGenericRGBProfilePathStr "/System/Library/ColorSync/Profiles/Generic RGB Profile.icc"
/*
This function locates, opens, and returns the profile reference for the calibrated
Generic RGB color space. It is up to the caller to call CMCloseProfile when done
with the profile reference this function returns.
*/
CMProfileRef wxMacOpenGenericProfile(void)
{
static CMProfileRef cachedRGBProfileRef = NULL;
// we only create the profile reference once
if (cachedRGBProfileRef == NULL)
{
CMProfileLocation loc;
loc.locType = cmPathBasedProfile;
strcpy(loc.u.pathLoc.path, kGenericRGBProfilePathStr);
verify_noerr( CMOpenProfile(&cachedRGBProfileRef, &loc) );
}
if (cachedRGBProfileRef)
{
// clone the profile reference so that the caller has their own reference, not our cached one
CMCloneProfileRef(cachedRGBProfileRef);
}
return cachedRGBProfileRef;
}
/*
Return the generic RGB color space. This is a 'get' function and the caller should
not release the returned value unless the caller retains it first. Usually callers
of this routine will immediately use the returned colorspace with CoreGraphics
so they typically do not need to retain it themselves.
This function creates the generic RGB color space once and hangs onto it so it can
return it whenever this function is called.
*/
CGColorSpaceRef wxMacGetGenericRGBColorSpace()
{
static CGColorSpaceRef genericRGBColorSpace = NULL;
if (genericRGBColorSpace == NULL)
{
CMProfileRef genericRGBProfile = wxMacOpenGenericProfile();
if (genericRGBProfile)
{
genericRGBColorSpace = CGColorSpaceCreateWithPlatformColorSpace(genericRGBProfile);
wxASSERT_MSG( genericRGBColorSpace != NULL, wxT("couldn't create the generic RGB color space") ) ;
// we opened the profile so it is up to us to close it
CMCloseProfile(genericRGBProfile);
}
}
return genericRGBColorSpace;
}
void AddEllipticArcToPath(CGContextRef c, CGPoint center, float a, float b, float fromDegree , float toDegree )
{
CGContextSaveGState(c);

View File

@ -1457,5 +1457,73 @@ OSStatus wxMacControl::SetTabEnabled( SInt16 tabNo , bool enable )
return ::SetTabEnabled( m_controlRef , tabNo , enable ) ;
}
//
// Quartz Support
//
#ifdef __WXMAC_OSX__
// snippets from Sketch Sample from Apple :
#define kGenericRGBProfilePathStr "/System/Library/ColorSync/Profiles/Generic RGB Profile.icc"
/*
This function locates, opens, and returns the profile reference for the calibrated
Generic RGB color space. It is up to the caller to call CMCloseProfile when done
with the profile reference this function returns.
*/
CMProfileRef wxMacOpenGenericProfile(void)
{
static CMProfileRef cachedRGBProfileRef = NULL;
// we only create the profile reference once
if (cachedRGBProfileRef == NULL)
{
CMProfileLocation loc;
loc.locType = cmPathBasedProfile;
strcpy(loc.u.pathLoc.path, kGenericRGBProfilePathStr);
verify_noerr( CMOpenProfile(&cachedRGBProfileRef, &loc) );
}
if (cachedRGBProfileRef)
{
// clone the profile reference so that the caller has their own reference, not our cached one
CMCloneProfileRef(cachedRGBProfileRef);
}
return cachedRGBProfileRef;
}
/*
Return the generic RGB color space. This is a 'get' function and the caller should
not release the returned value unless the caller retains it first. Usually callers
of this routine will immediately use the returned colorspace with CoreGraphics
so they typically do not need to retain it themselves.
This function creates the generic RGB color space once and hangs onto it so it can
return it whenever this function is called.
*/
CGColorSpaceRef wxMacGetGenericRGBColorSpace()
{
static CGColorSpaceRef genericRGBColorSpace = NULL;
if (genericRGBColorSpace == NULL)
{
CMProfileRef genericRGBProfile = wxMacOpenGenericProfile();
if (genericRGBProfile)
{
genericRGBColorSpace = CGColorSpaceCreateWithPlatformColorSpace(genericRGBProfile);
wxASSERT_MSG( genericRGBColorSpace != NULL, wxT("couldn't create the generic RGB color space") ) ;
// we opened the profile so it is up to us to close it
CMCloseProfile(genericRGBProfile);
}
}
return genericRGBColorSpace;
}
#endif
#endif // wxUSE_GUI