Cairo backend builds again. But is dead slow and isn't complete.

SVN revision: 16447
This commit is contained in:
sebastid 2005-09-01 00:53:34 +00:00 committed by sebastid
parent 044b599af0
commit 94a05490b6
7 changed files with 427 additions and 227 deletions

View File

@ -475,25 +475,25 @@ fi
## Check if we should build the gl_x11 engine
have_evas_cairo_x11="no";
ENGINE_CAIRO_X11_PRG="";
## Automatic check...
#PKG_CHECK_MODULES(CAIRO, cairo >= 0.1.23,
# [ have_evas_cairo_x11="yes" ],
# [ have_evas_cairo_x11="no" ]
#)
## Manual override
#AC_MSG_CHECKING(whether cairo x11 backend is to be built)
#AC_ARG_ENABLE(cairo-x11, [ --enable-cairo-x11 enable the Cairo X11 display engine], [
# if [ test "$enableval" = "yes" ]; then
# AC_MSG_RESULT(yes)
# have_evas_cairo_x11="yes"
# else
# AC_MSG_RESULT(no)
# have_evas_cairo_x11="no"
# fi
# ], [
# AC_MSG_RESULT($have_evas_cairo_x11)
# ]
#)
# Automatic check...
PKG_CHECK_MODULES(CAIRO, cairo >= 1.0.0,
[ have_evas_cairo_x11="yes" ],
[ have_evas_cairo_x11="no" ]
)
# Manual override
AC_MSG_CHECKING(whether cairo x11 backend is to be built)
AC_ARG_ENABLE(cairo-x11, [ --enable-cairo-x11 enable the Cairo X11 display engine], [
if [ test "$enableval" = "yes" ]; then
AC_MSG_RESULT(yes)
have_evas_cairo_x11="yes"
else
AC_MSG_RESULT(no)
have_evas_cairo_x11="no"
fi
], [
AC_MSG_RESULT($have_evas_cairo_x11)
]
)
if test "x$have_evas_cairo_x11" = "xyes"; then
AC_CHECK_HEADER(X11/X.h,
[

View File

@ -11,3 +11,4 @@ evas_software_x11_test
evas_directfb_test
evas_directfb_window
moc_evas_software_qtopia_main.cpp
evas_cairo_x11_test

View File

@ -2,5 +2,5 @@ Makefile.in
Makefile
.deps
.libs
libevas_engine_gl_x11.la
libevas_engine_cairo_x11.la
*.lo

View File

@ -1,3 +1,6 @@
/*
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
*/
#include "evas_common.h"
#include "evas_private.h"
#include "evas_engine.h"
@ -80,11 +83,7 @@ typedef struct _Render_Engine Render_Engine;
struct _Render_Engine
{
Tilebuf *tb;
Tilebuf_Rect *rects;
Evas_Object_List *cur_rect;
Evas_Cairo_X11_Window *win;
unsigned char end : 1;
};
Evas_Func evas_engine_cairo_x11_func =
@ -220,12 +219,11 @@ static void *
evas_engine_cairo_x11_output_setup(int w, int h, Display *disp, Drawable draw, Visual *vis, Colormap cmap, int depth)
{
Render_Engine *re;
int eb, evb;
re = calloc(1, sizeof(Render_Engine));
re->win = evas_engine_cairo_x11_window_new(disp, draw,
0 /* FIXME: screen 0 assumption */,
vis, cmap, depth, w, h);
0 /* FIXME: screen 0 assumption */,
vis, cmap, depth, w, h);
if (!re->win)
{
free(re);
@ -246,9 +244,6 @@ evas_engine_cairo_x11_output_setup(int w, int h, Display *disp, Drawable draw, V
evas_common_draw_init();
evas_common_tilebuf_init();
re->tb = evas_common_tilebuf_new(w, h);
evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE);
return re;
}
@ -259,8 +254,7 @@ evas_engine_cairo_x11_output_free(void *data)
re = (Render_Engine *)data;
evas_common_tilebuf_free(re->tb);
if (re->rects) evas_common_tilebuf_free_render_rects(re->rects);
evas_engine_cairo_x11_window_free(re->win);
free(re);
@ -277,10 +271,7 @@ evas_engine_cairo_x11_output_resize(void *data, int w, int h)
re->win->w = w;
re->win->h = h;
evas_common_tilebuf_free(re->tb);
re->tb = evas_common_tilebuf_new(w, h);
if (re->tb)
evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE);
evas_engine_cairo_x11_window_size_set(re->win, w, h);
}
static void
@ -289,16 +280,31 @@ evas_engine_cairo_x11_output_tile_size_set(void *data, int w, int h)
Render_Engine *re;
re = (Render_Engine *)data;
evas_common_tilebuf_set_tile_size(re->tb, w, h);
/* not used in cairo engine */
}
static void
evas_engine_cairo_x11_output_redraws_rect_add(void *data, int x, int y, int w, int h)
{
Render_Engine *re;
/* FIXME? cairo_surface_mark_dirty_rectangle */
re = (Render_Engine *)data;
evas_common_tilebuf_add_redraw(re->tb, x, y, w, h);
if (!re->win->draw.redraw)
{
re->win->draw.x1 = 0;
re->win->draw.y1 = 0;
re->win->draw.x2 = re->win->w - 1;
re->win->draw.y2 = re->win->h - 1;
}
else
{
if (x < re->win->draw.x1) re->win->draw.x1 = x;
if (y < re->win->draw.y1) re->win->draw.y1 = y;
if ((x + w - 1) > re->win->draw.x2) re->win->draw.x2 = x + w - 1;
if ((y + h - 1) > re->win->draw.y2) re->win->draw.y2 = y + h - 1;
}
re->win->draw.redraw = 1;
}
static void
@ -307,7 +313,7 @@ evas_engine_cairo_x11_output_redraws_rect_del(void *data, int x, int y, int w, i
Render_Engine *re;
re = (Render_Engine *)data;
evas_common_tilebuf_del_redraw(re->tb, x, y, w, h);
/* not used in cairo engine */
}
static void
@ -316,98 +322,73 @@ evas_engine_cairo_x11_output_redraws_clear(void *data)
Render_Engine *re;
re = (Render_Engine *)data;
evas_common_tilebuf_clear(re->tb);
re->win->draw.redraw = 0;
}
typedef struct _Update Update;
struct _Update
{
int x, y, w, h;
GC gc;
Pixmap pm;
};
static void *
evas_engine_cairo_x11_output_redraws_next_update_get(void *data, int *x, int *y, int *w, int *h, int *cx, int *cy, int *cw, int *ch)
{
Render_Engine *re;
Tilebuf_Rect *rect;
int ux, uy, uw, uh;
Update *u;
re = (Render_Engine *)data;
if (re->end)
{
re->end = 0;
return NULL;
}
if (!re->rects)
{
re->rects = evas_common_tilebuf_get_render_rects(re->tb);
re->cur_rect = (Evas_Object_List *)re->rects;
}
if (!re->cur_rect) return NULL;
rect = (Tilebuf_Rect *)re->cur_rect;
ux = rect->x; uy = rect->y; uw = rect->w; uh = rect->h;
re->cur_rect = re->cur_rect->next;
if (!re->cur_rect)
{
evas_common_tilebuf_free_render_rects(re->rects);
re->rects = NULL;
re->end = 1;
}
*x = ux; *y = uy; *w = uw; *h = uh;
*cx = 0; *cy = 0; *cw = uw; *ch = uh;
u = malloc(sizeof(Update));
u->pm = XCreatePixmap(re->win->disp, re->win->win, uw, uh, re->win->depth);
u->gc = XCreateGC(re->win->disp, u->pm, 0, NULL);
u->x = ux; u->y = uy; u->w = uw; u->h = uh;
cairo_set_target_drawable(re->win->cairo, re->win->disp, u->pm);
return u;
if (!re->win->draw.redraw) return NULL;
if (x) *x = re->win->draw.x1;
if (y) *y = re->win->draw.y1;
if (w) *w = re->win->draw.x2 - re->win->draw.x1 + 1;
if (h) *h = re->win->draw.y2 - re->win->draw.y1 + 1;
if (cx) *cx = re->win->draw.x1;
if (cy) *cy = re->win->draw.y1;
if (cw) *cw = re->win->draw.x2 - re->win->draw.x1 + 1;
if (ch) *ch = re->win->draw.y2 - re->win->draw.y1 + 1;
return re;
}
static void
evas_engine_cairo_x11_output_redraws_next_update_push(void *data, void *surface, int x, int y, int w, int h)
{
Render_Engine *re;
Update *u;
re = (Render_Engine *)data;
u = surface;
XCopyArea(re->win->disp, u->pm, re->win->win, u->gc, 0, 0, w, h, x, y);
XFreePixmap(re->win->disp, u->pm);
XFreeGC(re->win->disp, u->gc);
free(u);
re->win->draw.redraw = 0;
}
static void
evas_engine_cairo_x11_output_flush(void *data)
{
Render_Engine *re;
static int fr = 0;
Evas_Cairo_Context *ctxt;
Evas_List *l;
re = (Render_Engine *)data;
XSync(re->win->disp, False);
}
static void *
evas_engine_cairo_x11_context_new(void *data)
{
Render_Engine *re;
Evas_Cairo_Context *ctxt;
re = (Render_Engine *)data;
return evas_common_draw_context_new();
ctxt = calloc(1, sizeof(Evas_Cairo_Context));
if (!ctxt) return NULL;
ctxt->cairo = cairo_create(re->win->surface);
return ctxt;
}
static void
evas_engine_cairo_x11_context_free(void *data, void *context)
{
Render_Engine *re;
Evas_Cairo_Context *ctxt;
re = (Render_Engine *)data;
evas_common_draw_context_free(context);
ctxt = context;
cairo_destroy(ctxt->cairo);
free(ctxt);
}
static void
@ -416,7 +397,7 @@ evas_engine_cairo_x11_context_clip_set(void *data, void *context, int x, int y,
Render_Engine *re;
re = (Render_Engine *)data;
evas_common_draw_context_set_clip(context, x, y, w, h);
/* not used in cairo engine */
}
static void
@ -425,7 +406,7 @@ evas_engine_cairo_x11_context_clip_clip(void *data, void *context, int x, int y,
Render_Engine *re;
re = (Render_Engine *)data;
evas_common_draw_context_clip_clip(context, x, y, w, h);
/* not used in cairo engine */
}
static void
@ -434,7 +415,7 @@ evas_engine_cairo_x11_context_clip_unset(void *data, void *context)
Render_Engine *re;
re = (Render_Engine *)data;
evas_common_draw_context_unset_clip(context);
/* not used in cairo engine */
}
static int
@ -443,32 +424,38 @@ evas_engine_cairo_x11_context_clip_get(void *data, void *context, int *x, int *y
Render_Engine *re;
re = (Render_Engine *)data;
*x = ((RGBA_Draw_Context *)context)->clip.x;
*y = ((RGBA_Draw_Context *)context)->clip.y;
*w = ((RGBA_Draw_Context *)context)->clip.w;
*h = ((RGBA_Draw_Context *)context)->clip.h;
return ((RGBA_Draw_Context *)context)->clip.use;
/* not used in cairo engine */
return 0;
}
static void
evas_engine_cairo_x11_context_color_set(void *data, void *context, int r, int g, int b, int a)
{
Render_Engine *re;
Evas_Cairo_Context *ctxt;
re = (Render_Engine *)data;
evas_common_draw_context_set_color(context, r, g, b, a);
ctxt = (Evas_Cairo_Context *)context;
ctxt->col.r = (double)r / 255.0;
ctxt->col.g = (double)g / 255.0;
ctxt->col.b = (double)b / 255.0;
ctxt->col.a = (double)a / 255.0;
}
static int
evas_engine_cairo_x11_context_color_get(void *data, void *context, int *r, int *g, int *b, int *a)
{
Render_Engine *re;
Evas_Cairo_Context *ctxt;
re = (Render_Engine *)data;
*r = (int)(R_VAL(&((RGBA_Draw_Context *)context)->col.col));
*g = (int)(G_VAL(&((RGBA_Draw_Context *)context)->col.col));
*b = (int)(B_VAL(&((RGBA_Draw_Context *)context)->col.col));
*a = (int)(A_VAL(&((RGBA_Draw_Context *)context)->col.col));
ctxt = (Evas_Cairo_Context *)context;
if (r) *r = ctxt->col.r * 255;
if (g) *g = ctxt->col.g * 255;
if (b) *b = ctxt->col.b * 255;
if (a) *a = ctxt->col.a * 255;
return 1;
}
@ -476,31 +463,43 @@ static void
evas_engine_cairo_x11_context_multiplier_set(void *data, void *context, int r, int g, int b, int a)
{
Render_Engine *re;
Evas_Cairo_Context *ctxt;
re = (Render_Engine *)data;
evas_common_draw_context_set_multiplier(context, r, g, b, a);
ctxt = (Evas_Cairo_Context *)context;
ctxt->mul.r = (double)r / 255.0;
ctxt->mul.g = (double)g / 255.0;
ctxt->mul.b = (double)b / 255.0;
ctxt->mul.a = (double)a / 255.0;
ctxt->mul.set = 1;
}
static void
evas_engine_cairo_x11_context_multiplier_unset(void *data, void *context)
{
Render_Engine *re;
Evas_Cairo_Context *ctxt;
re = (Render_Engine *)data;
evas_common_draw_context_unset_multiplier(context);
ctxt = (Evas_Cairo_Context *)context;
ctxt->mul.set = 0;
}
static int
evas_engine_cairo_x11_context_multiplier_get(void *data, void *context, int *r, int *g, int *b, int *a)
{
Render_Engine *re;
Evas_Cairo_Context *ctxt;
re = (Render_Engine *)data;
*r = (int)(R_VAL(&((RGBA_Draw_Context *)context)->mul.col));
*g = (int)(G_VAL(&((RGBA_Draw_Context *)context)->mul.col));
*b = (int)(B_VAL(&((RGBA_Draw_Context *)context)->mul.col));
*a = (int)(A_VAL(&((RGBA_Draw_Context *)context)->mul.col));
return ((RGBA_Draw_Context *)context)->mul.use;
ctxt = (Evas_Cairo_Context *)context;
if (r) *r = ctxt->mul.r * 255;
if (g) *g = ctxt->mul.g * 255;
if (b) *b = ctxt->mul.b * 255;
if (a) *a = ctxt->mul.a * 255;
return ctxt->mul.set;
}
static void
@ -521,42 +520,100 @@ evas_engine_cairo_x11_context_cutout_clear(void *data, void *context)
/* not used in cairo engine */
}
static void
evas_engine_cairo_x11_rectangle_draw(void *data, void *context, void *surface, int x, int y, int w, int h)
{
Render_Engine *re;
Evas_Cairo_Context *ctxt;
double r, g, b, a;
re = (Render_Engine *)data;
ctxt = (Evas_Cairo_Context *)context;
cairo_rectangle(ctxt->cairo, x, y, w, h);
r = ctxt->col.r;
g = ctxt->col.g;
b = ctxt->col.b;
a = ctxt->col.a;
if (ctxt->mul.set)
{
r *= ctxt->mul.r;
g *= ctxt->mul.g;
b *= ctxt->mul.b;
a *= ctxt->mul.a;
}
cairo_set_source_rgba(ctxt->cairo, r, g, b, a);
cairo_fill(ctxt->cairo);
}
static void
evas_engine_cairo_x11_line_draw(void *data, void *context, void *surface, int x1, int y1, int x2, int y2)
{
Render_Engine *re;
Evas_Cairo_Context *ctxt;
double r, g, b, a;
re = (Render_Engine *)data;
ctxt = (Evas_Cairo_Context *)context;
cairo_move_to(ctxt->cairo, x1, y1);
cairo_line_to(ctxt->cairo, x2, y2);
r = ctxt->col.r;
g = ctxt->col.g;
b = ctxt->col.b;
a = ctxt->col.a;
if (ctxt->mul.set)
{
r *= ctxt->mul.r;
g *= ctxt->mul.g;
b *= ctxt->mul.b;
a *= ctxt->mul.a;
}
cairo_set_source_rgba(ctxt->cairo, r, g, b, a);
cairo_stroke(ctxt->cairo);
}
static void *
evas_engine_cairo_x11_polygon_point_add(void *data, void *context, void *polygon, int x, int y)
{
Render_Engine *re;
Evas_Cairo_Context *ctxt;
Evas_Cairo_Polygon *poly;
Evas_Cairo_Polygon_Point *pt;
re = (Render_Engine *)data;
return NULL;
ctxt = (Evas_Cairo_Context *)context;
poly = (Evas_Cairo_Polygon *)polygon;
if (!poly) poly = calloc(1, sizeof(Evas_Cairo_Polygon));
pt = malloc(sizeof(Evas_Cairo_Polygon_Point));
if (pt)
{
pt->x = x;
pt->y = y;
poly->points = evas_list_append(poly->points, pt);
}
return poly;
}
static void *
evas_engine_cairo_x11_polygon_points_clear(void *data, void *context, void *polygon)
{
Render_Engine *re;
Evas_Cairo_Context *ctxt;
Evas_Cairo_Polygon *poly;
re = (Render_Engine *)data;
ctxt = (Evas_Cairo_Context *)context;
poly = (Evas_Cairo_Polygon *)polygon;
while (poly->points)
{
free(poly->points->data);
poly->points = evas_list_remove_list(poly->points, poly->points);
}
free(poly);
return NULL;
}
@ -564,8 +621,39 @@ static void
evas_engine_cairo_x11_polygon_draw(void *data, void *context, void *surface, void *polygon)
{
Render_Engine *re;
Evas_Cairo_Context *ctxt;
Evas_Cairo_Polygon *poly;
Evas_Cairo_Polygon_Point *pt;
double r, g, b, a;
re = (Render_Engine *)data;
ctxt = (Evas_Cairo_Context *)context;
poly = (Evas_Cairo_Polygon *)polygon;
pt = poly->points->data;
if (pt)
{
Evas_List *l;
cairo_move_to(ctxt->cairo, pt->x, pt->y);
for (l = poly->points->next; l; l = l->next)
{
pt = l->data;
cairo_line_to(ctxt->cairo, pt->x, pt->y);
}
}
r = ctxt->col.r;
g = ctxt->col.g;
b = ctxt->col.b;
a = ctxt->col.a;
if (ctxt->mul.set)
{
r *= ctxt->mul.r;
g *= ctxt->mul.g;
b *= ctxt->mul.b;
a *= ctxt->mul.a;
}
cairo_set_source_rgba(ctxt->cairo, r, g, b, a);
cairo_stroke(ctxt->cairo);
}
static void *
@ -598,49 +686,93 @@ static void *
evas_engine_cairo_x11_image_load(void *data, char *file, char *key, int *error)
{
Render_Engine *re;
Evas_Cairo_Image *im;
re = (Render_Engine *)data;
*error = 0;
{
Evas_Cairo_Image *im;
if (error) *error = 0;
im = calloc(1, sizeof(Evas_Cairo_Image));
im->im = evas_common_load_image_from_file(file, key);
if (!im->im)
{
free(im);
return NULL;
}
im->references = 1;
return im;
im = calloc(1, sizeof(Evas_Cairo_Image));
if (!im) return NULL;
im->im = evas_common_load_image_from_file(file, key);
if (!im->im)
{
free(im);
return NULL;
}
return NULL;
im->references = 1;
return im;
}
static void *
evas_engine_cairo_x11_image_new_from_data(void *data, int w, int h, DATA32 *image_data)
{
Render_Engine *re;
Evas_Cairo_Image *im;
re = (Render_Engine *)data;
return NULL;
/* FIXME, cache! */
im = calloc(1, sizeof(Evas_Cairo_Image));
if (!im) return NULL;
im->im = evas_common_image_new();
if (!im->im)
{
free(im);
return NULL;
}
im->im->image = evas_common_image_surface_new(im->im);
if (!im->im->image)
{
evas_common_image_free(im->im);
free(im);
return NULL;
}
im->im->image->w = w;
im->im->image->h = h;
im->im->image->data = image_data;
im->im->image->no_free = 1;
im->references = 1;
return im;
}
static void *
evas_engine_cairo_x11_image_new_from_copied_data(void *data, int w, int h, DATA32 *image_data)
{
Render_Engine *re;
Evas_Cairo_Image *im;
re = (Render_Engine *)data;
return NULL;
/* FIXME, cache! */
im = calloc(1, sizeof(Evas_Cairo_Image));
if (!im) return NULL;
im->references = 1;
im->im = evas_common_image_create(w, h);
if (!im->im)
{
free(im);
return NULL;
}
if (data)
memcpy(im->im->image->data, data, w * h * sizeof(DATA32));
return im;
}
static void
evas_engine_cairo_x11_image_free(void *data, void *image)
{
Render_Engine *re;
Evas_Cairo_Image *im;
re = (Render_Engine *)data;
im = (Evas_Cairo_Image *)image;
evas_common_image_free(im->im);
if (im->surface) cairo_surface_destroy(im->surface);
if (im->pattern) cairo_pattern_destroy(im->pattern);
free(im);
}
static void
@ -653,8 +785,8 @@ evas_engine_cairo_x11_image_size_get(void *data, void *image, int *w, int *h)
{
if (w) *w = 0;
if (h) *h = 0;
return;
}
else
{
Evas_Cairo_Image *im;
@ -669,6 +801,7 @@ evas_engine_cairo_x11_image_size_set(void *data, void *image, int w, int h)
{
Render_Engine *re;
/* FIXME */
re = (Render_Engine *)data;
return image;
}
@ -678,6 +811,7 @@ evas_engine_cairo_x11_image_dirty_region(void *data, void *image, int x, int y,
{
Render_Engine *re;
/* FIXME */
re = (Render_Engine *)data;
return image;
}
@ -687,6 +821,7 @@ evas_engine_cairo_x11_image_data_get(void *data, void *image, int to_write, DATA
{
Render_Engine *re;
/* FIXME */
re = (Render_Engine *)data;
*image_data = NULL;
return image;
@ -697,6 +832,7 @@ evas_engine_cairo_x11_image_data_put(void *data, void *image, DATA32 *image_data
{
Render_Engine *re;
/* FIXME */
re = (Render_Engine *)data;
return image;
}
@ -706,6 +842,7 @@ evas_engine_cairo_x11_image_alpha_set(void *data, void *image, int has_alpha)
{
Render_Engine *re;
/* FIXME */
re = (Render_Engine *)data;
return image;
}
@ -714,15 +851,13 @@ static int
evas_engine_cairo_x11_image_alpha_get(void *data, void *image)
{
Render_Engine *re;
Evas_Cairo_Image *im;
re = (Render_Engine *)data;
if (!image) return 0;
{
Evas_Cairo_Image *im;
im = image;
if (im->im->flags & RGBA_IMAGE_HAS_ALPHA) return 1;
}
im = image;
if (im->im->flags & RGBA_IMAGE_HAS_ALPHA) return 1;
return 0;
}
@ -730,74 +865,72 @@ static void
evas_engine_cairo_x11_image_draw(void *data, void *context, void *surface, void *image, int src_x, int src_y, int src_w, int src_h, int dst_x, int dst_y, int dst_w, int dst_h, int smooth)
{
Render_Engine *re;
Evas_Cairo_Context *ctxt;
Evas_Cairo_Image *im;
DATA32 *pix;
re = (Render_Engine *)data;
ctxt = (Evas_Cairo_Context *)context;
if (!image) return;
im = image;
evas_common_load_image_data_from_file(im->im);
pix = im->im->image->data;
if (pix)
{
Evas_Cairo_Image *im;
Update *u;
DATA32 *pix;
im = image;
u = surface;
evas_common_load_image_data_from_file(im->im);
pix = im->im->image->data;
if (pix)
if (!im->surface)
{
if (!im->surf)
im->mulpix = malloc(im->im->image->w * im->im->image->h * sizeof(DATA32));
if (im->mulpix)
{
im->mulpix = malloc(im->im->image->w * im->im->image->h * sizeof(DATA32));
if (im->mulpix)
int i, n;
DATA32 *p;
n = im->im->image->w * im->im->image->h;
p = im->mulpix;
for (i = 0; i < n; i++)
{
int i, n;
DATA32 *p;
int a;
n = im->im->image->w * im->im->image->h;
p = im->mulpix;
for (i = 0; i < n; i++)
{
int a;
a = A_VAL(pix);
R_VAL(p) = (R_VAL(pix) * a) / 255;
G_VAL(p) = (G_VAL(pix) * a) / 255;
B_VAL(p) = (B_VAL(pix) * a) / 255;
A_VAL(p) = a;
p++;
pix++;
}
im->surf = cairo_surface_create_for_image(im->mulpix,
CAIRO_FORMAT_ARGB32,
im->im->image->w,
im->im->image->h,
0);
a = A_VAL(pix);
R_VAL(p) = (R_VAL(pix) * a) / 255;
G_VAL(p) = (G_VAL(pix) * a) / 255;
B_VAL(p) = (B_VAL(pix) * a) / 255;
A_VAL(p) = a;
p++;
pix++;
}
im->surface = cairo_image_surface_create_for_data(im->mulpix,
CAIRO_FORMAT_ARGB32,
im->im->image->w,
im->im->image->h,
0);
im->pattern = cairo_pattern_create_for_surface(im->surface);
}
if (smooth)
cairo_surface_set_filter(im->surf, CAIRO_FILTER_BILINEAR);
else
cairo_surface_set_filter(im->surf, CAIRO_FILTER_NEAREST);
cairo_save(re->win->cairo);
cairo_translate(re->win->cairo,
dst_x,
dst_y);
cairo_scale(re->win->cairo,
(double)src_w / (double)dst_w,
(double)src_h / (double)dst_h
);
cairo_move_to(re->win->cairo, 0, 0);
// cairo_set_rgb_color(re->win->cairo,
// (double)(R_VAL(((RGBA_Draw_Context *)context)->col.col)) / 255.0,
// (double)(R_VAL(((RGBA_Draw_Context *)context)->col.col)) / 255.0,
// (double)(R_VAL(((RGBA_Draw_Context *)context)->col.col)) / 255.0);
// cairo_set_alpha(re->win->cairo,
// (double)(A_VAL(((RGBA_Draw_Context *)context)->col.col)) / 255.0);
cairo_show_surface(re->win->cairo,
im->surf,
im->im->image->w,
im->im->image->h);
cairo_restore(re->win->cairo);
}
if (smooth)
cairo_pattern_set_filter(im->pattern, CAIRO_FILTER_BILINEAR);
else
cairo_pattern_set_filter(im->pattern, CAIRO_FILTER_NEAREST);
cairo_save(ctxt->cairo);
cairo_translate(ctxt->cairo, dst_x, dst_y);
cairo_scale(ctxt->cairo,
(double)src_w / (double)dst_w,
(double)src_h / (double)dst_h);
cairo_move_to(ctxt->cairo, 0, 0);
// cairo_set_rgb_color(re->win->cairo,
// (double)(R_VAL(((RGBA_Draw_Context *)context)->col.col)) / 255.0,
// (double)(R_VAL(((RGBA_Draw_Context *)context)->col.col)) / 255.0,
// (double)(R_VAL(((RGBA_Draw_Context *)context)->col.col)) / 255.0);
// cairo_set_alpha(re->win->cairo,
// (double)(A_VAL(((RGBA_Draw_Context *)context)->col.col)) / 255.0);
cairo_set_source_surface(ctxt->cairo,
im->surface,
im->im->image->w,
im->im->image->h);
cairo_paint(ctxt->cairo);
cairo_restore(ctxt->cairo);
}
}
@ -806,6 +939,7 @@ evas_engine_cairo_x11_image_comment_get(void *data, void *image, char *key)
{
Render_Engine *re;
/* FIXME */
re = (Render_Engine *)data;
return NULL;
}
@ -815,6 +949,7 @@ evas_engine_cairo_x11_image_format_get(void *data, void *image)
{
Render_Engine *re;
/* FIXME */
re = (Render_Engine *)data;
return "";
}
@ -854,8 +989,9 @@ evas_engine_cairo_x11_font_load(void *data, char *name, int size)
{
Render_Engine *re;
/* FIXME, use cairo font subsystem */
re = (Render_Engine *)data;
return evas_common_font_load(name, size);
return NULL;
}
static void *
@ -863,8 +999,9 @@ evas_engine_cairo_x11_font_memory_load(void *data, char *name, int size, const v
{
Render_Engine *re;
/* FIXME, use cairo font subsystem */
re = (Render_Engine *)data;
return evas_common_font_memory_load(name, size, fdata, fdata_size);
return NULL;
}
static void *
@ -872,8 +1009,9 @@ evas_engine_cairo_x11_font_add(void *data, void *font, char *name, int size)
{
Render_Engine *re;
/* FIXME, use cairo font subsystem */
re = (Render_Engine *)data;
return evas_common_font_add(font, name, size);
return NULL;
}
static void *
@ -881,8 +1019,9 @@ evas_engine_cairo_x11_font_memory_add(void *data, void *font, char *name, int si
{
Render_Engine *re;
/* FIXME, use cairo font subsystem */
re = (Render_Engine *)data;
return evas_common_font_memory_add(font, name, size, fdata, fdata_size);
return NULL;
}
static void
@ -890,8 +1029,8 @@ evas_engine_cairo_x11_font_free(void *data, void *font)
{
Render_Engine *re;
/* FIXME, use cairo font subsystem */
re = (Render_Engine *)data;
evas_common_font_free(font);
}
static int
@ -899,8 +1038,9 @@ evas_engine_cairo_x11_font_ascent_get(void *data, void *font)
{
Render_Engine *re;
/* FIXME, use cairo font subsystem */
re = (Render_Engine *)data;
return evas_common_font_ascent_get(font);
return 0;
}
static int
@ -908,8 +1048,9 @@ evas_engine_cairo_x11_font_descent_get(void *data, void *font)
{
Render_Engine *re;
/* FIXME, use cairo font subsystem */
re = (Render_Engine *)data;
return evas_common_font_descent_get(font);
return 0;
}
static int
@ -917,8 +1058,9 @@ evas_engine_cairo_x11_font_max_ascent_get(void *data, void *font)
{
Render_Engine *re;
/* FIXME, use cairo font subsystem */
re = (Render_Engine *)data;
return evas_common_font_max_ascent_get(font);
return 0;
}
static int
@ -926,8 +1068,9 @@ evas_engine_cairo_x11_font_max_descent_get(void *data, void *font)
{
Render_Engine *re;
/* FIXME, use cairo font subsystem */
re = (Render_Engine *)data;
return evas_common_font_max_descent_get(font);
return 0;
}
static void
@ -935,8 +1078,8 @@ evas_engine_cairo_x11_font_string_size_get(void *data, void *font, char *text, i
{
Render_Engine *re;
/* FIXME, use cairo font subsystem */
re = (Render_Engine *)data;
evas_common_font_query_size(font, text, w, h);
}
static int
@ -944,8 +1087,9 @@ evas_engine_cairo_x11_font_inset_get(void *data, void *font, char *text)
{
Render_Engine *re;
/* FIXME, use cairo font subsystem */
re = (Render_Engine *)data;
return evas_common_font_query_inset(font, text);
return 0;
}
static int
@ -954,9 +1098,9 @@ evas_engine_cairo_x11_font_h_advance_get(void *data, void *font, char *text)
Render_Engine *re;
int h, v;
/* FIXME, use cairo font subsystem */
re = (Render_Engine *)data;
evas_common_font_query_advance(font, text, &h, &v);
return h;
return 0;
}
static int
@ -965,9 +1109,9 @@ evas_engine_cairo_x11_font_v_advance_get(void *data, void *font, char *text)
Render_Engine *re;
int h, v;
/* FIXME, use cairo font subsystem */
re = (Render_Engine *)data;
evas_common_font_query_advance(font, text, &h, &v);
return v;
return 0;
}
static int
@ -975,8 +1119,9 @@ evas_engine_cairo_x11_font_char_coords_get(void *data, void *font, char *text, i
{
Render_Engine *re;
/* FIXME, use cairo font subsystem */
re = (Render_Engine *)data;
return evas_common_font_query_char_coords(font, text, pos, cx, cy, cw, ch);
return 0;
}
static int
@ -984,8 +1129,9 @@ evas_engine_cairo_x11_font_char_at_coords_get(void *data, void *font, char *text
{
Render_Engine *re;
/* FIXME, use cairo font subsystem */
re = (Render_Engine *)data;
return evas_common_font_query_text_at_pos(font, text, x, y, cx, cy, cw, ch);
return 0;
}
static void
@ -993,6 +1139,7 @@ evas_engine_cairo_x11_font_draw(void *data, void *context, void *surface, void *
{
Render_Engine *re;
/* FIXME, use cairo font subsystem */
re = (Render_Engine *)data;
}
@ -1001,8 +1148,8 @@ evas_engine_cairo_x11_font_cache_flush(void *data)
{
Render_Engine *re;
/* FIXME, use cairo font subsystem */
re = (Render_Engine *)data;
evas_common_font_flush();
}
static void
@ -1010,8 +1157,8 @@ evas_engine_cairo_x11_font_cache_set(void *data, int bytes)
{
Render_Engine *re;
/* FIXME, use cairo font subsystem */
re = (Render_Engine *)data;
evas_common_font_cache_set(bytes);
}
static int
@ -1019,6 +1166,7 @@ evas_engine_cairo_x11_font_cache_get(void *data)
{
Render_Engine *re;
/* FIXME, use cairo font subsystem */
re = (Render_Engine *)data;
return evas_common_font_cache_get();
return 0;
}

View File

@ -14,7 +14,12 @@ struct _Evas_Cairo_X11_Window
Visual *visual;
Colormap colormap;
int depth;
cairo_t *cairo;
cairo_surface_t *surface;
struct {
int redraw : 1;
int x1, y1, x2, y2;
} draw;
};
Evas_Cairo_X11_Window *
@ -30,5 +35,7 @@ void
evas_engine_cairo_x11_window_free(Evas_Cairo_X11_Window *cw);
void
evas_engine_cairo_x11_window_use(Evas_Cairo_X11_Window *cw);
void
evas_engine_cairo_x11_window_size_set(Evas_Cairo_X11_Window *cw, int w, int h);
#endif

View File

@ -9,13 +9,13 @@ static Evas_Cairo_X11_Window *_evas_cairo_x11_window = NULL;
Evas_Cairo_X11_Window *
evas_engine_cairo_x11_window_new(Display *disp,
Window win,
int screen,
Visual *vis,
Colormap cmap,
int depth,
int w,
int h)
Window win,
int screen,
Visual *vis,
Colormap cmap,
int depth,
int w,
int h)
{
Evas_Cairo_X11_Window *cw;
@ -27,8 +27,7 @@ evas_engine_cairo_x11_window_new(Display *disp,
cw->visual = vis;
cw->colormap = cmap;
cw->depth = depth;
cw->cairo = cairo_create();
// evas_gl_common_context_resize(gw->gl_context, w, h);
cw->surface = cairo_xlib_surface_create(disp, win, vis, w, h);
return cw;
}
@ -36,7 +35,7 @@ void
evas_engine_cairo_x11_window_free(Evas_Cairo_X11_Window *cw)
{
if (cw == _evas_cairo_x11_window) _evas_cairo_x11_window = NULL;
cairo_destroy(cw->cairo);
cairo_surface_destroy(cw->surface);
free(cw);
}
@ -47,5 +46,10 @@ evas_engine_cairo_x11_window_use(Evas_Cairo_X11_Window *cw)
{
_evas_cairo_x11_window = cw;
}
// evas_gl_common_context_use(cw->gl_context);
}
void
evas_engine_cairo_x11_window_size_set(Evas_Cairo_X11_Window *cw, int w, int h)
{
cairo_xlib_surface_set_size(cw->surface, w, h);
}

View File

@ -17,6 +17,7 @@
#include <X11/Xutil.h>
#include <cairo.h>
#include <cairo-xlib.h>
typedef struct _Evas_Cairo_Context Evas_Cairo_Context;
typedef struct _Evas_Cairo_Image Evas_Cairo_Image;
@ -24,6 +25,44 @@ typedef struct _Evas_Cairo_Polygon Evas_Cairo_Polygon;
typedef struct _Evas_Cairo_Polygon_Point Evas_Cairo_Polygon_Point;
typedef struct _Evas_Cairo_Gradient Evas_Cairo_Gradient;
struct _Evas_Cairo_Context
{
cairo_t *cairo;
struct {
double r, g, b, a;
} col;
struct {
unsigned int set : 1;
double r, g, b, a;
} mul;
};
struct _Evas_Cairo_Image
{
RGBA_Image *im;
int references;
DATA32 *mulpix;
cairo_surface_t *surface;
cairo_pattern_t *pattern;
#if 0
Evas_Cairo_Context *cc;
char dirty : 1;
char cached : 1;
#endif
};
struct _Evas_Cairo_Polygon
{
Evas_List *points;
};
struct _Evas_Cairo_Polygon_Point
{
int x, y;
};
#if 0
struct _Evas_Cairo_Context
{
unsigned char r, g, b, a;
@ -80,6 +119,7 @@ struct _Evas_Cairo_Gradient
{
RGBA_Gradient *grad;
};
#endif
/*
Evas_GL_Context *evas_gl_common_context_new(void);