mirror of
https://github.com/gnustep/libs-back.git
synced 2025-02-23 20:01:22 +00:00
2005-11-19 21:39 Alexander Malmberg <alexander@malmberg.org>
* Source/art/ARTContext.m (flip_bytes, byte_order) (-initWithContextInfo:): Detect if the server doesn't have the same endianness and adjust the color bitmasks if necessary. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/trunk@22044 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
b846b79559
commit
9ec13d3934
2 changed files with 41 additions and 2 deletions
|
@ -1,3 +1,9 @@
|
|||
2005-11-19 21:39 Alexander Malmberg <alexander@malmberg.org>
|
||||
|
||||
* Source/art/ARTContext.m (flip_bytes, byte_order)
|
||||
(-initWithContextInfo:): Detect if the server doesn't have the same
|
||||
endianness and adjust the color bitmasks if necessary.
|
||||
|
||||
2005-11-18 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/x11/XGServerWindow.m (-window::::): Don't use the NET WM
|
||||
|
|
|
@ -725,6 +725,25 @@ very expensive
|
|||
}
|
||||
|
||||
|
||||
static unsigned int flip_bytes(unsigned int i)
|
||||
{
|
||||
return ((i>>24)&0xff)
|
||||
|((i>> 8)&0xff00)
|
||||
|((i<< 8)&0xff0000)
|
||||
|((i<<24)&0xff000000);
|
||||
}
|
||||
|
||||
static int byte_order(void)
|
||||
{
|
||||
union
|
||||
{
|
||||
unsigned int i;
|
||||
char c;
|
||||
} foo;
|
||||
foo.i = 1;
|
||||
return foo.c != 1;
|
||||
}
|
||||
|
||||
|
||||
- (id) initWithContextInfo: (NSDictionary *)info
|
||||
{
|
||||
|
@ -794,6 +813,20 @@ very expensive
|
|||
bpp = i->bits_per_pixel;
|
||||
XDestroyImage(i);
|
||||
|
||||
/* If the server doesn't have the same endianness as we do, we need
|
||||
to flip the masks around (well, at least sometimes; not sure
|
||||
what'll really happen for 15/16bpp modes). */
|
||||
{
|
||||
int us = byte_order(); /* True iff we're big-endian. */
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/* Only returns if the visual was usable. */
|
||||
artcontext_setup_draw_info(&DI, visual->red_mask, visual->green_mask,
|
||||
visual->blue_mask, bpp);
|
||||
|
|
Loading…
Reference in a new issue