Ector: Move drawhelper to static_libs

Rename a few things:
 - draw helper -> efl_draw
 - Ector_Rop -> Efl.Gfx.Render_Op
 - ECTOR_ bla bla -> DRAW_ bla bla (base pixel ops)
 - ector_memfill -> draw_memset32 (and invert arg order to match memset)

The main rasterizer file is now draw.h in static_libs/draw
This is a non functional change, simple code refactor.
This commit is contained in:
Jean-Philippe Andre 2015-12-02 18:46:29 +09:00
parent bad7911cd0
commit 615b2442b7
29 changed files with 240 additions and 210 deletions

View File

@ -90,6 +90,13 @@ lib/ector/cairo/ector_cairo_surface.c
installed_ectorcairoheadersdir = $(includedir)/ector-@VMAJ@/cairo installed_ectorcairoheadersdir = $(includedir)/ector-@VMAJ@/cairo
nodist_installed_ectorcairoheaders_DATA = $(ector_eolian_cairo_h) nodist_installed_ectorcairoheaders_DATA = $(ector_eolian_cairo_h)
# SW draw static lib
draw_sources = \
static_libs/draw/draw_main_sse2.c \
static_libs/draw/draw_main.c \
static_libs/draw/draw_main_neon.c \
$(NULL)
# And the default software backend # And the default software backend
lib_ector_libector_la_SOURCES += \ lib_ector_libector_la_SOURCES += \
lib/ector/software/ector_renderer_software_gradient_linear.c \ lib/ector/software/ector_renderer_software_gradient_linear.c \
@ -103,9 +110,7 @@ lib/ector/software/ector_software_buffer.c \
static_libs/freetype/sw_ft_math.c \ static_libs/freetype/sw_ft_math.c \
static_libs/freetype/sw_ft_raster.c \ static_libs/freetype/sw_ft_raster.c \
static_libs/freetype/sw_ft_stroker.c \ static_libs/freetype/sw_ft_stroker.c \
lib/ector/software/ector_drawhelper.c \ $(draw_sources)
lib/ector/software/ector_drawhelper_sse2.c \
lib/ector/software/ector_drawhelper_neon.c
installed_ectorsoftwareheadersdir = $(includedir)/ector-@VMAJ@/software installed_ectorsoftwareheadersdir = $(includedir)/ector-@VMAJ@/software
nodist_installed_ectorsoftwareheaders_DATA = $(ector_eolian_software_h) nodist_installed_ectorsoftwareheaders_DATA = $(ector_eolian_software_h)
@ -115,6 +120,7 @@ lib_ector_libector_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl \
-I$(top_builddir)/src/lib/ector/cairo \ -I$(top_builddir)/src/lib/ector/cairo \
-I$(top_builddir)/src/lib/ector/software \ -I$(top_builddir)/src/lib/ector/software \
-I$(top_srcdir)/src/static_libs/freetype \ -I$(top_srcdir)/src/static_libs/freetype \
-I$(top_srcdir)/src/static_libs/draw \
@ECTOR_CFLAGS@ \ @ECTOR_CFLAGS@ \
-DPACKAGE_BIN_DIR=\"$(bindir)\" \ -DPACKAGE_BIN_DIR=\"$(bindir)\" \
-DPACKAGE_LIB_DIR=\"$(libdir)\" \ -DPACKAGE_LIB_DIR=\"$(libdir)\" \
@ -165,4 +171,6 @@ lib/ector/software/ector_software_private.h \
static_libs/freetype/sw_ft_math.h \ static_libs/freetype/sw_ft_math.h \
static_libs/freetype/sw_ft_raster.h \ static_libs/freetype/sw_ft_raster.h \
static_libs/freetype/sw_ft_stroker.h \ static_libs/freetype/sw_ft_stroker.h \
static_libs/freetype/sw_ft_types.h static_libs/freetype/sw_ft_types.h \
static_libs/draw/draw.h \
static_libs/draw/draw_private.h

View File

@ -1,6 +1,7 @@
# Even though libefl is new, it contains definitions used by legacy APIs # Even though libefl is new, it contains definitions used by legacy APIs
efl_eolian_legacy_files = \ efl_eolian_legacy_files = \
lib/efl/interfaces/efl_gfx_fill.eo \ lib/efl/interfaces/efl_gfx_fill.eo \
lib/efl/interfaces/efl_gfx_base.eo \
$(NULL) $(NULL)
efl_eolian_files = \ efl_eolian_files = \
@ -10,7 +11,6 @@ efl_eolian_files = \
lib/efl/interfaces/efl_player.eo \ lib/efl/interfaces/efl_player.eo \
lib/efl/interfaces/efl_text.eo \ lib/efl/interfaces/efl_text.eo \
lib/efl/interfaces/efl_text_properties.eo \ lib/efl/interfaces/efl_text_properties.eo \
lib/efl/interfaces/efl_gfx_base.eo \
lib/efl/interfaces/efl_gfx_stack.eo \ lib/efl/interfaces/efl_gfx_stack.eo \
lib/efl/interfaces/efl_gfx_view.eo \ lib/efl/interfaces/efl_gfx_view.eo \
lib/efl/interfaces/efl_gfx_shape.eo \ lib/efl/interfaces/efl_gfx_shape.eo \

View File

@ -349,6 +349,7 @@ lib_evas_libevas_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl \
-I$(top_srcdir)/src/lib/evas/file \ -I$(top_srcdir)/src/lib/evas/file \
-I$(top_srcdir)/src/lib/evas/include \ -I$(top_srcdir)/src/lib/evas/include \
-I$(top_srcdir)/src/static_libs/libunibreak \ -I$(top_srcdir)/src/static_libs/libunibreak \
-I$(top_srcdir)/src/static_libs/draw \
-I$(top_builddir)/src/lib/evas/canvas \ -I$(top_builddir)/src/lib/evas/canvas \
-I$(top_builddir)/src/modules/evas/engines/software_generic \ -I$(top_builddir)/src/modules/evas/engines/software_generic \
-I$(top_builddir)/src/modules/evas/engines/gl_generic \ -I$(top_builddir)/src/modules/evas/engines/gl_generic \

View File

@ -113,16 +113,6 @@ typedef Eo Ector_Renderer;
// FIXME: Enable that when we have merged Emile // FIXME: Enable that when we have merged Emile
/* typedef Evas_Colorspace Ector_Colorspace; */ /* typedef Evas_Colorspace Ector_Colorspace; */
/**
* Raster operations at pixel level
*/
typedef enum _Ector_Rop
{
ECTOR_ROP_BLEND, /**< D = S + D(1 - Sa) */
ECTOR_ROP_COPY, /**< D = S */
ECTOR_ROP_LAST
} Ector_Rop;
/** /**
* Quality values * Quality values
*/ */

View File

@ -1,6 +1,8 @@
#ifndef ECTOR_CAIRO_PRIVATE_H_ #ifndef ECTOR_CAIRO_PRIVATE_H_
# define ECTOR_CAIRO_PRIVATE_H_ # define ECTOR_CAIRO_PRIVATE_H_
#include "draw.h"
typedef void cairo_pattern_t; typedef void cairo_pattern_t;
typedef struct { typedef struct {

View File

@ -121,7 +121,7 @@ _ector_renderer_cairo_base_ector_renderer_generic_base_prepare(Eo *obj, Ector_Re
static Eina_Bool static Eina_Bool
_ector_renderer_cairo_base_ector_renderer_generic_base_draw(Eo *obj EINA_UNUSED, _ector_renderer_cairo_base_ector_renderer_generic_base_draw(Eo *obj EINA_UNUSED,
Ector_Renderer_Cairo_Base_Data *pd, Ector_Renderer_Cairo_Base_Data *pd,
Ector_Rop op, Efl_Gfx_Render_Op op,
Eina_Array *clips EINA_UNUSED, Eina_Array *clips EINA_UNUSED,
unsigned int mul_col) unsigned int mul_col)
{ {
@ -131,10 +131,10 @@ _ector_renderer_cairo_base_ector_renderer_generic_base_draw(Eo *obj EINA_UNUSED,
switch (op) switch (op)
{ {
case ECTOR_ROP_BLEND: case EFL_GFX_RENDER_OP_BLEND:
cop = CAIRO_OPERATOR_OVER; cop = CAIRO_OPERATOR_OVER;
break; break;
case ECTOR_ROP_COPY: case EFL_GFX_RENDER_OP_COPY:
default: default:
cop = CAIRO_OPERATOR_SOURCE; cop = CAIRO_OPERATOR_SOURCE;
break; break;

View File

@ -64,7 +64,7 @@ _ector_renderer_cairo_gradient_linear_ector_renderer_generic_base_prepare(Eo *ob
static Eina_Bool static Eina_Bool
_ector_renderer_cairo_gradient_linear_ector_renderer_generic_base_draw(Eo *obj, _ector_renderer_cairo_gradient_linear_ector_renderer_generic_base_draw(Eo *obj,
Ector_Renderer_Cairo_Gradient_Linear_Data *pd, Ector_Renderer_Cairo_Gradient_Linear_Data *pd,
Ector_Rop op, Eina_Array *clips, unsigned int mul_col) Efl_Gfx_Render_Op op, Eina_Array *clips, unsigned int mul_col)
{ {
Ector_Renderer_Generic_Gradient_Linear_Data *gld; Ector_Renderer_Generic_Gradient_Linear_Data *gld;
Ector_Renderer_Generic_Gradient_Data *gd; Ector_Renderer_Generic_Gradient_Data *gd;

View File

@ -68,7 +68,7 @@ _ector_renderer_cairo_gradient_radial_prepare(Eo *obj EINA_UNUSED,
// Clearly duplicated and should be in a common place... // Clearly duplicated and should be in a common place...
static Eina_Bool static Eina_Bool
_ector_renderer_cairo_gradient_radial_ector_renderer_generic_base_draw(Eo *obj, Ector_Renderer_Cairo_Gradient_Radial_Data *pd, Ector_Rop op, Eina_Array *clips, unsigned int mul_col) _ector_renderer_cairo_gradient_radial_ector_renderer_generic_base_draw(Eo *obj, Ector_Renderer_Cairo_Gradient_Radial_Data *pd, Efl_Gfx_Render_Op op, Eina_Array *clips, unsigned int mul_col)
{ {
Ector_Renderer_Generic_Gradient_Radial_Data *grd; Ector_Renderer_Generic_Gradient_Radial_Data *grd;
Ector_Renderer_Generic_Gradient_Data *gd; Ector_Renderer_Generic_Gradient_Data *gd;

View File

@ -153,7 +153,7 @@ _ector_renderer_cairo_shape_ector_renderer_generic_base_prepare(Eo *obj, Ector_R
} }
static Eina_Bool static Eina_Bool
_ector_renderer_cairo_shape_ector_renderer_generic_base_draw(Eo *obj, Ector_Renderer_Cairo_Shape_Data *pd, Ector_Rop op, Eina_Array *clips, unsigned int mul_col) _ector_renderer_cairo_shape_ector_renderer_generic_base_draw(Eo *obj, Ector_Renderer_Cairo_Shape_Data *pd, Efl_Gfx_Render_Op op, Eina_Array *clips, unsigned int mul_col)
{ {
int r, g, b, a; int r, g, b, a;
unsigned i; unsigned i;

View File

@ -43,24 +43,6 @@ extern int _ector_log_dom_global;
typedef unsigned char DATA8; typedef unsigned char DATA8;
typedef unsigned short DATA16; typedef unsigned short DATA16;
#ifndef WORDS_BIGENDIAN
/* x86 */
#define A_VAL(p) (((DATA8 *)(p))[3])
#define R_VAL(p) (((DATA8 *)(p))[2])
#define G_VAL(p) (((DATA8 *)(p))[1])
#define B_VAL(p) (((DATA8 *)(p))[0])
#define AR_VAL(p) ((DATA16 *)(p)[1])
#define GB_VAL(p) ((DATA16 *)(p)[0])
#else
/* ppc */
#define A_VAL(p) (((DATA8 *)(p))[0])
#define R_VAL(p) (((DATA8 *)(p))[1])
#define G_VAL(p) (((DATA8 *)(p))[2])
#define B_VAL(p) (((DATA8 *)(p))[3])
#define AR_VAL(p) ((DATA16 *)(p)[0])
#define GB_VAL(p) ((DATA16 *)(p)[1])
#endif
#define RGB_JOIN(r,g,b) \ #define RGB_JOIN(r,g,b) \
(((r) << 16) + ((g) << 8) + (b)) (((r) << 16) + ((g) << 8) + (b))

View File

@ -105,7 +105,7 @@ abstract Ector.Renderer.Generic.Base (Eo.Base)
draw { draw {
return: bool @warn_unused; return: bool @warn_unused;
params { params {
@in op: Ector_Rop; @in op: Efl.Gfx.Render_Op;
@in clips: array<Eina.Rectangle *> *; [[array of @Eina.Rectangle clip]] @in clips: array<Eina.Rectangle *> *; [[array of @Eina.Rectangle clip]]
@in mul_col: uint; @in mul_col: uint;
} }

View File

@ -47,7 +47,7 @@ _ector_renderer_software_gradient_linear_ector_renderer_generic_base_prepare(Eo
static Eina_Bool static Eina_Bool
_ector_renderer_software_gradient_linear_ector_renderer_generic_base_draw(Eo *obj EINA_UNUSED, _ector_renderer_software_gradient_linear_ector_renderer_generic_base_draw(Eo *obj EINA_UNUSED,
Ector_Renderer_Software_Gradient_Data *pd EINA_UNUSED, Ector_Renderer_Software_Gradient_Data *pd EINA_UNUSED,
Ector_Rop op EINA_UNUSED, Eina_Array *clips EINA_UNUSED, Efl_Gfx_Render_Op op EINA_UNUSED, Eina_Array *clips EINA_UNUSED,
unsigned int mul_col EINA_UNUSED) unsigned int mul_col EINA_UNUSED)
{ {
return EINA_TRUE; return EINA_TRUE;
@ -57,7 +57,7 @@ static Eina_Bool
_ector_renderer_software_gradient_linear_ector_renderer_software_base_fill(Eo *obj EINA_UNUSED, _ector_renderer_software_gradient_linear_ector_renderer_software_base_fill(Eo *obj EINA_UNUSED,
Ector_Renderer_Software_Gradient_Data *pd) Ector_Renderer_Software_Gradient_Data *pd)
{ {
ector_software_rasterizer_linear_gradient_set(pd->surface->software, pd); ector_software_rasterizer_linear_gradient_set(pd->surface->rasterizer, pd);
return EINA_TRUE; return EINA_TRUE;
} }

View File

@ -58,7 +58,7 @@ _ector_renderer_software_gradient_radial_ector_renderer_generic_base_prepare(Eo
static Eina_Bool static Eina_Bool
_ector_renderer_software_gradient_radial_ector_renderer_generic_base_draw(Eo *obj EINA_UNUSED, _ector_renderer_software_gradient_radial_ector_renderer_generic_base_draw(Eo *obj EINA_UNUSED,
Ector_Renderer_Software_Gradient_Data *pd EINA_UNUSED, Ector_Renderer_Software_Gradient_Data *pd EINA_UNUSED,
Ector_Rop op EINA_UNUSED, Eina_Array *clips EINA_UNUSED, Efl_Gfx_Render_Op op EINA_UNUSED, Eina_Array *clips EINA_UNUSED,
unsigned int mul_col EINA_UNUSED) unsigned int mul_col EINA_UNUSED)
{ {
return EINA_TRUE; return EINA_TRUE;
@ -68,7 +68,7 @@ _ector_renderer_software_gradient_radial_ector_renderer_generic_base_draw(Eo *ob
static Eina_Bool static Eina_Bool
_ector_renderer_software_gradient_radial_ector_renderer_software_base_fill(Eo *obj EINA_UNUSED, Ector_Renderer_Software_Gradient_Data *pd) _ector_renderer_software_gradient_radial_ector_renderer_software_base_fill(Eo *obj EINA_UNUSED, Ector_Renderer_Software_Gradient_Data *pd)
{ {
ector_software_rasterizer_radial_gradient_set(pd->surface->software, pd); ector_software_rasterizer_radial_gradient_set(pd->surface->rasterizer, pd);
return EINA_TRUE; return EINA_TRUE;
} }

View File

@ -536,13 +536,13 @@ _update_rle(Eo *obj, Ector_Renderer_Software_Shape_Data *pd)
//shape data generation //shape data generation
if (_generate_shape_data(pd)) if (_generate_shape_data(pd))
pd->shape_data = ector_software_rasterizer_generate_rle_data(pd->surface->software, pd->shape_data = ector_software_rasterizer_generate_rle_data(pd->surface->rasterizer,
&outline->ft_outline); &outline->ft_outline);
//stroke data generation //stroke data generation
if ( _generate_stroke_data(pd)) if ( _generate_stroke_data(pd))
{ {
ector_software_rasterizer_stroke_set(pd->surface->software, ector_software_rasterizer_stroke_set(pd->surface->rasterizer,
(pd->public_shape->stroke.width * (pd->public_shape->stroke.width *
pd->public_shape->stroke.scale), pd->public_shape->stroke.scale),
pd->public_shape->stroke.cap, pd->public_shape->stroke.cap,
@ -555,14 +555,14 @@ _update_rle(Eo *obj, Ector_Renderer_Software_Shape_Data *pd)
pd->public_shape->stroke.dash, pd->public_shape->stroke.dash,
pd->public_shape->stroke.dash_length); pd->public_shape->stroke.dash_length);
_outline_transform(dash_outline, pd->base->m); _outline_transform(dash_outline, pd->base->m);
pd->outline_data = ector_software_rasterizer_generate_stroke_rle_data(pd->surface->software, pd->outline_data = ector_software_rasterizer_generate_stroke_rle_data(pd->surface->rasterizer,
&dash_outline->ft_outline, &dash_outline->ft_outline,
close_path); close_path);
_outline_destroy(dash_outline); _outline_destroy(dash_outline);
} }
else else
{ {
pd->outline_data = ector_software_rasterizer_generate_stroke_rle_data(pd->surface->software, pd->outline_data = ector_software_rasterizer_generate_stroke_rle_data(pd->surface->rasterizer,
&outline->ft_outline, &outline->ft_outline,
close_path); close_path);
} }
@ -593,7 +593,7 @@ _ector_renderer_software_shape_ector_renderer_generic_base_prepare(Eo *obj,
static Eina_Bool static Eina_Bool
_ector_renderer_software_shape_ector_renderer_generic_base_draw(Eo *obj, _ector_renderer_software_shape_ector_renderer_generic_base_draw(Eo *obj,
Ector_Renderer_Software_Shape_Data *pd, Ector_Renderer_Software_Shape_Data *pd,
Ector_Rop op, Eina_Array *clips, Efl_Gfx_Render_Op op, Eina_Array *clips,
unsigned int mul_col) unsigned int mul_col)
{ {
int x, y; int x, y;
@ -606,13 +606,13 @@ _ector_renderer_software_shape_ector_renderer_generic_base_draw(Eo *obj,
y = pd->surface->y + (int)pd->base->origin.y; y = pd->surface->y + (int)pd->base->origin.y;
// fill the span_data structure // fill the span_data structure
ector_software_rasterizer_clip_rect_set(pd->surface->software, clips); ector_software_rasterizer_clip_rect_set(pd->surface->rasterizer, clips);
ector_software_rasterizer_transform_set(pd->surface->software, pd->base->m); ector_software_rasterizer_transform_set(pd->surface->rasterizer, pd->base->m);
if (pd->shape->fill) if (pd->shape->fill)
{ {
eo_do(pd->shape->fill, ector_renderer_software_base_fill()); eo_do(pd->shape->fill, ector_renderer_software_base_fill());
ector_software_rasterizer_draw_rle_data(pd->surface->software, ector_software_rasterizer_draw_rle_data(pd->surface->rasterizer,
x, y, mul_col, op, x, y, mul_col, op,
pd->shape_data); pd->shape_data);
} }
@ -620,12 +620,12 @@ _ector_renderer_software_shape_ector_renderer_generic_base_draw(Eo *obj,
{ {
if (pd->base->color.a > 0) if (pd->base->color.a > 0)
{ {
ector_software_rasterizer_color_set(pd->surface->software, ector_software_rasterizer_color_set(pd->surface->rasterizer,
pd->base->color.r, pd->base->color.r,
pd->base->color.g, pd->base->color.g,
pd->base->color.b, pd->base->color.b,
pd->base->color.a); pd->base->color.a);
ector_software_rasterizer_draw_rle_data(pd->surface->software, ector_software_rasterizer_draw_rle_data(pd->surface->rasterizer,
x, y, mul_col, op, x, y, mul_col, op,
pd->shape_data); pd->shape_data);
} }
@ -634,7 +634,7 @@ _ector_renderer_software_shape_ector_renderer_generic_base_draw(Eo *obj,
if (pd->shape->stroke.fill) if (pd->shape->stroke.fill)
{ {
eo_do(pd->shape->stroke.fill, ector_renderer_software_base_fill()); eo_do(pd->shape->stroke.fill, ector_renderer_software_base_fill());
ector_software_rasterizer_draw_rle_data(pd->surface->software, ector_software_rasterizer_draw_rle_data(pd->surface->rasterizer,
x, y, mul_col, op, x, y, mul_col, op,
pd->outline_data); pd->outline_data);
} }
@ -642,12 +642,12 @@ _ector_renderer_software_shape_ector_renderer_generic_base_draw(Eo *obj,
{ {
if (pd->public_shape->stroke.color.a > 0) if (pd->public_shape->stroke.color.a > 0)
{ {
ector_software_rasterizer_color_set(pd->surface->software, ector_software_rasterizer_color_set(pd->surface->rasterizer,
pd->public_shape->stroke.color.r, pd->public_shape->stroke.color.r,
pd->public_shape->stroke.color.g, pd->public_shape->stroke.color.g,
pd->public_shape->stroke.color.b, pd->public_shape->stroke.color.b,
pd->public_shape->stroke.color.a); pd->public_shape->stroke.color.a);
ector_software_rasterizer_draw_rle_data(pd->surface->software, ector_software_rasterizer_draw_rle_data(pd->surface->rasterizer,
x, y, mul_col, op, x, y, mul_col, op,
pd->outline_data); pd->outline_data);
} }

View File

@ -10,6 +10,7 @@
#include "ector_software_private.h" #include "ector_software_private.h"
#include "ector_generic_buffer.eo.h" #include "ector_generic_buffer.eo.h"
#include "ector_software_buffer_base.eo.h" #include "ector_software_buffer_base.eo.h"
#include "draw.h"
#define MY_CLASS ECTOR_SOFTWARE_BUFFER_CLASS #define MY_CLASS ECTOR_SOFTWARE_BUFFER_CLASS

View File

@ -9,8 +9,7 @@
#include "ector_private.h" #include "ector_private.h"
#include "ector_software_private.h" #include "ector_software_private.h"
#include "ector_drawhelper_private.h" #include "draw.h"
#define GRADIENT_STOPTABLE_SIZE 1024 #define GRADIENT_STOPTABLE_SIZE 1024
#define FIXPT_BITS 8 #define FIXPT_BITS 8
@ -302,7 +301,7 @@ _generate_gradient_color_table(Efl_Gfx_Gradient_Stop *gradient_stops, int stop_c
curr = gradient_stops; curr = gradient_stops;
if (curr->a != 255) alpha = EINA_TRUE; if (curr->a != 255) alpha = EINA_TRUE;
current_color = ECTOR_ARGB_JOIN(curr->a, curr->r, curr->g, curr->b); current_color = DRAW_ARGB_JOIN(curr->a, curr->r, curr->g, curr->b);
incr = 1.0 / (double)size; incr = 1.0 / (double)size;
fpos = 1.5 * incr; fpos = 1.5 * incr;
@ -323,7 +322,7 @@ _generate_gradient_color_table(Efl_Gfx_Gradient_Stop *gradient_stops, int stop_c
next = (gradient_stops + i + 1); next = (gradient_stops + i + 1);
delta = 1/(next->offset - curr->offset); delta = 1/(next->offset - curr->offset);
if (next->a != 255) alpha = EINA_TRUE; if (next->a != 255) alpha = EINA_TRUE;
next_color = ECTOR_ARGB_JOIN(next->a, next->r, next->g, next->b); next_color = DRAW_ARGB_JOIN(next->a, next->r, next->g, next->b);
func = &_ease_linear; func = &_ease_linear;
while (fpos < next->offset && pos < size) while (fpos < next->offset && pos < size)
{ {
@ -405,7 +404,7 @@ fetch_linear_gradient(uint *buffer, Span_Data *data, int y, int x, int length)
end = buffer + length; end = buffer + length;
if (inc > (float)(-1e-5) && inc < (float)(1e-5)) if (inc > (float)(-1e-5) && inc < (float)(1e-5))
{ {
_ector_memfill(buffer, length, _gradient_pixel_fixed(g_data, (int)(t * FIXPT_SIZE))); draw_memset32(buffer, _gradient_pixel_fixed(g_data, (int)(t * FIXPT_SIZE)), length);
} }
else else
{ {
@ -456,7 +455,7 @@ fetch_radial_gradient(uint *buffer, Span_Data *data, int y, int x, int length)
// avoid division by zero // avoid division by zero
if (fabsf(g_data->radial.a) <= 0.00001f) if (fabsf(g_data->radial.a) <= 0.00001f)
{ {
_ector_memfill(buffer, length, 0); draw_memset32(buffer, 0, length);
return; return;
} }
@ -495,17 +494,21 @@ fetch_radial_gradient(uint *buffer, Span_Data *data, int y, int x, int length)
_ector_radial_helper(buffer, length, g_data, det, delta_det, delta_delta_det, b, delta_b); _ector_radial_helper(buffer, length, g_data, det, delta_det, delta_delta_det, b, delta_b);
} }
int
void ector_software_gradient_init(void)
drawhelper_gradient_init()
{ {
_ector_radial_helper = _radial_helper_generic; static int i = 0;
_ector_linear_helper = _linear_helper_generic; if (!(i++))
#ifdef BUILD_SSE3
if (eina_cpu_features_get() & EINA_CPU_SSE3)
{ {
_ector_radial_helper = _radial_helper_sse3; _ector_radial_helper = _radial_helper_generic;
_ector_linear_helper = _linear_helper_sse3; _ector_linear_helper = _linear_helper_generic;
} #ifdef BUILD_SSE3
if (eina_cpu_features_get() & EINA_CPU_SSE3)
{
_ector_radial_helper = _radial_helper_sse3;
_ector_linear_helper = _linear_helper_sse3;
}
#endif #endif
}
return i;
} }

View File

@ -91,7 +91,7 @@ typedef struct _Span_Data
Span_Data_Type type; Span_Data_Type type;
Eina_Bool fast_matrix ; Eina_Bool fast_matrix ;
DATA32 mul_col; DATA32 mul_col;
Ector_Rop op; Efl_Gfx_Render_Op op;
union { union {
DATA32 color; DATA32 color;
Ector_Renderer_Software_Gradient_Data *gradient; Ector_Renderer_Software_Gradient_Data *gradient;
@ -112,12 +112,13 @@ struct _Software_Rasterizer
struct _Ector_Software_Surface_Data struct _Ector_Software_Surface_Data
{ {
Software_Rasterizer *software; Software_Rasterizer *rasterizer;
int x; int x;
int y; int y;
}; };
int ector_software_gradient_init(void);
void ector_software_rasterizer_init(Software_Rasterizer *rasterizer); void ector_software_rasterizer_init(Software_Rasterizer *rasterizer);
void ector_software_rasterizer_done(Software_Rasterizer *rasterizer); void ector_software_rasterizer_done(Software_Rasterizer *rasterizer);
@ -137,7 +138,7 @@ void ector_software_rasterizer_clip_shape_set(Software_Rasterizer *rasterizer, S
Shape_Rle_Data * ector_software_rasterizer_generate_rle_data(Software_Rasterizer *rasterizer, SW_FT_Outline *outline); Shape_Rle_Data * ector_software_rasterizer_generate_rle_data(Software_Rasterizer *rasterizer, SW_FT_Outline *outline);
Shape_Rle_Data * ector_software_rasterizer_generate_stroke_rle_data(Software_Rasterizer *rasterizer, SW_FT_Outline *outline, Eina_Bool closePath); Shape_Rle_Data * ector_software_rasterizer_generate_stroke_rle_data(Software_Rasterizer *rasterizer, SW_FT_Outline *outline, Eina_Bool closePath);
void ector_software_rasterizer_draw_rle_data(Software_Rasterizer *rasterizer, int x, int y, uint mul_col, Ector_Rop op, Shape_Rle_Data* rle); void ector_software_rasterizer_draw_rle_data(Software_Rasterizer *rasterizer, int x, int y, uint mul_col, Efl_Gfx_Render_Op op, Shape_Rle_Data* rle);
void ector_software_rasterizer_destroy_rle_data(Shape_Rle_Data *rle); void ector_software_rasterizer_destroy_rle_data(Shape_Rle_Data *rle);

View File

@ -9,7 +9,7 @@
#include "ector_private.h" #include "ector_private.h"
#include "ector_software_private.h" #include "ector_software_private.h"
#include "ector_drawhelper_private.h" #include "draw.h"
static void static void
_blend_color_argb(int count, const SW_FT_Span *spans, void *user_data) _blend_color_argb(int count, const SW_FT_Span *spans, void *user_data)
@ -20,8 +20,8 @@ _blend_color_argb(int count, const SW_FT_Span *spans, void *user_data)
const int pix_stride = data->raster_buffer->stride / 4; const int pix_stride = data->raster_buffer->stride / 4;
// multiply the color with mul_col if any // multiply the color with mul_col if any
color = ECTOR_MUL4_SYM(data->color, data->mul_col); color = DRAW_MUL4_SYM(data->color, data->mul_col);
comp_func = ector_comp_func_solid_span_get(data->op, color); comp_func = efl_draw_func_solid_span_get(data->op, color);
// move to the offset location // move to the offset location
buffer = data->raster_buffer->pixels.u32 + ((pix_stride * data->offy) + data->offx); buffer = data->raster_buffer->pixels.u32 + ((pix_stride * data->offy) + data->offx);
@ -55,7 +55,7 @@ _blend_gradient(int count, const SW_FT_Span *spans, void *user_data)
if (!fetchfunc) if (!fetchfunc)
return; return;
comp_func = ector_comp_func_span_get(data->op, data->mul_col, data->gradient->alpha); comp_func = efl_draw_func_span_get(data->op, data->mul_col, data->gradient->alpha);
// move to the offset location // move to the offset location
destbuffer = data->raster_buffer->pixels.u32 + ((pix_stride * data->offy) + data->offx); destbuffer = data->raster_buffer->pixels.u32 + ((pix_stride * data->offy) + data->offx);
@ -102,7 +102,7 @@ _blend_image_argb(int count, const SW_FT_Span *spans, void *user_data)
#warning FIXME: Image scaling, anyone? #warning FIXME: Image scaling, anyone?
#warning FIXME: Optimize eo call with early call resolution #warning FIXME: Optimize eo call with early call resolution
comp_func = ector_comp_func_span_get(data->op, data->mul_col, EINA_TRUE); comp_func = efl_draw_func_span_get(data->op, data->mul_col, EINA_TRUE);
buffer = data->raster_buffer->pixels.u32 + ((pix_stride * data->offy) + data->offx); buffer = data->raster_buffer->pixels.u32 + ((pix_stride * data->offy) + data->offx);
@ -368,7 +368,8 @@ void ector_software_rasterizer_init(Software_Rasterizer *rasterizer)
rasterizer->fill_data.clip.enabled = EINA_FALSE; rasterizer->fill_data.clip.enabled = EINA_FALSE;
rasterizer->fill_data.unclipped_blend = 0; rasterizer->fill_data.unclipped_blend = 0;
rasterizer->fill_data.blend = 0; rasterizer->fill_data.blend = 0;
draw_helper_init(); efl_draw_init();
ector_software_gradient_init();
} }
void ector_software_rasterizer_done(Software_Rasterizer *rasterizer) void ector_software_rasterizer_done(Software_Rasterizer *rasterizer)
@ -551,7 +552,7 @@ void ector_software_rasterizer_clip_shape_set(Software_Rasterizer *rasterizer, S
void ector_software_rasterizer_color_set(Software_Rasterizer *rasterizer, int r, int g, int b, int a) void ector_software_rasterizer_color_set(Software_Rasterizer *rasterizer, int r, int g, int b, int a)
{ {
rasterizer->fill_data.color = ECTOR_ARGB_JOIN(a, r, g, b); rasterizer->fill_data.color = DRAW_ARGB_JOIN(a, r, g, b);
rasterizer->fill_data.type = Solid; rasterizer->fill_data.type = Solid;
} }
@ -578,7 +579,7 @@ void ector_software_rasterizer_buffer_set(Software_Rasterizer *rasterizer,
void ector_software_rasterizer_draw_rle_data(Software_Rasterizer *rasterizer, void ector_software_rasterizer_draw_rle_data(Software_Rasterizer *rasterizer,
int x, int y, uint mul_col, int x, int y, uint mul_col,
Ector_Rop op, Shape_Rle_Data* rle) Efl_Gfx_Render_Op op, Shape_Rle_Data* rle)
{ {
// check for NULL rle data // check for NULL rle data
if (!rle) return; if (!rle) return;

View File

@ -35,19 +35,19 @@ static Eo *
_ector_software_surface_eo_base_constructor(Eo *obj, Ector_Software_Surface_Data *pd) _ector_software_surface_eo_base_constructor(Eo *obj, Ector_Software_Surface_Data *pd)
{ {
obj = eo_do_super_ret(obj, MY_CLASS, obj, eo_constructor()); obj = eo_do_super_ret(obj, MY_CLASS, obj, eo_constructor());
pd->software = (Software_Rasterizer *) calloc(1, sizeof(Software_Rasterizer)); pd->rasterizer = (Software_Rasterizer *) calloc(1, sizeof(Software_Rasterizer));
ector_software_rasterizer_init(pd->software); ector_software_rasterizer_init(pd->rasterizer);
pd->software->fill_data.raster_buffer = eo_data_ref(obj, ECTOR_SOFTWARE_BUFFER_BASE_MIXIN); pd->rasterizer->fill_data.raster_buffer = eo_data_ref(obj, ECTOR_SOFTWARE_BUFFER_BASE_MIXIN);
return obj; return obj;
} }
static void static void
_ector_software_surface_eo_base_destructor(Eo *obj, Ector_Software_Surface_Data *pd) _ector_software_surface_eo_base_destructor(Eo *obj, Ector_Software_Surface_Data *pd)
{ {
ector_software_rasterizer_done(pd->software); ector_software_rasterizer_done(pd->rasterizer);
eo_data_unref(obj, pd->software->fill_data.raster_buffer); eo_data_unref(obj, pd->rasterizer->fill_data.raster_buffer);
free(pd->software); free(pd->rasterizer);
pd->software = NULL; pd->rasterizer = NULL;
eo_do_super(obj, ECTOR_SOFTWARE_SURFACE_CLASS, eo_destructor()); eo_do_super(obj, ECTOR_SOFTWARE_SURFACE_CLASS, eo_destructor());
} }

View File

@ -196,6 +196,7 @@ EAPI extern const Eo_Event_Description _EFL_GFX_PATH_CHANGED;
#ifndef EFL_NOLEGACY_API_SUPPORT #ifndef EFL_NOLEGACY_API_SUPPORT
#include "interfaces/efl_gfx_fill.eo.legacy.h" #include "interfaces/efl_gfx_fill.eo.legacy.h"
#include "interfaces/efl_gfx_base.eo.legacy.h"
#endif #endif
#endif #endif

View File

@ -3,6 +3,12 @@ enum Efl.Gfx.Colorspace {
gry8 = 4, [[8-bit gray image, or alpha only]] gry8 = 4, [[8-bit gray image, or alpha only]]
} }
enum Efl.Gfx.Render_Op {
blend = 0, [[Alpha blending onto destination (default); d = d*(1-sa) + s]]
copy = 1, [[Copy source to destination; d = s]]
last
}
interface Efl.Gfx.Base { interface Efl.Gfx.Base {
legacy_prefix: null; legacy_prefix: null;
eo_prefix: efl_gfx; eo_prefix: efl_gfx;

View File

@ -55,7 +55,6 @@
# include <Eet.h> # include <Eet.h>
#endif #endif
#include "Evas.h" #include "Evas.h"
//#include "Evas_GL.h"
#ifdef EAPI #ifdef EAPI
# undef EAPI # undef EAPI
@ -1159,6 +1158,7 @@ struct _Convert_Pal
/*****************************************************************************/ /*****************************************************************************/
#include "evas_macros.h" #include "evas_macros.h"
#ifndef A_VAL
#ifndef WORDS_BIGENDIAN #ifndef WORDS_BIGENDIAN
/* x86 */ /* x86 */
#define A_VAL(p) (((DATA8 *)(p))[3]) #define A_VAL(p) (((DATA8 *)(p))[3])
@ -1176,6 +1176,7 @@ struct _Convert_Pal
#define AR_VAL(p) ((DATA16 *)(p)[0]) #define AR_VAL(p) ((DATA16 *)(p)[0])
#define GB_VAL(p) ((DATA16 *)(p)[1]) #define GB_VAL(p) ((DATA16 *)(p)[1])
#endif #endif
#endif
#define RGB_JOIN(r,g,b) \ #define RGB_JOIN(r,g,b) \
(((r) << 16) + ((g) << 8) + (b)) (((r) << 16) + ((g) << 8) + (b))

View File

@ -2452,17 +2452,17 @@ eng_ector_destroy(void *data EINA_UNUSED, Ector_Surface *ector)
if (ector) eo_del(ector); if (ector) eo_del(ector);
} }
static Ector_Rop static Efl_Gfx_Render_Op
_evas_render_op_to_ector_rop(Evas_Render_Op op) _evas_render_op_to_ector_rop(Evas_Render_Op op)
{ {
switch (op) switch (op)
{ {
case EVAS_RENDER_BLEND: case EVAS_RENDER_BLEND:
return ECTOR_ROP_BLEND; return EFL_GFX_RENDER_OP_BLEND;
case EVAS_RENDER_COPY: case EVAS_RENDER_COPY:
return ECTOR_ROP_COPY; return EFL_GFX_RENDER_OP_COPY;
default: default:
return ECTOR_ROP_BLEND; return EFL_GFX_RENDER_OP_BLEND;
} }
} }

View File

@ -398,7 +398,7 @@ struct _Evas_Thread_Command_Ector
Eina_Array *clips; Eina_Array *clips;
DATA32 mul_col; DATA32 mul_col;
Ector_Rop render_op; Efl_Gfx_Render_Op render_op;
Eina_Bool free_it; Eina_Bool free_it;
}; };
@ -3754,17 +3754,17 @@ eng_ector_destroy(void *data EINA_UNUSED, Ector_Surface *ector)
if (ector) eo_del(ector); if (ector) eo_del(ector);
} }
static Ector_Rop static Efl_Gfx_Render_Op
_evas_render_op_to_ector_rop(Evas_Render_Op op) _evas_render_op_to_ector_rop(Evas_Render_Op op)
{ {
switch (op) switch (op)
{ {
case EVAS_RENDER_BLEND: case EVAS_RENDER_BLEND:
return ECTOR_ROP_BLEND; return EFL_GFX_RENDER_OP_BLEND;
case EVAS_RENDER_COPY: case EVAS_RENDER_COPY:
return ECTOR_ROP_COPY; return EFL_GFX_RENDER_OP_COPY;
default: default:
return ECTOR_ROP_BLEND; return EFL_GFX_RENDER_OP_BLEND;
} }
} }

View File

@ -1,7 +1,22 @@
#ifndef ECTOR_DRAWHELPER_PRIVATE_H #ifndef EFL_DRAW_H
#define ECTOR_DRAWHELPER_PRIVATE_H #define EFL_DRAW_H
#include "ector_private.h" #ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <Efl.h>
typedef void (*RGBA_Comp_Func)(uint *dest, const uint *src, int length, uint mul_col, uint const_alpha);
typedef void (*RGBA_Comp_Func_Solid)(uint *dest, int length, uint color, uint const_alpha);
int efl_draw_init(void);
RGBA_Comp_Func_Solid efl_draw_func_solid_span_get(Efl_Gfx_Render_Op op, uint color);
RGBA_Comp_Func efl_draw_func_span_get(Efl_Gfx_Render_Op op, uint color, Eina_Bool src_alpha);
/* common sw draw helpers */
#ifndef MIN #ifndef MIN
#define MIN( a, b ) ( (a) < (b) ? (a) : (b) ) #define MIN( a, b ) ( (a) < (b) ? (a) : (b) )
@ -11,53 +26,53 @@
#define MAX( a, b ) ( (a) > (b) ? (a) : (b) ) #define MAX( a, b ) ( (a) > (b) ? (a) : (b) )
#endif #endif
#ifndef uint #ifndef A_VAL
typedef unsigned int uint; #ifndef WORDS_BIGENDIAN
/* x86 */
#define A_VAL(p) (((uint8_t *)(p))[3])
#define R_VAL(p) (((uint8_t *)(p))[2])
#define G_VAL(p) (((uint8_t *)(p))[1])
#define B_VAL(p) (((uint8_t *)(p))[0])
#define AR_VAL(p) ((uint16_t *)(p)[1])
#define GB_VAL(p) ((uint16_t *)(p)[0])
#else
/* ppc */
#define A_VAL(p) (((uint8_t *)(p))[0])
#define R_VAL(p) (((uint8_t *)(p))[1])
#define G_VAL(p) (((uint8_t *)(p))[2])
#define B_VAL(p) (((uint8_t *)(p))[3])
#define AR_VAL(p) ((uint16_t *)(p)[0])
#define GB_VAL(p) ((uint16_t *)(p)[1])
#endif
#endif #endif
#define ECTOR_ARGB_JOIN(a,r,g,b) \ #define DRAW_ARGB_JOIN(a,r,g,b) \
(((a) << 24) + ((r) << 16) + ((g) << 8) + (b)) (((a) << 24) + ((r) << 16) + ((g) << 8) + (b))
#define ECTOR_MUL4_SYM(x, y) \ #define DRAW_MUL4_SYM(x, y) \
( ((((((x) >> 16) & 0xff00) * (((y) >> 16) & 0xff00)) + 0xff0000) & 0xff000000) + \ ( ((((((x) >> 16) & 0xff00) * (((y) >> 16) & 0xff00)) + 0xff0000) & 0xff000000) + \
((((((x) >> 8) & 0xff00) * (((y) >> 16) & 0xff)) + 0xff00) & 0xff0000) + \ ((((((x) >> 8) & 0xff00) * (((y) >> 16) & 0xff)) + 0xff00) & 0xff0000) + \
((((((x) & 0xff00) * ((y) & 0xff00)) + 0xff0000) >> 16) & 0xff00) + \ ((((((x) & 0xff00) * ((y) & 0xff00)) + 0xff0000) >> 16) & 0xff00) + \
(((((x) & 0xff) * ((y) & 0xff)) + 0xff) >> 8) ) (((((x) & 0xff) * ((y) & 0xff)) + 0xff) >> 8) )
#define BYTE_MUL(c, a) \ static inline uint
( (((((c) >> 8) & 0x00ff00ff) * (a)) & 0xff00ff00) + \ INTERPOLATE_PIXEL_256(uint x, uint a, uint y, uint b)
(((((c) & 0x00ff00ff) * (a)) >> 8) & 0x00ff00ff) )
#define LOOP_ALIGNED_U1_A4(DEST, LENGTH, UOP, A4OP) \
{ \
while((uintptr_t)DEST & 0xF && LENGTH) UOP \
\
while(LENGTH) { \
switch(LENGTH) { \
case 3: \
case 2: \
case 1: \
UOP \
break; \
default: \
A4OP \
break; \
} \
} \
}
static inline int
alpha_inverse(int color)
{ {
color = ~color; uint t = (x & 0xff00ff) * a + (y & 0xff00ff) * b;
return A_VAL(&color); t >>= 8;
t &= 0xff00ff;
x = ((x >> 8) & 0xff00ff) * a + ((y >> 8) & 0xff00ff) * b;
x &= 0xff00ff00;
x |= t;
return x;
} }
static inline void static inline void
_ector_memfill(uint *dest, int length, uint value) draw_memset32(uint *dest, uint value, int length)
{ {
int n; int n;
if (!length)
if (length <= 0)
return; return;
n = (length + 7) / 8; n = (length + 7) / 8;
@ -75,31 +90,4 @@ _ector_memfill(uint *dest, int length, uint value)
} }
} }
static inline uint
INTERPOLATE_PIXEL_256(uint x, uint a, uint y, uint b)
{
uint t = (x & 0xff00ff) * a + (y & 0xff00ff) * b;
t >>= 8;
t &= 0xff00ff;
x = ((x >> 8) & 0xff00ff) * a + ((y >> 8) & 0xff00ff) * b;
x &= 0xff00ff00;
x |= t;
return x;
}
typedef void (*RGBA_Comp_Func)(uint *dest, const uint *src, int length, uint mul_col, uint const_alpha);
typedef void (*RGBA_Comp_Func_Solid)(uint *dest, int length, uint color, uint const_alpha);
extern RGBA_Comp_Func_Solid func_for_mode_solid[ECTOR_ROP_LAST];
extern RGBA_Comp_Func func_for_mode[ECTOR_ROP_LAST];
void drawhelper_gradient_init(void);
void draw_helper_sse2_init(void);
void draw_helper_neon_init(void);
void draw_helper_init(void);
RGBA_Comp_Func_Solid ector_comp_func_solid_span_get(Ector_Rop op, uint color);
RGBA_Comp_Func ector_comp_func_span_get(Ector_Rop op, uint color, Eina_Bool src_alpha);
#endif #endif

View File

@ -3,7 +3,7 @@
#endif #endif
#include <Ector.h> #include <Ector.h>
#include "ector_drawhelper_private.h" #include "draw_private.h"
/* /*
s = source pixel s = source pixel
@ -27,10 +27,10 @@ _comp_func_solid_source_over(uint *dest, int length, uint color, uint const_alph
int ialpha, i; int ialpha, i;
if (const_alpha != 255) if (const_alpha != 255)
color = BYTE_MUL(color, const_alpha); color = DRAW_BYTE_MUL(color, const_alpha);
ialpha = alpha_inverse(color); ialpha = alpha_inverse(color);
for (i = 0; i < length; ++i) for (i = 0; i < length; ++i)
dest[i] = color + BYTE_MUL(dest[i], ialpha); dest[i] = color + DRAW_BYTE_MUL(dest[i], ialpha);
} }
static void static void
@ -40,7 +40,7 @@ _comp_func_source_over(uint *dest, const uint *src, int length, uint color, uint
uint s, sc, sia; uint s, sc, sia;
if (const_alpha != 255) if (const_alpha != 255)
color = BYTE_MUL(color, const_alpha); color = DRAW_BYTE_MUL(color, const_alpha);
if (color == 0xffffffff) // No color multiplier if (color == 0xffffffff) // No color multiplier
{ {
@ -52,7 +52,7 @@ _comp_func_source_over(uint *dest, const uint *src, int length, uint color, uint
else if (s != 0) else if (s != 0)
{ {
sia = alpha_inverse(s); sia = alpha_inverse(s);
dest[i] = s + BYTE_MUL(dest[i], sia); dest[i] = s + DRAW_BYTE_MUL(dest[i], sia);
} }
} }
} }
@ -61,9 +61,9 @@ _comp_func_source_over(uint *dest, const uint *src, int length, uint color, uint
for (i = 0; i < length; ++i) for (i = 0; i < length; ++i)
{ {
s = src[i]; s = src[i];
sc = ECTOR_MUL4_SYM(color, s); sc = DRAW_MUL4_SYM(color, s);
sia = alpha_inverse(sc); sia = alpha_inverse(sc);
dest[i] = sc + BYTE_MUL(dest[i], sia); dest[i] = sc + DRAW_BYTE_MUL(dest[i], sia);
} }
} }
} }
@ -79,14 +79,14 @@ _comp_func_solid_source(uint *dest, int length, uint color, uint const_alpha)
if (const_alpha == 255) if (const_alpha == 255)
{ {
_ector_memfill(dest, length, color); draw_memset32(dest, color, length);
} }
else else
{ {
ialpha = 255 - const_alpha; ialpha = 255 - const_alpha;
color = BYTE_MUL(color, const_alpha); color = DRAW_BYTE_MUL(color, const_alpha);
for (i = 0; i < length; ++i) for (i = 0; i < length; ++i)
dest[i] = color + BYTE_MUL(dest[i], ialpha); dest[i] = color + DRAW_BYTE_MUL(dest[i], ialpha);
} }
} }
@ -114,54 +114,59 @@ _comp_func_source(uint *dest, const uint *src, int length, uint color, uint cons
if (const_alpha == 255) if (const_alpha == 255)
{ {
for (i = 0; i < length; ++i) for (i = 0; i < length; ++i)
dest[i] = ECTOR_MUL4_SYM(src[i], color); dest[i] = DRAW_MUL4_SYM(src[i], color);
} }
else else
{ {
ialpha = 255 - const_alpha; ialpha = 255 - const_alpha;
for (i = 0; i < length; ++i) for (i = 0; i < length; ++i)
{ {
src_color = ECTOR_MUL4_SYM(src[i], color); src_color = DRAW_MUL4_SYM(src[i], color);
dest[i] = INTERPOLATE_PIXEL_256(src_color, const_alpha, dest[i], ialpha); dest[i] = INTERPOLATE_PIXEL_256(src_color, const_alpha, dest[i], ialpha);
} }
} }
} }
} }
RGBA_Comp_Func_Solid func_for_mode_solid[ECTOR_ROP_LAST] = { RGBA_Comp_Func_Solid func_for_mode_solid[EFL_GFX_RENDER_OP_LAST] = {
_comp_func_solid_source_over, _comp_func_solid_source_over,
_comp_func_solid_source _comp_func_solid_source
}; };
RGBA_Comp_Func func_for_mode[ECTOR_ROP_LAST] = { RGBA_Comp_Func func_for_mode[EFL_GFX_RENDER_OP_LAST] = {
_comp_func_source_over, _comp_func_source_over,
_comp_func_source _comp_func_source
}; };
RGBA_Comp_Func_Solid RGBA_Comp_Func_Solid
ector_comp_func_solid_span_get(Ector_Rop op, uint color) efl_draw_func_solid_span_get(Efl_Gfx_Render_Op op, uint color)
{ {
if ((color & 0xff000000) == 0xff000000) if ((color & 0xff000000) == 0xff000000)
{ {
if (op == ECTOR_ROP_BLEND) op = ECTOR_ROP_COPY; if (op == EFL_GFX_RENDER_OP_BLEND) op = EFL_GFX_RENDER_OP_COPY;
} }
return func_for_mode_solid[op]; return func_for_mode_solid[op];
} }
RGBA_Comp_Func ector_comp_func_span_get(Ector_Rop op, uint color, Eina_Bool src_alpha) RGBA_Comp_Func efl_draw_func_span_get(Efl_Gfx_Render_Op op, uint color, Eina_Bool src_alpha)
{ {
if (((color & 0xff000000) == 0xff000000) && !src_alpha) if (((color & 0xff000000) == 0xff000000) && !src_alpha)
{ {
if (op == ECTOR_ROP_BLEND) op = ECTOR_ROP_COPY; if (op == EFL_GFX_RENDER_OP_BLEND) op = EFL_GFX_RENDER_OP_COPY;
} }
return func_for_mode[op]; return func_for_mode[op];
} }
void draw_helper_init() int
efl_draw_init()
{ {
drawhelper_gradient_init(); static int i = 0;
draw_helper_sse2_init(); if (!(i++))
draw_helper_neon_init(); {
efl_draw_sse2_init();
efl_draw_neon_init();
}
return i;
} }

View File

@ -2,8 +2,7 @@
#include "config.h" #include "config.h"
#endif #endif
#include <Ector.h> #include "draw_private.h"
#include "ector_drawhelper_private.h"
#undef BUILD_NEON #undef BUILD_NEON
#ifdef BUILD_NEON #ifdef BUILD_NEON
@ -36,7 +35,7 @@ comp_func_solid_source_over_neon(uint * __restrict dest, int length, uint color,
uint8x8_t temp11_8x8; uint8x8_t temp11_8x8;
if (const_alpha != 255) if (const_alpha != 255)
color = BYTE_MUL(color, const_alpha); color = DRAW_BYTE_MUL(color, const_alpha);
// alpha can only be 0 if color is 0x0. In that case we can just return. // alpha can only be 0 if color is 0x0. In that case we can just return.
// Otherwise we can assume alpha != 0. This allows more optimization in // Otherwise we can assume alpha != 0. This allows more optimization in
@ -140,7 +139,7 @@ comp_func_source_over_sse2(uint * __restrict dest, const uint * __restrict src,
DATA32 *end; DATA32 *end;
if (const_alpha != 255) if (const_alpha != 255)
color = BYTE_MUL(color, const_alpha); color = DRAW_BYTE_MUL(color, const_alpha);
c_32x2 = vdup_n_u32(color); c_32x2 = vdup_n_u32(color);
c_8x8 = vreinterpret_u8_u32(c_32x2); c_8x8 = vreinterpret_u8_u32(c_32x2);
@ -215,18 +214,18 @@ comp_func_source_over_sse2(uint * __restrict dest, const uint * __restrict src,
#endif #endif
void void
draw_helper_neon_init() efl_draw_neon_init()
{ {
#ifdef BUILD_NEON #ifdef BUILD_NEON
if (eina_cpu_features_get() & EINA_CPU_NEON) if (eina_cpu_features_get() & EINA_CPU_NEON)
{ {
// update the comp_function table for solid color // update the comp_function table for solid color
//func_for_mode_solid[ECTOR_ROP_COPY] = comp_func_solid_source_sse2; //func_for_mode_solid[EFL_GFX_RENDER_OP_COPY] = comp_func_solid_source_sse2;
func_for_mode_solid[ECTOR_ROP_BLEND] = comp_func_solid_source_over_neon; func_for_mode_solid[EFL_GFX_RENDER_OP_BLEND] = comp_func_solid_source_over_neon;
// update the comp_function table for source data // update the comp_function table for source data
//func_for_mode[ECTOR_ROP_COPY] = comp_func_source_sse2; //func_for_mode[EFL_GFX_RENDER_OP_COPY] = comp_func_source_sse2;
func_for_mode[ECTOR_ROP_BLEND] = comp_func_source_over_neon; func_for_mode[EFL_GFX_RENDER_OP_BLEND] = comp_func_source_over_neon;
} }
#endif #endif
} }

View File

@ -3,7 +3,7 @@
#endif #endif
#include <Ector.h> #include <Ector.h>
#include "ector_drawhelper_private.h" #include "draw_private.h"
#ifdef BUILD_SSE3 #ifdef BUILD_SSE3
#include <immintrin.h> #include <immintrin.h>
@ -125,7 +125,7 @@ comp_func_helper_sse2 (uint *dest, int length, uint color, uint alpha)
LOOP_ALIGNED_U1_A4(dest, length, LOOP_ALIGNED_U1_A4(dest, length,
{ /* UOP */ { /* UOP */
*dest = color + BYTE_MUL(*dest, alpha); *dest = color + DRAW_BYTE_MUL(*dest, alpha);
dest++; length--; dest++; length--;
}, },
{ /* A4OP */ { /* A4OP */
@ -145,14 +145,14 @@ comp_func_solid_source_sse2(uint *dest, int length, uint color, uint const_alpha
{ {
if (const_alpha == 255) if (const_alpha == 255)
{ {
_ector_memfill(dest, length, color); draw_memset32(dest, color, length);
} }
else else
{ {
int ialpha; int ialpha;
ialpha = 255 - const_alpha; ialpha = 255 - const_alpha;
color = BYTE_MUL(color, const_alpha); color = DRAW_BYTE_MUL(color, const_alpha);
comp_func_helper_sse2(dest, length, color, ialpha); comp_func_helper_sse2(dest, length, color, ialpha);
} }
} }
@ -163,7 +163,7 @@ comp_func_solid_source_over_sse2(uint *dest, int length, uint color, uint const_
int ialpha; int ialpha;
if (const_alpha != 255) if (const_alpha != 255)
color = BYTE_MUL(color, const_alpha); color = DRAW_BYTE_MUL(color, const_alpha);
ialpha = alpha_inverse(color); ialpha = alpha_inverse(color);
comp_func_helper_sse2(dest, length, color, ialpha); comp_func_helper_sse2(dest, length, color, ialpha);
} }
@ -239,7 +239,7 @@ comp_func_source_sse2(uint *dest, const uint *src, int length, uint color, uint
{ {
LOOP_ALIGNED_U1_A4(dest, length, LOOP_ALIGNED_U1_A4(dest, length,
{ /* UOP */ { /* UOP */
*dest = ECTOR_MUL4_SYM(*src, color); *dest = DRAW_MUL4_SYM(*src, color);
dest++; src++; length--; dest++; src++; length--;
}, },
{ /* A4OP */ { /* A4OP */
@ -256,7 +256,7 @@ comp_func_source_sse2(uint *dest, const uint *src, int length, uint color, uint
LOOP_ALIGNED_U1_A4(dest, length, LOOP_ALIGNED_U1_A4(dest, length,
{ /* UOP */ { /* UOP */
src_color = ECTOR_MUL4_SYM(*src, color); src_color = DRAW_MUL4_SYM(*src, color);
*dest = INTERPOLATE_PIXEL_256(src_color, const_alpha, *dest, ialpha); *dest = INTERPOLATE_PIXEL_256(src_color, const_alpha, *dest, ialpha);
dest++; src++; length--; dest++; src++; length--;
}, },
@ -277,7 +277,7 @@ comp_func_source_over_sse2(uint *dest, const uint *src, int length, uint color,
uint s, sia; uint s, sia;
if (const_alpha != 255) if (const_alpha != 255)
color = BYTE_MUL(color, const_alpha); color = DRAW_BYTE_MUL(color, const_alpha);
if (color == 0xffffffff) // No color multiplier if (color == 0xffffffff) // No color multiplier
{ {
@ -285,7 +285,7 @@ comp_func_source_over_sse2(uint *dest, const uint *src, int length, uint color,
{ /* UOP */ { /* UOP */
s = *src; s = *src;
sia = alpha_inverse(s); sia = alpha_inverse(s);
*dest = s + BYTE_MUL(*dest, sia); *dest = s + DRAW_BYTE_MUL(*dest, sia);
dest++; src++; length--; dest++; src++; length--;
}, },
{ /* A4OP */ { /* A4OP */
@ -301,9 +301,9 @@ comp_func_source_over_sse2(uint *dest, const uint *src, int length, uint color,
LOOP_ALIGNED_U1_A4(dest, length, LOOP_ALIGNED_U1_A4(dest, length,
{ /* UOP */ { /* UOP */
s = ECTOR_MUL4_SYM(*src, color); s = DRAW_MUL4_SYM(*src, color);
sia = alpha_inverse(s); sia = alpha_inverse(s);
*dest = s + BYTE_MUL(*dest, sia); *dest = s + DRAW_BYTE_MUL(*dest, sia);
dest++; src++; length--; dest++; src++; length--;
}, },
{ /* A4OP */ { /* A4OP */
@ -319,18 +319,18 @@ comp_func_source_over_sse2(uint *dest, const uint *src, int length, uint color,
#endif #endif
void void
draw_helper_sse2_init() efl_draw_sse2_init()
{ {
#ifdef BUILD_SSE3 #ifdef BUILD_SSE3
if (eina_cpu_features_get() & EINA_CPU_SSE2) if (eina_cpu_features_get() & EINA_CPU_SSE2)
{ {
// update the comp_function table for solid color // update the comp_function table for solid color
func_for_mode_solid[ECTOR_ROP_COPY] = comp_func_solid_source_sse2; func_for_mode_solid[EFL_GFX_RENDER_OP_COPY] = comp_func_solid_source_sse2;
func_for_mode_solid[ECTOR_ROP_BLEND] = comp_func_solid_source_over_sse2; func_for_mode_solid[EFL_GFX_RENDER_OP_BLEND] = comp_func_solid_source_over_sse2;
// update the comp_function table for source data // update the comp_function table for source data
func_for_mode[ECTOR_ROP_COPY] = comp_func_source_sse2; func_for_mode[EFL_GFX_RENDER_OP_COPY] = comp_func_source_sse2;
func_for_mode[ECTOR_ROP_BLEND] = comp_func_source_over_sse2; func_for_mode[EFL_GFX_RENDER_OP_BLEND] = comp_func_source_over_sse2;
} }
#endif #endif
} }

View File

@ -0,0 +1,41 @@
#ifndef EFL_DRAW_PRIVATE_H
#define EFL_DRAW_PRIVATE_H
#include "draw.h"
#define DRAW_BYTE_MUL(c, a) \
( (((((c) >> 8) & 0x00ff00ff) * (a)) & 0xff00ff00) + \
(((((c) & 0x00ff00ff) * (a)) >> 8) & 0x00ff00ff) )
#define LOOP_ALIGNED_U1_A4(DEST, LENGTH, UOP, A4OP) \
{ \
while((uintptr_t)DEST & 0xF && LENGTH) UOP \
\
while(LENGTH) { \
switch(LENGTH) { \
case 3: \
case 2: \
case 1: \
UOP \
break; \
default: \
A4OP \
break; \
} \
} \
}
static inline int
alpha_inverse(uint32_t color)
{
color = ~color;
return A_VAL(&color);
}
RGBA_Comp_Func_Solid func_for_mode_solid[EFL_GFX_RENDER_OP_LAST];
RGBA_Comp_Func func_for_mode[EFL_GFX_RENDER_OP_LAST];
void efl_draw_sse2_init(void);
void efl_draw_neon_init(void);
#endif