mirror of
https://github.com/gnustep/libs-back.git
synced 2025-06-04 03:00:43 +00:00
Added cairo transparancy patch by Yen-Ju Chen <yjchenx@gmail.com>.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/trunk@24244 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
50e93efdab
commit
cf27a422f6
5 changed files with 76 additions and 18 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
||||||
|
2006-12-26 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
|
* Headers/cairo/XGCairoXImageSurface.h:
|
||||||
|
* Source/cairo/XGCairoXImageSurface.m (-initWithDevice:): Use
|
||||||
|
XWindowBuffer to draw on.
|
||||||
|
* Source/cairo/CairoContext.m (+initializeBackend): Use
|
||||||
|
XGCairoXImageSurface as surface.
|
||||||
|
* Source/cairo/CairoGState.m (-DPSimage:...:): Respect endianess,
|
||||||
|
when creating a cairo image surface.
|
||||||
|
Patch by Yen-Ju Chen <yjchenx@gmail.com>.
|
||||||
|
|
||||||
2006-12-19 Fred Kiefer <FredKiefer@gmx.de>
|
2006-12-19 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
* Source/cairo/XGCairoGlitzSurface.m (-initWithDevice:): Correct
|
* Source/cairo/XGCairoGlitzSurface.m (-initWithDevice:): Correct
|
||||||
|
|
|
@ -25,12 +25,13 @@
|
||||||
|
|
||||||
#include "x11/XGServer.h"
|
#include "x11/XGServer.h"
|
||||||
#include "x11/XGServerWindow.h"
|
#include "x11/XGServerWindow.h"
|
||||||
|
#include "x11/XWindowBuffer.h"
|
||||||
#include "cairo/CairoSurface.h"
|
#include "cairo/CairoSurface.h"
|
||||||
|
|
||||||
@interface XGCairoXImageSurface : CairoSurface
|
@interface XGCairoXImageSurface : CairoSurface
|
||||||
{
|
{
|
||||||
XImage *image;
|
@public
|
||||||
|
XWindowBuffer *wi;
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include "cairo/XGCairoGlitzSurface.h"
|
#include "cairo/XGCairoGlitzSurface.h"
|
||||||
#else
|
#else
|
||||||
#include "cairo/XGCairoSurface.h"
|
#include "cairo/XGCairoSurface.h"
|
||||||
|
#include "cairo/XGCairoXImageSurface.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define CGSTATE ((CairoGState *)gstate)
|
#define CGSTATE ((CairoGState *)gstate)
|
||||||
|
@ -45,7 +46,8 @@
|
||||||
#ifdef USE_GLITZ
|
#ifdef USE_GLITZ
|
||||||
[CairoSurface setDefaultSurfaceClass: [XGCairoGlitzSurface class]];
|
[CairoSurface setDefaultSurfaceClass: [XGCairoGlitzSurface class]];
|
||||||
#else
|
#else
|
||||||
[CairoSurface setDefaultSurfaceClass: [XGCairoSurface class]];
|
// [CairoSurface setDefaultSurfaceClass: [XGCairoSurface class]];
|
||||||
|
[CairoSurface setDefaultSurfaceClass: [XGCairoXImageSurface class]];
|
||||||
#endif
|
#endif
|
||||||
[GSFontEnumerator setDefaultClass: [CairoFontEnumerator class]];
|
[GSFontEnumerator setDefaultClass: [CairoFontEnumerator class]];
|
||||||
[GSFontInfo setDefaultClass: [CairoFontInfo class]];
|
[GSFontInfo setDefaultClass: [CairoFontInfo class]];
|
||||||
|
@ -76,6 +78,26 @@
|
||||||
XFlush([(XGServer *)server xDisplay]);
|
XFlush([(XGServer *)server xDisplay]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Private backend methods */
|
||||||
|
+(void) handleExposeRect: (NSRect)rect forDriver: (void *)driver
|
||||||
|
{
|
||||||
|
[(XWindowBuffer *)driver _exposeRect: rect];
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef XSHM
|
||||||
|
|
||||||
|
+(void) _gotShmCompletion: (Drawable)d
|
||||||
|
{
|
||||||
|
[XWindowBuffer _gotShmCompletion: d];
|
||||||
|
}
|
||||||
|
|
||||||
|
-(void) gotShmCompletion: (Drawable)d
|
||||||
|
{
|
||||||
|
[XWindowBuffer _gotShmCompletion: d];
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation CairoContext (Ops)
|
@implementation CairoContext (Ops)
|
||||||
|
|
|
@ -835,11 +835,18 @@ _set_op(cairo_t * ct, NSCompositingOperation op)
|
||||||
unsigned char *d = rowData;
|
unsigned char *d = rowData;
|
||||||
|
|
||||||
for (j = 0; j < pixelsWide; j++)
|
for (j = 0; j < pixelsWide; j++)
|
||||||
{
|
{
|
||||||
|
#if GS_WORDS_BIGENDIAN
|
||||||
|
tmp[index++] = d[3];
|
||||||
|
tmp[index++] = d[0];
|
||||||
|
tmp[index++] = d[1];
|
||||||
|
tmp[index++] = d[2];
|
||||||
|
#else
|
||||||
tmp[index++] = d[2];
|
tmp[index++] = d[2];
|
||||||
tmp[index++] = d[1];
|
tmp[index++] = d[1];
|
||||||
tmp[index++] = d[0];
|
tmp[index++] = d[0];
|
||||||
tmp[index++] = d[3];
|
tmp[index++] = d[3];
|
||||||
|
#endif
|
||||||
d += 4;
|
d += 4;
|
||||||
}
|
}
|
||||||
rowData += bytesPerRow;
|
rowData += bytesPerRow;
|
||||||
|
@ -858,10 +865,17 @@ _set_op(cairo_t * ct, NSCompositingOperation op)
|
||||||
|
|
||||||
for (j = 0; j < pixelsWide; j++)
|
for (j = 0; j < pixelsWide; j++)
|
||||||
{
|
{
|
||||||
|
#if GS_WORDS_BIGENDIAN
|
||||||
|
tmp[index++] = 0;
|
||||||
|
tmp[index++] = d[0];
|
||||||
|
tmp[index++] = d[1];
|
||||||
|
tmp[index++] = d[2];
|
||||||
|
#else
|
||||||
tmp[index++] = d[2];
|
tmp[index++] = d[2];
|
||||||
tmp[index++] = d[1];
|
tmp[index++] = d[1];
|
||||||
tmp[index++] = d[0];
|
tmp[index++] = d[0];
|
||||||
tmp[index++] = 0;
|
tmp[index++] = 0;
|
||||||
|
#endif
|
||||||
d += 3;
|
d += 3;
|
||||||
}
|
}
|
||||||
rowData += bytesPerRow;
|
rowData += bytesPerRow;
|
||||||
|
@ -967,6 +981,7 @@ _set_op(cairo_t * ct, NSCompositingOperation op)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
cairo_save(_ct);
|
cairo_save(_ct);
|
||||||
|
//cairo_new_path(_ct);
|
||||||
_set_op(_ct, op);
|
_set_op(_ct, op);
|
||||||
|
|
||||||
src = cairo_get_target(source->_ct);
|
src = cairo_get_target(source->_ct);
|
||||||
|
|
|
@ -28,21 +28,30 @@
|
||||||
|
|
||||||
- (id) initWithDevice: (void *)device
|
- (id) initWithDevice: (void *)device
|
||||||
{
|
{
|
||||||
/* FIXME format is ignore when Visual isn't NULL
|
struct XWindowBuffer_depth_info_s di;
|
||||||
* Cairo may change this API
|
XWindowBuffer *new_wi;
|
||||||
*/
|
|
||||||
gsDevice = device;
|
gsDevice = device;
|
||||||
image = XCreateImage(GSWINDEVICE->display,
|
|
||||||
DefaultVisual(GSWINDEVICE->display,
|
di.drawing_depth = 24;
|
||||||
DefaultScreen(GSWINDEVICE->display)),
|
di.bytes_per_pixel = 4;
|
||||||
24, ZPixmap, 0, NULL,
|
di.inline_alpha = YES;
|
||||||
GSWINDEVICE->xframe.size.width,
|
di.inline_alpha_ofs = 0;
|
||||||
GSWINDEVICE->xframe.size.height,
|
new_wi = [XWindowBuffer windowBufferForWindow: GSWINDEVICE depthInfo: &di];
|
||||||
8, 0);
|
if (new_wi != wi)
|
||||||
image->data = malloc(image->height * image->bytes_per_line);
|
{
|
||||||
//NSLog(@"alloc %d %d %d",image->width,image->height,(image->height * image->bytes_per_line));
|
DESTROY(wi);
|
||||||
_surface = cairo_image_surface_create_for_data((unsigned char*)image->data, CAIRO_FORMAT_ARGB32,
|
wi = new_wi;
|
||||||
image->width, image->height, image->width*4);
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DESTROY(new_wi);
|
||||||
|
}
|
||||||
|
|
||||||
|
_surface = cairo_image_surface_create_for_data((unsigned char*)wi->data,
|
||||||
|
CAIRO_FORMAT_ARGB32,
|
||||||
|
wi->sx, wi->sy,
|
||||||
|
wi->bytes_per_line);
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue