mirror of
https://github.com/gnustep/libs-back.git
synced 2025-02-22 19:31:19 +00:00
Merge with trunk revision 40072
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/branches/gnustep_testplant_branch@40135 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
ca9fe0459b
commit
66866885ef
9 changed files with 196 additions and 89 deletions
|
@ -69,6 +69,9 @@ typedef enum {
|
|||
NSAffineTransform *textCtm; /* Text transform - concat with ctm */
|
||||
GSTextDrawingMode textMode;
|
||||
BOOL viewIsFlipped;
|
||||
BOOL _antialias;
|
||||
NSPoint _patternPhase;
|
||||
NSCompositingOperation _compositingOperation;
|
||||
}
|
||||
|
||||
- initWithDrawContext: (GSContext *)context;
|
||||
|
@ -80,6 +83,13 @@ typedef enum {
|
|||
- (void) setColor: (device_color_t *)color state: (color_state_t)cState;
|
||||
- (void) GSSetPatterColor: (NSImage*)image;
|
||||
|
||||
- (void) setShouldAntialias: (BOOL)antialias;
|
||||
- (BOOL) shouldAntialias;
|
||||
- (NSPoint) patternPhase;
|
||||
- (void) setPatternPhase: (NSPoint)phase;
|
||||
- (NSCompositingOperation) compositingOperation;
|
||||
- (void) setCompositingOperation:(NSCompositingOperation) operation;
|
||||
|
||||
- (void) compositeGState: (GSGState *)source
|
||||
fromRect: (NSRect)aRect
|
||||
toPoint: (NSPoint)aPoint
|
||||
|
|
|
@ -56,6 +56,12 @@
|
|||
#include <config.h>
|
||||
#include <windows.h>
|
||||
|
||||
/* MINGW64 hack to build */
|
||||
#ifdef __MINGW64__
|
||||
#undef GWL_USERDATA
|
||||
#define GWL_USERDATA GWLP_USERDATA
|
||||
#endif
|
||||
|
||||
/*
|
||||
This standard windows macros are missing in MinGW. The definition
|
||||
here is almost correct, but will fail for multi monitor systems
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
<abstract>Backend server using the X11.</abstract>
|
||||
|
||||
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 2002-2015 Free Software Foundation, Inc.
|
||||
|
||||
Author: Adam Fedor <fedor@gnu.org>
|
||||
Date: Mar 2002
|
||||
|
@ -36,7 +36,7 @@
|
|||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include "x11/XGGeneric.h"
|
||||
#ifdef HAVE_LIBXEXT
|
||||
#ifdef HAVE_X11_EXTENSIONS_SYNC_H
|
||||
#include <X11/extensions/sync.h>
|
||||
#endif
|
||||
/*
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* Window ops for X11 server
|
||||
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
Copyright (C) 1999-2015 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Adam Fedor <fedor@gnu.org>
|
||||
Date: Nov 1999
|
||||
|
@ -117,7 +117,7 @@ typedef struct _gswindow_device_t {
|
|||
void *gdriver; /* gdriver ident. Managed by gdriver */
|
||||
int gdriverProtocol; /* Managed by gdriver */
|
||||
BOOL ignore_take_focus;
|
||||
#ifdef HAVE_LIBXEXT
|
||||
#ifdef HAVE_X11_EXTENSIONS_SYNC_H
|
||||
uint32_t net_wm_sync_request_counter_value_low;
|
||||
uint32_t net_wm_sync_request_counter_value_high;
|
||||
XSyncCounter net_wm_sync_request_counter;
|
||||
|
|
|
@ -723,6 +723,7 @@ static inline cairo_filter_t cairoFilterFromNSImageInterpolation(NSImageInterpol
|
|||
break;
|
||||
}
|
||||
}
|
||||
cairo_set_antialias(_ct, [self shouldAntialias] ? CAIRO_ANTIALIAS_DEFAULT : CAIRO_ANTIALIAS_NONE);
|
||||
}
|
||||
|
||||
- (void) DPSclip
|
||||
|
@ -836,6 +837,7 @@ static inline cairo_filter_t cairoFilterFromNSImageInterpolation(NSImageInterpol
|
|||
|
||||
- (NSDictionary *) GSReadRect: (NSRect)r
|
||||
{
|
||||
static NSDictionary *baseDict = nil;
|
||||
NSMutableDictionary *dict;
|
||||
NSSize ssize;
|
||||
NSAffineTransform *matrix;
|
||||
|
@ -846,10 +848,11 @@ static inline cairo_filter_t cairoFilterFromNSImageInterpolation(NSImageInterpol
|
|||
cairo_surface_t *isurface;
|
||||
cairo_t *ct;
|
||||
cairo_status_t status;
|
||||
int size;
|
||||
int i;
|
||||
int dataSize;
|
||||
NSMutableData *data;
|
||||
unsigned char *cdata;
|
||||
unsigned char *dataBytes;
|
||||
uint32_t *dataPixel;
|
||||
int pixelCounter;
|
||||
|
||||
if (!_ct)
|
||||
{
|
||||
|
@ -863,31 +866,35 @@ static inline cairo_filter_t cairoFilterFromNSImageInterpolation(NSImageInterpol
|
|||
iy = fabs(floor(y));
|
||||
ssize = NSMakeSize(ix, iy);
|
||||
|
||||
dict = [NSMutableDictionary dictionary];
|
||||
[dict setObject: [NSValue valueWithSize: ssize] forKey: @"Size"];
|
||||
[dict setObject: NSDeviceRGBColorSpace forKey: @"ColorSpace"];
|
||||
|
||||
[dict setObject: [NSNumber numberWithUnsignedInt: 8] forKey: @"BitsPerSample"];
|
||||
[dict setObject: [NSNumber numberWithUnsignedInt: 32]
|
||||
forKey: @"Depth"];
|
||||
[dict setObject: [NSNumber numberWithUnsignedInt: 4]
|
||||
forKey: @"SamplesPerPixel"];
|
||||
[dict setObject: [NSNumber numberWithUnsignedInt: 1]
|
||||
forKey: @"HasAlpha"];
|
||||
if (!baseDict)
|
||||
{
|
||||
baseDict = [[NSDictionary dictionaryWithObjectsAndKeys:
|
||||
NSDeviceRGBColorSpace, @"ColorSpace",
|
||||
[NSNumber numberWithUnsignedInt: 8], @"BitsPerSample",
|
||||
[NSNumber numberWithUnsignedInt: 32], @"Depth",
|
||||
[NSNumber numberWithUnsignedInt: 4], @"SamplesPerPixel",
|
||||
[NSNumber numberWithUnsignedInt: 1], @"HasAlpha",
|
||||
nil]
|
||||
retain];
|
||||
}
|
||||
|
||||
dict = [NSMutableDictionary dictionaryWithDictionary: baseDict];
|
||||
|
||||
[dict setObject: [NSValue valueWithSize: ssize] forKey: @"Size"];
|
||||
|
||||
matrix = [self GSCurrentCTM];
|
||||
[matrix translateXBy: -r.origin.x - offset.x
|
||||
yBy: r.origin.y + NSHeight(r) - offset.y];
|
||||
[dict setObject: matrix forKey: @"Matrix"];
|
||||
|
||||
size = ix*iy*4;
|
||||
data = [NSMutableData dataWithLength: size];
|
||||
dataSize = ix*iy*4;
|
||||
data = [NSMutableData dataWithLength: dataSize];
|
||||
if (data == nil)
|
||||
return nil;
|
||||
cdata = [data mutableBytes];
|
||||
dataBytes = [data mutableBytes];
|
||||
|
||||
surface = cairo_get_target(_ct);
|
||||
isurface = cairo_image_surface_create_for_data(cdata, format, ix, iy, 4*ix);
|
||||
isurface = cairo_image_surface_create_for_data(dataBytes, format, ix, iy, 4*ix);
|
||||
status = cairo_surface_status(isurface);
|
||||
if (status != CAIRO_STATUS_SUCCESS)
|
||||
{
|
||||
|
@ -919,21 +926,24 @@ static inline cairo_filter_t cairoFilterFromNSImageInterpolation(NSImageInterpol
|
|||
cairo_destroy(ct);
|
||||
cairo_surface_destroy(isurface);
|
||||
|
||||
for (i = 0; i < 4 * ix * iy; i += 4)
|
||||
{
|
||||
unsigned char d = cdata[i];
|
||||
dataPixel = (uint32_t *) dataBytes;
|
||||
|
||||
pixelCounter = ix * iy;
|
||||
|
||||
while (pixelCounter--)
|
||||
{
|
||||
#if GS_WORDS_BIGENDIAN
|
||||
cdata[i] = cdata[i + 1];
|
||||
cdata[i + 1] = cdata[i + 2];
|
||||
cdata[i + 2] = cdata[i + 3];
|
||||
cdata[i + 3] = d;
|
||||
// ARGB -> RGBA
|
||||
*dataPixel = (*dataPixel << 8) // ARGB -> RGB_
|
||||
| (*dataPixel >> 24); // ARGB -> ___A
|
||||
#else
|
||||
cdata[i] = cdata[i + 2];
|
||||
//cdata[i + 1] = cdata[i + 1];
|
||||
cdata[i + 2] = d;
|
||||
//cdata[i + 3] = cdata[i + 3];
|
||||
// ARGB -> ABGR
|
||||
*dataPixel = ((*dataPixel & 0x000000FF) << 16) // ___B -> _B__
|
||||
| ((*dataPixel & 0x00FF0000) >> 16) // _R__ -> ___R
|
||||
| (*dataPixel & 0xFF00FF00); // A_G_ -> A_G_
|
||||
#endif
|
||||
|
||||
dataPixel++;
|
||||
}
|
||||
|
||||
[dict setObject: data forKey: @"Data"];
|
||||
|
@ -1016,12 +1026,9 @@ _set_op(cairo_t *ct, NSCompositingOperation op)
|
|||
cairo_format_t format;
|
||||
NSAffineTransformStruct tstruct;
|
||||
cairo_surface_t *surface;
|
||||
unsigned char *tmp = NULL;
|
||||
int i = 0;
|
||||
int j;
|
||||
int index;
|
||||
unsigned int pixels = pixelsHigh * pixelsWide;
|
||||
unsigned char *rowData;
|
||||
unsigned char *dataRow, *reformattedData;
|
||||
int reformattedDataSize, rowCounter, columnCounter;
|
||||
uint32_t *reformattedDataPixel;
|
||||
cairo_matrix_t local_matrix;
|
||||
cairo_status_t status;
|
||||
|
||||
|
@ -1054,73 +1061,78 @@ _set_op(cairo_t *ct, NSCompositingOperation op)
|
|||
while ((bytesPerRow * 8) < (bitsPerPixel * pixelsWide))
|
||||
bytesPerRow++;
|
||||
|
||||
reformattedDataSize = pixelsWide * pixelsHigh * sizeof(*reformattedDataPixel);
|
||||
|
||||
switch (bitsPerPixel)
|
||||
{
|
||||
case 32:
|
||||
tmp = malloc(pixels * 4);
|
||||
if (!tmp)
|
||||
reformattedData = malloc(reformattedDataSize);
|
||||
if (!reformattedData)
|
||||
{
|
||||
NSLog(@"Could not allocate drawing space for image");
|
||||
return;
|
||||
}
|
||||
|
||||
rowData = (unsigned char *)data[0];
|
||||
index = 0;
|
||||
dataRow = (unsigned char *)data[0];
|
||||
reformattedDataPixel = (uint32_t *) reformattedData;
|
||||
|
||||
for (i = 0; i < pixelsHigh; i++)
|
||||
rowCounter = pixelsHigh;
|
||||
|
||||
while (rowCounter--)
|
||||
{
|
||||
unsigned char *d = rowData;
|
||||
uint32_t *dataPixel = (uint32_t *) dataRow;
|
||||
|
||||
for (j = 0; j < pixelsWide; j++)
|
||||
columnCounter = pixelsWide;
|
||||
|
||||
while (columnCounter--)
|
||||
{
|
||||
#if GS_WORDS_BIGENDIAN
|
||||
tmp[index++] = d[3];
|
||||
tmp[index++] = d[0];
|
||||
tmp[index++] = d[1];
|
||||
tmp[index++] = d[2];
|
||||
// RGBA (uint32) -> ARGB (uint32)
|
||||
*reformattedDataPixel++ = (*dataPixel >> 8) // RGBA -> _RGB
|
||||
| (*dataPixel << 24); // RGBA -> A___
|
||||
#else
|
||||
tmp[index++] = d[2];
|
||||
tmp[index++] = d[1];
|
||||
tmp[index++] = d[0];
|
||||
tmp[index++] = d[3];
|
||||
// ABGR (uint32) -> ARGB (uint32)
|
||||
*reformattedDataPixel++ = ((*dataPixel & 0x000000FF) << 16) // ___R -> _R__
|
||||
| ((*dataPixel & 0x00FF0000) >> 16) // _B__ -> ___B
|
||||
| (*dataPixel & 0xFF00FF00); // A_G_ -> A_G_
|
||||
#endif
|
||||
d += 4;
|
||||
dataPixel++;
|
||||
}
|
||||
rowData += bytesPerRow;
|
||||
|
||||
dataRow += bytesPerRow;
|
||||
}
|
||||
format = CAIRO_FORMAT_ARGB32;
|
||||
break;
|
||||
case 24:
|
||||
tmp = malloc(pixels * 4);
|
||||
if (!tmp)
|
||||
reformattedData = malloc(reformattedDataSize);
|
||||
if (!reformattedData)
|
||||
{
|
||||
NSLog(@"Could not allocate drawing space for image");
|
||||
return;
|
||||
}
|
||||
|
||||
rowData = (unsigned char *)data[0];
|
||||
index = 0;
|
||||
dataRow = (unsigned char *)data[0];
|
||||
reformattedDataPixel = (uint32_t *) reformattedData;
|
||||
|
||||
for (i = 0; i < pixelsHigh; i++)
|
||||
rowCounter = pixelsHigh;
|
||||
|
||||
while (rowCounter--)
|
||||
{
|
||||
unsigned char *d = rowData;
|
||||
unsigned char *dataPixelComponent = dataRow;
|
||||
|
||||
for (j = 0; j < pixelsWide; j++)
|
||||
columnCounter = pixelsWide;
|
||||
|
||||
while (columnCounter--)
|
||||
{
|
||||
#if GS_WORDS_BIGENDIAN
|
||||
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;
|
||||
#endif
|
||||
d += 3;
|
||||
// R,G,B (uchar[0-2]) -> _RGB (uint32)
|
||||
*reformattedDataPixel++ = (((uint32_t) dataPixelComponent[0]) << 16) // R -> _R__
|
||||
| (((uint32_t) dataPixelComponent[1]) << 8) // G -> __G_
|
||||
| ((uint32_t) dataPixelComponent[2]); // B -> ___B
|
||||
|
||||
dataPixelComponent += 3;
|
||||
}
|
||||
rowData += bytesPerRow;
|
||||
|
||||
dataRow += bytesPerRow;
|
||||
}
|
||||
format = CAIRO_FORMAT_RGB24;
|
||||
break;
|
||||
|
@ -1129,18 +1141,18 @@ _set_op(cairo_t *ct, NSCompositingOperation op)
|
|||
return;
|
||||
}
|
||||
|
||||
surface = cairo_image_surface_create_for_data((void*)tmp,
|
||||
surface = cairo_image_surface_create_for_data((void*)reformattedData,
|
||||
format,
|
||||
pixelsWide,
|
||||
pixelsHigh,
|
||||
pixelsWide * 4);
|
||||
pixelsWide * sizeof(*reformattedDataPixel));
|
||||
status = cairo_surface_status(surface);
|
||||
if (status != CAIRO_STATUS_SUCCESS)
|
||||
{
|
||||
NSLog(@"Cairo status '%s' in DPSimage", cairo_status_to_string(status));
|
||||
if (tmp)
|
||||
if (reformattedData)
|
||||
{
|
||||
free(tmp);
|
||||
free(reformattedData);
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -1190,9 +1202,9 @@ _set_op(cairo_t *ct, NSCompositingOperation op)
|
|||
cairo_surface_destroy(surface);
|
||||
cairo_restore(_ct);
|
||||
|
||||
if (tmp)
|
||||
if (reformattedData)
|
||||
{
|
||||
free(tmp);
|
||||
free(reformattedData);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -209,6 +209,12 @@ static NSMapTable *gtable;
|
|||
gstate = [[[object_getClass(self) GStateClass] allocWithZone: z]
|
||||
initWithDrawContext: self];
|
||||
|
||||
// Set some default values
|
||||
[self setShouldAntialias: YES];
|
||||
[self setImageInterpolation: NSImageInterpolationNone];
|
||||
[self setPatternPhase: NSMakePoint(0.0, 0.0)];
|
||||
[self setCompositingOperation: NSCompositeSourceOver];
|
||||
|
||||
// Special handling for window drawing
|
||||
dest = [info objectForKey: NSGraphicsContextDestinationAttributeName];
|
||||
if ((dest != nil) && [dest isKindOfClass: [NSWindow class]])
|
||||
|
@ -254,6 +260,36 @@ static NSMapTable *gtable;
|
|||
return gstate;
|
||||
}
|
||||
|
||||
- (void) setShouldAntialias: (BOOL)antialias
|
||||
{
|
||||
[gstate setShouldAntialias: antialias];
|
||||
}
|
||||
|
||||
- (BOOL) shouldAntialias
|
||||
{
|
||||
return [gstate shouldAntialias];
|
||||
}
|
||||
|
||||
- (NSPoint) patternPhase
|
||||
{
|
||||
return [gstate patternPhase];
|
||||
}
|
||||
|
||||
- (void) setPatternPhase: (NSPoint)phase
|
||||
{
|
||||
[gstate setPatternPhase: phase];
|
||||
}
|
||||
|
||||
- (NSCompositingOperation) compositingOperation
|
||||
{
|
||||
return [gstate compositingOperation];
|
||||
}
|
||||
|
||||
- (void) setCompositingOperation: (NSCompositingOperation)operation
|
||||
{
|
||||
[gstate setCompositingOperation: operation];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation GSContext (Ops)
|
||||
|
|
|
@ -143,6 +143,36 @@
|
|||
ASSIGN(pattern, image);
|
||||
}
|
||||
|
||||
- (void) setShouldAntialias: (BOOL)antialias
|
||||
{
|
||||
_antialias = antialias;
|
||||
}
|
||||
|
||||
- (BOOL) shouldAntialias
|
||||
{
|
||||
return _antialias;
|
||||
}
|
||||
|
||||
- (NSPoint) patternPhase
|
||||
{
|
||||
return _patternPhase;
|
||||
}
|
||||
|
||||
- (void) setPatternPhase: (NSPoint)phase
|
||||
{
|
||||
_patternPhase = phase;
|
||||
}
|
||||
|
||||
- (NSCompositingOperation) compositingOperation
|
||||
{
|
||||
return _compositingOperation;
|
||||
}
|
||||
|
||||
- (void) setCompositingOperation: (NSCompositingOperation)operation
|
||||
{
|
||||
_compositingOperation = operation;
|
||||
}
|
||||
|
||||
// This is only a fall back, the method should not be called any more.
|
||||
- (void) compositeGState: (GSGState *)source
|
||||
fromRect: (NSRect)aRect
|
||||
|
@ -1285,7 +1315,7 @@ typedef enum {
|
|||
[ictm invert];
|
||||
|
||||
size = [color_pattern size];
|
||||
patternPhase = [drawcontext patternPhase];
|
||||
patternPhase = [self patternPhase];
|
||||
|
||||
if (!NSEqualPoints(patternPhase, NSZeroPoint))
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* -*-objc-*-
|
||||
GSStreamContext - Drawing context to a stream.
|
||||
|
||||
Copyright (C) 1995, 2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 1995-2016 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Adam Fedor <fedor@gnu.org>
|
||||
Date: Nov 1995
|
||||
|
@ -34,6 +34,7 @@
|
|||
#include <AppKit/NSBezierPath.h>
|
||||
#include <AppKit/NSView.h>
|
||||
#include <AppKit/NSBitmapImageRep.h>
|
||||
#import <AppKit/NSFontDescriptor.h>
|
||||
#include <Foundation/NSArray.h>
|
||||
#include <Foundation/NSData.h>
|
||||
#include <Foundation/NSDebug.h>
|
||||
|
@ -264,8 +265,14 @@ fpfloat(FILE *stream, float f)
|
|||
- (void) GSSetFont: (void *)fontref
|
||||
{
|
||||
const CGFloat *m = [(GSFontInfo *)fontref matrix];
|
||||
fprintf(gstream, "/%s findfont ",
|
||||
[[(GSFontInfo *)fontref fontName] cString]);
|
||||
NSString *postscriptName;
|
||||
|
||||
postscriptName = [[(GSFontInfo *)fontref fontDescriptor] postscriptName];
|
||||
if (nil == postscriptName)
|
||||
{
|
||||
postscriptName = [(GSFontInfo *)fontref fontName];
|
||||
}
|
||||
fprintf(gstream, "/%s findfont ", [postscriptName cString]);
|
||||
fprintf(gstream, "[");
|
||||
fpfloat(gstream, m[0]);
|
||||
fpfloat(gstream, m[1]);
|
||||
|
|
12
config.h.in
12
config.h.in
|
@ -53,9 +53,6 @@
|
|||
/* Define to 1 if you have the `Xt' library (-lXt). */
|
||||
#undef HAVE_LIBXT
|
||||
|
||||
/* Define to 1 if you have the `shape' extension. */
|
||||
#undef HAVE_XSHAPE
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#undef HAVE_MEMORY_H
|
||||
|
||||
|
@ -98,6 +95,12 @@
|
|||
/* Define if you have the wgl library */
|
||||
#undef HAVE_WGL
|
||||
|
||||
/* Define to 1 if you have the <X11/extensions/shape.h> header file. */
|
||||
#undef HAVE_X11_EXTENSIONS_SHAPE_H
|
||||
|
||||
/* Define to 1 if you have the <X11/extensions/sync.h> header file. */
|
||||
#undef HAVE_X11_EXTENSIONS_SYNC_H
|
||||
|
||||
/* Define to 1 if you have the <X11/extensions/XShm.h> header file. */
|
||||
#undef HAVE_X11_EXTENSIONS_XSHM_H
|
||||
|
||||
|
@ -114,6 +117,9 @@
|
|||
/* Define to 1 if you have 'XInternAtoms' function. */
|
||||
#undef HAVE_XINTERNATOMS
|
||||
|
||||
/* Define to enable Xshape support */
|
||||
#undef HAVE_XSHAPE
|
||||
|
||||
/* Define to 1 if you have the `Xutf8LookupString' function. */
|
||||
#undef HAVE_XUTF8LOOKUPSTRING
|
||||
|
||||
|
|
Loading…
Reference in a new issue