mirror of
https://github.com/gnustep/libs-back.git
synced 2025-04-22 15:31:14 +00:00
* Source/opal/OpalContext.m (-initWithGraphicsPort:flipped:): Implement.
* Source/opal/OpalContext.m (-GSSetDevice:::): Get height form surface if no y value is given. * Source/opal/OpalSurface.m: Rewrite to handle the case where device is not set.
This commit is contained in:
parent
7ee9b40793
commit
442eb2515e
3 changed files with 61 additions and 20 deletions
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,11 @@
|
|||
2018-09-16 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/opal/OpalContext.m (-initWithGraphicsPort:flipped:): Implement.
|
||||
* Source/opal/OpalContext.m (-GSSetDevice:::): Get height form
|
||||
surface if no y value is given.
|
||||
* Source/opal/OpalSurface.m: Rewrite to handle the case where
|
||||
device is not set.
|
||||
|
||||
2018-07-16 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/x11/XGServerWindow.m (_setupRootWindow): Make sure the
|
||||
|
@ -112,7 +120,7 @@
|
|||
2017-07-17 Daniel Ferreira <dtf@stanford.edu>
|
||||
|
||||
* Source/opal/GNUmakefile: add OpalBridge.m to project.
|
||||
* Source/opal/OpalBridge.m:
|
||||
* Source/opal/OpalBridge.m:
|
||||
Implement a bridge between NSColor and CGColorRef and a stub for a
|
||||
bridge between NSImage and CGImageRef. This improves compatibility with
|
||||
Quartz.
|
||||
|
@ -121,7 +129,7 @@
|
|||
|
||||
* Headers/opal/OpalSurface.h
|
||||
* Source/opal/OpalContext.m
|
||||
* Source/opal/OpalSurface.m:
|
||||
* Source/opal/OpalSurface.m:
|
||||
In Quartz, the "graphics port" bound to an NSGraphicsContext (subclassed
|
||||
by OpalContext) is a CGContext. We currently initialize one in
|
||||
OpalSurface if it does not exist, however we do not allow the client to
|
||||
|
|
|
@ -115,9 +115,21 @@
|
|||
#endif // XSHM
|
||||
#endif // BUILD_SERVER = SERVER_x11
|
||||
|
||||
@end
|
||||
- (id) initWithGraphicsPort: (void *)port
|
||||
flipped: (BOOL)flag;
|
||||
{
|
||||
self = [super initWithGraphicsPort: port
|
||||
flipped: flag];
|
||||
if (self != nil)
|
||||
{
|
||||
[self GSSetDevice: NULL : -1 : -1];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@implementation OpalContext (Ops)
|
||||
@end
|
||||
|
||||
@implementation OpalContext (Ops)
|
||||
|
||||
- (BOOL) isCompatibleBitmap: (NSBitmapImageRep*)bitmap
|
||||
{
|
||||
|
@ -167,7 +179,7 @@
|
|||
: (int)y
|
||||
{
|
||||
OpalSurface *surface;
|
||||
|
||||
|
||||
/*
|
||||
* The "graphics port" associated to an OpalContext is necessarily a
|
||||
* CGContextRef supplied by the client to back the OpalContext, instead
|
||||
|
@ -181,6 +193,12 @@
|
|||
CGContextRef suppliedContext = self->_graphicsPort;
|
||||
surface = [[OpalSurface alloc] initWithDevice: device
|
||||
context: suppliedContext];
|
||||
if (x == -1 && y == -1)
|
||||
{
|
||||
NSSize size = [surface size];
|
||||
x = 0;
|
||||
y = size.height;
|
||||
}
|
||||
|
||||
[OGSTATE GSSetSurface: surface
|
||||
: x
|
||||
|
|
|
@ -72,6 +72,8 @@ static CGContextRef createCGBitmapContext(int pixelsWide,
|
|||
|
||||
- (void) createCGContextsWithSuppliedBackingContext: (CGContextRef)ctx
|
||||
{
|
||||
int pixelsWide;
|
||||
int pixelsHigh;
|
||||
// FIXME: this method and class presumes we are being passed
|
||||
// a window device.
|
||||
|
||||
|
@ -80,10 +82,26 @@ static CGContextRef createCGBitmapContext(int pixelsWide,
|
|||
NSLog(@"FIXME: Replacement of OpalSurface %p's CGContexts (x11=%p,backing=%p) without transfer of gstate", self, _x11CGContext, _backingCGContext);
|
||||
}
|
||||
|
||||
Display * display = _gsWindowDevice->display;
|
||||
Window window = _gsWindowDevice->ident;
|
||||
if (ctx)
|
||||
{
|
||||
_x11CGContext = ctx;
|
||||
pixelsWide = CGBitmapContextGetWidth(ctx);
|
||||
pixelsHigh = CGBitmapContextGetHeight(ctx);
|
||||
}
|
||||
else
|
||||
{
|
||||
Display * display = _gsWindowDevice->display;
|
||||
Window window = _gsWindowDevice->ident;
|
||||
|
||||
_x11CGContext = ctx ?: OPX11ContextCreate(display, window);
|
||||
_x11CGContext = OPX11ContextCreate(display, window);
|
||||
pixelsWide = _gsWindowDevice->buffer_width;
|
||||
pixelsHigh = _gsWindowDevice->buffer_height;
|
||||
|
||||
// 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
|
||||
if (_gsWindowDevice->type == NSBackingStoreNonretained)
|
||||
|
@ -98,19 +116,11 @@ static CGContextRef createCGBitmapContext(int pixelsWide,
|
|||
{
|
||||
// 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;
|
||||
|
||||
_backingCGContext = createCGBitmapContext(
|
||||
_gsWindowDevice->buffer_width,
|
||||
_gsWindowDevice->buffer_height);
|
||||
_backingCGContext = createCGBitmapContext(pixelsWide, pixelsHigh);
|
||||
}
|
||||
|
||||
NSDebugLLog(@"OpalSurface", @"Created CGContexts: X11=%p, backing=%p, width=%d height=%d",
|
||||
_x11CGContext, _backingCGContext, _gsWindowDevice->buffer_width, _gsWindowDevice->buffer_height);
|
||||
_x11CGContext, _backingCGContext, pixelsWide, pixelsHigh);
|
||||
|
||||
}
|
||||
|
||||
|
@ -155,6 +165,11 @@ static CGContextRef createCGBitmapContext(int pixelsWide,
|
|||
{
|
||||
NSDebugLLog(@"OpalSurface", @"handleExposeRect %@", NSStringFromRect(rect));
|
||||
|
||||
if (!_backingCGContext)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CGImageRef backingImage = CGBitmapContextCreateImage(_backingCGContext);
|
||||
if (!backingImage) // FIXME: writing a nil image fails with Opal
|
||||
return;
|
||||
|
@ -222,8 +237,8 @@ static CGContextRef createCGBitmapContext(int pixelsWide,
|
|||
|
||||
- (NSSize) size
|
||||
{
|
||||
return NSMakeSize(_gsWindowDevice->buffer_width,
|
||||
_gsWindowDevice->buffer_height);
|
||||
return NSMakeSize(CGBitmapContextGetWidth(_backingCGContext),
|
||||
CGBitmapContextGetHeight(_backingCGContext));
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in a new issue