* Add Windows CE engine (1st step)

The engine is not entirely working right now. Recent devices which
  supports the raw frame buffer should work though. But having it in
  cvs will help me as I'm coding it most of the time "blindly" (no
  device to test it)

 * minor formatting in the top evel Makefile.am too


SVN revision: 34354
devs/devilhorns/wayland_egl
doursse 16 years ago committed by doursse
parent 56eacad43d
commit 208d20a30f
  1. 134
      legacy/evas/Makefile.am
  2. 45
      legacy/evas/configure.in
  3. 3
      legacy/evas/evas-software-16-wince.pc.in
  4. 3
      legacy/evas/src/lib/canvas/evas_main.c
  5. 1
      legacy/evas/src/modules/engines/Makefile.am
  6. 30
      legacy/evas/src/modules/engines/software_16_wince/Evas_Engine_Software_16_WinCE.h
  7. 35
      legacy/evas/src/modules/engines/software_16_wince/Makefile.am
  8. 697
      legacy/evas/src/modules/engines/software_16_wince/evas_engine.c
  9. 49
      legacy/evas/src/modules/engines/software_16_wince/evas_engine.h
  10. 122
      legacy/evas/src/modules/engines/software_16_wince/evas_wince_fb_buffer.c
  11. 278
      legacy/evas/src/modules/engines/software_16_wince/evas_wince_gapi_buffer.c

@ -2,58 +2,80 @@ ACLOCAL_AMFLAGS = -I m4
SUBDIRS = src
MAINTAINERCLEANFILES = Makefile.in aclocal.m4 config.guess \
config.h.in config.sub configure install-sh \
ltconfig ltmain.sh missing mkinstalldirs \
stamp-h.in build-stamp configure-stamp depcomp \
evas_docs.tar.gz evas.c \
README \
evas-cairo-x11.pc \
evas-directfb.pc \
evas-fb.pc \
evas-glitz-x11.pc \
evas-opengl-x11.pc \
evas-opengl-glew.pc \
evas-software-buffer.pc \
evas-software-qtopia.pc \
evas-software-x11.pc \
evas-software-16-x11.pc \
evas-software-xcb.pc \
evas-xrender-x11.pc \
evas-xrender-xcb.pc \
evas-software-ddraw.pc \
evas-software-16-ddraw.pc \
evas-direct3d.pc \
evas-software-sdl.pc \
evas.pc \
evas.spec
bin_SCRIPTS =
EXTRA_DIST = AUTHORS COPYING COPYING-PLAIN autogen.sh evas.c.in gendoc \
Doxyfile \
README.in README \
evas.pc.in \
evas-cairo-x11.pc \
evas-directfb.pc \
evas-fb.pc \
evas-glitz-x11.pc \
evas-opengl-x11.pc \
evas-opengl-glew.pc \
evas-software-buffer.pc \
evas-software-qtopia.pc \
evas-software-x11.pc \
evas-software-16-x11.pc \
evas-software-xcb.pc \
evas-xrender-x11.pc \
evas-xrender-xcb.pc \
evas-software-ddraw.pc \
evas-software-16-ddraw.pc \
evas-direct3d.pc \
evas-software-sdl.pc \
evas.pc \
evas.spec.in evas.spec \
doc gendoc
MAINTAINERCLEANFILES = \
Makefile.in \
aclocal.m4 \
config.guess \
config.h.in \
config.sub \
configure \
install-sh \
ltconfig \
ltmain.sh \
missing \
mkinstalldirs \
stamp-h.in \
build-stamp \
configure-stamp \
depcomp \
evas_docs.tar.gz \
evas.c \
README \
evas-cairo-x11.pc \
evas-directfb.pc \
evas-fb.pc \
evas-glitz-x11.pc \
evas-opengl-x11.pc \
evas-opengl-glew.pc \
evas-software-buffer.pc \
evas-software-qtopia.pc \
evas-software-x11.pc \
evas-software-16-x11.pc \
evas-software-xcb.pc \
evas-xrender-x11.pc \
evas-xrender-xcb.pc \
evas-software-ddraw.pc \
evas-software-16-ddraw.pc \
evas-direct3d.pc \
evas-software-16-wince.pc \
evas-software-sdl.pc \
evas.pc \
evas.spec
bin_SCRIPTS =
EXTRA_DIST = \
AUTHORS \
COPYING \
COPYING-PLAIN \
autogen.sh \
evas.c.in \
gendoc \
Doxyfile \
README.in \
README \
evas.pc.in \
evas-cairo-x11.pc \
evas-directfb.pc \
evas-fb.pc \
evas-glitz-x11.pc \
evas-opengl-x11.pc \
evas-opengl-glew.pc \
evas-software-buffer.pc \
evas-software-qtopia.pc \
evas-software-x11.pc \
evas-software-16-x11.pc \
evas-software-xcb.pc \
evas-xrender-x11.pc \
evas-xrender-xcb.pc \
evas-software-ddraw.pc \
evas-software-16-ddraw.pc \
evas-direct3d.pc \
evas-software-16-wince.pc \
evas-software-sdl.pc \
evas.pc \
evas.spec.in evas.spec \
doc gendoc
if BUILD_ENGINE_SOFTWARE_X11
psoftwarex11 = evas-software-x11.pc
@ -112,13 +134,17 @@ psoftwareddraw = evas-software-ddraw.pc
endif
if BUILD_ENGINE_SOFTWARE_16_DDRAW
psoftwared16draw = evas-software-16-ddraw.pc
psoftware16ddraw = evas-software-16-ddraw.pc
endif
if BUILD_ENGINE_DIRECT3D
pdirect3d = evas-direct3d.pc
endif
if BUILD_ENGINE_SOFTWARE_16_WINCE
psoftware16wince = evas-software-16-wince.pc
endif
if BUILD_ENGINE_SDL
psoftwaresdl = evas-software-sdl.pc
endif
@ -128,4 +154,4 @@ pkgconfig_DATA = \
evas.pc $(psoftwarex11) $(psoftwarexcb) $(pdirectfb) $(pfb) \
$(psoftwarebuffer) $(psoftwareqtopia) $(popenglx11) $(pcairox11) \
$(pxrenderx11) $(pxrenderxcb) $(pglitzx11) $(psoftwareddraw) $(psoftwaresdl) \
$(psoftware16x11) $(pdirect3d) $(psoftwared16draw) $(popenglglew)
$(psoftware16x11) $(pdirect3d) $(psoftware16ddraw) $(psoftware16wince) $(popenglglew)

@ -41,7 +41,7 @@ WIN32_CFLAGS=""
lt_no_undefined=""
lt_enable_auto_import=""
case "$host_os" in
mingw|mingw32*|cegcc)
mingw*|cegcc*)
PKG_CHECK_MODULES(EVIL, evil)
AC_DEFINE(HAVE_EVIL, 1, [Set to 1 if evil package is installed])
dnl needed for correct definition of EAPI
@ -134,8 +134,8 @@ fi
dlopen_libs=""
case "$host_os" in
mingw|mingw32)
AC_CHECK_HEADER(windows.h, [], [AC_MSG_ERROR(Cannot find windows.h)])
mingw*|cegcc*)
dnl managed by evil
;;
*)
AC_CHECK_FUNCS(dlopen, res=yes, res=no)
@ -266,6 +266,37 @@ AC_MSG_RESULT($have_evas_direct3d)
AM_CONDITIONAL(BUILD_ENGINE_DIRECT3D, test "x$have_evas_direct3d" = "xyes")
#######################################
## Check if we should build the 16bit software_wince engine
want_evas_software_16_wince="auto";
have_evas_software_16_wince="no";
AC_MSG_CHECKING(whether 16 bit software WinCE backend is to be built)
AC_ARG_ENABLE(software-16-wince,
AC_HELP_STRING([--enable-software-16-wince], [enable the 16bit Software WinCE rendering backend]),
[ want_evas_software_16_wince=$enableval ]
)
AC_MSG_RESULT($want_evas_software_16_wince)
if test "x$want_evas_software_16_wince" = "xyes" -o "x$want_evas_software_16_wince" = "xauto"; then
AC_CHECK_HEADER(windows.h,
[
AC_DEFINE(BUILD_ENGINE_SOFTWARE_16_WINCE, 1, [16bit Software WinCE Rendering Backend])
wince_16_libs=""
have_evas_software_16_wince="yes"
],
[
if test "x$want_evas_software_16_wince" = "xyes" -a "x$use_strict" = "xyes" ; then
AC_MSG_ERROR([WinCE not found (strict dependencies checking)])
fi
]
)
fi
AC_MSG_CHECKING(whether 16 bits software WinCE backend will be built)
AC_MSG_RESULT($have_evas_software_16_wince)
AM_CONDITIONAL(BUILD_ENGINE_SOFTWARE_16_WINCE, test "x$have_evas_software_16_wince" = "xyes")
#######################################
## Check if we should build the software_x11 engine
want_evas_software_x11="auto";
@ -861,7 +892,7 @@ fi
dnl Windows has no sigsetjmp function, nor equivalent.
dnl So we disable the jpeg saver.
case "$host_os" in
mingw|mingw32)
mingw*|cegcc*)
have_jpeg_saver="no"
;;
esac
@ -1538,6 +1569,9 @@ fi
if test "x$have_evas_software_16_ddraw" = "xyes"; then
have_evas_software_16="yes"
fi
if test "x$have_evas_software_16_wince" = "xyes"; then
have_evas_software_16="yes"
fi
AM_CONDITIONAL(BUILD_ENGINE_SOFTWARE_16, test "x$have_evas_software_16" = "xyes")
#####################################################################
@ -1596,6 +1630,7 @@ evas-xrender-xcb.pc
evas-software-ddraw.pc
evas-software-16-ddraw.pc
evas-direct3d.pc
evas-software-16-wince.pc
evas-software-sdl.pc
evas.pc
src/Makefile
@ -1619,6 +1654,7 @@ src/modules/engines/Makefile
src/modules/engines/software_generic/Makefile
src/modules/engines/software_ddraw/Makefile
src/modules/engines/direct3d/Makefile
src/modules/engines/software_16_wince/Makefile
src/modules/engines/software_x11/Makefile
src/modules/engines/software_xcb/Makefile
src/modules/engines/fb/Makefile
@ -1691,6 +1727,7 @@ echo " Glitz X11..................: $have_evas_glitz_x11"
echo " Software 16bit ............: $have_evas_software_16"
echo " Software 16bit X11.........: $have_evas_software_16_x11"
echo " Software 16bit Directdraw..: $have_evas_software_16_ddraw"
echo " Software 16bit WinCE.......: $have_evas_software_16_wince"
echo " Software 16bit SDL.........: $have_evas_sdl (primitive: $sdl_primitive)"
# FIXME: opengl engine needs to be fixed and tested lots for all drivers
# FIXME: xrender engine to be written

@ -0,0 +1,3 @@
Name: evas-software-16-wince
Description: Evas 16bit software WinCE engine
Version: @VERSION@

@ -712,6 +712,9 @@ evas_render_method_list(void)
#ifdef BUILD_ENGINE_DIRECT3D
methods = evas_list_append(methods, strdup("direct3d"));
#endif
#ifdef BUILD_ENGINE_SOFTWARE_16_WINCE
methods = evas_list_append(methods, strdup("software_16_wince"));
#endif
#ifdef BUILD_ENGINE_SOFTWARE_X11
methods = evas_list_append(methods, strdup("software_x11"));
#endif

@ -23,5 +23,6 @@ software_16 \
software_16_x11 \
direct3d \
software_16_ddraw \
software_16_wince \
software_16_sdl

@ -0,0 +1,30 @@
#ifndef __EVAS_ENGINE_SOFTWARE_16_WINCE_H__
#define __EVAS_ENGINE_SOFTWARE_16_WINCE_H__
#include <windows.h>
typedef struct _Evas_Engine_Info_Software_16_WinCE Evas_Engine_Info_Software_16_WinCE;
struct _Evas_Engine_Info_Software_16_WinCE
{
/* PRIVATE - don't mess with this baby or evas will poke its tongue out */
/* at you and make nasty noises */
Evas_Engine_Info magic;
struct {
HWND window;
int backend; /* 0: auto, 1: raw, 2: gapi, 3: ddraw */
int rotation;
} info;
/* engine specific function calls to query stuff about messages */
struct {
int (*suspend) (int backend);
int (*resume) (int backend);
void *(*default_keys) (int backend);
} func;
};
#endif /* __EVAS_ENGINE_SOFTWARE_16_WINCE_H__ */

@ -0,0 +1,35 @@
MAINTAINERCLEANFILES = Makefile.in
AM_CPPFLAGS = \
-I. \
-I$(top_srcdir)/src/lib \
-I$(top_srcdir)/src/lib/include \
-I$(top_srcdir)/src/modules/engines \
-I$(top_srcdir)/src/modules/engines/software_16 \
@FREETYPE_CFLAGS@
if BUILD_ENGINE_SOFTWARE_16_WINCE
pkgdir = $(libdir)/evas/modules/engines/software_16_wince/$(MODULE_ARCH)
pkg_LTLIBRARIES = module.la
module_la_SOURCES = \
evas_engine.h \
evas_engine.c \
evas_wince_fb_buffer.c \
evas_wince_gapi_buffer.c
module_la_CFLAGS = @WIN32_CFLAGS@
module_la_LIBADD = $(top_builddir)/src/lib/libevas.la
module_la_LDFLAGS = @lt_no_undefined@ -module -avoid-version
module_la_LIBTOOLFLAGS = --tag=disable-static
module_la_DEPENDENCIES = $(top_builddir)/config.h
include_HEADERS = Evas_Engine_Software_16_WinCE.h
install-exec-hook:
mv $(libdir)/evas/modules/engines/software_16_wince/$(MODULE_ARCH)/module.dll $(bindir)/engine_buffer.dll
endif

