forked from enlightenment/efl
evas detects gl and build in gl backend optionally if it finds it. evas will
fall back to stfware imlib2 rendering if an app requests GL rendering.. SVN revision: 3111
This commit is contained in:
parent
bcb7bcea6c
commit
331b113f4d
|
@ -111,7 +111,11 @@ AC_CHECK_LIB(GL, glBindTexture, AC_DEFINE(HAVE_GL) ,[
|
|||
AC_CHECK_HEADER($x_includes"/GL/gl.h",
|
||||
gl_includes="-I/usr/include -I/usr/local/include -I/usr/X11R6/include/"
|
||||
AC_CHECK_LIB(GL, glBindTexture, AC_DEFINE(HAVE_GL) ,[
|
||||
echo "... no GL found"
|
||||
echo "WARNING:......."
|
||||
echo "no OpenGL libraries / headers found. This means no GL support will be"
|
||||
echo "built into Evas. This means much slower rendering perfromance."
|
||||
echo "Please read the config.log file for more information as to why this library"
|
||||
echo "was not found."
|
||||
], -L/usr/local/lib -lGL $X_LDFLAGS $X_EXTRA_LIBS $X_LIBS)
|
||||
)
|
||||
], -L/usr/local/lib -lGL $X_LDFLAGS $X_EXTRA_LIBS $X_LIBS)
|
||||
|
@ -123,7 +127,11 @@ AC_CHECK_LIB(GLU, gluBuild2DMipmaps, AC_DEFINE(HAVE_GLU) ,[
|
|||
AC_CHECK_HEADER($x_includes"/GL/glu.h",
|
||||
gl_includes=$gl_includes" -I/usr/include -I/usr/local/include -I/usr/X11R6/include/"
|
||||
AC_CHECK_LIB(GLU, gluBuild2DMipmaps, AC_DEFINE(HAVE_GLU) ,[
|
||||
echo "... no GLU found"
|
||||
echo "WARNING:......."
|
||||
echo "no libGLU was found. This means filtered (anti-aliased) scaling down"
|
||||
echo "of images will be disabled."
|
||||
echo "Please read the config.log file for more information as to why this library"
|
||||
echo "was not found."
|
||||
], -L/usr/local/lib -lGL -lGLU $X_LDFLAGS $X_EXTRA_LIBS $X_LIBS)
|
||||
)
|
||||
], -L/usr/local/lib -lGL -lGLU $X_LDFLAGS $X_EXTRA_LIBS $X_LIBS)
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef HAVE_GL
|
||||
|
||||
static int __evas_gl_configuration[] =
|
||||
{
|
||||
GLX_DOUBLEBUFFER,
|
||||
|
@ -99,12 +101,21 @@ __evas_gl_image_copy_image_rect_to_texture(Evas_GL_Image *im, int x, int y,
|
|||
glBindTexture(GL_TEXTURE_2D, texture);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
|
||||
#ifdef HAVE_GLU
|
||||
if (__evas_anti_alias)
|
||||
{
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
||||
}
|
||||
else
|
||||
#else
|
||||
if (__evas_anti_alias)
|
||||
{
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
|
@ -139,10 +150,12 @@ __evas_gl_image_copy_image_rect_to_texture(Evas_GL_Image *im, int x, int y,
|
|||
if (tx < tw)
|
||||
*p2 = p2[-1];
|
||||
}
|
||||
#ifdef HAVE_GLU
|
||||
if (__evas_anti_alias)
|
||||
gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA8, tw, th, GL_RGBA,
|
||||
GL_UNSIGNED_BYTE, data);
|
||||
else
|
||||
#endif
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, tw, th, 0,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE, data);
|
||||
free(data);
|
||||
|
@ -2074,7 +2087,15 @@ int
|
|||
__evas_gl_capable(Display *disp)
|
||||
{
|
||||
int eb, evb;
|
||||
return glXQueryExtension(disp, &eb, &evb);
|
||||
|
||||
if (__evas_gl_cx) return 1;
|
||||
if (glXQueryExtension(disp, &eb, &evb))
|
||||
{
|
||||
__evas_gl_init(disp, 0);
|
||||
if (__evas_gl_cx) return 1;
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Visual *
|
||||
|
@ -2117,7 +2138,6 @@ __evas_gl_init(Display *disp, int screen)
|
|||
{
|
||||
if (__evas_gl_cx) return;
|
||||
|
||||
if (!__evas_gl_capable(disp)) return;
|
||||
__evas_gl_get_visual(disp, screen);
|
||||
/* direct rendering client */
|
||||
__evas_gl_cx = glXCreateContext(disp, __evas_vi, NULL, GL_TRUE);
|
||||
|
@ -2132,3 +2152,66 @@ __evas_gl_draw_add_rect(Display *disp, Window win,
|
|||
return;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
/***************/
|
||||
/* image stuff */
|
||||
/***************/
|
||||
Evas_GL_Image *__evas_gl_image_new_from_file(Display *disp, char *file){return NULL;}
|
||||
void __evas_gl_image_free(Evas_GL_Image *im){}
|
||||
void __evas_gl_image_cache_empty(Display *disp){}
|
||||
void __evas_gl_image_cache_set_size(Display *disp, int size){}
|
||||
int __evas_gl_image_cache_get_size(Display *disp){return 0;}
|
||||
int __evas_gl_image_get_width(Evas_GL_Image *im){return 0;}
|
||||
int __evas_gl_image_get_height(Evas_GL_Image *im){return 0;}
|
||||
void __evas_gl_image_set_borders(Evas_GL_Image *im, int left, int right, int top, int bottom){}
|
||||
void __evas_gl_image_set_smooth_scaling(int on){}
|
||||
void __evas_gl_image_draw(Evas_GL_Image *im, Display *disp, Window w, int win_w, int win_h, int src_x, int src_y, int src_w, int src_h, int dst_x, int dst_y, int dst_w, int dst_h){}
|
||||
|
||||
/********/
|
||||
/* text */
|
||||
/********/
|
||||
Evas_GL_Font *__evas_gl_text_font_new(Display *disp, char *font, int size){return NULL;}
|
||||
void __evas_gl_text_font_free(Evas_GL_Font *fn){}
|
||||
void __evas_gl_text_font_add_path(char *path){}
|
||||
void __evas_gl_text_font_del_path(char *path){}
|
||||
char **__evas_gl_text_font_list_paths(int *count){return NULL;}
|
||||
void __evas_gl_text_cache_empty(Display *disp){}
|
||||
void __evas_gl_text_cache_set_size(Display *disp, int size){}
|
||||
int __evas_gl_text_cache_get_size(Display *disp){return 0;}
|
||||
void __evas_gl_text_get_size(Evas_GL_Font *fn, char *text, int *w, int *h){}
|
||||
int __evas_gl_text_get_character_at_pos(Evas_GL_Font *fn, char *text, int x, int y, int *cx, int *cy, int *cw, int *ch){return 0;}
|
||||
void __evas_gl_text_get_character_number(Evas_GL_Font *fn, char *text, int num, int *cx, int *cy, int *cw, int *ch){}
|
||||
void __evas_gl_text_draw(Evas_GL_Font *fn, Display *disp, Window win, int win_w, int win_h, int x, int y, char *text, int r, int g, int b, int a){}
|
||||
|
||||
/**************/
|
||||
/* rectangles */
|
||||
/**************/
|
||||
void __evas_gl_rectangle_draw(Display *disp, Window win, int win_w, int win_h, int x, int y, int w, int h, int r, int g, int b, int a){}
|
||||
|
||||
/*********/
|
||||
/* lines */
|
||||
/*********/
|
||||
void __evas_gl_line_draw(Display *disp, Window win, int win_w, int win_h, int x1, int y1, int x2, int y2, int r, int g, int b, int a){}
|
||||
|
||||
/*************/
|
||||
/* gradients */
|
||||
/*************/
|
||||
Evas_GL_Graident *__evas_gl_gradient_new(Display *disp){return NULL;}
|
||||
void __evas_gl_gradient_free(Evas_GL_Graident *gr){}
|
||||
void __evas_gl_gradient_color_add(Evas_GL_Graident *gr, int r, int g, int b, int a, int dist){}
|
||||
void __evas_gl_gradient_draw(Evas_GL_Graident *gr, Display *disp, Window win, int win_w, int win_h, int x, int y, int w, int h, double angle){}
|
||||
|
||||
/***********/
|
||||
/* drawing */
|
||||
/***********/
|
||||
void __evas_gl_init(Display *disp, int screen){}
|
||||
int __evas_gl_capable(Display *disp){return 0;}
|
||||
void __evas_gl_flush_draw(Display *disp, Window win){}
|
||||
void __evas_gl_sync(Display *disp){}
|
||||
Visual *__evas_gl_get_visual(Display *disp, int screen){return NULL;}
|
||||
XVisualInfo *__evas_gl_get_visual_info(Display *disp, int screen){return NULL;}
|
||||
Colormap __evas_gl_get_colormap(Display *disp, int screen){return 0;}
|
||||
void __evas_gl_draw_add_rect(Display *disp, Window win, int x, int y, int w, int h){}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include <config.h>
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -7,12 +7,20 @@
|
|||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef HAVE_GL
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glx.h>
|
||||
#ifdef HAVE_GLU
|
||||
#include <GL/glu.h>
|
||||
#endif
|
||||
#else
|
||||
typedef int GLXContext;
|
||||
typedef int GLuint;
|
||||
#endif
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/Xmu/StdCmap.h>
|
||||
|
||||
#ifdef HAVE_FREETYPE_FREETYPE_H
|
||||
|
|
|
@ -26,9 +26,13 @@ evas_free(Evas e)
|
|||
|
||||
for (l = e->layers; l; l = l->next)
|
||||
{
|
||||
/* FIXME: free layer */
|
||||
Evas_Layer layer;
|
||||
|
||||
layer = l->data;
|
||||
_evas_layer_free(layer);
|
||||
}
|
||||
if (e->layers) evas_list_free(e->layers);
|
||||
if (e->updates) imlib_updates_free(e->updates);
|
||||
free(e);
|
||||
}
|
||||
|
||||
|
|
|
@ -39,6 +39,26 @@ _evas_real_del_object(Evas e, Evas_Object o)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
_evas_layer_free(Evas e, Evas_Layer layer)
|
||||
{
|
||||
if (layer->objects)
|
||||
{
|
||||
Evas_List l;
|
||||
|
||||
for (l = layer->objects; l; l = l->next)
|
||||
{
|
||||
Evas_Object o;
|
||||
|
||||
o = l->data;
|
||||
o->object_renderer_data_free(e, o);
|
||||
o->object_free(o);
|
||||
}
|
||||
evas_list_free(layer->objects);
|
||||
}
|
||||
free(layer);
|
||||
}
|
||||
|
||||
/* deleting objects */
|
||||
void
|
||||
evas_del_object(Evas e, Evas_Object o)
|
||||
|
@ -49,15 +69,63 @@ evas_del_object(Evas e, Evas_Object o)
|
|||
|
||||
/* layer stacking for object */
|
||||
void
|
||||
evas_set_layer(Evas e, Evas_Object o, int l)
|
||||
evas_set_layer(Evas e, Evas_Object o, int layer_num)
|
||||
{
|
||||
Evas_Layer layer;
|
||||
Evas_List l;
|
||||
|
||||
if (layer_num == o->current.layer) return;
|
||||
|
||||
o->changed = 1;
|
||||
e->changed = 1;
|
||||
for (l = e->layers; l; l = l->next)
|
||||
{
|
||||
layer = l->data;
|
||||
if (layer->layer == o->current.layer)
|
||||
{
|
||||
layer->objects = evas_list_remove(layer->objects, o);
|
||||
if (!layer->objects)
|
||||
{
|
||||
e->layers = evas_list_remove(e->layers, layer);
|
||||
_evas_layer_free(e, layer);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
o->current.layer = layer_num;
|
||||
for (l = e->layers; l; l = l->next)
|
||||
{
|
||||
layer = l->data;
|
||||
if (layer->layer == o->current.layer)
|
||||
{
|
||||
layer->objects = evas_list_append(layer->objects, o);
|
||||
break;
|
||||
}
|
||||
if (layer->layer > o->current.layer)
|
||||
{
|
||||
Evas_Layer layer_new;
|
||||
|
||||
layer_new = malloc(sizeof(struct _Evas_Layer));
|
||||
memset(layer_new, 0, sizeof(struct _Evas_Layer));
|
||||
e->layers = evas_list_prepend_relative(e->layers, layer_new, layer);
|
||||
layer_new->objects = evas_list_append(layer_new->objects, o);
|
||||
layer_new->layer = o->current.layer;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
layer = malloc(sizeof(struct _Evas_Layer));
|
||||
memset(layer, 0, sizeof(struct _Evas_Layer));
|
||||
e->layers = evas_list_append(e->layers, layer);
|
||||
layer->objects = evas_list_append(layer->objects, o);
|
||||
layer->layer = o->current.layer;
|
||||
}
|
||||
|
||||
void
|
||||
evas_set_layer_store(Evas e, int l, int store)
|
||||
{
|
||||
e->changed = 1;
|
||||
/* FIXME: find layer and set store flag */
|
||||
/* e->changed = 1; */
|
||||
}
|
||||
|
||||
/* stacking within a layer */
|
||||
|
|
|
@ -496,12 +496,22 @@ evas_get_optimal_visual(Evas e, Display *disp)
|
|||
switch (e->current.render_method)
|
||||
{
|
||||
case RENDER_METHOD_ALPHA_SOFTWARE:
|
||||
return __evas_imlib_get_visual(disp, e->current.screen);
|
||||
if (__evas_imlib_capable(disp))
|
||||
return __evas_imlib_get_visual(disp, e->current.screen);
|
||||
else
|
||||
{
|
||||
}
|
||||
break;
|
||||
case RENDER_METHOD_BASIC_HARDWARE:
|
||||
break;
|
||||
case RENDER_METHOD_3D_HARDWARE:
|
||||
return __evas_gl_get_visual(disp, e->current.screen);
|
||||
if (__evas_gl_capable(disp))
|
||||
return __evas_gl_get_visual(disp, e->current.screen);
|
||||
else
|
||||
{
|
||||
e->current.render_method = RENDER_METHOD_ALPHA_SOFTWARE;
|
||||
return evas_get_optimal_visual(e, disp);
|
||||
}
|
||||
break;
|
||||
case RENDER_METHOD_ALPHA_HARDWARE:
|
||||
break;
|
||||
|
@ -509,6 +519,7 @@ evas_get_optimal_visual(Evas e, Display *disp)
|
|||
return NULL;
|
||||
break;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Colormap
|
||||
|
@ -517,12 +528,22 @@ evas_get_optimal_colormap(Evas e, Display *disp)
|
|||
switch (e->current.render_method)
|
||||
{
|
||||
case RENDER_METHOD_ALPHA_SOFTWARE:
|
||||
return __evas_imlib_get_colormap(disp, e->current.screen);
|
||||
if (__evas_imlib_capable(disp))
|
||||
return __evas_imlib_get_colormap(disp, e->current.screen);
|
||||
else
|
||||
{
|
||||
}
|
||||
break;
|
||||
case RENDER_METHOD_BASIC_HARDWARE:
|
||||
break;
|
||||
case RENDER_METHOD_3D_HARDWARE:
|
||||
return __evas_gl_get_colormap(disp, e->current.screen);
|
||||
if (__evas_gl_capable(disp))
|
||||
return __evas_gl_get_colormap(disp, e->current.screen);
|
||||
else
|
||||
{
|
||||
e->current.render_method = RENDER_METHOD_ALPHA_SOFTWARE;
|
||||
return evas_get_optimal_colormap(e, disp);
|
||||
}
|
||||
break;
|
||||
case RENDER_METHOD_ALPHA_HARDWARE:
|
||||
break;
|
||||
|
@ -530,6 +551,7 @@ evas_get_optimal_colormap(Evas e, Display *disp)
|
|||
return 0;
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* the output settings */
|
||||
|
@ -564,8 +586,11 @@ evas_set_output_viewport(Evas e, double x, double y, double w, double h)
|
|||
void
|
||||
evas_set_output_method(Evas e, Evas_Render_Method method)
|
||||
{
|
||||
e->current.render_method = method;
|
||||
e->changed = 1;
|
||||
if (!e->current.display)
|
||||
{
|
||||
e->current.render_method = method;
|
||||
e->changed = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -1,16 +1,6 @@
|
|||
LIBS_X = @x_ldflags@ @x_libs@
|
||||
LIBS_IMLIB2 = -lImlib2 -lttf -ldl -lm
|
||||
LIBS_DB = -ledb
|
||||
LIBS_GL = -lGLU -lGL
|
||||
LIBS_EXTRA = -L/usr/local/lib
|
||||
|
||||
CFLAGS_X = @x_cflags@
|
||||
CFLAGS_IMLIB2 =
|
||||
CFLAGS_DB =
|
||||
CFLAGS_GL = @gl_includes@
|
||||
CFLAGS_EXTRA = -I$(includedir) -I$(top_srcdir) -I$(top_srcdir)/src -I/usr/local/include
|
||||
|
||||
LIBS_ALL = $(LIBS_X) $(LIBS_IMLIB2) $(LIBS_DB) $(LIBS_GL) $(LIBS_EXTRA)
|
||||
CFLGAS_ALL = $(CFLAGS_X) $(CFLAGS_IMLIB2) $(CFLAGS_DB) $(CFLAGS_GL) $(CFLAGS_EXTRA)
|
||||
|
||||
INCLUDES = $(CFLGAS_ALL)
|
||||
|
|
|
@ -84,6 +84,7 @@ main(int argc, char **argv)
|
|||
evas_raise(e, o[1]);
|
||||
evas_move(e, o[0], 0, 0);
|
||||
evas_resize(e, o[0], win_w, win_h);
|
||||
evas_set_image_fill(e, o[0], 0, 0, win_w, win_h);
|
||||
a = 0;
|
||||
down = 0;
|
||||
for (;;)
|
||||
|
|
Loading…
Reference in New Issue