HIThemeBrushCreateCGColor seems to have become very CPU-expensive, cache the results for better performance
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73208 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -246,9 +246,26 @@ CGColorSpaceRef wxMacGetGenericRGBColorSpace()
|
||||
|
||||
CGColorRef wxMacCreateCGColorFromHITheme( ThemeBrush brush )
|
||||
{
|
||||
const int maxcachedbrush = 58+5; // negative indices are for metabrushes, cache down to -5)
|
||||
int brushindex = brush+5;
|
||||
if ( brushindex < 0 || brush > brushindex )
|
||||
{
|
||||
CGColorRef color ;
|
||||
HIThemeBrushCreateCGColor( brush, &color );
|
||||
return color;
|
||||
}
|
||||
else
|
||||
{
|
||||
static bool inited = false;
|
||||
static CGColorRef themecolors[maxcachedbrush+1];
|
||||
if ( !inited )
|
||||
{
|
||||
for ( int i = 0 ; i <= maxcachedbrush ; ++i )
|
||||
HIThemeBrushCreateCGColor( i-5, &themecolors[i] );
|
||||
inited = true;
|
||||
}
|
||||
return CGColorRetain(themecolors[brushindex ]);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user