@ -0,0 +1,697 @@
#include "evas_common.h"
#include "evas_private.h"
#include "evas_engine.h"
#include "Evas_Engine_Software_16_WinCE.h"
#include "evas_common_soft16.h"
typedef enum
{
EVAS_ENGINE_WINCE_FB,
EVAS_ENGINE_WINCE_GAPI,
EVAS_ENGINE_WINCE_DDRAW
} Evas_Engine_WinCE_Backend;
/* function tables - filled in later (func and parent func) */
static Evas_Func func, pfunc;
/* engine struct data */
typedef struct _Render_Engine Render_Engine;
struct _Render_Engine
{
Evas_Engine_WinCE_Backend backend; /* 1: raw, 2: gapi, 3: ddraw */
void *backend_priv;
void (*backend_shutdown)(void *priv);
FB_Output_Buffer *(*backend_output_buffer_new)(void *priv,
int width,
int height);
void (*backend_output_buffer_free)(FB_Output_Buffer *fbob);
void (*backend_output_buffer_paste)(FB_Output_Buffer *fbob);
int width;
int height;
int rotation;
Tilebuf *tb;
Tilebuf_Rect *rects;
Tilebuf_Rect *cur_rect;
FB_Output_Buffer *fbob;
Soft16_Image *tmp_out; /* used by indirect render, like rotation */
HRGN clip_rects;
unsigned char end : 1;
};
/* prototypes we will use here */
static void *eng_info(Evas *e);
static void eng_info_free(Evas *e, void *info);
static void eng_setup(Evas *e, void *info);
static void eng_output_free(void *data);
static void eng_output_resize(void *data, int w, int h);
static void eng_output_tile_size_set(void *data, int w, int h);
static void eng_output_redraws_rect_add(void *data, int x, int y, int w, int h);
static void eng_output_redraws_rect_del(void *data, int x, int y, int w, int h);
static void eng_output_redraws_clear(void *data);
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);
static void eng_output_redraws_next_update_push(void *data, void *surface, int x, int y, int w, int h);
static void eng_output_flush(void *data);
static void eng_output_idle_flush(void *data);
static int
_suspend(int backend)
{
switch (backend)
{
case 2: /* gapi */
return evas_software_wince_gapi_suspend();
default: /* other engines do not need it */
return 0;
}
}
static int
_resume(int backend)
{
switch (backend)
{
case 2: /* gapi */
return evas_software_wince_gapi_resume();
default: /* other engines do not need it */
return 0;
}
}
static void *
_default_keys(int backend)
{
switch (backend)
{
case 2: /* gapi */
return evas_software_wince_gapi_default_keys();
default: /* other engines do not need it */
return NULL;
}
}
/* engine api this module provides */
static void *
eng_info(Evas *e)
{
Evas_Engine_Info_Software_16_WinCE *info;
info = calloc(1, sizeof(Evas_Engine_Info_Software_16_WinCE));
if (!info) return NULL;
info->magic.magic = rand();
info->func.suspend = _suspend;
info->func.resume = _resume;
info->func.default_keys = _default_keys;
return info;
e = NULL;
}
static void
eng_info_free(Evas *e, void *info)
{
Evas_Engine_Info_Software_16_WinCE *in;
in = (Evas_Engine_Info_Software_16_WinCE *)info;
free(in);
}
static void
_tmp_out_alloc(Render_Engine *re)
{
Tilebuf_Rect *r;
int w = 0, h = 0;
for (r = re->rects; r; r = (Tilebuf_Rect *)(r->_list_data.next))
{
if (r->w > w) w = r->w;
if (r->h > h) h = r->h;
}
if (re->tmp_out)
{
if ((re->tmp_out->cache_entry.w < w) || (re->tmp_out->cache_entry.h < h))
{
evas_cache_image_drop(&re->tmp_out->cache_entry);
re->tmp_out = NULL;
}
}
if (!re->tmp_out)
{
Soft16_Image *im;
im = (Soft16_Image *) evas_cache_image_empty(evas_common_soft16_image_cache_get());
im->flags.have_alpha = 0;
evas_cache_image_surface_alloc(&im->cache_entry, w, h);
re->tmp_out = im;
}
}
static void
eng_setup(Evas *e, void *in)
{
Render_Engine *re;
Evas_Engine_Info_Software_16_WinCE *info;
info = (Evas_Engine_Info_Software_16_WinCE *)in;
if (!e->engine.data.output)
{
/* do common routine init - we wil at least use it for core
* image loading and font loading/glyph rendering & placement */
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();
evas_common_soft16_image_init();
/* render engine specific data */
re = calloc(1, sizeof(Render_Engine));
if (!re)
return;
e->engine.data.output = re;
switch(info->info.backend)
{
case 1: /* FB */
re->backend = EVAS_ENGINE_WINCE_FB;
re->backend_priv = evas_software_wince_fb_init(info->info.window);
if (!re->backend_priv)
{
free(re);
return;
}
re->backend_shutdown = evas_software_wince_fb_shutdown;
re->backend_output_buffer_new = evas_software_wince_fb_output_buffer_new;
re->backend_output_buffer_free = evas_software_wince_fb_output_buffer_free;
re->backend_output_buffer_paste = evas_software_wince_fb_output_buffer_paste;
break;
case 2: /* GAPI */
re->backend = EVAS_ENGINE_WINCE_GAPI;
re->backend_priv = evas_software_wince_gapi_init(info->info.window);
if (!re->backend_priv)
{
free(re);
return;
}
re->backend_shutdown = evas_software_wince_gapi_shutdown;
re->backend_output_buffer_new = evas_software_wince_gapi_output_buffer_new;
re->backend_output_buffer_free = evas_software_wince_gapi_output_buffer_free;
re->backend_output_buffer_paste = evas_software_wince_gapi_output_buffer_paste;
break;
default:
free(re);
return;
}
re->width = e->output.w;
re->height = e->output.h;
re->rotation = info->info.rotation;
re->tb = evas_common_tilebuf_new(e->output.w, e->output.h);
if (re->tb)
evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE);
}
else
{
re = e->engine.data.output;
if (re->tb) evas_common_tilebuf_free(re->tb);
switch(info->info.backend)
{
case 1: /* FB */
re->backend = EVAS_ENGINE_WINCE_FB;
re->backend_priv = evas_software_wince_fb_init(info->info.window);
if (!re->backend_priv)
{
free(re);
return;
}
re->backend_shutdown = evas_software_wince_fb_shutdown;
re->backend_output_buffer_new = evas_software_wince_fb_output_buffer_new;
re->backend_output_buffer_free = evas_software_wince_fb_output_buffer_free;
re->backend_output_buffer_paste = evas_software_wince_fb_output_buffer_paste;
break;
case 2: /* GAPI */
re->backend = EVAS_ENGINE_WINCE_GAPI;
re->backend_priv = evas_software_wince_gapi_init(info->info.window);
if (!re->backend_priv)
{
free(re);
return;
}
re->backend_shutdown = evas_software_wince_gapi_shutdown;
re->backend_output_buffer_new = evas_software_wince_gapi_output_buffer_new;
re->backend_output_buffer_free = evas_software_wince_gapi_output_buffer_free;
re->backend_output_buffer_paste = evas_software_wince_gapi_output_buffer_paste;
break;
default:
free(re);
return;
}
re->width = e->output.w;
re->height = e->output.h;
re->rotation = info->info.rotation;
re->tb = evas_common_tilebuf_new(e->output.w, e->output.h);
if (re->tb)
evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE);
if (re->tmp_out)
{
evas_cache_image_drop(&re->tmp_out->cache_entry);
re->tmp_out = NULL;
}
}
if (!e->engine.data.output) return;
/* add a draw context if we dont have one */
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;
if (re->fbob) re->backend_output_buffer_free(re->backend_priv);
re->backend_shutdown(re->backend_priv);
if (re->clip_rects) DeleteObject(re->clip_rects);
if (re->tb) evas_common_tilebuf_free(re->tb);
if (re->rects) evas_common_tilebuf_free_render_rects(re->rects);
if (re->tmp_out) evas_cache_image_drop(&re->tmp_out->cache_entry);
free(re);
evas_common_font_shutdown();
evas_common_image_shutdown();
evas_common_soft16_image_shutdown();
}
static void
eng_output_resize(void *data, int w, int h)
{
Render_Engine *re;
re = (Render_Engine *)data;
if ((re->width == w) && (re->height == h)) return;
/* FIXME: is it needed ?? */
if (re->fbob)
evas_software_wince_fb_surface_resize(re->fbob);
evas_common_tilebuf_free(re->tb);
re->width = w;
re->height = h;
re->tb = evas_common_tilebuf_new(w, h);
if (re->tb)
evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE);
if (re->fbob)
{
evas_software_wince_fb_output_buffer_free(re->fbob);
re->fbob = NULL;
}
if (re->clip_rects)
{
DeleteObject(re->clip_rects);
re->clip_rects = NULL;
}
if (re->tmp_out)
{
evas_cache_image_drop(&re->tmp_out->cache_entry);
re->tmp_out = NULL;
}
}
static void
eng_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);
}
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_common_tilebuf_add_redraw(re->tb, x, y, w, h);
}
static void
eng_output_redraws_rect_del(void *data, int x, int y, int w, int h)
{
Render_Engine *re;
re = (Render_Engine *)data;
evas_common_tilebuf_del_redraw(re->tb, x, y, w, h);
}
static void
eng_output_redraws_clear(void *data)
{
Render_Engine *re;
re = (Render_Engine *)data;
evas_common_tilebuf_clear(re->tb);
}
static inline void
_output_buffer_alloc(Render_Engine *re)
{
int width;
int height;
if (re->fbob) return;
if ((re->rotation == 0) || (re->rotation == 180))
{
width = re->width;
height = re->height;
}
else
{
width = re->height;
height = re->width;
}
re->fbob = re->backend_output_buffer_new(re->backend_priv,
width,
height);
}
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;
Tilebuf_Rect *rect;
int ux, uy, uw, uh;
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);
if (!re->rects) return NULL;
re->cur_rect = re->rects;
_output_buffer_alloc(re);
if (re->rotation != 0) _tmp_out_alloc(re); /* grows if required */
}
if (!re->cur_rect)
{
if (re->rects) evas_common_tilebuf_free_render_rects(re->rects);
re->rects = NULL;
return NULL;
}
rect = re->cur_rect;
ux = rect->x; uy = rect->y; uw = rect->w; uh = rect->h;
re->cur_rect = (Tilebuf_Rect *)(re->cur_rect->_list_data.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;
if (re->rotation == 0)
{
*cx = ux; *cy = uy; *cw = uw; *ch = uh;
return re->fbob->im;
}
else
{
*cx = 0; *cy = 0; *cw = uw; *ch = uh;
return re->tmp_out;
}
}
static void
_blit_rot_90(Soft16_Image *dst, const Soft16_Image *src,
int out_x, int out_y, int w, int h)
{
DATA16 *dp, *sp;
int x, y;
sp = src->pixels;
dp = dst->pixels + (out_x +
(w + out_y - 1) * dst->stride);
for (y = 0; y < h; y++)
{
DATA16 *dp_itr, *sp_itr;
sp_itr = sp;
dp_itr = dp;
for (x = 0; x < w; x++)
{
*dp_itr = *sp_itr;
sp_itr++;
dp_itr -= dst->stride;
}
sp += src->stride;
dp++;
}
}
static void
_blit_rot_180(Soft16_Image *dst, const Soft16_Image *src,
int out_x, int out_y, int w, int h)
{
DATA16 *dp, *sp;
int x, y;
sp = src->pixels;
dp = dst->pixels + ((w + out_x - 1) +
(h + out_y - 1) * dst->stride);
for (y = 0; y < h; y++)
{
DATA16 *dp_itr, *sp_itr;
sp_itr = sp;
dp_itr = dp;
for (x = 0; x < w; x++)
{
*dp_itr = *sp_itr;
sp_itr++;
dp_itr--;
}
sp += src->stride;
dp -= dst->stride;
}
}
static void
_blit_rot_270(Soft16_Image *dst, const Soft16_Image *src,
int out_x, int out_y, int w, int h)
{
DATA16 *dp, *sp;
int x, y;
sp = src->pixels;
dp = dst->pixels + ((h + out_x - 1) +
out_y * dst->stride);
for (y = 0; y < h; y++)
{
DATA16 *dp_itr, *sp_itr;
sp_itr = sp;
dp_itr = dp;
for (x = 0; x < w; x++)
{
*dp_itr = *sp_itr;
sp_itr++;
dp_itr += dst->stride;
}
sp += src->stride;
dp--;
}
}
static void
_tmp_out_process(Render_Engine *re, int out_x, int out_y, int w, int h)
{
Soft16_Image *d, *s;
d = re->fbob->im;
s = re->tmp_out;
if ((w < 1) || (h < 1) || (out_x >= d->cache_entry.w) || (out_y >= d->cache_entry.h))
return;
if (re->rotation == 90)
_blit_rot_90(d, s, out_x, out_y, w, h);
else if (re->rotation == 180)
_blit_rot_180(d, s, out_x, out_y, w, h);
else if (re->rotation == 270)
_blit_rot_270(d, s, out_x, out_y, w, h);
}
static void
eng_output_redraws_next_update_push(void *data, void *surface, int x, int y, int w, int h)
{
Render_Engine *re;
HRGN region;
int xx;
int yy;
int width;
int height;
re = (Render_Engine *)data;
if (!re->clip_rects)
re->clip_rects = CreateRectRgn(0, 0, 0, 0);
if (re->rotation == 0)
{
xx = x;
yy = y;
width = w;
height = h;
}
else if (re->rotation == 90)
{
xx = y;
yy = re->width - w - x;
width = h;
height = w;
}
else if (re->rotation == 180)
{
xx = re->width - w - x;
yy = re->height - h - y;
width = w;
height = h;
}
else if (re->rotation == 270)
{
xx = re->height - h - y;
yy = x;
width = h;
height = w;
}
region = CreateRectRgn(xx, yy, xx + width, yy + height);
if (re->rotation != 0)
_tmp_out_process(re, xx, yy, w, h);
CombineRgn(re->clip_rects, re->clip_rects, region, RGN_OR);
}
static void
eng_output_flush(void *data)
{
Render_Engine *re;
re = (Render_Engine *)data;
if (re->clip_rects)
{
/* FIXME : i have to manage that */
/* XSetRegion(re->disp, re->gc, re->clip_rects); */
DeleteObject(re->clip_rects);
re->clip_rects = NULL;
}
else return;
evas_software_wince_fb_output_buffer_paste(re->fbob);
/* FIXME : i have to manage that */
/* XSetClipMask(re->disp, re->gc, None); */
}
static void
eng_output_idle_flush(void *data)
{
Render_Engine *re;
re = (Render_Engine *)data;
if (re->fbob)
{
evas_software_wince_fb_output_buffer_free(re->fbob);
re->fbob = NULL;
}
if (re->clip_rects)
{
DeleteObject(re->clip_rects);
re->clip_rects = NULL;
}
if (re->tmp_out)
{
evas_cache_image_drop(&re->tmp_out->cache_entry);
re->tmp_out = NULL;
}
}
/* module advertising code */
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_16")) 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(output_flush);
ORD(output_idle_flush);
/* 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,
"software_16_wince_fb",
"none"
};

@ -0,0 +1,49 @@
#ifndef __EVAS_ENGINE_H__
#define __EVAS_ENGINE_H__
#include <windows.h>
#include "evas_common_soft16.h"
typedef struct _FB_Output_Buffer FB_Output_Buffer;
struct _FB_Output_Buffer
{
Soft16_Image *im;
void *priv;
};
/* Raw FrameBuffer */
void *evas_software_wince_fb_init (HWND window);
FB_Output_Buffer *evas_software_wince_fb_output_buffer_new (void *priv,
int width,
int height);
void evas_software_wince_fb_shutdown(void *priv);
void evas_software_wince_fb_output_buffer_free (FB_Output_Buffer *fbob);
void evas_software_wince_fb_output_buffer_paste (FB_Output_Buffer *fbob);
void evas_software_wince_fb_surface_resize(FB_Output_Buffer *fbob);
/* GAPI */
void *evas_software_wince_gapi_init (HWND window);
FB_Output_Buffer *evas_software_wince_gapi_output_buffer_new (void *priv,
int width,
int height);
void evas_software_wince_gapi_shutdown(void *priv);
void evas_software_wince_gapi_output_buffer_free (FB_Output_Buffer *fbob);
void evas_software_wince_gapi_output_buffer_paste (FB_Output_Buffer *fbob);
void evas_software_wince_gapi_surface_resize(FB_Output_Buffer *fbob);
void *evas_software_wince_gapi_default_keys(void);
int evas_software_wince_gapi_suspend(void);
int evas_software_wince_gapi_resume(void);
#endif /* __EVAS_ENGINE_H__ */

@ -0,0 +1,122 @@
#include "evas_common.h"
#include "evas_engine.h"
#define GETRAWFRAMEBUFFER 0x00020001
typedef struct _RawFrameBufferInfo
{
WORD wFormat;
WORD wBPP;
VOID *pFramePointer;
int cxStride;
int cyStride;
int cxPixels;
int cyPixels;
} RawFrameBufferInfo;
typedef struct Evas_Engine_WinCE_FB_Priv Evas_Engine_WinCE_FB_Priv;
struct Evas_Engine_WinCE_FB_Priv
{
int width;
int height;
void *buffer;
};
void *
evas_software_wince_fb_init (HWND window)
{
RawFrameBufferInfo rfbi;
HDC dc;
Evas_Engine_WinCE_FB_Priv *priv;
priv = (Evas_Engine_WinCE_FB_Priv *)malloc(sizeof(Evas_Engine_WinCE_FB_Priv));
if (!priv)
return NULL;
dc = GetDC (window);
if (!dc)
{
free(priv);
return NULL;
}
if (!ExtEscape(dc, GETRAWFRAMEBUFFER, 0, 0, sizeof(rfbi), (char *) &rfbi)||
(rfbi.wBPP != 16) ||
(rfbi.wFormat != 1))
{
ReleaseDC(window, dc);
free(priv);
return NULL;
}
priv->width = rfbi.cxPixels;
priv->height = rfbi.cyPixels;
priv->buffer = rfbi.pFramePointer;
ReleaseDC(window, dc);
return priv;
}
void
evas_software_wince_fb_shutdown(void *priv)
{
free(priv);
}
FB_Output_Buffer *
evas_software_wince_fb_output_buffer_new(void *priv,
int width,
int height)
{
FB_Output_Buffer *fbob;
void *buffer;
fbob = calloc(1, sizeof(FB_Output_Buffer));
if (!fbob) return NULL;
buffer = malloc (width * height * 2); /* we are sure to have 16bpp */
if (!buffer)
{
free(fbob);
return NULL;
}
fbob->priv = priv;
fbob->im = (Soft16_Image *) evas_cache_image_data(evas_common_soft16_image_cache_get(), width, height, (DATA32 *)buffer, 0, EVAS_COLORSPACE_RGB565_A5P);
if (fbob->im)
fbob->im->stride = width;
return fbob;
}
void
evas_software_wince_fb_output_buffer_free(FB_Output_Buffer *fbob)
{
free(fbob->im->pixels);
free(fbob);
}
void
evas_software_wince_fb_output_buffer_paste(FB_Output_Buffer *fbob)
{
Evas_Engine_WinCE_FB_Priv *priv;
priv = (Evas_Engine_WinCE_FB_Priv *)fbob->priv;
if ((fbob->im->cache_entry.w == priv->width) &&
(fbob->im->cache_entry.h == priv->height))
memcpy(priv->buffer, fbob->im->pixels,
priv->width * priv->height * 2);
}
void
evas_software_wince_fb_surface_resize(FB_Output_Buffer *ddob)
{
}

@ -0,0 +1,278 @@
#include "evas_common.h"
#include "evas_engine.h"
typedef int (*evas_engine_wince_close_display)();
typedef int (*evas_engine_wince_close_input)();
typedef struct Evas_Engine_WinCE_GAPI_Priv Evas_Engine_WinCE_GAPI_Priv;
#define LINK(type,name,import) \
name = (gapi_##type)GetProcAddress (gapi_lib, import)
#define GX_FULLSCREEN 0x01
#define GX_NORMALKEYS 0x02
#define kfDirect555 0x40
#define kfDirect565 0x80
typedef struct
{
DWORD cxWidth;
DWORD cyHeight;
LONG cbxPitch;
LONG cbyPitch;
LONG cBPP;
DWORD ffFormat;
} _GAPI_Display_Properties;
typedef struct
{
short vkUp; // key for up
POINT ptUp; // x,y position of key/button. Not on screen but in screen coordinates.
short vkDown;
POINT ptDown;
short vkLeft;
POINT ptLeft;
short vkRight;
POINT ptRight;
short vkA;
POINT ptA;
short vkB;
POINT ptB;
short vkC;
POINT ptC;
short vkStart;
POINT ptStart;
} _GAPI_Key_List;
typedef int (*gapi_display_open)(HWND hWnd, DWORD dwFlags);
typedef int (*gapi_display_close)();
typedef _GAPI_Display_Properties (*gapi_display_properties_get)(void);
typedef void* (*gapi_draw_begin)(void);
typedef int (*gapi_draw_end)(void);
typedef int (*gapi_input_open)(void);
typedef int (*gapi_input_close)(void);
typedef _GAPI_Key_List (*gapi_default_keys_get)(int iOptions);
typedef int (*gapi_suspend)(void);
typedef int (*gapi_resume)(void);
gapi_default_keys_get default_keys_get = NULL;
gapi_suspend suspend = NULL;
gapi_resume resume = NULL;
int
evas_software_wince_gapi_suspend(void)
{
return suspend();
}
int
evas_software_wince_gapi_resume(void)
{
return resume();
}
void *
evas_software_wince_gapi_default_keys(void)
{
_GAPI_Key_List key_list;
_GAPI_Key_List *keys;
keys = (_GAPI_Key_List *)malloc(sizeof(_GAPI_Key_List));
if (!keys)
return NULL;
key_list = default_keys_get(GX_NORMALKEYS);
memcpy(keys, &key_list, sizeof(_GAPI_Key_List));
return keys;
}
struct Evas_Engine_WinCE_GAPI_Priv
{
HMODULE lib;
gapi_display_close close_display;
gapi_input_close close_input;
gapi_draw_begin draw_begin;
gapi_draw_end draw_end;
int width;
int height;
};
void *
evas_software_wince_gapi_init (HWND window)
{
_GAPI_Display_Properties prop;
_GAPI_Key_List key_list;
HMODULE gapi_lib;
Evas_Engine_WinCE_GAPI_Priv *priv;
gapi_display_open display_open = NULL;
gapi_display_close display_close = NULL;
gapi_display_properties_get display_properties_get = NULL;
gapi_draw_begin draw_begin = NULL;
gapi_draw_end draw_end = NULL;
gapi_input_open input_open = NULL;
gapi_input_close input_close = NULL;
priv = (Evas_Engine_WinCE_GAPI_Priv *)malloc(sizeof(Evas_Engine_WinCE_GAPI_Priv));
if (!priv)
return NULL;
gapi_lib = LoadLibrary(L"\\Windows\\gx.dll");
if (!gapi_lib)
{
gapi_lib = LoadLibrary(L"gx.dll");
if (!gapi_lib) {
printf ("error : LoadLibrary\n");
goto free_priv;
}
}
LINK(display_open, display_open, L"?GXOpenDisplay@@YAHPAUHWND__@@K@Z");
LINK(display_close, display_close, L"?GXCloseDisplay@@YAHXZ");
LINK(display_properties_get, display_properties_get, L"?GXGetDisplayProperties@@YA?AUGXDisplayProperties@@XZ");
LINK(draw_begin, draw_begin, L"?GXBeginDraw@@YAPAXXZ");
LINK(draw_end, draw_end, L"?GXEndDraw@@YAHXZ");
LINK(input_open, input_open, L"?GXOpenInput@@YAHXZ" );
LINK(input_close, input_close, L"?GXCloseInput@@YAHXZ" );
LINK(default_keys_get, default_keys_get, L"?GXGetDefaultKeys@@YA?AUGXKeyList@@H@Z");
LINK(suspend, suspend, L"?GXSuspend@@YAHXZ" );
LINK(resume, resume, L"?GXResume@@YAHXZ" );
if (!display_open ||
!display_close ||
!display_properties_get ||
!draw_begin ||
!draw_end ||
!input_open ||
!input_close ||
!default_keys_get ||
!suspend ||
!resume)
{
printf ("error : no valid symbols\n");
goto free_lib;
}
if (!display_open(window, GX_FULLSCREEN))
{
printf ("error : GXOpenDisplay\n");
goto free_lib;
}