mirror of
https://github.com/gnustep/libs-back.git
synced 2025-04-22 15:31:14 +00:00
opal: Implementation of -graphicsPort that returns a CGContext. Stubs for -DPSsetlinejoin:, -DPSsetlinecap:, -DPSsetmiterlimit:. Implementation of -DPSimage::::::::::: for 32-bit RGB colorspaces
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/trunk@36940 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
5e0b1d096d
commit
2dadc661ff
3 changed files with 96 additions and 6 deletions
|
@ -1,3 +1,12 @@
|
|||
2013-08-02 Ivan Vucica <ivan@vucica.net>
|
||||
|
||||
* Source/opal/OpalContext.m:
|
||||
Implementation of -graphicsPort that returns a CGContext
|
||||
|
||||
* Source/opal/OpalGState.m:
|
||||
-Stubs for -DPSsetlinejoin:, -DPSsetlinecap:, -DPSsetmiterlimit:
|
||||
-Implementation of -DPSimage::::::::::: for 32-bit RGB colorspaces
|
||||
|
||||
2013-07-29 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/gsc/GSContext.m: Replace isa with object_getClass().
|
||||
|
|
|
@ -93,6 +93,13 @@
|
|||
}
|
||||
}
|
||||
|
||||
- (void *) graphicsPort
|
||||
{
|
||||
OpalSurface * surface;
|
||||
[OGSTATE GSCurrentSurface: &surface : NULL : NULL];
|
||||
return [surface cgContext];
|
||||
}
|
||||
|
||||
#if BUILD_SERVER == SERVER_x11
|
||||
#ifdef XSHM
|
||||
+ (void) _gotShmCompletion: (Drawable)d
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
#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"
|
||||
|
@ -63,12 +64,12 @@
|
|||
- (void) DPSimage: (NSAffineTransform *)matrix
|
||||
: (NSInteger)pixelsWide
|
||||
: (NSInteger)pixelsHigh
|
||||
: (NSInteger)bitsPerSample
|
||||
: (NSInteger)samplesPerPixel
|
||||
: (NSInteger)bitsPerSample // is this used correctly ?
|
||||
: (NSInteger)samplesPerPixel // < unused
|
||||
: (NSInteger)bitsPerPixel
|
||||
: (NSInteger)bytesPerRow
|
||||
: (BOOL)isPlanar
|
||||
: (BOOL)hasAlpha
|
||||
: (BOOL)isPlanar // < unused
|
||||
: (BOOL)hasAlpha // < unused
|
||||
: (NSString *)colorSpaceName
|
||||
: (const unsigned char *const[5])data
|
||||
{
|
||||
|
@ -83,9 +84,64 @@
|
|||
CGAffineTransform cgAT = *(CGAffineTransform *)&nsAT;
|
||||
|
||||
CGContextSaveGState(CGCTX);
|
||||
CGContextSetRGBFillColor(CGCTX, 1, 0, 0, 1);
|
||||
// CGContextSetRGBFillColor(CGCTX, 1, 0, 0, 1);
|
||||
CGContextConcatCTM(CGCTX, cgAT);
|
||||
CGContextFillRect(CGCTX, CGRectMake(0, 0, pixelsWide, pixelsHigh));
|
||||
// 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);
|
||||
}
|
||||
|
||||
|
@ -143,6 +199,24 @@
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue