Glew OpenGL engine added. Windows can have an opengl engine thgough the Glew library, now. See INSTALL note

SVN revision: 31180
This commit is contained in:
doursse 2007-08-05 07:22:44 +00:00 committed by doursse
parent 4b435be1ed
commit 31c47b3461
13 changed files with 1196 additions and 9 deletions

View File

@ -12,3 +12,4 @@ Bernhard Nemec <Bernhard.Nemec@viasyshc.com>
Jorge Luis Zapata Muga <jorgeluis.zapata@gmail.com>
Cedric Bail <cedric.bail@free.fr>
Gustavo Sverzut Barbieri <barbieri@gmail.com>
Vincent Torri <vtorri at univ-evry dot fr>

View File

@ -11,3 +11,7 @@ NOTE: for compilation with MinGW, fnmatch.h is probably missing.
That file can be found here:
http://www.koders.com/c/fid2B518462CB1EED3D4E31E271DB83CD1582F6EEBE.aspx
It should be installed in the mingw include directory.
NOTE: for the OpenGL engine on Windows, the glew library:
http://glew.sourceforge.net/
is needed.

View File

@ -236,7 +236,7 @@ fi
AM_CONDITIONAL(BUILD_ENGINE_SOFTWARE_X11, test "x$have_evas_software_x11" = "xyes")
#######################################
## Check if we should build the software_x11 engine
## Check if we should build the software_x11 16bit engine
have_evas_software_16_x11="no";
## Automatic check...
# -- disable software_16 by default - its usefulness as a speedup in 16bit
@ -603,9 +603,54 @@ else
fi
#######################################
## Check if we should build the gl_glew engine
have_evas_gl_glew="no";
## Automatic check...
AC_CHECK_HEADERS(GL/glew.h,
[ have_evas_gl_glew="yes" ],
[ have_evas_gl_glew="no" ],
[
#include <windows.h>
]
)
## manually disable gl engine by default - not auto detected.
have_evas_gl_glew="no"
## Manual override
AC_MSG_CHECKING(whether gl glew backend is to be built)
AC_ARG_ENABLE(gl-glew, [ --enable-gl-glew enable the OpenGL Glew display engine], [
if test x"$enableval" = x"yes" ; then
have_evas_gl_glew="yes"
else
have_evas_gl_glew="no"
fi
]
)
AC_MSG_RESULT($have_evas_gl_glew)
if test "x$have_evas_gl_glew" = "xyes"; then
AC_CHECK_HEADER(GL/glew.h,
[
AC_DEFINE(BUILD_ENGINE_GL_GLEW, 1, [OpenGL Glew Rendering Backend])
AC_DEFINE(BUILD_ENGINE_GL_COMMON, 1, [Generic OpenGL Rendering Support])
glew_libs="-lglew32 -lopengl32 -lgdi32"
gl_libs="-lglu32"
], [
have_evas_gl_glew="no"
],
[
#include <windows.h>
]
)
fi
AM_CONDITIONAL(BUILD_ENGINE_GL_GLEW, test "x$have_evas_gl_glew" = "xyes")
AM_CONDITIONAL(BUILD_ENGINE_GL_COMMON, test "x$have_evas_gl_glew" = "xyes")
#######################################
## Check if we should build the gl_x11 engine
## Check if we should build the cairo_x11 engine
have_evas_cairo_x11="no";
# Automatic check...
#PKG_CHECK_MODULES(CAIRO, cairo >= 1.0.0,
@ -2068,6 +2113,8 @@ AC_SUBST(VALGRIND_CFLAGS)
AC_SUBST(ddraw_libs)
AC_SUBST(glew_libs)
AC_SUBST(x_cflags)
AC_SUBST(x_libs)
@ -2111,6 +2158,7 @@ evas-cairo-x11.pc
evas-directfb.pc
evas-framebuffer.pc
evas-glitz-x11.pc
evas-opengl-glew.pc
evas-opengl-x11.pc
evas-software-buffer.pc
evas-software-qtopia.pc
@ -2148,6 +2196,7 @@ src/modules/engines/software_win32_gdi/Makefile
src/modules/engines/software_qtopia/Makefile
src/modules/engines/directfb/Makefile
src/modules/engines/gl_common/Makefile
src/modules/engines/gl_glew/Makefile
src/modules/engines/gl_x11/Makefile
src/modules/engines/cairo_common/Makefile
src/modules/engines/cairo_x11/Makefile
@ -2199,6 +2248,7 @@ echo " Software Qtopia.........: $have_evas_qtopia"
echo " Software Memory Buffer..: $have_evas_buffer"
echo " DirectFB................: $have_evas_directfb"
echo " SDL.....................: $have_evas_sdl"
echo " OpenGL Glew.............: $have_evas_gl_glew"
echo " OpenGL X11..............: $have_evas_gl_x11"
echo " Cairo X11...............: $have_evas_cairo_x11"
echo " XRender X11.............: $have_evas_xrender_x11"

View File

@ -0,0 +1,3 @@
Name: evas-opengl-glew
Description: Evas OpenGL Glew engine
Version: @VERSION@

View File

@ -13,6 +13,7 @@
@author Yuri Hudobin <glassy_ape\@users.sourceforge.net>
@author Nathan Ingersoll <ningerso\@d.umn.edu>
@author Willem Monsuwe <willem\@stack.nl>
@author Vincent Torri <vtorri at univ-evry dot fr>
@date 2000-2003
@section intro What is Evas?
@ -200,16 +201,14 @@ make install
@todo (1.2) Add loadable image loader module support (evas loads file.so)
@todo (1.2) Add external image lodaer modules (application proivdes path to file.so)
@todo (1.3) Add X11 primtive engine (ie pixmap)
@todo (1.3) Add Xrender engine (once xrender works fast/well)
@todo (1.3) Add immediate mode drawing commands to image objects
@todo (1.3) Fix FB engine to allocate vt and release properly
@todo (1.4) Add SDL Engine
@todo (1.4) Add ellipse objects (circle, arc, ellipse etc.)
@todo (1.5) Make software engine draw lines & polys etc. with aa
@todo (1.5) Add radial gradients to gradient objects
@todo (1.5) Add Symbian Engine
@todo (1.6) Add PalmOS Engine
@todo (1.6) Add Win32 OpenGL Engine
@todo (1.6) Add Win32 Direct3D Engine
@todo (1.6) Add Apple OpenGL Engine
@todo (1.7) Document engine API and other internals
@todo (1.7) Allow any object to clip any other object, and not just rectangles

View File

@ -724,6 +724,9 @@ evas_render_method_list(void)
#ifdef BUILD_ENGINE_GL_X11
methods = evas_list_append(methods, strdup("gl_x11"));
#endif
#ifdef BUILD_ENGINE_GL_GLEW
methods = evas_list_append(methods, strdup("gl_glew"));
#endif
#ifdef BUILD_ENGINE_CAIRO_X11
methods = evas_list_append(methods, strdup("cairo_x11"));
#endif

View File

@ -9,6 +9,7 @@ directfb \
fb \
gl_common \
gl_x11 \
gl_glew \
software_qtopia \
software_win32_gdi \
software_ddraw \

View File

@ -20,13 +20,18 @@
#include <sys/time.h>
#include <unistd.h>
#ifndef WIN32
# include <X11/Xlib.h>
# include <X11/Xatom.h>
# include <X11/Xutil.h>
#else
# include <windows.h>
# include <GL/glew.h>
#endif /* WIN32 */
#include <GL/gl.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;

View File

@ -0,0 +1,24 @@
#ifndef __EVAS_ENGINE_GL_GLEW_H__
#define __EVAS_ENGINE_GL_GLEW_H__
#include <windows.h>
typedef struct _Evas_Engine_Info_GL_Glew Evas_Engine_Info_GL_Glew;
struct _Evas_Engine_Info_GL_Glew
{
/* PRIVATE - don't mess with this baby or evas will poke its tongue out */
/* at you and make nasty noises */
Evas_Engine_Info magic;
/* engine specific data & parameters it needs to set up */
struct {
HDC dc;
HWND window;
int depth;
} info;
};
#endif /* __EVAS_ENGINE_GL_GLEW_H__ */

View File

@ -0,0 +1,30 @@
AUTOMAKE_OPTIONS = 1.4 foreign
MAINTAINERCLEANFILES = Makefile.in
INCLUDES = -I. -I$(top_srcdir)/src/lib -I$(top_srcdir)/src/lib/include -I$(top_srcdir)/src/modules/engines/gl_common @FREETYPE_CFLAGS@
if BUILD_ENGINE_GL_GLEW
pkgdir = $(libdir)/evas/modules/engines/gl_glew/$(MODULE_ARCH)
pkg_LTLIBRARIES = module.la
module_la_SOURCES = \
evas_engine.h \
evas_engine.c \
evas_glew_main.c
module_la_LIBADD = $(top_builddir)/src/modules/engines/gl_common/libevas_engine_gl_common.la $(top_builddir)/src/lib/libevas.la @gl_libs@ @glew_libs@
module_la_LDFLAGS = @create_shared_lib@ -module -avoid-version -L$(top_builddir)/src/lib -L$(top_builddir)/src/lib/.libs
module_la_DEPENDENCIES = $(top_builddir)/config.h
include_HEADERS = Evas_Engine_GL_Glew.h
endif
EXTRA_DIST = \
evas_engine.h \
evas_engine.c \
evas_glew_main.c \
Evas_Engine_GL_Glew.h

View File

@ -0,0 +1,957 @@
#include "evas_engine.h"
#include "Evas_Engine_GL_Glew.h"
/* function tables - filled in later (func and parent func) */
static Evas_Func func, pfunc;
typedef struct _Render_Engine Render_Engine;
struct _Render_Engine
{
Evas_GL_Glew_Window *window;
int end;
};
static void *
eng_info(Evas *e)
{
Evas_Engine_Info_GL_Glew *info;
info = calloc(1, sizeof(Evas_Engine_Info_GL_Glew));
if (!info) return NULL;
info->magic.magic = rand();
return info;
e = NULL;
}
static void
eng_info_free(Evas *e, void *info)
{
Evas_Engine_Info_GL_Glew *in;
in = (Evas_Engine_Info_GL_Glew *)info;
free(in);
}
static void
eng_setup(Evas *e, void *in)
{
Render_Engine *re;
Evas_Engine_Info_GL_Glew *info;
info = (Evas_Engine_Info_GL_Glew *)in;
if (!e->engine.data.output)
{
re = calloc(1, sizeof(Render_Engine));
if (!re) return;
e->engine.data.output = re;
re->window = eng_window_new(info->info.dc,
info->info.window,
info->info.depth,
e->output.w,
e->output.h);
if (!re->window)
{
free(re);
e->engine.data.output = NULL;
return;
}
evas_common_cpu_init();
evas_common_blend_init();
evas_common_image_init();
evas_common_convert_init();
evas_common_scale_init();
evas_common_rectangle_init();
evas_common_gradient_init();
evas_common_polygon_init();
evas_common_line_init();
evas_common_font_init();
evas_common_draw_init();
evas_common_tilebuf_init();
}
else
{
re = e->engine.data.output;
eng_window_free(re->window);
re->window = eng_window_new(info->info.dc,
info->info.window,
info->info.depth,
e->output.w,
e->output.h);
}
if (!e->engine.data.output) return;
if (!e->engine.data.context)
e->engine.data.context =
e->engine.func->context_new(e->engine.data.output);
}
static void
eng_output_free(void *data)
{
Render_Engine *re;
re = (Render_Engine *)data;
eng_window_free(re->window);
free(re);
evas_common_font_shutdown();
evas_common_image_shutdown();
}
static void
eng_output_resize(void *data, int w, int h)
{
Render_Engine *re;
re = (Render_Engine *)data;
re->window->width = w;
re->window->height = h;
evas_gl_common_context_resize(re->window->gl_context, w, h);
}
static void
eng_output_tile_size_set(void *data, int w, int h)
{
Render_Engine *re;
re = (Render_Engine *)data;
}
static void
eng_output_redraws_rect_add(void *data, int x, int y, int w, int h)
{
Render_Engine *re;
re = (Render_Engine *)data;
evas_gl_common_context_resize(re->window->gl_context, re->window->width, re->window->height);
/* simple bounding box */
if (!re->window->draw.redraw)
{
#if 0
re->window->draw.x1 = x;
re->window->draw.y1 = y;
re->window->draw.x2 = x + w - 1;
re->window->draw.y2 = y + h - 1;
#else
re->window->draw.x1 = 0;
re->window->draw.y1 = 0;
re->window->draw.x2 = re->window->width - 1;
re->window->draw.y2 = re->window->height - 1;
#endif
}
else
{
if (x < re->window->draw.x1) re->window->draw.x1 = x;
if (y < re->window->draw.y1) re->window->draw.y1 = y;
if ((x + w - 1) > re->window->draw.x2) re->window->draw.x2 = x + w - 1;
if ((y + h - 1) > re->window->draw.y2) re->window->draw.y2 = y + h - 1;
}
re->window->draw.redraw = 1;
}
static void
eng_output_redraws_rect_del(void *data, int x, int y, int w, int h)
{
Render_Engine *re;
re = (Render_Engine *)data;
}
static void
eng_output_redraws_clear(void *data)
{
Render_Engine *re;
re = (Render_Engine *)data;
re->window->draw.redraw = 0;
}
#define SLOW_GL_COPY_RECT 1
static void *
eng_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;
re = (Render_Engine *)data;
/* get the upate rect surface - return engine data as dummy */
if (!re->window->draw.redraw)
{
// printf("GL: NO updates!\n");
return NULL;
}
// printf("GL: update....!\n");
#ifdef SLOW_GL_COPY_RECT
/* if any update - just return the whole canvas - works with swap
* buffers then */
if (x) *x = 0;
if (y) *y = 0;
if (w) *w = re->window->width;
if (h) *h = re->window->height;
if (cx) *cx = 0;
if (cy) *cy = 0;
if (cw) *cw = re->window->width;
if (ch) *ch = re->window->height;
#else
/* 1 update - INCREDIBLY SLOW if combined with swap_rect in flush. a gl
* problem where there just is no hardware path for somethnig that
* obviously SHOULD be there */
/* only 1 update to minimise gl context games and rendering multiple update
* regions as evas does with other engines
*/
if (x) *x = re->window->draw.x1;
if (y) *y = re->window->draw.y1;
if (w) *w = re->window->draw.x2 - re->window->draw.x1 + 1;
if (h) *h = re->window->draw.y2 - re->window->draw.y1 + 1;
if (cx) *cx = re->window->draw.x1;
if (cy) *cy = re->window->draw.y1;
if (cw) *cw = re->window->draw.x2 - re->window->draw.x1 + 1;
if (ch) *ch = re->window->draw.y2 - re->window->draw.y1 + 1;
#endif
return re;
}
static void
eng_output_redraws_next_update_push(void *data, void *surface, int x, int y, int w, int h)
{
Render_Engine *re;
re = (Render_Engine *)data;
/* put back update surface.. in this case just unflag redraw */
re->window->draw.redraw = 0;
re->window->draw.drew = 1;
}
static void
eng_output_flush(void *data)
{
Render_Engine *re;
re = (Render_Engine *)data;
if (!re->window->draw.drew) return;
re->window->draw.drew = 0;
eng_window_use(re->window);
#ifdef SLOW_GL_COPY_RECT
SwapBuffers(re->window->dc);
#else
/* SLOW AS ALL HELL */
evas_gl_common_swap_rect(re->window->gl_context,
re->window->draw.x1, re->window->draw.y1,
re->window->draw.x2 - re->window->draw.x1 + 1,
re->window->draw.y2 - re->window->draw.y1 + 1);
#endif
}
static void
eng_output_idle_flush(void *data)
{
Render_Engine *re;
re = (Render_Engine *)data;
}
static void
eng_context_cutout_add(void *data, void *context, int x, int y, int w, int h)
{
Render_Engine *re;
re = (Render_Engine *)data;
/* not used in gl engine */
}
static void
eng_context_cutout_clear(void *data, void *context)
{
Render_Engine *re;
re = (Render_Engine *)data;
/* not used in gl engine */
}
static void
eng_rectangle_draw(void *data, void *context, void *surface, int x, int y, int w, int h)
{
Render_Engine *re;
re = (Render_Engine *)data;
eng_window_use(re->window);
re->window->gl_context->dc = context;
evas_gl_common_rect_draw(re->window->gl_context, x, y, w, h);
}
static void
eng_line_draw(void *data, void *context, void *surface, int x1, int y1, int x2, int y2)
{
Render_Engine *re;
re = (Render_Engine *)data;
re->window->gl_context->dc = context;
evas_gl_common_line_draw(re->window->gl_context, x1, y1, x2, y2);
}
static void *
eng_polygon_point_add(void *data, void *context, void *polygon, int x, int y)
{
Render_Engine *re;
re = (Render_Engine *)data;
return evas_gl_common_poly_point_add(polygon, x, y);
}
static void *
eng_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
eng_polygon_draw(void *data, void *context, void *surface, void *polygon)
{
Render_Engine *re;
re = (Render_Engine *)data;
re->window->gl_context->dc = context;
evas_gl_common_poly_draw(re->window->gl_context, polygon);
}
static void *
eng_gradient_new(void *data)
{
return evas_gl_common_gradient_new();
}
static void
eng_gradient_color_stop_add(void *data, void *gradient, int r, int g, int b, int a, int delta)
{
evas_gl_common_gradient_color_stop_add(gradient, r, g, b, a, delta);
}
static void
eng_gradient_alpha_stop_add(void *data, void *gradient, int a, int delta)
{
evas_gl_common_gradient_alpha_stop_add(gradient, a, delta);
}
static void
eng_gradient_clear(void *data, void *gradient)
{
evas_gl_common_gradient_clear(gradient);
}
static void
eng_gradient_color_data_set(void *data, void *gradient, void *map, int len, int has_alpha)
{
evas_gl_common_gradient_color_data_set(gradient, map, len, has_alpha);
}
static void
eng_gradient_alpha_data_set(void *data, void *gradient, void *alpha_map, int len)
{
evas_gl_common_gradient_alpha_data_set(gradient, alpha_map, len);
}
static void
eng_gradient_free(void *data, void *gradient)
{
evas_gl_common_gradient_free(gradient);
}
static void
eng_gradient_fill_set(void *data, void *gradient, int x, int y, int w, int h)
{
evas_gl_common_gradient_fill_set(gradient, x, y, w, h);
}
static void
eng_gradient_fill_angle_set(void *data, void *gradient, double angle)
{
evas_gl_common_gradient_fill_angle_set(gradient, angle);
}
static void
eng_gradient_fill_spread_set(void *data, void *gradient, int spread)
{
evas_gl_common_gradient_fill_spread_set(gradient, spread);
}
static void
eng_gradient_angle_set(void *data, void *gradient, double angle)
{
evas_gl_common_gradient_map_angle_set(gradient, angle);
}
static void
eng_gradient_offset_set(void *data, void *gradient, float offset)
{
evas_gl_common_gradient_map_offset_set(gradient, offset);
}
static void
eng_gradient_direction_set(void *data, void *gradient, int direction)
{
evas_gl_common_gradient_map_direction_set(gradient, direction);
}
static void
eng_gradient_type_set(void *data, void *gradient, char *name, char *params)
{
evas_gl_common_gradient_type_set(gradient, name, params);
}
static int
eng_gradient_is_opaque(void *data, void *context, void *gradient, int x, int y, int w, int h)
{
Render_Engine *re = (Render_Engine *)data;
re->window->gl_context->dc = context;
return evas_gl_common_gradient_is_opaque(re->window->gl_context, gradient, x, y, w, h);
}
static int
eng_gradient_is_visible(void *data, void *context, void *gradient, int x, int y, int w, int h)
{
Render_Engine *re = (Render_Engine *)data;
re->window->gl_context->dc = context;
return evas_gl_common_gradient_is_visible(re->window->gl_context, gradient, x, y, w, h);
}
static void
eng_gradient_render_pre(void *data, void *context, void *gradient)
{
Render_Engine *re = (Render_Engine *)data;
re->window->gl_context->dc = context;
evas_gl_common_gradient_render_pre(re->window->gl_context, gradient);
}
static void
eng_gradient_render_post(void *data, void *gradient)
{
evas_gl_common_gradient_render_post(gradient);
}
static void
eng_gradient_draw(void *data, void *context, void *surface, void *gradient, int x, int y, int w, int h)
{
Render_Engine *re;
re = (Render_Engine *)data;
eng_window_use(re->window);
re->window->gl_context->dc = context;
evas_gl_common_gradient_draw(re->window->gl_context, gradient, x, y, w, h);
}
static int
eng_image_alpha_get(void *data, void *image)
{
Render_Engine *re;
Evas_GL_Image *im;
re = (Render_Engine *)data;
if (!image) return 1;
im = image;
/* FIXME: can move to gl_common */
switch (im->cs.space)
{
case EVAS_COLORSPACE_ARGB8888:
if (im->im->flags & RGBA_IMAGE_HAS_ALPHA) return 1;
default:
break;
}
return 0;
}
static int
eng_image_colorspace_get(void *data, void *image)
{
Render_Engine *re;
Evas_GL_Image *im;
re = (Render_Engine *)data;
if (!image) return EVAS_COLORSPACE_ARGB8888;
im = image;
return im->cs.space;
}
static void *
eng_image_alpha_set(void *data, void *image, int has_alpha)
{
Render_Engine *re;
Evas_GL_Image *im;
re = (Render_Engine *)data;
if (!image) return NULL;
eng_window_use(re->window);
im = image;
/* FIXME: can move to gl_common */
if (im->cs.space != EVAS_COLORSPACE_ARGB8888) return im;
if ((has_alpha) && (im->im->flags & RGBA_IMAGE_HAS_ALPHA)) return image;
else if ((!has_alpha) && (!(im->im->flags & RGBA_IMAGE_HAS_ALPHA))) return 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,
eng_image_alpha_get(data, image),
eng_image_colorspace_get(data, image));
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;
}
static void *
eng_image_border_set(void *data, void *image, int l, int r, int t, int b)
{
Render_Engine *re;
re = (Render_Engine *)data;
return image;
}
static void
eng_image_border_get(void *data, void *image, int *l, int *r, int *t, int *b)
{
Render_Engine *re;
re = (Render_Engine *)data;
}
static char *
eng_image_comment_get(void *data, void *image, char *key)
{
Render_Engine *re;
Evas_GL_Image *im;
re = (Render_Engine *)data;
if (!image) return NULL;
im = image;
return im->im->info.comment;
}
static char *
eng_image_format_get(void *data, void *image)
{
Render_Engine *re;
Evas_GL_Image *im;
re = (Render_Engine *)data;
im = image;
return NULL;
}
static void
eng_image_colorspace_set(void *data, void *image, int cspace)
{
Render_Engine *re;
Evas_GL_Image *im;
re = (Render_Engine *)data;
if (!image) return;
im = image;
/* FIXME: can move to gl_common */
if (im->cs.space == cspace) return;
switch (cspace)
{
case EVAS_COLORSPACE_ARGB8888:
if (im->cs.data)
{
if (!im->cs.no_free) free(im->cs.data);
im->cs.data = NULL;
im->cs.no_free = 0;
}
if (!im->im->image->no_free)
evas_common_image_surface_alloc(im->im->image);
break;
case EVAS_COLORSPACE_YCBCR422P601_PL:
case EVAS_COLORSPACE_YCBCR422P709_PL:
evas_common_image_surface_dealloc(im->im->image);
im->im->image->data = NULL;
if (im->tex) evas_gl_common_texture_free(im->tex);
im->tex = NULL;
if (im->cs.data)
{
if (!im->cs.no_free) free(im->cs.data);
}
im->cs.data = calloc(1, im->im->image->h * sizeof(unsigned char *) * 2);
im->cs.no_free = 0;
break;
default:
abort();
break;
}
im->cs.space = cspace;
}
static void
eng_image_native_set(void *data, void *image, void *native)
{
}
static void *
eng_image_native_get(void *data, void *image)
{
return NULL;
}
static void *
eng_image_load(void *data, const char *file, const char *key, int *error, Evas_Image_Load_Opts *lo)
{
Render_Engine *re;
re = (Render_Engine *)data;
if (!re)
printf ("MERDE2\n");
*error = 0;
eng_window_use(re->window);
return evas_gl_common_image_load(re->window->gl_context, file, key, lo);
}
static void *
eng_image_new_from_data(void *data, int w, int h, DATA32 *image_data, int alpha, int cspace)
{
Render_Engine *re;
re = (Render_Engine *)data;
eng_window_use(re->window);
return evas_gl_common_image_new_from_data(re->window->gl_context, w, h, image_data, alpha, cspace);
}
static void *
eng_image_new_from_copied_data(void *data, int w, int h, DATA32 *image_data, int alpha, int cspace)
{
Render_Engine *re;
re = (Render_Engine *)data;
eng_window_use(re->window);
return evas_gl_common_image_new_from_copied_data(re->window->gl_context, w, h, image_data, alpha, cspace);
}
static void
eng_image_free(void *data, void *image)
{
Render_Engine *re;
re = (Render_Engine *)data;
if (!image) return;
eng_window_use(re->window);
evas_gl_common_image_free(image);
}
static void
eng_image_size_get(void *data, void *image, int *w, int *h)
{
Render_Engine *re;
re = (Render_Engine *)data;
if (!image)
{
*w = 0;
*h = 0;
return;
}
if (w) *w = ((Evas_GL_Image *)image)->im->image->w;
if (h) *h = ((Evas_GL_Image *)image)->im->image->h;
}
static void *
eng_image_size_set(void *data, void *image, int w, int h)
{
Render_Engine *re;
Evas_GL_Image *im, *im_old;
re = (Render_Engine *)data;
if (!image) return NULL;
eng_window_use(re->window);
im_old = image;
if ((eng_image_colorspace_get(data, image) == EVAS_COLORSPACE_YCBCR422P601_PL) ||
(eng_image_colorspace_get(data, image) == EVAS_COLORSPACE_YCBCR422P709_PL))
w &= ~0x1;
if ((im_old) && (im_old->im->image->w == w) && (im_old->im->image->h == h))
return image;
if (im_old)
{
im = evas_gl_common_image_new(re->window->gl_context, w, h,
eng_image_alpha_get(data, image),
eng_image_colorspace_get(data, image));
/*
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);
}
else
im = evas_gl_common_image_new(re->window->gl_context, w, h, 1, EVAS_COLORSPACE_ARGB8888);
return im;
}
static void *
eng_image_dirty_region(void *data, void *image, int x, int y, int w, int h)
{
Render_Engine *re;
re = (Render_Engine *)data;
if (!image) return NULL;
evas_gl_common_image_dirty(image);
return image;
}
static void *
eng_image_data_get(void *data, void *image, int to_write, DATA32 **image_data)
{
Render_Engine *re;
Evas_GL_Image *im;
re = (Render_Engine *)data;
if (!image)
{
*image_data = NULL;
return NULL;
}
im = image;
eng_window_use(re->window);
evas_common_load_image_data_from_file(im->im);
switch (im->cs.space)
{
case EVAS_COLORSPACE_ARGB8888:
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,
eng_image_alpha_get(data, image),
eng_image_colorspace_get(data, image));
if (!im_new)
{
*image_data = NULL;
return im;
}
evas_gl_common_image_free(im);
im = im_new;
}
else
evas_gl_common_image_dirty(im);
}
*image_data = im->im->image->data;
break;
case EVAS_COLORSPACE_YCBCR422P601_PL:
case EVAS_COLORSPACE_YCBCR422P709_PL:
*image_data = im->cs.data;
break;
default:
abort();
break;
}
return im;
}
static void *
eng_image_data_put(void *data, void *image, DATA32 *image_data)
{
Render_Engine *re;
Evas_GL_Image *im, *im2;
re = (Render_Engine *)data;
if (!image) return NULL;
im = image;
eng_window_use(re->window);
switch (im->cs.space)
{
case EVAS_COLORSPACE_ARGB8888:
if (image_data != im->im->image->data)
{
int w, h;
w = im->im->image->w;
h = im->im->image->h;
im2 = eng_image_new_from_data(data, w, h, image_data,
eng_image_alpha_get(data, image),
eng_image_colorspace_get(data, image));
if (!im2) return im;
evas_gl_common_image_free(im);
im = im2;
}
break;
case EVAS_COLORSPACE_YCBCR422P601_PL:
case EVAS_COLORSPACE_YCBCR422P709_PL:
if (image_data != im->cs.data)
{
if (im->cs.data)
{
if (!im->cs.no_free) free(im->cs.data);
}
im->cs.data = image_data;
}
break;
default:
abort();
break;
}
/* hmmm - but if we wrote... why bother? */
evas_gl_common_image_dirty(im);
return im;
}
static void
eng_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;
if (!image) return;
eng_window_use(re->window);
re->window->gl_context->dc = context;
evas_gl_common_image_draw(re->window->gl_context, image,
src_x, src_y, src_w, src_h,
dst_x, dst_y, dst_w, dst_h,
smooth);
}
static void
eng_font_draw(void *data, void *context, void *surface, void *font, int x, int y, int w, int h, int ow, int oh, const char *text)
{
Render_Engine *re;
re = (Render_Engine *)data;
{
static RGBA_Image *im = NULL;
if (!im)
{
im = evas_common_image_new();
im->image = evas_common_image_surface_new(im);
im->image->no_free = 1;
}
im->image->w = re->window->width;
im->image->h = re->window->height;
im->image->data = NULL;
evas_common_draw_context_font_ext_set(context,
re->window->gl_context,
evas_gl_font_texture_new,
evas_gl_font_texture_free,
evas_gl_font_texture_draw);
evas_common_font_draw(im, context, font, x, y, text);
evas_common_draw_context_font_ext_set(context,
NULL,
NULL,
NULL,
NULL);
}
}
EAPI int
module_open(Evas_Module *em)
{
if (!em) return 0;
/* get whatever engine module we inherit from */
if (!_evas_module_engine_inherit(&pfunc, "software_generic")) return 0;
/* store it for later use */
func = pfunc;
/* now to override methods */
#define ORD(f) EVAS_API_OVERRIDE(f, &func, eng_)
ORD(info);
ORD(info_free);
ORD(setup);
ORD(output_free);
ORD(output_resize);
ORD(output_tile_size_set);
ORD(output_redraws_rect_add);
ORD(output_redraws_rect_del);
ORD(output_redraws_clear);
ORD(output_redraws_next_update_get);
ORD(output_redraws_next_update_push);
ORD(context_cutout_add);
ORD(context_cutout_clear);
ORD(output_flush);
ORD(output_idle_flush);
ORD(rectangle_draw);
ORD(line_draw);
ORD(polygon_point_add);
ORD(polygon_points_clear);
ORD(polygon_draw);
ORD(gradient_new);
ORD(gradient_free);
ORD(gradient_color_stop_add);
ORD(gradient_alpha_stop_add);
ORD(gradient_color_data_set);
ORD(gradient_alpha_data_set);
ORD(gradient_clear);
ORD(gradient_fill_set);
ORD(gradient_fill_angle_set);
ORD(gradient_fill_spread_set);
ORD(gradient_angle_set);
ORD(gradient_offset_set);
ORD(gradient_direction_set);
ORD(gradient_type_set);
ORD(gradient_is_opaque);
ORD(gradient_is_visible);
ORD(gradient_render_pre);
ORD(gradient_render_post);
ORD(gradient_draw);
ORD(image_load);
ORD(image_new_from_data);
ORD(image_new_from_copied_data);
ORD(image_free);
ORD(image_size_get);
ORD(image_size_set);
ORD(image_dirty_region);
ORD(image_data_get);
ORD(image_data_put);
ORD(image_alpha_set);
ORD(image_alpha_get);
ORD(image_border_set);
ORD(image_border_get);
ORD(image_draw);
ORD(image_comment_get);
ORD(image_format_get);
ORD(image_colorspace_set);
ORD(image_colorspace_get);
ORD(image_native_set);
ORD(image_native_get);
ORD(font_draw);
/* now advertise out own api */
em->functions = (void *)(&func);
return 1;
}
EAPI void
module_close(void)
{
}
EAPI Evas_Module_Api evas_modapi =
{
EVAS_MODULE_API_VERSION,
EVAS_MODULE_TYPE_ENGINE,
"gl_glew",
"none"
};

