remove 8bpp engine too form evas.

SVN revision: 78026
This commit is contained in:
Carsten Haitzler 2012-10-16 02:49:01 +00:00
parent bb90530f7b
commit 7e3479e2f8
27 changed files with 6 additions and 4774 deletions

View File

@ -1099,3 +1099,7 @@
* Fix C code fallback line rendering path in software
2012-10-17 Carsten Haitzler (The Rasterman)
* Like 16bpp engine, 8bpp engine goes the way of the dodo.

View File

@ -36,7 +36,6 @@ evas-opengl-x11.pc.in \
evas-opengl-sdl.pc.in \
evas-software-buffer.pc.in \
evas-software-x11.pc.in \
evas-software-8-x11.pc.in \
evas-software-gdi.pc.in \
evas-software-ddraw.pc.in \
evas-direct3d.pc.in \
@ -64,10 +63,6 @@ if BUILD_ENGINE_SOFTWARE_X11
pkgconfig_DATA += evas-software-x11.pc
endif
if BUILD_ENGINE_SOFTWARE_8_X11
pkgconfig_DATA += evas-software-8-x11.pc
endif
if BUILD_ENGINE_DIRECTFB
pkgconfig_DATA += evas-directfb.pc
endif

View File

@ -29,6 +29,8 @@ Fixes:
Removal:
* No more support s3c6410.
* 16bpp engine removed.
* 8bpp engine removed.
Evas 1.7.0

View File

@ -353,45 +353,6 @@ software-rendered with evas's default software rendering core.
opengl (and opengl-es2.0) rendering engine that uses sdl as the front
end interface. see --enable-gl-x11 etc. for information.
--enable-software-8-x11[=static]
8bit only rendering core. intended for greyscale output on things like
e-paper or simplistic greyscale LCD devices which have no color, such
as ebook readers.
if compiling with =static suffix, then must
"./configure --enable-static-software-8" as well.
--enable-software-16-x11[=static]
16bit specific renderer. lower quality than the default. also limited
in abilities (no support for smooth scale or transformations/map). in
a state of disrepair. do not use unless your hardware is just 16bpp
and very limited in CPU and memory.
if compiling with =static suffix, then must
"./configure --enable-static-software-16" as well.
--enable-software-16-ddraw[=static]
16bit renderer for direct-draw. same as software-16-x11 - don't use.
in disrepair.
if compiling with =static suffix, then must
"./configure --enable-static-software-16" as well.
--enable-software-16-wince[=static]
same as software-16-ddraw but for windows-ce. in disrepair. don't use.
if compiling with =static suffix, then must
"./configure --enable-static-software-16" as well.
------------------------------------------------------------------------------
CPU:
--enable-cpu-c

View File

@ -98,7 +98,6 @@ want_evas_engine_software_xlib="no"
want_evas_engine_software_xcb="no"
want_evas_engine_software_gdi="no"
want_evas_engine_software_ddraw="no"
want_evas_engine_software_8_x11="no"
want_evas_engine_gl_xlib="no"
want_evas_engine_gl_xcb="no"
want_evas_engine_gl_sdl="no"
@ -140,8 +139,6 @@ case "$host_os" in
want_evas_engine_fb="auto"
want_evas_engine_wayland_shm="auto"
want_evas_engine_wayland_egl="auto"
### no - not ready/usable/complete
# want_evas_engine_software_8_x11="auto"
;;
esac
@ -619,7 +616,6 @@ EVAS_CHECK_ENGINE([gl-sdl], [${want_evas_engine_gl_sdl}], [no], [OpenGL SDL])
EVAS_CHECK_ENGINE([gl-cocoa], [${want_evas_engine_gl_cocoa}], [no], [OpenGL Cocoa])
EVAS_CHECK_ENGINE([fb], [${want_evas_engine_fb}], [no], [Framebuffer])
EVAS_CHECK_ENGINE([directfb], [${want_evas_engine_directfb}], [no], [DirectFB])
EVAS_CHECK_ENGINE([software-8-x11], [${want_evas_engine_software_8_x11}], [no], [Software X11 8 bits grayscale])
EVAS_CHECK_ENGINE([wayland-shm], [${want_evas_engine_wayland_shm}], [no], [Wayland Shm])
EVAS_CHECK_ENGINE([wayland-egl], [${want_evas_engine_wayland_egl}], [no], [Wayland Egl])
@ -815,28 +811,6 @@ if test "x$gl_flavor_gles" = "xyes"; then
[#include <SDL/SDL_video.h>])
fi
# if software 8 x11 is enabled - build software_8 (the generic 8bit
# engine).
have_evas_engine_software_8="no"
if test "x$have_evas_engine_software_8_x11" = "xyes" -o "x$have_evas_engine_software_8_x11" = "xstatic"; then
have_evas_engine_software_8="yes"
fi
AM_CONDITIONAL(BUILD_ENGINE_SOFTWARE_8, test "x$have_evas_engine_software_8" = "xyes")
# if software 8 need to be build as part of libevas.so
have_static_software_8="no"
AC_ARG_ENABLE([static-software-8],
[AC_HELP_STRING([--enable-static-software-8], [Build software 8 engine as part of libevas])],
[have_static_software_8=${enableval}]
)
AC_MSG_CHECKING([Whether to build software 8 engine as part of libevas])
AC_MSG_RESULT([${have_static_software_8}])
AM_CONDITIONAL(EVAS_STATIC_BUILD_SOFTWARE_8, test "x${have_static_software_8}" = "xyes")
if test "x${have_static_software_8}" = "xyes"; then
AC_DEFINE(EVAS_STATIC_BUILD_SOFTWARE_8, [1], [Build software 8 engine as part of libevas])
fi
#####################################################################
## Font Loaders
@ -1348,7 +1322,6 @@ evas-opengl-sdl.pc
evas-opengl-cocoa.pc
evas-software-buffer.pc
evas-software-x11.pc
evas-software-8-x11.pc
evas-software-gdi.pc
evas-software-ddraw.pc
evas-direct3d.pc
@ -1389,7 +1362,6 @@ src/lib/engines/common/evas_op_copy/Makefile
src/lib/engines/common/evas_op_mask/Makefile
src/lib/engines/common/evas_op_mul/Makefile
src/lib/engines/common/evas_op_sub/Makefile
src/lib/engines/common_8/Makefile
src/modules/Makefile
src/modules/engines/Makefile
src/modules/engines/software_generic/Makefile
@ -1405,8 +1377,6 @@ src/modules/engines/gl_x11/Makefile
src/modules/engines/gl_sdl/Makefile
src/modules/engines/gl_cocoa/Makefile
src/modules/engines/psl1ght/Makefile
src/modules/engines/software_8/Makefile
src/modules/engines/software_8_x11/Makefile
src/modules/engines/wayland_shm/Makefile
src/modules/engines/wayland_egl/Makefile
src/modules/loaders/Makefile
@ -1473,7 +1443,6 @@ echo " OpenGL Cocoa...............: $have_evas_engine_gl_cocoa"
echo " Software Framebuffer.......: $have_evas_engine_fb"
echo " DirectFB...................: $have_evas_engine_directfb"
echo " PSL1GHT....................: $have_evas_engine_psl1ght"
echo " Software 8bit grayscale....: $have_evas_engine_software_8"
echo " Wayland Shm................: $have_evas_engine_wayland_shm"
echo " Wayland Egl................: $have_evas_engine_wayland_egl"
echo

View File

@ -1,3 +0,0 @@
Name: evas-software-8-x11
Description: Evas software X11 8bpp grayscale engine
Version: @VERSION@

View File

@ -48,15 +48,6 @@ SUBDIRS += ../modules/engines/psl1ght/
EVAS_STATIC_MODULE += ../modules/engines/psl1ght/libevas_engine_psl1ght.la
EVAS_STATIC_LIBADD += @evas_engine_psl1ght_libs@
endif
if EVAS_STATIC_BUILD_SOFTWARE_8
SUBDIRS += ../modules/engines/software_8/
EVAS_STATIC_MODULE += ../modules/engines/software_8/libevas_engine_software_8.la
endif
if EVAS_STATIC_BUILD_SOFTWARE_8_X11
SUBDIRS += ../modules/engines/software_8_x11/
EVAS_STATIC_MODULE += ../modules/engines/software_8_x11/libevas_engine_software_8_x11.la
EVAS_STATIC_LIBADD += @evas_engine_software_8_x11_libs@
endif
if EVAS_STATIC_BUILD_SOFTWARE_DDRAW
SUBDIRS += ../modules/engines/software_ddraw/
EVAS_STATIC_MODULE += ../modules/engines/software_ddraw/libevas_engine_software_ddraw.la
@ -214,11 +205,6 @@ libevas_la_DEPENDENCIES += \
cache2/libevas_cache2.la
endif
if BUILD_ENGINE_SOFTWARE_8
libevas_la_LIBADD += engines/common_8/libevas_engine_common_8.la
libevas_la_DEPENDENCIES += engines/common_8/libevas_engine_common_8.la
endif
libevas_la_LDFLAGS = -no-undefined @lt_enable_auto_import@ -version-info @version_info@ @release_info@
### Evas_GL we are still using it in our code, so just don't install it.

View File

@ -1,7 +1,3 @@
MAINTAINERCLEANFILES = Makefile.in
SUBDIRS = common
if BUILD_ENGINE_SOFTWARE_8
SUBDIRS += common_8
endif

View File

@ -1,32 +0,0 @@
MAINTAINERCLEANFILES = Makefile.in
AM_CPPFLAGS = \
-I. \
-I$(top_srcdir)/src/lib \
-I$(top_srcdir)/src/lib/include \
@FREETYPE_CFLAGS@ \
@PIXMAN_CFLAGS@ \
@VALGRIND_CFLAGS@ \
@EVAS_GENERAL_CFLAGS@ \
@EET_CFLAGS@ \
@pthread_cflags@
noinst_LTLIBRARIES = libevas_engine_common_8.la
libevas_engine_common_8_la_SOURCES = \
evas_soft8_dither_mask.c \
evas_soft8_font.c \
evas_soft8_image_unscaled.c \
evas_soft8_main.c \
evas_soft8_rectangle.c \
evas_soft8_line.c \
evas_soft8_polygon.c \
evas_soft8_image_scaled_sampled.c
libevas_engine_common_8_la_DEPENDENCIES = $(top_builddir)/config.h
EXTRA_DIST = \
evas_soft8_scanline_blend.c \
evas_soft8_scanline_fill.c

View File

@ -1,100 +0,0 @@
#include "evas_common_soft8.h"
EFL_ALWAYS_INLINE void
_soft8_convert_from_rgba_pt(const DATA32 * src, DATA8 * dst, DATA8 * alpha)
{
if (A_VAL(src) == 0)
{
*dst = 0;
*alpha = 0;
}
else
{
*dst = GRY_8_FROM_RGB(src);
*alpha = A_VAL(src);
}
}
static inline void
_soft8_convert_from_rgba_scanline(const DATA32 * src, DATA8 * dst,
DATA8 * alpha, const int w)
{
int x, m;
m = (w & ~7);
x = 0;
pld(src, 0);
while (x < m)
{
pld(src, 32);
UNROLL8(
{
_soft8_convert_from_rgba_pt(src, dst, alpha);
src++; dst++; alpha++; x++;}
);
}
for (; x < w; x++, src++, dst++, alpha++)
_soft8_convert_from_rgba_pt(src, dst, alpha);
}
void
evas_common_soft8_image_convert_from_rgba(Soft8_Image * im, const DATA32 * src)
{
const DATA32 *sp;
DATA8 *dp;
DATA8 *ap;
unsigned int y;
sp = src;
dp = im->pixels;
ap = im->alpha;
for (y = 0; y < im->cache_entry.h;
y++, sp += im->cache_entry.w, dp += im->stride, ap += im->stride)
_soft8_convert_from_rgba_scanline(sp, dp, ap, im->cache_entry.w);
}
EFL_ALWAYS_INLINE void
_soft8_convert_from_rgb_pt(const DATA32 * src, DATA8 * dst)
{
*dst = GRY_8_FROM_RGB(src);
}
static inline void
_soft8_convert_from_rgb_scanline(const DATA32 * src, DATA8 * dst, const int w)
{
int x, m;
m = (w & ~7);
x = 0;
pld(src, 0);
while (x < m)
{
pld(src, 32);
UNROLL8(
{
_soft8_convert_from_rgb_pt(src, dst); src++; dst++; x++;}
);
}
for (; x < w; x++, src++, dst++)
_soft8_convert_from_rgb_pt(src, dst);
}
void
evas_common_soft8_image_convert_from_rgb(Soft8_Image * im, const DATA32 * src)
{
const DATA32 *sp;
DATA8 *dp;
unsigned int y;
sp = src;
dp = im->pixels;
for (y = 0; y < im->cache_entry.h;
y++, sp += im->cache_entry.w, dp += im->stride)
_soft8_convert_from_rgb_scanline(sp, dp, im->cache_entry.w);
}

View File

@ -1,285 +0,0 @@
#include "evas_common_soft8.h"
#include "evas_soft8_scanline_blend.c"
EFL_ALWAYS_INLINE void
_glyph_pt_mask_solid_solid(DATA8 * dst, const DATA8 gry8, const DATA8 * mask)
{
DATA8 alpha = *mask;
if (alpha == 0xff)
*dst = gry8;
else if (alpha > 0)
{
*dst = GRY_8_BLEND_UNMUL(gry8, *dst, alpha);
}
}
static void
_glyph_scanline_mask_solid_solid(DATA8 * dst,
int size, const DATA8 gry8, const DATA8 * mask)
{
DATA8 *start, *end;
start = dst;
pld(start, 0);
pld(mask, 0);
end = start + (size & ~3);
while (start < end)
{
pld(start, 8);
pld(mask, 4);
UNROLL4(
{
_glyph_pt_mask_solid_solid(start, gry8, mask);
start++; mask++;}
);
}
end = start + (size & 3);
for (; start < end; start++, mask++)
_glyph_pt_mask_solid_solid(start, gry8, mask);
}
EFL_ALWAYS_INLINE void
_glyph_pt_mask_transp_solid(DATA8 * dst,
DATA8 gry8, DATA8 alpha, const DATA8 * mask)
{
int rel_alpha;
rel_alpha = *mask;
alpha = (alpha * rel_alpha) >> 8;
if (alpha == 0)
return;
alpha++;
*dst = GRY_8_BLEND((gry8 * rel_alpha) >> 8, *dst, alpha);
}
static void
_glyph_scanline_mask_transp_solid(DATA8 * dst,
int size,
const DATA8 gry8,
const DATA8 rel_alpha, const DATA8 * mask)
{
DATA8 *start, *end;
start = dst;
pld(start, 0);
pld(mask, 0);
end = start + (size & ~3);
while (start < end)
{
pld(start, 8);
pld(mask, 4);
UNROLL4(
{
_glyph_pt_mask_transp_solid(start, gry8, rel_alpha, mask);
start++; mask++;}
);
}
end = start + (size & 3);
for (; start < end; start++, mask++)
_glyph_pt_mask_transp_solid(start, gry8, rel_alpha, mask);
}
static inline void
_calc_ext(const Soft8_Image * dst, const RGBA_Draw_Context * dc,
Eina_Rectangle * ext)
{
EINA_RECTANGLE_SET(ext, 0, 0, dst->cache_entry.w, dst->cache_entry.h);
if (dc->clip.use)
{
int v;
EINA_RECTANGLE_SET(ext, dc->clip.x, dc->clip.y, dc->clip.w, dc->clip.h);
if (ext->x < 0)
{
ext->w += ext->x;
ext->x = 0;
}
if (ext->y < 0)
{
ext->h += ext->y;
ext->y = 0;
}
v = dst->cache_entry.w - ext->x;
if (ext->w > v)
ext->w = v;
v = dst->cache_entry.h - ext->y;
if (ext->h > v)
ext->h = v;
}
}
static inline void
_glyph_scanline(Soft8_Image * dst, const DATA8 * p_mask,
const Eina_Rectangle ext, int dx, int dy, int max_x, int max_y,
int w, DATA8 alpha, const DATA8 gry8)
{
int size, in_x, in_w;
DATA8 *p_pixels;
if ((dx >= max_x) || (dy < ext.y) || (dy >= max_y))
return;
in_x = 0;
in_w = 0;
if (dx + w > max_x)
in_w += (dx + w) - max_x;
if (dx < ext.x)
{
in_w += ext.x - dx;
in_x = ext.x - dx;
dx = ext.x;
}
size = w - in_w;
p_pixels = dst->pixels + (dy * dst->stride) + dx;
p_mask += in_x;
if (size > 1)
{
if (alpha == 0xff)
_glyph_scanline_mask_solid_solid(p_pixels, size, gry8, p_mask);
else if (alpha != 0)
_glyph_scanline_mask_transp_solid
(p_pixels, size, gry8, alpha, p_mask);
}
else if (size == 1)
{
if (alpha == 0xff)
_glyph_pt_mask_solid_solid(p_pixels, gry8, p_mask);
else if (alpha != 0)
_glyph_pt_mask_transp_solid(p_pixels, gry8, alpha, p_mask);
}
}
static void
_soft8_font_glyph_draw_grayscale(Soft8_Image * dst,
RGBA_Draw_Context * dc __UNUSED__,
RGBA_Font_Glyph * fg __UNUSED__, int x, int y,
DATA8 alpha, DATA8 gry8,
const Eina_Rectangle ext, int bw, int bh,
int bpitch, const DATA8 * bitmap)
{
int i, max_x, max_y;
max_x = ext.x + ext.w;
max_y = ext.y + ext.h;
for (i = 0; i < bh; i++, bitmap += bpitch)
_glyph_scanline(dst, bitmap, ext, x, y + i, max_x, max_y, bw,
alpha, gry8);
}
static inline void
_glyph_create_mask_line(DATA8 * mask, const DATA8 * bitmap, int w)
{
const DATA8 bitrepl[2] = { 0x0, 0xff };
int i;
for (i = 0; i < w; i += 8, bitmap++)
{
int j, size;
DATA32 bits;
if (i + 8 < w)
size = 8;
else
size = w - i;
bits = *bitmap;
for (j = size - 1; j >= 0; j--, mask++)
*mask = bitrepl[(bits >> j) & 0x1];
}
}
static void
_soft8_font_glyph_draw_mono(Soft8_Image * dst,
RGBA_Draw_Context * dc __UNUSED__,
RGBA_Font_Glyph * fg __UNUSED__, int x, int y,
DATA8 alpha, DATA8 gry8, const Eina_Rectangle ext,
int bw, int bh, int bpitch, const DATA8 * bitmap)
{
DATA8 *mask;
int i, max_x, max_y;
max_x = ext.x + ext.w;
max_y = ext.y + ext.h;
mask = alloca(bpitch);
for (i = 0; i < bh; i++, bitmap += bpitch)
{
_glyph_create_mask_line(mask, bitmap, bw);
_glyph_scanline(dst, mask, ext, x, y + i, max_x, max_y, bw,
alpha, gry8);
}
}
void
evas_common_soft8_font_glyph_draw(void *data, void *dest __UNUSED__, void *context,
RGBA_Font_Glyph * fg, int x, int y)
{
Soft8_Image *dst;
RGBA_Draw_Context *dc;
const DATA8 *bitmap;
DATA8 alpha; // r, g, b
DATA8 gry8;
Eina_Rectangle ext;
int bpitch, bw, bh;
dst = data;
dc = context;
alpha = A_VAL(&dc->col.col);
if (alpha == 0)
return;
gry8 = GRY_8_FROM_RGB(&dc->col.col);
/*
* if (r > alpha) r = alpha;
* if (g > alpha) g = alpha;
* if (b > alpha) b = alpha;
*
* gry8 = GRY_8_FROM_COMPONENTS(r, g, b);
*/
bitmap = fg->glyph_out->bitmap.buffer;
bh = fg->glyph_out->bitmap.rows;
bw = fg->glyph_out->bitmap.width;
bpitch = fg->glyph_out->bitmap.pitch;
if (bpitch < bw)
bpitch = bw;
_calc_ext(dst, dc, &ext);
if ((fg->glyph_out->bitmap.num_grays == 256) &&
(fg->glyph_out->bitmap.pixel_mode == ft_pixel_mode_grays))
_soft8_font_glyph_draw_grayscale(dst, dc, fg, x, y, alpha, gry8,
ext, bw, bh, bpitch, bitmap);
else
_soft8_font_glyph_draw_mono(dst, dc, fg, x, y, alpha, gry8,
ext, bw, bh, bpitch, bitmap);
}
void *
evas_common_soft8_font_glyph_new(void *data __UNUSED__, RGBA_Font_Glyph * fg __UNUSED__)
{
return (void *)1; /* core requires != NULL to work */
}
void
evas_common_soft8_font_glyph_free(void *ext_dat __UNUSED__)
{
}

View File

@ -1,463 +0,0 @@
#include "evas_common_soft8.h"
#include "evas_soft8_scanline_blend.c"
static void
_soft8_image_draw_scaled_solid_solid(Soft8_Image * src,
Soft8_Image * dst,
RGBA_Draw_Context * dc __UNUSED__,
int dst_offset, int w, int h,
int *offset_x, int *offset_y)
{
DATA8 *dst_itr;
int y, w_align;
w_align = w & ~7;
dst_itr = dst->pixels + dst_offset;
for (y = 0; y < h; y++, dst_itr += dst->stride)
{
DATA8 *d, *s;
int x;
s = src->pixels + offset_y[y];
pld(s, 0);
pld(offset_x, 0);
d = dst_itr;
x = 0;
while (x < w_align)
{
pld(s, 32);
pld(offset_x + x, 32);
UNROLL8(
{
_soft8_pt_blend_solid_solid(d, s[offset_x[x]]); x++; d++;}
);
}
for (; x < w; x++, d++)
_soft8_pt_blend_solid_solid(d, s[offset_x[x]]);
}
}
static void
_soft8_image_draw_scaled_transp_solid(Soft8_Image * src,
Soft8_Image * dst,
RGBA_Draw_Context * dc __UNUSED__,
int dst_offset, int w, int h,
int *offset_x, int *offset_y)
{
DATA8 *dst_itr;
int y, w_align;
w_align = w & ~7;
dst_itr = dst->pixels + dst_offset;
for (y = 0; y < h; y++, dst_itr += dst->stride)
{
DATA8 *d, *s;
DATA8 *a;
int x;
s = src->pixels + offset_y[y];
a = src->alpha + offset_y[y];
pld(s, 0);
pld(a, 0);
pld(offset_x, 0);
d = dst_itr;
x = 0;
while (x < w_align)
{
pld(s, 32);
pld(a, 8);
pld(offset_x + x, 32);
UNROLL8(
{
int off_x = offset_x[x];
_soft8_pt_blend_transp_solid(d, s[off_x], a[off_x]);
x++; d++;});
}
for (; x < w; x++, d++)
_soft8_pt_blend_transp_solid(d, s[offset_x[x]], a[offset_x[x]]);
}
}
static inline void
_soft8_image_draw_scaled_no_mul(Soft8_Image * src, Soft8_Image * dst,
RGBA_Draw_Context * dc,
int dst_offset, int w, int h,
int *offset_x, int *offset_y)
{
if ((src->cache_entry.flags.alpha && src->alpha) &&
(!dst->cache_entry.flags.alpha))
_soft8_image_draw_scaled_transp_solid
(src, dst, dc, dst_offset, w, h, offset_x, offset_y);
else if (!dst->cache_entry.flags.alpha)
_soft8_image_draw_scaled_solid_solid
(src, dst, dc, dst_offset, w, h, offset_x, offset_y);
else
ERR("Unsupported draw of scaled images src->cache_entry.flags.alpha=%d, "
"dst->cache_entry.flags.alpha=%d, WITHOUT COLOR MUL",
src->cache_entry.flags.alpha, dst->cache_entry.flags.alpha);
}
static void
_soft8_image_draw_scaled_solid_solid_mul_alpha(Soft8_Image * src,
Soft8_Image * dst,
RGBA_Draw_Context *
dc __UNUSED__, int dst_offset,
int w, int h, int *offset_x,
int *offset_y, DATA8 alpha)
{
DATA8 *dst_itr;
int y, w_align;
w_align = w & ~7;
dst_itr = dst->pixels + dst_offset;
for (y = 0; y < h; y++, dst_itr += dst->stride)
{
DATA8 *d, *s;
int x;
s = src->pixels + offset_y[y];
pld(s, 0);
pld(offset_x, 0);
d = dst_itr;
x = 0;
while (x < w_align)
{
pld(s, 32);
pld(offset_x + x, 32);
UNROLL8(
{
_soft8_pt_blend_solid_solid_mul_alpha
(d, s[offset_x[x]], alpha); x++; d++;}
);
}
for (; x < w; x++, d++)
_soft8_pt_blend_solid_solid_mul_alpha(d, s[offset_x[x]], alpha);
}
}
static void
_soft8_image_draw_scaled_transp_solid_mul_alpha(Soft8_Image * src,
Soft8_Image * dst,
RGBA_Draw_Context *
dc __UNUSED__, int dst_offset,
int w, int h, int *offset_x,
int *offset_y, DATA8 alpha)
{
DATA8 *dst_itr;
int y, w_align;
w_align = w & ~7;
dst_itr = dst->pixels + dst_offset;
for (y = 0; y < h; y++, dst_itr += dst->stride)
{
DATA8 *d, *s;
DATA8 *a;
int x;
s = src->pixels + offset_y[y];
a = src->alpha + offset_y[y];
pld(s, 0);
pld(a, 0);
pld(offset_x, 0);
d = dst_itr;
x = 0;
while (x < w_align)
{
pld(s, 32);
pld(a, 8);
pld(offset_x + x, 32);
UNROLL8(
{
int off_x = offset_x[x];
_soft8_pt_blend_transp_solid_mul_alpha
(d, s[off_x], a[off_x], alpha); x++; d++;});
}
for (; x < w; x++, d++)
_soft8_pt_blend_transp_solid_mul_alpha
(d, s[offset_x[x]], a[offset_x[x]], alpha);
}
}
static inline void
_soft8_image_draw_scaled_mul_alpha(Soft8_Image * src, Soft8_Image * dst,
RGBA_Draw_Context * dc,
int dst_offset, int w, int h,
int *offset_x, int *offset_y, DATA8 a)
{
if ((src->cache_entry.flags.alpha && src->alpha) &&
(!dst->cache_entry.flags.alpha))
_soft8_image_draw_scaled_transp_solid_mul_alpha
(src, dst, dc, dst_offset, w, h, offset_x, offset_y, a);
else if (!dst->cache_entry.flags.alpha)
_soft8_image_draw_scaled_solid_solid_mul_alpha
(src, dst, dc, dst_offset, w, h, offset_x, offset_y, a);
else
ERR("Unsupported draw of scaled images src->cache_entry.flags.alpha=%d, "
"dst->cache_entry.flags.alpha=%d, WITH ALPHA MUL %d",
src->cache_entry.flags.alpha, dst->cache_entry.flags.alpha,
A_VAL(&dc->mul.col));
}
static void
_soft8_image_draw_scaled_solid_solid_mul_color(Soft8_Image * src,
Soft8_Image * dst,
RGBA_Draw_Context *
dc __UNUSED__, int dst_offset,
int w, int h, int *offset_x,
int *offset_y, DATA8 r, DATA8 g,
DATA8 b, DATA8 alpha)
{
DATA8 *dst_itr;
int y, w_align;
w_align = w & ~7;
dst_itr = dst->pixels + dst_offset;
if (alpha == 0xff)
for (y = 0; y < h; y++, dst_itr += dst->stride)
{
DATA8 *d, *s;
int x;
s = src->pixels + offset_y[y];
pld(s, 0);
pld(offset_x, 0);
d = dst_itr;
x = 0;
while (x < w_align)
{
pld(s, 32);
pld(offset_x + x, 32);
UNROLL8(
{
_soft8_pt_blend_solid_solid_mul_color_solid
(d, s[offset_x[x]], r, g, b); x++; d++;}
);
}
for (; x < w; x++, d++)
_soft8_pt_blend_solid_solid_mul_color_solid
(d, s[offset_x[x]], r, g, b);
}
else
for (y = 0; y < h; y++, dst_itr += dst->stride)
{
DATA8 *d, *s;
int x;
s = src->pixels + offset_y[y];
pld(s, 0);
pld(offset_x, 0);
d = dst_itr;
x = 0;
while (x < w_align)
{
pld(s, 32);
pld(offset_x + x, 32);
UNROLL8(
{
_soft8_pt_blend_solid_solid_mul_color_transp
(d, s[offset_x[x]], alpha, r, g, b); x++; d++;}
);
}
for (; x < w; x++, d++)
_soft8_pt_blend_solid_solid_mul_color_transp
(d, s[offset_x[x]], alpha, r, g, b);
}
}
static void
_soft8_image_draw_scaled_transp_solid_mul_color(Soft8_Image * src,
Soft8_Image * dst,
RGBA_Draw_Context *
dc __UNUSED__, int dst_offset,
int w, int h, int *offset_x,
int *offset_y, DATA8 r, DATA8 g,
DATA8 b, DATA8 alpha)
{
DATA8 *dst_itr;
int y, w_align;
w_align = w & ~7;
dst_itr = dst->pixels + dst_offset;
if (alpha == 0xff)
for (y = 0; y < h; y++, dst_itr += dst->stride)
{
DATA8 *d, *s;
DATA8 *a;
int x;
s = src->pixels + offset_y[y];
a = src->alpha + offset_y[y];
pld(s, 0);
pld(a, 0);
pld(offset_x, 0);
d = dst_itr;
x = 0;
while (x < w_align)
{
pld(s, 32);
pld(a, 8);
pld(offset_x + x, 32);
UNROLL8(
{
int off_x = offset_x[x];
_soft8_pt_blend_transp_solid_mul_color_solid
(d, s[off_x], a[off_x], r, g, b); x++; d++;});
}
for (; x < w; x++, d++)
_soft8_pt_blend_transp_solid_mul_color_solid
(d, s[offset_x[x]], a[offset_x[x]], r, g, b);
}
else
for (y = 0; y < h; y++, dst_itr += dst->stride)
{
DATA8 *d, *s;
DATA8 *a;
int x;
s = src->pixels + offset_y[y];
a = src->alpha + offset_y[y];
pld(s, 0);
pld(a, 0);
pld(offset_x, 0);
d = dst_itr;
x = 0;
while (x < w_align)
{
pld(s, 32);
pld(a, 8);
pld(offset_x + x, 32);
UNROLL8(
{
int off_x = offset_x[x];
_soft8_pt_blend_transp_solid_mul_color_transp
(d, s[off_x], a[off_x], alpha, r, g, b); x++; d++;});
}
for (; x < w; x++, d++)
_soft8_pt_blend_transp_solid_mul_color_transp
(d, s[offset_x[x]], a[offset_x[x]], alpha, r, g, b);
}
}
static inline void
_soft8_image_draw_scaled_mul_color(Soft8_Image * src, Soft8_Image * dst,
RGBA_Draw_Context * dc,
int dst_offset, int w, int h,
int *offset_x, int *offset_y,
DATA8 r, DATA8 g, DATA8 b, DATA8 a)
{
if ((src->cache_entry.flags.alpha && src->alpha) &&
(!dst->cache_entry.flags.alpha))
_soft8_image_draw_scaled_transp_solid_mul_color
(src, dst, dc, dst_offset, w, h, offset_x, offset_y, r, g, b, a);
else if (!dst->cache_entry.flags.alpha)
_soft8_image_draw_scaled_solid_solid_mul_color
(src, dst, dc, dst_offset, w, h, offset_x, offset_y, r, g, b, a);
else
ERR("Unsupported draw of scaled images src->cache_entry.flags.alpha=%d, "
"dst->cache_entry.flags.alpha=%d, WITH COLOR MUL 0x%08x",
src->cache_entry.flags.alpha, dst->cache_entry.flags.alpha,
dc->mul.col);
}
static inline void
_soft8_image_draw_scaled_mul(Soft8_Image * src, Soft8_Image * dst,
RGBA_Draw_Context * dc,
int dst_offset, int w, int h,
int *offset_x, int *offset_y, DATA8 r, DATA8 g,
DATA8 b, DATA8 a)
{
if ((a == r) && (a == g) && (a == b))
_soft8_image_draw_scaled_mul_alpha
(src, dst, dc, dst_offset, w, h, offset_x, offset_y, a);
else
_soft8_image_draw_scaled_mul_color
(src, dst, dc, dst_offset, w, h, offset_x, offset_y, r, g, b, a);
}
void
evas_common_soft8_image_draw_scaled_sampled(Soft8_Image * src, Soft8_Image * dst,
RGBA_Draw_Context * dc,
const Eina_Rectangle sr,
const Eina_Rectangle dr,
const Eina_Rectangle cr)
{
int x, y, dst_offset, *offset_x, *offset_y;
DATA8 mul_gry8;
DATA8 r, g, b, a;
if (!dc->mul.use)
{
r = g = b = a = 0xff;
mul_gry8 = 0xff;
}
else
{
a = A_VAL(&dc->mul.col);
if (a == 0)
return;
r = R_VAL(&dc->mul.col);
g = G_VAL(&dc->mul.col);
b = B_VAL(&dc->mul.col);
if (r > a)
r = a;
if (g > a)
g = a;
if (b > a)
b = a;
mul_gry8 = GRY_8_FROM_COMPONENTS(r, g, b);
}
/* pre-calculated scale tables */
offset_x = alloca(cr.w * sizeof(*offset_x));
for (x = 0; x < cr.w; x++)
offset_x[x] = (((x + cr.x - dr.x) * sr.w) / dr.w) + sr.x;
offset_y = alloca(cr.h * sizeof(*offset_y));
for (y = 0; y < cr.h; y++)
offset_y[y] = (((((y + cr.y - dr.y) * sr.h) / dr.h) + sr.y)
* src->stride);
dst_offset = cr.x + (cr.y * dst->stride);
if (mul_gry8 == 0xff)
_soft8_image_draw_scaled_no_mul
(src, dst, dc, dst_offset, cr.w, cr.h, offset_x, offset_y);
else
_soft8_image_draw_scaled_mul
(src, dst, dc, dst_offset, cr.w, cr.h, offset_x, offset_y, r, g, b,
a);
}

View File

@ -1,284 +0,0 @@
#include "evas_common_soft8.h"
#include "evas_soft8_scanline_blend.c"
static void
_soft8_image_draw_unscaled_solid_solid(Soft8_Image * src, Soft8_Image * dst,
RGBA_Draw_Context * dc __UNUSED__,
int src_offset, int dst_offset,
int w, int h)
{
DATA8 *src_itr, *dst_itr;
int y;
src_itr = src->pixels + src_offset;
dst_itr = dst->pixels + dst_offset;
for (y = 0; y < h; y++)
{
_soft8_scanline_blend_solid_solid(src_itr, dst_itr, w);
src_itr += src->stride;
dst_itr += dst->stride;
}
}
static void
_soft8_image_draw_unscaled_transp_solid(Soft8_Image * src, Soft8_Image * dst,
RGBA_Draw_Context * dc __UNUSED__,
int src_offset, int dst_offset,
int w, int h)
{
DATA8 *src_itr, *dst_itr;
DATA8 *alpha_itr;
int y;
src_itr = src->pixels + src_offset;
alpha_itr = src->alpha + src_offset;
dst_itr = dst->pixels + dst_offset;
for (y = 0; y < h; y++)
{
_soft8_scanline_blend_transp_solid(src_itr, alpha_itr, dst_itr, w);
src_itr += src->stride;
alpha_itr += src->stride;
dst_itr += dst->stride;
}
}
static inline void
_soft8_image_draw_unscaled_no_mul(Soft8_Image * src, Soft8_Image * dst,
RGBA_Draw_Context * dc,
int src_offset, int dst_offset,
int width, int height)
{
if (src->cache_entry.flags.alpha && (!dst->cache_entry.flags.alpha))
_soft8_image_draw_unscaled_transp_solid(src, dst, dc,
src_offset, dst_offset,
width, height);
else if ((!src->cache_entry.flags.alpha) && (!dst->cache_entry.flags.alpha))
_soft8_image_draw_unscaled_solid_solid(src, dst, dc,
src_offset, dst_offset,
width, height);
else
ERR("Unsupported draw of unscaled images src->cache_entry.flags.alpha=%d, "
"dst->cache_entry.flags.alpha=%d, WITHOUT COLOR MUL",
src->cache_entry.flags.alpha, dst->cache_entry.flags.alpha);
}
static void
_soft8_image_draw_unscaled_solid_solid_mul_alpha(Soft8_Image * src,
Soft8_Image * dst,
RGBA_Draw_Context *
dc __UNUSED__, int src_offset,
int dst_offset, int w, int h,
DATA8 a)
{
DATA8 *src_itr, *dst_itr;
int y;
src_itr = src->pixels + src_offset;
dst_itr = dst->pixels + dst_offset;
for (y = 0; y < h; y++)
{
_soft8_scanline_blend_solid_solid_mul_alpha(src_itr, dst_itr, w, a);
src_itr += src->stride;
dst_itr += dst->stride;
}
}
static void
_soft8_image_draw_unscaled_transp_solid_mul_alpha(Soft8_Image * src,
Soft8_Image * dst,
RGBA_Draw_Context *
dc __UNUSED__, int src_offset,
int dst_offset, int w, int h,
DATA8 a)
{
DATA8 *src_itr, *dst_itr;
DATA8 *alpha_itr;
int y;
src_itr = src->pixels + src_offset;
alpha_itr = src->alpha + src_offset;
dst_itr = dst->pixels + dst_offset;
for (y = 0; y < h; y++)
{
_soft8_scanline_blend_transp_solid_mul_alpha(src_itr, alpha_itr,
dst_itr, w, a);
src_itr += src->stride;
alpha_itr += src->stride;
dst_itr += dst->stride;
}
}
static inline void
_soft8_image_draw_unscaled_mul_alpha(Soft8_Image * src, Soft8_Image * dst,
RGBA_Draw_Context * dc,
int src_offset, int dst_offset,
int width, int height, DATA8 a)
{
if (src->cache_entry.flags.alpha && (!dst->cache_entry.flags.alpha))
_soft8_image_draw_unscaled_transp_solid_mul_alpha
(src, dst, dc, src_offset, dst_offset, width, height, a);
else if ((!src->cache_entry.flags.alpha) && (!dst->cache_entry.flags.alpha))
_soft8_image_draw_unscaled_solid_solid_mul_alpha
(src, dst, dc, src_offset, dst_offset, width, height, a);
else
ERR("Unsupported draw of unscaled images src->cache_entry.flags.alpha=%d, "
"dst->cache_entry.flags.alpha=%d, WITH ALPHA MUL %d",
src->cache_entry.flags.alpha, dst->cache_entry.flags.alpha, A_VAL(&dc->mul.col));
}
static void
_soft8_image_draw_unscaled_solid_solid_mul_color(Soft8_Image * src,
Soft8_Image * dst,
RGBA_Draw_Context *
dc __UNUSED__, int src_offset,
int dst_offset, int w, int h,
DATA8 r, DATA8 g, DATA8 b,
DATA8 a)
{
DATA8 *src_itr, *dst_itr;
int y;
src_itr = src->pixels + src_offset;
dst_itr = dst->pixels + dst_offset;
if (a == 0xff)
for (y = 0; y < h; y++)
{
_soft8_scanline_blend_solid_solid_mul_color_solid
(src_itr, dst_itr, w, r, g, b);
src_itr += src->stride;
dst_itr += dst->stride;
}
else
for (y = 0; y < h; y++)
{
_soft8_scanline_blend_solid_solid_mul_color_transp
(src_itr, dst_itr, w, a, r, g, b);
src_itr += src->stride;
dst_itr += dst->stride;
}
}
static void
_soft8_image_draw_unscaled_transp_solid_mul_color(Soft8_Image * src,
Soft8_Image * dst,
RGBA_Draw_Context *
dc __UNUSED__, int src_offset,
int dst_offset, int w, int h,
DATA8 r, DATA8 g, DATA8 b,
DATA8 a)
{
DATA8 *src_itr, *dst_itr;
DATA8 *alpha_itr;
int y;
src_itr = src->pixels + src_offset;
alpha_itr = src->alpha + src_offset;
dst_itr = dst->pixels + dst_offset;
if (a == 0xff)
for (y = 0; y < h; y++)
{
_soft8_scanline_blend_transp_solid_mul_color_solid
(src_itr, alpha_itr, dst_itr, w, r, g, b);
src_itr += src->stride;
alpha_itr += src->stride;
dst_itr += dst->stride;
}
else
for (y = 0; y < h; y++)
{
_soft8_scanline_blend_transp_solid_mul_color_transp
(src_itr, alpha_itr, dst_itr, w, a, r, g, b);
src_itr += src->stride;
alpha_itr += src->stride;
dst_itr += dst->stride;
}
}
static inline void
_soft8_image_draw_unscaled_mul_color(Soft8_Image * src, Soft8_Image * dst,
RGBA_Draw_Context * dc,
int src_offset, int dst_offset,
int width, int height,
DATA8 r, DATA8 g, DATA8 b, DATA8 a)
{
if (src->cache_entry.flags.alpha && (!dst->cache_entry.flags.alpha))
_soft8_image_draw_unscaled_transp_solid_mul_color
(src, dst, dc, src_offset, dst_offset, width, height, r, g, b, a);
else if ((!src->cache_entry.flags.alpha) && (!dst->cache_entry.flags.alpha))
_soft8_image_draw_unscaled_solid_solid_mul_color
(src, dst, dc, src_offset, dst_offset, width, height, r, g, b, a);
else
ERR("Unsupported draw of unscaled images src->cache_entry.flags.alpha=%d, "
"dst->cache_entry.flags.alpha=%d, WITH COLOR MUL 0x%08x",
src->cache_entry.flags.alpha, dst->cache_entry.flags.alpha, dc->mul.col);
}
static inline void
_soft8_image_draw_unscaled_mul(Soft8_Image * src, Soft8_Image * dst,
RGBA_Draw_Context * dc,
int src_offset, int dst_offset,
int width, int height, DATA8 r, DATA8 g,
DATA8 b, DATA8 a)
{
if ((a == r) && (a == g) && (a == b))
_soft8_image_draw_unscaled_mul_alpha(src, dst, dc, src_offset,
dst_offset, width, height, a);
else
_soft8_image_draw_unscaled_mul_color(src, dst, dc, src_offset,
dst_offset, width, height,
r, g, b, a);
}
void
evas_common_soft8_image_draw_unscaled(Soft8_Image * src, Soft8_Image * dst,
RGBA_Draw_Context * dc,
const Eina_Rectangle sr,
const Eina_Rectangle dr, const Eina_Rectangle cr)
{
int src_offset_rows, src_offset, dst_offset;
DATA8 mul_gry8;
DATA8 r, g, b, a;
if (!dc->mul.use)
{
r = g = b = a = 0xff;
mul_gry8 = 0xff;
}
else
{
a = A_VAL(&dc->mul.col);
if (a == 0)
return;
r = R_VAL(&dc->mul.col);
g = G_VAL(&dc->mul.col);
b = B_VAL(&dc->mul.col);
if (r > a)
r = a;
if (g > a)
g = a;
if (b > a)
b = a;
mul_gry8 = GRY_8_FROM_COMPONENTS(r, g, b);
}
src_offset_rows = (cr.y - dr.y) + sr.y;
src_offset = (src_offset_rows * src->stride) + (cr.x - dr.x) + sr.x;
dst_offset = cr.x + (cr.y * dst->stride);
if (mul_gry8 == 0xff)
_soft8_image_draw_unscaled_no_mul(src, dst, dc, src_offset, dst_offset,
cr.w, cr.h);
else
_soft8_image_draw_unscaled_mul(src, dst, dc, src_offset, dst_offset,
cr.w, cr.h, r, g, b, a);
}

View File

@ -1,426 +0,0 @@
#include "evas_common_soft8.h"
#include "evas_soft8_scanline_fill.c"
/*
* All functions except by evas_common_soft8_line_draw() expect x0 <= x1.
*/
static inline int
_in_range(int value, int min, int max)
{
return min <= value && value <= max;
}
static inline int
_is_xy_inside_clip(int x, int y, const struct RGBA_Draw_Context_clip clip)
{
if (!clip.use)
return 1;
if (!_in_range(x, clip.x, clip.x + clip.w - 1))
return 0;
if (!_in_range(y, clip.y, clip.y + clip.h - 1))
return 0;
return 1;
}
static inline int
_is_x_inside_clip(int x, const struct RGBA_Draw_Context_clip clip)
{
if (!clip.use)
return 1;
return _in_range(x, clip.x, clip.x + clip.w - 1);
}
static inline int
_is_y_inside_clip(int y, const struct RGBA_Draw_Context_clip clip)
{
if (!clip.use)
return 1;
return _in_range(y, clip.y, clip.y + clip.h - 1);
}
static inline int
_is_xy_inside_rect(int x, int y, int w, int h)
{
return _in_range(x, 0, w - 1) && _in_range(y, 0, h - 1);
}
static inline int
_is_empty_clip(const struct RGBA_Draw_Context_clip clip)
{
return clip.w < 1 || clip.h < 1;
}
static void
_soft8_line_point(Soft8_Image * dst, RGBA_Draw_Context * dc, int x, int y)
{
DATA8 gry8, *dst_itr;
DATA8 alpha;
if (!_is_xy_inside_rect(x, y, dst->cache_entry.w, dst->cache_entry.h))
return;
if (!_is_xy_inside_clip(x, y, dc->clip))
return;
dst_itr = dst->pixels + (dst->stride * y) + x;
alpha = A_VAL(&dc->col.col);
gry8 = GRY_8_FROM_RGB(&dc->col.col);
if (alpha == 0xff)
_soft8_pt_fill_solid_solid(dst_itr, gry8);
else if (alpha > 0)
{
alpha++;
_soft8_pt_fill_transp_solid(dst_itr, gry8, alpha);
}
}
static void
_soft8_line_horiz(Soft8_Image * dst, RGBA_Draw_Context * dc, int x0, int x1,
int y)
{
DATA8 gry8, *dst_itr;
DATA8 alpha;
int w;
if (!_is_y_inside_clip(y, dc->clip))
return;
if (x0 < dc->clip.x)
x0 = dc->clip.x;
if (x1 >= dc->clip.x + dc->clip.w)
x1 = dc->clip.x + dc->clip.w - 1;
w = x1 - x0;
if (w < 1)
return;
dst_itr = dst->pixels + (dst->stride * y) + x0;
alpha = A_VAL(&dc->col.col);
gry8 = GRY_8_FROM_RGB(&dc->col.col);
if (alpha == 0xff)
_soft8_scanline_fill_solid_solid(dst_itr, w, gry8);
else if (alpha > 0)
{
alpha++;
_soft8_scanline_fill_transp_solid(dst_itr, w, gry8, alpha);
}
}
static void
_soft8_line_vert(Soft8_Image * dst, RGBA_Draw_Context * dc, int x, int y0,
int y1)
{
DATA8 gry8, *dst_itr;
DATA8 alpha;
int h;
if (!_is_x_inside_clip(x, dc->clip))
return;
if (y1 < y0)
{
int t;
t = y0;
y0 = y1;
y1 = t;
}
if (y0 < dc->clip.y)
y0 = dc->clip.y;
if (y1 >= dc->clip.y + dc->clip.h)
y1 = dc->clip.y + dc->clip.h - 1;
h = y1 - y0;
if (h < 1)
return;
dst_itr = dst->pixels + (dst->stride * y0) + x;
alpha = A_VAL(&dc->col.col);
gry8 = GRY_8_FROM_RGB(&dc->col.col);
if (alpha == 0xff)
{
for (; h > 0; h--, dst_itr += dst->stride)
_soft8_pt_fill_solid_solid(dst_itr, gry8);
}
else if (alpha > 0)
{
alpha++;
for (; h > 0; h--, dst_itr += dst->stride)
_soft8_pt_fill_transp_solid(dst_itr, gry8, alpha);
}
}
static inline void
_soft8_line_45deg_adjust_boundaries(const struct RGBA_Draw_Context_clip clip,
int *p_x0, int *p_y0, int *p_x1, int *p_y1)
{
int diff, dy, x0, y0, x1, y1;
x0 = *p_x0;
y0 = *p_y0;
x1 = *p_x1;
y1 = *p_y1;
dy = y1 - y0;
diff = clip.x - x0;
if (diff > 0)
{
x0 = clip.x;
y0 += (dy > 0) ? diff : -diff;
}
diff = x1 - (clip.x + clip.w);
if (diff > 0)
{
x1 = clip.x + clip.w;
y1 += (dy > 0) ? -diff : diff;
}
if (dy > 0)
{
diff = clip.y - y0;
if (diff > 0)
{
y0 = clip.y;
x0 += diff;
}
diff = y1 - (clip.y + clip.h);
if (diff > 0)
{
y1 = clip.y + clip.h;
x1 -= diff;
}
}
else
{
diff = clip.y - y1;
if (diff > 0)
{
y1 = clip.y;
x1 -= diff;
}
diff = y0 - (clip.y + clip.h - 1);
if (diff > 0)
{
y0 = clip.y + clip.h - 1;
x0 += diff;
}
}
*p_x0 = x0;
*p_y0 = y0;
*p_x1 = x1;
*p_y1 = y1;
}
static void
_soft8_line_45deg(Soft8_Image * dst, RGBA_Draw_Context * dc, int x0, int y0,
int x1, int y1)
{
int dy, step_dst_itr, len;
DATA8 alpha;
DATA8 *dst_itr, gry8;
alpha = A_VAL(&dc->col.col);
if (alpha < 1)
return;
gry8 = GRY_8_FROM_RGB(&dc->col.col);
dy = y1 - y0;
step_dst_itr = 1 + ((dy > 0) ? dst->stride : -dst->stride);
_soft8_line_45deg_adjust_boundaries(dc->clip, &x0, &y0, &x1, &y1);
len = (dy > 0) ? (y1 - y0) : (y0 - y1);
if (len < 1)
return;
dst_itr = dst->pixels + dst->stride * y0 + x0;
if (alpha == 0xff)
{
for (; len > 0; len--, dst_itr += step_dst_itr)
_soft8_pt_fill_solid_solid(dst_itr, gry8);
}
else
{
alpha++;
for (; len > 0; len--, dst_itr += step_dst_itr)
_soft8_pt_fill_transp_solid(dst_itr, gry8, alpha);
}
}
EFL_ALWAYS_INLINE void
_soft8_line_aliased_pt(DATA8 * dst_itr, DATA8 gry8, DATA8 alpha)
{
if (alpha == 32)
_soft8_pt_fill_solid_solid(dst_itr, gry8);
else
_soft8_pt_fill_transp_solid(dst_itr, gry8, alpha);
}
static void
_soft8_line_aliased(Soft8_Image * dst, RGBA_Draw_Context * dc, int x0, int y0,
int x1, int y1)
{
int dx, dy, step_y, step_dst_itr;
DATA8 gry8;
DATA8 alpha;
alpha = A_VAL(&dc->col.col);
if (alpha == 0)
return;
alpha++;
gry8 = GRY_8_FROM_RGB(&dc->col.col);
dx = x1 - x0;
dy = y1 - y0;
if (dy >= 0)
{
step_y = 1;
step_dst_itr = dst->stride;
}
else
{
dy = -dy;
step_y = -1;
step_dst_itr = -dst->stride;
}
if (dx > dy)
{
DATA8 *dst_itr;
int e, x, y;
e = -(dx / 2);
y = y0;
dst_itr = dst->pixels + dst->stride * y0 + x0;
for (x = x0; x <= x1; x++, dst_itr++)
{
if (_is_xy_inside_clip(x, y, dc->clip))
_soft8_line_aliased_pt(dst_itr, gry8, alpha);
e += dy;
if (e >= 0)
{
dst_itr += step_dst_itr;
y += step_y;
e -= dx;
}
}
}
else
{
DATA8 *dst_itr;
int e, x, y;
e = -(dy / 2);
x = x0;
dst_itr = dst->pixels + dst->stride * y0 + x0;
for (y = y0; y != y1; y += step_y, dst_itr += step_dst_itr)
{
if (_is_xy_inside_clip(x, y, dc->clip))
_soft8_line_aliased_pt(dst_itr, gry8, alpha);
e += dx;
if (e >= 0)
{
dst_itr++;
x++;
e -= dy;
}
}
}
}
void
evas_common_soft8_line_draw(Soft8_Image * dst, RGBA_Draw_Context * dc, int x0, int y0,
int x1, int y1)
{
struct RGBA_Draw_Context_clip c_bkp, c_tmp;
int dx, dy;
int x, y, w, h;
c_tmp.use = 1;
c_tmp.x = 0;
c_tmp.y = 0;
c_tmp.w = dst->cache_entry.w;
c_tmp.h = dst->cache_entry.h;
/* save out clip info */
c_bkp = dc->clip;
if (c_bkp.use)
{
RECTS_CLIP_TO_RECT(c_tmp.x, c_tmp.y, c_tmp.w, c_tmp.h,
c_bkp.x, c_bkp.y, c_bkp.w, c_bkp.h);
if (_is_empty_clip(c_tmp))
return;
}
x = MIN(x0, x1);
y = MIN(y0, y1);
w = MAX(x0, x1) - x + 1;
h = MAX(y0, y1) - y + 1;
RECTS_CLIP_TO_RECT(c_tmp.x, c_tmp.y, c_tmp.w, c_tmp.h, x, y, w, h);
if (_is_empty_clip(c_tmp))
return;
/* Check if the line doesn't cross the clip area */
if (x0 < c_tmp.x && x1 < c_tmp.x)
return;
if (x0 >= c_tmp.x + c_tmp.w && x1 >= c_tmp.x + c_tmp.w)
return;
if (y0 < c_tmp.y && y1 < c_tmp.y)
return;
if (y0 >= c_tmp.y + c_tmp.h && y1 >= c_tmp.y + c_tmp.h)
return;
dc->clip = c_tmp;
dx = x1 - x0;
dy = y1 - y0;
if (dx < 0)
{
int t;
t = x0;
x0 = x1;
x1 = t;
t = y0;
y0 = y1;
y1 = t;
}
if (dx == 0 && dy == 0)
_soft8_line_point(dst, dc, x0, y0);
else if (dx == 0)
_soft8_line_vert(dst, dc, x0, y0, y1);
else if (dy == 0)
_soft8_line_horiz(dst, dc, x0, x1, y0);
else if (dy == dx || dy == -dx)
_soft8_line_45deg(dst, dc, x0, y0, x1, y1);
else
_soft8_line_aliased(dst, dc, x0, y0, x1, y1);
/* restore clip info */
dc->clip = c_bkp;
}

View File

@ -1,655 +0,0 @@
#include "evas_common_soft8.h"
static Evas_Cache_Image *eci = NULL;
static int reference = 0;
static Image_Entry *_evas_common_soft8_image_new(void);
static void _evas_common_soft8_image_delete(Image_Entry * ie);
static int _evas_common_soft8_image_surface_alloc(Image_Entry * ie, unsigned int w, unsigned int h);
static void _evas_common_soft8_image_surface_delete(Image_Entry * ie);
static DATA32 *_evas_common_soft8_image_surface_pixels(Image_Entry * ie);
static int _evas_common_load_soft8_image_from_file(Image_Entry * ie);
static void _evas_common_soft8_image_unload(Image_Entry * ie);
static void _evas_common_soft8_image_dirty_region(Image_Entry * im, unsigned int x, unsigned int y, unsigned int w, unsigned int h);
static int _evas_common_soft8_image_dirty(Image_Entry * ie_dst,
const Image_Entry * ie_src);
static int _evas_common_soft8_image_ram_usage(Image_Entry * ie);
static int _evas_common_soft8_image_size_set(Image_Entry * ie_dst,
const Image_Entry * ie_im, unsigned int w, unsigned int h);
static int _evas_common_soft8_image_from_copied_data(Image_Entry * ie_dst, unsigned int w, unsigned int h, DATA32 * image_data, int alpha, int cspace);
static int _evas_common_soft8_image_from_data(Image_Entry * ie_dst, unsigned int w, unsigned int h, DATA32 * image_data, int alpha, int cspace);
static int _evas_common_soft8_image_colorspace_set(Image_Entry * ie_dst,
int cspace);
static int _evas_common_load_soft8_image_data_from_file(Image_Entry * ie);
/*
static void
_evas_common_soft8_image_debug(const char* context, Image_Entry *eim)
{
DBG("[8] %p = [%s] {%s,%s} %i [%i|%i]", eim, context, eim->file, eim->key, eim->references, eim->w, eim->h);
}
*/
static const Evas_Cache_Image_Func _evas_common_soft8_image_func = {
_evas_common_soft8_image_new,
_evas_common_soft8_image_delete,
_evas_common_soft8_image_surface_alloc,
_evas_common_soft8_image_surface_delete,
_evas_common_soft8_image_surface_pixels,
_evas_common_load_soft8_image_from_file,
_evas_common_soft8_image_unload,
_evas_common_soft8_image_dirty_region,
_evas_common_soft8_image_dirty,
_evas_common_soft8_image_size_set,
_evas_common_soft8_image_from_copied_data,
_evas_common_soft8_image_from_data,
_evas_common_soft8_image_colorspace_set,
_evas_common_load_soft8_image_data_from_file,
_evas_common_soft8_image_ram_usage,
/* _evas_common_soft8_image_debug */
NULL
};
EAPI void
evas_common_soft8_image_init(void)
{
if (!eci)
eci = evas_cache_image_init(&_evas_common_soft8_image_func);
reference++;
}
EAPI void
evas_common_soft8_image_shutdown(void)
{
if (--reference == 0)
{
// DISABLE for now - something wrong with cache shutdown freeing things
// still in use - rage_thumb segv's now.
//
// actually - i think i see it. cache ref goes to 0 (and thus gets freed)
// because in eng_setup() when a buffer changes size it is FIRST freed
// THEN allocated again - thus brignhjing ref to 0 then back to 1 immediately
// where it should stay at 1. - see evas_engine.c in the buffer enigne for
// example. eng_output_free() is called BEFORE _output_setup(). although this
// is only a SIGNE of the problem. we can patch this up with either freeing
// after the setup (so we just pt a ref of 2 then back to 1), or just
// evas_common_image_init() at the start and evas_common_image_shutdown()
// after it all. really ref 0 should only be reached when no more canvases
// with no more objects exist anywhere.
// ENABLE IT AGAIN, hope it is fixed. Gustavo @ January 22nd, 2009.
//evas_cache_image_shutdown(eci);
//eci = NULL;
}
}
EAPI Evas_Cache_Image *
evas_common_soft8_image_cache_get(void)
{
return eci;
}
static Image_Entry *
_evas_common_soft8_image_new(void)
{
Soft8_Image *im;
im = calloc(1, sizeof(Soft8_Image));
if (!im)
return NULL;
im->stride = -1;
return (Image_Entry *) im;
}
static void
_evas_common_soft8_image_delete(Image_Entry * ie)
{
memset(ie, 0xFF, sizeof(Soft8_Image));
free(ie);
}
static int
_evas_common_soft8_image_surface_alloc(Image_Entry * ie, unsigned int w, unsigned int h)
{
Soft8_Image *im = (Soft8_Image *) ie;
if (im->stride < 0)
im->stride = _calc_stride(w);
im->pixels =
realloc(im->pixels, IMG_BYTE_SIZE(im->stride, h, ie->flags.alpha));
if (!im->pixels)
return -1;
if (ie->flags.alpha)
{
im->alpha = (DATA8 *) (im->pixels + (im->stride * h));
im->flags.free_alpha = 0;
}
im->flags.free_pixels = 1;
return 0;
}
static void
_evas_common_soft8_image_surface_delete(Image_Entry * ie)
{
Soft8_Image *im = (Soft8_Image *) ie;
if (im->flags.free_pixels)
free(im->pixels);
im->pixels = NULL;
im->flags.free_pixels = 0;
if (im->flags.free_alpha)
free(im->alpha);
im->alpha = NULL;
im->flags.free_alpha = 0;
}
static DATA32 *
_evas_common_soft8_image_surface_pixels(Image_Entry * ie __UNUSED__)
{
abort();
return NULL;
}
static int
_evas_common_load_soft8_image_from_file(Image_Entry * ie)
{
Soft8_Image *sim = (Soft8_Image *) ie;
RGBA_Image *im;
int error = 0;
im = (RGBA_Image *) evas_cache_image_request(evas_common_image_cache_get(),
sim->cache_entry.file,
sim->cache_entry.key,
&sim->cache_entry.load_opts,
&error);
sim->source = im;
if (!sim->source)
return -1;
sim->cache_entry.w = sim->source->cache_entry.w;
sim->cache_entry.h = sim->source->cache_entry.h;
ie->flags.alpha = im->cache_entry.flags.alpha;
if (sim->stride < 0)
sim->stride = _calc_stride(sim->cache_entry.w);
return 0;
}
static void
_evas_common_soft8_image_unload(Image_Entry * ie __UNUSED__)
{
}
static void
_evas_common_soft8_image_dirty_region(Image_Entry * im __UNUSED__,
unsigned int x __UNUSED__,
unsigned int y __UNUSED__,
unsigned int w __UNUSED__,
unsigned int h __UNUSED__)
{
}
static int
_evas_common_soft8_image_dirty(Image_Entry * ie_dst, const Image_Entry * ie_src)
{
Soft8_Image *dst = (Soft8_Image *) ie_dst;
Soft8_Image *src = (Soft8_Image *) ie_src;
evas_cache_image_load_data(&src->cache_entry);
evas_cache_image_surface_alloc(&dst->cache_entry,
src->cache_entry.w, src->cache_entry.h);
/* evas_common_blit_rectangle(src, dst, 0, 0, src->cache_entry.w, src->cache_entry.h, 0, 0); */
return 0;
}
static int
_evas_common_soft8_image_ram_usage(Image_Entry * ie)
{
Soft8_Image *im = (Soft8_Image *) ie;
if (im->pixels && im->flags.free_pixels)
return IMG_BYTE_SIZE(im->stride, im->cache_entry.h, ie->flags.alpha);
return 0;
}
static int
_evas_common_soft8_image_size_set(Image_Entry * ie_dst,
const Image_Entry * ie_im,
unsigned int w __UNUSED__,
unsigned int h __UNUSED__)
{
Soft8_Image *dst = (Soft8_Image *) ie_dst;
Soft8_Image *im = (Soft8_Image *) ie_im;
dst->flags = im->flags;
return 0;
}
static int
_evas_common_soft8_image_from_data(Image_Entry * ie_dst,
unsigned int w, unsigned int h,
DATA32 * image_data, int alpha,
int cspace __UNUSED__)
{
Soft8_Image *im = (Soft8_Image *) ie_dst;
/* FIXME: handle colorspace */
ie_dst->w = w;
ie_dst->h = h;
ie_dst->flags.alpha = alpha;
im->flags.free_pixels = 0;
im->flags.free_alpha = 0;
if (im->stride < 0)
im->stride = _calc_stride(w);
/* FIXME: That's bad, the application must be aware of the engine internal. */
im->pixels = (DATA8 *) image_data;
if (ie_dst->flags.alpha)
im->alpha = (DATA8 *) (im->pixels + (im->stride * h));
return 0;
}
static int
_evas_common_soft8_image_from_copied_data(Image_Entry * ie_dst,
unsigned int w __UNUSED__,
unsigned int h,
DATA32 * image_data,
int alpha __UNUSED__,
int cspace __UNUSED__)
{
Soft8_Image *im = (Soft8_Image *) ie_dst;
/* FIXME: handle colorspace */
if (image_data)
memcpy(im->pixels, image_data,
IMG_BYTE_SIZE(im->stride, h, ie_dst->flags.alpha));
else
memset(im->pixels, 0, IMG_BYTE_SIZE(im->stride, h, ie_dst->flags.alpha));
return 0;
}
static int
_evas_common_soft8_image_colorspace_set(Image_Entry * ie_dst __UNUSED__,
int cspace __UNUSED__)
{
/* FIXME: handle colorspace */
return 0;
}
static int
_evas_common_load_soft8_image_data_from_file(Image_Entry * ie)
{
Soft8_Image *im = (Soft8_Image *) ie;
if (im->pixels)
return 0;
if (!im->source)
return -1;
evas_cache_image_load_data(&im->source->cache_entry);
if (im->source->image.data)
{
DATA32 *sp;
evas_cache_image_surface_alloc(&im->cache_entry,
im->source->cache_entry.w,
im->source->cache_entry.h);
sp = im->source->image.data;
if (im->alpha)
evas_common_soft8_image_convert_from_rgba(im, sp);
else
evas_common_soft8_image_convert_from_rgb(im, sp);
}
evas_cache_image_drop(&im->source->cache_entry);
im->source = NULL;
return 0;
}
/* Soft16_Image * */
/* evas_common_soft16_image_new(int w, unsigned int h, unsigned int stride, int have_alpha, DATA16 *pixels, */
/* int copy) */
/* { */
/* Soft16_Image *im; */
/* if (stride < 0) stride = _calc_stride(w); */
/* im = evas_common_soft16_image_alloc(w, h, stride, have_alpha, copy); */
/* if (!im) return NULL; */
/* if (pixels) */
/* { */
/* if (copy) */
/* memcpy(im->pixels, pixels, IMG_BYTE_SIZE(stride, h, have_alpha)); */
/* else */
/* { */
/* im->pixels = pixels; */
/* if (have_alpha) im->alpha = (DATA8 *)(im->pixels + (stride * h)); */
/* } */
/* } */
/* return im; */
/* } */
static inline void
_get_clip(const RGBA_Draw_Context * dc, const Soft8_Image * im,
Eina_Rectangle * clip)
{
if (dc->clip.use)
{
EINA_RECTANGLE_SET(clip, dc->clip.x, dc->clip.y, dc->clip.w,
dc->clip.h);
if (clip->x < 0)
{
clip->w += clip->x;
clip->x = 0;
}
if (clip->y < 0)
{
clip->h += clip->y;
clip->y = 0;
}
if ((clip->x + clip->w) > (int)im->cache_entry.w)
clip->w = im->cache_entry.w - clip->x;
if ((clip->y + clip->h) > (int)im->cache_entry.h)
clip->h = im->cache_entry.h - clip->y;
}
else
{
EINA_RECTANGLE_SET(clip, 0, 0, im->cache_entry.w, im->cache_entry.h);
}
}
static inline int
_is_empty_rectangle(const Eina_Rectangle * r)
{
return (r->w < 1) || (r->h < 1);
}
static inline void
_shrink(int *s_pos, int *s_size, int pos, int size)
{
int d;
d = (*s_pos) - pos;
if (d < 0)
{
(*s_size) += d;
(*s_pos) = pos;
}
d = size + pos - (*s_pos);
if ((*s_size) > d)
(*s_size) = d;
}
static int
_soft8_adjust_areas(Eina_Rectangle * src,
int src_max_x, int src_max_y, Eina_Rectangle * dst,
int dst_max_x, int dst_max_y, Eina_Rectangle * dst_clip)
{
if (_is_empty_rectangle(src) ||
_is_empty_rectangle(dst) || _is_empty_rectangle(dst_clip))
return 0;
/* shrink clip */
_shrink(&dst_clip->x, &dst_clip->w, dst->x, dst->w);
_shrink(&dst_clip->y, &dst_clip->h, dst->y, dst->h);
if (_is_empty_rectangle(dst_clip))
return 0;
/* sanitise x */
if (src->x < 0)
{
dst->x -= (src->x * dst->w) / src->w;
dst->w += (src->x * dst->w) / src->w;
src->w += src->x;
src->x = 0;
}
if (src->x >= src_max_x)
return 0;
if ((src->x + src->w) > src_max_x)
{
dst->w = (dst->w * (src_max_x - src->x)) / (src->w);
src->w = src_max_x - src->x;
}
if (dst->w <= 0)
return 0;
if (src->w <= 0)
return 0;
if (dst_clip->x < 0)
{
dst_clip->w += dst_clip->x;
dst_clip->x = 0;
}
if (dst_clip->w <= 0)
return 0;
if (dst_clip->x >= dst_max_x)
return 0;
_shrink(&dst_clip->x, &dst_clip->w, 0, dst_max_x);
if (dst_clip->w <= 0)
return 0;
/* sanitise y */
if (src->y < 0)
{
dst->y -= (src->y * dst->h) / src->h;
dst->h += (src->y * dst->h) / src->h;
src->h += src->y;
src->y = 0;
}
if (src->y >= src_max_y)
return 0;
if ((src->y + src->h) > src_max_y)
{
dst->h = (dst->h * (src_max_y - src->y)) / (src->h);
src->h = src_max_y - src->y;
}
if (dst->h <= 0)
return 0;
if (src->h <= 0)
return 0;
if (dst_clip->y < 0)
{
dst_clip->h += dst_clip->y;
dst_clip->y = 0;
}
if (dst_clip->h <= 0)
return 0;
if (dst_clip->y >= dst_max_y)
return 0;
_shrink(&dst_clip->y, &dst_clip->h, 0, dst_max_y);
if (dst_clip->h <= 0)
return 0;
return 1;
}
static void
_soft8_image_draw_sampled_int(Soft8_Image * src, Soft8_Image * dst,
RGBA_Draw_Context * dc,
Eina_Rectangle sr, Eina_Rectangle dr)
{
Eina_Rectangle cr;
if (!
(RECTS_INTERSECT
(dr.x, dr.y, dr.w, dr.h, 0, 0, dst->cache_entry.w, dst->cache_entry.h)))
return;
if (!
(RECTS_INTERSECT
(sr.x, sr.y, sr.w, sr.h, 0, 0, src->cache_entry.w, src->cache_entry.h)))
return;
_get_clip(dc, dst, &cr);
if (!_soft8_adjust_areas
(&sr, src->cache_entry.w, src->cache_entry.h, &dr, dst->cache_entry.w,
dst->cache_entry.h, &cr))
return;
if ((dr.w == sr.w) && (dr.h == sr.h))
evas_common_soft8_image_draw_unscaled(src, dst, dc, sr, dr, cr);
else
evas_common_soft8_image_draw_scaled_sampled(src, dst, dc, sr, dr, cr);
}
EAPI void
evas_common_soft8_image_draw(Soft8_Image * src, Soft8_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 __UNUSED__)
{
static Cutout_Rects *rects = NULL;
Eina_Rectangle sr, dr;
Cutout_Rect *r;
struct RGBA_Draw_Context_clip clip_bkp;
int i;
/* handle cutouts here! */
EINA_RECTANGLE_SET(&dr, dst_region_x, dst_region_y, dst_region_w,
dst_region_h);
if (_is_empty_rectangle(&dr))
return;
if (!
(RECTS_INTERSECT
(dr.x, dr.y, dr.w, dr.h, 0, 0, dst->cache_entry.w, dst->cache_entry.h)))
return;
EINA_RECTANGLE_SET(&sr, src_region_x, src_region_y, src_region_w,
src_region_h);
if (_is_empty_rectangle(&sr))
return;
if (!
(RECTS_INTERSECT
(sr.x, sr.y, sr.w, sr.h, 0, 0, src->cache_entry.w, src->cache_entry.h)))
return;
/* no cutouts - cut right to the chase */
if (!dc->cutout.rects)
{
_soft8_image_draw_sampled_int(src, dst, dc, sr, dr);
return;
}
/* save out clip info */
clip_bkp = dc->clip;
evas_common_draw_context_clip_clip(dc, 0, 0, dst->cache_entry.w,
dst->cache_entry.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 = clip_bkp;
return;
}
rects = evas_common_draw_context_apply_cutouts(dc, rects);
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);
_soft8_image_draw_sampled_int(src, dst, dc, sr, dr);
}
dc->clip = clip_bkp;
}
EAPI Soft8_Image *
evas_common_soft8_image_alpha_set(Soft8_Image * im, int have_alpha)
{
Soft8_Image *new_im;
if (im->cache_entry.flags.alpha == have_alpha)
return im;
new_im = (Soft8_Image *) evas_cache_image_alone(&im->cache_entry);
new_im->cache_entry.flags.alpha = have_alpha;
if (im->cache_entry.w > 0 && im->cache_entry.h)
new_im =
(Soft8_Image *) evas_cache_image_size_set(&new_im->cache_entry,
im->cache_entry.w,
im->cache_entry.h);
return new_im;
}
/* Soft16_Image * */
/* evas_common_soft16_image_size_set(Soft16_Image *old_im, unsigned int w, unsigned int h) */
/* { */
/* Soft16_Image *new_im; */
/* DATA16 *dp, *sp; */
/* int i, cw, ch, ew; */
/* if ((old_im->cache_entry.w == w) && (old_im->cache_entry.h == h)) return old_im; */
/* new_im = evas_common_soft16_image_new(w, h, -1, old_im->flags.have_alpha, NULL, 1); */
/* if (old_im->cache_entry.w < new_im->cache_entry.w) */
/* cw = old_im->cache_entry.w; */
/* else */
/* cw = new_im->cache_entry.w; */
/* ew = new_im->cache_entry.w - cw; */
/* if (old_im->cache_entry.h < new_im->cache_entry.h) */
/* ch = old_im->cache_entry.h; */
/* else */
/* ch = new_im->cache_entry.h; */
/* dp = new_im->pixels; */
/* sp = old_im->pixels; */
/* for (i = 0; i < ch; i++) */
/* { */
/* memcpy(dp, sp, cw * sizeof(DATA16)); */
/* if (ew > 0) memset(dp, 0, ew * sizeof(DATA16)); */
/* dp += new_im->stride; */
/* sp += old_im->stride; */
/* } */
/* if (old_im->flags.have_alpha) */
/* { */
/* DATA8 *dp, *sp; */
/* dp = new_im->alpha; */
/* sp = old_im->alpha; */
/* for (i = 0; i < ch; i++) */
/* { */
/* memcpy(dp, sp, cw * sizeof(DATA8)); */
/* if (ew > 0) memset(dp, 0, ew * sizeof(DATA8)); */
/* dp += new_im->stride; */
/* sp += old_im->stride; */
/* } */
/* } */
/* evas_cache_image_drop(&old_im->cache_entry); */
/* return new_im; */
/* } */

View File

@ -1,230 +0,0 @@
#include <evas_common_soft8.h>
#include "evas_soft8_scanline_fill.c"
#include <math.h>
typedef struct _RGBA_Edge RGBA_Edge;
typedef struct _RGBA_Vertex RGBA_Vertex;
struct _RGBA_Edge {
float x, dx;
int i;
};
struct _RGBA_Vertex {
float x, y;
int i;
};
#define POLY_EDGE_DEL(_i) \
{ \
int _j; \
\
for (_j = 0; (_j < num_active_edges) && (edges[_j].i != _i); _j++); \
if (_j < num_active_edges) \
{ \
num_active_edges--; \
memmove(&(edges[_j]), &(edges[_j + 1]), \
(num_active_edges - _j) * sizeof(RGBA_Edge)); \
} \
}
#define POLY_EDGE_ADD(_i, _y) \
{ \
int _j; \
float _dx; \
RGBA_Vertex *_p, *_q; \
if (_i < (n - 1)) _j = _i + 1; \
else _j = 0; \
if (point[_i].y < point[_j].y) \
{ \
_p = &(point[_i]); \
_q = &(point[_j]); \
} \
else \
{ \
_p = &(point[_j]); \
_q = &(point[_i]); \
} \
edges[num_active_edges].dx = _dx = (_q->x - _p->x) / (_q->y - _p->y); \
edges[num_active_edges].x = (_dx * ((float)_y + 0.5 - _p->y)) + _p->x; \
edges[num_active_edges].i = _i; \
num_active_edges++; \
}
static int
polygon_point_sorter(const void *a, const void *b)
{
RGBA_Vertex *p, *q;
p = (RGBA_Vertex *) a;
q = (RGBA_Vertex *) b;
if (p->y <= q->y)
return -1;
return 1;
}
static int
polygon_edge_sorter(const void *a, const void *b)
{
RGBA_Edge *p, *q;
p = (RGBA_Edge *) a;
q = (RGBA_Edge *) b;
if (p->x <= q->x)
return -1;
return 1;
}
void
evas_common_soft8_polygon_draw(Soft8_Image * dst, RGBA_Draw_Context * dc,
RGBA_Polygon_Point * points, int x, int y)
{
RGBA_Polygon_Point *pt;
RGBA_Vertex *point;
RGBA_Edge *edges;
int num_active_edges;
int n;
int i, j, k;
int y0, y1, yi;
int ext_x, ext_y, ext_w, ext_h;
int *sorted_index;
DATA8 alpha;
DATA8 gry8;
alpha = A_VAL(&dc->col.col);
if (alpha == 0)
return;
alpha++;
gry8 = GRY_8_FROM_RGB(&dc->col.col);
ext_x = 0;
ext_y = 0;
ext_w = dst->cache_entry.w;
ext_h = dst->cache_entry.h;
if (dc->clip.use)
RECTS_CLIP_TO_RECT(ext_x, ext_y, ext_w, ext_h,
dc->clip.x, dc->clip.y, dc->clip.w, dc->clip.h);
if ((ext_w <= 0) || (ext_h <= 0))
return;
n = 0;
EINA_INLIST_FOREACH(points, pt) n++;
if (n < 3)
return;
edges = malloc(sizeof(RGBA_Edge) * n);
if (!edges)
return;
point = malloc(sizeof(RGBA_Vertex) * n);
if (!point)
{
free(edges);
return;
}
sorted_index = malloc(sizeof(int) * n);
if (!sorted_index)
{
free(edges);
free(point);
return;
}
k = 0;
EINA_INLIST_FOREACH(points, pt)
{
point[k].x = pt->x + x;
point[k].y = pt->y + y;
point[k].i = k;
k++;
}
qsort(point, n, sizeof(RGBA_Vertex), polygon_point_sorter);
for (k = 0; k < n; k++)
sorted_index[k] = point[k].i;
k = 0;
EINA_INLIST_FOREACH(points, pt)
{
point[k].x = pt->x + x;
point[k].y = pt->y + y;
point[k].i = k;
k++;
}
y0 = MAX(ext_y, ceil(point[sorted_index[0]].y - 0.5));
y1 = MIN(ext_y + ext_h - 1, floor(point[sorted_index[n - 1]].y - 0.5));
k = 0;
num_active_edges = 0;
for (yi = y0; yi <= y1; yi++)
{
for (; (k < n) && (point[sorted_index[k]].y <= ((float)yi + 0.5)); k++)
{
i = sorted_index[k];
if (i > 0)
j = i - 1;
else
j = n - 1;
if (point[j].y <= ((float)yi - 0.5))
{
POLY_EDGE_DEL(j)}
else if (point[j].y > ((float)yi + 0.5))
{
POLY_EDGE_ADD(j, yi)}
if (i < (n - 1))
j = i + 1;
else
j = 0;
if (point[j].y <= ((float)yi - 0.5))
{
POLY_EDGE_DEL(i)}
else if (point[j].y > ((float)yi + 0.5))
{
POLY_EDGE_ADD(i, yi)}
}
qsort(edges, num_active_edges, sizeof(RGBA_Edge), polygon_edge_sorter);
for (j = 0; j < num_active_edges; j += 2)
{
int x0, x1;
x0 = ceil(edges[j].x - 0.5);
if (j < (num_active_edges - 1))
x1 = floor(edges[j + 1].x - 0.5);
else
x1 = x0;
if ((x1 >= ext_x) && (x0 < (ext_x + ext_w)) && (x0 <= x1))
{
DATA8 *dst_itr;
int w;
if (x0 < ext_x)
x0 = ext_x;
if (x1 >= (ext_x + ext_w))
x1 = ext_x + ext_w - 1;
w = (x1 - x0) + 1;
dst_itr = dst->pixels + (yi * dst->stride) + x0;
if (alpha == 0xff)
_soft8_scanline_fill_solid_solid(dst_itr, w, gry8);
else
_soft8_scanline_fill_transp_solid(dst_itr, w, gry8, alpha);
}
edges[j].x += edges[j].dx;
edges[j + 1].x += edges[j + 1].dx;
}
}
free(edges);
free(point);
free(sorted_index);
}

View File

@ -1,124 +0,0 @@
#include "evas_common_soft8.h"
#include "evas_soft8_scanline_fill.c"
static inline int
_is_empty_rectangle(const Eina_Rectangle * r)
{
return (r->w < 1) || (r->h < 1);
}
static inline void
_soft8_rectangle_draw_solid_solid(Soft8_Image * dst, int offset, int w, int h,
DATA8 gry8)
{
DATA8 *dst_itr;
int i;
dst_itr = dst->pixels + offset;
for (i = 0; i < h; i++, dst_itr += dst->stride)
_soft8_scanline_fill_solid_solid(dst_itr, w, gry8);
}
static inline void
_soft8_rectangle_draw_transp_solid(Soft8_Image * dst, int offset, int w, int h,
DATA8 gry8, DATA8 alpha)
{
DATA8 *dst_itr;
int i;
dst_itr = dst->pixels + offset;
alpha++;
for (i = 0; i < h; i++, dst_itr += dst->stride)
_soft8_scanline_fill_transp_solid(dst_itr, w, gry8, alpha);
}
static void
_soft8_rectangle_draw_int(Soft8_Image * dst, RGBA_Draw_Context * dc,
Eina_Rectangle dr)
{
int dst_offset;
if (_is_empty_rectangle(&dr))
return;
RECTS_CLIP_TO_RECT(dr.x, dr.y, dr.w, dr.h, 0, 0, dst->cache_entry.w,
dst->cache_entry.h);
if (_is_empty_rectangle(&dr))
return;
if (dc->clip.use)
RECTS_CLIP_TO_RECT(dr.x, dr.y, dr.w, dr.h, dc->clip.x,
dc->clip.y, dc->clip.w, dc->clip.h);
if (_is_empty_rectangle(&dr))
return;
if (A_VAL(&dc->col.col) == 0)
return;
dst_offset = dr.x + (dr.y * dst->stride);
if (!dst->cache_entry.flags.alpha)
{
DATA8 gry8;
DATA8 alpha;
alpha = A_VAL(&dc->col.col);
gry8 = GRY_8_FROM_RGB(&dc->col.col);
if (alpha == 0xff)
_soft8_rectangle_draw_solid_solid(dst, dst_offset, dr.w, dr.h, gry8);
else if (alpha > 0)
_soft8_rectangle_draw_transp_solid
(dst, dst_offset, dr.w, dr.h, gry8, alpha);
}
else
ERR("Unsupported feature: drawing rectangle to non-opaque destination.");
}
void
evas_common_soft8_rectangle_draw(Soft8_Image * dst, RGBA_Draw_Context * dc,
int x, int y, int w, int h)
{
static Cutout_Rects *rects = NULL;
Eina_Rectangle dr;
Cutout_Rect *r;
struct RGBA_Draw_Context_clip c_bkp;
int i;
/* handle cutouts here! */
EINA_RECTANGLE_SET(&dr, x, y, w, h);
if (_is_empty_rectangle(&dr))
return;
if (!
(RECTS_INTERSECT
(dr.x, dr.y, dr.w, dr.h, 0, 0, dst->cache_entry.w, dst->cache_entry.h)))
return;
/* no cutouts - cut right to the chase */
if (!dc->cutout.rects)
{
_soft8_rectangle_draw_int(dst, dc, dr);
return;
}
c_bkp = dc->clip;
evas_common_draw_context_clip_clip(dc, 0, 0, dst->cache_entry.w,
dst->cache_entry.h);
evas_common_draw_context_clip_clip(dc, x, y, w, h);
/* our clip is 0 size.. abort */
if ((dc->clip.w <= 0) || (dc->clip.h <= 0))
{
dc->clip = c_bkp;
return;
}
rects = evas_common_draw_context_apply_cutouts(dc, rects);
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);
_soft8_rectangle_draw_int(dst, dc, dr);
}
dc->clip = c_bkp;
}

View File

@ -1,447 +0,0 @@
/** NOTE: This file is meant to be included by users **/
/** NOTE2: r, g, b parameters are 16bits, so you can pass 0 to 256 inclusive.
** this is due our division by 256 when multiplying the color.
**/
/*****************************************************************************
* Scanline processing
*
* _soft8_scanline_<description>_<src>_<dst>[_<modifier>]()
*
****************************************************************************/
EFL_ALWAYS_INLINE void
_soft8_pt_blend_transp_solid(DATA8 * p_dst, DATA8 src, DATA8 alpha)
{
if (alpha == 0xff)
*p_dst = src;
else if (alpha != 0)
{
*p_dst = GRY_8_BLEND(src, *p_dst, alpha);
}
}
/***********************************************************************
* Regular blend operations
*/
static void
_soft8_scanline_blend_transp_solid(DATA8 * src, DATA8 * alpha, DATA8 * dst,
int size)
{
DATA8 *start, *end;
start = dst;
end = start + (size & ~7);
pld(alpha, 0);
pld(src, 0);
/* work on 8 pixels per time, do data preload */
while (start < end)
{
DATA8 alpha1, alpha2;
alpha1 = alpha[0];
alpha += 8;
/* empirical tests show these give the best performance */
pld(alpha, 8);
pld(src, 32);
src += 8;
start += 8;
alpha2 = alpha[-7];
_soft8_pt_blend_transp_solid(start - 8, src[-8], alpha1);
alpha1 = alpha[-6];
_soft8_pt_blend_transp_solid(start - 7, src[-7], alpha2);
alpha2 = alpha[-5];
_soft8_pt_blend_transp_solid(start - 6, src[-6], alpha1);
alpha1 = alpha[-4];
_soft8_pt_blend_transp_solid(start - 5, src[-5], alpha2);
alpha2 = alpha[-3];
_soft8_pt_blend_transp_solid(start - 4, src[-4], alpha1);
alpha1 = alpha[-2];
_soft8_pt_blend_transp_solid(start - 3, src[-3], alpha2);
alpha2 = alpha[-1];
_soft8_pt_blend_transp_solid(start - 2, src[-2], alpha1);
_soft8_pt_blend_transp_solid(start - 1, src[-1], alpha2);
}
/* remaining pixels (up to 7) */
end = start + (size & 7);
for (; start < end; start++, src++, alpha++)
_soft8_pt_blend_transp_solid(start, *src, *alpha);
}
EFL_ALWAYS_INLINE void
_soft8_pt_blend_solid_solid(DATA8 * p_dst, DATA8 src)
{
*p_dst = src;
}
static inline void
_soft8_scanline_blend_solid_solid(DATA8 * src, DATA8 * dst, int size)
{
memcpy(dst, src, size * sizeof(DATA8));
}
/***********************************************************************
* Blend operations taking an extra alpha (fade in, out)
*/
static inline void
_soft8_pt_blend_transp_solid_mul_alpha(DATA8 * p_dst, DATA8 src, DATA8 alpha,
DATA8 rel_alpha)
{
alpha = alpha * rel_alpha;
if (alpha == 0)
return;
alpha++;
*p_dst = GRY_8_BLEND((src * rel_alpha) & 0xff, *p_dst, alpha);
}
static void
_soft8_scanline_blend_transp_solid_mul_alpha(DATA8 * src, DATA8 * alpha,
DATA8 * dst, int size,
const DATA8 rel_alpha)
{
DATA8 *start, *end;
start = dst;
end = start + (size & ~7);
pld(alpha, 0);
pld(src, 0);
while (start < end)
{
DATA8 alpha1, alpha2;
alpha1 = alpha[0];
alpha += 8;
pld(alpha, 8);
pld(src, 32);
src += 8;
start += 8;
alpha2 = alpha[-7];
_soft8_pt_blend_transp_solid_mul_alpha
(start - 8, src[-8], alpha1, rel_alpha);
alpha1 = alpha[-6];
_soft8_pt_blend_transp_solid_mul_alpha
(start - 7, src[-7], alpha2, rel_alpha);
alpha2 = alpha[-5];
_soft8_pt_blend_transp_solid_mul_alpha
(start - 6, src[-6], alpha1, rel_alpha);
alpha1 = alpha[-4];
_soft8_pt_blend_transp_solid_mul_alpha
(start - 5, src[-5], alpha2, rel_alpha);
alpha2 = alpha[-3];
_soft8_pt_blend_transp_solid_mul_alpha
(start - 4, src[-4], alpha1, rel_alpha);
alpha1 = alpha[-2];
_soft8_pt_blend_transp_solid_mul_alpha
(start - 3, src[-3], alpha2, rel_alpha);
alpha2 = alpha[-1];
_soft8_pt_blend_transp_solid_mul_alpha
(start - 2, src[-2], alpha1, rel_alpha);
_soft8_pt_blend_transp_solid_mul_alpha
(start - 1, src[-1], alpha2, rel_alpha);
}
end = start + (size & 7);
for (; start < end; start++, src++, alpha++)
_soft8_pt_blend_transp_solid_mul_alpha(start, *src, *alpha, rel_alpha);
}
EFL_ALWAYS_INLINE void
_soft8_pt_blend_solid_solid_mul_alpha(DATA8 * p_dst, DATA8 src, DATA8 rel_alpha)
{
*p_dst = GRY_8_BLEND_UNMUL(src, *p_dst, rel_alpha);
}
static void
_soft8_scanline_blend_solid_solid_mul_alpha(DATA8 * src, DATA8 * dst, int size,
DATA8 rel_alpha)
{
DATA8 *start, *end;
start = dst;
end = start + (size & ~7);
pld(src, 0);
while (start < end)
{
pld(src, 32);
UNROLL8(
{
_soft8_pt_blend_solid_solid_mul_alpha(start, *src, rel_alpha);
start++; src++;}
);
}
end = start + (size & 7);
for (; start < end; start++, src++)
_soft8_pt_blend_solid_solid_mul_alpha(start, *src, rel_alpha);
}
/***********************************************************************
* Blend operations with extra alpha and multiply color
*/
EFL_ALWAYS_INLINE void
_soft8_pt_blend_transp_solid_mul_color_transp(DATA8 * p_dst, DATA8 src,
DATA8 alpha, DATA8 rel_alpha,
DATA8 r, DATA8 g, DATA8 b)
{
alpha = alpha * rel_alpha;
if (alpha == 0)
return;
alpha++;
DATA8 gry8 = (src * GRY_8_FROM_COMPONENTS(r, g, b)) >> 8;
*p_dst = GRY_8_BLEND(gry8, *p_dst, alpha);
}
static void
_soft8_scanline_blend_transp_solid_mul_color_transp(DATA8 * src, DATA8 * alpha,
DATA8 * dst, int size,
DATA8 rel_alpha, DATA8 r,
DATA8 g, DATA8 b)
{
DATA8 *start, *end;
start = dst;
end = start + (size & ~7);
pld(alpha, 0);
pld(src, 0);
while (start < end)
{
DATA8 alpha1, alpha2;
alpha1 = alpha[0];
alpha += 8;
pld(src, 32);
pld(start, 32);
src += 8;
start += 8;
alpha2 = alpha[-7];
_soft8_pt_blend_transp_solid_mul_color_transp
(start - 8, src[-8], alpha1, rel_alpha, r, g, b);
alpha1 = alpha[-6];
_soft8_pt_blend_transp_solid_mul_color_transp
(start - 7, src[-7], alpha2, rel_alpha, r, g, b);
alpha2 = alpha[-5];
_soft8_pt_blend_transp_solid_mul_color_transp
(start - 6, src[-6], alpha1, rel_alpha, r, g, b);
alpha1 = alpha[-4];
_soft8_pt_blend_transp_solid_mul_color_transp
(start - 5, src[-5], alpha2, rel_alpha, r, g, b);
alpha2 = alpha[-3];
_soft8_pt_blend_transp_solid_mul_color_transp
(start - 4, src[-4], alpha1, rel_alpha, r, g, b);
alpha1 = alpha[-2];
_soft8_pt_blend_transp_solid_mul_color_transp
(start - 3, src[-3], alpha2, rel_alpha, r, g, b);
alpha2 = alpha[-1];
_soft8_pt_blend_transp_solid_mul_color_transp
(start - 2, src[-2], alpha1, rel_alpha, r, g, b);
_soft8_pt_blend_transp_solid_mul_color_transp
(start - 1, src[-1], alpha2, rel_alpha, r, g, b);
}
end = start + (size & 7);
for (; start < end; start++, src++, alpha++)
_soft8_pt_blend_transp_solid_mul_color_transp
(start, *src, *alpha, rel_alpha, r, g, b);
}
EFL_ALWAYS_INLINE void
_soft8_pt_blend_solid_solid_mul_color_transp(DATA8 * p_dst, DATA8 src,
DATA8 rel_alpha, DATA8 r, DATA8 g,
DATA8 b)
{
DATA8 gry8 = (src * GRY_8_FROM_COMPONENTS(r, g, b)) >> 8;
*p_dst = GRY_8_BLEND(gry8, *p_dst, rel_alpha);
}
static void
_soft8_scanline_blend_solid_solid_mul_color_transp(DATA8 * src, DATA8 * dst,
int size, DATA8 rel_alpha,
DATA8 r, DATA8 g, DATA8 b)
{
DATA8 *start, *end;
start = dst;
end = start + (size & ~7);
pld(src, 0);
while (start < end)
{
pld(src, 32);
UNROLL8(
{
_soft8_pt_blend_solid_solid_mul_color_transp
(start, *src, rel_alpha, r, g, b); start++; src++;}
);
}
end = start + (size & 7);
for (; start < end; start++, src++)
_soft8_pt_blend_solid_solid_mul_color_transp
(start, *src, rel_alpha, r, g, b);
}
/***********************************************************************
* Blend operations with extra multiply color
*/
EFL_ALWAYS_INLINE void
_soft8_pt_blend_transp_solid_mul_color_solid(DATA8 * p_dst, DATA8 src,
DATA8 alpha, DATA8 r, DATA8 g,
DATA8 b)
{
if (alpha == 0)
return;
DATA8 gry8 = (src * GRY_8_FROM_COMPONENTS(r, g, b)) >> 8;
if (alpha == 0xff)
*p_dst = gry8;
else
{
*p_dst = GRY_8_BLEND(gry8, *p_dst, alpha);
}
}
static void
_soft8_scanline_blend_transp_solid_mul_color_solid(DATA8 * src, DATA8 * alpha,
DATA8 * dst, int size,
DATA8 r, DATA8 g, DATA8 b)
{
DATA8 *start, *end;
start = dst;
end = start + (size & ~7);
pld(alpha, 0);
pld(src, 0);
while (start < end)
{
DATA8 alpha1, alpha2;
alpha1 = alpha[0];
alpha += 8;
pld(alpha, 8);
pld(src, 32);
src += 8;
start += 8;
alpha2 = alpha[-7];
_soft8_pt_blend_transp_solid_mul_color_solid
(start - 8, src[-8], alpha1, r, g, b);
alpha1 = alpha[-6];
_soft8_pt_blend_transp_solid_mul_color_solid
(start - 7, src[-7], alpha2, r, g, b);
alpha2 = alpha[-5];
_soft8_pt_blend_transp_solid_mul_color_solid
(start - 6, src[-6], alpha1, r, g, b);
alpha1 = alpha[-4];
_soft8_pt_blend_transp_solid_mul_color_solid
(start - 5, src[-5], alpha2, r, g, b);
alpha2 = alpha[-3];
_soft8_pt_blend_transp_solid_mul_color_solid
(start - 4, src[-4], alpha1, r, g, b);
alpha1 = alpha[-2];
_soft8_pt_blend_transp_solid_mul_color_solid
(start - 3, src[-3], alpha2, r, g, b);
alpha2 = alpha[-1];
_soft8_pt_blend_transp_solid_mul_color_solid
(start - 2, src[-2], alpha1, r, g, b);
_soft8_pt_blend_transp_solid_mul_color_solid
(start - 1, src[-1], alpha2, r, g, b);
}
end = start + (size & 7);
for (; start < end; start++, src++, alpha++)
_soft8_pt_blend_transp_solid_mul_color_solid
(start, *src, *alpha, r, g, b);
}
EFL_ALWAYS_INLINE void
_soft8_pt_blend_solid_solid_mul_color_solid(DATA8 * p_dst, DATA8 src, DATA8 r,
DATA8 g, DATA8 b)
{
*p_dst = (src * GRY_8_FROM_COMPONENTS(r, g, b)) >> 8;
}
static void
_soft8_scanline_blend_solid_solid_mul_color_solid(DATA8 * src, DATA8 * dst,
int size, DATA8 r, DATA8 g,
DATA8 b)
{
DATA8 *start, *end;
start = dst;
end = start + (size & ~7);
pld(src, 0);
while (start < end)
{
pld(src, 32);
UNROLL8(
{
_soft8_pt_blend_solid_solid_mul_color_solid(start, *src, r, g,
b); start++;
src++;}
);
}
end = start + (size & 7);
for (; start < end; start++, src++)
_soft8_pt_blend_solid_solid_mul_color_solid(start, *src, r, g, b);
}

View File

@ -1,53 +0,0 @@
/** NOTE: This file is meant to be included by users **/
/*****************************************************************************
* Point processing
*
* _soft8_pt_<description>_<src>_<dst>[_<modifier>]()
*
* Scanline processing
*
* _soft8_scanline_<description>_<src>_<dst>[_<modifier>]()
*
****************************************************************************/
EFL_ALWAYS_INLINE void
_soft8_pt_fill_solid_solid(DATA8 * dst, DATA8 gry8)
{
*dst = gry8;
}
EFL_ALWAYS_INLINE void
_soft8_scanline_fill_solid_solid(DATA8 * dst, int size, DATA8 gry8)
{
memset(dst, gry8, size);
}
EFL_ALWAYS_INLINE void
_soft8_pt_fill_transp_solid(DATA8 * dst, DATA8 gry8, DATA8 alpha)
{
*dst = GRY_8_BLEND(gry8, *dst, alpha);
}
static void
_soft8_scanline_fill_transp_solid(DATA8 * dst, int size, DATA8 gry8,
DATA8 alpha)
{
DATA8 *start, *end;
start = dst;
pld(start, 0);
end = start + (size & ~7);
while (start < end)
{
pld(start, 32);
UNROLL8(
{
_soft8_pt_fill_transp_solid(start, gry8, alpha); start++;}
);
}
end = start + (size & 7);
for (; start < end; start++)
_soft8_pt_fill_transp_solid(start, gry8, alpha);
}

View File

@ -35,12 +35,6 @@ if !EVAS_STATIC_BUILD_GL_COCOA
SUBDIRS += gl_cocoa
endif
if !EVAS_STATIC_BUILD_SOFTWARE_8
SUBDIRS += software_8
endif
if !EVAS_STATIC_BUILD_SOFTWARE_8_X11
SUBDIRS += software_8_x11
endif
if !EVAS_STATIC_BUILD_SOFTWARE_DDRAW
SUBDIRS += software_ddraw
endif

View File

@ -1,38 +0,0 @@
MAINTAINERCLEANFILES = Makefile.in
AM_CPPFLAGS = \
-I. \
-I$(top_srcdir)/src/lib \
-I$(top_srcdir)/src/lib/include \
-I$(top_srcdir)/src/modules/engines \
@FREETYPE_CFLAGS@ \
@PIXMAN_CFLAGS@ \
@FRIBIDI_CFLAGS@ \
@EVAS_GENERAL_CFLAGS@
if BUILD_ENGINE_SOFTWARE_8
SOFTWARE_8_SOURCES = evas_engine.c
if !EVAS_STATIC_BUILD_SOFTWARE_8_X11
pkgdir = $(libdir)/evas/modules/engines/software_8/$(MODULE_ARCH)
pkg_LTLIBRARIES = module.la
module_la_SOURCES = $(SOFTWARE_8_SOURCES)
module_la_LIBADD = @EVAS_GENERAL_LIBS@ $(top_builddir)/src/lib/libevas.la
module_la_LDFLAGS = -no-undefined @lt_enable_auto_import@ -module -avoid-version
module_la_LIBTOOLFLAGS = --tag=disable-static
else
noinst_LTLIBRARIES = libevas_engine_software_8.la
libevas_engine_software_8_la_SOURCES = $(SOFTWARE_8_SOURCES)
endif
endif
EXTRA_DIST = \
evas_engine.c

View File

@ -1,440 +0,0 @@
#include "evas_common.h"
#include "evas_common_soft8.h"
/*
*****
**
** ENGINE ROUTINES
**
*****
*/
int _evas_soft8_log_dom = -1;
static Evas_Func func, pfunc;
#ifdef ERR
#undef ERR
#endif
#define ERR(...) EINA_LOG_DOM_ERR( _evas_soft8_log_dom, __VA_ARGS__)
#ifdef DBG
#undef DBG
#endif
#define DBG(...) EINA_LOG_DOM_DBG(_evas_soft8_log_dom, __VA_ARGS__)
#ifdef INF
#undef INF
#endif
#define INF(...) EINA_LOG_DOM_INFO(_evas_soft8_log_dom, __VA_ARGS__)
#ifdef WRN
#undef WRN
#endif
#define WRN(...) EINA_LOG_DOM_WARN(_evas_soft8_log_dom, __VA_ARGS__)
#ifdef CRIT
#undef CRIT
#endif
#define CRIT(...) EINA_LOG_DOM_CRIT(_evas_soft8_log_dom, __VA_ARGS__)
#define NOT_IMPLEMENTED() \
WRN("NOT_IMPLEMENTED: %s() at %s:%d", \
__FUNCTION__, __FILE__, __LINE__)
static void
eng_rectangle_draw(void *data __UNUSED__, void *context, void *surface, int x,
int y, int w, int h)
{
evas_common_soft8_rectangle_draw(surface, context, x, y, w, h);
}
static void
eng_line_draw(void *data __UNUSED__, void *context, void *surface, int x1,
int y1, int x2, int y2)
{
evas_common_soft8_line_draw(surface, context, x1, y1, x2, y2);
}
static void
eng_polygon_draw(void *data __UNUSED__, void *context, void *surface,
void *polygon, int x, int y)
{
evas_common_soft8_polygon_draw(surface, context, polygon, x, y);
}
static int
eng_image_alpha_get(void *data __UNUSED__, void *image)
{
Soft8_Image *im;
if (!image)
return 0;
im = image;
return im->cache_entry.flags.alpha;
}
static int
eng_image_colorspace_get(void *data __UNUSED__, void *image __UNUSED__)
{
return EVAS_COLORSPACE_GRY8;
}
static void *
eng_image_alpha_set(void *data __UNUSED__, void *image, int have_alpha)
{
if (!image)
return NULL;
have_alpha = !!have_alpha;
image = evas_common_soft8_image_alpha_set(image, have_alpha);
return image;
}
static char *
eng_image_comment_get(void *data __UNUSED__, void *image __UNUSED__,
char *key __UNUSED__)
{
return NULL;
}
static char *
eng_image_format_get(void *data __UNUSED__, void *image __UNUSED__)
{
NOT_IMPLEMENTED();
return NULL;
}
static void
eng_image_colorspace_set(void *data __UNUSED__, void *image __UNUSED__,
int cspace __UNUSED__)
{
NOT_IMPLEMENTED();
}
static void *
eng_image_native_set(void *data __UNUSED__, void *image,
void *native __UNUSED__)
{
NOT_IMPLEMENTED();
return image;
}
static void *
eng_image_native_get(void *data __UNUSED__, void *image __UNUSED__)
{
NOT_IMPLEMENTED();
return NULL;
}
static void *
eng_image_load(void *data __UNUSED__, const char *file, const char *key,
int *error, Evas_Image_Load_Opts * lo)
{
return evas_cache_image_request(evas_common_soft8_image_cache_get(), file,
key, lo, error);
}
static void *
eng_image_new_from_data(void *data __UNUSED__, int w, int h,
DATA32 * image_data, int alpha, int cspace)
{
if ((image_data) && (cspace != EVAS_COLORSPACE_GRY8))
{
WRN("Unsupported colorspace %d in %s() (%s:%d)",
cspace, __FUNCTION__, __FILE__, __LINE__);
return NULL;
}
return evas_cache_image_data(evas_common_soft8_image_cache_get(), w, h,
image_data, alpha, EVAS_COLORSPACE_GRY8);
}
static void *
eng_image_new_from_copied_data(void *data __UNUSED__, int w, int h,
DATA32 * image_data, int alpha, int cspace)
{
if ((image_data) && (cspace != EVAS_COLORSPACE_GRY8))
{
WRN("Unsupported colorspace %d in %s() (%s:%d)",
cspace, __FUNCTION__, __FILE__, __LINE__);
return NULL;
}
return evas_cache_image_copied_data(evas_common_soft8_image_cache_get(), w,
h, image_data, alpha,
EVAS_COLORSPACE_GRY8);
}
static void
eng_image_free(void *data __UNUSED__, void *image)
{
evas_cache_image_drop((Image_Entry *) image);
}
static void
eng_image_size_get(void *data __UNUSED__, void *image, int *w, int *h)
{
Soft8_Image *im;
if (w)
*w = 0;
if (h)
*h = 0;
if (!image)
return;
im = image;
if (w)
*w = im->cache_entry.w;
if (h)
*h = im->cache_entry.h;
}
static void *
eng_image_size_set(void *data __UNUSED__, void *image, int w, int h)
{
if (!image)
return NULL;
if ((w <= 0) || (h <= 0))
{
evas_cache_image_drop((Image_Entry *) image);
return NULL;
}
return evas_cache_image_size_set((Image_Entry *) image, w, h);
}
static void
eng_image_stride_get(void *data __UNUSED__, void *image, int *stride)
{
Soft8_Image *im;
if (stride)
*stride = 0;
if (!image)
return;
im = image;
if (stride)
*stride = im->stride;
}
static void *
eng_image_dirty_region(void *data __UNUSED__, void *image __UNUSED__,
int x __UNUSED__, int y __UNUSED__, int w __UNUSED__,
int h __UNUSED__)
{
/* FIXME: is this required? */
//NOT_IMPLEMENTED();
return image;
}
static void *
eng_image_data_get(void *data __UNUSED__, void *image, int to_write,
DATA32 ** image_data, int *err)
{
Soft8_Image *im;
int error;
if (!image)
{
*image_data = NULL;
return NULL;
}
im = image;
error = evas_cache_image_load_data(&im->cache_entry);
if (to_write)
im = (Soft8_Image *) evas_cache_image_alone(&im->cache_entry);
if (image_data)
*image_data = (DATA32 *) im->pixels;
if (err) *err = error;
return im;
}
static void *
eng_image_data_put(void *data __UNUSED__, void *image, DATA32 * image_data)
{
Soft8_Image *old_im, *new_im;
if (!image)
return NULL;
old_im = image;
if ((DATA8 *) image_data == old_im->pixels)
return old_im;
new_im =
(Soft8_Image *)
evas_cache_image_data(evas_common_soft8_image_cache_get(),
old_im->cache_entry.w, old_im->cache_entry.h,
image_data, old_im->cache_entry.flags.alpha,
EVAS_COLORSPACE_GRY8);
evas_cache_image_drop(&old_im->cache_entry);
return new_im;
}
static void
eng_image_data_preload_request(void *data __UNUSED__, void *image,
const void *target)
{
Soft8_Image *im = image;
if (!im)
return;
evas_cache_image_preload_data(&im->cache_entry, target);
}
static void
eng_image_data_preload_cancel(void *data __UNUSED__, void *image,
const void *target)
{
Soft8_Image *im = image;
if (!im)
return;
evas_cache_image_preload_cancel(&im->cache_entry, target);
}
static void
eng_image_draw(void *data __UNUSED__, 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)
{
Soft8_Image *im;
im = (Soft8_Image *) image;
evas_cache_image_load_data(&im->cache_entry);
evas_common_soft8_image_draw(im, surface, context,
src_x, src_y, src_w, src_h,
dst_x, dst_y, dst_w, dst_h, smooth);
}
static void
eng_image_scale_hint_set(void *data __UNUSED__, void *image __UNUSED__,
int hint __UNUSED__)
{
}
static int
eng_image_scale_hint_get(void *data __UNUSED__, void *image __UNUSED__)
{
return EVAS_IMAGE_SCALE_HINT_NONE;
}
static void
eng_image_cache_flush(void *data __UNUSED__)
{
evas_cache_image_flush(evas_common_soft8_image_cache_get());
}
static void
eng_image_cache_set(void *data __UNUSED__, int bytes)
{
evas_cache_image_set(evas_common_soft8_image_cache_get(), bytes);
}
static int
eng_image_cache_get(void *data __UNUSED__)
{
return evas_cache_image_get(evas_common_soft8_image_cache_get());
}
static void
eng_font_draw(void *data __UNUSED__, void *context, void *surface,
Evas_Font_Set *font, int x, int y, int w __UNUSED__, int h __UNUSED__,
int ow __UNUSED__, int oh __UNUSED__, const Evas_Text_Props *text_props)
{
evas_common_font_draw_prepare(text_props);
evas_common_font_draw(surface, context, x, y, text_props);
evas_common_draw_context_font_ext_set(context, NULL, NULL, NULL, NULL);
}
static void
eng_font_cache_flush(void *data __UNUSED__)
{
evas_common_font_flush();
}
/*
*****
**
** MODULE ACCESSIBLE API API
**
*****
*/
static int
module_open(Evas_Module * em)
{
if (!em)
return 0;
if (!_evas_module_engine_inherit(&pfunc, "software_generic")) return 0;
_evas_soft8_log_dom = eina_log_domain_register
("evas-software_8", EVAS_DEFAULT_LOG_COLOR);
if (_evas_soft8_log_dom < 0)
{
EINA_LOG_ERR("Can not create a module log domain.");
return 0;
}
/* store it for later use */
func = pfunc;
/* now to override methods */
EVAS_API_RESET(info, &func);
EVAS_API_RESET(info_free, &func);
EVAS_API_RESET(setup, &func);
#define ORD(f) EVAS_API_OVERRIDE(f, &func, eng_)
ORD(rectangle_draw);
ORD(line_draw);
ORD(polygon_draw);
ORD(image_load);
ORD(image_new_from_data);
ORD(image_new_from_copied_data);
ORD(image_free);
ORD(image_size_get);
ORD(image_size_set);
ORD(image_stride_get);
ORD(image_dirty_region);
ORD(image_data_get);
ORD(image_data_put);
ORD(image_data_preload_request);
ORD(image_data_preload_cancel);
ORD(image_alpha_set);
ORD(image_alpha_get);
ORD(image_draw);
ORD(image_comment_get);
ORD(image_format_get);
ORD(image_colorspace_set);
ORD(image_colorspace_get);
ORD(image_native_set);
ORD(image_native_get);
ORD(image_cache_flush);
ORD(image_cache_set);
ORD(image_cache_get);
ORD(font_draw);
ORD(image_scale_hint_set);
ORD(image_scale_hint_get);
em->functions = (void *)(&func);
return 1;
}
static void
module_close(Evas_Module * em __UNUSED__)
{
eina_log_domain_unregister(_evas_soft8_log_dom);
}
static Evas_Module_Api evas_modapi = {
EVAS_MODULE_API_VERSION,
"software_8",
"none",
{
module_open,
module_close}
};
EVAS_MODULE_DEFINE(EVAS_MODULE_TYPE_ENGINE, engine, software_8);
#ifndef EVAS_STATIC_BUILD_SOFTWARE_8
EVAS_EINA_MODULE_DEFINE(engine, software_8);
#endif

View File

@ -1,38 +0,0 @@
#ifndef _EVAS_ENGINE_SOFTWARE_8_X11_H
#define _EVAS_ENGINE_SOFTWARE_8_X11_H
#include <xcb/xcb.h>
typedef struct _Evas_Engine_Info_Software_8_X11 Evas_Engine_Info_Software_8_X11;
struct _Evas_Engine_Info_Software_8_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 {
xcb_connection_t *connection;
xcb_drawable_t drawable;
xcb_gcontext_t gc;
xcb_screen_t *screen;
unsigned int mask;
void *visual;
unsigned int colormap;
int depth;
int rotation;
int alloc_grayscale : 1;
int debug : 1;
int shape_dither : 1;
int destination_alpha : 1;
int track_mask_changes : 1;
} info;
/* non-blocking or blocking mode */
Evas_Engine_Render_Mode render_mode;
};
#endif

View File

@ -1,49 +0,0 @@
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_8 \
@FREETYPE_CFLAGS@ \
@PIXMAN_CFLAGS@ \
@EVAS_GENERAL_CFLAGS@ \
@FRIBIDI_CFLAGS@ \
@evas_engine_software_8_x11_cflags@
if BUILD_ENGINE_SOFTWARE_8_X11
SOFTWARE_8_X11_SOURCES = \
evas_engine.c \
evas_x_buffer.c
SOFTWARE_8_X11_LIBADD = @evas_engine_software_8_x11_libs@
includes_HEADERS = Evas_Engine_Software_8_X11.h
includesdir = $(includedir)/evas-@VMAJ@
if !EVAS_STATIC_BUILD_SOFTWARE_8_X11
pkgdir = $(libdir)/evas/modules/engines/software_8_x11/$(MODULE_ARCH)
pkg_LTLIBRARIES = module.la
module_la_SOURCES = $(SOFTWARE_8_X11_SOURCES)
module_la_LIBADD = @EVAS_GENERAL_LIBS@ $(SOFTWARE_8_X11_LIBADD) $(top_builddir)/src/lib/libevas.la
#-lxcb-image -lxcb-shm -lxcb -lpixman-1
module_la_LDFLAGS = -no-undefined -module -avoid-version
module_la_LIBTOOLFLAGS = --tag=disable-static
else
noinst_LTLIBRARIES = libevas_engine_software_8_x11.la
libevas_engine_software_8_x11_la_SOURCES = $(SOFTWARE_8_X11_SOURCES)
libevas_engine_software_8_x11_la_LIBADD = $(SOFTWARE_8_X11_LIBADD)
endif
endif
EXTRA_DIST = evas_engine.h

View File

@ -1,700 +0,0 @@
#include "evas_common.h"
#include "evas_private.h"
#include "evas_engine.h"
#include "Evas_Engine_Software_8_X11.h"
#include "evas_common_soft8.h"
#include <pixman.h>
int _evas_engine_soft8_x11_log_dom = -1;
/* 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 {
xcb_connection_t *connection;
xcb_drawable_t drawable;
xcb_screen_t *screen;
unsigned char pal[256];
int depth;
int w, h, rot;
Tilebuf *tb;
Tilebuf_Rect *rects;
Tilebuf_Rect *cur_rect;
X_Output_Buffer *shbuf;
Soft8_Image *tmp_out; /* used by indirect render, like rotation */
pixman_region16_t *clip_rects;
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 int 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);
/* engine api this module provides */
static void *
eng_info(Evas * e)
{
Evas_Engine_Info_Software_8_X11 *info;
info = calloc(1, sizeof(Evas_Engine_Info_Software_8_X11));
if (!info)
return NULL;
info->magic.magic = rand();
info->render_mode = EVAS_RENDER_MODE_BLOCKING;
return info;
e = NULL;
}
static void
eng_info_free(Evas * e __UNUSED__, void *info)
{
Evas_Engine_Info_Software_8_X11 *in;
in = (Evas_Engine_Info_Software_8_X11 *) info;
free(in);
}
static void
_tmp_out_alloc(Render_Engine * re)
{
Tilebuf_Rect *r;
unsigned int w = 0, h = 0;
EINA_INLIST_FOREACH(re->rects, r)
{
if (r->w > (int)w)
w = r->w;
if (r->h > (int)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)
{
Soft8_Image *im;
im = (Soft8_Image *)
evas_cache_image_empty(evas_common_soft8_image_cache_get());
im->cache_entry.flags.alpha = 0;
evas_cache_image_surface_alloc(&im->cache_entry, w, h);
re->tmp_out = im;
}
}
static void
alloc_colors(Render_Engine * re)
{
xcb_alloc_color_cookie_t color_rq[256];
xcb_alloc_color_reply_t *rep;
xcb_colormap_t colormap = re->screen->default_colormap;
int i;
for (i = 0; i < 256; i++)
color_rq[i] =
xcb_alloc_color(re->connection, colormap, i << 8, i << 8, i << 8);
for (i = 0; i < 256; i++)
{
rep = xcb_alloc_color_reply(re->connection, color_rq[i], NULL);
re->pal[i] = rep->pixel;
free(rep);
}
}
static int
eng_setup(Evas *eo_e, void *in)
{
Evas_Public_Data *e = eo_data_get(eo_e, EVAS_CLASS);
Render_Engine *re;
Evas_Engine_Info_Software_8_X11 *info;
/* X_Output_Buffer *xob; */
info = (Evas_Engine_Info_Software_8_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 8bit display mode
* and no real other acceleration, and high resolution so we
* can pre-dither into 8bpp. */
// if (DefaultDepth(info->info.display,
// DefaultScreen(info->info.display)) != 8)
// 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_polygon_init();
evas_common_line_init();
evas_common_font_init();
evas_common_draw_init();
evas_common_tilebuf_init();
evas_common_soft8_image_init();
/* render engine specific data */
re = calloc(1, sizeof(Render_Engine));
if (!re)
return 0;
e->engine.data.output = re;
re->connection = info->info.connection;
re->screen = info->info.screen;
re->drawable = info->info.drawable;
re->depth = info->info.depth;
re->w = e->output.w;
re->h = e->output.h;
re->rot = 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);
alloc_colors(re);
}
else
{
/* we changed the info after first init - do a re-eval where
* appropriate */
re = e->engine.data.output;
if (re->tb)
evas_common_tilebuf_free(re->tb);
re->connection = info->info.connection;
re->screen = info->info.screen;
re->drawable = info->info.drawable;
re->w = e->output.w;
re->h = e->output.h;
re->rot = 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;
}
alloc_colors(re);
}
if (!e->engine.data.output)
return 0;
/* 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_8_x11_x_can_do_shm(re->connection, re->screen);
return 1;
}
static void
eng_output_free(void *data)
{
Render_Engine *re;
re = (Render_Engine *) data;
if (re->shbuf)
evas_software_8_x11_x_output_buffer_free(re->shbuf, 0);
if (re->clip_rects)
{
pixman_region_fini(re->clip_rects);
free(re->clip_rects);
re->clip_rects = NULL;
}
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_soft8_image_shutdown();
}
static void
eng_output_resize(void *data, int w, int h)
{
Render_Engine *re;
re = (Render_Engine *) data;
if ((re->w == w) && (re->h == h))
return;
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);
if (re->shbuf)
{
evas_software_8_x11_x_output_buffer_free(re->shbuf, 0);
re->shbuf = NULL;
}
if (re->clip_rects)
{
pixman_region_fini(re->clip_rects);
free(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 w, h;
if (re->shbuf)
return;
if ((re->rot == 0) || (re->rot == 180))
{
w = re->w;
h = re->h;
}
else
{
w = re->h;
h = re->w;
}
re->shbuf = evas_software_8_x11_x_output_buffer_new
(re->connection, re->screen, re->depth, re->pal, w, h, 1, NULL);
re->shbuf->drawable = re->drawable;
re->shbuf->screen = re->screen;
if (re->shbuf->gc)
{
xcb_free_gc(re->shbuf->connection, re->shbuf->gc);
re->shbuf->gc = 0;
}
re->shbuf->gc = xcb_generate_id(re->shbuf->connection);
xcb_create_gc(re->shbuf->connection, re->shbuf->gc, re->shbuf->drawable, 0,
NULL);
}
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->rot != 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 *) ((EINA_INLIST_GET(re->cur_rect))->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->rot == 0)
{
*cx = ux;
*cy = uy;
*cw = uw;
*ch = uh;
return re->shbuf->im;
}
else
{
*cx = 0;
*cy = 0;
*cw = uw;
*ch = uh;
return re->tmp_out;
}
}
static void
_blit_rot_90(Soft8_Image * dst, const Soft8_Image * src,
int out_x, int out_y, int w, int h)
{
DATA8 *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++)
{
DATA8 *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(Soft8_Image * dst, const Soft8_Image * src,
int out_x, int out_y, int w, int h)
{
DATA8 *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++)
{
DATA8 *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(Soft8_Image * dst, const Soft8_Image * src,
int out_x, int out_y, int w, int h)
{
DATA8 *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++)
{
DATA8 *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)
{
Soft8_Image *d, *s;
d = re->shbuf->im;
s = re->tmp_out;
if ((w < 1) || (h < 1) ||
(out_x >= (int)d->cache_entry.w) ||
(out_y >= (int)d->cache_entry.h))
return;
if (re->rot == 90)
_blit_rot_90(d, s, out_x, out_y, w, h);
else if (re->rot == 180)
_blit_rot_180(d, s, out_x, out_y, w, h);
else if (re->rot == 270)
_blit_rot_270(d, s, out_x, out_y, w, h);
}
static void
eng_output_redraws_next_update_push(void *data, void *surface __UNUSED__, int x,
int y, int w, int h)
{
Render_Engine *re;
struct {
int x, y, width, height;
} r =
{
0, 0, 0, 0};
re = (Render_Engine *) data;
if (!re->clip_rects)
{
re->clip_rects =
(pixman_region16_t *) malloc(sizeof(pixman_region16_t));
pixman_region_init(re->clip_rects);
}
if (re->rot == 0)
{
r.x = x;
r.y = y;
r.width = w;
r.height = h;
}
else if (re->rot == 90)
{
r.x = y;
r.y = re->w - w - x;
r.width = h;
r.height = w;
}
else if (re->rot == 180)
{
r.x = re->w - w - x;
r.y = re->h - h - y;
r.width = w;
r.height = h;
}
else if (re->rot == 270)
{
r.x = re->h - h - y;
r.y = x;
r.width = h;
r.height = w;
}
if (re->rot != 0)
_tmp_out_process(re, r.x, r.y, w, h);
pixman_region_union_rect(re->clip_rects, re->clip_rects,
r.x, r.y, r.width, r.height);
}
static void
eng_output_flush(void *data)
{
Render_Engine *re;
re = (Render_Engine *) data;
if (re->clip_rects)
{
re->shbuf->drawable = re->drawable;
{
int i;
pixman_box16_t *rects =
pixman_region_rectangles(re->clip_rects, NULL);
for (i = 0; i < pixman_region_n_rects(re->clip_rects); i++, rects++)
evas_software_8_x11_x_output_buffer_paste
(re->shbuf, re->drawable, re->shbuf->gc, rects->x1, rects->y1,
rects->x2 - rects->x1, rects->y2 - rects->y1, 1);
}
pixman_region_fini(re->clip_rects);
free(re->clip_rects);
re->clip_rects = NULL;
}
}
static void
eng_output_idle_flush(void *data)
{
Render_Engine *re;
re = (Render_Engine *) data;
if (re->shbuf)
{
evas_software_8_x11_x_output_buffer_free(re->shbuf, 0);
re->shbuf = NULL;
}
if (re->clip_rects)
{
pixman_region_fini(re->clip_rects);
free(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 Eina_Bool
eng_canvas_alpha_get(void *data __UNUSED__, void *context __UNUSED__)
{
return EINA_FALSE;
}
/* module advertising code */
static int
module_open(Evas_Module * em)
{
if (!em)
return 0;
/* get whatever engine module we inherit from */
if (!_evas_module_engine_inherit(&pfunc, "software_8"))
return 0;
_evas_engine_soft8_x11_log_dom = eina_log_domain_register
("evas-software_8_x11", EVAS_DEFAULT_LOG_COLOR);
if (_evas_engine_soft8_x11_log_dom < 0)
{
EINA_LOG_ERR("Can not create a module log domain.");
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(canvas_alpha_get);
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;
}
static void
module_close(Evas_Module * em __UNUSED__)
{
eina_log_domain_unregister(_evas_engine_soft8_x11_log_dom);
}
static Evas_Module_Api evas_modapi = {
EVAS_MODULE_API_VERSION,
"software_8_x11",
"none",
{
module_open,
module_close}
};
EVAS_MODULE_DEFINE(EVAS_MODULE_TYPE_ENGINE, engine, software_8_x11);
#ifndef EVAS_STATIC_BUILD_SOFTWARE_8_X11
EVAS_EINA_MODULE_DEFINE(engine, software_8_x11);
#endif

View File

@ -1,65 +0,0 @@
#ifndef EVAS_ENGINE_H
#define EVAS_ENGINE_H
#include <sys/ipc.h>
#include <sys/shm.h>
#include <xcb/xcb.h>
#include <xcb/shm.h>
#include <xcb/xcb_image.h>
#include "evas_common.h"
#include "evas_common_soft8.h"
extern int _evas_engine_soft8_x11_log_dom;
#ifdef ERR
# undef ERR
#endif
#define ERR(...) EINA_LOG_DOM_ERR(_evas_engine_soft8_x11_log_dom, __VA_ARGS__)
#ifdef DBG
# undef DBG
#endif
#define DBG(...) EINA_LOG_DOM_DBG(_evas_engine_soft8_x11_log_dom, __VA_ARGS__)
#ifdef INF
# undef INF
#endif
#define INF(...) EINA_LOG_DOM_INFO(_evas_engine_soft8_x11_log_dom, __VA_ARGS__)
#ifdef WRN
# undef WRN
#endif
#define WRN(...) EINA_LOG_DOM_WARN(_evas_engine_soft8_x11_log_dom, __VA_ARGS__)
#ifdef CRIT
# undef CRIT
#endif
#define CRIT(...) EINA_LOG_DOM_CRIT(_evas_engine_soft8_x11_log_dom, __VA_ARGS__)
typedef struct _X_Output_Buffer X_Output_Buffer;
struct _X_Output_Buffer
{
Soft8_Image *im;
xcb_connection_t *connection;
xcb_screen_t *screen;
xcb_image_t *xim;
xcb_drawable_t drawable;
xcb_gcontext_t gc;
xcb_shm_segment_info_t *shm_info;
unsigned char *pal;
void *data;
};
/****/
int evas_software_8_x11_x_can_do_shm (xcb_connection_t *c, xcb_screen_t *screen);
X_Output_Buffer *evas_software_8_x11_x_output_buffer_new (xcb_connection_t *, xcb_screen_t *screen, int depth, unsigned char *pal, int w, int h, int try_shm, void *data);
void evas_software_8_x11_x_output_buffer_free (X_Output_Buffer *xob, int sync);
void evas_software_8_x11_x_output_buffer_paste (X_Output_Buffer *xob, xcb_drawable_t d, xcb_gcontext_t gc, int x, int y, int w, int h, int sync);
DATA8 *evas_software_8_x11_x_output_buffer_data (X_Output_Buffer *xob, int *bytes_per_line_ret);
int evas_software_8_x11_x_output_buffer_depth (X_Output_Buffer *xob);
int evas_software_8_x11_x_output_buffer_byte_order (X_Output_Buffer *xob);
int evas_software_8_x11_x_output_buffer_bit_order (X_Output_Buffer *xob);
#endif

View File

@ -1,243 +0,0 @@
#include "evas_common.h"
#include "evas_engine.h"
static int _xcb_err = 0;
int
evas_software_8_x11_x_can_do_shm(xcb_connection_t * c, xcb_screen_t * screen)
{
static xcb_connection_t *cached_c = NULL;
static int cached_result = 0;
if (c == cached_c)
return cached_result;
cached_c = c;
if (xcb_get_extension_data(c, &xcb_shm_id))
{
X_Output_Buffer *xob;
xob = evas_software_8_x11_x_output_buffer_new
(c, screen, screen->root_depth, (unsigned char *)NULL,
16, 16, 2, NULL);
if (!xob)
{
cached_result = 0;
return 0;
}
evas_software_8_x11_x_output_buffer_free(xob, 1);
cached_result = 1;
return 1;
}
cached_result = 0;
return 0;
}
X_Output_Buffer *
evas_software_8_x11_x_output_buffer_new(xcb_connection_t * c,
xcb_screen_t * s,
int depth,
unsigned char *pal,
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->connection = c;
xob->screen = s;
xob->xim = NULL;
xob->shm_info = NULL;
xob->pal = pal;
if (try_shm > 0)
{
xob->shm_info = malloc(sizeof(xcb_shm_segment_info_t));
if (xob->shm_info)
{
xob->shm_info->shmseg = xcb_generate_id(c);
xob->xim = xcb_image_create_native(c, w, h,
XCB_IMAGE_FORMAT_Z_PIXMAP,
depth, NULL, ~0, NULL);
if (xob->xim)
{
int shmid = shmget
(IPC_PRIVATE, xob->xim->size, IPC_CREAT | 0777);
if (shmid >= 0)
{
xob->shm_info->shmid = shmid;
xob->shm_info->shmaddr = xob->xim->data =
shmat(xob->shm_info->shmid, 0, 0);
if (xob->shm_info->shmaddr)
{
/*
* FIXME: no error mechanism
*/
/* XErrorHandler ph; */
/* EventHandlers eh; */
free(xcb_get_input_focus_reply
(c, xcb_get_input_focus_unchecked(c), NULL));
_xcb_err = 0;
/* ph = XSetErrorHandler((XErrorHandler) */
/* x_output_tmp_x_err); */
xcb_shm_attach(c,
xob->shm_info->shmseg,
xob->shm_info->shmid, 0);
free(xcb_get_input_focus_reply
(c, xcb_get_input_focus_unchecked(c), NULL));
/* XSetErrorHandler((XErrorHandler)ph); */
if (!_xcb_err)
{
xob->im =
(Soft8_Image *)
evas_cache_image_data
(evas_common_soft8_image_cache_get(), w, h,
(DATA32 *) xob->xim->data, 0,
EVAS_COLORSPACE_GRY8);
if (xob->im)
xob->im->stride =
xob->xim->stride / sizeof(DATA8);
return xob;
}
}
shmdt(xob->shm_info->shmaddr);
shmctl(xob->shm_info->shmid, IPC_RMID, 0);
}
if (xob->xim)
xcb_image_destroy(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 = xcb_image_create_native(c, w, h, XCB_IMAGE_FORMAT_Z_PIXMAP,
depth, NULL, ~0, NULL);
if (!xob->xim)
{
free(xob);
return NULL;
}
xob->data = data;
if (!xob->xim->data)
{
xob->xim->data = malloc(xob->xim->stride * xob->xim->height);
if (!xob->xim->data)
{
xcb_image_destroy(xob->xim);
free(xob);
return NULL;
}
}
if (xob->im)
evas_cache_image_drop(&xob->im->cache_entry);
xob->im =
(Soft8_Image *)
evas_cache_image_data(evas_common_soft8_image_cache_get(), w, h,
(DATA32 *) xob->xim->data, 0,
EVAS_COLORSPACE_GRY8);
if (xob->im)
xob->im->stride = xob->xim->stride / sizeof(DATA8);
return xob;
}
void
evas_software_8_x11_x_output_buffer_free(X_Output_Buffer * xob, int sync)
{
if (xob->shm_info)
{
if (sync)
free(xcb_get_input_focus_reply(xob->connection,
xcb_get_input_focus_unchecked(xob->
connection),
NULL));
xcb_shm_detach(xob->connection, xob->shm_info->shmseg);
xcb_image_destroy(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;
free(xob->xim->data);
xcb_image_destroy(xob->xim);
}
free(xob);
}
void
evas_software_8_x11_x_output_buffer_paste(X_Output_Buffer * xob,
xcb_drawable_t d,
xcb_gcontext_t gc,
int x, int y, int w, int h, int sync)
{
unsigned char *data;
int i, j;
if (xob->shm_info)
{
for (i = y; i < y + h; i++)
{
data = xob->xim->data + i * xob->xim->width + x;
for (j = x; j < x + w; j++, data++)
*data = xob->pal[*data];
}
xcb_image_shm_put(xob->connection, d, gc,
xob->xim, *xob->shm_info, x, y, x, y, w, h, 0);
if (sync)
free(xcb_get_input_focus_reply(xob->connection,
xcb_get_input_focus_unchecked(xob->
connection),
NULL));
}
else
{
xcb_image_put(xob->connection, d, gc, xob->xim, x, y, 0);
}
}
DATA8 *
evas_software_8_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->stride;
return (DATA8 *) xob->xim->data;
}
int
evas_software_8_x11_x_output_buffer_depth(X_Output_Buffer * xob)
{
return xob->xim->bpp;
}
int
evas_software_8_x11_x_output_buffer_byte_order(X_Output_Buffer * xob)
{
return xob->xim->byte_order;
}
int
evas_software_8_x11_x_output_buffer_bit_order(X_Output_Buffer * xob)
{
return xob->xim->bit_order;
}