mirror of
https://github.com/gnustep/libs-back.git
synced 2025-02-23 11:51:27 +00:00
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:
parent
7f68c2ef43
commit
ff21318a0a
6 changed files with 159 additions and 90 deletions
13
ChangeLog
13
ChangeLog
|
@ -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>
|
||||
|
||||
* header/xlib/XGGeometry.h: Replace calls to the now deprecated
|
||||
|
|
|
@ -38,6 +38,8 @@
|
|||
|
||||
- (void) GSCurrentDevice: (void **)device: (int *)x : (int *)y;
|
||||
- (void) GSSetDevice: (void *)device : (int)x : (int)y;
|
||||
- (void) DPSgsave;
|
||||
- (void) DPSgrestore;
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -40,7 +40,6 @@
|
|||
void *opstack;
|
||||
void *gstack;
|
||||
GSGState *gstate;
|
||||
NSMapTable *gtable;
|
||||
}
|
||||
|
||||
- (GSGState *) currentGState;
|
||||
|
|
|
@ -113,4 +113,14 @@
|
|||
[CGSTATE GSSetDevice: device : x : y];
|
||||
}
|
||||
|
||||
- (void) DPSgrestore
|
||||
{
|
||||
[CGSTATE DPSgrestore];
|
||||
}
|
||||
|
||||
- (void) DPSgsave
|
||||
{
|
||||
[CGSTATE DPSgsave];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -120,8 +120,8 @@
|
|||
status = cairo_status(copy->_ct);
|
||||
if (status != CAIRO_STATUS_SUCCESS)
|
||||
{
|
||||
NSLog(@"Cairo status %s in copy", cairo_status_to_string(status));
|
||||
}
|
||||
NSLog(@"Cairo status %s in copy", cairo_status_to_string(status));
|
||||
}
|
||||
}
|
||||
|
||||
RETAIN(_surface);
|
||||
|
@ -138,13 +138,13 @@
|
|||
if (device)
|
||||
{
|
||||
if (_surface)
|
||||
{
|
||||
*device = _surface->gsDevice;
|
||||
}
|
||||
{
|
||||
*device = _surface->gsDevice;
|
||||
}
|
||||
else
|
||||
{
|
||||
*device = NULL;
|
||||
}
|
||||
{
|
||||
*device = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -169,6 +169,22 @@
|
|||
theOffset.y - size.height);
|
||||
}
|
||||
|
||||
- (void) DPSgrestore
|
||||
{
|
||||
if (_ct)
|
||||
{
|
||||
cairo_restore(_ct);
|
||||
}
|
||||
}
|
||||
|
||||
- (void) DPSgsave
|
||||
{
|
||||
if (_ct)
|
||||
{
|
||||
cairo_save(_ct);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Color operations
|
||||
*/
|
||||
|
@ -420,9 +436,9 @@
|
|||
i = size;
|
||||
while (i)
|
||||
{
|
||||
i--;
|
||||
dpat[i] = pat[i];
|
||||
}
|
||||
i--;
|
||||
dpat[i] = pat[i];
|
||||
}
|
||||
// FIXME: There may be a difference in concept as some dashes look wrong
|
||||
cairo_set_dash(_ct, dpat, size, doffset);
|
||||
GS_ENDITEMBUF();
|
||||
|
@ -494,23 +510,23 @@
|
|||
type = (NSBezierPathElement)(*elmidx)(path, elmsel, i, points);
|
||||
switch(type)
|
||||
{
|
||||
case NSMoveToBezierPathElement:
|
||||
cairo_move_to(_ct, points[0].x, points[0].y);
|
||||
break;
|
||||
case NSLineToBezierPathElement:
|
||||
cairo_line_to(_ct, points[0].x, points[0].y);
|
||||
break;
|
||||
case NSCurveToBezierPathElement:
|
||||
cairo_curve_to(_ct, points[0].x, points[0].y,
|
||||
points[1].x, points[1].y,
|
||||
points[2].x, points[2].y);
|
||||
break;
|
||||
case NSClosePathBezierPathElement:
|
||||
cairo_close_path(_ct);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
case NSMoveToBezierPathElement:
|
||||
cairo_move_to(_ct, points[0].x, points[0].y);
|
||||
break;
|
||||
case NSLineToBezierPathElement:
|
||||
cairo_line_to(_ct, points[0].x, points[0].y);
|
||||
break;
|
||||
case NSCurveToBezierPathElement:
|
||||
cairo_curve_to(_ct, points[0].x, points[0].y,
|
||||
points[1].x, points[1].y,
|
||||
points[2].x, points[2].y);
|
||||
break;
|
||||
case NSClosePathBezierPathElement:
|
||||
cairo_close_path(_ct);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -772,25 +788,25 @@ _set_op(cairo_t *ct, NSCompositingOperation op)
|
|||
|
||||
for (i = 0; i < pixelsHigh; i++)
|
||||
{
|
||||
unsigned char *d = rowData;
|
||||
unsigned char *d = rowData;
|
||||
|
||||
for (j = 0; j < pixelsWide; j++)
|
||||
{
|
||||
for (j = 0; j < pixelsWide; j++)
|
||||
{
|
||||
#if GS_WORDS_BIGENDIAN
|
||||
tmp[index++] = d[3];
|
||||
tmp[index++] = d[0];
|
||||
tmp[index++] = d[1];
|
||||
tmp[index++] = d[2];
|
||||
tmp[index++] = d[3];
|
||||
tmp[index++] = d[0];
|
||||
tmp[index++] = d[1];
|
||||
tmp[index++] = d[2];
|
||||
#else
|
||||
tmp[index++] = d[2];
|
||||
tmp[index++] = d[1];
|
||||
tmp[index++] = d[0];
|
||||
tmp[index++] = d[3];
|
||||
tmp[index++] = d[2];
|
||||
tmp[index++] = d[1];
|
||||
tmp[index++] = d[0];
|
||||
tmp[index++] = d[3];
|
||||
#endif
|
||||
d += 4;
|
||||
}
|
||||
rowData += bytesPerRow;
|
||||
}
|
||||
d += 4;
|
||||
}
|
||||
rowData += bytesPerRow;
|
||||
}
|
||||
format = CAIRO_FORMAT_ARGB32;
|
||||
break;
|
||||
case 24:
|
||||
|
@ -800,25 +816,25 @@ _set_op(cairo_t *ct, NSCompositingOperation op)
|
|||
|
||||
for (i = 0; i < pixelsHigh; i++)
|
||||
{
|
||||
unsigned char *d = rowData;
|
||||
unsigned char *d = rowData;
|
||||
|
||||
for (j = 0; j < pixelsWide; j++)
|
||||
{
|
||||
for (j = 0; j < pixelsWide; j++)
|
||||
{
|
||||
#if GS_WORDS_BIGENDIAN
|
||||
tmp[index++] = 0;
|
||||
tmp[index++] = d[0];
|
||||
tmp[index++] = d[1];
|
||||
tmp[index++] = d[2];
|
||||
tmp[index++] = 0;
|
||||
tmp[index++] = d[0];
|
||||
tmp[index++] = d[1];
|
||||
tmp[index++] = d[2];
|
||||
#else
|
||||
tmp[index++] = d[2];
|
||||
tmp[index++] = d[1];
|
||||
tmp[index++] = d[0];
|
||||
tmp[index++] = 0;
|
||||
tmp[index++] = d[2];
|
||||
tmp[index++] = d[1];
|
||||
tmp[index++] = d[0];
|
||||
tmp[index++] = 0;
|
||||
#endif
|
||||
d += 3;
|
||||
}
|
||||
rowData += bytesPerRow;
|
||||
}
|
||||
d += 3;
|
||||
}
|
||||
rowData += bytesPerRow;
|
||||
}
|
||||
format = CAIRO_FORMAT_RGB24;
|
||||
break;
|
||||
default:
|
||||
|
@ -837,8 +853,8 @@ _set_op(cairo_t *ct, NSCompositingOperation op)
|
|||
NSLog(@"Image surface could not be created");
|
||||
if (tmp)
|
||||
{
|
||||
objc_free(tmp);
|
||||
}
|
||||
objc_free(tmp);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -924,10 +940,10 @@ _set_op(cairo_t *ct, NSCompositingOperation op)
|
|||
}
|
||||
|
||||
- (void) compositeGState: (CairoGState *)source
|
||||
fromRect: (NSRect)aRect
|
||||
toPoint: (NSPoint)aPoint
|
||||
op: (NSCompositingOperation)op
|
||||
fraction: (float)delta
|
||||
fromRect: (NSRect)aRect
|
||||
toPoint: (NSPoint)aPoint
|
||||
op: (NSCompositingOperation)op
|
||||
fraction: (float)delta
|
||||
{
|
||||
cairo_surface_t *src;
|
||||
double minx, miny;
|
||||
|
@ -956,26 +972,32 @@ _set_op(cairo_t *ct, NSCompositingOperation op)
|
|||
targetRect.size = aRect.size;
|
||||
|
||||
if (!NSIsEmptyRect(NSIntersectionRect(aRect, targetRect)))
|
||||
{
|
||||
NSLog(@"Copy onto self");
|
||||
NSLog(NSStringFromRect(aRect));
|
||||
NSLog(NSStringFromPoint(aPoint));
|
||||
NSLog(@"src %p(%p,%@) des %p(%p,%@)",
|
||||
source,cairo_get_target(source->_ct),NSStringFromSize([source->_surface size]),
|
||||
self,cairo_get_target(_ct),NSStringFromSize([_surface size]));
|
||||
}
|
||||
{
|
||||
NSLog(@"Copy onto self");
|
||||
NSLog(NSStringFromRect(aRect));
|
||||
NSLog(NSStringFromPoint(aPoint));
|
||||
NSLog(@"src %p(%p,%@) des %p(%p,%@)",
|
||||
source,cairo_get_target(source->_ct),NSStringFromSize([source->_surface size]),
|
||||
self,cairo_get_target(_ct),NSStringFromSize([_surface size]));
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
/*
|
||||
With this bit of code enable scrolling works correctly, but images in cells get displayed wrongly.
|
||||
// Undo flipping in gui
|
||||
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];
|
||||
aPoint = [ctm transformPoint: aPoint];
|
||||
|
||||
x = aPoint.x;
|
||||
y = aPoint.y;
|
||||
|
|
|
@ -98,6 +98,7 @@
|
|||
|
||||
/* Globally unique gstate number */
|
||||
static unsigned int unique_index = 0;
|
||||
static NSMapTable *gtable;
|
||||
|
||||
@interface GSContext (PrivateOps)
|
||||
- (void)DPSdefineuserobject;
|
||||
|
@ -112,6 +113,7 @@ static unsigned int unique_index = 0;
|
|||
- (void)DPSpop;
|
||||
@end
|
||||
|
||||
|
||||
/**
|
||||
<unit>
|
||||
<heading>GSContext</heading>
|
||||
|
@ -128,6 +130,28 @@ static unsigned int unique_index = 0;
|
|||
</unit> */
|
||||
@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
|
||||
{
|
||||
NSString *contextType;
|
||||
|
@ -152,9 +176,6 @@ static unsigned int unique_index = 0;
|
|||
GSIArrayInitWithZoneAndCapacity((GSIArray)opstack, z, 2);
|
||||
gstack = NSZoneMalloc(z, sizeof(GSIArray_t));
|
||||
GSIArrayInitWithZoneAndCapacity((GSIArray)gstack, z, 2);
|
||||
gtable = NSCreateMapTable(NSIntMapKeyCallBacks,
|
||||
NSObjectMapValueCallBacks, 20);
|
||||
|
||||
[super initWithContextInfo: info];
|
||||
|
||||
return self;
|
||||
|
@ -170,7 +191,6 @@ static unsigned int unique_index = 0;
|
|||
NSZoneFree([self zone], opstack);
|
||||
GSIArrayEmpty((GSIArray)gstack);
|
||||
NSZoneFree([self zone], gstack);
|
||||
NSFreeMapTable(gtable);
|
||||
DESTROY(gstate);
|
||||
[super dealloc];
|
||||
}
|
||||
|
@ -419,8 +439,8 @@ static unsigned int unique_index = 0;
|
|||
DPS_ERROR(DPSundefined, @"No gstate");
|
||||
return 0;
|
||||
}
|
||||
NSMapInsert(gtable,
|
||||
(void *)(uintptr_t)++unique_index, AUTORELEASE([gstate copy]));
|
||||
[isa insertObject: AUTORELEASE([gstate copy]) forKey: ++unique_index];
|
||||
|
||||
return unique_index;
|
||||
}
|
||||
|
||||
|
@ -433,7 +453,8 @@ static unsigned int unique_index = 0;
|
|||
{
|
||||
if (gst <= 0)
|
||||
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)
|
||||
DPS_ERROR(DPSinvalidparam, @"Invalid userobject index");
|
||||
else
|
||||
NSMapInsert(gtable, (void *)(uintptr_t)n, obj);
|
||||
[isa insertObject: obj forKey: n];
|
||||
}
|
||||
|
||||
- (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");
|
||||
return;
|
||||
}
|
||||
ctxt_push((id)NSMapGet(gtable, (void *)(uintptr_t)index), opstack);
|
||||
ctxt_push(obj, opstack);
|
||||
}
|
||||
|
||||
- (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");
|
||||
return;
|
||||
}
|
||||
NSMapRemove(gtable, (void *)(uintptr_t)index);
|
||||
[isa removeObjectForKey: index];
|
||||
}
|
||||
|
||||
- (void)DPSclear
|
||||
|
|
Loading…
Reference in a new issue