View File

@ -0,0 +1,35 @@
#ifndef __EVAS_ENGINE_H__
#define __EVAS_ENGINE_H__
#include "evas_gl_common.h"
typedef struct _Evas_GL_Glew_Window Evas_GL_Glew_Window;
struct _Evas_GL_Glew_Window
{
HDC dc;
HWND window;
int width;
int height;
int depth;
HGLRC context;
Evas_GL_Context *gl_context;
struct {
int redraw : 1;
int drew : 1;
int x1, y1, x2, y2;
} draw;
};
Evas_GL_Glew_Window *eng_window_new(HDC dc,
HWND window,
int depth,
int width,
int height);
void eng_window_free(Evas_GL_Glew_Window *gw);
void eng_window_use(Evas_GL_Glew_Window *gw);
#endif /* __EVAS_ENGINE_H__ */

View File

@ -0,0 +1,75 @@
#include "evas_common.h"
#include "evas_engine.h"
#include "Evas_Engine_GL_Glew.h"
static Evas_GL_Glew_Window *_evas_gl_glew_window = NULL;
static HGLRC context = NULL;
static int glew_is_init = 0;
Evas_GL_Glew_Window *
eng_window_new(HDC dc,
HWND window,
int depth,
int width,
int height)
{
Evas_GL_Glew_Window *gw;
gw = calloc(1, sizeof(Evas_GL_Glew_Window));
if (!gw) return NULL;
gw->dc = dc;
gw->window = window;
gw->depth = depth;
if (!context)
context = wglCreateContext(dc);
if (!context)
{
free(gw);
return NULL;
}
gw->context = context;
wglMakeCurrent(dc, context);
if (!glew_is_init)
if (glewInit() != GLEW_OK)
{
wglMakeCurrent(NULL, NULL);
wglDeleteContext(context);
free(gw);
return NULL;
}
gw->gl_context = evas_gl_common_context_new();
if (!gw->gl_context)
{
wglMakeCurrent(NULL, NULL);
wglDeleteContext(context);
free(gw);
return NULL;
}
evas_gl_common_context_resize(gw->gl_context, width, height);
return gw;
}
void
eng_window_free(Evas_GL_Glew_Window *gw)
{
if (gw == _evas_gl_glew_window) _evas_gl_glew_window = NULL;
evas_gl_common_context_free(gw->gl_context);
/* wglDeleteContext(gw->context); */
free(gw);
}
void
eng_window_use(Evas_GL_Glew_Window *gw)
{
if (_evas_gl_glew_window != gw)
{
_evas_gl_glew_window = gw;
wglMakeCurrent(gw->dc, gw->context);
}
evas_gl_common_context_use(gw->gl_context);
}