mirror of
https://github.com/gnustep/libs-back.git
synced 2025-04-22 07:21:02 +00:00
Try to handle endianess differences better in the art backend.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/trunk@26813 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
90a62908d3
commit
b685c50b0e
4 changed files with 88 additions and 45 deletions
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
|||
2008-08-19 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/art/ARTContext.m (-GSSetDevice:::): Only call
|
||||
setupDrawInfo once.
|
||||
* Source/art/ARTContext.m (-setupDrawInfo): Try to handle
|
||||
endianess differance better.
|
||||
* Source/art/ARTContext.m (-initializeBackend): Call
|
||||
artcontext_setup_gamma().
|
||||
* Source/art/blit.h,
|
||||
* Source/art/blit-main.m: New function artcontext_setup_gamma()
|
||||
split off from artcontext_setup_draw_info().
|
||||
|
||||
2008-08-14 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/x11/XGServerWindow.m (-_ewmh_isMinimized:): Correct
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
|
||||
#include <Foundation/NSDebug.h>
|
||||
#include <Foundation/NSDictionary.h>
|
||||
#include <Foundation/NSUserDefaults.h>
|
||||
|
||||
#include "ARTGState.h"
|
||||
#include "blit.h"
|
||||
|
@ -35,12 +36,18 @@
|
|||
#endif
|
||||
|
||||
// Could use NSSwapInt() instead
|
||||
static unsigned int flip_bytes(unsigned int i)
|
||||
static unsigned int flip_bytes32(unsigned int i)
|
||||
{
|
||||
return ((i >> 24) & 0xff)
|
||||
|((i >> 8) & 0xff00)
|
||||
|((i << 8) & 0xff0000)
|
||||
|((i << 24) & 0xff000000);
|
||||
|((i >> 8) & 0xff00)
|
||||
|((i << 8) & 0xff0000)
|
||||
|((i << 24) & 0xff000000);
|
||||
}
|
||||
|
||||
static unsigned int flip_bytes16(unsigned int i)
|
||||
{
|
||||
return ((i >> 8) & 0xff)
|
||||
|((i << 8) & 0xff00);
|
||||
}
|
||||
|
||||
static int byte_order(void)
|
||||
|
@ -58,10 +65,16 @@ static int byte_order(void)
|
|||
|
||||
+ (void)initializeBackend
|
||||
{
|
||||
float gamma;
|
||||
|
||||
NSDebugLLog(@"back-art",@"Initializing libart/freetype backend");
|
||||
|
||||
[NSGraphicsContext setDefaultContextClass: [ARTContext class]];
|
||||
[FTFontInfo initializeBackend];
|
||||
|
||||
gamma = [[NSUserDefaults standardUserDefaults]
|
||||
floatForKey: @"back-art-text-gamma"];
|
||||
artcontext_setup_gamma(gamma);
|
||||
}
|
||||
|
||||
+ (Class) GStateClass
|
||||
|
@ -126,9 +139,18 @@ static int byte_order(void)
|
|||
int them = ImageByteOrder(d); /* True iff the server is big-endian. */
|
||||
if (us != them)
|
||||
{
|
||||
visual->red_mask = flip_bytes(visual->red_mask);
|
||||
visual->green_mask = flip_bytes(visual->green_mask);
|
||||
visual->blue_mask = flip_bytes(visual->blue_mask);
|
||||
if ((bpp == 32) || (bpp == 24))
|
||||
{
|
||||
visual->red_mask = flip_bytes32(visual->red_mask);
|
||||
visual->green_mask = flip_bytes32(visual->green_mask);
|
||||
visual->blue_mask = flip_bytes32(visual->blue_mask);
|
||||
}
|
||||
else if (bpp == 16)
|
||||
{
|
||||
visual->red_mask = flip_bytes16(visual->red_mask);
|
||||
visual->green_mask = flip_bytes16(visual->green_mask);
|
||||
visual->blue_mask = flip_bytes16(visual->blue_mask);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -168,9 +190,18 @@ static int byte_order(void)
|
|||
@end
|
||||
|
||||
@implementation ARTContext (ops)
|
||||
|
||||
- (void) GSSetDevice: (void*)device : (int)x : (int)y
|
||||
{
|
||||
[self setupDrawInfo];
|
||||
// Currently all windows share the same drawing info.
|
||||
// It is enough to initialize it once.
|
||||
static BOOL serverInitialized = NO;
|
||||
|
||||
if (!serverInitialized)
|
||||
{
|
||||
[self setupDrawInfo];
|
||||
serverInitialized = YES;
|
||||
}
|
||||
[(ARTGState *)gstate GSSetDevice: device : x : y];
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <string.h>
|
||||
|
||||
#include <Foundation/NSDebug.h>
|
||||
#include <Foundation/NSString.h>
|
||||
|
||||
#include "blit.h"
|
||||
|
||||
|
@ -389,9 +390,6 @@ static int byte_ofs_of_mask(unsigned int m)
|
|||
return -1;
|
||||
}
|
||||
|
||||
|
||||
#include <Foundation/NSUserDefaults.h>
|
||||
|
||||
void artcontext_setup_draw_info(draw_info_t *di,
|
||||
unsigned int red_mask, unsigned int green_mask, unsigned int blue_mask,
|
||||
int bpp)
|
||||
|
@ -420,23 +418,23 @@ void artcontext_setup_draw_info(draw_info_t *di,
|
|||
b = byte_ofs_of_mask(blue_mask);
|
||||
|
||||
if (bpp == 24)
|
||||
{
|
||||
if (r == 0 && g == 1 && b == 2)
|
||||
t = DI_24_RGB;
|
||||
else if (r == 2 && g == 1 && b == 0)
|
||||
t = DI_24_BGR;
|
||||
}
|
||||
{
|
||||
if (r == 0 && g == 1 && b == 2)
|
||||
t = DI_24_RGB;
|
||||
else if (r == 2 && g == 1 && b == 0)
|
||||
t = DI_24_BGR;
|
||||
}
|
||||
else if (bpp == 32)
|
||||
{
|
||||
if (r == 0 && g == 1 && b == 2)
|
||||
t = DI_32_RGBA;
|
||||
else if (r == 2 && g == 1 && b == 0)
|
||||
t = DI_32_BGRA;
|
||||
else if (r == 1 && g == 2 && b == 3)
|
||||
t = DI_32_ARGB;
|
||||
else if (r == 3 && g == 2 && b == 1)
|
||||
t = DI_32_ABGR;
|
||||
}
|
||||
{
|
||||
if (r == 0 && g == 1 && b == 2)
|
||||
t = DI_32_RGBA;
|
||||
else if (r == 2 && g == 1 && b == 0)
|
||||
t = DI_32_BGRA;
|
||||
else if (r == 1 && g == 2 && b == 3)
|
||||
t = DI_32_ARGB;
|
||||
else if (r == 3 && g == 2 && b == 1)
|
||||
t = DI_32_ABGR;
|
||||
}
|
||||
}
|
||||
|
||||
NSDebugLLog(@"back-art", @"got t=%i", t);
|
||||
|
@ -453,26 +451,27 @@ void artcontext_setup_draw_info(draw_info_t *di,
|
|||
@"Better: implement it and send a patch.)");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
{
|
||||
float gamma = [[NSUserDefaults standardUserDefaults]
|
||||
floatForKey: @"back-art-text-gamma"];
|
||||
int i;
|
||||
if (!gamma)
|
||||
gamma = 1.4;
|
||||
|
||||
NSDebugLLog(@"back-art",@"gamma=%g",gamma);
|
||||
|
||||
gamma = 1.0 / gamma;
|
||||
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
gamma_table[i] = pow(i / 255.0, gamma) * 255 + .5;
|
||||
inv_gamma_table[i] = pow(i / 255.0, 1.0 / gamma) * 255 + .5;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void artcontext_setup_gamma(float gamma)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!gamma)
|
||||
gamma = 1.4;
|
||||
|
||||
NSDebugLLog(@"back-art",@"gamma=%g",gamma);
|
||||
|
||||
gamma = 1.0 / gamma;
|
||||
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
gamma_table[i] = pow(i / 255.0, gamma) * 255 + .5;
|
||||
inv_gamma_table[i] = pow(i / 255.0, 1.0 / gamma) * 255 + .5;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
||||
|
|
|
@ -160,6 +160,7 @@ typedef struct draw_info_s
|
|||
void artcontext_setup_draw_info(draw_info_t *di,
|
||||
unsigned int red_mask, unsigned int green_mask, unsigned int blue_mask,
|
||||
int bpp);
|
||||
void artcontext_setup_gamma(float gamma);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in a new issue