Backend part of graphic context rewrite.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/trunk@24965 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2007-04-04 14:33:10 +00:00
parent 7f68c2ef43
commit ff21318a0a
6 changed files with 159 additions and 90 deletions

View file

@ -1,3 +1,16 @@
2007-04-04 Fred Kiefer <FredKiefer@gmx.de>
* Headers/gsc/GSContext.h: Remove ivar gtable.
* Source/gsc/GSContext.m: Changed to use a gtable object
shared between all contexts.
* Headers/cairo/CairoGState.h:
Declare new methods for save and restore.
* Source/cairo/CairoContext.m (-DPSgrestore, -DPSgsave): Use these methods.
* Source/cairo/CairoGState.m (-DPSgrestore, -DPSgsave): Implement
these methods.
* Source/cairo/CairoGState.m (-compositeGState:...fraction:):
Another try on conversion of the coordinates.
2007-03-30 Fred Kiefer <FredKiefer@gmx.de> 2007-03-30 Fred Kiefer <FredKiefer@gmx.de>
* header/xlib/XGGeometry.h: Replace calls to the now deprecated * header/xlib/XGGeometry.h: Replace calls to the now deprecated

View file

@ -38,6 +38,8 @@
- (void) GSCurrentDevice: (void **)device: (int *)x : (int *)y; - (void) GSCurrentDevice: (void **)device: (int *)x : (int *)y;
- (void) GSSetDevice: (void *)device : (int)x : (int)y; - (void) GSSetDevice: (void *)device : (int)x : (int)y;
- (void) DPSgsave;
- (void) DPSgrestore;
@end @end

View file

@ -40,7 +40,6 @@
void *opstack; void *opstack;
void *gstack; void *gstack;
GSGState *gstate; GSGState *gstate;
NSMapTable *gtable;
} }
- (GSGState *) currentGState; - (GSGState *) currentGState;

View file

@ -113,4 +113,14 @@
[CGSTATE GSSetDevice: device : x : y]; [CGSTATE GSSetDevice: device : x : y];
} }
- (void) DPSgrestore
{
[CGSTATE DPSgrestore];
}
- (void) DPSgsave
{
[CGSTATE DPSgsave];
}
@end @end

View file

@ -169,6 +169,22 @@
theOffset.y - size.height); theOffset.y - size.height);
} }
- (void) DPSgrestore
{
if (_ct)
{
cairo_restore(_ct);
}
}
- (void) DPSgsave
{
if (_ct)
{
cairo_save(_ct);
}
}
/* /*
* Color operations * Color operations
*/ */
@ -967,15 +983,21 @@ _set_op(cairo_t *ct, NSCompositingOperation op)
*/ */
} }
/* // Undo flipping in gui
With this bit of code enable scrolling works correctly, but images in cells get displayed wrongly.
if (viewIsFlipped) if (viewIsFlipped)
{ {
aPoint.y += NSHeight(aRect); aPoint.y -= NSHeight(aRect);
} }
*/ {
NSRect newRect;
newRect.origin = aPoint;
newRect.size = aRect.size;
[ctm boundingRectFor: newRect result: &newRect];
aPoint = newRect.origin;
}
//aPoint = [ctm transformPoint: aPoint];
[source->ctm boundingRectFor: aRect result: &aRect]; [source->ctm boundingRectFor: aRect result: &aRect];
aPoint = [ctm transformPoint: aPoint];
x = aPoint.x; x = aPoint.x;
y = aPoint.y; y = aPoint.y;

View file

@ -98,6 +98,7 @@
/* Globally unique gstate number */ /* Globally unique gstate number */
static unsigned int unique_index = 0; static unsigned int unique_index = 0;
static NSMapTable *gtable;
@interface GSContext (PrivateOps) @interface GSContext (PrivateOps)
- (void)DPSdefineuserobject; - (void)DPSdefineuserobject;
@ -112,6 +113,7 @@ static unsigned int unique_index = 0;
- (void)DPSpop; - (void)DPSpop;
@end @end
/** /**
<unit> <unit>
<heading>GSContext</heading> <heading>GSContext</heading>
@ -128,6 +130,28 @@ static unsigned int unique_index = 0;
</unit> */ </unit> */
@implementation GSContext @implementation GSContext
+ (void) initialize
{
gtable = NSCreateMapTable(NSIntMapKeyCallBacks,
NSObjectMapValueCallBacks, 20);
}
+ (void) insertObject: (id)obj forKey: (int)index
{
NSMapInsert(gtable, (void *)(uintptr_t)index, obj);
}
+ (id) getObjectForKey: (int)index
{
return NSMapGet(gtable, (void *)(uintptr_t)index);
}
+ (void) removeObjectForKey: (int)index
{
NSMapRemove(gtable, (void *)(uintptr_t)index);
}
- (id) initWithContextInfo: (NSDictionary *)info - (id) initWithContextInfo: (NSDictionary *)info
{ {
NSString *contextType; NSString *contextType;
@ -152,9 +176,6 @@ static unsigned int unique_index = 0;
GSIArrayInitWithZoneAndCapacity((GSIArray)opstack, z, 2); GSIArrayInitWithZoneAndCapacity((GSIArray)opstack, z, 2);
gstack = NSZoneMalloc(z, sizeof(GSIArray_t)); gstack = NSZoneMalloc(z, sizeof(GSIArray_t));
GSIArrayInitWithZoneAndCapacity((GSIArray)gstack, z, 2); GSIArrayInitWithZoneAndCapacity((GSIArray)gstack, z, 2);
gtable = NSCreateMapTable(NSIntMapKeyCallBacks,
NSObjectMapValueCallBacks, 20);
[super initWithContextInfo: info]; [super initWithContextInfo: info];
return self; return self;
@ -170,7 +191,6 @@ static unsigned int unique_index = 0;
NSZoneFree([self zone], opstack); NSZoneFree([self zone], opstack);
GSIArrayEmpty((GSIArray)gstack); GSIArrayEmpty((GSIArray)gstack);
NSZoneFree([self zone], gstack); NSZoneFree([self zone], gstack);
NSFreeMapTable(gtable);
DESTROY(gstate); DESTROY(gstate);
[super dealloc]; [super dealloc];
} }
@ -419,8 +439,8 @@ static unsigned int unique_index = 0;
DPS_ERROR(DPSundefined, @"No gstate"); DPS_ERROR(DPSundefined, @"No gstate");
return 0; return 0;
} }
NSMapInsert(gtable, [isa insertObject: AUTORELEASE([gstate copy]) forKey: ++unique_index];
(void *)(uintptr_t)++unique_index, AUTORELEASE([gstate copy]));
return unique_index; return unique_index;
} }
@ -433,7 +453,8 @@ static unsigned int unique_index = 0;
{ {
if (gst <= 0) if (gst <= 0)
return; return;
NSMapInsert(gtable, (void *)(uintptr_t)gst, AUTORELEASE([gstate copy]));
[isa insertObject: AUTORELEASE([gstate copy]) forKey: gst];
} }
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
@ -865,27 +886,29 @@ static unsigned int unique_index = 0;
if (n < 0) if (n < 0)
DPS_ERROR(DPSinvalidparam, @"Invalid userobject index"); DPS_ERROR(DPSinvalidparam, @"Invalid userobject index");
else else
NSMapInsert(gtable, (void *)(uintptr_t)n, obj); [isa insertObject: obj forKey: n];
} }
- (void)DPSexecuserobject: (int)index - (void)DPSexecuserobject: (int)index
{ {
if (index < 0 || NSMapGet(gtable, (void *)(uintptr_t)index) == nil) id obj;
if (index < 0 || (obj = [isa getObjectForKey: index]) == nil)
{ {
DPS_ERROR(DPSinvalidparam, @"Invalid userobject index"); DPS_ERROR(DPSinvalidparam, @"Invalid userobject index");
return; return;
} }
ctxt_push((id)NSMapGet(gtable, (void *)(uintptr_t)index), opstack); ctxt_push(obj, opstack);
} }
- (void)DPSundefineuserobject: (int)index - (void)DPSundefineuserobject: (int)index
{ {
if (index < 0 || NSMapGet(gtable, (void *)(uintptr_t)index) == nil) if (index < 0 || [isa getObjectForKey: index] == nil)
{ {
DPS_ERROR(DPSinvalidparam, @"Invalid gstate index"); DPS_ERROR(DPSinvalidparam, @"Invalid gstate index");
return; return;
} }
NSMapRemove(gtable, (void *)(uintptr_t)index); [isa removeObjectForKey: index];
} }
- (void)DPSclear - (void)DPSclear