Merged Trunk changes from rev 35217 to TestPlant branch.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/branches/gnustep_testplant_branch@36952 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Frank Le Grand 2013-08-09 14:21:15 +00:00
parent 36d045cf0a
commit 1b82d912b5
60 changed files with 2794 additions and 905 deletions

View file

@ -1,3 +1,10 @@
2013-08-08 Frank Le Grand <frank.legrand@testplant.com>
Merged changes from Trunk (since rev 35217) to TestPlant branch.
Some files were partially merged to pull changes from Trunk and
remain with large numbers of diffs (Source/win32/WIN32Server.m,
Source/cairo/Win32CairoSurface.m, Source/cairo/CairoContext.m)
2013-01-10 Doug Simons <doug.simons@testplant.com>
* Source/win32/w32_general.m : Fix a bug that could cause a modal run loop to

View file

@ -7,14 +7,20 @@
@include version.texi
@end ifset
@section Noteworthy changes in version @samp{0.23.0}
Added cairo support for ms-windows.
Updated for NSInteger/CGFloat support
@ifclear ANNOUNCE-ONLY
@section Noteworthy changes in version @samp{0.22.0}
Added new user defaults to make app icons and mini windows sticky (omnipresent)
Many improvements to Cairo rendering, including buffering, glyphs and DPI scaling.
@ifclear ANNOUNCE-ONLY
@section Noteworthy changes in version @samp{0.20.0}
Cairo is now the default backend, but falls back to art and xlib gracefully.

View file

@ -38,7 +38,7 @@
CairoSurface *_surface;
}
- (void) GSCurrentSurface: (CairoSurface **)surface: (int *)x : (int *)y;
- (void) GSCurrentSurface: (CairoSurface **)surface : (int *)x : (int *)y;
- (void) GSSetSurface: (CairoSurface *)surface : (int)x : (int)y;
- (void) showPage;

View file

@ -65,7 +65,7 @@ typedef enum {
color_state_t cstate; /* state last time color was set */
NSImage *pattern; /* If set, image to draw with */
float charSpacing;
CGFloat charSpacing;
NSAffineTransform *textCtm; /* Text transform - concat with ctm */
GSTextDrawingMode textMode;
BOOL viewIsFlipped;
@ -88,13 +88,13 @@ typedef enum {
- (void) dissolveGState: (GSGState *)source
fromRect: (NSRect)aRect
toPoint: (NSPoint)aPoint
delta: (float)delta;
delta: (CGFloat)delta;
- (void) compositeGState: (GSGState *)source
fromRect: (NSRect)aRect
toPoint: (NSPoint)aPoint
op: (NSCompositingOperation)op
fraction: (float)delta;
fraction: (CGFloat)delta;
- (void) compositerect: (NSRect)aRect
op: (NSCompositingOperation)op;
@ -112,7 +112,7 @@ graphics state with arbitrary transforms on the current graphics context. */
fromRect: (NSRect)aRect
toPoint: (NSPoint)aPoint
op: (NSCompositingOperation)op
fraction: (float)delta;
fraction: (CGFloat)delta;
@end
#include "GSGStateOps.h"

View file

@ -33,16 +33,16 @@
/* ----------------------------------------------------------------------- */
/* Color operations */
/* ----------------------------------------------------------------------- */
- (void) DPScurrentalpha: (float*)a;
- (void) DPScurrentcmykcolor: (float*)c : (float*)m : (float*)y : (float*)k;
- (void) DPScurrentgray: (float*)gray;
- (void) DPScurrenthsbcolor: (float*)h : (float*)s : (float*)b;
- (void) DPScurrentrgbcolor: (float*)r : (float*)g : (float*)b;
- (void) DPSsetalpha: (float)a;
- (void) DPSsetcmykcolor: (float)c : (float)m : (float)y : (float)k;
- (void) DPSsetgray: (float)gray;
- (void) DPSsethsbcolor: (float)h : (float)s : (float)b;
- (void) DPSsetrgbcolor: (float)r : (float)g : (float)b;
- (void) DPScurrentalpha: (CGFloat*)a;
- (void) DPScurrentcmykcolor: (CGFloat*)c : (CGFloat*)m : (CGFloat*)y : (CGFloat*)k;
- (void) DPScurrentgray: (CGFloat*)gray;
- (void) DPScurrenthsbcolor: (CGFloat*)h : (CGFloat*)s : (CGFloat*)b;
- (void) DPScurrentrgbcolor: (CGFloat*)r : (CGFloat*)g : (CGFloat*)b;
- (void) DPSsetalpha: (CGFloat)a;
- (void) DPSsetcmykcolor: (CGFloat)c : (CGFloat)m : (CGFloat)y : (CGFloat)k;
- (void) DPSsetgray: (CGFloat)gray;
- (void) DPSsethsbcolor: (CGFloat)h : (CGFloat)s : (CGFloat)b;
- (void) DPSsetrgbcolor: (CGFloat)r : (CGFloat)g : (CGFloat)b;
- (void) GSSetFillColorspace: (void *)spaceref;
- (void) GSSetStrokeColorspace: (void *)spaceref;
@ -52,21 +52,21 @@
/* ----------------------------------------------------------------------- */
/* Text operations */
/* ----------------------------------------------------------------------- */
- (void) DPSashow: (float)x : (float)y : (const char*)s;
- (void) DPSawidthshow: (float)cx : (float)cy : (int)c : (float)ax : (float)ay
: (const char*)s;
- (void) DPSashow: (CGFloat)x : (CGFloat)y : (const char*)s;
- (void) DPSawidthshow: (CGFloat)cx : (CGFloat)cy : (int)c
: (CGFloat)ax : (CGFloat)ay : (const char*)s;
- (void) DPScharpath: (const char*)s : (int)b;
- (void) appendBezierPathWithPackedGlyphs: (const char *)packedGlyphs
path: (NSBezierPath*)aPath;
- (void) DPSshow: (const char*)s;
- (void) DPSwidthshow: (float)x : (float)y : (int)c : (const char*)s;
- (void) DPSxshow: (const char*)s : (const float*)numarray : (int)size;
- (void) DPSxyshow: (const char*)s : (const float*)numarray : (int)size;
- (void) DPSyshow: (const char*)s : (const float*)numarray : (int)size;
- (void) DPSwidthshow: (CGFloat)x : (CGFloat)y : (int)c : (const char*)s;
- (void) DPSxshow: (const char*)s : (const CGFloat*)numarray : (int)size;
- (void) DPSxyshow: (const char*)s : (const CGFloat*)numarray : (int)size;
- (void) DPSyshow: (const char*)s : (const CGFloat*)numarray : (int)size;
- (void) GSSetCharacterSpacing: (float)extra;
- (void) GSSetCharacterSpacing: (CGFloat)extra;
- (void) GSSetFont: (GSFontInfo *)fontref;
- (void) GSSetFontSize: (float)size;
- (void) GSSetFontSize: (CGFloat)size;
- (NSAffineTransform *) GSGetTextCTM;
- (NSPoint) GSGetTextPosition;
- (void) GSSetTextCTM: (NSAffineTransform *)ctm;
@ -81,29 +81,29 @@
/* ----------------------------------------------------------------------- */
- (void) DPSinitgraphics;
- (void) DPScurrentflat: (float*)flatness;
- (void) DPScurrentflat: (CGFloat*)flatness;
- (void) DPScurrentlinecap: (int*)linecap;
- (void) DPScurrentlinejoin: (int*)linejoin;
- (void) DPScurrentlinewidth: (float*)width;
- (void) DPScurrentmiterlimit: (float*)limit;
- (void) DPScurrentpoint: (float*)x : (float*)y;
- (void) DPScurrentlinewidth: (CGFloat*)width;
- (void) DPScurrentmiterlimit: (CGFloat*)limit;
- (void) DPScurrentpoint: (CGFloat*)x : (CGFloat*)y;
- (void) DPScurrentstrokeadjust: (int*)b;
- (void) DPSsetdash: (const float*)pat : (int)size : (float)offset;
- (void) DPSsetflat: (float)flatness;
- (void) DPSsetdash: (const CGFloat*)pat : (NSInteger)size : (CGFloat)offset;
- (void) DPSsetflat: (CGFloat)flatness;
- (void) DPSsetlinecap: (int)linecap;
- (void) DPSsetlinejoin: (int)linejoin;
- (void) DPSsetlinewidth: (float)width;
- (void) DPSsetmiterlimit: (float)limit;
- (void) DPSsetlinewidth: (CGFloat)width;
- (void) DPSsetmiterlimit: (CGFloat)limit;
- (void) DPSsetstrokeadjust: (int)b;
/* ----------------------------------------------------------------------- */
/* Matrix operations */
/* ----------------------------------------------------------------------- */
- (void) DPSconcat: (const float*)m;
- (void) DPSconcat: (const CGFloat*)m;
- (void) DPSinitmatrix;
- (void) DPSrotate: (float)angle;
- (void) DPSscale: (float)x : (float)y;
- (void) DPStranslate: (float)x : (float)y;
- (void) DPSrotate: (CGFloat)angle;
- (void) DPSscale: (CGFloat)x : (CGFloat)y;
- (void) DPStranslate: (CGFloat)x : (CGFloat)y;
- (NSAffineTransform *) GSCurrentCTM;
- (void) GSSetCTM: (NSAffineTransform *)ctm;
@ -114,32 +114,32 @@
/* ----------------------------------------------------------------------- */
- (NSPoint) currentPoint;
- (void) DPSarc: (float)x : (float)y : (float)r : (float)angle1
: (float)angle2;
- (void) DPSarcn: (float)x : (float)y : (float)r : (float)angle1
: (float)angle2;
- (void) DPSarct: (float)x1 : (float)y1 : (float)x2 : (float)y2 : (float)r;
- (void) DPSarc: (CGFloat)x : (CGFloat)y : (CGFloat)r : (CGFloat)angle1
: (CGFloat)angle2;
- (void) DPSarcn: (CGFloat)x : (CGFloat)y : (CGFloat)r : (CGFloat)angle1
: (CGFloat)angle2;
- (void) DPSarct: (CGFloat)x1 : (CGFloat)y1 : (CGFloat)x2 : (CGFloat)y2 : (CGFloat)r;
- (void) DPSclip;
- (void) DPSclosepath;
- (void) DPScurveto: (float)x1 : (float)y1 : (float)x2 : (float)y2
: (float)x3 : (float)y3;
- (void) DPScurveto: (CGFloat)x1 : (CGFloat)y1 : (CGFloat)x2 : (CGFloat)y2
: (CGFloat)x3 : (CGFloat)y3;
- (void) DPSeoclip;
- (void) DPSeofill;
- (void) DPSfill;
- (void) DPSflattenpath;
- (void) DPSinitclip;
- (void) DPSlineto: (float)x : (float)y;
- (void) DPSmoveto: (float)x : (float)y;
- (void) DPSlineto: (CGFloat)x : (CGFloat)y;
- (void) DPSmoveto: (CGFloat)x : (CGFloat)y;
- (void) DPSnewpath;
- (void) DPSpathbbox: (float*)llx : (float*)lly : (float*)urx : (float*)ury;
- (void) DPSrcurveto: (float)x1 : (float)y1 : (float)x2 : (float)y2
: (float)x3 : (float)y3;
- (void) DPSrectclip: (float)x : (float)y : (float)w : (float)h;
- (void) DPSrectfill: (float)x : (float)y : (float)w : (float)h;
- (void) DPSrectstroke: (float)x : (float)y : (float)w : (float)h;
- (void) DPSpathbbox: (CGFloat*)llx : (CGFloat*)lly : (CGFloat*)urx : (CGFloat*)ury;
- (void) DPSrcurveto: (CGFloat)x1 : (CGFloat)y1 : (CGFloat)x2 : (CGFloat)y2
: (CGFloat)x3 : (CGFloat)y3;
- (void) DPSrectclip: (CGFloat)x : (CGFloat)y : (CGFloat)w : (CGFloat)h;
- (void) DPSrectfill: (CGFloat)x : (CGFloat)y : (CGFloat)w : (CGFloat)h;
- (void) DPSrectstroke: (CGFloat)x : (CGFloat)y : (CGFloat)w : (CGFloat)h;
- (void) DPSreversepath;
- (void) DPSrlineto: (float)x : (float)y;
- (void) DPSrmoveto: (float)x : (float)y;
- (void) DPSrlineto: (CGFloat)x : (CGFloat)y;
- (void) DPSrmoveto: (CGFloat)x : (CGFloat)y;
- (void) DPSstroke;
- (void) GSSendBezierPath: (NSBezierPath *)path;
@ -149,9 +149,9 @@
- (NSDictionary *) GSReadRect: (NSRect)rect;
- (void)DPSimage: (NSAffineTransform*) matrix
: (int) pixelsWide : (int) pixelsHigh
: (int) bitsPerSample : (int) samplesPerPixel
: (int) bitsPerPixel : (int) bytesPerRow : (BOOL) isPlanar
: (NSInteger) pixelsWide : (NSInteger) pixelsHigh
: (NSInteger) bitsPerSample : (NSInteger) samplesPerPixel
: (NSInteger) bitsPerPixel : (NSInteger) bytesPerRow : (BOOL) isPlanar
: (BOOL) hasAlpha : (NSString *) colorSpaceName
: (const unsigned char *const [5]) data;

View file

@ -33,8 +33,8 @@
{
@public
int clinecap, clinejoin;
float clinewidth, cmiterlimit;
float cstrokeadjust;
CGFloat clinewidth, cmiterlimit;
CGFloat cstrokeadjust;
}
@end

View file

@ -1,10 +1,11 @@
/*
Win32CairoGState.m
OpalContext.h
Copyright (C) 2003 Free Software Foundation, Inc.
Copyright (C) 2013 Free Software Foundation, Inc.
Author: Ivan Vucica <ivan@vucica.net>
Date: June 2013
August 8, 2012
This file is part of GNUstep.
This library is free software; you can redistribute it and/or
@ -24,37 +25,21 @@
Boston, MA 02110-1301, USA.
*/
#include "cairo/Win32CairoGState.h"
#include "cairo/CairoSurface.h"
#include <cairo-win32.h>
#ifndef OpalContext_h_defined
#define OpalContext_h_defined
@implementation Win32CairoGState
#import "gsc/GSContext.h"
+ (void) initialize
@interface OpalContext : GSContext
{
if (self == [Win32CairoGState class])
{
}
}
- (HDC) getHDC
{
if (_surface)
{
cairo_surface_flush([_surface surface]);
NSDebugLLog(@"CairoGState",
@"%s:_surface: %p hdc: %p\n", __PRETTY_FUNCTION__,
_surface, cairo_win32_surface_get_dc([_surface surface]));
return cairo_win32_surface_get_dc([_surface surface]);
}
NSLog(@"%s:_surface is NULL\n", __PRETTY_FUNCTION__);
return NULL;
}
- (void) releaseHDC: (HDC)hdc
{
if (hdc && _surface)
cairo_surface_mark_dirty([_surface surface]);
}
+ (void) initializeBackend;
+ (Class) GStateClass;
- (void) GSSetDevice: (void *)device
: (int)x
: (int)y;
@end
#endif

View file

@ -1,5 +1,10 @@
/*
Copyright (C) 2004 Free Software Foundation, Inc.
OpalFontEnumerator.h
Copyright (C) 2013 Free Software Foundation, Inc.
Author: Ivan Vucica <ivan@vucica.net>
Date: June 2013
This file is part of GNUstep.
@ -20,19 +25,19 @@
Boston, MA 02110-1301, USA.
*/
#ifndef Win32CairoGState_h
#define Win32CairoGState_h
#ifndef OpalFontEnumerator_h_defined
#define OpalFontEnumerator_h_defined
#include "cairo/CairoGState.h"
#import <GNUstepGUI/GSFontInfo.h>
@interface Win32CairoGState : CairoGState
@interface OpalFontEnumerator : GSFontEnumerator
{
}
- (HDC) getHDC;
- (void) releaseHDC: (HDC)hdc;
- (void) enumerateFontsAndFamilies;
@end
#endif

View file

@ -0,0 +1,45 @@
/*
OpalFontInfo.h
Copyright (C) 2013 Free Software Foundation, Inc.
Author: Ivan Vucica <ivan@vucica.net>
Date: June 2013
This file is part of GNUstep.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; see the file COPYING.LIB.
If not, see <http://www.gnu.org/licenses/> or write to the
Free Software Foundation, 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef OpalFontInfo_h_defined
#define OpalFontInfo_h_defined
#import <GNUstepGUI/GSFontInfo.h>
@interface OpalFontInfo : GSFontInfo
{
}
- (id) initWithFontName: (NSString *)name
matrix: (const CGFloat *)fmatrix
screenFont: (BOOL)p_screenFont;
@end
#endif

66
Headers/opal/OpalGState.h Normal file
View file

@ -0,0 +1,66 @@
/*
OpalGState.h
Copyright (C) 2013 Free Software Foundation, Inc.
Author: Ivan Vucica <ivan@vucica.net>
Date: June 2013
This file is part of GNUstep.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; see the file COPYING.LIB.
If not, see <http://www.gnu.org/licenses/> or write to the
Free Software Foundation, 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#import "gsc/GSGState.h"
@class OpalSurface;
@interface OpalGState : GSGState
{
OpalSurface * _opalSurface;
}
- (void) DPSinitclip;
- (void) DPSinitgraphics;
- (void) DPSclip;
- (void) DPSfill;
- (void) DPSimage: (NSAffineTransform *)matrix
: (NSInteger)pixelsWide
: (NSInteger)pixelsHigh
: (NSInteger)bitsPerSample
: (NSInteger)samplesPerPixel
: (NSInteger)bitsPerPixel
: (NSInteger)bytesPerRow
: (BOOL)isPlanar
: (BOOL)hasAlpha
: (NSString *)colorSpaceName
: (const unsigned char *const[5])data;
- (void) compositeGState: (OpalGState *)source
fromRect: (NSRect)srcRect
toPoint: (NSPoint)destPoint
op: (NSCompositingOperation)op
fraction: (CGFloat)delta;
- (void) compositerect: (NSRect)aRect
op: (NSCompositingOperation)op;
- (void) GSSetSurface: (OpalSurface *)opalSurface
: (int)x
: (int)y;
@end
@interface OpalGState (Accessors)
- (CGContextRef) cgContext;
@end

View file

@ -0,0 +1,48 @@
/*
OpalSurface.h
Copyright (C) 2013 Free Software Foundation, Inc.
Author: Ivan Vucica <ivan@vucica.net>
Date: June 2013
This file is part of GNUstep.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; see the file COPYING.LIB.
If not, see <http://www.gnu.org/licenses/> or write to the
Free Software Foundation, 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#import <Foundation/Foundation.h>
#import <CoreGraphics/CoreGraphics.h>
@interface OpalSurface : NSObject
{
struct _gswindow_device_t * _gsWindowDevice;
CGContextRef _backingCGContext;
CGContextRef _x11CGContext;
}
- (id) initWithDevice: (void *)device;
- (struct _gswindow_device_t *) device;
- (CGContextRef) cgContext;
- (void) createCGContexts;
@end
@interface OpalSurface (DebugExtensions)
- (void) dummyDraw;
@end

View file

@ -76,10 +76,11 @@
DWORD windowStyleForGSStyle(unsigned int style);
typedef struct w32serverFlags {
BOOL HOLD_MINI_FOR_SIZE; // override GS size event on miniturize
BOOL _eventHandled; // did we handle the event?
} serverFlags;
typedef struct w32serverFlags
{
BOOL HOLD_MINI_FOR_SIZE; // override GS size event on miniturize
BOOL _eventHandled; // did we handle the event?
} serverFlags;
@interface WIN32Server : GSDisplayServer
{

View file

@ -58,9 +58,14 @@
{
Display * display;
long int glxminorversion;
GLXFBConfig *fbconfig;
XVisualInfo *visualinfo;
int pickedFBConfig;
int configurationCount;
BOOL shouldRequestARGBVisual;
XVisualInfo *visualinfo;
}
+ (int) glxMinorVersion;

View file

@ -37,14 +37,15 @@ ADDITIONAL_CPPFLAGS += -Wall
ADDITIONAL_CFLAGS +=
# Additional include directories the compiler should search
ADDITIONAL_INCLUDE_DIRS += -I../Headers \
-I$(GNUSTEP_TARGET_DIR) $(GRAPHIC_CFLAGS)
ADDITIONAL_INCLUDE_DIRS += -I../Headers -I$(GNUSTEP_TARGET_DIR)
CONFIG_SYSTEM_INCL += $(GRAPHIC_CFLAGS)
# Additional LDFLAGS to pass to the linker
#ADDITIONAL_LDFLAGS +=
# Additional library directories the linker should search
ADDITIONAL_LIB_DIRS += $(GRAPHIC_LFLAGS)
#ADDITIONAL_LIB_DIRS +=
CONFIG_SYSTEM_LIB_DIR += $(GRAPHIC_LFLAGS)
#
# Flags for compiling as a bundle or library (if the system depends

View file

@ -87,6 +87,8 @@
context = @"WIN32Context";
#elif (BUILD_GRAPHICS==GRAPHICS_cairo)
context = @"CairoContext";
#elif (BUILD_GRAPHICS==GRAPHICS_opal)
context = @"OpalContext";
#else
#error INVALID build graphics type
#endif

View file

@ -26,6 +26,8 @@
#include <Foundation/NSDebug.h>
#include <Foundation/NSDictionary.h>
#include <Foundation/NSUserDefaults.h>
#include <AppKit/NSBitmapImageRep.h>
#include <AppKit/NSGraphics.h>
#include "ARTGState.h"
#include "blit.h"
@ -100,6 +102,49 @@
[(XWindowBuffer *)driver _exposeRect: rect];
}
- (BOOL) isCompatibleBitmap: (NSBitmapImageRep*)bitmap
{
NSString *colorSpaceName;
int numColors;
if ([bitmap bitmapFormat] != 0)
{
return NO;
}
if (([bitmap bitsPerSample] > 8) &&
([bitmap bitsPerSample] != 16))
{
return NO;
}
numColors = [bitmap samplesPerPixel] - ([bitmap hasAlpha] ? 1 : 0);
colorSpaceName = [bitmap colorSpaceName];
if ([colorSpaceName isEqualToString: NSDeviceRGBColorSpace] ||
[colorSpaceName isEqualToString: NSCalibratedRGBColorSpace])
{
return (numColors == 3);
}
else if ([colorSpaceName isEqualToString: NSDeviceCMYKColorSpace])
{
return (numColors == 4);
}
else if ([colorSpaceName isEqualToString: NSDeviceWhiteColorSpace] ||
[colorSpaceName isEqualToString: NSCalibratedWhiteColorSpace])
{
return (numColors == 1);
}
else if ([colorSpaceName isEqualToString: NSDeviceBlackColorSpace] ||
[colorSpaceName isEqualToString: NSCalibratedBlackColorSpace])
{
return (numColors == 1);
}
else
{
return NO;
}
}
@end
@implementation ARTContext (ops)

View file

@ -95,7 +95,7 @@ draw_info_t ART_DI;
}
/* specially optimized versions (since these are common and simple) */
-(void) DPSsetgray: (float)gray
-(void) DPSsetgray: (CGFloat)gray
{
if (gray < 0.0) gray = 0.0;
if (gray > 1.0) gray = 1.0;
@ -108,7 +108,7 @@ draw_info_t ART_DI;
fill_color[0] = fill_color[1] = fill_color[2] = gray * 255;
}
-(void) DPSsetalpha: (float)a
-(void) DPSsetalpha: (CGFloat)a
{
if (a < 0.0) a = 0.0;
if (a > 1.0) a = 1.0;
@ -116,7 +116,7 @@ draw_info_t ART_DI;
stroke_color[3] = fill_color[3] = a * 255;
}
- (void) DPSsetrgbcolor: (float)r : (float)g : (float)b
- (void) DPSsetrgbcolor: (CGFloat)r : (CGFloat)g : (CGFloat)b
{
if (r < 0.0) r = 0.0; if (r > 1.0) r = 1.0;
if (g < 0.0) g = 0.0; if (g > 1.0) g = 1.0;
@ -137,11 +137,11 @@ draw_info_t ART_DI;
/* ----------------------------------------------------------------------- */
/* Text operations */
/* ----------------------------------------------------------------------- */
- (void) DPSashow: (float)ax : (float)ay : (const char*)s
- (void) DPSashow: (CGFloat)ax : (CGFloat)ay : (const char*)s
{ /* adds (ax,ay) in user space to each glyph's x/y advancement */
NSPoint p;
int x, y;
float numarray[2];
CGFloat numarray[2];
if (!wi || !wi->data) return;
if (all_clipped)
@ -168,13 +168,13 @@ draw_info_t ART_DI;
UPDATE_UNBUFFERED
}
- (void) DPSawidthshow: (float)cx : (float)cy : (int)c : (float)ax : (float)ay
- (void) DPSawidthshow: (CGFloat)cx : (CGFloat)cy : (int)c : (CGFloat)ax : (CGFloat)ay
: (const char*)s
{ /* adds (ax,ay) in user space to every glyph's advancement and (cx,cy)
to character c's x/y advancement */
NSPoint p;
int x, y;
float numarray[4];
CGFloat numarray[4];
if (!wi || !wi->data) return;
if (all_clipped)
@ -244,11 +244,11 @@ draw_info_t ART_DI;
UPDATE_UNBUFFERED
}
- (void) DPSwidthshow: (float)cx : (float)cy : (int)c : (const char*)s
- (void) DPSwidthshow: (CGFloat)cx : (CGFloat)cy : (int)c : (const char*)s
{ /* adds (x,y) in user space to character c's x/y advancement */
NSPoint p;
int x, y;
float numarray[2];
CGFloat numarray[2];
if (!wi || !wi->data) return;
if (all_clipped)
@ -274,7 +274,7 @@ draw_info_t ART_DI;
UPDATE_UNBUFFERED
}
- (void) DPSxshow: (const char*)s : (const float*)numarray : (int)size
- (void) DPSxshow: (const char*)s : (const CGFloat*)numarray : (int)size
{
NSPoint p;
int x, y;
@ -301,7 +301,7 @@ draw_info_t ART_DI;
UPDATE_UNBUFFERED
}
- (void) DPSxyshow: (const char*)s : (const float*)numarray : (int)size
- (void) DPSxyshow: (const char*)s : (const CGFloat*)numarray : (int)size
{
NSPoint p;
int x, y;
@ -328,7 +328,7 @@ draw_info_t ART_DI;
UPDATE_UNBUFFERED
}
- (void) DPSyshow: (const char*)s : (const float*)numarray : (int)size
- (void) DPSyshow: (const char*)s : (const CGFloat*)numarray : (int)size
{
NSPoint p;
int x, y;
@ -453,19 +453,19 @@ draw_info_t ART_DI;
}
}
- (void) DPScurrentlinewidth: (float*)width
- (void) DPScurrentlinewidth: (CGFloat*)width
{
*width = line_width;
}
- (void) DPScurrentmiterlimit: (float*)limit
- (void) DPScurrentmiterlimit: (CGFloat*)limit
{
*limit = miter_limit;
}
- (void) DPSsetdash: (const float*)pat : (int)size : (float)offs
- (void) DPSsetdash: (const CGFloat*)pat : (NSInteger)size : (CGFloat)offs
{
int i;
NSInteger i;
if (dash.n_dash)
{
@ -530,14 +530,14 @@ draw_info_t ART_DI;
}
}
- (void) DPSsetlinewidth: (float)width
- (void) DPSsetlinewidth: (CGFloat)width
{
line_width = width;
/* TODO? handle line_width=0 properly */
if (line_width <= 0) line_width = 1;
}
- (void) DPSsetmiterlimit: (float)limit
- (void) DPSsetmiterlimit: (CGFloat)limit
{
miter_limit=limit;
}

View file

@ -834,7 +834,7 @@ static BOOL _rect_advance(rect_trace_t *t, int *x0, int *x1)
- (void) dissolveGState: (GSGState *)source
fromRect: (NSRect)aRect
toPoint: (NSPoint)aPoint
delta: (float)fraction
delta: (CGFloat)fraction
{
/* much setup code shared with compositeGState:... */
ARTGState *ags = (ARTGState *)source;
@ -1209,7 +1209,7 @@ static BOOL _rect_advance(rect_trace_t *t, int *x0, int *x1)
fromRect: (NSRect)aRect
toPoint: (NSPoint)aPoint
op: (NSCompositingOperation)op
fraction: (float)delta
fraction: (CGFloat)delta
{
if (op == NSCompositeSourceOver)
{

View file

@ -363,7 +363,7 @@ static FT_Error ft_get_face(FTC_FaceID fid, FT_Library lib, FT_Pointer data, FT_
: (unsigned char *)abuf : (int)abpl
color:(unsigned char)r : (unsigned char)g : (unsigned char)b : (unsigned char)alpha
transform: (NSAffineTransform *)transform
deltas: (const float *)delta_data : (int)delta_size : (int)delta_flags
deltas: (const CGFloat *)delta_data : (int)delta_size : (int)delta_flags
widthChar: (int) wch
drawinfo: (draw_info_t *)di
{
@ -2129,7 +2129,7 @@ delta:0,
/* TODO: sometimes gets 'glyph transformation failed', probably need to
add code to avoid loading bitmaps for glyphs */
-(void) outlineString: (const char *)s
at: (float)x : (float)y
at: (CGFloat)x : (CGFloat)y
gstate: (void *)func_param
{
unichar *c;

View file

@ -36,7 +36,7 @@
color: (unsigned char)r : (unsigned char)g : (unsigned char)b
: (unsigned char)alpha
transform: (NSAffineTransform *)transform
deltas: (const float *)delta_data : (int)delta_size : (int)delta_flags
deltas: (const CGFloat *)delta_data : (int)delta_size : (int)delta_flags
widthChar: (int) wch
drawinfo: (struct draw_info_s *)di;
@ -60,7 +60,7 @@
drawinfo: (struct draw_info_s *)di;
-(void) outlineString: (const char *)s
at: (float)x : (float)y
at: (CGFloat)x : (CGFloat)y
gstate: (void *)func_param;
+(void) initializeBackend;

View file

@ -449,7 +449,7 @@ static FT_Error ft_get_face(FTC_FaceID fid, FT_Library lib,
: (unsigned char)b
: (unsigned char)alpha
transform: (NSAffineTransform *)transform
deltas: (const float *)delta_data : (int)delta_size : (int)delta_flags
deltas: (const CGFloat *)delta_data : (int)delta_size : (int)delta_flags
widthChar: (int) wch
drawinfo: (draw_info_t *)di
{
@ -2032,7 +2032,7 @@ static FT_Outline_Funcs bezierpath_funcs = {
/* TODO: sometimes gets 'glyph transformation failed', probably need to
add code to avoid loading bitmaps for glyphs */
- (void) outlineString: (const char *)s
at: (float)x : (float)y
at: (CGFloat)x : (CGFloat)y
gstate: (void *)func_param
{
#if 0

View file

@ -398,7 +398,7 @@ static void artcontext_render_svp(const ArtSVP *svp, int x0, int y0, int x1, int
also fills in the axis coordinates (x0/y0 is min) and returns 1. Otherwise
returns 0. (Actually, if pixel is NO, it's enough that the edges remain
within one pixel.) */
- (int) _axis_rectangle: (float)x : (float)y : (float)w : (float)h
- (int) _axis_rectangle: (CGFloat)x : (CGFloat)y : (CGFloat)w : (CGFloat)h
vpath: (ArtVpath *)vp
axis: (int *)px0 : (int *)py0 : (int *)px1 : (int *)py1
pixel: (BOOL)pixel
@ -834,7 +834,7 @@ static void clip_svp_callback(void *data, int y, int start,
[self _clip: ART_WIND_RULE_ODDEVEN];
}
- (void) DPSrectclip: (float)x : (float)y : (float)w : (float)h
- (void) DPSrectclip: (CGFloat)x : (CGFloat)y : (CGFloat)w : (CGFloat)h
{
ArtVpath vp[6];
ArtSVP *svp;
@ -972,7 +972,7 @@ static void clip_svp_callback(void *data, int y, int start,
[self _fill: ART_WIND_RULE_NONZERO];
}
- (void) DPSrectfill: (float)x : (float)y : (float)w : (float)h
- (void) DPSrectfill: (CGFloat)x : (CGFloat)y : (CGFloat)w : (CGFloat)h
{
ArtVpath vp[6];
ArtSVP *svp;
@ -1303,7 +1303,7 @@ static void clip_svp_callback(void *data, int y, int start,
UPDATE_UNBUFFERED
}
- (void) DPSrectstroke: (float)x : (float)y : (float)w : (float)h
- (void) DPSrectstroke: (CGFloat)x : (CGFloat)y : (CGFloat)w : (CGFloat)h
{
ArtVpath *vp, *vp2;
double matrix[6];

View file

@ -149,7 +149,7 @@
GetClientRect(hwnd, &rect);
NSRect frame = MSWindowRectToGS((WIN32Server*)GSCurrentServer(), hwnd, rect);
[[self class] handleExposeRect: frame forDriver: surface];
}
}
#endif
}
@ -194,6 +194,37 @@
@implementation CairoContext (Ops)
- (BOOL) isCompatibleBitmap: (NSBitmapImageRep*)bitmap
{
NSString *colorSpaceName;
if ([bitmap bitmapFormat] != 0)
{
return NO;
}
if ([bitmap isPlanar])
{
return NO;
}
if ([bitmap bitsPerSample] != 8)
{
return NO;
}
colorSpaceName = [bitmap colorSpaceName];
if (![colorSpaceName isEqualToString: NSDeviceRGBColorSpace] &&
![colorSpaceName isEqualToString: NSCalibratedRGBColorSpace])
{
return NO;
}
else
{
return YES;
}
}
- (void) GSDrawImage: (NSRect)rect: (void *)imageref
{
NSBitmapImageRep *bitmap;
@ -221,12 +252,12 @@
bitmapFormat: 0
bytesPerRow: 0
bitsPerPixel: 0];
if (new == nil)
{
{
NSLog(@"Could not convert bitmap data");
return;
}
}
bitmap = new;
}
@ -236,7 +267,7 @@
: [bitmap bitsPerPixel] : [bitmap bytesPerRow] : [bitmap isPlanar]
: [bitmap hasAlpha] : [bitmap colorSpaceName]
: data];
}
}
- (void) GSCurrentDevice: (void **)device : (int *)x : (int *)y
{

View file

@ -93,7 +93,7 @@
/* setting GSFontInfo:
* xHeight, pix_width, pix_height
*/
cairo_matrix_init(&font_matrix, matrix[0], matrix[1], matrix[2],
cairo_matrix_init(&font_matrix, matrix[0], matrix[1], -matrix[2],
matrix[3], matrix[4], matrix[5]);
//cairo_matrix_scale(&font_matrix, 0.9, 0.9);
cairo_matrix_init_identity(&ctm);
@ -494,7 +494,7 @@ BOOL _cairo_extents_for_NSGlyph(cairo_scaled_font_t *scaled_font, NSGlyph glyph,
return;
}
cairo_matrix_init(&font_matrix, matrix[0], matrix[1], matrix[2],
cairo_matrix_init(&font_matrix, matrix[0], matrix[1], -matrix[2],
matrix[3], matrix[4], matrix[5]);
cairo_set_font_matrix(ct, &font_matrix);
if (cairo_status(ct) != CAIRO_STATUS_SUCCESS)

View file

@ -74,7 +74,7 @@
NSZoneFree(NSDefaultMallocZone(), _base); \
}
static inline double doubleFromUserSpace(NSAffineTransform *ctm, double d)
static inline double doubleFromUserSpace(NSAffineTransform *ctm, CGFloat d)
{
if (ctm)
{
@ -87,7 +87,7 @@ static inline double doubleFromUserSpace(NSAffineTransform *ctm, double d)
return d;
}
static inline float floatToUserSpace(NSAffineTransform *ctm, double d)
static inline CGFloat floatToUserSpace(NSAffineTransform *ctm, double d)
{
if (ctm)
{
@ -98,7 +98,7 @@ static inline float floatToUserSpace(NSAffineTransform *ctm, double d)
d = doubleFromUserSpace(ictm, d);
RELEASE(ictm);
}
return (float)d;
return (CGFloat)d;
}
@ -267,7 +267,7 @@ static inline float floatToUserSpace(NSAffineTransform *ctm, double d)
return copy;
}
- (void) GSCurrentSurface: (CairoSurface **)surface: (int *)x : (int *)y
- (void) GSCurrentSurface: (CairoSurface **)surface : (int *)x : (int *)y
{
if (x)
*x = offset.x;
@ -416,7 +416,7 @@ static inline float floatToUserSpace(NSAffineTransform *ctm, double d)
}
}
- (void) GSSetFontSize: (float)size
- (void) GSSetFontSize: (CGFloat)size
{
if (_ct)
{
@ -529,11 +529,11 @@ static inline float floatToUserSpace(NSAffineTransform *ctm, double d)
cairo_new_path(_ct);
}
- (void) DPScurrentflat: (float *)flatness
- (void) DPScurrentflat: (CGFloat *)flatness
{
if (_ct)
{
*flatness = (float)cairo_get_tolerance(_ct) * 2;
*flatness = (CGFloat)cairo_get_tolerance(_ct) * 2;
}
}
@ -593,7 +593,7 @@ static inline float floatToUserSpace(NSAffineTransform *ctm, double d)
*/
}
- (void) DPScurrentlinewidth: (float *)width
- (void) DPScurrentlinewidth: (CGFloat *)width
{
if (_ct)
{
@ -601,7 +601,7 @@ static inline float floatToUserSpace(NSAffineTransform *ctm, double d)
}
}
- (void) DPScurrentmiterlimit: (float *)limit
- (void) DPScurrentmiterlimit: (CGFloat *)limit
{
if (_ct)
{
@ -613,7 +613,7 @@ static inline float floatToUserSpace(NSAffineTransform *ctm, double d)
{
}
- (void) DPSsetdash: (const float *)pat : (int)size : (float)foffset
- (void) DPSsetdash: (const CGFloat *)pat : (NSInteger)size : (CGFloat)foffset
{
if (_ct)
{
@ -633,7 +633,7 @@ static inline float floatToUserSpace(NSAffineTransform *ctm, double d)
}
}
- (void) DPSsetflat: (float)flatness
- (void) DPSsetflat: (CGFloat)flatness
{
[super DPSsetflat: flatness];
if (_ct)
@ -660,7 +660,7 @@ static inline float floatToUserSpace(NSAffineTransform *ctm, double d)
}
}
- (void) DPSsetlinewidth: (float)width
- (void) DPSsetlinewidth: (CGFloat)width
{
if (_ct)
{
@ -668,7 +668,7 @@ static inline float floatToUserSpace(NSAffineTransform *ctm, double d)
}
}
- (void) DPSsetmiterlimit: (float)limit
- (void) DPSsetmiterlimit: (CGFloat)limit
{
if (_ct)
{
@ -686,10 +686,11 @@ static inline float floatToUserSpace(NSAffineTransform *ctm, double d)
- (void) _setPath
{
unsigned count = [path elementCount];
unsigned i;
NSInteger count = [path elementCount];
NSInteger i;
SEL elmsel = @selector(elementAtIndex:associatedPoints:);
IMP elmidx = [path methodForSelector: elmsel];
NSBezierPathElement (*elmidx)(id, SEL, NSInteger, NSPoint*) =
(NSBezierPathElement (*)(id, SEL, NSInteger, NSPoint*))[path methodForSelector: elmsel];
// reset current cairo path
cairo_new_path(_ct);
@ -1002,10 +1003,10 @@ _set_op(cairo_t *ct, NSCompositingOperation op)
cairo_fill(_ct);
}
- (void) DPSimage: (NSAffineTransform *)matrix : (int)pixelsWide
: (int)pixelsHigh : (int)bitsPerSample
: (int)samplesPerPixel : (int)bitsPerPixel
: (int)bytesPerRow : (BOOL)isPlanar
- (void) DPSimage: (NSAffineTransform *)matrix : (NSInteger)pixelsWide
: (NSInteger)pixelsHigh : (NSInteger)bitsPerSample
: (NSInteger)samplesPerPixel : (NSInteger)bitsPerPixel
: (NSInteger)bytesPerRow : (BOOL)isPlanar
: (BOOL)hasAlpha : (NSString *)colorSpaceName
: (const unsigned char *const[5])data
{
@ -1232,7 +1233,7 @@ _set_op(cairo_t *ct, NSCompositingOperation op)
fromRect: (NSRect)srcRect
toPoint: (NSPoint)destPoint
op: (NSCompositingOperation)op
fraction: (float)delta
fraction: (CGFloat)delta
{
cairo_surface_t *src;
NSSize ssize = NSZeroSize;
@ -1374,7 +1375,7 @@ doesn't support to use the receiver cairo target as the source. */
fromRect: (NSRect)aRect
toPoint: (NSPoint)aPoint
op: (NSCompositingOperation)op
fraction: (float)delta
fraction: (CGFloat)delta
{
NSAffineTransformStruct tstruct = [ctm transformStruct];
cairo_surface_t *src;
@ -1607,16 +1608,39 @@ doesn't support to use the receiver cairo target as the source. */
double green;
double blue;
double alpha;
NSString *colorSpaceName;
[gradient getColor: &color
location: &location
atIndex: i];
red = [color redComponent];
green = [color greenComponent];
blue = [color blueComponent];
alpha = [color alphaComponent];
cairo_pattern_add_color_stop_rgba(cpattern, location,
red, green, blue, alpha);
colorSpaceName = [color colorSpaceName];
if([NSCalibratedRGBColorSpace isEqualToString: colorSpaceName] ||
[NSDeviceRGBColorSpace isEqualToString: colorSpaceName])
{
red = [color redComponent];
green = [color greenComponent];
blue = [color blueComponent];
alpha = [color alphaComponent];
cairo_pattern_add_color_stop_rgba(cpattern, location,
red, green, blue, alpha);
}
else if([NSCalibratedWhiteColorSpace isEqualToString: colorSpaceName] ||
[NSDeviceWhiteColorSpace isEqualToString: colorSpaceName] ||
[NSCalibratedBlackColorSpace isEqualToString: colorSpaceName] ||
[NSDeviceBlackColorSpace isEqualToString: colorSpaceName])
{
red = [color whiteComponent];
green = [color whiteComponent];
blue = [color whiteComponent];
alpha = [color alphaComponent];
cairo_pattern_add_color_stop_rgba(cpattern, location,
red, green, blue, alpha);
}
else
{
NSLog(@"Cannot draw gradient for %@",colorSpaceName);
}
}
cairo_save(_ct);

View file

@ -32,7 +32,244 @@
#include <cairo-win32.h>
@implementation Win32CairoSurface
- (HWND)gsDevice
{
return (HWND)gsDevice;
}
- (id) initWithDevice: (void *)device
{
if (self)
{
// Save/set initial state...
gsDevice = device;
_surface = NULL;
WIN_INTERN *win = (WIN_INTERN *)GetWindowLong(device, GWL_USERDATA);
HDC hDC = GetDC(device);
if (hDC == NULL)
{
NSWarnMLog(@"Win32CairoSurface line: %d : no device context", __LINE__);
// And deallocate ourselves...
DESTROY(self);
}
else
{
// Create the cairo surfaces...
// NSBackingStoreRetained works like Buffered since 10.5 (See apple docs)...
// NOTE: According to Apple docs NSBackingStoreBuffered should be the only one
// ever used anymore....others are NOT recommended...
#if 0 // FIXME:
// Non-retained backing store type on windows doesn't re-display correctly
// after first time (see additional comments in method -[CairoContext flushGraphics])
// Currently handling such windows as buffered store types until a fix can be resolved.
if (win && (win->type == NSBackingStoreNonretained))
{
// This is the raw DC surface...
_surface = cairo_win32_surface_create(hDC);
// Check for error...
if (cairo_surface_status(_surface) != CAIRO_STATUS_SUCCESS)
{
// Output the surface create error...
cairo_status_t status = cairo_surface_status(_surface);
NSWarnMLog(@"surface create FAILED - status: %s\n", cairo_status_to_string(status));
// Destroy the initial surface created...
cairo_surface_destroy(_surface);
// And deallocate ourselves...
DESTROY(self);
// Release the device context...
ReleaseDC(device, hDC);
}
}
else
#endif
{
NSSize csize = [self size];
// This is the raw DC surface...
cairo_surface_t *window = cairo_win32_surface_create(hDC);
// Check for error...
if (cairo_surface_status(window) != CAIRO_STATUS_SUCCESS)
{
// Output the surface create error...
cairo_status_t status = cairo_surface_status(window);
NSWarnMLog(@"surface create FAILED - status: %s\n", cairo_status_to_string(status));
// And deallocate ourselves...
DESTROY(self);
}
else
{
// and this is the in-memory DC surface...surface owns its DC...
// NOTE: For some reason we get an init sequence with zero width/height,
// which creates problems in the cairo layer. It tries to clear
// the 'similar' surface it's creating, and with a zero width/height
// it incorrectly thinks the clear failed...so we will init with
// a minimum size of 1 for width/height...
_surface = cairo_surface_create_similar(window, CAIRO_CONTENT_COLOR_ALPHA,
MAX(1, csize.width),
MAX(1, csize.height));
// Check for error...
if (cairo_surface_status(_surface) != CAIRO_STATUS_SUCCESS)
{
// Output the surface create error...
cairo_status_t status = cairo_surface_status(_surface);
NSWarnMLog(@"surface create FAILED - status: %s\n", cairo_status_to_string(status));
// Destroy the surface created...
cairo_surface_destroy(_surface);
// And deallocate ourselves...
DESTROY(self);
}
}
// Destroy the initial surface created...
cairo_surface_destroy(window);
// Release the device context...
ReleaseDC(device, hDC);
}
if (self)
{
// We need this for handleExposeEvent in WIN32Server...
win->surface = (void*)self;
}
}
}
return self;
}
- (void) dealloc
{
// After further testing and monitoring USER/GDI object counts found
// that releasing the HDC is redundant and unnecessary...
[super dealloc];
}
- (NSString*) description
{
NSMutableString *description = AUTORELEASE([[super description] mutableCopy]);
HDC shdc = NULL;
if (_surface)
{
shdc = cairo_win32_surface_get_dc(_surface);
}
[description appendFormat: @" size: %@",NSStringFromSize([self size])];
[description appendFormat: @" _surface: %p",_surface];
[description appendFormat: @" surfDC: %p",shdc];
return AUTORELEASE(description);
}
- (NSSize) size
{
RECT csize;
GetClientRect([self gsDevice], &csize);
return NSMakeSize(csize.right - csize.left, csize.bottom - csize.top);
}
- (void) setSize: (NSSize)newSize
{
NSDebugMLLog(@"Win32CairoSurface", @"size: %@\n", NSStringFromSize(newSize));
}
- (void) handleExposeRect: (NSRect)rect
{
// If the surface is buffered then we will have been invoked...
HDC hdc = GetDC([self gsDevice]);
// Make sure we got a HDC...
if (hdc == NULL)
{
NSWarnMLog(@"ERROR: cannot get a HDC for surface: %@\n", self);
}
else
{
// Create a cairo surface for the hDC...
cairo_surface_t *window = cairo_win32_surface_create(hdc);
// If the surface is buffered then...
if (window == NULL)
{
NSWarnMLog(@"ERROR: cannot create cairo surface for: %@\n", self);
}
else
{
// First check the current status of the foreground surface...
if (cairo_surface_status(window) != CAIRO_STATUS_SUCCESS)
{
NSWarnMLog(@"cairo initial window error status: %s\n",
cairo_status_to_string(cairo_surface_status(window)));
}
else
{
cairo_t *context = cairo_create(window);
if (cairo_status(context) != CAIRO_STATUS_SUCCESS)
{
NSWarnMLog(@"cairo context create error - status: _surface: %s window: %s windowCtxt: %s (%d)",
cairo_status_to_string(cairo_surface_status(_surface)),
cairo_status_to_string(cairo_surface_status(window)),
cairo_status_to_string(cairo_status(context)), cairo_get_reference_count(context));
}
else
{
double backupOffsetX = 0;
double backupOffsetY = 0;
RECT msRect = GSWindowRectToMS((WIN32Server*)GSCurrentServer(), [self gsDevice], rect);
// Need to save the device offset context...
cairo_surface_get_device_offset(_surface, &backupOffsetX, &backupOffsetY);
cairo_surface_set_device_offset(_surface, 0, 0);
cairo_rectangle(context, msRect.left, msRect.top, rect.size.width, rect.size.height);
cairo_clip(context);
cairo_set_source_surface(context, _surface, 0, 0);
cairo_set_operator(context, CAIRO_OPERATOR_SOURCE);
cairo_paint(context);
if (cairo_status(context) != CAIRO_STATUS_SUCCESS)
{
NSWarnMLog(@"cairo expose error - status: _surface: %s window: %s windowCtxt: %s",
cairo_status_to_string(cairo_surface_status(_surface)),
cairo_status_to_string(cairo_surface_status(window)),
cairo_status_to_string(cairo_status(context)));
}
// Cleanup...
cairo_destroy(context);
// Restore device offset
cairo_surface_set_device_offset(_surface, backupOffsetX, backupOffsetY);
}
}
// Destroy the surface...
cairo_surface_destroy(window);
}
// Release the aquired HDC...
ReleaseDC([self gsDevice], hdc);
}
}
@end
@implementation WIN32Server (ScreenCapture)
- (NSImage *) contentsOfScreen: (int)screen inRect: (NSRect)rect
{
NSImage *result = nil;
@ -139,238 +376,3 @@
}
@end
@implementation Win32CairoSurface
- (HWND)gsDevice
{
return (HWND)gsDevice;
}
- (id) initWithDevice: (void *)device
{
if (self)
{
// Save/set initial state...
gsDevice = device;
_surface = NULL;
WIN_INTERN *win = (WIN_INTERN *)GetWindowLong(device, GWL_USERDATA);
HDC hDC = GetDC(device);
if (hDC == NULL)
{
NSWarnMLog(@"Win32CairoSurface line: %d : no device context", __LINE__);
// And deallocate ourselves...
DESTROY(self);
}
else
{
// Create the cairo surfaces...
// NSBackingStoreRetained works like Buffered since 10.5 (See apple docs)...
// NOTE: According to Apple docs NSBackingStoreBuffered should be the only one
// ever used anymore....others are NOT recommended...
#if 0 // FIXME:
// Non-retained backing store type on windows doesn't re-display correctly
// after first time (see additional comments in method -[CairoContext flushGraphics])
// Currently handling such windows as buffered store types until a fix can be resolved.
if (win && (win->type == NSBackingStoreNonretained))
{
// This is the raw DC surface...
_surface = cairo_win32_surface_create(hDC);
// Check for error...
if (cairo_surface_status(_surface) != CAIRO_STATUS_SUCCESS)
{
// Output the surface create error...
cairo_status_t status = cairo_surface_status(_surface);
NSWarnMLog(@"surface create FAILED - status: %s\n", cairo_status_to_string(status));
// Destroy the initial surface created...
cairo_surface_destroy(_surface);
// And deallocate ourselves...
DESTROY(self);
// Release the device context...
ReleaseDC(device, hDC);
}
}
else
#endif
{
NSSize csize = [self size];
// This is the raw DC surface...
cairo_surface_t *window = cairo_win32_surface_create(hDC);
// Check for error...
if (cairo_surface_status(window) != CAIRO_STATUS_SUCCESS)
{
// Output the surface create error...
cairo_status_t status = cairo_surface_status(window);
NSWarnMLog(@"surface create FAILED - status: %s\n", cairo_status_to_string(status));
// And deallocate ourselves...
DESTROY(self);
}
else
{
// and this is the in-memory DC surface...surface owns its DC...
// NOTE: For some reason we get an init sequence with zero width/height,
// which creates problems in the cairo layer. It tries to clear
// the 'similar' surface it's creating, and with a zero width/height
// it incorrectly thinks the clear failed...so we will init with
// a minimum size of 1 for width/height...
_surface = cairo_surface_create_similar(window, CAIRO_CONTENT_COLOR_ALPHA,
MAX(1, csize.width),
MAX(1, csize.height));
// Check for error...
if (cairo_surface_status(_surface) != CAIRO_STATUS_SUCCESS)
{
// Output the surface create error...
cairo_status_t status = cairo_surface_status(_surface);
NSWarnMLog(@"surface create FAILED - status: %s\n", cairo_status_to_string(status));
// Destroy the surface created...
cairo_surface_destroy(_surface);
// And deallocate ourselves...
DESTROY(self);
}
}
// Destroy the initial surface created...
cairo_surface_destroy(window);
// Release the device context...
ReleaseDC(device, hDC);
}
if (self)
{
// We need this for handleExposeEvent in WIN32Server...
win->surface = (void*)self;
}
}
}
return self;
}
- (void) dealloc
{
// After further testing and monitoring USER/GDI object counts found
// that releasing the HDC is redundant and unnecessary...
[super dealloc];
}
- (NSString*) description
{
HDC shdc = NULL;
if (_surface)
{
shdc = cairo_win32_surface_get_dc(_surface);
}
NSMutableString *description = AUTORELEASE([[super description] mutableCopy]);
[description appendFormat: @" size: %@",NSStringFromSize([self size])];
[description appendFormat: @" _surface: %p",_surface];
[description appendFormat: @" surfDC: %p",shdc];
return AUTORELEASE([description copy]);
}
- (NSSize) size
{
RECT csize;
GetClientRect([self gsDevice], &csize);
return NSMakeSize(csize.right - csize.left, csize.bottom - csize.top);
}
- (void) setSize: (NSSize)newSize
{
NSDebugMLLog(@"Win32CairoSurface", @"size: %@\n", NSStringFromSize(newSize));
}
- (void) handleExposeRect: (NSRect)rect
{
// If the surface is buffered then we will have been invoked...
HDC hdc = GetDC([self gsDevice]);
// Make sure we got a HDC...
if (hdc == NULL)
{
NSWarnMLog(@"ERROR: cannot get a HDC for surface: %@\n", self);
}
else
{
// Create a cairo surface for the hDC...
cairo_surface_t *window = cairo_win32_surface_create(hdc);
// If the surface is buffered then...
if (window == NULL)
{
NSWarnMLog(@"ERROR: cannot create cairo surface for: %@\n", self);
}
else
{
// First check the current status of the foreground surface...
if (cairo_surface_status(window) != CAIRO_STATUS_SUCCESS)
{
NSWarnMLog(@"cairo initial window error status: %s\n",
cairo_status_to_string(cairo_surface_status(window)));
}
else
{
cairo_t *context = cairo_create(window);
if (cairo_status(context) != CAIRO_STATUS_SUCCESS)
{
NSWarnMLog(@"cairo context create error - status: _surface: %s window: %s windowCtxt: %s (%d)",
cairo_status_to_string(cairo_surface_status(_surface)),
cairo_status_to_string(cairo_surface_status(window)),
cairo_status_to_string(cairo_status(context)), cairo_get_reference_count(context));
}
else
{
double backupOffsetX = 0;
double backupOffsetY = 0;
RECT msRect = GSWindowRectToMS((WIN32Server*)GSCurrentServer(), [self gsDevice], rect);
// Need to save the device offset context...
cairo_surface_get_device_offset(_surface, &backupOffsetX, &backupOffsetY);
cairo_surface_set_device_offset(_surface, 0, 0);
cairo_rectangle(context, msRect.left, msRect.top, rect.size.width, rect.size.height);
cairo_clip(context);
cairo_set_source_surface(context, _surface, 0, 0);
cairo_set_operator(context, CAIRO_OPERATOR_SOURCE);
cairo_paint(context);
if (cairo_status(context) != CAIRO_STATUS_SUCCESS)
{
NSWarnMLog(@"cairo expose error - status: _surface: %s window: %s windowCtxt: %s",
cairo_status_to_string(cairo_surface_status(_surface)),
cairo_status_to_string(cairo_surface_status(window)),
cairo_status_to_string(cairo_status(context)));
}
// Cleanup...
cairo_destroy(context);
// Restore device offset
cairo_surface_set_device_offset(_surface, backupOffsetX, backupOffsetY);
}
}
// Destroy the surface...
cairo_surface_destroy(window);
}
// Release the aquired HDC...
ReleaseDC([self gsDevice], hdc);
}
}
@end

View file

@ -44,7 +44,7 @@
// I see no reason, why it isn't working, as the code is identical
// to the one in the art backend.
RELEASE(self);
return [[XGCairoSurface alloc] initWithDevice: device];
return (XGCairoXImageSurface*)[[XGCairoSurface alloc] initWithDevice: device];
}
di.drawing_depth = GSWINDEVICE->depth;

View file

@ -29,6 +29,7 @@
#include <AppKit/NSAffineTransform.h>
#include <AppKit/NSBitmapImageRep.h>
#include <AppKit/NSColor.h>
#include <AppKit/NSGraphics.h>
#include <AppKit/NSView.h>
#include <AppKit/NSWindow.h>
#include <GNUstepGUI/GSDisplayServer.h>
@ -105,8 +106,8 @@ static NSMapTable *gtable;
@interface GSContext (PrivateOps)
- (void)DPSdefineuserobject;
- (void)DPSexecuserobject: (int)index;
- (void)DPSundefineuserobject: (int)index;
- (void)DPSexecuserobject: (NSInteger)index;
- (void)DPSundefineuserobject: (NSInteger)index;
- (void)DPSclear;
- (void)DPScopy: (int)n;
- (void)DPScount: (int *)n;
@ -116,6 +117,17 @@ static NSMapTable *gtable;
- (void)DPSpop;
@end
@interface NSBitmapImageRep (GSPrivate)
- (NSBitmapImageRep *) _convertToFormatBitsPerSample: (NSInteger)bps
samplesPerPixel: (NSInteger)spp
hasAlpha: (BOOL)alpha
isPlanar: (BOOL)isPlanar
colorSpaceName: (NSString*)colorSpaceName
bitmapFormat: (NSBitmapFormat)bitmapFormat
bytesPerRow: (NSInteger)rowBytes
bitsPerPixel: (NSInteger)pixelBits;
@end
/**
<unit>
@ -175,7 +187,7 @@ static NSMapTable *gtable;
contextType = [info objectForKey:
NSGraphicsContextRepresentationFormatAttributeName];
if (([isa handlesPS] == NO) && contextType
if (([object_getClass(self) handlesPS] == NO) && contextType
&& [contextType isEqual: NSGraphicsContextPSFormat])
{
/* Don't call self, since we aren't initialized */
@ -194,7 +206,7 @@ static NSMapTable *gtable;
gstack = NSZoneMalloc(z, sizeof(GSIArray_t));
GSIArrayInitWithZoneAndCapacity((GSIArray)gstack, z, 2);
/* Create a default gstate */
gstate = [[[isa GStateClass] allocWithZone: z]
gstate = [[[object_getClass(self) GStateClass] allocWithZone: z]
initWithDrawContext: self];
// Special handling for window drawing
@ -249,23 +261,23 @@ static NSMapTable *gtable;
/* ----------------------------------------------------------------------- */
/* Color operations */
/* ----------------------------------------------------------------------- */
- (void) DPScurrentalpha: (float *)a
- (void) DPScurrentalpha: (CGFloat *)a
{
[gstate DPScurrentalpha: a];
}
- (void) DPScurrentcmykcolor: (float*)c : (float*)m : (float*)y : (float*)k
- (void) DPScurrentcmykcolor: (CGFloat*)c : (CGFloat*)m : (CGFloat*)y : (CGFloat*)k
{
[gstate DPScurrentcmykcolor:c :m :y :k];
}
- (void) DPScurrentgray: (float*)gray
- (void) DPScurrentgray: (CGFloat*)gray
{
CHECK_NULL_OUTPUT(gray);
[gstate DPScurrentgray: gray];
}
- (void) DPScurrenthsbcolor: (float*)h : (float*)s : (float*)b
- (void) DPScurrenthsbcolor: (CGFloat*)h : (CGFloat*)s : (CGFloat*)b
{
CHECK_NULL_OUTPUT(h);
CHECK_NULL_OUTPUT(s);
@ -273,7 +285,7 @@ static NSMapTable *gtable;
[gstate DPScurrenthsbcolor:h :s :b];
}
- (void) DPScurrentrgbcolor: (float*)r : (float*)g : (float*)b
- (void) DPScurrentrgbcolor: (CGFloat*)r : (CGFloat*)g : (CGFloat*)b
{
CHECK_NULL_OUTPUT(r);
CHECK_NULL_OUTPUT(g);
@ -281,27 +293,27 @@ static NSMapTable *gtable;
[gstate DPScurrentrgbcolor:r :g :b];
}
- (void) DPSsetalpha: (float)a
- (void) DPSsetalpha: (CGFloat)a
{
[gstate DPSsetalpha: a];
}
- (void) DPSsetcmykcolor: (float)c : (float)m : (float)y : (float)k
- (void) DPSsetcmykcolor: (CGFloat)c : (CGFloat)m : (CGFloat)y : (CGFloat)k
{
[gstate DPSsetcmykcolor:c :m :y :k];
}
- (void) DPSsetgray: (float)gray
- (void) DPSsetgray: (CGFloat)gray
{
[gstate DPSsetgray: gray];
}
- (void) DPSsethsbcolor: (float)h : (float)s : (float)b
- (void) DPSsethsbcolor: (CGFloat)h : (CGFloat)s : (CGFloat)b
{
[gstate DPSsethsbcolor:h :s :b];
}
- (void) DPSsetrgbcolor: (float)r : (float)g : (float)b
- (void) DPSsetrgbcolor: (CGFloat)r : (CGFloat)g : (CGFloat)b
{
[gstate DPSsetrgbcolor:r :g :b];
}
@ -334,12 +346,12 @@ static NSMapTable *gtable;
/* ----------------------------------------------------------------------- */
/* Text operations */
/* ----------------------------------------------------------------------- */
- (void) DPSashow: (float)x : (float)y : (const char *)s
- (void) DPSashow: (CGFloat)x : (CGFloat)y : (const char *)s
{
[gstate DPSashow: x : y : s];
}
- (void) DPSawidthshow: (float)cx : (float)cy : (int)c : (float)ax : (float)ay : (const char *)s
- (void) DPSawidthshow: (CGFloat)cx : (CGFloat)cy : (int)c : (CGFloat)ax : (CGFloat)ay : (const char *)s
{
[gstate DPSawidthshow: cx : cy : c : ax : ay : s];
}
@ -360,27 +372,27 @@ static NSMapTable *gtable;
[gstate DPSshow: s];
}
- (void) DPSwidthshow: (float)x : (float)y : (int)c : (const char *)s
- (void) DPSwidthshow: (CGFloat)x : (CGFloat)y : (int)c : (const char *)s
{
[gstate DPSwidthshow: x : y : c : s];
}
- (void) DPSxshow: (const char *)s : (const float*)numarray : (int)size
- (void) DPSxshow: (const char *)s : (const CGFloat*)numarray : (int)size
{
[gstate DPSxshow: s : numarray : size];
}
- (void) DPSxyshow: (const char *)s : (const float*)numarray : (int)size
- (void) DPSxyshow: (const char *)s : (const CGFloat*)numarray : (int)size
{
[gstate DPSxyshow: s : numarray : size];
}
- (void) DPSyshow: (const char *)s : (const float*)numarray : (int)size
- (void) DPSyshow: (const char *)s : (const CGFloat*)numarray : (int)size
{
[gstate DPSyshow: s : numarray : size];
}
- (void) GSSetCharacterSpacing: (float)extra
- (void) GSSetCharacterSpacing: (CGFloat)extra
{
[gstate GSSetCharacterSpacing: extra];
}
@ -390,7 +402,7 @@ static NSMapTable *gtable;
[gstate GSSetFont: fontref];
}
- (void) GSSetFontSize: (float)size
- (void) GSSetFontSize: (CGFloat)size
{
[gstate GSSetFontSize: size];
}
@ -461,7 +473,7 @@ static NSMapTable *gtable;
[gstate DPSinitgraphics];
}
- (void) DPSsetgstate: (int)gst
- (void) DPSsetgstate: (NSInteger)gst
{
if (gst)
{
@ -474,35 +486,35 @@ static NSMapTable *gtable;
DESTROY(gstate);
}
- (int) GSDefineGState
- (NSInteger) GSDefineGState
{
if (gstate == nil)
{
DPS_ERROR(DPSundefined, @"No gstate");
return 0;
}
[isa insertObject: AUTORELEASE([gstate copy]) forKey: ++unique_index];
[object_getClass(self) insertObject: AUTORELEASE([gstate copy]) forKey: ++unique_index];
return unique_index;
}
- (void) GSUndefineGState: (int)gst
- (void) GSUndefineGState: (NSInteger)gst
{
[self DPSundefineuserobject: gst];
}
- (void) GSReplaceGState: (int)gst
- (void) GSReplaceGState: (NSInteger)gst
{
if (gst <= 0)
return;
[isa insertObject: AUTORELEASE([gstate copy]) forKey: gst];
[object_getClass(self) insertObject: AUTORELEASE([gstate copy]) forKey: gst];
}
/* ----------------------------------------------------------------------- */
/* Gstate operations */
/* ----------------------------------------------------------------------- */
- (void) DPScurrentflat: (float*)flatness
- (void) DPScurrentflat: (CGFloat*)flatness
{
CHECK_NULL_OUTPUT(flatness);
[gstate DPScurrentflat: flatness];
@ -518,18 +530,18 @@ static NSMapTable *gtable;
[gstate DPScurrentlinejoin: linejoin];
}
- (void) DPScurrentlinewidth: (float*)width
- (void) DPScurrentlinewidth: (CGFloat*)width
{
[gstate DPScurrentlinewidth: width];
}
- (void) DPScurrentmiterlimit: (float*)limit
- (void) DPScurrentmiterlimit: (CGFloat*)limit
{
CHECK_NULL_OUTPUT(limit);
[gstate DPScurrentmiterlimit: limit];
}
- (void) DPScurrentpoint: (float*)x : (float*)y
- (void) DPScurrentpoint: (CGFloat*)x : (CGFloat*)y
{
CHECK_NULL_OUTPUT(x);
CHECK_NULL_OUTPUT(y);
@ -542,17 +554,17 @@ static NSMapTable *gtable;
[gstate DPScurrentstrokeadjust: b];
}
- (void) DPSsetdash: (const float*)pat : (int)size : (float)offset
- (void) DPSsetdash: (const CGFloat*)pat : (NSInteger)size : (CGFloat)offset
{
[gstate DPSsetdash: pat : size : offset];
}
- (void) DPSsetflat: (float)flatness
- (void) DPSsetflat: (CGFloat)flatness
{
[gstate DPSsetflat: flatness];
}
- (void) DPSsethalftonephase: (float)x : (float)y
- (void) DPSsethalftonephase: (CGFloat)x : (CGFloat)y
{
[self notImplemented: _cmd];
}
@ -567,12 +579,12 @@ static NSMapTable *gtable;
[gstate DPSsetlinejoin: linejoin];
}
- (void) DPSsetlinewidth: (float)width
- (void) DPSsetlinewidth: (CGFloat)width
{
[gstate DPSsetlinewidth: width];
}
- (void) DPSsetmiterlimit: (float)limit
- (void) DPSsetmiterlimit: (CGFloat)limit
{
[gstate DPSsetmiterlimit: limit];
}
@ -585,7 +597,7 @@ static NSMapTable *gtable;
/* ----------------------------------------------------------------------- */
/* Matrix operations */
/* ----------------------------------------------------------------------- */
- (void) DPSconcat: (const float*)m
- (void) DPSconcat: (const CGFloat*)m
{
[gstate DPSconcat: m];
}
@ -595,17 +607,17 @@ static NSMapTable *gtable;
[gstate DPSinitmatrix];
}
- (void) DPSrotate: (float)angle
- (void) DPSrotate: (CGFloat)angle
{
[gstate DPSrotate: angle];
}
- (void) DPSscale: (float)x : (float)y
- (void) DPSscale: (CGFloat)x : (CGFloat)y
{
[gstate DPSscale:x :y];
}
- (void) DPStranslate: (float)x : (float)y
- (void) DPStranslate: (CGFloat)x : (CGFloat)y
{
[gstate DPStranslate:x :y];
}
@ -628,19 +640,19 @@ static NSMapTable *gtable;
/* ----------------------------------------------------------------------- */
/* Paint operations */
/* ----------------------------------------------------------------------- */
- (void) DPSarc: (float)x : (float)y : (float)r : (float)angle1
: (float)angle2
- (void) DPSarc: (CGFloat)x : (CGFloat)y : (CGFloat)r : (CGFloat)angle1
: (CGFloat)angle2
{
[gstate DPSarc: x : y : r : angle1 : angle2];
}
- (void) DPSarcn: (float)x : (float)y : (float)r : (float)angle1
: (float)angle2
- (void) DPSarcn: (CGFloat)x : (CGFloat)y : (CGFloat)r : (CGFloat)angle1
: (CGFloat)angle2
{
[gstate DPSarcn: x : y : r : angle1 : angle2];
}
- (void) DPSarct: (float)x1 : (float)y1 : (float)x2 : (float)y2 : (float)r;
- (void) DPSarct: (CGFloat)x1 : (CGFloat)y1 : (CGFloat)x2 : (CGFloat)y2 : (CGFloat)r;
{
[gstate DPSarct: x1 : y1 : x2 : y2 : r];
}
@ -655,8 +667,8 @@ static NSMapTable *gtable;
[gstate DPSclosepath];
}
- (void) DPScurveto: (float)x1 : (float)y1 : (float)x2 : (float)y2
: (float)x3 : (float)y3
- (void) DPScurveto: (CGFloat)x1 : (CGFloat)y1 : (CGFloat)x2 : (CGFloat)y2
: (CGFloat)x3 : (CGFloat)y3
{
[gstate DPScurveto: x1 : y1 : x2 : y2 : x3 : y3];
}
@ -686,12 +698,12 @@ static NSMapTable *gtable;
[gstate DPSinitclip];
}
- (void) DPSlineto: (float)x : (float)y
- (void) DPSlineto: (CGFloat)x : (CGFloat)y
{
[gstate DPSlineto: x : y];
}
- (void) DPSmoveto: (float)x : (float)y
- (void) DPSmoveto: (CGFloat)x : (CGFloat)y
{
[gstate DPSmoveto: x : y];
}
@ -701,28 +713,28 @@ static NSMapTable *gtable;
[gstate DPSnewpath];
}
- (void) DPSpathbbox: (float*)llx : (float*)lly : (float*)urx : (float*)ury
- (void) DPSpathbbox: (CGFloat*)llx : (CGFloat*)lly : (CGFloat*)urx : (CGFloat*)ury
{
[gstate DPSpathbbox: llx : lly : urx : ury];
}
- (void) DPSrcurveto: (float)x1 : (float)y1 : (float)x2 : (float)y2
: (float)x3 : (float)y3
- (void) DPSrcurveto: (CGFloat)x1 : (CGFloat)y1 : (CGFloat)x2 : (CGFloat)y2
: (CGFloat)x3 : (CGFloat)y3
{
[gstate DPSrcurveto: x1 : y1 : x2 : y2 : x3 : y3];
}
- (void) DPSrectclip: (float)x : (float)y : (float)w : (float)h
- (void) DPSrectclip: (CGFloat)x : (CGFloat)y : (CGFloat)w : (CGFloat)h
{
[gstate DPSrectclip: x : y : w : h];
}
- (void) DPSrectfill: (float)x : (float)y : (float)w : (float)h
- (void) DPSrectfill: (CGFloat)x : (CGFloat)y : (CGFloat)w : (CGFloat)h
{
[gstate DPSrectfill:x :y :w :h];
}
- (void) DPSrectstroke: (float)x : (float)y : (float)w : (float)h
- (void) DPSrectstroke: (CGFloat)x : (CGFloat)y : (CGFloat)w : (CGFloat)h
{
[gstate DPSrectstroke:x :y :w :h];
}
@ -732,12 +744,12 @@ static NSMapTable *gtable;
[gstate DPSreversepath];
}
- (void) DPSrlineto: (float)x : (float)y
- (void) DPSrlineto: (CGFloat)x : (CGFloat)y
{
[gstate DPSrlineto: x : y];
}
- (void) DPSrmoveto: (float)x : (float)y
- (void) DPSrmoveto: (CGFloat)x : (CGFloat)y
{
[gstate DPSrmoveto: x : y];
}
@ -783,8 +795,8 @@ static NSMapTable *gtable;
/*-------------------------------------------------------------------------*/
/* Graphics Extension Ops */
/*-------------------------------------------------------------------------*/
- (void) DPScomposite: (float)x : (float)y : (float)w : (float)h
: (int)gstateNum : (float)dx : (float)dy : (int)op
- (void) DPScomposite: (CGFloat)x : (CGFloat)y : (CGFloat)w : (CGFloat)h
: (NSInteger)gstateNum : (CGFloat)dx : (CGFloat)dy : (NSCompositingOperation)op
{
[self GScomposite: gstateNum
toPoint: NSMakePoint(dx, dy)
@ -793,13 +805,13 @@ static NSMapTable *gtable;
fraction: 1.0];
}
- (void) DPScompositerect: (float)x : (float)y : (float)w : (float)h : (int)op
- (void) DPScompositerect: (CGFloat)x : (CGFloat)y : (CGFloat)w : (CGFloat)h : (NSCompositingOperation)op
{
[gstate compositerect: NSMakeRect(x, y, w, h) op: op];
[gstate compositerect: NSMakeRect(x, y, w, h) op: op];
}
- (void) DPSdissolve: (float)x : (float)y : (float)w : (float)h
: (int)gstateNum : (float)dx : (float)dy : (float)delta
- (void) DPSdissolve: (CGFloat)x : (CGFloat)y : (CGFloat)w : (CGFloat)h
: (NSInteger)gstateNum : (CGFloat)dx : (CGFloat)dy : (CGFloat)delta
{
[self GScomposite: gstateNum
toPoint: NSMakePoint(dx, dy)
@ -808,11 +820,11 @@ static NSMapTable *gtable;
fraction: delta];
}
- (void) GScomposite: (int)gstateNum
- (void) GScomposite: (NSInteger)gstateNum
toPoint: (NSPoint)aPoint
fromRect: (NSRect)srcRect
operation: (NSCompositingOperation)op
fraction: (float)delta
fraction: (CGFloat)delta
{
GSGState *g = gstate;
@ -829,11 +841,11 @@ static NSMapTable *gtable;
fraction: delta];
}
- (void) GSdraw: (int)gstateNum
- (void) GSdraw: (NSInteger)gstateNum
toPoint: (NSPoint)aPoint
fromRect: (NSRect)srcRect
operation: (NSCompositingOperation)op
fraction: (float)delta
fraction: (CGFloat)delta
{
GSGState *g = gstate;
@ -850,12 +862,42 @@ static NSMapTable *gtable;
fraction: delta];
}
- (void) GSDrawImage: (NSRect) rect: (void *) imageref
- (BOOL) isCompatibleBitmap: (NSBitmapImageRep*)bitmap
{
return ([bitmap bitmapFormat] == 0);
}
- (void) GSDrawImage: (NSRect) rect : (void *) imageref
{
NSBitmapImageRep *bitmap;
unsigned char *data[5];
bitmap = (NSBitmapImageRep*)imageref;
if (![self isCompatibleBitmap: bitmap])
{
NSInteger bitsPerSample = 8;
BOOL isPlanar = NO;
NSInteger samplesPerPixel = [bitmap hasAlpha] ? 4 : 3;
NSString *colorSpaceName = NSCalibratedRGBColorSpace;
NSBitmapImageRep *new;
new = [bitmap _convertToFormatBitsPerSample: bitsPerSample
samplesPerPixel: samplesPerPixel
hasAlpha: [bitmap hasAlpha]
isPlanar: isPlanar
colorSpaceName: colorSpaceName
bitmapFormat: 0
bytesPerRow: 0
bitsPerPixel: 0];
if (new == nil)
{
NSLog(@"Could not convert bitmap data");
return;
}
bitmap = new;
}
[bitmap getBitmapDataPlanes: data];
[self NSDrawBitmap: rect : [bitmap pixelsWide] : [bitmap pixelsHigh]
: [bitmap bitsPerSample] : [bitmap samplesPerPixel]
@ -892,9 +934,9 @@ static NSMapTable *gtable;
/*
* Render Bitmap Images
*/
- (void) NSDrawBitmap: (NSRect) rect : (int) pixelsWide : (int) pixelsHigh
: (int) bitsPerSample : (int) samplesPerPixel
: (int) bitsPerPixel : (int) bytesPerRow : (BOOL) isPlanar
- (void) NSDrawBitmap: (NSRect) rect : (NSInteger) pixelsWide : (NSInteger) pixelsHigh
: (NSInteger) bitsPerSample : (NSInteger) samplesPerPixel
: (NSInteger) bitsPerPixel : (NSInteger) bytesPerRow : (BOOL) isPlanar
: (BOOL) hasAlpha : (NSString *) colorSpaceName
: (const unsigned char *const [5]) data
{
@ -939,20 +981,21 @@ static NSMapTable *gtable;
int n;
id obj;
NSNumber *number;
ctxt_pop(obj, opstack, NSObject);
ctxt_pop(number, opstack, NSNumber);
n = [number intValue];
if (n < 0)
DPS_ERROR(DPSinvalidparam, @"Invalid userobject index");
else
[isa insertObject: obj forKey: n];
[object_getClass(self) insertObject: obj forKey: n];
}
- (void)DPSexecuserobject: (int)index
- (void)DPSexecuserobject: (NSInteger)index
{
id obj;
if (index < 0 || (obj = [isa getObjectForKey: index]) == nil)
if (index < 0 || (obj = [object_getClass(self) getObjectForKey: index]) == nil)
{
DPS_ERROR(DPSinvalidparam, @"Invalid userobject index");
return;
@ -960,14 +1003,14 @@ static NSMapTable *gtable;
ctxt_push(obj, opstack);
}
- (void)DPSundefineuserobject: (int)index
- (void)DPSundefineuserobject: (NSInteger)index
{
if (index < 0 || [isa getObjectForKey: index] == nil)
if (index < 0 || [object_getClass(self) getObjectForKey: index] == nil)
{
DPS_ERROR(DPSinvalidparam, @"Invalid gstate index");
return;
}
[isa removeObjectForKey: index];
[object_getClass(self) removeObjectForKey: index];
}
- (void)DPSclear

View file

@ -161,7 +161,7 @@
- (void) dissolveGState: (GSGState *)source
fromRect: (NSRect)aRect
toPoint: (NSPoint)aPoint
delta: (float)delta
delta: (CGFloat)delta
{
[self compositeGState: source
fromRect: aRect
@ -174,7 +174,7 @@
fromRect: (NSRect)aRect
toPoint: (NSPoint)aPoint
op: (NSCompositingOperation)op
fraction: (float)delta
fraction: (CGFloat)delta
{
[self subclassResponsibility: _cmd];
}
@ -207,12 +207,12 @@
/* ----------------------------------------------------------------------- */
/* Color operations */
/* ----------------------------------------------------------------------- */
- (void) DPScurrentalpha: (float*)a
- (void) DPScurrentalpha: (CGFloat*)a
{
*a = fillColor.field[AINDEX];
}
- (void) DPScurrentcmykcolor: (float*)c : (float*)m : (float*)y : (float*)k
- (void) DPScurrentcmykcolor: (CGFloat*)c : (CGFloat*)m : (CGFloat*)y : (CGFloat*)k
{
device_color_t new = fillColor;
gsColorToCMYK(&new);
@ -222,21 +222,21 @@
*k = new.field[3];
}
- (void) DPScurrentgray: (float*)gray
- (void) DPScurrentgray: (CGFloat*)gray
{
device_color_t gcolor = fillColor;
gsColorToGray(&gcolor);
*gray = gcolor.field[0];
}
- (void) DPScurrenthsbcolor: (float*)h : (float*)s : (float*)b
- (void) DPScurrenthsbcolor: (CGFloat*)h : (CGFloat*)s : (CGFloat*)b
{
device_color_t gcolor = fillColor;
gsColorToHSB(&gcolor);
*h = gcolor.field[0]; *s = gcolor.field[1]; *b = gcolor.field[2];
}
- (void) DPScurrentrgbcolor: (float*)r : (float*)g : (float*)b
- (void) DPScurrentrgbcolor: (CGFloat*)r : (CGFloat*)g : (CGFloat*)b
{
device_color_t gcolor = fillColor;
gsColorToRGB(&gcolor);
@ -247,7 +247,7 @@
if (x < 0.0) x = 0.0; \
if (x > 1.0) x = 1.0;
- (void) DPSsetalpha: (float)a
- (void) DPSsetalpha: (CGFloat)a
{
CLAMP(a)
fillColor.field[AINDEX] = strokeColor.field[AINDEX] = a;
@ -255,7 +255,7 @@
[self setColor: &strokeColor state: COLOR_STROKE];
}
- (void) DPSsetcmykcolor: (float)c : (float)m : (float)y : (float)k
- (void) DPSsetcmykcolor: (CGFloat)c : (CGFloat)m : (CGFloat)y : (CGFloat)k
{
device_color_t col;
CLAMP(c)
@ -268,7 +268,7 @@
[self setColor: &col state: COLOR_BOTH];
}
- (void) DPSsetgray: (float)gray
- (void) DPSsetgray: (CGFloat)gray
{
device_color_t col;
CLAMP(gray)
@ -278,7 +278,7 @@
[self setColor: &col state: COLOR_BOTH];
}
- (void) DPSsethsbcolor: (float)h : (float)s : (float)b
- (void) DPSsethsbcolor: (CGFloat)h : (CGFloat)s : (CGFloat)b
{
device_color_t col;
CLAMP(h)
@ -290,7 +290,7 @@
[self setColor: &col state: COLOR_BOTH];
}
- (void) DPSsetrgbcolor: (float)r : (float)g : (float)b
- (void) DPSsetrgbcolor: (CGFloat)r : (CGFloat)g : (CGFloat)b
{
device_color_t col;
CLAMP(r)
@ -402,10 +402,10 @@ typedef enum {
/* Omnibus show string routine that combines that characteristics of
ashow, awidthshow, widthshow, xshow, xyshow, and yshow */
- (void) _showString: (const char *)s
xCharAdj: (float)cx
yCharAdj: (float)cy
xCharAdj: (CGFloat)cx
yCharAdj: (CGFloat)cy
char: (char)c
adjArray: (const float *)arr
adjArray: (const CGFloat *)arr
arrType: (show_array_t)type
isRelative: (BOOL)relative;
{
@ -478,9 +478,9 @@ typedef enum {
free(uch);
}
- (void) DPSashow: (float)x : (float)y : (const char*)s
- (void) DPSashow: (CGFloat)x : (CGFloat)y : (const char*)s
{
float arr[2];
CGFloat arr[2];
arr[0] = x; arr[1] = y;
[self _showString: s
@ -488,10 +488,10 @@ typedef enum {
isRelative: YES];
}
- (void) DPSawidthshow: (float)cx : (float)cy : (int)c : (float)ax : (float)ay
- (void) DPSawidthshow: (CGFloat)cx : (CGFloat)cy : (int)c : (CGFloat)ax : (CGFloat)ay
: (const char*)s
{
float arr[2];
CGFloat arr[2];
arr[0] = ax; arr[1] = ay;
[self _showString: s
@ -571,9 +571,9 @@ typedef enum {
[self subclassResponsibility: _cmd];
}
- (void) DPSwidthshow: (float)x : (float)y : (int)c : (const char*)s
- (void) DPSwidthshow: (CGFloat)x : (CGFloat)y : (int)c : (const char*)s
{
float arr[2];
CGFloat arr[2];
arr[0] = 0; arr[1] = 0;
[self _showString: s
@ -581,28 +581,28 @@ typedef enum {
isRelative: YES];
}
- (void) DPSxshow: (const char*)s : (const float*)numarray : (int)size
- (void) DPSxshow: (const char*)s : (const CGFloat*)numarray : (int)size
{
[self _showString: s
xCharAdj: 0 yCharAdj: 0 char: 0 adjArray: numarray arrType: show_array_x
isRelative: NO];
}
- (void) DPSxyshow: (const char*)s : (const float*)numarray : (int)size
- (void) DPSxyshow: (const char*)s : (const CGFloat*)numarray : (int)size
{
[self _showString: s
xCharAdj: 0 yCharAdj: 0 char: 0 adjArray: numarray arrType: show_array_xy
isRelative: NO];
}
- (void) DPSyshow: (const char*)s : (const float*)numarray : (int)size
- (void) DPSyshow: (const char*)s : (const CGFloat*)numarray : (int)size
{
[self _showString: s
xCharAdj: 0 yCharAdj: 0 char: 0 adjArray: numarray arrType: show_array_y
isRelative: NO];
}
- (void) GSSetCharacterSpacing: (float)extra
- (void) GSSetCharacterSpacing: (CGFloat)extra
{
charSpacing = extra;
}
@ -614,7 +614,7 @@ typedef enum {
ASSIGN(font, fontref);
}
- (void) GSSetFontSize: (float)size
- (void) GSSetFontSize: (CGFloat)size
{
}
@ -694,7 +694,7 @@ typedef enum {
textCtm = [[NSAffineTransform allocWithZone: [self zone]] init];
}
- (void)DPScurrentflat: (float *)flatness
- (void)DPScurrentflat: (CGFloat *)flatness
{
if (path)
*flatness = [path flatness];
@ -712,12 +712,12 @@ typedef enum {
[self subclassResponsibility: _cmd];
}
- (void) DPScurrentlinewidth: (float*)width
- (void) DPScurrentlinewidth: (CGFloat*)width
{
[self subclassResponsibility: _cmd];
}
- (void) DPScurrentmiterlimit: (float*)limit
- (void) DPScurrentmiterlimit: (CGFloat*)limit
{
[self subclassResponsibility: _cmd];
}
@ -740,7 +740,7 @@ typedef enum {
return user;
}
- (void)DPScurrentpoint: (float *)x : (float *)y
- (void)DPScurrentpoint: (CGFloat *)x : (CGFloat *)y
{
NSPoint user;
@ -754,12 +754,12 @@ typedef enum {
[self subclassResponsibility: _cmd];
}
- (void) DPSsetdash: (const float*)pat : (int)size : (float)offset
- (void) DPSsetdash: (const CGFloat*)pat : (NSInteger)size : (CGFloat)offset
{
[self subclassResponsibility: _cmd];
}
- (void)DPSsetflat: (float)flatness
- (void)DPSsetflat: (CGFloat)flatness
{
if (path)
[path setFlatness: flatness];
@ -775,12 +775,12 @@ typedef enum {
[self subclassResponsibility: _cmd];
}
- (void) DPSsetlinewidth: (float)width
- (void) DPSsetlinewidth: (CGFloat)width
{
[self subclassResponsibility: _cmd];
}
- (void) DPSsetmiterlimit: (float)limit
- (void) DPSsetmiterlimit: (CGFloat)limit
{
[self subclassResponsibility: _cmd];
}
@ -793,7 +793,7 @@ typedef enum {
/* ----------------------------------------------------------------------- */
/* Matrix operations */
/* ----------------------------------------------------------------------- */
- (void)DPSconcat: (const float *)m
- (void)DPSconcat: (const CGFloat *)m
{
NSAffineTransformStruct matrix;
NSAffineTransform *new_ctm = [NSAffineTransform new];
@ -815,17 +815,17 @@ typedef enum {
[ctm makeIdentityMatrix];
}
- (void)DPSrotate: (float)angle
- (void)DPSrotate: (CGFloat)angle
{
[ctm rotateByDegrees: angle];
}
- (void)DPSscale: (float)x : (float)y
- (void)DPSscale: (CGFloat)x : (CGFloat)y
{
[ctm scaleXBy: x yBy: y];
}
- (void)DPStranslate: (float)x : (float)y
- (void)DPStranslate: (CGFloat)x : (CGFloat)y
{
[ctm translateToPoint: NSMakePoint(x, y)];
}
@ -848,7 +848,7 @@ typedef enum {
/* ----------------------------------------------------------------------- */
/* Paint operations */
/* ----------------------------------------------------------------------- */
- (void) DPSarc: (float)x : (float)y : (float)r : (float)angle1 : (float)angle2
- (void) DPSarc: (CGFloat)x : (CGFloat)y : (CGFloat)r : (CGFloat)angle1 : (CGFloat)angle2
{
NSBezierPath *newPath;
@ -868,7 +868,7 @@ typedef enum {
RELEASE(newPath);
}
- (void) DPSarcn: (float)x : (float)y : (float)r : (float)angle1 : (float)angle2
- (void) DPSarcn: (CGFloat)x : (CGFloat)y : (CGFloat)r : (CGFloat)angle1 : (CGFloat)angle2
{
NSBezierPath *newPath;
@ -888,7 +888,7 @@ typedef enum {
RELEASE(newPath);
}
- (void)DPSarct: (float)x1 : (float)y1 : (float)x2 : (float)y2 : (float)r
- (void)DPSarct: (CGFloat)x1 : (CGFloat)y1 : (CGFloat)x2 : (CGFloat)y2 : (CGFloat)r
{
NSBezierPath *newPath;
@ -917,8 +917,8 @@ typedef enum {
[path closePath];
}
- (void)DPScurveto: (float)x1 : (float)y1 : (float)x2 : (float)y2 : (float)x3
: (float)y3
- (void)DPScurveto: (CGFloat)x1 : (CGFloat)y1 : (CGFloat)x2 : (CGFloat)y2 : (CGFloat)x3
: (CGFloat)y3
{
NSPoint p1 = [ctm transformPoint: NSMakePoint(x1, y1)];
NSPoint p2 = [ctm transformPoint: NSMakePoint(x2, y2)];
@ -954,7 +954,7 @@ typedef enum {
[self subclassResponsibility: _cmd];
}
- (void)DPSlineto: (float)x : (float)y
- (void)DPSlineto: (CGFloat)x : (CGFloat)y
{
NSPoint p = [ctm transformPoint: NSMakePoint(x, y)];
@ -962,7 +962,7 @@ typedef enum {
[path lineToPoint: p];
}
- (void)DPSmoveto: (float)x : (float)y
- (void)DPSmoveto: (CGFloat)x : (CGFloat)y
{
NSPoint p = [ctm transformPoint: NSMakePoint(x, y)];
@ -988,7 +988,7 @@ typedef enum {
return AUTORELEASE(newPath);
}
- (void)DPSpathbbox: (float *)llx : (float *)lly : (float *)urx : (float *)ury
- (void)DPSpathbbox: (CGFloat *)llx : (CGFloat *)lly : (CGFloat *)urx : (CGFloat *)ury
{
NSBezierPath *bpath = [self bezierPath];
NSRect rect = [bpath controlPointBounds];
@ -1003,8 +1003,8 @@ typedef enum {
*ury = NSMaxY(rect);
}
- (void)DPSrcurveto: (float)x1 : (float)y1 : (float)x2 : (float)y2 : (float)x3
: (float)y3
- (void)DPSrcurveto: (CGFloat)x1 : (CGFloat)y1 : (CGFloat)x2 : (CGFloat)y2 : (CGFloat)x3
: (CGFloat)y3
{
NSPoint p1 = [ctm deltaPointInMatrixSpace: NSMakePoint(x1, y1)];
NSPoint p2 = [ctm deltaPointInMatrixSpace: NSMakePoint(x2, y2)];
@ -1016,7 +1016,7 @@ typedef enum {
controlPoint2: p2];
}
- (void) DPSrectclip: (float)x : (float)y : (float)w : (float)h
- (void) DPSrectclip: (CGFloat)x : (CGFloat)y : (CGFloat)w : (CGFloat)h
{
NSBezierPath *oldPath = path;
@ -1030,7 +1030,7 @@ typedef enum {
[path removeAllPoints];
}
- (void) DPSrectfill: (float)x : (float)y : (float)w : (float)h
- (void) DPSrectfill: (CGFloat)x : (CGFloat)y : (CGFloat)w : (CGFloat)h
{
NSBezierPath *oldPath = path;
@ -1042,7 +1042,7 @@ typedef enum {
path = oldPath;
}
- (void) DPSrectstroke: (float)x : (float)y : (float)w : (float)h
- (void) DPSrectstroke: (CGFloat)x : (CGFloat)y : (CGFloat)w : (CGFloat)h
{
NSBezierPath *oldPath = path;
@ -1060,7 +1060,7 @@ typedef enum {
ASSIGN(path, [path bezierPathByReversingPath]);
}
- (void)DPSrlineto: (float)x : (float)y
- (void)DPSrlineto: (CGFloat)x : (CGFloat)y
{
NSPoint p = [ctm deltaPointInMatrixSpace: NSMakePoint(x, y)];
@ -1068,7 +1068,7 @@ typedef enum {
[path relativeLineToPoint: p];
}
- (void)DPSrmoveto: (float)x : (float)y
- (void)DPSrmoveto: (CGFloat)x : (CGFloat)y
{
NSPoint p = [ctm deltaPointInMatrixSpace: NSMakePoint(x, y)];
@ -1083,9 +1083,9 @@ typedef enum {
- (void) GSSendBezierPath: (NSBezierPath *)newpath
{
int count = 10;
float dash_pattern[10];
float phase;
NSInteger count = 10;
CGFloat dash_pattern[10];
CGFloat phase;
// Appending to the current path is a lot faster than copying!
//ASSIGNCOPY(path, newpath);
@ -1141,9 +1141,9 @@ typedef enum {
}
- (void)DPSimage: (NSAffineTransform*) matrix
: (int) pixelsWide : (int) pixelsHigh
: (int) bitsPerSample : (int) samplesPerPixel
: (int) bitsPerPixel : (int) bytesPerRow : (BOOL) isPlanar
: (NSInteger) pixelsWide : (NSInteger) pixelsHigh
: (NSInteger) bitsPerSample : (NSInteger) samplesPerPixel
: (NSInteger) bitsPerPixel : (NSInteger) bytesPerRow : (BOOL) isPlanar
: (BOOL) hasAlpha : (NSString *) colorSpaceName
: (const unsigned char *const [5]) data
{
@ -1276,8 +1276,8 @@ typedef enum {
- (void) _fillRect: (NSRect)rect withPattern: (NSImage*)color_pattern
{
NSSize size;
float x;
float y;
CGFloat x;
CGFloat y;
NSAffineTransform *ictm;
// The coordinates we get here are already in device space,

View file

@ -134,7 +134,7 @@ fpfloat(FILE *stream, float f)
/* ----------------------------------------------------------------------- */
/* Color operations */
/* ----------------------------------------------------------------------- */
- (void) DPSsetalpha: (float)a
- (void) DPSsetalpha: (CGFloat)a
{
[super DPSsetalpha: a];
/* This needs to be defined base on the the language level, etc. in
@ -143,7 +143,7 @@ fpfloat(FILE *stream, float f)
fprintf(gstream, "GSsetalpha\n");
}
- (void) DPSsetcmykcolor: (float)c : (float)m : (float)y : (float)k
- (void) DPSsetcmykcolor: (CGFloat)c : (CGFloat)m : (CGFloat)y : (CGFloat)k
{
[super DPSsetcmykcolor: c : m : y : k];
fpfloat(gstream, c);
@ -153,14 +153,14 @@ fpfloat(FILE *stream, float f)
fprintf(gstream, "setcmykcolor\n");
}
- (void) DPSsetgray: (float)gray
- (void) DPSsetgray: (CGFloat)gray
{
[super DPSsetgray: gray];
fpfloat(gstream, gray);
fprintf(gstream, "setgray\n");
}
- (void) DPSsethsbcolor: (float)h : (float)s : (float)b
- (void) DPSsethsbcolor: (CGFloat)h : (CGFloat)s : (CGFloat)b
{
[super DPSsethsbcolor: h : s : b];
fpfloat(gstream, h);
@ -169,7 +169,7 @@ fpfloat(FILE *stream, float f)
fprintf(gstream, "sethsbcolor\n");
}
- (void) DPSsetrgbcolor: (float)r : (float)g : (float)b
- (void) DPSsetrgbcolor: (CGFloat)r : (CGFloat)g : (CGFloat)b
{
[super DPSsetrgbcolor: r : g : b];
fpfloat(gstream, r);
@ -196,7 +196,7 @@ fpfloat(FILE *stream, float f)
/* ----------------------------------------------------------------------- */
/* Text operations */
/* ----------------------------------------------------------------------- */
- (void) DPSashow: (float)x : (float)y : (const char*)s
- (void) DPSashow: (CGFloat)x : (CGFloat)y : (const char*)s
{
fpfloat(gstream, x);
fpfloat(gstream, y);
@ -205,7 +205,7 @@ fpfloat(FILE *stream, float f)
fprintf(gstream, ") ashow\n");
}
- (void) DPSawidthshow: (float)cx : (float)cy : (int)c : (float)ax : (float)ay : (const char*)s
- (void) DPSawidthshow: (CGFloat)cx : (CGFloat)cy : (int)c : (CGFloat)ax : (CGFloat)ay : (const char*)s
{
fpfloat(gstream, cx);
fpfloat(gstream, cy);
@ -231,7 +231,7 @@ fpfloat(FILE *stream, float f)
fprintf(gstream, ") show\n");
}
- (void) DPSwidthshow: (float)x : (float)y : (int)c : (const char*)s
- (void) DPSwidthshow: (CGFloat)x : (CGFloat)y : (int)c : (const char*)s
{
fpfloat(gstream, x);
fpfloat(gstream, y);
@ -240,23 +240,23 @@ fpfloat(FILE *stream, float f)
fprintf(gstream, ") widthshow\n");
}
- (void) DPSxshow: (const char*)s : (const float*)numarray : (int)size
- (void) DPSxshow: (const char*)s : (const CGFloat*)numarray : (int)size
{
[self notImplemented: _cmd];
}
- (void) DPSxyshow: (const char*)s : (const float*)numarray : (int)size
- (void) DPSxyshow: (const char*)s : (const CGFloat*)numarray : (int)size
{
[self notImplemented: _cmd];
}
- (void) DPSyshow: (const char*)s : (const float*)numarray : (int)size
- (void) DPSyshow: (const char*)s : (const CGFloat*)numarray : (int)size
{
[self notImplemented: _cmd];
}
- (void) GSSetCharacterSpacing: (float)extra
- (void) GSSetCharacterSpacing: (CGFloat)extra
{
[self notImplemented: _cmd];
}
@ -278,7 +278,7 @@ fpfloat(FILE *stream, float f)
[super GSSetFont: fontref];
}
- (void) GSSetFontSize: (float)size
- (void) GSSetFontSize: (CGFloat)size
{
[self notImplemented: _cmd];
}
@ -379,7 +379,7 @@ fpfloat(FILE *stream, float f)
/* ----------------------------------------------------------------------- */
/* Gstate operations */
/* ----------------------------------------------------------------------- */
- (void) DPSsetdash: (const float*)pat : (int)size : (float)offset
- (void) DPSsetdash: (const CGFloat*)pat : (NSInteger)size : (CGFloat)offset
{
int i;
fprintf(gstream, "[");
@ -390,14 +390,14 @@ fpfloat(FILE *stream, float f)
fprintf(gstream, "setdash\n");
}
- (void) DPSsetflat: (float)flatness
- (void) DPSsetflat: (CGFloat)flatness
{
[super DPSsetflat: flatness];
fpfloat(gstream, flatness);
fprintf(gstream, "setflat\n");
}
- (void) DPSsethalftonephase: (float)x : (float)y
- (void) DPSsethalftonephase: (CGFloat)x : (CGFloat)y
{
[super DPSsethalftonephase: x : y];
fpfloat(gstream, x);
@ -417,14 +417,14 @@ fpfloat(FILE *stream, float f)
fprintf(gstream, "%d setlinejoin\n", linejoin);
}
- (void) DPSsetlinewidth: (float)width
- (void) DPSsetlinewidth: (CGFloat)width
{
[super DPSsetlinewidth: width];
fpfloat(gstream, width);
fprintf(gstream, "setlinewidth\n");
}
- (void) DPSsetmiterlimit: (float)limit
- (void) DPSsetmiterlimit: (CGFloat)limit
{
[super DPSsetmiterlimit: limit];
fpfloat(gstream, limit);
@ -441,7 +441,7 @@ fpfloat(FILE *stream, float f)
/* ----------------------------------------------------------------------- */
/* Matrix operations */
/* ----------------------------------------------------------------------- */
- (void) DPSconcat: (const float*)m
- (void) DPSconcat: (const CGFloat*)m
{
[super DPSconcat: m];
@ -474,14 +474,14 @@ fpfloat(FILE *stream, float f)
fprintf(gstream, "initmatrix\n");
}
- (void) DPSrotate: (float)angle
- (void) DPSrotate: (CGFloat)angle
{
[super DPSrotate: angle];
fpfloat(gstream, angle);
fprintf(gstream, "rotate\n");
}
- (void) DPSscale: (float)x : (float)y
- (void) DPSscale: (CGFloat)x : (CGFloat)y
{
[super DPSscale: x : y];
fpfloat(gstream, x);
@ -489,7 +489,7 @@ fpfloat(FILE *stream, float f)
fprintf(gstream, "scale\n");
}
- (void) DPStranslate: (float)x : (float)y
- (void) DPStranslate: (CGFloat)x : (CGFloat)y
{
[super DPStranslate: x : y];
fpfloat(gstream, x);
@ -529,7 +529,7 @@ fpfloat(FILE *stream, float f)
/* ----------------------------------------------------------------------- */
/* Paint operations */
/* ----------------------------------------------------------------------- */
- (void) DPSarc: (float)x : (float)y : (float)r : (float)angle1 : (float)angle2
- (void) DPSarc: (CGFloat)x : (CGFloat)y : (CGFloat)r : (CGFloat)angle1 : (CGFloat)angle2
{
fpfloat(gstream, x);
fpfloat(gstream, y);
@ -539,7 +539,7 @@ fpfloat(FILE *stream, float f)
fprintf(gstream, "arc\n");
}
- (void) DPSarcn: (float)x : (float)y : (float)r : (float)angle1 : (float)angle2
- (void) DPSarcn: (CGFloat)x : (CGFloat)y : (CGFloat)r : (CGFloat)angle1 : (CGFloat)angle2
{
fpfloat(gstream, x);
fpfloat(gstream, y);
@ -549,7 +549,7 @@ fpfloat(FILE *stream, float f)
fprintf(gstream, "arcn\n");
}
- (void) DPSarct: (float)x1 : (float)y1 : (float)x2 : (float)y2 : (float)r
- (void) DPSarct: (CGFloat)x1 : (CGFloat)y1 : (CGFloat)x2 : (CGFloat)y2 : (CGFloat)r
{
fpfloat(gstream, x1);
fpfloat(gstream, y1);
@ -569,8 +569,8 @@ fpfloat(FILE *stream, float f)
fprintf(gstream, "closepath\n");
}
- (void)DPScurveto: (float)x1 : (float)y1 : (float)x2 : (float)y2
: (float)x3 : (float)y3
- (void)DPScurveto: (CGFloat)x1 : (CGFloat)y1 : (CGFloat)x2 : (CGFloat)y2
: (CGFloat)x3 : (CGFloat)y3
{
fpfloat(gstream, x1);
fpfloat(gstream, y1);
@ -606,14 +606,14 @@ fpfloat(FILE *stream, float f)
fprintf(gstream, "initclip\n");
}
- (void) DPSlineto: (float)x : (float)y
- (void) DPSlineto: (CGFloat)x : (CGFloat)y
{
fpfloat(gstream, x);
fpfloat(gstream, y);
fprintf(gstream, "lineto\n");
}
- (void) DPSmoveto: (float)x : (float)y
- (void) DPSmoveto: (CGFloat)x : (CGFloat)y
{
fpfloat(gstream, x);
fpfloat(gstream, y);
@ -625,12 +625,12 @@ fpfloat(FILE *stream, float f)
fprintf(gstream, "newpath\n");
}
- (void) DPSpathbbox: (float*)llx : (float*)lly : (float*)urx : (float*)ury
- (void) DPSpathbbox: (CGFloat*)llx : (CGFloat*)lly : (CGFloat*)urx : (CGFloat*)ury
{
}
- (void) DPSrcurveto: (float)x1 : (float)y1 : (float)x2 : (float)y2
: (float)x3 : (float)y3
- (void) DPSrcurveto: (CGFloat)x1 : (CGFloat)y1 : (CGFloat)x2 : (CGFloat)y2
: (CGFloat)x3 : (CGFloat)y3
{
fpfloat(gstream, x1);
fpfloat(gstream, y1);
@ -641,7 +641,7 @@ fpfloat(FILE *stream, float f)
fprintf(gstream, "rcurveto\n");
}
- (void) DPSrectclip: (float)x : (float)y : (float)w : (float)h
- (void) DPSrectclip: (CGFloat)x : (CGFloat)y : (CGFloat)w : (CGFloat)h
{
fpfloat(gstream, x);
fpfloat(gstream, y);
@ -650,7 +650,7 @@ fpfloat(FILE *stream, float f)
fprintf(gstream, "rectclip\n");
}
- (void) DPSrectfill: (float)x : (float)y : (float)w : (float)h
- (void) DPSrectfill: (CGFloat)x : (CGFloat)y : (CGFloat)w : (CGFloat)h
{
fpfloat(gstream, x);
fpfloat(gstream, y);
@ -659,7 +659,7 @@ fpfloat(FILE *stream, float f)
fprintf(gstream, "rectfill\n");
}
- (void) DPSrectstroke: (float)x : (float)y : (float)w : (float)h
- (void) DPSrectstroke: (CGFloat)x : (CGFloat)y : (CGFloat)w : (CGFloat)h
{
fpfloat(gstream, x);
fpfloat(gstream, y);
@ -673,14 +673,14 @@ fpfloat(FILE *stream, float f)
fprintf(gstream, "reversepath\n");
}
- (void) DPSrlineto: (float)x : (float)y
- (void) DPSrlineto: (CGFloat)x : (CGFloat)y
{
fpfloat(gstream, x);
fpfloat(gstream, y);
fprintf(gstream, "rlineto\n");
}
- (void) DPSrmoveto: (float)x : (float)y
- (void) DPSrmoveto: (CGFloat)x : (CGFloat)y
{
fpfloat(gstream, x);
fpfloat(gstream, y);
@ -696,9 +696,9 @@ fpfloat(FILE *stream, float f)
{
NSBezierPathElement type;
NSPoint pts[3];
int i, count = 10;
float pattern[10];
float phase = 0.0;
NSInteger i, count = 10;
CGFloat pattern[10];
CGFloat phase = 0.0;
[self DPSnewpath];
[self DPSsetlinewidth: [path lineWidth]];
@ -736,7 +736,7 @@ fpfloat(FILE *stream, float f)
}
}
- (void) GSRectClipList: (const NSRect *)rects: (int)count
- (void) GSRectClipList: (const NSRect *)rects : (int)count
{
int i;
NSRect union_rect;
@ -757,7 +757,7 @@ fpfloat(FILE *stream, float f)
: NSWidth(union_rect) : NSHeight(union_rect)];
}
- (void) GSRectFillList: (const NSRect *)rects: (int)count
- (void) GSRectFillList: (const NSRect *)rects : (int)count
{
int i;
for (i = 0; i < count; i++)
@ -792,39 +792,39 @@ fpfloat(FILE *stream, float f)
/*-------------------------------------------------------------------------*/
/* Graphics Extensions Ops */
/*-------------------------------------------------------------------------*/
- (void) DPScomposite: (float)x : (float)y : (float)w : (float)h
: (int)gstateNum : (float)dx : (float)dy : (int)op
- (void) DPScomposite: (CGFloat)x : (CGFloat)y : (CGFloat)w : (CGFloat)h
: (NSInteger)gstateNum : (CGFloat)dx : (CGFloat)dy : (NSCompositingOperation)op
{
fpfloat(gstream, x);
fpfloat(gstream, y);
fpfloat(gstream, w);
fpfloat(gstream, h);
fprintf(gstream, "%d ", gstateNum);
fprintf(gstream, "%d ", (int)gstateNum);
fpfloat(gstream, dx);
fpfloat(gstream, dy);
fprintf(gstream, "%d composite\n", op);
fprintf(gstream, "%d composite\n", (int)op);
}
- (void) DPScompositerect: (float)x : (float)y : (float)w : (float)h : (int)op
- (void) DPScompositerect: (CGFloat)x : (CGFloat)y : (CGFloat)w : (CGFloat)h : (NSCompositingOperation)op
{
fpfloat(gstream, x);
fpfloat(gstream, y);
fpfloat(gstream, w);
fpfloat(gstream, h);
fprintf(gstream, "%d compositerect\n", op);
fprintf(gstream, "%d compositerect\n", (int)op);
}
- (void) DPSdissolve: (float)x : (float)y : (float)w : (float)h
: (int)gstateNum : (float)dx : (float)dy : (float)delta
- (void) DPSdissolve: (CGFloat)x : (CGFloat)y : (CGFloat)w : (CGFloat)h
: (NSInteger)gstateNum : (CGFloat)dx : (CGFloat)dy : (CGFloat)delta
{
NSLog(@"DPSinvalidcontext: dissolve in a stream context");
}
- (void) GScomposite: (int)gstateNum
- (void) GScomposite: (NSInteger)gstateNum
toPoint: (NSPoint)aPoint
fromRect: (NSRect)srcRect
operation: (NSCompositingOperation)op
fraction: (float)delta
fraction: (CGFloat)delta
{
[self DPScomposite: NSMinX(srcRect) : NSMinY(srcRect) : NSWidth(srcRect) : NSHeight(srcRect)
: gstateNum : aPoint.x : aPoint.y : op];
@ -888,14 +888,14 @@ static const char *hexdigits = "0123456789abcdef";
@implementation GSStreamContext (Graphics)
- (void) NSDrawBitmap: (NSRect)rect : (int)pixelsWide : (int)pixelsHigh
: (int)bitsPerSample : (int)samplesPerPixel
: (int)bitsPerPixel : (int)bytesPerRow : (BOOL)isPlanar
- (void) NSDrawBitmap: (NSRect)rect : (NSInteger)pixelsWide : (NSInteger)pixelsHigh
: (NSInteger)bitsPerSample : (NSInteger)samplesPerPixel
: (NSInteger)bitsPerPixel : (NSInteger)bytesPerRow : (BOOL)isPlanar
: (BOOL)hasAlpha : (NSString *)colorSpaceName
: (const unsigned char *const [5])data
{
int bytes, spp;
float y;
NSInteger bytes, spp;
CGFloat y;
BOOL flipped = NO;
/* In a flipped view, we don't want to flip the image again, which would
@ -921,9 +921,9 @@ static const char *hexdigits = "0123456789abcdef";
(bitsPerSample * pixelsWide * pixelsHigh + 7) / 8;
if (bytes * samplesPerPixel != bytesPerRow * pixelsHigh)
{
NSLog(@"Image Rendering Error: Dodgy bytesPerRow value %d", bytesPerRow);
NSLog(@"Image Rendering Error: Dodgy bytesPerRow value %d", (int)bytesPerRow);
NSLog(@" pixelsHigh=%d, bytes=%d, samplesPerPixel=%d",
bytesPerRow, pixelsHigh, bytes);
(int)bytesPerRow, (int)pixelsHigh, (int)bytes);
return;
}
if (hasAlpha)
@ -942,17 +942,17 @@ static const char *hexdigits = "0123456789abcdef";
}
}
fprintf(gstream, "%d %d %d [%d 0 0 %d 0 %d]\n",
pixelsWide, pixelsHigh, bitsPerSample, pixelsWide,
(flipped) ? pixelsHigh : -pixelsHigh, pixelsHigh);
(int)pixelsWide, (int)pixelsHigh, (int)bitsPerSample, (int)pixelsWide,
(flipped) ? (int)pixelsHigh : (int)-pixelsHigh, (int)pixelsHigh);
fprintf(gstream, "{currentfile %d string readhexstring pop}\n",
pixelsWide * spp);
fprintf(gstream, "false %d colorimage\n", spp);
(int)(pixelsWide * spp));
fprintf(gstream, "false %d colorimage\n", (int)spp);
}
else
{
fprintf(gstream, "%d %d %d [%d 0 0 %d 0 %d]\n",
pixelsWide, pixelsHigh, bitsPerSample, pixelsWide,
(flipped) ? pixelsHigh : -pixelsHigh, pixelsHigh);
(int)pixelsWide, (int)pixelsHigh, (int)bitsPerSample, (int)pixelsWide,
(flipped) ? (int)pixelsHigh : (int)-pixelsHigh, (int)pixelsHigh);
fprintf(gstream, "currentfile image\n");
}

View file

@ -62,13 +62,13 @@
*linejoin = clinejoin;
}
- (void) DPScurrentlinewidth: (float*)width
- (void) DPScurrentlinewidth: (CGFloat*)width
{
if (width)
*width = clinewidth;
}
- (void) DPScurrentmiterlimit: (float*)limit
- (void) DPScurrentmiterlimit: (CGFloat*)limit
{
if (limit)
*limit = cmiterlimit;
@ -90,12 +90,12 @@
clinejoin = linejoin;
}
- (void) DPSsetlinewidth: (float)width
- (void) DPSsetlinewidth: (CGFloat)width
{
clinewidth = width;
}
- (void) DPSsetmiterlimit: (float)limit
- (void) DPSsetmiterlimit: (CGFloat)limit
{
cmiterlimit = limit;
}
@ -106,5 +106,3 @@
}
@end

65
Source/opal/GNUmakefile Normal file
View file

@ -0,0 +1,65 @@
# Copyright (C) 2013 Free Software Foundation, Inc.
#
# Author: Ivan Vucica <ivan@vucica.net>
#
# This file is part of the GNUstep Backend.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; see the file COPYING.LIB.
# If not, see <http://www.gnu.org/licenses/> or write to the
# Free Software Foundation, 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
PACKAGE_NAME = gnustep-back
GNUSTEP_LOCAL_ADDITIONAL_MAKEFILES=../../back.make
include $(GNUSTEP_MAKEFILES)/common.make
include ../../config.make
SUBPROJECT_NAME=opal
# The Objective-C source files to be compiled
opal_OBJC_FILES = OpalSurface.m \
OpalFontInfo.m \
OpalGState.m \
OpalContext.m \
OpalFontEnumerator.m \
OpalFaceInfo.m \
OpalPSSurface.m \
OpalPDFSurface.m \
ifeq ($(BUILD_SERVER),x11DISABLED)
ifeq ($(WITH_GLITZ),yes)
opal_OBJC_FILES += XGCairoGlitzSurface.m
else
opal_OBJC_FILES += XGCairoSurface.m XGCairoXImageSurface.m XGCairoModernSurface.m
endif
else
ifeq ($(BUILD_GRAPHICS),opalDISABLED)
ifeq ($(WITH_GLITZ),yes)
opal_OBJC_FILES += Win32CairoGlitzSurface.m
else
opal_OBJC_FILES += Win32CairoSurface.m Win32CairoGState.m
# Win32CairoXImageSurface.m
endif
endif
endif
opal_OBJC_FILES +=
-include GNUmakefile.preamble
include $(GNUSTEP_MAKEFILES)/subproject.make
-include GNUmakefile.postamble

View file

@ -0,0 +1,52 @@
#
# GNUmakefile.preamble
#
# Copyright (C) 2002 Free Software Foundation, Inc.
#
# Author: Adam Fedor <fedor@gnu.org>
#
# This file is part of the GNUstep Backend.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; see the file COPYING.LIB.
# If not, see <http://www.gnu.org/licenses/> or write to the
# Free Software Foundation, 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
#
# Flags dealing with compiling and linking
#
# Additional flags to pass to the preprocessor
ADDITIONAL_CPPFLAGS += -Wall $(CONFIG_SYSTEM_DEFS)
# Additional flags to pass to the Objective-C compiler
#ADDITIONAL_OBJCFLAGS =
# Additional flags to pass to the C compiler
#ADDITIONAL_CFLAGS =
# Additional include directories the compiler should search
ADDITIONAL_INCLUDE_DIRS = -I../../Headers \
-I../$(GNUSTEP_TARGET_DIR) $(GRAPHIC_CFLAGS) \
# Additional LDFLAGS to pass to the linker
#ADDITIONAL_LDFLAGS =
# Additional library directories the linker should search
#ADDITIONAL_LIB_DIRS =
#
# Flags dealing with installing and uninstalling
#

118
Source/opal/OpalContext.m Normal file
View file

@ -0,0 +1,118 @@
/*
OpalContext.m
Copyright (C) 2013 Free Software Foundation, Inc.
Author: Ivan Vucica <ivan@vucica.net>
Date: June 2013
This file is part of GNUstep.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; see the file COPYING.LIB.
If not, see <http://www.gnu.org/licenses/> or write to the
Free Software Foundation, 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#import "opal/OpalContext.h"
#import "opal/OpalFontInfo.h"
#import "opal/OpalFontEnumerator.h"
#import "opal/OpalSurface.h"
#import "opal/OpalGState.h"
#define OGSTATE ((OpalGState *)gstate)
@implementation OpalContext
+ (void) initializeBackend
{
[NSGraphicsContext setDefaultContextClass: self];
[GSFontEnumerator setDefaultClass: [OpalFontEnumerator class]];
[GSFontInfo setDefaultClass: [OpalFontInfo class]];
}
+ (Class) GStateClass
{
return [OpalGState class];
}
- (void) GSSetDevice: (void *)device
: (int)x
: (int)y
{
OpalSurface *surface;
surface = [[OpalSurface alloc] initWithDevice: device];
[OGSTATE GSSetSurface: surface
: x
: y];
[surface release];
}
- (BOOL) isDrawingToScreen
{
OpalSurface *surface = nil;
[OGSTATE GSCurrentSurface: &surface : NULL : NULL];
return [surface isDrawingToScreen];
}
- (void) DPSgsave
{
[super DPSgsave];
[OGSTATE DPSgsave];
}
- (void) DPSgrestore
{
[super DPSgrestore];
[OGSTATE DPSgrestore];
}
/**
This handles 'expose' event notifications that arrive from
X11.
*/
+ (void) handleExposeRect: (NSRect)rect forDriver: (void *)driver
{
if ([(id)driver isKindOfClass: [OpalSurface class]])
{
[(OpalSurface *)driver handleExposeRect: rect];
}
}
- (void *) graphicsPort
{
OpalSurface * surface;
[OGSTATE GSCurrentSurface: &surface : NULL : NULL];
return [surface cgContext];
}
#if BUILD_SERVER == SERVER_x11
#ifdef XSHM
+ (void) _gotShmCompletion: (Drawable)d
{
[XWindowBuffer _gotShmCompletion: d];
}
- (void) gotShmCompletion: (Drawable)d
{
[XWindowBuffer _gotShmCompletion: d];
}
#endif // XSHM
#endif // BUILD_SERVER = SERVER_x11
@end

View file

View file

@ -0,0 +1,125 @@
/*
OpalFontEnumerator.m
Copyright (C) 2013 Free Software Foundation, Inc.
Author: Ivan Vucica <ivan@vucica.net>
Date: June 2013
This file is part of GNUstep.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; see the file COPYING.LIB.
If not, see <http://www.gnu.org/licenses/> or write to the
Free Software Foundation, 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#import "opal/OpalFontEnumerator.h"
#import <Foundation/Foundation.h>
@interface OpalFaceInfo : NSObject
/* DUMMY interface */
{
NSString * _familyName;
int _weight;
unsigned int _traits;
}
- (id) initWithFamilyName: (NSString *)familyName
weight: (int)weight
traits: (unsigned int)traits;
- (unsigned int) cacheSize;
- (int) weight;
- (void) setWeight: (int)weight;
- (unsigned int) traits;
- (void) setTraits: (unsigned int)traits;
- (NSString *) familyName;
- (void) setFamilyName: (NSString *)name;
- (NSCharacterSet*)characterSet;
@end
@implementation OpalFaceInfo
/* DUMMY implementation */
- (id) initWithFamilyName: (NSString *)familyName
weight: (int)weight
traits: (unsigned int)traits
{
self = [super init];
if (!self)
return nil;
_familyName = [familyName retain];
_weight = weight;
_traits = traits;
return self;
}
- (int) weight { NSDebugLLog(@"OpalFaceInfo", @"OpalFaceInfo: Weight %d", _weight); return _weight; }
- (void) setWeight: (int)weight { _weight = weight; }
- (unsigned int) traits { return _traits; }
- (void) setTraits: (unsigned int)traits { _traits = traits; }
- (NSString *)familyName { return _familyName; }
- (void) setFamilyName: (NSString *)name { [_familyName release]; _familyName = [name retain]; }
- (NSCharacterSet *) characterSet { NSDebugLLog(@"OpalFaceInfo", @"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
return [NSCharacterSet alphanumericCharacterSet]; }
@end
@implementation OpalFontEnumerator
+ (OpalFaceInfo *) fontWithName: (NSString *) name
{
NSDebugLLog(@"OpalFontEnumerator", @"%p (%@): %s - %@", self, [self class], __PRETTY_FUNCTION__, name);
return [[[OpalFaceInfo alloc] initWithFamilyName:name weight:1 traits:0] autorelease];
}
- (void) enumerateFontsAndFamilies
{
NSDebugLLog(@"OpalFontEnumerator", @"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
allFontNames = [[NSArray arrayWithObjects: @"FreeSans",
@"FreeSans-Bold", @"FreeMono", nil] retain];
allFontFamilies = [[NSDictionary dictionaryWithObjectsAndKeys:
@"FreeSans", @"FreeSans",
@"FreeMono", @"FreeMono",
nil] retain];
}
- (NSString *) defaultSystemFontName
{
NSDebugLLog(@"OpalFontEnumerator", @"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
return @"FreeSans";
}
- (NSString *) defaultBoldSystemFontName
{
NSDebugLLog(@"OpalFontEnumerator", @"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
return @"FreeSans-Bold";
}
- (NSString *) defaultFixedPitchFontName
{
NSDebugLLog(@"OpalFontEnumerator", @"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
return @"FreeMono";
}
- (NSArray *) matchingFontDescriptorsFor: (NSDictionary *)attributes
{
NSDebugLLog(@"OpalFontEnumerator", @"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
return [NSArray arrayWithObject:[NSFontDescriptor fontDescriptorWithName:@"FreeSans" size: 10]];
}
@end

View file

@ -0,0 +1,77 @@
/*
OpalFontInfo.m
Copyright (C) 2013 Free Software Foundation, Inc.
Author: Ivan Vucica <ivan@vucica.net>
Date: June 2013
This file is part of GNUstep.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; see the file COPYING.LIB.
If not, see <http://www.gnu.org/licenses/> or write to the
Free Software Foundation, 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#import <Foundation/Foundation.h>
#import "opal/OpalFontInfo.h"
@implementation OpalFontInfo
- (id) initWithFontName: (NSString *)name
matrix: (const CGFloat *)fmatrix
screenFont: (BOOL)p_screenFont
{
NSDebugLLog(@"OpalFontInfo", @"OpalFontInfo: instantiating font info for %@", name);
return [super init];
}
- (NSRect) boundingRectForGlyph: (NSGlyph)glyph
{
NSDebugLLog(@"OpalFontInfo", @"OpalFontInfo: %s - %c", __PRETTY_FUNCTION__, glyph);
return NSMakeRect(0, 0, 10, 10);
}
- (CGFloat) widthOfString: (NSString *)string
{
NSDebugLLog(@"OpalFontInfo", @"OpalFontInfo: %s - %@", __PRETTY_FUNCTION__, string);
return [string length] * 10;
}
- (NSSize) advancementForGlyph: (NSGlyph)glyph
{
NSDebugLLog(@"OpalFontInfo", @"OpalFontInfo: %s - %c", __PRETTY_FUNCTION__, glyph);
return NSMakeSize(100,100);
}
- (NSGlyph) glyphWithName: (NSString *) glyphName
{
NSDebugLLog(@"OpalFontInfo", @"OpalFontInfo: %s - %@", __PRETTY_FUNCTION__, glyphName);
// FIXME: incorrect
NSGlyph g = [glyphName cString][0];
return g;
}
- (NSGlyph) glyphForCharacter: (unichar)c
{
// FIXME: default in 'gui' uses -glyphIsEncoded: or otherwise
// returns null glyph. the default should be sufficient, and is
// sufficient for cairo backend.
return c;
}
- (void) appendBezierPathWithGlyphs: (NSGlyph *)glyphs
count: (int)length
toBezierPath: (NSBezierPath *)path
{
[path lineToPoint: NSMakePoint(length*10, 10)];
}
@end

635
Source/opal/OpalGState.m Normal file
View file

@ -0,0 +1,635 @@
/*
OpalGState.m
Copyright (C) 2013 Free Software Foundation, Inc.
Author: Ivan Vucica <ivan@vucica.net>
Date: June 2013
This file is part of GNUstep.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; see the file COPYING.LIB.
If not, see <http://www.gnu.org/licenses/> or write to the
Free Software Foundation, 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#import <CoreGraphics/CoreGraphics.h>
#import <X11/Xlib.h>
#import <AppKit/NSGraphics.h> // NS*ColorSpace
#import "opal/OpalGState.h"
#import "opal/OpalSurface.h"
#import "x11/XGServerWindow.h"
#define CGCTX [self cgContext]
@implementation OpalGState
// MARK: Minimum required methods
// MARK: -
- (void) DPSinitclip
{
NSDebugLLog(@"OpalGState", @"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
OPContextResetClip(CGCTX);
}
- (void) DPSclip
{
NSDebugLLog(@"OpalGState", @"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
CGContextClip(CGCTX);
}
- (void) DPSfill
{
NSDebugLLog(@"OpalGState", @"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
CGContextFillPath(CGCTX);
}
- (void) DPSimage: (NSAffineTransform *)matrix
: (NSInteger)pixelsWide
: (NSInteger)pixelsHigh
: (NSInteger)bitsPerSample // is this used correctly ?
: (NSInteger)samplesPerPixel // < unused
: (NSInteger)bitsPerPixel
: (NSInteger)bytesPerRow
: (BOOL)isPlanar // < unused
: (BOOL)hasAlpha // < unused
: (NSString *)colorSpaceName
: (const unsigned char *const[5])data
{
NSDebugLLog(@"OpalGState", @"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
// This depends on CGAffineTransform and NSAffineTransformStruct having
// the same in-memory layout.
// Here's an elementary check if that is true.
// We should probably check this in -back's "configure" script.
assert(sizeof(CGAffineTransform) == sizeof(NSAffineTransformStruct));
NSAffineTransformStruct nsAT = [matrix transformStruct];
CGAffineTransform cgAT = *(CGAffineTransform *)&nsAT;
CGContextSaveGState(CGCTX);
// CGContextSetRGBFillColor(CGCTX, 1, 0, 0, 1);
CGContextConcatCTM(CGCTX, cgAT);
// CGContextFillRect(CGCTX, CGRectMake(0, 0, pixelsWide, pixelsHigh));
// TODO:
// We may want to normalize colorspace names between Opal and -gui,
// to avoid this conversion?
NSLog(@"Colorspace %@", colorSpaceName);
if ([colorSpaceName isEqualToString:NSCalibratedRGBColorSpace])
colorSpaceName = kCGColorSpaceGenericRGB; // SRGB?
else if ([colorSpaceName isEqualToString:NSDeviceRGBColorSpace])
colorSpaceName = kCGColorSpaceGenericRGB;
// TODO: bitsPerComponent (in variable bitsPerSample) is not
// liked combined with bitsBerPixel
else if ([colorSpaceName isEqualToString:NSCalibratedWhiteColorSpace])
colorSpaceName = kCGColorSpaceGenericGray;
else if ([colorSpaceName isEqualToString:NSDeviceWhiteColorSpace])
colorSpaceName = kCGColorSpaceGenericGray;
else
{
NSLog(@"Opal backend: Unhandled colorspace: %@", colorSpaceName);
CGContextRestoreGState(CGCTX);
return;
}
if (bitsPerPixel != 32)
{
NSLog(@"Bits per pixel: %d - the only verified combination is 32", bitsPerPixel);
CGContextRestoreGState(CGCTX);
return;
}
//CGColorSpaceRef colorSpace = CGColorSpaceCreateWithName(colorSpaceName);
CGColorSpaceRef colorSpace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
#if 0
NSData * nsData = [NSData dataWithBytesNoCopy: *data
length: pixelsHigh * bytesPerRow];
#else
#warning Using suboptimal '-dataWithBytes:length:' because NoCopy variant breaks down
NSData * nsData = [NSData dataWithBytes: *data
length: pixelsHigh * bytesPerRow];
#endif
CGDataProviderRef dataProvider = CGDataProviderCreateWithCFData(nsData);
NSLog(@"Bits per component : bitspersample = %d", bitsPerSample);
NSLog(@"Bits per pixel : bitsperpixel = %d", bitsPerPixel);
NSLog(@" : samplesperpixel = %d", samplesPerPixel);
CGImageRef img = CGImageCreate(pixelsWide, pixelsHigh, bitsPerSample,
bitsPerPixel, bytesPerRow, colorSpace,
hasAlpha ? kCGImageAlphaPremultipliedLast : 0 /* correct? */,
dataProvider,
NULL /* const CGFloat decode[] is what? */,
false, /* shouldInterpolate? */
kCGRenderingIntentDefault );
CGContextDrawImage(CGCTX, CGRectMake(0, 0, pixelsWide, pixelsHigh), img);
CGDataProviderRelease(dataProvider);
CGImageRelease(img);
CGContextRestoreGState(CGCTX);
}
- (void) compositeGState: (OpalGState *)source
fromRect: (NSRect)srcRect
toPoint: (NSPoint)destPoint
op: (NSCompositingOperation)op
fraction: (CGFloat)delta
{
NSDebugLLog(@"OpalGState", @"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
#if 1
CGContextSaveGState(CGCTX);
CGContextSetRGBFillColor(CGCTX, 1, 1, 0, 1);
CGContextFillRect(CGCTX, CGRectMake(destPoint.x, destPoint.y, srcRect.size.width, srcRect.size.height));
CGContextRestoreGState(CGCTX);
#else
CGRect srcCGRect = CGRectMake(srcRect.origin.x, srcRect.origin.y,
srcRect.size.width, srcRect.size.height);
// FIXME: this presumes that the backing cgContext of 'source' is
// an OpalSurface with a backing CGBitmapContext
CGImageRef backingImage = CGBitmapContextCreateImage([source cgContext]);
CGContextMoveToPoint(CGCTX, destPoint.x, destPoint.y);
// TODO: this ignores op
// TODO: this ignores delta
CGContextDrawImage(CGCTX, srcCGRect, backingImage);
CGImageRelease(backingImage);
#endif
}
- (void) compositerect: (NSRect)aRect
op: (NSCompositingOperation)op
{
NSDebugLLog(@"OpalGState", @"%p (%@): %s - %@", self, [self class], __PRETTY_FUNCTION__, NSStringFromRect(aRect));
CGContextSaveGState(CGCTX);
[self DPSinitmatrix];
CGContextFillRect(CGCTX, CGRectMake(aRect.origin.x, [_opalSurface device]->buffer_height - aRect.origin.y,
aRect.size.width, aRect.size.height));
CGContextRestoreGState(CGCTX);
}
- (void) DPSsetdash: (const CGFloat*)pat
: (NSInteger)size
: (CGFloat)offset
{
NSDebugLLog(@"OpalGState", @"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
// TODO: stub
}
- (void) DPSstroke
{
NSDebugLLog(@"OpalGState", @"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
CGContextStrokePath(CGCTX);
}
- (void) DPSsetlinejoin: (int)linejoin
{
NSDebugLLog(@"OpalGState", @"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
// TODO: stub
}
- (void) DPSsetlinecap: (int)linecap
{
NSDebugLLog(@"OpalGState", @"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
// TODO: stub
}
- (void) DPSsetmiterlimit: (CGFloat)miterlimit
{
NSDebugLLog(@"OpalGState", @"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
// TODO: stub
}
@end
// MARK: Initialization methods
// MARK: -
@implementation OpalGState (InitializationMethods)
/* SOME NOTES:
- GState approximates a cairo context: a drawing state.
- Surface approximates a cairo surface: a place to draw things.
- CGContext seems to be a mix of these two: surface + state.
Should we unite these two somehow? Can we unite these two somehow?
Possibly not. We still need to support bitmap contexts, pdf contexts
etc which contain both state and contents.
So, we will still need surfaces (containing CGContexts, hence including
state) and GState as a wrapper around whatever context happens to be
the current one.
*/
/**
Makes the specified surface active in the current graphics state,
ready for use. Also, sets the device offset to specified coordinates.
**/
- (void) GSSetSurface: (OpalSurface *)opalSurface
: (int)x
: (int)y
{
NSDebugLLog(@"OpalGState", @"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
if(_opalSurface != opalSurface)
{
id old = _opalSurface;
_opalSurface = [opalSurface retain];
[old release];
}
[self setOffset: NSMakePoint(x, y)];
[self DPSinitgraphics];
}
- (id) GSCurrentSurface: (OpalSurface **)surface
: (int *)x
: (int *)y
{
NSDebugLLog(@"OpalGState", @"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
return _opalSurface;
}
/**
Sets up a new CG*Context() for drawing content.
**/
- (void) DPSinitgraphics
{
NSDebugLLog(@"OpalGState", @"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
[super DPSinitgraphics];
[_opalSurface createCGContexts];
/*
if ([_opalSurface device])
{
CGContextTranslateCTM(CGCTX, 0, [_opalSurface device]->buffer_height);
CGContextScaleCTM(CGCTX, 1, -1);
}
*/
}
@end
// MARK: Accessors
// MARK: -
@implementation OpalGState (Accessors)
- (CGContextRef) cgContext
{
if (!_opalSurface)
NSDebugMLLog(@"OpalGState", @"No OpalSurface");
else if (![_opalSurface cgContext])
NSDebugMLLog(@"OpalGState", @"No OpalSurface CGContext");
return [_opalSurface cgContext];
}
@end
// MARK: Non-required methods
// MARK: -
static CGFloat theAlpha = 1.; // TODO: removeme
@implementation OpalGState (NonrequiredMethods)
- (void) DPSsetrgbcolor: (CGFloat)r : (CGFloat)g : (CGFloat)b
{
NSDebugLLog(@"OpalGState", @"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
const CGFloat alpha = 1; // TODO: is this correct?
if(!CGCTX)
return;
CGContextSetRGBStrokeColor(CGCTX, r, g, b, alpha);
CGContextSetRGBFillColor(CGCTX, r, g, b, alpha);
}
- (void) DPSrectfill: (CGFloat)x : (CGFloat)y : (CGFloat)w : (CGFloat)h
{
NSDebugLLog(@"OpalGState", @"%p (%@): %s - rect %g %g %g %g", self, [self class], __PRETTY_FUNCTION__, x, y, w, h);
CGContextFillRect(CGCTX, CGRectMake(x, y, w, h));
}
- (void) DPSrectclip: (CGFloat)x : (CGFloat)y : (CGFloat)w : (CGFloat)h
{
NSDebugLLog(@"OpalGState", @"%p (%@): %s - %g %g %g %g", self, [self class], __PRETTY_FUNCTION__, x, y, w, h);
[self DPSinitclip];
CGContextClipToRect(CGCTX, CGRectMake(x, y, w, h));
}
- (void) DPSsetgray: (CGFloat)gray
{
NSDebugLLog(@"OpalGState", @"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
const CGFloat alpha = 1; // TODO: is this correct?
CGContextSetGrayFillColor(CGCTX, gray, alpha);
}
- (void) DPSsetalpha: (CGFloat)a
{
NSDebugLLog(@"OpalGState", @"%p (%@): %s - alpha %g", self, [self class], __PRETTY_FUNCTION__, a);
CGContextSetAlpha(CGCTX, a);
theAlpha = a;
}
- (void)DPSinitmatrix
{
NSDebugLLog(@"OpalGState", @"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
OPContextSetIdentityCTM(CGCTX);
#if 0
// Flipping the coordinate system is NOT required
CGContextTranslateCTM(CGCTX, 0, [_opalSurface device]->buffer_height);
CGContextScaleCTM(CGCTX, 1, -1);
#endif
[super DPSinitmatrix];
}
- (void)DPSconcat: (const CGFloat *)m
{
NSDebugLLog(@"OpalGState", @"%p (%@): %s - %g %g %g %g %g %g", self, [self class], __PRETTY_FUNCTION__, m[0], m[1], m[2], m[3], m[4], m[5]);
CGContextConcatCTM(CGCTX, CGAffineTransformMake(
m[0], m[1], m[2],
m[3], m[4], m[5]));
[super DPSconcat:m];
}
- (void)DPSscale: (CGFloat)x
: (CGFloat)y
{
NSDebugLLog(@"OpalGState", @"%p (%@): %s - %g %g", self, [self class], __PRETTY_FUNCTION__, x, y);
CGContextScaleCTM(CGCTX, x, y);
}
- (void)DPStranslate: (CGFloat)x
: (CGFloat)y
{
NSDebugLLog(@"OpalGState", @"%p (%@): %s - x %g y %g", self, [self class], __PRETTY_FUNCTION__, x, y);
CGContextTranslateCTM(CGCTX, x, y);
[super DPStranslate:x:y];
}
- (void) DPSmoveto: (CGFloat) x
: (CGFloat) y
{
NSDebugLLog(@"OpalGState", @"%p (%@): %s - %g %g", self, [self class], __PRETTY_FUNCTION__, x, y);
CGContextMoveToPoint(CGCTX, x, y);
}
- (void) DPSlineto: (CGFloat) x
: (CGFloat) y
{
NSDebugLLog(@"OpalGState", @"%p (%@): %s - %g %g", self, [self class], __PRETTY_FUNCTION__, x, y);
CGContextAddLineToPoint(CGCTX, x, y);
}
- (void) setOffset: (NSPoint)theOffset
{
NSDebugLLog(@"OpalGState", @"%p (%@): %s - %g %g", self, [self class], __PRETTY_FUNCTION__, theOffset.x, theOffset.y);
#if 1
if (CGCTX != nil)
{
#if 1
OPContextSetCairoDeviceOffset(CGCTX, -theOffset.x,
theOffset.y - [_opalSurface device]->buffer_height);
#else
OPContextSetCairoDeviceOffset(CGCTX, theOffset.x,
theOffset.y);
#endif
}
#else
// This is a BAD hack using transform matrix.
// It'll break horribly when Opal state is saved and restored.
static NSPoint OFFSET = { 0, 0 };
//CGContextTranslateCTM(CGCTX, -(-OFFSET.x),
// -(OFFSET.y - [_opalSurface device]->buffer_height));
CGContextTranslateCTM(CGCTX, -theOffset.x,
theOffset.y - [_opalSurface device]->buffer_height);
OFFSET = theOffset;
#endif
[super setOffset: theOffset];
}
/*
- (void) setColor: (device_color_t *)color state: (color_state_t)cState
{
NSDebugLLog(@"OpalGState", @"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
[super setColor: color
state: cState];
switch (color->space)
{
case rgb_colorspace:
if (cState & COLOR_STROKE)
CGContextSetRGBStrokeColor(CGCTX, color->field[0],
color->field[1], color->field[2], color->field[3]);
if (cState & COLOR_FILL)
CGContextSetRGBFillColor(CGCTX, color->field[0],
color->field[1], color->field[2], color->field[3]);
break;
}
}
*/
- (NSAffineTransform *) GSCurrentCTM
{
NSDebugLLog(@"OpalGState", @"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
CGAffineTransform cgCTM = CGContextGetCTM(CGCTX);
NSAffineTransform * affineTransform = [NSAffineTransform transform];
// This depends on CGAffineTransform and NSAffineTransformStruct having
// the same in-memory layout.
// Here's an elementary check if that is true.
// We should probably check this in -back's "configure" script.
assert(sizeof(CGAffineTransform) == sizeof(NSAffineTransformStruct));
NSAffineTransformStruct nsCTM = *(NSAffineTransformStruct *)&cgCTM;
[affineTransform setTransformStruct: nsCTM];
return affineTransform;
}
- (void) flushGraphics
{
NSDebugLLog(@"OpalGState", @"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
CGContextFlush(CGCTX);
[_opalSurface handleExpose:CGRectMake(0, 0, 1024, 1024)];
}
- (void) DPSgsave
{
NSDebugLLog(@"OpalGState", @"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
#warning Opal bug: nil ctx should 'only' print a warning instead of crashing
if (CGCTX)
CGContextSaveGState(CGCTX);
}
- (void) DPSgrestore
{
NSDebugLLog(@"OpalGState", @"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
#warning Opal bug: nil ctx should 'only' print a warning instead of crashing
if (CGCTX)
CGContextRestoreGState(CGCTX);
}
- (void *) saveClip
{
NSDebugLLog(@"OpalGState", @"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
CGRect * r = calloc(sizeof(CGRect), 1);
*r = CGContextGetClipBoundingBox(CGCTX);
return r;
}
- (void) restoreClip: (void *)savedClip
{
NSDebugLLog(@"OpalGState", @"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
OPContextResetClip(CGCTX);
CGContextClipToRect(CGCTX, *(CGRect *)savedClip);
free(savedClip);
}
- (void) DPSeoclip
{
NSDebugLLog(@"OpalGState", @"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
CGContextEOClip(CGCTX);
}
- (void) DPSeofill
{
NSDebugLLog(@"OpalGState", @"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
CGContextEOFillPath(CGCTX);
}
- (void) DPSshow: (const char *)s
{
NSDebugLLog(@"OpalGState", @"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
CGContextSaveGState(CGCTX);
CGContextSetRGBFillColor(CGCTX, 0, 1, 0, 1);
CGContextFillRect(CGCTX, CGRectMake(0, 0, 12, strlen(s) * 12));
CGContextRestoreGState(CGCTX);
}
- (void) GSShowText: (const char *)s : (size_t) length
{
NSDebugLLog(@"OpalGState", @"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
/*
const char * s2 = calloc(s, length+1);
strcpy(s2, s);
*/
CGContextSaveGState(CGCTX);
CGContextSetRGBFillColor(CGCTX, 0, 1, 0, 1);
CGContextFillRect(CGCTX, CGRectMake(0, 0, 12, length * 12));
CGContextRestoreGState(CGCTX);
// free(s2);
}
- (void) GSShowGlyphsWithAdvances: (const NSGlyph *)glyphs : (const NSSize *)advances : (size_t) length
{
NSDebugLLog(@"OpalGState", @"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
CGContextSaveGState(CGCTX);
CGContextSetRGBFillColor(CGCTX, 0, 1, 0, 1);
CGContextFillRect(CGCTX, CGRectMake(0, 0, 12, length * 12));
CGContextRestoreGState(CGCTX);
}
#if 0
- (void) DPSrlineto: (CGFloat) x
: (CGFloat) y
{
NSDebugLLog(@"OpalGState", @"%p (%@): %s - %g %g", self, [self class], __PRETTY_FUNCTION__, x, y);
CGContextAddRelativeLine(CGCTX, x, y);
}
#else
#warning -DPSrlineto:: not implemented directly
#endif
- (void) DPScurrentpoint: (CGFloat *)x
: (CGFloat *)y
{
NSDebugLLog(@"OpalGState", @"%p (%@): %s - %g %g", self, [self class], __PRETTY_FUNCTION__, x, y);
CGPoint currentPoint = CGContextGetPathCurrentPoint(CGCTX);
*x = currentPoint.x;
*y = currentPoint.y;
}
@end
// MARK: Non-required unimplemented methods
// MARK: -
@implementation OpalGState (NonrequiredUnimplementedMethods)
/*
Methods that follow have not been implemented.
They are here to prevent GSGState implementations from
executing.
Sole criteria for picking them is looking at what methods
are called by a dummy AppKit application with a single
empty NSWindow.
*/
- (void) DPSsetlinewidth: (CGFloat) width
{
NSDebugLLog(@"OpalGState", @"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
}
- (void) DPSsetgstate: (NSInteger) gst
{
NSDebugLLog(@"OpalGState", @"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
abort();
}
@end
@implementation OpalGState (Unused)
- (void) _setPath
{
#if 0
NSInteger count = [path elementCount];
NSInteger i;
SEL elmsel = @selector(elementAtIndex:associatedPoints:);
NSBezierPathElement (*elmidx)(id, SEL, NSInteger, NSPoint*) =
(NSBezierPathElement (*)(id, SEL, NSInteger, NSPoint*))[path methodForSelector: elmsel];
// reset current cairo path
cairo_new_path(_ct);
for (i = 0; i < count; i++)
{
NSBezierPathElement type;
NSPoint points[3];
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;
}
}
#endif
}
@end

View file

View file

264
Source/opal/OpalSurface.m Normal file
View file

@ -0,0 +1,264 @@
/*
OpalSurface.m
Copyright (C) 2013 Free Software Foundation, Inc.
Author: Ivan Vucica <ivan@vucica.net>
Date: June 2013
This file is part of GNUstep.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; see the file COPYING.LIB.
If not, see <http://www.gnu.org/licenses/> or write to the
Free Software Foundation, 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#import "opal/OpalSurface.h"
#import "x11/XGServerWindow.h"
/* TODO: expose these from within opal */
extern CGContextRef OPX11ContextCreate(Display *display, Drawable drawable);
extern void OPContextSetSize(CGContextRef ctx, CGSize s);
/* Taken from GSQuartzCore's CABackingStore */
static CGContextRef createCGBitmapContext (int pixelsWide,
int pixelsHigh)
{
CGContextRef context = NULL;
CGColorSpaceRef colorSpace;
void * bitmapData;
int bitmapByteCount;
int bitmapBytesPerRow;
bitmapBytesPerRow = (pixelsWide * 4);
bitmapByteCount = (bitmapBytesPerRow * pixelsHigh);
colorSpace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);// 2
// Let CGBitmapContextCreate() allocate the memory.
// This should be good under Cocoa too.
bitmapData = NULL;
context = CGBitmapContextCreate (bitmapData,
pixelsWide,
pixelsHigh,
8, // bits per component
bitmapBytesPerRow,
colorSpace,
#if !GNUSTEP
kCGImageAlphaPremultipliedLast);
#else
// Opal only supports kCGImageAlphaPremultipliedFirst.
// However, this is incorrect since it implies ARGB.
kCGImageAlphaPremultipliedFirst);
#endif
// Note: our use of premultiplied alpha means that we need to
// do alpha blending using:
// GL_SRC_ALPHA, GL_ONE
CGColorSpaceRelease(colorSpace);
if (context== NULL)
{
free (bitmapData);// 5
fprintf (stderr, "Context not created!");
return NULL;
}
#if GNUSTEP
#warning Opal bug: context should be cleared automatically
#if 0
CGContextClearRect (context, CGRectInfinite);
#else
#warning Opal bug: CGContextClearRect() permanently whacks the context
memset (CGBitmapContextGetData (context),
0, bitmapBytesPerRow * pixelsHigh);
#endif
#endif
return context;
}
@implementation OpalSurface
- (id) initWithDevice: (void *)device
{
self = [super init];
if (!self)
return nil;
// FIXME: this method and class presumes we are being passed
// a window device.
_gsWindowDevice = (gswindow_device_t *) device;
[self createCGContexts];
return self;
}
- (void) createCGContexts
{
// FIXME: this method and class presumes we are being passed
// a window device.
Display * display = _gsWindowDevice->display;
Window window = _gsWindowDevice->ident;
_x11CGContext = OPX11ContextCreate(display, window);
if (_gsWindowDevice->type == NSBackingStoreNonretained)
{
// Don't double-buffer:
// use the window surface as the drawing destination.
}
else
{
// Do double-buffer:
// Create a similar surface to the window which supports alpha
// Ask XGServerWindow to call +[OpalContext handleExposeRect:forDriver:]
// to let us handle the back buffer -> front buffer copy using Opal.
_gsWindowDevice->gdriverProtocol |= GDriverHandlesExpose | GDriverHandlesBacking;
_gsWindowDevice->gdriver = self;
#if 0
_backingCGContext = createCGBitmapContext(
_gsWindowDevice->buffer_width,
_gsWindowDevice->buffer_height);
#else
#warning NOTE! Doublebuffering disabled.
#endif
}
}
- (gswindow_device_t *) device
{
return _gsWindowDevice;
}
- (CGContextRef) cgContext
{
return _backingCGContext ? _backingCGContext : _x11CGContext;
}
- (void) handleExposeRect: (NSRect)rect
{
NSDebugLLog(@"OpalSurface", @"handleExposeRect %@", NSStringFromRect(rect));
CGImageRef backingImage = CGBitmapContextCreateImage(_backingCGContext);
if (!backingImage) // FIXME: writing a nil image fails with Opal
return;
#if 1
CGRect cgRect = CGRectMake(rect.origin.x, rect.origin.y,
rect.size.width, rect.size.height);
CGRect subimageCGRect = cgRect;
//subimageCGRect.origin.y = CGImageGetHeight(backingImage) - cgRect.origin.y - cgRect.size.height;
// TODO: opal might be able to provide a variant of DrawImage that does
// not require creating a subimage
CGImageRef subImage = CGImageCreateWithImageInRect(backingImage, subimageCGRect);
CGContextSaveGState(_x11CGContext);
OPContextResetClip(_x11CGContext);
OPContextSetIdentityCTM(_x11CGContext);
cgRect.origin.y = [self device]->buffer_height - cgRect.origin.y - cgRect.size.height;
NSDebugLLog(@"OpalSurface, "@"Painting from %@ to %@", NSStringFromRect(*(NSRect *)&subimageCGRect), NSStringFromRect(*(NSRect *)&cgRect));
CGContextDrawImage(_x11CGContext, cgRect, subImage);
CGContextSetRGBFillColor(_x11CGContext, 0, (rand() % 255) / 255., 1, 0.7);
CGContextSetRGBStrokeColor(_x11CGContext, 1, 0, 0, 1);
CGContextSetLineWidth(_x11CGContext, 2);
//CGContextFillRect(_x11CGContext, cgRect);
// CGContextStrokeRect(_x11CGContext, cgRect);i
#else
CGContextSaveGState(_x11CGContext);
OPContextResetClip(_x11CGContext);
OPContextSetIdentityCTM(_x11CGContext);
CGContextDrawImage(_x11CGContext, CGRectMake(0, 0, [self device]->buffer_width, [self device]->buffer_height), backingImage);
#endif
[self _saveImage: backingImage withPrefix:@"/tmp/opalback-backing-" size: CGSizeZero];
[self _saveImage: subImage withPrefix:@"/tmp/opalback-subimage-" size: subimageCGRect.size ];
CGImageRelease(backingImage);
CGImageRelease(subImage);
CGContextRestoreGState(_x11CGContext);
}
- (void) _saveImage: (CGImageRef) img withPrefix: (NSString *) prefix size: (CGSize) size
{
#if 0
#warning Saving debug images
#if 1
#warning Opal bug: cannot properly save subimage created with CGImageCreateWithImageInRect()
if (size.width != 0 || size.height != 0)
{
CGContextRef tmp = createCGBitmapContext(size.width, size.height);
CGContextDrawImage(tmp, CGRectMake(0, 0, size.width, size.height), img);
img = CGBitmapContextCreateImage(tmp);
[(id)img autorelease];
}
#endif
// FIXME: Opal tries to access -path from CFURLRef
//CFURLRef fileUrl = CFURLCreateWithFileSystemPath(NULL, @"/tmp/opalback.jpg", kCFURLPOSIXPathStyle, NO);
NSString * path = [NSString stringWithFormat: @"%@%dx%d.png", prefix, CGImageGetWidth(img), CGImageGetHeight(img)];
CFURLRef fileUrl = (CFURLRef)[[NSURL fileURLWithPath: path] retain];
NSLog(@"FileURL %@", fileUrl);
//CGImageDestinationRef outfile = CGImageDestinationCreateWithURL(fileUrl, @"public.jpeg"/*kUTTypeJPEG*/, 1, NULL);
CGImageDestinationRef outfile = CGImageDestinationCreateWithURL(fileUrl, @"public.png"/*kUTTypePNG*/, 1, NULL);
CGImageDestinationAddImage(outfile, img, NULL);
CGImageDestinationFinalize(outfile);
CFRelease(fileUrl);
CFRelease(outfile);
#endif
}
- (BOOL) isDrawingToScreen
{
// TODO: stub
return YES;
}
- (void) dummyDraw
{
NSDebugLLog(@"OpalSurface", @"performing dummy draw");
CGContextSaveGState([self cgContext]);
CGRect r = CGRectMake(0, 0, 1024, 1024);
CGContextSetRGBFillColor([self cgContext], 1, 0, 0, 1);
CGContextFillRect([self cgContext], r);
CGContextRestoreGState([self cgContext]);
}
@end

View file

@ -473,7 +473,7 @@ BOOL CALLBACK LoadDisplayMonitorInfo(HMONITOR hMonitor,
// MESSAGE PROCESSING!!!!!
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
}
}
@ -625,7 +625,7 @@ BOOL CALLBACK LoadDisplayMonitorInfo(HMONITOR hMonitor,
{
[self _initWin32Context];
[super initWithAttributes: info];
// Load system cursor resources for overriding system level cursors on
// capture and release mouse sequences...
loadsystemcursors();
@ -644,34 +644,34 @@ BOOL CALLBACK LoadDisplayMonitorInfo(HMONITOR hMonitor,
[GSTheme theme];
{ // Check user defaults
NSUserDefaults *defs;
defs = [NSUserDefaults standardUserDefaults];
if ([defs objectForKey: @"GSUseWMStyles"])
{
NSWarnLog(@"Usage of 'GSUseWMStyles' as user default option is deprecated. "
@"This option will be ignored in future versions. "
@"You should use 'GSBackHandlesWindowDecorations' option.");
[self setHandlesWindowDecorations: ![defs boolForKey: @"GSUseWMStyles"]];
}
if ([defs objectForKey: @"GSUsesWMTaskbar"])
{
NSWarnLog(@"Usage of 'GSUseWMTaskbar' as user default option is deprecated. "
@"This option will be ignored in future versions. "
@"You should use 'GSBackUsesNativeTaskbar' option.");
[self setUsesNativeTaskbar: [defs boolForKey: @"GSUseWMTaskbar"]];
}
if ([defs objectForKey: @"GSBackHandlesWindowDecorations"])
{
[self setHandlesWindowDecorations:
[defs boolForKey: @"GSBackHandlesWindowDecorations"]];
}
if ([defs objectForKey: @"GSBackUsesNativeTaskbar"])
{
[self setUsesNativeTaskbar:
[defs boolForKey: @"GSBackUsesNativeTaskbar"]];
}
NSUserDefaults *defs;
defs = [NSUserDefaults standardUserDefaults];
if ([defs objectForKey: @"GSUseWMStyles"])
{
NSWarnLog(@"Usage of 'GSUseWMStyles' as user default option is deprecated. "
@"This option will be ignored in future versions. "
@"You should use 'GSBackHandlesWindowDecorations' option.");
[self setHandlesWindowDecorations: ![defs boolForKey: @"GSUseWMStyles"]];
}
if ([defs objectForKey: @"GSUsesWMTaskbar"])
{
NSWarnLog(@"Usage of 'GSUseWMTaskbar' as user default option is deprecated. "
@"This option will be ignored in future versions. "
@"You should use 'GSBackUsesNativeTaskbar' option.");
[self setUsesNativeTaskbar: [defs boolForKey: @"GSUseWMTaskbar"]];
}
if ([defs objectForKey: @"GSBackHandlesWindowDecorations"])
{
[self setHandlesWindowDecorations:
[defs boolForKey: @"GSBackHandlesWindowDecorations"]];
}
if ([defs objectForKey: @"GSBackUsesNativeTaskbar"])
{
[self setUsesNativeTaskbar:
[defs boolForKey: @"GSBackUsesNativeTaskbar"]];
}
}
}
return self;
@ -711,21 +711,21 @@ static POINT findWindowAtPoint;
LRESULT CALLBACK windowEnumCallback(HWND hwnd, LPARAM lParam)
{
if (foundWindowHwnd == 0 && hwnd != (HWND)lParam)
{
RECT r;
GetWindowRect(hwnd, &r);
if (PtInRect(&r,findWindowAtPoint) && IsWindowVisible(hwnd))
{
NSWindow *window = GSWindowWithNumber((int)hwnd);
if (![window ignoresMouseEvents])
foundWindowHwnd = hwnd;
{
RECT r;
GetWindowRect(hwnd, &r);
if (PtInRect(&r,findWindowAtPoint) && IsWindowVisible(hwnd))
{
NSWindow *window = GSWindowWithNumber((int)hwnd);
if (![window ignoresMouseEvents])
foundWindowHwnd = hwnd;
}
}
}
return true;
}
- (int) findWindowAt: (NSPoint)screenLocation
- (int) findWindowAt: (NSPoint)screenLocation
windowRef: (int*)windowRef
excluding: (int)win
{
@ -778,9 +778,9 @@ LRESULT CALLBACK windowEnumCallback(HWND hwnd, LPARAM lParam)
- (NSRect) boundsForScreen: (int)screen
{
if (screen < [monitorInfo count])
{
return [[monitorInfo objectAtIndex:screen] frame];
}
{
return [[monitorInfo objectAtIndex: screen] frame];
}
return NSZeroRect;
}
@ -831,15 +831,14 @@ LRESULT CALLBACK windowEnumCallback(HWND hwnd, LPARAM lParam)
{
HDC hdc = [self createHdcForScreen:screen];
int bits = 0;
if (hdc)
{
bits = GetDeviceCaps(hdc, BITSPIXEL) / 3;
//planes = GetDeviceCaps(hdc, PLANES);
//NSLog(@"bits %d planes %d", bits, planes);
[self deleteScreenHdc:hdc];
}
{
bits = GetDeviceCaps(hdc, BITSPIXEL) / 3;
//planes = GetDeviceCaps(hdc, PLANES);
//NSLog(@"bits %d planes %d", bits, planes);
[self deleteScreenHdc:hdc];
}
return (_GSRGBBitValue | bits);
}
@ -1587,7 +1586,7 @@ LRESULT CALLBACK windowEnumCallback(HWND hwnd, LPARAM lParam)
else
[self decodeWM_KILLFOCUSParams: wParam : lParam : hwnd];
break;
case WM_SETCURSOR:
case WM_SETCURSOR:
break;
case WM_QUERYOPEN:
[self decodeWM_QUERYOPENParams: wParam : lParam : hwnd];
@ -1657,7 +1656,7 @@ LRESULT CALLBACK windowEnumCallback(HWND hwnd, LPARAM lParam)
case WM_ENABLE:
case WM_CHILDACTIVATE:
break;
case WM_NULL:
case WM_NULL:
break;
case WM_NCHITTEST: //MOUSE
@ -2615,14 +2614,14 @@ LRESULT CALLBACK windowEnumCallback(HWND hwnd, LPARAM lParam)
if (!GetCursorPos(&p))
{
// Try using cursorInfo which should work in more situations
CURSORINFO cursorInfo;
cursorInfo.cbSize = sizeof(CURSORINFO);
if (!GetCursorInfo(&cursorInfo)) {
NSLog(@"GetCursorInfo failed with %d", GetLastError());
return NSZeroPoint;
}
p = cursorInfo.ptScreenPos;
// Try using cursorInfo which should work in more situations
CURSORINFO cursorInfo;
cursorInfo.cbSize = sizeof(CURSORINFO);
if (!GetCursorInfo(&cursorInfo)) {
NSLog(@"GetCursorInfo failed with %d", GetLastError());
return NSZeroPoint;
}
p = cursorInfo.ptScreenPos;
}
return MSScreenPointToGS(p.x, p.y);
@ -2699,18 +2698,18 @@ LRESULT CALLBACK windowEnumCallback(HWND hwnd, LPARAM lParam)
{
// Default the return cursur ID to NULL...
*cid = NULL;
NSBitmapImageRep *rep = getStandardBitmap(image);
if (rep == nil)
{
/* FIXME: We might create a blank cursor here? */
NSWarnMLog(@"Could not convert cursor bitmap data");
}
}
else
{
if (hotp.x >= [rep pixelsWide])
hotp.x = [rep pixelsWide]-1;
if (hotp.y >= [rep pixelsHigh])
hotp.y = [rep pixelsHigh]-1;
@ -2838,7 +2837,7 @@ LRESULT CALLBACK windowEnumCallback(HWND hwnd, LPARAM lParam)
if (cursorId == NULL)
{
NSWarnMLog(@"trying to free a cursor not created by us: %p", cid);
}
}
else
{
// Remove the entry and destroy the cursor...
@ -2855,6 +2854,20 @@ LRESULT CALLBACK windowEnumCallback(HWND hwnd, LPARAM lParam)
//SetParent((HWND)childWin, (HWND)parentWin);
}
- (void) setIgnoreMouse: (BOOL)ignoreMouse : (int)win
{
int extendedStyle = GetWindowLong((HWND)win, GWL_EXSTYLE);
if (ignoreMouse)
{
SetWindowLong((HWND)win, GWL_EXSTYLE, extendedStyle | WS_EX_TRANSPARENT);
}
else
{
SetWindowLong((HWND)win, GWL_EXSTYLE, extendedStyle & ~WS_EX_TRANSPARENT);
}
}
@end
static unichar
@ -3099,15 +3112,15 @@ process_key_event(WIN32Server *svr, HWND hwnd, WPARAM wParam, LPARAM lParam, NSE
windowNumber = (int)hwnd;
event = [NSEvent keyEventWithType: eventType
location: eventLocation
modifierFlags: eventFlags
timestamp: time
windowNumber: windowNumber
context: gcontext
characters: keys
charactersIgnoringModifiers: ukeys
isARepeat: repeat
keyCode: wParam];
location: eventLocation
modifierFlags: eventFlags
timestamp: time
windowNumber: windowNumber
context: gcontext
characters: keys
charactersIgnoringModifiers: ukeys
isARepeat: repeat
keyCode: wParam];
return event;
}

View file

@ -337,11 +337,10 @@ static Win32GLContext *currentGLContext;
- (id)initWithCGLContextObj: (void *)context
{
self = [super init];
if (!self)
{
return nil;
}
{
return nil;
}
// FIXME: Need to set the pixelFormat ivar
wgl_context = context;

View file

@ -35,10 +35,11 @@
@implementation WIN32Server (w32_General)
- (void) decodeWM_CLOSEParams:(WPARAM)wParam :(LPARAM)lParam :(HWND)hwnd;
- (void) decodeWM_CLOSEParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
{
NSEvent * ev;
NSEvent *ev;
NSPoint eventLocation = NSMakePoint(0, 0);
ev = [NSEvent otherEventWithType: NSAppKitDefined
location: eventLocation
modifierFlags: 0
@ -49,14 +50,11 @@
data1: 0
data2: 0];
// need to send the event... or handle it directly.
// Sending the event directly to the window bypasses the event queue, which can cause a modal loop to lock up
//[EVENT_WINDOW(hwnd) sendEvent:ev];
// So we'll post it to the queue like any other event, which will get it to the window in the usual way
[GSCurrentServer() postEvent:ev atStart:NO];
// Sending the event directly to the window bypasses the event queue,
// which can cause a modal loop to lock up.
[GSCurrentServer() postEvent: ev atStart: NO];
ev=nil;
flags._eventHandled=YES;
flags._eventHandled = YES;
}
- (void) decodeWM_NCDESTROYParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
@ -80,7 +78,6 @@
free(win);
free((IME_INFO_T*)GetWindowLongPtr(hwnd, IME_INFO));
flags._eventHandled=YES;
}
- (void) decodeWM_QUERYOPENParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd

View file

@ -34,30 +34,30 @@
- (LRESULT) decodeWM_MOVEParams:(HWND)hwnd : (WPARAM)wParam : (LPARAM)lParam
{
if (flags.HOLD_MINI_FOR_SIZE == FALSE)
{
NSPoint eventLocation;
NSRect rect;
RECT r;
NSEvent *ev = nil;
GetWindowRect(hwnd, &r);
rect = MSScreenRectToGS(r);
eventLocation = rect.origin;
ev = [NSEvent otherEventWithType: NSAppKitDefined
location: eventLocation
modifierFlags: 0
timestamp: 0
windowNumber: (int)hwnd
context: GSCurrentContext()
subtype: GSAppKitWindowMoved
data1: rect.origin.x
data2: rect.origin.y];
//need native code here?
[EVENT_WINDOW(hwnd) sendEvent: ev];
}
{
NSPoint eventLocation;
NSRect rect;
RECT r;
NSEvent *ev = nil;
GetWindowRect(hwnd, &r);
rect = MSScreenRectToGS(r);
eventLocation = rect.origin;
ev = [NSEvent otherEventWithType: NSAppKitDefined
location: eventLocation
modifierFlags: 0
timestamp: 0
windowNumber: (int)hwnd
context: GSCurrentContext()
subtype: GSAppKitWindowMoved
data1: rect.origin.x
data2: rect.origin.y];
//need native code here?
[EVENT_WINDOW(hwnd) sendEvent: ev];
}
return 0;
}
@ -266,7 +266,7 @@
- (void) decodeWM_WINDOWPOSCHANGINGParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
{
WINDOWPOS *inf = (WINDOWPOS*)lParam;
WINDOWPOS *inf = (WINDOWPOS*)lParam;
if ((inf->flags & SWP_NOZORDER) == 0)
{
@ -284,7 +284,6 @@
- (LRESULT) decodeWM_GETMINMAXINFOParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
{
// reused from original author (added debug code)
WIN_INTERN *win = (WIN_INTERN *)GetWindowLong(hwnd, GWL_USERDATA);
MINMAXINFO *mm;
@ -327,13 +326,8 @@
- (LRESULT) decodeWM_MOVINGParams:(HWND)hwnd : (WPARAM)wParam : (LPARAM)lParam
{
// [self decodeWM_MOVEParams:(HWND)hwnd : (WPARAM)wParam : (LPARAM)lParam];
[EVENT_WINDOW(hwnd) display];
return TRUE;
}
@end

View file

@ -26,6 +26,8 @@
#include <Foundation/NSDebug.h>
#include <Foundation/NSString.h>
#include <AppKit/NSBitmapImageRep.h>
#include <AppKit/NSGraphics.h>
#include "winlib/WIN32GState.h"
#include "winlib/WIN32FontEnumerator.h"
@ -54,6 +56,50 @@
{
}
// Try to match restrictions in GSCreateBitmap()
- (BOOL) isCompatibleBitmap: (NSBitmapImageRep*)bitmap
{
NSString *colorSpaceName;
NSInteger numColors;
if ([bitmap bitmapFormat] != 0)
{
return NO;
}
if ([bitmap isPlanar])
{
return NO;
}
if ([bitmap bitsPerSample] != 8)
{
return NO;
}
numColors = [bitmap samplesPerPixel] - ([bitmap hasAlpha] ? 1 : 0);
colorSpaceName = [bitmap colorSpaceName];
if ([colorSpaceName isEqualToString: NSDeviceRGBColorSpace] ||
[colorSpaceName isEqualToString: NSCalibratedRGBColorSpace])
{
return (numColors == 3);
}
else if ([colorSpaceName isEqualToString: NSDeviceWhiteColorSpace] ||
[colorSpaceName isEqualToString: NSCalibratedWhiteColorSpace])
{
return (numColors == 1);
}
else if ([colorSpaceName isEqualToString: NSDeviceBlackColorSpace] ||
[colorSpaceName isEqualToString: NSCalibratedBlackColorSpace])
{
return (numColors == 1);
}
else
{
return NO;
}
}
@end
@implementation WIN32Context (Ops)

View file

@ -164,7 +164,7 @@ BOOL alpha_blend_source_over(HDC destDC,
HDC srcDC,
RECT rectFrom,
int x, int y, int w, int h,
float delta)
CGFloat delta)
{
BOOL success = YES;
@ -302,7 +302,7 @@ BOOL alpha_blend_source_over(HDC destDC,
fromRect: (NSRect)sourceRect
toPoint: (NSPoint)destPoint
op: (NSCompositingOperation)op
fraction: (float)delta
fraction: (CGFloat)delta
{
HDC sourceDC;
HDC hDC;
@ -408,7 +408,7 @@ BOOL alpha_blend_source_over(HDC destDC,
- (void) compositerect: (NSRect)aRect
op: (NSCompositingOperation)op
{
float gray;
CGFloat gray;
// FIXME: This is taken from the xlib backend
[self DPScurrentgray: &gray];
@ -462,7 +462,7 @@ BOOL alpha_blend_source_over(HDC destDC,
fromRect: (NSRect)aRect
toPoint: (NSPoint)aPoint
op: (NSCompositingOperation)op
fraction: (float)delta
fraction: (CGFloat)delta
{
HDC sourceDC;
HDC hDC;
@ -569,9 +569,9 @@ BOOL alpha_blend_source_over(HDC destDC,
}
static
HBITMAP GSCreateBitmap(HDC hDC, int pixelsWide, int pixelsHigh,
int bitsPerSample, int samplesPerPixel,
int bitsPerPixel, int bytesPerRow,
HBITMAP GSCreateBitmap(HDC hDC, NSInteger pixelsWide, NSInteger pixelsHigh,
NSInteger bitsPerSample, NSInteger samplesPerPixel,
NSInteger bitsPerPixel, NSInteger bytesPerRow,
BOOL isPlanar, BOOL hasAlpha,
NSString *colorSpaceName,
const unsigned char *const data[5])
@ -584,10 +584,12 @@ HBITMAP GSCreateBitmap(HDC hDC, int pixelsWide, int pixelsHigh,
UINT fuColorUse;
if (isPlanar
|| !([colorSpaceName isEqualToString: NSDeviceRGBColorSpace]
|| ![colorSpaceName isEqualToString: NSCalibratedWhiteColorSpace]
|| ![colorSpaceName isEqualToString: NSCalibratedBlackColorSpace]
|| [colorSpaceName isEqualToString: NSCalibratedRGBColorSpace]))
|| (![colorSpaceName isEqualToString: NSDeviceRGBColorSpace]
&& ![colorSpaceName isEqualToString: NSCalibratedRGBColorSpace]
&& ![colorSpaceName isEqualToString: NSDeviceWhiteColorSpace]
&& ![colorSpaceName isEqualToString: NSCalibratedWhiteColorSpace]
&& ![colorSpaceName isEqualToString: NSDeviceBlackColorSpace]
&& ![colorSpaceName isEqualToString: NSCalibratedBlackColorSpace]))
{
NSLog(@"Bitmap type currently not supported %d %@",
isPlanar, colorSpaceName);
@ -680,7 +682,8 @@ HBITMAP GSCreateBitmap(HDC hDC, int pixelsWide, int pixelsHigh,
return NULL;
}
if ([colorSpaceName isEqualToString: NSCalibratedWhiteColorSpace])
if ([colorSpaceName isEqualToString: NSDeviceWhiteColorSpace] ||
[colorSpaceName isEqualToString: NSCalibratedWhiteColorSpace])
{
while (i < (pixels*4))
{
@ -694,7 +697,8 @@ HBITMAP GSCreateBitmap(HDC hDC, int pixelsWide, int pixelsHigh,
j++;
}
}
else if ([colorSpaceName isEqualToString: NSCalibratedBlackColorSpace])
else if ([colorSpaceName isEqualToString: NSDeviceBlackColorSpace] ||
[colorSpaceName isEqualToString: NSCalibratedBlackColorSpace])
{
while (i < (pixels*4))
{
@ -710,7 +714,74 @@ HBITMAP GSCreateBitmap(HDC hDC, int pixelsWide, int pixelsHigh,
}
else
{
NSLog(@"Unexpected condition, greyscale which is neither white nor black calibrated");
NSLog(@"Unexpected condition, greyscale which is neither white nor black");
free(tmp);
free(bitmap);
DeleteObject(hbitmap);
return NULL;
}
bits = tmp;
}
else if (bitsPerPixel == 16 && samplesPerPixel == 2) // 8 bit greyscale 8 bit alpha
{
BITMAPV4HEADER *bmih;
unsigned char *tmp;
unsigned int pixels = pixelsHigh * pixelsWide;
unsigned int i = 0;
unsigned int j = 0;
((BITMAPINFOHEADER*)bitmap)->biBitCount = 32;
bmih = (BITMAPV4HEADER*)bitmap;
bmih->bV4Size = sizeof(BITMAPV4HEADER);
bmih->bV4V4Compression = BI_BITFIELDS;
bmih->bV4BlueMask = 0x000000FF;
bmih->bV4GreenMask = 0x0000FF00;
bmih->bV4RedMask = 0x00FF0000;
bmih->bV4AlphaMask = 0xFF000000;
tmp = malloc(pixels * 4);
if (!tmp)
{
NSLog(@"Failed to allocate temporary memory for bitmap. Error %d",
GetLastError());
free(bitmap);
DeleteObject(hbitmap);
return NULL;
}
if ([colorSpaceName isEqualToString: NSDeviceWhiteColorSpace] ||
[colorSpaceName isEqualToString: NSCalibratedWhiteColorSpace])
{
while (i < (pixels*4))
{
unsigned char pix;
pix = bits[j];
tmp[i+0] = pix;
tmp[i+1] = pix;
tmp[i+2] = pix;
tmp[i+3] = bits[j + 1];
i += 4;
j += 2;
}
}
else if ([colorSpaceName isEqualToString: NSDeviceBlackColorSpace] ||
[colorSpaceName isEqualToString: NSCalibratedBlackColorSpace])
{
while (i < (pixels*4))
{
unsigned char pix;
pix = UCHAR_MAX - bits[j];
tmp[i+0] = pix;
tmp[i+1] = pix;
tmp[i+2] = pix;
tmp[i+3] = bits[j + 1];
i += 4;
j += 2;
}
}
else
{
NSLog(@"Unexpected condition, greyscale which is neither white nor black");
free(tmp);
free(bitmap);
DeleteObject(hbitmap);
@ -752,43 +823,6 @@ HBITMAP GSCreateBitmap(HDC hDC, int pixelsWide, int pixelsHigh,
}
bits = tmp;
}
else if (bitsPerPixel == 16 && samplesPerPixel == 2) // 8 bit greyscale 8 bit alpha
{
BITMAPV4HEADER *bmih;
unsigned char *tmp;
unsigned int pixels = pixelsHigh * pixelsWide;
unsigned int i = 0, j = 0;
((BITMAPINFOHEADER*)bitmap)->biBitCount = 32;
bmih = (BITMAPV4HEADER*)bitmap;
bmih->bV4Size = sizeof(BITMAPV4HEADER);
bmih->bV4V4Compression = BI_BITFIELDS;
bmih->bV4BlueMask = 0x000000FF;
bmih->bV4GreenMask = 0x0000FF00;
bmih->bV4RedMask = 0x00FF0000;
bmih->bV4AlphaMask = 0xFF000000;
tmp = malloc(pixels * 4);
if (!tmp)
{
NSLog(@"Failed to allocate temporary memory for bitmap. Error %d",
GetLastError());
free(bitmap);
DeleteObject(hbitmap);
return NULL;
}
while (i < pixels*4)
{
tmp[i+0] = bits[j];
tmp[i+1] = bits[j];
tmp[i+2] = bits[j];
tmp[i+3] = bits[j + 1];
i += 4;
j += 2;
}
bits = tmp;
}
else if (bitsPerPixel == 24)
{
unsigned char* tmp;
@ -868,9 +902,9 @@ HBITMAP GSCreateBitmap(HDC hDC, int pixelsWide, int pixelsHigh,
// -DPSimage: can cause images to be drawn with a 1px horizontal line cut at
// the top. That's why -DPSimage we still use the GDI top left coordinates.
- (void)DPSimage: (NSAffineTransform*) matrix
: (int) pixelsWide : (int) pixelsHigh
: (int) bitsPerSample : (int) samplesPerPixel
: (int) bitsPerPixel : (int) bytesPerRow : (BOOL) isPlanar
: (NSInteger) pixelsWide : (NSInteger) pixelsHigh
: (NSInteger) bitsPerSample : (NSInteger) samplesPerPixel
: (NSInteger) bitsPerPixel : (NSInteger) bytesPerRow : (BOOL) isPlanar
: (BOOL) hasAlpha : (NSString *) colorSpaceName
: (const unsigned char *const [5]) data
{
@ -1215,7 +1249,7 @@ HBITMAP GSCreateBitmap(HDC hDC, int pixelsWide, int pixelsHigh,
}
- (void) DPSsetdash: (const float*)thePattern : (int)count : (float)phase
- (void) DPSsetdash: (const CGFloat*)thePattern : (NSInteger)count : (CGFloat)phase
{
if (!path)
{
@ -1226,12 +1260,12 @@ HBITMAP GSCreateBitmap(HDC hDC, int pixelsWide, int pixelsHigh,
[path setLineDash: thePattern count: count phase: phase];
}
- (void)DPScurrentmiterlimit: (float *)limit
- (void)DPScurrentmiterlimit: (CGFloat *)limit
{
*limit = miterlimit;
}
- (void)DPSsetmiterlimit: (float)limit
- (void)DPSsetmiterlimit: (CGFloat)limit
{
// FIXME: Convert to ctm first
miterlimit = limit;
@ -1257,12 +1291,12 @@ HBITMAP GSCreateBitmap(HDC hDC, int pixelsWide, int pixelsHigh,
joinStyle = linejoin;
}
- (void)DPScurrentlinewidth: (float *)width
- (void)DPScurrentlinewidth: (CGFloat *)width
{
*width = lineWidth;
}
- (void)DPSsetlinewidth: (float)width
- (void)DPSsetlinewidth: (CGFloat)width
{
// FIXME: Convert to ctm first
lineWidth = width;
@ -1290,10 +1324,8 @@ HBITMAP GSCreateBitmap(HDC hDC, int pixelsWide, int pixelsHigh,
DWORD penStyle;
// Temporary variables for gathering pen information
float* thePattern = NULL;
DWORD* iPattern = NULL;
int patternCount = 0;
float phase = 0.0;
NSInteger patternCount = 0;
SetBkMode(hDC, TRANSPARENT);
br.lbStyle = BS_SOLID;
@ -1342,20 +1374,22 @@ HBITMAP GSCreateBitmap(HDC hDC, int pixelsWide, int pixelsHigh,
if (patternCount > 0)
{
NSInteger i = 0;
CGFloat* thePattern[patternCount];
CGFloat phase = 0.0;
penStyle = PS_GEOMETRIC | PS_USERSTYLE;
// The user has defined a dash pattern for stroking on
// the path. Note that we lose the floating point information
// here, as windows only supports DWORD elements, not float.
thePattern = malloc(sizeof(float) * patternCount);
[path getLineDash: thePattern count: &patternCount phase: &phase];
iPattern = malloc(sizeof(DWORD) * patternCount);
int i = 0;
for (i = 0 ; i < patternCount; i ++)
iPattern[i] = (DWORD)thePattern[i];
free(thePattern);
thePattern = NULL;
{
iPattern[i] = (DWORD)thePattern[i];
}
}
else
{

View file

@ -485,7 +485,7 @@ static XGDragView *sharedDragView = nil;
[self setExcludedFromWindowsMenu: YES];
}
- (void) orderWindow: (NSWindowOrderingMode)place relativeTo: (int)otherWin
- (void) orderWindow: (NSWindowOrderingMode)place relativeTo: (NSInteger)otherWin
{
XSetWindowAttributes winattrs;
unsigned long valuemask;

View file

@ -282,7 +282,7 @@ static XGGLContext *currentGLContext;
MAKE_DISPLAY(dpy);
if (currentGLContext == self)
{
{
[XGGLContext clearCurrentContext];
}

View file

@ -39,6 +39,10 @@
#include <X11/Xlib.h>
#include <math.h>
#ifdef XRENDER
#include <X11/extensions/Xrender.h>
#endif
@implementation XGGLPixelFormat
+ (int) glxMinorVersion
@ -85,7 +89,7 @@
if (glxminorversion >= 3)
{
error = glXGetFBConfigAttrib(display, fbconfig[0], attrib, vals);
error = glXGetFBConfigAttrib(display, fbconfig[pickedFBConfig], attrib, vals);
if ( error != 0 )
NSDebugMLLog( @"GLX", @"Can not get FB attribute for pixel format %@ - Error %u",
self, error );
@ -104,6 +108,8 @@
int AccumSize;
NSOpenGLPixelFormatAttribute *ptr = pixelFormatAttributes;
NSMutableData *data = [NSMutableData data];
shouldRequestARGBVisual = NO;
#define append(a, b) \
do \
@ -176,6 +182,8 @@ do \
{
ptr++;
append(GLX_ALPHA_SIZE, *ptr);
if (*ptr > 0)
shouldRequestARGBVisual = YES;
break;
}
case NSOpenGLPFADepthSize:
@ -344,7 +352,30 @@ do \
[glxAttributes mutableBytes],
&configurationCount);
visualinfo = glXGetVisualFromFBConfig(display,fbconfig[0]);
#if defined(XRENDER)
int i;
for (i = 0; i < configurationCount; i++)
{
XVisualInfo * vinfo = glXGetVisualFromFBConfig(display, fbconfig[i]);
XRenderPictFormat* pictFormat = XRenderFindVisualFormat (display, vinfo->visual);
if ((NULL != pictFormat
&& (pictFormat->type == PictTypeDirect)
&& (pictFormat->direct.alphaMask))
||
!shouldRequestARGBVisual)
{
pickedFBConfig = i;
visualinfo = vinfo;
break;
}
}
#endif
if(!visualinfo && configurationCount > 0)
{
visualinfo = glXGetVisualFromFBConfig(display,fbconfig[0]);
pickedFBConfig = 0;
}
}
else
{
@ -384,7 +415,7 @@ do \
if (glxminorversion >= 3)
{
context = glXCreateNewContext(display, fbconfig[0],
context = glXCreateNewContext(display, fbconfig[pickedFBConfig],
GLX_RGBA_TYPE, [share glxcontext], YES);
}
else
@ -410,7 +441,7 @@ do \
if (glxminorversion >= 3)
{
win = glXCreateWindow(display, fbconfig[0], xwindowid, NULL);
win = glXCreateWindow(display, fbconfig[pickedFBConfig], xwindowid, NULL);
}
else
{

View file

@ -890,10 +890,12 @@ posixFileDescriptor: (NSPosixFileDescriptor*)fileDescriptor
*/
if (!NSEqualSizes(r.size, x.size))
{
NSEvent *r;
/* Resize events move the origin. There's no good
place to pass this info back, so we put it in
the event location field */
e = [NSEvent otherEventWithType: NSAppKitDefined
r = [NSEvent otherEventWithType: NSAppKitDefined
location: n.origin
modifierFlags: eventFlags
timestamp: ts / 1000.0
@ -902,14 +904,19 @@ posixFileDescriptor: (NSPosixFileDescriptor*)fileDescriptor
subtype: GSAppKitWindowResized
data1: n.size.width
data2: n.size.height];
/* We don't add this event in event_queue, to don't delay
* its sent. Instead, send it directly to the window. If not,
* the programa can move/resize the window while we send
* this event, causing a confusion.
*/
[[NSApp windowWithWindowNumber: cWin->number] sendEvent: r];
}
if (!NSEqualPoints(r.origin, x.origin))
{
if (e != nil)
{
[event_queue addObject: e];
}
e = [NSEvent otherEventWithType: NSAppKitDefined
NSEvent *r;
r = [NSEvent otherEventWithType: NSAppKitDefined
location: eventLocation
modifierFlags: eventFlags
timestamp: ts / 1000.0
@ -918,6 +925,13 @@ posixFileDescriptor: (NSPosixFileDescriptor*)fileDescriptor
subtype: GSAppKitWindowMoved
data1: n.origin.x
data2: n.origin.y];
/* We don't add this event in event_queue, to don't delay
* its sent. Instead, send it directly to the window. If not,
* the programa can move/resize the window while we send
* this event, causing a confusion.
*/
[[NSApp windowWithWindowNumber: cWin->number] sendEvent: r];
}
}
break;

View file

@ -63,6 +63,9 @@
#ifdef HAVE_XSHAPE
#include <X11/extensions/shape.h>
#endif
#if HAVE_XFIXES
#include <X11/extensions/Xfixes.h>
#endif
#include "x11/XGDragView.h"
#include "x11/XGInputServer.h"
@ -99,14 +102,14 @@ static int last_win_num = 0;
@end
@interface NSBitmapImageRep (GSPrivate)
- (NSBitmapImageRep *) _convertToFormatBitsPerSample: (int)bps
samplesPerPixel: (int)spp
- (NSBitmapImageRep *) _convertToFormatBitsPerSample: (NSInteger)bps
samplesPerPixel: (NSInteger)spp
hasAlpha: (BOOL)alpha
isPlanar: (BOOL)isPlanar
colorSpaceName: (NSString*)colorSpaceName
bitmapFormat: (NSBitmapFormat)bitmapFormat
bytesPerRow: (int)rowBytes
bitsPerPixel: (int)pixelBits;
bytesPerRow: (NSInteger)rowBytes
bitsPerPixel: (NSInteger)pixelBits;
@end
static NSBitmapImageRep *getStandardBitmap(NSImage *image)
@ -658,6 +661,47 @@ static void setWindowHintsForStyle (Display *dpy, Window window,
return NO;
}
static void
select_input(Display *display, Window w, BOOL ignoreMouse)
{
long event_mask;
if (!ignoreMouse)
{
event_mask = ExposureMask
| KeyPressMask
| KeyReleaseMask
| ButtonPressMask
| ButtonReleaseMask
| ButtonMotionMask
| StructureNotifyMask
| PointerMotionMask
| EnterWindowMask
| LeaveWindowMask
| FocusChangeMask
/* enable property notifications to detect window (de)miniaturization */
| PropertyChangeMask
// | ColormapChangeMask
| KeymapStateMask
| VisibilityChangeMask;
}
else
{
event_mask = ExposureMask
| KeyPressMask
| KeyReleaseMask
| StructureNotifyMask
| FocusChangeMask
/* enable property notifications to detect window (de)miniaturization */
| PropertyChangeMask
// | ColormapChangeMask
| KeymapStateMask
| VisibilityChangeMask;
}
XSelectInput(display, w, event_mask);
}
Bool
_get_next_prop_new_event(Display *display, XEvent *event, char *arg)
{
@ -819,24 +863,8 @@ _get_next_prop_new_event(Display *display, XEvent *event, char *arg)
valuemask = (GCForeground | GCBackground | GCFunction);
window->gc = XCreateGC(dpy, window->ident, valuemask, &values);
/* Set the X event mask
*/
XSelectInput(dpy, window->ident, ExposureMask
| KeyPressMask
| KeyReleaseMask
| ButtonPressMask
| ButtonReleaseMask
| ButtonMotionMask
| StructureNotifyMask
| PointerMotionMask
| EnterWindowMask
| LeaveWindowMask
| FocusChangeMask
| PropertyChangeMask
// | ColormapChangeMask
| KeymapStateMask
| VisibilityChangeMask
);
/* Set the X event mask */
select_input(dpy, window->ident, YES);
/*
* Initial attributes for any GNUstep window tell Window Maker not to
@ -1345,9 +1373,19 @@ _get_next_prop_new_event(Display *display, XEvent *event, char *arg)
window->visibility = -1;
window->wm_state = NormalState;
if (window->ident)
XGetGeometry(dpy, window->ident, &window->root,
&x, &y, &width, &height,
&window->border, &window->depth);
{
XGetGeometry(dpy, window->ident, &window->root,
&x, &y, &width, &height,
&window->border, &window->depth);
}
else
{
NSLog(@"Failed to get root window");
x = 0;
y = 0;
width = 0;
height = 0;
}
window->xframe = NSMakeRect(x, y, width, height);
NSMapInsert (windowtags, (void*)(uintptr_t)window->number, window);
@ -1960,7 +1998,7 @@ _get_next_prop_new_event(Display *display, XEvent *event, char *arg)
XClassHint classhint;
RContext *context;
NSDebugLLog(@"XGTrace", @"DPSwindow: %@ %d", NSStringFromRect(frame), type);
NSDebugLLog(@"XGTrace", @"DPSwindow: %@ %d", NSStringFromRect(frame), (int)type);
root = [self _rootWindowForScreen: screen];
context = [self xrContextForScreen: screen];
@ -2034,25 +2072,8 @@ _get_next_prop_new_event(Display *display, XEvent *event, char *arg)
valuemask = (GCForeground | GCBackground | GCFunction);
window->gc = XCreateGC(dpy, window->ident, valuemask, &values);
/* Set the X event mask
*/
XSelectInput(dpy, window->ident, ExposureMask
| KeyPressMask
| KeyReleaseMask
| ButtonPressMask
| ButtonReleaseMask
| ButtonMotionMask
| StructureNotifyMask
| PointerMotionMask
| EnterWindowMask
| LeaveWindowMask
| FocusChangeMask
/* enable property notifications to detect window (de)miniaturization */
| PropertyChangeMask
// | ColormapChangeMask
| KeymapStateMask
| VisibilityChangeMask
);
/* Set the X event mask */
select_input(dpy, window->ident, NO);
/*
* Initial attributes for any GNUstep window tell Window Maker not to
@ -2526,7 +2547,7 @@ NSLog(@"styleoffsets ... guessing offsets\n");
if (!window)
return;
NSDebugLLog(@"XGTrace", @"DPSwindowbacking: %@ : %d", type, win);
NSDebugLLog(@"XGTrace", @"DPSwindowbacking: %d : %d", (int)type, win);
if ((window->gdriverProtocol & GDriverHandlesBacking))
{
@ -3908,7 +3929,7 @@ static BOOL didCreatePixmaps;
}
/** Sets the transparancy value for the whole window */
- (void) setalpha: (float)alpha: (int) win
- (void) setalpha: (float)alpha : (int) win
{
gswindow_device_t *window = WINDOW_WITH_TAG(win);
static Atom opacity_atom = None;
@ -4997,4 +5018,44 @@ _computeDepth(int class, int bpp)
XSetTransientForHint(dpy, cwindow->ident, p);
}
- (void) setIgnoreMouse: (BOOL)ignoreMouse : (int)win
{
#if HAVE_XFIXES
gswindow_device_t *window;
XserverRegion region;
int error;
int xFixesEventBase;
if (!XFixesQueryExtension(dpy, &xFixesEventBase, &error))
{
return;
}
window = WINDOW_WITH_TAG(win);
if (!window)
{
return;
}
if (ignoreMouse)
{
region = XFixesCreateRegion(dpy, NULL, 0);
}
else
{
region = None;
}
XFixesSetWindowShapeRegion(dpy,
window->ident,
ShapeInput,
0, 0, region);
if (region != None)
{
XFixesDestroyRegion(dpy, region);
}
#endif
}
@end

View file

@ -28,6 +28,8 @@
#include "config.h"
#include <AppKit/AppKitExceptions.h>
#include <AppKit/NSAffineTransform.h>
#include <AppKit/NSBitmapImageRep.h>
#include <AppKit/NSGraphics.h>
#include <AppKit/NSColor.h>
#include <AppKit/NSView.h>
#include <AppKit/NSWindow.h>
@ -141,6 +143,49 @@
XFlush([(XGServer *)server xDisplay]);
}
// Try to match the restrictions in XGBitmap
- (BOOL) isCompatibleBitmap: (NSBitmapImageRep*)bitmap
{
NSString *colorSpaceName;
int numColors;
if ([bitmap bitmapFormat] != 0)
{
return NO;
}
if ([bitmap bitsPerSample] > 8)
{
return NO;
}
numColors = [bitmap samplesPerPixel] - ([bitmap hasAlpha] ? 1 : 0);
colorSpaceName = [bitmap colorSpaceName];
if ([colorSpaceName isEqualToString: NSDeviceRGBColorSpace] ||
[colorSpaceName isEqualToString: NSCalibratedRGBColorSpace])
{
return (numColors == 3);
}
else if ([colorSpaceName isEqualToString: NSDeviceCMYKColorSpace])
{
return (numColors == 4);
}
else if ([colorSpaceName isEqualToString: NSDeviceWhiteColorSpace] ||
[colorSpaceName isEqualToString: NSCalibratedWhiteColorSpace])
{
return (numColors == 1);
}
else if ([colorSpaceName isEqualToString: NSDeviceBlackColorSpace] ||
[colorSpaceName isEqualToString: NSCalibratedBlackColorSpace])
{
return (numColors == 1);
}
else
{
return NO;
}
}
@end
@implementation XGContext (Ops)

View file

@ -471,7 +471,7 @@ static Region emptyRegion;
dest_win->depth);
/* Fill alpha also (opaque by default) */
[self setAlphaColor: 1];
[self setAlphaColor: 1.0];
XFillRectangle(XDPY, dest_win->alpha_buffer, agcntxt, 0, 0,
NSWidth(dest_win->xframe), NSHeight(dest_win->xframe));
}
@ -486,7 +486,7 @@ static Region emptyRegion;
fromRect: (NSRect) fromRect
toPoint: (NSPoint) toPoint
op: (NSCompositingOperation) op
fraction: (float)delta
fraction: (CGFloat)delta
{
XRectangle srect;
XRectangle drect;
@ -639,7 +639,7 @@ static Region emptyRegion;
fromRect: (NSRect)aRect
toPoint: (NSPoint)aPoint
op: (NSCompositingOperation)op
fraction: (float)delta
fraction: (CGFloat)delta
{
BOOL do_copy, source_alpha;
XGCValues comp_gcv;
@ -780,7 +780,7 @@ static Region emptyRegion;
- (void) compositerect: (NSRect)aRect
op: (NSCompositingOperation)op
{
float gray;
CGFloat gray;
[self DPScurrentgray: &gray];
if (fabs(gray - 0.667) < 0.005)
@ -1234,7 +1234,7 @@ static Region emptyRegion;
@implementation XGGState (Ops)
- (void) DPSsetalpha: (float)a
- (void) DPSsetalpha: (CGFloat)a
{
gswindow_device_t *gs_win;
[super DPSsetalpha: a];
@ -1373,7 +1373,7 @@ static Region emptyRegion;
*linejoin = gcv.join_style - JoinMiter;
}
- (void)DPScurrentlinewidth: (float *)width
- (void)DPScurrentlinewidth: (CGFloat *)width
{
*width = gcv.line_width;
}
@ -1386,7 +1386,7 @@ static Region emptyRegion;
clipregion = 0;
}
- (void)DPSsetdash: (const float *)pat : (int)size : (float)pat_offset
- (void)DPSsetdash: (const CGFloat *)pat : (NSInteger)size : (CGFloat)pat_offset
{
int dash_offset;
char dash_list[size];
@ -1427,7 +1427,7 @@ static Region emptyRegion;
[self setGCValues: gcv withMask: GCJoinStyle];
}
- (void)DPSsetlinewidth: (float)width
- (void)DPSsetlinewidth: (CGFloat)width
{
int w;
NSSize ws;
@ -1451,7 +1451,7 @@ static Region emptyRegion;
}
}
- (void) DPSsetmiterlimit: (float)limit
- (void) DPSsetmiterlimit: (CGFloat)limit
{
/* Do nothing. X11 does its own thing and doesn't give us a choice */
}
@ -1505,7 +1505,7 @@ static Region emptyRegion;
[self setClipMask];
}
- (void)DPSrectclip: (float)x : (float)y : (float)w : (float)h
- (void)DPSrectclip: (CGFloat)x : (CGFloat)y : (CGFloat)w : (CGFloat)h
{
XRectangle xrect;
NSRect orect;
@ -1532,7 +1532,7 @@ static Region emptyRegion;
[self DPSnewpath];
}
- (void)DPSrectfill: (float)x : (float)y : (float)w : (float)h
- (void)DPSrectfill: (CGFloat)x : (CGFloat)y : (CGFloat)w : (CGFloat)h
{
XRectangle bounds;
@ -1578,7 +1578,7 @@ NSDebugLLog(@"XGGraphics", @"Fill %@ X rect %d,%d,%d,%d",
}
}
- (void)DPSrectstroke: (float)x : (float)y : (float)w : (float)h
- (void)DPSrectstroke: (CGFloat)x : (CGFloat)y : (CGFloat)w : (CGFloat)h
{
XRectangle bounds;
@ -1620,9 +1620,9 @@ NSDebugLLog(@"XGGraphics", @"Fill %@ X rect %d,%d,%d,%d",
/* ----------------------------------------------------------------------- */
/* NSGraphics Ops */
/* ----------------------------------------------------------------------- */
- (void)DPSimage: (NSAffineTransform*) matrix : (int) pixelsWide : (int) pixelsHigh
: (int) bitsPerSample : (int) samplesPerPixel
: (int) bitsPerPixel : (int) bytesPerRow : (BOOL) isPlanar
- (void)DPSimage: (NSAffineTransform*) matrix : (NSInteger) pixelsWide : (NSInteger) pixelsHigh
: (NSInteger) bitsPerSample : (NSInteger) samplesPerPixel
: (NSInteger) bitsPerPixel : (NSInteger) bytesPerRow : (BOOL) isPlanar
: (BOOL) hasAlpha : (NSString *) colorSpaceName
: (const unsigned char *const [5]) data
{
@ -1640,8 +1640,8 @@ NSDebugLLog(@"XGGraphics", @"Fill %@ X rect %d,%d,%d,%d",
rect = NSZeroRect;
one_is_black = NO;
cspace = rgb_colorspace;
rect.size.width = (float) pixelsWide;
rect.size.height = (float) pixelsHigh;
rect.size.width = (CGFloat) pixelsWide;
rect.size.height = (CGFloat) pixelsHigh;
// default is 8 bit grayscale
if (!bitsPerSample)

View file

@ -43,7 +43,6 @@ ADDITIONAL_OBJCFLAGS += -Wall
# Additional include directories the compiler should search
ADDITIONAL_INCLUDE_DIRS += -I../Headers -I../Source/$(GNUSTEP_TARGET_DIR)
# Additional LDFLAGS to pass to the linker
# ADDITIONAL_LDFLAGS +=
@ -63,8 +62,8 @@ ADDITIONAL_INSTALL_DIRS +=
# Flags for when the backend is compiled as a bundle
ifneq ($(BACKEND_BUNDLE),)
ADDITIONAL_TOOL_LIBS += $(GUI_LIBS) $(GRAPHIC_LIBS) $(SYSTEM_LIBS)
ADDITIONAL_INCLUDE_DIRS += $(GRAPHIC_CFLAGS)
ADDITIONAL_LIB_DIRS += $(GRAPHIC_LFLAGS)
CONFIG_SYSTEM_INCL += $(GRAPHIC_CFLAGS)
CONFIG_SYSTEM_LIB_DIR += $(GRAPHIC_LFLAGS)
else
ADDITIONAL_TOOL_LIBS += -lgnustep-gui -lgnustep-back $(SYSTEM_LIBS)
endif

View file

@ -399,23 +399,23 @@ LRESULT CALLBACK MainWndProc(HWND hwnd, UINT uMsg,
case WM_RENDERALLFORMATS:
if (!OpenClipboard(hwnd))
{
NSWarnMLog(@"Failed to get the Win32 clipboard. %d", GetLastError());
}
{
NSWarnMLog(@"Failed to get the Win32 clipboard. %d", GetLastError());
}
else if (GetClipboardOwner() == hwnd)
{
if (!EmptyClipboard())
{
NSWarnMLog(@"Failed to get the Win32 clipboard. %d", GetLastError());
}
else
{
SendMessage(hwnd, WM_RENDERFORMAT, CF_UNICODETEXT, 0);
CloseClipboard();
}
}
{
if (!EmptyClipboard())
{
NSWarnMLog(@"Failed to get the Win32 clipboard. %d", GetLastError());
}
else
{
SendMessage(hwnd, WM_RENDERFORMAT, CF_UNICODETEXT, 0);
CloseClipboard();
}
}
break;
default:
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}

View file

@ -4,9 +4,9 @@
# The version number of this release.
GNUSTEP_BACK_MAJOR_VERSION=0
GNUSTEP_BACK_MINOR_VERSION=23
GNUSTEP_BACK_SUBMINOR_VERSION=0
GNUSTEP_BACK_SUBMINOR_VERSION=1
# This numeric value should match above
VERSION_NUMBER=023.0
VERSION_NUMBER=023.1
# This numeric value should match the compatible gui interface version
INTERFACE_VERSION_NUMBER=023

View file

@ -8,6 +8,7 @@
#define GRAPHICS_xlib 2
#define GRAPHICS_winlib 3
#define GRAPHICS_cairo 4
#define GRAPHICS_opal 5
/* Define to type of graphics context to build */

4
configure vendored
View file

@ -1341,7 +1341,7 @@ Optional Features:
--disable-wgl Disable WGL support
--enable-glitz Enable Glitz support
--enable-server=SRV Build server type: x11, win32
--enable-graphics=GPH Build graphics: xlib, xdps, winlib, art, cairo
--enable-graphics=GPH Build graphics: xlib, xdps, winlib, art, cairo, opal
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
@ -7149,6 +7149,8 @@ elif test x"$BUILD_GRAPHICS" = "xxlib"; then
: # Nothing to do
elif test x"$BUILD_GRAPHICS" = "xwinlib"; then
: # Nothing to do
elif test x"$BUILD_GRAPHICS" = "xopal"; then
LIBS="-lopal -lgnustep-corebase $LIBS"
else
as_fn_error $? "Invalid graphics backend $BUILD_GRAPHICS" "$LINENO" 5
fi

View file

@ -529,7 +529,7 @@ AC_ARG_ENABLE(server,
[ --enable-server=SRV Build server type: x11, win32],,
enable_server=$BUILD_SERVER)
AC_ARG_ENABLE(graphics,
[ --enable-graphics=GPH Build graphics: xlib, xdps, winlib, art, cairo],,
[ --enable-graphics=GPH Build graphics: xlib, xdps, winlib, art, cairo, opal],,
enable_graphics="$BUILD_GRAPHICS")
BUILD_SERVER=$enable_server
@ -641,6 +641,8 @@ elif test x"$BUILD_GRAPHICS" = "xxlib"; then
: # Nothing to do
elif test x"$BUILD_GRAPHICS" = "xwinlib"; then
: # Nothing to do
elif test x"$BUILD_GRAPHICS" = "xopal"; then
LIBS="-lopal -lgnustep-corebase $LIBS"
else
AC_MSG_ERROR([Invalid graphics backend $BUILD_GRAPHICS])
fi
@ -688,6 +690,7 @@ AH_TOP([
#define GRAPHICS_xlib 2
#define GRAPHICS_winlib 3
#define GRAPHICS_cairo 4
#define GRAPHICS_opal 5
])
AC_DEFINE_UNQUOTED(BUILD_SERVER,SERVER_$BUILD_SERVER,
[Define to type of window server to build])