mirror of
https://github.com/gnustep/libs-back.git
synced 2025-06-02 18:21:01 +00:00
Extract the bitmap conversion into a local function and use it througout the file.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/trunk@32643 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
7775bb0f77
commit
e6d1827e27
2 changed files with 63 additions and 68 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2011-03-18 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
|
* Source/x11/XGServerWindow.m: Extract the bitmap conversion into
|
||||||
|
a local function and use it througout the file.
|
||||||
|
|
||||||
2011-03-13 Eric Wasylishen <ewasylishen@gmail.com>
|
2011-03-13 Eric Wasylishen <ewasylishen@gmail.com>
|
||||||
|
|
||||||
* configure.ac: Check for the X extention libraries (Xext, Xt, Xmu)
|
* configure.ac: Check for the X extention libraries (Xext, Xt, Xmu)
|
||||||
|
|
|
@ -105,6 +105,50 @@ static int last_win_num = 0;
|
||||||
bitsPerPixel: (int)pixelBits;
|
bitsPerPixel: (int)pixelBits;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
static NSBitmapImageRep *getStandardBitmap(NSImage *image)
|
||||||
|
{
|
||||||
|
NSBitmapImageRep *rep;
|
||||||
|
|
||||||
|
if (image == nil)
|
||||||
|
{
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
We should rather convert the image to a bitmap representation here via
|
||||||
|
the following code, but this is currently not supported by the libart backend
|
||||||
|
|
||||||
|
{
|
||||||
|
NSSize size = [image size];
|
||||||
|
|
||||||
|
[image lockFocus];
|
||||||
|
rep = [[NSBitmapImageRep alloc] initWithFocusedViewRect:
|
||||||
|
NSMakeRect(0, 0, size.width, size.height)];
|
||||||
|
AUTORELEASE(rep);
|
||||||
|
[image unlockFocus];
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
rep = (NSBitmapImageRep *)[image bestRepresentationForDevice: nil];
|
||||||
|
if (!rep || ![rep respondsToSelector: @selector(samplesPerPixel)])
|
||||||
|
{
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Convert into something usable by the backend
|
||||||
|
return [rep _convertToFormatBitsPerSample: 8
|
||||||
|
samplesPerPixel: [rep hasAlpha] ? 4 : 3
|
||||||
|
hasAlpha: [rep hasAlpha]
|
||||||
|
isPlanar: NO
|
||||||
|
colorSpaceName: NSCalibratedRGBColorSpace
|
||||||
|
bitmapFormat: 0
|
||||||
|
bytesPerRow: 0
|
||||||
|
bitsPerPixel: 0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void __objc_xgcontextwindow_linking (void)
|
void __objc_xgcontextwindow_linking (void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -367,6 +411,7 @@ static void setWindowHintsForStyle (Display *dpy, Window window,
|
||||||
* End of motif hints for window manager code
|
* End of motif hints for window manager code
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@interface NSEvent (WindowHack)
|
@interface NSEvent (WindowHack)
|
||||||
- (void) _patchLocation: (NSPoint)loc;
|
- (void) _patchLocation: (NSPoint)loc;
|
||||||
@end
|
@end
|
||||||
|
@ -1761,17 +1806,8 @@ _get_next_prop_new_event(Display *display, XEvent *event, char *arg)
|
||||||
long *iconPropertyData;
|
long *iconPropertyData;
|
||||||
int iconSize;
|
int iconSize;
|
||||||
|
|
||||||
rep = (NSBitmapImageRep *)[image bestRepresentationForDevice:nil];
|
rep = getStandardBitmap(image);
|
||||||
if (![rep isKindOfClass: [NSBitmapImageRep class]])
|
if (rep == nil)
|
||||||
{
|
|
||||||
NSLog(@"Wrong bitmap class for WM icon %@ %@", rep, image);
|
|
||||||
return NO;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ([rep bitsPerSample] != 8
|
|
||||||
|| (![[rep colorSpaceName] isEqual: NSDeviceRGBColorSpace]
|
|
||||||
&& ![[rep colorSpaceName] isEqual: NSCalibratedRGBColorSpace])
|
|
||||||
|| [rep isPlanar])
|
|
||||||
{
|
{
|
||||||
NSLog(@"Wrong image type for WM icon");
|
NSLog(@"Wrong image type for WM icon");
|
||||||
return NO;
|
return NO;
|
||||||
|
@ -2697,15 +2733,8 @@ static BOOL didCreatePixmaps;
|
||||||
didCreatePixmaps = YES;
|
didCreatePixmaps = YES;
|
||||||
|
|
||||||
image = [NSApp applicationIconImage];
|
image = [NSApp applicationIconImage];
|
||||||
rep = (NSBitmapImageRep *)[image bestRepresentationForDevice:nil];
|
rep = getStandardBitmap(image);
|
||||||
|
if (rep == nil)
|
||||||
if (![rep isKindOfClass: [NSBitmapImageRep class]])
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if ([rep bitsPerSample] != 8
|
|
||||||
|| (![[rep colorSpaceName] isEqual: NSDeviceRGBColorSpace]
|
|
||||||
&& ![[rep colorSpaceName] isEqual: NSCalibratedRGBColorSpace])
|
|
||||||
|| [rep isPlanar])
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
data = [rep bitmapData];
|
data = [rep bitmapData];
|
||||||
|
@ -3003,17 +3032,16 @@ static BOOL didCreatePixmaps;
|
||||||
if ([[image backgroundColor] alphaComponent] * 256 <= ALPHA_THRESHOLD)
|
if ([[image backgroundColor] alphaComponent] * 256 <= ALPHA_THRESHOLD)
|
||||||
{
|
{
|
||||||
// The mask computed here is only correct for unscaled images.
|
// The mask computed here is only correct for unscaled images.
|
||||||
NSImageRep *rep = [image bestRepresentationForDevice: nil];
|
NSBitmapImageRep *rep = getStandardBitmap(image);
|
||||||
|
|
||||||
if ([rep isKindOfClass: [NSBitmapImageRep class]])
|
if (rep != nil)
|
||||||
{
|
{
|
||||||
if (![(NSBitmapImageRep*)rep isPlanar] &&
|
if ([rep samplesPerPixel] == 4)
|
||||||
([(NSBitmapImageRep*)rep samplesPerPixel] == 4))
|
|
||||||
{
|
{
|
||||||
pixmap = xgps_cursor_mask(dpy, GET_XDRAWABLE(window),
|
pixmap = xgps_cursor_mask(dpy, GET_XDRAWABLE(window),
|
||||||
[(NSBitmapImageRep*)rep bitmapData],
|
[rep bitmapData],
|
||||||
[rep pixelsWide], [rep pixelsHigh],
|
[rep pixelsWide], [rep pixelsHigh],
|
||||||
[(NSBitmapImageRep*)rep samplesPerPixel]);
|
[rep samplesPerPixel]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4178,53 +4206,15 @@ xgps_cursor_image(Display *xdpy, Drawable draw, const unsigned char *data,
|
||||||
int colors;
|
int colors;
|
||||||
const unsigned char *data;
|
const unsigned char *data;
|
||||||
|
|
||||||
/* FIXME: We might create a blank cursor here? */
|
rep = getStandardBitmap(image);
|
||||||
if (image == nil)
|
if (rep == nil)
|
||||||
{
|
{
|
||||||
|
/* FIXME: We might create a blank cursor here? */
|
||||||
|
NSLog(@"Could not convert cursor bitmap data");
|
||||||
*cid = NULL;
|
*cid = NULL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
We should rather convert the image to a bitmap representation here via
|
|
||||||
the following code, but this is currently not supported by the libart backend
|
|
||||||
|
|
||||||
{
|
|
||||||
NSSize size = [image size];
|
|
||||||
|
|
||||||
[image lockFocus];
|
|
||||||
rep = [[NSBitmapImageRep alloc] initWithFocusedViewRect:
|
|
||||||
NSMakeRect(0, 0, size.width, size.height)];
|
|
||||||
AUTORELEASE(rep);
|
|
||||||
[image unlockFocus];
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
rep = (NSBitmapImageRep *)[image bestRepresentationForDevice: nil];
|
|
||||||
if (!rep || ![rep respondsToSelector: @selector(samplesPerPixel)])
|
|
||||||
{
|
|
||||||
NSLog(@"NSCursor can only handle NSBitmapImageReps for now");
|
|
||||||
*cid = NULL;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Convert into something usable by the backend
|
|
||||||
rep = [rep _convertToFormatBitsPerSample: 8
|
|
||||||
samplesPerPixel: [rep hasAlpha] ? 4 : 3
|
|
||||||
hasAlpha: [rep hasAlpha]
|
|
||||||
isPlanar: NO
|
|
||||||
colorSpaceName: NSCalibratedRGBColorSpace
|
|
||||||
bitmapFormat: 0
|
|
||||||
bytesPerRow: 0
|
|
||||||
bitsPerPixel: 0];
|
|
||||||
if (rep == nil)
|
|
||||||
{
|
|
||||||
NSLog(@"Could not convert bitmap data");
|
|
||||||
*cid = NULL;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hotp.x >= [rep pixelsWide])
|
if (hotp.x >= [rep pixelsWide])
|
||||||
hotp.x = [rep pixelsWide]-1;
|
hotp.x = [rep pixelsWide]-1;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue