opal: Switched to NSDebugLLog(). Added linking with CoreBase. Implemented CTM management methods. Added DPSsavegstate and DPSrestoregstate.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/trunk@36918 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Ivan Vučica 2013-07-23 23:18:48 +00:00
parent a64b9f9058
commit 82088f34e0
7 changed files with 128 additions and 58 deletions

View file

@ -1,3 +1,26 @@
2013-07-24 Ivan Vucica <ivan@vucica.net>
* configure.ac:
* configure:
Opal backend depends on both Opal and CoreBase. Added
CoreBase to list of libraries we link with.
* Source/opal/OpalFontInfo.m:
* Source/opal/OpalFontEnumerator.m:
Switched to NSDebugLLog().
* Source/opal/OpalGState.m:
-Switched to NSDebugLLog().
-Fixed DPSimage method's conversion of NSAffineTransform to
CGAffineTransform
-Implemented GSCurrentCTM
-Implemented flushGraphics
-Implemented DPSsavegstate and DPSrestoregstate
* Source/opal/OpalSurface.m:
-Switched to NSDebugLLog().
-Fixed section that is supposed to write out the debug image.
2013-07-21 Ivan Vucica <ivan@vucica.net>
* Source/opal/OpalFontInfo.m:

View file

@ -68,14 +68,14 @@
return self;
}
- (int) weight { NSLog(@"OpalFontEnumerator: Weight %d", _weight); return _weight; }
- (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 { NSLog(@"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
- (NSCharacterSet *) characterSet { NSDebugLLog(@"OpalFaceInfo", @"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
return [NSCharacterSet alphanumericCharacterSet]; }
@end
@ -85,42 +85,40 @@
+ (OpalFaceInfo *) fontWithName: (NSString *) name
{
NSLog(@"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
NSDebugLLog(@"OpalFontEnumerator", @"%p (%@): %s - %@", self, [self class], __PRETTY_FUNCTION__, name);
NSLog(@"Font with name %@", name);
return [[[OpalFaceInfo alloc] initWithFamilyName:name weight:1 traits:0] autorelease];
}
- (void) enumerateFontsAndFamilies
{
NSLog(@"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
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
{
NSLog(@"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
NSDebugLLog(@"OpalFontEnumerator", @"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
return @"FreeSans";
}
- (NSString *) defaultBoldSystemFontName
{
NSLog(@"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
NSDebugLLog(@"OpalFontEnumerator", @"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
return @"FreeSans-Bold";
}
- (NSString *) defaultFixedPitchFontName
{
NSLog(@"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
NSDebugLLog(@"OpalFontEnumerator", @"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
return @"FreeMono";
}
- (NSArray *) matchingFontDescriptorsFor: (NSDictionary *)attributes
{
NSLog(@"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
NSDebugLLog(@"OpalFontEnumerator", @"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
return [NSArray arrayWithObject:[NSFontDescriptor fontDescriptorWithName:@"FreeSans" size: 10]];
}
@end

View file

@ -25,6 +25,7 @@
Boston, MA 02110-1301, USA.
*/
#import <Foundation/Foundation.h>
#import "opal/OpalFontInfo.h"
@implementation OpalFontInfo
@ -33,27 +34,27 @@
matrix: (const CGFloat *)fmatrix
screenFont: (BOOL)p_screenFont
{
NSLog(@"OpalFontInfo: FONT INFO FOR %@", name);
NSDebugLLog(@"OpalFontInfo", @"OpalFontInfo: instantiating font info for %@", name);
return [super init];
}
- (NSRect) boundingRectForGlyph: (NSGlyph)glyph
{
NSLog(@"OpalFontInfo: BOUNDING RECT FOR GLYPTH %c", glyph);
NSDebugLLog(@"OpalFontInfo", @"OpalFontInfo: %s - %c", __PRETTY_FUNCTION__, glyph);
return NSMakeRect(0, 0, 10, 10);
}
- (CGFloat) widthOfString: (NSString *)string
{
NSLog(@"OpalFontInfo: WIDTH OF %@", string);
NSDebugLLog(@"OpalFontInfo", @"OpalFontInfo: %s - %@", __PRETTY_FUNCTION__, string);
return [string length] * 10;
}
- (NSSize) advancementForGlyph: (NSGlyph)glyph
{
NSLog(@"OpalFontInfo: ADVANCEMENT FOR %d", glyph);
NSDebugLLog(@"OpalFontInfo", @"OpalFontInfo: %s - %c", __PRETTY_FUNCTION__, glyph);
return NSMakeSize(100,100);
}
- (NSGlyph) glyphWithName: (NSString *) glyphName
{
NSLog(@"OpalFontInfo: GLYPH WITH NAME %s", glyphName);
NSDebugLLog(@"OpalFontInfo", @"OpalFontInfo: %s - %@", __PRETTY_FUNCTION__, glyphName);
// FIXME: incorrect
NSGlyph g = [glyphName cString][0];

View file

@ -33,6 +33,7 @@
#define CGCTX [self cgContext]
@implementation OpalGState
// MARK: Minimum required methods
@ -40,21 +41,21 @@
- (void) DPSinitclip
{
NSLog(@"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
NSDebugLLog(@"OpalGState", @"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
OPContextResetClip(CGCTX);
}
- (void) DPSclip
{
NSLog(@"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
NSDebugLLog(@"OpalGState", @"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
CGContextClip(CGCTX);
}
- (void) DPSfill
{
NSLog(@"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
NSDebugLLog(@"OpalGState", @"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
//CGContextFillPath(CGCTX);
}
@ -71,11 +72,19 @@
: (NSString *)colorSpaceName
: (const unsigned char *const[5])data
{
NSLog(@"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
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, *(CGAffineTransform*)matrix);
CGContextConcatCTM(CGCTX, cgAT);
CGContextFillRect(CGCTX, CGRectMake(0, 0, pixelsWide, pixelsHigh));
CGContextRestoreGState(CGCTX);
}
@ -86,7 +95,7 @@
op: (NSCompositingOperation)op
fraction: (CGFloat)delta
{
NSLog(@"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
NSDebugLLog(@"OpalGState", @"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
#if 1
CGContextSaveGState(CGCTX);
CGContextSetRGBFillColor(CGCTX, 1, 1, 0, 1);
@ -110,7 +119,7 @@
- (void) compositerect: (NSRect)aRect
op: (NSCompositingOperation)op
{
NSLog(@"%p (%@): %s - %@", self, [self class], __PRETTY_FUNCTION__, NSStringFromRect(aRect));
NSDebugLLog(@"OpalGState", @"%p (%@): %s - %@", self, [self class], __PRETTY_FUNCTION__, NSStringFromRect(aRect));
CGContextSaveGState(CGCTX);
[self DPSinitmatrix];
@ -123,13 +132,13 @@
: (NSInteger)size
: (CGFloat)offset
{
NSLog(@"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
NSDebugLLog(@"OpalGState", @"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
// TODO: stub
}
- (void) DPSstroke
{
NSLog(@"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
NSDebugLLog(@"OpalGState", @"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
CGContextStrokePath(CGCTX);
}
@ -164,7 +173,7 @@
: (int)x
: (int)y
{
NSLog(@"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
NSDebugLLog(@"OpalGState", @"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
if(_opalSurface != opalSurface)
{
@ -180,18 +189,16 @@
: (int *)x
: (int *)y
{
NSLog(@"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
NSDebugLLog(@"OpalGState", @"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
return _opalSurface;
}
/**
Sets up a new CG*Context() for drawing content.
TODO: tell _opalSurface to create a new context
**/
- (void) DPSinitgraphics
{
NSLog(@"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
NSDebugLLog(@"OpalGState", @"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
[super DPSinitgraphics];
@ -208,6 +215,10 @@
- (CGContextRef) cgContext
{
if (!_opalSurface)
NSDebugMLLog(@"OpalGState", @"No OpalSurface");
else if (![_opalSurface cgContext])
NSDebugMLLog(@"OpalGState", @"No OpalSurface CGContext");
return [_opalSurface cgContext];
}
@ -220,7 +231,7 @@ static CGFloat theAlpha = 1.; // TODO: removeme
- (void) DPSsetrgbcolor: (CGFloat)r : (CGFloat)g : (CGFloat)b
{
NSLog(@"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
NSDebugLLog(@"OpalGState", @"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
const CGFloat alpha = 1; // TODO: is this correct?
if(!CGCTX)
@ -229,34 +240,34 @@ static CGFloat theAlpha = 1.; // TODO: removeme
}
- (void) DPSrectfill: (CGFloat)x : (CGFloat)y : (CGFloat)w : (CGFloat)h
{
NSLog(@"%p (%@): %s - rect %g %g %g %g", self, [self class], __PRETTY_FUNCTION__, x, y, w, 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
{
NSLog(@"%p (%@): %s - %g %g %g %g", self, [self class], __PRETTY_FUNCTION__, x, y, w, 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
{
NSLog(@"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
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
{
NSLog(@"%p (%@): %s - alpha %g", self, [self class], __PRETTY_FUNCTION__, a);
NSDebugLLog(@"OpalGState", @"%p (%@): %s - alpha %g", self, [self class], __PRETTY_FUNCTION__, a);
CGContextSetAlpha(CGCTX, a);
theAlpha = a;
}
- (void)DPSinitmatrix
{
NSLog(@"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
NSDebugLLog(@"OpalGState", @"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
OPContextSetIdentityCTM(CGCTX);
#if 0
@ -268,7 +279,7 @@ static CGFloat theAlpha = 1.; // TODO: removeme
}
- (void)DPSconcat: (const CGFloat *)m
{
NSLog(@"%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]);
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],
@ -278,14 +289,14 @@ static CGFloat theAlpha = 1.; // TODO: removeme
- (void)DPSscale: (CGFloat)x
: (CGFloat)y
{
NSLog(@"%p (%@): %s - %g %g", self, [self class], __PRETTY_FUNCTION__, x, y);
NSDebugLLog(@"OpalGState", @"%p (%@): %s - %g %g", self, [self class], __PRETTY_FUNCTION__, x, y);
CGContextScaleCTM(CGCTX, x, y);
}
- (void)DPStranslate: (CGFloat)x
: (CGFloat)y
{
NSLog(@"%p (%@): %s - x %g y %g", self, [self class], __PRETTY_FUNCTION__, x, y);
NSDebugLLog(@"OpalGState", @"%p (%@): %s - x %g y %g", self, [self class], __PRETTY_FUNCTION__, x, y);
CGContextTranslateCTM(CGCTX, x, y);
[super DPStranslate:x:y];
@ -293,20 +304,20 @@ static CGFloat theAlpha = 1.; // TODO: removeme
- (void) DPSmoveto: (CGFloat) x
: (CGFloat) y
{
NSLog(@"%p (%@): %s - %g %g", self, [self class], __PRETTY_FUNCTION__, x, y);
NSDebugLLog(@"OpalGState", @"%p (%@): %s - %g %g", self, [self class], __PRETTY_FUNCTION__, x, y);
CGContextMoveToPoint(CGCTX, x, y);
}
- (void) DPSlineto: (CGFloat) x
: (CGFloat) y
{
NSLog(@"%p (%@): %s - %g %g", self, [self class], __PRETTY_FUNCTION__, x, y);
NSDebugLLog(@"OpalGState", @"%p (%@): %s - %g %g", self, [self class], __PRETTY_FUNCTION__, x, y);
CGContextAddLineToPoint(CGCTX, x, y);
}
- (void) setOffset: (NSPoint)theOffset
{
NSLog(@"%p (%@): %s - %g %g", self, [self class], __PRETTY_FUNCTION__, theOffset.x, theOffset.y);
NSDebugLLog(@"OpalGState", @"%p (%@): %s - %g %g", self, [self class], __PRETTY_FUNCTION__, theOffset.x, theOffset.y);
#if 1
if (CGCTX != nil)
@ -335,7 +346,7 @@ static CGFloat theAlpha = 1.; // TODO: removeme
/*
- (void) setColor: (device_color_t *)color state: (color_state_t)cState
{
NSLog(@"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
NSDebugLLog(@"OpalGState", @"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
[super setColor: color
state: cState];
@ -353,6 +364,42 @@ static CGFloat theAlpha = 1.; // TODO: removeme
}
}
*/
- (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) DPSsavegstate
{
NSDebugLLog(@"OpalGState", @"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
[super DPSsavegstate];
CGContextSaveGState(CGCTX);
}
- (void) DPSrestoregstate
{
NSDebugLLog(@"OpalGState", @"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
[super DPSrestoregstate];
CGContextRestoreGState(CGCTX);
}
@end
// MARK: Non-required unimplemented methods
@ -372,15 +419,8 @@ static CGFloat theAlpha = 1.; // TODO: removeme
- (void) DPSsetlinewidth: (CGFloat) width
{
NSLog(@"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
NSDebugLLog(@"OpalGState", @"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
}
/*
- (NSAffineTransform *) GSCurrentCTM
{
NSLog(@"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
return nil;
}
*/
@end

View file

@ -155,26 +155,34 @@ static CGContextRef createCGBitmapContext (int pixelsWide,
- (void) handleExposeRect: (NSRect)rect
{
NSDebugLLog(@"OpalSurface", @"handleExposeRect %@", NSStringFromRect(rect));
CGRect cgRect = CGRectMake(rect.origin.x, rect.origin.y,
rect.size.width, rect.size.height);
CGImageRef backingImage = CGBitmapContextCreateImage(_backingCGContext);
if (!backingImage) // FIXME: writing a nil image fails with Opal
return;
CGContextSaveGState(_x11CGContext);
OPContextResetClip(_x11CGContext);
OPContextSetIdentityCTM(_x11CGContext);
CGContextDrawImage(_x11CGContext, cgRect, backingImage);
// FIXME: Opal tries to access -path from CFURLRef
//CFURLRef fileUrl = CFURLCreateWithFileSystemPath(NULL, @"/tmp/opalback.jpg", kCFURLPOSIXPathStyle, NO);
CFURLRef fileUrl = (CFURLRef)[[NSURL fileURLWithPath: @"/tmp/opalback.jpg"] retain];
NSLog(@"FileURL %@", fileUrl);
CGImageDestinationRef outfile = CGImageDestinationCreateWithURL(fileUrl, @"public.jpeg"/*kUTTypeJPEG*/, 1, NULL);
CGImageDestinationAddImage(outfile, backingImage, NULL);
CGImageDestinationFinalize(outfile);
//CFRelease(fileUrl);
//CFRelease(outfile);
CFRelease(fileUrl);
CFRelease(outfile);
CGImageRelease(backingImage);
CGContextRestoreGState(_x11CGContext);
}
- (BOOL) isDrawingToScreen
@ -186,7 +194,7 @@ static CGContextRef createCGBitmapContext (int pixelsWide,
- (void) dummyDraw
{
NSLog(@"performing dummy draw");
NSDebugLLog(@"OpalSurface", @"performing dummy draw");
CGContextSaveGState([self cgContext]);

2
configure vendored
View file

@ -7158,7 +7158,7 @@ elif test x"$BUILD_GRAPHICS" = "xxlib"; then
elif test x"$BUILD_GRAPHICS" = "xwinlib"; then
: # Nothing to do
elif test x"$BUILD_GRAPHICS" = "xopal"; then
LIBS="-lopal $LIBS"
LIBS="-lopal -lgnustep-corebase $LIBS"
else
as_fn_error $? "Invalid graphics backend $BUILD_GRAPHICS" "$LINENO" 5
fi

View file

@ -642,7 +642,7 @@ elif test x"$BUILD_GRAPHICS" = "xxlib"; then
elif test x"$BUILD_GRAPHICS" = "xwinlib"; then
: # Nothing to do
elif test x"$BUILD_GRAPHICS" = "xopal"; then
LIBS="-lopal $LIBS"
LIBS="-lopal -lgnustep-corebase $LIBS"
else
AC_MSG_ERROR([Invalid graphics backend $BUILD_GRAPHICS])
fi