GL engine goes in... its not 100% complete. fonts are sub-optimal. i quickly

hooked them in to work at all...


SVN revision: 7408
This commit is contained in:
Carsten Haitzler 2003-09-04 07:40:34 +00:00
parent df683295dd
commit bac314fd93
17 changed files with 1866 additions and 40 deletions

View File

@ -166,6 +166,13 @@ make CFLAGS="-O9 -mpentiumpro -march=pentiumpro -mcpu=pentiumpro"
###### OpenGL (being worked on. does nothing much at the moment) #######
This requires OpengGL 1.2 or above. it needs libGL and libGLU. Speedup
benefit may vary depending on graphcis card. Many GL implimentations have
many bugs that have been triggered during development. There are workarounds
for known bugs. You may encounter more. At this stage please help out if you
know OpenGL well. NB: you MUST enable the smooth scaler to use the gl engine
- currently it isn't properly forced to be enabled for you.
./configure \
--enable-gl-x11 \
--enable-image-loader-png \

View File

@ -4,6 +4,7 @@ make clean distclean
rm config.cache
./configure \
--enable-software-x11 \
--enable-gl-x11 \
--enable-image-loader-png \
--enable-image-loader-jpeg \
--enable-image-loader-eet \

View File

@ -480,7 +480,7 @@ loop(void)
double x, y;
evas_object_image_size_get(test_pattern, &iw, &ih);
v = 2.0 - ((t - 96.0) / 10.0);
v = 2.0 - ((t - 76.0) / 10.0);
if ((v >= 0.4) && (v <= 1.4))
{
evas_object_text_text_set(comment,
@ -889,12 +889,12 @@ loop(void)
"Destroy gradient blue, create red");
ob = evas_object_gradient_add(evas);
evas_object_gradient_color_add(ob, 255, 0, 0, 0, 1);
evas_object_gradient_color_add(ob, 255, 0, 0, 255, 1);
evas_object_gradient_color_add(ob, 255, 255, 0, 255, 1);
evas_object_gradient_color_add(ob, 255, 255, 255, 255, 1);
evas_object_gradient_angle_set(ob, 45.0);
evas_object_move(ob, (win_w - 48) / 2,
(win_h - 240) + ((240 - 48) / 2));
evas_object_resize(ob, 48, 48);
evas_object_move(ob, (win_w - 128) / 2,
(win_h - 240) + ((240 - 128) / 2));
evas_object_resize(ob, 128, 128);
evas_object_layer_set(ob, 5);
evas_object_clip_set(ob, panel_clip);
evas_object_show(ob);
@ -914,12 +914,12 @@ loop(void)
"Destroy gradient red, create blue");
ob = evas_object_gradient_add(evas);
evas_object_gradient_color_add(ob, 0, 0, 255, 0, 1);
evas_object_gradient_color_add(ob, 0, 0, 255, 255, 1);
evas_object_gradient_color_add(ob, 0, 255, 255, 255, 1);
evas_object_gradient_color_add(ob, 255, 255, 255, 255, 1);
evas_object_gradient_angle_set(ob, 45.0);
evas_object_move(ob, (win_w - 48) / 2,
(win_h - 240) + ((240 - 48) / 2));
evas_object_resize(ob, 48, 48);
evas_object_move(ob, (win_w - 128) / 2,
(win_h - 240) + ((240 - 128) / 2));
evas_object_resize(ob, 128, 128);
evas_object_layer_set(ob, 5);
evas_object_clip_set(ob, panel_clip);
evas_object_show(ob);

View File

@ -65,7 +65,15 @@ ENGINE_SOFTWARE_QTOPIA =
ENGINE_SOFTWARE_QTOPIA_INC =
endif
if BUILD_ENGINE_GL_X11
if BUILD_ENGINE_GL_COMMON
ENGINE_GL_COMMON = engines/gl_common/libevas_engine_gl_common.la
ENGINE_GL_COMMON_INC =
else
ENGINE_GL_COMMON =
ENGINE_GL_COMMON_INC =
endif
if BUILD_ENGINE_GL_COMMON
ENGINE_GL_X11 = engines/gl_x11/libevas_engine_gl_x11.la
ENGINE_GL_X11_INC = Evas_Engine_GL_X11.h
else
@ -80,6 +88,7 @@ $(ENGINE_DIRECTFB_INC) \
$(ENGINE_FB_INC) \
$(ENGINE_BUFFER_INC) \
$(ENGINE_SOFTWARE_QTOPIA_INC) \
$(ENGINE_GL_COMMON_INC) \
$(ENGINE_GL_X11_INC)
libevas_la_SOURCES = \
@ -97,6 +106,7 @@ libevas_la_LIBADD = $(LDFLAGS) \
$(ENGINE_FB) \
$(ENGINE_BUFFER) \
$(ENGINE_SOFTWARE_QTOPIA) \
$(ENGINE_GL_COMMON) \
$(ENGINE_GL_X11)
@ -111,6 +121,7 @@ libevas_la_DEPENDENCIES = \
$(ENGINE_FB) \
$(ENGINE_BUFFER) \
$(ENGINE_SOFTWARE_QTOPIA) \
$(ENGINE_GL_COMMON) \
$(ENGINE_GL_X11)
libevas_la_LDFLAGS = -version-info 1:0:0

View File

@ -794,7 +794,8 @@ evas_engine_buffer_image_data_put(void *data, void *image, DATA32 *image_data)
evas_common_image_unref(im);
return evas_engine_buffer_image_new_from_data(data, w, h, image_data);
}
evas_common_image_dirty(im);
/* hmmm - but if we wrote... why bother? */
/* evas_common_image_dirty(im); */
return im;
}

View File

@ -713,7 +713,8 @@ evas_engine_fb_image_data_put(void *data, void *image, DATA32 *image_data)
evas_common_image_unref(im);
return evas_engine_fb_image_new_from_data(data, w, h, image_data);
}
evas_common_image_dirty(im);
/* hmmm - but if we wrote... why bother? */
/* evas_common_image_dirty(im); */
return im;
}

View File

@ -17,6 +17,8 @@ if BUILD_ENGINE_GL_COMMON
noinst_LTLIBRARIES = libevas_engine_gl_common.la
libevas_engine_gl_common_la_SOURCES = \
evas_gl_routines.c \
evas_gl_routines.h \
evas_gl_image.c
libevas_engine_gl_common_la_LIBADD = \

View File

@ -1 +1,2 @@
#include "evas_common.h"
#include "evas_gl_common.h"

File diff suppressed because it is too large Load Diff

View File

@ -4,11 +4,12 @@
#include "evas_engine_api_gl_x11.h"
#include "Evas.h"
#include "Evas_Engine_GL_X11.h"
#include "evas_gl_common.h"
static void *evas_engine_gl_x11_info(Evas *e);
static void evas_engine_gl_x11_info_free(Evas *e, void *info);
static void evas_engine_gl_x11_setup(Evas *e, void *info);
static void *evas_engine_gl_x11_output_setup(int w, int h, int rot, Display *disp, Drawable draw, Visual *vis, Colormap cmap, int depth);
static void *evas_engine_gl_x11_output_setup(int w, int h, Display *disp, Drawable draw, Visual *vis, Colormap cmap, int depth);
static void evas_engine_gl_x11_output_free(void *data);
static void evas_engine_gl_x11_output_resize(void *data, int w, int h);
static void evas_engine_gl_x11_output_tile_size_set(void *data, int w, int h);
@ -82,7 +83,8 @@ typedef struct _Render_Engine Render_Engine;
struct _Render_Engine
{
int end;
Evas_GL_X11_Window *win;
int end;
};
Evas_Func evas_engine_gl_x11_func =
@ -175,6 +177,7 @@ evas_engine_gl_x11_info(Evas *e)
info->func.best_visual_get = evas_engine_gl_x11_best_visual_get;
info->func.best_colormap_get = evas_engine_gl_x11_best_colormap_get;
info->func.best_depth_get = evas_engine_gl_x11_best_depth_get;
printf("GL: create info...\n");
return info;
e = NULL;
}
@ -195,23 +198,41 @@ evas_engine_gl_x11_setup(Evas *e, void *in)
Evas_Engine_Info_GL_X11 *info;
info = (Evas_Engine_Info_GL_X11 *)in;
printf("GL: setup info...\n");
if (!e->engine.data.output)
e->engine.data.output = 1;
e->engine.data.output =
evas_engine_gl_x11_output_setup(e->output.w,
e->output.h,
info->info.display,
info->info.drawable,
info->info.visual,
info->info.colormap,
info->info.depth);
if (!e->engine.data.output) return;
if (!e->engine.data.context)
e->engine.data.context =
e->engine.func->context_new(e->engine.data.output);
e->engine.func->context_new(e->engine.data.output);
re = e->engine.data.output;
}
static void *
evas_engine_gl_x11_output_setup(int w, int h, int rot, Display *disp, Drawable draw, Visual *vis, Colormap cmap, int depth)
evas_engine_gl_x11_output_setup(int w, int h, Display *disp, Drawable draw, Visual *vis, Colormap cmap, int depth)
{
Render_Engine *re;
int eb, evb;
if (!glXQueryExtension(disp, &eb, &evb)) return NULL;
re = calloc(1, sizeof(Render_Engine));
/* if we haven't initialized - init (automatic abort if already done) */
re->win = evas_engine_gl_x11_window_new(disp, draw,
0 /* FIXME: screen 0 assumption */,
vis, cmap, depth, w, h);
if (!re->win)
{
free(re);
return NULL;
}
printf("GL: gl window setup done.\n");
evas_common_cpu_init();
evas_common_blend_init();
@ -226,8 +247,6 @@ evas_engine_gl_x11_output_setup(int w, int h, int rot, Display *disp, Drawable d
evas_common_draw_init();
evas_common_tilebuf_init();
evas_gl_x11_init();
return re;
}
@ -246,6 +265,9 @@ evas_engine_gl_x11_output_resize(void *data, int w, int h)
Render_Engine *re;
re = (Render_Engine *)data;
re->win->w = w;
re->win->h = h;
evas_gl_common_context_resize(re->win->gl_context, w, h);
}
static void
@ -262,6 +284,22 @@ evas_engine_gl_x11_output_redraws_rect_add(void *data, int x, int y, int w, int
Render_Engine *re;
re = (Render_Engine *)data;
/* smple bounding box */
if (!re->win->draw.redraw)
{
re->win->draw.x1 = x;
re->win->draw.y1 = y;
re->win->draw.x2 = x + w - 1;
re->win->draw.y2 = y + 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
@ -278,6 +316,8 @@ evas_engine_gl_x11_output_redraws_clear(void *data)
Render_Engine *re;
re = (Render_Engine *)data;
re->win->draw.redraw = 0;
// printf("GL: finish update cycle!\n");
}
static void *
@ -286,6 +326,22 @@ evas_engine_gl_x11_output_redraws_next_update_get(void *data, int *x, int *y, in
Render_Engine *re;
re = (Render_Engine *)data;
/* get the upate rect surface - return engine data as dummy */
if (!re->win->draw.redraw)
{
// printf("GL: NO updates!\n");
return NULL;
}
// printf("GL: update....!\n");
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
@ -294,15 +350,33 @@ evas_engine_gl_x11_output_redraws_next_update_push(void *data, void *surface, in
Render_Engine *re;
re = (Render_Engine *)data;
/* put back update surface.. in this case just unflag redraw */
// printf("GL: update done.\n");
re->win->draw.redraw = 0;
}
static void
evas_engine_gl_x11_output_flush(void *data)
{
Render_Engine *re;
static int fr = 0;
re = (Render_Engine *)data;
/* XSync(re->ob->priv.x.disp, False); */
// printf("GL: flush your mush!\n");
evas_engine_gl_x11_window_use(re->win);
/* SLOW AS ALL HELL! */
/*
evas_gl_common_swap_rect(re->win->gl_context,
re->win->draw.x1, re->win->draw.y1,
re->win->draw.x2 - re->win->draw.x1 + 1,
re->win->draw.y2 - re->win->draw.y1 + 1);
*/
glXSwapBuffers(re->win->disp, re->win->win);
glFlush();
// glXWaitGL();
// XSync(re->win->disp, False);
// printf("SYNC! %i\n", fr++);
}
static void *
@ -311,6 +385,7 @@ evas_engine_gl_x11_context_new(void *data)
Render_Engine *re;
re = (Render_Engine *)data;
return evas_common_draw_context_new();
}
static void
@ -319,6 +394,7 @@ evas_engine_gl_x11_context_free(void *data, void *context)
Render_Engine *re;
re = (Render_Engine *)data;
evas_common_draw_context_free(context);
}
static void
@ -327,6 +403,7 @@ evas_engine_gl_x11_context_clip_set(void *data, void *context, int x, int y, int
Render_Engine *re;
re = (Render_Engine *)data;
evas_common_draw_context_set_clip(context, x, y, w, h);
}
static void
@ -335,6 +412,7 @@ evas_engine_gl_x11_context_clip_clip(void *data, void *context, int x, int y, in
Render_Engine *re;
re = (Render_Engine *)data;
evas_common_draw_context_clip_clip(context, x, y, w, h);
}
static void
@ -343,6 +421,7 @@ evas_engine_gl_x11_context_clip_unset(void *data, void *context)
Render_Engine *re;
re = (Render_Engine *)data;
evas_common_draw_context_unset_clip(context);
}
static int
@ -351,6 +430,11 @@ evas_engine_gl_x11_context_clip_get(void *data, void *context, int *x, int *y, i
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;
}
static void
@ -359,6 +443,7 @@ evas_engine_gl_x11_context_color_set(void *data, void *context, int r, int g, in
Render_Engine *re;
re = (Render_Engine *)data;
evas_common_draw_context_set_color(context, r, g, b, a);
}
static int
@ -367,6 +452,11 @@ evas_engine_gl_x11_context_color_get(void *data, void *context, int *r, int *g,
Render_Engine *re;
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));
return 1;
}
static void
@ -375,6 +465,7 @@ evas_engine_gl_x11_context_multiplier_set(void *data, void *context, int r, int
Render_Engine *re;
re = (Render_Engine *)data;
evas_common_draw_context_set_multiplier(context, r, g, b, a);
}
static void
@ -383,6 +474,7 @@ evas_engine_gl_x11_context_multiplier_unset(void *data, void *context)
Render_Engine *re;
re = (Render_Engine *)data;
evas_common_draw_context_unset_multiplier(context);
}
static int
@ -391,6 +483,11 @@ evas_engine_gl_x11_context_multiplier_get(void *data, void *context, int *r, int
Render_Engine *re;
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;
}
static void
@ -399,6 +496,7 @@ evas_engine_gl_x11_context_cutout_add(void *data, void *context, int x, int y, i
Render_Engine *re;
re = (Render_Engine *)data;
/* not used in gl engine */
}
static void
@ -407,6 +505,7 @@ evas_engine_gl_x11_context_cutout_clear(void *data, void *context)
Render_Engine *re;
re = (Render_Engine *)data;
/* not used in gl engine */
}
@ -420,6 +519,8 @@ evas_engine_gl_x11_rectangle_draw(void *data, void *context, void *surface, int
Render_Engine *re;
re = (Render_Engine *)data;
evas_engine_gl_x11_window_use(re->win);
evas_gl_common_rect_draw(re->win->gl_context, context, x, y, w, h);
}
static void
@ -428,6 +529,7 @@ evas_engine_gl_x11_line_draw(void *data, void *context, void *surface, int x1, i
Render_Engine *re;
re = (Render_Engine *)data;
evas_gl_common_line_draw(re->win->gl_context, context, x1, y1, x2, y2);
}
static void *
@ -436,6 +538,8 @@ evas_engine_gl_x11_polygon_point_add(void *data, void *context, void *polygon, i
Render_Engine *re;
re = (Render_Engine *)data;
return evas_gl_common_poly_point_add(polygon, x, y);
}
static void *
@ -444,6 +548,7 @@ evas_engine_gl_x11_polygon_points_clear(void *data, void *context, void *polygon
Render_Engine *re;
re = (Render_Engine *)data;
return evas_gl_common_poly_points_clear(polygon);
}
static void
@ -452,6 +557,7 @@ evas_engine_gl_x11_polygon_draw(void *data, void *context, void *surface, void *
Render_Engine *re;
re = (Render_Engine *)data;
evas_gl_common_poly_draw(re->win->gl_context, context, polygon);
}
static void *
@ -460,6 +566,7 @@ evas_engine_gl_x11_gradient_color_add(void *data, void *context, void *gradient,
Render_Engine *re;
re = (Render_Engine *)data;
return evas_gl_common_gradient_color_add(gradient, r, g, b, a, distance);
}
static void *
@ -468,6 +575,7 @@ evas_engine_gl_x11_gradient_colors_clear(void *data, void *context, void *gradie
Render_Engine *re;
re = (Render_Engine *)data;
return evas_gl_common_gradient_colors_clear(gradient);
}
static void
@ -476,6 +584,8 @@ evas_engine_gl_x11_gradient_draw(void *data, void *context, void *surface, void
Render_Engine *re;
re = (Render_Engine *)data;
evas_engine_gl_x11_window_use(re->win);
evas_gl_common_gradient_draw(re->win->gl_context, context, gradient, x, y, w, h, angle);
}
static void *
@ -484,6 +594,9 @@ evas_engine_gl_x11_image_load(void *data, char *file, char *key, int *error)
Render_Engine *re;
re = (Render_Engine *)data;
*error = 0;
evas_engine_gl_x11_window_use(re->win);
return evas_gl_common_image_load(re->win->gl_context, file, key);
}
static void *
@ -492,6 +605,8 @@ evas_engine_gl_x11_image_new_from_data(void *data, int w, int h, DATA32 *image_d
Render_Engine *re;
re = (Render_Engine *)data;
evas_engine_gl_x11_window_use(re->win);
return evas_gl_common_image_new_from_data(re->win->gl_context, w, h, image_data);
}
static void *
@ -500,6 +615,8 @@ evas_engine_gl_x11_image_new_from_copied_data(void *data, int w, int h, DATA32 *
Render_Engine *re;
re = (Render_Engine *)data;
evas_engine_gl_x11_window_use(re->win);
return evas_gl_common_image_new_from_copied_data(re->win->gl_context, w, h, image_data);
}
static void
@ -508,6 +625,8 @@ evas_engine_gl_x11_image_free(void *data, void *image)
Render_Engine *re;
re = (Render_Engine *)data;
evas_engine_gl_x11_window_use(re->win);
evas_gl_common_image_free(image);
}
static void
@ -516,46 +635,120 @@ evas_engine_gl_x11_image_size_get(void *data, void *image, int *w, int *h)
Render_Engine *re;
re = (Render_Engine *)data;
if (w) *w = ((Evas_GL_Image *)image)->im->image->w;
if (h) *h = ((Evas_GL_Image *)image)->im->image->h;
}
static void *
evas_engine_gl_x11_image_size_set(void *data, void *image, int w, int h)
{
Render_Engine *re;
Evas_GL_Image *im, *im_old;
re = (Render_Engine *)data;
evas_engine_gl_x11_window_use(re->win);
if (!image) return NULL;
im_old = image;
im = evas_gl_common_image_new(re->win->gl_context, w, h);
if (im_old)
{
evas_common_load_image_data_from_file(im_old->im);
if (im_old->im->image->data)
{
evas_common_blit_rectangle(im_old->im, im->im, 0, 0, w, h, 0, 0);
evas_common_cpu_end_opt();
}
evas_gl_common_image_free(im_old);
}
return im;
}
static void *
evas_engine_gl_x11_image_dirty_region(void *data, void *image, int x, int y, int w, int h)
{
Render_Engine *re;
Evas_GL_Image *im;
re = (Render_Engine *)data;
evas_gl_common_image_dirty(image);
return image;
}
static void *
evas_engine_gl_x11_image_data_get(void *data, void *image, int to_write, DATA32 **image_data)
{
Render_Engine *re;
Evas_GL_Image *im;
re = (Render_Engine *)data;
im = image;
evas_engine_gl_x11_window_use(re->win);
evas_common_load_image_data_from_file(im->im);
if (to_write)
{
if (im->references > 1)
{
Evas_GL_Image *im_new;
im_new = evas_gl_common_image_new_from_copied_data(im->gc, im->im->image->w, im->im->image->h, im->im->image->data);
if (!im_new) return im;
im = im_new;
}
else
evas_gl_common_image_dirty(im);
}
*image_data = im->im->image->data;
return im;
}
static void *
evas_engine_gl_x11_image_data_put(void *data, void *image, DATA32 *image_data)
{
Render_Engine *re;
Evas_GL_Image *im;
re = (Render_Engine *)data;
im = image;
evas_engine_gl_x11_window_use(re->win);
if (image_data != im->im->image->data)
{
int w, h;
w = im->im->image->w;
h = im->im->image->h;
evas_gl_common_image_free(im);
return evas_engine_gl_x11_image_new_from_data(data, w, h, image_data);
}
/* hmmm - but if we wrote... why bother? */
/* evas_gl_common_image_dirty(im); */
return im;
}
static void *
evas_engine_gl_x11_image_alpha_set(void *data, void *image, int has_alpha)
{
Render_Engine *re;
Evas_GL_Image *im;
re = (Render_Engine *)data;
evas_engine_gl_x11_window_use(re->win);
im = image;
if (im->references > 1)
{
Evas_GL_Image *im_new;
im_new = evas_gl_common_image_new_from_copied_data(im->gc, im->im->image->w, im->im->image->h, im->im->image->data);
if (!im_new) return im;
evas_gl_common_image_free(im);
im = im_new;
}
else
evas_gl_common_image_dirty(im);
if (has_alpha)
im->im->flags |= RGBA_IMAGE_HAS_ALPHA;
else
im->im->flags &= ~RGBA_IMAGE_HAS_ALPHA;
return image;
}
@ -563,40 +756,61 @@ static int
evas_engine_gl_x11_image_alpha_get(void *data, void *image)
{
Render_Engine *re;
Evas_GL_Image *im;
re = (Render_Engine *)data;
im = image;
evas_engine_gl_x11_window_use(re->win);
if (im->im->flags & RGBA_IMAGE_HAS_ALPHA) return 1;
return 0;
}
static void
evas_engine_gl_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;
re = (Render_Engine *)data;
evas_engine_gl_x11_window_use(re->win);
evas_gl_common_image_draw(re->win->gl_context, context, image,
src_x, src_y, src_w, src_h,
dst_x, dst_y, dst_w, dst_h,
smooth);
}
static char *
evas_engine_gl_x11_image_comment_get(void *data, void *image, char *key)
{
Render_Engine *re;
Evas_GL_Image *im;
re = (Render_Engine *)data;
im = image;
return im->im->info.comment;
}
static char *
evas_engine_gl_x11_image_format_get(void *data, void *image)
{
Render_Engine *re;
Evas_GL_Image *im;
re = (Render_Engine *)data;
im = image;
if (im->im->info.format == 1) return "png";
return NULL;
}
static void
evas_engine_gl_x11_image_cache_flush(void *data)
{
Render_Engine *re;
int tmp_size;
re = (Render_Engine *)data;
tmp_size = evas_common_image_get_cache();
evas_common_image_set_cache(0);
evas_common_image_set_cache(tmp_size);
}
static void
@ -605,6 +819,7 @@ evas_engine_gl_x11_image_cache_set(void *data, int bytes)
Render_Engine *re;
re = (Render_Engine *)data;
evas_common_image_set_cache(bytes);
}
static int
@ -613,6 +828,7 @@ evas_engine_gl_x11_image_cache_get(void *data)
Render_Engine *re;
re = (Render_Engine *)data;
return evas_common_image_get_cache();
}
static void *
@ -621,6 +837,7 @@ evas_engine_gl_x11_font_load(void *data, char *name, int size)
Render_Engine *re;
re = (Render_Engine *)data;
return evas_common_font_load(name, size);
}
static void
@ -629,6 +846,7 @@ evas_engine_gl_x11_font_free(void *data, void *font)
Render_Engine *re;
re = (Render_Engine *)data;
evas_common_font_free(font);
}
static int
@ -637,6 +855,7 @@ evas_engine_gl_x11_font_ascent_get(void *data, void *font)
Render_Engine *re;
re = (Render_Engine *)data;
return evas_common_font_ascent_get(font);
}
static int
@ -645,6 +864,7 @@ evas_engine_gl_x11_font_descent_get(void *data, void *font)
Render_Engine *re;
re = (Render_Engine *)data;
return evas_common_font_descent_get(font);
}
static int
@ -653,6 +873,7 @@ evas_engine_gl_x11_font_max_ascent_get(void *data, void *font)
Render_Engine *re;
re = (Render_Engine *)data;
return evas_common_font_max_ascent_get(font);
}
static int
@ -661,6 +882,7 @@ evas_engine_gl_x11_font_max_descent_get(void *data, void *font)
Render_Engine *re;
re = (Render_Engine *)data;
return evas_common_font_max_descent_get(font);
}
static void
@ -669,6 +891,7 @@ evas_engine_gl_x11_font_string_size_get(void *data, void *font, char *text, int
Render_Engine *re;
re = (Render_Engine *)data;
evas_common_font_query_size(font, text, w, h);
}
static int
@ -677,22 +900,29 @@ evas_engine_gl_x11_font_inset_get(void *data, void *font, char *text)
Render_Engine *re;
re = (Render_Engine *)data;
return evas_common_font_query_inset(font, text);
}
static int
evas_engine_gl_x11_font_h_advance_get(void *data, void *font, char *text)
{
Render_Engine *re;
int h, v;
re = (Render_Engine *)data;
evas_common_font_query_advance(font, text, &h, &v);
return h;
}
static int
evas_engine_gl_x11_font_v_advance_get(void *data, void *font, char *text)
{
Render_Engine *re;
int h, v;
re = (Render_Engine *)data;
evas_common_font_query_advance(font, text, &h, &v);
return v;
}
static int
@ -701,6 +931,7 @@ evas_engine_gl_x11_font_char_coords_get(void *data, void *font, char *text, int
Render_Engine *re;
re = (Render_Engine *)data;
return evas_common_font_query_char_coords(font, text, pos, cx, cy, cw, ch);
}
static int
@ -709,6 +940,7 @@ evas_engine_gl_x11_font_char_at_coords_get(void *data, void *font, char *text, i
Render_Engine *re;
re = (Render_Engine *)data;
return evas_common_font_query_text_at_pos(font, text, x, y, cx, cy, cw, ch);
}
static void
@ -717,6 +949,76 @@ evas_engine_gl_x11_font_draw(void *data, void *context, void *surface, void *fon
Render_Engine *re;
re = (Render_Engine *)data;
#define GL_TXT 1
#ifdef GL_TXT
{
/* create output surface size ow x oh and scale to w x h */
RGBA_Draw_Context *dc;
RGBA_Image *im;
dc = context;
im = evas_common_image_create(ow, oh);
if (im)
{
int max_ascent;
int i, j;
RGBA_Draw_Context *dct;
im->flags |= RGBA_IMAGE_HAS_ALPHA;
j = ow * oh;
memset(im->image->data, 0, j * sizeof(DATA32));
max_ascent = evas_common_font_max_ascent_get(font);
dct = evas_common_draw_context_new();
if (dct)
{
evas_common_draw_context_set_color(dct, 255, 255, 255, 255);
evas_common_font_draw(im, dct, font, 0, max_ascent, text);
evas_common_cpu_end_opt();
evas_common_draw_context_free(dct);
}
{
Evas_GL_Texture *tex;
Evas_GL_Context *gc;
double tx1, ty1, tx2, ty2;
int r, g, b, a;
gc = re->win->gl_context;
tex = evas_gl_common_texture_new(gc, im, 0);
evas_gl_common_context_texture_set(gc, tex, 0, w, h);
tx1 = 0;
ty1 = 0;
tx2 = (double)(ow) / (double)(tex->w);
ty2 = (double)(oh) / (double)(tex->h);
a = (dc->col.col >> 24) & 0xff;
r = (dc->col.col >> 16) & 0xff;
g = (dc->col.col >> 8 ) & 0xff;
b = (dc->col.col ) & 0xff;
evas_gl_common_context_color_set(gc, r, g, b, a);
evas_gl_common_context_blend_set(gc, 1);
if (dc->clip.use)
evas_gl_common_context_clip_set(gc, 1,
dc->clip.x, dc->clip.y,
dc->clip.w, dc->clip.h);
else
evas_gl_common_context_clip_set(gc, 0,
0, 0, 0, 0);
evas_gl_common_context_read_buf_set(gc, GL_BACK);
evas_gl_common_context_write_buf_set(gc, GL_BACK);
glBegin(GL_QUADS);
glTexCoord2d(tx1, ty1); glVertex2i(x , y - ((max_ascent * h) / oh));
glTexCoord2d(tx2, ty1); glVertex2i(x + w, y - ((max_ascent * h) / oh));
glTexCoord2d(tx2, ty2); glVertex2i(x + w, y - ((max_ascent * h) / oh) + h);
glTexCoord2d(tx1, ty2); glVertex2i(x , y - ((max_ascent * h) / oh) + h);
glEnd();
evas_gl_common_texture_free(tex);
}
evas_common_image_free(im);
}
}
#endif
}
static void
@ -725,6 +1027,7 @@ evas_engine_gl_x11_font_cache_flush(void *data)
Render_Engine *re;
re = (Render_Engine *)data;
evas_common_font_flush();
}
static void
@ -733,6 +1036,7 @@ evas_engine_gl_x11_font_cache_set(void *data, int bytes)
Render_Engine *re;
re = (Render_Engine *)data;
evas_common_font_cache_set(bytes);
}
static int
@ -741,6 +1045,7 @@ evas_engine_gl_x11_font_cache_get(void *data)
Render_Engine *re;
re = (Render_Engine *)data;
return evas_common_font_cache_get();
}
@ -757,19 +1062,31 @@ static Visual *
evas_engine_gl_x11_best_visual_get(Display *disp, int screen)
{
if (!disp) return NULL;
return DefaultVisual(disp, screen);
if (!_evas_gl_x11_vi)
_evas_gl_x11_vi = glXChooseVisual(disp, screen,
_evas_gl_x11_configuration);
if (!_evas_gl_x11_vi) return NULL;
return _evas_gl_x11_vi->visual;
}
static Colormap
evas_engine_gl_x11_best_colormap_get(Display *disp, int screen)
{
if (!disp) return 0;
return DefaultColormap(disp, screen);
if (!_evas_gl_x11_vi)
evas_engine_gl_x11_best_visual_get(disp, screen);
if (!_evas_gl_x11_vi) return 0;
_evas_gl_x11_cmap = XCreateColormap(disp, RootWindow(disp, screen),
_evas_gl_x11_vi->visual, 0);
return _evas_gl_x11_cmap;
}
static int
evas_engine_gl_x11_best_depth_get(Display *disp, int screen)
{
if (!disp) return 0;
return DefaultDepth(disp, screen);
if (!_evas_gl_x11_vi)
evas_engine_gl_x11_best_visual_get(disp, screen);
if (!_evas_gl_x11_vi) return 0;
return _evas_gl_x11_vi->depth;
}

View File

@ -1,13 +1,44 @@
#ifndef EVAS_ENGINE_H
#define EVAS_ENGINE_H
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>
#include "evas_gl_common.h"
/* data structs go here for engine internals */
typedef struct _Evas_GL_X11_Window Evas_GL_X11_Window;
/****/
void evas_gl_x11_init (void);
struct _Evas_GL_X11_Window
{
Display *disp;
Window win;
int w, h;
int screen;
XVisualInfo *visualinfo;
Visual *visual;
Colormap colormap;
int depth;
GLXContext context;
Evas_GL_Context *gl_context;
struct {
int redraw : 1;
int x1, y1, x2, y2;
} draw;
};
extern int _evas_gl_x11_configuration[9];
extern XVisualInfo *_evas_gl_x11_vi;
extern Colormap _evas_gl_x11_cmap;
Evas_GL_X11_Window *
evas_engine_gl_x11_window_new(Display *disp,
Window win,
int screen,
Visual *vis,
Colormap cmap,
int depth,
int w,
int h);
void
evas_engine_gl_x11_window_free(Evas_GL_X11_Window *gw);
void
evas_engine_gl_x11_window_use(Evas_GL_X11_Window *gw);
#endif

View File

@ -1,10 +1,82 @@
#include "evas_common.h"
#include "evas_private.h"
#include "evas_engine.h"
#include "evas_engine_api_gl_x11.h"
#include "Evas.h"
#include "Evas_Engine_GL_X11.h"
#include "evas_gl_common.h"
#include <X11/Xlib.h>
#include <X11/Xutil.h>
static Evas_GL_X11_Window *_evas_gl_x11_window = NULL;
/* FIXME: this will only work for 1 display connection... :( */
static GLXContext context = 0;
int _evas_gl_x11_configuration[9] =
{
GLX_DOUBLEBUFFER,
GLX_RGBA,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
None
};
XVisualInfo *_evas_gl_x11_vi = NULL;
Colormap _evas_gl_x11_cmap = 0;
Evas_GL_X11_Window *
evas_engine_gl_x11_window_new(Display *disp,
Window win,
int screen,
Visual *vis,
Colormap cmap,
int depth,
int w,
int h)
{
Evas_GL_X11_Window *gw;
if (!_evas_gl_x11_vi) return NULL;
gw = calloc(1, sizeof(Evas_GL_X11_Window));
if (!gw) return NULL;
gw->disp = disp;
gw->win = win;
gw->screen = screen;
gw->visual = vis;
gw->colormap = cmap;
gw->depth = depth;
gw->visualinfo = _evas_gl_x11_vi;
if (!context)
context = glXCreateContext(disp, gw->visualinfo, NULL, GL_TRUE);
gw->context = context;
gw->gl_context = evas_gl_common_context_new();
if (!gw->gl_context)
{
glXDestroyContext(gw->disp, gw->context);
free(gw);
return NULL;
}
evas_gl_common_context_resize(gw->gl_context, w, h);
return gw;
}
void
evas_gl_x11_init(void)
evas_engine_gl_x11_window_free(Evas_GL_X11_Window *gw)
{
if (gw == _evas_gl_x11_window) _evas_gl_x11_window = NULL;
evas_gl_common_context_free(gw->gl_context);
glXDestroyContext(gw->disp, gw->context);
free(gw);
}
void
evas_engine_gl_x11_window_use(Evas_GL_X11_Window *gw)
{
if (_evas_gl_x11_window != gw)
{
_evas_gl_x11_window = gw;
glXMakeCurrent(gw->disp, gw->win, gw->context);
}
evas_gl_common_context_use(gw->gl_context);
}

View File

@ -736,7 +736,8 @@ evas_engine_software_qtopia_image_data_put(void *data, void *image, DATA32 *imag
evas_common_image_unref(im);
return evas_engine_software_qtopia_image_new_from_data(data, w, h, image_data);
}
evas_common_image_dirty(im);
/* hmmm - but if we wrote... why bother? */
/* evas_common_image_dirty(im); */
return im;
}

View File

@ -780,7 +780,8 @@ evas_engine_software_x11_image_data_put(void *data, void *image, DATA32 *image_d
evas_common_image_unref(im);
return evas_engine_software_x11_image_new_from_data(data, w, h, image_data);
}
evas_common_image_dirty(im);
/* hmmm - but if we wrote... why bother? */
/* evas_common_image_dirty(im); */
return im;
}

View File

@ -8,6 +8,7 @@ evas_engine_api_fb.h \
evas_engine_api_buffer.h \
evas_engine_api_software_qtopia.h \
evas_engine_api_gl_x11.h \
evas_gl_common.h \
evas_mmx.h \
evas_options.h \
evas_private.h

View File

@ -128,7 +128,7 @@
#ifndef _WIN32_WCE
typedef unsigned long long DATA64;
#else
typedef unsigned __int64 DATA64;
typedef unsigned __int64 DATA64;
#define strdup _strdup
#define snprintf _snprintf
#define rewind(f) fseek(f,0,SEEK_SET)

View File

@ -0,0 +1,154 @@
#ifndef EVAS_GL_COMMON_H
#define EVAS_GL_COMMON_H
//#define RADEON_HACK
#define NVIDIA_HACK
#include "evas_common.h"
#include "config.h"
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <sys/time.h>
#include <unistd.h>
#include <GL/gl.h>
#include <GL/glx.h>
#include <GL/glu.h>
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <X11/Xutil.h>
typedef struct _Evas_GL_Context Evas_GL_Context;
typedef struct _Evas_GL_Texture Evas_GL_Texture;
typedef struct _Evas_GL_Image Evas_GL_Image;
typedef struct _Evas_GL_Polygon Evas_GL_Polygon;
typedef struct _Evas_GL_Polygon_Point Evas_GL_Polygon_Point;
typedef struct _Evas_GL_Gradient Evas_GL_Gradient;
struct _Evas_GL_Context
{
int w, h;
char dither : 1;
char blend : 1;
unsigned char r, g, b, a;
struct {
char size : 1;
char dither : 1;
char blend : 1;
char color : 1;
char texture : 1;
char clip : 1;
char buf : 1;
char other : 1;
} change;
struct {
char active : 1;
int x, y, w, h;
} clip;
GLenum read_buf;
GLenum write_buf;
Evas_GL_Texture *texture;
int max_texture_depth;
int max_texture_size;
int references;
Evas_List *images;
};
struct _Evas_GL_Texture
{
Evas_GL_Context *gc;
int w, h;
int tw, th;
int uw, uh;
GLuint texture;
char smooth : 1;
char changed : 1;
char have_mipmaps : 1;
int references;
};
struct _Evas_GL_Image
{
Evas_GL_Context *gc;
RGBA_Image *im;
Evas_GL_Texture *tex;
int references;
char dirty : 1;
char cached : 1;
};
struct _Evas_GL_Polygon
{
Evas_List *points;
};
struct _Evas_GL_Polygon_Point
{
int x, y;
};
struct _Evas_GL_Gradient
{
RGBA_Gradient *grad;
Evas_GL_Texture *tex;
};
Evas_GL_Context *evas_gl_common_context_new(void);
void evas_gl_common_context_free(Evas_GL_Context *gc);
void evas_gl_common_context_use(Evas_GL_Context *gc);
void evas_gl_common_context_resize(Evas_GL_Context *gc, int w, int h);
void evas_gl_common_context_color_set(Evas_GL_Context *gc, int r, int g, int b, int a);
void evas_gl_common_context_blend_set(Evas_GL_Context *gc, int blend);
void evas_gl_common_context_dither_set(Evas_GL_Context *gc, int dither);
void evas_gl_common_context_texture_set(Evas_GL_Context *gc, Evas_GL_Texture *tex, int smooth, int w, int h);
void evas_gl_common_context_clip_set(Evas_GL_Context *gc, int on, int x, int y, int w, int h);
void evas_gl_common_context_read_buf_set(Evas_GL_Context *gc, GLenum buf);
void evas_gl_common_context_write_buf_set(Evas_GL_Context *gc, GLenum buf);
Evas_GL_Texture *evas_gl_common_texture_new(Evas_GL_Context *gc, RGBA_Image *im, int smooth);
void evas_gl_common_texture_free(Evas_GL_Texture *tex);
Evas_GL_Image *evas_gl_common_image_load(Evas_GL_Context *gc, char *file, char *key);
Evas_GL_Image *evas_gl_common_image_new_from_data(Evas_GL_Context *gc, int w, int h, int *data);
Evas_GL_Image *evas_gl_common_image_new_from_copied_data(Evas_GL_Context *gc, int w, int h, int *data);
Evas_GL_Image *evas_gl_common_image_new(Evas_GL_Context *gc, int w, int h);
void evas_gl_common_image_free(Evas_GL_Image *im);
void evas_gl_common_image_dirty(Evas_GL_Image *im);
Evas_GL_Polygon *evas_gl_common_poly_point_add(Evas_GL_Polygon *poly, int x, int y);
Evas_GL_Polygon *evas_gl_common_poly_points_clear(Evas_GL_Polygon *poly);
Evas_GL_Gradient *evas_gl_common_gradient_color_add(Evas_GL_Gradient *gr, int r, int g, int b, int a, int distance);
Evas_GL_Gradient *evas_gl_common_gradient_colors_clear(Evas_GL_Gradient *gr);
void evas_gl_common_swap_rect(Evas_GL_Context *gc, int x, int y, int w, int h);
void evas_gl_common_rect_draw(Evas_GL_Context *gc, RGBA_Draw_Context *dc, int x, int y, int w, int h);
void evas_gl_common_image_draw(Evas_GL_Context *gc, RGBA_Draw_Context *dc, Evas_GL_Image *im, int sx, int sy, int sw, int sh, int dx, int dy, int dw, int dh, int smooth);
void evas_gl_common_line_draw(Evas_GL_Context *gc, RGBA_Draw_Context *dc, int x1, int y1, int x2, int y2);
void evas_gl_common_poly_draw(Evas_GL_Context *gc, RGBA_Draw_Context *dc, Evas_GL_Polygon *poly);
void evas_gl_common_gradient_draw(Evas_GL_Context *gc, RGBA_Draw_Context *dc, Evas_GL_Gradient *gr, int x, int y, int w, int h, double angle);
/* FIXME:
*
* for images:
* speculative cache for textures too
* texture mesh support
*
* for text/fonts:
* need to not render to a texture each time.... this is sloooooow.
* but its a "bootstrap" for just right now.
*/
#endif