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:
fredkiefer 2006-12-26 13:26:40 +00:00
parent 9862ceb0cc
commit 782df5561f
5 changed files with 76 additions and 18 deletions

View file

@ -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>
* Source/cairo/XGCairoGlitzSurface.m (-initWithDevice:): Correct

View file

@ -25,12 +25,13 @@
#include "x11/XGServer.h"
#include "x11/XGServerWindow.h"
#include "x11/XWindowBuffer.h"
#include "cairo/CairoSurface.h"
@interface XGCairoXImageSurface : CairoSurface
{
XImage *image;
@public
XWindowBuffer *wi;
}
@end

View file

@ -30,6 +30,7 @@
#include "cairo/XGCairoGlitzSurface.h"
#else
#include "cairo/XGCairoSurface.h"
#include "cairo/XGCairoXImageSurface.h"
#endif
#define CGSTATE ((CairoGState *)gstate)
@ -45,7 +46,8 @@
#ifdef USE_GLITZ
[CairoSurface setDefaultSurfaceClass: [XGCairoGlitzSurface class]];
#else
[CairoSurface setDefaultSurfaceClass: [XGCairoSurface class]];
// [CairoSurface setDefaultSurfaceClass: [XGCairoSurface class]];
[CairoSurface setDefaultSurfaceClass: [XGCairoXImageSurface class]];
#endif
[GSFontEnumerator setDefaultClass: [CairoFontEnumerator class]];
[GSFontInfo setDefaultClass: [CairoFontInfo class]];
@ -76,6 +78,26 @@
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
@implementation CairoContext (Ops)

View file

@ -835,11 +835,18 @@ _set_op(cairo_t * ct, NSCompositingOperation op)
unsigned char *d = rowData;
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[1];
tmp[index++] = d[0];
tmp[index++] = d[3];
#endif
d += 4;
}
rowData += bytesPerRow;
@ -858,10 +865,17 @@ _set_op(cairo_t * ct, NSCompositingOperation op)
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[1];
tmp[index++] = d[0];
tmp[index++] = 0;
#endif
d += 3;
}
rowData += bytesPerRow;
@ -967,6 +981,7 @@ _set_op(cairo_t * ct, NSCompositingOperation op)
*/
cairo_save(_ct);
//cairo_new_path(_ct);
_set_op(_ct, op);
src = cairo_get_target(source->_ct);

View file

@ -28,21 +28,30 @@
- (id) initWithDevice: (void *)device
{
/* FIXME format is ignore when Visual isn't NULL
* Cairo may change this API
*/
struct XWindowBuffer_depth_info_s di;
XWindowBuffer *new_wi;
gsDevice = device;
image = XCreateImage(GSWINDEVICE->display,
DefaultVisual(GSWINDEVICE->display,
DefaultScreen(GSWINDEVICE->display)),
24, ZPixmap, 0, NULL,
GSWINDEVICE->xframe.size.width,
GSWINDEVICE->xframe.size.height,
8, 0);
image->data = malloc(image->height * image->bytes_per_line);
//NSLog(@"alloc %d %d %d",image->width,image->height,(image->height * image->bytes_per_line));
_surface = cairo_image_surface_create_for_data((unsigned char*)image->data, CAIRO_FORMAT_ARGB32,
image->width, image->height, image->width*4);
di.drawing_depth = 24;
di.bytes_per_pixel = 4;
di.inline_alpha = YES;
di.inline_alpha_ofs = 0;
new_wi = [XWindowBuffer windowBufferForWindow: GSWINDEVICE depthInfo: &di];
if (new_wi != wi)
{
DESTROY(wi);
wi = new_wi;
}
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;
}