forked from enlightenment/efl
add in the work I did for a 16bit engine - for now, a dormant project until i
can be convinced it provides real and significant speedups that warrant the significant effort. SVN revision: 29770
This commit is contained in:
parent
d1b66f89e6
commit
16df9e0047
|
@ -177,6 +177,53 @@ if test "x$have_evas_software_x11" = "xyes"; then
|
|||
fi
|
||||
AM_CONDITIONAL(BUILD_ENGINE_SOFTWARE_X11, test "x$have_evas_software_x11" = "xyes")
|
||||
|
||||
#######################################
|
||||
## Check if we should build the software_x11 engine
|
||||
have_evas_software_16_x11="no";
|
||||
## Automatic check...
|
||||
# -- disable software_16 by default - its usefulness as a speedup in 16bit
|
||||
# seems dubious at this stage.
|
||||
#AC_CHECK_HEADER(X11/X.h,
|
||||
# [ have_evas_software_16_x11="yes" ],
|
||||
# [ have_evas_software_16_x11="no" ]
|
||||
#)
|
||||
## Manual override
|
||||
AC_MSG_CHECKING(whether software 16bit x11 backend is to be built)
|
||||
AC_ARG_ENABLE(software-16-x11,
|
||||
AC_HELP_STRING([--enable-software-16-x11],[enable the Software 16bit X11 rendering backend]), [
|
||||
if test x"$enableval" = x"yes" ; then
|
||||
AC_MSG_RESULT(yes)
|
||||
have_evas_software_16_x11="yes"
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
have_evas_software_16_x11="no"
|
||||
fi
|
||||
], [
|
||||
AC_MSG_RESULT($have_evas_software_16_x11)
|
||||
]
|
||||
)
|
||||
if test "x$have_evas_software_16_x11" = "xyes"; then
|
||||
AC_PATH_XTRA
|
||||
AC_CHECK_HEADER(X11/X.h,
|
||||
[
|
||||
AC_DEFINE(BUILD_ENGINE_SOFTWARE_16_X11, 1, [Software 16bit X11 Rendering Backend])
|
||||
x_dir=${x_dir:-/usr/X11R6}
|
||||
x_cflags=${x_cflags:--I${x_includes:-$x_dir/include}}
|
||||
x_libs="${x_libs:--L${x_libraries:-$x_dir/lib}} -lX11 -lXext"
|
||||
],
|
||||
[
|
||||
AC_MSG_RESULT(disabling software 16bit X11 engine)
|
||||
have_evas_software_16_x11="no"
|
||||
]
|
||||
)
|
||||
fi
|
||||
AM_CONDITIONAL(BUILD_ENGINE_SOFTWARE_16_X11, test "x$have_evas_software_16_x11" = "xyes")
|
||||
|
||||
### if software 16 x11 is enabled - build software_16 (the generic 16bit
|
||||
### engine). later enable it fb_16 or other "16" bit engines are enabled.
|
||||
have_evas_software_16=$have_evas_software_16_x11
|
||||
AM_CONDITIONAL(BUILD_ENGINE_SOFTWARE_16, test "x$have_evas_software_16" = "xyes")
|
||||
|
||||
#######################################
|
||||
## Check if we should build the software_xcb engine
|
||||
have_evas_software_xcb="no";
|
||||
|
@ -1985,6 +2032,8 @@ src/modules/engines/cairo_x11/Makefile
|
|||
src/modules/engines/xrender_x11/Makefile
|
||||
src/modules/engines/xrender_xcb/Makefile
|
||||
src/modules/engines/glitz_x11/Makefile
|
||||
src/modules/engines/software_16/Makefile
|
||||
src/modules/engines/software_16_x11/Makefile
|
||||
src/modules/loaders/Makefile
|
||||
src/modules/loaders/edb/Makefile
|
||||
src/modules/loaders/eet/Makefile
|
||||
|
@ -2033,6 +2082,7 @@ echo " Cairo X11...............: $have_evas_cairo_x11"
|
|||
echo " XRender X11.............: $have_evas_xrender_x11"
|
||||
echo " XRender Xcb.............: $have_evas_xrender_xcb"
|
||||
echo " Glitz X11...............: $have_evas_glitz_x11"
|
||||
echo " Software 16bit X11......: $have_evas_software_16_x11"
|
||||
# FIXME: opengl engine needs to be fixed and tested lots for all drivers
|
||||
# FIXME: xrender engine to be written
|
||||
echo
|
||||
|
|
|
@ -66,7 +66,9 @@ typedef enum _Evas_Colorspace
|
|||
EVAS_COLORSPACE_ARGB8888, /**< ARGB 32 bits per pixel, high-byte is Alpha, accessed 1 32bit word at a time */
|
||||
/* these are not currently supported - but planned for the future */
|
||||
EVAS_COLORSPACE_YCBCR422P601_PL, /**< YCbCr 4:2:2 Planar, ITU.BT-601 specifications. The data poitned to is just an array of row pointer, pointing to the Y rows, then the Cb, then Cr rows */
|
||||
EVAS_COLORSPACE_YCBCR422P709_PL /**< YCbCr 4:2:2 Planar, ITU.BT-709 specifications. The data poitned to is just an array of row pointer, pointing to the Y rows, then the Cb, then Cr rows */
|
||||
EVAS_COLORSPACE_YCBCR422P709_PL,/**< YCbCr 4:2:2 Planar, ITU.BT-709 specifications. The data poitned to is just an array of row pointer, pointing to the Y rows, then the Cb, then Cr rows */
|
||||
EVAS_COLORSPACE_RGB565, /**< 16bit rgb565 */
|
||||
EVAS_COLORSPACE_RGB565_A5P /**< 16bit rgb565 + Alpha plane at end - 5 bits of the 8 being used per alpha byte */
|
||||
} Evas_Colorspace; /**< Colorspaces for pixel data supported by Evas */
|
||||
|
||||
typedef struct _Evas_List Evas_List; /**< A generic linked list node handle */
|
||||
|
|
|
@ -692,7 +692,7 @@ evas_render_method_list(void)
|
|||
{
|
||||
Evas_List *methods = NULL;
|
||||
|
||||
/* FIXME: get from modules */
|
||||
/* FIXME: get from modules - this is currently coded-in */
|
||||
#ifdef BUILD_ENGINE_SOFTWARE_X11
|
||||
methods = evas_list_append(methods, strdup("software_x11"));
|
||||
#endif
|
||||
|
@ -705,6 +705,9 @@ evas_render_method_list(void)
|
|||
#ifdef BUILD_ENGINE_XRENDER_XCB
|
||||
methods = evas_list_append(methods, strdup("xrender_xcb"));
|
||||
#endif
|
||||
#ifdef BUILD_ENGINE_SOFTWARE_16_X11
|
||||
methods = evas_list_append(methods, strdup("software_16_x11"));
|
||||
#endif
|
||||
#ifdef BUILD_ENGINE_GL_X11
|
||||
methods = evas_list_append(methods, strdup("gl_x11"));
|
||||
#endif
|
||||
|
|
|
@ -425,7 +425,7 @@ evas_common_image_get_cache(void)
|
|||
EAPI void
|
||||
evas_common_image_store(RGBA_Image *im)
|
||||
{
|
||||
char buf[4096 + 1204];
|
||||
char buf[4096 + 1024];
|
||||
|
||||
if (im->flags & RGBA_IMAGE_IS_DIRTY) return;
|
||||
if (im->flags & RGBA_IMAGE_INDEXED) return;
|
||||
|
|
|
@ -15,4 +15,6 @@ software_x11 \
|
|||
software_xcb \
|
||||
xrender_x11 \
|
||||
xrender_xcb \
|
||||
glitz_x11
|
||||
glitz_x11 \
|
||||
software_16 \
|
||||
software_16_x11
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
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 @FREETYPE_CFLAGS@
|
||||
|
||||
if BUILD_ENGINE_SOFTWARE_16
|
||||
|
||||
pkgdir = $(libdir)/evas/modules/engines/software_16/$(MODULE_ARCH)
|
||||
|
||||
pkg_LTLIBRARIES = module.la
|
||||
module_la_SOURCES = \
|
||||
evas_engine.c \
|
||||
evas_soft16.h \
|
||||
evas_soft16_main.c
|
||||
|
||||
module_la_LIBADD = $(top_builddir)/src/lib/libevas.la
|
||||
module_la_LDFLAGS = -module -avoid-version -L$(top_builddir)/src/lib -L$(top_builddir)/src/lib/.libs
|
||||
module_la_DEPENDENCIES = $(top_builddir)/config.h
|
||||
|
||||
endif
|
||||
|
||||
EXTRA_DIST = \
|
||||
evas_engine.c \
|
||||
evas_soft16.h \
|
||||
evas_soft16_main.c
|
|
@ -0,0 +1,763 @@
|
|||
#include "evas_common.h"
|
||||
#include "evas_private.h"
|
||||
#include "evas_soft16.h"
|
||||
|
||||
/*
|
||||
*****
|
||||
**
|
||||
** ENGINE ROUTINES
|
||||
**
|
||||
*****
|
||||
*/
|
||||
|
||||
static int cpunum = 0;
|
||||
|
||||
static void *
|
||||
eng_context_new(void *data)
|
||||
{
|
||||
return evas_common_draw_context_new();
|
||||
}
|
||||
|
||||
static void
|
||||
eng_context_free(void *data, void *context)
|
||||
{
|
||||
evas_common_draw_context_free(context);
|
||||
}
|
||||
|
||||
static void
|
||||
eng_context_clip_set(void *data, void *context, int x, int y, int w, int h)
|
||||
{
|
||||
evas_common_draw_context_set_clip(context, x, y, w, h);
|
||||
}
|
||||
|
||||
static void
|
||||
eng_context_clip_clip(void *data, void *context, int x, int y, int w, int h)
|
||||
{
|
||||
evas_common_draw_context_clip_clip(context, x, y, w, h);
|
||||
}
|
||||
|
||||
static void
|
||||
eng_context_clip_unset(void *data, void *context)
|
||||
{
|
||||
evas_common_draw_context_unset_clip(context);
|
||||
}
|
||||
|
||||
static int
|
||||
eng_context_clip_get(void *data, void *context, int *x, int *y, int *w, int *h)
|
||||
{
|
||||
*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
|
||||
eng_context_color_set(void *data, void *context, int r, int g, int b, int a)
|
||||
{
|
||||
evas_common_draw_context_set_color(context, r, g, b, a);
|
||||
}
|
||||
|
||||
static int
|
||||
eng_context_color_get(void *data, void *context, int *r, int *g, int *b, int *a)
|
||||
{
|
||||
*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
|
||||
eng_context_multiplier_set(void *data, void *context, int r, int g, int b, int a)
|
||||
{
|
||||
evas_common_draw_context_set_multiplier(context, r, g, b, a);
|
||||
}
|
||||
|
||||
static void
|
||||
eng_context_multiplier_unset(void *data, void *context)
|
||||
{
|
||||
evas_common_draw_context_unset_multiplier(context);
|
||||
}
|
||||
|
||||
static int
|
||||
eng_context_multiplier_get(void *data, void *context, int *r, int *g, int *b, int *a)
|
||||
{
|
||||
*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
|
||||
eng_context_cutout_add(void *data, void *context, int x, int y, int w, int h)
|
||||
{
|
||||
evas_common_draw_context_add_cutout(context, x, y, w, h);
|
||||
}
|
||||
|
||||
static void
|
||||
eng_context_cutout_clear(void *data, void *context)
|
||||
{
|
||||
evas_common_draw_context_clear_cutouts(context);
|
||||
}
|
||||
|
||||
static void
|
||||
eng_context_anti_alias_set(void *data, void *context, unsigned char aa)
|
||||
{
|
||||
evas_common_draw_context_set_anti_alias(context, aa);
|
||||
}
|
||||
|
||||
static unsigned char
|
||||
eng_context_anti_alias_get(void *data, void *context)
|
||||
{
|
||||
return ((RGBA_Draw_Context *)context)->anti_alias;
|
||||
}
|
||||
|
||||
static void
|
||||
eng_context_color_interpolation_set(void *data, void *context, int color_space)
|
||||
{
|
||||
evas_common_draw_context_set_color_interpolation(context, color_space);
|
||||
}
|
||||
|
||||
static int
|
||||
eng_context_color_interpolation_get(void *data, void *context)
|
||||
{
|
||||
return ((RGBA_Draw_Context *)context)->interpolation.color_space;
|
||||
}
|
||||
|
||||
static void
|
||||
eng_context_render_op_set(void *data, void *context, int op)
|
||||
{
|
||||
evas_common_draw_context_set_render_op(context, op);
|
||||
}
|
||||
|
||||
static int
|
||||
eng_context_render_op_get(void *data, void *context)
|
||||
{
|
||||
return ((RGBA_Draw_Context *)context)->render_op;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
eng_rectangle_draw(void *data, void *context, void *surface, int x, int y, int w, int h)
|
||||
{
|
||||
// evas_common_rectangle_draw(surface, context, x, y, w, h);
|
||||
// evas_common_cpu_end_opt();
|
||||
}
|
||||
|
||||
static void
|
||||
eng_line_draw(void *data, void *context, void *surface, int x1, int y1, int x2, int y2)
|
||||
{
|
||||
// evas_common_line_draw(surface, context, x1, y1, x2, y2);
|
||||
// evas_common_cpu_end_opt();
|
||||
}
|
||||
|
||||
static void *
|
||||
eng_polygon_point_add(void *data, void *context, void *polygon, int x, int y)
|
||||
{
|
||||
return NULL;
|
||||
// return evas_common_polygon_point_add(polygon, x, y);
|
||||
}
|
||||
|
||||
static void *
|
||||
eng_polygon_points_clear(void *data, void *context, void *polygon)
|
||||
{
|
||||
return NULL;
|
||||
// return evas_common_polygon_points_clear(polygon);
|
||||
}
|
||||
|
||||
static void
|
||||
eng_polygon_draw(void *data, void *context, void *surface, void *polygon)
|
||||
{
|
||||
// evas_common_polygon_draw(surface, context, polygon);
|
||||
// evas_common_cpu_end_opt();
|
||||
}
|
||||
|
||||
static void *
|
||||
eng_gradient_new(void *data)
|
||||
{
|
||||
return NULL;
|
||||
// return evas_common_gradient_new();
|
||||
}
|
||||
|
||||
static void
|
||||
eng_gradient_free(void *data, void *gradient)
|
||||
{
|
||||
// evas_common_gradient_free(gradient);
|
||||
}
|
||||
|
||||
static void
|
||||
eng_gradient_color_stop_add(void *data, void *gradient, int r, int g, int b, int a, int delta)
|
||||
{
|
||||
// evas_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_common_gradient_alpha_stop_add(gradient, a, delta);
|
||||
}
|
||||
|
||||
static void
|
||||
eng_gradient_color_data_set(void *data, void *gradient, void *map, int len, int has_alpha)
|
||||
{
|
||||
// evas_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_common_gradient_alpha_data_set(gradient, alpha_map, len);
|
||||
}
|
||||
|
||||
static void
|
||||
eng_gradient_clear(void *data, void *gradient)
|
||||
{
|
||||
// evas_common_gradient_clear(gradient);
|
||||
}
|
||||
|
||||
static void
|
||||
eng_gradient_fill_set(void *data, void *gradient, int x, int y, int w, int h)
|
||||
{
|
||||
// evas_common_gradient_fill_set(gradient, x, y, w, h);
|
||||
}
|
||||
|
||||
static void
|
||||
eng_gradient_fill_angle_set(void *data, void *gradient, double angle)
|
||||
{
|
||||
// evas_common_gradient_fill_angle_set(gradient, angle);
|
||||
}
|
||||
|
||||
static void
|
||||
eng_gradient_fill_spread_set(void *data, void *gradient, int spread)
|
||||
{
|
||||
// evas_common_gradient_fill_spread_set(gradient, spread);
|
||||
}
|
||||
|
||||
static void
|
||||
eng_gradient_angle_set(void *data, void *gradient, double angle)
|
||||
{
|
||||
// evas_common_gradient_map_angle_set(gradient, angle);
|
||||
}
|
||||
|
||||
static void
|
||||
eng_gradient_offset_set(void *data, void *gradient, float offset)
|
||||
{
|
||||
// evas_common_gradient_map_offset_set(gradient, offset);
|
||||
}
|
||||
|
||||
static void
|
||||
eng_gradient_direction_set(void *data, void *gradient, int direction)
|
||||
{
|
||||
// evas_common_gradient_map_direction_set(gradient, direction);
|
||||
}
|
||||
|
||||
static void
|
||||
eng_gradient_type_set(void *data, void *gradient, char *name, char *params)
|
||||
{
|
||||
// evas_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)
|
||||
{
|
||||
return 0;
|
||||
// RGBA_Draw_Context *dc = (RGBA_Draw_Context *)context;
|
||||
// RGBA_Gradient *gr = (RGBA_Gradient *)gradient;
|
||||
//
|
||||
// if (!dc || !gr || !gr->type.geometer) return 0;
|
||||
// return !(gr->type.geometer->has_alpha(gr, dc->render_op) |
|
||||
// gr->type.geometer->has_mask(gr, dc->render_op));
|
||||
}
|
||||
|
||||
static int
|
||||
eng_gradient_is_visible(void *data, void *context, void *gradient, int x, int y, int w, int h)
|
||||
{
|
||||
return 0;
|
||||
// RGBA_Draw_Context *dc = (RGBA_Draw_Context *)context;
|
||||
//
|
||||
// if (!dc || !gradient) return 0;
|
||||
// return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
eng_gradient_render_pre(void *data, void *context, void *gradient)
|
||||
{
|
||||
// RGBA_Draw_Context *dc = (RGBA_Draw_Context *)context;
|
||||
// RGBA_Gradient *gr = (RGBA_Gradient *)gradient;
|
||||
// int len;
|
||||
//
|
||||
// if (!dc || !gr || !gr->type.geometer) return;
|
||||
// gr->type.geometer->geom_set(gr);
|
||||
// len = gr->type.geometer->get_map_len(gr);
|
||||
// evas_common_gradient_map(dc, gr, len);
|
||||
}
|
||||
|
||||
static void
|
||||
eng_gradient_render_post(void *data, void *gradient)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
eng_gradient_draw(void *data, void *context, void *surface, void *gradient, int x, int y, int w, int h)
|
||||
{
|
||||
// evas_common_gradient_draw(surface, context, x, y, w, h, gradient);
|
||||
// evas_common_cpu_end_opt();
|
||||
}
|
||||
|
||||
static int
|
||||
eng_image_alpha_get(void *data, void *image)
|
||||
{
|
||||
Soft16_Image *im;
|
||||
|
||||
if (!image) return 0;
|
||||
im = image;
|
||||
if (im->have_alpha) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
eng_image_colorspace_get(void *data, void *image)
|
||||
{
|
||||
Soft16_Image *im;
|
||||
|
||||
if (!image) return EVAS_COLORSPACE_RGB565;
|
||||
im = image;
|
||||
if (im->have_alpha) return EVAS_COLORSPACE_RGB565_A5P;
|
||||
return EVAS_COLORSPACE_RGB565;
|
||||
}
|
||||
|
||||
static void *
|
||||
eng_image_alpha_set(void *data, void *image, int has_alpha)
|
||||
{
|
||||
// FIXME: implement
|
||||
return image;
|
||||
}
|
||||
|
||||
static void *
|
||||
eng_image_border_set(void *data, void *image, int l, int r, int t, int b)
|
||||
{
|
||||
return image;
|
||||
}
|
||||
|
||||
static void
|
||||
eng_image_border_get(void *data, void *image, int *l, int *r, int *t, int *b)
|
||||
{
|
||||
}
|
||||
|
||||
static char *
|
||||
eng_image_comment_get(void *data, void *image, char *key)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static char *
|
||||
eng_image_format_get(void *data, void *image)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
eng_image_colorspace_set(void *data, void *image, int cspace)
|
||||
{
|
||||
// FIXME: implement
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
return soft16_image_load(file, key, error, lo);
|
||||
}
|
||||
|
||||
static void *
|
||||
eng_image_new_from_data(void *data, int w, int h, DATA32 *image_data, int alpha, int cspace)
|
||||
{
|
||||
// FIXME: implement
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void *
|
||||
eng_image_new_from_copied_data(void *data, int w, int h, DATA32 *image_data, int alpha, int cspace)
|
||||
{
|
||||
// FIXME: implement
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
eng_image_free(void *data, void *image)
|
||||
{
|
||||
soft16_image_free(image);
|
||||
}
|
||||
|
||||
static void
|
||||
eng_image_size_get(void *data, void *image, int *w, int *h)
|
||||
{
|
||||
Soft16_Image *im;
|
||||
|
||||
if (w) *w = 0;
|
||||
if (h) *h = 0;
|
||||
if (!image) return;
|
||||
im = image;
|
||||
if (w) *w = im->w;
|
||||
if (h) *h = im->h;
|
||||
}
|
||||
|
||||
static void *
|
||||
eng_image_size_set(void *data, void *image, int w, int h)
|
||||
{
|
||||
// FIXME: implement
|
||||
return image;
|
||||
}
|
||||
|
||||
static void *
|
||||
eng_image_dirty_region(void *data, void *image, int x, int y, int w, int h)
|
||||
{
|
||||
// FIXME: implement
|
||||
return image;
|
||||
}
|
||||
|
||||
static void *
|
||||
eng_image_data_get(void *data, void *image, int to_write, DATA32 **image_data)
|
||||
{
|
||||
// FIXME: implement
|
||||
*image_data = NULL;
|
||||
return image;
|
||||
}
|
||||
|
||||
static void *
|
||||
eng_image_data_put(void *data, void *image, DATA32 *image_data)
|
||||
{
|
||||
// FIXME: implement
|
||||
return image;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
soft16_image_load_data(image);
|
||||
soft16_image_draw(image, surface, context,
|
||||
src_x, src_y, src_w, src_h,
|
||||
dst_x, dst_y, dst_w, dst_h,
|
||||
smooth);
|
||||
}
|
||||
|
||||
static void
|
||||
eng_image_cache_flush(void *data)
|
||||
{
|
||||
int tmp_size;
|
||||
|
||||
tmp_size = evas_common_image_get_cache();
|
||||
evas_common_image_set_cache(0);
|
||||
evas_common_image_set_cache(tmp_size);
|
||||
}
|
||||
|
||||
static void
|
||||
eng_image_cache_set(void *data, int bytes)
|
||||
{
|
||||
evas_common_image_set_cache(bytes);
|
||||
}
|
||||
|
||||
static int
|
||||
eng_image_cache_get(void *data)
|
||||
{
|
||||
return evas_common_image_get_cache();
|
||||
}
|
||||
|
||||
static void *
|
||||
eng_font_load(void *data, const char *name, int size)
|
||||
{
|
||||
return evas_common_font_load(name, size);
|
||||
}
|
||||
|
||||
static void *
|
||||
eng_font_memory_load(void *data, char *name, int size, const void *fdata, int fdata_size)
|
||||
{
|
||||
return evas_common_font_memory_load(name, size, fdata, fdata_size);
|
||||
}
|
||||
|
||||
static void *
|
||||
eng_font_add(void *data, void *font, const char *name, int size)
|
||||
{
|
||||
return evas_common_font_add(font, name, size);
|
||||
}
|
||||
|
||||
static void *
|
||||
eng_font_memory_add(void *data, void *font, char *name, int size, const void *fdata, int fdata_size)
|
||||
{
|
||||
return evas_common_font_memory_add(font, name, size, fdata, fdata_size);
|
||||
}
|
||||
|
||||
static void
|
||||
eng_font_free(void *data, void *font)
|
||||
{
|
||||
evas_common_font_free(font);
|
||||
}
|
||||
|
||||
static int
|
||||
eng_font_ascent_get(void *data, void *font)
|
||||
{
|
||||
return evas_common_font_ascent_get(font);
|
||||
}
|
||||
|
||||
static int
|
||||
eng_font_descent_get(void *data, void *font)
|
||||
{
|
||||
return evas_common_font_descent_get(font);
|
||||
}
|
||||
|
||||
static int
|
||||
eng_font_max_ascent_get(void *data, void *font)
|
||||
{
|
||||
return evas_common_font_max_ascent_get(font);
|
||||
}
|
||||
|
||||
static int
|
||||
eng_font_max_descent_get(void *data, void *font)
|
||||
{
|
||||
return evas_common_font_max_descent_get(font);
|
||||
}
|
||||
|
||||
static void
|
||||
eng_font_string_size_get(void *data, void *font, const char *text, int *w, int *h)
|
||||
{
|
||||
evas_common_font_query_size(font, text, w, h);
|
||||
}
|
||||
|
||||
static int
|
||||
eng_font_inset_get(void *data, void *font, const char *text)
|
||||
{
|
||||
return evas_common_font_query_inset(font, text);
|
||||
}
|
||||
|
||||
static int
|
||||
eng_font_h_advance_get(void *data, void *font, const char *text)
|
||||
{
|
||||
int h, v;
|
||||
|
||||
evas_common_font_query_advance(font, text, &h, &v);
|
||||
return h;
|
||||
}
|
||||
|
||||
static int
|
||||
eng_font_v_advance_get(void *data, void *font, const char *text)
|
||||
{
|
||||
int h, v;
|
||||
|
||||
evas_common_font_query_advance(font, text, &h, &v);
|
||||
return v;
|
||||
}
|
||||
|
||||
static int
|
||||
eng_font_char_coords_get(void *data, void *font, const char *text, int pos, int *cx, int *cy, int *cw, int *ch)
|
||||
{
|
||||
return evas_common_font_query_char_coords(font, text, pos, cx, cy, cw, ch);
|
||||
}
|
||||
|
||||
static int
|
||||
eng_font_char_at_coords_get(void *data, void *font, const char *text, int x, int y, int *cx, int *cy, int *cw, int *ch)
|
||||
{
|
||||
return evas_common_font_query_text_at_pos(font, text, x, y, cx, cy, cw, ch);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
// evas_common_font_draw(surface, context, font, x, y, text);
|
||||
// evas_common_cpu_end_opt();
|
||||
}
|
||||
|
||||
static void
|
||||
eng_font_cache_flush(void *data)
|
||||
{
|
||||
evas_common_font_flush();
|
||||
}
|
||||
|
||||
static void
|
||||
eng_font_cache_set(void *data, int bytes)
|
||||
{
|
||||
evas_common_font_cache_set(bytes);
|
||||
}
|
||||
|
||||
static int
|
||||
eng_font_cache_get(void *data)
|
||||
{
|
||||
return evas_common_font_cache_get();
|
||||
}
|
||||
|
||||
static void
|
||||
eng_font_hinting_set(void *data, void *font, int hinting)
|
||||
{
|
||||
evas_common_font_hinting_set(font, hinting);
|
||||
}
|
||||
|
||||
static int
|
||||
eng_font_hinting_can_hint(void *data, int hinting)
|
||||
{
|
||||
return evas_common_hinting_available(hinting);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*****
|
||||
**
|
||||
** ENGINE API
|
||||
**
|
||||
*****
|
||||
*/
|
||||
|
||||
static Evas_Func func =
|
||||
{
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
/* draw context virtual methods */
|
||||
eng_context_new,
|
||||
eng_context_free,
|
||||
eng_context_clip_set,
|
||||
eng_context_clip_clip,
|
||||
eng_context_clip_unset,
|
||||
eng_context_clip_get,
|
||||
eng_context_color_set,
|
||||
eng_context_color_get,
|
||||
eng_context_multiplier_set,
|
||||
eng_context_multiplier_unset,
|
||||
eng_context_multiplier_get,
|
||||
eng_context_cutout_add,
|
||||
eng_context_cutout_clear,
|
||||
eng_context_anti_alias_set,
|
||||
eng_context_anti_alias_get,
|
||||
eng_context_color_interpolation_set,
|
||||
eng_context_color_interpolation_get,
|
||||
eng_context_render_op_set,
|
||||
eng_context_render_op_get,
|
||||
/* rect draw funcs */
|
||||
eng_rectangle_draw,
|
||||
/* line draw funcs */
|
||||
eng_line_draw,
|
||||
/* polygon draw funcs */
|
||||
eng_polygon_point_add,
|
||||
eng_polygon_points_clear,
|
||||
eng_polygon_draw,
|
||||
/* gradient draw funcs */
|
||||
eng_gradient_new,
|
||||
eng_gradient_free,
|
||||
eng_gradient_color_stop_add,
|
||||
eng_gradient_alpha_stop_add,
|
||||
eng_gradient_color_data_set,
|
||||
eng_gradient_alpha_data_set,
|
||||
eng_gradient_clear,
|
||||
eng_gradient_fill_set,
|
||||
eng_gradient_fill_angle_set,
|
||||
eng_gradient_fill_spread_set,
|
||||
eng_gradient_angle_set,
|
||||
eng_gradient_offset_set,
|
||||
eng_gradient_direction_set,
|
||||
eng_gradient_type_set,
|
||||
eng_gradient_is_opaque,
|
||||
eng_gradient_is_visible,
|
||||
eng_gradient_render_pre,
|
||||
eng_gradient_render_post,
|
||||
eng_gradient_draw,
|
||||
/* image draw funcs */
|
||||
eng_image_load,
|
||||
eng_image_new_from_data,
|
||||
eng_image_new_from_copied_data,
|
||||
eng_image_free,
|
||||
eng_image_size_get,
|
||||
eng_image_size_set,
|
||||
eng_image_dirty_region,
|
||||
eng_image_data_get,
|
||||
eng_image_data_put,
|
||||
eng_image_alpha_set,
|
||||
eng_image_alpha_get,
|
||||
eng_image_border_set,
|
||||
eng_image_border_get,
|
||||
eng_image_draw,
|
||||
eng_image_comment_get,
|
||||
eng_image_format_get,
|
||||
eng_image_colorspace_set,
|
||||
eng_image_colorspace_get,
|
||||
eng_image_native_set,
|
||||
eng_image_native_get,
|
||||
/* image cache funcs */
|
||||
eng_image_cache_flush,
|
||||
eng_image_cache_set,
|
||||
eng_image_cache_get,
|
||||
/* font draw functions */
|
||||
eng_font_load,
|
||||
eng_font_memory_load,
|
||||
eng_font_add,
|
||||
eng_font_memory_add,
|
||||
eng_font_free,
|
||||
eng_font_ascent_get,
|
||||
eng_font_descent_get,
|
||||
eng_font_max_ascent_get,
|
||||
eng_font_max_descent_get,
|
||||
eng_font_string_size_get,
|
||||
eng_font_inset_get,
|
||||
eng_font_h_advance_get,
|
||||
eng_font_v_advance_get,
|
||||
eng_font_char_coords_get,
|
||||
eng_font_char_at_coords_get,
|
||||
eng_font_draw,
|
||||
/* font cache functions */
|
||||
eng_font_cache_flush,
|
||||
eng_font_cache_set,
|
||||
eng_font_cache_get,
|
||||
/* font hinting functions */
|
||||
eng_font_hinting_set,
|
||||
eng_font_hinting_can_hint
|
||||
/* FUTURE software generic calls go here */
|
||||
};
|
||||
|
||||
/*
|
||||
*****
|
||||
**
|
||||
** MODULE ACCESSIBLE API API
|
||||
**
|
||||
*****
|
||||
*/
|
||||
|
||||
EAPI int
|
||||
module_open(Evas_Module *em)
|
||||
{
|
||||
if (!em) return 0;
|
||||
em->functions = (void *)(&func);
|
||||
cpunum = evas_common_cpu_count();
|
||||
return 1;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
module_close(void)
|
||||
{
|
||||
}
|
||||
|
||||
EAPI Evas_Module_Api evas_modapi =
|
||||
{
|
||||
EVAS_MODULE_API_VERSION,
|
||||
EVAS_MODULE_TYPE_ENGINE,
|
||||
"software_16",
|
||||
"none"
|
||||
};
|
|
@ -0,0 +1,45 @@
|
|||
#ifndef EVAS_SOFT16_H
|
||||
#define EVAS_SOFT16_H
|
||||
|
||||
#include "Evas.h"
|
||||
#include "evas_private.h"
|
||||
#include "evas_common.h"
|
||||
|
||||
typedef struct _Soft16_Image Soft16_Image;
|
||||
|
||||
struct _Soft16_Image
|
||||
{
|
||||
const char *file; // file source - optional
|
||||
const char *key; // key within file source - optional
|
||||
time_t timestamp; // file modified timestamp
|
||||
time_t laststat; // last time this file was statted
|
||||
int w, h; // width and height in pixels
|
||||
int stride; // pixel stride - likely a multiple of 2
|
||||
DATA16 *pixels; // 16bpp pixels rgb565
|
||||
DATA8 *alpha; // 8bit alpha mask - optional. points into pixels
|
||||
int references; // refcount
|
||||
RGBA_Image *source_im; // original source rgba image - if still reffed
|
||||
|
||||
Evas_Image_Load_Opts lo; // load options
|
||||
|
||||
unsigned char have_alpha : 1; // 1 if we have halpha
|
||||
unsigned char free_pixels : 1; // 1 if pixels should be freed
|
||||
unsigned char free_alpha : 1; // 1 if alpha mask should be freed
|
||||
};
|
||||
|
||||
Soft16_Image *soft16_image_new(int w, int h, int stride, int have_alpha,
|
||||
DATA16 *pixels, int copy);
|
||||
void soft16_image_free(Soft16_Image *im);
|
||||
Soft16_Image *soft16_image_load(const char *file, const char *key, int *error,
|
||||
Evas_Image_Load_Opts *lo);
|
||||
void soft16_image_load_data(Soft16_Image *im);
|
||||
void soft16_image_draw(Soft16_Image *src, Soft16_Image *dst,
|
||||
RGBA_Draw_Context *dc,
|
||||
int src_region_x, int src_region_y,
|
||||
int src_region_w, int src_region_h,
|
||||
int dst_region_x, int dst_region_y,
|
||||
int dst_region_w, int dst_region_h,
|
||||
int smooth);
|
||||
|
||||
|
||||
#endif
|
|
@ -0,0 +1,741 @@
|
|||
#include "evas_common.h"
|
||||
#include "evas_private.h"
|
||||
#include "evas_soft16.h"
|
||||
|
||||
#define BLEND(s, a, d) \
|
||||
{ DATA32 wsp, wdp; \
|
||||
wsp = (*s | (*s << 16)) & 0x07e0f81f; \
|
||||
wdp = (*d | (*d << 16)) & 0x07e0f81f; \
|
||||
wdp = (((wdp * (32 - *a)) >> 5) & 0x07e0f81f) + wsp; \
|
||||
*d = wdp | (wdp >> 16); \
|
||||
}
|
||||
|
||||
typedef void (*Scanline_Func) (DATA16 *s, DATA8 *a, DATA8 *m, DATA32 c, DATA16 *d, int l);
|
||||
|
||||
static void
|
||||
_soft16_image_rgba32_import(Soft16_Image *im, DATA32 *src);
|
||||
static void
|
||||
_soft16_image_draw_sampled_int(Soft16_Image *src, Soft16_Image *dst,
|
||||
RGBA_Draw_Context *dc,
|
||||
int src_region_x, int src_region_y,
|
||||
int src_region_w, int src_region_h,
|
||||
int dst_region_x, int dst_region_y,
|
||||
int dst_region_w, int dst_region_h);
|
||||
static void
|
||||
_soft16_scanline_blend(DATA16 *s, DATA8 *a, DATA8 *m, DATA32 c, DATA16 *d, int l);
|
||||
static void
|
||||
_soft16_scanline_copy(DATA16 *s, DATA8 *a, DATA8 *m, DATA32 c, DATA16 *d, int l);
|
||||
|
||||
static Evas_Hash *_soft16_image_cache_hash = NULL;
|
||||
|
||||
Soft16_Image *
|
||||
soft16_image_new(int w, int h, int stride, int have_alpha, DATA16 *pixels, int copy)
|
||||
{
|
||||
Soft16_Image *im;
|
||||
|
||||
im = calloc(1, sizeof(Soft16_Image));
|
||||
if (!im) return NULL;
|
||||
im->w = w;
|
||||
im->h = h;
|
||||
im->stride = w;
|
||||
if (copy)
|
||||
{
|
||||
if (have_alpha)
|
||||
{
|
||||
im->pixels = malloc((im->stride * im->h * sizeof(DATA16)) +
|
||||
(im->stride * im->h * sizeof(DATA8)));
|
||||
if (!im->pixels)
|
||||
{
|
||||
free(im);
|
||||
return NULL;
|
||||
}
|
||||
im->alpha = (DATA8 *)(im->pixels + (im->stride * im->h));
|
||||
if (pixels)
|
||||
memcpy(im->pixels, pixels,
|
||||
(im->stride * im->h * sizeof(DATA16)) +
|
||||
(im->stride * im->h * sizeof(DATA8)));
|
||||
}
|
||||
else
|
||||
{
|
||||
im->pixels = malloc(im->stride * im->h * sizeof(DATA16));
|
||||
if (!im->pixels)
|
||||
{
|
||||
free(im);
|
||||
return NULL;
|
||||
}
|
||||
if (pixels)
|
||||
memcpy(im->pixels, pixels,
|
||||
im->stride * im->h * sizeof(DATA16));
|
||||
}
|
||||
im->free_pixels = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
im->pixels = pixels;
|
||||
if (have_alpha) im->alpha = (DATA8 *)(im->pixels + (im->stride * im->h));
|
||||
}
|
||||
im->references = 1;
|
||||
return im;
|
||||
}
|
||||
|
||||
void
|
||||
soft16_image_free(Soft16_Image *im)
|
||||
{
|
||||
if (!im) return;
|
||||
im->references--;
|
||||
if (im->references > 0) return;
|
||||
if (im->file)
|
||||
{
|
||||
char buf[4096 + 1024];
|
||||
|
||||
if ((im->lo.scale_down_by == 0) && (im->lo.dpi == 0.0) &&
|
||||
((im->lo.w == 0) || (im->lo.h == 0)))
|
||||
{
|
||||
if (im->key)
|
||||
snprintf(buf, sizeof(buf), "%s//://%s", im->file, im->key);
|
||||
else
|
||||
snprintf(buf, sizeof(buf), "%s", im->file);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (im->key)
|
||||
snprintf(buf, sizeof(buf), "//@/%i/%1.5f/%ix%i//%s//://%s",
|
||||
im->lo.scale_down_by, im->lo.dpi, im->lo.w, im->lo.h,
|
||||
im->file, im->key);
|
||||
else
|
||||
snprintf(buf, sizeof(buf), "//@/%i/%1.5f/%ix%i//%s",
|
||||
im->lo.scale_down_by, im->lo.dpi, im->lo.w, im->lo.h,
|
||||
im->file);
|
||||
}
|
||||
_soft16_image_cache_hash = evas_hash_del(_soft16_image_cache_hash,
|
||||
buf, im);
|
||||
}
|
||||
if (im->file) evas_stringshare_del(im->file);
|
||||
if (im->key) evas_stringshare_del(im->key);
|
||||
if (im->free_pixels) free(im->pixels);
|
||||
free(im);
|
||||
}
|
||||
|
||||
#define STAT_GAP 2
|
||||
|
||||
Soft16_Image *
|
||||
soft16_image_load(const char *file, const char *key, int *error,
|
||||
Evas_Image_Load_Opts *lo)
|
||||
{
|
||||
Soft16_Image *im;
|
||||
RGBA_Image *sim;
|
||||
char buf[4096 + 1024];
|
||||
struct stat st;
|
||||
static time_t laststat = 0;
|
||||
time_t t, mt = 0;
|
||||
|
||||
*error = 0;
|
||||
if (!(lo) ||
|
||||
((lo->scale_down_by == 0) && (lo->dpi == 0.0) &&
|
||||
((lo->w == 0) || (lo->h == 0))))
|
||||
{
|
||||
if (key)
|
||||
snprintf(buf, sizeof(buf), "%s//://%s", file, key);
|
||||
else
|
||||
snprintf(buf, sizeof(buf), "%s", file);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (key)
|
||||
snprintf(buf, sizeof(buf), "//@/%i/%1.5f/%ix%i//%s//://%s",
|
||||
lo->scale_down_by, lo->dpi, lo->w, lo->h, file, key);
|
||||
else
|
||||
snprintf(buf, sizeof(buf), "//@/%i/%1.5f/%ix%i//%s",
|
||||
lo->scale_down_by, lo->dpi, lo->w, lo->h, file);
|
||||
}
|
||||
im = evas_hash_find(_soft16_image_cache_hash, buf);
|
||||
if (im)
|
||||
{
|
||||
if ((t - im->laststat) < STAT_GAP)
|
||||
{
|
||||
im->references++;
|
||||
return im;
|
||||
}
|
||||
else
|
||||
{
|
||||
struct stat st;
|
||||
|
||||
if (stat(file, &st) < 0) return NULL;
|
||||
mt = st.st_mtime;
|
||||
if (mt == im->timestamp)
|
||||
{
|
||||
im->laststat = t;
|
||||
laststat = t;
|
||||
im->references++;
|
||||
return im;
|
||||
}
|
||||
}
|
||||
}
|
||||
sim = evas_common_load_image_from_file(file, key, lo);
|
||||
if (!sim) return NULL;
|
||||
im = calloc(1, sizeof(Soft16_Image));
|
||||
if (!im)
|
||||
{
|
||||
evas_common_image_unref(sim);
|
||||
return NULL;
|
||||
}
|
||||
im->source_im = sim;
|
||||
im->w = im->source_im->image->w;
|
||||
im->h = im->source_im->image->h;
|
||||
im->stride = im->w;
|
||||
im->timestamp = im->source_im->timestamp;
|
||||
im->laststat = im->source_im->laststat;
|
||||
if (lo) im->lo = *lo;
|
||||
if (file) im->file = evas_stringshare_add(file);
|
||||
if (key) im->key = evas_stringshare_add(key);
|
||||
if (im->source_im->flags & RGBA_IMAGE_HAS_ALPHA) im->have_alpha = 1;
|
||||
im->references = 1;
|
||||
_soft16_image_cache_hash = evas_hash_add(_soft16_image_cache_hash, buf, im);
|
||||
return im;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
_soft16_image_rgba32_import(Soft16_Image *im, DATA32 *src)
|
||||
{
|
||||
DATA32 *sp, r, g, b, a;
|
||||
DATA16 *dp, *dpl;
|
||||
DATA8 *da, *dal;
|
||||
int x, y;
|
||||
|
||||
/* FIXME: dither and optimize */
|
||||
sp = src;
|
||||
dpl = im->pixels;
|
||||
dal = im->alpha;
|
||||
if (dal)
|
||||
{
|
||||
for (y = 0; y < im->h; y++)
|
||||
{
|
||||
dp = dpl;
|
||||
da = dal;
|
||||
for (x = 0; x < im->w; x++)
|
||||
{
|
||||
a = (A_VAL(sp) * 32) / 255;
|
||||
r = (R_VAL(sp) >> 3);
|
||||
g = (G_VAL(sp) >> 2);
|
||||
b = (B_VAL(sp) >> 3);
|
||||
/* FIXME: not sure about this yet - also need to check alpha is not letss that G when alpha is upscaled to 6bits */
|
||||
*da = a; /* scale 0-32 - yes, 1 over 5bits - makes bitshift math later work better */
|
||||
if ((*da << 1) < g) g--;
|
||||
*dp = (r << 11) | (g << 5) | (b);
|
||||
dp++;
|
||||
da++;
|
||||
sp++;
|
||||
}
|
||||
dpl += im->stride;
|
||||
dal += im->stride;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (y = 0; y < im->h; y++)
|
||||
{
|
||||
dp = dpl;
|
||||
for (x = 0; x < im->w; x++)
|
||||
{
|
||||
*dp =
|
||||
((R_VAL(sp) >> 3) << 11) |
|
||||
((G_VAL(sp) >> 2) << 5 ) |
|
||||
((B_VAL(sp) >> 3) );
|
||||
dp++;
|
||||
sp++;
|
||||
}
|
||||
dpl += im->stride;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
soft16_image_load_data(Soft16_Image *im)
|
||||
{
|
||||
if (!im) return;
|
||||
if (im->pixels) return;
|
||||
if (!im->source_im) return;
|
||||
|
||||
evas_common_load_image_data_from_file(im->source_im);
|
||||
if (im->source_im->image->data)
|
||||
{
|
||||
if (im->source_im->flags & RGBA_IMAGE_HAS_ALPHA)
|
||||
{
|
||||
im->pixels = malloc((im->stride * im->h * sizeof(DATA16)) +
|
||||
(im->stride * im->h * sizeof(DATA8)));
|
||||
if (!im->pixels) goto done;
|
||||
im->alpha = (DATA8 *)(im->pixels + (im->stride * im->h));
|
||||
}
|
||||
else
|
||||
{
|
||||
im->pixels = malloc(im->stride * im->h * sizeof(DATA16));
|
||||
if (!im->pixels) goto done;
|
||||
}
|
||||
_soft16_image_rgba32_import(im, im->source_im->image->data);
|
||||
im->free_pixels = 1;
|
||||
}
|
||||
done:
|
||||
evas_common_image_unref(im->source_im);
|
||||
im->source_im = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
_soft16_image_draw_sampled_int(Soft16_Image *src, Soft16_Image *dst,
|
||||
RGBA_Draw_Context *dc,
|
||||
int src_region_x, int src_region_y,
|
||||
int src_region_w, int src_region_h,
|
||||
int dst_region_x, int dst_region_y,
|
||||
int dst_region_w, int dst_region_h)
|
||||
{
|
||||
Scanline_Func func;
|
||||
int x, y;
|
||||
int *lin_ptr;
|
||||
DATA16 *buf, *dptr;
|
||||
DATA16 **row_ptr = NULL;
|
||||
DATA16 *ptr, *dst_ptr, *src_data, *dst_data;
|
||||
DATA8 *bufa, *daptr;
|
||||
DATA8 **rowa_ptr = NULL;
|
||||
DATA8 *aptr, *dsta_ptr, *srca_data, *dsta_data;
|
||||
int dst_jump, dst_stride, src_stride;
|
||||
int dst_clip_x, dst_clip_y, dst_clip_w, dst_clip_h;
|
||||
int src_w, src_h, dst_w, dst_h;
|
||||
|
||||
|
||||
if (!(RECTS_INTERSECT(dst_region_x, dst_region_y, dst_region_w, dst_region_h, 0, 0, dst->w, dst->h)))
|
||||
return;
|
||||
if (!(RECTS_INTERSECT(src_region_x, src_region_y, src_region_w, src_region_h, 0, 0, src->w, src->h)))
|
||||
return;
|
||||
|
||||
src_w = src->w;
|
||||
src_h = src->h;
|
||||
dst_w = dst->w;
|
||||
dst_h = dst->h;
|
||||
|
||||
if (dc->clip.use)
|
||||
{
|
||||
dst_clip_x = dc->clip.x;
|
||||
dst_clip_y = dc->clip.y;
|
||||
dst_clip_w = dc->clip.w;
|
||||
dst_clip_h = dc->clip.h;
|
||||
if (dst_clip_x < 0)
|
||||
{
|
||||
dst_clip_w += dst_clip_x;
|
||||
dst_clip_x = 0;
|
||||
}
|
||||
if (dst_clip_y < 0)
|
||||
{
|
||||
dst_clip_h += dst_clip_y;
|
||||
dst_clip_y = 0;
|
||||
}
|
||||
if ((dst_clip_x + dst_clip_w) > dst_w)
|
||||
dst_clip_w = dst_w - dst_clip_x;
|
||||
if ((dst_clip_y + dst_clip_h) > dst_h)
|
||||
dst_clip_h = dst_h - dst_clip_y;
|
||||
}
|
||||
else
|
||||
{
|
||||
dst_clip_x = 0;
|
||||
dst_clip_y = 0;
|
||||
dst_clip_w = dst_w;
|
||||
dst_clip_h = dst_h;
|
||||
}
|
||||
|
||||
if (dst_clip_x < dst_region_x)
|
||||
{
|
||||
dst_clip_w += dst_clip_x - dst_region_x;
|
||||
dst_clip_x = dst_region_x;
|
||||
}
|
||||
if ((dst_clip_x + dst_clip_w) > (dst_region_x + dst_region_w))
|
||||
dst_clip_w = dst_region_x + dst_region_w - dst_clip_x;
|
||||
if (dst_clip_y < dst_region_y)
|
||||
{
|
||||
dst_clip_h += dst_clip_y - dst_region_y;
|
||||
dst_clip_y = dst_region_y;
|
||||
}
|
||||
if ((dst_clip_y + dst_clip_h) > (dst_region_y + dst_region_h))
|
||||
dst_clip_h = dst_region_y + dst_region_h - dst_clip_y;
|
||||
|
||||
if ((src_region_w <= 0) || (src_region_h <= 0) ||
|
||||
(dst_region_w <= 0) || (dst_region_h <= 0) ||
|
||||
(dst_clip_w <= 0) || (dst_clip_h <= 0))
|
||||
return;
|
||||
|
||||
/* sanitise x */
|
||||
if (src_region_x < 0)
|
||||
{
|
||||
dst_region_x -= (src_region_x * dst_region_w) / src_region_w;
|
||||
dst_region_w += (src_region_x * dst_region_w) / src_region_w;
|
||||
src_region_w += src_region_x;
|
||||
src_region_x = 0;
|
||||
}
|
||||
if (src_region_x >= src_w) return;
|
||||
if ((src_region_x + src_region_w) > src_w)
|
||||
{
|
||||
dst_region_w = (dst_region_w * (src_w - src_region_x)) / (src_region_w);
|
||||
src_region_w = src_w - src_region_x;
|
||||
}
|
||||
if (dst_region_w <= 0) return;
|
||||
if (src_region_w <= 0) return;
|
||||
if (dst_clip_x < 0)
|
||||
{
|
||||
dst_clip_w += dst_clip_x;
|
||||
dst_clip_x = 0;
|
||||
}
|
||||
if (dst_clip_w <= 0) return;
|
||||
if (dst_clip_x >= dst_w) return;
|
||||
if (dst_clip_x < dst_region_x)
|
||||
{
|
||||
dst_clip_w += (dst_clip_x - dst_region_x);
|
||||
dst_clip_x = dst_region_x;
|
||||
}
|
||||
if ((dst_clip_x + dst_clip_w) > dst_w)
|
||||
{
|
||||
dst_clip_w = dst_w - dst_clip_x;
|
||||
}
|
||||
if (dst_clip_w <= 0) return;
|
||||
|
||||
/* sanitise y */
|
||||
if (src_region_y < 0)
|
||||
{
|
||||
dst_region_y -= (src_region_y * dst_region_h) / src_region_h;
|
||||
dst_region_h += (src_region_y * dst_region_h) / src_region_h;
|
||||
src_region_h += src_region_y;
|
||||
src_region_y = 0;
|
||||
}
|
||||
if (src_region_y >= src_h) return;
|
||||
if ((src_region_y + src_region_h) > src_h)
|
||||
{
|
||||
dst_region_h = (dst_region_h * (src_h - src_region_y)) / (src_region_h);
|
||||
src_region_h = src_h - src_region_y;
|
||||
}
|
||||
if (dst_region_h <= 0) return;
|
||||
if (src_region_h <= 0) return;
|
||||
if (dst_clip_y < 0)
|
||||
{
|
||||
dst_clip_h += dst_clip_y;
|
||||
dst_clip_y = 0;
|
||||
}
|
||||
if (dst_clip_h <= 0) return;
|
||||
if (dst_clip_y >= dst_h) return;
|
||||
if (dst_clip_y < dst_region_y)
|
||||
{
|
||||
dst_clip_h += (dst_clip_y - dst_region_y);
|
||||
dst_clip_y = dst_region_y;
|
||||
}
|
||||
if ((dst_clip_y + dst_clip_h) > dst_h)
|
||||
{
|
||||
dst_clip_h = dst_h - dst_clip_y;
|
||||
}
|
||||
if (dst_clip_h <= 0) return;
|
||||
|
||||
src_data = src->pixels;
|
||||
srca_data = src->alpha;
|
||||
dst_data = dst->pixels;
|
||||
dsta_data = dst->alpha;
|
||||
|
||||
dst_stride = dst->stride;
|
||||
src_stride = src->stride;
|
||||
|
||||
/* figure out dest start ptr */
|
||||
dst_ptr = dst_data + dst_clip_x + (dst_clip_y * dst_stride);
|
||||
dsta_ptr = dsta_data + dst_clip_x + (dst_clip_y * dst_stride);
|
||||
|
||||
func = _soft16_scanline_copy;
|
||||
if (( src->alpha) && ( dst->alpha)) func = _soft16_scanline_blend;
|
||||
else if (( src->alpha) && (!dst->alpha)) func = _soft16_scanline_blend;
|
||||
else if ((!src->alpha) && ( dst->alpha)) func = _soft16_scanline_copy;
|
||||
else if ((!src->alpha) && (!dst->alpha)) func = _soft16_scanline_copy;
|
||||
|
||||
/* not being scaled at all */
|
||||
if ((dst_region_w == src_region_w) && (dst_region_h == src_region_h))
|
||||
{
|
||||
ptr = src_data + ((dst_clip_y - dst_region_y + src_region_y) * src_stride) + (dst_clip_x - dst_region_x) + src_region_x;
|
||||
aptr = srca_data + ((dst_clip_y - dst_region_y + src_region_y) * src_stride) + (dst_clip_x - dst_region_x) + src_region_x;
|
||||
for (y = 0; y < dst_clip_h; y++)
|
||||
{
|
||||
/* * blend here [clip_w *] ptr -> dst_ptr * */
|
||||
func(ptr, aptr, NULL, dc->mul.col, dst_ptr, dst_clip_w);
|
||||
ptr += src_stride;
|
||||
aptr += src_stride;
|
||||
dst_ptr += dst_stride;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* allocate scale lookup tables */
|
||||
lin_ptr = alloca(dst_clip_w * sizeof(int));
|
||||
row_ptr = alloca(dst_clip_h * sizeof(DATA16 *));
|
||||
rowa_ptr = alloca(dst_clip_h * sizeof(DATA8 *));
|
||||
|
||||
/* fill scale tables */
|
||||
for (x = 0; x < dst_clip_w; x++)
|
||||
lin_ptr[x] = (((x + dst_clip_x - dst_region_x) * src_region_w) / dst_region_w) + src_region_x;
|
||||
for (y = 0; y < dst_clip_h; y++)
|
||||
{
|
||||
row_ptr[y] = src_data +
|
||||
(((((y + dst_clip_y - dst_region_y) * src_region_h) /
|
||||
dst_region_h) + src_region_y) * src_stride);
|
||||
rowa_ptr[y] = srca_data +
|
||||
(((((y + dst_clip_y - dst_region_y) * src_region_h) /
|
||||
dst_region_h) + src_region_y) * src_stride);
|
||||
}
|
||||
/* scale to dst */
|
||||
dptr = dst_ptr;
|
||||
daptr = dsta_ptr;
|
||||
if ((!(src->alpha)) && (!(dst->alpha)) && (!dc->mul.use))
|
||||
{
|
||||
for (y = 0; y < dst_clip_h; y++)
|
||||
{
|
||||
dst_ptr = dptr;
|
||||
for (x = 0; x < dst_clip_w; x++)
|
||||
{
|
||||
ptr = row_ptr[y] + lin_ptr[x];
|
||||
*dst_ptr = *ptr;
|
||||
dst_ptr++;
|
||||
}
|
||||
dptr += dst_stride;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* a scanline buffer */
|
||||
buf = alloca(dst_clip_w * sizeof(DATA16) * 2);
|
||||
if (src->alpha)
|
||||
{
|
||||
bufa = alloca(dst_clip_w * sizeof(DATA8) * 2);
|
||||
for (y = 0; y < dst_clip_h; y++)
|
||||
{
|
||||
dst_ptr = dptr;
|
||||
for (x = 0; x < dst_clip_w; x++)
|
||||
{
|
||||
ptr = row_ptr[y] + lin_ptr[x];
|
||||
aptr = rowa_ptr[y] + lin_ptr[x];
|
||||
BLEND(ptr, aptr, dst_ptr);
|
||||
dst_ptr++;
|
||||
}
|
||||
/*
|
||||
dst_ptr = buf;
|
||||
dsta_ptr = bufa;
|
||||
for (x = 0; x < dst_clip_w; x++)
|
||||
{
|
||||
ptr = row_ptr[y] + lin_ptr[x];
|
||||
*dst_ptr = *ptr;
|
||||
dst_ptr++;
|
||||
|
||||
aptr = rowa_ptr[y] + lin_ptr[x];
|
||||
*dsta_ptr = *aptr;
|
||||
dsta_ptr++;
|
||||
}
|
||||
func(buf, bufa, NULL, dc->mul.col, dptr, dst_clip_w);
|
||||
*/
|
||||
dptr += dst_stride;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (y = 0; y < dst_clip_h; y++)
|
||||
{
|
||||
dst_ptr = dptr;
|
||||
for (x = 0; x < dst_clip_w; x++)
|
||||
{
|
||||
ptr = row_ptr[y] + lin_ptr[x];
|
||||
*dst_ptr = *ptr;
|
||||
dst_ptr++;
|
||||
}
|
||||
/*
|
||||
dst_ptr = buf;
|
||||
for (x = 0; x < dst_clip_w; x++)
|
||||
{
|
||||
ptr = row_ptr[y] + lin_ptr[x];
|
||||
*dst_ptr = *ptr;
|
||||
dst_ptr++;
|
||||
}
|
||||
func(buf, NULL, NULL, dc->mul.col, dptr, dst_clip_w);
|
||||
*/
|
||||
dptr += dst_stride;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
soft16_image_draw(Soft16_Image *src, Soft16_Image *dst,
|
||||
RGBA_Draw_Context *dc,
|
||||
int src_region_x, int src_region_y,
|
||||
int src_region_w, int src_region_h,
|
||||
int dst_region_x, int dst_region_y,
|
||||
int dst_region_w, int dst_region_h,
|
||||
int smooth)
|
||||
{
|
||||
Cutout_Rects *rects;
|
||||
Cutout_Rect *r;
|
||||
int c, cx, cy, cw, ch;
|
||||
int i;
|
||||
/* handle cutouts here! */
|
||||
|
||||
if ((dst_region_w <= 0) || (dst_region_h <= 0)) return;
|
||||
if (!(RECTS_INTERSECT(dst_region_x, dst_region_y, dst_region_w, dst_region_h, 0, 0, dst->w, dst->h)))
|
||||
return;
|
||||
/* no cutouts - cut right to the chase */
|
||||
if (!dc->cutout.rects)
|
||||
{
|
||||
_soft16_image_draw_sampled_int(src, dst, dc,
|
||||
src_region_x, src_region_y,
|
||||
src_region_w, src_region_h,
|
||||
dst_region_x, dst_region_y,
|
||||
dst_region_w, dst_region_h);
|
||||
return;
|
||||
}
|
||||
/* save out clip info */
|
||||
c = dc->clip.use; cx = dc->clip.x; cy = dc->clip.y; cw = dc->clip.w; ch = dc->clip.h;
|
||||
evas_common_draw_context_clip_clip(dc, 0, 0, dst->w, dst->h);
|
||||
evas_common_draw_context_clip_clip(dc, dst_region_x, dst_region_y, dst_region_w, dst_region_h);
|
||||
/* our clip is 0 size.. abort */
|
||||
if ((dc->clip.w <= 0) || (dc->clip.h <= 0))
|
||||
{
|
||||
dc->clip.use = c; dc->clip.x = cx; dc->clip.y = cy; dc->clip.w = cw; dc->clip.h = ch;
|
||||
return;
|
||||
}
|
||||
rects = evas_common_draw_context_apply_cutouts(dc);
|
||||
for (i = 0; i < rects->active; i++)
|
||||
{
|
||||
r = rects->rects + i;
|
||||
evas_common_draw_context_set_clip(dc, r->x, r->y, r->w, r->h);
|
||||
_soft16_image_draw_sampled_int(src, dst, dc,
|
||||
src_region_x, src_region_y,
|
||||
src_region_w, src_region_h,
|
||||
dst_region_x, dst_region_y,
|
||||
dst_region_w, dst_region_h);
|
||||
|
||||
}
|
||||
evas_common_draw_context_apply_clear_cutouts(rects);
|
||||
/* restore clip info */
|
||||
dc->clip.use = c; dc->clip.x = cx; dc->clip.y = cy; dc->clip.w = cw; dc->clip.h = ch;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
_soft16_scanline_blend(DATA16 *s, DATA8 *a, DATA8 *m, DATA32 c, DATA16 *d, int l)
|
||||
{
|
||||
DATA16 *e = d + l;
|
||||
DATA32 wsp, wdp;
|
||||
DATA32 xsp, xdp;
|
||||
DATA32 ysp, ydp;
|
||||
DATA32 zsp, zdp;
|
||||
|
||||
/*
|
||||
if (((unsigned long)(((DATA8 *)s)) & 0x3) ==
|
||||
(((unsigned long)((DATA8 *)d)) & 0x3))
|
||||
{
|
||||
if (((unsigned long)(((DATA8 *)s)) & 0x3) == 2)
|
||||
{
|
||||
wsp = (*s | (*s << 16)) & 0x07e0f81f;
|
||||
wdp = (*d | (*d << 16)) & 0x07e0f81f;
|
||||
wdp = (((wdp * (32 - *a)) >> 5) & 0x07e0f81f) + wsp;
|
||||
*d = wdp | (wdp >> 16);
|
||||
s++; a++; d++;
|
||||
}
|
||||
e -= 3;
|
||||
while (d < e)
|
||||
{
|
||||
wsp = (s[0] | (s[0] << 16)) & 0x07e0f81f;
|
||||
xsp = (s[1] | (s[1] << 16)) & 0x07e0f81f;
|
||||
ysp = (s[2] | (s[2] << 16)) & 0x07e0f81f;
|
||||
zsp = (s[3] | (s[3] << 16)) & 0x07e0f81f;
|
||||
wdp = (d[0] | (d[0] << 16)) & 0x07e0f81f;
|
||||
xdp = (d[1] | (d[1] << 16)) & 0x07e0f81f;
|
||||
ydp = (d[2] | (d[2] << 16)) & 0x07e0f81f;
|
||||
zdp = (d[3] | (d[3] << 16)) & 0x07e0f81f;
|
||||
wdp = (((wdp * (32 - a[0])) >> 5) & 0x07e0f81f) + wsp;
|
||||
xdp = (((xdp * (32 - a[1])) >> 5) & 0x07e0f81f) + xsp;
|
||||
ydp = (((ydp * (32 - a[2])) >> 5) & 0x07e0f81f) + ysp;
|
||||
zdp = (((zdp * (32 - a[3])) >> 5) & 0x07e0f81f) + zsp;
|
||||
*((DATA32 *)d) =
|
||||
((xdp | (xdp >> 16)) << 16) |
|
||||
((wdp | (wdp >> 16)) & 0x0000ffff);
|
||||
d += 2;
|
||||
*((DATA32 *)d) =
|
||||
((zdp | (zdp >> 16)) << 16) |
|
||||
((ydp | (ydp >> 16)) & 0x0000ffff);
|
||||
d += 2;
|
||||
s += 4; a += 4;
|
||||
}
|
||||
e += 3;
|
||||
while (d < e)
|
||||
{
|
||||
wsp = (*s | (*s << 16)) & 0x07e0f81f;
|
||||
wdp = (*d | (*d << 16)) & 0x07e0f81f;
|
||||
wdp = (((wdp * (32 - *a)) >> 5) & 0x07e0f81f) + wsp;
|
||||
*d = wdp | (wdp >> 16);
|
||||
s++; a++; d++;
|
||||
}
|
||||
}
|
||||
else
|
||||
*/
|
||||
{
|
||||
while (d < e)
|
||||
{
|
||||
wsp = (*s | (*s << 16)) & 0x07e0f81f;
|
||||
wdp = (*d | (*d << 16)) & 0x07e0f81f;
|
||||
wdp = (((wdp * (32 - *a)) >> 5) & 0x07e0f81f) + wsp;
|
||||
*d = wdp | (wdp >> 16);
|
||||
s++; a++; d++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//#define MEMCPY 1
|
||||
//#define SIMPLE 1
|
||||
|
||||
static void
|
||||
_soft16_scanline_copy(DATA16 *s, DATA8 *a, DATA8 *m, DATA32 c, DATA16 *d, int l)
|
||||
{
|
||||
#ifdef MEMCPY
|
||||
memcpy(d, s, l * sizeof(DATA16));
|
||||
#else
|
||||
DATA16 *e = d + l;
|
||||
|
||||
#ifdef SIMPLE
|
||||
while (d < e)
|
||||
{
|
||||
*d = *s;
|
||||
d++;
|
||||
s++;
|
||||
}
|
||||
#else
|
||||
if (((unsigned long)(((DATA8 *)s)) & 0x3) ==
|
||||
(((unsigned long)((DATA8 *)d)) & 0x3))
|
||||
{
|
||||
if (((unsigned long)(((DATA8 *)s)) & 0x3) == 2)
|
||||
{
|
||||
*d = *s;
|
||||
d++;
|
||||
s++;
|
||||
}
|
||||
e -= 1;
|
||||
while (d < e)
|
||||
{
|
||||
*((DATA32 *)d) = *((DATA32 *)s);
|
||||
d += 2;
|
||||
s += 2;
|
||||
}
|
||||
e += 1;
|
||||
if (d < e)
|
||||
{
|
||||
*d = *s;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while (d < e)
|
||||
{
|
||||
*d = *s;
|
||||
d++;
|
||||
s++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
#ifndef _EVAS_ENGINE_SOFTWARE_16_X11_H
|
||||
#define _EVAS_ENGINE_SOFTWARE_16_X11_H
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
typedef struct _Evas_Engine_Info_Software_16_X11 Evas_Engine_Info_Software_16_X11;
|
||||
|
||||
struct _Evas_Engine_Info_Software_16_X11
|
||||
{
|
||||
/* 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 {
|
||||
Display *display;
|
||||
Drawable drawable;
|
||||
} info;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
|
@ -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 -I$(top_srcdir)/src/modules/engines/software_16 @FREETYPE_CFLAGS@ @x_cflags@
|
||||
|
||||
if BUILD_ENGINE_SOFTWARE_16_X11
|
||||
|
||||
pkgdir = $(libdir)/evas/modules/engines/software_16_x11/$(MODULE_ARCH)
|
||||
|
||||
pkg_LTLIBRARIES = module.la
|
||||
|
||||
module_la_SOURCES = \
|
||||
evas_engine.h \
|
||||
evas_engine.c \
|
||||
evas_x_buffer.c
|
||||
|
||||
module_la_LIBADD = @x_libs@ $(top_builddir)/src/lib/libevas.la
|
||||
module_la_LDFLAGS = -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_Software_16_X11.h
|
||||
|
||||
endif
|
||||
|
||||
EXTRA_DIST = \
|
||||
evas_engine.h \
|
||||
evas_engine.c \
|
||||
evas_x_buffer.c \
|
||||
Evas_Engine_Software_16_X11.h
|
|
@ -0,0 +1,334 @@
|
|||
#include "evas_common.h"
|
||||
#include "evas_private.h"
|
||||
#include "evas_engine.h"
|
||||
#include "Evas_Engine_Software_16_X11.h"
|
||||
#include "evas_soft16.h"
|
||||
|
||||
/* 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
|
||||
{
|
||||
Display *disp;
|
||||
Drawable draw;
|
||||
GC gc;
|
||||
int w, h;
|
||||
Tilebuf *tb;
|
||||
Tilebuf_Rect *rects;
|
||||
Tilebuf_Rect *cur_rect;
|
||||
X_Output_Buffer *shbuf;
|
||||
unsigned char end : 1;
|
||||
unsigned char shm : 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);
|
||||
|
||||
/* engine api this module provides */
|
||||
static void *
|
||||
eng_info(Evas *e)
|
||||
{
|
||||
Evas_Engine_Info_Software_16_X11 *info;
|
||||
|
||||
info = calloc(1, sizeof(Evas_Engine_Info_Software_16_X11));
|
||||
if (!info) return NULL;
|
||||
info->magic.magic = rand();
|
||||
return info;
|
||||
e = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
eng_info_free(Evas *e, void *info)
|
||||
{
|
||||
Evas_Engine_Info_Software_16_X11 *in;
|
||||
|
||||
in = (Evas_Engine_Info_Software_16_X11 *)info;
|
||||
free(in);
|
||||
}
|
||||
|
||||
static void
|
||||
eng_setup(Evas *e, void *in)
|
||||
{
|
||||
Render_Engine *re;
|
||||
Evas_Engine_Info_Software_16_X11 *info;
|
||||
X_Output_Buffer *xob;
|
||||
XGCValues gcv;
|
||||
|
||||
info = (Evas_Engine_Info_Software_16_X11 *)in;
|
||||
if (!e->engine.data.output)
|
||||
{
|
||||
/* the only check - simplistic, i know, but enough for this
|
||||
* "special purpose" engine. Remember it is meant to be used
|
||||
* for limited power devices that have a 16bit display mode
|
||||
* and no real other acceleration, and high resolution so we
|
||||
* can pre-dither into 16bpp. */
|
||||
// if (DefaultDepth(info->info.display,
|
||||
// DefaultScreen(info->info.display)) != 16)
|
||||
// return;
|
||||
/* 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();
|
||||
|
||||
/* render engine specific data */
|
||||
re = calloc(1, sizeof(Render_Engine));
|
||||
e->engine.data.output = re;
|
||||
re->disp = info->info.display;
|
||||
re->draw = info->info.drawable;
|
||||
re->gc = XCreateGC(re->disp, re->draw, 0, &gcv);
|
||||
re->w = e->output.w;
|
||||
re->h = e->output.h;
|
||||
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
|
||||
{
|
||||
/* we changed the info after first init - do a re-eval where
|
||||
* appropriate */
|
||||
// if (DefaultDepth(info->info.display,
|
||||
// DefaultScreen(info->info.display)) != 16)
|
||||
// return;
|
||||
re = e->engine.data.output;
|
||||
if (re->tb) evas_common_tilebuf_free(re->tb);
|
||||
re->disp = info->info.display;
|
||||
re->draw = info->info.drawable;
|
||||
XFreeGC(re->disp, re->gc);
|
||||
re->gc = XCreateGC(re->disp, re->draw, 0, &gcv);
|
||||
re->w = e->output.w;
|
||||
re->h = e->output.h;
|
||||
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 (!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);
|
||||
/* check if the display can do shm */
|
||||
re->shm = evas_software_x11_x_can_do_shm(re->disp);
|
||||
}
|
||||
|
||||
static void
|
||||
eng_output_free(void *data)
|
||||
{
|
||||
Render_Engine *re;
|
||||
|
||||
re = (Render_Engine *)data;
|
||||
if (re->gc) XFreeGC(re->disp, re->gc);
|
||||
if (re->tb) evas_common_tilebuf_free(re->tb);
|
||||
if (re->rects) evas_common_tilebuf_free_render_rects(re->rects);
|
||||
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;
|
||||
evas_common_tilebuf_free(re->tb);
|
||||
re->w = w;
|
||||
re->h = h;
|
||||
re->tb = evas_common_tilebuf_new(w, h);
|
||||
if (re->tb)
|
||||
evas_common_tilebuf_set_tile_size(re->tb, TILESIZE, TILESIZE);
|
||||
}
|
||||
|
||||
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 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;
|
||||
Soft16_Image *surface = NULL;
|
||||
Tilebuf_Rect *rect;
|
||||
int ux, uy, uw, uh;
|
||||
|
||||
re = (Render_Engine *)data;
|
||||
if (re->end)
|
||||
{
|
||||
if (re->shbuf)
|
||||
{
|
||||
evas_software_x11_x_output_buffer_free(re->shbuf, 0);
|
||||
re->shbuf = NULL;
|
||||
}
|
||||
re->end = 0;
|
||||
return NULL;
|
||||
}
|
||||
if (!re->rects)
|
||||
{
|
||||
int mw, mh;
|
||||
|
||||
mw = 0;
|
||||
mh = 0;
|
||||
re->rects = evas_common_tilebuf_get_render_rects(re->tb);
|
||||
re->cur_rect = re->rects;
|
||||
for (rect = re->cur_rect; rect; rect = (Tilebuf_Rect *)(rect->_list_data.next))
|
||||
{
|
||||
if (rect->w > mw) mw = rect->w;
|
||||
if (rect->h > mh) mh = rect->h;
|
||||
}
|
||||
if (re->rects)
|
||||
re->shbuf = evas_software_x11_x_output_buffer_new
|
||||
(re->disp, DefaultVisual(re->disp, DefaultScreen(re->disp)),
|
||||
DefaultDepth(re->disp, DefaultScreen(re->disp)), mw, mh, 1, NULL);
|
||||
}
|
||||
if ((!re->cur_rect) || (!re->shbuf))
|
||||
{
|
||||
if (re->rects) evas_common_tilebuf_free_render_rects(re->rects);
|
||||
re->rects = NULL;
|
||||
if (re->shbuf)
|
||||
{
|
||||
evas_software_x11_x_output_buffer_free(re->shbuf, 0);
|
||||
re->shbuf = 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;
|
||||
}
|
||||
surface = re->shbuf;
|
||||
surface->w = uw;
|
||||
surface->h = uh;
|
||||
|
||||
*cx = 0; *cy = 0; *cw = uw; *ch = uh;
|
||||
*x = ux; *y = uy; *w = uw; *h = uh;
|
||||
return surface;
|
||||
}
|
||||
|
||||
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;
|
||||
evas_software_x11_x_output_buffer_paste(surface, re->draw, re->gc,
|
||||
x, y, w, h, 1);
|
||||
// evas_software_x11_outbuf_push_updated_region(re->ob, surface, x, y, w, h);
|
||||
// evas_software_x11_outbuf_free_region_for_update(re->ob, surface);
|
||||
// evas_common_cpu_end_opt();
|
||||
}
|
||||
|
||||
static void
|
||||
eng_output_flush(void *data)
|
||||
{
|
||||
Render_Engine *re;
|
||||
|
||||
re = (Render_Engine *)data;
|
||||
/* FIXME: later on defer the eng_output_redraws_next_update_push() until
|
||||
* flush and keep a list */
|
||||
// evas_software_x11_outbuf_flush(re->ob);
|
||||
}
|
||||
|
||||
|
||||
/* 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);
|
||||
/* 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_x11",
|
||||
"none"
|
||||
};
|
|
@ -0,0 +1,36 @@
|
|||
#ifndef EVAS_ENGINE_H
|
||||
#define EVAS_ENGINE_H
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/extensions/XShm.h>
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/shm.h>
|
||||
|
||||
#include "evas_soft16.h"
|
||||
|
||||
typedef struct _X_Output_Buffer X_Output_Buffer;
|
||||
|
||||
struct _X_Output_Buffer
|
||||
{
|
||||
Soft16_Image im;
|
||||
Display *display;
|
||||
XImage *xim;
|
||||
XShmSegmentInfo *shm_info;
|
||||
void *data;
|
||||
};
|
||||
|
||||
/****/
|
||||
void evas_software_x11_x_init (void);
|
||||
|
||||
int evas_software_x11_x_can_do_shm (Display *d);
|
||||
X_Output_Buffer *evas_software_x11_x_output_buffer_new (Display *d, Visual *v, int depth, int w, int h, int try_shm, void *data);
|
||||
void evas_software_x11_x_output_buffer_free (X_Output_Buffer *xob, int sync);
|
||||
void evas_software_x11_x_output_buffer_paste (X_Output_Buffer *xob, Drawable d, GC gc, int x, int y, int w, int h, int sync);
|
||||
DATA8 *evas_software_x11_x_output_buffer_data (X_Output_Buffer *xob, int *bytes_per_line_ret);
|
||||
int evas_software_x11_x_output_buffer_depth (X_Output_Buffer *xob);
|
||||
int evas_software_x11_x_output_buffer_byte_order (X_Output_Buffer *xob);
|
||||
int evas_software_x11_x_output_buffer_bit_order (X_Output_Buffer *xob);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,187 @@
|
|||
#include "evas_common.h"
|
||||
#include "evas_engine.h"
|
||||
|
||||
static int _x_err = 0;
|
||||
|
||||
int
|
||||
evas_software_x11_x_can_do_shm(Display *d)
|
||||
{
|
||||
static Display *cached_d = NULL;
|
||||
static int cached_result = 0;
|
||||
|
||||
if (d == cached_d) return cached_result;
|
||||
cached_d = d;
|
||||
if (XShmQueryExtension(d))
|
||||
{
|
||||
X_Output_Buffer *xob;
|
||||
|
||||
xob = evas_software_x11_x_output_buffer_new
|
||||
(d, DefaultVisual(d, DefaultScreen(d)),
|
||||
DefaultDepth(d, DefaultScreen(d)), 16, 16, 2, NULL);
|
||||
if (!xob)
|
||||
{
|
||||
cached_result = 0;
|
||||
return 0;
|
||||
}
|
||||
evas_software_x11_x_output_buffer_free(xob, 1);
|
||||
cached_result = 1;
|
||||
return 1;
|
||||
}
|
||||
cached_result = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
x_output_tmp_x_err(Display * d, XErrorEvent * ev)
|
||||
{
|
||||
_x_err = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
X_Output_Buffer *
|
||||
evas_software_x11_x_output_buffer_new(Display *d, Visual *v, int depth, int w, int h, int try_shm, void *data)
|
||||
{
|
||||
X_Output_Buffer *xob;
|
||||
|
||||
xob = calloc(1, sizeof(X_Output_Buffer));
|
||||
if (!xob) return NULL;
|
||||
|
||||
xob->display = d;
|
||||
xob->xim = NULL;
|
||||
xob->shm_info = NULL;
|
||||
|
||||
if (try_shm > 0)
|
||||
{
|
||||
xob->shm_info = malloc(sizeof(XShmSegmentInfo));
|
||||
if (xob->shm_info)
|
||||
{
|
||||
xob->xim = XShmCreateImage(d, v, depth, ZPixmap, NULL,
|
||||
xob->shm_info, w, h);
|
||||
if (xob->xim)
|
||||
{
|
||||
xob->shm_info->shmid = shmget(IPC_PRIVATE,
|
||||
xob->xim->bytes_per_line *
|
||||
xob->xim->height,
|
||||
IPC_CREAT | 0777);
|
||||
if (xob->shm_info->shmid >= 0)
|
||||
{
|
||||
xob->shm_info->readOnly = False;
|
||||
xob->shm_info->shmaddr = xob->xim->data =
|
||||
shmat(xob->shm_info->shmid, 0, 0);
|
||||
if (xob->shm_info->shmaddr != NULL)
|
||||
{
|
||||
XErrorHandler ph;
|
||||
|
||||
XSync(d, False);
|
||||
_x_err = 0;
|
||||
ph = XSetErrorHandler((XErrorHandler)
|
||||
x_output_tmp_x_err);
|
||||
XShmAttach(d, xob->shm_info);
|
||||
XSync(d, False);
|
||||
XSetErrorHandler((XErrorHandler)ph);
|
||||
if (!_x_err)
|
||||
{
|
||||
xob->im.pixels = xob->xim->data;
|
||||
xob->im.w = w;
|
||||
xob->im.h = h;
|
||||
xob->im.stride = xob->xim->bytes_per_line / sizeof(DATA16);
|
||||
xob->im.references = 1;
|
||||
return xob;
|
||||
}
|
||||
}
|
||||
shmdt(xob->shm_info->shmaddr);
|
||||
shmctl(xob->shm_info->shmid, IPC_RMID, 0);
|
||||
}
|
||||
if (xob->xim) XDestroyImage(xob->xim);
|
||||
xob->xim = NULL;
|
||||
}
|
||||
if (xob->shm_info) free(xob->shm_info);
|
||||
xob->shm_info = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (try_shm > 1) return NULL;
|
||||
|
||||
xob->xim = XCreateImage(d, v, depth, ZPixmap, 0, data, w, h, 32, 0);
|
||||
if (!xob->xim)
|
||||
{
|
||||
free(xob);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
xob->data = data;
|
||||
|
||||
if (!xob->xim->data)
|
||||
{
|
||||
xob->xim->data = malloc(xob->xim->bytes_per_line * xob->xim->height);
|
||||
if (!xob->xim->data)
|
||||
{
|
||||
XDestroyImage(xob->xim);
|
||||
free(xob);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
xob->im.pixels = xob->xim->data;
|
||||
xob->im.w = w;
|
||||
xob->im.h = h;
|
||||
xob->im.stride = xob->xim->bytes_per_line / sizeof(DATA16);
|
||||
xob->im.references = 1;
|
||||
return xob;
|
||||
}
|
||||
|
||||
void
|
||||
evas_software_x11_x_output_buffer_free(X_Output_Buffer *xob, int sync)
|
||||
{
|
||||
if (xob->shm_info)
|
||||
{
|
||||
if (sync) XSync(xob->display, False);
|
||||
XShmDetach(xob->display, xob->shm_info);
|
||||
XDestroyImage(xob->xim);
|
||||
shmdt(xob->shm_info->shmaddr);
|
||||
shmctl(xob->shm_info->shmid, IPC_RMID, 0);
|
||||
free(xob->shm_info);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (xob->data) xob->xim->data = NULL;
|
||||
XDestroyImage(xob->xim);
|
||||
}
|
||||
free(xob);
|
||||
}
|
||||
|
||||
void
|
||||
evas_software_x11_x_output_buffer_paste(X_Output_Buffer *xob, Drawable d, GC gc, int x, int y, int w, int h, int sync)
|
||||
{
|
||||
if (xob->shm_info)
|
||||
{
|
||||
XShmPutImage(xob->display, d, gc, xob->xim, 0, 0, x, y, w, h, False);
|
||||
if (sync) XSync(xob->display, False);
|
||||
}
|
||||
else
|
||||
XPutImage(xob->display, d, gc, xob->xim, 0, 0, x, y, w, h);
|
||||
}
|
||||
|
||||
DATA8 *
|
||||
evas_software_x11_x_output_buffer_data(X_Output_Buffer *xob, int *bytes_per_line_ret)
|
||||
{
|
||||
if (bytes_per_line_ret) *bytes_per_line_ret = xob->xim->bytes_per_line;
|
||||
return xob->xim->data;
|
||||
}
|
||||
|
||||
int
|
||||
evas_software_x11_x_output_buffer_depth(X_Output_Buffer *xob)
|
||||
{
|
||||
return xob->xim->bits_per_pixel;
|
||||
}
|
||||
|
||||
int
|
||||
evas_software_x11_x_output_buffer_byte_order(X_Output_Buffer *xob)
|
||||
{
|
||||
return xob->xim->byte_order;
|
||||
}
|
||||
|
||||
int
|
||||
evas_software_x11_x_output_buffer_bit_order(X_Output_Buffer *xob)
|
||||
{
|
||||
return xob->xim->bitmap_bit_order;
|
||||
}
|
Loading…
Reference in New Issue