forked from enlightenment/efl
efl: rename namespace Graphics to Gfx.
This commit is contained in:
parent
dfd40467fc
commit
c000ee8099
|
@ -5,10 +5,10 @@ efl_eolian_files = \
|
|||
lib/efl/interfaces/efl_player.eo \
|
||||
lib/efl/interfaces/efl_text.eo \
|
||||
lib/efl/interfaces/efl_text_properties.eo \
|
||||
lib/efl/interfaces/efl_graphics_shape.eo \
|
||||
lib/efl/interfaces/efl_graphics_gradient.eo \
|
||||
lib/efl/interfaces/efl_graphics_gradient_linear.eo \
|
||||
lib/efl/interfaces/efl_graphics_gradient_radial.eo
|
||||
lib/efl/interfaces/efl_gfx_shape.eo \
|
||||
lib/efl/interfaces/efl_gfx_gradient.eo \
|
||||
lib/efl/interfaces/efl_gfx_gradient_linear.eo \
|
||||
lib/efl/interfaces/efl_gfx_gradient_radial.eo
|
||||
|
||||
efl_eolian_files_h = $(efl_eolian_files:%.eo=%.eo.h)
|
||||
efl_eolian_files_c = $(efl_eolian_files:%.eo=%.eo.c)
|
||||
|
@ -24,7 +24,7 @@ CLEANFILES += \
|
|||
EXTRA_DIST += \
|
||||
lib/efl/Efl_Config.h \
|
||||
lib/efl/Efl.h \
|
||||
lib/efl/interfaces/efl_graphics_utils.h \
|
||||
lib/efl/interfaces/efl_gfx_utils.h \
|
||||
$(efl_eolian_files)
|
||||
|
||||
efleolianfilesdir = $(datadir)/eolian/include/efl-@VMAJ@
|
||||
|
@ -34,7 +34,7 @@ lib_LTLIBRARIES += lib/efl/libefl.la
|
|||
|
||||
lib_efl_libefl_la_SOURCES = \
|
||||
lib/efl/interfaces/efl_interfaces_main.c \
|
||||
lib/efl/interfaces/efl_graphics_utils.c
|
||||
lib/efl/interfaces/efl_gfx_utils.c
|
||||
|
||||
lib_efl_libefl_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl -I$(top_srcdir)/src/lib/efl @EFL_CFLAGS@
|
||||
lib_efl_libefl_la_LIBADD = @EFL_LIBS@
|
||||
|
@ -49,7 +49,7 @@ dist_installed_eflheaders_DATA = \
|
|||
installed_eflinterfacesdir = $(includedir)/efl-@VMAJ@/interfaces
|
||||
nodist_installed_eflinterfaces_DATA = \
|
||||
$(efl_eolian_files_h) \
|
||||
lib/efl/interfaces/efl_graphics_utils.h
|
||||
lib/efl/interfaces/efl_gfx_utils.h
|
||||
|
||||
if HAVE_ELUA
|
||||
|
||||
|
|
|
@ -116,7 +116,7 @@ _ector_renderer_cairo_gradient_linear_eo_base_destructor(Eo *obj,
|
|||
}
|
||||
|
||||
void
|
||||
_ector_renderer_cairo_gradient_linear_efl_graphics_gradient_stop_set(Eo *obj, Ector_Renderer_Cairo_Gradient_Linear_Data *pd, const Efl_Graphics_Gradient_Stop *colors, unsigned int length)
|
||||
_ector_renderer_cairo_gradient_linear_efl_gfx_gradient_stop_set(Eo *obj, Ector_Renderer_Cairo_Gradient_Linear_Data *pd, const Efl_Gfx_Gradient_Stop *colors, unsigned int length)
|
||||
{
|
||||
USE(obj, cairo_pattern_destroy, );
|
||||
|
||||
|
@ -124,7 +124,7 @@ _ector_renderer_cairo_gradient_linear_efl_graphics_gradient_stop_set(Eo *obj, Ec
|
|||
pd->pat = NULL;
|
||||
|
||||
eo_do_super(obj, ECTOR_RENDERER_CAIRO_GRADIENT_LINEAR_CLASS,
|
||||
efl_graphics_gradient_stop_set(colors, length));
|
||||
efl_gfx_gradient_stop_set(colors, length));
|
||||
}
|
||||
|
||||
#include "ector_renderer_cairo_gradient_linear.eo.c"
|
||||
|
|
|
@ -7,6 +7,6 @@ class Ector.Renderer.Cairo.Gradient_Linear (Ector.Renderer.Cairo.Base, Ector.Ren
|
|||
Ector.Renderer.Generic.Base.draw;
|
||||
Ector.Renderer.Cairo.Base.fill;
|
||||
Eo.Base.destructor;
|
||||
Efl.Graphics.Gradient.stop.set;
|
||||
Efl.Gfx.Gradient.stop.set;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -118,7 +118,7 @@ _ector_renderer_cairo_gradient_radial_eo_base_destructor(Eo *obj,
|
|||
}
|
||||
|
||||
void
|
||||
_ector_renderer_cairo_gradient_radial_efl_graphics_gradient_stop_set(Eo *obj, Ector_Renderer_Cairo_Gradient_Radial_Data *pd, const Efl_Graphics_Gradient_Stop *colors, unsigned int length)
|
||||
_ector_renderer_cairo_gradient_radial_efl_gfx_gradient_stop_set(Eo *obj, Ector_Renderer_Cairo_Gradient_Radial_Data *pd, const Efl_Gfx_Gradient_Stop *colors, unsigned int length)
|
||||
{
|
||||
USE(obj, cairo_pattern_destroy, );
|
||||
|
||||
|
@ -126,7 +126,7 @@ _ector_renderer_cairo_gradient_radial_efl_graphics_gradient_stop_set(Eo *obj, Ec
|
|||
pd->pat = NULL;
|
||||
|
||||
eo_do_super(obj, ECTOR_RENDERER_CAIRO_GRADIENT_LINEAR_CLASS,
|
||||
efl_graphics_gradient_stop_set(colors, length));
|
||||
efl_gfx_gradient_stop_set(colors, length));
|
||||
}
|
||||
|
||||
#include "ector_renderer_cairo_gradient_radial.eo.c"
|
||||
|
|
|
@ -7,6 +7,6 @@ class Ector.Renderer.Cairo.Gradient_Radial (Ector.Renderer.Cairo.Base, Ector.Ren
|
|||
Ector.Renderer.Generic.Base.draw;
|
||||
Ector.Renderer.Cairo.Base.fill;
|
||||
Eo.Base.destructor;
|
||||
Efl.Graphics.Gradient.stop.set;
|
||||
Efl.Gfx.Gradient.stop.set;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,25 +78,25 @@ _ector_renderer_cairo_shape_ector_renderer_generic_base_prepare(Eo *obj, Ector_R
|
|||
cairo_new_path(pd->parent->cairo);
|
||||
|
||||
pts = pd->shape->path.pts;
|
||||
for (i = 0; pd->shape->path.cmd[i] != EFL_GRAPHICS_PATH_COMMAND_TYPE_END; i++)
|
||||
for (i = 0; pd->shape->path.cmd[i] != EFL_GFX_PATH_COMMAND_TYPE_END; i++)
|
||||
{
|
||||
switch (pd->shape->path.cmd[i])
|
||||
{
|
||||
case EFL_GRAPHICS_PATH_COMMAND_TYPE_MOVE_TO:
|
||||
case EFL_GFX_PATH_COMMAND_TYPE_MOVE_TO:
|
||||
USE(obj, cairo_move_to, EINA_FALSE);
|
||||
|
||||
cairo_move_to(pd->parent->cairo, pts[0], pts[1]);
|
||||
|
||||
pts += 2;
|
||||
break;
|
||||
case EFL_GRAPHICS_PATH_COMMAND_TYPE_LINE_TO:
|
||||
case EFL_GFX_PATH_COMMAND_TYPE_LINE_TO:
|
||||
USE(obj, cairo_line_to, EINA_FALSE);
|
||||
|
||||
cairo_line_to(pd->parent->cairo, pts[0], pts[1]);
|
||||
|
||||
pts += 2;
|
||||
break;
|
||||
case EFL_GRAPHICS_PATH_COMMAND_TYPE_CUBIC_TO:
|
||||
case EFL_GFX_PATH_COMMAND_TYPE_CUBIC_TO:
|
||||
USE(obj, cairo_curve_to, EINA_FALSE);
|
||||
|
||||
// Be careful, we do have a different order than
|
||||
|
@ -108,13 +108,13 @@ _ector_renderer_cairo_shape_ector_renderer_generic_base_prepare(Eo *obj, Ector_R
|
|||
|
||||
pts += 6;
|
||||
break;
|
||||
case EFL_GRAPHICS_PATH_COMMAND_TYPE_CLOSE:
|
||||
case EFL_GFX_PATH_COMMAND_TYPE_CLOSE:
|
||||
USE(obj, cairo_close_path, EINA_FALSE);
|
||||
|
||||
cairo_close_path(pd->parent->cairo);
|
||||
break;
|
||||
case EFL_GRAPHICS_PATH_COMMAND_TYPE_LAST:
|
||||
case EFL_GRAPHICS_PATH_COMMAND_TYPE_END:
|
||||
case EFL_GFX_PATH_COMMAND_TYPE_LAST:
|
||||
case EFL_GFX_PATH_COMMAND_TYPE_END:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ _ector_renderer_cairo_shape_efl_gfx_shape_path_set(Eo *obj, Ector_Renderer_Cairo
|
|||
if (pd->path) cairo_path_destroy(pd->path);
|
||||
pd->path = NULL;
|
||||
|
||||
eo_do_super(obj, ECTOR_RENDERER_CAIRO_SHAPE_CLASS, efl_graphics_shape_path_set(op, points));
|
||||
eo_do_super(obj, ECTOR_RENDERER_CAIRO_SHAPE_CLASS, efl_gfx_shape_path_set(op, points));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ class Ector.Renderer.Cairo.Shape (Ector.Renderer.Cairo.Base, Ector.Renderer.Gene
|
|||
Ector.Renderer.Generic.Base.prepare;
|
||||
Ector.Renderer.Generic.Base.draw;
|
||||
Ector.Renderer.Cairo.Base.fill;
|
||||
Efl.Graphics.Shape.path.set;
|
||||
Efl.Gfx.Shape.path.set;
|
||||
Eo.Base.constructor;
|
||||
Eo.Base.destructor;
|
||||
}
|
||||
|
|
|
@ -72,10 +72,10 @@ struct _Ector_Renderer_Generic_Base_Data
|
|||
|
||||
struct _Ector_Renderer_Generic_Gradient_Data
|
||||
{
|
||||
Efl_Graphics_Gradient_Stop *colors;
|
||||
Efl_Gfx_Gradient_Stop *colors;
|
||||
unsigned int colors_count;
|
||||
|
||||
Efl_Graphics_Gradient_Spread s;
|
||||
Efl_Gfx_Gradient_Spread s;
|
||||
};
|
||||
|
||||
struct _Ector_Renderer_Generic_Gradient_Linear_Data
|
||||
|
@ -96,7 +96,7 @@ struct _Ector_Renderer_Generic_Gradient_Radial_Data
|
|||
struct _Ector_Renderer_Generic_Shape_Data
|
||||
{
|
||||
struct {
|
||||
Efl_Graphics_Path_Command *cmd;
|
||||
Efl_Gfx_Path_Command *cmd;
|
||||
double *pts;
|
||||
} path;
|
||||
|
||||
|
@ -113,11 +113,11 @@ struct _Ector_Renderer_Generic_Shape_Data
|
|||
int r, g, b, a;
|
||||
} color;
|
||||
|
||||
Efl_Graphics_Dash *dash;
|
||||
Efl_Gfx_Dash *dash;
|
||||
unsigned int dash_length;
|
||||
|
||||
Efl_Graphics_Cap cap;
|
||||
Efl_Graphics_Cap join;
|
||||
Efl_Gfx_Cap cap;
|
||||
Efl_Gfx_Cap join;
|
||||
} stroke;
|
||||
};
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
abstract Ector.Renderer.Generic.Gradient (Ector.Renderer.Generic.Base, Efl.Graphics.Gradient)
|
||||
abstract Ector.Renderer.Generic.Gradient (Ector.Renderer.Generic.Base, Efl.Gfx.Gradient)
|
||||
{
|
||||
eo_prefix: ector_renderer_gradient;
|
||||
legacy_prefix: null;
|
||||
implements {
|
||||
Efl.Graphics.Gradient.stop.set;
|
||||
Efl.Graphics.Gradient.stop.get;
|
||||
Efl.Graphics.Gradient.spread.set;
|
||||
Efl.Graphics.Gradient.spread.get;
|
||||
Efl.Gfx.Gradient.stop.set;
|
||||
Efl.Gfx.Gradient.stop.get;
|
||||
Efl.Gfx.Gradient.spread.set;
|
||||
Efl.Gfx.Gradient.spread.get;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
abstract Ector.Renderer.Generic.Gradient_Linear (Ector.Renderer.Generic.Gradient, Efl.Graphics.Gradient_Linear)
|
||||
abstract Ector.Renderer.Generic.Gradient_Linear (Ector.Renderer.Generic.Gradient, Efl.Gfx.Gradient_Linear)
|
||||
{
|
||||
eo_prefix: ector_renderer_gradient_linear;
|
||||
legacy_prefix: null;
|
||||
implements {
|
||||
Efl.Graphics.Gradient_Linear.start.set;
|
||||
Efl.Graphics.Gradient_Linear.start.get;
|
||||
Efl.Graphics.Gradient_Linear.end.set;
|
||||
Efl.Graphics.Gradient_Linear.end.get;
|
||||
Efl.Gfx.Gradient_Linear.start.set;
|
||||
Efl.Gfx.Gradient_Linear.start.get;
|
||||
Efl.Gfx.Gradient_Linear.end.set;
|
||||
Efl.Gfx.Gradient_Linear.end.get;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
abstract Ector.Renderer.Generic.Gradient_Radial (Ector.Renderer.Generic.Gradient, Efl.Graphics.Gradient_Radial)
|
||||
abstract Ector.Renderer.Generic.Gradient_Radial (Ector.Renderer.Generic.Gradient, Efl.Gfx.Gradient_Radial)
|
||||
{
|
||||
eo_prefix: ector_renderer_gradient_radial;
|
||||
legacy_prefix: null;
|
||||
implements {
|
||||
Efl.Graphics.Gradient_Radial.center.set;
|
||||
Efl.Graphics.Gradient_Radial.center.get;
|
||||
Efl.Graphics.Gradient_Radial.radius.set;
|
||||
Efl.Graphics.Gradient_Radial.radius.get;
|
||||
Efl.Graphics.Gradient_Radial.focal.set;
|
||||
Efl.Graphics.Gradient_Radial.focal.get;
|
||||
Efl.Gfx.Gradient_Radial.center.set;
|
||||
Efl.Gfx.Gradient_Radial.center.get;
|
||||
Efl.Gfx.Gradient_Radial.radius.set;
|
||||
Efl.Gfx.Gradient_Radial.radius.get;
|
||||
Efl.Gfx.Gradient_Radial.focal.set;
|
||||
Efl.Gfx.Gradient_Radial.focal.get;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class Ector.Renderer.Generic.Shape (Ector.Renderer.Generic.Base, Efl.Graphics.Shape)
|
||||
class Ector.Renderer.Generic.Shape (Ector.Renderer.Generic.Base, Efl.Gfx.Shape)
|
||||
{
|
||||
eo_prefix: ector_renderer_shape;
|
||||
legacy_prefix: null;
|
||||
|
@ -32,14 +32,14 @@ class Ector.Renderer.Generic.Shape (Ector.Renderer.Generic.Base, Efl.Graphics.Sh
|
|||
}
|
||||
}
|
||||
implements {
|
||||
Efl.Graphics.Shape.stroke_scale;
|
||||
Efl.Graphics.Shape.stroke_color;
|
||||
Efl.Graphics.Shape.stroke_width;
|
||||
Efl.Graphics.Shape.stroke_location;
|
||||
Efl.Graphics.Shape.stroke_dash;
|
||||
Efl.Graphics.Shape.stroke_cap;
|
||||
Efl.Graphics.Shape.stroke_join;
|
||||
Efl.Graphics.Shape.path;
|
||||
Efl.Gfx.Shape.stroke_scale;
|
||||
Efl.Gfx.Shape.stroke_color;
|
||||
Efl.Gfx.Shape.stroke_width;
|
||||
Efl.Gfx.Shape.stroke_location;
|
||||
Efl.Gfx.Shape.stroke_dash;
|
||||
Efl.Gfx.Shape.stroke_cap;
|
||||
Efl.Gfx.Shape.stroke_join;
|
||||
Efl.Gfx.Shape.path;
|
||||
Eo.Base.constructor;
|
||||
Eo.Base.destructor;
|
||||
}
|
||||
|
|
|
@ -8,43 +8,43 @@
|
|||
#include "ector_private.h"
|
||||
|
||||
static void
|
||||
_ector_renderer_generic_gradient_efl_graphics_gradient_stop_set(Eo *obj,
|
||||
Ector_Renderer_Generic_Gradient_Data *pd,
|
||||
const Efl_Graphics_Gradient_Stop *colors,
|
||||
unsigned int length)
|
||||
_ector_renderer_generic_gradient_efl_gfx_gradient_stop_set(Eo *obj,
|
||||
Ector_Renderer_Generic_Gradient_Data *pd,
|
||||
const Efl_Gfx_Gradient_Stop *colors,
|
||||
unsigned int length)
|
||||
{
|
||||
pd->colors = realloc(pd->colors, length * sizeof(Efl_Graphics_Gradient_Stop));
|
||||
pd->colors = realloc(pd->colors, length * sizeof(Efl_Gfx_Gradient_Stop));
|
||||
if (!pd->colors)
|
||||
{
|
||||
pd->colors_count = 0;
|
||||
return ;
|
||||
}
|
||||
|
||||
memcpy(pd->colors, colors, length * sizeof(Efl_Graphics_Gradient_Stop));
|
||||
memcpy(pd->colors, colors, length * sizeof(Efl_Gfx_Gradient_Stop));
|
||||
pd->colors_count = length;
|
||||
}
|
||||
|
||||
static void
|
||||
_ector_renderer_generic_gradient_efl_graphics_gradient_stop_get(Eo *obj,
|
||||
Ector_Renderer_Generic_Gradient_Data *pd,
|
||||
const Efl_Graphics_Gradient_Stop **colors,
|
||||
unsigned int *length)
|
||||
_ector_renderer_generic_gradient_efl_gfx_gradient_stop_get(Eo *obj,
|
||||
Ector_Renderer_Generic_Gradient_Data *pd,
|
||||
const Efl_Gfx_Gradient_Stop **colors,
|
||||
unsigned int *length)
|
||||
{
|
||||
if (colors) *colors = pd->colors;
|
||||
if (length) *length = pd->colors_count;
|
||||
}
|
||||
|
||||
static void
|
||||
_ector_renderer_generic_gradient_efl_graphics_gradient_spread_set(Eo *obj,
|
||||
Ector_Renderer_Generic_Gradient_Data *pd,
|
||||
Efl_Graphics_Gradient_Spread s)
|
||||
_ector_renderer_generic_gradient_efl_gfx_gradient_spread_set(Eo *obj,
|
||||
Ector_Renderer_Generic_Gradient_Data *pd,
|
||||
Efl_Gfx_Gradient_Spread s)
|
||||
{
|
||||
pd->s = s;
|
||||
}
|
||||
|
||||
static Efl_Graphics_Gradient_Spread
|
||||
_ector_renderer_generic_gradient_efl_graphics_gradient_spread_get(Eo *obj,
|
||||
Ector_Renderer_Generic_Gradient_Data *pd)
|
||||
static Efl_Gfx_Gradient_Spread
|
||||
_ector_renderer_generic_gradient_efl_gfx_gradient_spread_get(Eo *obj,
|
||||
Ector_Renderer_Generic_Gradient_Data *pd)
|
||||
{
|
||||
return pd->s;
|
||||
}
|
||||
|
|
|
@ -8,36 +8,36 @@
|
|||
#include "ector_private.h"
|
||||
|
||||
static void
|
||||
_ector_renderer_generic_gradient_linear_efl_graphics_gradient_linear_start_set(Eo *obj EINA_UNUSED,
|
||||
Ector_Renderer_Generic_Gradient_Linear_Data *pd,
|
||||
double x, double y)
|
||||
_ector_renderer_generic_gradient_linear_efl_gfx_gradient_linear_start_set(Eo *obj EINA_UNUSED,
|
||||
Ector_Renderer_Generic_Gradient_Linear_Data *pd,
|
||||
double x, double y)
|
||||
{
|
||||
pd->start.x = x;
|
||||
pd->start.y = y;
|
||||
}
|
||||
|
||||
static void
|
||||
_ector_renderer_generic_gradient_linear_efl_graphics_gradient_linear_start_get(Eo *obj EINA_UNUSED,
|
||||
Ector_Renderer_Generic_Gradient_Linear_Data *pd,
|
||||
double *x, double *y)
|
||||
_ector_renderer_generic_gradient_linear_efl_gfx_gradient_linear_start_get(Eo *obj EINA_UNUSED,
|
||||
Ector_Renderer_Generic_Gradient_Linear_Data *pd,
|
||||
double *x, double *y)
|
||||
{
|
||||
if (x) *x = pd->start.x;
|
||||
if (y) *y = pd->start.y;
|
||||
}
|
||||
|
||||
static void
|
||||
_ector_renderer_generic_gradient_linear_efl_graphics_gradient_linear_end_set(Eo *obj EINA_UNUSED,
|
||||
Ector_Renderer_Generic_Gradient_Linear_Data *pd,
|
||||
double x, double y)
|
||||
_ector_renderer_generic_gradient_linear_efl_gfx_gradient_linear_end_set(Eo *obj EINA_UNUSED,
|
||||
Ector_Renderer_Generic_Gradient_Linear_Data *pd,
|
||||
double x, double y)
|
||||
{
|
||||
pd->end.x = x;
|
||||
pd->end.y = y;
|
||||
}
|
||||
|
||||
static void
|
||||
_ector_renderer_generic_gradient_linear_efl_graphics_gradient_linear_end_get(Eo *obj EINA_UNUSED,
|
||||
Ector_Renderer_Generic_Gradient_Linear_Data *pd,
|
||||
double *x, double *y)
|
||||
_ector_renderer_generic_gradient_linear_efl_gfx_gradient_linear_end_get(Eo *obj EINA_UNUSED,
|
||||
Ector_Renderer_Generic_Gradient_Linear_Data *pd,
|
||||
double *x, double *y)
|
||||
{
|
||||
if (x) *x = pd->end.x;
|
||||
if (y) *y = pd->end.y;
|
||||
|
|
|
@ -8,52 +8,52 @@
|
|||
#include "ector_private.h"
|
||||
|
||||
static void
|
||||
_ector_renderer_generic_gradient_radial_efl_graphics_gradient_radial_center_set(Eo *obj EINA_UNUSED,
|
||||
Ector_Renderer_Generic_Gradient_Radial_Data *pd,
|
||||
double x, double y)
|
||||
_ector_renderer_generic_gradient_radial_efl_gfx_gradient_radial_center_set(Eo *obj EINA_UNUSED,
|
||||
Ector_Renderer_Generic_Gradient_Radial_Data *pd,
|
||||
double x, double y)
|
||||
{
|
||||
pd->radial.x = x;
|
||||
pd->radial.y = y;
|
||||
}
|
||||
|
||||
static void
|
||||
_ector_renderer_generic_gradient_radial_efl_graphics_gradient_radial_center_get(Eo *obj EINA_UNUSED,
|
||||
Ector_Renderer_Generic_Gradient_Radial_Data *pd,
|
||||
double *x, double *y)
|
||||
_ector_renderer_generic_gradient_radial_efl_gfx_gradient_radial_center_get(Eo *obj EINA_UNUSED,
|
||||
Ector_Renderer_Generic_Gradient_Radial_Data *pd,
|
||||
double *x, double *y)
|
||||
{
|
||||
if (x) *x = pd->radial.x;
|
||||
if (y) *y = pd->radial.y;
|
||||
}
|
||||
|
||||
static void
|
||||
_ector_renderer_generic_gradient_radial_efl_graphics_gradient_radial_radius_set(Eo *obj EINA_UNUSED,
|
||||
Ector_Renderer_Generic_Gradient_Radial_Data *pd,
|
||||
double r)
|
||||
_ector_renderer_generic_gradient_radial_efl_gfx_gradient_radial_radius_set(Eo *obj EINA_UNUSED,
|
||||
Ector_Renderer_Generic_Gradient_Radial_Data *pd,
|
||||
double r)
|
||||
{
|
||||
pd->radius = r;
|
||||
}
|
||||
|
||||
static double
|
||||
_ector_renderer_generic_gradient_radial_efl_graphics_gradient_radial_radius_get(Eo *obj EINA_UNUSED,
|
||||
Ector_Renderer_Generic_Gradient_Radial_Data *pd)
|
||||
_ector_renderer_generic_gradient_radial_efl_gfx_gradient_radial_radius_get(Eo *obj EINA_UNUSED,
|
||||
Ector_Renderer_Generic_Gradient_Radial_Data *pd)
|
||||
{
|
||||
return pd->radius;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
_ector_renderer_generic_gradient_radial_efl_graphics_gradient_radial_focal_set(Eo *obj EINA_UNUSED,
|
||||
Ector_Renderer_Generic_Gradient_Radial_Data *pd,
|
||||
double x, double y)
|
||||
_ector_renderer_generic_gradient_radial_efl_gfx_gradient_radial_focal_set(Eo *obj EINA_UNUSED,
|
||||
Ector_Renderer_Generic_Gradient_Radial_Data *pd,
|
||||
double x, double y)
|
||||
{
|
||||
pd->focal.x = x;
|
||||
pd->focal.y = y;
|
||||
}
|
||||
|
||||
static void
|
||||
_ector_renderer_generic_gradient_radial_efl_graphics_gradient_radial_focal_get(Eo *obj EINA_UNUSED,
|
||||
Ector_Renderer_Generic_Gradient_Radial_Data *pd,
|
||||
double *x, double *y)
|
||||
_ector_renderer_generic_gradient_radial_efl_gfx_gradient_radial_focal_get(Eo *obj EINA_UNUSED,
|
||||
Ector_Renderer_Generic_Gradient_Radial_Data *pd,
|
||||
double *x, double *y)
|
||||
{
|
||||
if (x) *x = pd->focal.x;
|
||||
if (y) *y = pd->focal.y;
|
||||
|
|
|
@ -53,24 +53,24 @@ _ector_renderer_generic_shape_stroke_marker_get(Eo *obj EINA_UNUSED,
|
|||
}
|
||||
|
||||
static void
|
||||
_ector_renderer_generic_shape_efl_graphics_shape_stroke_scale_set(Eo *obj EINA_UNUSED,
|
||||
Ector_Renderer_Generic_Shape_Data *pd,
|
||||
double s)
|
||||
_ector_renderer_generic_shape_efl_gfx_shape_stroke_scale_set(Eo *obj EINA_UNUSED,
|
||||
Ector_Renderer_Generic_Shape_Data *pd,
|
||||
double s)
|
||||
{
|
||||
pd->stroke.scale = s;
|
||||
}
|
||||
|
||||
static double
|
||||
_ector_renderer_generic_shape_efl_graphics_shape_stroke_scale_get(Eo *obj EINA_UNUSED,
|
||||
Ector_Renderer_Generic_Shape_Data *pd)
|
||||
_ector_renderer_generic_shape_efl_gfx_shape_stroke_scale_get(Eo *obj EINA_UNUSED,
|
||||
Ector_Renderer_Generic_Shape_Data *pd)
|
||||
{
|
||||
return pd->stroke.scale;
|
||||
}
|
||||
|
||||
static void
|
||||
_ector_renderer_generic_shape_efl_graphics_shape_stroke_color_set(Eo *obj EINA_UNUSED,
|
||||
Ector_Renderer_Generic_Shape_Data *pd,
|
||||
int r, int g, int b, int a)
|
||||
_ector_renderer_generic_shape_efl_gfx_shape_stroke_color_set(Eo *obj EINA_UNUSED,
|
||||
Ector_Renderer_Generic_Shape_Data *pd,
|
||||
int r, int g, int b, int a)
|
||||
{
|
||||
pd->stroke.color.r = r;
|
||||
pd->stroke.color.g = g;
|
||||
|
@ -79,9 +79,9 @@ _ector_renderer_generic_shape_efl_graphics_shape_stroke_color_set(Eo *obj EINA_U
|
|||
}
|
||||
|
||||
static void
|
||||
_ector_renderer_generic_shape_efl_graphics_shape_stroke_color_get(Eo *obj EINA_UNUSED,
|
||||
Ector_Renderer_Generic_Shape_Data *pd,
|
||||
int *r, int *g, int *b, int *a)
|
||||
_ector_renderer_generic_shape_efl_gfx_shape_stroke_color_get(Eo *obj EINA_UNUSED,
|
||||
Ector_Renderer_Generic_Shape_Data *pd,
|
||||
int *r, int *g, int *b, int *a)
|
||||
{
|
||||
if (r) *r = pd->stroke.color.r;
|
||||
if (g) *g = pd->stroke.color.g;
|
||||
|
@ -90,42 +90,42 @@ _ector_renderer_generic_shape_efl_graphics_shape_stroke_color_get(Eo *obj EINA_U
|
|||
}
|
||||
|
||||
static void
|
||||
_ector_renderer_generic_shape_efl_graphics_shape_stroke_width_set(Eo *obj EINA_UNUSED,
|
||||
Ector_Renderer_Generic_Shape_Data *pd,
|
||||
double w)
|
||||
_ector_renderer_generic_shape_efl_gfx_shape_stroke_width_set(Eo *obj EINA_UNUSED,
|
||||
Ector_Renderer_Generic_Shape_Data *pd,
|
||||
double w)
|
||||
{
|
||||
pd->stroke.width = w;
|
||||
}
|
||||
|
||||
static double
|
||||
_ector_renderer_generic_shape_efl_graphics_shape_stroke_width_get(Eo *obj EINA_UNUSED,
|
||||
Ector_Renderer_Generic_Shape_Data *pd)
|
||||
_ector_renderer_generic_shape_efl_gfx_shape_stroke_width_get(Eo *obj EINA_UNUSED,
|
||||
Ector_Renderer_Generic_Shape_Data *pd)
|
||||
{
|
||||
return pd->stroke.width;
|
||||
}
|
||||
|
||||
static void
|
||||
_ector_renderer_generic_shape_efl_graphics_shape_stroke_location_set(Eo *obj EINA_UNUSED,
|
||||
Ector_Renderer_Generic_Shape_Data *pd,
|
||||
double centered)
|
||||
_ector_renderer_generic_shape_efl_gfx_shape_stroke_location_set(Eo *obj EINA_UNUSED,
|
||||
Ector_Renderer_Generic_Shape_Data *pd,
|
||||
double centered)
|
||||
{
|
||||
pd->stroke.centered = centered;
|
||||
}
|
||||
|
||||
static double
|
||||
_ector_renderer_generic_shape_efl_graphics_shape_stroke_location_get(Eo *obj EINA_UNUSED,
|
||||
Ector_Renderer_Generic_Shape_Data *pd)
|
||||
_ector_renderer_generic_shape_efl_gfx_shape_stroke_location_get(Eo *obj EINA_UNUSED,
|
||||
Ector_Renderer_Generic_Shape_Data *pd)
|
||||
{
|
||||
return pd->stroke.centered;
|
||||
}
|
||||
|
||||
static void
|
||||
_ector_renderer_generic_shape_efl_graphics_shape_stroke_dash_set(Eo *obj EINA_UNUSED,
|
||||
Ector_Renderer_Generic_Shape_Data *pd,
|
||||
const Efl_Graphics_Dash *dash,
|
||||
unsigned int length)
|
||||
_ector_renderer_generic_shape_efl_gfx_shape_stroke_dash_set(Eo *obj EINA_UNUSED,
|
||||
Ector_Renderer_Generic_Shape_Data *pd,
|
||||
const Efl_Gfx_Dash *dash,
|
||||
unsigned int length)
|
||||
{
|
||||
Efl_Graphics_Dash *tmp;
|
||||
Efl_Gfx_Dash *tmp;
|
||||
|
||||
if (!dash)
|
||||
{
|
||||
|
@ -135,73 +135,73 @@ _ector_renderer_generic_shape_efl_graphics_shape_stroke_dash_set(Eo *obj EINA_UN
|
|||
return ;
|
||||
}
|
||||
|
||||
tmp = realloc(pd->stroke.dash, length * sizeof (Efl_Graphics_Dash));
|
||||
tmp = realloc(pd->stroke.dash, length * sizeof (Efl_Gfx_Dash));
|
||||
if (!tmp) return ;
|
||||
memcpy(tmp, dash, length * sizeof (Efl_Graphics_Dash));
|
||||
memcpy(tmp, dash, length * sizeof (Efl_Gfx_Dash));
|
||||
|
||||
pd->stroke.dash = tmp;
|
||||
pd->stroke.dash_length = length;
|
||||
}
|
||||
|
||||
static void
|
||||
_ector_renderer_generic_shape_efl_graphics_shape_stroke_dash_get(Eo *obj EINA_UNUSED,
|
||||
Ector_Renderer_Generic_Shape_Data *pd,
|
||||
const Efl_Graphics_Dash **dash,
|
||||
unsigned int *length)
|
||||
_ector_renderer_generic_shape_efl_gfx_shape_stroke_dash_get(Eo *obj EINA_UNUSED,
|
||||
Ector_Renderer_Generic_Shape_Data *pd,
|
||||
const Efl_Gfx_Dash **dash,
|
||||
unsigned int *length)
|
||||
{
|
||||
if (dash) *dash = pd->stroke.dash;
|
||||
if (length) *length = pd->stroke.dash_length;
|
||||
}
|
||||
|
||||
static void
|
||||
_ector_renderer_generic_shape_efl_graphics_shape_stroke_cap_set(Eo *obj EINA_UNUSED,
|
||||
Ector_Renderer_Generic_Shape_Data *pd,
|
||||
Efl_Graphics_Cap c)
|
||||
_ector_renderer_generic_shape_efl_gfx_shape_stroke_cap_set(Eo *obj EINA_UNUSED,
|
||||
Ector_Renderer_Generic_Shape_Data *pd,
|
||||
Efl_Gfx_Cap c)
|
||||
{
|
||||
pd->stroke.cap = c;
|
||||
}
|
||||
|
||||
static Efl_Graphics_Cap
|
||||
_ector_renderer_generic_shape_efl_graphics_shape_stroke_cap_get(Eo *obj EINA_UNUSED,
|
||||
Ector_Renderer_Generic_Shape_Data *pd)
|
||||
static Efl_Gfx_Cap
|
||||
_ector_renderer_generic_shape_efl_gfx_shape_stroke_cap_get(Eo *obj EINA_UNUSED,
|
||||
Ector_Renderer_Generic_Shape_Data *pd)
|
||||
{
|
||||
return pd->stroke.cap;
|
||||
}
|
||||
|
||||
static void
|
||||
_ector_renderer_generic_shape_efl_graphics_shape_stroke_join_set(Eo *obj EINA_UNUSED,
|
||||
Ector_Renderer_Generic_Shape_Data *pd,
|
||||
Efl_Graphics_Join j)
|
||||
_ector_renderer_generic_shape_efl_gfx_shape_stroke_join_set(Eo *obj EINA_UNUSED,
|
||||
Ector_Renderer_Generic_Shape_Data *pd,
|
||||
Efl_Gfx_Join j)
|
||||
{
|
||||
pd->stroke.join = j;
|
||||
}
|
||||
|
||||
static Efl_Graphics_Join
|
||||
_ector_renderer_generic_shape_efl_graphics_shape_stroke_join_get(Eo *obj EINA_UNUSED,
|
||||
Ector_Renderer_Generic_Shape_Data *pd)
|
||||
static Efl_Gfx_Join
|
||||
_ector_renderer_generic_shape_efl_gfx_shape_stroke_join_get(Eo *obj EINA_UNUSED,
|
||||
Ector_Renderer_Generic_Shape_Data *pd)
|
||||
{
|
||||
return pd->stroke.join;
|
||||
}
|
||||
|
||||
static void
|
||||
_ector_renderer_generic_shape_efl_graphics_shape_path_set(Eo *obj EINA_UNUSED,
|
||||
Ector_Renderer_Generic_Shape_Data *pd,
|
||||
const Efl_Graphics_Path_Command *cmd,
|
||||
const double *points)
|
||||
_ector_renderer_generic_shape_efl_gfx_shape_path_set(Eo *obj EINA_UNUSED,
|
||||
Ector_Renderer_Generic_Shape_Data *pd,
|
||||
const Efl_Gfx_Path_Command *cmd,
|
||||
const double *points)
|
||||
{
|
||||
free(pd->path.cmd);
|
||||
pd->path.cmd = NULL;
|
||||
free(pd->path.pts);
|
||||
pd->path.pts = NULL;
|
||||
|
||||
efl_graphics_path_dup(&pd->path.cmd, &pd->path.pts, cmd, points);
|
||||
efl_gfx_path_dup(&pd->path.cmd, &pd->path.pts, cmd, points);
|
||||
}
|
||||
|
||||
void
|
||||
_ector_renderer_generic_shape_efl_graphics_shape_path_get(Eo *obj EINA_UNUSED,
|
||||
Ector_Renderer_Generic_Shape_Data *pd,
|
||||
const Efl_Graphics_Path_Command **op,
|
||||
const double **points)
|
||||
_ector_renderer_generic_shape_efl_gfx_shape_path_get(Eo *obj EINA_UNUSED,
|
||||
Ector_Renderer_Generic_Shape_Data *pd,
|
||||
const Efl_Gfx_Path_Command **op,
|
||||
const double **points)
|
||||
{
|
||||
if (op) *op = pd->path.cmd;
|
||||
if (points) *points = pd->path.pts;
|
||||
|
|
|
@ -38,24 +38,24 @@ extern "C"
|
|||
* Path command enum.
|
||||
*
|
||||
* @since 1.13
|
||||
* @ingroup Efl_Graphics_Shape
|
||||
* @ingroup Efl_Gfx_Shape
|
||||
*/
|
||||
typedef enum _Efl_Graphics_Path_Command
|
||||
typedef enum _Efl_Gfx_Path_Command
|
||||
{
|
||||
EFL_GRAPHICS_PATH_COMMAND_TYPE_END = 0, /**< End of the stream of command */
|
||||
EFL_GRAPHICS_PATH_COMMAND_TYPE_MOVE_TO, /**< A move command type */
|
||||
EFL_GRAPHICS_PATH_COMMAND_TYPE_LINE_TO, /**< A line command type */
|
||||
EFL_GRAPHICS_PATH_COMMAND_TYPE_CUBIC_TO, /**< A cubic command type */
|
||||
EFL_GRAPHICS_PATH_COMMAND_TYPE_CLOSE, /**< A close command type */
|
||||
EFL_GRAPHICS_PATH_COMMAND_TYPE_LAST, /**< Not a valid command, but last one according to this version header */
|
||||
} Efl_Graphics_Path_Command;
|
||||
EFL_GFX_PATH_COMMAND_TYPE_END = 0, /**< End of the stream of command */
|
||||
EFL_GFX_PATH_COMMAND_TYPE_MOVE_TO, /**< A move command type */
|
||||
EFL_GFX_PATH_COMMAND_TYPE_LINE_TO, /**< A line command type */
|
||||
EFL_GFX_PATH_COMMAND_TYPE_CUBIC_TO, /**< A cubic command type */
|
||||
EFL_GFX_PATH_COMMAND_TYPE_CLOSE, /**< A close command type */
|
||||
EFL_GFX_PATH_COMMAND_TYPE_LAST, /**< Not a valid command, but last one according to this version header */
|
||||
} Efl_Gfx_Path_Command;
|
||||
|
||||
/**
|
||||
* Type describing dash
|
||||
* @since 1.13
|
||||
*/
|
||||
typedef struct _Efl_Graphics_Dash Efl_Graphics_Dash;
|
||||
struct _Efl_Graphics_Dash
|
||||
typedef struct _Efl_Gfx_Dash Efl_Gfx_Dash;
|
||||
struct _Efl_Gfx_Dash
|
||||
{
|
||||
double length;
|
||||
double gap;
|
||||
|
@ -65,32 +65,32 @@ struct _Efl_Graphics_Dash
|
|||
* Type defining how a line end.
|
||||
* @since 1.13
|
||||
*/
|
||||
typedef enum _Efl_Graphics_Cap
|
||||
typedef enum _Efl_Gfx_Cap
|
||||
{
|
||||
EFL_GRAPHICS_CAP_BUTT,
|
||||
EFL_GRAPHICS_CAP_ROUND,
|
||||
EFL_GRAPHICS_CAP_SQUARE,
|
||||
EFL_GRAPHICS_CAP_LAST
|
||||
} Efl_Graphics_Cap;
|
||||
EFL_GFX_CAP_BUTT,
|
||||
EFL_GFX_CAP_ROUND,
|
||||
EFL_GFX_CAP_SQUARE,
|
||||
EFL_GFX_CAP_LAST
|
||||
} Efl_Gfx_Cap;
|
||||
|
||||
/**
|
||||
* Type defining how join between path are drawn.
|
||||
* @since 1.13
|
||||
*/
|
||||
typedef enum _Efl_Graphics_Join
|
||||
typedef enum _Efl_Gfx_Join
|
||||
{
|
||||
EFL_GRAPHICS_JOIN_MITER,
|
||||
EFL_GRAPHICS_JOIN_ROUND,
|
||||
EFL_GRAPHICS_JOIN_BEVEL,
|
||||
EFL_GRAPHICS_JOIN_LAST
|
||||
} Efl_Graphics_Join;
|
||||
EFL_GFX_JOIN_MITER,
|
||||
EFL_GFX_JOIN_ROUND,
|
||||
EFL_GFX_JOIN_BEVEL,
|
||||
EFL_GFX_JOIN_LAST
|
||||
} Efl_Gfx_Join;
|
||||
|
||||
/**
|
||||
* Type defining gradient stop.
|
||||
* @since 1.13
|
||||
*/
|
||||
typedef struct _Efl_Graphics_Gradient_Stop Efl_Graphics_Gradient_Stop;
|
||||
struct _Efl_Graphics_Gradient_Stop
|
||||
typedef struct _Efl_Gfx_Gradient_Stop Efl_Gfx_Gradient_Stop;
|
||||
struct _Efl_Gfx_Gradient_Stop
|
||||
{
|
||||
double offset;
|
||||
int r;
|
||||
|
@ -103,13 +103,13 @@ struct _Efl_Graphics_Gradient_Stop
|
|||
* Type defining how the gradient spread after its limit.
|
||||
* @since 1.13
|
||||
*/
|
||||
typedef enum _Efl_Graphics_Gradient_Spread
|
||||
typedef enum _Efl_Gfx_Gradient_Spread
|
||||
{
|
||||
EFL_GRAPHICS_GRADIENT_SPREAD_PAD,
|
||||
EFL_GRAPHICS_GRADIENT_SPREAD_REFLECT,
|
||||
EFL_GRAPHICS_GRADIENT_SPREAD_REPEAT,
|
||||
EFL_GRAPHICS_GRADIENT_SPREAD_LAST
|
||||
} Efl_Graphics_Gradient_Spread;
|
||||
EFL_GFX_GRADIENT_SPREAD_PAD,
|
||||
EFL_GFX_GRADIENT_SPREAD_REFLECT,
|
||||
EFL_GFX_GRADIENT_SPREAD_REPEAT,
|
||||
EFL_GFX_GRADIENT_SPREAD_LAST
|
||||
} Efl_Gfx_Gradient_Spread;
|
||||
|
||||
#ifdef EFL_BETA_API_SUPPORT
|
||||
|
||||
|
@ -121,11 +121,12 @@ typedef enum _Efl_Graphics_Gradient_Spread
|
|||
#include "interfaces/efl_text.eo.h"
|
||||
#include "interfaces/efl_text_properties.eo.h"
|
||||
|
||||
#include "interfaces/efl_graphics_utils.h"
|
||||
#include "interfaces/efl_graphics_shape.eo.h"
|
||||
#include "interfaces/efl_graphics_gradient.eo.h"
|
||||
#include "interfaces/efl_graphics_gradient_linear.eo.h"
|
||||
#include "interfaces/efl_graphics_gradient_radial.eo.h"
|
||||
#include "interfaces/efl_gfx_utils.h"
|
||||
|
||||
#include "interfaces/efl_gfx_shape.eo.h"
|
||||
#include "interfaces/efl_gfx_gradient.eo.h"
|
||||
#include "interfaces/efl_gfx_gradient_linear.eo.h"
|
||||
#include "interfaces/efl_gfx_gradient_radial.eo.h"
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
interface Efl.Graphics.Gradient
|
||||
interface Efl.Gfx.Gradient
|
||||
{
|
||||
legacy_prefix: null;
|
||||
properties {
|
||||
|
@ -8,7 +8,7 @@ interface Efl.Graphics.Gradient
|
|||
get {
|
||||
}
|
||||
values {
|
||||
const(Efl_Graphics_Gradient_Stop) *colors;
|
||||
const(Efl_Gfx_Gradient_Stop) *colors;
|
||||
uint length;
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ interface Efl.Graphics.Gradient
|
|||
get {
|
||||
}
|
||||
values {
|
||||
Efl_Graphics_Gradient_Spread s;
|
||||
Efl_Gfx_Gradient_Spread s;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
interface Efl.Graphics.Gradient_Linear (Efl.Graphics.Gradient)
|
||||
interface Efl.Gfx.Gradient_Linear (Efl.Gfx.Gradient)
|
||||
{
|
||||
legacy_prefix: null;
|
||||
properties {
|
|
@ -1,4 +1,4 @@
|
|||
interface Efl.Graphics.Gradient_Radial (Efl.Graphics.Gradient)
|
||||
interface Efl.Gfx.Gradient_Radial (Efl.Gfx.Gradient)
|
||||
{
|
||||
legacy_prefix: null;
|
||||
properties {
|
|
@ -1,4 +1,4 @@
|
|||
interface Efl.Graphics.Shape
|
||||
interface Efl.Gfx.Shape
|
||||
{
|
||||
legacy_prefix: null;
|
||||
properties {
|
||||
|
@ -47,7 +47,7 @@ interface Efl.Graphics.Shape
|
|||
get {
|
||||
}
|
||||
values {
|
||||
const(Efl_Graphics_Dash) *dash;
|
||||
const(Efl_Gfx_Dash) *dash;
|
||||
uint length;
|
||||
}
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ interface Efl.Graphics.Shape
|
|||
get {
|
||||
}
|
||||
values {
|
||||
Efl_Graphics_Cap c;
|
||||
Efl_Gfx_Cap c;
|
||||
}
|
||||
}
|
||||
stroke_join {
|
||||
|
@ -66,7 +66,7 @@ interface Efl.Graphics.Shape
|
|||
get {
|
||||
}
|
||||
values {
|
||||
Efl_Graphics_Join j;
|
||||
Efl_Gfx_Join j;
|
||||
}
|
||||
}
|
||||
path {
|
||||
|
@ -75,7 +75,7 @@ interface Efl.Graphics.Shape
|
|||
get {
|
||||
}
|
||||
values {
|
||||
const(Efl_Graphics_Path_Command) *op;
|
||||
const(Efl_Gfx_Path_Command) *op;
|
||||
const(double) *points;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,973 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <Efl.h>
|
||||
|
||||
#include <math.h>
|
||||
#include <float.h>
|
||||
#include <ctype.h>
|
||||
|
||||
static inline unsigned int
|
||||
efl_gfx_path_command_length(Efl_Gfx_Path_Command command)
|
||||
{
|
||||
switch (command)
|
||||
{
|
||||
case EFL_GFX_PATH_COMMAND_TYPE_END: return 0;
|
||||
case EFL_GFX_PATH_COMMAND_TYPE_MOVE_TO: return 2;
|
||||
case EFL_GFX_PATH_COMMAND_TYPE_LINE_TO: return 2;
|
||||
case EFL_GFX_PATH_COMMAND_TYPE_CUBIC_TO: return 6;
|
||||
case EFL_GFX_PATH_COMMAND_TYPE_CLOSE: return 0;
|
||||
case EFL_GFX_PATH_COMMAND_TYPE_LAST: return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void
|
||||
_efl_gfx_path_length(const Efl_Gfx_Path_Command *commands,
|
||||
unsigned int *cmd_length,
|
||||
unsigned int *pts_length)
|
||||
{
|
||||
if (commands)
|
||||
while (commands[*cmd_length] != EFL_GFX_PATH_COMMAND_TYPE_END)
|
||||
{
|
||||
*pts_length += efl_gfx_path_command_length(commands[*cmd_length]);
|
||||
(*cmd_length)++;
|
||||
}
|
||||
|
||||
// Accounting for END command and handle gracefully the NULL case at the same time
|
||||
cmd_length++;
|
||||
}
|
||||
|
||||
static inline Eina_Bool
|
||||
efl_gfx_path_grow(Efl_Gfx_Path_Command command,
|
||||
Efl_Gfx_Path_Command **commands, double **points,
|
||||
double **offset_point)
|
||||
{
|
||||
Efl_Gfx_Path_Command *cmd_tmp;
|
||||
double *pts_tmp;
|
||||
unsigned int cmd_length = 0, pts_length = 0;
|
||||
|
||||
_efl_gfx_path_length(*commands, &cmd_length, &pts_length);
|
||||
|
||||
if (efl_gfx_path_command_length(command))
|
||||
{
|
||||
pts_length += efl_gfx_path_command_length(command);
|
||||
pts_tmp = realloc(*points, pts_length * sizeof (double));
|
||||
if (!pts_tmp) return EINA_FALSE;
|
||||
|
||||
*points = pts_tmp;
|
||||
*offset_point = *points + pts_length - efl_gfx_path_command_length(command);
|
||||
}
|
||||
|
||||
cmd_tmp = realloc(*commands,
|
||||
(cmd_length + 1) * sizeof (Efl_Gfx_Path_Command));
|
||||
if (!cmd_tmp) return EINA_FALSE;
|
||||
*commands = cmd_tmp;
|
||||
|
||||
// Append the command
|
||||
cmd_tmp[cmd_length - 1] = command;
|
||||
// NULL terminate the stream
|
||||
cmd_tmp[cmd_length] = EFL_GFX_PATH_COMMAND_TYPE_END;
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
efl_gfx_path_dup(Efl_Gfx_Path_Command **out_cmd, double **out_pts,
|
||||
const Efl_Gfx_Path_Command *in_cmd, const double *in_pts)
|
||||
{
|
||||
unsigned int cmd_length = 0, pts_length = 0;
|
||||
|
||||
_efl_gfx_path_length(in_cmd, &cmd_length, &pts_length);
|
||||
|
||||
*out_pts = malloc(pts_length * sizeof (double));
|
||||
*out_cmd = malloc(cmd_length * sizeof (Efl_Gfx_Path_Command));
|
||||
if (!(*out_pts) || !(*out_cmd))
|
||||
{
|
||||
free(*out_pts);
|
||||
free(*out_cmd);
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
memcpy(*out_pts, in_pts, pts_length * sizeof (double));
|
||||
memcpy(*out_cmd, in_cmd, cmd_length * sizeof (Efl_Gfx_Path_Command));
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
efl_gfx_path_equal_commands(const Efl_Gfx_Path_Command *a,
|
||||
const Efl_Gfx_Path_Command *b)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
if (!a && !b) return EINA_TRUE;
|
||||
if (!a || !b) return EINA_FALSE;
|
||||
|
||||
for (i = 0; a[i] == b[i] && a[i] != EFL_GFX_PATH_COMMAND_TYPE_END; i++)
|
||||
;
|
||||
|
||||
return a[i] == b[i];
|
||||
}
|
||||
|
||||
EAPI void
|
||||
efl_gfx_path_interpolate(const Efl_Gfx_Path_Command *cmd,
|
||||
double pos_map,
|
||||
const double *from, const double *to, double *r)
|
||||
{
|
||||
unsigned int i;
|
||||
unsigned int j;
|
||||
|
||||
if (!cmd) return ;
|
||||
|
||||
for (i = 0; cmd[i] != EFL_GFX_PATH_COMMAND_TYPE_END; i++)
|
||||
for (j = 0; j < efl_gfx_path_command_length(cmd[i]); j++)
|
||||
*r = (*from) * pos_map + ((*to) * (1.0 - pos_map));
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
efl_gfx_path_current_get(const Efl_Gfx_Path_Command *cmd,
|
||||
const double *points,
|
||||
double *current_x, double *current_y,
|
||||
double *current_ctrl_x, double *current_ctrl_y)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
if (current_x) *current_x = 0;
|
||||
if (current_y) *current_y = 0;
|
||||
if (current_ctrl_x) *current_ctrl_x = 0;
|
||||
if (current_ctrl_y) *current_ctrl_y = 0;
|
||||
if (!cmd || !points) return EINA_FALSE;
|
||||
|
||||
for (i = 0; cmd[i] != EFL_GFX_PATH_COMMAND_TYPE_END; i++)
|
||||
{
|
||||
switch (cmd[i])
|
||||
{
|
||||
case EFL_GFX_PATH_COMMAND_TYPE_END:
|
||||
break;
|
||||
case EFL_GFX_PATH_COMMAND_TYPE_MOVE_TO:
|
||||
case EFL_GFX_PATH_COMMAND_TYPE_LINE_TO:
|
||||
if (current_x) *current_x = points[0];
|
||||
if (current_y) *current_y = points[1];
|
||||
|
||||
points += 2;
|
||||
break;
|
||||
case EFL_GFX_PATH_COMMAND_TYPE_CUBIC_TO:
|
||||
if (current_x) *current_x = points[0];
|
||||
if (current_y) *current_y = points[1];
|
||||
if (current_ctrl_x) *current_ctrl_x = points[4];
|
||||
if (current_ctrl_y) *current_ctrl_y = points[5];
|
||||
|
||||
points += 6;
|
||||
break;
|
||||
case EFL_GFX_PATH_COMMAND_TYPE_CLOSE:
|
||||
break;
|
||||
case EFL_GFX_PATH_COMMAND_TYPE_LAST:
|
||||
default:
|
||||
return EINA_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
efl_gfx_path_append_move_to(Efl_Gfx_Path_Command **commands, double **points,
|
||||
double x, double y)
|
||||
{
|
||||
double *offset_point;
|
||||
|
||||
if (!efl_gfx_path_grow(EFL_GFX_PATH_COMMAND_TYPE_MOVE_TO,
|
||||
commands, points, &offset_point))
|
||||
return ;
|
||||
|
||||
offset_point[0] = x;
|
||||
offset_point[1] = y;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
efl_gfx_path_append_line_to(Efl_Gfx_Path_Command **commands, double **points,
|
||||
double x, double y)
|
||||
{
|
||||
double *offset_point;
|
||||
|
||||
if (!efl_gfx_path_grow(EFL_GFX_PATH_COMMAND_TYPE_LINE_TO,
|
||||
commands, points, &offset_point))
|
||||
return ;
|
||||
|
||||
offset_point[0] = x;
|
||||
offset_point[1] = y;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
efl_gfx_path_append_quadratic_to(Efl_Gfx_Path_Command **commands, double **points,
|
||||
double x, double y, double ctrl_x, double ctrl_y)
|
||||
{
|
||||
double current_x = 0, current_y = 0;
|
||||
double ctrl_x0, ctrl_y0, ctrl_x1, ctrl_y1;
|
||||
|
||||
if (!efl_gfx_path_current_get(*commands, *points,
|
||||
¤t_x, ¤t_y,
|
||||
NULL, NULL))
|
||||
return ;
|
||||
|
||||
// Convert quadratic bezier to cubic
|
||||
ctrl_x0 = (current_x + 2 * ctrl_x) * (1.0 / 3.0);
|
||||
ctrl_y0 = (current_y + 2 * ctrl_y) * (1.0 / 3.0);
|
||||
ctrl_x1 = (x + 2 * ctrl_x) * (1.0 / 3.0);
|
||||
ctrl_y1 = (y + 2 * ctrl_y) * (1.0 / 3.0);
|
||||
|
||||
efl_gfx_path_append_cubic_to(commands, points, x, y,
|
||||
ctrl_x0, ctrl_y0, ctrl_x1, ctrl_y1);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
efl_gfx_path_append_squadratic_to(Efl_Gfx_Path_Command **commands, double **points,
|
||||
double x, double y)
|
||||
{
|
||||
double xc, yc; /* quadratic control point */
|
||||
double ctrl_x0, ctrl_y0, ctrl_x1, ctrl_y1;
|
||||
double current_x = 0, current_y = 0;
|
||||
double current_ctrl_x = 0, current_ctrl_y = 0;
|
||||
|
||||
if (!efl_gfx_path_current_get(*commands, *points,
|
||||
¤t_x, ¤t_y,
|
||||
¤t_ctrl_x, ¤t_ctrl_y))
|
||||
return ;
|
||||
|
||||
xc = 2 * current_x - current_ctrl_x;
|
||||
yc = 2 * current_y - current_ctrl_y;
|
||||
/* generate a quadratic bezier with control point = xc, yc */
|
||||
ctrl_x0 = (current_x + 2 * xc) * (1.0 / 3.0);
|
||||
ctrl_y0 = (current_y + 2 * yc) * (1.0 / 3.0);
|
||||
ctrl_x1 = (x + 2 * xc) * (1.0 / 3.0);
|
||||
ctrl_y1 = (y + 2 * yc) * (1.0 / 3.0);
|
||||
|
||||
efl_gfx_path_append_cubic_to(commands, points, x, y,
|
||||
ctrl_x0, ctrl_y0,
|
||||
ctrl_x1, ctrl_y1);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
efl_gfx_path_append_cubic_to(Efl_Gfx_Path_Command **commands, double **points,
|
||||
double x, double y,
|
||||
double ctrl_x0, double ctrl_y0,
|
||||
double ctrl_x1, double ctrl_y1)
|
||||
{
|
||||
double *offset_point;
|
||||
|
||||
if (!efl_gfx_path_grow(EFL_GFX_PATH_COMMAND_TYPE_CUBIC_TO,
|
||||
commands, points, &offset_point))
|
||||
return ;
|
||||
|
||||
offset_point[0] = x;
|
||||
offset_point[1] = y;
|
||||
offset_point[2] = ctrl_x0;
|
||||
offset_point[3] = ctrl_y0;
|
||||
offset_point[4] = ctrl_x1;
|
||||
offset_point[5] = ctrl_y1;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
efl_gfx_path_append_scubic_to(Efl_Gfx_Path_Command **commands, double **points,
|
||||
double x, double y,
|
||||
double ctrl_x, double ctrl_y)
|
||||
{
|
||||
double ctrl_x0, ctrl_y0;
|
||||
double current_x = 0, current_y = 0;
|
||||
double current_ctrl_x = 0, current_ctrl_y = 0;
|
||||
|
||||
if (!efl_gfx_path_current_get(*commands, *points,
|
||||
¤t_x, ¤t_y,
|
||||
¤t_ctrl_x, ¤t_ctrl_y))
|
||||
return ;
|
||||
|
||||
ctrl_x0 = 2 * current_x - current_ctrl_x;
|
||||
ctrl_y0 = 2 * current_y - current_ctrl_y;
|
||||
|
||||
efl_gfx_path_append_cubic_to(commands, points, x, y,
|
||||
ctrl_x0, ctrl_y0, ctrl_x, ctrl_y);
|
||||
}
|
||||
|
||||
// This function come from librsvg rsvg-path.c
|
||||
static void
|
||||
_efl_gfx_path_append_arc_segment(Efl_Gfx_Path_Command **commands, double **points,
|
||||
double xc, double yc,
|
||||
double th0, double th1, double rx, double ry,
|
||||
double angle)
|
||||
{
|
||||
double x1, y1, x2, y2, x3, y3;
|
||||
double t;
|
||||
double th_half;
|
||||
double f, sinf, cosf;
|
||||
|
||||
f = angle * M_PI / 180.0;
|
||||
sinf = sin(f);
|
||||
cosf = cos(f);
|
||||
|
||||
th_half = 0.5 * (th1 - th0);
|
||||
t = (8.0 / 3.0) * sin(th_half * 0.5) * sin(th_half * 0.5) / sin(th_half);
|
||||
x1 = rx * (cos(th0) - t * sin(th0));
|
||||
y1 = ry * (sin(th0) + t * cos(th0));
|
||||
x3 = rx* cos(th1);
|
||||
y3 = ry* sin(th1);
|
||||
x2 = x3 + rx * (t * sin(th1));
|
||||
y2 = y3 + ry * (-t * cos(th1));
|
||||
|
||||
efl_gfx_path_append_cubic_to(commands, points,
|
||||
xc + cosf * x3 - sinf * y3,
|
||||
yc + sinf * x3 + cosf * y3,
|
||||
xc + cosf * x1 - sinf * y1,
|
||||
yc + sinf * x1 + cosf * y1,
|
||||
xc + cosf * x2 - sinf * y2,
|
||||
yc + sinf * x2 + cosf * y2);
|
||||
}
|
||||
|
||||
// This function come from librsvg rsvg-path.c
|
||||
EAPI void
|
||||
efl_gfx_path_append_arc_to(Efl_Gfx_Path_Command **commands, double **points,
|
||||
double x, double y,
|
||||
double rx, double ry, double angle,
|
||||
Eina_Bool large_arc, Eina_Bool sweep)
|
||||
{
|
||||
/* See Appendix F.6 Elliptical arc implementation notes
|
||||
http://www.w3.org/TR/SVG/implnote.html#ArcImplementationNotes */
|
||||
double f, sinf, cosf;
|
||||
double x1, y1, x2, y2;
|
||||
double x1_, y1_;
|
||||
double cx_, cy_, cx, cy;
|
||||
double gamma;
|
||||
double theta1, delta_theta;
|
||||
double k1, k2, k3, k4, k5;
|
||||
int i, n_segs;
|
||||
|
||||
if (!efl_gfx_path_current_get(*commands, *points,
|
||||
&x1, &y1,
|
||||
NULL, NULL))
|
||||
return ;
|
||||
|
||||
/* Start and end of path segment */
|
||||
x2 = x;
|
||||
y2 = y;
|
||||
|
||||
if (x1 == x2 && y1 == y2)
|
||||
return;
|
||||
|
||||
/* X-axis */
|
||||
f = angle * M_PI / 180.0;
|
||||
sinf = sin(f);
|
||||
cosf = cos(f);
|
||||
|
||||
/* Check the radius against floading point underflow.
|
||||
See http://bugs.debian.org/508443 */
|
||||
if ((fabs(rx) < DBL_EPSILON) || (fabs(ry) < DBL_EPSILON))
|
||||
{
|
||||
efl_gfx_path_append_line_to(commands, points, x, y);
|
||||
return;
|
||||
}
|
||||
|
||||
if (rx < 0) rx = -rx;
|
||||
if (ry < 0) ry = -ry;
|
||||
|
||||
k1 = (x1 - x2) / 2;
|
||||
k2 = (y1 - y2) / 2;
|
||||
|
||||
x1_ = cosf * k1 + sinf * k2;
|
||||
y1_ = -sinf * k1 + cosf * k2;
|
||||
|
||||
gamma = (x1_ * x1_) / (rx * rx) + (y1_ * y1_) / (ry * ry);
|
||||
if (gamma > 1)
|
||||
{
|
||||
rx *= sqrt(gamma);
|
||||
ry *= sqrt(gamma);
|
||||
}
|
||||
|
||||
/* Compute the center */
|
||||
k1 = rx * rx * y1_ * y1_ + ry * ry * x1_ * x1_;
|
||||
if (k1 == 0) return;
|
||||
|
||||
k1 = sqrt(fabs((rx * rx * ry * ry) / k1 - 1));
|
||||
if (sweep == large_arc)
|
||||
k1 = -k1;
|
||||
|
||||
cx_ = k1 * rx * y1_ / ry;
|
||||
cy_ = -k1 * ry * x1_ / rx;
|
||||
|
||||
cx = cosf * cx_ - sinf * cy_ + (x1 + x2) / 2;
|
||||
cy = sinf * cx_ + cosf * cy_ + (y1 + y2) / 2;
|
||||
|
||||
/* Compute start angle */
|
||||
k1 = (x1_ - cx_) / rx;
|
||||
k2 = (y1_ - cy_) / ry;
|
||||
k3 = (-x1_ - cx_) / rx;
|
||||
k4 = (-y1_ - cy_) / ry;
|
||||
|
||||
k5 = sqrt(fabs(k1 * k1 + k2 * k2));
|
||||
if (k5 == 0) return;
|
||||
|
||||
k5 = k1 / k5;
|
||||
if (k5 < -1) k5 = -1;
|
||||
else if(k5 > 1) k5 = 1;
|
||||
|
||||
theta1 = acos(k5);
|
||||
if(k2 < 0) theta1 = -theta1;
|
||||
|
||||
/* Compute delta_theta */
|
||||
k5 = sqrt(fabs((k1 * k1 + k2 * k2) * (k3 * k3 + k4 * k4)));
|
||||
if (k5 == 0) return;
|
||||
|
||||
k5 = (k1 * k3 + k2 * k4) / k5;
|
||||
if (k5 < -1) k5 = -1;
|
||||
else if (k5 > 1) k5 = 1;
|
||||
delta_theta = acos(k5);
|
||||
if(k1 * k4 - k3 * k2 < 0) delta_theta = -delta_theta;
|
||||
|
||||
if (sweep && delta_theta < 0)
|
||||
delta_theta += M_PI*2;
|
||||
else if (!sweep && delta_theta > 0)
|
||||
delta_theta -= M_PI*2;
|
||||
|
||||
/* Now draw the arc */
|
||||
n_segs = ceil(fabs(delta_theta / (M_PI * 0.5 + 0.001)));
|
||||
|
||||
for (i = 0; i < n_segs; i++)
|
||||
_efl_gfx_path_append_arc_segment(commands, points,
|
||||
cx, cy,
|
||||
theta1 + i * delta_theta / n_segs,
|
||||
theta1 + (i + 1) * delta_theta / n_segs,
|
||||
rx, ry, angle);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
efl_gfx_path_append_close(Efl_Gfx_Path_Command **commands, double **points)
|
||||
{
|
||||
double *offset_point;
|
||||
|
||||
efl_gfx_path_grow(EFL_GFX_PATH_COMMAND_TYPE_CLOSE,
|
||||
commands, points, &offset_point);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
efl_gfx_path_append_circle(Efl_Gfx_Path_Command **commands, double **points,
|
||||
double x, double y, double radius)
|
||||
{
|
||||
efl_gfx_path_append_move_to(commands, points, x, y - radius);
|
||||
efl_gfx_path_append_arc_to(commands, points, x - radius, y, radius, radius, 0, EINA_FALSE, EINA_FALSE);
|
||||
efl_gfx_path_append_arc_to(commands, points, x, y + radius, radius, radius, 0, EINA_FALSE, EINA_FALSE);
|
||||
efl_gfx_path_append_arc_to(commands, points, x + radius, y, radius, radius, 0, EINA_FALSE, EINA_FALSE);
|
||||
efl_gfx_path_append_arc_to(commands, points, x, y - radius, radius, radius, 0, EINA_FALSE, EINA_FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
_efl_gfx_path_append_horizontal_to(Efl_Gfx_Path_Command **commands, double **points,
|
||||
double d, double current_x EINA_UNUSED, double current_y)
|
||||
{
|
||||
efl_gfx_path_append_line_to(commands, points, d, current_y);
|
||||
}
|
||||
|
||||
static void
|
||||
_efl_gfx_path_append_vertical_to(Efl_Gfx_Path_Command **commands, double **points,
|
||||
double d, double current_x, double current_y EINA_UNUSED)
|
||||
{
|
||||
efl_gfx_path_append_line_to(commands, points, current_x, d);
|
||||
}
|
||||
|
||||
static char *
|
||||
_strcomma(const char *content)
|
||||
{
|
||||
while (*content && isspace(*content)) content++;
|
||||
if (*content != ',') return NULL;
|
||||
return (char*) content + 1;
|
||||
}
|
||||
|
||||
static inline Eina_Bool
|
||||
_next_isnumber(const char *content)
|
||||
{
|
||||
char *tmp = NULL;
|
||||
|
||||
(void) strtod(content, &tmp);
|
||||
return content != tmp;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_efl_gfx_path_parse_pair(const char *content, char **end, double *x, double *y)
|
||||
{
|
||||
/* "x,y" */
|
||||
char *end1 = NULL;
|
||||
char *end2 = NULL;
|
||||
|
||||
*x = strtod(content, &end1);
|
||||
end1 = _strcomma(end1);
|
||||
if (!end1) return EINA_FALSE;
|
||||
*y = strtod(end1, &end2);
|
||||
if (end1 == end2) return EINA_FALSE;
|
||||
|
||||
*end = end2;
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_efl_gfx_path_parse_pair_to(const char *content, char **end,
|
||||
Efl_Gfx_Path_Command **commands, double **points,
|
||||
double *current_x, double *current_y,
|
||||
void (*func)(Efl_Gfx_Path_Command **commands, double **points, double x, double y),
|
||||
Eina_Bool rel)
|
||||
{
|
||||
double x, y;
|
||||
|
||||
*end = (char*) content;
|
||||
do
|
||||
{
|
||||
Eina_Bool r;
|
||||
|
||||
r = _efl_gfx_path_parse_pair(content, end, &x, &y);
|
||||
if (!r) return EINA_FALSE;
|
||||
|
||||
if (rel)
|
||||
{
|
||||
x += *current_x;
|
||||
y += *current_y;
|
||||
}
|
||||
|
||||
func(commands, points, x, y);
|
||||
content = *end;
|
||||
|
||||
*current_x = x;
|
||||
*current_y = y;
|
||||
}
|
||||
while (_next_isnumber(content));
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_efl_gfx_path_parse_double_to(const char *content, char **end,
|
||||
Efl_Gfx_Path_Command **commands, double **points,
|
||||
double *current, double current_x, double current_y,
|
||||
void (*func)(Efl_Gfx_Path_Command **commands, double **points, double d, double current_x, double current_y),
|
||||
Eina_Bool rel)
|
||||
{
|
||||
double d;
|
||||
Eina_Bool first = EINA_FALSE;
|
||||
|
||||
*end = (char*) content;
|
||||
do
|
||||
{
|
||||
d = strtod(content, end);
|
||||
if (content == *end)
|
||||
return first;
|
||||
first = EINA_TRUE;
|
||||
|
||||
if (rel)
|
||||
{
|
||||
d += *current;
|
||||
}
|
||||
|
||||
func(commands, points, d, current_x, current_y);
|
||||
content = *end;
|
||||
|
||||
*current = d;
|
||||
}
|
||||
while (1); // This is an optimisation as we have only one parameter.
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_efl_gfx_path_parse_six(const char *content, char **end,
|
||||
double *x, double *y,
|
||||
double *ctrl_x0, double *ctrl_y0,
|
||||
double *ctrl_x1, double *ctrl_y1)
|
||||
{
|
||||
/* "x,y ctrl_x0,ctrl_y0 ctrl_x1,ctrl_y1" */
|
||||
char *end1 = NULL;
|
||||
char *end2 = NULL;
|
||||
|
||||
*x = strtod(content, &end1);
|
||||
end1 = _strcomma(end1);
|
||||
if (!end1) return EINA_FALSE;
|
||||
*y = strtod(end1, &end2);
|
||||
if (end1 == end2) return EINA_FALSE;
|
||||
|
||||
*ctrl_x0 = strtod(end2, &end2);
|
||||
end2 = _strcomma(end2);
|
||||
if (!end2) return EINA_FALSE;
|
||||
*ctrl_y0 = strtod(end2, &end1);
|
||||
if (end1 == end2) return EINA_FALSE;
|
||||
|
||||
*ctrl_x1 = strtod(end1, &end2);
|
||||
end2 = _strcomma(end2);
|
||||
if (!end2) return EINA_FALSE;
|
||||
*ctrl_y1 = strtod(end2, &end1);
|
||||
if (end1 == end2) return EINA_FALSE;
|
||||
|
||||
*end = end1;
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_efl_gfx_path_parse_six_to(const char *content, char **end,
|
||||
Efl_Gfx_Path_Command **commands, double **points,
|
||||
double *current_x, double *current_y,
|
||||
void (*func)(Efl_Gfx_Path_Command **commands, double **points, double x, double y, double ctrl_x0, double ctrl_y0, double ctrl_x1, double ctrl_y1),
|
||||
Eina_Bool rel)
|
||||
{
|
||||
double x, y, ctrl_x0, ctrl_y0, ctrl_x1, ctrl_y1;
|
||||
|
||||
*end = (char*) content;
|
||||
do
|
||||
{
|
||||
Eina_Bool r;
|
||||
|
||||
r = _efl_gfx_path_parse_six(content, end,
|
||||
&x, &y,
|
||||
&ctrl_x0, &ctrl_y0,
|
||||
&ctrl_x1, &ctrl_y1);
|
||||
if (!r) return EINA_FALSE;
|
||||
|
||||
if (rel)
|
||||
{
|
||||
x += *current_x;
|
||||
y += *current_y;
|
||||
}
|
||||
|
||||
func(commands, points, x, y, ctrl_x0, ctrl_y0, ctrl_x1, ctrl_y1);
|
||||
content = *end;
|
||||
|
||||
*current_x = x;
|
||||
*current_y = y;
|
||||
}
|
||||
while (_next_isnumber(content));
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_efl_gfx_path_parse_quad(const char *content, char **end,
|
||||
double *x, double *y,
|
||||
double *ctrl_x0, double *ctrl_y0)
|
||||
{
|
||||
/* "x,y ctrl_x0,ctrl_y0" */
|
||||
char *end1 = NULL;
|
||||
char *end2 = NULL;
|
||||
|
||||
*x = strtod(content, &end1);
|
||||
end1 = _strcomma(end1);
|
||||
if (!end1) return EINA_FALSE;
|
||||
*y = strtod(end1, &end2);
|
||||
if (end1 == end2) return EINA_FALSE;
|
||||
|
||||
*ctrl_x0 = strtod(end2, &end1);
|
||||
end1 = _strcomma(end2);
|
||||
if (!end1) return EINA_FALSE;
|
||||
*ctrl_y0 = strtod(end1, &end2);
|
||||
if (end1 == end2) return EINA_FALSE;
|
||||
|
||||
*end = end2;
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_efl_gfx_path_parse_quad_to(const char *content, char **end,
|
||||
Efl_Gfx_Path_Command **commands, double **points,
|
||||
double *current_x, double *current_y,
|
||||
void (*func)(Efl_Gfx_Path_Command **commands, double **points,
|
||||
double x, double y, double ctrl_x0, double ctrl_y0),
|
||||
Eina_Bool rel)
|
||||
{
|
||||
double x, y, ctrl_x0, ctrl_y0;
|
||||
|
||||
*end = (char*) content;
|
||||
do
|
||||
{
|
||||
Eina_Bool r;
|
||||
|
||||
r = _efl_gfx_path_parse_quad(content, end,
|
||||
&x, &y,
|
||||
&ctrl_x0, &ctrl_y0);
|
||||
if (!r) return EINA_FALSE;
|
||||
|
||||
if (rel)
|
||||
{
|
||||
x += *current_x;
|
||||
y += *current_y;
|
||||
}
|
||||
|
||||
func(commands, points, x, y, ctrl_x0, ctrl_y0);
|
||||
content = *end;
|
||||
|
||||
*current_x = x;
|
||||
*current_y = y;
|
||||
}
|
||||
while (_next_isnumber(content));
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_efl_gfx_path_parse_arc(const char *content, char **end,
|
||||
double *x, double *y,
|
||||
double *rx, double *ry,
|
||||
double *radius,
|
||||
Eina_Bool *large_arc, Eina_Bool *sweep)
|
||||
{
|
||||
/* "rx,ry r large-arc-flag,sweep-flag x,y" */
|
||||
char *end1 = NULL;
|
||||
char *end2 = NULL;
|
||||
|
||||
*rx = strtod(content, &end1);
|
||||
end1 = _strcomma(end1);
|
||||
if (!end1) return EINA_FALSE;
|
||||
*ry = strtod(end1, &end2);
|
||||
if (end1 == end2) return EINA_FALSE;
|
||||
|
||||
*radius = strtod(end2, &end1);
|
||||
if (end1 == end2) return EINA_FALSE;
|
||||
|
||||
*large_arc = strtol(end1, &end2, 10) ? EINA_TRUE : EINA_FALSE;
|
||||
end1 = _strcomma(end2);
|
||||
if (!end1) return EINA_FALSE;
|
||||
*sweep = strtol(end1, &end2, 10) ? EINA_TRUE : EINA_FALSE;
|
||||
if (end1 == end2) return EINA_FALSE;
|
||||
|
||||
*x = strtod(end2, &end1);
|
||||
end1 = _strcomma(end2);
|
||||
if (!end1) return EINA_FALSE;
|
||||
*y = strtod(end1, &end2);
|
||||
if (end1 == end2) return EINA_FALSE;
|
||||
|
||||
*end = end2;
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_efl_gfx_path_parse_arc_to(const char *content, char **end,
|
||||
Efl_Gfx_Path_Command **commands, double **points,
|
||||
double *current_x, double *current_y,
|
||||
void (*func)(Efl_Gfx_Path_Command **commands, double **points,
|
||||
double x, double y, double rx, double ry, double angle,
|
||||
Eina_Bool large_arc, Eina_Bool sweep),
|
||||
Eina_Bool rel)
|
||||
{
|
||||
double x, y, rx, ry, angle;
|
||||
Eina_Bool large_arc, sweep; // FIXME: handle those flag
|
||||
|
||||
*end = (char*) content;
|
||||
do
|
||||
{
|
||||
Eina_Bool r;
|
||||
|
||||
r = _efl_gfx_path_parse_arc(content, end,
|
||||
&x, &y,
|
||||
&rx, &ry,
|
||||
&angle,
|
||||
&large_arc, &sweep);
|
||||
if (!r) return EINA_FALSE;
|
||||
|
||||
if (rel)
|
||||
{
|
||||
x += *current_x;
|
||||
y += *current_y;
|
||||
}
|
||||
|
||||
func(commands, points, x, y, rx, ry, angle, large_arc, sweep);
|
||||
content = *end;
|
||||
|
||||
*current_x = x;
|
||||
*current_y = y;
|
||||
}
|
||||
while (_next_isnumber(content));
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
efl_gfx_path_append_svg_path(Efl_Gfx_Path_Command **commands, double **points, const char *svg_path_data)
|
||||
{
|
||||
double current_x = 0, current_y = 0;
|
||||
char *content = (char*) svg_path_data;
|
||||
|
||||
if (!content) return EINA_FALSE;
|
||||
|
||||
while (content[0] != '\0')
|
||||
{
|
||||
while (isspace(content[0])) content++;
|
||||
|
||||
switch (content[0])
|
||||
{
|
||||
case 'M':
|
||||
if (!_efl_gfx_path_parse_pair_to(&content[1],
|
||||
&content,
|
||||
commands, points,
|
||||
¤t_x, ¤t_y,
|
||||
efl_gfx_path_append_move_to,
|
||||
EINA_FALSE))
|
||||
return EINA_FALSE;
|
||||
break;
|
||||
case 'm':
|
||||
if (!_efl_gfx_path_parse_pair_to(&content[1],
|
||||
&content,
|
||||
commands, points,
|
||||
¤t_x, ¤t_y,
|
||||
efl_gfx_path_append_move_to,
|
||||
EINA_TRUE))
|
||||
return EINA_FALSE;
|
||||
break;
|
||||
case 'z':
|
||||
efl_gfx_path_append_close(commands, points);
|
||||
content++;
|
||||
break;
|
||||
case 'L':
|
||||
if (!_efl_gfx_path_parse_pair_to(&content[1],
|
||||
&content,
|
||||
commands, points,
|
||||
¤t_x, ¤t_y,
|
||||
efl_gfx_path_append_line_to,
|
||||
EINA_FALSE))
|
||||
return EINA_FALSE;
|
||||
break;
|
||||
case 'l':
|
||||
if (!_efl_gfx_path_parse_pair_to(&content[1],
|
||||
&content,
|
||||
commands, points,
|
||||
¤t_x, ¤t_y,
|
||||
efl_gfx_path_append_line_to,
|
||||
EINA_TRUE))
|
||||
return EINA_FALSE;
|
||||
break;
|
||||
case 'H':
|
||||
if (!_efl_gfx_path_parse_double_to(&content[1],
|
||||
&content,
|
||||
commands, points,
|
||||
¤t_x, current_x, current_y,
|
||||
_efl_gfx_path_append_horizontal_to,
|
||||
EINA_FALSE))
|
||||
return EINA_FALSE;
|
||||
break;
|
||||
case 'h':
|
||||
if (!_efl_gfx_path_parse_double_to(&content[1],
|
||||
&content,
|
||||
commands, points,
|
||||
¤t_x, current_x, current_y,
|
||||
_efl_gfx_path_append_horizontal_to,
|
||||
EINA_TRUE))
|
||||
return EINA_FALSE;
|
||||
break;
|
||||
case 'V':
|
||||
if (!_efl_gfx_path_parse_double_to(&content[1],
|
||||
&content,
|
||||
commands, points,
|
||||
¤t_y, current_x, current_y,
|
||||
_efl_gfx_path_append_vertical_to,
|
||||
EINA_FALSE))
|
||||
return EINA_FALSE;
|
||||
break;
|
||||
case 'v':
|
||||
if (!_efl_gfx_path_parse_double_to(&content[1],
|
||||
&content,
|
||||
commands, points,
|
||||
¤t_y, current_x, current_y,
|
||||
_efl_gfx_path_append_vertical_to,
|
||||
EINA_TRUE))
|
||||
return EINA_FALSE;
|
||||
break;
|
||||
case 'C':
|
||||
if (!_efl_gfx_path_parse_six_to(&content[1],
|
||||
&content,
|
||||
commands, points,
|
||||
¤t_x, ¤t_y,
|
||||
efl_gfx_path_append_cubic_to,
|
||||
EINA_FALSE))
|
||||
return EINA_FALSE;
|
||||
break;
|
||||
case 'c':
|
||||
if (!_efl_gfx_path_parse_six_to(&content[1],
|
||||
&content,
|
||||
commands, points,
|
||||
¤t_x, ¤t_y,
|
||||
efl_gfx_path_append_cubic_to,
|
||||
EINA_TRUE))
|
||||
return EINA_FALSE;
|
||||
break;
|
||||
case 'S':
|
||||
if (!_efl_gfx_path_parse_quad_to(&content[1],
|
||||
&content,
|
||||
commands, points,
|
||||
¤t_x, ¤t_y,
|
||||
efl_gfx_path_append_scubic_to,
|
||||
EINA_FALSE))
|
||||
return EINA_FALSE;
|
||||
break;
|
||||
case 's':
|
||||
if (!_efl_gfx_path_parse_quad_to(&content[1],
|
||||
&content,
|
||||
commands, points,
|
||||
¤t_x, ¤t_y,
|
||||
efl_gfx_path_append_scubic_to,
|
||||
EINA_TRUE))
|
||||
return EINA_FALSE;
|
||||
break;
|
||||
case 'Q':
|
||||
if (!_efl_gfx_path_parse_quad_to(&content[1],
|
||||
&content,
|
||||
commands, points,
|
||||
¤t_x, ¤t_y,
|
||||
efl_gfx_path_append_quadratic_to,
|
||||
EINA_FALSE))
|
||||
return EINA_FALSE;
|
||||
break;
|
||||
case 'q':
|
||||
if (!_efl_gfx_path_parse_quad_to(&content[1],
|
||||
&content,
|
||||
commands, points,
|
||||
¤t_x, ¤t_y,
|
||||
efl_gfx_path_append_quadratic_to,
|
||||
EINA_TRUE))
|
||||
return EINA_FALSE;
|
||||
break;
|
||||
case 'T':
|
||||
if (!_efl_gfx_path_parse_pair_to(&content[1],
|
||||
&content,
|
||||
commands, points,
|
||||
¤t_x, ¤t_y,
|
||||
efl_gfx_path_append_squadratic_to,
|
||||
EINA_FALSE))
|
||||
return EINA_FALSE;
|
||||
break;
|
||||
case 't':
|
||||
if (!_efl_gfx_path_parse_pair_to(&content[1],
|
||||
&content,
|
||||
commands, points,
|
||||
¤t_x, ¤t_y,
|
||||
efl_gfx_path_append_squadratic_to,
|
||||
EINA_TRUE))
|
||||
return EINA_FALSE;
|
||||
break;
|
||||
case 'A':
|
||||
if (!_efl_gfx_path_parse_arc_to(&content[1],
|
||||
&content,
|
||||
commands, points,
|
||||
¤t_x, ¤t_y,
|
||||
efl_gfx_path_append_arc_to,
|
||||
EINA_FALSE))
|
||||
return EINA_FALSE;
|
||||
break;
|
||||
case 'a':
|
||||
if (!_efl_gfx_path_parse_arc_to(&content[1],
|
||||
&content,
|
||||
commands, points,
|
||||
¤t_x, ¤t_y,
|
||||
efl_gfx_path_append_arc_to,
|
||||
EINA_TRUE))
|
||||
return EINA_FALSE;
|
||||
break;
|
||||
default:
|
||||
return EINA_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
#ifndef EFL_GRAPHICS_UTILS_H_
|
||||
# define EFL_GRAPHICS_UTILS_H_
|
||||
|
||||
EAPI Eina_Bool
|
||||
efl_gfx_path_dup(Efl_Gfx_Path_Command **out_cmd, double **out_pts,
|
||||
const Efl_Gfx_Path_Command *in_cmd, const double *in_pts);
|
||||
|
||||
EAPI void
|
||||
efl_gfx_path_append_move_to(Efl_Gfx_Path_Command **commands, double **points,
|
||||
double x, double y);
|
||||
|
||||
EAPI void
|
||||
efl_gfx_path_append_line_to(Efl_Gfx_Path_Command **commands, double **points,
|
||||
double x, double y);
|
||||
|
||||
EAPI void
|
||||
efl_gfx_path_append_quadratic_to(Efl_Gfx_Path_Command **commands, double **points,
|
||||
double x, double y, double ctrl_x, double ctrl_y);
|
||||
|
||||
EAPI void
|
||||
efl_gfx_path_append_squadratic_to(Efl_Gfx_Path_Command **commands, double **points,
|
||||
double x, double y);
|
||||
|
||||
EAPI void
|
||||
efl_gfx_path_append_cubic_to(Efl_Gfx_Path_Command **commands, double **points,
|
||||
double x, double y,
|
||||
double ctrl_x0, double ctrl_y0,
|
||||
double ctrl_x1, double ctrl_y1);
|
||||
|
||||
EAPI void
|
||||
efl_gfx_path_append_scubic_to(Efl_Gfx_Path_Command **commands, double **points,
|
||||
double x, double y,
|
||||
double ctrl_x, double ctrl_y);
|
||||
|
||||
EAPI void
|
||||
efl_gfx_path_append_arc_to(Efl_Gfx_Path_Command **commands, double **points,
|
||||
double x, double y,
|
||||
double rx, double ry,
|
||||
double angle,
|
||||
Eina_Bool large_arc, Eina_Bool sweep);
|
||||
|
||||
EAPI void
|
||||
efl_gfx_path_append_close(Efl_Gfx_Path_Command **commands, double **points);
|
||||
|
||||
EAPI void
|
||||
efl_gfx_path_append_circle(Efl_Gfx_Path_Command **commands, double **points,
|
||||
double x, double y, double radius);
|
||||
|
||||
EAPI Eina_Bool
|
||||
efl_gfx_path_append_svg_path(Efl_Gfx_Path_Command **commands, double **points, const char *svg_path_data);
|
||||
|
||||
EAPI void
|
||||
efl_gfx_path_interpolate(const Efl_Gfx_Path_Command *cmd,
|
||||
double pos_map,
|
||||
const double *from, const double *to, double *r);
|
||||
|
||||
EAPI Eina_Bool
|
||||
efl_gfx_path_equal_commands(const Efl_Gfx_Path_Command *a,
|
||||
const Efl_Gfx_Path_Command *b);
|
||||
|
||||
EAPI Eina_Bool
|
||||
efl_gfx_path_current_get(const Efl_Gfx_Path_Command *cmd,
|
||||
const double *points,
|
||||
double *current_x, double *current_y,
|
||||
double *current_ctrl_x, double *current_ctrl_y);
|
||||
|
||||
#endif
|
|
@ -1,973 +0,0 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <Efl.h>
|
||||
|
||||
#include <math.h>
|
||||
#include <float.h>
|
||||
#include <ctype.h>
|
||||
|
||||
static inline unsigned int
|
||||
efl_graphics_path_command_length(Efl_Graphics_Path_Command command)
|
||||
{
|
||||
switch (command)
|
||||
{
|
||||
case EFL_GRAPHICS_PATH_COMMAND_TYPE_END: return 0;
|
||||
case EFL_GRAPHICS_PATH_COMMAND_TYPE_MOVE_TO: return 2;
|
||||
case EFL_GRAPHICS_PATH_COMMAND_TYPE_LINE_TO: return 2;
|
||||
case EFL_GRAPHICS_PATH_COMMAND_TYPE_CUBIC_TO: return 6;
|
||||
case EFL_GRAPHICS_PATH_COMMAND_TYPE_CLOSE: return 0;
|
||||
case EFL_GRAPHICS_PATH_COMMAND_TYPE_LAST: return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void
|
||||
_efl_graphics_path_length(const Efl_Graphics_Path_Command *commands,
|
||||
unsigned int *cmd_length,
|
||||
unsigned int *pts_length)
|
||||
{
|
||||
if (commands)
|
||||
while (commands[*cmd_length] != EFL_GRAPHICS_PATH_COMMAND_TYPE_END)
|
||||
{
|
||||
*pts_length += efl_graphics_path_command_length(commands[*cmd_length]);
|
||||
(*cmd_length)++;
|
||||
}
|
||||
|
||||
// Accounting for END command and handle gracefully the NULL case at the same time
|
||||
cmd_length++;
|
||||
}
|
||||
|
||||
static inline Eina_Bool
|
||||
efl_graphics_path_grow(Efl_Graphics_Path_Command command,
|
||||
Efl_Graphics_Path_Command **commands, double **points,
|
||||
double **offset_point)
|
||||
{
|
||||
Efl_Graphics_Path_Command *cmd_tmp;
|
||||
double *pts_tmp;
|
||||
unsigned int cmd_length = 0, pts_length = 0;
|
||||
|
||||
_efl_graphics_path_length(*commands, &cmd_length, &pts_length);
|
||||
|
||||
if (efl_graphics_path_command_length(command))
|
||||
{
|
||||
pts_length += efl_graphics_path_command_length(command);
|
||||
pts_tmp = realloc(*points, pts_length * sizeof (double));
|
||||
if (!pts_tmp) return EINA_FALSE;
|
||||
|
||||
*points = pts_tmp;
|
||||
*offset_point = *points + pts_length - efl_graphics_path_command_length(command);
|
||||
}
|
||||
|
||||
cmd_tmp = realloc(*commands,
|
||||
(cmd_length + 1) * sizeof (Efl_Graphics_Path_Command));
|
||||
if (!cmd_tmp) return EINA_FALSE;
|
||||
*commands = cmd_tmp;
|
||||
|
||||
// Append the command
|
||||
cmd_tmp[cmd_length - 1] = command;
|
||||
// NULL terminate the stream
|
||||
cmd_tmp[cmd_length] = EFL_GRAPHICS_PATH_COMMAND_TYPE_END;
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
efl_graphics_path_dup(Efl_Graphics_Path_Command **out_cmd, double **out_pts,
|
||||
const Efl_Graphics_Path_Command *in_cmd, const double *in_pts)
|
||||
{
|
||||
unsigned int cmd_length = 0, pts_length = 0;
|
||||
|
||||
_efl_graphics_path_length(in_cmd, &cmd_length, &pts_length);
|
||||
|
||||
*out_pts = malloc(pts_length * sizeof (double));
|
||||
*out_cmd = malloc(cmd_length * sizeof (Efl_Graphics_Path_Command));
|
||||
if (!(*out_pts) || !(*out_cmd))
|
||||
{
|
||||
free(*out_pts);
|
||||
free(*out_cmd);
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
memcpy(*out_pts, in_pts, pts_length * sizeof (double));
|
||||
memcpy(*out_cmd, in_cmd, cmd_length * sizeof (Efl_Graphics_Path_Command));
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
efl_graphics_path_equal_commands(const Efl_Graphics_Path_Command *a,
|
||||
const Efl_Graphics_Path_Command *b)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
if (!a && !b) return EINA_TRUE;
|
||||
if (!a || !b) return EINA_FALSE;
|
||||
|
||||
for (i = 0; a[i] == b[i] && a[i] != EFL_GRAPHICS_PATH_COMMAND_TYPE_END; i++)
|
||||
;
|
||||
|
||||
return a[i] == b[i];
|
||||
}
|
||||
|
||||
EAPI void
|
||||
efl_graphics_path_interpolate(const Efl_Graphics_Path_Command *cmd,
|
||||
double pos_map,
|
||||
const double *from, const double *to, double *r)
|
||||
{
|
||||
unsigned int i;
|
||||
unsigned int j;
|
||||
|
||||
if (!cmd) return ;
|
||||
|
||||
for (i = 0; cmd[i] != EFL_GRAPHICS_PATH_COMMAND_TYPE_END; i++)
|
||||
for (j = 0; j < efl_graphics_path_command_length(cmd[i]); j++)
|
||||
*r = (*from) * pos_map + ((*to) * (1.0 - pos_map));
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
efl_graphics_path_current_get(const Efl_Graphics_Path_Command *cmd,
|
||||
const double *points,
|
||||
double *current_x, double *current_y,
|
||||
double *current_ctrl_x, double *current_ctrl_y)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
if (current_x) *current_x = 0;
|
||||
if (current_y) *current_y = 0;
|
||||
if (current_ctrl_x) *current_ctrl_x = 0;
|
||||
if (current_ctrl_y) *current_ctrl_y = 0;
|
||||
if (!cmd || !points) return EINA_FALSE;
|
||||
|
||||
for (i = 0; cmd[i] != EFL_GRAPHICS_PATH_COMMAND_TYPE_END; i++)
|
||||
{
|
||||
switch (cmd[i])
|
||||
{
|
||||
case EFL_GRAPHICS_PATH_COMMAND_TYPE_END:
|
||||
break;
|
||||
case EFL_GRAPHICS_PATH_COMMAND_TYPE_MOVE_TO:
|
||||
case EFL_GRAPHICS_PATH_COMMAND_TYPE_LINE_TO:
|
||||
if (current_x) *current_x = points[0];
|
||||
if (current_y) *current_y = points[1];
|
||||
|
||||
points += 2;
|
||||
break;
|
||||
case EFL_GRAPHICS_PATH_COMMAND_TYPE_CUBIC_TO:
|
||||
if (current_x) *current_x = points[0];
|
||||
if (current_y) *current_y = points[1];
|
||||
if (current_ctrl_x) *current_ctrl_x = points[4];
|
||||
if (current_ctrl_y) *current_ctrl_y = points[5];
|
||||
|
||||
points += 6;
|
||||
break;
|
||||
case EFL_GRAPHICS_PATH_COMMAND_TYPE_CLOSE:
|
||||
break;
|
||||
case EFL_GRAPHICS_PATH_COMMAND_TYPE_LAST:
|
||||
default:
|
||||
return EINA_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
efl_graphics_path_append_move_to(Efl_Graphics_Path_Command **commands, double **points,
|
||||
double x, double y)
|
||||
{
|
||||
double *offset_point;
|
||||
|
||||
if (!efl_graphics_path_grow(EFL_GRAPHICS_PATH_COMMAND_TYPE_MOVE_TO,
|
||||
commands, points, &offset_point))
|
||||
return ;
|
||||
|
||||
offset_point[0] = x;
|
||||
offset_point[1] = y;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
efl_graphics_path_append_line_to(Efl_Graphics_Path_Command **commands, double **points,
|
||||
double x, double y)
|
||||
{
|
||||
double *offset_point;
|
||||
|
||||
if (!efl_graphics_path_grow(EFL_GRAPHICS_PATH_COMMAND_TYPE_LINE_TO,
|
||||
commands, points, &offset_point))
|
||||
return ;
|
||||
|
||||
offset_point[0] = x;
|
||||
offset_point[1] = y;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
efl_graphics_path_append_quadratic_to(Efl_Graphics_Path_Command **commands, double **points,
|
||||
double x, double y, double ctrl_x, double ctrl_y)
|
||||
{
|
||||
double current_x = 0, current_y = 0;
|
||||
double ctrl_x0, ctrl_y0, ctrl_x1, ctrl_y1;
|
||||
|
||||
if (!efl_graphics_path_current_get(*commands, *points,
|
||||
¤t_x, ¤t_y,
|
||||
NULL, NULL))
|
||||
return ;
|
||||
|
||||
// Convert quadratic bezier to cubic
|
||||
ctrl_x0 = (current_x + 2 * ctrl_x) * (1.0 / 3.0);
|
||||
ctrl_y0 = (current_y + 2 * ctrl_y) * (1.0 / 3.0);
|
||||
ctrl_x1 = (x + 2 * ctrl_x) * (1.0 / 3.0);
|
||||
ctrl_y1 = (y + 2 * ctrl_y) * (1.0 / 3.0);
|
||||
|
||||
efl_graphics_path_append_cubic_to(commands, points, x, y,
|
||||
ctrl_x0, ctrl_y0, ctrl_x1, ctrl_y1);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
efl_graphics_path_append_squadratic_to(Efl_Graphics_Path_Command **commands, double **points,
|
||||
double x, double y)
|
||||
{
|
||||
double xc, yc; /* quadratic control point */
|
||||
double ctrl_x0, ctrl_y0, ctrl_x1, ctrl_y1;
|
||||
double current_x = 0, current_y = 0;
|
||||
double current_ctrl_x = 0, current_ctrl_y = 0;
|
||||
|
||||
if (!efl_graphics_path_current_get(*commands, *points,
|
||||
¤t_x, ¤t_y,
|
||||
¤t_ctrl_x, ¤t_ctrl_y))
|
||||
return ;
|
||||
|
||||
xc = 2 * current_x - current_ctrl_x;
|
||||
yc = 2 * current_y - current_ctrl_y;
|
||||
/* generate a quadratic bezier with control point = xc, yc */
|
||||
ctrl_x0 = (current_x + 2 * xc) * (1.0 / 3.0);
|
||||
ctrl_y0 = (current_y + 2 * yc) * (1.0 / 3.0);
|
||||
ctrl_x1 = (x + 2 * xc) * (1.0 / 3.0);
|
||||
ctrl_y1 = (y + 2 * yc) * (1.0 / 3.0);
|
||||
|
||||
efl_graphics_path_append_cubic_to(commands, points, x, y,
|
||||
ctrl_x0, ctrl_y0,
|
||||
ctrl_x1, ctrl_y1);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
efl_graphics_path_append_cubic_to(Efl_Graphics_Path_Command **commands, double **points,
|
||||
double x, double y,
|
||||
double ctrl_x0, double ctrl_y0,
|
||||
double ctrl_x1, double ctrl_y1)
|
||||
{
|
||||
double *offset_point;
|
||||
|
||||
if (!efl_graphics_path_grow(EFL_GRAPHICS_PATH_COMMAND_TYPE_CUBIC_TO,
|
||||
commands, points, &offset_point))
|
||||
return ;
|
||||
|
||||
offset_point[0] = x;
|
||||
offset_point[1] = y;
|
||||
offset_point[2] = ctrl_x0;
|
||||
offset_point[3] = ctrl_y0;
|
||||
offset_point[4] = ctrl_x1;
|
||||
offset_point[5] = ctrl_y1;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
efl_graphics_path_append_scubic_to(Efl_Graphics_Path_Command **commands, double **points,
|
||||
double x, double y,
|
||||
double ctrl_x, double ctrl_y)
|
||||
{
|
||||
double ctrl_x0, ctrl_y0;
|
||||
double current_x = 0, current_y = 0;
|
||||
double current_ctrl_x = 0, current_ctrl_y = 0;
|
||||
|
||||
if (!efl_graphics_path_current_get(*commands, *points,
|
||||
¤t_x, ¤t_y,
|
||||
¤t_ctrl_x, ¤t_ctrl_y))
|
||||
return ;
|
||||
|
||||
ctrl_x0 = 2 * current_x - current_ctrl_x;
|
||||
ctrl_y0 = 2 * current_y - current_ctrl_y;
|
||||
|
||||
efl_graphics_path_append_cubic_to(commands, points, x, y,
|
||||
ctrl_x0, ctrl_y0, ctrl_x, ctrl_y);
|
||||
}
|
||||
|
||||
// This function come from librsvg rsvg-path.c
|
||||
static void
|
||||
_efl_graphics_path_append_arc_segment(Efl_Graphics_Path_Command **commands, double **points,
|
||||
double xc, double yc,
|
||||
double th0, double th1, double rx, double ry,
|
||||
double angle)
|
||||
{
|
||||
double x1, y1, x2, y2, x3, y3;
|
||||
double t;
|
||||
double th_half;
|
||||
double f, sinf, cosf;
|
||||
|
||||
f = angle * M_PI / 180.0;
|
||||
sinf = sin(f);
|
||||
cosf = cos(f);
|
||||
|
||||
th_half = 0.5 * (th1 - th0);
|
||||
t = (8.0 / 3.0) * sin(th_half * 0.5) * sin(th_half * 0.5) / sin(th_half);
|
||||
x1 = rx * (cos(th0) - t * sin(th0));
|
||||
y1 = ry * (sin(th0) + t * cos(th0));
|
||||
x3 = rx* cos(th1);
|
||||
y3 = ry* sin(th1);
|
||||
x2 = x3 + rx * (t * sin(th1));
|
||||
y2 = y3 + ry * (-t * cos(th1));
|
||||
|
||||
efl_graphics_path_append_cubic_to(commands, points,
|
||||
xc + cosf * x3 - sinf * y3,
|
||||
yc + sinf * x3 + cosf * y3,
|
||||
xc + cosf * x1 - sinf * y1,
|
||||
yc + sinf * x1 + cosf * y1,
|
||||
xc + cosf * x2 - sinf * y2,
|
||||
yc + sinf * x2 + cosf * y2);
|
||||
}
|
||||
|
||||
// This function come from librsvg rsvg-path.c
|
||||
EAPI void
|
||||
efl_graphics_path_append_arc_to(Efl_Graphics_Path_Command **commands, double **points,
|
||||
double x, double y,
|
||||
double rx, double ry, double angle,
|
||||
Eina_Bool large_arc, Eina_Bool sweep)
|
||||
{
|
||||
/* See Appendix F.6 Elliptical arc implementation notes
|
||||
http://www.w3.org/TR/SVG/implnote.html#ArcImplementationNotes */
|
||||
double f, sinf, cosf;
|
||||
double x1, y1, x2, y2;
|
||||
double x1_, y1_;
|
||||
double cx_, cy_, cx, cy;
|
||||
double gamma;
|
||||
double theta1, delta_theta;
|
||||
double k1, k2, k3, k4, k5;
|
||||
int i, n_segs;
|
||||
|
||||
if (!efl_graphics_path_current_get(*commands, *points,
|
||||
&x1, &y1,
|
||||
NULL, NULL))
|
||||
return ;
|
||||
|
||||
/* Start and end of path segment */
|
||||
x2 = x;
|
||||
y2 = y;
|
||||
|
||||
if (x1 == x2 && y1 == y2)
|
||||
return;
|
||||
|
||||
/* X-axis */
|
||||
f = angle * M_PI / 180.0;
|
||||
sinf = sin(f);
|
||||
cosf = cos(f);
|
||||
|
||||
/* Check the radius against floading point underflow.
|
||||
See http://bugs.debian.org/508443 */
|
||||
if ((fabs(rx) < DBL_EPSILON) || (fabs(ry) < DBL_EPSILON))
|
||||
{
|
||||
efl_graphics_path_append_line_to(commands, points, x, y);
|
||||
return;
|
||||
}
|
||||
|
||||
if (rx < 0) rx = -rx;
|
||||
if (ry < 0) ry = -ry;
|
||||
|
||||
k1 = (x1 - x2) / 2;
|
||||
k2 = (y1 - y2) / 2;
|
||||
|
||||
x1_ = cosf * k1 + sinf * k2;
|
||||
y1_ = -sinf * k1 + cosf * k2;
|
||||
|
||||
gamma = (x1_ * x1_) / (rx * rx) + (y1_ * y1_) / (ry * ry);
|
||||
if (gamma > 1)
|
||||
{
|
||||
rx *= sqrt(gamma);
|
||||
ry *= sqrt(gamma);
|
||||
}
|
||||
|
||||
/* Compute the center */
|
||||
k1 = rx * rx * y1_ * y1_ + ry * ry * x1_ * x1_;
|
||||
if (k1 == 0) return;
|
||||
|
||||
k1 = sqrt(fabs((rx * rx * ry * ry) / k1 - 1));
|
||||
if (sweep == large_arc)
|
||||
k1 = -k1;
|
||||
|
||||
cx_ = k1 * rx * y1_ / ry;
|
||||
cy_ = -k1 * ry * x1_ / rx;
|
||||
|
||||
cx = cosf * cx_ - sinf * cy_ + (x1 + x2) / 2;
|
||||
cy = sinf * cx_ + cosf * cy_ + (y1 + y2) / 2;
|
||||
|
||||
/* Compute start angle */
|
||||
k1 = (x1_ - cx_) / rx;
|
||||
k2 = (y1_ - cy_) / ry;
|
||||
k3 = (-x1_ - cx_) / rx;
|
||||
k4 = (-y1_ - cy_) / ry;
|
||||
|
||||
k5 = sqrt(fabs(k1 * k1 + k2 * k2));
|
||||
if (k5 == 0) return;
|
||||
|
||||
k5 = k1 / k5;
|
||||
if (k5 < -1) k5 = -1;
|
||||
else if(k5 > 1) k5 = 1;
|
||||
|
||||
theta1 = acos(k5);
|
||||
if(k2 < 0) theta1 = -theta1;
|
||||
|
||||
/* Compute delta_theta */
|
||||
k5 = sqrt(fabs((k1 * k1 + k2 * k2) * (k3 * k3 + k4 * k4)));
|
||||
if (k5 == 0) return;
|
||||
|
||||
k5 = (k1 * k3 + k2 * k4) / k5;
|
||||
if (k5 < -1) k5 = -1;
|
||||
else if (k5 > 1) k5 = 1;
|
||||
delta_theta = acos(k5);
|
||||
if(k1 * k4 - k3 * k2 < 0) delta_theta = -delta_theta;
|
||||
|
||||
if (sweep && delta_theta < 0)
|
||||
delta_theta += M_PI*2;
|
||||
else if (!sweep && delta_theta > 0)
|
||||
delta_theta -= M_PI*2;
|
||||
|
||||
/* Now draw the arc */
|
||||
n_segs = ceil(fabs(delta_theta / (M_PI * 0.5 + 0.001)));
|
||||
|
||||
for (i = 0; i < n_segs; i++)
|
||||
_efl_graphics_path_append_arc_segment(commands, points,
|
||||
cx, cy,
|
||||
theta1 + i * delta_theta / n_segs,
|
||||
theta1 + (i + 1) * delta_theta / n_segs,
|
||||
rx, ry, angle);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
efl_graphics_path_append_close(Efl_Graphics_Path_Command **commands, double **points)
|
||||
{
|
||||
double *offset_point;
|
||||
|
||||
efl_graphics_path_grow(EFL_GRAPHICS_PATH_COMMAND_TYPE_CLOSE,
|
||||
commands, points, &offset_point);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
efl_graphics_path_append_circle(Efl_Graphics_Path_Command **commands, double **points,
|
||||
double x, double y, double radius)
|
||||
{
|
||||
efl_graphics_path_append_move_to(commands, points, x, y - radius);
|
||||
efl_graphics_path_append_arc_to(commands, points, x - radius, y, radius, radius, 0, EINA_FALSE, EINA_FALSE);
|
||||
efl_graphics_path_append_arc_to(commands, points, x, y + radius, radius, radius, 0, EINA_FALSE, EINA_FALSE);
|
||||
efl_graphics_path_append_arc_to(commands, points, x + radius, y, radius, radius, 0, EINA_FALSE, EINA_FALSE);
|
||||
efl_graphics_path_append_arc_to(commands, points, x, y - radius, radius, radius, 0, EINA_FALSE, EINA_FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
_efl_graphics_path_append_horizontal_to(Efl_Graphics_Path_Command **commands, double **points,
|
||||
double d, double current_x EINA_UNUSED, double current_y)
|
||||
{
|
||||
efl_graphics_path_append_line_to(commands, points, d, current_y);
|
||||
}
|
||||
|
||||
static void
|
||||
_efl_graphics_path_append_vertical_to(Efl_Graphics_Path_Command **commands, double **points,
|
||||
double d, double current_x, double current_y EINA_UNUSED)
|
||||
{
|
||||
efl_graphics_path_append_line_to(commands, points, current_x, d);
|
||||
}
|
||||
|
||||
static char *
|
||||
_strcomma(const char *content)
|
||||
{
|
||||
while (*content && isspace(*content)) content++;
|
||||
if (*content != ',') return NULL;
|
||||
return (char*) content + 1;
|
||||
}
|
||||
|
||||
static inline Eina_Bool
|
||||
_next_isnumber(const char *content)
|
||||
{
|
||||
char *tmp = NULL;
|
||||
|
||||
(void) strtod(content, &tmp);
|
||||
return content != tmp;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_efl_graphics_path_parse_pair(const char *content, char **end, double *x, double *y)
|
||||
{
|
||||
/* "x,y" */
|
||||
char *end1 = NULL;
|
||||
char *end2 = NULL;
|
||||
|
||||
*x = strtod(content, &end1);
|
||||
end1 = _strcomma(end1);
|
||||
if (!end1) return EINA_FALSE;
|
||||
*y = strtod(end1, &end2);
|
||||
if (end1 == end2) return EINA_FALSE;
|
||||
|
||||
*end = end2;
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_efl_graphics_path_parse_pair_to(const char *content, char **end,
|
||||
Efl_Graphics_Path_Command **commands, double **points,
|
||||
double *current_x, double *current_y,
|
||||
void (*func)(Efl_Graphics_Path_Command **commands, double **points, double x, double y),
|
||||
Eina_Bool rel)
|
||||
{
|
||||
double x, y;
|
||||
|
||||
*end = (char*) content;
|
||||
do
|
||||
{
|
||||
Eina_Bool r;
|
||||
|
||||
r = _efl_graphics_path_parse_pair(content, end, &x, &y);
|
||||
if (!r) return EINA_FALSE;
|
||||
|
||||
if (rel)
|
||||
{
|
||||
x += *current_x;
|
||||
y += *current_y;
|
||||
}
|
||||
|
||||
func(commands, points, x, y);
|
||||
content = *end;
|
||||
|
||||
*current_x = x;
|
||||
*current_y = y;
|
||||
}
|
||||
while (_next_isnumber(content));
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_efl_graphics_path_parse_double_to(const char *content, char **end,
|
||||
Efl_Graphics_Path_Command **commands, double **points,
|
||||
double *current, double current_x, double current_y,
|
||||
void (*func)(Efl_Graphics_Path_Command **commands, double **points, double d, double current_x, double current_y),
|
||||
Eina_Bool rel)
|
||||
{
|
||||
double d;
|
||||
Eina_Bool first = EINA_FALSE;
|
||||
|
||||
*end = (char*) content;
|
||||
do
|
||||
{
|
||||
d = strtod(content, end);
|
||||
if (content == *end)
|
||||
return first;
|
||||
first = EINA_TRUE;
|
||||
|
||||
if (rel)
|
||||
{
|
||||
d += *current;
|
||||
}
|
||||
|
||||
func(commands, points, d, current_x, current_y);
|
||||
content = *end;
|
||||
|
||||
*current = d;
|
||||
}
|
||||
while (1); // This is an optimisation as we have only one parameter.
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_efl_graphics_path_parse_six(const char *content, char **end,
|
||||
double *x, double *y,
|
||||
double *ctrl_x0, double *ctrl_y0,
|
||||
double *ctrl_x1, double *ctrl_y1)
|
||||
{
|
||||
/* "x,y ctrl_x0,ctrl_y0 ctrl_x1,ctrl_y1" */
|
||||
char *end1 = NULL;
|
||||
char *end2 = NULL;
|
||||
|
||||
*x = strtod(content, &end1);
|
||||
end1 = _strcomma(end1);
|
||||
if (!end1) return EINA_FALSE;
|
||||
*y = strtod(end1, &end2);
|
||||
if (end1 == end2) return EINA_FALSE;
|
||||
|
||||
*ctrl_x0 = strtod(end2, &end2);
|
||||
end2 = _strcomma(end2);
|
||||
if (!end2) return EINA_FALSE;
|
||||
*ctrl_y0 = strtod(end2, &end1);
|
||||
if (end1 == end2) return EINA_FALSE;
|
||||
|
||||
*ctrl_x1 = strtod(end1, &end2);
|
||||
end2 = _strcomma(end2);
|
||||
if (!end2) return EINA_FALSE;
|
||||
*ctrl_y1 = strtod(end2, &end1);
|
||||
if (end1 == end2) return EINA_FALSE;
|
||||
|
||||
*end = end1;
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_efl_graphics_path_parse_six_to(const char *content, char **end,
|
||||
Efl_Graphics_Path_Command **commands, double **points,
|
||||
double *current_x, double *current_y,
|
||||
void (*func)(Efl_Graphics_Path_Command **commands, double **points, double x, double y, double ctrl_x0, double ctrl_y0, double ctrl_x1, double ctrl_y1),
|
||||
Eina_Bool rel)
|
||||
{
|
||||
double x, y, ctrl_x0, ctrl_y0, ctrl_x1, ctrl_y1;
|
||||
|
||||
*end = (char*) content;
|
||||
do
|
||||
{
|
||||
Eina_Bool r;
|
||||
|
||||
r = _efl_graphics_path_parse_six(content, end,
|
||||
&x, &y,
|
||||
&ctrl_x0, &ctrl_y0,
|
||||
&ctrl_x1, &ctrl_y1);
|
||||
if (!r) return EINA_FALSE;
|
||||
|
||||
if (rel)
|
||||
{
|
||||
x += *current_x;
|
||||
y += *current_y;
|
||||
}
|
||||
|
||||
func(commands, points, x, y, ctrl_x0, ctrl_y0, ctrl_x1, ctrl_y1);
|
||||
content = *end;
|
||||
|
||||
*current_x = x;
|
||||
*current_y = y;
|
||||
}
|
||||
while (_next_isnumber(content));
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_efl_graphics_path_parse_quad(const char *content, char **end,
|
||||
double *x, double *y,
|
||||
double *ctrl_x0, double *ctrl_y0)
|
||||
{
|
||||
/* "x,y ctrl_x0,ctrl_y0" */
|
||||
char *end1 = NULL;
|
||||
char *end2 = NULL;
|
||||
|
||||
*x = strtod(content, &end1);
|
||||
end1 = _strcomma(end1);
|
||||
if (!end1) return EINA_FALSE;
|
||||
*y = strtod(end1, &end2);
|
||||
if (end1 == end2) return EINA_FALSE;
|
||||
|
||||
*ctrl_x0 = strtod(end2, &end1);
|
||||
end1 = _strcomma(end2);
|
||||
if (!end1) return EINA_FALSE;
|
||||
*ctrl_y0 = strtod(end1, &end2);
|
||||
if (end1 == end2) return EINA_FALSE;
|
||||
|
||||
*end = end2;
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_efl_graphics_path_parse_quad_to(const char *content, char **end,
|
||||
Efl_Graphics_Path_Command **commands, double **points,
|
||||
double *current_x, double *current_y,
|
||||
void (*func)(Efl_Graphics_Path_Command **commands, double **points,
|
||||
double x, double y, double ctrl_x0, double ctrl_y0),
|
||||
Eina_Bool rel)
|
||||
{
|
||||
double x, y, ctrl_x0, ctrl_y0;
|
||||
|
||||
*end = (char*) content;
|
||||
do
|
||||
{
|
||||
Eina_Bool r;
|
||||
|
||||
r = _efl_graphics_path_parse_quad(content, end,
|
||||
&x, &y,
|
||||
&ctrl_x0, &ctrl_y0);
|
||||
if (!r) return EINA_FALSE;
|
||||
|
||||
if (rel)
|
||||
{
|
||||
x += *current_x;
|
||||
y += *current_y;
|
||||
}
|
||||
|
||||
func(commands, points, x, y, ctrl_x0, ctrl_y0);
|
||||
content = *end;
|
||||
|
||||
*current_x = x;
|
||||
*current_y = y;
|
||||
}
|
||||
while (_next_isnumber(content));
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_efl_graphics_path_parse_arc(const char *content, char **end,
|
||||
double *x, double *y,
|
||||
double *rx, double *ry,
|
||||
double *radius,
|
||||
Eina_Bool *large_arc, Eina_Bool *sweep)
|
||||
{
|
||||
/* "rx,ry r large-arc-flag,sweep-flag x,y" */
|
||||
char *end1 = NULL;
|
||||
char *end2 = NULL;
|
||||
|
||||
*rx = strtod(content, &end1);
|
||||
end1 = _strcomma(end1);
|
||||
if (!end1) return EINA_FALSE;
|
||||
*ry = strtod(end1, &end2);
|
||||
if (end1 == end2) return EINA_FALSE;
|
||||
|
||||
*radius = strtod(end2, &end1);
|
||||
if (end1 == end2) return EINA_FALSE;
|
||||
|
||||
*large_arc = strtol(end1, &end2, 10) ? EINA_TRUE : EINA_FALSE;
|
||||
end1 = _strcomma(end2);
|
||||
if (!end1) return EINA_FALSE;
|
||||
*sweep = strtol(end1, &end2, 10) ? EINA_TRUE : EINA_FALSE;
|
||||
if (end1 == end2) return EINA_FALSE;
|
||||
|
||||
*x = strtod(end2, &end1);
|
||||
end1 = _strcomma(end2);
|
||||
if (!end1) return EINA_FALSE;
|
||||
*y = strtod(end1, &end2);
|
||||
if (end1 == end2) return EINA_FALSE;
|
||||
|
||||
*end = end2;
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_efl_graphics_path_parse_arc_to(const char *content, char **end,
|
||||
Efl_Graphics_Path_Command **commands, double **points,
|
||||
double *current_x, double *current_y,
|
||||
void (*func)(Efl_Graphics_Path_Command **commands, double **points,
|
||||
double x, double y, double rx, double ry, double angle,
|
||||
Eina_Bool large_arc, Eina_Bool sweep),
|
||||
Eina_Bool rel)
|
||||
{
|
||||
double x, y, rx, ry, angle;
|
||||
Eina_Bool large_arc, sweep; // FIXME: handle those flag
|
||||
|
||||
*end = (char*) content;
|
||||
do
|
||||
{
|
||||
Eina_Bool r;
|
||||
|
||||
r = _efl_graphics_path_parse_arc(content, end,
|
||||
&x, &y,
|
||||
&rx, &ry,
|
||||
&angle,
|
||||
&large_arc, &sweep);
|
||||
if (!r) return EINA_FALSE;
|
||||
|
||||
if (rel)
|
||||
{
|
||||
x += *current_x;
|
||||
y += *current_y;
|
||||
}
|
||||
|
||||
func(commands, points, x, y, rx, ry, angle, large_arc, sweep);
|
||||
content = *end;
|
||||
|
||||
*current_x = x;
|
||||
*current_y = y;
|
||||
}
|
||||
while (_next_isnumber(content));
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
efl_graphics_path_append_svg_path(Efl_Graphics_Path_Command **commands, double **points, const char *svg_path_data)
|
||||
{
|
||||
double current_x = 0, current_y = 0;
|
||||
char *content = (char*) svg_path_data;
|
||||
|
||||
if (!content) return EINA_FALSE;
|
||||
|
||||
while (content[0] != '\0')
|
||||
{
|
||||
while (isspace(content[0])) content++;
|
||||
|
||||
switch (content[0])
|
||||
{
|
||||
case 'M':
|
||||
if (!_efl_graphics_path_parse_pair_to(&content[1],
|
||||
&content,
|
||||
commands, points,
|
||||
¤t_x, ¤t_y,
|
||||
efl_graphics_path_append_move_to,
|
||||
EINA_FALSE))
|
||||
return EINA_FALSE;
|
||||
break;
|
||||
case 'm':
|
||||
if (!_efl_graphics_path_parse_pair_to(&content[1],
|
||||
&content,
|
||||
commands, points,
|
||||
¤t_x, ¤t_y,
|
||||
efl_graphics_path_append_move_to,
|
||||
EINA_TRUE))
|
||||
return EINA_FALSE;
|
||||
break;
|
||||
case 'z':
|
||||
efl_graphics_path_append_close(commands, points);
|
||||
content++;
|
||||
break;
|
||||
case 'L':
|
||||
if (!_efl_graphics_path_parse_pair_to(&content[1],
|
||||
&content,
|
||||
commands, points,
|
||||
¤t_x, ¤t_y,
|
||||
efl_graphics_path_append_line_to,
|
||||
EINA_FALSE))
|
||||
return EINA_FALSE;
|
||||
break;
|
||||
case 'l':
|
||||
if (!_efl_graphics_path_parse_pair_to(&content[1],
|
||||
&content,
|
||||
commands, points,
|
||||
¤t_x, ¤t_y,
|
||||
efl_graphics_path_append_line_to,
|
||||
EINA_TRUE))
|
||||
return EINA_FALSE;
|
||||
break;
|
||||
case 'H':
|
||||
if (!_efl_graphics_path_parse_double_to(&content[1],
|
||||
&content,
|
||||
commands, points,
|
||||
¤t_x, current_x, current_y,
|
||||
_efl_graphics_path_append_horizontal_to,
|
||||
EINA_FALSE))
|
||||
return EINA_FALSE;
|
||||
break;
|
||||
case 'h':
|
||||
if (!_efl_graphics_path_parse_double_to(&content[1],
|
||||
&content,
|
||||
commands, points,
|
||||
¤t_x, current_x, current_y,
|
||||
_efl_graphics_path_append_horizontal_to,
|
||||
EINA_TRUE))
|
||||
return EINA_FALSE;
|
||||
break;
|
||||
case 'V':
|
||||
if (!_efl_graphics_path_parse_double_to(&content[1],
|
||||
&content,
|
||||
commands, points,
|
||||
¤t_y, current_x, current_y,
|
||||
_efl_graphics_path_append_vertical_to,
|
||||
EINA_FALSE))
|
||||
return EINA_FALSE;
|
||||
break;
|
||||
case 'v':
|
||||
if (!_efl_graphics_path_parse_double_to(&content[1],
|
||||
&content,
|
||||
commands, points,
|
||||
¤t_y, current_x, current_y,
|
||||
_efl_graphics_path_append_vertical_to,
|
||||
EINA_TRUE))
|
||||
return EINA_FALSE;
|
||||
break;
|
||||
case 'C':
|
||||
if (!_efl_graphics_path_parse_six_to(&content[1],
|
||||
&content,
|
||||
commands, points,
|
||||
¤t_x, ¤t_y,
|
||||
efl_graphics_path_append_cubic_to,
|
||||
EINA_FALSE))
|
||||
return EINA_FALSE;
|
||||
break;
|
||||
case 'c':
|
||||
if (!_efl_graphics_path_parse_six_to(&content[1],
|
||||
&content,
|
||||
commands, points,
|
||||
¤t_x, ¤t_y,
|
||||
efl_graphics_path_append_cubic_to,
|
||||
EINA_TRUE))
|
||||
return EINA_FALSE;
|
||||
break;
|
||||
case 'S':
|
||||
if (!_efl_graphics_path_parse_quad_to(&content[1],
|
||||
&content,
|
||||
commands, points,
|
||||
¤t_x, ¤t_y,
|
||||
efl_graphics_path_append_scubic_to,
|
||||
EINA_FALSE))
|
||||
return EINA_FALSE;
|
||||
break;
|
||||
case 's':
|
||||
if (!_efl_graphics_path_parse_quad_to(&content[1],
|
||||
&content,
|
||||
commands, points,
|
||||
¤t_x, ¤t_y,
|
||||
efl_graphics_path_append_scubic_to,
|
||||
EINA_TRUE))
|
||||
return EINA_FALSE;
|
||||
break;
|
||||
case 'Q':
|
||||
if (!_efl_graphics_path_parse_quad_to(&content[1],
|
||||
&content,
|
||||
commands, points,
|
||||
¤t_x, ¤t_y,
|
||||
efl_graphics_path_append_quadratic_to,
|
||||
EINA_FALSE))
|
||||
return EINA_FALSE;
|
||||
break;
|
||||
case 'q':
|
||||
if (!_efl_graphics_path_parse_quad_to(&content[1],
|
||||
&content,
|
||||
commands, points,
|
||||
¤t_x, ¤t_y,
|
||||
efl_graphics_path_append_quadratic_to,
|
||||
EINA_TRUE))
|
||||
return EINA_FALSE;
|
||||
break;
|
||||
case 'T':
|
||||
if (!_efl_graphics_path_parse_pair_to(&content[1],
|
||||
&content,
|
||||
commands, points,
|
||||
¤t_x, ¤t_y,
|
||||
efl_graphics_path_append_squadratic_to,
|
||||
EINA_FALSE))
|
||||
return EINA_FALSE;
|
||||
break;
|
||||
case 't':
|
||||
if (!_efl_graphics_path_parse_pair_to(&content[1],
|
||||
&content,
|
||||
commands, points,
|
||||
¤t_x, ¤t_y,
|
||||
efl_graphics_path_append_squadratic_to,
|
||||
EINA_TRUE))
|
||||
return EINA_FALSE;
|
||||
break;
|
||||
case 'A':
|
||||
if (!_efl_graphics_path_parse_arc_to(&content[1],
|
||||
&content,
|
||||
commands, points,
|
||||
¤t_x, ¤t_y,
|
||||
efl_graphics_path_append_arc_to,
|
||||
EINA_FALSE))
|
||||
return EINA_FALSE;
|
||||
break;
|
||||
case 'a':
|
||||
if (!_efl_graphics_path_parse_arc_to(&content[1],
|
||||
&content,
|
||||
commands, points,
|
||||
¤t_x, ¤t_y,
|
||||
efl_graphics_path_append_arc_to,
|
||||
EINA_TRUE))
|
||||
return EINA_FALSE;
|
||||
break;
|
||||
default:
|
||||
return EINA_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
|
@ -1,67 +0,0 @@
|
|||
#ifndef EFL_GRAPHICS_UTILS_H_
|
||||
# define EFL_GRAPHICS_UTILS_H_
|
||||
|
||||
EAPI Eina_Bool
|
||||
efl_graphics_path_dup(Efl_Graphics_Path_Command **out_cmd, double **out_pts,
|
||||
const Efl_Graphics_Path_Command *in_cmd, const double *in_pts);
|
||||
|
||||
EAPI void
|
||||
efl_graphics_path_append_move_to(Efl_Graphics_Path_Command **commands, double **points,
|
||||
double x, double y);
|
||||
|
||||
EAPI void
|
||||
efl_graphics_path_append_line_to(Efl_Graphics_Path_Command **commands, double **points,
|
||||
double x, double y);
|
||||
|
||||
EAPI void
|
||||
efl_graphics_path_append_quadratic_to(Efl_Graphics_Path_Command **commands, double **points,
|
||||
double x, double y, double ctrl_x, double ctrl_y);
|
||||
|
||||
EAPI void
|
||||
efl_graphics_path_append_squadratic_to(Efl_Graphics_Path_Command **commands, double **points,
|
||||
double x, double y);
|
||||
|
||||
EAPI void
|
||||
efl_graphics_path_append_cubic_to(Efl_Graphics_Path_Command **commands, double **points,
|
||||
double x, double y,
|
||||
double ctrl_x0, double ctrl_y0,
|
||||
double ctrl_x1, double ctrl_y1);
|
||||
|
||||
EAPI void
|
||||
efl_graphics_path_append_scubic_to(Efl_Graphics_Path_Command **commands, double **points,
|
||||
double x, double y,
|
||||
double ctrl_x, double ctrl_y);
|
||||
|
||||
EAPI void
|
||||
efl_graphics_path_append_arc_to(Efl_Graphics_Path_Command **commands, double **points,
|
||||
double x, double y,
|
||||
double rx, double ry,
|
||||
double angle,
|
||||
Eina_Bool large_arc, Eina_Bool sweep);
|
||||
|
||||
EAPI void
|
||||
efl_graphics_path_append_close(Efl_Graphics_Path_Command **commands, double **points);
|
||||
|
||||
EAPI void
|
||||
efl_graphics_path_append_circle(Efl_Graphics_Path_Command **commands, double **points,
|
||||
double x, double y, double radius);
|
||||
|
||||
EAPI Eina_Bool
|
||||
efl_graphics_path_append_svg_path(Efl_Graphics_Path_Command **commands, double **points, const char *svg_path_data);
|
||||
|
||||
EAPI void
|
||||
efl_graphics_path_interpolate(const Efl_Graphics_Path_Command *cmd,
|
||||
double pos_map,
|
||||
const double *from, const double *to, double *r);
|
||||
|
||||
EAPI Eina_Bool
|
||||
efl_graphics_path_equal_commands(const Efl_Graphics_Path_Command *a,
|
||||
const Efl_Graphics_Path_Command *b);
|
||||
|
||||
EAPI Eina_Bool
|
||||
efl_graphics_path_current_get(const Efl_Graphics_Path_Command *cmd,
|
||||
const double *points,
|
||||
double *current_x, double *current_y,
|
||||
double *current_ctrl_x, double *current_ctrl_y);
|
||||
|
||||
#endif
|
|
@ -11,7 +11,7 @@
|
|||
#include "interfaces/efl_text.eo.c"
|
||||
#include "interfaces/efl_text_properties.eo.c"
|
||||
|
||||
#include "interfaces/efl_graphics_shape.eo.c"
|
||||
#include "interfaces/efl_graphics_gradient.eo.c"
|
||||
#include "interfaces/efl_graphics_gradient_linear.eo.c"
|
||||
#include "interfaces/efl_graphics_gradient_radial.eo.c"
|
||||
#include "interfaces/efl_gfx_shape.eo.c"
|
||||
#include "interfaces/efl_gfx_gradient.eo.c"
|
||||
#include "interfaces/efl_gfx_gradient_linear.eo.c"
|
||||
#include "interfaces/efl_gfx_gradient_radial.eo.c"
|
||||
|
|
|
@ -6,43 +6,43 @@
|
|||
#include <strings.h>
|
||||
|
||||
static void
|
||||
_evas_vg_gradient_efl_graphics_gradient_stop_set(Eo *obj EINA_UNUSED,
|
||||
Evas_VG_Gradient_Data *pd,
|
||||
const Efl_Graphics_Gradient_Stop *colors,
|
||||
unsigned int length)
|
||||
_evas_vg_gradient_efl_gfx_gradient_stop_set(Eo *obj EINA_UNUSED,
|
||||
Evas_VG_Gradient_Data *pd,
|
||||
const Efl_Gfx_Gradient_Stop *colors,
|
||||
unsigned int length)
|
||||
{
|
||||
pd->colors = realloc(pd->colors, length * sizeof(Efl_Graphics_Gradient_Stop));
|
||||
pd->colors = realloc(pd->colors, length * sizeof(Efl_Gfx_Gradient_Stop));
|
||||
if (!pd->colors)
|
||||
{
|
||||
pd->colors_count = 0;
|
||||
return ;
|
||||
}
|
||||
|
||||
memcpy(pd->colors, colors, length * sizeof(Efl_Graphics_Gradient_Stop));
|
||||
memcpy(pd->colors, colors, length * sizeof(Efl_Gfx_Gradient_Stop));
|
||||
pd->colors_count = length;
|
||||
}
|
||||
|
||||
static void
|
||||
_evas_vg_gradient_efl_graphics_gradient_stop_get(Eo *obj EINA_UNUSED,
|
||||
Evas_VG_Gradient_Data *pd,
|
||||
const Efl_Graphics_Gradient_Stop **colors,
|
||||
unsigned int *length)
|
||||
_evas_vg_gradient_efl_gfx_gradient_stop_get(Eo *obj EINA_UNUSED,
|
||||
Evas_VG_Gradient_Data *pd,
|
||||
const Efl_Gfx_Gradient_Stop **colors,
|
||||
unsigned int *length)
|
||||
{
|
||||
if (colors) *colors = pd->colors;
|
||||
if (length) *length = pd->colors_count;
|
||||
}
|
||||
|
||||
static void
|
||||
_evas_vg_gradient_efl_graphics_gradient_spread_set(Eo *obj EINA_UNUSED,
|
||||
Evas_VG_Gradient_Data *pd,
|
||||
Efl_Graphics_Gradient_Spread s)
|
||||
_evas_vg_gradient_efl_gfx_gradient_spread_set(Eo *obj EINA_UNUSED,
|
||||
Evas_VG_Gradient_Data *pd,
|
||||
Efl_Gfx_Gradient_Spread s)
|
||||
{
|
||||
pd->s = s;
|
||||
}
|
||||
|
||||
static Efl_Graphics_Gradient_Spread
|
||||
_evas_vg_gradient_efl_graphics_gradient_spread_get(Eo *obj EINA_UNUSED,
|
||||
Evas_VG_Gradient_Data *pd)
|
||||
static Efl_Gfx_Gradient_Spread
|
||||
_evas_vg_gradient_efl_gfx_gradient_spread_get(Eo *obj EINA_UNUSED,
|
||||
Evas_VG_Gradient_Data *pd)
|
||||
{
|
||||
return pd->s;
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
abstract Evas.VG_Gradient (Evas.VG_Node, Efl.Graphics.Gradient)
|
||||
abstract Evas.VG_Gradient (Evas.VG_Node, Efl.Gfx.Gradient)
|
||||
{
|
||||
eo_prefix: evas_vg_gradient;
|
||||
legacy_prefix: null;
|
||||
implements {
|
||||
Efl.Graphics.Gradient.stop.set;
|
||||
Efl.Graphics.Gradient.stop.get;
|
||||
Efl.Graphics.Gradient.spread.set;
|
||||
Efl.Graphics.Gradient.spread.get;
|
||||
Efl.Gfx.Gradient.stop.set;
|
||||
Efl.Gfx.Gradient.stop.get;
|
||||
Efl.Gfx.Gradient.spread.set;
|
||||
Efl.Gfx.Gradient.spread.get;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,36 +16,36 @@ struct _Evas_VG_Gradient_Linear_Data
|
|||
};
|
||||
|
||||
static void
|
||||
_evas_vg_gradient_linear_efl_graphics_gradient_linear_start_set(Eo *obj EINA_UNUSED,
|
||||
Evas_VG_Gradient_Linear_Data *pd,
|
||||
double x, double y)
|
||||
_evas_vg_gradient_linear_efl_gfx_gradient_linear_start_set(Eo *obj EINA_UNUSED,
|
||||
Evas_VG_Gradient_Linear_Data *pd,
|
||||
double x, double y)
|
||||
{
|
||||
pd->start.x = x;
|
||||
pd->start.y = y;
|
||||
}
|
||||
|
||||
static void
|
||||
_evas_vg_gradient_linear_efl_graphics_gradient_linear_start_get(Eo *obj EINA_UNUSED,
|
||||
Evas_VG_Gradient_Linear_Data *pd,
|
||||
double *x, double *y)
|
||||
_evas_vg_gradient_linear_efl_gfx_gradient_linear_start_get(Eo *obj EINA_UNUSED,
|
||||
Evas_VG_Gradient_Linear_Data *pd,
|
||||
double *x, double *y)
|
||||
{
|
||||
if (x) *x = pd->start.x;
|
||||
if (y) *y = pd->start.y;
|
||||
}
|
||||
|
||||
static void
|
||||
_evas_vg_gradient_linear_efl_graphics_gradient_linear_end_set(Eo *obj EINA_UNUSED,
|
||||
Evas_VG_Gradient_Linear_Data *pd,
|
||||
double x, double y)
|
||||
_evas_vg_gradient_linear_efl_gfx_gradient_linear_end_set(Eo *obj EINA_UNUSED,
|
||||
Evas_VG_Gradient_Linear_Data *pd,
|
||||
double x, double y)
|
||||
{
|
||||
pd->end.x = x;
|
||||
pd->end.y = y;
|
||||
}
|
||||
|
||||
static void
|
||||
_evas_vg_gradient_linear_efl_graphics_gradient_linear_end_get(Eo *obj EINA_UNUSED,
|
||||
Evas_VG_Gradient_Linear_Data *pd,
|
||||
double *x, double *y)
|
||||
_evas_vg_gradient_linear_efl_gfx_gradient_linear_end_get(Eo *obj EINA_UNUSED,
|
||||
Evas_VG_Gradient_Linear_Data *pd,
|
||||
double *x, double *y)
|
||||
{
|
||||
if (x) *x = pd->end.x;
|
||||
if (y) *y = pd->end.y;
|
||||
|
@ -72,10 +72,10 @@ _evas_vg_gradient_linear_render_pre(Eo *obj,
|
|||
ector_renderer_origin_set(nd->x, nd->y),
|
||||
ector_renderer_color_set(nd->r, nd->g, nd->b, nd->a),
|
||||
ector_renderer_visibility_set(nd->visibility),
|
||||
efl_graphics_gradient_stop_set(gd->colors, gd->colors_count),
|
||||
efl_graphics_gradient_spread_set(gd->s),
|
||||
efl_graphics_gradient_linear_start_set(pd->start.x, pd->start.y),
|
||||
efl_graphics_gradient_linear_end_set(pd->end.x, pd->end.y),
|
||||
efl_gfx_gradient_stop_set(gd->colors, gd->colors_count),
|
||||
efl_gfx_gradient_spread_set(gd->s),
|
||||
efl_gfx_gradient_linear_start_set(pd->start.x, pd->start.y),
|
||||
efl_gfx_gradient_linear_end_set(pd->end.x, pd->end.y),
|
||||
ector_renderer_prepare());
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
class Evas.VG_Gradient_Linear (Evas.VG_Gradient, Efl.Graphics.Gradient_Linear)
|
||||
class Evas.VG_Gradient_Linear (Evas.VG_Gradient, Efl.Gfx.Gradient_Linear)
|
||||
{
|
||||
eo_prefix: evas_vg_gradient_linear;
|
||||
legacy_prefix: null;
|
||||
implements {
|
||||
Efl.Graphics.Gradient_Linear.start.set;
|
||||
Efl.Graphics.Gradient_Linear.start.get;
|
||||
Efl.Graphics.Gradient_Linear.end.set;
|
||||
Efl.Graphics.Gradient_Linear.end.get;
|
||||
Efl.Gfx.Gradient_Linear.start.set;
|
||||
Efl.Gfx.Gradient_Linear.start.get;
|
||||
Efl.Gfx.Gradient_Linear.end.set;
|
||||
Efl.Gfx.Gradient_Linear.end.get;
|
||||
Eo.Base.constructor;
|
||||
Eo.Base.destructor;
|
||||
}
|
||||
|
|
|
@ -15,51 +15,51 @@ struct _Evas_VG_Gradient_Radial_Data
|
|||
};
|
||||
|
||||
static void
|
||||
_evas_vg_gradient_radial_efl_graphics_gradient_radial_center_set(Eo *obj EINA_UNUSED,
|
||||
Evas_VG_Gradient_Radial_Data *pd,
|
||||
double x, double y)
|
||||
_evas_vg_gradient_radial_efl_gfx_gradient_radial_center_set(Eo *obj EINA_UNUSED,
|
||||
Evas_VG_Gradient_Radial_Data *pd,
|
||||
double x, double y)
|
||||
{
|
||||
pd->center.x = x;
|
||||
pd->center.y = y;
|
||||
}
|
||||
|
||||
static void
|
||||
_evas_vg_gradient_radial_efl_graphics_gradient_radial_center_get(Eo *obj EINA_UNUSED,
|
||||
Evas_VG_Gradient_Radial_Data *pd,
|
||||
double *x, double *y)
|
||||
_evas_vg_gradient_radial_efl_gfx_gradient_radial_center_get(Eo *obj EINA_UNUSED,
|
||||
Evas_VG_Gradient_Radial_Data *pd,
|
||||
double *x, double *y)
|
||||
{
|
||||
if (x) *x = pd->center.x;
|
||||
if (y) *y = pd->center.y;
|
||||
}
|
||||
|
||||
static void
|
||||
_evas_vg_gradient_radial_efl_graphics_gradient_radial_radius_set(Eo *obj EINA_UNUSED,
|
||||
Evas_VG_Gradient_Radial_Data *pd,
|
||||
double r)
|
||||
_evas_vg_gradient_radial_efl_gfx_gradient_radial_radius_set(Eo *obj EINA_UNUSED,
|
||||
Evas_VG_Gradient_Radial_Data *pd,
|
||||
double r)
|
||||
{
|
||||
pd->radius = r;
|
||||
}
|
||||
|
||||
static double
|
||||
_evas_vg_gradient_radial_efl_graphics_gradient_radial_radius_get(Eo *obj EINA_UNUSED,
|
||||
Evas_VG_Gradient_Radial_Data *pd)
|
||||
_evas_vg_gradient_radial_efl_gfx_gradient_radial_radius_get(Eo *obj EINA_UNUSED,
|
||||
Evas_VG_Gradient_Radial_Data *pd)
|
||||
{
|
||||
return pd->radius;
|
||||
}
|
||||
|
||||
static void
|
||||
_evas_vg_gradient_radial_efl_graphics_gradient_radial_focal_set(Eo *obj EINA_UNUSED,
|
||||
Evas_VG_Gradient_Radial_Data *pd,
|
||||
double x, double y)
|
||||
_evas_vg_gradient_radial_efl_gfx_gradient_radial_focal_set(Eo *obj EINA_UNUSED,
|
||||
Evas_VG_Gradient_Radial_Data *pd,
|
||||
double x, double y)
|
||||
{
|
||||
pd->focal.x = x;
|
||||
pd->focal.y = y;
|
||||
}
|
||||
|
||||
static void
|
||||
_evas_vg_gradient_radial_efl_graphics_gradient_radial_focal_get(Eo *obj EINA_UNUSED,
|
||||
Evas_VG_Gradient_Radial_Data *pd,
|
||||
double *x, double *y)
|
||||
_evas_vg_gradient_radial_efl_gfx_gradient_radial_focal_get(Eo *obj EINA_UNUSED,
|
||||
Evas_VG_Gradient_Radial_Data *pd,
|
||||
double *x, double *y)
|
||||
{
|
||||
if (x) *x = pd->focal.x;
|
||||
if (y) *y = pd->focal.y;
|
||||
|
@ -86,11 +86,11 @@ _evas_vg_gradient_radial_render_pre(Eo *obj,
|
|||
ector_renderer_origin_set(nd->x, nd->y),
|
||||
ector_renderer_color_set(nd->r, nd->g, nd->b, nd->a),
|
||||
ector_renderer_visibility_set(nd->visibility),
|
||||
efl_graphics_gradient_stop_set(gd->colors, gd->colors_count),
|
||||
efl_graphics_gradient_spread_set(gd->s),
|
||||
efl_graphics_gradient_radial_center_set(pd->center.x, pd->center.y),
|
||||
efl_graphics_gradient_radial_focal_set(pd->focal.x, pd->focal.y),
|
||||
efl_graphics_gradient_radial_radius_set(pd->radius),
|
||||
efl_gfx_gradient_stop_set(gd->colors, gd->colors_count),
|
||||
efl_gfx_gradient_spread_set(gd->s),
|
||||
efl_gfx_gradient_radial_center_set(pd->center.x, pd->center.y),
|
||||
efl_gfx_gradient_radial_focal_set(pd->focal.x, pd->focal.y),
|
||||
efl_gfx_gradient_radial_radius_set(pd->radius),
|
||||
ector_renderer_prepare());
|
||||
}
|
||||
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
class Evas.VG_Gradient_Radial (Evas.VG_Gradient, Efl.Graphics.Gradient_Radial)
|
||||
class Evas.VG_Gradient_Radial (Evas.VG_Gradient, Efl.Gfx.Gradient_Radial)
|
||||
{
|
||||
eo_prefix: evas_vg_gradient_radial;
|
||||
legacy_prefix: null;
|
||||
implements {
|
||||
Efl.Graphics.Gradient_Radial.center.set;
|
||||
Efl.Graphics.Gradient_Radial.center.get;
|
||||
Efl.Graphics.Gradient_Radial.radius.set;
|
||||
Efl.Graphics.Gradient_Radial.radius.get;
|
||||
Efl.Graphics.Gradient_Radial.focal.set;
|
||||
Efl.Graphics.Gradient_Radial.focal.get;
|
||||
Efl.Gfx.Gradient_Radial.center.set;
|
||||
Efl.Gfx.Gradient_Radial.center.get;
|
||||
Efl.Gfx.Gradient_Radial.radius.set;
|
||||
Efl.Gfx.Gradient_Radial.radius.get;
|
||||
Efl.Gfx.Gradient_Radial.focal.set;
|
||||
Efl.Gfx.Gradient_Radial.focal.get;
|
||||
Eo.Base.constructor;
|
||||
Eo.Base.destructor;
|
||||
}
|
||||
|
|
|
@ -31,10 +31,10 @@ struct _Evas_VG_Container_Data
|
|||
struct _Evas_VG_Gradient_Data
|
||||
{
|
||||
// FIXME: Later on we should deduplicate it somehow (Using Ector ?).
|
||||
Efl_Graphics_Gradient_Stop *colors;
|
||||
Efl_Gfx_Gradient_Stop *colors;
|
||||
unsigned int colors_count;
|
||||
|
||||
Efl_Graphics_Gradient_Spread s;
|
||||
Efl_Gfx_Gradient_Spread s;
|
||||
};
|
||||
|
||||
static inline Evas_VG_Node_Data *
|
||||
|
|
|
@ -8,13 +8,13 @@
|
|||
typedef struct _Evas_VG_Shape_Data Evas_VG_Shape_Data;
|
||||
struct _Evas_VG_Shape_Data
|
||||
{
|
||||
Efl_Graphics_Path_Command *ops;
|
||||
Efl_Gfx_Path_Command *ops;
|
||||
double *points;
|
||||
|
||||
Evas_VG_Node *fill;
|
||||
|
||||
struct {
|
||||
Efl_Graphics_Dash *dash;
|
||||
Efl_Gfx_Dash *dash;
|
||||
Evas_VG_Node *fill;
|
||||
Evas_VG_Node *marker;
|
||||
|
||||
|
@ -26,30 +26,30 @@ struct _Evas_VG_Shape_Data
|
|||
|
||||
unsigned int dash_count;
|
||||
|
||||
Efl_Graphics_Cap cap;
|
||||
Efl_Graphics_Join join;
|
||||
Efl_Gfx_Cap cap;
|
||||
Efl_Gfx_Join join;
|
||||
} stroke;
|
||||
};
|
||||
|
||||
static void
|
||||
_evas_vg_shape_efl_graphics_shape_path_set(Eo *obj EINA_UNUSED,
|
||||
Evas_VG_Shape_Data *pd,
|
||||
const Efl_Graphics_Path_Command *ops,
|
||||
const double *points)
|
||||
_evas_vg_shape_efl_gfx_shape_path_set(Eo *obj EINA_UNUSED,
|
||||
Evas_VG_Shape_Data *pd,
|
||||
const Efl_Gfx_Path_Command *ops,
|
||||
const double *points)
|
||||
{
|
||||
free(pd->points);
|
||||
pd->points = NULL;
|
||||
free(pd->ops);
|
||||
pd->ops = NULL;
|
||||
|
||||
efl_graphics_path_dup(&pd->ops, &pd->points, ops, points);
|
||||
efl_gfx_path_dup(&pd->ops, &pd->points, ops, points);
|
||||
}
|
||||
|
||||
static void
|
||||
_evas_vg_shape_efl_graphics_shape_path_get(Eo *obj EINA_UNUSED,
|
||||
Evas_VG_Shape_Data *pd,
|
||||
const Efl_Graphics_Path_Command **op,
|
||||
const double **points)
|
||||
_evas_vg_shape_efl_gfx_shape_path_get(Eo *obj EINA_UNUSED,
|
||||
Evas_VG_Shape_Data *pd,
|
||||
const Efl_Gfx_Path_Command **op,
|
||||
const double **points)
|
||||
{
|
||||
if (op) *op = pd->ops;
|
||||
if (points) *points = pd->points;
|
||||
|
@ -81,24 +81,24 @@ _evas_vg_shape_fill_get(Eo *obj EINA_UNUSED, Evas_VG_Shape_Data *pd)
|
|||
}
|
||||
|
||||
static void
|
||||
_evas_vg_shape_efl_graphics_shape_stroke_scale_set(Eo *obj EINA_UNUSED,
|
||||
Evas_VG_Shape_Data *pd,
|
||||
double s)
|
||||
_evas_vg_shape_efl_gfx_shape_stroke_scale_set(Eo *obj EINA_UNUSED,
|
||||
Evas_VG_Shape_Data *pd,
|
||||
double s)
|
||||
{
|
||||
pd->stroke.scale = s;
|
||||
}
|
||||
|
||||
static double
|
||||
_evas_vg_shape_efl_graphics_shape_stroke_scale_get(Eo *obj EINA_UNUSED,
|
||||
Evas_VG_Shape_Data *pd)
|
||||
_evas_vg_shape_efl_gfx_shape_stroke_scale_get(Eo *obj EINA_UNUSED,
|
||||
Evas_VG_Shape_Data *pd)
|
||||
{
|
||||
return pd->stroke.scale;
|
||||
}
|
||||
|
||||
static void
|
||||
_evas_vg_shape_efl_graphics_shape_stroke_color_set(Eo *obj EINA_UNUSED,
|
||||
Evas_VG_Shape_Data *pd,
|
||||
int r, int g, int b, int a)
|
||||
_evas_vg_shape_efl_gfx_shape_stroke_color_set(Eo *obj EINA_UNUSED,
|
||||
Evas_VG_Shape_Data *pd,
|
||||
int r, int g, int b, int a)
|
||||
{
|
||||
pd->stroke.r = r;
|
||||
pd->stroke.g = g;
|
||||
|
@ -107,9 +107,9 @@ _evas_vg_shape_efl_graphics_shape_stroke_color_set(Eo *obj EINA_UNUSED,
|
|||
}
|
||||
|
||||
static void
|
||||
_evas_vg_shape_efl_graphics_shape_stroke_color_get(Eo *obj EINA_UNUSED,
|
||||
Evas_VG_Shape_Data *pd,
|
||||
int *r, int *g, int *b, int *a)
|
||||
_evas_vg_shape_efl_gfx_shape_stroke_color_get(Eo *obj EINA_UNUSED,
|
||||
Evas_VG_Shape_Data *pd,
|
||||
int *r, int *g, int *b, int *a)
|
||||
{
|
||||
if (r) *r = pd->stroke.r;
|
||||
if (g) *g = pd->stroke.g;
|
||||
|
@ -136,57 +136,57 @@ _evas_vg_shape_stroke_fill_get(Eo *obj EINA_UNUSED,
|
|||
}
|
||||
|
||||
static void
|
||||
_evas_vg_shape_efl_graphics_shape_stroke_width_set(Eo *obj EINA_UNUSED,
|
||||
Evas_VG_Shape_Data *pd,
|
||||
double w)
|
||||
_evas_vg_shape_efl_gfx_shape_stroke_width_set(Eo *obj EINA_UNUSED,
|
||||
Evas_VG_Shape_Data *pd,
|
||||
double w)
|
||||
{
|
||||
pd->stroke.width = w;
|
||||
}
|
||||
|
||||
static double
|
||||
_evas_vg_shape_efl_graphics_shape_stroke_width_get(Eo *obj EINA_UNUSED,
|
||||
Evas_VG_Shape_Data *pd)
|
||||
_evas_vg_shape_efl_gfx_shape_stroke_width_get(Eo *obj EINA_UNUSED,
|
||||
Evas_VG_Shape_Data *pd)
|
||||
{
|
||||
return pd->stroke.width;
|
||||
}
|
||||
|
||||
static void
|
||||
_evas_vg_shape_efl_graphics_shape_stroke_location_set(Eo *obj EINA_UNUSED,
|
||||
Evas_VG_Shape_Data *pd,
|
||||
double centered)
|
||||
_evas_vg_shape_efl_gfx_shape_stroke_location_set(Eo *obj EINA_UNUSED,
|
||||
Evas_VG_Shape_Data *pd,
|
||||
double centered)
|
||||
{
|
||||
pd->stroke.centered = centered;
|
||||
}
|
||||
|
||||
static double
|
||||
_evas_vg_shape_efl_graphics_shape_stroke_location_get(Eo *obj EINA_UNUSED,
|
||||
Evas_VG_Shape_Data *pd)
|
||||
_evas_vg_shape_efl_gfx_shape_stroke_location_get(Eo *obj EINA_UNUSED,
|
||||
Evas_VG_Shape_Data *pd)
|
||||
{
|
||||
return pd->stroke.centered;
|
||||
}
|
||||
|
||||
static void
|
||||
_evas_vg_shape_efl_graphics_shape_stroke_dash_set(Eo *obj EINA_UNUSED,
|
||||
Evas_VG_Shape_Data *pd,
|
||||
const Efl_Graphics_Dash *dash,
|
||||
unsigned int length)
|
||||
_evas_vg_shape_efl_gfx_shape_stroke_dash_set(Eo *obj EINA_UNUSED,
|
||||
Evas_VG_Shape_Data *pd,
|
||||
const Efl_Gfx_Dash *dash,
|
||||
unsigned int length)
|
||||
{
|
||||
free(pd->stroke.dash);
|
||||
pd->stroke.dash = NULL;
|
||||
pd->stroke.dash_count = 0;
|
||||
|
||||
pd->stroke.dash = malloc(sizeof (Efl_Graphics_Dash) * length);
|
||||
pd->stroke.dash = malloc(sizeof (Efl_Gfx_Dash) * length);
|
||||
if (!pd->stroke.dash) return ;
|
||||
|
||||
memcpy(pd->stroke.dash, dash, sizeof (Efl_Graphics_Dash) * length);
|
||||
memcpy(pd->stroke.dash, dash, sizeof (Efl_Gfx_Dash) * length);
|
||||
pd->stroke.dash_count = length;
|
||||
}
|
||||
|
||||
static void
|
||||
_evas_vg_shape_efl_graphics_shape_stroke_dash_get(Eo *obj EINA_UNUSED,
|
||||
Evas_VG_Shape_Data *pd,
|
||||
const Efl_Graphics_Dash **dash,
|
||||
unsigned int *length)
|
||||
_evas_vg_shape_efl_gfx_shape_stroke_dash_get(Eo *obj EINA_UNUSED,
|
||||
Evas_VG_Shape_Data *pd,
|
||||
const Efl_Gfx_Dash **dash,
|
||||
unsigned int *length)
|
||||
{
|
||||
if (dash) *dash = pd->stroke.dash;
|
||||
if (length) *length = pd->stroke.dash_count;
|
||||
|
@ -211,31 +211,31 @@ _evas_vg_shape_stroke_marker_get(Eo *obj EINA_UNUSED,
|
|||
}
|
||||
|
||||
static void
|
||||
_evas_vg_shape_efl_graphics_shape_stroke_cap_set(Eo *obj EINA_UNUSED,
|
||||
Evas_VG_Shape_Data *pd,
|
||||
Efl_Graphics_Cap c)
|
||||
_evas_vg_shape_efl_gfx_shape_stroke_cap_set(Eo *obj EINA_UNUSED,
|
||||
Evas_VG_Shape_Data *pd,
|
||||
Efl_Gfx_Cap c)
|
||||
{
|
||||
pd->stroke.cap = c;
|
||||
}
|
||||
|
||||
static Efl_Graphics_Cap
|
||||
_evas_vg_shape_efl_graphics_shape_stroke_cap_get(Eo *obj EINA_UNUSED,
|
||||
Evas_VG_Shape_Data *pd)
|
||||
static Efl_Gfx_Cap
|
||||
_evas_vg_shape_efl_gfx_shape_stroke_cap_get(Eo *obj EINA_UNUSED,
|
||||
Evas_VG_Shape_Data *pd)
|
||||
{
|
||||
return pd->stroke.cap;
|
||||
}
|
||||
|
||||
static void
|
||||
_evas_vg_shape_efl_graphics_shape_stroke_join_set(Eo *obj EINA_UNUSED,
|
||||
Evas_VG_Shape_Data *pd,
|
||||
Efl_Graphics_Join j)
|
||||
_evas_vg_shape_efl_gfx_shape_stroke_join_set(Eo *obj EINA_UNUSED,
|
||||
Evas_VG_Shape_Data *pd,
|
||||
Efl_Gfx_Join j)
|
||||
{
|
||||
pd->stroke.join = j;
|
||||
}
|
||||
|
||||
static Efl_Graphics_Join
|
||||
_evas_vg_shape_efl_graphics_shape_stroke_join_get(Eo *obj EINA_UNUSED,
|
||||
Evas_VG_Shape_Data *pd)
|
||||
static Efl_Gfx_Join
|
||||
_evas_vg_shape_efl_gfx_shape_stroke_join_get(Eo *obj EINA_UNUSED,
|
||||
Evas_VG_Shape_Data *pd)
|
||||
{
|
||||
return pd->stroke.join;
|
||||
}
|
||||
|
@ -270,17 +270,17 @@ _evas_vg_shape_render_pre(Eo *obj EINA_UNUSED,
|
|||
ector_renderer_shape_fill_set(fill ? fill->renderer : NULL),
|
||||
ector_renderer_shape_stroke_fill_set(stroke_fill ? stroke_fill->renderer : NULL),
|
||||
ector_renderer_shape_stroke_marker_set(stroke_marker ? stroke_marker->renderer : NULL),
|
||||
efl_graphics_shape_stroke_scale_set(pd->stroke.scale),
|
||||
efl_graphics_shape_stroke_color_set(pd->stroke.r,
|
||||
pd->stroke.g,
|
||||
pd->stroke.b,
|
||||
pd->stroke.a),
|
||||
efl_graphics_shape_stroke_width_set(pd->stroke.width),
|
||||
efl_graphics_shape_stroke_location_set(pd->stroke.centered),
|
||||
efl_graphics_shape_stroke_dash_set(pd->stroke.dash, pd->stroke.dash_count),
|
||||
efl_graphics_shape_stroke_cap_set(pd->stroke.cap),
|
||||
efl_graphics_shape_stroke_join_set(pd->stroke.join),
|
||||
efl_graphics_shape_path_set(pd->ops, pd->points),
|
||||
efl_gfx_shape_stroke_scale_set(pd->stroke.scale),
|
||||
efl_gfx_shape_stroke_color_set(pd->stroke.r,
|
||||
pd->stroke.g,
|
||||
pd->stroke.b,
|
||||
pd->stroke.a),
|
||||
efl_gfx_shape_stroke_width_set(pd->stroke.width),
|
||||
efl_gfx_shape_stroke_location_set(pd->stroke.centered),
|
||||
efl_gfx_shape_stroke_dash_set(pd->stroke.dash, pd->stroke.dash_count),
|
||||
efl_gfx_shape_stroke_cap_set(pd->stroke.cap),
|
||||
efl_gfx_shape_stroke_join_set(pd->stroke.join),
|
||||
efl_gfx_shape_path_set(pd->ops, pd->points),
|
||||
ector_renderer_prepare());
|
||||
}
|
||||
|
||||
|
@ -291,8 +291,8 @@ _evas_vg_shape_eo_base_constructor(Eo *obj, Evas_VG_Shape_Data *pd)
|
|||
|
||||
eo_do_super(obj, MY_CLASS, eo_constructor());
|
||||
|
||||
pd->stroke.cap = EFL_GRAPHICS_CAP_BUTT;
|
||||
pd->stroke.join = EFL_GRAPHICS_JOIN_MITER;
|
||||
pd->stroke.cap = EFL_GFX_CAP_BUTT;
|
||||
pd->stroke.join = EFL_GFX_JOIN_MITER;
|
||||
pd->stroke.scale = 1;
|
||||
pd->stroke.a = 1;
|
||||
pd->stroke.centered = 0.5;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class Evas.VG_Shape (Evas.VG_Node, Efl.Graphics.Shape)
|
||||
class Evas.VG_Shape (Evas.VG_Node, Efl.Gfx.Shape)
|
||||
{
|
||||
eo_prefix: evas_vg_shape;
|
||||
legacy_prefix: null;
|
||||
|
@ -32,14 +32,14 @@ class Evas.VG_Shape (Evas.VG_Node, Efl.Graphics.Shape)
|
|||
}
|
||||
}
|
||||
implements {
|
||||
Efl.Graphics.Shape.stroke_scale;
|
||||
Efl.Graphics.Shape.stroke_color;
|
||||
Efl.Graphics.Shape.stroke_width;
|
||||
Efl.Graphics.Shape.stroke_location;
|
||||
Efl.Graphics.Shape.stroke_dash;
|
||||
Efl.Graphics.Shape.stroke_cap;
|
||||
Efl.Graphics.Shape.stroke_join;
|
||||
Efl.Graphics.Shape.path;
|
||||
Efl.Gfx.Shape.stroke_scale;
|
||||
Efl.Gfx.Shape.stroke_color;
|
||||
Efl.Gfx.Shape.stroke_width;
|
||||
Efl.Gfx.Shape.stroke_location;
|
||||
Efl.Gfx.Shape.stroke_dash;
|
||||
Efl.Gfx.Shape.stroke_cap;
|
||||
Efl.Gfx.Shape.stroke_join;
|
||||
Efl.Gfx.Shape.path;
|
||||
Evas.VG_Node.bound_get;
|
||||
Eo.Base.constructor;
|
||||
Eo.Base.destructor;
|
||||
|
|
Loading…
Reference in New Issue