mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-01 00:10:47 +00:00
* Headers/AppKit/NSOpenGL.h,
* Source/NSOpenGLPixelFormat.m: NSOpenGLPixelFormat directly * implements initWithCoder so that it may marshall the pixel attributes prior to initWithAttributes:. Change the getValues:... method to take an int argument instead of long. GLint is mapped to int on most systems. * Source/NSOpenGLContext.m: Use the format decoding to decode an * OpenGL context. Patch by Clint Smullen <daemonae>. * Source/GSLayoutManager.m: Small cleanup in glyph code. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@35923 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
91c4c487ae
commit
3065898052
5 changed files with 134 additions and 91 deletions
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
||||||
|
2012-12-26 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
|
* Headers/AppKit/NSOpenGL.h,
|
||||||
|
* Source/NSOpenGLPixelFormat.m: NSOpenGLPixelFormat directly implements
|
||||||
|
initWithCoder so that it may marshall the pixel attributes prior to
|
||||||
|
initWithAttributes:. Change the getValues:... method to take an
|
||||||
|
int argument instead of long. GLint is mapped to int on most systems.
|
||||||
|
* Source/NSOpenGLContext.m: Use the format decoding to decode an OpenGL context.
|
||||||
|
Patch by Clint Smullen <daemonae>.
|
||||||
|
|
||||||
|
* Source/GSLayoutManager.m: Small cleanup in glyph code.
|
||||||
|
|
||||||
2012-12-23 Fred Kiefer <FredKiefer@gmx.de>
|
2012-12-23 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
* Source/NSFont.m (-initWithName:...): Move replacement name into
|
* Source/NSFont.m (-initWithName:...): Move replacement name into
|
||||||
|
|
|
@ -86,10 +86,10 @@ typedef enum {
|
||||||
NSOpenGLGOResetLibrary = 504
|
NSOpenGLGOResetLibrary = 504
|
||||||
} NSOpenGLGlobalOption;
|
} NSOpenGLGlobalOption;
|
||||||
|
|
||||||
@interface NSOpenGLPixelFormat : NSObject
|
@interface NSOpenGLPixelFormat : NSObject <NSCoding>
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
- (void)getValues:(long *)vals
|
- (void)getValues:(int *)vals
|
||||||
forAttribute:(NSOpenGLPixelFormatAttribute)attrib
|
forAttribute:(NSOpenGLPixelFormatAttribute)attrib
|
||||||
forVirtualScreen:(int)screen;
|
forVirtualScreen:(int)screen;
|
||||||
- (id)initWithAttributes:(NSOpenGLPixelFormatAttribute *)attribs;
|
- (id)initWithAttributes:(NSOpenGLPixelFormatAttribute *)attribs;
|
||||||
|
|
|
@ -43,7 +43,7 @@
|
||||||
#import "GNUstepGUI/GSLayoutManager_internal.h"
|
#import "GNUstepGUI/GSLayoutManager_internal.h"
|
||||||
|
|
||||||
/* TODO: is using rand() here ok? */
|
/* TODO: is using rand() here ok? */
|
||||||
static int random_level(void)
|
static inline int random_level(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < SKIP_LIST_DEPTH - 2; i++)
|
for (i = 0; i < SKIP_LIST_DEPTH - 2; i++)
|
||||||
|
@ -82,31 +82,6 @@ static glyph_run_t *run_insert(glyph_run_head_t **context, int level)
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Remove the run r from the context of the skip list and free it.
|
|
||||||
* The context does not point at r, but to the run immediately before r.
|
|
||||||
* context[0]->next == r
|
|
||||||
*/
|
|
||||||
static void run_remove(glyph_run_head_t **context, glyph_run_t *r)
|
|
||||||
{
|
|
||||||
glyph_run_head_t *h;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
// Free the glyphs
|
|
||||||
if (r->glyphs)
|
|
||||||
free(r->glyphs);
|
|
||||||
|
|
||||||
h = &r->head;
|
|
||||||
if (h->next)
|
|
||||||
((glyph_run_t *)h->next)->prev = r->prev;
|
|
||||||
|
|
||||||
for (i = 0; i <= r->level; i++)
|
|
||||||
context[i]->next = context[i]->next->next;
|
|
||||||
|
|
||||||
h -= r->level;
|
|
||||||
free(h);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Free the glphys of a run.
|
* Free the glphys of a run.
|
||||||
*/
|
*/
|
||||||
|
@ -121,6 +96,30 @@ static inline void run_free_glyphs(glyph_run_t *r)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Remove the run r from the context of the skip list and free it.
|
||||||
|
* The context does not point at r, but to the run immediately before r.
|
||||||
|
* context[0]->next == r
|
||||||
|
*/
|
||||||
|
static inline void run_remove(glyph_run_head_t **context, glyph_run_t *r)
|
||||||
|
{
|
||||||
|
glyph_run_head_t *h;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
// Free the glyphs
|
||||||
|
run_free_glyphs(r);
|
||||||
|
|
||||||
|
h = &r->head;
|
||||||
|
if (h->next)
|
||||||
|
((glyph_run_t *)h->next)->prev = r->prev;
|
||||||
|
|
||||||
|
for (i = 0; i <= r->level; i++)
|
||||||
|
context[i]->next = context[i]->next->next;
|
||||||
|
|
||||||
|
h -= r->level;
|
||||||
|
free(h);
|
||||||
|
}
|
||||||
|
|
||||||
/* Recalculates char_length, glyph_length, and complete for a
|
/* Recalculates char_length, glyph_length, and complete for a
|
||||||
glyph_run_head_t. All "children" of this head must have valid values. */
|
glyph_run_head_t. All "children" of this head must have valid values. */
|
||||||
static void run_fix_head(glyph_run_head_t *h)
|
static void run_fix_head(glyph_run_head_t *h)
|
||||||
|
@ -175,6 +174,7 @@ Private method used internally by GSLayoutManager for sanity checking.
|
||||||
{
|
{
|
||||||
/* set up attributes for this run */
|
/* set up attributes for this run */
|
||||||
NSNumber *n;
|
NSNumber *n;
|
||||||
|
NSFont *font;
|
||||||
|
|
||||||
r->explicit_kern = !![attributes objectForKey: NSKernAttributeName];
|
r->explicit_kern = !![attributes objectForKey: NSKernAttributeName];
|
||||||
|
|
||||||
|
@ -184,7 +184,7 @@ Private method used internally by GSLayoutManager for sanity checking.
|
||||||
else
|
else
|
||||||
r->ligature = 1;
|
r->ligature = 1;
|
||||||
|
|
||||||
r->font = [typesetter fontForCharactersWithAttributes: attributes];
|
font = [typesetter fontForCharactersWithAttributes: attributes];
|
||||||
/* TODO: it might be useful to change this slightly:
|
/* TODO: it might be useful to change this slightly:
|
||||||
Returning a nil font from -fontForCharactersWithAttributes: causes those
|
Returning a nil font from -fontForCharactersWithAttributes: causes those
|
||||||
characters to not be displayed (ie. no glyphs are generated).
|
characters to not be displayed (ie. no glyphs are generated).
|
||||||
|
@ -192,10 +192,10 @@ Private method used internally by GSLayoutManager for sanity checking.
|
||||||
How would glyph<->char mapping be handled? Map the entire run to one
|
How would glyph<->char mapping be handled? Map the entire run to one
|
||||||
NSNullGlyph?
|
NSNullGlyph?
|
||||||
*/
|
*/
|
||||||
if (!r->font)
|
if (font == nil)
|
||||||
r->font = [NSFont userFontOfSize: 0];
|
font = [NSFont userFontOfSize: 0];
|
||||||
r->font = [self substituteFontForFont: r->font];
|
font = [self substituteFontForFont: font];
|
||||||
r->font = [r->font retain];
|
ASSIGN(r->font, font);
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void) _run_free_attributes: (glyph_run_t *)r
|
-(void) _run_free_attributes: (glyph_run_t *)r
|
||||||
|
@ -418,8 +418,6 @@ Private method used internally by GSLayoutManager for sanity checking.
|
||||||
* glyph_pos and char_pos, when supplied, will contain the starting
|
* glyph_pos and char_pos, when supplied, will contain the starting
|
||||||
* glyph/character index for this run.
|
* glyph/character index for this run.
|
||||||
*/
|
*/
|
||||||
#define run_for_character_index(a,b,c,d) [self run_for_character_index: a : c : d]
|
|
||||||
|
|
||||||
- (glyph_run_t *)run_for_character_index: (unsigned int)charIndex
|
- (glyph_run_t *)run_for_character_index: (unsigned int)charIndex
|
||||||
: (unsigned int *)glyph_pos
|
: (unsigned int *)glyph_pos
|
||||||
: (unsigned int *)char_pos
|
: (unsigned int *)char_pos
|
||||||
|
@ -771,7 +769,7 @@ Fills in all glyph holes up to last. only looking at levels below level
|
||||||
unsigned int pos, cpos;
|
unsigned int pos, cpos;
|
||||||
int lo, hi, mid, i;
|
int lo, hi, mid, i;
|
||||||
|
|
||||||
r = run_for_character_index(target, glyphs, &pos, &cpos);
|
r = [self run_for_character_index: target : &pos : &cpos];
|
||||||
if (!r)
|
if (!r)
|
||||||
{
|
{
|
||||||
[NSException raise: NSRangeException
|
[NSException raise: NSRangeException
|
||||||
|
@ -1718,32 +1716,40 @@ places where we switch.
|
||||||
- (void) deleteGlyphsInRange: (NSRange)aRange
|
- (void) deleteGlyphsInRange: (NSRange)aRange
|
||||||
{
|
{
|
||||||
/* See invalidateGlyphsForCharacterRange:changeInLength:actualCharacterRange:
|
/* See invalidateGlyphsForCharacterRange:changeInLength:actualCharacterRange:
|
||||||
glyph_run_t *r;
|
glyph_run_t *run;
|
||||||
unsigned int pos, cpos;
|
unsigned int pos, cpos;
|
||||||
unsigned int glyphIndex;
|
unsigned int glyphIndex;
|
||||||
|
unsigned int lastGlyphIndex;
|
||||||
glyph_run_head_t *context[SKIP_LIST_DEPTH];
|
glyph_run_head_t *context[SKIP_LIST_DEPTH];
|
||||||
|
|
||||||
glyphIndex = NSMinRange(aRange);
|
glyphIndex = NSMinRange(aRange);
|
||||||
while (glyphIndex < NSMaxRange(aRange))
|
lastGlyphIndex = NSMaxRange(aRange) - 1;
|
||||||
|
while (glyphIndex <= lastGlyphIndex)
|
||||||
{
|
{
|
||||||
if (glyphs->glyph_length <= glyphIndex)
|
run = run_for_glyph_index(glyphIndex, glyphs, &pos, &cpos);
|
||||||
|
if (!run)
|
||||||
{
|
{
|
||||||
[NSException raise: NSRangeException
|
[NSException raise: NSRangeException
|
||||||
format: @"%s glyph index out of range", __PRETTY_FUNCTION__];
|
format: @"%s glyph index out of range", __PRETTY_FUNCTION__];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
r = run_for_glyph_index(glyphIndex, glyphs, &pos, &cpos);
|
// FIXME: remove all invalid glyphs from run
|
||||||
if (!r)
|
if ((pos == 0) && (lastGlyphIndex >= glyphIndex - pos + run->head.glyph_length))
|
||||||
{
|
{
|
||||||
[NSException raise: NSRangeException
|
run_free_glyphs(run);
|
||||||
format: @"%s glyph index out of range", __PRETTY_FUNCTION__];
|
}
|
||||||
return;
|
else
|
||||||
|
{
|
||||||
|
if (lastGlyphIndex >= glyphIndex - pos + run->head.glyph_length)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
r->head.glyph_length = len;
|
||||||
}
|
}
|
||||||
|
|
||||||
glyphIndex += r->head.glyph_length;
|
|
||||||
run_free_glyphs(r);
|
|
||||||
// FIXME: Need to invalidate the entries above this one.
|
// FIXME: Need to invalidate the entries above this one.
|
||||||
|
|
||||||
|
// FIXME Cache this value
|
||||||
|
glyphIndex += r->head.glyph_length - pos;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
NSLog(@"Internal method %s called", __PRETTY_FUNCTION__);
|
NSLog(@"Internal method %s called", __PRETTY_FUNCTION__);
|
||||||
|
@ -3184,7 +3190,7 @@ forStartingGlyphAtIndex: (NSUInteger)glyph
|
||||||
|
|
||||||
//NSLog(@"Insert %d glyphs at %d for index %d", length, glyph, index);
|
//NSLog(@"Insert %d glyphs at %d for index %d", length, glyph, index);
|
||||||
|
|
||||||
run = run_for_character_index(index, glyphs, &gpos, &cpos);
|
run = [self run_for_character_index: index : &gpos : &cpos];
|
||||||
if (!run)
|
if (!run)
|
||||||
{
|
{
|
||||||
[NSException raise: NSRangeException
|
[NSException raise: NSRangeException
|
||||||
|
@ -3193,6 +3199,15 @@ forStartingGlyphAtIndex: (NSUInteger)glyph
|
||||||
}
|
}
|
||||||
|
|
||||||
len = glyph - gpos + length;
|
len = glyph - gpos + length;
|
||||||
|
if (len < 0)
|
||||||
|
{
|
||||||
|
NSLog(@"Insert %d glyphs at %d for index %d", length, glyph, index);
|
||||||
|
NSLog(@"Found gpos %d cpos %d len %d", gpos, cpos, len);
|
||||||
|
[NSException raise: NSRangeException
|
||||||
|
format: @"%s glyph index out of range", __PRETTY_FUNCTION__];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!run->glyphs)
|
if (!run->glyphs)
|
||||||
{
|
{
|
||||||
run->glyphs = malloc(sizeof(glyph_t) * len);
|
run->glyphs = malloc(sizeof(glyph_t) * len);
|
||||||
|
@ -3227,7 +3242,7 @@ forStartingGlyphAtIndex: (NSUInteger)glyph
|
||||||
unsigned int gpos, cpos;
|
unsigned int gpos, cpos;
|
||||||
NSSize advances[length];
|
NSSize advances[length];
|
||||||
|
|
||||||
run = run_for_character_index(index, glyphs, &gpos, &cpos);
|
run = [self run_for_character_index: index : &gpos : &cpos];
|
||||||
if (!run)
|
if (!run)
|
||||||
{
|
{
|
||||||
[NSException raise: NSRangeException
|
[NSException raise: NSRangeException
|
||||||
|
|
|
@ -27,29 +27,14 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import <Foundation/NSString.h>
|
#import <Foundation/NSString.h>
|
||||||
|
#import <Foundation/NSData.h>
|
||||||
#import <Foundation/NSDebug.h>
|
#import <Foundation/NSDebug.h>
|
||||||
#import "AppKit/NSOpenGL.h"
|
#import "AppKit/NSOpenGL.h"
|
||||||
#import "GNUstepGUI/GSDisplayServer.h"
|
#import "GNUstepGUI/GSDisplayServer.h"
|
||||||
|
|
||||||
|
|
||||||
// @interface GSGLPixelFormat : NSOpenGLPixelFormat
|
|
||||||
// {}
|
|
||||||
// + _classContext;
|
|
||||||
// @end
|
|
||||||
|
|
||||||
// @implementation GSGLPixelFormat
|
|
||||||
// - (id)initWithAttributes:(NSOpenGLPixelFormatAttribute *)attribs
|
|
||||||
// {
|
|
||||||
// self = [[GSGLPixelFormat _classContext] alloc];
|
|
||||||
|
|
||||||
// return [self initWithAttributes: attribs];
|
|
||||||
// }
|
|
||||||
// @end
|
|
||||||
|
|
||||||
//static GSGLPixelFormat *temp;
|
|
||||||
|
|
||||||
@implementation NSOpenGLPixelFormat
|
@implementation NSOpenGLPixelFormat
|
||||||
+ _classPixelFormat
|
|
||||||
|
+ (Class) _classPixelFormat
|
||||||
{
|
{
|
||||||
Class glPixelFormatClass = [GSCurrentServer() glPixelFormatClass];
|
Class glPixelFormatClass = [GSCurrentServer() glPixelFormatClass];
|
||||||
|
|
||||||
|
@ -65,16 +50,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// + (void) initialize
|
+ (id) allocWithZone: (NSZone*) z
|
||||||
// {
|
|
||||||
// if (self == [NSOpenGLPixelFormat class])
|
|
||||||
// {
|
|
||||||
// temp = (GSGLPixelFormat *) NSAllocateObject([GSGLPixelFormat class], 0,
|
|
||||||
// NSDefaultMallocZone());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
+ allocWithZone: (NSZone *) z
|
|
||||||
{
|
{
|
||||||
Class c = [self _classPixelFormat];
|
Class c = [self _classPixelFormat];
|
||||||
if (c)
|
if (c)
|
||||||
|
@ -83,7 +59,7 @@
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)getValues:(long *)vals
|
- (void) getValues: (int*)vals
|
||||||
forAttribute: (NSOpenGLPixelFormatAttribute)attrib
|
forAttribute: (NSOpenGLPixelFormatAttribute)attrib
|
||||||
forVirtualScreen: (int)screen
|
forVirtualScreen: (int)screen
|
||||||
{
|
{
|
||||||
|
@ -102,6 +78,37 @@
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (id) initWithCoder: (NSCoder*)aDecoder
|
||||||
|
{
|
||||||
|
if ([aDecoder allowsKeyedCoding])
|
||||||
|
{
|
||||||
|
NSMutableData *attrs = [aDecoder decodeObjectForKey: @"NSPixelAttributes"];
|
||||||
|
|
||||||
|
if (attrs != nil)
|
||||||
|
{
|
||||||
|
NSOpenGLPixelFormatAttribute *glattrs;
|
||||||
|
unsigned char tmp = 0;
|
||||||
|
|
||||||
|
// Ensure that it is zero-terminated
|
||||||
|
[attrs appendBytes: &tmp length: sizeof(tmp)];
|
||||||
|
// FIXME: Deserialize an integer array
|
||||||
|
glattrs = (NSOpenGLPixelFormatAttribute *)[attrs mutableBytes];
|
||||||
|
|
||||||
|
return [self initWithAttributes: glattrs];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) encodeWithCoder: (NSCoder*)aCoder
|
||||||
|
{
|
||||||
|
[self subclassResponsibility: _cmd];
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -252,11 +252,20 @@ static NSOpenGLPixelFormatAttribute attrs[] =
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) initWithCoder: (NSCoder *)aCoder
|
- (id) initWithCoder: (NSCoder *)aDecoder
|
||||||
{
|
{
|
||||||
self = [super initWithCoder: aCoder];
|
self = [super initWithCoder: aDecoder];
|
||||||
|
if (!self)
|
||||||
|
return nil;
|
||||||
|
|
||||||
// FIXME: Should set a pixel format like -init does
|
if ([aDecoder allowsKeyedCoding])
|
||||||
|
{
|
||||||
|
[self setPixelFormat: [aDecoder decodeObjectForKey: @"NSPixelFormat"]];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[self setPixelFormat: [[self class] defaultPixelFormat]];
|
||||||
|
}
|
||||||
|
|
||||||
[[NSNotificationCenter defaultCenter]
|
[[NSNotificationCenter defaultCenter]
|
||||||
addObserver: self
|
addObserver: self
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue