forked from enlightenment/efl
ector: simplify code by avoiding unecessary intermediate function.
This commit is contained in:
parent
ef975a9fd2
commit
9023f6d28c
|
@ -9,31 +9,6 @@
|
|||
#include "ector_private.h"
|
||||
#include "ector_software_private.h"
|
||||
|
||||
|
||||
static void
|
||||
_update_linear_data(Ector_Renderer_Software_Gradient_Data *gdata)
|
||||
{
|
||||
update_color_table(gdata);
|
||||
gdata->linear.x1 = gdata->gld->start.x;
|
||||
gdata->linear.y1 = gdata->gld->start.y;
|
||||
|
||||
gdata->linear.x2 = gdata->gld->end.x;
|
||||
gdata->linear.y2 = gdata->gld->end.y;
|
||||
|
||||
gdata->linear.dx = gdata->linear.x2 - gdata->linear.x1;
|
||||
gdata->linear.dy = gdata->linear.y2 - gdata->linear.y1;
|
||||
gdata->linear.l = gdata->linear.dx * gdata->linear.dx + gdata->linear.dy * gdata->linear.dy;
|
||||
gdata->linear.off = 0;
|
||||
|
||||
if (gdata->linear.l != 0)
|
||||
{
|
||||
gdata->linear.dx /= gdata->linear.l;
|
||||
gdata->linear.dy /= gdata->linear.l;
|
||||
gdata->linear.off = -gdata->linear.dx * gdata->linear.x1 - gdata->linear.dy * gdata->linear.y1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static Eina_Bool
|
||||
_ector_renderer_software_gradient_linear_ector_renderer_generic_base_prepare(Eo *obj,
|
||||
Ector_Renderer_Software_Gradient_Data *pd)
|
||||
|
@ -47,8 +22,25 @@ _ector_renderer_software_gradient_linear_ector_renderer_generic_base_prepare(Eo
|
|||
pd->surface = eo_data_xref(parent, ECTOR_SOFTWARE_SURFACE_CLASS, obj);
|
||||
}
|
||||
|
||||
_update_linear_data(pd);
|
||||
update_color_table(pd);
|
||||
|
||||
pd->linear.x1 = pd->gld->start.x;
|
||||
pd->linear.y1 = pd->gld->start.y;
|
||||
|
||||
pd->linear.x2 = pd->gld->end.x;
|
||||
pd->linear.y2 = pd->gld->end.y;
|
||||
|
||||
pd->linear.dx = pd->linear.x2 - pd->linear.x1;
|
||||
pd->linear.dy = pd->linear.y2 - pd->linear.y1;
|
||||
pd->linear.l = pd->linear.dx * pd->linear.dx + pd->linear.dy * pd->linear.dy;
|
||||
pd->linear.off = 0;
|
||||
|
||||
if (pd->linear.l != 0)
|
||||
{
|
||||
pd->linear.dx /= pd->linear.l;
|
||||
pd->linear.dy /= pd->linear.l;
|
||||
pd->linear.off = -pd->linear.dx * pd->linear.x1 - pd->linear.dy * pd->linear.y1;
|
||||
}
|
||||
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
|
|
@ -9,42 +9,6 @@
|
|||
#include "ector_private.h"
|
||||
#include "ector_software_private.h"
|
||||
|
||||
static void
|
||||
_update_radial_data(Ector_Renderer_Software_Gradient_Data *gdata)
|
||||
{
|
||||
update_color_table(gdata);
|
||||
|
||||
gdata->radial.cx = gdata->grd->radial.x;
|
||||
gdata->radial.cy = gdata->grd->radial.y;
|
||||
gdata->radial.cradius = gdata->grd->radius;
|
||||
|
||||
if (!gdata->grd->focal.x)
|
||||
gdata->radial.fx = gdata->grd->radial.x;
|
||||
else
|
||||
gdata->radial.fx = gdata->grd->focal.x;
|
||||
|
||||
if (!gdata->grd->focal.y)
|
||||
gdata->radial.fy = gdata->grd->radial.y;
|
||||
else
|
||||
gdata->radial.fy = gdata->grd->focal.y;
|
||||
|
||||
gdata->radial.fradius = 0;
|
||||
|
||||
gdata->radial.dx = gdata->radial.cx - gdata->radial.fx;
|
||||
gdata->radial.dy = gdata->radial.cy - gdata->radial.fy;
|
||||
|
||||
gdata->radial.dr = gdata->radial.cradius - gdata->radial.fradius;
|
||||
gdata->radial.sqrfr = gdata->radial.fradius * gdata->radial.fradius;
|
||||
|
||||
gdata->radial.a = gdata->radial.dr * gdata->radial.dr -
|
||||
gdata->radial.dx * gdata->radial.dx -
|
||||
gdata->radial.dy * gdata->radial.dy;
|
||||
gdata->radial.inv2a = 1 / (2 * gdata->radial.a);
|
||||
|
||||
gdata->radial.extended = (gdata->radial.fradius >= 0.00001f) || gdata->radial.a >= 0.00001f;
|
||||
}
|
||||
|
||||
|
||||
static Eina_Bool
|
||||
_ector_renderer_software_gradient_radial_ector_renderer_generic_base_prepare(Eo *obj, Ector_Renderer_Software_Gradient_Data *pd)
|
||||
{
|
||||
|
@ -57,7 +21,37 @@ _ector_renderer_software_gradient_radial_ector_renderer_generic_base_prepare(Eo
|
|||
pd->surface = eo_data_xref(parent, ECTOR_SOFTWARE_SURFACE_CLASS, obj);
|
||||
}
|
||||
|
||||
_update_radial_data(pd);
|
||||
update_color_table(pd);
|
||||
|
||||
pd->radial.cx = pd->grd->radial.x;
|
||||
pd->radial.cy = pd->grd->radial.y;
|
||||
pd->radial.cradius = pd->grd->radius;
|
||||
|
||||
if (!pd->grd->focal.x)
|
||||
pd->radial.fx = pd->grd->radial.x;
|
||||
else
|
||||
pd->radial.fx = pd->grd->focal.x;
|
||||
|
||||
if (!pd->grd->focal.y)
|
||||
pd->radial.fy = pd->grd->radial.y;
|
||||
else
|
||||
pd->radial.fy = pd->grd->focal.y;
|
||||
|
||||
pd->radial.fradius = 0;
|
||||
|
||||
pd->radial.dx = pd->radial.cx - pd->radial.fx;
|
||||
pd->radial.dy = pd->radial.cy - pd->radial.fy;
|
||||
|
||||
pd->radial.dr = pd->radial.cradius - pd->radial.fradius;
|
||||
pd->radial.sqrfr = pd->radial.fradius * pd->radial.fradius;
|
||||
|
||||
pd->radial.a = pd->radial.dr * pd->radial.dr -
|
||||
pd->radial.dx * pd->radial.dx -
|
||||
pd->radial.dy * pd->radial.dy;
|
||||
pd->radial.inv2a = 1 / (2 * pd->radial.a);
|
||||
|
||||
pd->radial.extended = (pd->radial.fradius >= 0.00001f) || pd->radial.a >= 0.00001f;
|
||||
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue