mirror of
https://github.com/gnustep/libs-back.git
synced 2025-04-22 23:42:16 +00:00
Drawing a red rectangle with Opal.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/trunk@36873 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
6f2602b8dd
commit
0a75b89dd3
8 changed files with 240 additions and 7 deletions
20
ChangeLog
20
ChangeLog
|
@ -1,3 +1,23 @@
|
|||
2013-07-11 Ivan Vucica <ivan@vucica.net>
|
||||
|
||||
* Source/opal/OpalContext.m:
|
||||
Once the surface is created in context, it's also set as
|
||||
the active surface of the GState.
|
||||
|
||||
* Source/opal/OpalGState.m:
|
||||
Blocked some superclass methods from running. Added debug
|
||||
output. Added call to dummy paint method in OpalSurface.
|
||||
|
||||
* Source/opal/OpalSurface.m:
|
||||
* Headers/opal/OpalSurface.h:
|
||||
* Headers/opal/OpalGState.h:
|
||||
Opal context is now created in the surface. Added a dummy
|
||||
draw method.
|
||||
|
||||
* configure.ac:
|
||||
* configure:
|
||||
Ensured linking with the Opal library.
|
||||
|
||||
2013-07-08 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/x11/XGServerWindow.m (-setIgnoreMouse::): Completely
|
||||
|
|
|
@ -27,10 +27,36 @@
|
|||
|
||||
#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
|
||||
|
|
|
@ -26,11 +26,15 @@
|
|||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <CoreGraphics/CoreGraphics.h>
|
||||
|
||||
@interface OpalSurface : NSObject
|
||||
{
|
||||
struct _gswindow_device_t * _gsWindowDevice;
|
||||
CGContextRef _cgContext;
|
||||
}
|
||||
|
||||
- (id) initWithDevice: (void *)device;
|
||||
- (struct _gswindow_device_t *) device;
|
||||
|
||||
@end
|
||||
|
|
|
@ -56,11 +56,10 @@
|
|||
|
||||
surface = [[OpalSurface alloc] initWithDevice: device];
|
||||
|
||||
/*
|
||||
[OGSTATE GSSetSurface: surface
|
||||
: x
|
||||
: y];
|
||||
*/
|
||||
|
||||
[surface release];
|
||||
}
|
||||
@end
|
||||
|
|
|
@ -25,23 +25,33 @@
|
|||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#import <CoreGraphics/CoreGraphics.h>
|
||||
#import <X11/Xlib.h>
|
||||
#import "opal/OpalGState.h"
|
||||
#import "opal/OpalSurface.h"
|
||||
#import "x11/XGServerWindow.h"
|
||||
|
||||
@implementation OpalGState
|
||||
|
||||
// MARK: Minimum required methods
|
||||
// MARK: -
|
||||
|
||||
- (void) DPSinitclip
|
||||
{
|
||||
|
||||
NSLog(@"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
|
||||
}
|
||||
|
||||
- (void) DPSclip
|
||||
{
|
||||
|
||||
NSLog(@"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
|
||||
}
|
||||
|
||||
- (void) DPSfill
|
||||
{
|
||||
|
||||
NSLog(@"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
|
||||
[_opalSurface dummyDraw];
|
||||
}
|
||||
|
||||
- (void) DPSimage: (NSAffineTransform *)matrix
|
||||
|
@ -57,6 +67,7 @@
|
|||
: (const unsigned char *const[5])data
|
||||
{
|
||||
|
||||
NSLog(@"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
|
||||
}
|
||||
|
||||
- (void) compositeGState: (OpalGState *)source
|
||||
|
@ -66,12 +77,147 @@
|
|||
fraction: (CGFloat)delta
|
||||
{
|
||||
|
||||
NSLog(@"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
|
||||
}
|
||||
|
||||
- (void) compositerect: (NSRect)aRect
|
||||
op: (NSCompositingOperation)op
|
||||
{
|
||||
|
||||
NSLog(@"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
|
||||
}
|
||||
|
||||
@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 in methods such as -DPSinitgraphics. Also, sets the
|
||||
device offset to specified coordinates.
|
||||
**/
|
||||
|
||||
- (void) GSSetSurface: (OpalSurface *)opalSurface
|
||||
: (int)x
|
||||
: (int)y
|
||||
{
|
||||
NSLog(@"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
|
||||
|
||||
// FIXME: improper setter
|
||||
[_opalSurface release];
|
||||
_opalSurface = [opalSurface retain];
|
||||
|
||||
// TODO: apply offset using [self setOffset:]
|
||||
|
||||
[_opalSurface dummyDraw];
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
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__);
|
||||
|
||||
[super DPSinitgraphics];
|
||||
|
||||
[_opalSurface dummyDraw];
|
||||
|
||||
}
|
||||
|
||||
@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
|
||||
{
|
||||
NSLog(@"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
|
||||
}
|
||||
- (void) setColor: (device_color_t *)color state: (color_state_t)cState
|
||||
{
|
||||
NSLog(@"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
|
||||
}
|
||||
- (void)DPSinitmatrix
|
||||
{
|
||||
NSLog(@"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
|
||||
}
|
||||
- (void)DPSconcat: (const CGFloat *)m
|
||||
{
|
||||
NSLog(@"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
|
||||
}
|
||||
- (void) DPSsetalpha: (CGFloat)a
|
||||
{
|
||||
NSLog(@"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
|
||||
}
|
||||
- (void) DPSrectfill: (CGFloat)x : (CGFloat)y : (CGFloat)w : (CGFloat)h
|
||||
{
|
||||
NSLog(@"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
|
||||
[_opalSurface dummyDraw];
|
||||
}
|
||||
- (void) DPSrectclip: (CGFloat)x : (CGFloat)y : (CGFloat)w : (CGFloat)h
|
||||
{
|
||||
NSLog(@"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
|
||||
}
|
||||
- (void) DPSsetrgbcolor: (CGFloat)r : (CGFloat)g : (CGFloat)b
|
||||
{
|
||||
NSLog(@"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
|
||||
}
|
||||
- (void) GSSetCTM: (NSAffineTransform *)newctm
|
||||
{
|
||||
NSLog(@"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
|
||||
}
|
||||
- (void) DPSsetgray: (CGFloat)gray
|
||||
{
|
||||
NSLog(@"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
|
||||
}
|
||||
/*
|
||||
- (NSAffineTransform *) GSCurrentCTM
|
||||
{
|
||||
NSLog(@"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
|
||||
return nil;
|
||||
}
|
||||
*/
|
||||
- (void)DPSscale: (CGFloat)x : (CGFloat)y
|
||||
{
|
||||
NSLog(@"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
|
||||
}
|
||||
- (void)DPStranslate: (CGFloat)x : (CGFloat)y
|
||||
{
|
||||
NSLog(@"%p (%@): %s", self, [self class], __PRETTY_FUNCTION__);
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -26,12 +26,50 @@
|
|||
*/
|
||||
|
||||
#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);
|
||||
|
||||
@implementation OpalSurface
|
||||
|
||||
- (id) initWithDevice: (void *)device
|
||||
{
|
||||
return [super init];
|
||||
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;
|
||||
|
||||
Display * display = _gsWindowDevice->display;
|
||||
Window window = _gsWindowDevice->ident;
|
||||
|
||||
_cgContext = OPX11ContextCreate(display, window);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (gswindow_device_t *) device
|
||||
{
|
||||
return _gsWindowDevice;
|
||||
}
|
||||
|
||||
- (void) dummyDraw
|
||||
{
|
||||
|
||||
NSLog(@"performing dummy draw");
|
||||
|
||||
CGContextSaveGState(_cgContext);
|
||||
|
||||
CGRect r = CGRectMake(0, 0, 1024, 1024);
|
||||
CGContextSetRGBFillColor(_cgContext, 1, 0, 0, 1);
|
||||
CGContextFillRect(_cgContext, r);
|
||||
|
||||
CGContextRestoreGState(_cgContext);
|
||||
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
2
configure
vendored
2
configure
vendored
|
@ -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
|
||||
: # Nothing to do
|
||||
LIBS="-lopal $LIBS"
|
||||
else
|
||||
as_fn_error $? "Invalid graphics backend $BUILD_GRAPHICS" "$LINENO" 5
|
||||
fi
|
||||
|
|
|
@ -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
|
||||
: # Nothing to do
|
||||
LIBS="-lopal $LIBS"
|
||||
else
|
||||
AC_MSG_ERROR([Invalid graphics backend $BUILD_GRAPHICS])
|
||||
fi
|
||||
|
|
Loading…
Reference in a new issue