mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-23 21:42:54 +00:00
Some more optimisation
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@4235 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
0644a7dfeb
commit
0c507ab2d0
8 changed files with 59 additions and 22 deletions
|
@ -55,7 +55,29 @@ static NSMutableDictionary *classMethodTable;
|
|||
/* Lock for use when creating contexts */
|
||||
static NSRecursiveLock *contextLock = nil;
|
||||
|
||||
static NSString *NSGraphicsContextThredKey = @"NSGraphicsContextThredKey";
|
||||
#ifndef GNUSTEP_BASE_LIBRARY
|
||||
static NSString *NSGraphicsContextThreadKey = @"NSGraphicsContextThreadKey";
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Function for rapid access to current graphics context.
|
||||
*/
|
||||
NSGraphicsContext *GSCurrentContext()
|
||||
{
|
||||
#ifdef GNUSTEP_BASE_LIBRARY
|
||||
/*
|
||||
* gstep-base has a faster mechanism to get the current thread.
|
||||
*/
|
||||
NSThread *th = GSCurrentThread();
|
||||
|
||||
return (NSGraphicsContext*) th->_gcontext;
|
||||
#else
|
||||
NSMutableDictionary *dict [[NSThread currentThread] threadDictionary];
|
||||
|
||||
return (NSGraphicsContext*) [dict objectForKey: NSGraphicsContextThreadKey];
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@interface NSGraphicsContext (Private)
|
||||
+ (gsMethodTable *) _initializeMethodTable;
|
||||
|
@ -103,29 +125,31 @@ struct NSWindow_struct
|
|||
return ctxt;
|
||||
}
|
||||
|
||||
+ (void) setCurrentContext: (NSGraphicsContext *)context
|
||||
{
|
||||
#ifdef GNUSTEP_BASE_LIBRARY
|
||||
/*
|
||||
* gstep-base has a faster mechanism to get the current thread.
|
||||
*/
|
||||
#ifndef GNUSTEP_BASE_LIBRARY
|
||||
#define GSCurrentThreadDictionary() [[NSThread currentThread] threadDictionary]
|
||||
NSThread *th = GSCurrentThread();
|
||||
|
||||
th->_gcontext = context;
|
||||
#else
|
||||
NSMutableDictionary *dict [[NSThread currentThread] threadDictionary];
|
||||
|
||||
[dict setObject: context forKey: NSGraphicsContextThreadKey];
|
||||
#endif
|
||||
|
||||
+ (void) setCurrentContext: (NSGraphicsContext *)context
|
||||
{
|
||||
NSMutableDictionary *dict = GSCurrentThreadDictionary();
|
||||
|
||||
[dict setObject: context forKey: NSGraphicsContextThredKey];
|
||||
}
|
||||
|
||||
+ (NSGraphicsContext *) currentContext
|
||||
{
|
||||
NSMutableDictionary *dict = GSCurrentThreadDictionary();
|
||||
|
||||
return (NSGraphicsContext*) [dict objectForKey: NSGraphicsContextThredKey];
|
||||
return GSCurrentContext();
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
if (GSCurrentContext() == self)
|
||||
[NSGraphicsContext setCurrentContext: nil];
|
||||
DESTROY(focus_stack);
|
||||
DESTROY(context_data);
|
||||
DESTROY(context_info);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue