From 659d3c4fd7bb49a440662f036af2e0a9b71711c2 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:12:48 +0200 Subject: [PATCH 001/251] eina: add eina_matrix. This code come from Enesim and was done by Jorge. I did just take care of changing the namespace and coding style. --- src/Makefile_Eina.am | 8 +- src/lib/eina/Eina.h | 1 + src/lib/eina/eina_matrix.c | 586 +++++++++++++++++++++++++++++++++++++ src/lib/eina/eina_matrix.h | 339 +++++++++++++++++++++ src/lib/eina/eina_quad.c | 127 ++++++++ src/lib/eina/eina_quad.h | 67 +++++ 6 files changed, 1126 insertions(+), 2 deletions(-) create mode 100644 src/lib/eina/eina_matrix.c create mode 100644 src/lib/eina/eina_matrix.h create mode 100644 src/lib/eina/eina_quad.c create mode 100644 src/lib/eina/eina_quad.h diff --git a/src/Makefile_Eina.am b/src/Makefile_Eina.am index 6341cd1268..ae41cc8090 100644 --- a/src/Makefile_Eina.am +++ b/src/Makefile_Eina.am @@ -85,7 +85,9 @@ lib/eina/eina_tmpstr.h \ lib/eina/eina_alloca.h \ lib/eina/eina_cow.h \ lib/eina/eina_inline_unicode.x \ -lib/eina/eina_thread_queue.h +lib/eina/eina_thread_queue.h \ +lib/eina/eina_matrix.h \ +lib/eina/eina_quad.h # Will be back for developper after 1.2. # lib/eina/eina_model.h @@ -144,7 +146,9 @@ lib/eina/eina_xattr.c \ lib/eina/eina_share_common.h \ lib/eina/eina_private.h \ lib/eina/eina_strbuf_common.h \ -lib/eina/eina_thread_queue.c +lib/eina/eina_thread_queue.c \ +lib/eina/eina_matrix.c \ +lib/eina/eina_quad.c # Will be back for developper after 1.2 # lib/eina/eina_model.c \ diff --git a/src/lib/eina/Eina.h b/src/lib/eina/Eina.h index f7283f7a9c..0f6851a5e4 100644 --- a/src/lib/eina/Eina.h +++ b/src/lib/eina/Eina.h @@ -262,6 +262,7 @@ extern "C" { #include #include #include +#include #ifdef __cplusplus } diff --git a/src/lib/eina/eina_matrix.c b/src/lib/eina/eina_matrix.c new file mode 100644 index 0000000000..dc2e65cc21 --- /dev/null +++ b/src/lib/eina/eina_matrix.c @@ -0,0 +1,586 @@ +/* EINA - Drawing Library + * Copyright (C) 2007-2014 Jorge Luis Zapata + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. + * If not, see . + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include "eina_private.h" + +#include + +#include "eina_fp.h" +#include "eina_rectangle.h" +#include "eina_quad.h" +#include "eina_matrix.h" + +#define MATRIX_XX(m) (m)->xx +#define MATRIX_XY(m) (m)->xy +#define MATRIX_XZ(m) (m)->xz +#define MATRIX_YX(m) (m)->yx +#define MATRIX_YY(m) (m)->yy +#define MATRIX_YZ(m) (m)->yz +#define MATRIX_ZX(m) (m)->zx +#define MATRIX_ZY(m) (m)->zy +#define MATRIX_ZZ(m) (m)->zz +#define MATRIX_SIZE 9 + +#define QUAD_X0(q) q->x0 +#define QUAD_Y0(q) q->y0 +#define QUAD_X1(q) q->x1 +#define QUAD_Y1(q) q->y1 +#define QUAD_X2(q) q->x2 +#define QUAD_Y2(q) q->y2 +#define QUAD_X3(q) q->x3 +#define QUAD_Y3(q) q->y3 + +/*============================================================================* + * Local * + *============================================================================*/ +/** @cond internal */ +/* + * In the range [-pi pi] + * (4/pi)*x - ((4/(pi*pi))*x*abs(x)) + * http://www.devmaster.net/forums/showthread.php?t=5784 + */ +#define EXTRA_PRECISION +static inline double + _sin(double x) +{ + const double B = 4/M_PI; + const double C = -4/(M_PI*M_PI); + + double y = (B * x) + (C * x * fabsf(x)); + +#ifdef EXTRA_PRECISION + // const float Q = 0.775; + const double P = 0.225; + + y = P * (y * fabsf(y) - y) + y; // Q * y + P * y * abs(y) +#endif + return y; +} + +static inline double +_cos(double x) +{ + x += M_PI_2; + + if (x > M_PI) // Original x > pi/2 + { + x -= 2 * M_PI; // Wrap: cos(x) = cos(x - 2 pi) + } + + return _sin(x); +} +/** @endcond */ + +/*============================================================================* + * API * + *============================================================================*/ +EAPI Eina_Matrix_Type +eina_matrix3_type_get(const Eina_Matrix3 *m) +{ + if ((MATRIX_ZX(m) != 0) || (MATRIX_ZY(m) != 0) || (MATRIX_ZZ(m) != 1)) + return EINA_MATRIX_TYPE_PROJECTIVE; + else + { + if ((MATRIX_XX(m) == 1) && (MATRIX_XY(m) == 0) && (MATRIX_XZ(m) == 0) && + (MATRIX_YX(m) == 0) && (MATRIX_YY(m) == 1) && (MATRIX_YZ(m) == 0)) + return EINA_MATRIX_TYPE_IDENTITY; + else + return EINA_MATRIX_TYPE_AFFINE; + } +} + +EAPI Eina_Matrix_Type +eina_matrix3_f16p16_type_get(const Eina_Matrix3_F16p16 *m) +{ + if ((MATRIX_ZX(m) != 0) || (MATRIX_ZY(m) != 0) || (MATRIX_ZZ(m) != 65536)) + return EINA_MATRIX_TYPE_PROJECTIVE; + else + { + if ((MATRIX_XX(m) == 65536) && (MATRIX_XY(m) == 0) && (MATRIX_XZ(m) == 0) && + (MATRIX_YX(m) == 0) && (MATRIX_YY(m) == 65536) && (MATRIX_YZ(m) == 0)) + return EINA_MATRIX_TYPE_IDENTITY; + else + return EINA_MATRIX_TYPE_AFFINE; + } +} + +EAPI void +eina_matrix3_values_set(Eina_Matrix3 *m, + double xx, double xy, double xz, + double yx, double yy, double yz, + double zx, double zy, double zz) +{ + MATRIX_XX(m) = xx; + MATRIX_XY(m) = xy; + MATRIX_XZ(m) = xz; + MATRIX_YX(m) = yx; + MATRIX_YY(m) = yy; + MATRIX_YZ(m) = yz; + MATRIX_ZX(m) = zx; + MATRIX_ZY(m) = zy; + MATRIX_ZZ(m) = zz; +} + +EAPI void +eina_matrix3_values_get(const Eina_Matrix3 *m, + double *xx, double *xy, double *xz, + double *yx, double *yy, double *yz, + double *zx, double *zy, double *zz) +{ + if (xx) *xx = MATRIX_XX(m); + if (xy) *xy = MATRIX_XY(m); + if (xz) *xz = MATRIX_XZ(m); + if (yx) *yx = MATRIX_YX(m); + if (yy) *yy = MATRIX_YY(m); + if (yz) *yz = MATRIX_YZ(m); + if (zx) *zx = MATRIX_ZX(m); + if (zy) *zy = MATRIX_ZY(m); + if (zz) *zz = MATRIX_ZZ(m); +} + +EAPI void +eina_matrix3_fixed_values_get(const Eina_Matrix3 *m, + Eina_F16p16 *xx, Eina_F16p16 *xy, Eina_F16p16 *xz, + Eina_F16p16 *yx, Eina_F16p16 *yy, Eina_F16p16 *yz, + Eina_F16p16 *zx, Eina_F16p16 *zy, Eina_F16p16 *zz) +{ + if (xx) *xx = eina_f16p16_double_from(MATRIX_XX(m)); + if (xy) *xy = eina_f16p16_double_from(MATRIX_XY(m)); + if (xz) *xz = eina_f16p16_double_from(MATRIX_XZ(m)); + if (yx) *yx = eina_f16p16_double_from(MATRIX_YX(m)); + if (yy) *yy = eina_f16p16_double_from(MATRIX_YY(m)); + if (yz) *yz = eina_f16p16_double_from(MATRIX_YZ(m)); + if (zx) *zx = eina_f16p16_double_from(MATRIX_ZX(m)); + if (zy) *zy = eina_f16p16_double_from(MATRIX_ZY(m)); + if (zz) *zz = eina_f16p16_double_from(MATRIX_ZZ(m)); +} + +EAPI void +eina_matrix3_matrix3_f16p16_to(const Eina_Matrix3 *m, + Eina_Matrix3_F16p16 *fm) +{ + eina_matrix3_fixed_values_get(m, + &fm->xx, &fm->xy, &fm->xz, + &fm->yx, &fm->yy, &fm->yz, + &fm->zx, &fm->zy, &fm->zz); +} + +EAPI void +eina_matrix3_point_transform(const Eina_Matrix3 *m, + double x, double y, + double *xr, double *yr) +{ + double xrr, yrr; + + if (!MATRIX_ZX(m) && !MATRIX_ZY(m)) + { + xrr = (x * MATRIX_XX(m) + y * MATRIX_XY(m) + MATRIX_XZ(m)); + yrr = (x * MATRIX_YX(m) + y * MATRIX_YY(m) + MATRIX_YZ(m)); + } + else + { + xrr = (x * MATRIX_XX(m) + y * MATRIX_XY(m) + MATRIX_XZ(m)) / + (x * MATRIX_ZX(m) + y * MATRIX_ZY(m) + MATRIX_ZZ(m)); + yrr = (x * MATRIX_YX(m) + y * MATRIX_YY(m) + MATRIX_YZ(m)) / + (x * MATRIX_ZX(m) + y * MATRIX_ZY(m) + MATRIX_ZZ(m)); + } + + if (xr) *xr = xrr; + if (yr) *yr = yrr; +} + +EAPI void +eina_matrix3_rectangle_transform(const Eina_Matrix3 *m, + const Eina_Rectangle *r, + const Eina_Quad *q) +{ + eina_matrix3_point_transform(m, r->x, r->y, &((Eina_Quad *)q)->x0, &((Eina_Quad *)q)->y0); + eina_matrix3_point_transform(m, r->x + r->w, r->y, &((Eina_Quad *)q)->x1, &((Eina_Quad *)q)->y1); + eina_matrix3_point_transform(m, r->x + r->w, r->y + r->h, &((Eina_Quad *)q)->x2, &((Eina_Quad *)q)->y2); + eina_matrix3_point_transform(m, r->x, r->y + r->h, &((Eina_Quad *)q)->x3, &((Eina_Quad *)q)->y3); +} + +EAPI void +eina_matrix3_cofactor(const Eina_Matrix3 *m, Eina_Matrix3 *a) +{ + double a11, a12, a13, a21, a22, a23, a31, a32, a33; + + a11 = (MATRIX_YY(m) * MATRIX_ZZ(m)) - (MATRIX_YZ(m) * MATRIX_ZY(m)); + a12 = -1 * ((MATRIX_YX(m) * MATRIX_ZZ(m)) - (MATRIX_YZ(m) * MATRIX_ZX(m))); + a13 = (MATRIX_YX(m) * MATRIX_ZY(m)) - (MATRIX_YY(m) * MATRIX_ZX(m)); + + a21 = -1 * ((MATRIX_XY(m) * MATRIX_ZZ(m)) - (MATRIX_XZ(m) * MATRIX_ZY(m))); + a22 = (MATRIX_XX(m) * MATRIX_ZZ(m)) - (MATRIX_XZ(m) * MATRIX_ZX(m)); + a23 = -1 * ((MATRIX_XX(m) * MATRIX_ZY(m)) - (MATRIX_XY(m) * MATRIX_ZX(m))); + + a31 = (MATRIX_XY(m) * MATRIX_YZ(m)) - (MATRIX_XZ(m) * MATRIX_YY(m)); + a32 = -1 * ((MATRIX_XX(m) * MATRIX_YZ(m)) - (MATRIX_XZ(m) * MATRIX_YX(m))); + a33 = (MATRIX_XX(m) * MATRIX_YY(m)) - (MATRIX_XY(m) * MATRIX_YX(m)); + + MATRIX_XX(a) = a11; + MATRIX_XY(a) = a12; + MATRIX_XZ(a) = a13; + + MATRIX_YX(a) = a21; + MATRIX_YY(a) = a22; + MATRIX_YZ(a) = a23; + + MATRIX_ZX(a) = a31; + MATRIX_ZY(a) = a32; + MATRIX_ZZ(a) = a33; +} + +EAPI void +eina_matrix3_transpose(const Eina_Matrix3 *m, Eina_Matrix3 *a) +{ + MATRIX_XX(a) = MATRIX_XX(m); + MATRIX_XY(a) = MATRIX_YX(m); + MATRIX_XZ(a) = MATRIX_ZX(m); + + MATRIX_YX(a) = MATRIX_XY(m); + MATRIX_YY(a) = MATRIX_YY(m); + MATRIX_YZ(a) = MATRIX_ZY(m); + + MATRIX_ZX(a) = MATRIX_XZ(m); + MATRIX_ZY(a) = MATRIX_YZ(m); + MATRIX_ZZ(a) = MATRIX_ZZ(m); +} + +EAPI void +eina_matrix3_adjoint(const Eina_Matrix3 *m, Eina_Matrix3 *a) +{ + Eina_Matrix3 cofactor; + + /* cofactor */ + eina_matrix3_cofactor(m, &cofactor); + /* transpose */ + eina_matrix3_transpose(&cofactor, a); +} + +EAPI double +eina_matrix3_determinant(const Eina_Matrix3 *m) +{ + double det; + + det = MATRIX_XX(m) * ((MATRIX_YY(m) * MATRIX_ZZ(m)) - (MATRIX_YZ(m) * MATRIX_ZY(m))); + det -= MATRIX_XY(m) * ((MATRIX_YX(m) * MATRIX_ZZ(m)) - (MATRIX_YZ(m) * MATRIX_ZX(m))); + det += MATRIX_XZ(m) * ((MATRIX_YX(m) * MATRIX_ZY(m)) - (MATRIX_YY(m) * MATRIX_ZX(m))); + + return det; +} + +EAPI void +eina_matrix3_divide(Eina_Matrix3 *m, double scalar) +{ + MATRIX_XX(m) /= scalar; + MATRIX_XY(m) /= scalar; + MATRIX_XZ(m) /= scalar; + + MATRIX_YX(m) /= scalar; + MATRIX_YY(m) /= scalar; + MATRIX_YZ(m) /= scalar; + + MATRIX_ZX(m) /= scalar; + MATRIX_ZY(m) /= scalar; + MATRIX_ZZ(m) /= scalar; +} + +EAPI void +eina_matrix3_inverse(const Eina_Matrix3 *m, Eina_Matrix3 *m2) +{ + double scalar; + + /* determinant */ + scalar = eina_matrix3_determinant(m); + if (!scalar) + { + eina_matrix3_identity(m2); + return; + } + /* do its adjoint */ + eina_matrix3_adjoint(m, m2); + /* divide */ + eina_matrix3_divide(m2, scalar); +} + +EAPI void +eina_matrix3_compose(const Eina_Matrix3 *m1, + const Eina_Matrix3 *m2, + Eina_Matrix3 *dst) +{ + double a11, a12, a13, a21, a22, a23, a31, a32, a33; + + a11 = (MATRIX_XX(m1) * MATRIX_XX(m2)) + (MATRIX_XY(m1) * MATRIX_YX(m2)) + (MATRIX_XZ(m1) * MATRIX_ZX(m2)); + a12 = (MATRIX_XX(m1) * MATRIX_XY(m2)) + (MATRIX_XY(m1) * MATRIX_YY(m2)) + (MATRIX_XZ(m1) * MATRIX_ZY(m2)); + a13 = (MATRIX_XX(m1) * MATRIX_XZ(m2)) + (MATRIX_XY(m1) * MATRIX_YZ(m2)) + (MATRIX_XZ(m1) * MATRIX_ZZ(m2)); + + a21 = (MATRIX_YX(m1) * MATRIX_XX(m2)) + (MATRIX_YY(m1) * MATRIX_YX(m2)) + (MATRIX_YZ(m1) * MATRIX_ZX(m2)); + a22 = (MATRIX_YX(m1) * MATRIX_XY(m2)) + (MATRIX_YY(m1) * MATRIX_YY(m2)) + (MATRIX_YZ(m1) * MATRIX_ZY(m2)); + a23 = (MATRIX_YX(m1) * MATRIX_XZ(m2)) + (MATRIX_YY(m1) * MATRIX_YZ(m2)) + (MATRIX_YZ(m1) * MATRIX_ZZ(m2)); + + a31 = (MATRIX_ZX(m1) * MATRIX_XX(m2)) + (MATRIX_ZY(m1) * MATRIX_YX(m2)) + (MATRIX_ZZ(m1) * MATRIX_ZX(m2)); + a32 = (MATRIX_ZX(m1) * MATRIX_XY(m2)) + (MATRIX_ZY(m1) * MATRIX_YY(m2)) + (MATRIX_ZZ(m1) * MATRIX_ZY(m2)); + a33 = (MATRIX_ZX(m1) * MATRIX_XZ(m2)) + (MATRIX_ZY(m1) * MATRIX_YZ(m2)) + (MATRIX_ZZ(m1) * MATRIX_ZZ(m2)); + + MATRIX_XX(dst) = a11; + MATRIX_XY(dst) = a12; + MATRIX_XZ(dst) = a13; + MATRIX_YX(dst) = a21; + MATRIX_YY(dst) = a22; + MATRIX_YZ(dst) = a23; + MATRIX_ZX(dst) = a31; + MATRIX_ZY(dst) = a32; + MATRIX_ZZ(dst) = a33; +} + +EAPI Eina_Bool +eina_matrix3_equal(const Eina_Matrix3 *m1, const Eina_Matrix3 *m2) +{ + if (m1->xx != m2->xx || + m1->xy != m2->xy || + m1->xz != m2->xz || + m1->yx != m2->yx || + m1->yy != m2->yy || + m1->yz != m2->yz || + m1->zx != m2->zx || + m1->zy != m2->zy || + m1->zz != m2->zz) + return EINA_FALSE; + return EINA_TRUE; +} + +EAPI void +eina_matrix3_f16p16_compose(const Eina_Matrix3_F16p16 *m1, + const Eina_Matrix3_F16p16 *m2, + Eina_Matrix3_F16p16 *dst) +{ + Eina_F16p16 a11, a12, a13, a21, a22, a23, a31, a32, a33; + + a11 = eina_f16p16_mul(MATRIX_XX(m1), MATRIX_XX(m2)) + + eina_f16p16_mul(MATRIX_XY(m1), MATRIX_YX(m2)) + + eina_f16p16_mul(MATRIX_XZ(m1), MATRIX_ZX(m2)); + a12 = eina_f16p16_mul(MATRIX_XX(m1), MATRIX_XY(m2)) + + eina_f16p16_mul(MATRIX_XY(m1), MATRIX_YY(m2)) + + eina_f16p16_mul(MATRIX_XZ(m1), MATRIX_ZY(m2)); + a13 = eina_f16p16_mul(MATRIX_XX(m1), MATRIX_XZ(m2)) + + eina_f16p16_mul(MATRIX_XY(m1), MATRIX_YZ(m2)) + + eina_f16p16_mul(MATRIX_XZ(m1), MATRIX_ZZ(m2)); + + a21 = eina_f16p16_mul(MATRIX_YX(m1), MATRIX_XX(m2)) + + eina_f16p16_mul(MATRIX_YY(m1), MATRIX_YX(m2)) + + eina_f16p16_mul(MATRIX_YZ(m1), MATRIX_ZX(m2)); + a22 = eina_f16p16_mul(MATRIX_YX(m1), MATRIX_XY(m2)) + + eina_f16p16_mul(MATRIX_YY(m1), MATRIX_YY(m2)) + + eina_f16p16_mul(MATRIX_YZ(m1), MATRIX_ZY(m2)); + a23 = eina_f16p16_mul(MATRIX_YX(m1), MATRIX_XZ(m2)) + + eina_f16p16_mul(MATRIX_YY(m1), MATRIX_YZ(m2)) + + eina_f16p16_mul(MATRIX_YZ(m1), MATRIX_ZZ(m2)); + + a31 = eina_f16p16_mul(MATRIX_ZX(m1), MATRIX_XX(m2)) + + eina_f16p16_mul(MATRIX_ZY(m1), MATRIX_YX(m2)) + + eina_f16p16_mul(MATRIX_ZZ(m1), MATRIX_ZX(m2)); + a32 = eina_f16p16_mul(MATRIX_ZX(m1), MATRIX_XY(m2)) + + eina_f16p16_mul(MATRIX_ZY(m1), MATRIX_YY(m2)) + + eina_f16p16_mul(MATRIX_ZZ(m1), MATRIX_ZY(m2)); + a33 = eina_f16p16_mul(MATRIX_ZX(m1), MATRIX_XZ(m2)) + + eina_f16p16_mul(MATRIX_ZY(m1), MATRIX_YZ(m2)) + + eina_f16p16_mul(MATRIX_ZZ(m1), MATRIX_ZZ(m2)); + + MATRIX_XX(dst) = a11; + MATRIX_XY(dst) = a12; + MATRIX_XZ(dst) = a13; + MATRIX_YX(dst) = a21; + MATRIX_YY(dst) = a22; + MATRIX_YZ(dst) = a23; + MATRIX_ZX(dst) = a31; + MATRIX_ZY(dst) = a32; + MATRIX_ZZ(dst) = a33; +} + +EAPI void +eina_matrix3_translate(Eina_Matrix3 *m, double tx, double ty) +{ + MATRIX_XX(m) = 1; + MATRIX_XY(m) = 0; + MATRIX_XZ(m) = tx; + MATRIX_YX(m) = 0; + MATRIX_YY(m) = 1; + MATRIX_YZ(m) = ty; + MATRIX_ZX(m) = 0; + MATRIX_ZY(m) = 0; + MATRIX_ZZ(m) = 1; +} + +EAPI void +eina_matrix3_scale(Eina_Matrix3 *m, double sx, double sy) +{ + MATRIX_XX(m) = sx; + MATRIX_XY(m) = 0; + MATRIX_XZ(m) = 0; + MATRIX_YX(m) = 0; + MATRIX_YY(m) = sy; + MATRIX_YZ(m) = 0; + MATRIX_ZX(m) = 0; + MATRIX_ZY(m) = 0; + MATRIX_ZZ(m) = 1; +} + +EAPI void +eina_matrix3_rotate(Eina_Matrix3 *m, double rad) +{ + double c, s; +#if 0 + c = cosf(rad); + s = sinf(rad); +#else + /* normalize the angle between -pi,pi */ + rad = fmod(rad + M_PI, 2 * M_PI) - M_PI; + c = _cos(rad); + s = _sin(rad); +#endif + + MATRIX_XX(m) = c; + MATRIX_XY(m) = -s; + MATRIX_XZ(m) = 0; + MATRIX_YX(m) = s; + MATRIX_YY(m) = c; + MATRIX_YZ(m) = 0; + MATRIX_ZX(m) = 0; + MATRIX_ZY(m) = 0; + MATRIX_ZZ(m) = 1; +} + +EAPI void +eina_matrix3_identity(Eina_Matrix3 *m) +{ + MATRIX_XX(m) = 1; + MATRIX_XY(m) = 0; + MATRIX_XZ(m) = 0; + MATRIX_YX(m) = 0; + MATRIX_YY(m) = 1; + MATRIX_YZ(m) = 0; + MATRIX_ZX(m) = 0; + MATRIX_ZY(m) = 0; + MATRIX_ZZ(m) = 1; +} + +EAPI void +eina_matrix3_f16p16_identity(Eina_Matrix3_F16p16 *m) +{ + MATRIX_XX(m) = 65536; + MATRIX_XY(m) = 0; + MATRIX_XZ(m) = 0; + MATRIX_YX(m) = 0; + MATRIX_YY(m) = 65536; + MATRIX_YZ(m) = 0; + MATRIX_ZX(m) = 0; + MATRIX_ZY(m) = 0; + MATRIX_ZZ(m) = 65536; +} + +EAPI Eina_Bool +eina_matrix3_square_quad_map(Eina_Matrix3 *m, const Eina_Quad *q) +{ + // x0 - x1 + x2 - x3 + double ex = QUAD_X0(q) - QUAD_X1(q) + QUAD_X2(q) - QUAD_X3(q); + // y0 - y1 + y2 - y3 + double ey = QUAD_Y0(q) - QUAD_Y1(q) + QUAD_Y2(q) - QUAD_Y3(q); + + /* paralellogram */ + if (!ex && !ey) + { + /* create the affine matrix */ + MATRIX_XX(m) = QUAD_X1(q) - QUAD_X0(q); + MATRIX_XY(m) = QUAD_X2(q) - QUAD_X1(q); + MATRIX_XZ(m) = QUAD_X0(q); + + MATRIX_YX(m) = QUAD_Y1(q) - QUAD_Y0(q); + MATRIX_YY(m) = QUAD_Y2(q) - QUAD_Y1(q); + MATRIX_YZ(m) = QUAD_Y0(q); + + MATRIX_ZX(m) = 0; + MATRIX_ZY(m) = 0; + MATRIX_ZZ(m) = 1; + + return EINA_TRUE; + } + else + { + double dx1 = QUAD_X1(q) - QUAD_X2(q); // x1 - x2 + double dx2 = QUAD_X3(q) - QUAD_X2(q); // x3 - x2 + double dy1 = QUAD_Y1(q) - QUAD_Y2(q); // y1 - y2 + double dy2 = QUAD_Y3(q) - QUAD_Y2(q); // y3 - y2 + double den = (dx1 * dy2) - (dx2 * dy1); + + if (!den) + return EINA_FALSE; + + MATRIX_ZX(m) = ((ex * dy2) - (dx2 * ey)) / den; + MATRIX_ZY(m) = ((dx1 * ey) - (ex * dy1)) / den; + MATRIX_ZZ(m) = 1; + MATRIX_XX(m) = QUAD_X1(q) - QUAD_X0(q) + (MATRIX_ZX(m) * QUAD_X1(q)); + MATRIX_XY(m) = QUAD_X3(q) - QUAD_X0(q) + (MATRIX_ZY(m) * QUAD_X3(q)); + MATRIX_XZ(m) = QUAD_X0(q); + MATRIX_YX(m) = QUAD_Y1(q) - QUAD_Y0(q) + (MATRIX_ZX(m) * QUAD_Y1(q)); + MATRIX_YY(m) = QUAD_Y3(q) - QUAD_Y0(q) + (MATRIX_ZY(m) * QUAD_Y3(q)); + MATRIX_YZ(m) = QUAD_Y0(q); + + return EINA_TRUE; + } +} + +EAPI Eina_Bool +eina_matrix3_quad_square_map(Eina_Matrix3 *m, + const Eina_Quad *q) +{ + Eina_Matrix3 tmp; + + /* compute square to quad */ + if (!eina_matrix3_square_quad_map(&tmp, q)) + return EINA_FALSE; + + eina_matrix3_inverse(&tmp, m); + /* make the projective matrix3 always have 1 on zz */ + if (MATRIX_ZZ(m) != 1) + { + eina_matrix3_divide(m, MATRIX_ZZ(m)); + } + + return EINA_TRUE; +} + +EAPI Eina_Bool +eina_matrix3_quad_quad_map(Eina_Matrix3 *m, + const Eina_Quad *src, + const Eina_Quad *dst) +{ + Eina_Matrix3 tmp; + + /* TODO check that both are actually quadrangles */ + if (!eina_matrix3_quad_square_map(m, src)) + return EINA_FALSE; + if (!eina_matrix3_square_quad_map(&tmp, dst)) + return EINA_FALSE; + eina_matrix3_compose(&tmp, m, m); + + return EINA_TRUE; +} diff --git a/src/lib/eina/eina_matrix.h b/src/lib/eina/eina_matrix.h new file mode 100644 index 0000000000..57b5baba82 --- /dev/null +++ b/src/lib/eina/eina_matrix.h @@ -0,0 +1,339 @@ +/* EINA - EFL data type library + * Copyright (C) 2007-2014 Jorge Luis Zapata + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. + * If not, see . + */ +#ifndef EINA_MATRIX3_H_ +#define EINA_MATRIX3_H_ + +#include "eina_quad.h" + +/** + * @file + * @ender_group{Eina_Matrix_Type} + * @ender_group{Eina_Matrix3_F16p16} + * @ender_group{Eina_Matrix3} + */ + +/** + * @defgroup Eina_Matrix_Type Matrices type + * @ingroup Eina_Basic + * @brief Matrix3 types + * @{ + */ +typedef enum _Eina_Matrix_Type + { + EINA_MATRIX_TYPE_IDENTITY, /**< Identity matrix3 type */ + EINA_MATRIX_TYPE_AFFINE, /**< Affine matrix3 type */ + EINA_MATRIX_TYPE_PROJECTIVE, /**< Projective matrix3 type */ + EINA_MATRIX_TYPE_LAST /**< The total number of matrix3 types */ + } Eina_Matrix_Type; + +/** + * @} + * @defgroup Eina_Matrix3_F16p16 Matrices in fixed point + * @ingroup Eina_Basic + * @brief Fixed point matrices operations + * @{ + */ + +/** + * Fixed point matrix3 handler + */ +typedef struct _Eina_Matrix3_F16p16 Eina_Matrix3_F16p16; + +struct _Eina_Matrix3_F16p16 +{ + Eina_F16p16 xx; /**< xx in x' = (x * xx) + (y * xy) + xz */ + Eina_F16p16 xy; /**< xy in x' = (x * xx) + (y * xy) + xz */ + Eina_F16p16 xz; /**< xz in x' = (x * xx) + (y * xy) + xz */ + + Eina_F16p16 yx; /**< yx in y' = (x * yx) + (y * yy) + yz */ + Eina_F16p16 yy; /**< yy in y' = (x * yx) + (y * yy) + yz */ + Eina_F16p16 yz; /**< yz in y' = (x * yx) + (y * yy) + yz */ + + Eina_F16p16 zx; /**< zx in z' = (x * zx) + (y * zy) + zz */ + Eina_F16p16 zy; /**< zy in z' = (x * zx) + (y * zy) + zz */ + Eina_F16p16 zz; /**< zz in z' = (x * zx) + (y * zy) + zz */ +}; + +/** + * @brief Set the given fixed point matrix to the identity matrix. + * + * @param m The fixed point matrix to set + * + * This function sets @p m to the identity matrix. No check is done on + * @p m. + */ +EAPI void eina_matrix3_f16p16_identity(Eina_Matrix3_F16p16 *m); + +EAPI void eina_matrix3_f16p16_compose(const Eina_Matrix3_F16p16 *m1, + const Eina_Matrix3_F16p16 *m2, + Eina_Matrix3_F16p16 *dst); + +/** + * @brief Return the type of the given fixed point matrix. + * + * @param m The fixed point matrix. + * @return The type of the matrix. + * + * This function returns the type of the matrix @p m. No check is done + * on @p m. + */ +EAPI Eina_Matrix_Type eina_matrix3_f16p16_type_get(const Eina_Matrix3_F16p16 *m); + +/** + * @} + * @defgroup Eina_Matrix3 Matrices in floating point + * @ingroup Eina_Basic + * @brief Matrix definition and operations + * @{ + */ + +/** Helper macro for printf formatting */ +#define EINA_MATRIX3_FORMAT "g %g %g | %g %g %g | %g %g %g" +/** Helper macro for printf formatting arg */ +#define EINA_MATRIX3_ARGS(m) (m)->xx, (m)->xy, (m)->xz, \ + (m)->yx, (m)->yy, (m)->yz, \ + (m)->zx, (m)->zy, (m)->zz + + +/** + * Floating point matrix3 handler + */ +typedef struct _Eina_Matrix3 Eina_Matrix3; + +struct _Eina_Matrix3 +{ + double xx; /**< xx in x' = (x * xx) + (y * xy) + xz */ + double xy; /**< xy in x' = (x * xx) + (y * xy) + xz */ + double xz; /**< xz in x' = (x * xx) + (y * xy) + xz */ + + double yx; /**< yx in y' = (x * yx) + (y * yy) + yz */ + double yy; /**< yy in y' = (x * yx) + (y * yy) + yz */ + double yz; /**< yz in y' = (x * yx) + (y * yy) + yz */ + + double zx; /**< zx in z' = (x * zx) + (y * zy) + zz */ + double zy; /**< zy in z' = (x * zx) + (y * zy) + zz */ + double zz; /**< zz in z' = (x * zx) + (y * zy) + zz */ +}; + +/** + * @brief Return the type of the given floating point matrix. + * + * @param m The floating point matrix. + * @return The type of the matrix. + * + * This function returns the type of the matrix @p m. No check is done + * on @p m. + */ +EAPI Eina_Matrix_Type eina_matrix3_type_get(const Eina_Matrix3 *m); + +/** + * @brief Set the values of the coefficients of the given floating + * point matrix. + * + * @param m The floating point matrix. + * @param xx The first coefficient value. + * @param xy The second coefficient value. + * @param xz The third coefficient value. + * @param yx The fourth coefficient value. + * @param yy The fifth coefficient value. + * @param yz The sixth coefficient value. + * @param zx The seventh coefficient value. + * @param zy The heighth coefficient value. + * @param zz The nineth coefficient value. + * + * This function sets the values of the coefficients of the matrix + * @p m. No check is done on @p m. + * + * @see eina_matrix3_values_get() + */ +EAPI void eina_matrix3_values_set(Eina_Matrix3 *m, + double xx, double xy, double xz, + double yx, double yy, double yz, + double zx, double zy, double zz); + +/** + * @brief Get the values of the coefficients of the given floating + * point matrix. + * + * @param m The floating point matrix. + * @param xx The first coefficient value. + * @param xy The second coefficient value. + * @param xz The third coefficient value. + * @param yx The fourth coefficient value. + * @param yy The fifth coefficient value. + * @param yz The sixth coefficient value. + * @param zx The seventh coefficient value. + * @param zy The heighth coefficient value. + * @param zz The nineth coefficient value. + * + * This function gets the values of the coefficients of the matrix + * @p m. No check is done on @p m. + * + * @see eina_matrix3_values_set() + */ +EAPI void eina_matrix3_values_get(const Eina_Matrix3 *m, + double *xx, double *xy, double *xz, + double *yx, double *yy, double *yz, + double *zx, double *zy, double *zz); + +/** + * @brief Get the values of the coefficients of the given fixed + * point matrix. + * + * @param m The fixed point matrix. + * @param xx The first coefficient value. + * @param xy The second coefficient value. + * @param xz The third coefficient value. + * @param yx The fourth coefficient value. + * @param yy The fifth coefficient value. + * @param yz The sixth coefficient value. + * @param zx The seventh coefficient value. + * @param zy The heighth coefficient value. + * @param zz The nineth coefficient value. + * + * This function gets the values of the coefficients of the matrix + * @p m. No check is done on @p m. + * + * @see eina_matrix3_values_set() + */ +EAPI void eina_matrix3_fixed_values_get(const Eina_Matrix3 *m, + Eina_F16p16 *xx, Eina_F16p16 *xy, Eina_F16p16 *xz, + Eina_F16p16 *yx, Eina_F16p16 *yy, Eina_F16p16 *yz, + Eina_F16p16 *zx, Eina_F16p16 *zy, Eina_F16p16 *zz); + +/** + * @brief Transform the given floating point matrix to the given fixed + * point matrix. + * + * @param m The floating point matrix. + * @param fm The fixed point matrix. + * + * This function transforms the floating point matrix @p m to a fixed + * point matrix and store the coefficients into the fixed point matrix + * @p fm. + */ +EAPI void eina_matrix3_matrix3_f16p16_to(const Eina_Matrix3 *m, + Eina_Matrix3_F16p16 *fm); + +/** + * @brief Check whether the two given matrices are equal or not. + * + * @param m1 The first matrix. + * @param m2 The second matrix. + * @return EINA_TRUE if the two matrices are equal, 0 otherwise. + * + * This function return EINA_TRUE if thematrices @p m1 and @p m2 are + * equal, EINA_FALSE otherwise. No check is done on the matrices. + */ +EAPI Eina_Bool eina_matrix3_equal(const Eina_Matrix3 *m1, const Eina_Matrix3 *m2); +EAPI void eina_matrix3_compose(const Eina_Matrix3 *m1, + const Eina_Matrix3 *m2, + Eina_Matrix3 *dst); + +/** + * Set the matrix values for a translation + * @param[in] m The matrix to set the translation values + * @param[in] tx The X coordinate translate + * @param[in] ty The Y coordinate translate + */ +EAPI void eina_matrix3_translate(Eina_Matrix3 *t, double tx, double ty); + +/** + * Set the matrix values for a scale + * @param[in] m The matrix to set the scale values + * @param[in] sx The X coordinate scale + * @param[in] sy The Y coordinate scale + */ +EAPI void eina_matrix3_scale(Eina_Matrix3 *t, double sx, double sy); + +/** + * Set the matrix values for a rotation + * @param[in] m The matrix to set the rotation values + * @param[in] rad The radius to rotate the matrix + */ +EAPI void eina_matrix3_rotate(Eina_Matrix3 *t, double rad); + +/** + * @brief Set the given floating point matrix to the identity matrix. + * + * @param m The floating point matrix to set + * + * This function sets @p m to the identity matrix. No check is done on + * @p m. + */ +EAPI void eina_matrix3_identity(Eina_Matrix3 *t); + +/** + * @brief Return the determinant of the given matrix. + * + * @param m The matrix. + * @return The determinant. + * + * This function returns the determinant of the matrix @p m. No check + * is done on @p m. + */ +EAPI double eina_matrix3_determinant(const Eina_Matrix3 *m); + +/** + * @brief Divide the given matrix by the given scalar. + * + * @param m The matrix. + * @param scalar The scalar number. + * + * This function divides the matrix @p m by @p scalar. No check + * is done on @p m. + */ +EAPI void eina_matrix3_divide(Eina_Matrix3 *m, double scalar); + +/** + * @brief Compute the inverse of the given matrix. + * + * @param m The matrix to inverse. + * @param m2 The inverse matrix. + * + * This function inverse the matrix @p m and stores the result in + * @p m2. No check is done on @p m or @p m2. If @p m can not be + * invertible, then @p m2 is set to the identity matrix. + */ +EAPI void eina_matrix3_inverse(const Eina_Matrix3 *m, Eina_Matrix3 *m2); +EAPI void eina_matrix3_transpose(const Eina_Matrix3 *m, Eina_Matrix3 *a); +EAPI void eina_matrix3_cofactor(const Eina_Matrix3 *m, Eina_Matrix3 *a); +EAPI void eina_matrix3_adjoint(const Eina_Matrix3 *m, Eina_Matrix3 *a); + +EAPI void eina_matrix3_point_transform(const Eina_Matrix3 *m, + double x, double y, + double *xr, double *yr); +EAPI void eina_matrix3_rectangle_transform(const Eina_Matrix3 *m, + const Eina_Rectangle *r, + const Eina_Quad *q); + +/** + * @brief Creates a projective matrix that maps a quadrangle to a quadrangle + */ +EAPI Eina_Bool eina_matrix3_quad_quad_map(Eina_Matrix3 *m, + const Eina_Quad *src, + const Eina_Quad *dst); +EAPI Eina_Bool eina_matrix3_square_quad_map(Eina_Matrix3 *m, + const Eina_Quad *q); +EAPI Eina_Bool eina_matrix3_quad_square_map(Eina_Matrix3 *m, + const Eina_Quad *q); + +/** + * @} + */ +#endif /*EINA_MATRIX3_H_*/ diff --git a/src/lib/eina/eina_quad.c b/src/lib/eina/eina_quad.c new file mode 100644 index 0000000000..d2874c004d --- /dev/null +++ b/src/lib/eina/eina_quad.c @@ -0,0 +1,127 @@ +/* EINA - EFL data type library + * Copyright (C) 2007-2014 Jorge Luis Zapata + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. + * If not, see . + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include "eina_private.h" + +#include +#include + +#include "eina_rectangle.h" +#include "eina_quad.h" + +#define QUAD_X0(q) q->x0 +#define QUAD_Y0(q) q->y0 +#define QUAD_X1(q) q->x1 +#define QUAD_Y1(q) q->y1 +#define QUAD_X2(q) q->x2 +#define QUAD_Y2(q) q->y2 +#define QUAD_X3(q) q->x3 +#define QUAD_Y3(q) q->y3 + +/*============================================================================* + * Local * + *============================================================================*/ +/** @cond internal */ +/* FIXME make this function on API */ +static inline void _quad_dump(Eina_Quad *q) +{ + printf("Q = %f %f, %f %f, %f %f, %f %f\n", QUAD_X0(q), QUAD_Y0(q), QUAD_X1(q), QUAD_Y1(q), QUAD_X2(q), QUAD_Y2(q), QUAD_X3(q), QUAD_Y3(q)); +} +/** @endcond */ + +/*============================================================================* + * API * + *============================================================================*/ +EAPI void +eina_quad_rectangle_to(const Eina_Quad *q, + Eina_Rectangle *r) +{ + double xmin, ymin, xmax, ymax; + /* FIXME this code is very ugly, for sure there must be a better + * implementation */ + xmin = QUAD_X0(q) < QUAD_X1(q) ? QUAD_X0(q) : QUAD_X1(q); + xmin = xmin < QUAD_X2(q) ? xmin : QUAD_X2(q); + xmin = xmin < QUAD_X3(q) ? xmin : QUAD_X3(q); + + ymin = QUAD_Y0(q) < QUAD_Y1(q) ? QUAD_Y0(q) : QUAD_Y1(q); + ymin = ymin < QUAD_Y2(q) ? ymin : QUAD_Y2(q); + ymin = ymin < QUAD_Y3(q) ? ymin : QUAD_Y3(q); + + xmax = QUAD_X0(q) > QUAD_X1(q) ? QUAD_X0(q) : QUAD_X1(q); + xmax = xmax > QUAD_X2(q) ? xmax : QUAD_X2(q); + xmax = xmax > QUAD_X3(q) ? xmax : QUAD_X3(q); + + ymax = QUAD_Y0(q) > QUAD_Y1(q) ? QUAD_Y0(q) : QUAD_Y1(q); + ymax = ymax > QUAD_Y2(q) ? ymax : QUAD_Y2(q); + ymax = ymax > QUAD_Y3(q) ? ymax : QUAD_Y3(q); + + r->x = lround(xmin); + r->w = lround(xmax) - r->x; + r->y = lround(ymin); + r->h = lround(ymax) - r->y; +} + +EAPI void +eina_quad_rectangle_from(Eina_Quad *q, + const Eina_Rectangle *r) +{ + QUAD_X0(q) = r->x; + QUAD_Y0(q) = r->y; + QUAD_X1(q) = r->x + r->w; + QUAD_Y1(q) = r->y; + QUAD_X2(q) = r->x + r->w; + QUAD_Y2(q) = r->y + r->h; + QUAD_X3(q) = r->x; + QUAD_Y3(q) = r->y + r->h; +} + +EAPI void eina_quad_coords_get(const Eina_Quad *q, + double *qx0, double *qy0, + double *qx1, double *qy1, + double *qx2, double *qy2, + double *qx3, double *qy3) +{ + if (qx0) *qx0 = q->x0; + if (qy0) *qy0 = q->y0; + if (qx1) *qx1 = q->x1; + if (qy1) *qy1 = q->y1; + if (qx2) *qx2 = q->x2; + if (qy2) *qy2 = q->y2; + if (qx3) *qx3 = q->x3; + if (qy3) *qy3 = q->y3; +} + +EAPI void eina_quad_coords_set(Eina_Quad *q, + double qx0, double qy0, + double qx1, double qy1, + double qx2, double qy2, + double qx3, double qy3) +{ + QUAD_X0(q) = qx0; + QUAD_Y0(q) = qy0; + QUAD_X1(q) = qx1; + QUAD_Y1(q) = qy1; + QUAD_X2(q) = qx2; + QUAD_Y2(q) = qy2; + QUAD_X3(q) = qx3; + QUAD_Y3(q) = qy3; +} diff --git a/src/lib/eina/eina_quad.h b/src/lib/eina/eina_quad.h new file mode 100644 index 0000000000..2abbc34bd0 --- /dev/null +++ b/src/lib/eina/eina_quad.h @@ -0,0 +1,67 @@ +/* EINA - EFL data type library + * Copyright (C) 2007-2014 Jorge Luis Zapata + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. + * If not, see . + */ +#ifndef EINA_QUAD_H_ +#define EINA_QUAD_H_ + +/** + * @file + * @ender_group{Eina_Quad} + */ + +/** + * @defgroup Eina_Quad Quadrangles + * @ingroup Eina_Basic + * @brief Quadrangles operations + * @{ + */ + +/** + * Quadrangle definition + */ +typedef struct _Eina_Quad +{ + double x0; /**< Top left x coordinate */ + double y0; /**< Top left y coordinate */ + double x1; /**< Top right x coordinate */ + double y1; /**< Top right y coordinate */ + double x2; /**< Bottom right x coordinate */ + double y2; /**< Bottom right y coordinate */ + double x3; /**< Bottom left x coordinate */ + double y3; /**< Bottom left y coordinate */ +} Eina_Quad; + +EAPI void eina_quad_rectangle_to(const Eina_Quad *q, + Eina_Rectangle *r); +EAPI void eina_quad_rectangle_from(Eina_Quad *q, + const Eina_Rectangle *r); +EAPI void eina_quad_coords_set(Eina_Quad *q, + double x1, double y1, + double x2, double y2, + double x3, double y3, + double x4, double y4); +EAPI void eina_quad_coords_get(const Eina_Quad *q, + double *x1, double *y1, + double *x2, double *y2, + double *x3, double *y3, + double *x4, double *y4); + +/** + * @} + */ + +#endif From 9ba6e1a0ae5d82d10fbe2ea33e9ee0175242d534 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:12:59 +0200 Subject: [PATCH 002/251] evas: add initial Evas_Object_VG. Evas_Object_VG is meant to become an object that can hold a SVG scenegraph inside of it. --- src/Makefile_Evas.am | 21 +- src/lib/evas/Evas_Eo.h | 86 +++++ src/lib/evas/canvas/evas_object_vg.c | 315 ++++++++++++++++++ src/lib/evas/canvas/evas_vg.eo | 17 + src/lib/evas/canvas/evas_vg_container.c | 33 ++ src/lib/evas/canvas/evas_vg_container.eo | 8 + src/lib/evas/canvas/evas_vg_gradient.c | 58 ++++ src/lib/evas/canvas/evas_vg_gradient.eo | 26 ++ src/lib/evas/canvas/evas_vg_gradient_linear.c | 50 +++ .../evas/canvas/evas_vg_gradient_linear.eo | 27 ++ src/lib/evas/canvas/evas_vg_gradient_radial.c | 64 ++++ .../evas/canvas/evas_vg_gradient_radial.eo | 36 ++ src/lib/evas/canvas/evas_vg_node.c | 167 ++++++++++ src/lib/evas/canvas/evas_vg_node.eo | 162 +++++++++ src/lib/evas/canvas/evas_vg_private.h | 10 + src/lib/evas/canvas/evas_vg_root_node.c | 41 +++ src/lib/evas/canvas/evas_vg_root_node.eo | 8 + src/lib/evas/canvas/evas_vg_shape.c | 39 +++ src/lib/evas/canvas/evas_vg_shape.eo | 113 +++++++ src/lib/evas/include/evas_private.h | 1 + 20 files changed, 1281 insertions(+), 1 deletion(-) create mode 100644 src/lib/evas/canvas/evas_object_vg.c create mode 100644 src/lib/evas/canvas/evas_vg.eo create mode 100644 src/lib/evas/canvas/evas_vg_container.c create mode 100644 src/lib/evas/canvas/evas_vg_container.eo create mode 100644 src/lib/evas/canvas/evas_vg_gradient.c create mode 100644 src/lib/evas/canvas/evas_vg_gradient.eo create mode 100644 src/lib/evas/canvas/evas_vg_gradient_linear.c create mode 100644 src/lib/evas/canvas/evas_vg_gradient_linear.eo create mode 100644 src/lib/evas/canvas/evas_vg_gradient_radial.c create mode 100644 src/lib/evas/canvas/evas_vg_gradient_radial.eo create mode 100644 src/lib/evas/canvas/evas_vg_node.c create mode 100644 src/lib/evas/canvas/evas_vg_node.eo create mode 100644 src/lib/evas/canvas/evas_vg_private.h create mode 100644 src/lib/evas/canvas/evas_vg_root_node.c create mode 100644 src/lib/evas/canvas/evas_vg_root_node.eo create mode 100644 src/lib/evas/canvas/evas_vg_shape.c create mode 100644 src/lib/evas/canvas/evas_vg_shape.eo diff --git a/src/Makefile_Evas.am b/src/Makefile_Evas.am index bd3d377757..d2410e34e2 100644 --- a/src/Makefile_Evas.am +++ b/src/Makefile_Evas.am @@ -31,7 +31,15 @@ evas_eolian_files = \ lib/evas/canvas/evas_3d_mesh.eo\ lib/evas/canvas/evas_3d_node.eo\ lib/evas/canvas/evas_3d_scene.eo\ - lib/evas/canvas/evas_3d_object.eo + lib/evas/canvas/evas_3d_object.eo \ + lib/evas/canvas/evas_vg.eo \ + lib/evas/canvas/evas_vg_node.eo \ + lib/evas/canvas/evas_vg_container.eo \ + lib/evas/canvas/evas_vg_shape.eo \ + lib/evas/canvas/evas_vg_root_node.eo \ + lib/evas/canvas/evas_vg_gradient.eo \ + lib/evas/canvas/evas_vg_gradient_radial.eo \ + lib/evas/canvas/evas_vg_gradient_linear.eo evas_eolian_c = $(evas_eolian_files:%.eo=%.eo.c) evas_eolian_h = $(evas_eolian_files:%.eo=%.eo.h) \ @@ -176,6 +184,7 @@ lib/evas/file/evas_path.h lib_evas_libevas_la_SOURCES += \ $(lib_evas_file_SOURCES) +# Evas_3D noinst_HEADERS += \ lib/evas/include/evas_3d_utils.h @@ -201,6 +210,16 @@ modules/evas/model_savers/obj/evas_model_save_obj.c \ modules/evas/model_savers/ply/evas_model_save_ply.c \ lib/evas/canvas/evas_3d_eet.c +# Evas_VG +lib_evas_libevas_la_SOURCES += \ +lib/evas/canvas/evas_object_vg.c \ +lib/evas/canvas/evas_vg_node.c \ +lib/evas/canvas/evas_vg_container.c \ +lib/evas/canvas/evas_vg_root_node.c \ +lib/evas/canvas/evas_vg_gradient.c \ +lib/evas/canvas/evas_vg_gradient_linear.c \ +lib/evas/canvas/evas_vg_gradient_radial.c + # Engine lib_evas_libevas_la_SOURCES += \ lib/evas/common/evas_op_copy_main_.c \ diff --git a/src/lib/evas/Evas_Eo.h b/src/lib/evas/Evas_Eo.h index 34ab6a486b..cfadf6d331 100644 --- a/src/lib/evas/Evas_Eo.h +++ b/src/lib/evas/Evas_Eo.h @@ -845,3 +845,89 @@ typedef enum _Evas_3D_Material_Attrib #include "canvas/evas_3d_object.eo.h" +/** + * Path command enum. + * + * @since 1.14 + * @ingroup Evas_VG_Shape + */ +typedef enum _Evas_VG_Path_Command +{ + EVAS_VG_PATH_COMMAND_TYPE_END = 0, /**< End of the stream of command */ + EVAS_VG_PATH_COMMAND_TYPE_MOVE_TO, /**< A move command type */ + EVAS_VG_PATH_COMMAND_TYPE_LINE_TO, /**< A line command type */ + EVAS_VG_PATH_COMMAND_TYPE_QUADRATIC_TO, /**< A quadratic command type */ + EVAS_VG_PATH_COMMAND_TYPE_SQUADRATIC_TO, /**< A smooth quadratic command type */ + EVAS_VG_PATH_COMMAND_TYPE_CUBIC_TO, /**< A cubic command type */ + EVAS_VG_PATH_COMMAND_TYPE_SCUBIC_TO, /**< A smooth cubic command type */ + EVAS_VG_PATH_COMMAND_TYPE_ARC_TO, /**< An arc command type */ + EVAS_VG_PATH_COMMAND_TYPE_CLOSE, /**< A close command type */ + EVAS_VG_PATH_COMMAND_TYPE_LAST, /**< Not a valid command, but last one according to this version header */ +} Evas_VG_Path_Command; + +/** + * Type of abstract VG node + */ +typedef Eo Evas_VG_Node; + + +/** + * Type describing dash + */ +typedef struct _Evas_VG_Dash Evas_VG_Dash; +struct _Evas_VG_Dash +{ + double length; + double gap; +}; + +typedef struct _Evas_VG_Gradient_Stop Evas_VG_Gradient_Stop; +struct _Evas_VG_Gradient_Stop +{ + double offset; + int r; + int g; + int b; + int a; +}; + +typedef enum _Evas_VG_Cap +{ + EVAS_VG_CAP_BUTT, + EVAS_VG_CAP_ROUND, + EVAS_VG_CAP_SQUARE, + EVAS_VG_CAP_LAST +} Evas_VG_Cap; + +typedef enum _Evas_VG_Join +{ + EVAS_VG_JOIN_MITER, + EVAS_VG_JOIN_ROUND, + EVAS_VG_JOIN_BEVEL, + EVAS_VG_JOIN_LAST +} Evas_VG_Join; + +typedef enum _Evas_VG_Gradient_Spread +{ + EVAS_VG_GRADIENT_SPREAD_PAD, + EVAS_VG_GRADIENT_SPREAD_REFLECT, + EVAS_VG_GRADIENT_SPREAD_REPEAT, + EVAS_VG_GRADIENT_SPREAD_LAST +} Evas_VG_Gradient_Spread; + +/** + * @ingroup Evas_Object_VG + * + * @{ + */ +#include "canvas/evas_vg.eo.h" +/** + * @} + */ + +#include "canvas/evas_vg_node.eo.h" +#include "canvas/evas_vg_container.eo.h" +#include "canvas/evas_vg_shape.eo.h" +#include "canvas/evas_vg_gradient.eo.h" +#include "canvas/evas_vg_gradient_linear.eo.h" +#include "canvas/evas_vg_gradient_radial.eo.h" diff --git a/src/lib/evas/canvas/evas_object_vg.c b/src/lib/evas/canvas/evas_object_vg.c new file mode 100644 index 0000000000..c956fb8fa5 --- /dev/null +++ b/src/lib/evas/canvas/evas_object_vg.c @@ -0,0 +1,315 @@ +#include "evas_common_private.h" +#include "evas_private.h" + +#include "evas_vg_root_node.eo.h" + +#define MY_CLASS EVAS_VG_CLASS + + +/* private magic number for rectangle objects */ +static const char o_type[] = "rectangle"; + +const char *o_vg_type = o_type; + +/* private struct for rectangle object internal data */ +typedef struct _Evas_VG_Data Evas_VG_Data; + +struct _Evas_VG_Data +{ + void *engine_data; + Evas_VG_Node *root; +}; + +static void evas_object_vg_render(Evas_Object *eo_obj, + Evas_Object_Protected_Data *obj, + void *type_private_data, + void *output, void *context, void *surface, + int x, int y, Eina_Bool do_async); +static void evas_object_vg_render_pre(Evas_Object *eo_obj, + Evas_Object_Protected_Data *obj, + void *type_private_data); +static void evas_object_vg_render_post(Evas_Object *eo_obj, + Evas_Object_Protected_Data *obj, + void *type_private_data); +static unsigned int evas_object_vg_id_get(Evas_Object *eo_obj); +static unsigned int evas_object_vg_visual_id_get(Evas_Object *eo_obj); +static void *evas_object_vg_engine_data_get(Evas_Object *eo_obj); +static int evas_object_vg_is_opaque(Evas_Object *eo_obj, + Evas_Object_Protected_Data *obj, + void *type_private_data); +static int evas_object_vg_was_opaque(Evas_Object *eo_obj, + Evas_Object_Protected_Data *obj, + void *type_private_data); + +static const Evas_Object_Func object_func = +{ + /* methods (compulsory) */ + NULL, + evas_object_vg_render, + evas_object_vg_render_pre, + evas_object_vg_render_post, + evas_object_vg_id_get, + evas_object_vg_visual_id_get, + evas_object_vg_engine_data_get, + /* these are optional. NULL = nothing */ + NULL, + NULL, + NULL, + NULL, + evas_object_vg_is_opaque, + evas_object_vg_was_opaque, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL +}; + +/* the actual api call to add a vector graphic object */ +EAPI Evas_Object * +evas_object_vg_add(Evas *e) +{ + MAGIC_CHECK(e, Evas, MAGIC_EVAS); + return NULL; + MAGIC_CHECK_END(); + Evas_Object *eo_obj = eo_add(MY_CLASS, e); + return eo_obj; +} + +void +_evas_vg_root_node_set(Eo *obj EINA_UNUSED, Evas_VG_Data *pd, Evas_VG_Node *container) +{ + Evas_VG_Node *tmp; + + tmp = pd->root; + pd->root = eo_ref(container); + eo_unref(tmp); +} + +Evas_VG_Node * +_evas_vg_root_node_get(Eo *obj EINA_UNUSED, Evas_VG_Data *pd) +{ + return pd->root; +} + +void +_evas_vg_eo_base_constructor(Eo *eo_obj, Evas_VG_Data *pd EINA_UNUSED) +{ + Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS); + Eo *parent = NULL; + + eo_do_super(eo_obj, MY_CLASS, eo_constructor()); + + /* set up methods (compulsory) */ + obj->func = &object_func; + obj->private_data = eo_data_ref(eo_obj, MY_CLASS); + obj->type = o_type; + + eo_do(eo_obj, parent = eo_parent_get()); + evas_object_inject(eo_obj, obj, evas_object_evas_get(parent)); +} + +static void +evas_object_vg_render(Evas_Object *eo_obj EINA_UNUSED, + Evas_Object_Protected_Data *obj EINA_UNUSED, + void *type_private_data EINA_UNUSED, + void *output EINA_UNUSED, void *context EINA_UNUSED, void *surface EINA_UNUSED, + int x EINA_UNUSED, int y EINA_UNUSED, Eina_Bool do_async EINA_UNUSED) +{ + /* render object to surface with context, and offxet by x,y */ + /* obj->layer->evas->engine.func->context_color_set(output, */ + /* context, */ + /* obj->cur->cache.clip.r, */ + /* obj->cur->cache.clip.g, */ + /* obj->cur->cache.clip.b, */ + /* obj->cur->cache.clip.a); */ + /* obj->layer->evas->engine.func->context_anti_alias_set(output, context, */ + /* obj->cur->anti_alias); */ + /* obj->layer->evas->engine.func->context_multiplier_unset(output, */ + /* context); */ + /* obj->layer->evas->engine.func->context_render_op_set(output, context, */ + /* obj->cur->render_op); */ + /* obj->layer->evas->engine.func->rectangle_draw(output, */ + /* context, */ + /* surface, */ + /* obj->cur->geometry.x + x, */ + /* obj->cur->geometry.y + y, */ + /* obj->cur->geometry.w, */ + /* obj->cur->geometry.h, */ + /* do_async); */ + // FIXME: I guess I should create an image, get the pixels data and + // start using that for Cairo. +} + +static void +evas_object_vg_render_pre(Evas_Object *eo_obj, + Evas_Object_Protected_Data *obj, + void *type_private_data EINA_UNUSED) +{ + int is_v, was_v; + + // FIXME: Later on start doing precalc of span and stuff for all shape. + + /* dont pre-render the obj twice! */ + if (obj->pre_render_done) return; + obj->pre_render_done = EINA_TRUE; + /* pre-render phase. this does anything an object needs to do just before */ + /* rendering. this could mean loading the image data, retrieving it from */ + /* elsewhere, decoding video etc. */ + /* then when this is done the object needs to figure if it changed and */ + /* if so what and where and add the appropriate redraw rectangles */ + /* if someone is clipping this obj - go calculate the clipper */ + if (obj->cur->clipper) + { + if (obj->cur->cache.clip.dirty) + evas_object_clip_recalc(obj->cur->clipper); + obj->cur->clipper->func->render_pre(obj->cur->clipper->object, + obj->cur->clipper, + obj->cur->clipper->private_data); + } + /* now figure what changed and add draw rects */ + /* if it just became visible or invisible */ + is_v = evas_object_is_visible(eo_obj, obj); + was_v = evas_object_was_visible(eo_obj,obj); + if (!(is_v | was_v)) goto done; + if (is_v != was_v) + { + evas_object_render_pre_visible_change(&obj->layer->evas->clip_changes, eo_obj, is_v, was_v); + goto done; + } + if (obj->changed_map || obj->changed_src_visible) + { + evas_object_render_pre_prev_cur_add(&obj->layer->evas->clip_changes, eo_obj, obj); + goto done; + } + /* it's not visible - we accounted for it appearing or not so just abort */ + if (!is_v) goto done; + /* clipper changed this is in addition to anything else for obj */ + evas_object_render_pre_clipper_change(&obj->layer->evas->clip_changes, eo_obj); + /* if we restacked (layer or just within a layer) and don't clip anyone */ + if ((obj->restack) && (!obj->clip.clipees)) + { + evas_object_render_pre_prev_cur_add(&obj->layer->evas->clip_changes, eo_obj, obj); + goto done; + } + /* if it changed render op */ + if (obj->cur->render_op != obj->prev->render_op) + { + evas_object_render_pre_prev_cur_add(&obj->layer->evas->clip_changes, eo_obj, obj); + goto done; + } + /* if it changed color */ + if ((obj->cur->color.r != obj->prev->color.r) || + (obj->cur->color.g != obj->prev->color.g) || + (obj->cur->color.b != obj->prev->color.b) || + (obj->cur->color.a != obj->prev->color.a)) + { + evas_object_render_pre_prev_cur_add(&obj->layer->evas->clip_changes, eo_obj, obj); + goto done; + } + /* if it changed geometry - and obviously not visibility or color */ + /* calculate differences since we have a constant color fill */ + /* we really only need to update the differences */ + if ((obj->cur->geometry.x != obj->prev->geometry.x) || + (obj->cur->geometry.y != obj->prev->geometry.y) || + (obj->cur->geometry.w != obj->prev->geometry.w) || + (obj->cur->geometry.h != obj->prev->geometry.h)) + { + evas_rects_return_difference_rects(&obj->layer->evas->clip_changes, + obj->cur->geometry.x, + obj->cur->geometry.y, + obj->cur->geometry.w, + obj->cur->geometry.h, + obj->prev->geometry.x, + obj->prev->geometry.y, + obj->prev->geometry.w, + obj->prev->geometry.h); + goto done; + } + /* it obviously didn't change - add a NO obscure - this "unupdates" this */ + /* area so if there were updates for it they get wiped. don't do it if we */ + /* arent fully opaque and we are visible */ + if (evas_object_is_visible(eo_obj, obj) && + evas_object_is_opaque(eo_obj, obj) && + (!obj->clip.clipees)) + { + Evas_Coord x, y, w, h; + + x = obj->cur->cache.clip.x; + y = obj->cur->cache.clip.y; + w = obj->cur->cache.clip.w; + h = obj->cur->cache.clip.h; + if (obj->cur->clipper) + { + RECTS_CLIP_TO_RECT(x, y, w, h, + obj->cur->clipper->cur->cache.clip.x, + obj->cur->clipper->cur->cache.clip.y, + obj->cur->clipper->cur->cache.clip.w, + obj->cur->clipper->cur->cache.clip.h); + } + obj->layer->evas->engine.func->output_redraws_rect_del + (obj->layer->evas->engine.data.output, + x + obj->layer->evas->framespace.x, + y + obj->layer->evas->framespace.y, + w, h); + } + done: + evas_object_render_pre_effect_updates(&obj->layer->evas->clip_changes, eo_obj, is_v, was_v); +} + +static void +evas_object_vg_render_post(Evas_Object *eo_obj, + Evas_Object_Protected_Data *obj EINA_UNUSED, + void *type_private_data EINA_UNUSED) +{ + /* this moves the current data to the previous state parts of the object */ + /* in whatever way is safest for the object. also if we don't need object */ + /* data anymore we can free it if the object deems this is a good idea */ + /* remove those pesky changes */ + evas_object_clip_changes_clean(eo_obj); + /* move cur to prev safely for object data */ + evas_object_cur_prev(eo_obj); +} + +static unsigned int +evas_object_vg_id_get(Evas_Object *eo_obj) +{ + Evas_VG_Data *o = eo_data_scope_get(eo_obj, MY_CLASS); + if (!o) return 0; + return MAGIC_OBJ_VG; +} + +static unsigned int +evas_object_vg_visual_id_get(Evas_Object *eo_obj) +{ + Evas_VG_Data *o = eo_data_scope_get(eo_obj, MY_CLASS); + if (!o) return 0; + return MAGIC_OBJ_SHAPE; +} + +static void * +evas_object_vg_engine_data_get(Evas_Object *eo_obj) +{ + Evas_VG_Data *o = eo_data_scope_get(eo_obj, MY_CLASS); + return o->engine_data; +} + +static int +evas_object_vg_is_opaque(Evas_Object *eo_obj EINA_UNUSED, + Evas_Object_Protected_Data *obj EINA_UNUSED, + void *type_private_data EINA_UNUSED) +{ + return 0; +} + +static int +evas_object_vg_was_opaque(Evas_Object *eo_obj EINA_UNUSED, + Evas_Object_Protected_Data *obj EINA_UNUSED, + void *type_private_data EINA_UNUSED) +{ + return 0; +} + +#include "evas_vg.eo.c" diff --git a/src/lib/evas/canvas/evas_vg.eo b/src/lib/evas/canvas/evas_vg.eo new file mode 100644 index 0000000000..fef9e8ad30 --- /dev/null +++ b/src/lib/evas/canvas/evas_vg.eo @@ -0,0 +1,17 @@ +class Evas.VG (Evas.Object) +{ + legacy_prefix: evas_object_vg; + eo_prefix: evas_obj_vg; + properties { + root_node { + get { + } + values { + Evas_VG_Node *container; + } + } + } + implements { + Eo.Base.constructor; + } +} \ No newline at end of file diff --git a/src/lib/evas/canvas/evas_vg_container.c b/src/lib/evas/canvas/evas_vg_container.c new file mode 100644 index 0000000000..fc008bb552 --- /dev/null +++ b/src/lib/evas/canvas/evas_vg_container.c @@ -0,0 +1,33 @@ +#include "evas_common_private.h" +#include "evas_private.h" + +#include "evas_vg_private.h" + +#define MY_CLASS EVAS_VG_CONTAINER_CLASS + +void +_evas_vg_container_eo_base_constructor(Eo *obj, Evas_VG_Container_Data *pd) +{ + Eo *parent; + + eo_do_super(obj, MY_CLASS, eo_constructor()); + + eo_do(obj, parent = eo_parent_get()); + if (!eo_isa(obj, EVAS_VG_CONTAINER_CLASS) && + !eo_isa(obj, EVAS_VG_CLASS)) + { + ERR("Parent must be either an Evas_Object_VG or an Evas_VG_Container."); + eo_error_set(obj); + } +} + +Eina_Bool +_evas_vg_container_evas_vg_node_bound_get(Eo *obj, + Evas_VG_Container_Data *pd, + Eina_Rectangle *r) +{ + // FIXME: iterate children and get their boundary to +} + + +#include "evas_vg_container.eo.c" diff --git a/src/lib/evas/canvas/evas_vg_container.eo b/src/lib/evas/canvas/evas_vg_container.eo new file mode 100644 index 0000000000..423a202bb1 --- /dev/null +++ b/src/lib/evas/canvas/evas_vg_container.eo @@ -0,0 +1,8 @@ +class Evas.VG_Container (Evas.VG_Node) +{ + eo_prefix: evas_vg_container; + implements { + Eo.Base.constructor; + Evas.VG_Node.bound_get; + } +} diff --git a/src/lib/evas/canvas/evas_vg_gradient.c b/src/lib/evas/canvas/evas_vg_gradient.c new file mode 100644 index 0000000000..df7edc641b --- /dev/null +++ b/src/lib/evas/canvas/evas_vg_gradient.c @@ -0,0 +1,58 @@ +#include "evas_common_private.h" +#include "evas_private.h" + +#include + +typedef struct _Evas_VG_Gradient_Data Evas_VG_Gradient_Data; +struct _Evas_VG_Gradient_Data +{ + // FIXME: Later on we should deduplicate it somehow. + Evas_VG_Gradient_Stop *colors; + unsigned int colors_count; + + Evas_VG_Gradient_Spread s; +}; + +void +_evas_vg_gradient_stop_set(Eo *obj EINA_UNUSED, + Evas_VG_Gradient_Data *pd, + const Evas_VG_Gradient_Stop *colors, + unsigned int length) +{ + pd->colors = realloc(pd->colors, length * sizeof(Evas_VG_Gradient_Stop)); + if (!pd->colors) + { + pd->colors_count = 0; + return ; + } + + memcpy(pd->colors, colors, length * sizeof(Evas_VG_Gradient_Stop)); + pd->colors_count = length; +} + +void +_evas_vg_gradient_stop_get(Eo *obj EINA_UNUSED, + Evas_VG_Gradient_Data *pd, + const Evas_VG_Gradient_Stop **colors, + unsigned int *length) +{ + if (colors) *colors = pd->colors; + if (length) *length = pd->colors_count; +} + +void +_evas_vg_gradient_spread_set(Eo *obj EINA_UNUSED, + Evas_VG_Gradient_Data *pd, + Evas_VG_Gradient_Spread s) +{ + pd->s = s; +} + +Evas_VG_Gradient_Spread +_evas_vg_gradient_spread_get(Eo *obj EINA_UNUSED, + Evas_VG_Gradient_Data *pd) +{ + return pd->s; +} + +#include "evas_vg_gradient.eo.c" diff --git a/src/lib/evas/canvas/evas_vg_gradient.eo b/src/lib/evas/canvas/evas_vg_gradient.eo new file mode 100644 index 0000000000..549d28ac39 --- /dev/null +++ b/src/lib/evas/canvas/evas_vg_gradient.eo @@ -0,0 +1,26 @@ +abstract Evas.VG_Gradient (Evas.VG_Node) +{ + eo_prefix: evas_vg_gradient; + legacy_prefix: null; + properties { + stop { + set { + } + get { + } + values { + const(Evas_VG_Gradient_Stop) *colors; + uint length; + } + } + spread { + set { + } + get { + } + values { + Evas_VG_Gradient_Spread s; + } + } + } +} diff --git a/src/lib/evas/canvas/evas_vg_gradient_linear.c b/src/lib/evas/canvas/evas_vg_gradient_linear.c new file mode 100644 index 0000000000..9332178a18 --- /dev/null +++ b/src/lib/evas/canvas/evas_vg_gradient_linear.c @@ -0,0 +1,50 @@ +#include "evas_common_private.h" +#include "evas_private.h" + +#include + +typedef struct _Evas_VG_Gradient_Linear_Data Evas_VG_Gradient_Linear_Data; +struct _Evas_VG_Gradient_Linear_Data +{ + struct { + double x, y; + } start, end; +}; + +void +_evas_vg_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; +} + +void +_evas_vg_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; +} + +void +_evas_vg_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; +} + +void +_evas_vg_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; +} + +#include "evas_vg_gradient_linear.eo.c" diff --git a/src/lib/evas/canvas/evas_vg_gradient_linear.eo b/src/lib/evas/canvas/evas_vg_gradient_linear.eo new file mode 100644 index 0000000000..07c05391b0 --- /dev/null +++ b/src/lib/evas/canvas/evas_vg_gradient_linear.eo @@ -0,0 +1,27 @@ +class Evas.VG_Gradient_Linear (Evas.VG_Gradient) +{ + eo_prefix: evas_vg_gradient_linear; + legacy_prefix: null; + properties { + start { + set { + } + get { + } + values { + double x; + double y; + } + } + end { + set { + } + get { + } + values { + double x; + double y; + } + } + } +} diff --git a/src/lib/evas/canvas/evas_vg_gradient_radial.c b/src/lib/evas/canvas/evas_vg_gradient_radial.c new file mode 100644 index 0000000000..04ab5bbea0 --- /dev/null +++ b/src/lib/evas/canvas/evas_vg_gradient_radial.c @@ -0,0 +1,64 @@ +#include "evas_common_private.h" +#include "evas_private.h" + +typedef struct _Evas_VG_Gradient_Radial_Data Evas_VG_Gradient_Radial_Data; +struct _Evas_VG_Gradient_Radial_Data +{ + struct { + double x, y; + } center, focal; + double radius; +}; + +void +_evas_vg_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; +} + +void +_evas_vg_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; +} + +void +_evas_vg_gradient_radial_radius_set(Eo *obj EINA_UNUSED, + Evas_VG_Gradient_Radial_Data *pd, + double r) +{ + pd->radius = r; +} + +double +_evas_vg_gradient_radial_radius_get(Eo *obj EINA_UNUSED, + Evas_VG_Gradient_Radial_Data *pd) +{ + return pd->radius; +} + +void +_evas_vg_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; +} + +void +_evas_vg_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; +} + +#include "evas_vg_gradient_radial.eo.c" diff --git a/src/lib/evas/canvas/evas_vg_gradient_radial.eo b/src/lib/evas/canvas/evas_vg_gradient_radial.eo new file mode 100644 index 0000000000..0a7d548346 --- /dev/null +++ b/src/lib/evas/canvas/evas_vg_gradient_radial.eo @@ -0,0 +1,36 @@ +class Evas.VG_Gradient_Radial (Evas.VG_Gradient) +{ + eo_prefix: evas_vg_gradient_radial; + legacy_prefix: null; + properties { + center { + set { + } + get { + } + values { + double x; + double y; + } + } + radius { + set { + } + get { + } + values { + double r; + } + } + focal { + set { + } + get { + } + values { + double x; + double y; + } + } + } +} diff --git a/src/lib/evas/canvas/evas_vg_node.c b/src/lib/evas/canvas/evas_vg_node.c new file mode 100644 index 0000000000..029b986223 --- /dev/null +++ b/src/lib/evas/canvas/evas_vg_node.c @@ -0,0 +1,167 @@ +#include "evas_common_private.h" +#include "evas_private.h" + +#include + +#define MY_CLASS EVAS_VG_NODE_CLASS + +typedef struct _Evas_VG_Node_Data Evas_VG_Node_Data; +struct _Evas_VG_Node_Data +{ + Eina_Matrix3 *m; + Evas_VG_Node *mask; + + double x, y; + int r, g, b, a; + Eina_Bool visibility; +}; + +// FIXME: +// - share private structure with evas_object_vg +// - mark parent canvas evas_object dirty after any change on the object +// - add a virtual render function as part of the private data field + +void +_evas_vg_node_transformation_set(Eo *obj EINA_UNUSED, + Evas_VG_Node_Data *pd, + const Eina_Matrix3 *m) +{ + if (!pd->m) + { + pd->m = malloc(sizeof (Eina_Matrix3)); + if (!pd->m) return ; + } + memcpy(pd->m, m, sizeof (Eina_Matrix3)); +} + +const Eina_Matrix3 * +_evas_vg_node_transformation_get(Eo *obj EINA_UNUSED, Evas_VG_Node_Data *pd) +{ + return pd->m; +} + +void +_evas_vg_node_origin_set(Eo *obj EINA_UNUSED, + Evas_VG_Node_Data *pd, + double x, double y) +{ + pd->x = x; + pd->y = y; +} + +void +_evas_vg_node_origin_get(Eo *obj EINA_UNUSED, + Evas_VG_Node_Data *pd, + double *x, double *y) +{ + if (x) *x = pd->x; + if (y) *y = pd->y; +} + +void +_evas_vg_node_visibility_set(Eo *obj EINA_UNUSED, + Evas_VG_Node_Data *pd, + Eina_Bool v) +{ + pd->visibility = v; +} + +Eina_Bool +_evas_vg_node_visibility_get(Eo *obj EINA_UNUSED, Evas_VG_Node_Data *pd) +{ + return pd->visibility; +} + +void +_evas_vg_node_color_set(Eo *obj EINA_UNUSED, + Evas_VG_Node_Data *pd, + int r, int g, int b, int a) +{ + pd->r = r; + pd->g = g; + pd->b = b; + pd->a = a; +} + +void +_evas_vg_node_color_get(Eo *obj EINA_UNUSED, + Evas_VG_Node_Data *pd, + int *r, int *g, int *b, int *a) +{ + if (r) *r = pd->r; + if (g) *g = pd->g; + if (b) *b = pd->b; + if (a) *a = pd->a; +} + +void +_evas_vg_node_mask_set(Eo *obj EINA_UNUSED, + Evas_VG_Node_Data *pd, + Evas_VG_Node *r) +{ + Evas_VG_Node *tmp = pd->mask; + + pd->mask = eo_ref(r); + eo_unref(tmp); +} + +Evas_VG_Node* +_evas_vg_node_mask_get(Eo *obj EINA_UNUSED, Evas_VG_Node_Data *pd) +{ + return pd->mask; +} + +// Parent should be a container otherwise dismissing the stacking operation +void +_evas_vg_node_eo_base_constructor(Eo *obj, Evas_VG_Node_Data *pd) +{ + Eo *parent; + + eo_do_super(obj, MY_CLASS, eo_constructor()); + eo_do(obj, parent = eo_parent_get()); + if (!eo_isa(parent, EVAS_VG_CONTAINER_CLASS)) + eo_error_set(obj); +} + +void +_evas_vg_node_eo_base_parent_set(Eo *obj, Evas_VG_Node_Data *pd, Eo *parent) +{ +} + +void +_evas_vg_node_raise(Eo *obj, Evas_VG_Node_Data *pd EINA_UNUSED) +{ + Eo *parent; + + eo_do(obj, parent = eo_parent_get()); +} + +void +_evas_vg_node_stack_above(Eo *obj, + Evas_VG_Node_Data *pd EINA_UNUSED, + Evas_VG_Node *above) +{ + Eo *parent; + + eo_do(obj, parent = eo_parent_get()); +} + +void +_evas_vg_node_stack_below(Eo *obj, + Evas_VG_Node_Data *pd EINA_UNUSED, + Evas_Object *below) +{ + Eo *parent; + + eo_do(obj, parent = eo_parent_get()); +} + +void +_evas_vg_node_lower(Eo *obj, Evas_VG_Node_Data *pd EINA_UNUSED) +{ + Eo *parent; + + eo_do(obj, parent = eo_parent_get()); +} + +#include "evas_vg_node.eo.c" diff --git a/src/lib/evas/canvas/evas_vg_node.eo b/src/lib/evas/canvas/evas_vg_node.eo new file mode 100644 index 0000000000..e989f7a331 --- /dev/null +++ b/src/lib/evas/canvas/evas_vg_node.eo @@ -0,0 +1,162 @@ +abstract Evas.VG_Node (Eo.Base) +{ + eo_prefix: evas_vg_node; + legacy_prefix: null; + properties { + transformation { + set { + } + get { + } + values { + const(Eina_Matrix3) *m; + } + } + origin { + set { + } + get { + } + values { + double x; + double y; + } + } + visibility { + set { + /*@ Makes the given Evas_VG node visible or invisible. */ + } + get { + /*@ Retrieves whether or not the given Evas_VG node is visible. */ + } + values { + Eina_Bool v; /*@ @c EINA_TRUE if to make the object visible, @c EINA_FALSE otherwise */ + } + } + color { + set { + /*@ + Sets the general/main color of the given Evas_VG node to the given + one. + + @note These color values are expected to be premultiplied by @p a. + + @ingroup Evas_VG_Node_Group */ + } + get { + /*@ + Retrieves the general/main color of the given Evas_VG node. + + Retrieves the “main” color's RGB component (and alpha channel) + values, which range from 0 to 255. For the alpha channel, + which defines the object's transparency level, 0 means totally + transparent, while 255 means opaque. These color values are + premultiplied by the alpha value. + + @note Use @c NULL pointers on the components you're not interested + in: they'll be ignored by the function. + + @ingroup Evas_VG_Node_Group */ + } + values { + int r; /*@ The red component of the given color. */ + int g; /*@ The green component of the given color. */ + int b; /*@ The blue component of the given color. */ + int a; /*@ The alpha component of the given color. */ + } + } + mask { + set { + } + get { + } + values { + Evas_VG_Node *m; + } + } +/* quality { + set { + } + get { + } + values { + Evas_VG_Quality q; + } + } */ + } + methods { + bound_get { + return: bool @warn_unused; + params { + @out Eina_Rectangle r; + } + } + raise { + /*@ + Raise @p obj to the top of its layer. + + @p obj will, then, be the highest one in the layer it belongs + to. Object on other layers won't get touched. + + @see evas_vg_node_stack_above() + @see evas_vg_node_stack_below() + @see evas_vg_node_lower() */ + } + stack_above { + /*@ + Stack @p obj immediately above @p above + + Objects, in a given Evas_VG_Container, are stacked in the order they get added + to it. This means that, if they overlap, the highest ones will + cover the lowest ones, in that order. This function is a way to + change the stacking order for the objects. + + This function is intended to be used with objects belonging to + the same container, otherwise it will fail (and + accomplish nothing). + + @see evas_vg_node_stack_below() */ + + params { + @in Evas_VG_Node *above @nonull; /*@ the object above which to stack */ + } + } + stack_below { + /*@ + Stack @p obj immediately below @p below + + Objects, in a given container, are stacked in the order they get added + to it. This means that, if they overlap, the highest ones will + cover the lowest ones, in that order. This function is a way to + change the stacking order for the objects. + + This function is intended to be used with objects belonging to + the same container, otherwise it will fail (and + accomplish nothing). + + @see evas_vg_node_layer_get() + @see evas_vg_node_layer_set() + @see evas_vg_node_stack_below() */ + + params { + @in Evas_Object *below @nonull; /*@ the object below which to stack */ + } + } + lower { + /*@ + Lower @p obj to the bottom of its layer. + + @p obj will, then, be the lowest one in the layer it belongs + to. Objects on other layers won't get touched. + + @see evas_vg_node_stack_above() + @see evas_vg_node_stack_below() + @see evas_vg_node_raise() */ + } + } + implements { + Eo.Base.parent.set; + Eo.Base.constructor; + @virtual .bound_get; + } +} \ No newline at end of file diff --git a/src/lib/evas/canvas/evas_vg_private.h b/src/lib/evas/canvas/evas_vg_private.h new file mode 100644 index 0000000000..0578b5383d --- /dev/null +++ b/src/lib/evas/canvas/evas_vg_private.h @@ -0,0 +1,10 @@ +#ifndef EVAS_VG_PRIVATE_H_ +# define EVAS_VG_PRIVATE_H_ + +typedef struct _Evas_VG_Container_Data Evas_VG_Container_Data; +struct _Evas_VG_Container_Data +{ + Eina_List *children; +}; + +#endif diff --git a/src/lib/evas/canvas/evas_vg_root_node.c b/src/lib/evas/canvas/evas_vg_root_node.c new file mode 100644 index 0000000000..33f9d2180b --- /dev/null +++ b/src/lib/evas/canvas/evas_vg_root_node.c @@ -0,0 +1,41 @@ +#include "evas_common_private.h" +#include "evas_private.h" + +#include "evas_vg_root_node.eo.h" + +#include + +#define MY_CLASS EVAS_VG_ROOT_NODE_CLASS + +typedef struct _Evas_VG_Root_Node_Data Evas_VG_Root_Node_Data; +struct _Evas_VG_Root_Node_Data +{ +}; + +void +_evas_vg_root_node_eo_base_parent_set(Eo *obj, + Evas_VG_Root_Node_Data *pd EINA_UNUSED, + Eo *parent) +{ + // Nice little hack, jump over parent parent_set in Evas_VG_Root + eo_do_super(obj, EVAS_VG_NODE_CLASS, eo_constructor()); + if (!eo_isa(parent, EVAS_VG_CLASS) && + !eo_isa(parent, EVAS_VG_CONTAINER_CLASS)) + eo_error_set(obj); +} + +void +_evas_vg_root_node_eo_base_constructor(Eo *obj, + Evas_VG_Root_Node_Data *pd EINA_UNUSED) +{ + Eo *parent; + + // Nice little hack, jump over parent constructor in Evas_VG_Root + eo_do_super(obj, EVAS_VG_NODE_CLASS, eo_constructor()); + eo_do(obj, parent = eo_parent_get()); + if (!eo_isa(parent, EVAS_VG_CLASS) && + !eo_isa(parent, EVAS_VG_CONTAINER_CLASS)) + eo_error_set(obj); +} + +#include "evas_vg_root_node.eo.c" diff --git a/src/lib/evas/canvas/evas_vg_root_node.eo b/src/lib/evas/canvas/evas_vg_root_node.eo new file mode 100644 index 0000000000..db0837d9f2 --- /dev/null +++ b/src/lib/evas/canvas/evas_vg_root_node.eo @@ -0,0 +1,8 @@ +class Evas.VG_Root_Node (Evas.VG_Node) +{ + eo_prefix: evas_vg_root_node; + implements { + Eo.Base.parent.set; + Eo.Base.constructor; + } +} diff --git a/src/lib/evas/canvas/evas_vg_shape.c b/src/lib/evas/canvas/evas_vg_shape.c new file mode 100644 index 0000000000..878cc7eb3d --- /dev/null +++ b/src/lib/evas/canvas/evas_vg_shape.c @@ -0,0 +1,39 @@ +#include "evas_common_private.h" +#include "evas_private.h" + +#define MY_CLASS EVAS_VG_SHAPE_CLASS + +typedef struct _Evas_VG_Shape_Data Evas_VG_Shape_Data; +struct _Evas_VG_Shape_Data +{ + Evas_VG_Path_Command *op; + double *points; + unsigned int op_count; + unsigned int pts_counts; +}; + +Eina_Bool +_evas_vg_shape_path_set(Eo *obj, Evas_VG_Shape_Data *pd, Evas_VG_Path_Command *op, double *points) +{ +} + +Eina_Bool +_evas_vg_shape_bounds_get(Eo *obj, Evas_VG_Shape_Data *pd, Eina_Rectangle *r) +{ +} + +void +_evas_vg_shape_eo_base_constructor(Eo *obj, Evas_VG_Shape_Data *pd) +{ + Eo *parent; + + eo_super_do(obj, MY_CLASS, eo_constructor()); + + eo_do(obj, parent = eo_parent_get()); + if (!eo_isa(obj, EVAS_VG_CONTAINER_CLASS) && + !eo_isa(obj, EVAS_VG_CLASS)) + { + ERR("Parent must be either an Evas_Object_VG or an Evas_VG_Container."); + eo_error_set(obj); + } +} diff --git a/src/lib/evas/canvas/evas_vg_shape.eo b/src/lib/evas/canvas/evas_vg_shape.eo new file mode 100644 index 0000000000..32d959df62 --- /dev/null +++ b/src/lib/evas/canvas/evas_vg_shape.eo @@ -0,0 +1,113 @@ +class Evas.VG_Shape (Evas.VG_Node) +{ + eo_prefix: evas_vg_shape; + properties { + fill { + set { + } + get { + } + values { + Evas_VG_Node *f; + } + } + stroke_scale { + set { + } + get { + } + values { + double s; + } + } + stroke_color { + set { + } + get { + } + values { + int r; + int g; + int b; + int a; + } + } + stroke_fill { + set { + } + get { + } + values { + Evas_VG_Node *f; + } + } + stroke_width { + set { + } + get { + } + values { + double w; + } + } + stroke_location { + set { + } + get { + } + values { + double centered; + } + } + stroke_dash { + set { + } + get { + } + values { + const(Evas_VG_Dash) *dash; + uint length; + } + } + stroke_marker { + set { + } + get { + } + values { + Evas_VG_Shape *m; + } + } + stroke_cap { + set { + } + get { + } + values { + Evas_VG_Cap c; + } + } + stroke_join { + set { + } + get { + } + values { + Evas_VG_Join j; + } + } + } + methods { + path_set { + return: bool; + params { + @in const(Evas_VG_Path_Command) *op; + @in const(double) *points; + } + } + } + implements { + Eo.Base.constructor; + Eo.Base.destructor; + } +} diff --git a/src/lib/evas/include/evas_private.h b/src/lib/evas/include/evas_private.h index b1c82e59ca..bc3421d315 100644 --- a/src/lib/evas/include/evas_private.h +++ b/src/lib/evas/include/evas_private.h @@ -488,6 +488,7 @@ OPAQUE_TYPE(Evas_Font_Instance); /* General type for RGBA_Font_Int */ #define MAGIC_SMART 0x7c6977c5 #define MAGIC_OBJ_SHAPE 0x747297f7 #define MAGIC_OBJ_CONTAINER 0x71877776 +#define MAGIC_OBJ_VG 0x77817EE7 #define MAGIC_OBJ_CUSTOM 0x7b7857ab #define MAGIC_EVAS_GL 0x77976718 #define MAGIC_MAP 0x7575177d From 45ccb8f6d1874d41c1a9b500af66922908fdcd71 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:13:00 +0200 Subject: [PATCH 003/251] evas: add utility function to build path. --- src/Makefile_Evas.am | 3 +- src/lib/evas/canvas/evas_vg_utils.c | 198 ++++++++++++++++++++++++++++ 2 files changed, 200 insertions(+), 1 deletion(-) create mode 100644 src/lib/evas/canvas/evas_vg_utils.c diff --git a/src/Makefile_Evas.am b/src/Makefile_Evas.am index d2410e34e2..ba1f525764 100644 --- a/src/Makefile_Evas.am +++ b/src/Makefile_Evas.am @@ -218,7 +218,8 @@ lib/evas/canvas/evas_vg_container.c \ lib/evas/canvas/evas_vg_root_node.c \ lib/evas/canvas/evas_vg_gradient.c \ lib/evas/canvas/evas_vg_gradient_linear.c \ -lib/evas/canvas/evas_vg_gradient_radial.c +lib/evas/canvas/evas_vg_gradient_radial.c \ +lib/evas/canvas/evas_vg_utils.c # Engine lib_evas_libevas_la_SOURCES += \ diff --git a/src/lib/evas/canvas/evas_vg_utils.c b/src/lib/evas/canvas/evas_vg_utils.c new file mode 100644 index 0000000000..ec09fe77ce --- /dev/null +++ b/src/lib/evas/canvas/evas_vg_utils.c @@ -0,0 +1,198 @@ +#include "evas_common_private.h" +#include "evas_private.h" + +static unsigned int +evas_vg_path_command_length(Evas_VG_Path_Command command) +{ + switch (command) + { + case EVAS_VG_PATH_COMMAND_TYPE_END: return 0; + case EVAS_VG_PATH_COMMAND_TYPE_MOVE_TO: return 2; + case EVAS_VG_PATH_COMMAND_TYPE_LINE_TO: return 2; + case EVAS_VG_PATH_COMMAND_TYPE_QUADRATIC_TO: return 4; + case EVAS_VG_PATH_COMMAND_TYPE_SQUADRATIC_TO: return 2; + case EVAS_VG_PATH_COMMAND_TYPE_CUBIC_TO: return 6; + case EVAS_VG_PATH_COMMAND_TYPE_SCUBIC_TO: return 4; + case EVAS_VG_PATH_COMMAND_TYPE_ARC_TO: return 5; + case EVAS_VG_PATH_COMMAND_TYPE_CLOSE: return 0; + case EVAS_VG_PATH_COMMAND_TYPE_LAST: return 0; + } + return 0; +} + +static inline Eina_Bool +evas_vg_path_grow(Evas_VG_Path_Command command, + Evas_VG_Path_Command **commands, double **points, + double **offset_point) +{ + Evas_VG_Path_Command *cmd_tmp; + double *pts_tmp; + unsigned int cmd_length = 0, pts_length = 0; + + if (command) + { + while (commands[cmd_length] != EVAS_VG_PATH_COMMAND_TYPE_END) + { + pts_length += evas_vg_path_command_length((*commands)[cmd_length]); + cmd_length++; + } + } + // Accounting for END command and handle gracefully the NULL case at the same time + cmd_length++; + + if (evas_vg_path_command_length(command)) + { + pts_length += evas_vg_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 - evas_vg_path_command_length(command); + } + + cmd_tmp = realloc(*commands, + (cmd_length + 1) * sizeof (Evas_VG_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] = EVAS_VG_PATH_COMMAND_TYPE_END; + + return EINA_TRUE; +} + +void +evas_vg_path_append_move_to(Evas_VG_Path_Command **commands, double **points, + double x, double y) +{ + double *offset_point; + + if (!evas_vg_path_grow(EVAS_VG_PATH_COMMAND_TYPE_MOVE_TO, + commands, points, &offset_point)) + return ; + + offset_point[0] = x; + offset_point[1] = y; +} + +void +evas_vg_path_append_line_to(Evas_VG_Path_Command **commands, double **points, + double x, double y) +{ + double *offset_point; + + if (!evas_vg_path_grow(EVAS_VG_PATH_COMMAND_TYPE_LINE_TO, + commands, points, &offset_point)) + return ; + + offset_point[0] = x; + offset_point[1] = y; +} + +void +evas_vg_path_append_quadratic_to(Evas_VG_Path_Command **commands, double **points, + double x, double y, double ctrl_x, double ctrl_y) +{ + double *offset_point; + + if (!evas_vg_path_grow(EVAS_VG_PATH_COMMAND_TYPE_QUADRATIC_TO, + commands, points, &offset_point)) + return ; + + offset_point[0] = x; + offset_point[1] = y; + offset_point[2] = ctrl_x; + offset_point[3] = ctrl_y; +} + +void +evas_vg_path_append_squadratic_to(Evas_VG_Path_Command **commands, double **points, + double x, double y) +{ + double *offset_point; + + if (!evas_vg_path_grow(EVAS_VG_PATH_COMMAND_TYPE_SQUADRATIC_TO, + commands, points, &offset_point)) + return ; + + offset_point[0] = x; + offset_point[1] = y; +} + +void +evas_vg_path_append_cubic_to(Evas_VG_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 (!evas_vg_path_grow(EVAS_VG_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; +} + +void +evas_vg_path_append_scubic_to(Evas_VG_Path_Command **commands, double **points, + double x, double y, + double ctrl_x, double ctrl_y) +{ + double *offset_point; + + if (!evas_vg_path_grow(EVAS_VG_PATH_COMMAND_TYPE_SCUBIC_TO, + commands, points, &offset_point)) + return ; + + offset_point[0] = x; + offset_point[1] = y; + offset_point[2] = ctrl_x; + offset_point[3] = ctrl_y; +} + +void +evas_vg_path_append_arc_to(Evas_VG_Path_Command **commands, double **points, + double x, double y, + double rx, double ry, + double angle) +{ + double *offset_point; + + if (!evas_vg_path_grow(EVAS_VG_PATH_COMMAND_TYPE_ARC_TO, + commands, points, &offset_point)) + return ; + + offset_point[0] = x; + offset_point[1] = y; + offset_point[2] = rx; + offset_point[3] = ry; + offset_point[4] = angle; +} + +void +evas_vg_path_append_close(Evas_VG_Path_Command **commands, double **points) +{ + double *offset_point; + + evas_vg_path_grow(EVAS_VG_PATH_COMMAND_TYPE_ARC_TO, + commands, points, &offset_point); +} + +void +evas_vg_path_append_circle(Evas_VG_Path_Command **commands, double **points, + double x, double y, double radius) +{ + evas_vg_path_append_move_to(commands, points, x, y - radius); + evas_vg_path_append_arc_to(commands, points, x + radius, y, radius, radius, 0); + evas_vg_path_append_arc_to(commands, points, x, y + radius, radius, radius, 0); + evas_vg_path_append_arc_to(commands, points, x - radius, y, radius, radius, 0); + evas_vg_path_append_arc_to(commands, points, x, y - radius, radius, radius, 0); +} From 7b759ceeca12f5e1c56bbdbbf1bd454f46bb4369 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:13:02 +0200 Subject: [PATCH 004/251] evas: add evas_vg note. --- NOTES | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 NOTES diff --git a/NOTES b/NOTES new file mode 100644 index 0000000000..bb565c266b --- /dev/null +++ b/NOTES @@ -0,0 +1,31 @@ +Evas_VG_Color_List + - List of color + +Evas_VG_Gradient + gradient_type_set (radial, linear) + color_list_set + point_set (i, x, y) + +Evas_VG_Fill + - abstract + +Evas_VG_Root_Node (only one at the top, Evas_VG_Container) + +Evas_VG_Shape + fill + stroke_scale + stroke_color + stroke_fill + stroke_width + stroke_location + stroke_dash(length[], gap[]) + stroke_marker(Evas_VG_Shape *) + stroke_cap + stroke_join + +Evas_VG_Filter + ?? + +bounds_get -> Evas_VG_Node + +Eina_Matrix3 From 95e70ee5cbd5c62c703fd5e9cd220f4dfc87ddb0 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:13:03 +0200 Subject: [PATCH 005/251] evas: remove unecessary duplicated code. --- src/lib/evas/canvas/evas_vg_container.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/lib/evas/canvas/evas_vg_container.c b/src/lib/evas/canvas/evas_vg_container.c index fc008bb552..4bedd863b7 100644 --- a/src/lib/evas/canvas/evas_vg_container.c +++ b/src/lib/evas/canvas/evas_vg_container.c @@ -11,14 +11,6 @@ _evas_vg_container_eo_base_constructor(Eo *obj, Evas_VG_Container_Data *pd) Eo *parent; eo_do_super(obj, MY_CLASS, eo_constructor()); - - eo_do(obj, parent = eo_parent_get()); - if (!eo_isa(obj, EVAS_VG_CONTAINER_CLASS) && - !eo_isa(obj, EVAS_VG_CLASS)) - { - ERR("Parent must be either an Evas_Object_VG or an Evas_VG_Container."); - eo_error_set(obj); - } } Eina_Bool From 9dcf840ade4c787c9cf26026328d0abfb6df5852 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:13:05 +0200 Subject: [PATCH 006/251] evas: Evas_VG_Root_Node should only be attached to an Evas_Object_VG. --- src/lib/evas/canvas/evas_vg_root_node.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/lib/evas/canvas/evas_vg_root_node.c b/src/lib/evas/canvas/evas_vg_root_node.c index 33f9d2180b..d77c4c581f 100644 --- a/src/lib/evas/canvas/evas_vg_root_node.c +++ b/src/lib/evas/canvas/evas_vg_root_node.c @@ -19,8 +19,7 @@ _evas_vg_root_node_eo_base_parent_set(Eo *obj, { // Nice little hack, jump over parent parent_set in Evas_VG_Root eo_do_super(obj, EVAS_VG_NODE_CLASS, eo_constructor()); - if (!eo_isa(parent, EVAS_VG_CLASS) && - !eo_isa(parent, EVAS_VG_CONTAINER_CLASS)) + if (!eo_isa(parent, EVAS_VG_CLASS)) eo_error_set(obj); } @@ -33,8 +32,7 @@ _evas_vg_root_node_eo_base_constructor(Eo *obj, // Nice little hack, jump over parent constructor in Evas_VG_Root eo_do_super(obj, EVAS_VG_NODE_CLASS, eo_constructor()); eo_do(obj, parent = eo_parent_get()); - if (!eo_isa(parent, EVAS_VG_CLASS) && - !eo_isa(parent, EVAS_VG_CONTAINER_CLASS)) + if (!eo_isa(parent, EVAS_VG_CLASS)) eo_error_set(obj); } From fa2f4e969e5433234998755486102157e8ac532c Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:13:06 +0200 Subject: [PATCH 007/251] evas: implement Evas_VG_Node stacking functions. --- src/lib/evas/canvas/evas_vg_node.c | 119 ++++++++++++++++++++++++++++- 1 file changed, 115 insertions(+), 4 deletions(-) diff --git a/src/lib/evas/canvas/evas_vg_node.c b/src/lib/evas/canvas/evas_vg_node.c index 029b986223..a6ffee050b 100644 --- a/src/lib/evas/canvas/evas_vg_node.c +++ b/src/lib/evas/canvas/evas_vg_node.c @@ -1,6 +1,8 @@ #include "evas_common_private.h" #include "evas_private.h" +#include "evas_vg_private.h" + #include #define MY_CLASS EVAS_VG_NODE_CLASS @@ -113,27 +115,79 @@ _evas_vg_node_mask_get(Eo *obj EINA_UNUSED, Evas_VG_Node_Data *pd) // Parent should be a container otherwise dismissing the stacking operation void -_evas_vg_node_eo_base_constructor(Eo *obj, Evas_VG_Node_Data *pd) +_evas_vg_node_eo_base_constructor(Eo *obj, Evas_VG_Node_Data *pd EINA_UNUSED) { + Evas_VG_Container_Data *cd; Eo *parent; eo_do_super(obj, MY_CLASS, eo_constructor()); + eo_do(obj, parent = eo_parent_get()); - if (!eo_isa(parent, EVAS_VG_CONTAINER_CLASS)) - eo_error_set(obj); + cd = eo_data_scope_get(parent, EVAS_VG_CONTAINER_CLASS); + if (!cd) + { + eo_error_set(obj); + return ; + } + cd->children = eina_list_append(cd->children, obj); } void -_evas_vg_node_eo_base_parent_set(Eo *obj, Evas_VG_Node_Data *pd, Eo *parent) +_evas_vg_node_eo_base_parent_set(Eo *obj, + Evas_VG_Node_Data *pd EINA_UNUSED, + Eo *parent) { + Evas_VG_Container_Data *cd; + Evas_VG_Container_Data *old_cd; + Eo *old_parent; + + cd = eo_data_scope_get(parent, EVAS_VG_CONTAINER_CLASS); + if (!cd) + { + eo_error_set(obj); + return ; + } + + eo_do(obj, old_parent = eo_parent_get()); + old_cd = eo_data_scope_get(old_parent, EVAS_VG_CONTAINER_CLASS); + if (!old_cd) + { + eo_error_set(obj); + return ; + } + + // FIXME: this may become slow with to much object + old_cd->children = eina_list_remove(old_cd->children, obj); + + eo_do_super(obj, MY_CLASS, eo_parent_set(parent)); + cd->children = eina_list_append(cd->children, obj); } void _evas_vg_node_raise(Eo *obj, Evas_VG_Node_Data *pd EINA_UNUSED) { + Evas_VG_Container_Data *cd; + Eina_List *lookup, *next; Eo *parent; eo_do(obj, parent = eo_parent_get()); + cd = eo_data_scope_get(parent, EVAS_VG_CONTAINER_CLASS); + if (!cd) goto on_error; + + // FIXME: this could become slow with to much object + lookup = eina_list_data_find_list(cd->children, obj); + if (!lookup) goto on_error; + + next = eina_list_next(lookup); + if (!next) return ; + + cd->children = eina_list_remove_list(cd->children, lookup); + cd->children = eina_list_append_relative_list(cd->children, obj, next); + + return ; + + on_error: + eo_error_set(obj); } void @@ -141,9 +195,28 @@ _evas_vg_node_stack_above(Eo *obj, Evas_VG_Node_Data *pd EINA_UNUSED, Evas_VG_Node *above) { + Evas_VG_Container_Data *cd; + Eina_List *lookup, *ref; Eo *parent; eo_do(obj, parent = eo_parent_get()); + cd = eo_data_scope_get(parent, EVAS_VG_CONTAINER_CLASS); + if (!cd) goto on_error; + + // FIXME: this could become slow with to much object + lookup = eina_list_data_find_list(cd->children, obj); + if (!lookup) goto on_error; + + ref = eina_list_data_find_list(cd->children, above); + if (!ref) goto on_error; + + cd->children = eina_list_remove_list(cd->children, lookup); + cd->children = eina_list_append_relative_list(cd->children, obj, ref); + + return ; + + on_error: + eo_error_set(obj); } void @@ -151,17 +224,55 @@ _evas_vg_node_stack_below(Eo *obj, Evas_VG_Node_Data *pd EINA_UNUSED, Evas_Object *below) { + Evas_VG_Container_Data *cd; + Eina_List *lookup, *ref; Eo *parent; eo_do(obj, parent = eo_parent_get()); + cd = eo_data_scope_get(parent, EVAS_VG_CONTAINER_CLASS); + if (!cd) goto on_error; + + // FIXME: this could become slow with to much object + lookup = eina_list_data_find_list(cd->children, obj); + if (!lookup) goto on_error; + + ref = eina_list_data_find_list(cd->children, below); + if (!ref) goto on_error; + + cd->children = eina_list_remove_list(cd->children, lookup); + cd->children = eina_list_prepend_relative_list(cd->children, obj, ref); + + return ; + + on_error: + eo_error_set(obj); } void _evas_vg_node_lower(Eo *obj, Evas_VG_Node_Data *pd EINA_UNUSED) { + Evas_VG_Container_Data *cd; + Eina_List *lookup, *prev; Eo *parent; eo_do(obj, parent = eo_parent_get()); + cd = eo_data_scope_get(parent, EVAS_VG_CONTAINER_CLASS); + if (!cd) goto on_error; + + // FIXME: this could become slow with to much object + lookup = eina_list_data_find_list(cd->children, obj); + if (!lookup) goto on_error; + + prev = eina_list_prev(lookup); + if (!prev) return ; + + cd->children = eina_list_remove_list(cd->children, lookup); + cd->children = eina_list_prepend_relative_list(cd->children, obj, prev); + + return ; + + on_error: + eo_error_set(obj); } #include "evas_vg_node.eo.c" From 161b7b93e2f5587ce2daab7eca05c2beb5d5e9d5 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:13:07 +0200 Subject: [PATCH 008/251] evas: add Evas_VG_Image. --- src/Makefile_Evas.am | 6 ++- src/lib/evas/Evas_Eo.h | 1 + src/lib/evas/canvas/evas_vg_image.c | 63 ++++++++++++++++++++++++++++ src/lib/evas/canvas/evas_vg_image.eo | 32 ++++++++++++++ 4 files changed, 100 insertions(+), 2 deletions(-) create mode 100644 src/lib/evas/canvas/evas_vg_image.c create mode 100644 src/lib/evas/canvas/evas_vg_image.eo diff --git a/src/Makefile_Evas.am b/src/Makefile_Evas.am index ba1f525764..32425870c0 100644 --- a/src/Makefile_Evas.am +++ b/src/Makefile_Evas.am @@ -39,7 +39,8 @@ evas_eolian_files = \ lib/evas/canvas/evas_vg_root_node.eo \ lib/evas/canvas/evas_vg_gradient.eo \ lib/evas/canvas/evas_vg_gradient_radial.eo \ - lib/evas/canvas/evas_vg_gradient_linear.eo + lib/evas/canvas/evas_vg_gradient_linear.eo \ + lib/evas/canvas/evas_vg_image.eo evas_eolian_c = $(evas_eolian_files:%.eo=%.eo.c) evas_eolian_h = $(evas_eolian_files:%.eo=%.eo.h) \ @@ -219,7 +220,8 @@ lib/evas/canvas/evas_vg_root_node.c \ lib/evas/canvas/evas_vg_gradient.c \ lib/evas/canvas/evas_vg_gradient_linear.c \ lib/evas/canvas/evas_vg_gradient_radial.c \ -lib/evas/canvas/evas_vg_utils.c +lib/evas/canvas/evas_vg_utils.c \ +lib/evas/canvas/evas_vg_image.c # Engine lib_evas_libevas_la_SOURCES += \ diff --git a/src/lib/evas/Evas_Eo.h b/src/lib/evas/Evas_Eo.h index cfadf6d331..846c8f6819 100644 --- a/src/lib/evas/Evas_Eo.h +++ b/src/lib/evas/Evas_Eo.h @@ -931,3 +931,4 @@ typedef enum _Evas_VG_Gradient_Spread #include "canvas/evas_vg_gradient.eo.h" #include "canvas/evas_vg_gradient_linear.eo.h" #include "canvas/evas_vg_gradient_radial.eo.h" +#include "canvas/evas_vg_image.eo.h" diff --git a/src/lib/evas/canvas/evas_vg_image.c b/src/lib/evas/canvas/evas_vg_image.c new file mode 100644 index 0000000000..b93fc13f9e --- /dev/null +++ b/src/lib/evas/canvas/evas_vg_image.c @@ -0,0 +1,63 @@ +#include "evas_common_private.h" +#include "evas_private.h" + +#include + +typedef struct _Evas_VG_Image_Data Evas_VG_Image_Data; +struct _Evas_VG_Image_Data +{ + // FIXME: only manipulate Eina_File internally. + Eina_Stringshare *file, *key; + + int x, y; + unsigned int w, h; +}; + +void +_evas_vg_image_position_set(Eo *obj, Evas_VG_Image_Data *pd, int x, int y) +{ + pd->x = x; + pd->y = y; +} + +void +_evas_vg_image_position_get(Eo *obj, Evas_VG_Image_Data *pd, int *x, int *y) +{ + if (x) *x = pd->x; + if (y) *y = pd->y; +} + +void +_evas_vg_image_size_set(Eo *obj, Evas_VG_Image_Data *pd, + unsigned int w, unsigned int h) +{ + pd->w = w; + pd->h = h; +} + +void +_evas_vg_image_size_get(Eo *obj, Evas_VG_Image_Data *pd, + unsigned int *w, unsigned int *h) +{ + if (w) *w = pd->w; + if (h) *h = pd->h; +} + +Eina_Bool +_evas_vg_image_efl_file_file_set(Eo *obj, Evas_VG_Image_Data *pd, + const char *file, const char *key) +{ + eina_stringshare_replace(&pd->file, file); + eina_stringshare_replace(&pd->key, key); +} + +void +_evas_vg_image_efl_file_file_get(Eo *obj, Evas_VG_Image_Data *pd, + const char **file, const char **key) +{ + if (file) *file = pd->file; + if (key) *key = pd->key; +} + + +#include "evas_vg_image.eo.c" diff --git a/src/lib/evas/canvas/evas_vg_image.eo b/src/lib/evas/canvas/evas_vg_image.eo new file mode 100644 index 0000000000..6ed670e93e --- /dev/null +++ b/src/lib/evas/canvas/evas_vg_image.eo @@ -0,0 +1,32 @@ +class Evas.VG_Image (Evas.VG_Node, Efl.File) +{ + eo_prefix: evas_vg_image; + legacy_prefix: null; + properties { + position { + set { + } + get { + } + values { + int x; + int y; + } + } + size { + set { + } + get { + } + values { + uint w; + uint h; + } + } + // FIXME: add aspect ratio following SVG specification + } + implements { + Efl.File.file.set; + Efl.File.file.get; + } +} \ No newline at end of file From 7f072eb607485d6cd34e4a96feb7d246062d229f Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:13:11 +0200 Subject: [PATCH 009/251] evas: add Efl.File interface to Evas_Object_VG. --- src/lib/evas/canvas/evas_object_vg.c | 15 +++++++++++++++ src/lib/evas/canvas/evas_vg.eo | 4 +++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/lib/evas/canvas/evas_object_vg.c b/src/lib/evas/canvas/evas_object_vg.c index c956fb8fa5..5d750c1cb9 100644 --- a/src/lib/evas/canvas/evas_object_vg.c +++ b/src/lib/evas/canvas/evas_object_vg.c @@ -312,4 +312,19 @@ evas_object_vg_was_opaque(Evas_Object *eo_obj EINA_UNUSED, return 0; } + +Eina_Bool +_evas_vg_efl_file_file_set(Eo *obj, Evas_VG_Data *pd, + const char *file, const char *key) +{ + // FIXME: just load SVG for now + return EINA_FALSE; +} + +void +_evas_vg_efl_file_file_get(Eo *obj, Evas_VG_Data *pd, + const char **file, const char **key) +{ +} + #include "evas_vg.eo.c" diff --git a/src/lib/evas/canvas/evas_vg.eo b/src/lib/evas/canvas/evas_vg.eo index fef9e8ad30..95c1ef04bc 100644 --- a/src/lib/evas/canvas/evas_vg.eo +++ b/src/lib/evas/canvas/evas_vg.eo @@ -1,4 +1,4 @@ -class Evas.VG (Evas.Object) +class Evas.VG (Evas.Object, Efl.File) { legacy_prefix: evas_object_vg; eo_prefix: evas_obj_vg; @@ -13,5 +13,7 @@ class Evas.VG (Evas.Object) } implements { Eo.Base.constructor; + Efl.File.file.set; + Efl.File.file.get; } } \ No newline at end of file From 1e5c596ca3ddb03e16aae5f2b1418a59cc9db699 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:13:12 +0200 Subject: [PATCH 010/251] evas: implement stupid bound get at container level. --- src/lib/evas/canvas/evas_vg_container.c | 32 +++++++++++++++++++++---- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/src/lib/evas/canvas/evas_vg_container.c b/src/lib/evas/canvas/evas_vg_container.c index 4bedd863b7..3459f4ad50 100644 --- a/src/lib/evas/canvas/evas_vg_container.c +++ b/src/lib/evas/canvas/evas_vg_container.c @@ -6,19 +6,41 @@ #define MY_CLASS EVAS_VG_CONTAINER_CLASS void -_evas_vg_container_eo_base_constructor(Eo *obj, Evas_VG_Container_Data *pd) +_evas_vg_container_eo_base_constructor(Eo *obj, + Evas_VG_Container_Data *pd EINA_UNUSED) { - Eo *parent; - eo_do_super(obj, MY_CLASS, eo_constructor()); } Eina_Bool -_evas_vg_container_evas_vg_node_bound_get(Eo *obj, +_evas_vg_container_evas_vg_node_bound_get(Eo *obj EINA_UNUSED, Evas_VG_Container_Data *pd, Eina_Rectangle *r) { - // FIXME: iterate children and get their boundary to + Eina_Rectangle s; + Eina_Bool first = EINA_TRUE; + Eina_List *l; + Eo *child; + + if (!r) return EINA_FALSE; + + EINA_RECTANGLE_SET(&s, -1, -1, 0, 0); + + EINA_LIST_FOREACH(pd->children, l, child) + { + if (first) + { + eo_do(child, evas_vg_node_bound_get(r)); + first = EINA_FALSE; + } + else + { + eo_do(child, evas_vg_node_bound_get(&s)); + eina_rectangle_union(r, &s); + } + } + // returning EINA_FALSE if no bouding box was found + return first ? EINA_FALSE : EINA_TRUE; } From ae5472379f099d4c6fc64fbf60ffa2f2ec98e9eb Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:13:13 +0200 Subject: [PATCH 011/251] evas: handle path set on shape object. --- src/lib/evas/canvas/evas_vg_shape.c | 9 ++++- src/lib/evas/canvas/evas_vg_utils.c | 51 +++++++++++++++++++++++------ 2 files changed, 49 insertions(+), 11 deletions(-) diff --git a/src/lib/evas/canvas/evas_vg_shape.c b/src/lib/evas/canvas/evas_vg_shape.c index 878cc7eb3d..4262fa5ec8 100644 --- a/src/lib/evas/canvas/evas_vg_shape.c +++ b/src/lib/evas/canvas/evas_vg_shape.c @@ -13,8 +13,15 @@ struct _Evas_VG_Shape_Data }; Eina_Bool -_evas_vg_shape_path_set(Eo *obj, Evas_VG_Shape_Data *pd, Evas_VG_Path_Command *op, double *points) +_evas_vg_shape_path_set(Eo *obj, Evas_VG_Shape_Data *pd, + Evas_VG_Path_Command *op, double *points) { + free(pd->points); + pd->points = NULL; + free(pd->op); + pd->op = NULL; + + return evas_vg_path_dup(&pd->op, &pd->points, op, points); } Eina_Bool diff --git a/src/lib/evas/canvas/evas_vg_utils.c b/src/lib/evas/canvas/evas_vg_utils.c index ec09fe77ce..cf5c1e1fe4 100644 --- a/src/lib/evas/canvas/evas_vg_utils.c +++ b/src/lib/evas/canvas/evas_vg_utils.c @@ -1,6 +1,8 @@ #include "evas_common_private.h" #include "evas_private.h" +#include "evas_vg_private.h" + static unsigned int evas_vg_path_command_length(Evas_VG_Path_Command command) { @@ -20,6 +22,22 @@ evas_vg_path_command_length(Evas_VG_Path_Command command) return 0; } +static inline void +_evas_vg_path_length(Evas_VG_Path_Command *commands, + unsigned int *cmd_length, + unsigned int *pts_length) +{ + if (commands) + while (commands[*cmd_length] != EVAS_VG_PATH_COMMAND_TYPE_END) + { + *pts_length += evas_vg_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 evas_vg_path_grow(Evas_VG_Path_Command command, Evas_VG_Path_Command **commands, double **points, @@ -29,16 +47,7 @@ evas_vg_path_grow(Evas_VG_Path_Command command, double *pts_tmp; unsigned int cmd_length = 0, pts_length = 0; - if (command) - { - while (commands[cmd_length] != EVAS_VG_PATH_COMMAND_TYPE_END) - { - pts_length += evas_vg_path_command_length((*commands)[cmd_length]); - cmd_length++; - } - } - // Accounting for END command and handle gracefully the NULL case at the same time - cmd_length++; + _evas_vg_path_length(commands, &cmd_length, &pts_length); if (evas_vg_path_command_length(command)) { @@ -63,6 +72,28 @@ evas_vg_path_grow(Evas_VG_Path_Command command, return EINA_TRUE; } +Eina_Bool +evas_vg_path_dup(Evas_VG_Path_Command **out_cmd, double **out_pts, + Evas_VG_Path_Command *in_cmd, double *in_pts) +{ + unsigned int cmd_length = 0, pts_length = 0; + + _evas_vg_path_length(in_cmd, &cmd_length, &pts_length); + + *out_pts = malloc(pts_length * sizeof (double)); + *out_cmd = malloc(cmd_length * sizeof (Evas_VG_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 (Evas_VG_Path_Command)); + return EINA_TRUE; +} + void evas_vg_path_append_move_to(Evas_VG_Path_Command **commands, double **points, double x, double y) From 3d37f150c7bb6ba4a17413a419d3c1c88e4328bc Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:14:19 +0200 Subject: [PATCH 012/251] eo: internal variable should not have that much chance to conflict prefix them with ___. --- src/lib/eo/Eo.h | 58 ++++++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index af787957d8..46e9d73ef8 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -486,32 +486,32 @@ EAPI extern Eo_Hook_Call eo_hook_call_post; #define EO_HOOK_CALL_PREPARE(Hook, FuncName) \ if (Hook) \ - Hook(call.klass, call.obj, FuncName, call.func); + Hook(___call.klass, ___call.obj, FuncName, ___call.func); #define EO_HOOK_CALL_PREPAREV(Hook, FuncName, ...) \ if (Hook) \ - Hook(call.klass, call.obj, FuncName, call.func, __VA_ARGS__); + Hook(___call.klass, ___call.obj, FuncName, ___call.func, __VA_ARGS__); // cache OP id, get real fct and object data then do the call #define EO_FUNC_COMMON_OP(Name, DefRet) \ - Eo_Op_Call_Data call; \ - Eina_Bool is_main_loop = eina_main_loop_is(); \ - static Eo_Op op = EO_NOOP; \ - if (op == EO_NOOP) \ - op = _eo_api_op_id_get((void*) Name, is_main_loop, __FILE__, __LINE__); \ - if (!_eo_call_resolve(#Name, op, &call, is_main_loop, __FILE__, __LINE__)) return DefRet; \ - _Eo_##Name##_func _func_ = (_Eo_##Name##_func) call.func; \ + Eo_Op_Call_Data ___call; \ + Eina_Bool ___is_main_loop = eina_main_loop_is(); \ + static Eo_Op ___op = EO_NOOP; \ + if (___op == EO_NOOP) \ + ___op = _eo_api_op_id_get((void*) Name, ___is_main_loop, __FILE__, __LINE__); \ + if (!_eo_call_resolve(#Name, ___op, &___call, ___is_main_loop, __FILE__, __LINE__)) return DefRet; \ + _Eo_##Name##_func _func_ = (_Eo_##Name##_func) ___call.func; \ // to define an EAPI function -#define EO_FUNC_BODY(Name, Ret, DefRet) \ +#define EO_FUNC_BODY(Name, Ret, DefRet) \ Ret \ Name(void) \ { \ - typedef Ret (*_Eo_##Name##_func)(Eo *, void *obj_data); \ + typedef Ret (*_Eo_##Name##_func)(Eo *, void *obj_data); \ Ret _r; \ - EO_FUNC_COMMON_OP(Name, DefRet); \ - EO_HOOK_CALL_PREPARE(eo_hook_call_pre, #Name); \ - _r = _func_(call.obj, call.data); \ + EO_FUNC_COMMON_OP(Name, DefRet); \ + EO_HOOK_CALL_PREPARE(eo_hook_call_pre, #Name); \ + _r = _func_(___call.obj, ___call.data); \ EO_HOOK_CALL_PREPARE(eo_hook_call_post, #Name); \ return _r; \ } @@ -520,35 +520,35 @@ EAPI extern Eo_Hook_Call eo_hook_call_post; void \ Name(void) \ { \ - typedef void (*_Eo_##Name##_func)(Eo *, void *obj_data); \ - EO_FUNC_COMMON_OP(Name, ); \ - EO_HOOK_CALL_PREPARE(eo_hook_call_pre, #Name); \ - _func_(call.obj, call.data); \ - EO_HOOK_CALL_PREPARE(eo_hook_call_post, #Name); \ + typedef void (*_Eo_##Name##_func)(Eo *, void *obj_data); \ + EO_FUNC_COMMON_OP(Name, ); \ + EO_HOOK_CALL_PREPARE(eo_hook_call_pre, #Name); \ + _func_(___call.obj, ___call.data); \ + EO_HOOK_CALL_PREPARE(eo_hook_call_post, #Name); \ } -#define EO_FUNC_BODYV(Name, Ret, DefRet, Arguments, ...) \ +#define EO_FUNC_BODYV(Name, Ret, DefRet, Arguments, ...) \ Ret \ Name(__VA_ARGS__) \ { \ typedef Ret (*_Eo_##Name##_func)(Eo *, void *obj_data, __VA_ARGS__); \ Ret _r; \ - EO_FUNC_COMMON_OP(Name, DefRet); \ - EO_HOOK_CALL_PREPAREV(eo_hook_call_pre, #Name, Arguments); \ - _r = _func_(call.obj, call.data, Arguments); \ - EO_HOOK_CALL_PREPAREV(eo_hook_call_post, #Name, Arguments); \ + EO_FUNC_COMMON_OP(Name, DefRet); \ + EO_HOOK_CALL_PREPAREV(eo_hook_call_pre, #Name, Arguments); \ + _r = _func_(___call.obj, ___call.data, Arguments); \ + EO_HOOK_CALL_PREPAREV(eo_hook_call_post, #Name, Arguments); \ return _r; \ } -#define EO_VOID_FUNC_BODYV(Name, Arguments, ...) \ +#define EO_VOID_FUNC_BODYV(Name, Arguments, ...) \ void \ Name(__VA_ARGS__) \ { \ typedef void (*_Eo_##Name##_func)(Eo *, void *obj_data, __VA_ARGS__); \ - EO_FUNC_COMMON_OP(Name, ); \ - EO_HOOK_CALL_PREPAREV(eo_hook_call_pre, #Name, Arguments); \ - _func_(call.obj, call.data, Arguments); \ - EO_HOOK_CALL_PREPAREV(eo_hook_call_post, #Name, Arguments); \ + EO_FUNC_COMMON_OP(Name, ); \ + EO_HOOK_CALL_PREPAREV(eo_hook_call_pre, #Name, Arguments); \ + _func_(___call.obj, ___call.data, Arguments); \ + EO_HOOK_CALL_PREPAREV(eo_hook_call_post, #Name, Arguments); \ } // OP ID of an overriding function From ea9330bfe8a251423c85a2e6db2fb6b50a072c1d Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:14:46 +0200 Subject: [PATCH 013/251] evas: declare internal evas_vg helper. --- src/lib/evas/canvas/evas_vg_private.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lib/evas/canvas/evas_vg_private.h b/src/lib/evas/canvas/evas_vg_private.h index 0578b5383d..09420e4929 100644 --- a/src/lib/evas/canvas/evas_vg_private.h +++ b/src/lib/evas/canvas/evas_vg_private.h @@ -7,4 +7,8 @@ struct _Evas_VG_Container_Data Eina_List *children; }; +Eina_Bool +evas_vg_path_dup(Evas_VG_Path_Command **out_cmd, double **out_pts, + const Evas_VG_Path_Command *in_cmd, const double *in_pts); + #endif From 2e6cc1a173e33775e527ca33874fe6030157e2b8 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:14:47 +0200 Subject: [PATCH 014/251] evas: fix prototype and correctly call the function. --- src/lib/evas/canvas/evas_vg_utils.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/evas/canvas/evas_vg_utils.c b/src/lib/evas/canvas/evas_vg_utils.c index cf5c1e1fe4..ae749249d8 100644 --- a/src/lib/evas/canvas/evas_vg_utils.c +++ b/src/lib/evas/canvas/evas_vg_utils.c @@ -23,7 +23,7 @@ evas_vg_path_command_length(Evas_VG_Path_Command command) } static inline void -_evas_vg_path_length(Evas_VG_Path_Command *commands, +_evas_vg_path_length(const Evas_VG_Path_Command *commands, unsigned int *cmd_length, unsigned int *pts_length) { @@ -47,7 +47,7 @@ evas_vg_path_grow(Evas_VG_Path_Command command, double *pts_tmp; unsigned int cmd_length = 0, pts_length = 0; - _evas_vg_path_length(commands, &cmd_length, &pts_length); + _evas_vg_path_length(*commands, &cmd_length, &pts_length); if (evas_vg_path_command_length(command)) { @@ -74,7 +74,7 @@ evas_vg_path_grow(Evas_VG_Path_Command command, Eina_Bool evas_vg_path_dup(Evas_VG_Path_Command **out_cmd, double **out_pts, - Evas_VG_Path_Command *in_cmd, double *in_pts) + const Evas_VG_Path_Command *in_cmd, const double *in_pts) { unsigned int cmd_length = 0, pts_length = 0; From 8097b8ab471c04d82325feda6e2a3251a7ecc383 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:14:48 +0200 Subject: [PATCH 015/251] evas: move Evas_VG_Node structure declaration into a shared header to use it directly from Evas_VG. --- src/lib/evas/canvas/evas_vg_node.c | 11 ----------- src/lib/evas/canvas/evas_vg_private.h | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/lib/evas/canvas/evas_vg_node.c b/src/lib/evas/canvas/evas_vg_node.c index a6ffee050b..096195fa74 100644 --- a/src/lib/evas/canvas/evas_vg_node.c +++ b/src/lib/evas/canvas/evas_vg_node.c @@ -7,17 +7,6 @@ #define MY_CLASS EVAS_VG_NODE_CLASS -typedef struct _Evas_VG_Node_Data Evas_VG_Node_Data; -struct _Evas_VG_Node_Data -{ - Eina_Matrix3 *m; - Evas_VG_Node *mask; - - double x, y; - int r, g, b, a; - Eina_Bool visibility; -}; - // FIXME: // - share private structure with evas_object_vg // - mark parent canvas evas_object dirty after any change on the object diff --git a/src/lib/evas/canvas/evas_vg_private.h b/src/lib/evas/canvas/evas_vg_private.h index 09420e4929..7a6cf58a20 100644 --- a/src/lib/evas/canvas/evas_vg_private.h +++ b/src/lib/evas/canvas/evas_vg_private.h @@ -1,6 +1,20 @@ #ifndef EVAS_VG_PRIVATE_H_ # define EVAS_VG_PRIVATE_H_ +typedef struct _Evas_VG_Node_Data Evas_VG_Node_Data; +struct _Evas_VG_Node_Data +{ + Eina_Matrix3 *m; + Evas_VG_Node *mask; + + void (*render_pre)(void); + void (*render)(void); + + double x, y; + int r, g, b, a; + Eina_Bool visibility; +}; + typedef struct _Evas_VG_Container_Data Evas_VG_Container_Data; struct _Evas_VG_Container_Data { From b50931a5ca6c3271595acc950cd97449ecc699ca Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:14:50 +0200 Subject: [PATCH 016/251] evas: actually compile Evas_VG_Shape. --- src/Makefile_Evas.am | 3 +- src/lib/evas/canvas/evas_vg_shape.c | 164 ++++++++++++++++++++++++--- src/lib/evas/canvas/evas_vg_shape.eo | 1 + 3 files changed, 153 insertions(+), 15 deletions(-) diff --git a/src/Makefile_Evas.am b/src/Makefile_Evas.am index 32425870c0..224ffcaaa4 100644 --- a/src/Makefile_Evas.am +++ b/src/Makefile_Evas.am @@ -221,7 +221,8 @@ lib/evas/canvas/evas_vg_gradient.c \ lib/evas/canvas/evas_vg_gradient_linear.c \ lib/evas/canvas/evas_vg_gradient_radial.c \ lib/evas/canvas/evas_vg_utils.c \ -lib/evas/canvas/evas_vg_image.c +lib/evas/canvas/evas_vg_image.c \ +lib/evas/canvas/evas_vg_shape.c # Engine lib_evas_libevas_la_SOURCES += \ diff --git a/src/lib/evas/canvas/evas_vg_shape.c b/src/lib/evas/canvas/evas_vg_shape.c index 4262fa5ec8..dd81a9c939 100644 --- a/src/lib/evas/canvas/evas_vg_shape.c +++ b/src/lib/evas/canvas/evas_vg_shape.c @@ -1,6 +1,8 @@ #include "evas_common_private.h" #include "evas_private.h" +#include "evas_vg_private.h" + #define MY_CLASS EVAS_VG_SHAPE_CLASS typedef struct _Evas_VG_Shape_Data Evas_VG_Shape_Data; @@ -13,8 +15,8 @@ struct _Evas_VG_Shape_Data }; Eina_Bool -_evas_vg_shape_path_set(Eo *obj, Evas_VG_Shape_Data *pd, - Evas_VG_Path_Command *op, double *points) +_evas_vg_shape_path_set(Eo *obj EINA_UNUSED, Evas_VG_Shape_Data *pd, + const Evas_VG_Path_Command *op, const double *points) { free(pd->points); pd->points = NULL; @@ -27,20 +29,154 @@ _evas_vg_shape_path_set(Eo *obj, Evas_VG_Shape_Data *pd, Eina_Bool _evas_vg_shape_bounds_get(Eo *obj, Evas_VG_Shape_Data *pd, Eina_Rectangle *r) { + (void) obj; (void) pd; (void) r; + return EINA_FALSE; } void -_evas_vg_shape_eo_base_constructor(Eo *obj, Evas_VG_Shape_Data *pd) +_evas_vg_shape_eo_base_constructor(Eo *obj, Evas_VG_Shape_Data *pd EINA_UNUSED) { - Eo *parent; - - eo_super_do(obj, MY_CLASS, eo_constructor()); - - eo_do(obj, parent = eo_parent_get()); - if (!eo_isa(obj, EVAS_VG_CONTAINER_CLASS) && - !eo_isa(obj, EVAS_VG_CLASS)) - { - ERR("Parent must be either an Evas_Object_VG or an Evas_VG_Container."); - eo_error_set(obj); - } + eo_do_super(obj, MY_CLASS, eo_constructor()); } + +void +_evas_vg_shape_eo_base_destructor(Eo *obj, Evas_VG_Shape_Data *pd) +{ + (void) obj; (void) pd; +} + +void +_evas_vg_shape_fill_set(Eo *obj, Evas_VG_Shape_Data *pd, Evas_VG_Node *f) +{ + (void) obj; (void) pd; (void) f; +} + +Evas_VG_Node * +_evas_vg_shape_fill_get(Eo *obj, Evas_VG_Shape_Data *pd) +{ + (void) obj; (void) pd; + return NULL; +} + +void +_evas_vg_shape_stroke_scale_set(Eo *obj, Evas_VG_Shape_Data *pd, double s) +{ + (void) obj; (void) pd; (void) s; +} + +double +_evas_vg_shape_stroke_scale_get(Eo *obj, Evas_VG_Shape_Data *pd) +{ + (void) obj; (void) pd; + return 0.0; +} + +void +_evas_vg_shape_stroke_color_set(Eo *obj, Evas_VG_Shape_Data *pd, + int r, int g, int b, int a) +{ + (void) obj; (void) pd; (void) r; (void) g; (void) b; (void) a; +} + +void +_evas_vg_shape_stroke_color_get(Eo *obj, Evas_VG_Shape_Data *pd, + int *r, int *g, int *b, int *a) +{ + (void) obj; (void) pd; (void) r; (void) g; (void) b; (void) a; +} + +void +_evas_vg_shape_stroke_fill_set(Eo *obj, Evas_VG_Shape_Data *pd, Evas_VG_Node *f) +{ + (void) obj; (void) pd; (void) f; +} + +Evas_VG_Node * +_evas_vg_shape_stroke_fill_get(Eo *obj, Evas_VG_Shape_Data *pd) +{ + (void) obj; (void) pd; + return NULL; +} + +void +_evas_vg_shape_stroke_width_set(Eo *obj, Evas_VG_Shape_Data *pd, double w) +{ + (void) obj; (void) pd; (void) w; +} + +double +_evas_vg_shape_stroke_width_get(Eo *obj, Evas_VG_Shape_Data *pd) +{ + (void) obj; (void) pd; + return 0.0; +} + +void +_evas_vg_shape_stroke_location_set(Eo *obj, Evas_VG_Shape_Data *pd, + double centered) +{ + (void) obj; (void) pd; (void) centered; +} + +double +_evas_vg_shape_stroke_location_get(Eo *obj, Evas_VG_Shape_Data *pd) +{ + (void) obj; (void) pd; + return 0.0; +} + +void +_evas_vg_shape_stroke_dash_set(Eo *obj, Evas_VG_Shape_Data *pd, + const Evas_VG_Dash *dash, unsigned int length) +{ + (void) obj; (void) pd; (void) dash; (void) length; +} + +void +_evas_vg_shape_stroke_dash_get(Eo *obj, Evas_VG_Shape_Data *pd, + const Evas_VG_Dash **dash, unsigned int *length) +{ + (void) obj; (void) pd; (void) dash; (void) length; +} + +void +_evas_vg_shape_stroke_marker_set(Eo *obj, Evas_VG_Shape_Data *pd, + Evas_VG_Shape *m) +{ + (void) obj; (void) pd; (void) m; +} + +Evas_VG_Shape * +_evas_vg_shape_stroke_marker_get(Eo *obj, Evas_VG_Shape_Data *pd) +{ + (void) obj; (void) pd; + return NULL; +} + +void +_evas_vg_shape_stroke_cap_set(Eo *obj, Evas_VG_Shape_Data *pd, Evas_VG_Cap c) +{ + (void) obj; (void) pd; (void) c; +} + +Evas_VG_Cap +_evas_vg_shape_stroke_cap_get(Eo *obj, Evas_VG_Shape_Data *pd) +{ + (void) obj; (void) pd; + return EVAS_VG_CAP_LAST; +} + +void +_evas_vg_shape_stroke_join_set(Eo *obj, Evas_VG_Shape_Data *pd, Evas_VG_Join j) +{ + (void) obj; (void) pd; (void) j; +} + +Evas_VG_Join +_evas_vg_shape_stroke_join_get(Eo *obj, Evas_VG_Shape_Data *pd) +{ + (void) obj; (void) pd; + return EVAS_VG_JOIN_LAST; +} + +#include "evas_vg_shape.eo.c" diff --git a/src/lib/evas/canvas/evas_vg_shape.eo b/src/lib/evas/canvas/evas_vg_shape.eo index 32d959df62..e65ea13fb3 100644 --- a/src/lib/evas/canvas/evas_vg_shape.eo +++ b/src/lib/evas/canvas/evas_vg_shape.eo @@ -1,6 +1,7 @@ class Evas.VG_Shape (Evas.VG_Node) { eo_prefix: evas_vg_shape; + legacy_prefix: null; properties { fill { set { From 3447936adbba21773d6e71f284613cc4688d76b7 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:14:51 +0200 Subject: [PATCH 017/251] evas: implement all Evas_VG_Shape property. --- src/lib/evas/canvas/evas_vg_shape.c | 162 +++++++++++++++++++--------- 1 file changed, 112 insertions(+), 50 deletions(-) diff --git a/src/lib/evas/canvas/evas_vg_shape.c b/src/lib/evas/canvas/evas_vg_shape.c index dd81a9c939..7c77e00ff2 100644 --- a/src/lib/evas/canvas/evas_vg_shape.c +++ b/src/lib/evas/canvas/evas_vg_shape.c @@ -10,6 +10,26 @@ struct _Evas_VG_Shape_Data { Evas_VG_Path_Command *op; double *points; + + Evas_VG_Node *fill; + + struct { + Evas_VG_Dash *dash; + Evas_VG_Node *fill; + Evas_VG_Node *marker; + + double scale; + double width; + double centered; // from 0 to 1 + + int r, g, b, a; + + unsigned int dash_count; + + Evas_VG_Cap cap; + Evas_VG_Join join; + } stroke; + unsigned int op_count; unsigned int pts_counts; }; @@ -37,146 +57,188 @@ void _evas_vg_shape_eo_base_constructor(Eo *obj, Evas_VG_Shape_Data *pd EINA_UNUSED) { eo_do_super(obj, MY_CLASS, eo_constructor()); + pd->stroke.cap = EVAS_VG_CAP_BUTT; + pd->stroke.join = EVAS_VG_JOIN_MITER; + pd->stroke.scale = 1; + pd->stroke.a = 1; + pd->stroke.centered = 0.5; } void -_evas_vg_shape_eo_base_destructor(Eo *obj, Evas_VG_Shape_Data *pd) +_evas_vg_shape_eo_base_destructor(Eo *obj, Evas_VG_Shape_Data *pd EINA_UNUSED) { - (void) obj; (void) pd; + eo_do_super(obj, MY_CLASS, eo_destructor()); } void -_evas_vg_shape_fill_set(Eo *obj, Evas_VG_Shape_Data *pd, Evas_VG_Node *f) +_evas_vg_shape_fill_set(Eo *obj EINA_UNUSED, + Evas_VG_Shape_Data *pd, + Evas_VG_Node *f) { - (void) obj; (void) pd; (void) f; + Evas_VG_Node *tmp = pd->fill; + + pd->fill = eo_ref(f); + eo_unref(tmp); } Evas_VG_Node * -_evas_vg_shape_fill_get(Eo *obj, Evas_VG_Shape_Data *pd) +_evas_vg_shape_fill_get(Eo *obj EINA_UNUSED, Evas_VG_Shape_Data *pd) { - (void) obj; (void) pd; - return NULL; + return pd->fill; } void -_evas_vg_shape_stroke_scale_set(Eo *obj, Evas_VG_Shape_Data *pd, double s) +_evas_vg_shape_stroke_scale_set(Eo *obj EINA_UNUSED, + Evas_VG_Shape_Data *pd, + double s) { - (void) obj; (void) pd; (void) s; + pd->stroke.scale = s; } double -_evas_vg_shape_stroke_scale_get(Eo *obj, Evas_VG_Shape_Data *pd) +_evas_vg_shape_stroke_scale_get(Eo *obj EINA_UNUSED, Evas_VG_Shape_Data *pd) { - (void) obj; (void) pd; - return 0.0; + return pd->stroke.scale; } void -_evas_vg_shape_stroke_color_set(Eo *obj, Evas_VG_Shape_Data *pd, +_evas_vg_shape_stroke_color_set(Eo *obj EINA_UNUSED, + Evas_VG_Shape_Data *pd, int r, int g, int b, int a) { - (void) obj; (void) pd; (void) r; (void) g; (void) b; (void) a; + pd->stroke.r = r; + pd->stroke.g = g; + pd->stroke.b = b; + pd->stroke.a = a; } void -_evas_vg_shape_stroke_color_get(Eo *obj, Evas_VG_Shape_Data *pd, +_evas_vg_shape_stroke_color_get(Eo *obj EINA_UNUSED, + Evas_VG_Shape_Data *pd, int *r, int *g, int *b, int *a) { - (void) obj; (void) pd; (void) r; (void) g; (void) b; (void) a; + if (r) *r = pd->stroke.r; + if (g) *g = pd->stroke.g; + if (b) *b = pd->stroke.b; + if (a) *a = pd->stroke.a; } void -_evas_vg_shape_stroke_fill_set(Eo *obj, Evas_VG_Shape_Data *pd, Evas_VG_Node *f) +_evas_vg_shape_stroke_fill_set(Eo *obj EINA_UNUSED, + Evas_VG_Shape_Data *pd, + Evas_VG_Node *f) { - (void) obj; (void) pd; (void) f; + Evas_VG_Node *tmp = pd->fill; + + pd->stroke.fill = eo_ref(f); + eo_unref(tmp); } Evas_VG_Node * -_evas_vg_shape_stroke_fill_get(Eo *obj, Evas_VG_Shape_Data *pd) +_evas_vg_shape_stroke_fill_get(Eo *obj EINA_UNUSED, + Evas_VG_Shape_Data *pd) { - (void) obj; (void) pd; - return NULL; + return pd->stroke.fill; } void -_evas_vg_shape_stroke_width_set(Eo *obj, Evas_VG_Shape_Data *pd, double w) +_evas_vg_shape_stroke_width_set(Eo *obj EINA_UNUSED, + Evas_VG_Shape_Data *pd, + double w) { - (void) obj; (void) pd; (void) w; + pd->stroke.width = w; } double -_evas_vg_shape_stroke_width_get(Eo *obj, Evas_VG_Shape_Data *pd) +_evas_vg_shape_stroke_width_get(Eo *obj EINA_UNUSED, Evas_VG_Shape_Data *pd) { - (void) obj; (void) pd; - return 0.0; + return pd->stroke.width; } void -_evas_vg_shape_stroke_location_set(Eo *obj, Evas_VG_Shape_Data *pd, +_evas_vg_shape_stroke_location_set(Eo *obj EINA_UNUSED, + Evas_VG_Shape_Data *pd, double centered) { - (void) obj; (void) pd; (void) centered; + pd->stroke.centered = centered; } double -_evas_vg_shape_stroke_location_get(Eo *obj, Evas_VG_Shape_Data *pd) +_evas_vg_shape_stroke_location_get(Eo *obj EINA_UNUSED, Evas_VG_Shape_Data *pd) { - (void) obj; (void) pd; - return 0.0; + return pd->stroke.centered; } void -_evas_vg_shape_stroke_dash_set(Eo *obj, Evas_VG_Shape_Data *pd, +_evas_vg_shape_stroke_dash_set(Eo *obj EINA_UNUSED, + Evas_VG_Shape_Data *pd, const Evas_VG_Dash *dash, unsigned int length) { - (void) obj; (void) pd; (void) dash; (void) length; + free(pd->stroke.dash); + pd->stroke.dash = NULL; + pd->stroke.dash_count = 0; + + pd->stroke.dash = malloc(sizeof (Evas_VG_Dash) * length); + if (!pd->stroke.dash) return ; + + memcpy(pd->stroke.dash, dash, sizeof (Evas_VG_Dash) * length); + pd->stroke.dash_count = length; } void -_evas_vg_shape_stroke_dash_get(Eo *obj, Evas_VG_Shape_Data *pd, +_evas_vg_shape_stroke_dash_get(Eo *obj EINA_UNUSED, + Evas_VG_Shape_Data *pd, const Evas_VG_Dash **dash, unsigned int *length) { - (void) obj; (void) pd; (void) dash; (void) length; + if (dash) *dash = pd->stroke.dash; + if (length) *length = pd->stroke.dash_count; } void -_evas_vg_shape_stroke_marker_set(Eo *obj, Evas_VG_Shape_Data *pd, +_evas_vg_shape_stroke_marker_set(Eo *obj EINA_UNUSED, + Evas_VG_Shape_Data *pd, Evas_VG_Shape *m) { - (void) obj; (void) pd; (void) m; + Evas_VG_Node *tmp = pd->stroke.marker; + + pd->stroke.marker = eo_ref(m); + eo_unref(tmp); } Evas_VG_Shape * -_evas_vg_shape_stroke_marker_get(Eo *obj, Evas_VG_Shape_Data *pd) +_evas_vg_shape_stroke_marker_get(Eo *obj EINA_UNUSED, + Evas_VG_Shape_Data *pd) { - (void) obj; (void) pd; - return NULL; + return pd->stroke.marker; } void -_evas_vg_shape_stroke_cap_set(Eo *obj, Evas_VG_Shape_Data *pd, Evas_VG_Cap c) +_evas_vg_shape_stroke_cap_set(Eo *obj EINA_UNUSED, + Evas_VG_Shape_Data *pd, + Evas_VG_Cap c) { - (void) obj; (void) pd; (void) c; + pd->stroke.cap = c; } Evas_VG_Cap -_evas_vg_shape_stroke_cap_get(Eo *obj, Evas_VG_Shape_Data *pd) +_evas_vg_shape_stroke_cap_get(Eo *obj EINA_UNUSED, + Evas_VG_Shape_Data *pd) { - (void) obj; (void) pd; - return EVAS_VG_CAP_LAST; + return pd->stroke.cap; } void -_evas_vg_shape_stroke_join_set(Eo *obj, Evas_VG_Shape_Data *pd, Evas_VG_Join j) +_evas_vg_shape_stroke_join_set(Eo *obj EINA_UNUSED, + Evas_VG_Shape_Data *pd, + Evas_VG_Join j) { - (void) obj; (void) pd; (void) j; + pd->stroke.join = j; } Evas_VG_Join -_evas_vg_shape_stroke_join_get(Eo *obj, Evas_VG_Shape_Data *pd) +_evas_vg_shape_stroke_join_get(Eo *obj EINA_UNUSED, Evas_VG_Shape_Data *pd) { - (void) obj; (void) pd; - return EVAS_VG_JOIN_LAST; + return pd->stroke.join; } #include "evas_vg_shape.eo.c" From a247ddeceb2fb9b8897d37a68b966e13cc6fccba Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:14:52 +0200 Subject: [PATCH 018/251] evas: fix Evas_VG eo files. --- src/lib/evas/canvas/evas_vg.eo | 13 +++++++++++++ src/lib/evas/canvas/evas_vg_node.eo | 16 ++++++++++++++++ src/lib/evas/canvas/evas_vg_root_node.eo | 2 +- 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/lib/evas/canvas/evas_vg.eo b/src/lib/evas/canvas/evas_vg.eo index 95c1ef04bc..64cd2d179b 100644 --- a/src/lib/evas/canvas/evas_vg.eo +++ b/src/lib/evas/canvas/evas_vg.eo @@ -10,6 +10,19 @@ class Evas.VG (Evas.Object, Efl.File) Evas_VG_Node *container; } } + size { + get { + /*@ + Get the size as defined in the original data + before any scaling (as in the file or when the + object were added). + */ + } + values { + uint w; + uint h; + } + } } implements { Eo.Base.constructor; diff --git a/src/lib/evas/canvas/evas_vg_node.eo b/src/lib/evas/canvas/evas_vg_node.eo index e989f7a331..b7df4693e9 100644 --- a/src/lib/evas/canvas/evas_vg_node.eo +++ b/src/lib/evas/canvas/evas_vg_node.eo @@ -86,11 +86,27 @@ abstract Evas.VG_Node (Eo.Base) } methods { bound_get { + /*@ + Give the bounding box in screen coordinate as being drawn. + It will start as the control box until it is refined once + the shape is computed. + */ return: bool @warn_unused; params { @out Eina_Rectangle r; } } + original_bound_get { + /*@ + Give the bounding box in screen coordinate as defined in + the file or at the insertion of the object (before any scaling). + */ + return: bool @warn_unused; + params { + @out Eina_Rectangle r; + } + } + raise { /*@ Raise @p obj to the top of its layer. diff --git a/src/lib/evas/canvas/evas_vg_root_node.eo b/src/lib/evas/canvas/evas_vg_root_node.eo index db0837d9f2..9489c7388f 100644 --- a/src/lib/evas/canvas/evas_vg_root_node.eo +++ b/src/lib/evas/canvas/evas_vg_root_node.eo @@ -1,4 +1,4 @@ -class Evas.VG_Root_Node (Evas.VG_Node) +class Evas.VG_Root_Node (Evas.VG_Container) { eo_prefix: evas_vg_root_node; implements { From 14dcad09c0e86c88e2883c977e29b1fd532ca4bb Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:14:54 +0200 Subject: [PATCH 019/251] efl: add an interface for Efl_Geometry_Shape. --- src/Makefile_Efl.am | 3 +- src/lib/efl/Efl.h | 57 ++++++++++++++ src/lib/efl/interfaces/efl_geometry_shape.eo | 82 ++++++++++++++++++++ src/lib/efl/interfaces/efl_interfaces_main.c | 2 + 4 files changed, 143 insertions(+), 1 deletion(-) create mode 100644 src/lib/efl/interfaces/efl_geometry_shape.eo diff --git a/src/Makefile_Efl.am b/src/Makefile_Efl.am index 5533dce961..687793545c 100644 --- a/src/Makefile_Efl.am +++ b/src/Makefile_Efl.am @@ -4,7 +4,8 @@ efl_eolian_files = \ lib/efl/interfaces/efl_image.eo \ lib/efl/interfaces/efl_player.eo \ lib/efl/interfaces/efl_text.eo \ - lib/efl/interfaces/efl_text_properties.eo + lib/efl/interfaces/efl_text_properties.eo \ + lib/efl/interfaces/efl_geometry_shape.eo efl_eolian_files_h = $(efl_eolian_files:%.eo=%.eo.h) efl_eolian_files_c = $(efl_eolian_files:%.eo=%.eo.c) diff --git a/src/lib/efl/Efl.h b/src/lib/efl/Efl.h index f4cdedcf99..c6705b4850 100644 --- a/src/lib/efl/Efl.h +++ b/src/lib/efl/Efl.h @@ -34,6 +34,61 @@ extern "C" # endif #endif /* ! _WIN32 */ +/** + * Path command enum. + * + * @since 1.13 + * @ingroup Efl_Geometry_Shape + */ +typedef enum _Efl_Geometry_Path_Command +{ + EFL_GEOMETRY_PATH_COMMAND_TYPE_END = 0, /**< End of the stream of command */ + EFL_GEOMETRY_PATH_COMMAND_TYPE_MOVE_TO, /**< A move command type */ + EFL_GEOMETRY_PATH_COMMAND_TYPE_LINE_TO, /**< A line command type */ + EFL_GEOMETRY_PATH_COMMAND_TYPE_QUADRATIC_TO, /**< A quadratic command type */ + EFL_GEOMETRY_PATH_COMMAND_TYPE_SQUADRATIC_TO, /**< A smooth quadratic command type */ + EFL_GEOMETRY_PATH_COMMAND_TYPE_CUBIC_TO, /**< A cubic command type */ + EFL_GEOMETRY_PATH_COMMAND_TYPE_SCUBIC_TO, /**< A smooth cubic command type */ + EFL_GEOMETRY_PATH_COMMAND_TYPE_ARC_TO, /**< An arc command type */ + EFL_GEOMETRY_PATH_COMMAND_TYPE_CLOSE, /**< A close command type */ + EFL_GEOMETRY_PATH_COMMAND_TYPE_LAST, /**< Not a valid command, but last one according to this version header */ +} Efl_Geometry_Path_Command; + +/** + * Type describing dash + * @since 1.13 + */ +typedef struct _Efl_Geometry_Dash Efl_Geometry_Dash; +struct _Efl_Geometry_Dash +{ + double length; + double gap; +}; + +/** + * Type defining how a line end. + * @since 1.13 + */ +typedef enum _Efl_Geometry_Cap +{ + EFL_GEOMETRY_CAP_BUTT, + EFL_GEOMETRY_CAP_ROUND, + EFL_GEOMETRY_CAP_SQUARE, + EFL_GEOMETRY_CAP_LAST +} Efl_Geometry_Cap; + +/** + * Type defining how join between path are drawn. + * @since 1.13 + */ +typedef enum _Efl_Geometry_Join +{ + EFL_GEOMETRY_JOIN_MITER, + EFL_GEOMETRY_JOIN_ROUND, + EFL_GEOMETRY_JOIN_BEVEL, + EFL_GEOMETRY_JOIN_LAST +} Efl_Geometry_Join; + #ifdef EFL_BETA_API_SUPPORT /* Interfaces */ @@ -44,6 +99,8 @@ extern "C" #include "interfaces/efl_text.eo.h" #include "interfaces/efl_text_properties.eo.h" +#include "interfaces/efl_geometry_shape.eo.h" + #endif #if defined ( __cplusplus ) diff --git a/src/lib/efl/interfaces/efl_geometry_shape.eo b/src/lib/efl/interfaces/efl_geometry_shape.eo new file mode 100644 index 0000000000..5f85e99f36 --- /dev/null +++ b/src/lib/efl/interfaces/efl_geometry_shape.eo @@ -0,0 +1,82 @@ +interface Efl.Geometry.Shape +{ + legacy_prefix: null; + properties { + stroke_scale { + set { + } + get { + } + values { + double s; + } + } + stroke_color { + set { + } + get { + } + values { + int r; + int g; + int b; + int a; + } + } + stroke_width { + set { + } + get { + } + values { + double w; + } + } + stroke_location { + set { + } + get { + } + values { + double centered; + } + } + stroke_dash { + set { + } + get { + } + values { + const(Efl_Geometry_Dash) *dash; + uint length; + } + } + stroke_cap { + set { + } + get { + } + values { + Efl_Geometry_Cap c; + } + } + stroke_join { + set { + } + get { + } + values { + Efl_Geometry_Join j; + } + } + } + methods { + path_set { + return: bool; + params { + @in const(Efl_Geometry_Path_Command) *op; + @in const(double) *points; + } + } + } +} diff --git a/src/lib/efl/interfaces/efl_interfaces_main.c b/src/lib/efl/interfaces/efl_interfaces_main.c index c490636a3d..e4e20ef6f6 100644 --- a/src/lib/efl/interfaces/efl_interfaces_main.c +++ b/src/lib/efl/interfaces/efl_interfaces_main.c @@ -10,3 +10,5 @@ #include "interfaces/efl_player.eo.c" #include "interfaces/efl_text.eo.c" #include "interfaces/efl_text_properties.eo.c" + +#include "interfaces/efl_geometry_shape.eo.c" From 411bb5b64ed57b24f11b89416f242ddecd68f0cc Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:14:55 +0200 Subject: [PATCH 020/251] efl: use Efl_Geometry_Shape. --- src/lib/evas/Evas_Eo.h | 47 ------------ src/lib/evas/canvas/evas_object_vg.c | 5 ++ src/lib/evas/canvas/evas_vg_node.c | 8 +++ src/lib/evas/canvas/evas_vg_private.h | 4 +- src/lib/evas/canvas/evas_vg_shape.c | 100 ++++++++++++++------------ src/lib/evas/canvas/evas_vg_shape.eo | 88 +++-------------------- src/lib/evas/canvas/evas_vg_utils.c | 100 +++++++++++++------------- 7 files changed, 129 insertions(+), 223 deletions(-) diff --git a/src/lib/evas/Evas_Eo.h b/src/lib/evas/Evas_Eo.h index 846c8f6819..b28e7ce570 100644 --- a/src/lib/evas/Evas_Eo.h +++ b/src/lib/evas/Evas_Eo.h @@ -845,42 +845,11 @@ typedef enum _Evas_3D_Material_Attrib #include "canvas/evas_3d_object.eo.h" -/** - * Path command enum. - * - * @since 1.14 - * @ingroup Evas_VG_Shape - */ -typedef enum _Evas_VG_Path_Command -{ - EVAS_VG_PATH_COMMAND_TYPE_END = 0, /**< End of the stream of command */ - EVAS_VG_PATH_COMMAND_TYPE_MOVE_TO, /**< A move command type */ - EVAS_VG_PATH_COMMAND_TYPE_LINE_TO, /**< A line command type */ - EVAS_VG_PATH_COMMAND_TYPE_QUADRATIC_TO, /**< A quadratic command type */ - EVAS_VG_PATH_COMMAND_TYPE_SQUADRATIC_TO, /**< A smooth quadratic command type */ - EVAS_VG_PATH_COMMAND_TYPE_CUBIC_TO, /**< A cubic command type */ - EVAS_VG_PATH_COMMAND_TYPE_SCUBIC_TO, /**< A smooth cubic command type */ - EVAS_VG_PATH_COMMAND_TYPE_ARC_TO, /**< An arc command type */ - EVAS_VG_PATH_COMMAND_TYPE_CLOSE, /**< A close command type */ - EVAS_VG_PATH_COMMAND_TYPE_LAST, /**< Not a valid command, but last one according to this version header */ -} Evas_VG_Path_Command; - /** * Type of abstract VG node */ typedef Eo Evas_VG_Node; - -/** - * Type describing dash - */ -typedef struct _Evas_VG_Dash Evas_VG_Dash; -struct _Evas_VG_Dash -{ - double length; - double gap; -}; - typedef struct _Evas_VG_Gradient_Stop Evas_VG_Gradient_Stop; struct _Evas_VG_Gradient_Stop { @@ -891,22 +860,6 @@ struct _Evas_VG_Gradient_Stop int a; }; -typedef enum _Evas_VG_Cap -{ - EVAS_VG_CAP_BUTT, - EVAS_VG_CAP_ROUND, - EVAS_VG_CAP_SQUARE, - EVAS_VG_CAP_LAST -} Evas_VG_Cap; - -typedef enum _Evas_VG_Join -{ - EVAS_VG_JOIN_MITER, - EVAS_VG_JOIN_ROUND, - EVAS_VG_JOIN_BEVEL, - EVAS_VG_JOIN_LAST -} Evas_VG_Join; - typedef enum _Evas_VG_Gradient_Spread { EVAS_VG_GRADIENT_SPREAD_PAD, diff --git a/src/lib/evas/canvas/evas_object_vg.c b/src/lib/evas/canvas/evas_object_vg.c index 5d750c1cb9..8ac8fe90af 100644 --- a/src/lib/evas/canvas/evas_object_vg.c +++ b/src/lib/evas/canvas/evas_object_vg.c @@ -327,4 +327,9 @@ _evas_vg_efl_file_file_get(Eo *obj, Evas_VG_Data *pd, { } +void +_evas_vg_size_get(Eo *obj, Evas_VG_Data *pd, unsigned int *w, unsigned int *h) +{ +} + #include "evas_vg.eo.c" diff --git a/src/lib/evas/canvas/evas_vg_node.c b/src/lib/evas/canvas/evas_vg_node.c index 096195fa74..b6d3f01f78 100644 --- a/src/lib/evas/canvas/evas_vg_node.c +++ b/src/lib/evas/canvas/evas_vg_node.c @@ -264,4 +264,12 @@ _evas_vg_node_lower(Eo *obj, Evas_VG_Node_Data *pd EINA_UNUSED) eo_error_set(obj); } +Eina_Bool +_evas_vg_node_original_bound_get(Eo *obj, + Evas_VG_Node_Data *pd, + Eina_Rectangle *r) +{ + return EINA_FALSE; +} + #include "evas_vg_node.eo.c" diff --git a/src/lib/evas/canvas/evas_vg_private.h b/src/lib/evas/canvas/evas_vg_private.h index 7a6cf58a20..1d288dcc3c 100644 --- a/src/lib/evas/canvas/evas_vg_private.h +++ b/src/lib/evas/canvas/evas_vg_private.h @@ -22,7 +22,7 @@ struct _Evas_VG_Container_Data }; Eina_Bool -evas_vg_path_dup(Evas_VG_Path_Command **out_cmd, double **out_pts, - const Evas_VG_Path_Command *in_cmd, const double *in_pts); +efl_geometry_path_dup(Efl_Geometry_Path_Command **out_cmd, double **out_pts, + const Efl_Geometry_Path_Command *in_cmd, const double *in_pts); #endif diff --git a/src/lib/evas/canvas/evas_vg_shape.c b/src/lib/evas/canvas/evas_vg_shape.c index 7c77e00ff2..2a0f5d2a69 100644 --- a/src/lib/evas/canvas/evas_vg_shape.c +++ b/src/lib/evas/canvas/evas_vg_shape.c @@ -8,13 +8,13 @@ typedef struct _Evas_VG_Shape_Data Evas_VG_Shape_Data; struct _Evas_VG_Shape_Data { - Evas_VG_Path_Command *op; + Efl_Geometry_Path_Command *op; double *points; Evas_VG_Node *fill; struct { - Evas_VG_Dash *dash; + Efl_Geometry_Dash *dash; Evas_VG_Node *fill; Evas_VG_Node *marker; @@ -26,8 +26,8 @@ struct _Evas_VG_Shape_Data unsigned int dash_count; - Evas_VG_Cap cap; - Evas_VG_Join join; + Efl_Geometry_Cap cap; + Efl_Geometry_Join join; } stroke; unsigned int op_count; @@ -35,15 +35,17 @@ struct _Evas_VG_Shape_Data }; Eina_Bool -_evas_vg_shape_path_set(Eo *obj EINA_UNUSED, Evas_VG_Shape_Data *pd, - const Evas_VG_Path_Command *op, const double *points) +_evas_vg_shape_efl_geometry_shape_path_set(Eo *obj EINA_UNUSED, + Evas_VG_Shape_Data *pd, + const Efl_Geometry_Path_Command *op, + const double *points) { free(pd->points); pd->points = NULL; free(pd->op); pd->op = NULL; - return evas_vg_path_dup(&pd->op, &pd->points, op, points); + return efl_geometry_path_dup(&pd->op, &pd->points, op, points); } Eina_Bool @@ -57,8 +59,8 @@ void _evas_vg_shape_eo_base_constructor(Eo *obj, Evas_VG_Shape_Data *pd EINA_UNUSED) { eo_do_super(obj, MY_CLASS, eo_constructor()); - pd->stroke.cap = EVAS_VG_CAP_BUTT; - pd->stroke.join = EVAS_VG_JOIN_MITER; + pd->stroke.cap = EFL_GEOMETRY_CAP_BUTT; + pd->stroke.join = EFL_GEOMETRY_JOIN_MITER; pd->stroke.scale = 1; pd->stroke.a = 1; pd->stroke.centered = 0.5; @@ -88,23 +90,24 @@ _evas_vg_shape_fill_get(Eo *obj EINA_UNUSED, Evas_VG_Shape_Data *pd) } void -_evas_vg_shape_stroke_scale_set(Eo *obj EINA_UNUSED, - Evas_VG_Shape_Data *pd, - double s) +_evas_vg_shape_efl_geometry_shape_stroke_scale_set(Eo *obj EINA_UNUSED, + Evas_VG_Shape_Data *pd, + double s) { pd->stroke.scale = s; } double -_evas_vg_shape_stroke_scale_get(Eo *obj EINA_UNUSED, Evas_VG_Shape_Data *pd) +_evas_vg_shape_efl_geometry_shape_stroke_scale_get(Eo *obj EINA_UNUSED, + Evas_VG_Shape_Data *pd) { return pd->stroke.scale; } void -_evas_vg_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_geometry_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; @@ -113,9 +116,9 @@ _evas_vg_shape_stroke_color_set(Eo *obj EINA_UNUSED, } void -_evas_vg_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_geometry_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; @@ -142,53 +145,57 @@ _evas_vg_shape_stroke_fill_get(Eo *obj EINA_UNUSED, } void -_evas_vg_shape_stroke_width_set(Eo *obj EINA_UNUSED, - Evas_VG_Shape_Data *pd, - double w) +_evas_vg_shape_efl_geometry_shape_stroke_width_set(Eo *obj EINA_UNUSED, + Evas_VG_Shape_Data *pd, + double w) { pd->stroke.width = w; } double -_evas_vg_shape_stroke_width_get(Eo *obj EINA_UNUSED, Evas_VG_Shape_Data *pd) +_evas_vg_shape_efl_geometry_shape_stroke_width_get(Eo *obj EINA_UNUSED, + Evas_VG_Shape_Data *pd) { return pd->stroke.width; } void -_evas_vg_shape_stroke_location_set(Eo *obj EINA_UNUSED, - Evas_VG_Shape_Data *pd, - double centered) +_evas_vg_shape_efl_geometry_shape_stroke_location_set(Eo *obj EINA_UNUSED, + Evas_VG_Shape_Data *pd, + double centered) { pd->stroke.centered = centered; } double -_evas_vg_shape_stroke_location_get(Eo *obj EINA_UNUSED, Evas_VG_Shape_Data *pd) +_evas_vg_shape_efl_geometry_shape_stroke_location_get(Eo *obj EINA_UNUSED, + Evas_VG_Shape_Data *pd) { return pd->stroke.centered; } void -_evas_vg_shape_stroke_dash_set(Eo *obj EINA_UNUSED, - Evas_VG_Shape_Data *pd, - const Evas_VG_Dash *dash, unsigned int length) +_evas_vg_shape_efl_geometry_shape_stroke_dash_set(Eo *obj EINA_UNUSED, + Evas_VG_Shape_Data *pd, + const Efl_Geometry_Dash *dash, + unsigned int length) { free(pd->stroke.dash); pd->stroke.dash = NULL; pd->stroke.dash_count = 0; - pd->stroke.dash = malloc(sizeof (Evas_VG_Dash) * length); + pd->stroke.dash = malloc(sizeof (Efl_Geometry_Dash) * length); if (!pd->stroke.dash) return ; - memcpy(pd->stroke.dash, dash, sizeof (Evas_VG_Dash) * length); + memcpy(pd->stroke.dash, dash, sizeof (Efl_Geometry_Dash) * length); pd->stroke.dash_count = length; } void -_evas_vg_shape_stroke_dash_get(Eo *obj EINA_UNUSED, - Evas_VG_Shape_Data *pd, - const Evas_VG_Dash **dash, unsigned int *length) +_evas_vg_shape_efl_geometry_shape_stroke_dash_get(Eo *obj EINA_UNUSED, + Evas_VG_Shape_Data *pd, + const Efl_Geometry_Dash **dash, + unsigned int *length) { if (dash) *dash = pd->stroke.dash; if (length) *length = pd->stroke.dash_count; @@ -213,30 +220,31 @@ _evas_vg_shape_stroke_marker_get(Eo *obj EINA_UNUSED, } void -_evas_vg_shape_stroke_cap_set(Eo *obj EINA_UNUSED, - Evas_VG_Shape_Data *pd, - Evas_VG_Cap c) +_evas_vg_shape_efl_geometry_shape_stroke_cap_set(Eo *obj EINA_UNUSED, + Evas_VG_Shape_Data *pd, + Efl_Geometry_Cap c) { pd->stroke.cap = c; } -Evas_VG_Cap -_evas_vg_shape_stroke_cap_get(Eo *obj EINA_UNUSED, - Evas_VG_Shape_Data *pd) +Efl_Geometry_Cap +_evas_vg_shape_efl_geometry_shape_stroke_cap_get(Eo *obj EINA_UNUSED, + Evas_VG_Shape_Data *pd) { return pd->stroke.cap; } void -_evas_vg_shape_stroke_join_set(Eo *obj EINA_UNUSED, - Evas_VG_Shape_Data *pd, - Evas_VG_Join j) +_evas_vg_shape_efl_geometry_shape_stroke_join_set(Eo *obj EINA_UNUSED, + Evas_VG_Shape_Data *pd, + Efl_Geometry_Join j) { pd->stroke.join = j; } -Evas_VG_Join -_evas_vg_shape_stroke_join_get(Eo *obj EINA_UNUSED, Evas_VG_Shape_Data *pd) +Efl_Geometry_Join +_evas_vg_shape_efl_geometry_shape_stroke_join_get(Eo *obj EINA_UNUSED, + Evas_VG_Shape_Data *pd) { return pd->stroke.join; } diff --git a/src/lib/evas/canvas/evas_vg_shape.eo b/src/lib/evas/canvas/evas_vg_shape.eo index e65ea13fb3..b26dc0846c 100644 --- a/src/lib/evas/canvas/evas_vg_shape.eo +++ b/src/lib/evas/canvas/evas_vg_shape.eo @@ -1,4 +1,4 @@ -class Evas.VG_Shape (Evas.VG_Node) +class Evas.VG_Shape (Evas.VG_Node, Efl.Geometry.Shape) { eo_prefix: evas_vg_shape; legacy_prefix: null; @@ -12,27 +12,6 @@ class Evas.VG_Shape (Evas.VG_Node) Evas_VG_Node *f; } } - stroke_scale { - set { - } - get { - } - values { - double s; - } - } - stroke_color { - set { - } - get { - } - values { - int r; - int g; - int b; - int a; - } - } stroke_fill { set { } @@ -42,72 +21,25 @@ class Evas.VG_Shape (Evas.VG_Node) Evas_VG_Node *f; } } - stroke_width { - set { - } - get { - } - values { - double w; - } - } - stroke_location { - set { - } - get { - } - values { - double centered; - } - } - stroke_dash { - set { - } - get { - } - values { - const(Evas_VG_Dash) *dash; - uint length; - } - } stroke_marker { set { } get { } values { - Evas_VG_Shape *m; - } - } - stroke_cap { - set { - } - get { - } - values { - Evas_VG_Cap c; - } - } - stroke_join { - set { - } - get { - } - values { - Evas_VG_Join j; - } - } - } - methods { - path_set { - return: bool; - params { - @in const(Evas_VG_Path_Command) *op; - @in const(double) *points; + Evas_VG_Node *m; } } } implements { + Efl.Geometry.Shape.stroke_scale; + Efl.Geometry.Shape.stroke_color; + Efl.Geometry.Shape.stroke_width; + Efl.Geometry.Shape.stroke_location; + Efl.Geometry.Shape.stroke_dash; + Efl.Geometry.Shape.stroke_cap; + Efl.Geometry.Shape.stroke_join; + Efl.Geometry.Shape.path_set; Eo.Base.constructor; Eo.Base.destructor; } diff --git a/src/lib/evas/canvas/evas_vg_utils.c b/src/lib/evas/canvas/evas_vg_utils.c index ae749249d8..de1e5afafa 100644 --- a/src/lib/evas/canvas/evas_vg_utils.c +++ b/src/lib/evas/canvas/evas_vg_utils.c @@ -4,33 +4,33 @@ #include "evas_vg_private.h" static unsigned int -evas_vg_path_command_length(Evas_VG_Path_Command command) +efl_geometry_path_command_length(Efl_Geometry_Path_Command command) { switch (command) { - case EVAS_VG_PATH_COMMAND_TYPE_END: return 0; - case EVAS_VG_PATH_COMMAND_TYPE_MOVE_TO: return 2; - case EVAS_VG_PATH_COMMAND_TYPE_LINE_TO: return 2; - case EVAS_VG_PATH_COMMAND_TYPE_QUADRATIC_TO: return 4; - case EVAS_VG_PATH_COMMAND_TYPE_SQUADRATIC_TO: return 2; - case EVAS_VG_PATH_COMMAND_TYPE_CUBIC_TO: return 6; - case EVAS_VG_PATH_COMMAND_TYPE_SCUBIC_TO: return 4; - case EVAS_VG_PATH_COMMAND_TYPE_ARC_TO: return 5; - case EVAS_VG_PATH_COMMAND_TYPE_CLOSE: return 0; - case EVAS_VG_PATH_COMMAND_TYPE_LAST: return 0; + case EFL_GEOMETRY_PATH_COMMAND_TYPE_END: return 0; + case EFL_GEOMETRY_PATH_COMMAND_TYPE_MOVE_TO: return 2; + case EFL_GEOMETRY_PATH_COMMAND_TYPE_LINE_TO: return 2; + case EFL_GEOMETRY_PATH_COMMAND_TYPE_QUADRATIC_TO: return 4; + case EFL_GEOMETRY_PATH_COMMAND_TYPE_SQUADRATIC_TO: return 2; + case EFL_GEOMETRY_PATH_COMMAND_TYPE_CUBIC_TO: return 6; + case EFL_GEOMETRY_PATH_COMMAND_TYPE_SCUBIC_TO: return 4; + case EFL_GEOMETRY_PATH_COMMAND_TYPE_ARC_TO: return 5; + case EFL_GEOMETRY_PATH_COMMAND_TYPE_CLOSE: return 0; + case EFL_GEOMETRY_PATH_COMMAND_TYPE_LAST: return 0; } return 0; } static inline void -_evas_vg_path_length(const Evas_VG_Path_Command *commands, +_efl_geometry_path_length(const Efl_Geometry_Path_Command *commands, unsigned int *cmd_length, unsigned int *pts_length) { if (commands) - while (commands[*cmd_length] != EVAS_VG_PATH_COMMAND_TYPE_END) + while (commands[*cmd_length] != EFL_GEOMETRY_PATH_COMMAND_TYPE_END) { - *pts_length += evas_vg_path_command_length(commands[*cmd_length]); + *pts_length += efl_geometry_path_command_length(commands[*cmd_length]); (*cmd_length)++; } @@ -39,49 +39,49 @@ _evas_vg_path_length(const Evas_VG_Path_Command *commands, } static inline Eina_Bool -evas_vg_path_grow(Evas_VG_Path_Command command, - Evas_VG_Path_Command **commands, double **points, +efl_geometry_path_grow(Efl_Geometry_Path_Command command, + Efl_Geometry_Path_Command **commands, double **points, double **offset_point) { - Evas_VG_Path_Command *cmd_tmp; + Efl_Geometry_Path_Command *cmd_tmp; double *pts_tmp; unsigned int cmd_length = 0, pts_length = 0; - _evas_vg_path_length(*commands, &cmd_length, &pts_length); + _efl_geometry_path_length(*commands, &cmd_length, &pts_length); - if (evas_vg_path_command_length(command)) + if (efl_geometry_path_command_length(command)) { - pts_length += evas_vg_path_command_length(command); + pts_length += efl_geometry_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 - evas_vg_path_command_length(command); + *offset_point = *points + pts_length - efl_geometry_path_command_length(command); } cmd_tmp = realloc(*commands, - (cmd_length + 1) * sizeof (Evas_VG_Path_Command)); + (cmd_length + 1) * sizeof (Efl_Geometry_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] = EVAS_VG_PATH_COMMAND_TYPE_END; + cmd_tmp[cmd_length] = EFL_GEOMETRY_PATH_COMMAND_TYPE_END; return EINA_TRUE; } Eina_Bool -evas_vg_path_dup(Evas_VG_Path_Command **out_cmd, double **out_pts, - const Evas_VG_Path_Command *in_cmd, const double *in_pts) +efl_geometry_path_dup(Efl_Geometry_Path_Command **out_cmd, double **out_pts, + const Efl_Geometry_Path_Command *in_cmd, const double *in_pts) { unsigned int cmd_length = 0, pts_length = 0; - _evas_vg_path_length(in_cmd, &cmd_length, &pts_length); + _efl_geometry_path_length(in_cmd, &cmd_length, &pts_length); *out_pts = malloc(pts_length * sizeof (double)); - *out_cmd = malloc(cmd_length * sizeof (Evas_VG_Path_Command)); + *out_cmd = malloc(cmd_length * sizeof (Efl_Geometry_Path_Command)); if (!(*out_pts) || !(*out_cmd)) { free(*out_pts); @@ -90,17 +90,17 @@ evas_vg_path_dup(Evas_VG_Path_Command **out_cmd, double **out_pts, } memcpy(*out_pts, in_pts, pts_length * sizeof (double)); - memcpy(*out_cmd, in_cmd, cmd_length * sizeof (Evas_VG_Path_Command)); + memcpy(*out_cmd, in_cmd, cmd_length * sizeof (Efl_Geometry_Path_Command)); return EINA_TRUE; } void -evas_vg_path_append_move_to(Evas_VG_Path_Command **commands, double **points, +efl_geometry_path_append_move_to(Efl_Geometry_Path_Command **commands, double **points, double x, double y) { double *offset_point; - if (!evas_vg_path_grow(EVAS_VG_PATH_COMMAND_TYPE_MOVE_TO, + if (!efl_geometry_path_grow(EFL_GEOMETRY_PATH_COMMAND_TYPE_MOVE_TO, commands, points, &offset_point)) return ; @@ -109,12 +109,12 @@ evas_vg_path_append_move_to(Evas_VG_Path_Command **commands, double **points, } void -evas_vg_path_append_line_to(Evas_VG_Path_Command **commands, double **points, +efl_geometry_path_append_line_to(Efl_Geometry_Path_Command **commands, double **points, double x, double y) { double *offset_point; - if (!evas_vg_path_grow(EVAS_VG_PATH_COMMAND_TYPE_LINE_TO, + if (!efl_geometry_path_grow(EFL_GEOMETRY_PATH_COMMAND_TYPE_LINE_TO, commands, points, &offset_point)) return ; @@ -123,12 +123,12 @@ evas_vg_path_append_line_to(Evas_VG_Path_Command **commands, double **points, } void -evas_vg_path_append_quadratic_to(Evas_VG_Path_Command **commands, double **points, +efl_geometry_path_append_quadratic_to(Efl_Geometry_Path_Command **commands, double **points, double x, double y, double ctrl_x, double ctrl_y) { double *offset_point; - if (!evas_vg_path_grow(EVAS_VG_PATH_COMMAND_TYPE_QUADRATIC_TO, + if (!efl_geometry_path_grow(EFL_GEOMETRY_PATH_COMMAND_TYPE_QUADRATIC_TO, commands, points, &offset_point)) return ; @@ -139,12 +139,12 @@ evas_vg_path_append_quadratic_to(Evas_VG_Path_Command **commands, double **point } void -evas_vg_path_append_squadratic_to(Evas_VG_Path_Command **commands, double **points, +efl_geometry_path_append_squadratic_to(Efl_Geometry_Path_Command **commands, double **points, double x, double y) { double *offset_point; - if (!evas_vg_path_grow(EVAS_VG_PATH_COMMAND_TYPE_SQUADRATIC_TO, + if (!efl_geometry_path_grow(EFL_GEOMETRY_PATH_COMMAND_TYPE_SQUADRATIC_TO, commands, points, &offset_point)) return ; @@ -153,14 +153,14 @@ evas_vg_path_append_squadratic_to(Evas_VG_Path_Command **commands, double **poin } void -evas_vg_path_append_cubic_to(Evas_VG_Path_Command **commands, double **points, +efl_geometry_path_append_cubic_to(Efl_Geometry_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 (!evas_vg_path_grow(EVAS_VG_PATH_COMMAND_TYPE_CUBIC_TO, + if (!efl_geometry_path_grow(EFL_GEOMETRY_PATH_COMMAND_TYPE_CUBIC_TO, commands, points, &offset_point)) return ; @@ -173,13 +173,13 @@ evas_vg_path_append_cubic_to(Evas_VG_Path_Command **commands, double **points, } void -evas_vg_path_append_scubic_to(Evas_VG_Path_Command **commands, double **points, +efl_geometry_path_append_scubic_to(Efl_Geometry_Path_Command **commands, double **points, double x, double y, double ctrl_x, double ctrl_y) { double *offset_point; - if (!evas_vg_path_grow(EVAS_VG_PATH_COMMAND_TYPE_SCUBIC_TO, + if (!efl_geometry_path_grow(EFL_GEOMETRY_PATH_COMMAND_TYPE_SCUBIC_TO, commands, points, &offset_point)) return ; @@ -190,14 +190,14 @@ evas_vg_path_append_scubic_to(Evas_VG_Path_Command **commands, double **points, } void -evas_vg_path_append_arc_to(Evas_VG_Path_Command **commands, double **points, +efl_geometry_path_append_arc_to(Efl_Geometry_Path_Command **commands, double **points, double x, double y, double rx, double ry, double angle) { double *offset_point; - if (!evas_vg_path_grow(EVAS_VG_PATH_COMMAND_TYPE_ARC_TO, + if (!efl_geometry_path_grow(EFL_GEOMETRY_PATH_COMMAND_TYPE_ARC_TO, commands, points, &offset_point)) return ; @@ -209,21 +209,21 @@ evas_vg_path_append_arc_to(Evas_VG_Path_Command **commands, double **points, } void -evas_vg_path_append_close(Evas_VG_Path_Command **commands, double **points) +efl_geometry_path_append_close(Efl_Geometry_Path_Command **commands, double **points) { double *offset_point; - evas_vg_path_grow(EVAS_VG_PATH_COMMAND_TYPE_ARC_TO, + efl_geometry_path_grow(EFL_GEOMETRY_PATH_COMMAND_TYPE_ARC_TO, commands, points, &offset_point); } void -evas_vg_path_append_circle(Evas_VG_Path_Command **commands, double **points, +efl_geometry_path_append_circle(Efl_Geometry_Path_Command **commands, double **points, double x, double y, double radius) { - evas_vg_path_append_move_to(commands, points, x, y - radius); - evas_vg_path_append_arc_to(commands, points, x + radius, y, radius, radius, 0); - evas_vg_path_append_arc_to(commands, points, x, y + radius, radius, radius, 0); - evas_vg_path_append_arc_to(commands, points, x - radius, y, radius, radius, 0); - evas_vg_path_append_arc_to(commands, points, x, y - radius, radius, radius, 0); + efl_geometry_path_append_move_to(commands, points, x, y - radius); + efl_geometry_path_append_arc_to(commands, points, x + radius, y, radius, radius, 0); + efl_geometry_path_append_arc_to(commands, points, x, y + radius, radius, radius, 0); + efl_geometry_path_append_arc_to(commands, points, x - radius, y, radius, radius, 0); + efl_geometry_path_append_arc_to(commands, points, x, y - radius, radius, radius, 0); } From 5e75d607c61189756b73b9c61c842ba1596a0d6b Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:14:56 +0200 Subject: [PATCH 021/251] ector: initial introduction. Idea for this library is to become a retained mode drawing library that use Eo/Eolian for its API and take a lot of the good design from Enesim by Jorge Zapata and Jose Gonzalez (http://enesim.org/). --- configure.ac | 43 +++++++++ pc/.gitignore | 1 + pc/ector.pc.in | 12 +++ src/Makefile.am | 1 + src/Makefile_Ector.am | 55 +++++++++++ src/lib/ector/Ector.h | 135 +++++++++++++++++++++++++++ src/lib/ector/ector_main.c | 81 ++++++++++++++++ src/lib/ector/ector_private.h | 39 ++++++++ src/tests/ector/cxx_compile_test.cxx | 34 +++++++ src/tests/ector/ector_suite.c | 113 ++++++++++++++++++++++ src/tests/ector/ector_suite.h | 8 ++ src/tests/ector/ector_test_init.c | 38 ++++++++ 12 files changed, 560 insertions(+) create mode 100644 pc/ector.pc.in create mode 100644 src/Makefile_Ector.am create mode 100644 src/lib/ector/Ector.h create mode 100644 src/lib/ector/ector_main.c create mode 100644 src/lib/ector/ector_private.h create mode 100644 src/tests/ector/cxx_compile_test.cxx create mode 100644 src/tests/ector/ector_suite.c create mode 100644 src/tests/ector/ector_suite.h create mode 100644 src/tests/ector/ector_test_init.c diff --git a/configure.ac b/configure.ac index 8c27ca465c..afad51b647 100644 --- a/configure.ac +++ b/configure.ac @@ -2094,6 +2094,47 @@ EFL_ADD_FEATURE([EVAS], [dither-mask], [${build_evas_dither_mask}]) EFL_LIB_END([Evas]) #### End of Evas +#### Ector + +EFL_LIB_START([Ector]) + + +### Default values + +### Additional options to configure + +### Checks for programs + +### Checks for libraries + +## Compatibility layers + +EFL_PLATFORM_DEPEND([ECTOR], [evil]) + +EFL_INTERNAL_DEPEND_PKG([ECTOR], [eina]) +EFL_INTERNAL_DEPEND_PKG([ECTOR], [eo]) +EFL_INTERNAL_DEPEND_PKG([ECTOR], [evas]) + +EFL_EVAL_PKGS([ECTOR]) + +### Checks for header files + +### Checks for types + +### Checks for structures + +### Checks for compiler characteristics + +### Checks for linker characteristics + +### Checks for library functions + +### Check availability + +EFL_LIB_END([ECTOR]) + +#### End of Ector + #### Edje CXX EFL_LIB_START([Evas_Cxx]) @@ -4524,6 +4565,7 @@ pc/ecore-imf-evas.pc pc/ecore-audio.pc pc/ecore-audio-cxx.pc pc/ecore-avahi.pc +pc/ector.pc pc/embryo.pc pc/eio.pc pc/eldbus.pc @@ -4691,6 +4733,7 @@ fi echo "Ecore_Audio.....: ${efl_lib_optional_ecore_audio} (${features_ecore_audio})" echo "Ecore_Avahi.....: yes (${features_ecore_avahi})" echo "Ecore_Evas......: yes (${features_ecore_evas})" +echo "Ector...........: yes" echo "Eeze............: ${efl_lib_optional_eeze} (${features_eeze})" echo "EPhysics........: ${efl_lib_optional_ephysics}" echo "Edje............: yes (${features_edje})" diff --git a/pc/.gitignore b/pc/.gitignore index 4aaaa1359c..25049d8fa9 100644 --- a/pc/.gitignore +++ b/pc/.gitignore @@ -17,6 +17,7 @@ /ecore-win32.pc /ecore-x.pc /ecore.pc +/ector.pc /edje.pc /eet.pc /eeze.pc diff --git a/pc/ector.pc.in b/pc/ector.pc.in new file mode 100644 index 0000000000..43d2db10f4 --- /dev/null +++ b/pc/ector.pc.in @@ -0,0 +1,12 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: ector +Description: Enlightenned retained mode drawing library +Requires.private: @requirements_pc_ector@ +Version: @VERSION@ +Libs: -L${libdir} -lector +Libs.private: @requirements_libs_ector@ +Cflags: -I${includedir}/efl-@VMAJ@ -I${includedir}/ector-@VMAJ@ diff --git a/src/Makefile.am b/src/Makefile.am index 580911a31a..924d7f8429 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -55,6 +55,7 @@ include Makefile_Ecore_Evas.am include Makefile_Ecore_Audio.am include Makefile_Ecore_Audio_Cxx.am include Makefile_Ecore_Avahi.am +include Makefile_Ector.am include Makefile_Embryo.am include Makefile_Eio.am include Makefile_Eldbus.am diff --git a/src/Makefile_Ector.am b/src/Makefile_Ector.am new file mode 100644 index 0000000000..25893793f1 --- /dev/null +++ b/src/Makefile_Ector.am @@ -0,0 +1,55 @@ + +### Library + +lib_LTLIBRARIES += lib/ector/libector.la + +installed_ectormainheadersdir = $(includedir)/ector-@VMAJ@ +dist_installed_ectormainheaders_DATA = \ +lib/ector/Ector.h + +lib_ector_libector_la_SOURCES = \ +lib/ector/ector_main.c + +lib_ector_libector_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl \ +@ECTOR_CFLAGS@ \ +-DPACKAGE_BIN_DIR=\"$(bindir)\" \ +-DPACKAGE_LIB_DIR=\"$(libdir)\" \ +-DPACKAGE_DATA_DIR=\"$(datadir)/ector\" \ +@VALGRIND_CFLAGS@ + +lib_ector_libector_la_LIBADD = @ECTOR_LIBS@ @DL_LIBS@ +lib_ector_libector_la_DEPENDENCIES = @ECTOR_INTERNAL_LIBS@ @DL_INTERNAL_LIBS@ +lib_ector_libector_la_LDFLAGS = @EFL_LTLIBRARY_FLAGS@ + +### Unit tests + +if EFL_ENABLE_TESTS + +check_PROGRAMS += tests/ector/ector_suite tests/ector/cxx_compile_test +TESTS += tests/ector/ector_suite + +tests_ector_ector_suite_SOURCES = \ +tests/ector/ector_suite.c \ +tests/ector/ector_suite.h \ +tests/ector/ector_test_init.c + +tests_ector_cxx_compile_test_SOURCES = tests/ector/cxx_compile_test.cxx +tests_ector_cxx_compile_test_CPPFLAGS = -I$(top_builddir)/src/lib/efl @ECTOR_CFLAGS@ +tests_ector_cxx_compile_test_LDADD = @USE_ECTOR_LIBS@ +tests_ector_cxx_compile_test_DEPENDENCIES = @USE_ECTOR_INTERNAL_LIBS@ + + +tests_ector_ector_suite_CPPFLAGS = -I$(top_builddir)/src/lib/efl \ +-DTESTS_WD=\"`pwd`\" \ +-DTESTS_SRC_DIR=\"$(top_srcdir)/src/tests/ector\" \ +-DPACKAGE_BUILD_DIR=\"$(abs_top_builddir)/src/tests/ector\" \ +-DTESTS_BUILD_DIR=PACKAGE_BUILD_DIR \ +@CHECK_CFLAGS@ \ +@ECTOR_CFLAGS@ +tests_ector_ector_suite_LDADD = @CHECK_LIBS@ @USE_ECTOR_LIBS@ +tests_ector_ector_suite_DEPENDENCIES = @USE_ECTOR_INTERNAL_LIBS@ + +endif + +EXTRA_DIST += \ +src/lib/ector/ector_private.h diff --git a/src/lib/ector/Ector.h b/src/lib/ector/Ector.h new file mode 100644 index 0000000000..833f113959 --- /dev/null +++ b/src/lib/ector/Ector.h @@ -0,0 +1,135 @@ +#ifndef ECTOR_H_ +#define ECTOR_H_ + +#include +#include + +#ifdef EAPI +# undef EAPI +#endif + +#ifdef _WIN32 +# ifdef EFL_ECTOR_BUILD +# ifdef DLL_EXPORT +# define EAPI __declspec(dllexport) +# else +# define EAPI +# endif /* ! DLL_EXPORT */ +# else +# define EAPI __declspec(dllimport) +# endif /* ! EFL_EO_BUILD */ +#else +# ifdef __GNUC__ +# if __GNUC__ >= 4 +# define EAPI __attribute__ ((visibility("default"))) +# else +# define EAPI +# endif +# else +# define EAPI +# endif +#endif /* ! _WIN32 */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @page ector_main Ector + * + * @date 2014 (created) + * + * @section toc Table of Contents + * + * @li @ref ector_main_intro + * @li @ref ector_main_compiling + * @li @ref ector_main_next_steps + * @li @ref ector_main_intro_example + * + * @section ector_main_intro Introduction + * + * Ector is a retained mode drawing library that is designed to work + * for and with an scenegraph like Evas. + * + * @section ector_main_compiling How to compile + * + * Ector is a library your application links to. The procedure for this is + * very simple. You simply have to compile your application with the + * appropriate compiler flags that the @c pkg-config script outputs. For + * example: + * + * Compiling C or C++ files into object files: + * + * @verbatim + gcc -c -o main.o main.c `pkg-config --cflags ector` + @endverbatim + * + * Linking object files into a binary executable: + * + * @verbatim + gcc -o my_application main.o `pkg-config --libs ector` + @endverbatim + * + * See @ref pkgconfig + * + * @section ector_main_next_steps Next Steps + * + * After you understood what Ector is and installed it in your system + * you should proceed understanding the programming interface. + * + * Recommended reading: + * + * @li @ref Ector_Surface + * @li @ref Ector_Renderer + * + * @section ector_main_intro_example Introductory Example + * + * @ref Ector_Tutorial + * + * + * @addtogroup Ector + * @{ + */ + +/** + * @typedef Ector_Surface + * The base type to render content into. + */ +typedef Eo Ector_Surface; + +/** + * @typedef Ector_Renderer + * The base type describing what to render. + */ +typedef Eo Ector_Renderer; + +#ifdef EFL_BETA_API_SUPPORT + +/** + * @brief Init the ector subsystem + * @return @c EINA_TRUE on success. + * + * @see ector_shutfown() + */ +EAPI int ector_init(void); + +/** + * @brief Shutdown the ector subsystem + * @return @c EINA_TRUE on success. + * + * @see ector_init() + */ +EAPI int ector_shutdown(void); + +#endif + +/** + * @} + */ + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/lib/ector/ector_main.c b/src/lib/ector/ector_main.c new file mode 100644 index 0000000000..5f09214bf4 --- /dev/null +++ b/src/lib/ector/ector_main.c @@ -0,0 +1,81 @@ +/* ECTOR - EFL retained mode drawing library + * Copyright (C) 2014 Cedric Bail + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; + * if not, see . + */ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include "ector_private.h" + +int _ector_log_dom = 0; + +static int _ector_main_count = 0; + +EAPI int +ector_init(void) +{ + if (EINA_LIKELY(_ector_main_count > 0)) + return ++_ector_main_count; + + eina_init(); + eo_init(); + + _ector_log_dom = eina_log_domain_register("ector", ECTOR_DEFAULT_LOG_COLOR); + if (_ector_log_dom < 0) + { + EINA_LOG_ERR("Could not register log domain: ector"); + goto on_error; + } + + _ector_main_count = 1; + + eina_log_timing(_ector_log_dom, EINA_LOG_STATE_STOP, EINA_LOG_STATE_INIT); + + return _ector_main_count; + + on_error: + eo_shutdown(); + eina_shutdown(); + + return 0; +} + +EAPI int +ector_shutdown(void) +{ + if (_ector_main_count <= 0) + { + EINA_LOG_ERR("Init count not greater than 0 in shutdown of ector."); + return 0; + } + + _ector_main_count--; + if (EINA_LIKELY(_ector_main_count > 0)) + return _ector_main_count; + + eina_log_timing(_ector_log_dom, + EINA_LOG_STATE_START, + EINA_LOG_STATE_SHUTDOWN); + + eo_shutdown(); + + eina_log_domain_unregister(_ector_log_dom); + + eina_shutdown(); + return _ector_main_count; +} diff --git a/src/lib/ector/ector_private.h b/src/lib/ector/ector_private.h new file mode 100644 index 0000000000..b41e1ef2dd --- /dev/null +++ b/src/lib/ector/ector_private.h @@ -0,0 +1,39 @@ +#ifndef ECTOR_PRIVATE_H_ +#define ECTOR_PRIVATE_H_ + +/* + * variable and macros used for the eina_log module + */ +extern int _ector_log_dom_global; + +/* + * Macros that are used everywhere + * + * the first four macros are the general macros for the lib + */ +#ifdef ECTOR_DEFAULT_LOG_COLOR +# undef ECTOR_DEFAULT_LOG_COLOR +#endif /* ifdef ECTOR_DEFAULT_LOG_COLOR */ +#define ECTOR_DEFAULT_LOG_COLOR EINA_COLOR_CYAN +#ifdef ERR +# undef ERR +#endif /* ifdef ERR */ +#define ERR(...) EINA_LOG_DOM_ERR(_ector_log_dom_global, __VA_ARGS__) +#ifdef DBG +# undef DBG +#endif /* ifdef DBG */ +#define DBG(...) EINA_LOG_DOM_DBG(_ector_log_dom_global, __VA_ARGS__) +#ifdef INF +# undef INF +#endif /* ifdef INF */ +#define INF(...) EINA_LOG_DOM_INFO(_ector_log_dom_global, __VA_ARGS__) +#ifdef WRN +# undef WRN +#endif /* ifdef WRN */ +#define WRN(...) EINA_LOG_DOM_WARN(_ector_log_dom_global, __VA_ARGS__) +#ifdef CRI +# undef CRI +#endif /* ifdef CRI */ +#define CRI(...) EINA_LOG_DOM_CRIT(_ector_log_dom_global, __VA_ARGS__) + +#endif diff --git a/src/tests/ector/cxx_compile_test.cxx b/src/tests/ector/cxx_compile_test.cxx new file mode 100644 index 0000000000..091757aa37 --- /dev/null +++ b/src/tests/ector/cxx_compile_test.cxx @@ -0,0 +1,34 @@ +/* EINA - EFL data type library + * Copyright (C) 2012 ProFUSION embedded systems + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; + * if not, see . + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include "Ector.h" + +#include +using namespace std; + +int main() +{ + ector_init(); + cout << "Ector compiles with C++!"; + ector_shutdown(); + return 0; +} diff --git a/src/tests/ector/ector_suite.c b/src/tests/ector/ector_suite.c new file mode 100644 index 0000000000..fbae22c4a0 --- /dev/null +++ b/src/tests/ector/ector_suite.c @@ -0,0 +1,113 @@ +/* ECTOR - EFL retained mode drawing library + * Copyright (C) 2014 Cedric Bail + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; + * if not, see . + */ + +#ifdef HAVE_CONFIG_H +# include +#endif /* ifdef HAVE_CONFIG_H */ + +#include +#include + +#include + +#include "Eina.h" + +#include "ector_suite.h" + +typedef struct _Ector_Test_Case Ector_Test_Case; +struct _Ector_Test_Case +{ + const char *test_case; + void (*build)(TCase *tc); +}; + +static const Ector_Test_Case etc[] = { + { "init", ector_test_init }, + { NULL, NULL } +}; + +static void +_list_tests(void) +{ + const Ector_Test_Case *itr = etc; + fputs("Available Test Cases:\n", stderr); + for (; itr->test_case; itr++) + fprintf(stderr, "\t%s\n", itr->test_case); +} + +static Eina_Bool +_use_test(int argc, const char **argv, const char *test_case) +{ + if (argc < 1) + return 1; + + for (; argc > 0; argc--, argv++) + if (strcmp(test_case, *argv) == 0) + return 1; + + return 0; +} + +int +main(int argc, char *argv[]) +{ + TCase *tc; + Suite *s; + SRunner *sr; + int failed_count, i; + + for (i = 1; i < argc; i++) + if ((strcmp(argv[i], "-h") == 0) || + (strcmp(argv[i], "--help") == 0)) + { + fprintf(stderr, "Usage:\n\t%s [test_case1 .. [test_caseN]]\n", + argv[0]); + _list_tests(); + return 0; + } + else if ((strcmp(argv[i], "-l") == 0) || + (strcmp(argv[i], "--list") == 0)) + { + _list_tests(); + return 0; + } + + putenv("EFL_RUN_IN_TREE=1"); + + s = suite_create("Ector"); + + for (i = 0; etc[i].test_case; ++i) + { + if (!_use_test(argc - 1, (const char **) argv + 1, etc[i].test_case)) + continue; + + tc = tcase_create(etc[i].test_case); + tcase_set_timeout(tc, 0); + + etc[i].build(tc); + suite_add_tcase(s, tc); + } + + sr = srunner_create(s); + srunner_set_xml(sr, TESTS_BUILD_DIR "/check-results.xml"); + srunner_run_all(sr, CK_ENV); + failed_count = srunner_ntests_failed(sr); + srunner_free(sr); + + return (failed_count == 0) ? EXIT_SUCCESS : EXIT_FAILURE; +} diff --git a/src/tests/ector/ector_suite.h b/src/tests/ector/ector_suite.h new file mode 100644 index 0000000000..176a838818 --- /dev/null +++ b/src/tests/ector/ector_suite.h @@ -0,0 +1,8 @@ +#ifndef ECTOR_SUITE_H +#define ECTOR_SUITE_H + +#include + +void ector_test_init(TCase *tc); + +#endif diff --git a/src/tests/ector/ector_test_init.c b/src/tests/ector/ector_test_init.c new file mode 100644 index 0000000000..1c36e4012d --- /dev/null +++ b/src/tests/ector/ector_test_init.c @@ -0,0 +1,38 @@ +/* ECTOR - EFL retained mode drawing library + * Copyright (C) 2014 Cedric Bail + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; + * if not, see . + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include "ector_suite.h" + +#include "Ector.h" + +START_TEST(ector_init_simple) +{ + fail_if(ector_init() != 1); + fail_if(ector_shutdown() != 0); +} +END_TEST + +void +ector_test_init(TCase *tc) +{ + tcase_add_test(tc, ector_init_simple); +} From 0510ea90bd8b25cff1e21eea48ec5efd13238993 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:14:58 +0200 Subject: [PATCH 022/251] ector: add initial interface for Surface and Renderer. --- AUTHORS | 8 +++ src/Makefile_Ector.am | 14 ++++ src/lib/ector/Ector.h | 53 +++++++++++++++ src/lib/ector/ector_renderer.eo | 114 ++++++++++++++++++++++++++++++++ src/lib/ector/ector_renderer.h | 6 ++ src/lib/ector/ector_surface.eo | 40 +++++++++++ src/lib/ector/ector_surface.h | 6 ++ 7 files changed, 241 insertions(+) create mode 100644 src/lib/ector/ector_renderer.eo create mode 100644 src/lib/ector/ector_renderer.h create mode 100644 src/lib/ector/ector_surface.eo create mode 100644 src/lib/ector/ector_surface.h diff --git a/AUTHORS b/AUTHORS index 8db85383b2..b283554660 100644 --- a/AUTHORS +++ b/AUTHORS @@ -77,6 +77,14 @@ Eo -- Tom Hacohen +Cedric Bail + +Ector +----- + +Cedric Bail +Jorge Luis Zapata Muga +Jose O Gonzalez Evas ---- diff --git a/src/Makefile_Ector.am b/src/Makefile_Ector.am index 25893793f1..00f89a4acd 100644 --- a/src/Makefile_Ector.am +++ b/src/Makefile_Ector.am @@ -1,5 +1,19 @@ ### Library +ector_eolian_files = \ + lib/ector/ector_surface.eo \ + lib/ector/ector_renderer.eo + +ector_eolian_c = $(ector_eolian_files:%.eo=%.eo.c) +ector_eolian_h = $(ector_eolian_files:%.eo=%.eo.h) + +BUILT_SOURCES += \ + $(ector_eolian_c) \ + $(ector_eolian_h) + +CLEANFILES += \ + $(ector_eolian_c) \ + $(ector_eolian_h) lib_LTLIBRARIES += lib/ector/libector.la diff --git a/src/lib/ector/Ector.h b/src/lib/ector/Ector.h index 833f113959..a47d2f109f 100644 --- a/src/lib/ector/Ector.h +++ b/src/lib/ector/Ector.h @@ -3,6 +3,7 @@ #include #include +#include #ifdef EAPI # undef EAPI @@ -103,6 +104,55 @@ typedef Eo Ector_Surface; */ typedef Eo Ector_Renderer; +/** + * @typedef Ector_Colorspace + * The definiton of colorspace. + */ +typedef Evas_Colorspace Ector_Colorspace; + +/** + * Raster operations at pixel level + */ +typedef enum _Ector_Rop +{ + ECTOR_ROP_BLEND, /**< D = S + D(1 - Sa) */ + ECTOR_ROP_COPY, /**< D = S */ + ECTOR_ROP_LAST +} Ector_Rop; + +/** + * Quality values + */ +typedef enum _Ector_Quality +{ + ECTOR_QUALITY_BEST, /**< Best quality */ + ECTOR_QUALITY_GOOD, /**< Good quality */ + ECTOR_QUALITY_FAST, /**< Lower quality, fastest */ + ECTOR_QUALITY_LAST +} Ector_Quality; + +/** + * Priorities + */ +typedef enum _Ector_Priority +{ + ECTOR_PRIORITY_NONE = 0, + ECTOR_PRIORITY_MARGINAL = 64, + ECTOR_PRIORITY_SECONDARY = 128, + ECTOR_PRIORITY_PRIMARY = 256, +} Ector_Priority; + +/** + * What kind of update is being pushed + */ +typedef enum _Ector_Update_Type +{ + ECTOR_UPDATE_BACKGROUND = 1, /* All the previous state in that area is reset to the new updated profile */ + ECTOR_UPDATE_EMPTY = 2, /* Pushing empty area (no visible pixels at all, no need to read this surface to render it) */ + ECTOR_UPDATE_ALPHA = 4, /* Pushing some transparent pixels (this impact the under layer and will require to read back the surface where this surface is blitted) */ + ECTOR_UPDATE_OPAQUE = 8 /* Pushing some opaque pixels (this means that their is no need to read the under layer when blitting this surface) */ +} Ector_Update_Type; + #ifdef EFL_BETA_API_SUPPORT /** @@ -121,6 +171,9 @@ EAPI int ector_init(void); */ EAPI int ector_shutdown(void); +#include "ector_surface.h" +#include "ector_renderer.h" + #endif /** diff --git a/src/lib/ector/ector_renderer.eo b/src/lib/ector/ector_renderer.eo new file mode 100644 index 0000000000..9073bcb3f8 --- /dev/null +++ b/src/lib/ector/ector_renderer.eo @@ -0,0 +1,114 @@ +abstract Ector.Renderer (Eo.Base) +{ + eo_prefix: ector_renderer; + legacy_prefix: null; + properties { + transformation { + set { + } + get { + } + values { + Eina_Matrix3 m; + } + } + origin { + set { + } + get { + } + values { + double x; + double y; + } + } + visibility { + set { + /*@ Makes the given Ector renderer visible or invisible. */ + } + get { + /*@ Retrieves whether or not the given Ector renderer is visible. */ + } + values { + bool v; /*@ @c EINA_TRUE if to make the object visible, @c EINA_FALSE otherwise */ + } + } + color { + set { + /*@ + Sets the general/main color of the given Ector renderer to the given + one. + + @note These color values are expected to be premultiplied by @p a. + + @ingroup Ector_Renderer_Group_Basic */ + } + get { + /*@ + Retrieves the general/main color of the given Ector renderer. + + Retrieves the “main” color's RGB component (and alpha channel) + values, which range from 0 to 255. For the alpha channel, + which defines the object's transparency level, 0 means totally + transparent, while 255 means opaque. These color values are + premultiplied by the alpha value. + + @note Use @c NULL pointers on the components you're not interested + in: they'll be ignored by the function. + + @ingroup Ector_Renderer_Group_Basic */ + } + values { + int r; /*@ The red component of the given color. */ + int g; /*@ The green component of the given color. */ + int b; /*@ The blue component of the given color. */ + int a; /*@ The alpha component of the given color. */ + } + } + mask { + set { + } + get { + } + values { + Ector_Renderer *r; + } + } + quality { + set { + } + get { + } + values { + Ector_Quality q; + } + } + } + methods { + bounds_get { + return: bool @warn_unused; + params { + @out Eina_Rectangle *r; + } + } + draw { + return: bool @warn_unused; + params { + @in Ector_Surface *s; + @in Ector_Rop op; + @in array *clips; /*@ array of Eina_Rectangle clip */ + @in int x; + @in int y; + } + } + prepare { + return: bool @warn_unused; + params { + @in Ector_Surface *s; + } + } + done { + return: bool @warn_unused; + } + } +} diff --git a/src/lib/ector/ector_renderer.h b/src/lib/ector/ector_renderer.h new file mode 100644 index 0000000000..effb3f59ea --- /dev/null +++ b/src/lib/ector/ector_renderer.h @@ -0,0 +1,6 @@ +#ifndef ECTOR_RENDERER_H +#define ECTOR_RENDERER_H + +#include "ector_renderer.eo.h" + +#endif diff --git a/src/lib/ector/ector_surface.eo b/src/lib/ector/ector_surface.eo new file mode 100644 index 0000000000..36dd9981a2 --- /dev/null +++ b/src/lib/ector/ector_surface.eo @@ -0,0 +1,40 @@ +abstract Ector.Surface (Eo.Base) +{ + eo_prefix: ector_surface; + properties { + size { + set { + /*@ Changes the size of the given Evas object. */ + } + get { + /*@ Retrieves the (rectangular) size of the given Evas object. */ + } + values { + int w; /*@ in */ + int h; /*@ in */ + } + } + } + methods { + renderer_factory_new { + return: Ector_Renderer *; + params { + @in const(Eo_Class) * type @nonull; + } + } + update_push { + return: bool; + params { + @in const(Eina_Rectangle) * r @nonull; + @in Ector_Update_Type type; + } + } + update_reset { + return: bool; + } + } + implements { + @virtual .size.set; + @virtual .size.get; + } +} diff --git a/src/lib/ector/ector_surface.h b/src/lib/ector/ector_surface.h new file mode 100644 index 0000000000..a1096bd714 --- /dev/null +++ b/src/lib/ector/ector_surface.h @@ -0,0 +1,6 @@ +#ifndef ECTOR_SURFACE_H +#define ECTOR_SURFACE_H + +#include "ector_surface.eo.h" + +#endif From b843394912489d1851ef7298eb7c834aed3906c4 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:14:59 +0200 Subject: [PATCH 023/251] autotools: add ector in the list of Eolian file provider. --- src/Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Makefile.am b/src/Makefile.am index 924d7f8429..df0026cd88 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -4,6 +4,7 @@ BUILT_SOURCES = EOLIAN_FLAGS = -I$(srcdir)\ -I$(srcdir)/lib/eo \ + -I$(srcdir)/lib/ector \ -I$(srcdir)/lib/evas/canvas \ -I$(srcdir)/lib/edje \ -I$(srcdir)/lib/efl/interfaces \ From 3635b6370866418fae5d8fdb3b95be932702a754 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:15:00 +0200 Subject: [PATCH 024/251] ector: add initial interface for a shape object. --- src/Makefile_Ector.am | 7 +- src/lib/ector/ector_private.h | 9 + src/lib/ector/ector_renderer.h | 3 +- src/lib/ector/ector_renderer_base.c | 170 +++++++++++++ ...tor_renderer.eo => ector_renderer_base.eo} | 4 +- src/lib/ector/ector_renderer_shape.c | 237 ++++++++++++++++++ src/lib/ector/ector_renderer_shape.eo | 47 ++++ 7 files changed, 472 insertions(+), 5 deletions(-) create mode 100644 src/lib/ector/ector_renderer_base.c rename src/lib/ector/{ector_renderer.eo => ector_renderer_base.eo} (97%) create mode 100644 src/lib/ector/ector_renderer_shape.c create mode 100644 src/lib/ector/ector_renderer_shape.eo diff --git a/src/Makefile_Ector.am b/src/Makefile_Ector.am index 00f89a4acd..8546db7183 100644 --- a/src/Makefile_Ector.am +++ b/src/Makefile_Ector.am @@ -2,7 +2,8 @@ ### Library ector_eolian_files = \ lib/ector/ector_surface.eo \ - lib/ector/ector_renderer.eo + lib/ector/ector_renderer_base.eo \ + lib/ector/ector_renderer_shape.eo ector_eolian_c = $(ector_eolian_files:%.eo=%.eo.c) ector_eolian_h = $(ector_eolian_files:%.eo=%.eo.h) @@ -22,7 +23,9 @@ dist_installed_ectormainheaders_DATA = \ lib/ector/Ector.h lib_ector_libector_la_SOURCES = \ -lib/ector/ector_main.c +lib/ector/ector_main.c \ +lib/ector/ector_renderer_shape.c \ +lib/ector/ector_renderer_base.c lib_ector_libector_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl \ @ECTOR_CFLAGS@ \ diff --git a/src/lib/ector/ector_private.h b/src/lib/ector/ector_private.h index b41e1ef2dd..8e95d0330e 100644 --- a/src/lib/ector/ector_private.h +++ b/src/lib/ector/ector_private.h @@ -36,4 +36,13 @@ extern int _ector_log_dom_global; #endif /* ifdef CRI */ #define CRI(...) EINA_LOG_DOM_CRIT(_ector_log_dom_global, __VA_ARGS__) +static inline void +_ector_renderer_replace(Ector_Renderer **d, const Ector_Renderer *s) +{ + Ector_Renderer *tmp = *d; + + *d = eo_ref(s); + eo_unref(tmp); +} + #endif diff --git a/src/lib/ector/ector_renderer.h b/src/lib/ector/ector_renderer.h index effb3f59ea..5fc674a5c9 100644 --- a/src/lib/ector/ector_renderer.h +++ b/src/lib/ector/ector_renderer.h @@ -1,6 +1,7 @@ #ifndef ECTOR_RENDERER_H #define ECTOR_RENDERER_H -#include "ector_renderer.eo.h" +#include "ector_renderer_base.eo.h" +#include "ector_renderer_shape.eo.h" #endif diff --git a/src/lib/ector/ector_renderer_base.c b/src/lib/ector/ector_renderer_base.c new file mode 100644 index 0000000000..b39b7372e2 --- /dev/null +++ b/src/lib/ector/ector_renderer_base.c @@ -0,0 +1,170 @@ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include + +#include "ector_private.h" + +typedef struct _Ector_Renderer_Base_Data Ector_Renderer_Base_Data; +struct _Ector_Renderer_Base_Data +{ + Eina_Matrix3 *m; + + struct { + double x; + double y; + } origin; + + struct { + int r, g, b, a; + } color; + + Ector_Renderer *mask; + + Ector_Quality q; + Eina_Bool visibility; +}; + +void +_ector_renderer_base_transformation_set(Eo *obj EINA_UNUSED, + Ector_Renderer_Base_Data *pd, + const Eina_Matrix3 *m) +{ + Eina_Matrix3 *tmp = pd->m; + + pd->m = NULL; + if (!m) + { + free(tmp); + tmp = NULL; + } + else + { + if (!tmp) tmp = malloc(sizeof (Eina_Matrix3)); + if (!tmp) return ; + + memcpy(tmp, m, sizeof (Eina_Matrix3)); + } + + pd->m = tmp; +} + +const Eina_Matrix3 * +_ector_renderer_base_transformation_get(Eo *obj EINA_UNUSED, + Ector_Renderer_Base_Data *pd) +{ + return pd->m; +} + +void +_ector_renderer_base_origin_set(Eo *obj EINA_UNUSED, + Ector_Renderer_Base_Data *pd, + double x, double y) +{ + pd->origin.x = x; + pd->origin.y = y; +} + +void +_ector_renderer_base_origin_get(Eo *obj EINA_UNUSED, + Ector_Renderer_Base_Data *pd, + double *x, double *y) +{ + if (x) *x = pd->origin.x; + if (y) *y = pd->origin.y; +} + +void +_ector_renderer_base_visibility_set(Eo *obj EINA_UNUSED, + Ector_Renderer_Base_Data *pd, + Eina_Bool v) +{ + pd->visibility = v; +} + +Eina_Bool +_ector_renderer_base_visibility_get(Eo *obj EINA_UNUSED, + Ector_Renderer_Base_Data *pd) +{ + return pd->visibility; +} + +void +_ector_renderer_base_color_set(Eo *obj EINA_UNUSED, + Ector_Renderer_Base_Data *pd, + int r, int g, int b, int a) +{ + pd->color.r = r; + pd->color.g = g; + pd->color.b = b; + pd->color.a = a; +} + +void +_ector_renderer_base_color_get(Eo *obj EINA_UNUSED, + Ector_Renderer_Base_Data *pd, + int *r, int *g, int *b, int *a) +{ + if (r) *r = pd->color.r; + if (g) *g = pd->color.g; + if (b) *b = pd->color.b; + if (a) *a = pd->color.a; +} + +void +_ector_renderer_base_mask_set(Eo *obj EINA_UNUSED, + Ector_Renderer_Base_Data *pd, + Ector_Renderer *r) +{ + _ector_renderer_replace(&pd->mask, r); +} + +Ector_Renderer * +_ector_renderer_base_mask_get(Eo *obj EINA_UNUSED, + Ector_Renderer_Base_Data *pd) +{ + return pd->mask; +} + +void +_ector_renderer_base_quality_set(Eo *obj EINA_UNUSED, + Ector_Renderer_Base_Data *pd, + Ector_Quality q) +{ + pd->q = q; +} + +Ector_Quality +_ector_renderer_base_quality_get(Eo *obj EINA_UNUSED, + Ector_Renderer_Base_Data *pd) +{ + return pd->q; +} + +Eina_Bool +_ector_renderer_base_bounds_get(Eo *obj, Ector_Renderer_Base_Data *pd, + Eina_Rectangle **r) +{ +} + +Eina_Bool +_ector_renderer_base_draw(Eo *obj, Ector_Renderer_Base_Data *pd, + Ector_Surface *s, Ector_Rop op, Eina_Array *clips, + int x, int y) +{ +} + +Eina_Bool +_ector_renderer_base_prepare(Eo *obj, Ector_Renderer_Base_Data *pd, + Ector_Surface *s) +{ +} + +Eina_Bool +_ector_renderer_base_done(Eo *obj, Ector_Renderer_Base_Data *pd) +{ +} + +#include "ector_renderer_base.eo.c" diff --git a/src/lib/ector/ector_renderer.eo b/src/lib/ector/ector_renderer_base.eo similarity index 97% rename from src/lib/ector/ector_renderer.eo rename to src/lib/ector/ector_renderer_base.eo index 9073bcb3f8..1e2e9eab8f 100644 --- a/src/lib/ector/ector_renderer.eo +++ b/src/lib/ector/ector_renderer_base.eo @@ -1,4 +1,4 @@ -abstract Ector.Renderer (Eo.Base) +abstract Ector.Renderer.Base (Eo.Base) { eo_prefix: ector_renderer; legacy_prefix: null; @@ -9,7 +9,7 @@ abstract Ector.Renderer (Eo.Base) get { } values { - Eina_Matrix3 m; + const(Eina_Matrix3) *m; } } origin { diff --git a/src/lib/ector/ector_renderer_shape.c b/src/lib/ector/ector_renderer_shape.c new file mode 100644 index 0000000000..a41845ed1a --- /dev/null +++ b/src/lib/ector/ector_renderer_shape.c @@ -0,0 +1,237 @@ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include + +#include "ector_private.h" + +typedef struct _Ector_Renderer_Shape_Data Ector_Renderer_Shape_Data; +struct _Ector_Renderer_Shape_Data +{ + Ector_Renderer *fill; + struct { + Ector_Renderer *fill; + Ector_Renderer *marker; + + double scale; + double width; + double centered; + + struct { + int r, g, b, a; + } color; + + Efl_Geometry_Dash *dash; + unsigned int dash_length; + + Efl_Geometry_Cap cap; + Efl_Geometry_Cap join; + } stroke; +}; + +void +_ector_renderer_shape_fill_set(Eo *obj EINA_UNUSED, + Ector_Renderer_Shape_Data *pd, + const Ector_Renderer *r) +{ + _ector_renderer_replace(&pd->fill, r); +} + +const Ector_Renderer * +_ector_renderer_shape_fill_get(Eo *obj EINA_UNUSED, + Ector_Renderer_Shape_Data *pd) +{ + return pd->fill; +} + +void +_ector_renderer_shape_stroke_fill_set(Eo *obj EINA_UNUSED, + Ector_Renderer_Shape_Data *pd, + const Ector_Renderer *r) +{ + _ector_renderer_replace(&pd->stroke.fill, r); +} + +const Ector_Renderer * +_ector_renderer_shape_stroke_fill_get(Eo *obj EINA_UNUSED, + Ector_Renderer_Shape_Data *pd) +{ + return pd->stroke.fill; +} + +void +_ector_renderer_shape_stroke_marker_set(Eo *obj EINA_UNUSED, + Ector_Renderer_Shape_Data *pd, + const Ector_Renderer *r) +{ + _ector_renderer_replace(&pd->stroke.marker, r); +} + +const Ector_Renderer * +_ector_renderer_shape_stroke_marker_get(Eo *obj EINA_UNUSED, + Ector_Renderer_Shape_Data *pd) +{ + return pd->stroke.marker; +} + +void +_ector_renderer_shape_efl_geometry_shape_stroke_scale_set(Eo *obj EINA_UNUSED, + Ector_Renderer_Shape_Data *pd, + double s) +{ + pd->stroke.scale = s; +} + +double +_ector_renderer_shape_efl_geometry_shape_stroke_scale_get(Eo *obj EINA_UNUSED, + Ector_Renderer_Shape_Data *pd) +{ + return pd->stroke.scale; +} + +void +_ector_renderer_shape_efl_geometry_shape_stroke_color_set(Eo *obj EINA_UNUSED, + Ector_Renderer_Shape_Data *pd, + int r, int g, int b, int a) +{ + pd->stroke.color.r = r; + pd->stroke.color.g = g; + pd->stroke.color.b = b; + pd->stroke.color.a = a; +} + + +void +_ector_renderer_shape_efl_geometry_shape_stroke_color_get(Eo *obj EINA_UNUSED, + Ector_Renderer_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; + if (b) *b = pd->stroke.color.b; + if (a) *a = pd->stroke.color.a; +} + +void +_ector_renderer_shape_efl_geometry_shape_stroke_width_set(Eo *obj EINA_UNUSED, + Ector_Renderer_Shape_Data *pd, + double w) +{ + pd->stroke.width = w; +} + +double +_ector_renderer_shape_efl_geometry_shape_stroke_width_get(Eo *obj EINA_UNUSED, + Ector_Renderer_Shape_Data *pd) +{ + return pd->stroke.width; +} + +void +_ector_renderer_shape_efl_geometry_shape_stroke_location_set(Eo *obj EINA_UNUSED, + Ector_Renderer_Shape_Data *pd, + double centered) +{ + pd->stroke.centered = centered; +} + +double +_ector_renderer_shape_efl_geometry_shape_stroke_location_get(Eo *obj EINA_UNUSED, + Ector_Renderer_Shape_Data *pd) +{ + return pd->stroke.centered; +} + +void +_ector_renderer_shape_efl_geometry_shape_stroke_dash_set(Eo *obj EINA_UNUSED, + Ector_Renderer_Shape_Data *pd, + const Efl_Geometry_Dash *dash, + unsigned int length) +{ + Efl_Geometry_Dash *tmp; + + if (!dash) + { + free(pd->stroke.dash); + pd->stroke.dash = NULL; + pd->stroke.dash_length = 0; + return ; + } + + tmp = realloc(pd->stroke.dash, length * sizeof (Efl_Geometry_Dash)); + if (!tmp) return ; + memcpy(tmp, dash, length * sizeof (Efl_Geometry_Dash)); + + pd->stroke.dash = tmp; + pd->stroke.dash_length = length; +} + +void +_ector_renderer_shape_efl_geometry_shape_stroke_dash_get(Eo *obj EINA_UNUSED, + Ector_Renderer_Shape_Data *pd, + const Efl_Geometry_Dash **dash, + unsigned int *length) +{ + if (dash) *dash = pd->stroke.dash; + if (length) *length = pd->stroke.dash_length; +} + +void +_ector_renderer_shape_efl_geometry_shape_stroke_cap_set(Eo *obj EINA_UNUSED, + Ector_Renderer_Shape_Data *pd, + Efl_Geometry_Cap c) +{ + pd->stroke.cap = c; +} + +Efl_Geometry_Cap +_ector_renderer_shape_efl_geometry_shape_stroke_cap_get(Eo *obj EINA_UNUSED, + Ector_Renderer_Shape_Data *pd) +{ + return pd->stroke.cap; +} + +void +_ector_renderer_shape_efl_geometry_shape_stroke_join_set(Eo *obj EINA_UNUSED, + Ector_Renderer_Shape_Data *pd, + Efl_Geometry_Join j) +{ + pd->stroke.join = j; +} + +Efl_Geometry_Join +_ector_renderer_shape_efl_geometry_shape_stroke_join_get(Eo *obj EINA_UNUSED, + Ector_Renderer_Shape_Data *pd) +{ + return pd->stroke.join; +} + +Eina_Bool +_ector_renderer_shape_efl_geometry_shape_path_set(Eo *obj, + Ector_Renderer_Shape_Data *pd, + const Efl_Geometry_Path_Command *op, + const double *points) +{ +} + +Eina_Bool +_ector_renderer_shape_ector_renderer_base_prepare(Eo *obj, + Ector_Renderer_Shape_Data *pd, + Ector_Surface *s) +{ +} + +void +_ector_renderer_shape_eo_base_constructor(Eo *obj, + Ector_Renderer_Shape_Data *pd) +{ +} + +void +_ector_renderer_shape_eo_base_destructor(Eo *obj, Ector_Renderer_Shape_Data *pd) +{ +} + +#include "ector_renderer_shape.eo.c" diff --git a/src/lib/ector/ector_renderer_shape.eo b/src/lib/ector/ector_renderer_shape.eo new file mode 100644 index 0000000000..2410b0a83d --- /dev/null +++ b/src/lib/ector/ector_renderer_shape.eo @@ -0,0 +1,47 @@ +class Ector.Renderer.Shape (Ector.Renderer.Base, Efl.Geometry.Shape) +{ + eo_prefix: ector_renderer_shape; + legacy_prefix: null; + properties { + fill { + set { + } + get { + } + values { + const(Ector_Renderer) *r; + } + } + stroke_fill { + set { + } + get { + } + values { + const(Ector_Renderer) *r; + } + } + stroke_marker { + set { + } + get { + } + values { + const(Ector_Renderer) *r; + } + } + } + implements { + Efl.Geometry.Shape.stroke_scale; + Efl.Geometry.Shape.stroke_color; + Efl.Geometry.Shape.stroke_width; + Efl.Geometry.Shape.stroke_location; + Efl.Geometry.Shape.stroke_dash; + Efl.Geometry.Shape.stroke_cap; + Efl.Geometry.Shape.stroke_join; + Efl.Geometry.Shape.path_set; + Ector.Renderer.Base.prepare; + Eo.Base.constructor; + Eo.Base.destructor; + } +} \ No newline at end of file From 1d49ff7df2c513088ec75a841705f7fab100340e Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:15:02 +0200 Subject: [PATCH 025/251] efl: rename geometry to graphics to be more general. --- src/Makefile_Efl.am | 2 +- src/lib/ector/ector_renderer_shape.c | 56 ++++---- src/lib/ector/ector_renderer_shape.eo | 18 +-- src/lib/efl/Efl.h | 56 ++++---- ...eometry_shape.eo => efl_graphics_shape.eo} | 10 +- src/lib/efl/interfaces/efl_interfaces_main.c | 2 +- src/lib/evas/canvas/evas_vg_private.h | 4 +- src/lib/evas/canvas/evas_vg_shape.c | 62 ++++---- src/lib/evas/canvas/evas_vg_shape.eo | 18 +-- src/lib/evas/canvas/evas_vg_utils.c | 132 +++++++++--------- 10 files changed, 180 insertions(+), 180 deletions(-) rename src/lib/efl/interfaces/{efl_geometry_shape.eo => efl_graphics_shape.eo} (82%) diff --git a/src/Makefile_Efl.am b/src/Makefile_Efl.am index 687793545c..0336e8f754 100644 --- a/src/Makefile_Efl.am +++ b/src/Makefile_Efl.am @@ -5,7 +5,7 @@ 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_geometry_shape.eo + lib/efl/interfaces/efl_graphics_shape.eo efl_eolian_files_h = $(efl_eolian_files:%.eo=%.eo.h) efl_eolian_files_c = $(efl_eolian_files:%.eo=%.eo.c) diff --git a/src/lib/ector/ector_renderer_shape.c b/src/lib/ector/ector_renderer_shape.c index a41845ed1a..6957210e93 100644 --- a/src/lib/ector/ector_renderer_shape.c +++ b/src/lib/ector/ector_renderer_shape.c @@ -23,11 +23,11 @@ struct _Ector_Renderer_Shape_Data int r, g, b, a; } color; - Efl_Geometry_Dash *dash; + Efl_Graphics_Dash *dash; unsigned int dash_length; - Efl_Geometry_Cap cap; - Efl_Geometry_Cap join; + Efl_Graphics_Cap cap; + Efl_Graphics_Cap join; } stroke; }; @@ -77,7 +77,7 @@ _ector_renderer_shape_stroke_marker_get(Eo *obj EINA_UNUSED, } void -_ector_renderer_shape_efl_geometry_shape_stroke_scale_set(Eo *obj EINA_UNUSED, +_ector_renderer_shape_efl_graphics_shape_stroke_scale_set(Eo *obj EINA_UNUSED, Ector_Renderer_Shape_Data *pd, double s) { @@ -85,14 +85,14 @@ _ector_renderer_shape_efl_geometry_shape_stroke_scale_set(Eo *obj EINA_UNUSED, } double -_ector_renderer_shape_efl_geometry_shape_stroke_scale_get(Eo *obj EINA_UNUSED, +_ector_renderer_shape_efl_graphics_shape_stroke_scale_get(Eo *obj EINA_UNUSED, Ector_Renderer_Shape_Data *pd) { return pd->stroke.scale; } void -_ector_renderer_shape_efl_geometry_shape_stroke_color_set(Eo *obj EINA_UNUSED, +_ector_renderer_shape_efl_graphics_shape_stroke_color_set(Eo *obj EINA_UNUSED, Ector_Renderer_Shape_Data *pd, int r, int g, int b, int a) { @@ -104,7 +104,7 @@ _ector_renderer_shape_efl_geometry_shape_stroke_color_set(Eo *obj EINA_UNUSED, void -_ector_renderer_shape_efl_geometry_shape_stroke_color_get(Eo *obj EINA_UNUSED, +_ector_renderer_shape_efl_graphics_shape_stroke_color_get(Eo *obj EINA_UNUSED, Ector_Renderer_Shape_Data *pd, int *r, int *g, int *b, int *a) { @@ -115,7 +115,7 @@ _ector_renderer_shape_efl_geometry_shape_stroke_color_get(Eo *obj EINA_UNUSED, } void -_ector_renderer_shape_efl_geometry_shape_stroke_width_set(Eo *obj EINA_UNUSED, +_ector_renderer_shape_efl_graphics_shape_stroke_width_set(Eo *obj EINA_UNUSED, Ector_Renderer_Shape_Data *pd, double w) { @@ -123,14 +123,14 @@ _ector_renderer_shape_efl_geometry_shape_stroke_width_set(Eo *obj EINA_UNUSED, } double -_ector_renderer_shape_efl_geometry_shape_stroke_width_get(Eo *obj EINA_UNUSED, +_ector_renderer_shape_efl_graphics_shape_stroke_width_get(Eo *obj EINA_UNUSED, Ector_Renderer_Shape_Data *pd) { return pd->stroke.width; } void -_ector_renderer_shape_efl_geometry_shape_stroke_location_set(Eo *obj EINA_UNUSED, +_ector_renderer_shape_efl_graphics_shape_stroke_location_set(Eo *obj EINA_UNUSED, Ector_Renderer_Shape_Data *pd, double centered) { @@ -138,19 +138,19 @@ _ector_renderer_shape_efl_geometry_shape_stroke_location_set(Eo *obj EINA_UNUSED } double -_ector_renderer_shape_efl_geometry_shape_stroke_location_get(Eo *obj EINA_UNUSED, +_ector_renderer_shape_efl_graphics_shape_stroke_location_get(Eo *obj EINA_UNUSED, Ector_Renderer_Shape_Data *pd) { return pd->stroke.centered; } void -_ector_renderer_shape_efl_geometry_shape_stroke_dash_set(Eo *obj EINA_UNUSED, +_ector_renderer_shape_efl_graphics_shape_stroke_dash_set(Eo *obj EINA_UNUSED, Ector_Renderer_Shape_Data *pd, - const Efl_Geometry_Dash *dash, + const Efl_Graphics_Dash *dash, unsigned int length) { - Efl_Geometry_Dash *tmp; + Efl_Graphics_Dash *tmp; if (!dash) { @@ -160,18 +160,18 @@ _ector_renderer_shape_efl_geometry_shape_stroke_dash_set(Eo *obj EINA_UNUSED, return ; } - tmp = realloc(pd->stroke.dash, length * sizeof (Efl_Geometry_Dash)); + tmp = realloc(pd->stroke.dash, length * sizeof (Efl_Graphics_Dash)); if (!tmp) return ; - memcpy(tmp, dash, length * sizeof (Efl_Geometry_Dash)); + memcpy(tmp, dash, length * sizeof (Efl_Graphics_Dash)); pd->stroke.dash = tmp; pd->stroke.dash_length = length; } void -_ector_renderer_shape_efl_geometry_shape_stroke_dash_get(Eo *obj EINA_UNUSED, +_ector_renderer_shape_efl_graphics_shape_stroke_dash_get(Eo *obj EINA_UNUSED, Ector_Renderer_Shape_Data *pd, - const Efl_Geometry_Dash **dash, + const Efl_Graphics_Dash **dash, unsigned int *length) { if (dash) *dash = pd->stroke.dash; @@ -179,39 +179,39 @@ _ector_renderer_shape_efl_geometry_shape_stroke_dash_get(Eo *obj EINA_UNUSED, } void -_ector_renderer_shape_efl_geometry_shape_stroke_cap_set(Eo *obj EINA_UNUSED, +_ector_renderer_shape_efl_graphics_shape_stroke_cap_set(Eo *obj EINA_UNUSED, Ector_Renderer_Shape_Data *pd, - Efl_Geometry_Cap c) + Efl_Graphics_Cap c) { pd->stroke.cap = c; } -Efl_Geometry_Cap -_ector_renderer_shape_efl_geometry_shape_stroke_cap_get(Eo *obj EINA_UNUSED, +Efl_Graphics_Cap +_ector_renderer_shape_efl_graphics_shape_stroke_cap_get(Eo *obj EINA_UNUSED, Ector_Renderer_Shape_Data *pd) { return pd->stroke.cap; } void -_ector_renderer_shape_efl_geometry_shape_stroke_join_set(Eo *obj EINA_UNUSED, +_ector_renderer_shape_efl_graphics_shape_stroke_join_set(Eo *obj EINA_UNUSED, Ector_Renderer_Shape_Data *pd, - Efl_Geometry_Join j) + Efl_Graphics_Join j) { pd->stroke.join = j; } -Efl_Geometry_Join -_ector_renderer_shape_efl_geometry_shape_stroke_join_get(Eo *obj EINA_UNUSED, +Efl_Graphics_Join +_ector_renderer_shape_efl_graphics_shape_stroke_join_get(Eo *obj EINA_UNUSED, Ector_Renderer_Shape_Data *pd) { return pd->stroke.join; } Eina_Bool -_ector_renderer_shape_efl_geometry_shape_path_set(Eo *obj, +_ector_renderer_shape_efl_graphics_shape_path_set(Eo *obj, Ector_Renderer_Shape_Data *pd, - const Efl_Geometry_Path_Command *op, + const Efl_Graphics_Path_Command *op, const double *points) { } diff --git a/src/lib/ector/ector_renderer_shape.eo b/src/lib/ector/ector_renderer_shape.eo index 2410b0a83d..4cd46016e0 100644 --- a/src/lib/ector/ector_renderer_shape.eo +++ b/src/lib/ector/ector_renderer_shape.eo @@ -1,4 +1,4 @@ -class Ector.Renderer.Shape (Ector.Renderer.Base, Efl.Geometry.Shape) +class Ector.Renderer.Shape (Ector.Renderer.Base, Efl.Graphics.Shape) { eo_prefix: ector_renderer_shape; legacy_prefix: null; @@ -32,14 +32,14 @@ class Ector.Renderer.Shape (Ector.Renderer.Base, Efl.Geometry.Shape) } } implements { - Efl.Geometry.Shape.stroke_scale; - Efl.Geometry.Shape.stroke_color; - Efl.Geometry.Shape.stroke_width; - Efl.Geometry.Shape.stroke_location; - Efl.Geometry.Shape.stroke_dash; - Efl.Geometry.Shape.stroke_cap; - Efl.Geometry.Shape.stroke_join; - Efl.Geometry.Shape.path_set; + 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_set; Ector.Renderer.Base.prepare; Eo.Base.constructor; Eo.Base.destructor; diff --git a/src/lib/efl/Efl.h b/src/lib/efl/Efl.h index c6705b4850..d184acaa1f 100644 --- a/src/lib/efl/Efl.h +++ b/src/lib/efl/Efl.h @@ -38,28 +38,28 @@ extern "C" * Path command enum. * * @since 1.13 - * @ingroup Efl_Geometry_Shape + * @ingroup Efl_Graphics_Shape */ -typedef enum _Efl_Geometry_Path_Command +typedef enum _Efl_Graphics_Path_Command { - EFL_GEOMETRY_PATH_COMMAND_TYPE_END = 0, /**< End of the stream of command */ - EFL_GEOMETRY_PATH_COMMAND_TYPE_MOVE_TO, /**< A move command type */ - EFL_GEOMETRY_PATH_COMMAND_TYPE_LINE_TO, /**< A line command type */ - EFL_GEOMETRY_PATH_COMMAND_TYPE_QUADRATIC_TO, /**< A quadratic command type */ - EFL_GEOMETRY_PATH_COMMAND_TYPE_SQUADRATIC_TO, /**< A smooth quadratic command type */ - EFL_GEOMETRY_PATH_COMMAND_TYPE_CUBIC_TO, /**< A cubic command type */ - EFL_GEOMETRY_PATH_COMMAND_TYPE_SCUBIC_TO, /**< A smooth cubic command type */ - EFL_GEOMETRY_PATH_COMMAND_TYPE_ARC_TO, /**< An arc command type */ - EFL_GEOMETRY_PATH_COMMAND_TYPE_CLOSE, /**< A close command type */ - EFL_GEOMETRY_PATH_COMMAND_TYPE_LAST, /**< Not a valid command, but last one according to this version header */ -} Efl_Geometry_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_QUADRATIC_TO, /**< A quadratic command type */ + EFL_GRAPHICS_PATH_COMMAND_TYPE_SQUADRATIC_TO, /**< A smooth quadratic command type */ + EFL_GRAPHICS_PATH_COMMAND_TYPE_CUBIC_TO, /**< A cubic command type */ + EFL_GRAPHICS_PATH_COMMAND_TYPE_SCUBIC_TO, /**< A smooth cubic command type */ + EFL_GRAPHICS_PATH_COMMAND_TYPE_ARC_TO, /**< An arc 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; /** * Type describing dash * @since 1.13 */ -typedef struct _Efl_Geometry_Dash Efl_Geometry_Dash; -struct _Efl_Geometry_Dash +typedef struct _Efl_Graphics_Dash Efl_Graphics_Dash; +struct _Efl_Graphics_Dash { double length; double gap; @@ -69,25 +69,25 @@ struct _Efl_Geometry_Dash * Type defining how a line end. * @since 1.13 */ -typedef enum _Efl_Geometry_Cap +typedef enum _Efl_Graphics_Cap { - EFL_GEOMETRY_CAP_BUTT, - EFL_GEOMETRY_CAP_ROUND, - EFL_GEOMETRY_CAP_SQUARE, - EFL_GEOMETRY_CAP_LAST -} Efl_Geometry_Cap; + EFL_GRAPHICS_CAP_BUTT, + EFL_GRAPHICS_CAP_ROUND, + EFL_GRAPHICS_CAP_SQUARE, + EFL_GRAPHICS_CAP_LAST +} Efl_Graphics_Cap; /** * Type defining how join between path are drawn. * @since 1.13 */ -typedef enum _Efl_Geometry_Join +typedef enum _Efl_Graphics_Join { - EFL_GEOMETRY_JOIN_MITER, - EFL_GEOMETRY_JOIN_ROUND, - EFL_GEOMETRY_JOIN_BEVEL, - EFL_GEOMETRY_JOIN_LAST -} Efl_Geometry_Join; + EFL_GRAPHICS_JOIN_MITER, + EFL_GRAPHICS_JOIN_ROUND, + EFL_GRAPHICS_JOIN_BEVEL, + EFL_GRAPHICS_JOIN_LAST +} Efl_Graphics_Join; #ifdef EFL_BETA_API_SUPPORT @@ -99,7 +99,7 @@ typedef enum _Efl_Geometry_Join #include "interfaces/efl_text.eo.h" #include "interfaces/efl_text_properties.eo.h" -#include "interfaces/efl_geometry_shape.eo.h" +#include "interfaces/efl_graphics_shape.eo.h" #endif diff --git a/src/lib/efl/interfaces/efl_geometry_shape.eo b/src/lib/efl/interfaces/efl_graphics_shape.eo similarity index 82% rename from src/lib/efl/interfaces/efl_geometry_shape.eo rename to src/lib/efl/interfaces/efl_graphics_shape.eo index 5f85e99f36..9e745d9c85 100644 --- a/src/lib/efl/interfaces/efl_geometry_shape.eo +++ b/src/lib/efl/interfaces/efl_graphics_shape.eo @@ -1,4 +1,4 @@ -interface Efl.Geometry.Shape +interface Efl.Graphics.Shape { legacy_prefix: null; properties { @@ -47,7 +47,7 @@ interface Efl.Geometry.Shape get { } values { - const(Efl_Geometry_Dash) *dash; + const(Efl_Graphics_Dash) *dash; uint length; } } @@ -57,7 +57,7 @@ interface Efl.Geometry.Shape get { } values { - Efl_Geometry_Cap c; + Efl_Graphics_Cap c; } } stroke_join { @@ -66,7 +66,7 @@ interface Efl.Geometry.Shape get { } values { - Efl_Geometry_Join j; + Efl_Graphics_Join j; } } } @@ -74,7 +74,7 @@ interface Efl.Geometry.Shape path_set { return: bool; params { - @in const(Efl_Geometry_Path_Command) *op; + @in const(Efl_Graphics_Path_Command) *op; @in const(double) *points; } } diff --git a/src/lib/efl/interfaces/efl_interfaces_main.c b/src/lib/efl/interfaces/efl_interfaces_main.c index e4e20ef6f6..793dbb65d8 100644 --- a/src/lib/efl/interfaces/efl_interfaces_main.c +++ b/src/lib/efl/interfaces/efl_interfaces_main.c @@ -11,4 +11,4 @@ #include "interfaces/efl_text.eo.c" #include "interfaces/efl_text_properties.eo.c" -#include "interfaces/efl_geometry_shape.eo.c" +#include "interfaces/efl_graphics_shape.eo.c" diff --git a/src/lib/evas/canvas/evas_vg_private.h b/src/lib/evas/canvas/evas_vg_private.h index 1d288dcc3c..6b26a24213 100644 --- a/src/lib/evas/canvas/evas_vg_private.h +++ b/src/lib/evas/canvas/evas_vg_private.h @@ -22,7 +22,7 @@ struct _Evas_VG_Container_Data }; Eina_Bool -efl_geometry_path_dup(Efl_Geometry_Path_Command **out_cmd, double **out_pts, - const Efl_Geometry_Path_Command *in_cmd, const double *in_pts); +efl_graphics_path_dup(Efl_Graphics_Path_Command **out_cmd, double **out_pts, + const Efl_Graphics_Path_Command *in_cmd, const double *in_pts); #endif diff --git a/src/lib/evas/canvas/evas_vg_shape.c b/src/lib/evas/canvas/evas_vg_shape.c index 2a0f5d2a69..c062ccb8a0 100644 --- a/src/lib/evas/canvas/evas_vg_shape.c +++ b/src/lib/evas/canvas/evas_vg_shape.c @@ -8,13 +8,13 @@ typedef struct _Evas_VG_Shape_Data Evas_VG_Shape_Data; struct _Evas_VG_Shape_Data { - Efl_Geometry_Path_Command *op; + Efl_Graphics_Path_Command *op; double *points; Evas_VG_Node *fill; struct { - Efl_Geometry_Dash *dash; + Efl_Graphics_Dash *dash; Evas_VG_Node *fill; Evas_VG_Node *marker; @@ -26,8 +26,8 @@ struct _Evas_VG_Shape_Data unsigned int dash_count; - Efl_Geometry_Cap cap; - Efl_Geometry_Join join; + Efl_Graphics_Cap cap; + Efl_Graphics_Join join; } stroke; unsigned int op_count; @@ -35,9 +35,9 @@ struct _Evas_VG_Shape_Data }; Eina_Bool -_evas_vg_shape_efl_geometry_shape_path_set(Eo *obj EINA_UNUSED, +_evas_vg_shape_efl_graphics_shape_path_set(Eo *obj EINA_UNUSED, Evas_VG_Shape_Data *pd, - const Efl_Geometry_Path_Command *op, + const Efl_Graphics_Path_Command *op, const double *points) { free(pd->points); @@ -45,7 +45,7 @@ _evas_vg_shape_efl_geometry_shape_path_set(Eo *obj EINA_UNUSED, free(pd->op); pd->op = NULL; - return efl_geometry_path_dup(&pd->op, &pd->points, op, points); + return efl_graphics_path_dup(&pd->op, &pd->points, op, points); } Eina_Bool @@ -59,8 +59,8 @@ void _evas_vg_shape_eo_base_constructor(Eo *obj, Evas_VG_Shape_Data *pd EINA_UNUSED) { eo_do_super(obj, MY_CLASS, eo_constructor()); - pd->stroke.cap = EFL_GEOMETRY_CAP_BUTT; - pd->stroke.join = EFL_GEOMETRY_JOIN_MITER; + pd->stroke.cap = EFL_GRAPHICS_CAP_BUTT; + pd->stroke.join = EFL_GRAPHICS_JOIN_MITER; pd->stroke.scale = 1; pd->stroke.a = 1; pd->stroke.centered = 0.5; @@ -90,7 +90,7 @@ _evas_vg_shape_fill_get(Eo *obj EINA_UNUSED, Evas_VG_Shape_Data *pd) } void -_evas_vg_shape_efl_geometry_shape_stroke_scale_set(Eo *obj EINA_UNUSED, +_evas_vg_shape_efl_graphics_shape_stroke_scale_set(Eo *obj EINA_UNUSED, Evas_VG_Shape_Data *pd, double s) { @@ -98,14 +98,14 @@ _evas_vg_shape_efl_geometry_shape_stroke_scale_set(Eo *obj EINA_UNUSED, } double -_evas_vg_shape_efl_geometry_shape_stroke_scale_get(Eo *obj EINA_UNUSED, +_evas_vg_shape_efl_graphics_shape_stroke_scale_get(Eo *obj EINA_UNUSED, Evas_VG_Shape_Data *pd) { return pd->stroke.scale; } void -_evas_vg_shape_efl_geometry_shape_stroke_color_set(Eo *obj EINA_UNUSED, +_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) { @@ -116,7 +116,7 @@ _evas_vg_shape_efl_geometry_shape_stroke_color_set(Eo *obj EINA_UNUSED, } void -_evas_vg_shape_efl_geometry_shape_stroke_color_get(Eo *obj EINA_UNUSED, +_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) { @@ -145,7 +145,7 @@ _evas_vg_shape_stroke_fill_get(Eo *obj EINA_UNUSED, } void -_evas_vg_shape_efl_geometry_shape_stroke_width_set(Eo *obj EINA_UNUSED, +_evas_vg_shape_efl_graphics_shape_stroke_width_set(Eo *obj EINA_UNUSED, Evas_VG_Shape_Data *pd, double w) { @@ -153,14 +153,14 @@ _evas_vg_shape_efl_geometry_shape_stroke_width_set(Eo *obj EINA_UNUSED, } double -_evas_vg_shape_efl_geometry_shape_stroke_width_get(Eo *obj EINA_UNUSED, +_evas_vg_shape_efl_graphics_shape_stroke_width_get(Eo *obj EINA_UNUSED, Evas_VG_Shape_Data *pd) { return pd->stroke.width; } void -_evas_vg_shape_efl_geometry_shape_stroke_location_set(Eo *obj EINA_UNUSED, +_evas_vg_shape_efl_graphics_shape_stroke_location_set(Eo *obj EINA_UNUSED, Evas_VG_Shape_Data *pd, double centered) { @@ -168,33 +168,33 @@ _evas_vg_shape_efl_geometry_shape_stroke_location_set(Eo *obj EINA_UNUSED, } double -_evas_vg_shape_efl_geometry_shape_stroke_location_get(Eo *obj EINA_UNUSED, +_evas_vg_shape_efl_graphics_shape_stroke_location_get(Eo *obj EINA_UNUSED, Evas_VG_Shape_Data *pd) { return pd->stroke.centered; } void -_evas_vg_shape_efl_geometry_shape_stroke_dash_set(Eo *obj EINA_UNUSED, +_evas_vg_shape_efl_graphics_shape_stroke_dash_set(Eo *obj EINA_UNUSED, Evas_VG_Shape_Data *pd, - const Efl_Geometry_Dash *dash, + const Efl_Graphics_Dash *dash, unsigned int length) { free(pd->stroke.dash); pd->stroke.dash = NULL; pd->stroke.dash_count = 0; - pd->stroke.dash = malloc(sizeof (Efl_Geometry_Dash) * length); + pd->stroke.dash = malloc(sizeof (Efl_Graphics_Dash) * length); if (!pd->stroke.dash) return ; - memcpy(pd->stroke.dash, dash, sizeof (Efl_Geometry_Dash) * length); + memcpy(pd->stroke.dash, dash, sizeof (Efl_Graphics_Dash) * length); pd->stroke.dash_count = length; } void -_evas_vg_shape_efl_geometry_shape_stroke_dash_get(Eo *obj EINA_UNUSED, +_evas_vg_shape_efl_graphics_shape_stroke_dash_get(Eo *obj EINA_UNUSED, Evas_VG_Shape_Data *pd, - const Efl_Geometry_Dash **dash, + const Efl_Graphics_Dash **dash, unsigned int *length) { if (dash) *dash = pd->stroke.dash; @@ -220,30 +220,30 @@ _evas_vg_shape_stroke_marker_get(Eo *obj EINA_UNUSED, } void -_evas_vg_shape_efl_geometry_shape_stroke_cap_set(Eo *obj EINA_UNUSED, +_evas_vg_shape_efl_graphics_shape_stroke_cap_set(Eo *obj EINA_UNUSED, Evas_VG_Shape_Data *pd, - Efl_Geometry_Cap c) + Efl_Graphics_Cap c) { pd->stroke.cap = c; } -Efl_Geometry_Cap -_evas_vg_shape_efl_geometry_shape_stroke_cap_get(Eo *obj EINA_UNUSED, +Efl_Graphics_Cap +_evas_vg_shape_efl_graphics_shape_stroke_cap_get(Eo *obj EINA_UNUSED, Evas_VG_Shape_Data *pd) { return pd->stroke.cap; } void -_evas_vg_shape_efl_geometry_shape_stroke_join_set(Eo *obj EINA_UNUSED, +_evas_vg_shape_efl_graphics_shape_stroke_join_set(Eo *obj EINA_UNUSED, Evas_VG_Shape_Data *pd, - Efl_Geometry_Join j) + Efl_Graphics_Join j) { pd->stroke.join = j; } -Efl_Geometry_Join -_evas_vg_shape_efl_geometry_shape_stroke_join_get(Eo *obj EINA_UNUSED, +Efl_Graphics_Join +_evas_vg_shape_efl_graphics_shape_stroke_join_get(Eo *obj EINA_UNUSED, Evas_VG_Shape_Data *pd) { return pd->stroke.join; diff --git a/src/lib/evas/canvas/evas_vg_shape.eo b/src/lib/evas/canvas/evas_vg_shape.eo index b26dc0846c..0574b72118 100644 --- a/src/lib/evas/canvas/evas_vg_shape.eo +++ b/src/lib/evas/canvas/evas_vg_shape.eo @@ -1,4 +1,4 @@ -class Evas.VG_Shape (Evas.VG_Node, Efl.Geometry.Shape) +class Evas.VG_Shape (Evas.VG_Node, Efl.Graphics.Shape) { eo_prefix: evas_vg_shape; legacy_prefix: null; @@ -32,14 +32,14 @@ class Evas.VG_Shape (Evas.VG_Node, Efl.Geometry.Shape) } } implements { - Efl.Geometry.Shape.stroke_scale; - Efl.Geometry.Shape.stroke_color; - Efl.Geometry.Shape.stroke_width; - Efl.Geometry.Shape.stroke_location; - Efl.Geometry.Shape.stroke_dash; - Efl.Geometry.Shape.stroke_cap; - Efl.Geometry.Shape.stroke_join; - Efl.Geometry.Shape.path_set; + 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_set; Eo.Base.constructor; Eo.Base.destructor; } diff --git a/src/lib/evas/canvas/evas_vg_utils.c b/src/lib/evas/canvas/evas_vg_utils.c index de1e5afafa..4b34e87225 100644 --- a/src/lib/evas/canvas/evas_vg_utils.c +++ b/src/lib/evas/canvas/evas_vg_utils.c @@ -4,33 +4,33 @@ #include "evas_vg_private.h" static unsigned int -efl_geometry_path_command_length(Efl_Geometry_Path_Command command) +efl_graphics_path_command_length(Efl_Graphics_Path_Command command) { switch (command) { - case EFL_GEOMETRY_PATH_COMMAND_TYPE_END: return 0; - case EFL_GEOMETRY_PATH_COMMAND_TYPE_MOVE_TO: return 2; - case EFL_GEOMETRY_PATH_COMMAND_TYPE_LINE_TO: return 2; - case EFL_GEOMETRY_PATH_COMMAND_TYPE_QUADRATIC_TO: return 4; - case EFL_GEOMETRY_PATH_COMMAND_TYPE_SQUADRATIC_TO: return 2; - case EFL_GEOMETRY_PATH_COMMAND_TYPE_CUBIC_TO: return 6; - case EFL_GEOMETRY_PATH_COMMAND_TYPE_SCUBIC_TO: return 4; - case EFL_GEOMETRY_PATH_COMMAND_TYPE_ARC_TO: return 5; - case EFL_GEOMETRY_PATH_COMMAND_TYPE_CLOSE: return 0; - case EFL_GEOMETRY_PATH_COMMAND_TYPE_LAST: return 0; + 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_QUADRATIC_TO: return 4; + case EFL_GRAPHICS_PATH_COMMAND_TYPE_SQUADRATIC_TO: return 2; + case EFL_GRAPHICS_PATH_COMMAND_TYPE_CUBIC_TO: return 6; + case EFL_GRAPHICS_PATH_COMMAND_TYPE_SCUBIC_TO: return 4; + case EFL_GRAPHICS_PATH_COMMAND_TYPE_ARC_TO: return 5; + case EFL_GRAPHICS_PATH_COMMAND_TYPE_CLOSE: return 0; + case EFL_GRAPHICS_PATH_COMMAND_TYPE_LAST: return 0; } return 0; } static inline void -_efl_geometry_path_length(const Efl_Geometry_Path_Command *commands, - unsigned int *cmd_length, - unsigned int *pts_length) +_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_GEOMETRY_PATH_COMMAND_TYPE_END) + while (commands[*cmd_length] != EFL_GRAPHICS_PATH_COMMAND_TYPE_END) { - *pts_length += efl_geometry_path_command_length(commands[*cmd_length]); + *pts_length += efl_graphics_path_command_length(commands[*cmd_length]); (*cmd_length)++; } @@ -39,49 +39,49 @@ _efl_geometry_path_length(const Efl_Geometry_Path_Command *commands, } static inline Eina_Bool -efl_geometry_path_grow(Efl_Geometry_Path_Command command, - Efl_Geometry_Path_Command **commands, double **points, - double **offset_point) +efl_graphics_path_grow(Efl_Graphics_Path_Command command, + Efl_Graphics_Path_Command **commands, double **points, + double **offset_point) { - Efl_Geometry_Path_Command *cmd_tmp; + Efl_Graphics_Path_Command *cmd_tmp; double *pts_tmp; unsigned int cmd_length = 0, pts_length = 0; - _efl_geometry_path_length(*commands, &cmd_length, &pts_length); + _efl_graphics_path_length(*commands, &cmd_length, &pts_length); - if (efl_geometry_path_command_length(command)) + if (efl_graphics_path_command_length(command)) { - pts_length += efl_geometry_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_geometry_path_command_length(command); + *offset_point = *points + pts_length - efl_graphics_path_command_length(command); } cmd_tmp = realloc(*commands, - (cmd_length + 1) * sizeof (Efl_Geometry_Path_Command)); + (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_GEOMETRY_PATH_COMMAND_TYPE_END; + cmd_tmp[cmd_length] = EFL_GRAPHICS_PATH_COMMAND_TYPE_END; return EINA_TRUE; } Eina_Bool -efl_geometry_path_dup(Efl_Geometry_Path_Command **out_cmd, double **out_pts, - const Efl_Geometry_Path_Command *in_cmd, const double *in_pts) +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_geometry_path_length(in_cmd, &cmd_length, &pts_length); + _efl_graphics_path_length(in_cmd, &cmd_length, &pts_length); *out_pts = malloc(pts_length * sizeof (double)); - *out_cmd = malloc(cmd_length * sizeof (Efl_Geometry_Path_Command)); + *out_cmd = malloc(cmd_length * sizeof (Efl_Graphics_Path_Command)); if (!(*out_pts) || !(*out_cmd)) { free(*out_pts); @@ -90,17 +90,17 @@ efl_geometry_path_dup(Efl_Geometry_Path_Command **out_cmd, double **out_pts, } memcpy(*out_pts, in_pts, pts_length * sizeof (double)); - memcpy(*out_cmd, in_cmd, cmd_length * sizeof (Efl_Geometry_Path_Command)); + memcpy(*out_cmd, in_cmd, cmd_length * sizeof (Efl_Graphics_Path_Command)); return EINA_TRUE; } void -efl_geometry_path_append_move_to(Efl_Geometry_Path_Command **commands, double **points, - double x, double y) +efl_graphics_path_append_move_to(Efl_Graphics_Path_Command **commands, double **points, + double x, double y) { double *offset_point; - if (!efl_geometry_path_grow(EFL_GEOMETRY_PATH_COMMAND_TYPE_MOVE_TO, + if (!efl_graphics_path_grow(EFL_GRAPHICS_PATH_COMMAND_TYPE_MOVE_TO, commands, points, &offset_point)) return ; @@ -109,12 +109,12 @@ efl_geometry_path_append_move_to(Efl_Geometry_Path_Command **commands, double ** } void -efl_geometry_path_append_line_to(Efl_Geometry_Path_Command **commands, double **points, - double x, double y) +efl_graphics_path_append_line_to(Efl_Graphics_Path_Command **commands, double **points, + double x, double y) { double *offset_point; - if (!efl_geometry_path_grow(EFL_GEOMETRY_PATH_COMMAND_TYPE_LINE_TO, + if (!efl_graphics_path_grow(EFL_GRAPHICS_PATH_COMMAND_TYPE_LINE_TO, commands, points, &offset_point)) return ; @@ -123,12 +123,12 @@ efl_geometry_path_append_line_to(Efl_Geometry_Path_Command **commands, double ** } void -efl_geometry_path_append_quadratic_to(Efl_Geometry_Path_Command **commands, double **points, - double x, double y, double ctrl_x, double ctrl_y) +efl_graphics_path_append_quadratic_to(Efl_Graphics_Path_Command **commands, double **points, + double x, double y, double ctrl_x, double ctrl_y) { double *offset_point; - if (!efl_geometry_path_grow(EFL_GEOMETRY_PATH_COMMAND_TYPE_QUADRATIC_TO, + if (!efl_graphics_path_grow(EFL_GRAPHICS_PATH_COMMAND_TYPE_QUADRATIC_TO, commands, points, &offset_point)) return ; @@ -139,12 +139,12 @@ efl_geometry_path_append_quadratic_to(Efl_Geometry_Path_Command **commands, doub } void -efl_geometry_path_append_squadratic_to(Efl_Geometry_Path_Command **commands, double **points, - double x, double y) +efl_graphics_path_append_squadratic_to(Efl_Graphics_Path_Command **commands, double **points, + double x, double y) { double *offset_point; - if (!efl_geometry_path_grow(EFL_GEOMETRY_PATH_COMMAND_TYPE_SQUADRATIC_TO, + if (!efl_graphics_path_grow(EFL_GRAPHICS_PATH_COMMAND_TYPE_SQUADRATIC_TO, commands, points, &offset_point)) return ; @@ -153,14 +153,14 @@ efl_geometry_path_append_squadratic_to(Efl_Geometry_Path_Command **commands, dou } void -efl_geometry_path_append_cubic_to(Efl_Geometry_Path_Command **commands, double **points, - double x, double y, - double ctrl_x0, double ctrl_y0, - double ctrl_x1, double ctrl_y1) +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_geometry_path_grow(EFL_GEOMETRY_PATH_COMMAND_TYPE_CUBIC_TO, + if (!efl_graphics_path_grow(EFL_GRAPHICS_PATH_COMMAND_TYPE_CUBIC_TO, commands, points, &offset_point)) return ; @@ -173,13 +173,13 @@ efl_geometry_path_append_cubic_to(Efl_Geometry_Path_Command **commands, double * } void -efl_geometry_path_append_scubic_to(Efl_Geometry_Path_Command **commands, double **points, - double x, double y, - double ctrl_x, double ctrl_y) +efl_graphics_path_append_scubic_to(Efl_Graphics_Path_Command **commands, double **points, + double x, double y, + double ctrl_x, double ctrl_y) { double *offset_point; - if (!efl_geometry_path_grow(EFL_GEOMETRY_PATH_COMMAND_TYPE_SCUBIC_TO, + if (!efl_graphics_path_grow(EFL_GRAPHICS_PATH_COMMAND_TYPE_SCUBIC_TO, commands, points, &offset_point)) return ; @@ -190,14 +190,14 @@ efl_geometry_path_append_scubic_to(Efl_Geometry_Path_Command **commands, double } void -efl_geometry_path_append_arc_to(Efl_Geometry_Path_Command **commands, double **points, - double x, double y, - double rx, double ry, - double angle) +efl_graphics_path_append_arc_to(Efl_Graphics_Path_Command **commands, double **points, + double x, double y, + double rx, double ry, + double angle) { double *offset_point; - if (!efl_geometry_path_grow(EFL_GEOMETRY_PATH_COMMAND_TYPE_ARC_TO, + if (!efl_graphics_path_grow(EFL_GRAPHICS_PATH_COMMAND_TYPE_ARC_TO, commands, points, &offset_point)) return ; @@ -209,21 +209,21 @@ efl_geometry_path_append_arc_to(Efl_Geometry_Path_Command **commands, double **p } void -efl_geometry_path_append_close(Efl_Geometry_Path_Command **commands, double **points) +efl_graphics_path_append_close(Efl_Graphics_Path_Command **commands, double **points) { double *offset_point; - efl_geometry_path_grow(EFL_GEOMETRY_PATH_COMMAND_TYPE_ARC_TO, + efl_graphics_path_grow(EFL_GRAPHICS_PATH_COMMAND_TYPE_ARC_TO, commands, points, &offset_point); } void -efl_geometry_path_append_circle(Efl_Geometry_Path_Command **commands, double **points, - double x, double y, double radius) +efl_graphics_path_append_circle(Efl_Graphics_Path_Command **commands, double **points, + double x, double y, double radius) { - efl_geometry_path_append_move_to(commands, points, x, y - radius); - efl_geometry_path_append_arc_to(commands, points, x + radius, y, radius, radius, 0); - efl_geometry_path_append_arc_to(commands, points, x, y + radius, radius, radius, 0); - efl_geometry_path_append_arc_to(commands, points, x - radius, y, radius, radius, 0); - efl_geometry_path_append_arc_to(commands, points, x, y - radius, radius, radius, 0); + 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); + efl_graphics_path_append_arc_to(commands, points, x, y + radius, radius, radius, 0); + efl_graphics_path_append_arc_to(commands, points, x - radius, y, radius, radius, 0); + efl_graphics_path_append_arc_to(commands, points, x, y - radius, radius, radius, 0); } From d59351732d1e38290131baee73fd01b596462f73 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:15:03 +0200 Subject: [PATCH 026/251] efl: add a gradient interface. --- src/Makefile_Efl.am | 3 +- src/lib/efl/Efl.h | 27 ++++++++++++++ .../efl/interfaces/efl_graphics_gradient.eo | 26 ++++++++++++++ src/lib/efl/interfaces/efl_interfaces_main.c | 1 + src/lib/evas/Evas_Eo.h | 18 ---------- src/lib/evas/canvas/evas_vg_gradient.c | 36 +++++++++---------- src/lib/evas/canvas/evas_vg_gradient.eo | 27 ++++---------- 7 files changed, 80 insertions(+), 58 deletions(-) create mode 100644 src/lib/efl/interfaces/efl_graphics_gradient.eo diff --git a/src/Makefile_Efl.am b/src/Makefile_Efl.am index 0336e8f754..815c78a6e0 100644 --- a/src/Makefile_Efl.am +++ b/src/Makefile_Efl.am @@ -5,7 +5,8 @@ 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_shape.eo \ + lib/efl/interfaces/efl_graphics_gradient.eo efl_eolian_files_h = $(efl_eolian_files:%.eo=%.eo.h) efl_eolian_files_c = $(efl_eolian_files:%.eo=%.eo.c) diff --git a/src/lib/efl/Efl.h b/src/lib/efl/Efl.h index d184acaa1f..bafa685ec4 100644 --- a/src/lib/efl/Efl.h +++ b/src/lib/efl/Efl.h @@ -89,6 +89,32 @@ typedef enum _Efl_Graphics_Join EFL_GRAPHICS_JOIN_LAST } Efl_Graphics_Join; +/** + * Type defining gradient stop. + * @since 1.13 + */ +typedef struct _Efl_Graphics_Gradient_Stop Efl_Graphics_Gradient_Stop; +struct _Efl_Graphics_Gradient_Stop +{ + double offset; + int r; + int g; + int b; + int a; +}; + +/** + * Type defining how the gradient spread after its limit. + * @since 1.13 + */ +typedef enum _Efl_Graphics_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; + #ifdef EFL_BETA_API_SUPPORT /* Interfaces */ @@ -100,6 +126,7 @@ typedef enum _Efl_Graphics_Join #include "interfaces/efl_text_properties.eo.h" #include "interfaces/efl_graphics_shape.eo.h" +#include "interfaces/efl_graphics_gradient.eo.h" #endif diff --git a/src/lib/efl/interfaces/efl_graphics_gradient.eo b/src/lib/efl/interfaces/efl_graphics_gradient.eo new file mode 100644 index 0000000000..378ffaf62f --- /dev/null +++ b/src/lib/efl/interfaces/efl_graphics_gradient.eo @@ -0,0 +1,26 @@ +interface Efl.Graphics.Gradient +{ + legacy_prefix: null; + properties { + stop { + set { + } + get { + } + values { + const(Efl_Graphics_Gradient_Stop) *colors; + uint length; + } + } + spread { + set { + } + get { + } + values { + Efl_Graphics_Gradient_Spread s; + } + } + } + +} diff --git a/src/lib/efl/interfaces/efl_interfaces_main.c b/src/lib/efl/interfaces/efl_interfaces_main.c index 793dbb65d8..10f9d1eebd 100644 --- a/src/lib/efl/interfaces/efl_interfaces_main.c +++ b/src/lib/efl/interfaces/efl_interfaces_main.c @@ -12,3 +12,4 @@ #include "interfaces/efl_text_properties.eo.c" #include "interfaces/efl_graphics_shape.eo.c" +#include "interfaces/efl_graphics_gradient.eo.c" diff --git a/src/lib/evas/Evas_Eo.h b/src/lib/evas/Evas_Eo.h index b28e7ce570..0209677fd3 100644 --- a/src/lib/evas/Evas_Eo.h +++ b/src/lib/evas/Evas_Eo.h @@ -850,24 +850,6 @@ typedef enum _Evas_3D_Material_Attrib */ typedef Eo Evas_VG_Node; -typedef struct _Evas_VG_Gradient_Stop Evas_VG_Gradient_Stop; -struct _Evas_VG_Gradient_Stop -{ - double offset; - int r; - int g; - int b; - int a; -}; - -typedef enum _Evas_VG_Gradient_Spread -{ - EVAS_VG_GRADIENT_SPREAD_PAD, - EVAS_VG_GRADIENT_SPREAD_REFLECT, - EVAS_VG_GRADIENT_SPREAD_REPEAT, - EVAS_VG_GRADIENT_SPREAD_LAST -} Evas_VG_Gradient_Spread; - /** * @ingroup Evas_Object_VG * diff --git a/src/lib/evas/canvas/evas_vg_gradient.c b/src/lib/evas/canvas/evas_vg_gradient.c index df7edc641b..72bddf7baa 100644 --- a/src/lib/evas/canvas/evas_vg_gradient.c +++ b/src/lib/evas/canvas/evas_vg_gradient.c @@ -7,50 +7,50 @@ typedef struct _Evas_VG_Gradient_Data Evas_VG_Gradient_Data; struct _Evas_VG_Gradient_Data { // FIXME: Later on we should deduplicate it somehow. - Evas_VG_Gradient_Stop *colors; + Efl_Graphics_Gradient_Stop *colors; unsigned int colors_count; - Evas_VG_Gradient_Spread s; + Efl_Graphics_Gradient_Spread s; }; void -_evas_vg_gradient_stop_set(Eo *obj EINA_UNUSED, - Evas_VG_Gradient_Data *pd, - const Evas_VG_Gradient_Stop *colors, - unsigned int length) +_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) { - pd->colors = realloc(pd->colors, length * sizeof(Evas_VG_Gradient_Stop)); + pd->colors = realloc(pd->colors, length * sizeof(Efl_Graphics_Gradient_Stop)); if (!pd->colors) { pd->colors_count = 0; return ; } - memcpy(pd->colors, colors, length * sizeof(Evas_VG_Gradient_Stop)); + memcpy(pd->colors, colors, length * sizeof(Efl_Graphics_Gradient_Stop)); pd->colors_count = length; } void -_evas_vg_gradient_stop_get(Eo *obj EINA_UNUSED, - Evas_VG_Gradient_Data *pd, - const Evas_VG_Gradient_Stop **colors, - unsigned int *length) +_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) { if (colors) *colors = pd->colors; if (length) *length = pd->colors_count; } void -_evas_vg_gradient_spread_set(Eo *obj EINA_UNUSED, - Evas_VG_Gradient_Data *pd, - Evas_VG_Gradient_Spread s) +_evas_vg_gradient_efl_graphics_gradient_spread_set(Eo *obj EINA_UNUSED, + Evas_VG_Gradient_Data *pd, + Efl_Graphics_Gradient_Spread s) { pd->s = s; } -Evas_VG_Gradient_Spread -_evas_vg_gradient_spread_get(Eo *obj EINA_UNUSED, - Evas_VG_Gradient_Data *pd) +Efl_Graphics_Gradient_Spread +_evas_vg_gradient_efl_graphics_gradient_spread_get(Eo *obj EINA_UNUSED, + Evas_VG_Gradient_Data *pd) { return pd->s; } diff --git a/src/lib/evas/canvas/evas_vg_gradient.eo b/src/lib/evas/canvas/evas_vg_gradient.eo index 549d28ac39..a71a7e7dde 100644 --- a/src/lib/evas/canvas/evas_vg_gradient.eo +++ b/src/lib/evas/canvas/evas_vg_gradient.eo @@ -1,26 +1,11 @@ -abstract Evas.VG_Gradient (Evas.VG_Node) +abstract Evas.VG_Gradient (Evas.VG_Node, Efl.Graphics.Gradient) { eo_prefix: evas_vg_gradient; legacy_prefix: null; - properties { - stop { - set { - } - get { - } - values { - const(Evas_VG_Gradient_Stop) *colors; - uint length; - } - } - spread { - set { - } - get { - } - values { - Evas_VG_Gradient_Spread s; - } - } + implements { + Efl.Graphics.Gradient.stop.set; + Efl.Graphics.Gradient.stop.get; + Efl.Graphics.Gradient.spread.set; + Efl.Graphics.Gradient.spread.get; } } From f701e1f0990c99a2202c65527b64261e69d99a7b Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:15:04 +0200 Subject: [PATCH 027/251] ector: add top gradient renderer. --- src/Makefile_Ector.am | 6 ++-- src/lib/ector/ector_renderer_gradient.c | 45 ++++++++++++++++++++++++ src/lib/ector/ector_renderer_gradient.eo | 11 ++++++ 3 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 src/lib/ector/ector_renderer_gradient.c create mode 100644 src/lib/ector/ector_renderer_gradient.eo diff --git a/src/Makefile_Ector.am b/src/Makefile_Ector.am index 8546db7183..9eba5d75e1 100644 --- a/src/Makefile_Ector.am +++ b/src/Makefile_Ector.am @@ -3,7 +3,8 @@ ector_eolian_files = \ lib/ector/ector_surface.eo \ lib/ector/ector_renderer_base.eo \ - lib/ector/ector_renderer_shape.eo + lib/ector/ector_renderer_shape.eo \ + lib/ector/ector_renderer_gradient.eo ector_eolian_c = $(ector_eolian_files:%.eo=%.eo.c) ector_eolian_h = $(ector_eolian_files:%.eo=%.eo.h) @@ -25,7 +26,8 @@ lib/ector/Ector.h lib_ector_libector_la_SOURCES = \ lib/ector/ector_main.c \ lib/ector/ector_renderer_shape.c \ -lib/ector/ector_renderer_base.c +lib/ector/ector_renderer_base.c \ +lib/ector/ector_renderer_gradient.c lib_ector_libector_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl \ @ECTOR_CFLAGS@ \ diff --git a/src/lib/ector/ector_renderer_gradient.c b/src/lib/ector/ector_renderer_gradient.c new file mode 100644 index 0000000000..7de90413af --- /dev/null +++ b/src/lib/ector/ector_renderer_gradient.c @@ -0,0 +1,45 @@ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include + +#include "ector_private.h" + +typedef struct _Ector_Renderer_Gradient_Data Ector_Renderer_Gradient_Data; +struct _Ector_Renderer_Gradient_Data +{ +}; + +void +_ector_renderer_gradient_efl_graphics_gradient_stop_set(Eo *obj, + Ector_Renderer_Gradient_Data *pd, + const Efl_Graphics_Gradient_Stop *colors, + unsigned int length) +{ +} + +void +_ector_renderer_gradient_efl_graphics_gradient_stop_get(Eo *obj, + Ector_Renderer_Gradient_Data *pd, + const Efl_Graphics_Gradient_Stop **colors, + unsigned int *length) +{ +} + +void +_ector_renderer_gradient_efl_graphics_gradient_spread_set(Eo *obj, + Ector_Renderer_Gradient_Data *pd, + Efl_Graphics_Gradient_Spread s) +{ +} + +Efl_Graphics_Gradient_Spread +_ector_renderer_gradient_efl_graphics_gradient_spread_get(Eo *obj, + Ector_Renderer_Gradient_Data *pd) +{ +} + + +#include "ector_renderer_gradient.eo.c" diff --git a/src/lib/ector/ector_renderer_gradient.eo b/src/lib/ector/ector_renderer_gradient.eo new file mode 100644 index 0000000000..d513b5490d --- /dev/null +++ b/src/lib/ector/ector_renderer_gradient.eo @@ -0,0 +1,11 @@ +abstract Ector.Renderer.Gradient (Ector.Renderer.Base, Efl.Graphics.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; + } +} From e15bdbe4577d22191481b7820346fdc644e56f18 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:15:36 +0200 Subject: [PATCH 028/251] efl: add a linear gradient interface. --- src/Makefile_Efl.am | 3 +- src/lib/efl/Efl.h | 1 + .../efl_graphics_gradient_linear.eo | 26 +++++++++++++++++ src/lib/efl/interfaces/efl_interfaces_main.c | 1 + src/lib/evas/canvas/evas_vg_gradient_linear.c | 8 +++--- .../evas/canvas/evas_vg_gradient_linear.eo | 28 ++++--------------- 6 files changed, 40 insertions(+), 27 deletions(-) create mode 100644 src/lib/efl/interfaces/efl_graphics_gradient_linear.eo diff --git a/src/Makefile_Efl.am b/src/Makefile_Efl.am index 815c78a6e0..88fe60534f 100644 --- a/src/Makefile_Efl.am +++ b/src/Makefile_Efl.am @@ -6,7 +6,8 @@ efl_eolian_files = \ 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.eo \ + lib/efl/interfaces/efl_graphics_gradient_linear.eo efl_eolian_files_h = $(efl_eolian_files:%.eo=%.eo.h) efl_eolian_files_c = $(efl_eolian_files:%.eo=%.eo.c) diff --git a/src/lib/efl/Efl.h b/src/lib/efl/Efl.h index bafa685ec4..df64c18a6a 100644 --- a/src/lib/efl/Efl.h +++ b/src/lib/efl/Efl.h @@ -127,6 +127,7 @@ typedef enum _Efl_Graphics_Gradient_Spread #include "interfaces/efl_graphics_shape.eo.h" #include "interfaces/efl_graphics_gradient.eo.h" +#include "interfaces/efl_graphics_gradient_linear.eo.h" #endif diff --git a/src/lib/efl/interfaces/efl_graphics_gradient_linear.eo b/src/lib/efl/interfaces/efl_graphics_gradient_linear.eo new file mode 100644 index 0000000000..2c4f083121 --- /dev/null +++ b/src/lib/efl/interfaces/efl_graphics_gradient_linear.eo @@ -0,0 +1,26 @@ +interface Efl.Graphics.Gradient_Linear (Efl.Graphics.Gradient) +{ + legacy_prefix: null; + properties { + start { + set { + } + get { + } + values { + double x; + double y; + } + } + end { + set { + } + get { + } + values { + double x; + double y; + } + } + } +} diff --git a/src/lib/efl/interfaces/efl_interfaces_main.c b/src/lib/efl/interfaces/efl_interfaces_main.c index 10f9d1eebd..95b9ff09e8 100644 --- a/src/lib/efl/interfaces/efl_interfaces_main.c +++ b/src/lib/efl/interfaces/efl_interfaces_main.c @@ -13,3 +13,4 @@ #include "interfaces/efl_graphics_shape.eo.c" #include "interfaces/efl_graphics_gradient.eo.c" +#include "interfaces/efl_graphics_gradient_linear.eo.c" diff --git a/src/lib/evas/canvas/evas_vg_gradient_linear.c b/src/lib/evas/canvas/evas_vg_gradient_linear.c index 9332178a18..f60dc3b90f 100644 --- a/src/lib/evas/canvas/evas_vg_gradient_linear.c +++ b/src/lib/evas/canvas/evas_vg_gradient_linear.c @@ -12,7 +12,7 @@ struct _Evas_VG_Gradient_Linear_Data }; void -_evas_vg_gradient_linear_start_set(Eo *obj EINA_UNUSED, +_evas_vg_gradient_linear_efl_graphics_gradient_linear_start_set(Eo *obj EINA_UNUSED, Evas_VG_Gradient_Linear_Data *pd, double x, double y) { @@ -21,7 +21,7 @@ _evas_vg_gradient_linear_start_set(Eo *obj EINA_UNUSED, } void -_evas_vg_gradient_linear_start_get(Eo *obj EINA_UNUSED, +_evas_vg_gradient_linear_efl_graphics_gradient_linear_start_get(Eo *obj EINA_UNUSED, Evas_VG_Gradient_Linear_Data *pd, double *x, double *y) { @@ -30,7 +30,7 @@ _evas_vg_gradient_linear_start_get(Eo *obj EINA_UNUSED, } void -_evas_vg_gradient_linear_end_set(Eo *obj EINA_UNUSED, +_evas_vg_gradient_linear_efl_graphics_gradient_linear_end_set(Eo *obj EINA_UNUSED, Evas_VG_Gradient_Linear_Data *pd, double x, double y) { @@ -39,7 +39,7 @@ _evas_vg_gradient_linear_end_set(Eo *obj EINA_UNUSED, } void -_evas_vg_gradient_linear_end_get(Eo *obj EINA_UNUSED, +_evas_vg_gradient_linear_efl_graphics_gradient_linear_end_get(Eo *obj EINA_UNUSED, Evas_VG_Gradient_Linear_Data *pd, double *x, double *y) { diff --git a/src/lib/evas/canvas/evas_vg_gradient_linear.eo b/src/lib/evas/canvas/evas_vg_gradient_linear.eo index 07c05391b0..d513f10905 100644 --- a/src/lib/evas/canvas/evas_vg_gradient_linear.eo +++ b/src/lib/evas/canvas/evas_vg_gradient_linear.eo @@ -1,27 +1,11 @@ -class Evas.VG_Gradient_Linear (Evas.VG_Gradient) +class Evas.VG_Gradient_Linear (Evas.VG_Gradient, Efl.Graphics.Gradient_Linear) { eo_prefix: evas_vg_gradient_linear; legacy_prefix: null; - properties { - start { - set { - } - get { - } - values { - double x; - double y; - } - } - end { - set { - } - get { - } - values { - double x; - double y; - } - } + 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; } } From 4036a22b108d387df2f0e325926562599bd9e761 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:15:37 +0200 Subject: [PATCH 029/251] efl: introduce an Efl Gradient Radial interface. --- src/Makefile_Efl.am | 3 +- src/lib/efl/Efl.h | 1 + .../efl_graphics_gradient_radial.eo | 35 +++++++++++++++++ src/lib/efl/interfaces/efl_interfaces_main.c | 1 + src/lib/evas/canvas/evas_vg_gradient_radial.c | 34 ++++++++-------- .../evas/canvas/evas_vg_gradient_radial.eo | 39 ++++--------------- 6 files changed, 64 insertions(+), 49 deletions(-) create mode 100644 src/lib/efl/interfaces/efl_graphics_gradient_radial.eo diff --git a/src/Makefile_Efl.am b/src/Makefile_Efl.am index 88fe60534f..0c4d8b9fe8 100644 --- a/src/Makefile_Efl.am +++ b/src/Makefile_Efl.am @@ -7,7 +7,8 @@ efl_eolian_files = \ 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_linear.eo \ + lib/efl/interfaces/efl_graphics_gradient_radial.eo efl_eolian_files_h = $(efl_eolian_files:%.eo=%.eo.h) efl_eolian_files_c = $(efl_eolian_files:%.eo=%.eo.c) diff --git a/src/lib/efl/Efl.h b/src/lib/efl/Efl.h index df64c18a6a..9f00be363b 100644 --- a/src/lib/efl/Efl.h +++ b/src/lib/efl/Efl.h @@ -128,6 +128,7 @@ typedef enum _Efl_Graphics_Gradient_Spread #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" #endif diff --git a/src/lib/efl/interfaces/efl_graphics_gradient_radial.eo b/src/lib/efl/interfaces/efl_graphics_gradient_radial.eo new file mode 100644 index 0000000000..8fd00c7291 --- /dev/null +++ b/src/lib/efl/interfaces/efl_graphics_gradient_radial.eo @@ -0,0 +1,35 @@ +interface Efl.Graphics.Gradient_Radial (Efl.Graphics.Gradient) +{ + legacy_prefix: null; + properties { + center { + set { + } + get { + } + values { + double x; + double y; + } + } + radius { + set { + } + get { + } + values { + double r; + } + } + focal { + set { + } + get { + } + values { + double x; + double y; + } + } + } +} diff --git a/src/lib/efl/interfaces/efl_interfaces_main.c b/src/lib/efl/interfaces/efl_interfaces_main.c index 95b9ff09e8..eabc1e038d 100644 --- a/src/lib/efl/interfaces/efl_interfaces_main.c +++ b/src/lib/efl/interfaces/efl_interfaces_main.c @@ -14,3 +14,4 @@ #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" diff --git a/src/lib/evas/canvas/evas_vg_gradient_radial.c b/src/lib/evas/canvas/evas_vg_gradient_radial.c index 04ab5bbea0..fecec50902 100644 --- a/src/lib/evas/canvas/evas_vg_gradient_radial.c +++ b/src/lib/evas/canvas/evas_vg_gradient_radial.c @@ -11,51 +11,51 @@ struct _Evas_VG_Gradient_Radial_Data }; void -_evas_vg_gradient_radial_center_set(Eo *obj EINA_UNUSED, - Evas_VG_Gradient_Radial_Data *pd, - double x, double y) +_evas_vg_gradient_radial_efl_graphics_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; } void -_evas_vg_gradient_radial_center_get(Eo *obj EINA_UNUSED, - Evas_VG_Gradient_Radial_Data *pd, - double *x, double *y) +_evas_vg_gradient_radial_efl_graphics_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; } void -_evas_vg_gradient_radial_radius_set(Eo *obj EINA_UNUSED, - Evas_VG_Gradient_Radial_Data *pd, - double r) +_evas_vg_gradient_radial_efl_graphics_gradient_radial_radius_set(Eo *obj EINA_UNUSED, + Evas_VG_Gradient_Radial_Data *pd, + double r) { pd->radius = r; } double -_evas_vg_gradient_radial_radius_get(Eo *obj EINA_UNUSED, - Evas_VG_Gradient_Radial_Data *pd) +_evas_vg_gradient_radial_efl_graphics_gradient_radial_radius_get(Eo *obj EINA_UNUSED, + Evas_VG_Gradient_Radial_Data *pd) { return pd->radius; } void -_evas_vg_gradient_radial_focal_set(Eo *obj EINA_UNUSED, - Evas_VG_Gradient_Radial_Data *pd, - double x, double y) +_evas_vg_gradient_radial_efl_graphics_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; } void -_evas_vg_gradient_radial_focal_get(Eo *obj EINA_UNUSED, - Evas_VG_Gradient_Radial_Data *pd, - double *x, double *y) +_evas_vg_gradient_radial_efl_graphics_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; diff --git a/src/lib/evas/canvas/evas_vg_gradient_radial.eo b/src/lib/evas/canvas/evas_vg_gradient_radial.eo index 0a7d548346..a6bfe70abd 100644 --- a/src/lib/evas/canvas/evas_vg_gradient_radial.eo +++ b/src/lib/evas/canvas/evas_vg_gradient_radial.eo @@ -1,36 +1,13 @@ -class Evas.VG_Gradient_Radial (Evas.VG_Gradient) +class Evas.VG_Gradient_Radial (Evas.VG_Gradient, Efl.Graphics.Gradient_Radial) { eo_prefix: evas_vg_gradient_radial; legacy_prefix: null; - properties { - center { - set { - } - get { - } - values { - double x; - double y; - } - } - radius { - set { - } - get { - } - values { - double r; - } - } - focal { - set { - } - get { - } - values { - double x; - double y; - } - } + 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; } } From 6f3fd4ac81cee9db71be0317b39cd58f608fce06 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:15:39 +0200 Subject: [PATCH 030/251] ector: add linear and radial gradial renderer to Ector. --- src/Makefile_Ector.am | 8 ++- src/lib/ector/ector_renderer.h | 3 + .../ector/ector_renderer_gradient_linear.c | 54 ++++++++++++++ .../ector/ector_renderer_gradient_linear.eo | 11 +++ .../ector/ector_renderer_gradient_radial.c | 71 +++++++++++++++++++ .../ector/ector_renderer_gradient_radial.eo | 13 ++++ 6 files changed, 158 insertions(+), 2 deletions(-) create mode 100644 src/lib/ector/ector_renderer_gradient_linear.c create mode 100644 src/lib/ector/ector_renderer_gradient_linear.eo create mode 100644 src/lib/ector/ector_renderer_gradient_radial.c create mode 100644 src/lib/ector/ector_renderer_gradient_radial.eo diff --git a/src/Makefile_Ector.am b/src/Makefile_Ector.am index 9eba5d75e1..1bbd35adc4 100644 --- a/src/Makefile_Ector.am +++ b/src/Makefile_Ector.am @@ -4,7 +4,9 @@ ector_eolian_files = \ lib/ector/ector_surface.eo \ lib/ector/ector_renderer_base.eo \ lib/ector/ector_renderer_shape.eo \ - lib/ector/ector_renderer_gradient.eo + lib/ector/ector_renderer_gradient.eo \ + lib/ector/ector_renderer_gradient_radial.eo \ + lib/ector/ector_renderer_gradient_linear.eo ector_eolian_c = $(ector_eolian_files:%.eo=%.eo.c) ector_eolian_h = $(ector_eolian_files:%.eo=%.eo.h) @@ -27,7 +29,9 @@ lib_ector_libector_la_SOURCES = \ lib/ector/ector_main.c \ lib/ector/ector_renderer_shape.c \ lib/ector/ector_renderer_base.c \ -lib/ector/ector_renderer_gradient.c +lib/ector/ector_renderer_gradient.c \ +lib/ector/ector_renderer_gradient_radial.c \ +lib/ector/ector_renderer_gradient_linear.c lib_ector_libector_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl \ @ECTOR_CFLAGS@ \ diff --git a/src/lib/ector/ector_renderer.h b/src/lib/ector/ector_renderer.h index 5fc674a5c9..4901eb1d10 100644 --- a/src/lib/ector/ector_renderer.h +++ b/src/lib/ector/ector_renderer.h @@ -3,5 +3,8 @@ #include "ector_renderer_base.eo.h" #include "ector_renderer_shape.eo.h" +#include "ector_renderer_gradient.eo.h" +#include "ector_renderer_gradient_linear.eo.h" +#include "ector_renderer_gradient_radial.eo.h" #endif diff --git a/src/lib/ector/ector_renderer_gradient_linear.c b/src/lib/ector/ector_renderer_gradient_linear.c new file mode 100644 index 0000000000..5ab442dc18 --- /dev/null +++ b/src/lib/ector/ector_renderer_gradient_linear.c @@ -0,0 +1,54 @@ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include + +#include "ector_private.h" + +typedef struct _Ector_Renderer_Gradient_Linear_Data Ector_Renderer_Gradient_Linear_Data; +struct _Ector_Renderer_Gradient_Linear_Data +{ + struct { + double x, y; + } start, end; +}; + +void +_ector_renderer_gradient_linear_efl_graphics_gradient_linear_start_set(Eo *obj EINA_UNUSED, + Ector_Renderer_Gradient_Linear_Data *pd, + double x, double y) +{ + pd->start.x = x; + pd->start.y = y; +} + +void +_ector_renderer_gradient_linear_efl_graphics_gradient_linear_start_get(Eo *obj EINA_UNUSED, + Ector_Renderer_Gradient_Linear_Data *pd, + double *x, double *y) +{ + if (x) *x = pd->start.x; + if (y) *y = pd->start.y; +} + +void +_ector_renderer_gradient_linear_efl_graphics_gradient_linear_end_set(Eo *obj EINA_UNUSED, + Ector_Renderer_Gradient_Linear_Data *pd, + double x, double y) +{ + pd->end.x = x; + pd->end.y = y; +} + +void +_ector_renderer_gradient_linear_efl_graphics_gradient_linear_end_get(Eo *obj EINA_UNUSED, + Ector_Renderer_Gradient_Linear_Data *pd, + double *x, double *y) +{ + if (x) *x = pd->end.x; + if (y) *y = pd->end.y; +} + +#include "ector_renderer_gradient_linear.eo.c" diff --git a/src/lib/ector/ector_renderer_gradient_linear.eo b/src/lib/ector/ector_renderer_gradient_linear.eo new file mode 100644 index 0000000000..fbe3fef5fd --- /dev/null +++ b/src/lib/ector/ector_renderer_gradient_linear.eo @@ -0,0 +1,11 @@ +abstract Ector.Renderer.Gradient_Linear (Ector.Renderer.Gradient, Efl.Graphics.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; + } +} diff --git a/src/lib/ector/ector_renderer_gradient_radial.c b/src/lib/ector/ector_renderer_gradient_radial.c new file mode 100644 index 0000000000..d813585701 --- /dev/null +++ b/src/lib/ector/ector_renderer_gradient_radial.c @@ -0,0 +1,71 @@ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include + +#include "ector_private.h" + +typedef struct _Ector_Renderer_Gradient_Radial_Data Ector_Renderer_Gradient_Radial_Data; +struct _Ector_Renderer_Gradient_Radial_Data +{ + struct { + double x, y; + } radial, focal; + double radius; +}; + +void +_ector_renderer_gradient_radial_efl_graphics_gradient_radial_center_set(Eo *obj EINA_UNUSED, + Ector_Renderer_Gradient_Radial_Data *pd, + double x, double y) +{ + pd->radial.x = x; + pd->radial.y = y; +} + +void +_ector_renderer_gradient_radial_efl_graphics_gradient_radial_center_get(Eo *obj EINA_UNUSED, + Ector_Renderer_Gradient_Radial_Data *pd, + double *x, double *y) +{ + if (x) *x = pd->radial.x; + if (y) *y = pd->radial.y; +} + +void +_ector_renderer_gradient_radial_efl_graphics_gradient_radial_radius_set(Eo *obj EINA_UNUSED, + Ector_Renderer_Gradient_Radial_Data *pd, + double r) +{ + pd->radius = r; +} + +double +_ector_renderer_gradient_radial_efl_graphics_gradient_radial_radius_get(Eo *obj EINA_UNUSED, + Ector_Renderer_Gradient_Radial_Data *pd) +{ + return pd->radius; +} + + +void +_ector_renderer_gradient_radial_efl_graphics_gradient_radial_focal_set(Eo *obj EINA_UNUSED, + Ector_Renderer_Gradient_Radial_Data *pd, + double x, double y) +{ + pd->focal.x = x; + pd->focal.y = y; +} + +void +_ector_renderer_gradient_radial_efl_graphics_gradient_radial_focal_get(Eo *obj EINA_UNUSED, + Ector_Renderer_Gradient_Radial_Data *pd, + double *x, double *y) +{ + if (x) *x = pd->focal.x; + if (y) *y = pd->focal.y; +} + +#include "ector_renderer_gradient_radial.eo.c" diff --git a/src/lib/ector/ector_renderer_gradient_radial.eo b/src/lib/ector/ector_renderer_gradient_radial.eo new file mode 100644 index 0000000000..0067de44e3 --- /dev/null +++ b/src/lib/ector/ector_renderer_gradient_radial.eo @@ -0,0 +1,13 @@ +abstract Ector.Renderer.Gradient_Radial (Ector.Renderer.Gradient, Efl.Graphics.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; + } +} From 0f27e887e4a6f94b9d708cb2b0fd495496907d76 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:15:40 +0200 Subject: [PATCH 031/251] evas: make the interface part of the Generic name space. This should enable having multiple backend that will use another namespace instead of Generic. --- src/lib/evas/canvas/evas_object_vg.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/lib/evas/canvas/evas_object_vg.c b/src/lib/evas/canvas/evas_object_vg.c index 8ac8fe90af..07bf19d8b9 100644 --- a/src/lib/evas/canvas/evas_object_vg.c +++ b/src/lib/evas/canvas/evas_object_vg.c @@ -75,6 +75,9 @@ evas_object_vg_add(Evas *e) return NULL; MAGIC_CHECK_END(); Evas_Object *eo_obj = eo_add(MY_CLASS, e); + + // Ask backend to return the main Ector_Surface + return eo_obj; } @@ -118,6 +121,13 @@ evas_object_vg_render(Evas_Object *eo_obj EINA_UNUSED, void *output EINA_UNUSED, void *context EINA_UNUSED, void *surface EINA_UNUSED, int x EINA_UNUSED, int y EINA_UNUSED, Eina_Bool do_async EINA_UNUSED) { + // FIXME: Set context (that should affect Ector_Surface) and + // then call Ector_Renderer render from bottom to top. Get the + // Ector_Surface that match the output from Evas engine API. + // It is a requirement that you can reparent an Ector_Renderer + // to another Ector_Surface as long as that Ector_Surface is a + // child of the main Ector_Surface (necessary for Evas_Map). + /* render object to surface with context, and offxet by x,y */ /* obj->layer->evas->engine.func->context_color_set(output, */ /* context, */ @@ -139,8 +149,6 @@ evas_object_vg_render(Evas_Object *eo_obj EINA_UNUSED, /* obj->cur->geometry.w, */ /* obj->cur->geometry.h, */ /* do_async); */ - // FIXME: I guess I should create an image, get the pixels data and - // start using that for Cairo. } static void @@ -150,7 +158,7 @@ evas_object_vg_render_pre(Evas_Object *eo_obj, { int is_v, was_v; - // FIXME: Later on start doing precalc of span and stuff for all shape. + // FIXME: call all modified Ector_Renderer prepare fct /* dont pre-render the obj twice! */ if (obj->pre_render_done) return; From 272967afe5a64c8f5a0b208a230c31a3d90ee180 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:15:41 +0200 Subject: [PATCH 032/251] ector: move all interface to be in the Generic namespace. This will enable the possibility to have many implementation for the backend. Will come first Cairo, followed by Software and GL one day. --- src/Makefile_Ector.am | 12 ++-- ...or_surface.eo => ector_generic_surface.eo} | 2 +- src/lib/ector/ector_renderer.h | 10 ++-- src/lib/ector/ector_renderer_base.c | 38 ++++++------ ...base.eo => ector_renderer_generic_base.eo} | 2 +- ....eo => ector_renderer_generic_gradient.eo} | 2 +- ...ector_renderer_generic_gradient_linear.eo} | 2 +- ...ector_renderer_generic_gradient_radial.eo} | 2 +- ...ape.eo => ector_renderer_generic_shape.eo} | 3 +- src/lib/ector/ector_renderer_gradient.c | 14 ++--- .../ector/ector_renderer_gradient_linear.c | 14 ++--- .../ector/ector_renderer_gradient_radial.c | 18 +++--- src/lib/ector/ector_renderer_shape.c | 59 ++++++++----------- src/lib/ector/ector_surface.h | 2 +- 14 files changed, 86 insertions(+), 94 deletions(-) rename src/lib/ector/{ector_surface.eo => ector_generic_surface.eo} (94%) rename src/lib/ector/{ector_renderer_base.eo => ector_renderer_generic_base.eo} (98%) rename src/lib/ector/{ector_renderer_gradient.eo => ector_renderer_generic_gradient.eo} (72%) rename src/lib/ector/{ector_renderer_gradient_linear.eo => ector_renderer_generic_gradient_linear.eo} (71%) rename src/lib/ector/{ector_renderer_gradient_radial.eo => ector_renderer_generic_gradient_radial.eo} (77%) rename src/lib/ector/{ector_renderer_shape.eo => ector_renderer_generic_shape.eo} (88%) diff --git a/src/Makefile_Ector.am b/src/Makefile_Ector.am index 1bbd35adc4..f907ee17d1 100644 --- a/src/Makefile_Ector.am +++ b/src/Makefile_Ector.am @@ -1,12 +1,12 @@ ### Library ector_eolian_files = \ - lib/ector/ector_surface.eo \ - lib/ector/ector_renderer_base.eo \ - lib/ector/ector_renderer_shape.eo \ - lib/ector/ector_renderer_gradient.eo \ - lib/ector/ector_renderer_gradient_radial.eo \ - lib/ector/ector_renderer_gradient_linear.eo + lib/ector/ector_generic_surface.eo \ + lib/ector/ector_renderer_generic_base.eo \ + lib/ector/ector_renderer_generic_shape.eo \ + lib/ector/ector_renderer_generic_gradient.eo \ + lib/ector/ector_renderer_generic_gradient_radial.eo \ + lib/ector/ector_renderer_generic_gradient_linear.eo ector_eolian_c = $(ector_eolian_files:%.eo=%.eo.c) ector_eolian_h = $(ector_eolian_files:%.eo=%.eo.h) diff --git a/src/lib/ector/ector_surface.eo b/src/lib/ector/ector_generic_surface.eo similarity index 94% rename from src/lib/ector/ector_surface.eo rename to src/lib/ector/ector_generic_surface.eo index 36dd9981a2..c852943843 100644 --- a/src/lib/ector/ector_surface.eo +++ b/src/lib/ector/ector_generic_surface.eo @@ -1,4 +1,4 @@ -abstract Ector.Surface (Eo.Base) +abstract Ector.Generic.Surface (Eo.Base) { eo_prefix: ector_surface; properties { diff --git a/src/lib/ector/ector_renderer.h b/src/lib/ector/ector_renderer.h index 4901eb1d10..4c69a41cce 100644 --- a/src/lib/ector/ector_renderer.h +++ b/src/lib/ector/ector_renderer.h @@ -1,10 +1,10 @@ #ifndef ECTOR_RENDERER_H #define ECTOR_RENDERER_H -#include "ector_renderer_base.eo.h" -#include "ector_renderer_shape.eo.h" -#include "ector_renderer_gradient.eo.h" -#include "ector_renderer_gradient_linear.eo.h" -#include "ector_renderer_gradient_radial.eo.h" +#include "ector_renderer_generic_base.eo.h" +#include "ector_renderer_generic_shape.eo.h" +#include "ector_renderer_generic_gradient.eo.h" +#include "ector_renderer_generic_gradient_linear.eo.h" +#include "ector_renderer_generic_gradient_radial.eo.h" #endif diff --git a/src/lib/ector/ector_renderer_base.c b/src/lib/ector/ector_renderer_base.c index b39b7372e2..e2a88d25d7 100644 --- a/src/lib/ector/ector_renderer_base.c +++ b/src/lib/ector/ector_renderer_base.c @@ -7,8 +7,8 @@ #include "ector_private.h" -typedef struct _Ector_Renderer_Base_Data Ector_Renderer_Base_Data; -struct _Ector_Renderer_Base_Data +typedef struct _Ector_Renderer_Generic_Base_Data Ector_Renderer_Generic_Base_Data; +struct _Ector_Renderer_Generic_Base_Data { Eina_Matrix3 *m; @@ -29,7 +29,7 @@ struct _Ector_Renderer_Base_Data void _ector_renderer_base_transformation_set(Eo *obj EINA_UNUSED, - Ector_Renderer_Base_Data *pd, + Ector_Renderer_Generic_Base_Data *pd, const Eina_Matrix3 *m) { Eina_Matrix3 *tmp = pd->m; @@ -53,14 +53,14 @@ _ector_renderer_base_transformation_set(Eo *obj EINA_UNUSED, const Eina_Matrix3 * _ector_renderer_base_transformation_get(Eo *obj EINA_UNUSED, - Ector_Renderer_Base_Data *pd) + Ector_Renderer_Generic_Base_Data *pd) { return pd->m; } void _ector_renderer_base_origin_set(Eo *obj EINA_UNUSED, - Ector_Renderer_Base_Data *pd, + Ector_Renderer_Generic_Base_Data *pd, double x, double y) { pd->origin.x = x; @@ -69,7 +69,7 @@ _ector_renderer_base_origin_set(Eo *obj EINA_UNUSED, void _ector_renderer_base_origin_get(Eo *obj EINA_UNUSED, - Ector_Renderer_Base_Data *pd, + Ector_Renderer_Generic_Base_Data *pd, double *x, double *y) { if (x) *x = pd->origin.x; @@ -78,7 +78,7 @@ _ector_renderer_base_origin_get(Eo *obj EINA_UNUSED, void _ector_renderer_base_visibility_set(Eo *obj EINA_UNUSED, - Ector_Renderer_Base_Data *pd, + Ector_Renderer_Generic_Base_Data *pd, Eina_Bool v) { pd->visibility = v; @@ -86,14 +86,14 @@ _ector_renderer_base_visibility_set(Eo *obj EINA_UNUSED, Eina_Bool _ector_renderer_base_visibility_get(Eo *obj EINA_UNUSED, - Ector_Renderer_Base_Data *pd) + Ector_Renderer_Generic_Base_Data *pd) { return pd->visibility; } void _ector_renderer_base_color_set(Eo *obj EINA_UNUSED, - Ector_Renderer_Base_Data *pd, + Ector_Renderer_Generic_Base_Data *pd, int r, int g, int b, int a) { pd->color.r = r; @@ -104,7 +104,7 @@ _ector_renderer_base_color_set(Eo *obj EINA_UNUSED, void _ector_renderer_base_color_get(Eo *obj EINA_UNUSED, - Ector_Renderer_Base_Data *pd, + Ector_Renderer_Generic_Base_Data *pd, int *r, int *g, int *b, int *a) { if (r) *r = pd->color.r; @@ -115,7 +115,7 @@ _ector_renderer_base_color_get(Eo *obj EINA_UNUSED, void _ector_renderer_base_mask_set(Eo *obj EINA_UNUSED, - Ector_Renderer_Base_Data *pd, + Ector_Renderer_Generic_Base_Data *pd, Ector_Renderer *r) { _ector_renderer_replace(&pd->mask, r); @@ -123,14 +123,14 @@ _ector_renderer_base_mask_set(Eo *obj EINA_UNUSED, Ector_Renderer * _ector_renderer_base_mask_get(Eo *obj EINA_UNUSED, - Ector_Renderer_Base_Data *pd) + Ector_Renderer_Generic_Base_Data *pd) { return pd->mask; } void _ector_renderer_base_quality_set(Eo *obj EINA_UNUSED, - Ector_Renderer_Base_Data *pd, + Ector_Renderer_Generic_Base_Data *pd, Ector_Quality q) { pd->q = q; @@ -138,33 +138,33 @@ _ector_renderer_base_quality_set(Eo *obj EINA_UNUSED, Ector_Quality _ector_renderer_base_quality_get(Eo *obj EINA_UNUSED, - Ector_Renderer_Base_Data *pd) + Ector_Renderer_Generic_Base_Data *pd) { return pd->q; } Eina_Bool -_ector_renderer_base_bounds_get(Eo *obj, Ector_Renderer_Base_Data *pd, +_ector_renderer_base_bounds_get(Eo *obj, Ector_Renderer_Generic_Base_Data *pd, Eina_Rectangle **r) { } Eina_Bool -_ector_renderer_base_draw(Eo *obj, Ector_Renderer_Base_Data *pd, +_ector_renderer_base_draw(Eo *obj, Ector_Renderer_Generic_Base_Data *pd, Ector_Surface *s, Ector_Rop op, Eina_Array *clips, int x, int y) { } Eina_Bool -_ector_renderer_base_prepare(Eo *obj, Ector_Renderer_Base_Data *pd, +_ector_renderer_base_prepare(Eo *obj, Ector_Renderer_Generic_Base_Data *pd, Ector_Surface *s) { } Eina_Bool -_ector_renderer_base_done(Eo *obj, Ector_Renderer_Base_Data *pd) +_ector_renderer_base_done(Eo *obj, Ector_Renderer_Generic_Base_Data *pd) { } -#include "ector_renderer_base.eo.c" +#include "ector_renderer_generic_base.eo.c" diff --git a/src/lib/ector/ector_renderer_base.eo b/src/lib/ector/ector_renderer_generic_base.eo similarity index 98% rename from src/lib/ector/ector_renderer_base.eo rename to src/lib/ector/ector_renderer_generic_base.eo index 1e2e9eab8f..4b051b4ba1 100644 --- a/src/lib/ector/ector_renderer_base.eo +++ b/src/lib/ector/ector_renderer_generic_base.eo @@ -1,4 +1,4 @@ -abstract Ector.Renderer.Base (Eo.Base) +abstract Ector.Renderer.Generic.Base (Eo.Base) { eo_prefix: ector_renderer; legacy_prefix: null; diff --git a/src/lib/ector/ector_renderer_gradient.eo b/src/lib/ector/ector_renderer_generic_gradient.eo similarity index 72% rename from src/lib/ector/ector_renderer_gradient.eo rename to src/lib/ector/ector_renderer_generic_gradient.eo index d513b5490d..bd6a9bb70a 100644 --- a/src/lib/ector/ector_renderer_gradient.eo +++ b/src/lib/ector/ector_renderer_generic_gradient.eo @@ -1,4 +1,4 @@ -abstract Ector.Renderer.Gradient (Ector.Renderer.Base, Efl.Graphics.Gradient) +abstract Ector.Renderer.Generic.Gradient (Ector.Renderer.Generic.Base, Efl.Graphics.Gradient) { eo_prefix: ector_renderer_gradient; legacy_prefix: null; diff --git a/src/lib/ector/ector_renderer_gradient_linear.eo b/src/lib/ector/ector_renderer_generic_gradient_linear.eo similarity index 71% rename from src/lib/ector/ector_renderer_gradient_linear.eo rename to src/lib/ector/ector_renderer_generic_gradient_linear.eo index fbe3fef5fd..45bb5e3729 100644 --- a/src/lib/ector/ector_renderer_gradient_linear.eo +++ b/src/lib/ector/ector_renderer_generic_gradient_linear.eo @@ -1,4 +1,4 @@ -abstract Ector.Renderer.Gradient_Linear (Ector.Renderer.Gradient, Efl.Graphics.Gradient_Linear) +abstract Ector.Renderer.Generic.Gradient_Linear (Ector.Renderer.Generic.Gradient, Efl.Graphics.Gradient_Linear) { eo_prefix: ector_renderer_gradient_linear; legacy_prefix: null; diff --git a/src/lib/ector/ector_renderer_gradient_radial.eo b/src/lib/ector/ector_renderer_generic_gradient_radial.eo similarity index 77% rename from src/lib/ector/ector_renderer_gradient_radial.eo rename to src/lib/ector/ector_renderer_generic_gradient_radial.eo index 0067de44e3..50c35bcdb4 100644 --- a/src/lib/ector/ector_renderer_gradient_radial.eo +++ b/src/lib/ector/ector_renderer_generic_gradient_radial.eo @@ -1,4 +1,4 @@ -abstract Ector.Renderer.Gradient_Radial (Ector.Renderer.Gradient, Efl.Graphics.Gradient_Radial) +abstract Ector.Renderer.Generic.Gradient_Radial (Ector.Renderer.Generic.Gradient, Efl.Graphics.Gradient_Radial) { eo_prefix: ector_renderer_gradient_radial; legacy_prefix: null; diff --git a/src/lib/ector/ector_renderer_shape.eo b/src/lib/ector/ector_renderer_generic_shape.eo similarity index 88% rename from src/lib/ector/ector_renderer_shape.eo rename to src/lib/ector/ector_renderer_generic_shape.eo index 4cd46016e0..20cad35771 100644 --- a/src/lib/ector/ector_renderer_shape.eo +++ b/src/lib/ector/ector_renderer_generic_shape.eo @@ -1,4 +1,4 @@ -class Ector.Renderer.Shape (Ector.Renderer.Base, Efl.Graphics.Shape) +class Ector.Renderer.Generic.Shape (Ector.Renderer.Generic.Base, Efl.Graphics.Shape) { eo_prefix: ector_renderer_shape; legacy_prefix: null; @@ -40,7 +40,6 @@ class Ector.Renderer.Shape (Ector.Renderer.Base, Efl.Graphics.Shape) Efl.Graphics.Shape.stroke_cap; Efl.Graphics.Shape.stroke_join; Efl.Graphics.Shape.path_set; - Ector.Renderer.Base.prepare; Eo.Base.constructor; Eo.Base.destructor; } diff --git a/src/lib/ector/ector_renderer_gradient.c b/src/lib/ector/ector_renderer_gradient.c index 7de90413af..610fb93809 100644 --- a/src/lib/ector/ector_renderer_gradient.c +++ b/src/lib/ector/ector_renderer_gradient.c @@ -7,14 +7,14 @@ #include "ector_private.h" -typedef struct _Ector_Renderer_Gradient_Data Ector_Renderer_Gradient_Data; -struct _Ector_Renderer_Gradient_Data +typedef struct _Ector_Renderer_Generic_Gradient_Data Ector_Renderer_Generic_Gradient_Data; +struct _Ector_Renderer_Generic_Gradient_Data { }; void _ector_renderer_gradient_efl_graphics_gradient_stop_set(Eo *obj, - Ector_Renderer_Gradient_Data *pd, + Ector_Renderer_Generic_Gradient_Data *pd, const Efl_Graphics_Gradient_Stop *colors, unsigned int length) { @@ -22,7 +22,7 @@ _ector_renderer_gradient_efl_graphics_gradient_stop_set(Eo *obj, void _ector_renderer_gradient_efl_graphics_gradient_stop_get(Eo *obj, - Ector_Renderer_Gradient_Data *pd, + Ector_Renderer_Generic_Gradient_Data *pd, const Efl_Graphics_Gradient_Stop **colors, unsigned int *length) { @@ -30,16 +30,16 @@ _ector_renderer_gradient_efl_graphics_gradient_stop_get(Eo *obj, void _ector_renderer_gradient_efl_graphics_gradient_spread_set(Eo *obj, - Ector_Renderer_Gradient_Data *pd, + Ector_Renderer_Generic_Gradient_Data *pd, Efl_Graphics_Gradient_Spread s) { } Efl_Graphics_Gradient_Spread _ector_renderer_gradient_efl_graphics_gradient_spread_get(Eo *obj, - Ector_Renderer_Gradient_Data *pd) + Ector_Renderer_Generic_Gradient_Data *pd) { } -#include "ector_renderer_gradient.eo.c" +#include "ector_renderer_generic_gradient.eo.c" diff --git a/src/lib/ector/ector_renderer_gradient_linear.c b/src/lib/ector/ector_renderer_gradient_linear.c index 5ab442dc18..21412ceb59 100644 --- a/src/lib/ector/ector_renderer_gradient_linear.c +++ b/src/lib/ector/ector_renderer_gradient_linear.c @@ -7,8 +7,8 @@ #include "ector_private.h" -typedef struct _Ector_Renderer_Gradient_Linear_Data Ector_Renderer_Gradient_Linear_Data; -struct _Ector_Renderer_Gradient_Linear_Data +typedef struct _Ector_Renderer_Generic_Gradient_Linear_Data Ector_Renderer_Generic_Gradient_Linear_Data; +struct _Ector_Renderer_Generic_Gradient_Linear_Data { struct { double x, y; @@ -17,7 +17,7 @@ struct _Ector_Renderer_Gradient_Linear_Data void _ector_renderer_gradient_linear_efl_graphics_gradient_linear_start_set(Eo *obj EINA_UNUSED, - Ector_Renderer_Gradient_Linear_Data *pd, + Ector_Renderer_Generic_Gradient_Linear_Data *pd, double x, double y) { pd->start.x = x; @@ -26,7 +26,7 @@ _ector_renderer_gradient_linear_efl_graphics_gradient_linear_start_set(Eo *obj E void _ector_renderer_gradient_linear_efl_graphics_gradient_linear_start_get(Eo *obj EINA_UNUSED, - Ector_Renderer_Gradient_Linear_Data *pd, + Ector_Renderer_Generic_Gradient_Linear_Data *pd, double *x, double *y) { if (x) *x = pd->start.x; @@ -35,7 +35,7 @@ _ector_renderer_gradient_linear_efl_graphics_gradient_linear_start_get(Eo *obj E void _ector_renderer_gradient_linear_efl_graphics_gradient_linear_end_set(Eo *obj EINA_UNUSED, - Ector_Renderer_Gradient_Linear_Data *pd, + Ector_Renderer_Generic_Gradient_Linear_Data *pd, double x, double y) { pd->end.x = x; @@ -44,11 +44,11 @@ _ector_renderer_gradient_linear_efl_graphics_gradient_linear_end_set(Eo *obj EIN void _ector_renderer_gradient_linear_efl_graphics_gradient_linear_end_get(Eo *obj EINA_UNUSED, - Ector_Renderer_Gradient_Linear_Data *pd, + Ector_Renderer_Generic_Gradient_Linear_Data *pd, double *x, double *y) { if (x) *x = pd->end.x; if (y) *y = pd->end.y; } -#include "ector_renderer_gradient_linear.eo.c" +#include "ector_renderer_generic_gradient_linear.eo.c" diff --git a/src/lib/ector/ector_renderer_gradient_radial.c b/src/lib/ector/ector_renderer_gradient_radial.c index d813585701..26d3b5dc80 100644 --- a/src/lib/ector/ector_renderer_gradient_radial.c +++ b/src/lib/ector/ector_renderer_gradient_radial.c @@ -7,8 +7,8 @@ #include "ector_private.h" -typedef struct _Ector_Renderer_Gradient_Radial_Data Ector_Renderer_Gradient_Radial_Data; -struct _Ector_Renderer_Gradient_Radial_Data +typedef struct _Ector_Renderer_Generic_Gradient_Radial_Data Ector_Renderer_Generic_Gradient_Radial_Data; +struct _Ector_Renderer_Generic_Gradient_Radial_Data { struct { double x, y; @@ -18,7 +18,7 @@ struct _Ector_Renderer_Gradient_Radial_Data void _ector_renderer_gradient_radial_efl_graphics_gradient_radial_center_set(Eo *obj EINA_UNUSED, - Ector_Renderer_Gradient_Radial_Data *pd, + Ector_Renderer_Generic_Gradient_Radial_Data *pd, double x, double y) { pd->radial.x = x; @@ -27,7 +27,7 @@ _ector_renderer_gradient_radial_efl_graphics_gradient_radial_center_set(Eo *obj void _ector_renderer_gradient_radial_efl_graphics_gradient_radial_center_get(Eo *obj EINA_UNUSED, - Ector_Renderer_Gradient_Radial_Data *pd, + Ector_Renderer_Generic_Gradient_Radial_Data *pd, double *x, double *y) { if (x) *x = pd->radial.x; @@ -36,7 +36,7 @@ _ector_renderer_gradient_radial_efl_graphics_gradient_radial_center_get(Eo *obj void _ector_renderer_gradient_radial_efl_graphics_gradient_radial_radius_set(Eo *obj EINA_UNUSED, - Ector_Renderer_Gradient_Radial_Data *pd, + Ector_Renderer_Generic_Gradient_Radial_Data *pd, double r) { pd->radius = r; @@ -44,7 +44,7 @@ _ector_renderer_gradient_radial_efl_graphics_gradient_radial_radius_set(Eo *obj double _ector_renderer_gradient_radial_efl_graphics_gradient_radial_radius_get(Eo *obj EINA_UNUSED, - Ector_Renderer_Gradient_Radial_Data *pd) + Ector_Renderer_Generic_Gradient_Radial_Data *pd) { return pd->radius; } @@ -52,7 +52,7 @@ _ector_renderer_gradient_radial_efl_graphics_gradient_radial_radius_get(Eo *obj void _ector_renderer_gradient_radial_efl_graphics_gradient_radial_focal_set(Eo *obj EINA_UNUSED, - Ector_Renderer_Gradient_Radial_Data *pd, + Ector_Renderer_Generic_Gradient_Radial_Data *pd, double x, double y) { pd->focal.x = x; @@ -61,11 +61,11 @@ _ector_renderer_gradient_radial_efl_graphics_gradient_radial_focal_set(Eo *obj E void _ector_renderer_gradient_radial_efl_graphics_gradient_radial_focal_get(Eo *obj EINA_UNUSED, - Ector_Renderer_Gradient_Radial_Data *pd, + Ector_Renderer_Generic_Gradient_Radial_Data *pd, double *x, double *y) { if (x) *x = pd->focal.x; if (y) *y = pd->focal.y; } -#include "ector_renderer_gradient_radial.eo.c" +#include "ector_renderer_generic_gradient_radial.eo.c" diff --git a/src/lib/ector/ector_renderer_shape.c b/src/lib/ector/ector_renderer_shape.c index 6957210e93..449b8e5bc8 100644 --- a/src/lib/ector/ector_renderer_shape.c +++ b/src/lib/ector/ector_renderer_shape.c @@ -7,8 +7,8 @@ #include "ector_private.h" -typedef struct _Ector_Renderer_Shape_Data Ector_Renderer_Shape_Data; -struct _Ector_Renderer_Shape_Data +typedef struct _Ector_Renderer_Generic_Shape_Data Ector_Renderer_Generic_Shape_Data; +struct _Ector_Renderer_Generic_Shape_Data { Ector_Renderer *fill; struct { @@ -33,7 +33,7 @@ struct _Ector_Renderer_Shape_Data void _ector_renderer_shape_fill_set(Eo *obj EINA_UNUSED, - Ector_Renderer_Shape_Data *pd, + Ector_Renderer_Generic_Shape_Data *pd, const Ector_Renderer *r) { _ector_renderer_replace(&pd->fill, r); @@ -41,14 +41,14 @@ _ector_renderer_shape_fill_set(Eo *obj EINA_UNUSED, const Ector_Renderer * _ector_renderer_shape_fill_get(Eo *obj EINA_UNUSED, - Ector_Renderer_Shape_Data *pd) + Ector_Renderer_Generic_Shape_Data *pd) { return pd->fill; } void _ector_renderer_shape_stroke_fill_set(Eo *obj EINA_UNUSED, - Ector_Renderer_Shape_Data *pd, + Ector_Renderer_Generic_Shape_Data *pd, const Ector_Renderer *r) { _ector_renderer_replace(&pd->stroke.fill, r); @@ -56,14 +56,14 @@ _ector_renderer_shape_stroke_fill_set(Eo *obj EINA_UNUSED, const Ector_Renderer * _ector_renderer_shape_stroke_fill_get(Eo *obj EINA_UNUSED, - Ector_Renderer_Shape_Data *pd) + Ector_Renderer_Generic_Shape_Data *pd) { return pd->stroke.fill; } void _ector_renderer_shape_stroke_marker_set(Eo *obj EINA_UNUSED, - Ector_Renderer_Shape_Data *pd, + Ector_Renderer_Generic_Shape_Data *pd, const Ector_Renderer *r) { _ector_renderer_replace(&pd->stroke.marker, r); @@ -71,14 +71,14 @@ _ector_renderer_shape_stroke_marker_set(Eo *obj EINA_UNUSED, const Ector_Renderer * _ector_renderer_shape_stroke_marker_get(Eo *obj EINA_UNUSED, - Ector_Renderer_Shape_Data *pd) + Ector_Renderer_Generic_Shape_Data *pd) { return pd->stroke.marker; } void _ector_renderer_shape_efl_graphics_shape_stroke_scale_set(Eo *obj EINA_UNUSED, - Ector_Renderer_Shape_Data *pd, + Ector_Renderer_Generic_Shape_Data *pd, double s) { pd->stroke.scale = s; @@ -86,14 +86,14 @@ _ector_renderer_shape_efl_graphics_shape_stroke_scale_set(Eo *obj EINA_UNUSED, double _ector_renderer_shape_efl_graphics_shape_stroke_scale_get(Eo *obj EINA_UNUSED, - Ector_Renderer_Shape_Data *pd) + Ector_Renderer_Generic_Shape_Data *pd) { return pd->stroke.scale; } void _ector_renderer_shape_efl_graphics_shape_stroke_color_set(Eo *obj EINA_UNUSED, - Ector_Renderer_Shape_Data *pd, + Ector_Renderer_Generic_Shape_Data *pd, int r, int g, int b, int a) { pd->stroke.color.r = r; @@ -105,7 +105,7 @@ _ector_renderer_shape_efl_graphics_shape_stroke_color_set(Eo *obj EINA_UNUSED, void _ector_renderer_shape_efl_graphics_shape_stroke_color_get(Eo *obj EINA_UNUSED, - Ector_Renderer_Shape_Data *pd, + Ector_Renderer_Generic_Shape_Data *pd, int *r, int *g, int *b, int *a) { if (r) *r = pd->stroke.color.r; @@ -116,7 +116,7 @@ _ector_renderer_shape_efl_graphics_shape_stroke_color_get(Eo *obj EINA_UNUSED, void _ector_renderer_shape_efl_graphics_shape_stroke_width_set(Eo *obj EINA_UNUSED, - Ector_Renderer_Shape_Data *pd, + Ector_Renderer_Generic_Shape_Data *pd, double w) { pd->stroke.width = w; @@ -124,14 +124,14 @@ _ector_renderer_shape_efl_graphics_shape_stroke_width_set(Eo *obj EINA_UNUSED, double _ector_renderer_shape_efl_graphics_shape_stroke_width_get(Eo *obj EINA_UNUSED, - Ector_Renderer_Shape_Data *pd) + Ector_Renderer_Generic_Shape_Data *pd) { return pd->stroke.width; } void _ector_renderer_shape_efl_graphics_shape_stroke_location_set(Eo *obj EINA_UNUSED, - Ector_Renderer_Shape_Data *pd, + Ector_Renderer_Generic_Shape_Data *pd, double centered) { pd->stroke.centered = centered; @@ -139,14 +139,14 @@ _ector_renderer_shape_efl_graphics_shape_stroke_location_set(Eo *obj EINA_UNUSED double _ector_renderer_shape_efl_graphics_shape_stroke_location_get(Eo *obj EINA_UNUSED, - Ector_Renderer_Shape_Data *pd) + Ector_Renderer_Generic_Shape_Data *pd) { return pd->stroke.centered; } void _ector_renderer_shape_efl_graphics_shape_stroke_dash_set(Eo *obj EINA_UNUSED, - Ector_Renderer_Shape_Data *pd, + Ector_Renderer_Generic_Shape_Data *pd, const Efl_Graphics_Dash *dash, unsigned int length) { @@ -170,7 +170,7 @@ _ector_renderer_shape_efl_graphics_shape_stroke_dash_set(Eo *obj EINA_UNUSED, void _ector_renderer_shape_efl_graphics_shape_stroke_dash_get(Eo *obj EINA_UNUSED, - Ector_Renderer_Shape_Data *pd, + Ector_Renderer_Generic_Shape_Data *pd, const Efl_Graphics_Dash **dash, unsigned int *length) { @@ -180,7 +180,7 @@ _ector_renderer_shape_efl_graphics_shape_stroke_dash_get(Eo *obj EINA_UNUSED, void _ector_renderer_shape_efl_graphics_shape_stroke_cap_set(Eo *obj EINA_UNUSED, - Ector_Renderer_Shape_Data *pd, + Ector_Renderer_Generic_Shape_Data *pd, Efl_Graphics_Cap c) { pd->stroke.cap = c; @@ -188,14 +188,14 @@ _ector_renderer_shape_efl_graphics_shape_stroke_cap_set(Eo *obj EINA_UNUSED, Efl_Graphics_Cap _ector_renderer_shape_efl_graphics_shape_stroke_cap_get(Eo *obj EINA_UNUSED, - Ector_Renderer_Shape_Data *pd) + Ector_Renderer_Generic_Shape_Data *pd) { return pd->stroke.cap; } void _ector_renderer_shape_efl_graphics_shape_stroke_join_set(Eo *obj EINA_UNUSED, - Ector_Renderer_Shape_Data *pd, + Ector_Renderer_Generic_Shape_Data *pd, Efl_Graphics_Join j) { pd->stroke.join = j; @@ -203,35 +203,28 @@ _ector_renderer_shape_efl_graphics_shape_stroke_join_set(Eo *obj EINA_UNUSED, Efl_Graphics_Join _ector_renderer_shape_efl_graphics_shape_stroke_join_get(Eo *obj EINA_UNUSED, - Ector_Renderer_Shape_Data *pd) + Ector_Renderer_Generic_Shape_Data *pd) { return pd->stroke.join; } Eina_Bool _ector_renderer_shape_efl_graphics_shape_path_set(Eo *obj, - Ector_Renderer_Shape_Data *pd, + Ector_Renderer_Generic_Shape_Data *pd, const Efl_Graphics_Path_Command *op, const double *points) { } -Eina_Bool -_ector_renderer_shape_ector_renderer_base_prepare(Eo *obj, - Ector_Renderer_Shape_Data *pd, - Ector_Surface *s) -{ -} - void _ector_renderer_shape_eo_base_constructor(Eo *obj, - Ector_Renderer_Shape_Data *pd) + Ector_Renderer_Generic_Shape_Data *pd) { } void -_ector_renderer_shape_eo_base_destructor(Eo *obj, Ector_Renderer_Shape_Data *pd) +_ector_renderer_shape_eo_base_destructor(Eo *obj, Ector_Renderer_Generic_Shape_Data *pd) { } -#include "ector_renderer_shape.eo.c" +#include "ector_renderer_generic_shape.eo.c" diff --git a/src/lib/ector/ector_surface.h b/src/lib/ector/ector_surface.h index a1096bd714..424726a235 100644 --- a/src/lib/ector/ector_surface.h +++ b/src/lib/ector/ector_surface.h @@ -1,6 +1,6 @@ #ifndef ECTOR_SURFACE_H #define ECTOR_SURFACE_H -#include "ector_surface.eo.h" +#include "ector_generic_surface.eo.h" #endif From a5f8532e276dfcf6c3ee4cecd574f37512fc008e Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:15:43 +0200 Subject: [PATCH 033/251] ector: make the drawing function virtual as it rely on the backend implementation. --- src/lib/ector/ector_renderer_base.c | 24 -------------------- src/lib/ector/ector_renderer_generic_base.eo | 6 +++++ 2 files changed, 6 insertions(+), 24 deletions(-) diff --git a/src/lib/ector/ector_renderer_base.c b/src/lib/ector/ector_renderer_base.c index e2a88d25d7..92ffaa51cc 100644 --- a/src/lib/ector/ector_renderer_base.c +++ b/src/lib/ector/ector_renderer_base.c @@ -143,28 +143,4 @@ _ector_renderer_base_quality_get(Eo *obj EINA_UNUSED, return pd->q; } -Eina_Bool -_ector_renderer_base_bounds_get(Eo *obj, Ector_Renderer_Generic_Base_Data *pd, - Eina_Rectangle **r) -{ -} - -Eina_Bool -_ector_renderer_base_draw(Eo *obj, Ector_Renderer_Generic_Base_Data *pd, - Ector_Surface *s, Ector_Rop op, Eina_Array *clips, - int x, int y) -{ -} - -Eina_Bool -_ector_renderer_base_prepare(Eo *obj, Ector_Renderer_Generic_Base_Data *pd, - Ector_Surface *s) -{ -} - -Eina_Bool -_ector_renderer_base_done(Eo *obj, Ector_Renderer_Generic_Base_Data *pd) -{ -} - #include "ector_renderer_generic_base.eo.c" diff --git a/src/lib/ector/ector_renderer_generic_base.eo b/src/lib/ector/ector_renderer_generic_base.eo index 4b051b4ba1..ea932500f4 100644 --- a/src/lib/ector/ector_renderer_generic_base.eo +++ b/src/lib/ector/ector_renderer_generic_base.eo @@ -111,4 +111,10 @@ abstract Ector.Renderer.Generic.Base (Eo.Base) return: bool @warn_unused; } } + implements { + @virtual .draw; + @virtual .bounds_get; + @virtual .prepare; + @virtual .done; + } } From 3ada4184d7cd0c1b9d8a843381e418903c6db194 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:18:30 +0200 Subject: [PATCH 034/251] ector: start the implementation of the Generic surface. --- src/Makefile_Ector.am | 1 + src/lib/ector/ector_generic_surface.eo | 3 +- src/lib/ector/ector_surface.c | 42 ++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 src/lib/ector/ector_surface.c diff --git a/src/Makefile_Ector.am b/src/Makefile_Ector.am index f907ee17d1..7b47e31de9 100644 --- a/src/Makefile_Ector.am +++ b/src/Makefile_Ector.am @@ -27,6 +27,7 @@ lib/ector/Ector.h lib_ector_libector_la_SOURCES = \ lib/ector/ector_main.c \ +lib/ector/ector_surface.c \ lib/ector/ector_renderer_shape.c \ lib/ector/ector_renderer_base.c \ lib/ector/ector_renderer_gradient.c \ diff --git a/src/lib/ector/ector_generic_surface.eo b/src/lib/ector/ector_generic_surface.eo index c852943843..18ebd47c60 100644 --- a/src/lib/ector/ector_generic_surface.eo +++ b/src/lib/ector/ector_generic_surface.eo @@ -34,7 +34,6 @@ abstract Ector.Generic.Surface (Eo.Base) } } implements { - @virtual .size.set; - @virtual .size.get; + @virtual .renderer_factory_new; } } diff --git a/src/lib/ector/ector_surface.c b/src/lib/ector/ector_surface.c new file mode 100644 index 0000000000..eda912fffe --- /dev/null +++ b/src/lib/ector/ector_surface.c @@ -0,0 +1,42 @@ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include + +#include "ector_private.h" + +typedef struct _Ector_Generic_Surface_Data Ector_Generic_Surface_Data; +struct _Ector_Generic_Surface_Data +{ +}; + +void +_ector_generic_surface_size_set(Eo *obj, + Ector_Generic_Surface_Data *pd, + int w, int h) +{ +} + +void +_ector_generic_surface_size_get(Eo *obj, + Ector_Generic_Surface_Data *pd, + int *w, int *h) +{ +} + +Eina_Bool +_ector_generic_surface_update_push(Eo *obj, + Ector_Generic_Surface_Data *pd, + const Eina_Rectangle *r, + Ector_Update_Type type) +{ +} + +Eina_Bool +_ector_generic_surface_update_reset(Eo *obj, Ector_Generic_Surface_Data *pd) +{ +} + +#include "ector_generic_surface.eo.c" From 62459acda746a2d3728e4bf31cb9176cb86517e7 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:19:11 +0200 Subject: [PATCH 035/251] ector: start the implementation of a Cairo backend. --- src/Makefile_Ector.am | 7 +++++++ src/lib/ector/cairo/ector_cairo_surface.eo | 7 +++++++ .../cairo/ector_renderer_cairo_gradient_linear.eo | 10 ++++++++++ .../cairo/ector_renderer_cairo_gradient_radial.eo | 10 ++++++++++ src/lib/ector/cairo/ector_renderer_cairo_shape.eo | 10 ++++++++++ 5 files changed, 44 insertions(+) create mode 100644 src/lib/ector/cairo/ector_cairo_surface.eo create mode 100644 src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.eo create mode 100644 src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.eo create mode 100644 src/lib/ector/cairo/ector_renderer_cairo_shape.eo diff --git a/src/Makefile_Ector.am b/src/Makefile_Ector.am index 7b47e31de9..270857a2b2 100644 --- a/src/Makefile_Ector.am +++ b/src/Makefile_Ector.am @@ -8,6 +8,13 @@ ector_eolian_files = \ lib/ector/ector_renderer_generic_gradient_radial.eo \ lib/ector/ector_renderer_generic_gradient_linear.eo +# Handle cairo backend +ector_eolian_files += \ + lib/ector/cairo/ector_cairo_surface.eo \ + lib/ector/cairo/ector_renderer_cairo_shape.eo \ + lib/ector/cairo/ector_renderer_cairo_gradient_linear.eo \ + lib/ector/cairo/ector_renderer_cairo_gradient_radial.eo + ector_eolian_c = $(ector_eolian_files:%.eo=%.eo.c) ector_eolian_h = $(ector_eolian_files:%.eo=%.eo.h) diff --git a/src/lib/ector/cairo/ector_cairo_surface.eo b/src/lib/ector/cairo/ector_cairo_surface.eo new file mode 100644 index 0000000000..08073254a7 --- /dev/null +++ b/src/lib/ector/cairo/ector_cairo_surface.eo @@ -0,0 +1,7 @@ +class Ector.cairo.Surface (Ector.Generic.Surface) +{ + eo_prefix: ector_cairo_surface; + implements { + Ector.Generic.Surface.renderer_factory_new; + } +} diff --git a/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.eo b/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.eo new file mode 100644 index 0000000000..3b25734de7 --- /dev/null +++ b/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.eo @@ -0,0 +1,10 @@ +class Ector.Renderer.Cairo.Gradient_Linear (Ector.Renderer.Generic.Gradient_Linear) +{ + eo_prefix: ector_renderer_cairo_gradient_linear; + legacy_prefix: null; + implements { + Ector.Renderer.Generic.Base.prepare; + Ector.Renderer.Generic.Base.draw; + Ector.Renderer.Generic.Base.done; + } +} diff --git a/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.eo b/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.eo new file mode 100644 index 0000000000..6aeb7507d2 --- /dev/null +++ b/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.eo @@ -0,0 +1,10 @@ +class Ector.Renderer.Cairo.Gradient_Radial (Ector.Renderer.Generic.Gradient_Radial) +{ + eo_prefix: ector_renderer_cairo_gradient_radial; + legacy_prefix: null; + implements { + Ector.Renderer.Generic.Base.prepare; + Ector.Renderer.Generic.Base.draw; + Ector.Renderer.Generic.Base.done; + } +} diff --git a/src/lib/ector/cairo/ector_renderer_cairo_shape.eo b/src/lib/ector/cairo/ector_renderer_cairo_shape.eo new file mode 100644 index 0000000000..d1a8e8c983 --- /dev/null +++ b/src/lib/ector/cairo/ector_renderer_cairo_shape.eo @@ -0,0 +1,10 @@ +class Ector.Renderer.Cairo.Shape (Ector.Renderer.Generic.Shape) +{ + eo_prefix: ector_renderer_cairo_shape; + legacy_prefix: null; + implements { + Ector.Renderer.Generic.Base.prepare; + Ector.Renderer.Generic.Base.draw; + Ector.Renderer.Generic.Base.done; + } +} From 75728e7ffff3c56cd4032f42b354c623ba90e5a8 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:21:48 +0200 Subject: [PATCH 036/251] efl: move PATH manipulation from Evas into Efl interfaces. --- src/Makefile_Efl.am | 10 +- src/lib/efl/Efl.h | 1 + src/lib/efl/interfaces/efl_graphics_utils.c | 230 ++++++++++++++++++++ src/lib/efl/interfaces/efl_graphics_utils.h | 49 +++++ src/lib/evas/canvas/evas_vg_private.h | 4 - src/lib/evas/canvas/evas_vg_utils.c | 225 ------------------- 6 files changed, 288 insertions(+), 231 deletions(-) create mode 100644 src/lib/efl/interfaces/efl_graphics_utils.c create mode 100644 src/lib/efl/interfaces/efl_graphics_utils.h diff --git a/src/Makefile_Efl.am b/src/Makefile_Efl.am index 0c4d8b9fe8..618069706b 100644 --- a/src/Makefile_Efl.am +++ b/src/Makefile_Efl.am @@ -24,6 +24,7 @@ CLEANFILES += \ EXTRA_DIST += \ lib/efl/Efl_Config.h \ lib/efl/Efl.h \ + lib/efl/interfaces/efl_graphics_utils.h \ $(efl_eolian_files) efleolianfilesdir = $(datadir)/eolian/include/efl-@VMAJ@ @@ -31,7 +32,10 @@ efleolianfiles_DATA = $(efl_eolian_files) lib_LTLIBRARIES += lib/efl/libefl.la -lib_efl_libefl_la_SOURCES = lib/efl/interfaces/efl_interfaces_main.c +lib_efl_libefl_la_SOURCES = \ +lib/efl/interfaces/efl_interfaces_main.c \ +lib/efl/interfaces/efl_graphics_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@ lib_efl_libefl_la_DEPENDENCIES = @EFL_INTERNAL_LIBS@ @@ -43,7 +47,9 @@ dist_installed_eflheaders_DATA = \ lib/efl/Efl.h installed_eflinterfacesdir = $(includedir)/efl-@VMAJ@/interfaces -nodist_installed_eflinterfaces_DATA = $(efl_eolian_files_h) +nodist_installed_eflinterfaces_DATA = \ +$(efl_eolian_files_h) \ +lib/efl/interfaces/efl_graphics_utils.h if HAVE_ELUA diff --git a/src/lib/efl/Efl.h b/src/lib/efl/Efl.h index 9f00be363b..bcbea5fbd6 100644 --- a/src/lib/efl/Efl.h +++ b/src/lib/efl/Efl.h @@ -125,6 +125,7 @@ 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" diff --git a/src/lib/efl/interfaces/efl_graphics_utils.c b/src/lib/efl/interfaces/efl_graphics_utils.c new file mode 100644 index 0000000000..5db0252434 --- /dev/null +++ b/src/lib/efl/interfaces/efl_graphics_utils.c @@ -0,0 +1,230 @@ +#ifdef HAVE_CONFIG_H +# include +#endif + +#include + +static 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_QUADRATIC_TO: return 4; + case EFL_GRAPHICS_PATH_COMMAND_TYPE_SQUADRATIC_TO: return 2; + case EFL_GRAPHICS_PATH_COMMAND_TYPE_CUBIC_TO: return 6; + case EFL_GRAPHICS_PATH_COMMAND_TYPE_SCUBIC_TO: return 4; + case EFL_GRAPHICS_PATH_COMMAND_TYPE_ARC_TO: return 5; + 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 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 *offset_point; + + if (!efl_graphics_path_grow(EFL_GRAPHICS_PATH_COMMAND_TYPE_QUADRATIC_TO, + commands, points, &offset_point)) + return ; + + offset_point[0] = x; + offset_point[1] = y; + offset_point[2] = ctrl_x; + offset_point[3] = ctrl_y; +} + +EAPI void +efl_graphics_path_append_squadratic_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_SQUADRATIC_TO, + commands, points, &offset_point)) + return ; + + offset_point[0] = x; + offset_point[1] = 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) +{ + 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 *offset_point; + + if (!efl_graphics_path_grow(EFL_GRAPHICS_PATH_COMMAND_TYPE_SCUBIC_TO, + commands, points, &offset_point)) + return ; + + offset_point[0] = x; + offset_point[1] = y; + offset_point[2] = ctrl_x; + offset_point[3] = 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) +{ + double *offset_point; + + if (!efl_graphics_path_grow(EFL_GRAPHICS_PATH_COMMAND_TYPE_ARC_TO, + commands, points, &offset_point)) + return ; + + offset_point[0] = x; + offset_point[1] = y; + offset_point[2] = rx; + offset_point[3] = ry; + offset_point[4] = 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_ARC_TO, + 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); + efl_graphics_path_append_arc_to(commands, points, x, y + radius, radius, radius, 0); + efl_graphics_path_append_arc_to(commands, points, x - radius, y, radius, radius, 0); + efl_graphics_path_append_arc_to(commands, points, x, y - radius, radius, radius, 0); +} diff --git a/src/lib/efl/interfaces/efl_graphics_utils.h b/src/lib/efl/interfaces/efl_graphics_utils.h new file mode 100644 index 0000000000..1465e13387 --- /dev/null +++ b/src/lib/efl/interfaces/efl_graphics_utils.h @@ -0,0 +1,49 @@ +#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); + +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); + + +#endif diff --git a/src/lib/evas/canvas/evas_vg_private.h b/src/lib/evas/canvas/evas_vg_private.h index 6b26a24213..3358e5018d 100644 --- a/src/lib/evas/canvas/evas_vg_private.h +++ b/src/lib/evas/canvas/evas_vg_private.h @@ -21,8 +21,4 @@ struct _Evas_VG_Container_Data Eina_List *children; }; -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); - #endif diff --git a/src/lib/evas/canvas/evas_vg_utils.c b/src/lib/evas/canvas/evas_vg_utils.c index 4b34e87225..f61c339781 100644 --- a/src/lib/evas/canvas/evas_vg_utils.c +++ b/src/lib/evas/canvas/evas_vg_utils.c @@ -2,228 +2,3 @@ #include "evas_private.h" #include "evas_vg_private.h" - -static 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_QUADRATIC_TO: return 4; - case EFL_GRAPHICS_PATH_COMMAND_TYPE_SQUADRATIC_TO: return 2; - case EFL_GRAPHICS_PATH_COMMAND_TYPE_CUBIC_TO: return 6; - case EFL_GRAPHICS_PATH_COMMAND_TYPE_SCUBIC_TO: return 4; - case EFL_GRAPHICS_PATH_COMMAND_TYPE_ARC_TO: return 5; - 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; -} - -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; -} - -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; -} - -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; -} - -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 *offset_point; - - if (!efl_graphics_path_grow(EFL_GRAPHICS_PATH_COMMAND_TYPE_QUADRATIC_TO, - commands, points, &offset_point)) - return ; - - offset_point[0] = x; - offset_point[1] = y; - offset_point[2] = ctrl_x; - offset_point[3] = ctrl_y; -} - -void -efl_graphics_path_append_squadratic_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_SQUADRATIC_TO, - commands, points, &offset_point)) - return ; - - offset_point[0] = x; - offset_point[1] = y; -} - -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; -} - -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 *offset_point; - - if (!efl_graphics_path_grow(EFL_GRAPHICS_PATH_COMMAND_TYPE_SCUBIC_TO, - commands, points, &offset_point)) - return ; - - offset_point[0] = x; - offset_point[1] = y; - offset_point[2] = ctrl_x; - offset_point[3] = ctrl_y; -} - -void -efl_graphics_path_append_arc_to(Efl_Graphics_Path_Command **commands, double **points, - double x, double y, - double rx, double ry, - double angle) -{ - double *offset_point; - - if (!efl_graphics_path_grow(EFL_GRAPHICS_PATH_COMMAND_TYPE_ARC_TO, - commands, points, &offset_point)) - return ; - - offset_point[0] = x; - offset_point[1] = y; - offset_point[2] = rx; - offset_point[3] = ry; - offset_point[4] = angle; -} - -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_ARC_TO, - commands, points, &offset_point); -} - -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); - efl_graphics_path_append_arc_to(commands, points, x, y + radius, radius, radius, 0); - efl_graphics_path_append_arc_to(commands, points, x - radius, y, radius, radius, 0); - efl_graphics_path_append_arc_to(commands, points, x, y - radius, radius, radius, 0); -} From c5d085999a73a0b644bdb2387ead17745731435a Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:21:49 +0200 Subject: [PATCH 037/251] ector: add stop implementation. --- src/lib/ector/ector_renderer_gradient.c | 17 +++++++++++++++++ src/lib/evas/canvas/evas_vg_gradient.c | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/lib/ector/ector_renderer_gradient.c b/src/lib/ector/ector_renderer_gradient.c index 610fb93809..d54f365fa9 100644 --- a/src/lib/ector/ector_renderer_gradient.c +++ b/src/lib/ector/ector_renderer_gradient.c @@ -10,6 +10,10 @@ typedef struct _Ector_Renderer_Generic_Gradient_Data Ector_Renderer_Generic_Gradient_Data; struct _Ector_Renderer_Generic_Gradient_Data { + Efl_Graphics_Gradient_Stop *colors; + unsigned int colors_count; + + Efl_Graphics_Gradient_Spread s; }; void @@ -18,6 +22,15 @@ _ector_renderer_gradient_efl_graphics_gradient_stop_set(Eo *obj, const Efl_Graphics_Gradient_Stop *colors, unsigned int length) { + pd->colors = realloc(pd->colors, length * sizeof(Efl_Graphics_Gradient_Stop)); + if (!pd->colors) + { + pd->colors_count = 0; + return ; + } + + memcpy(pd->colors, colors, length * sizeof(Efl_Graphics_Gradient_Stop)); + pd->colors_count = length; } void @@ -26,6 +39,8 @@ _ector_renderer_gradient_efl_graphics_gradient_stop_get(Eo *obj, const Efl_Graphics_Gradient_Stop **colors, unsigned int *length) { + if (colors) *colors = pd->colors; + if (length) *length = pd->colors_count; } void @@ -33,12 +48,14 @@ _ector_renderer_gradient_efl_graphics_gradient_spread_set(Eo *obj, Ector_Renderer_Generic_Gradient_Data *pd, Efl_Graphics_Gradient_Spread s) { + pd->s = s; } Efl_Graphics_Gradient_Spread _ector_renderer_gradient_efl_graphics_gradient_spread_get(Eo *obj, Ector_Renderer_Generic_Gradient_Data *pd) { + return pd->s; } diff --git a/src/lib/evas/canvas/evas_vg_gradient.c b/src/lib/evas/canvas/evas_vg_gradient.c index 72bddf7baa..28ed57930e 100644 --- a/src/lib/evas/canvas/evas_vg_gradient.c +++ b/src/lib/evas/canvas/evas_vg_gradient.c @@ -6,7 +6,7 @@ typedef struct _Evas_VG_Gradient_Data Evas_VG_Gradient_Data; struct _Evas_VG_Gradient_Data { - // FIXME: Later on we should deduplicate it somehow. + // FIXME: Later on we should deduplicate it somehow (Using Ector ?). Efl_Graphics_Gradient_Stop *colors; unsigned int colors_count; From 11ac85b40be4cf7a1c35160ff419f8bf3e9db175 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:21:50 +0200 Subject: [PATCH 038/251] ector: duplicate PATH could be useful. --- src/lib/ector/ector_renderer_shape.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/lib/ector/ector_renderer_shape.c b/src/lib/ector/ector_renderer_shape.c index 449b8e5bc8..27c60c85eb 100644 --- a/src/lib/ector/ector_renderer_shape.c +++ b/src/lib/ector/ector_renderer_shape.c @@ -10,6 +10,11 @@ typedef struct _Ector_Renderer_Generic_Shape_Data Ector_Renderer_Generic_Shape_Data; struct _Ector_Renderer_Generic_Shape_Data { + struct { + Efl_Graphics_Path_Command *cmd; + double *pts; + } path; + Ector_Renderer *fill; struct { Ector_Renderer *fill; @@ -209,11 +214,17 @@ _ector_renderer_shape_efl_graphics_shape_stroke_join_get(Eo *obj EINA_UNUSED, } Eina_Bool -_ector_renderer_shape_efl_graphics_shape_path_set(Eo *obj, +_ector_renderer_shape_efl_graphics_shape_path_set(Eo *obj EINA_UNUSED, Ector_Renderer_Generic_Shape_Data *pd, - const Efl_Graphics_Path_Command *op, + const Efl_Graphics_Path_Command *cmd, const double *points) { + free(pd->path.cmd); + pd->path.cmd = NULL; + free(pd->path.pts); + pd->path.pts = NULL; + + return efl_graphics_path_dup(&pd->path.cmd, &pd->path.pts, cmd, points); } void From 1df94f5baa5a13ed2fe7b849512f486226a0f9b7 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:21:52 +0200 Subject: [PATCH 039/251] ector: share base type structure to the rest of ecore_private.h. --- src/lib/ector/ector_private.h | 76 +++++++++++++++++++ src/lib/ector/ector_renderer_base.c | 20 ----- src/lib/ector/ector_renderer_gradient.c | 9 --- .../ector/ector_renderer_gradient_linear.c | 8 -- .../ector/ector_renderer_gradient_radial.c | 9 --- src/lib/ector/ector_renderer_shape.c | 29 ------- 6 files changed, 76 insertions(+), 75 deletions(-) diff --git a/src/lib/ector/ector_private.h b/src/lib/ector/ector_private.h index 8e95d0330e..41b51d880c 100644 --- a/src/lib/ector/ector_private.h +++ b/src/lib/ector/ector_private.h @@ -45,4 +45,80 @@ _ector_renderer_replace(Ector_Renderer **d, const Ector_Renderer *s) eo_unref(tmp); } +typedef struct _Ector_Renderer_Generic_Base_Data Ector_Renderer_Generic_Base_Data; +typedef struct _Ector_Renderer_Generic_Gradient_Data Ector_Renderer_Generic_Gradient_Data; +typedef struct _Ector_Renderer_Generic_Gradient_Linear_Data Ector_Renderer_Generic_Gradient_Linear_Data; +typedef struct _Ector_Renderer_Generic_Gradient_Radial_Data Ector_Renderer_Generic_Gradient_Radial_Data; +typedef struct _Ector_Renderer_Generic_Shape_Data Ector_Renderer_Generic_Shape_Data; + +struct _Ector_Renderer_Generic_Base_Data +{ + Eina_Matrix3 *m; + + struct { + double x; + double y; + } origin; + + struct { + int r, g, b, a; + } color; + + Ector_Renderer *mask; + + Ector_Quality q; + Eina_Bool visibility; +}; + +struct _Ector_Renderer_Generic_Gradient_Data +{ + Efl_Graphics_Gradient_Stop *colors; + unsigned int colors_count; + + Efl_Graphics_Gradient_Spread s; +}; + +struct _Ector_Renderer_Generic_Gradient_Linear_Data +{ + struct { + double x, y; + } start, end; +}; + +struct _Ector_Renderer_Generic_Gradient_Radial_Data +{ + struct { + double x, y; + } radial, focal; + double radius; +}; + +struct _Ector_Renderer_Generic_Shape_Data +{ + struct { + Efl_Graphics_Path_Command *cmd; + double *pts; + } path; + + Ector_Renderer *fill; + struct { + Ector_Renderer *fill; + Ector_Renderer *marker; + + double scale; + double width; + double centered; + + struct { + int r, g, b, a; + } color; + + Efl_Graphics_Dash *dash; + unsigned int dash_length; + + Efl_Graphics_Cap cap; + Efl_Graphics_Cap join; + } stroke; +}; + #endif diff --git a/src/lib/ector/ector_renderer_base.c b/src/lib/ector/ector_renderer_base.c index 92ffaa51cc..9bf001e1b9 100644 --- a/src/lib/ector/ector_renderer_base.c +++ b/src/lib/ector/ector_renderer_base.c @@ -7,26 +7,6 @@ #include "ector_private.h" -typedef struct _Ector_Renderer_Generic_Base_Data Ector_Renderer_Generic_Base_Data; -struct _Ector_Renderer_Generic_Base_Data -{ - Eina_Matrix3 *m; - - struct { - double x; - double y; - } origin; - - struct { - int r, g, b, a; - } color; - - Ector_Renderer *mask; - - Ector_Quality q; - Eina_Bool visibility; -}; - void _ector_renderer_base_transformation_set(Eo *obj EINA_UNUSED, Ector_Renderer_Generic_Base_Data *pd, diff --git a/src/lib/ector/ector_renderer_gradient.c b/src/lib/ector/ector_renderer_gradient.c index d54f365fa9..5cf3c442f6 100644 --- a/src/lib/ector/ector_renderer_gradient.c +++ b/src/lib/ector/ector_renderer_gradient.c @@ -7,15 +7,6 @@ #include "ector_private.h" -typedef struct _Ector_Renderer_Generic_Gradient_Data Ector_Renderer_Generic_Gradient_Data; -struct _Ector_Renderer_Generic_Gradient_Data -{ - Efl_Graphics_Gradient_Stop *colors; - unsigned int colors_count; - - Efl_Graphics_Gradient_Spread s; -}; - void _ector_renderer_gradient_efl_graphics_gradient_stop_set(Eo *obj, Ector_Renderer_Generic_Gradient_Data *pd, diff --git a/src/lib/ector/ector_renderer_gradient_linear.c b/src/lib/ector/ector_renderer_gradient_linear.c index 21412ceb59..46ed20fff9 100644 --- a/src/lib/ector/ector_renderer_gradient_linear.c +++ b/src/lib/ector/ector_renderer_gradient_linear.c @@ -7,14 +7,6 @@ #include "ector_private.h" -typedef struct _Ector_Renderer_Generic_Gradient_Linear_Data Ector_Renderer_Generic_Gradient_Linear_Data; -struct _Ector_Renderer_Generic_Gradient_Linear_Data -{ - struct { - double x, y; - } start, end; -}; - void _ector_renderer_gradient_linear_efl_graphics_gradient_linear_start_set(Eo *obj EINA_UNUSED, Ector_Renderer_Generic_Gradient_Linear_Data *pd, diff --git a/src/lib/ector/ector_renderer_gradient_radial.c b/src/lib/ector/ector_renderer_gradient_radial.c index 26d3b5dc80..8f377b303d 100644 --- a/src/lib/ector/ector_renderer_gradient_radial.c +++ b/src/lib/ector/ector_renderer_gradient_radial.c @@ -7,15 +7,6 @@ #include "ector_private.h" -typedef struct _Ector_Renderer_Generic_Gradient_Radial_Data Ector_Renderer_Generic_Gradient_Radial_Data; -struct _Ector_Renderer_Generic_Gradient_Radial_Data -{ - struct { - double x, y; - } radial, focal; - double radius; -}; - void _ector_renderer_gradient_radial_efl_graphics_gradient_radial_center_set(Eo *obj EINA_UNUSED, Ector_Renderer_Generic_Gradient_Radial_Data *pd, diff --git a/src/lib/ector/ector_renderer_shape.c b/src/lib/ector/ector_renderer_shape.c index 27c60c85eb..c69b0220d5 100644 --- a/src/lib/ector/ector_renderer_shape.c +++ b/src/lib/ector/ector_renderer_shape.c @@ -7,35 +7,6 @@ #include "ector_private.h" -typedef struct _Ector_Renderer_Generic_Shape_Data Ector_Renderer_Generic_Shape_Data; -struct _Ector_Renderer_Generic_Shape_Data -{ - struct { - Efl_Graphics_Path_Command *cmd; - double *pts; - } path; - - Ector_Renderer *fill; - struct { - Ector_Renderer *fill; - Ector_Renderer *marker; - - double scale; - double width; - double centered; - - struct { - int r, g, b, a; - } color; - - Efl_Graphics_Dash *dash; - unsigned int dash_length; - - Efl_Graphics_Cap cap; - Efl_Graphics_Cap join; - } stroke; -}; - void _ector_renderer_shape_fill_set(Eo *obj EINA_UNUSED, Ector_Renderer_Generic_Shape_Data *pd, From fe0672b80e37b39eb807f238762211d65251d557 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:21:53 +0200 Subject: [PATCH 040/251] ector: all those function needs to be static. --- src/lib/ector/ector_renderer_base.c | 24 +++++----- src/lib/ector/ector_renderer_gradient.c | 8 ++-- .../ector/ector_renderer_gradient_linear.c | 8 ++-- .../ector/ector_renderer_gradient_radial.c | 12 ++--- src/lib/ector/ector_renderer_shape.c | 47 +++++++++---------- 5 files changed, 49 insertions(+), 50 deletions(-) diff --git a/src/lib/ector/ector_renderer_base.c b/src/lib/ector/ector_renderer_base.c index 9bf001e1b9..f739e431c7 100644 --- a/src/lib/ector/ector_renderer_base.c +++ b/src/lib/ector/ector_renderer_base.c @@ -7,7 +7,7 @@ #include "ector_private.h" -void +static void _ector_renderer_base_transformation_set(Eo *obj EINA_UNUSED, Ector_Renderer_Generic_Base_Data *pd, const Eina_Matrix3 *m) @@ -31,14 +31,14 @@ _ector_renderer_base_transformation_set(Eo *obj EINA_UNUSED, pd->m = tmp; } -const Eina_Matrix3 * +static const Eina_Matrix3 * _ector_renderer_base_transformation_get(Eo *obj EINA_UNUSED, Ector_Renderer_Generic_Base_Data *pd) { return pd->m; } -void +static void _ector_renderer_base_origin_set(Eo *obj EINA_UNUSED, Ector_Renderer_Generic_Base_Data *pd, double x, double y) @@ -47,7 +47,7 @@ _ector_renderer_base_origin_set(Eo *obj EINA_UNUSED, pd->origin.y = y; } -void +static void _ector_renderer_base_origin_get(Eo *obj EINA_UNUSED, Ector_Renderer_Generic_Base_Data *pd, double *x, double *y) @@ -56,7 +56,7 @@ _ector_renderer_base_origin_get(Eo *obj EINA_UNUSED, if (y) *y = pd->origin.y; } -void +static void _ector_renderer_base_visibility_set(Eo *obj EINA_UNUSED, Ector_Renderer_Generic_Base_Data *pd, Eina_Bool v) @@ -64,14 +64,14 @@ _ector_renderer_base_visibility_set(Eo *obj EINA_UNUSED, pd->visibility = v; } -Eina_Bool +static Eina_Bool _ector_renderer_base_visibility_get(Eo *obj EINA_UNUSED, Ector_Renderer_Generic_Base_Data *pd) { return pd->visibility; } -void +static void _ector_renderer_base_color_set(Eo *obj EINA_UNUSED, Ector_Renderer_Generic_Base_Data *pd, int r, int g, int b, int a) @@ -82,7 +82,7 @@ _ector_renderer_base_color_set(Eo *obj EINA_UNUSED, pd->color.a = a; } -void +static void _ector_renderer_base_color_get(Eo *obj EINA_UNUSED, Ector_Renderer_Generic_Base_Data *pd, int *r, int *g, int *b, int *a) @@ -93,7 +93,7 @@ _ector_renderer_base_color_get(Eo *obj EINA_UNUSED, if (a) *a = pd->color.a; } -void +static void _ector_renderer_base_mask_set(Eo *obj EINA_UNUSED, Ector_Renderer_Generic_Base_Data *pd, Ector_Renderer *r) @@ -101,14 +101,14 @@ _ector_renderer_base_mask_set(Eo *obj EINA_UNUSED, _ector_renderer_replace(&pd->mask, r); } -Ector_Renderer * +static Ector_Renderer * _ector_renderer_base_mask_get(Eo *obj EINA_UNUSED, Ector_Renderer_Generic_Base_Data *pd) { return pd->mask; } -void +static void _ector_renderer_base_quality_set(Eo *obj EINA_UNUSED, Ector_Renderer_Generic_Base_Data *pd, Ector_Quality q) @@ -116,7 +116,7 @@ _ector_renderer_base_quality_set(Eo *obj EINA_UNUSED, pd->q = q; } -Ector_Quality +static Ector_Quality _ector_renderer_base_quality_get(Eo *obj EINA_UNUSED, Ector_Renderer_Generic_Base_Data *pd) { diff --git a/src/lib/ector/ector_renderer_gradient.c b/src/lib/ector/ector_renderer_gradient.c index 5cf3c442f6..4a0a4ca045 100644 --- a/src/lib/ector/ector_renderer_gradient.c +++ b/src/lib/ector/ector_renderer_gradient.c @@ -7,7 +7,7 @@ #include "ector_private.h" -void +static void _ector_renderer_gradient_efl_graphics_gradient_stop_set(Eo *obj, Ector_Renderer_Generic_Gradient_Data *pd, const Efl_Graphics_Gradient_Stop *colors, @@ -24,7 +24,7 @@ _ector_renderer_gradient_efl_graphics_gradient_stop_set(Eo *obj, pd->colors_count = length; } -void +static void _ector_renderer_gradient_efl_graphics_gradient_stop_get(Eo *obj, Ector_Renderer_Generic_Gradient_Data *pd, const Efl_Graphics_Gradient_Stop **colors, @@ -34,7 +34,7 @@ _ector_renderer_gradient_efl_graphics_gradient_stop_get(Eo *obj, if (length) *length = pd->colors_count; } -void +static void _ector_renderer_gradient_efl_graphics_gradient_spread_set(Eo *obj, Ector_Renderer_Generic_Gradient_Data *pd, Efl_Graphics_Gradient_Spread s) @@ -42,7 +42,7 @@ _ector_renderer_gradient_efl_graphics_gradient_spread_set(Eo *obj, pd->s = s; } -Efl_Graphics_Gradient_Spread +static Efl_Graphics_Gradient_Spread _ector_renderer_gradient_efl_graphics_gradient_spread_get(Eo *obj, Ector_Renderer_Generic_Gradient_Data *pd) { diff --git a/src/lib/ector/ector_renderer_gradient_linear.c b/src/lib/ector/ector_renderer_gradient_linear.c index 46ed20fff9..f44690b12c 100644 --- a/src/lib/ector/ector_renderer_gradient_linear.c +++ b/src/lib/ector/ector_renderer_gradient_linear.c @@ -7,7 +7,7 @@ #include "ector_private.h" -void +static void _ector_renderer_gradient_linear_efl_graphics_gradient_linear_start_set(Eo *obj EINA_UNUSED, Ector_Renderer_Generic_Gradient_Linear_Data *pd, double x, double y) @@ -16,7 +16,7 @@ _ector_renderer_gradient_linear_efl_graphics_gradient_linear_start_set(Eo *obj E pd->start.y = y; } -void +static void _ector_renderer_gradient_linear_efl_graphics_gradient_linear_start_get(Eo *obj EINA_UNUSED, Ector_Renderer_Generic_Gradient_Linear_Data *pd, double *x, double *y) @@ -25,7 +25,7 @@ _ector_renderer_gradient_linear_efl_graphics_gradient_linear_start_get(Eo *obj E if (y) *y = pd->start.y; } -void +static void _ector_renderer_gradient_linear_efl_graphics_gradient_linear_end_set(Eo *obj EINA_UNUSED, Ector_Renderer_Generic_Gradient_Linear_Data *pd, double x, double y) @@ -34,7 +34,7 @@ _ector_renderer_gradient_linear_efl_graphics_gradient_linear_end_set(Eo *obj EIN pd->end.y = y; } -void +static void _ector_renderer_gradient_linear_efl_graphics_gradient_linear_end_get(Eo *obj EINA_UNUSED, Ector_Renderer_Generic_Gradient_Linear_Data *pd, double *x, double *y) diff --git a/src/lib/ector/ector_renderer_gradient_radial.c b/src/lib/ector/ector_renderer_gradient_radial.c index 8f377b303d..3ee5783515 100644 --- a/src/lib/ector/ector_renderer_gradient_radial.c +++ b/src/lib/ector/ector_renderer_gradient_radial.c @@ -7,7 +7,7 @@ #include "ector_private.h" -void +static void _ector_renderer_gradient_radial_efl_graphics_gradient_radial_center_set(Eo *obj EINA_UNUSED, Ector_Renderer_Generic_Gradient_Radial_Data *pd, double x, double y) @@ -16,7 +16,7 @@ _ector_renderer_gradient_radial_efl_graphics_gradient_radial_center_set(Eo *obj pd->radial.y = y; } -void +static void _ector_renderer_gradient_radial_efl_graphics_gradient_radial_center_get(Eo *obj EINA_UNUSED, Ector_Renderer_Generic_Gradient_Radial_Data *pd, double *x, double *y) @@ -25,7 +25,7 @@ _ector_renderer_gradient_radial_efl_graphics_gradient_radial_center_get(Eo *obj if (y) *y = pd->radial.y; } -void +static void _ector_renderer_gradient_radial_efl_graphics_gradient_radial_radius_set(Eo *obj EINA_UNUSED, Ector_Renderer_Generic_Gradient_Radial_Data *pd, double r) @@ -33,7 +33,7 @@ _ector_renderer_gradient_radial_efl_graphics_gradient_radial_radius_set(Eo *obj pd->radius = r; } -double +static double _ector_renderer_gradient_radial_efl_graphics_gradient_radial_radius_get(Eo *obj EINA_UNUSED, Ector_Renderer_Generic_Gradient_Radial_Data *pd) { @@ -41,7 +41,7 @@ _ector_renderer_gradient_radial_efl_graphics_gradient_radial_radius_get(Eo *obj } -void +static void _ector_renderer_gradient_radial_efl_graphics_gradient_radial_focal_set(Eo *obj EINA_UNUSED, Ector_Renderer_Generic_Gradient_Radial_Data *pd, double x, double y) @@ -50,7 +50,7 @@ _ector_renderer_gradient_radial_efl_graphics_gradient_radial_focal_set(Eo *obj E pd->focal.y = y; } -void +static void _ector_renderer_gradient_radial_efl_graphics_gradient_radial_focal_get(Eo *obj EINA_UNUSED, Ector_Renderer_Generic_Gradient_Radial_Data *pd, double *x, double *y) diff --git a/src/lib/ector/ector_renderer_shape.c b/src/lib/ector/ector_renderer_shape.c index c69b0220d5..9c814523f7 100644 --- a/src/lib/ector/ector_renderer_shape.c +++ b/src/lib/ector/ector_renderer_shape.c @@ -7,7 +7,7 @@ #include "ector_private.h" -void +static void _ector_renderer_shape_fill_set(Eo *obj EINA_UNUSED, Ector_Renderer_Generic_Shape_Data *pd, const Ector_Renderer *r) @@ -15,14 +15,14 @@ _ector_renderer_shape_fill_set(Eo *obj EINA_UNUSED, _ector_renderer_replace(&pd->fill, r); } -const Ector_Renderer * +static const Ector_Renderer * _ector_renderer_shape_fill_get(Eo *obj EINA_UNUSED, Ector_Renderer_Generic_Shape_Data *pd) { return pd->fill; } -void +static void _ector_renderer_shape_stroke_fill_set(Eo *obj EINA_UNUSED, Ector_Renderer_Generic_Shape_Data *pd, const Ector_Renderer *r) @@ -30,14 +30,14 @@ _ector_renderer_shape_stroke_fill_set(Eo *obj EINA_UNUSED, _ector_renderer_replace(&pd->stroke.fill, r); } -const Ector_Renderer * +static const Ector_Renderer * _ector_renderer_shape_stroke_fill_get(Eo *obj EINA_UNUSED, Ector_Renderer_Generic_Shape_Data *pd) { return pd->stroke.fill; } -void +static void _ector_renderer_shape_stroke_marker_set(Eo *obj EINA_UNUSED, Ector_Renderer_Generic_Shape_Data *pd, const Ector_Renderer *r) @@ -45,14 +45,14 @@ _ector_renderer_shape_stroke_marker_set(Eo *obj EINA_UNUSED, _ector_renderer_replace(&pd->stroke.marker, r); } -const Ector_Renderer * +static const Ector_Renderer * _ector_renderer_shape_stroke_marker_get(Eo *obj EINA_UNUSED, Ector_Renderer_Generic_Shape_Data *pd) { return pd->stroke.marker; } -void +static void _ector_renderer_shape_efl_graphics_shape_stroke_scale_set(Eo *obj EINA_UNUSED, Ector_Renderer_Generic_Shape_Data *pd, double s) @@ -60,14 +60,14 @@ _ector_renderer_shape_efl_graphics_shape_stroke_scale_set(Eo *obj EINA_UNUSED, pd->stroke.scale = s; } -double +static double _ector_renderer_shape_efl_graphics_shape_stroke_scale_get(Eo *obj EINA_UNUSED, Ector_Renderer_Generic_Shape_Data *pd) { return pd->stroke.scale; } -void +static void _ector_renderer_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) @@ -78,8 +78,7 @@ _ector_renderer_shape_efl_graphics_shape_stroke_color_set(Eo *obj EINA_UNUSED, pd->stroke.color.a = a; } - -void +static void _ector_renderer_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) @@ -90,7 +89,7 @@ _ector_renderer_shape_efl_graphics_shape_stroke_color_get(Eo *obj EINA_UNUSED, if (a) *a = pd->stroke.color.a; } -void +static void _ector_renderer_shape_efl_graphics_shape_stroke_width_set(Eo *obj EINA_UNUSED, Ector_Renderer_Generic_Shape_Data *pd, double w) @@ -98,14 +97,14 @@ _ector_renderer_shape_efl_graphics_shape_stroke_width_set(Eo *obj EINA_UNUSED, pd->stroke.width = w; } -double +static double _ector_renderer_shape_efl_graphics_shape_stroke_width_get(Eo *obj EINA_UNUSED, Ector_Renderer_Generic_Shape_Data *pd) { return pd->stroke.width; } -void +static void _ector_renderer_shape_efl_graphics_shape_stroke_location_set(Eo *obj EINA_UNUSED, Ector_Renderer_Generic_Shape_Data *pd, double centered) @@ -113,14 +112,14 @@ _ector_renderer_shape_efl_graphics_shape_stroke_location_set(Eo *obj EINA_UNUSED pd->stroke.centered = centered; } -double +static double _ector_renderer_shape_efl_graphics_shape_stroke_location_get(Eo *obj EINA_UNUSED, Ector_Renderer_Generic_Shape_Data *pd) { return pd->stroke.centered; } -void +static void _ector_renderer_shape_efl_graphics_shape_stroke_dash_set(Eo *obj EINA_UNUSED, Ector_Renderer_Generic_Shape_Data *pd, const Efl_Graphics_Dash *dash, @@ -144,7 +143,7 @@ _ector_renderer_shape_efl_graphics_shape_stroke_dash_set(Eo *obj EINA_UNUSED, pd->stroke.dash_length = length; } -void +static void _ector_renderer_shape_efl_graphics_shape_stroke_dash_get(Eo *obj EINA_UNUSED, Ector_Renderer_Generic_Shape_Data *pd, const Efl_Graphics_Dash **dash, @@ -154,7 +153,7 @@ _ector_renderer_shape_efl_graphics_shape_stroke_dash_get(Eo *obj EINA_UNUSED, if (length) *length = pd->stroke.dash_length; } -void +static void _ector_renderer_shape_efl_graphics_shape_stroke_cap_set(Eo *obj EINA_UNUSED, Ector_Renderer_Generic_Shape_Data *pd, Efl_Graphics_Cap c) @@ -162,14 +161,14 @@ _ector_renderer_shape_efl_graphics_shape_stroke_cap_set(Eo *obj EINA_UNUSED, pd->stroke.cap = c; } -Efl_Graphics_Cap +static Efl_Graphics_Cap _ector_renderer_shape_efl_graphics_shape_stroke_cap_get(Eo *obj EINA_UNUSED, Ector_Renderer_Generic_Shape_Data *pd) { return pd->stroke.cap; } -void +static void _ector_renderer_shape_efl_graphics_shape_stroke_join_set(Eo *obj EINA_UNUSED, Ector_Renderer_Generic_Shape_Data *pd, Efl_Graphics_Join j) @@ -177,14 +176,14 @@ _ector_renderer_shape_efl_graphics_shape_stroke_join_set(Eo *obj EINA_UNUSED, pd->stroke.join = j; } -Efl_Graphics_Join +static Efl_Graphics_Join _ector_renderer_shape_efl_graphics_shape_stroke_join_get(Eo *obj EINA_UNUSED, Ector_Renderer_Generic_Shape_Data *pd) { return pd->stroke.join; } -Eina_Bool +static Eina_Bool _ector_renderer_shape_efl_graphics_shape_path_set(Eo *obj EINA_UNUSED, Ector_Renderer_Generic_Shape_Data *pd, const Efl_Graphics_Path_Command *cmd, @@ -198,13 +197,13 @@ _ector_renderer_shape_efl_graphics_shape_path_set(Eo *obj EINA_UNUSED, return efl_graphics_path_dup(&pd->path.cmd, &pd->path.pts, cmd, points); } -void +static void _ector_renderer_shape_eo_base_constructor(Eo *obj, Ector_Renderer_Generic_Shape_Data *pd) { } -void +static void _ector_renderer_shape_eo_base_destructor(Eo *obj, Ector_Renderer_Generic_Shape_Data *pd) { } From b06e7706140971a8890a0efb7b4e964a5f418ea1 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:21:54 +0200 Subject: [PATCH 041/251] ector: add beginning of a cairo implementation. --- src/Makefile_Ector.am | 6 ++++ .../ector_renderer_cairo_gradient_linear.c | 30 +++++++++++++++++++ .../ector_renderer_cairo_gradient_radial.c | 30 +++++++++++++++++++ .../ector/cairo/ector_renderer_cairo_shape.c | 30 +++++++++++++++++++ 4 files changed, 96 insertions(+) create mode 100644 src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c create mode 100644 src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c create mode 100644 src/lib/ector/cairo/ector_renderer_cairo_shape.c diff --git a/src/Makefile_Ector.am b/src/Makefile_Ector.am index 270857a2b2..35ded52399 100644 --- a/src/Makefile_Ector.am +++ b/src/Makefile_Ector.am @@ -41,6 +41,12 @@ lib/ector/ector_renderer_gradient.c \ lib/ector/ector_renderer_gradient_radial.c \ lib/ector/ector_renderer_gradient_linear.c +# And now the cairo backend +lib_ector_libector_la_SOURCES += \ +lib/ector/cairo/ector_renderer_cairo_gradient_linear.c \ +lib/ector/cairo/ector_renderer_cairo_gradient_radial.c \ +lib/ector/cairo/ector_renderer_cairo_shape.c + lib_ector_libector_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl \ @ECTOR_CFLAGS@ \ -DPACKAGE_BIN_DIR=\"$(bindir)\" \ diff --git a/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c b/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c new file mode 100644 index 0000000000..364c3b37b3 --- /dev/null +++ b/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c @@ -0,0 +1,30 @@ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include + +#include "ector_private.h" + +typedef struct _Ector_Renderer_Cairo_Gradient_Linear_Data Ector_Renderer_Cairo_Gradient_Linear_Data; +struct _Ector_Renderer_Cairo_Gradient_Linear_Data +{ +}; + +static Eina_Bool +_ector_renderer_cairo_gradient_linear_ector_renderer_generic_base_prepare(Eo *obj, Ector_Renderer_Cairo_Gradient_Linear_Data *pd, Ector_Surface *s) +{ +} + +static Eina_Bool +_ector_renderer_cairo_gradient_linear_ector_renderer_generic_base_draw(Eo *obj, Ector_Renderer_Cairo_Gradient_Linear_Data *pd, Ector_Surface *s, Ector_Rop op, Eina_Array *clips, int x, int y) +{ +} + +static Eina_Bool +_ector_renderer_cairo_gradient_linear_ector_renderer_generic_base_done(Eo *obj, Ector_Renderer_Cairo_Gradient_Linear_Data *pd) +{ +} + +#include "ector_renderer_cairo_gradient_linear.eo.c" diff --git a/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c b/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c new file mode 100644 index 0000000000..c1e03adc45 --- /dev/null +++ b/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c @@ -0,0 +1,30 @@ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include + +#include "ector_private.h" + +typedef struct _Ector_Renderer_Cairo_Gradient_Radial_Data Ector_Renderer_Cairo_Gradient_Radial_Data; +struct _Ector_Renderer_Cairo_Gradient_Radial_Data +{ +}; + +static Eina_Bool +_ector_renderer_cairo_gradient_radial_ector_renderer_generic_base_prepare(Eo *obj, Ector_Renderer_Cairo_Gradient_Radial_Data *pd, Ector_Surface *s) +{ +} + +static Eina_Bool +_ector_renderer_cairo_gradient_radial_ector_renderer_generic_base_draw(Eo *obj, Ector_Renderer_Cairo_Gradient_Radial_Data *pd, Ector_Surface *s, Ector_Rop op, Eina_Array *clips, int x, int y) +{ +} + +static Eina_Bool +_ector_renderer_cairo_gradient_radial_ector_renderer_generic_base_done(Eo *obj, Ector_Renderer_Cairo_Gradient_Radial_Data *pd) +{ +} + +#include "ector_renderer_cairo_gradient_radial.eo.c" diff --git a/src/lib/ector/cairo/ector_renderer_cairo_shape.c b/src/lib/ector/cairo/ector_renderer_cairo_shape.c new file mode 100644 index 0000000000..6b9b32925b --- /dev/null +++ b/src/lib/ector/cairo/ector_renderer_cairo_shape.c @@ -0,0 +1,30 @@ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include + +#include "ector_private.h" + +typedef struct _Ector_Renderer_Cairo_Shape_Data Ector_Renderer_Cairo_Shape_Data; +struct _Ector_Renderer_Cairo_Shape_Data +{ +}; + +static Eina_Bool +_ector_renderer_cairo_shape_ector_renderer_generic_base_prepare(Eo *obj, Ector_Renderer_Cairo_Shape_Data *pd, Ector_Surface *s) +{ +} + +static Eina_Bool +_ector_renderer_cairo_shape_ector_renderer_generic_base_draw(Eo *obj, Ector_Renderer_Cairo_Shape_Data *pd, Ector_Surface *s, Ector_Rop op, Eina_Array *clips, int x, int y) +{ +} + +static Eina_Bool +_ector_renderer_cairo_shape_ector_renderer_generic_base_done(Eo *obj, Ector_Renderer_Cairo_Shape_Data *pd) +{ +} + +#include "ector_renderer_cairo_shape.eo.c" From cba397fcf1505b164d7f8b5ef4f6a0dd7cc7822d Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:21:56 +0200 Subject: [PATCH 042/251] ector: and here come the beginning of a Cairo backend. The idea is that Evas engine will actually inherit from it to instanciate their own Cairo backend (Software and GL) from there. --- src/Makefile_Ector.am | 8 +++++-- src/lib/ector/cairo/Ector_Cairo.h | 10 +++++++++ src/lib/ector/cairo/ector_cairo_surface.c | 26 ++++++++++++++++++++++ src/lib/ector/cairo/ector_cairo_surface.eo | 11 ++++++++- 4 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 src/lib/ector/cairo/Ector_Cairo.h create mode 100644 src/lib/ector/cairo/ector_cairo_surface.c diff --git a/src/Makefile_Ector.am b/src/Makefile_Ector.am index 35ded52399..2327bc6b6c 100644 --- a/src/Makefile_Ector.am +++ b/src/Makefile_Ector.am @@ -30,7 +30,10 @@ lib_LTLIBRARIES += lib/ector/libector.la installed_ectormainheadersdir = $(includedir)/ector-@VMAJ@ dist_installed_ectormainheaders_DATA = \ -lib/ector/Ector.h +lib/ector/Ector.h \ +lib/ector/cairo/Ector_Cairo.h + +# And the cairo header lib_ector_libector_la_SOURCES = \ lib/ector/ector_main.c \ @@ -45,7 +48,8 @@ lib/ector/ector_renderer_gradient_linear.c lib_ector_libector_la_SOURCES += \ lib/ector/cairo/ector_renderer_cairo_gradient_linear.c \ lib/ector/cairo/ector_renderer_cairo_gradient_radial.c \ -lib/ector/cairo/ector_renderer_cairo_shape.c +lib/ector/cairo/ector_renderer_cairo_shape.c \ +lib/ector/cairo/ector_cairo_surface.c lib_ector_libector_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl \ @ECTOR_CFLAGS@ \ diff --git a/src/lib/ector/cairo/Ector_Cairo.h b/src/lib/ector/cairo/Ector_Cairo.h new file mode 100644 index 0000000000..13de627e21 --- /dev/null +++ b/src/lib/ector/cairo/Ector_Cairo.h @@ -0,0 +1,10 @@ +#ifndef ECTOR_CAIRO_H_ +# define ECTOR_CAIRO_H_ + +#include + +typedef Eo Ector_Cairo_Surface; + +#include "cairo/ector_cairo_surface.eo.h" + +#endif diff --git a/src/lib/ector/cairo/ector_cairo_surface.c b/src/lib/ector/cairo/ector_cairo_surface.c new file mode 100644 index 0000000000..67a8158dc8 --- /dev/null +++ b/src/lib/ector/cairo/ector_cairo_surface.c @@ -0,0 +1,26 @@ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include +#include + +#include "ector_private.h" + +typedef struct _Ector_Cairo_Surface_Data Ector_Cairo_Surface_Data; +struct _Ector_Cairo_Surface_Data +{ +}; + +void * +_ector_cairo_surface_symbol_get(Eo *obj, Ector_Cairo_Surface_Data *pd, char *name) +{ +} + +Ector_Renderer * +_ector_cairo_surface_ector_generic_surface_renderer_factory_new(Eo *obj, Ector_Cairo_Surface_Data *pd, const Eo_Class *type) +{ +} + +#include "ector_cairo_surface.eo.c" diff --git a/src/lib/ector/cairo/ector_cairo_surface.eo b/src/lib/ector/cairo/ector_cairo_surface.eo index 08073254a7..9c4e979714 100644 --- a/src/lib/ector/cairo/ector_cairo_surface.eo +++ b/src/lib/ector/cairo/ector_cairo_surface.eo @@ -1,6 +1,15 @@ -class Ector.cairo.Surface (Ector.Generic.Surface) +class Ector.Cairo.Surface (Ector.Generic.Surface) { eo_prefix: ector_cairo_surface; + legacy_prefix: null; + methods { + symbol_get { + return: void * @warn_unused; + params { + @in char* name; + } + } + } implements { Ector.Generic.Surface.renderer_factory_new; } From fcbc29f85e04fa4dba30baa4ec692ae1fcad173d Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:21:57 +0200 Subject: [PATCH 043/251] ector: move dependency around. Evas now depend on Ector. --- configure.ac | 3 ++- src/Makefile_Evas.am | 1 + src/lib/ector/Ector.h | 5 ++-- src/lib/ector/cairo/Ector_Cairo.h | 1 + src/lib/ector/cairo/ector_cairo_surface.eo | 7 +++++ .../ector_cairo_software_surface.eo | 21 +++++++++++++++ .../engines/software_generic/evas_engine.c | 26 +++++++++++++++++++ 7 files changed, 61 insertions(+), 3 deletions(-) create mode 100644 src/modules/evas/engines/software_generic/ector_cairo_software_surface.eo diff --git a/configure.ac b/configure.ac index afad51b647..e773931ce6 100644 --- a/configure.ac +++ b/configure.ac @@ -1676,6 +1676,7 @@ EFL_INTERNAL_DEPEND_PKG([EVAS], [eet]) EFL_INTERNAL_DEPEND_PKG([EVAS], [eina]) EFL_INTERNAL_DEPEND_PKG([EVAS], [efl]) EFL_INTERNAL_DEPEND_PKG([EVAS], [emile]) +EFL_INTERNAL_DEPEND_PKG([EVAS], [ector]) EFL_ADD_LIBS([EVAS], [-lm]) @@ -2113,7 +2114,7 @@ EFL_PLATFORM_DEPEND([ECTOR], [evil]) EFL_INTERNAL_DEPEND_PKG([ECTOR], [eina]) EFL_INTERNAL_DEPEND_PKG([ECTOR], [eo]) -EFL_INTERNAL_DEPEND_PKG([ECTOR], [evas]) +EFL_INTERNAL_DEPEND_PKG([ECTOR], [efl]) EFL_EVAL_PKGS([ECTOR]) diff --git a/src/Makefile_Evas.am b/src/Makefile_Evas.am index 224ffcaaa4..b5f42a52ac 100644 --- a/src/Makefile_Evas.am +++ b/src/Makefile_Evas.am @@ -519,6 +519,7 @@ lib/evas/filters/blur/blur_box_rgba_neon.c ### Engines if EVAS_STATIC_BUILD_SOFTWARE_GENERIC +evas_eolian_files += modules/evas/engines/software_generic/ector_cairo_software_surface.eo lib_evas_libevas_la_SOURCES += modules/evas/engines/software_generic/evas_engine.c modules/evas/engines/software_generic/Evas_Engine_Software_Generic.h lib_evas_libevas_la_LIBADD += else diff --git a/src/lib/ector/Ector.h b/src/lib/ector/Ector.h index a47d2f109f..fe8d13c62e 100644 --- a/src/lib/ector/Ector.h +++ b/src/lib/ector/Ector.h @@ -3,7 +3,7 @@ #include #include -#include +#include #ifdef EAPI # undef EAPI @@ -108,7 +108,8 @@ typedef Eo Ector_Renderer; * @typedef Ector_Colorspace * The definiton of colorspace. */ -typedef Evas_Colorspace Ector_Colorspace; + // FIXME: Enable that when we have merged Emile +/* typedef Evas_Colorspace Ector_Colorspace; */ /** * Raster operations at pixel level diff --git a/src/lib/ector/cairo/Ector_Cairo.h b/src/lib/ector/cairo/Ector_Cairo.h index 13de627e21..a11a53f646 100644 --- a/src/lib/ector/cairo/Ector_Cairo.h +++ b/src/lib/ector/cairo/Ector_Cairo.h @@ -4,6 +4,7 @@ #include typedef Eo Ector_Cairo_Surface; +typedef struct _cairo_t cairo_t; #include "cairo/ector_cairo_surface.eo.h" diff --git a/src/lib/ector/cairo/ector_cairo_surface.eo b/src/lib/ector/cairo/ector_cairo_surface.eo index 9c4e979714..8a3676770b 100644 --- a/src/lib/ector/cairo/ector_cairo_surface.eo +++ b/src/lib/ector/cairo/ector_cairo_surface.eo @@ -9,8 +9,15 @@ class Ector.Cairo.Surface (Ector.Generic.Surface) @in char* name; } } + context_set { + return: Eina_Bool; + params { + @in cairo_t *ctx; + } + } } implements { Ector.Generic.Surface.renderer_factory_new; + Eo.Base.finalize; } } diff --git a/src/modules/evas/engines/software_generic/ector_cairo_software_surface.eo b/src/modules/evas/engines/software_generic/ector_cairo_software_surface.eo new file mode 100644 index 0000000000..9387f3185a --- /dev/null +++ b/src/modules/evas/engines/software_generic/ector_cairo_software_surface.eo @@ -0,0 +1,21 @@ +class Ector.Cairo_Software.Surface (Ector.Cairo.Surface) +{ + eo_prefix: ector_cairo_software_surface; + legacy_prefix: null; + properties { + surface { + set { + } + get { + } + values { + void *pixels; + uint width; + uint height; + } + } + } + implements { + Eo.Base.finalize; + } +} diff --git a/src/modules/evas/engines/software_generic/evas_engine.c b/src/modules/evas/engines/software_generic/evas_engine.c index a679d5c767..a2d5a1ceeb 100644 --- a/src/modules/evas/engines/software_generic/evas_engine.c +++ b/src/modules/evas/engines/software_generic/evas_engine.c @@ -18,6 +18,10 @@ #include "Evas_Engine_Software_Generic.h" +#include "cairo/Ector_Cairo.h" + +#include "ector_cairo_software_surface.eo.h" + #ifdef EVAS_GL //----------------------------------// // OSMesa... @@ -4694,3 +4698,25 @@ EVAS_MODULE_DEFINE(EVAS_MODULE_TYPE_ENGINE, engine, software_generic); #ifndef EVAS_STATIC_BUILD_SOFTWARE_GENERIC EVAS_EINA_MODULE_DEFINE(engine, software_generic); #endif + +typedef struct _Ector_Cairo_Software_Surface_Data Ector_Cairo_Software_Surface_Data; +struct _Ector_Cairo_Software_Surface_Data +{ +}; + +void +_ector_cairo_software_surface_surface_set(Eo *obj, Ector_Cairo_Software_Surface_Data *pd, void *pixels, unsigned int width, unsigned int height) +{ +} + +void +_ector_cairo_software_surface_surface_get(Eo *obj, Ector_Cairo_Software_Surface_Data *pd, void **pixels, unsigned int *width, unsigned int *height) +{ +} + +Eo * +_ector_cairo_software_surface_eo_base_finalize(Eo *obj, Ector_Cairo_Software_Surface_Data *pd) +{ +} + +#include "ector_cairo_software_surface.eo.c" From fedfbf4bf619cd8bf117ac45625ed15d261b8df4 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:21:58 +0200 Subject: [PATCH 044/251] ector: fix building of cairo backend. --- src/lib/ector/cairo/ector_cairo_surface.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/lib/ector/cairo/ector_cairo_surface.c b/src/lib/ector/cairo/ector_cairo_surface.c index 67a8158dc8..06f8ed760a 100644 --- a/src/lib/ector/cairo/ector_cairo_surface.c +++ b/src/lib/ector/cairo/ector_cairo_surface.c @@ -23,4 +23,14 @@ _ector_cairo_surface_ector_generic_surface_renderer_factory_new(Eo *obj, Ector_C { } +Eina_Bool +_ector_cairo_surface_context_set(Eo *obj, Ector_Cairo_Surface_Data *pd, cairo_t *ctx) +{ +} + +Eo * +_ector_cairo_surface_eo_base_finalize(Eo *obj, Ector_Cairo_Surface_Data *pd) +{ +} + #include "ector_cairo_surface.eo.c" From 85036dbeb1e901d1d540ae776e592164de6117b9 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:21:59 +0200 Subject: [PATCH 045/251] ector: fix building of the generic backend. --- src/lib/ector/ector_renderer_base.c | 64 ++++----- src/lib/ector/ector_renderer_gradient.c | 26 ++-- .../ector/ector_renderer_gradient_linear.c | 24 ++-- .../ector/ector_renderer_gradient_radial.c | 34 ++--- src/lib/ector/ector_renderer_shape.c | 122 +++++++++--------- 5 files changed, 135 insertions(+), 135 deletions(-) diff --git a/src/lib/ector/ector_renderer_base.c b/src/lib/ector/ector_renderer_base.c index f739e431c7..70b636b861 100644 --- a/src/lib/ector/ector_renderer_base.c +++ b/src/lib/ector/ector_renderer_base.c @@ -8,9 +8,9 @@ #include "ector_private.h" static void -_ector_renderer_base_transformation_set(Eo *obj EINA_UNUSED, - Ector_Renderer_Generic_Base_Data *pd, - const Eina_Matrix3 *m) +_ector_renderer_generic_base_transformation_set(Eo *obj EINA_UNUSED, + Ector_Renderer_Generic_Base_Data *pd, + const Eina_Matrix3 *m) { Eina_Matrix3 *tmp = pd->m; @@ -32,49 +32,49 @@ _ector_renderer_base_transformation_set(Eo *obj EINA_UNUSED, } static const Eina_Matrix3 * -_ector_renderer_base_transformation_get(Eo *obj EINA_UNUSED, - Ector_Renderer_Generic_Base_Data *pd) +_ector_renderer_generic_base_transformation_get(Eo *obj EINA_UNUSED, + Ector_Renderer_Generic_Base_Data *pd) { return pd->m; } static void -_ector_renderer_base_origin_set(Eo *obj EINA_UNUSED, - Ector_Renderer_Generic_Base_Data *pd, - double x, double y) +_ector_renderer_generic_base_origin_set(Eo *obj EINA_UNUSED, + Ector_Renderer_Generic_Base_Data *pd, + double x, double y) { pd->origin.x = x; pd->origin.y = y; } static void -_ector_renderer_base_origin_get(Eo *obj EINA_UNUSED, - Ector_Renderer_Generic_Base_Data *pd, - double *x, double *y) +_ector_renderer_generic_base_origin_get(Eo *obj EINA_UNUSED, + Ector_Renderer_Generic_Base_Data *pd, + double *x, double *y) { if (x) *x = pd->origin.x; if (y) *y = pd->origin.y; } static void -_ector_renderer_base_visibility_set(Eo *obj EINA_UNUSED, - Ector_Renderer_Generic_Base_Data *pd, - Eina_Bool v) +_ector_renderer_generic_base_visibility_set(Eo *obj EINA_UNUSED, + Ector_Renderer_Generic_Base_Data *pd, + Eina_Bool v) { pd->visibility = v; } static Eina_Bool -_ector_renderer_base_visibility_get(Eo *obj EINA_UNUSED, - Ector_Renderer_Generic_Base_Data *pd) +_ector_renderer_generic_base_visibility_get(Eo *obj EINA_UNUSED, + Ector_Renderer_Generic_Base_Data *pd) { return pd->visibility; } static void -_ector_renderer_base_color_set(Eo *obj EINA_UNUSED, - Ector_Renderer_Generic_Base_Data *pd, - int r, int g, int b, int a) +_ector_renderer_generic_base_color_set(Eo *obj EINA_UNUSED, + Ector_Renderer_Generic_Base_Data *pd, + int r, int g, int b, int a) { pd->color.r = r; pd->color.g = g; @@ -83,9 +83,9 @@ _ector_renderer_base_color_set(Eo *obj EINA_UNUSED, } static void -_ector_renderer_base_color_get(Eo *obj EINA_UNUSED, - Ector_Renderer_Generic_Base_Data *pd, - int *r, int *g, int *b, int *a) +_ector_renderer_generic_base_color_get(Eo *obj EINA_UNUSED, + Ector_Renderer_Generic_Base_Data *pd, + int *r, int *g, int *b, int *a) { if (r) *r = pd->color.r; if (g) *g = pd->color.g; @@ -94,31 +94,31 @@ _ector_renderer_base_color_get(Eo *obj EINA_UNUSED, } static void -_ector_renderer_base_mask_set(Eo *obj EINA_UNUSED, - Ector_Renderer_Generic_Base_Data *pd, - Ector_Renderer *r) +_ector_renderer_generic_base_mask_set(Eo *obj EINA_UNUSED, + Ector_Renderer_Generic_Base_Data *pd, + Ector_Renderer *r) { _ector_renderer_replace(&pd->mask, r); } static Ector_Renderer * -_ector_renderer_base_mask_get(Eo *obj EINA_UNUSED, - Ector_Renderer_Generic_Base_Data *pd) +_ector_renderer_generic_base_mask_get(Eo *obj EINA_UNUSED, + Ector_Renderer_Generic_Base_Data *pd) { return pd->mask; } static void -_ector_renderer_base_quality_set(Eo *obj EINA_UNUSED, - Ector_Renderer_Generic_Base_Data *pd, - Ector_Quality q) +_ector_renderer_generic_base_quality_set(Eo *obj EINA_UNUSED, + Ector_Renderer_Generic_Base_Data *pd, + Ector_Quality q) { pd->q = q; } static Ector_Quality -_ector_renderer_base_quality_get(Eo *obj EINA_UNUSED, - Ector_Renderer_Generic_Base_Data *pd) +_ector_renderer_generic_base_quality_get(Eo *obj EINA_UNUSED, + Ector_Renderer_Generic_Base_Data *pd) { return pd->q; } diff --git a/src/lib/ector/ector_renderer_gradient.c b/src/lib/ector/ector_renderer_gradient.c index 4a0a4ca045..4e6a1b0776 100644 --- a/src/lib/ector/ector_renderer_gradient.c +++ b/src/lib/ector/ector_renderer_gradient.c @@ -8,10 +8,10 @@ #include "ector_private.h" static void -_ector_renderer_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_graphics_gradient_stop_set(Eo *obj, + Ector_Renderer_Generic_Gradient_Data *pd, + const Efl_Graphics_Gradient_Stop *colors, + unsigned int length) { pd->colors = realloc(pd->colors, length * sizeof(Efl_Graphics_Gradient_Stop)); if (!pd->colors) @@ -25,26 +25,26 @@ _ector_renderer_gradient_efl_graphics_gradient_stop_set(Eo *obj, } static void -_ector_renderer_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_graphics_gradient_stop_get(Eo *obj, + Ector_Renderer_Generic_Gradient_Data *pd, + const Efl_Graphics_Gradient_Stop **colors, + unsigned int *length) { if (colors) *colors = pd->colors; if (length) *length = pd->colors_count; } static void -_ector_renderer_gradient_efl_graphics_gradient_spread_set(Eo *obj, - Ector_Renderer_Generic_Gradient_Data *pd, - Efl_Graphics_Gradient_Spread s) +_ector_renderer_generic_gradient_efl_graphics_gradient_spread_set(Eo *obj, + Ector_Renderer_Generic_Gradient_Data *pd, + Efl_Graphics_Gradient_Spread s) { pd->s = s; } static Efl_Graphics_Gradient_Spread -_ector_renderer_gradient_efl_graphics_gradient_spread_get(Eo *obj, - Ector_Renderer_Generic_Gradient_Data *pd) +_ector_renderer_generic_gradient_efl_graphics_gradient_spread_get(Eo *obj, + Ector_Renderer_Generic_Gradient_Data *pd) { return pd->s; } diff --git a/src/lib/ector/ector_renderer_gradient_linear.c b/src/lib/ector/ector_renderer_gradient_linear.c index f44690b12c..475a1d9c04 100644 --- a/src/lib/ector/ector_renderer_gradient_linear.c +++ b/src/lib/ector/ector_renderer_gradient_linear.c @@ -8,36 +8,36 @@ #include "ector_private.h" static void -_ector_renderer_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_graphics_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_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_graphics_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_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_graphics_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_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_graphics_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; diff --git a/src/lib/ector/ector_renderer_gradient_radial.c b/src/lib/ector/ector_renderer_gradient_radial.c index 3ee5783515..f23485b9fe 100644 --- a/src/lib/ector/ector_renderer_gradient_radial.c +++ b/src/lib/ector/ector_renderer_gradient_radial.c @@ -8,52 +8,52 @@ #include "ector_private.h" static void -_ector_renderer_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_graphics_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_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_graphics_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_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_graphics_gradient_radial_radius_set(Eo *obj EINA_UNUSED, + Ector_Renderer_Generic_Gradient_Radial_Data *pd, + double r) { pd->radius = r; } static double -_ector_renderer_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_graphics_gradient_radial_radius_get(Eo *obj EINA_UNUSED, + Ector_Renderer_Generic_Gradient_Radial_Data *pd) { return pd->radius; } static void -_ector_renderer_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_graphics_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_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_graphics_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; diff --git a/src/lib/ector/ector_renderer_shape.c b/src/lib/ector/ector_renderer_shape.c index 9c814523f7..e171c4c0c2 100644 --- a/src/lib/ector/ector_renderer_shape.c +++ b/src/lib/ector/ector_renderer_shape.c @@ -8,69 +8,69 @@ #include "ector_private.h" static void -_ector_renderer_shape_fill_set(Eo *obj EINA_UNUSED, - Ector_Renderer_Generic_Shape_Data *pd, - const Ector_Renderer *r) +_ector_renderer_generic_shape_fill_set(Eo *obj EINA_UNUSED, + Ector_Renderer_Generic_Shape_Data *pd, + const Ector_Renderer *r) { _ector_renderer_replace(&pd->fill, r); } static const Ector_Renderer * -_ector_renderer_shape_fill_get(Eo *obj EINA_UNUSED, - Ector_Renderer_Generic_Shape_Data *pd) +_ector_renderer_generic_shape_fill_get(Eo *obj EINA_UNUSED, + Ector_Renderer_Generic_Shape_Data *pd) { return pd->fill; } static void -_ector_renderer_shape_stroke_fill_set(Eo *obj EINA_UNUSED, - Ector_Renderer_Generic_Shape_Data *pd, - const Ector_Renderer *r) +_ector_renderer_generic_shape_stroke_fill_set(Eo *obj EINA_UNUSED, + Ector_Renderer_Generic_Shape_Data *pd, + const Ector_Renderer *r) { _ector_renderer_replace(&pd->stroke.fill, r); } static const Ector_Renderer * -_ector_renderer_shape_stroke_fill_get(Eo *obj EINA_UNUSED, - Ector_Renderer_Generic_Shape_Data *pd) +_ector_renderer_generic_shape_stroke_fill_get(Eo *obj EINA_UNUSED, + Ector_Renderer_Generic_Shape_Data *pd) { return pd->stroke.fill; } static void -_ector_renderer_shape_stroke_marker_set(Eo *obj EINA_UNUSED, - Ector_Renderer_Generic_Shape_Data *pd, - const Ector_Renderer *r) +_ector_renderer_generic_shape_stroke_marker_set(Eo *obj EINA_UNUSED, + Ector_Renderer_Generic_Shape_Data *pd, + const Ector_Renderer *r) { _ector_renderer_replace(&pd->stroke.marker, r); } static const Ector_Renderer * -_ector_renderer_shape_stroke_marker_get(Eo *obj EINA_UNUSED, - Ector_Renderer_Generic_Shape_Data *pd) +_ector_renderer_generic_shape_stroke_marker_get(Eo *obj EINA_UNUSED, + Ector_Renderer_Generic_Shape_Data *pd) { return pd->stroke.marker; } static void -_ector_renderer_shape_efl_graphics_shape_stroke_scale_set(Eo *obj EINA_UNUSED, - Ector_Renderer_Generic_Shape_Data *pd, - double s) +_ector_renderer_generic_shape_efl_graphics_shape_stroke_scale_set(Eo *obj EINA_UNUSED, + Ector_Renderer_Generic_Shape_Data *pd, + double s) { pd->stroke.scale = s; } static double -_ector_renderer_shape_efl_graphics_shape_stroke_scale_get(Eo *obj EINA_UNUSED, - Ector_Renderer_Generic_Shape_Data *pd) +_ector_renderer_generic_shape_efl_graphics_shape_stroke_scale_get(Eo *obj EINA_UNUSED, + Ector_Renderer_Generic_Shape_Data *pd) { return pd->stroke.scale; } static void -_ector_renderer_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_graphics_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_shape_efl_graphics_shape_stroke_color_set(Eo *obj EINA_UNUSED, } static void -_ector_renderer_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_graphics_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,40 +90,40 @@ _ector_renderer_shape_efl_graphics_shape_stroke_color_get(Eo *obj EINA_UNUSED, } static void -_ector_renderer_shape_efl_graphics_shape_stroke_width_set(Eo *obj EINA_UNUSED, - Ector_Renderer_Generic_Shape_Data *pd, - double w) +_ector_renderer_generic_shape_efl_graphics_shape_stroke_width_set(Eo *obj EINA_UNUSED, + Ector_Renderer_Generic_Shape_Data *pd, + double w) { pd->stroke.width = w; } static double -_ector_renderer_shape_efl_graphics_shape_stroke_width_get(Eo *obj EINA_UNUSED, - Ector_Renderer_Generic_Shape_Data *pd) +_ector_renderer_generic_shape_efl_graphics_shape_stroke_width_get(Eo *obj EINA_UNUSED, + Ector_Renderer_Generic_Shape_Data *pd) { return pd->stroke.width; } static void -_ector_renderer_shape_efl_graphics_shape_stroke_location_set(Eo *obj EINA_UNUSED, - Ector_Renderer_Generic_Shape_Data *pd, - double centered) +_ector_renderer_generic_shape_efl_graphics_shape_stroke_location_set(Eo *obj EINA_UNUSED, + Ector_Renderer_Generic_Shape_Data *pd, + double centered) { pd->stroke.centered = centered; } static double -_ector_renderer_shape_efl_graphics_shape_stroke_location_get(Eo *obj EINA_UNUSED, - Ector_Renderer_Generic_Shape_Data *pd) +_ector_renderer_generic_shape_efl_graphics_shape_stroke_location_get(Eo *obj EINA_UNUSED, + Ector_Renderer_Generic_Shape_Data *pd) { return pd->stroke.centered; } static void -_ector_renderer_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_graphics_shape_stroke_dash_set(Eo *obj EINA_UNUSED, + Ector_Renderer_Generic_Shape_Data *pd, + const Efl_Graphics_Dash *dash, + unsigned int length) { Efl_Graphics_Dash *tmp; @@ -144,50 +144,50 @@ _ector_renderer_shape_efl_graphics_shape_stroke_dash_set(Eo *obj EINA_UNUSED, } static void -_ector_renderer_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_graphics_shape_stroke_dash_get(Eo *obj EINA_UNUSED, + Ector_Renderer_Generic_Shape_Data *pd, + const Efl_Graphics_Dash **dash, + unsigned int *length) { if (dash) *dash = pd->stroke.dash; if (length) *length = pd->stroke.dash_length; } static void -_ector_renderer_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_graphics_shape_stroke_cap_set(Eo *obj EINA_UNUSED, + Ector_Renderer_Generic_Shape_Data *pd, + Efl_Graphics_Cap c) { pd->stroke.cap = c; } static Efl_Graphics_Cap -_ector_renderer_shape_efl_graphics_shape_stroke_cap_get(Eo *obj EINA_UNUSED, - Ector_Renderer_Generic_Shape_Data *pd) +_ector_renderer_generic_shape_efl_graphics_shape_stroke_cap_get(Eo *obj EINA_UNUSED, + Ector_Renderer_Generic_Shape_Data *pd) { return pd->stroke.cap; } static void -_ector_renderer_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_graphics_shape_stroke_join_set(Eo *obj EINA_UNUSED, + Ector_Renderer_Generic_Shape_Data *pd, + Efl_Graphics_Join j) { pd->stroke.join = j; } static Efl_Graphics_Join -_ector_renderer_shape_efl_graphics_shape_stroke_join_get(Eo *obj EINA_UNUSED, - Ector_Renderer_Generic_Shape_Data *pd) +_ector_renderer_generic_shape_efl_graphics_shape_stroke_join_get(Eo *obj EINA_UNUSED, + Ector_Renderer_Generic_Shape_Data *pd) { return pd->stroke.join; } static Eina_Bool -_ector_renderer_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_graphics_shape_path_set(Eo *obj EINA_UNUSED, + Ector_Renderer_Generic_Shape_Data *pd, + const Efl_Graphics_Path_Command *cmd, + const double *points) { free(pd->path.cmd); pd->path.cmd = NULL; @@ -198,13 +198,13 @@ _ector_renderer_shape_efl_graphics_shape_path_set(Eo *obj EINA_UNUSED, } static void -_ector_renderer_shape_eo_base_constructor(Eo *obj, - Ector_Renderer_Generic_Shape_Data *pd) +_ector_renderer_generic_shape_eo_base_constructor(Eo *obj, + Ector_Renderer_Generic_Shape_Data *pd) { } static void -_ector_renderer_shape_eo_base_destructor(Eo *obj, Ector_Renderer_Generic_Shape_Data *pd) +_ector_renderer_generic_shape_eo_base_destructor(Eo *obj, Ector_Renderer_Generic_Shape_Data *pd) { } From 33d538643a5011cf8321a0883ff2034bf2403204 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:22:00 +0200 Subject: [PATCH 046/251] ector: add a base interface for all cairo renderer. --- src/Makefile_Ector.am | 1 + src/lib/ector/cairo/ector_renderer_cairo_base.eo | 9 +++++++++ 2 files changed, 10 insertions(+) create mode 100644 src/lib/ector/cairo/ector_renderer_cairo_base.eo diff --git a/src/Makefile_Ector.am b/src/Makefile_Ector.am index 2327bc6b6c..dca175f53a 100644 --- a/src/Makefile_Ector.am +++ b/src/Makefile_Ector.am @@ -11,6 +11,7 @@ ector_eolian_files = \ # Handle cairo backend ector_eolian_files += \ lib/ector/cairo/ector_cairo_surface.eo \ + lib/ector/cairo/ector_renderer_cairo_base.eo \ lib/ector/cairo/ector_renderer_cairo_shape.eo \ lib/ector/cairo/ector_renderer_cairo_gradient_linear.eo \ lib/ector/cairo/ector_renderer_cairo_gradient_radial.eo diff --git a/src/lib/ector/cairo/ector_renderer_cairo_base.eo b/src/lib/ector/cairo/ector_renderer_cairo_base.eo new file mode 100644 index 0000000000..70757108ff --- /dev/null +++ b/src/lib/ector/cairo/ector_renderer_cairo_base.eo @@ -0,0 +1,9 @@ +interface Ector.Renderer.Cairo.Base +{ + legacy_prefix: null; + methods { + fill { + return: bool; + } + } +} From fdf3942aa0b9134229c57d7a153b23494f17b81b Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:22:01 +0200 Subject: [PATCH 047/251] ector: first implementation of a Cairo surface. --- src/Makefile_Ector.am | 3 +- src/lib/ector/cairo/ector_cairo_private.h | 31 ++++++++ src/lib/ector/cairo/ector_cairo_surface.c | 84 ++++++++++++++++++---- src/lib/ector/cairo/ector_cairo_surface.eo | 22 +++--- 4 files changed, 119 insertions(+), 21 deletions(-) create mode 100644 src/lib/ector/cairo/ector_cairo_private.h diff --git a/src/Makefile_Ector.am b/src/Makefile_Ector.am index dca175f53a..5b0fbd1411 100644 --- a/src/Makefile_Ector.am +++ b/src/Makefile_Ector.am @@ -94,4 +94,5 @@ tests_ector_ector_suite_DEPENDENCIES = @USE_ECTOR_INTERNAL_LIBS@ endif EXTRA_DIST += \ -src/lib/ector/ector_private.h +src/lib/ector/ector_private.h \ +src/lib/ector/cairo/ector_cairo_private,h diff --git a/src/lib/ector/cairo/ector_cairo_private.h b/src/lib/ector/cairo/ector_cairo_private.h new file mode 100644 index 0000000000..6777370be4 --- /dev/null +++ b/src/lib/ector/cairo/ector_cairo_private.h @@ -0,0 +1,31 @@ +#ifndef ECTOR_CAIRO_PRIVATE_H_ +# define ECTOR_CAIRO_PRIVATE_H_ + +typedef void cairo_pattern_t; + +typedef struct _Ector_Cairo_Surface_Data Ector_Cairo_Surface_Data; +struct _Ector_Cairo_Surface_Data +{ + cairo_t *cairo; +}; + +#define USE(Obj, Sym, Error) \ + if (!Sym) _ector_cairo_symbol_get(Obj, #Sym); \ + if (!Sym) return Error; + +#define CHECK_CAIRO(Parent) (!(Parent && Parent->cairo)) + +static inline void * +_ector_cairo_symbol_get(Eo *obj, const char *name) +{ + Eo *parent; + void *sym; + + eo_do(obj, parent = eo_parent_get()); + if (!parent) return NULL; + + eo_do(parent, sym = ector_cairo_surface_symbol_get(name)); + return sym; +} + +#endif diff --git a/src/lib/ector/cairo/ector_cairo_surface.c b/src/lib/ector/cairo/ector_cairo_surface.c index 06f8ed760a..c2d42a9b87 100644 --- a/src/lib/ector/cairo/ector_cairo_surface.c +++ b/src/lib/ector/cairo/ector_cairo_surface.c @@ -7,30 +7,90 @@ #include #include "ector_private.h" +#include "ector_cairo_private.h" -typedef struct _Ector_Cairo_Surface_Data Ector_Cairo_Surface_Data; -struct _Ector_Cairo_Surface_Data -{ -}; +static unsigned int _cairo_count = 0; +static Eina_Module *_cairo_so = NULL; -void * -_ector_cairo_surface_symbol_get(Eo *obj, Ector_Cairo_Surface_Data *pd, char *name) +static void * +_ector_cairo_surface_symbol_get(Eo *obj EINA_UNUSED, + Ector_Cairo_Surface_Data *pd EINA_UNUSED, + const char *name) { + if (!_cairo_so) + { +#define LOAD(x) \ + if (!_cairo_so) \ + { \ + _cairo_so = eina_module_new(x); \ + if (_cairo_so && \ + !eina_module_load(_cairo_so)) \ + { \ + eina_module_free(_cairo_so); \ + _cairo_so = NULL; \ + } \ + } +#if defined(_WIN32) || defined(__CYGWIN__) + LOAD("libcairo.dll"); +#elif defined(__APPLE__) && defined(__MACH__) + LOAD("libcairo.dylib"); + LOAD("libcairo.so"); +#else + LOAD("libcairo.so"); +#endif + +#undef LOAD + } + + return eina_module_symbol_get(_cairo_so, name); } -Ector_Renderer * -_ector_cairo_surface_ector_generic_surface_renderer_factory_new(Eo *obj, Ector_Cairo_Surface_Data *pd, const Eo_Class *type) + +static Ector_Renderer * +_ector_cairo_surface_ector_generic_surface_renderer_factory_new(Eo *obj, + Ector_Cairo_Surface_Data *pd EINA_UNUSED, + const Eo_Class *type) { + if (eo_isa(type, ECTOR_RENDERER_CAIRO_SHAPE_CLASS)) + return eo_add(ECTOR_RENDERER_CAIRO_SHAPE_CLASS, obj); + else if (eo_isa(type, ECTOR_RENDERER_CAIRO_GRADIENT_LINEAR_CLASS)) + return eo_add(ECTOR_RENDERER_CAIRO_GRADIENT_LINEAR_CLASS, obj); + else if (eo_isa(type, ECTOR_RENDERER_CAIRO_GRADIENT_RADIAL_CLASS)) + return eo_add(ECTOR_RENDERER_CAIRO_GRADIENT_RADIAL_CLASS, obj); + return NULL; } -Eina_Bool -_ector_cairo_surface_context_set(Eo *obj, Ector_Cairo_Surface_Data *pd, cairo_t *ctx) +static void +_ector_cairo_surface_context_set(Eo *obj EINA_UNUSED, + Ector_Cairo_Surface_Data *pd, + cairo_t *ctx) { + pd->cairo = ctx; } -Eo * -_ector_cairo_surface_eo_base_finalize(Eo *obj, Ector_Cairo_Surface_Data *pd) +static cairo_t * +_ector_cairo_surface_context_get(Eo *obj EINA_UNUSED, + Ector_Cairo_Surface_Data *pd) { + return pd->cairo; } +static void +_ector_cairo_surface_eo_base_constructor(Eo *obj EINA_UNUSED, + Ector_Cairo_Surface_Data *pd EINA_UNUSED) +{ + _cairo_count++; +} + +static void +_ector_cairo_surface_eo_base_destructor(Eo *obj EINA_UNUSED, + Ector_Cairo_Surface_Data *pd EINA_UNUSED) +{ + if (--_cairo_count) return ; + if (_cairo_so) eina_module_free(_cairo_so); + _cairo_so = NULL; +} + + #include "ector_cairo_surface.eo.c" +#include "ector_renderer_cairo_base.eo.c" diff --git a/src/lib/ector/cairo/ector_cairo_surface.eo b/src/lib/ector/cairo/ector_cairo_surface.eo index 8a3676770b..10f6d9f30e 100644 --- a/src/lib/ector/cairo/ector_cairo_surface.eo +++ b/src/lib/ector/cairo/ector_cairo_surface.eo @@ -2,22 +2,28 @@ class Ector.Cairo.Surface (Ector.Generic.Surface) { eo_prefix: ector_cairo_surface; legacy_prefix: null; + properties { + context { + set { + } + get { + } + values { + cairo_t *ctx; + } + } + } methods { symbol_get { return: void * @warn_unused; params { - @in char* name; + @in const(char)* name; } } - context_set { - return: Eina_Bool; - params { - @in cairo_t *ctx; - } - } } implements { Ector.Generic.Surface.renderer_factory_new; - Eo.Base.finalize; + Eo.Base.destructor; + Eo.Base.constructor; } } From ea8f37e47d68b429f725c8f54a2c9bc291a77d8e Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:22:02 +0200 Subject: [PATCH 048/251] ector: first try at implementing linear gradient renderer. --- .../ector_renderer_cairo_gradient_linear.c | 107 +++++++++++++++++- .../ector_renderer_cairo_gradient_linear.eo | 6 +- 2 files changed, 108 insertions(+), 5 deletions(-) diff --git a/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c b/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c index 364c3b37b3..78b0504229 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c @@ -4,27 +4,128 @@ #include #include +#include #include "ector_private.h" +#include "ector_cairo_private.h" + +static cairo_pattern_t *(*cairo_pattern_create_linear)(double x0, double y0, + double x1, double y1) = NULL; +static void (*cairo_set_source)(cairo_t *cr, cairo_pattern_t *source) = NULL; +static void (*cairo_fill)(cairo_t *cr) = NULL; +static void (*cairo_rectangle)(cairo_t *cr, + double x, double y, + double width, double height) = NULL; +static void (*cairo_pattern_add_color_stop_rgba)(cairo_pattern_t *pattern, double offset, + double red, double green, double blue, double alpha) = NULL; +static void (*cairo_pattern_destroy)(cairo_pattern_t *pattern) = NULL; typedef struct _Ector_Renderer_Cairo_Gradient_Linear_Data Ector_Renderer_Cairo_Gradient_Linear_Data; struct _Ector_Renderer_Cairo_Gradient_Linear_Data { + Ector_Cairo_Surface_Data *parent; + cairo_pattern_t *pat; }; static Eina_Bool -_ector_renderer_cairo_gradient_linear_ector_renderer_generic_base_prepare(Eo *obj, Ector_Renderer_Cairo_Gradient_Linear_Data *pd, Ector_Surface *s) +_ector_renderer_cairo_gradient_linear_ector_renderer_generic_base_prepare(Eo *obj, + Ector_Renderer_Cairo_Gradient_Linear_Data *pd, + Ector_Surface *s EINA_UNUSED) { + Ector_Renderer_Generic_Gradient_Linear_Data *gld; + Ector_Renderer_Generic_Gradient_Data *gd; + unsigned int i; + + if (pd->pat) return EINA_FALSE; + + gld = eo_data_scope_get(obj, ECTOR_RENDERER_GENERIC_GRADIENT_LINEAR_CLASS); + gd = eo_data_scope_get(obj, ECTOR_RENDERER_GENERIC_GRADIENT_CLASS); + if (!gld || !gd) return EINA_FALSE; + + USE(obj, cairo_pattern_create_linear, EINA_FALSE); + USE(obj, cairo_pattern_add_color_stop_rgba, EINA_FALSE); + + pd->pat = cairo_pattern_create_linear(gld->start.x, gld->start.y, + gld->end.x, gld->end.y); + for (i = 0; i < gd->colors_count; i++) + cairo_pattern_add_color_stop_rgba(pd->pat, gd->colors[i].offset, + gd->colors[i].r, gd->colors[i].g, + gd->colors[i].b, gd->colors[i].a); + + if (!pd->parent) + { + Eo *parent; + + eo_do(obj, parent = eo_parent_get()); + if (!parent) return EINA_FALSE; + pd->parent = eo_data_xref(parent, ECTOR_CAIRO_SURFACE_CLASS, obj); + } + + return EINA_FALSE; } static Eina_Bool -_ector_renderer_cairo_gradient_linear_ector_renderer_generic_base_draw(Eo *obj, Ector_Renderer_Cairo_Gradient_Linear_Data *pd, Ector_Surface *s, Ector_Rop op, Eina_Array *clips, int x, int y) +_ector_renderer_cairo_gradient_linear_ector_renderer_generic_base_draw(Eo *obj, + Ector_Renderer_Cairo_Gradient_Linear_Data *pd, + Ector_Surface *s, Ector_Rop op, Eina_Array *clips, int x, int y) { + Ector_Renderer_Generic_Gradient_Linear_Data *gld; + + // FIXME: don't ignore clipping and offset ! + gld = eo_data_scope_get(obj, ECTOR_RENDERER_GENERIC_GRADIENT_LINEAR_CLASS); + if (!pd->pat || !gld || CHECK_CAIRO(pd->parent)) return EINA_FALSE; + + USE(obj, cairo_rectangle, EINA_FALSE); + + cairo_rectangle(pd->parent->cairo, gld->start.x, gld->start.y, + gld->end.x - gld->start.x, gld->end.y - gld->start.y); + eo_do(obj, ector_renderer_cairo_base_fill()); + cairo_fill(pd->parent->cairo); + + return EINA_TRUE; } static Eina_Bool -_ector_renderer_cairo_gradient_linear_ector_renderer_generic_base_done(Eo *obj, Ector_Renderer_Cairo_Gradient_Linear_Data *pd) +_ector_renderer_cairo_gradient_linear_ector_renderer_cairo_base_fill(Eo *obj, + Ector_Renderer_Cairo_Gradient_Linear_Data *pd) { + if (!pd->pat || CHECK_CAIRO(pd->parent)) return EINA_FALSE; + + USE(obj, cairo_set_source, EINA_FALSE); + USE(obj, cairo_fill, EINA_FALSE); + + cairo_set_source(pd->parent->cairo, pd->pat); + + return EINA_TRUE; +} + +void +_ector_renderer_cairo_gradient_linear_eo_base_destructor(Eo *obj, + Ector_Renderer_Cairo_Gradient_Linear_Data *pd) +{ + Eo *parent; + + USE(obj, cairo_pattern_destroy, ); + + if (pd->pat) cairo_pattern_destroy(pd->pat); + pd->pat = NULL; + + eo_do(obj, parent = eo_parent_get()); + eo_data_xunref(parent, pd->parent, obj); + + eo_do_super(obj, ECTOR_RENDERER_CAIRO_GRADIENT_LINEAR_CLASS, eo_constructor()); +} + +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) +{ + USE(obj, cairo_pattern_destroy, ); + + if (pd->pat) cairo_pattern_destroy(pd->pat); + pd->pat = NULL; + + eo_do_super(obj, ECTOR_RENDERER_CAIRO_GRADIENT_LINEAR_CLASS, + efl_graphics_gradient_stop_set(colors, length)); } #include "ector_renderer_cairo_gradient_linear.eo.c" diff --git a/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.eo b/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.eo index 3b25734de7..61e8e28436 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.eo +++ b/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.eo @@ -1,10 +1,12 @@ -class Ector.Renderer.Cairo.Gradient_Linear (Ector.Renderer.Generic.Gradient_Linear) +class Ector.Renderer.Cairo.Gradient_Linear (Ector.Renderer.Cairo.Base, Ector.Renderer.Generic.Gradient_Linear) { eo_prefix: ector_renderer_cairo_gradient_linear; legacy_prefix: null; implements { Ector.Renderer.Generic.Base.prepare; Ector.Renderer.Generic.Base.draw; - Ector.Renderer.Generic.Base.done; + Ector.Renderer.Cairo.Base.fill; + Eo.Base.destructor; + Efl.Graphics.Gradient.stop.set; } } From 7417c034bf283e042bf5880620dd944c6c0ad92e Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:22:03 +0200 Subject: [PATCH 049/251] ector: cairo need a specialized fill function. --- src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c | 7 +++++++ .../ector/cairo/ector_renderer_cairo_gradient_radial.eo | 3 ++- src/lib/ector/cairo/ector_renderer_cairo_shape.c | 7 +++++++ src/lib/ector/cairo/ector_renderer_cairo_shape.eo | 3 ++- 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c b/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c index c1e03adc45..24800039dd 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c @@ -4,8 +4,10 @@ #include #include +#include #include "ector_private.h" +#include "ector_cairo_private.h" typedef struct _Ector_Renderer_Cairo_Gradient_Radial_Data Ector_Renderer_Cairo_Gradient_Radial_Data; struct _Ector_Renderer_Cairo_Gradient_Radial_Data @@ -27,4 +29,9 @@ _ector_renderer_cairo_gradient_radial_ector_renderer_generic_base_done(Eo *obj, { } +static Eina_Bool +_ector_renderer_cairo_gradient_radial_ector_renderer_cairo_base_fill(Eo *obj, Ector_Renderer_Cairo_Gradient_Radial_Data *pd) +{ +} + #include "ector_renderer_cairo_gradient_radial.eo.c" diff --git a/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.eo b/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.eo index 6aeb7507d2..918fe57e1d 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.eo +++ b/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.eo @@ -1,4 +1,4 @@ -class Ector.Renderer.Cairo.Gradient_Radial (Ector.Renderer.Generic.Gradient_Radial) +class Ector.Renderer.Cairo.Gradient_Radial (Ector.Renderer.Cairo.Base, Ector.Renderer.Generic.Gradient_Radial) { eo_prefix: ector_renderer_cairo_gradient_radial; legacy_prefix: null; @@ -6,5 +6,6 @@ class Ector.Renderer.Cairo.Gradient_Radial (Ector.Renderer.Generic.Gradient_Radi Ector.Renderer.Generic.Base.prepare; Ector.Renderer.Generic.Base.draw; Ector.Renderer.Generic.Base.done; + Ector.Renderer.Cairo.Base.fill; } } diff --git a/src/lib/ector/cairo/ector_renderer_cairo_shape.c b/src/lib/ector/cairo/ector_renderer_cairo_shape.c index 6b9b32925b..b760e54291 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_shape.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_shape.c @@ -4,8 +4,10 @@ #include #include +#include #include "ector_private.h" +#include "ector_cairo_private.h" typedef struct _Ector_Renderer_Cairo_Shape_Data Ector_Renderer_Cairo_Shape_Data; struct _Ector_Renderer_Cairo_Shape_Data @@ -27,4 +29,9 @@ _ector_renderer_cairo_shape_ector_renderer_generic_base_done(Eo *obj, Ector_Rend { } +static Eina_Bool +_ector_renderer_cairo_shape_ector_renderer_cairo_base_fill(Eo *obj, Ector_Renderer_Cairo_Shape_Data *pd) +{ +} + #include "ector_renderer_cairo_shape.eo.c" diff --git a/src/lib/ector/cairo/ector_renderer_cairo_shape.eo b/src/lib/ector/cairo/ector_renderer_cairo_shape.eo index d1a8e8c983..b923f6f6a3 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_shape.eo +++ b/src/lib/ector/cairo/ector_renderer_cairo_shape.eo @@ -1,4 +1,4 @@ -class Ector.Renderer.Cairo.Shape (Ector.Renderer.Generic.Shape) +class Ector.Renderer.Cairo.Shape (Ector.Renderer.Cairo.Base, Ector.Renderer.Generic.Shape) { eo_prefix: ector_renderer_cairo_shape; legacy_prefix: null; @@ -6,5 +6,6 @@ class Ector.Renderer.Cairo.Shape (Ector.Renderer.Generic.Shape) Ector.Renderer.Generic.Base.prepare; Ector.Renderer.Generic.Base.draw; Ector.Renderer.Generic.Base.done; + Ector.Renderer.Cairo.Base.fill; } } From d6cd365a48d8584648ad4acf4c9fa1a8e0901cf3 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:22:04 +0200 Subject: [PATCH 050/251] ector: now import header of all cairo renderer. --- src/lib/ector/cairo/Ector_Cairo.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lib/ector/cairo/Ector_Cairo.h b/src/lib/ector/cairo/Ector_Cairo.h index a11a53f646..e368ca2803 100644 --- a/src/lib/ector/cairo/Ector_Cairo.h +++ b/src/lib/ector/cairo/Ector_Cairo.h @@ -7,5 +7,9 @@ typedef Eo Ector_Cairo_Surface; typedef struct _cairo_t cairo_t; #include "cairo/ector_cairo_surface.eo.h" +#include "cairo/ector_renderer_cairo_base.eo.h" +#include "cairo/ector_renderer_cairo_shape.eo.h" +#include "cairo/ector_renderer_cairo_gradient_linear.eo.h" +#include "cairo/ector_renderer_cairo_gradient_radial.eo.h" #endif From 1a6dfd76e70dbc38aa62c9048647574419778335 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:22:06 +0200 Subject: [PATCH 051/251] eo_cxx: fix after change in internal function naming of Eo. --- src/bindings/eo_cxx/eo_inherit_bindings.hh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/bindings/eo_cxx/eo_inherit_bindings.hh b/src/bindings/eo_cxx/eo_inherit_bindings.hh index e560b06adf..73fc2b1554 100644 --- a/src/bindings/eo_cxx/eo_inherit_bindings.hh +++ b/src/bindings/eo_cxx/eo_inherit_bindings.hh @@ -235,23 +235,23 @@ template EAPI void inherit_constructor(void* this_, Args args) { typedef void (*func_t)(Eo *, void *, void*, Args); - Eo_Op_Call_Data call; + Eo_Op_Call_Data ___call; static Eo_Op op = EO_NOOP; if ( op == EO_NOOP ) op = _eo_api_op_id_get (reinterpret_cast (static_cast(&detail::inherit_constructor)), ::eina_main_loop_is(), __FILE__, __LINE__); - if (!_eo_call_resolve("detail::inherit_constructor", op, &call, + if (!_eo_call_resolve("detail::inherit_constructor", op, &___call, ::eina_main_loop_is(), __FILE__, __LINE__)) { - assert(_eo_call_resolve("detail::inherit_constructor", op, &call, + assert(_eo_call_resolve("detail::inherit_constructor", op, &___call, ::eina_main_loop_is(), __FILE__, __LINE__)); return; } - func_t func = (func_t) call.func; + func_t func = (func_t) ___call.func; EO_HOOK_CALL_PREPARE(eo_hook_call_pre, ""); - func(call.obj, call.data, this_, args); + func(___call.obj, ___call.data, this_, args); EO_HOOK_CALL_PREPARE(eo_hook_call_post, ""); } From 48beef6b21476d0873ae0e72f0f0a1f43932a47f Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:22:07 +0200 Subject: [PATCH 052/251] ector: fix cairo linear gradient implementation. --- .../ector/cairo/ector_renderer_cairo_gradient_linear.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c b/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c index 78b0504229..3379f9e103 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c @@ -71,14 +71,15 @@ _ector_renderer_cairo_gradient_linear_ector_renderer_generic_base_draw(Eo *obj, { Ector_Renderer_Generic_Gradient_Linear_Data *gld; - // FIXME: don't ignore clipping and offset ! + // FIXME: don't ignore clipping ! gld = eo_data_scope_get(obj, ECTOR_RENDERER_GENERIC_GRADIENT_LINEAR_CLASS); if (!pd->pat || !gld || CHECK_CAIRO(pd->parent)) return EINA_FALSE; USE(obj, cairo_rectangle, EINA_FALSE); - cairo_rectangle(pd->parent->cairo, gld->start.x, gld->start.y, - gld->end.x - gld->start.x, gld->end.y - gld->start.y); + cairo_rectangle(pd->parent->cairo, gld->start.x - x, gld->start.y - y, + gld->end.x - gld->start.x, + gld->end.y - gld->start.y); eo_do(obj, ector_renderer_cairo_base_fill()); cairo_fill(pd->parent->cairo); @@ -92,7 +93,6 @@ _ector_renderer_cairo_gradient_linear_ector_renderer_cairo_base_fill(Eo *obj, if (!pd->pat || CHECK_CAIRO(pd->parent)) return EINA_FALSE; USE(obj, cairo_set_source, EINA_FALSE); - USE(obj, cairo_fill, EINA_FALSE); cairo_set_source(pd->parent->cairo, pd->pat); @@ -113,7 +113,7 @@ _ector_renderer_cairo_gradient_linear_eo_base_destructor(Eo *obj, eo_do(obj, parent = eo_parent_get()); eo_data_xunref(parent, pd->parent, obj); - eo_do_super(obj, ECTOR_RENDERER_CAIRO_GRADIENT_LINEAR_CLASS, eo_constructor()); + eo_do_super(obj, ECTOR_RENDERER_CAIRO_GRADIENT_LINEAR_CLASS, eo_destructor()); } void From 60e4edd7b9a2ac9cdba56e43e777bc9bf4fea093 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:22:08 +0200 Subject: [PATCH 053/251] ector: start implementing radial gradient in cairo backend. --- .../ector_renderer_cairo_gradient_radial.c | 105 +++++++++++++++++- .../ector_renderer_cairo_gradient_radial.eo | 3 +- 2 files changed, 102 insertions(+), 6 deletions(-) diff --git a/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c b/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c index 24800039dd..55fa5455c7 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c @@ -9,29 +9,124 @@ #include "ector_private.h" #include "ector_cairo_private.h" +static cairo_pattern_t *(*cairo_pattern_create_radial)(double cx0, double cy0, + double radius0, + double cx1, double cy1, + double radius1) = NULL; +static void (*cairo_set_source)(cairo_t *cr, cairo_pattern_t *source) = NULL; +static void (*cairo_fill)(cairo_t *cr) = NULL; +static void (*cairo_rectangle)(cairo_t *cr, + double x, double y, + double width, double height) = NULL; +static void (*cairo_pattern_add_color_stop_rgba)(cairo_pattern_t *pattern, double offset, + double red, double green, double blue, double alpha) = NULL; +static void (*cairo_pattern_destroy)(cairo_pattern_t *pattern) = NULL; + + +// FIXME: as long as it is not possible to directly access the parent structure +// this will be duplicated from the linear gradient renderer typedef struct _Ector_Renderer_Cairo_Gradient_Radial_Data Ector_Renderer_Cairo_Gradient_Radial_Data; struct _Ector_Renderer_Cairo_Gradient_Radial_Data { + Ector_Cairo_Surface_Data *parent; + cairo_pattern_t *pat; }; static Eina_Bool _ector_renderer_cairo_gradient_radial_ector_renderer_generic_base_prepare(Eo *obj, Ector_Renderer_Cairo_Gradient_Radial_Data *pd, Ector_Surface *s) { + Ector_Renderer_Generic_Gradient_Radial_Data *grd; + Ector_Renderer_Generic_Gradient_Data *gd; + unsigned int i; + + if (pd->pat) return EINA_FALSE; + + grd = eo_data_scope_get(obj, ECTOR_RENDERER_GENERIC_GRADIENT_RADIAL_CLASS); + gd = eo_data_scope_get(obj, ECTOR_RENDERER_GENERIC_GRADIENT_CLASS); + if (!grd || !gd) return EINA_FALSE; + + USE(obj, cairo_pattern_create_radial, EINA_FALSE); + USE(obj, cairo_pattern_add_color_stop_rgba, EINA_FALSE); + + pd->pat = cairo_pattern_create_radial(grd->focal.x, grd->focal.y, 0, + grd->radial.x, grd->radial.y, grd->radius); + for (i = 0; i < gd->colors_count; i++) + cairo_pattern_add_color_stop_rgba(pd->pat, gd->colors[i].offset, + gd->colors[i].r, gd->colors[i].g, + gd->colors[i].b, gd->colors[i].a); + + if (!pd->parent) + { + Eo *parent; + + eo_do(obj, parent = eo_parent_get()); + if (!parent) return EINA_FALSE; + pd->parent = eo_data_xref(parent, ECTOR_CAIRO_SURFACE_CLASS, obj); + } + + return EINA_FALSE; } +// Clearly duplicated and should be in a common place... static Eina_Bool _ector_renderer_cairo_gradient_radial_ector_renderer_generic_base_draw(Eo *obj, Ector_Renderer_Cairo_Gradient_Radial_Data *pd, Ector_Surface *s, Ector_Rop op, Eina_Array *clips, int x, int y) { + Ector_Renderer_Generic_Gradient_Linear_Data *gld; + + // FIXME: don't ignore clipping ! + gld = eo_data_scope_get(obj, ECTOR_RENDERER_GENERIC_GRADIENT_LINEAR_CLASS); + if (!pd->pat || !gld || CHECK_CAIRO(pd->parent)) return EINA_FALSE; + + USE(obj, cairo_rectangle, EINA_FALSE); + + cairo_rectangle(pd->parent->cairo, gld->start.x - x, gld->start.y - y, + gld->end.x - gld->start.x, gld->end.y - gld->start.y); + eo_do(obj, ector_renderer_cairo_base_fill()); + cairo_fill(pd->parent->cairo); + + return EINA_TRUE; } -static Eina_Bool -_ector_renderer_cairo_gradient_radial_ector_renderer_generic_base_done(Eo *obj, Ector_Renderer_Cairo_Gradient_Radial_Data *pd) -{ -} - +// Clearly duplicated and should be in a common place... static Eina_Bool _ector_renderer_cairo_gradient_radial_ector_renderer_cairo_base_fill(Eo *obj, Ector_Renderer_Cairo_Gradient_Radial_Data *pd) { + if (!pd->pat || CHECK_CAIRO(pd->parent)) return EINA_FALSE; + + USE(obj, cairo_set_source, EINA_FALSE); + + cairo_set_source(pd->parent->cairo, pd->pat); + + return EINA_TRUE; +} + +void +_ector_renderer_cairo_gradient_radial_eo_base_destructor(Eo *obj, + Ector_Renderer_Cairo_Gradient_Radial_Data *pd) +{ + Eo *parent; + + USE(obj, cairo_pattern_destroy, ); + + if (pd->pat) cairo_pattern_destroy(pd->pat); + pd->pat = NULL; + + eo_do(obj, parent = eo_parent_get()); + eo_data_xunref(parent, pd->parent, obj); + + eo_do_super(obj, ECTOR_RENDERER_CAIRO_GRADIENT_RADIAL_CLASS, eo_destructor()); +} + +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) +{ + USE(obj, cairo_pattern_destroy, ); + + if (pd->pat) cairo_pattern_destroy(pd->pat); + pd->pat = NULL; + + eo_do_super(obj, ECTOR_RENDERER_CAIRO_GRADIENT_LINEAR_CLASS, + efl_graphics_gradient_stop_set(colors, length)); } #include "ector_renderer_cairo_gradient_radial.eo.c" diff --git a/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.eo b/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.eo index 918fe57e1d..db179c91e5 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.eo +++ b/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.eo @@ -5,7 +5,8 @@ class Ector.Renderer.Cairo.Gradient_Radial (Ector.Renderer.Cairo.Base, Ector.Ren implements { Ector.Renderer.Generic.Base.prepare; Ector.Renderer.Generic.Base.draw; - Ector.Renderer.Generic.Base.done; Ector.Renderer.Cairo.Base.fill; + Eo.Base.destructor; + Efl.Graphics.Gradient.stop.set; } } From 7ba0f46a39ced6d516248cf612e4a525479fc44a Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:22:10 +0200 Subject: [PATCH 054/251] ector: remove surface from draw command as it should be drawn on the parent, always ! --- src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c | 2 +- src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c | 2 +- src/lib/ector/cairo/ector_renderer_cairo_shape.c | 2 +- src/lib/ector/ector_renderer_generic_base.eo | 1 - 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c b/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c index 3379f9e103..bdf5c361df 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c @@ -67,7 +67,7 @@ _ector_renderer_cairo_gradient_linear_ector_renderer_generic_base_prepare(Eo *ob static Eina_Bool _ector_renderer_cairo_gradient_linear_ector_renderer_generic_base_draw(Eo *obj, Ector_Renderer_Cairo_Gradient_Linear_Data *pd, - Ector_Surface *s, Ector_Rop op, Eina_Array *clips, int x, int y) + Ector_Rop op, Eina_Array *clips, int x, int y) { Ector_Renderer_Generic_Gradient_Linear_Data *gld; diff --git a/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c b/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c index 55fa5455c7..d22f71039c 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c @@ -69,7 +69,7 @@ _ector_renderer_cairo_gradient_radial_ector_renderer_generic_base_prepare(Eo *ob // Clearly duplicated and should be in a common place... static Eina_Bool -_ector_renderer_cairo_gradient_radial_ector_renderer_generic_base_draw(Eo *obj, Ector_Renderer_Cairo_Gradient_Radial_Data *pd, Ector_Surface *s, Ector_Rop op, Eina_Array *clips, int x, int y) +_ector_renderer_cairo_gradient_radial_ector_renderer_generic_base_draw(Eo *obj, Ector_Renderer_Cairo_Gradient_Radial_Data *pd, Ector_Rop op, Eina_Array *clips, int x, int y) { Ector_Renderer_Generic_Gradient_Linear_Data *gld; diff --git a/src/lib/ector/cairo/ector_renderer_cairo_shape.c b/src/lib/ector/cairo/ector_renderer_cairo_shape.c index b760e54291..070ba164e1 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_shape.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_shape.c @@ -20,7 +20,7 @@ _ector_renderer_cairo_shape_ector_renderer_generic_base_prepare(Eo *obj, Ector_R } static Eina_Bool -_ector_renderer_cairo_shape_ector_renderer_generic_base_draw(Eo *obj, Ector_Renderer_Cairo_Shape_Data *pd, Ector_Surface *s, Ector_Rop op, Eina_Array *clips, int x, int y) +_ector_renderer_cairo_shape_ector_renderer_generic_base_draw(Eo *obj, Ector_Renderer_Cairo_Shape_Data *pd, Ector_Rop op, Eina_Array *clips, int x, int y) { } diff --git a/src/lib/ector/ector_renderer_generic_base.eo b/src/lib/ector/ector_renderer_generic_base.eo index ea932500f4..6f6808da03 100644 --- a/src/lib/ector/ector_renderer_generic_base.eo +++ b/src/lib/ector/ector_renderer_generic_base.eo @@ -94,7 +94,6 @@ abstract Ector.Renderer.Generic.Base (Eo.Base) draw { return: bool @warn_unused; params { - @in Ector_Surface *s; @in Ector_Rop op; @in array *clips; /*@ array of Eina_Rectangle clip */ @in int x; From 74b2eed15898b22af4514a406600cdb05e437585 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:22:11 +0200 Subject: [PATCH 055/251] ector: first implementation of an Cairo shape renderer. Note: still a lot on the todo, but it should display something that follow the correct path at least. Thanks librsvg for helping a lot. --- .../ector/cairo/ector_renderer_cairo_shape.c | 459 +++++++++++++++++- .../ector/cairo/ector_renderer_cairo_shape.eo | 4 +- 2 files changed, 458 insertions(+), 5 deletions(-) diff --git a/src/lib/ector/cairo/ector_renderer_cairo_shape.c b/src/lib/ector/cairo/ector_renderer_cairo_shape.c index 070ba164e1..499a01b52a 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_shape.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_shape.c @@ -2,6 +2,9 @@ # include "config.h" #endif +#include +#include + #include #include #include @@ -9,29 +12,477 @@ #include "ector_private.h" #include "ector_cairo_private.h" +typedef struct _cairo_path_t cairo_path_t; + +static void (*cairo_move_to)(cairo_t *cr, double x, double y) = NULL; +static void (*cairo_line_to)(cairo_t *cr, double x, double y) = NULL; +static void (*cairo_curve_to)(cairo_t *cr, + double x1, double y1, + double x2, double y2, + double x3, double y3) = NULL; +static void (*cairo_close_path)(cairo_t *cr) = NULL; + +static void (*cairo_fill)(cairo_t *cr) = NULL; +static void (*cairo_fill_preserve)(cairo_t *cr) = NULL; +static void (*cairo_stroke)(cairo_t *cr) = NULL; + +static void (*cairo_set_source_rgba)(cairo_t *cr, + double red, double green, + double blue, double alpha) = NULL; + + +static cairo_path_t *(*cairo_copy_path)(cairo_t *cr) = NULL; +static void (*cairo_path_destroy)(cairo_path_t *path) = NULL; +static void (*cairo_new_path)(cairo_t *cr) = NULL; +static void (*cairo_append_path)(cairo_t *cr, const cairo_path_t *path) = NULL; + typedef struct _Ector_Renderer_Cairo_Shape_Data Ector_Renderer_Cairo_Shape_Data; struct _Ector_Renderer_Cairo_Shape_Data { + Ector_Cairo_Surface_Data *parent; + Ector_Renderer_Generic_Shape_Data *shape; + Ector_Renderer_Generic_Base_Data *base; + cairo_path_t *path; }; +// This function come from librsvg rsvg-path.c +static void +_ector_arc_segment(Eo *obj, cairo_t* ctx, + double xc, double yc, + double th0, double th1, double rx, double ry, + double x_axis_rotation) +{ + double x1, y1, x2, y2, x3, y3; + double t; + double th_half; + double f, sinf, cosf; + + f = x_axis_rotation * 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)); + + USE(obj, cairo_curve_to, ); + + cairo_curve_to(ctx, + xc + cosf * x1 - sinf * y1, + yc + sinf * x1 + cosf * y1, + xc + cosf * x2 - sinf * y2, + yc + sinf * x2 + cosf * y2, + xc + cosf * x3 - sinf * y3, + yc + sinf * x3 + cosf * y3); +} + +// This function come from librsvg rsvg-path.c +static void +_ector_arc_to(Eo *obj, cairo_t* ctx, + double *current_x, double *current_y, + double rx, double ry, double x_axis_rotation, + Eina_Bool large_arc_flag, Eina_Bool sweep_flag, + double x, double y) +{ + /* 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; + + /* Start and end of path segment */ + x1 = *current_x; + y1 = *current_y; + + x2 = x; + y2 = y; + + if (x1 == x2 && y1 == y2) + return; + + /* X-axis */ + f = x_axis_rotation * 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)) { + USE(obj, cairo_line_to, ); + + cairo_line_to(ctx, x, y); + + *current_x = x; + *current_y = 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_flag == large_arc_flag) + 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_flag && delta_theta < 0) + delta_theta += M_PI*2; + else if (!sweep_flag && 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++) + _ector_arc_segment(obj, ctx, + cx, cy, + theta1 + i * delta_theta / n_segs, + theta1 + (i + 1) * delta_theta / n_segs, + rx, ry, x_axis_rotation); + + *current_x = x; + *current_y = y; +} + static Eina_Bool _ector_renderer_cairo_shape_ector_renderer_generic_base_prepare(Eo *obj, Ector_Renderer_Cairo_Shape_Data *pd, Ector_Surface *s) { + // FIXME: shouldn't that be part of the shape generic implementation ? + if (pd->shape->fill) + eo_do(pd->shape->fill, ector_renderer_prepare(s)); + if (pd->shape->stroke.fill) + eo_do(pd->shape->stroke.fill, ector_renderer_prepare(s)); + if (pd->shape->stroke.marker) + eo_do(pd->shape->stroke.marker, ector_renderer_prepare(s)); + eo_do_super(obj, ECTOR_RENDERER_CAIRO_SHAPE_CLASS, ector_renderer_prepare(s)); + + // shouldn't that be moved to the cairo base object + if (!pd->parent) + { + Eo *parent; + + eo_do(obj, parent = eo_parent_get()); + if (!parent) return EINA_FALSE; + pd->parent = eo_data_xref(parent, ECTOR_CAIRO_SURFACE_CLASS, obj); + if (!pd->parent) return EINA_FALSE; + } + + if (!pd->path && pd->shape->path.cmd) + { + double *pts; + double current_x = 0, current_y = 0; + double current_ctrl_x = 0, current_ctrl_y = 0; + unsigned int i; + + USE(obj, cairo_new_path, EINA_FALSE); + + 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++) + { + switch (pd->shape->path.cmd[i]) + { + case EFL_GRAPHICS_PATH_COMMAND_TYPE_MOVE_TO: + USE(obj, cairo_move_to, EINA_FALSE); + + cairo_move_to(pd->parent->cairo, pts[0], pts[1]); + + current_ctrl_x = current_x = pts[0]; + current_ctrl_y = current_y = pts[1]; + + pts += 2; + break; + case EFL_GRAPHICS_PATH_COMMAND_TYPE_LINE_TO: + USE(obj, cairo_line_to, EINA_FALSE); + + cairo_line_to(pd->parent->cairo, pts[0], pts[1]); + + current_ctrl_x = current_x = pts[0]; + current_ctrl_y = current_y = pts[1]; + + pts += 2; + break; + case EFL_GRAPHICS_PATH_COMMAND_TYPE_CUBIC_TO: + USE(obj, cairo_curve_to, EINA_FALSE); + + // Be careful, we do have a different order than + // cairo, first is destination point, followed by + // the control point. The opposite of cairo. + cairo_curve_to(pd->parent->cairo, + pts[2], pts[3], pts[4], pts[5], // control points + pts[0], pts[1]); // destination point + + current_ctrl_x = pts[4]; + current_ctrl_y = pts[5]; + current_x = pts[0]; + current_y = pts[1]; + + pts += 6; + break; + case EFL_GRAPHICS_PATH_COMMAND_TYPE_ARC_TO: + _ector_arc_to(obj, pd->parent->cairo, + ¤t_x, ¤t_y, + pts[2], pts[3], pts[4], + 0, 0, // FIXME: need to get the large arc and sweep flag + pts[0], pts[1]); + + pts += 5; + break; + case EFL_GRAPHICS_PATH_COMMAND_TYPE_CLOSE: + USE(obj, cairo_close_path, EINA_FALSE); + + cairo_close_path(pd->parent->cairo); + break; + case EFL_GRAPHICS_PATH_COMMAND_TYPE_QUADRATIC_TO: + { + double x1, y1, x2, y2, x3, y3; + // This code come from librsvg rsvg-path.c + // Be careful, we do have a different order than + // cairo, first is destination point, followed by + // the control point. The opposite of cairo. + /* raise quadratic bezier to cubic */ + x1 = (current_x + 2 * pts[2]) * (1.0 / 3.0); + y1 = (current_y + 2 * pts[3]) * (1.0 / 3.0); + x3 = pts[0]; + y3 = pts[1]; + x2 = (x3 + 2 * pts[2]) * (1.0 / 3.0); + y2 = (y3 + 2 * pts[3]) * (1.0 / 3.0); + + cairo_curve_to(pd->parent->cairo, + x1, y1, x2, y2, // control points + x3, y3); // destination point + + current_ctrl_x = pts[2]; + current_ctrl_y = pts[3]; + + current_x = x3; + current_y = y3; + break; + } + case EFL_GRAPHICS_PATH_COMMAND_TYPE_SQUADRATIC_TO: + { + // This code come from librsvg rsvg-path.c + // Smooth quadratic basically reusing the last control + // point in a meaningful way. + double xc, yc; /* quadratic control point */ + double x1, y1, x2, y2, x3, y3; + + xc = 2 * current_x - current_ctrl_x; + yc = 2 * current_y - current_ctrl_y; + /* generate a quadratic bezier with control point = xc, yc */ + x1 = (current_x + 2 * xc) * (1.0 / 3.0); + y1 = (current_y + 2 * yc) * (1.0 / 3.0); + x3 = pts[0]; + y3 = pts[1]; + x2 = (x3 + 2 * xc) * (1.0 / 3.0); + y2 = (y3 + 2 * yc) * (1.0 / 3.0); + + USE(obj, cairo_curve_to, EINA_FALSE); + + cairo_curve_to(pd->parent->cairo, + x1, y1, x2, y2, x3, y3); + + current_ctrl_x = xc; + current_ctrl_y = yc; + + current_x = x3; + current_y = y3; + + break; + } + case EFL_GRAPHICS_PATH_COMMAND_TYPE_SCUBIC_TO: + { + // This code come from librsvg rsvg-path.c + // Smooth cubic basically reusing the last control point + // in a meaningful way. + double x1, y1, x2, y2, x3, y3; + + x1 = 2 * current_x - current_ctrl_x; + y1 = 2 * current_y - current_ctrl_y; + x2 = pts[2]; + y2 = pts[3]; + x3 = pts[0]; + y3 = pts[1]; + + USE(obj, cairo_curve_to, EINA_FALSE); + + cairo_curve_to(pd->parent->cairo, + x1, y1, x2, y2, x3, y3); + + current_ctrl_x = x2; + current_ctrl_y = y2; + current_x = x3; + current_y = y3; + break; + } + case EFL_GRAPHICS_PATH_COMMAND_TYPE_LAST: + case EFL_GRAPHICS_PATH_COMMAND_TYPE_END: + break; + } + } + + USE(obj, cairo_copy_path, EINA_FALSE); + + pd->path = cairo_copy_path(pd->parent->cairo); + } + + return EINA_TRUE; } static Eina_Bool _ector_renderer_cairo_shape_ector_renderer_generic_base_draw(Eo *obj, Ector_Renderer_Cairo_Shape_Data *pd, Ector_Rop op, Eina_Array *clips, int x, int y) { -} + if (pd->path == NULL) return EINA_FALSE; -static Eina_Bool -_ector_renderer_cairo_shape_ector_renderer_generic_base_done(Eo *obj, Ector_Renderer_Cairo_Shape_Data *pd) -{ + // FIXME: find a way to offset the drawing and setting multiple clips + + eo_do_super(obj, ECTOR_RENDERER_CAIRO_SHAPE_CLASS, ector_renderer_draw(op, clips, x, y)); + + USE(obj, cairo_new_path, EINA_FALSE); + USE(obj, cairo_append_path, EINA_FALSE); + + cairo_new_path(pd->parent->cairo); + cairo_append_path(pd->parent->cairo, pd->path); + + if (pd->shape->fill) + eo_do(pd->shape->fill, ector_renderer_cairo_base_fill()); + + if (pd->shape->stroke.color.a > 0) + { + USE(obj, cairo_fill_preserve, EINA_FALSE); + USE(obj, cairo_set_source_rgba, EINA_FALSE); + USE(obj, cairo_stroke, EINA_FALSE); + + cairo_fill_preserve(pd->parent->cairo); + + cairo_set_source_rgba(pd->parent->cairo, + pd->shape->stroke.color.r / 255.0, + pd->shape->stroke.color.g / 255.0, + pd->shape->stroke.color.b / 255.0, + pd->shape->stroke.color.a / 255.0); + + if (pd->shape->stroke.fill) + eo_do(pd->shape->stroke.fill, ector_renderer_cairo_base_fill()); + // Set dash, cap and join + cairo_stroke(pd->parent->cairo); + } + else + { + USE(obj, cairo_fill, EINA_FALSE); + cairo_fill(pd->parent->cairo); + } + + return EINA_TRUE; } static Eina_Bool _ector_renderer_cairo_shape_ector_renderer_cairo_base_fill(Eo *obj, Ector_Renderer_Cairo_Shape_Data *pd) { + // FIXME: let's find out how to fill a shape with a shape later. + // I need to read SVG specification and see how to map that with cairo. } +static Eina_Bool +_ector_renderer_cairo_shape_efl_graphics_shape_path_set(Eo *obj, Ector_Renderer_Cairo_Shape_Data *pd, + const Efl_Graphics_Path_Command *op, const double *points) +{ + Eina_Bool r; + + USE(obj, cairo_path_destroy, EINA_FALSE); + + if (pd->path) cairo_path_destroy(pd->path); + pd->path = NULL; + + eo_do_super(obj, ECTOR_RENDERER_CAIRO_SHAPE_CLASS, r = efl_graphics_shape_path_set(op, points)); + + return r; +} + + +void +_ector_renderer_cairo_shape_eo_base_constructor(Eo *obj, Ector_Renderer_Cairo_Shape_Data *pd) +{ + eo_do_super(obj, ECTOR_RENDERER_CAIRO_SHAPE_CLASS, eo_constructor()); + pd->shape = eo_data_xref(obj, ECTOR_RENDERER_GENERIC_SHAPE_CLASS, obj); + pd->base = eo_data_xref(obj, ECTOR_RENDERER_GENERIC_BASE_CLASS, obj); +} + +void +_ector_renderer_cairo_shape_eo_base_destructor(Eo *obj, Ector_Renderer_Cairo_Shape_Data *pd) +{ + Eo *parent; + + USE(obj, cairo_path_destroy, ); + if (pd->path) cairo_path_destroy(pd->path); + + eo_do(obj, parent = eo_parent_get()); + eo_data_xunref(parent, pd->parent, obj); + + eo_data_xunref(obj, pd->shape, obj); + eo_data_xunref(obj, pd->base, obj); + eo_do_super(obj, ECTOR_RENDERER_CAIRO_SHAPE_CLASS, eo_destructor()); +} + + #include "ector_renderer_cairo_shape.eo.c" diff --git a/src/lib/ector/cairo/ector_renderer_cairo_shape.eo b/src/lib/ector/cairo/ector_renderer_cairo_shape.eo index b923f6f6a3..ea3e1b1295 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_shape.eo +++ b/src/lib/ector/cairo/ector_renderer_cairo_shape.eo @@ -5,7 +5,9 @@ class Ector.Renderer.Cairo.Shape (Ector.Renderer.Cairo.Base, Ector.Renderer.Gene implements { Ector.Renderer.Generic.Base.prepare; Ector.Renderer.Generic.Base.draw; - Ector.Renderer.Generic.Base.done; Ector.Renderer.Cairo.Base.fill; + Efl.Graphics.Shape.path_set; + Eo.Base.constructor; + Eo.Base.destructor; } } From 8f82b5a089c3e15e10ae8b2a72c4b494ea82f9f4 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:22:12 +0200 Subject: [PATCH 056/251] efl: fix some whitespace. --- src/lib/efl/interfaces/efl_graphics_utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/efl/interfaces/efl_graphics_utils.c b/src/lib/efl/interfaces/efl_graphics_utils.c index 5db0252434..64d70885ce 100644 --- a/src/lib/efl/interfaces/efl_graphics_utils.c +++ b/src/lib/efl/interfaces/efl_graphics_utils.c @@ -215,7 +215,7 @@ efl_graphics_path_append_close(Efl_Graphics_Path_Command **commands, double **po double *offset_point; efl_graphics_path_grow(EFL_GRAPHICS_PATH_COMMAND_TYPE_ARC_TO, - commands, points, &offset_point); + commands, points, &offset_point); } EAPI void From aad1cf28f6c1b5553cca4352784c4f3f1539f053 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:22:14 +0200 Subject: [PATCH 057/251] ector: prepare doesn't need surface, as it should always be the parent. --- .../ector/cairo/ector_renderer_cairo_gradient_linear.c | 3 +-- .../ector/cairo/ector_renderer_cairo_gradient_radial.c | 2 +- src/lib/ector/cairo/ector_renderer_cairo_shape.c | 10 +++++----- src/lib/ector/ector_renderer_generic_base.eo | 1 - 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c b/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c index bdf5c361df..4b47bb0dc9 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c @@ -29,8 +29,7 @@ struct _Ector_Renderer_Cairo_Gradient_Linear_Data static Eina_Bool _ector_renderer_cairo_gradient_linear_ector_renderer_generic_base_prepare(Eo *obj, - Ector_Renderer_Cairo_Gradient_Linear_Data *pd, - Ector_Surface *s EINA_UNUSED) + Ector_Renderer_Cairo_Gradient_Linear_Data *pd) { Ector_Renderer_Generic_Gradient_Linear_Data *gld; Ector_Renderer_Generic_Gradient_Data *gd; diff --git a/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c b/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c index d22f71039c..2659a46b2a 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c @@ -33,7 +33,7 @@ struct _Ector_Renderer_Cairo_Gradient_Radial_Data }; static Eina_Bool -_ector_renderer_cairo_gradient_radial_ector_renderer_generic_base_prepare(Eo *obj, Ector_Renderer_Cairo_Gradient_Radial_Data *pd, Ector_Surface *s) +_ector_renderer_cairo_gradient_radial_ector_renderer_generic_base_prepare(Eo *obj, Ector_Renderer_Cairo_Gradient_Radial_Data *pd) { Ector_Renderer_Generic_Gradient_Radial_Data *grd; Ector_Renderer_Generic_Gradient_Data *gd; diff --git a/src/lib/ector/cairo/ector_renderer_cairo_shape.c b/src/lib/ector/cairo/ector_renderer_cairo_shape.c index 499a01b52a..d063114200 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_shape.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_shape.c @@ -205,16 +205,16 @@ _ector_arc_to(Eo *obj, cairo_t* ctx, } static Eina_Bool -_ector_renderer_cairo_shape_ector_renderer_generic_base_prepare(Eo *obj, Ector_Renderer_Cairo_Shape_Data *pd, Ector_Surface *s) +_ector_renderer_cairo_shape_ector_renderer_generic_base_prepare(Eo *obj, Ector_Renderer_Cairo_Shape_Data *pd) { // FIXME: shouldn't that be part of the shape generic implementation ? if (pd->shape->fill) - eo_do(pd->shape->fill, ector_renderer_prepare(s)); + eo_do(pd->shape->fill, ector_renderer_prepare()); if (pd->shape->stroke.fill) - eo_do(pd->shape->stroke.fill, ector_renderer_prepare(s)); + eo_do(pd->shape->stroke.fill, ector_renderer_prepare()); if (pd->shape->stroke.marker) - eo_do(pd->shape->stroke.marker, ector_renderer_prepare(s)); - eo_do_super(obj, ECTOR_RENDERER_CAIRO_SHAPE_CLASS, ector_renderer_prepare(s)); + eo_do(pd->shape->stroke.marker, ector_renderer_prepare()); + eo_do_super(obj, ECTOR_RENDERER_CAIRO_SHAPE_CLASS, ector_renderer_prepare()); // shouldn't that be moved to the cairo base object if (!pd->parent) diff --git a/src/lib/ector/ector_renderer_generic_base.eo b/src/lib/ector/ector_renderer_generic_base.eo index 6f6808da03..af3bbeead1 100644 --- a/src/lib/ector/ector_renderer_generic_base.eo +++ b/src/lib/ector/ector_renderer_generic_base.eo @@ -103,7 +103,6 @@ abstract Ector.Renderer.Generic.Base (Eo.Base) prepare { return: bool @warn_unused; params { - @in Ector_Surface *s; } } done { From 5d982012363f8eb42dfd5941f0c8948c7eef8bd5 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:22:15 +0200 Subject: [PATCH 058/251] ector: reorder macro for easier reuse. --- src/lib/ector/cairo/ector_cairo_private.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/ector/cairo/ector_cairo_private.h b/src/lib/ector/cairo/ector_cairo_private.h index 6777370be4..eef2d10436 100644 --- a/src/lib/ector/cairo/ector_cairo_private.h +++ b/src/lib/ector/cairo/ector_cairo_private.h @@ -9,12 +9,12 @@ struct _Ector_Cairo_Surface_Data cairo_t *cairo; }; +#define CHECK_CAIRO(Parent) (!(Parent && Parent->cairo)) + #define USE(Obj, Sym, Error) \ if (!Sym) _ector_cairo_symbol_get(Obj, #Sym); \ if (!Sym) return Error; -#define CHECK_CAIRO(Parent) (!(Parent && Parent->cairo)) - static inline void * _ector_cairo_symbol_get(Eo *obj, const char *name) { From 3f3fb4cac772f743240cfd8e19693ed8c768741e Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:22:16 +0200 Subject: [PATCH 059/251] ector: handle color multiplier in the function declaration. --- src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c | 2 +- src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c | 2 +- src/lib/ector/cairo/ector_renderer_cairo_shape.c | 4 ++-- src/lib/ector/ector_renderer_generic_base.eo | 1 + 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c b/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c index 4b47bb0dc9..4df2b32a4b 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c @@ -66,7 +66,7 @@ _ector_renderer_cairo_gradient_linear_ector_renderer_generic_base_prepare(Eo *ob static Eina_Bool _ector_renderer_cairo_gradient_linear_ector_renderer_generic_base_draw(Eo *obj, Ector_Renderer_Cairo_Gradient_Linear_Data *pd, - Ector_Rop op, Eina_Array *clips, int x, int y) + Ector_Rop op, Eina_Array *clips, int x, int y, unsigned int mul_col) { Ector_Renderer_Generic_Gradient_Linear_Data *gld; diff --git a/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c b/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c index 2659a46b2a..fe8da9be25 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c @@ -69,7 +69,7 @@ _ector_renderer_cairo_gradient_radial_ector_renderer_generic_base_prepare(Eo *ob // Clearly duplicated and should be in a common place... static Eina_Bool -_ector_renderer_cairo_gradient_radial_ector_renderer_generic_base_draw(Eo *obj, Ector_Renderer_Cairo_Gradient_Radial_Data *pd, Ector_Rop op, Eina_Array *clips, int x, int y) +_ector_renderer_cairo_gradient_radial_ector_renderer_generic_base_draw(Eo *obj, Ector_Renderer_Cairo_Gradient_Radial_Data *pd, Ector_Rop op, Eina_Array *clips, int x, int y, unsigned int mul_col) { Ector_Renderer_Generic_Gradient_Linear_Data *gld; diff --git a/src/lib/ector/cairo/ector_renderer_cairo_shape.c b/src/lib/ector/cairo/ector_renderer_cairo_shape.c index d063114200..d46cf54c2c 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_shape.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_shape.c @@ -391,13 +391,13 @@ _ector_renderer_cairo_shape_ector_renderer_generic_base_prepare(Eo *obj, Ector_R } static Eina_Bool -_ector_renderer_cairo_shape_ector_renderer_generic_base_draw(Eo *obj, Ector_Renderer_Cairo_Shape_Data *pd, Ector_Rop op, Eina_Array *clips, int x, int y) +_ector_renderer_cairo_shape_ector_renderer_generic_base_draw(Eo *obj, Ector_Renderer_Cairo_Shape_Data *pd, Ector_Rop op, Eina_Array *clips, int x, int y, unsigned int mul_col) { if (pd->path == NULL) return EINA_FALSE; // FIXME: find a way to offset the drawing and setting multiple clips - eo_do_super(obj, ECTOR_RENDERER_CAIRO_SHAPE_CLASS, ector_renderer_draw(op, clips, x, y)); + eo_do_super(obj, ECTOR_RENDERER_CAIRO_SHAPE_CLASS, ector_renderer_draw(op, clips, x, y, mul_col)); USE(obj, cairo_new_path, EINA_FALSE); USE(obj, cairo_append_path, EINA_FALSE); diff --git a/src/lib/ector/ector_renderer_generic_base.eo b/src/lib/ector/ector_renderer_generic_base.eo index af3bbeead1..91275d55ee 100644 --- a/src/lib/ector/ector_renderer_generic_base.eo +++ b/src/lib/ector/ector_renderer_generic_base.eo @@ -98,6 +98,7 @@ abstract Ector.Renderer.Generic.Base (Eo.Base) @in array *clips; /*@ array of Eina_Rectangle clip */ @in int x; @in int y; + @in uint mul_col; } } prepare { From b6ffe1cc870a8208d5a245a6e8c247f3ec6272a0 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:22:18 +0200 Subject: [PATCH 060/251] evas: first implementation of an ector drawer inside Evas software engine. Note: this won't work with the OpenGL backend. --- src/lib/evas/include/evas_private.h | 6 +- .../ector_cairo_software_surface.eo | 3 - .../engines/software_generic/evas_engine.c | 254 +++++++++++++++++- 3 files changed, 251 insertions(+), 12 deletions(-) diff --git a/src/lib/evas/include/evas_private.h b/src/lib/evas/include/evas_private.h index bc3421d315..15b4c4bd40 100644 --- a/src/lib/evas/include/evas_private.h +++ b/src/lib/evas/include/evas_private.h @@ -6,7 +6,7 @@ #endif #include -#include +#include #include "Evas.h" @@ -737,6 +737,7 @@ struct _Evas_Public_Data struct { Evas_Module *module; Evas_Func *func; + Ector_Surface *surface; struct { void *output; @@ -1365,6 +1366,9 @@ struct _Evas_Func void (*texture_filter_set) (void *data, void *texture, Evas_3D_Texture_Filter min, Evas_3D_Texture_Filter mag); void (*texture_filter_get) (void *data, void *texture, Evas_3D_Texture_Filter *min, Evas_3D_Texture_Filter *mag); void (*texture_image_set) (void *data, void *texture, void *image); + + Ector_Surface *(*ector_get) (void *data); + void (*ector_draw) (void *data, void *context, void *surface, Ector_Renderer *r, Eina_Array *clips, int x, int y, Eina_Bool do_async); }; struct _Evas_Image_Save_Func diff --git a/src/modules/evas/engines/software_generic/ector_cairo_software_surface.eo b/src/modules/evas/engines/software_generic/ector_cairo_software_surface.eo index 9387f3185a..d5070abccf 100644 --- a/src/modules/evas/engines/software_generic/ector_cairo_software_surface.eo +++ b/src/modules/evas/engines/software_generic/ector_cairo_software_surface.eo @@ -15,7 +15,4 @@ class Ector.Cairo_Software.Surface (Ector.Cairo.Surface) } } } - implements { - Eo.Base.finalize; - } } diff --git a/src/modules/evas/engines/software_generic/evas_engine.c b/src/modules/evas/engines/software_generic/evas_engine.c index a2d5a1ceeb..b50f0f28d9 100644 --- a/src/modules/evas/engines/software_generic/evas_engine.c +++ b/src/modules/evas/engines/software_generic/evas_engine.c @@ -296,6 +296,7 @@ typedef struct _Evas_Thread_Command_Image Evas_Thread_Command_Image; typedef struct _Evas_Thread_Command_Font Evas_Thread_Command_Font; typedef struct _Evas_Thread_Command_Map Evas_Thread_Command_Map; typedef struct _Evas_Thread_Command_Multi_Font Evas_Thread_Command_Multi_Font; +typedef struct _Evas_Thread_Command_Ector Evas_Thread_Command_Ector; struct _Evas_Thread_Command_Rect { @@ -387,6 +388,19 @@ struct _Evas_Thread_Command_Multi_Font Evas_Font_Array *texts; }; +struct _Evas_Thread_Command_Ector +{ + void *surface; + Ector_Renderer *r; + Eina_Array *clips; + + DATA32 mul_col; + Ector_Rop render_op; + int x, y; + + Eina_Bool free_it; +}; + Eina_Mempool *_mp_command_rect = NULL; Eina_Mempool *_mp_command_line = NULL; Eina_Mempool *_mp_command_polygon = NULL; @@ -394,7 +408,7 @@ Eina_Mempool *_mp_command_image = NULL; Eina_Mempool *_mp_command_font = NULL; Eina_Mempool *_mp_command_map = NULL; Eina_Mempool *_mp_command_multi_font = NULL; - +Eina_Mempool *_mp_command_ector = NULL; /* ***** ** @@ -3431,6 +3445,148 @@ eng_output_idle_flush(void *data) if (re->outbuf_idle_flush) re->outbuf_idle_flush(re->ob); } +static Ector_Surface *_software_ector = NULL; + +static Ector_Surface * +eng_ector_get(void *data EINA_UNUSED) +{ + if (!_software_ector) + { + _software_ector = eo_add(ECTOR_CAIRO_SOFTWARE_SURFACE_CLASS, NULL); + } + return _software_ector; +} + +static Ector_Rop +_evas_render_op_to_ector_rop(Evas_Render_Op op) +{ + switch (op) + { + case EVAS_RENDER_BLEND: + return ECTOR_ROP_BLEND; + case EVAS_RENDER_COPY: + return ECTOR_ROP_COPY; + default: + return ECTOR_ROP_BLEND; + } +} + +static void +_draw_thread_ector_cleanup(Evas_Thread_Command_Ector *ector) +{ + Eina_Rectangle *r; + + while ((r = eina_array_pop(ector->clips))) + eina_rectangle_free(r); + eina_array_free(ector->clips); + eo_unref(ector->r); + + if (ector->free_it) + eina_mempool_free(_mp_command_ector, ector); +} + +static void +_draw_thread_ector_draw(void *data) +{ + Evas_Thread_Command_Ector *ector = data; + RGBA_Image *surface = ector->surface; + void *pixels = evas_cache_image_pixels(&surface->cache_entry); + unsigned int w, h; + + w = surface->cache_entry.w; + h = surface->cache_entry.h; + + // FIXME: do not reset cairo context if not necessary + eo_do(_software_ector, + ector_cairo_software_surface_set(pixels, w, h)); + + eo_do(ector->r, + ector_renderer_draw(ector->render_op, + ector->clips, + ector->x, + ector->y, + ector->mul_col)); + + _draw_thread_ector_cleanup(ector); +} + +static void +eng_ector_renderer_draw(void *data EINA_UNUSED, void *context, void *surface, Ector_Renderer *renderer, Eina_Array *clips, int x, int y, Eina_Bool do_async) +{ + RGBA_Image *dst = surface; + RGBA_Draw_Context *dc = context; + Evas_Thread_Command_Ector ector; + Eina_Array *c; + Eina_Rectangle *r; + Eina_Rectangle clip; + Eina_Array_Iterator it; + unsigned int i; + + if (dc->clip.use) + { + clip.x = dc->clip.x; + clip.y = dc->clip.y; + clip.w = dc->clip.w; + clip.h = dc->clip.h; + } + else + { + clip.x = 0; + clip.y = 0; + clip.w = dst->cache_entry.w; + clip.h = dst->cache_entry.h; + } + + c = eina_array_new(8); + EINA_ARRAY_ITER_NEXT(clips, i, r, it) + { + Eina_Rectangle *rc; + + rc = eina_rectangle_new(r->x, r->y, r->w, r->h); + if (!rc) continue; + + if (eina_rectangle_intersection(rc, &clip)) + eina_array_push(c, rc); + else + eina_rectangle_free(rc); + } + if (eina_array_count(c) == 0 && + eina_array_count(clips) > 0) + return ; + + if (eina_array_count(c) == 0) + eina_array_push(c, eina_rectangle_new(clip.x, clip.y, clip.w, clip.h)); + + ector.surface = surface; + ector.r = eo_ref(renderer); + ector.clips = c; + ector.render_op = _evas_render_op_to_ector_rop(dc->render_op); + ector.mul_col = dc->mul.use ? dc->mul.col : 0xffffffff; + ector.x = x; + ector.y = y; + ector.free_it = EINA_FALSE; + + if (do_async) + { + Evas_Thread_Command_Ector *ne; + + ne = eina_mempool_malloc(_mp_command_ector, sizeof (Evas_Thread_Command_Ector)); + if (!ne) + { + _draw_thread_ector_cleanup(&ector); + return ; + } + + memcpy(ne, &ector, sizeof (Evas_Thread_Command_Ector)); + ne->free_it = EINA_TRUE; + + evas_thread_cmd_enqueue(_draw_thread_ector_draw, ne); + } + else + { + _draw_thread_ector_draw(&ector); + } +} //------------------------------------------------// @@ -3613,6 +3769,8 @@ static Evas_Func func = NULL, // eng_texture_filter_set NULL, // eng_texture_filter_get NULL, // eng_texture_image_set + eng_ector_get, + eng_ector_renderer_draw /* FUTURE software generic calls go here */ }; @@ -4661,6 +4819,9 @@ module_open(Evas_Module *em) _mp_command_multi_font = eina_mempool_add("chained_mempool", "Evas_Thread_Command_Multi_Font", NULL, sizeof(Evas_Thread_Command_Multi_Font), 128); + _mp_command_ector = + eina_mempool_add("chained_mempool", "Evas_Thread_Command_Ector", + NULL, sizeof(Evas_Thread_Command_Ector), 128); init_gl(); evas_common_pipe_init(); @@ -4679,6 +4840,7 @@ module_close(Evas_Module *em EINA_UNUSED) eina_mempool_del(_mp_command_image); eina_mempool_del(_mp_command_font); eina_mempool_del(_mp_command_map); + eina_mempool_del(_mp_command_ector); eina_log_domain_unregister(_evas_soft_gen_log_dom); } @@ -4693,30 +4855,106 @@ static Evas_Module_Api evas_modapi = } }; -EVAS_MODULE_DEFINE(EVAS_MODULE_TYPE_ENGINE, engine, software_generic); +Eina_Bool evas_engine_software_generic_init(void) +{ + return evas_module_register(&evas_modapi, EVAS_MODULE_TYPE_ENGINE); +} + +// Time to destroy the ector context +void evas_engine_software_generic_shutdown(void) +{ + if (_software_ector) eo_del(_software_ector); + _software_ector = NULL; + + evas_module_unregister(&evas_modapi, EVAS_MODULE_TYPE_ENGINE); +} #ifndef EVAS_STATIC_BUILD_SOFTWARE_GENERIC EVAS_EINA_MODULE_DEFINE(engine, software_generic); #endif +#define USE(Obj, Sym, Error) \ + if (!Sym) _ector_cairo_symbol_get(Obj, #Sym); \ + if (!Sym) return Error; + +static inline void * +_ector_cairo_symbol_get(Eo *ector_surface, const char *name) +{ + void *sym; + + eo_do(ector_surface, + sym = ector_cairo_surface_symbol_get(name)); + return sym; +} + +typedef struct _cairo_surface_t cairo_surface_t; +typedef enum { + CAIRO_FORMAT_INVALID = -1, + CAIRO_FORMAT_ARGB32 = 0, + CAIRO_FORMAT_RGB24 = 1, + CAIRO_FORMAT_A8 = 2, + CAIRO_FORMAT_A1 = 3, + CAIRO_FORMAT_RGB16_565 = 4, + CAIRO_FORMAT_RGB30 = 5 +} cairo_format_t; + +static cairo_surface_t *(*cairo_image_surface_create_for_data)(unsigned char *data, + cairo_format_t format, + int width, + int height, + int stride) = NULL; +static void (*cairo_surface_destroy)(cairo_surface_t *surface) = NULL; +static cairo_t *(*cairo_create)(cairo_surface_t *target) = NULL; +static void (*cairo_destroy)(cairo_t *cr) = NULL; + typedef struct _Ector_Cairo_Software_Surface_Data Ector_Cairo_Software_Surface_Data; struct _Ector_Cairo_Software_Surface_Data { + cairo_surface_t *surface; + cairo_t *ctx; + + void *pixels; + + unsigned int width; + unsigned int height; }; void _ector_cairo_software_surface_surface_set(Eo *obj, Ector_Cairo_Software_Surface_Data *pd, void *pixels, unsigned int width, unsigned int height) { + USE(obj, cairo_image_surface_create_for_data, ); + USE(obj, cairo_surface_destroy, ); + USE(obj, cairo_create, ); + USE(obj, cairo_destroy, ); + + cairo_surface_destroy(pd->surface); pd->surface = NULL; + cairo_destroy(pd->ctx); pd->ctx = NULL; + + pd->pixels = NULL; + pd->width = 0; + pd->height = 0; + + pd->surface = cairo_image_surface_create_for_data(pixels, CAIRO_FORMAT_ARGB32, width, height, width); + if (pd->surface) goto end; + + pd->ctx = cairo_create(pd->surface); + if (pd->ctx) + { + pd->pixels = pixels; + pd->width = width; + pd->height = height; + } + + end: + eo_do(obj, ector_cairo_surface_context_set(pd->ctx)); } void -_ector_cairo_software_surface_surface_get(Eo *obj, Ector_Cairo_Software_Surface_Data *pd, void **pixels, unsigned int *width, unsigned int *height) -{ -} - -Eo * -_ector_cairo_software_surface_eo_base_finalize(Eo *obj, Ector_Cairo_Software_Surface_Data *pd) +_ector_cairo_software_surface_surface_get(Eo *obj EINA_UNUSED, Ector_Cairo_Software_Surface_Data *pd, void **pixels, unsigned int *width, unsigned int *height) { + if (pixels) *pixels = pd->pixels; + if (width) *width = pd->width; + if (height) *height = pd->height; } #include "ector_cairo_software_surface.eo.c" From 31a3664f7113eb6b3de3a1da9cfd293f91c23c37 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:22:20 +0200 Subject: [PATCH 061/251] ecore_evas: add a SVG vector dislay/converter tool. --- src/Makefile_Ecore_Evas.am | 8 +- src/bin/ecore_evas/.gitignore | 1 + src/bin/ecore_evas/ecore_evas_svg.c | 197 ++++++++++++++++++++++++++++ 3 files changed, 205 insertions(+), 1 deletion(-) create mode 100644 src/bin/ecore_evas/ecore_evas_svg.c diff --git a/src/Makefile_Ecore_Evas.am b/src/Makefile_Ecore_Evas.am index 1be87466e9..e61aa2ad75 100644 --- a/src/Makefile_Ecore_Evas.am +++ b/src/Makefile_Ecore_Evas.am @@ -282,7 +282,8 @@ endif bin_PROGRAMS += \ bin/ecore_evas/ecore_evas_convert \ -bin/ecore_evas/eetpack +bin/ecore_evas/eetpack \ +bin/ecore_evas/ecore_evas_svg bin_ecore_evas_ecore_evas_convert_SOURCES = bin/ecore_evas/ecore_evas_convert.c bin_ecore_evas_ecore_evas_convert_CPPFLAGS = -I$(top_builddir)/src/lib/efl @ECORE_EVAS_CFLAGS@ @@ -293,3 +294,8 @@ bin_ecore_evas_eetpack_SOURCES = bin/ecore_evas/eetpack.c bin_ecore_evas_eetpack_CPPFLAGS = -I$(top_builddir)/src/lib/efl @ECORE_EVAS_CFLAGS@ @EINA_CFLAGS@ @EET_CFLAGS@ @EVAS_CFLAGS@ bin_ecore_evas_eetpack_LDADD = @USE_ECORE_EVAS_LIBS@ @USE_EINA_LIBS@ @USE_EET_LIBS@ @USE_EVAS_LIBS@ bin_ecore_evas_eetpack_DEPENDENCIES = @USE_ECORE_EVAS_INTERNAL_LIBS@ @USE_EINA_INTERNAL_LIBS@ @USE_EET_INTERNAL_LIBS@ @USE_EVAS_INTERNAL_LIBS@ + +bin_ecore_evas_ecore_evas_svg_SOURCES = bin/ecore_evas/ecore_evas_svg.c +bin_ecore_evas_ecore_evas_svg_CPPFLAGS = -I$(top_builddir)/src/lib/efl @ECORE_EVAS_CFLAGS@ +bin_ecore_evas_ecore_evas_svg_LDADD = @USE_ECORE_EVAS_LIBS@ +bin_ecore_evas_ecore_evas_svg_DEPENDENCIES = @USE_ECORE_EVAS_INTERNAL_LIBS@ diff --git a/src/bin/ecore_evas/.gitignore b/src/bin/ecore_evas/.gitignore index 7f6f9cb40f..c6d0740831 100644 --- a/src/bin/ecore_evas/.gitignore +++ b/src/bin/ecore_evas/.gitignore @@ -1,2 +1,3 @@ /ecore_evas_convert /eetpack +/ecore_evas_svg diff --git a/src/bin/ecore_evas/ecore_evas_svg.c b/src/bin/ecore_evas/ecore_evas_svg.c new file mode 100644 index 0000000000..6e2f2eb70a --- /dev/null +++ b/src/bin/ecore_evas/ecore_evas_svg.c @@ -0,0 +1,197 @@ +#ifdef HAVE_CONFIG_H +#include +#endif + +#ifdef HAVE_EVIL +# include +#endif + +#include +#include +#include +#include +#include + +#undef EINA_LOG_DOMAIN_DEFAULT +#define EINA_LOG_DOMAIN_DEFAULT _log_dom +static int _log_dom = -1; + +static void +_cb_delete(Ecore_Evas *ee EINA_UNUSED) +{ + ecore_main_loop_quit(); +} + +static unsigned char +_parse_color(const Ecore_Getopt *parser EINA_UNUSED, + const Ecore_Getopt_Desc *desc EINA_UNUSED, + const char *str, + void *data EINA_UNUSED, Ecore_Getopt_Value *storage) +{ + unsigned char *color = (unsigned char *)storage->ptrp; + + if (sscanf(str, "%hhu,%hhu,%hhu", color, color + 1, color + 2) != 3) + { + fprintf(stderr, "ERROR: incorrect color value '%s'\n", str); + return 0; + } + + return 1; +} + +const Ecore_Getopt optdesc = { + "ecore_evas_svg", + "%prog [options] []", + PACKAGE_VERSION, + "(C) 2014 Enlightenment", + "BSD with advertisement clause", + "Simple application to display or convert SVG in their vector form.", + 0, + { + ECORE_GETOPT_STORE_INT('q', "quality", "define encoding quality in percent."), + ECORE_GETOPT_STORE_TRUE('c', "compress", "define if data should be compressed."), + ECORE_GETOPT_STORE_STR('c', "codec", "define the codec (for TGV files: etc1, etc2)"), + ECORE_GETOPT_CALLBACK_NOARGS('E', "list-engines", "list Ecore-Evas engines", + ecore_getopt_callback_ecore_evas_list_engines, NULL), + ECORE_GETOPT_STORE_STR('e', "engine", "The Ecore-Evas engine to use (see --list-engines)"), + ECORE_GETOPT_CALLBACK_ARGS('c', "bg-color", + "Color of the background (if not shaped or alpha)", + "RRGGBB", _parse_color, NULL), + ECORE_GETOPT_CALLBACK_ARGS('Z', "size", "size to use in wxh form.", "WxH", + ecore_getopt_callback_size_parse, NULL), + ECORE_GETOPT_STORE_TRUE('a', "alpha", "Display window with alpha channel " + " (needs composite manager!)"), + ECORE_GETOPT_STORE_STR('t', "title", "Define the window title string"), + ECORE_GETOPT_LICENSE('L', "license"), + ECORE_GETOPT_COPYRIGHT('C', "copyright"), + ECORE_GETOPT_VERSION('V', "version"), + ECORE_GETOPT_HELP('h', "help"), + ECORE_GETOPT_SENTINEL + } +}; + +int +main(int argc, char *argv[]) +{ + Ecore_Evas *ee; + Evas *e; + Evas_Object *im = NULL; + Evas_Object *vg; + Evas_Object *r; + char *encoding = NULL; + char *engine = NULL; + char *title = NULL; + Eina_Rectangle size = { 0, 0, 800, 600 }; + unsigned char color[3] = { 0, 0, 0 }; + + int arg_index; + int quality = -1; + + Eina_Bool compress = 1; + Eina_Bool quit_option = EINA_FALSE; + Eina_Bool display = EINA_FALSE; + Eina_Bool alpha = EINA_FALSE; + + Ecore_Getopt_Value values[] = { + ECORE_GETOPT_VALUE_INT(quality), + ECORE_GETOPT_VALUE_BOOL(compress), + ECORE_GETOPT_VALUE_STR(encoding), + ECORE_GETOPT_VALUE_BOOL(quit_option), + ECORE_GETOPT_VALUE_STR(engine), + ECORE_GETOPT_VALUE_PTR_CAST(color), + ECORE_GETOPT_VALUE_PTR_CAST(size), + ECORE_GETOPT_VALUE_BOOL(alpha), + ECORE_GETOPT_VALUE_STR(title), + ECORE_GETOPT_VALUE_BOOL(quit_option), + ECORE_GETOPT_VALUE_BOOL(quit_option), + ECORE_GETOPT_VALUE_BOOL(quit_option), + ECORE_GETOPT_VALUE_BOOL(quit_option), + ECORE_GETOPT_VALUE_NONE + }; + + eina_init(); + _log_dom = eina_log_domain_register(argv[0], EINA_COLOR_CYAN); + + ecore_init(); + ecore_evas_init(); + + arg_index = ecore_getopt_parse(&optdesc, values, argc, argv); + if (quit_option) goto end; + + if (arg_index < 0) + { + EINA_LOG_ERR("Could not parse argument."); + goto end; + } + if (arg_index + 1 == argc) + { + display = EINA_TRUE; + } + else if (arg_index + 2 != argc) + { + EINA_LOG_ERR("File not correctly specified."); + goto end; + } + + if (!display) + { + Ecore_Evas *sub_ee; + + ee = ecore_evas_buffer_new(1, 1); + im = ecore_evas_object_image_new(ee); + sub_ee = ecore_evas_object_ecore_evas_get(im); + ecore_evas_resize(sub_ee, size.w, size.h); + + e = ecore_evas_object_evas_get(im); + } + else + { + ee = ecore_evas_new(engine, 0, 0, size.w, size.h, NULL); + + e = ecore_evas_get(ee); + } + + ecore_evas_alpha_set(ee, alpha); + ecore_evas_callback_delete_request_set(ee, _cb_delete); + ecore_evas_title_set(ee, title ? title : "Ecore Evas SVG"); + + + r = eo_add(EVAS_RECTANGLE_CLASS, e, + evas_obj_color_set(color[0], color[1], color[2], alpha ? 0 : 255), + evas_obj_visibility_set(EINA_TRUE)); + ecore_evas_object_associate(ee, r, ECORE_EVAS_OBJECT_ASSOCIATE_BASE); + + vg = eo_add(EVAS_VG_CLASS, e, + efl_file_set(argv[arg_index], NULL)); + ecore_evas_object_associate(ee, vg, ECORE_EVAS_OBJECT_ASSOCIATE_BASE); + + if (!display) + { + ecore_evas_show(ee); + + ecore_main_loop_begin(); + } + else + { + Eina_Strbuf *flags = NULL; + + flags = eina_strbuf_new(); + eina_strbuf_append_printf(flags, "compress=%d", compress); + if (quality >= 0) + eina_strbuf_append_printf(flags, " quality=%d", quality); + if (encoding) + eina_strbuf_append_printf(flags, " encoding=%s", encoding); + + evas_object_image_save(im, argv[arg_index + 1], + NULL, eina_strbuf_string_get(flags)); + eina_strbuf_free(flags); + } + + ecore_evas_free(ee); + end: + ecore_evas_shutdown(); + ecore_shutdown(); + eina_shutdown(); + + return 0; +} From 36ba2fc01d654287875f3e491f1545b77cf6e4b8 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:22:22 +0200 Subject: [PATCH 062/251] evas: add file manipulation API to Evas_Object_VG. --- src/lib/evas/canvas/evas_object_vg.c | 53 ++++++++++++++++++++++++---- src/lib/evas/canvas/evas_vg.eo | 30 ++++++++++++++++ 2 files changed, 77 insertions(+), 6 deletions(-) diff --git a/src/lib/evas/canvas/evas_object_vg.c b/src/lib/evas/canvas/evas_object_vg.c index 07bf19d8b9..23cc4f7c77 100644 --- a/src/lib/evas/canvas/evas_object_vg.c +++ b/src/lib/evas/canvas/evas_object_vg.c @@ -16,8 +16,12 @@ typedef struct _Evas_VG_Data Evas_VG_Data; struct _Evas_VG_Data { - void *engine_data; - Evas_VG_Node *root; + void *engine_data; + Evas_VG_Node *root; + + /* Opening an SVG file (could actually be inside an eet section */ + Eina_File *f; + const char *key; }; static void evas_object_vg_render(Evas_Object *eo_obj, @@ -321,18 +325,55 @@ evas_object_vg_was_opaque(Evas_Object *eo_obj EINA_UNUSED, } +static Eina_Bool +_evas_vg_mmap_set(Eo *obj EINA_UNUSED, Evas_VG_Data *pd, + const Eina_File *f, const char *key EINA_UNUSED) +// For now we don't handle eet section filled with SVG, that's for later +{ + Eina_File *tmp = f ? eina_file_dup(f) : NULL; + + // Start parsing here. + + // it succeeded. + if (pd->f) eina_file_close(pd->f); + pd->f = tmp; + + return EINA_TRUE; +} + +static void +_evas_vg_mmap_get(Eo *obj EINA_UNUSED, Evas_VG_Data *pd, + const Eina_File **f, const char **key) +{ + if (f) *f = pd->f; + if (key) *key = pd->key; +} + Eina_Bool -_evas_vg_efl_file_file_set(Eo *obj, Evas_VG_Data *pd, +_evas_vg_efl_file_file_set(Eo *obj, Evas_VG_Data *pd EINA_UNUSED, const char *file, const char *key) { - // FIXME: just load SVG for now - return EINA_FALSE; + Eina_File *f; + Eina_Bool r = EINA_FALSE; + + f = eina_file_open(file, EINA_FALSE); + if (!f) return EINA_FALSE; + + eo_do(obj, r = evas_obj_vg_mmap_set(f, key)); + + eina_file_close(f); + return r; } void -_evas_vg_efl_file_file_get(Eo *obj, Evas_VG_Data *pd, +_evas_vg_efl_file_file_get(Eo *obj, Evas_VG_Data *pd EINA_UNUSED, const char **file, const char **key) { + const Eina_File *f = NULL; + + eo_do(obj, evas_obj_vg_mmap_get(&f, key)); + + if (file) *file = eina_file_filename_get(f); } void diff --git a/src/lib/evas/canvas/evas_vg.eo b/src/lib/evas/canvas/evas_vg.eo index 64cd2d179b..dcf047bf07 100644 --- a/src/lib/evas/canvas/evas_vg.eo +++ b/src/lib/evas/canvas/evas_vg.eo @@ -23,6 +23,36 @@ class Evas.VG (Evas.Object, Efl.File) uint h; } } + mmap { + set { + /*@ + Set the source mmaped file from where an image object must fetch the real + image data (it must be an Eina_File). + + If the file supports multiple data stored in it (as Eet files do), + you can specify the key to be used as the index of the image in + this file. + + @since 1.14 */ + return: bool; + } + get { + /*@ + Get the source mmaped file from where an image object must fetch the real + image data (it must be an Eina_File). + + If the file supports multiple data stored in it (as Eet files do), + you can get the key to be used as the index of the image in + this file. + + @since 1.14 */ + } + values { + const(Eina.File)* f; /*@ The mmaped file */ + const(char)* key; /*@ The image key in @p file (if its an Eet one), or @c + NULL, otherwise. */ + } + } } implements { Eo.Base.constructor; From 1be99f87c7db2f60dcdc2f9b50451a5ef6373f2c Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:22:24 +0200 Subject: [PATCH 063/251] ector: reorder compilation to first do Ector then Evas. --- configure.ac | 82 ++++++++++++++++++++++++------------------------- src/Makefile.am | 2 +- 2 files changed, 42 insertions(+), 42 deletions(-) diff --git a/configure.ac b/configure.ac index e773931ce6..f5f8d4404e 100644 --- a/configure.ac +++ b/configure.ac @@ -1215,6 +1215,47 @@ EFL_INTERNAL_DEPEND_PKG([EFL], [eo]) EFL_LIB_END([Efl]) #### End of Efl +#### Ector + +EFL_LIB_START([Ector]) + + +### Default values + +### Additional options to configure + +### Checks for programs + +### Checks for libraries + +## Compatibility layers + +EFL_PLATFORM_DEPEND([ECTOR], [evil]) + +EFL_INTERNAL_DEPEND_PKG([ECTOR], [eina]) +EFL_INTERNAL_DEPEND_PKG([ECTOR], [eo]) +EFL_INTERNAL_DEPEND_PKG([ECTOR], [efl]) + +EFL_EVAL_PKGS([ECTOR]) + +### Checks for header files + +### Checks for types + +### Checks for structures + +### Checks for compiler characteristics + +### Checks for linker characteristics + +### Checks for library functions + +### Check availability + +EFL_LIB_END([ECTOR]) + +#### End of Ector + #### Evas EFL_LIB_START([Evas]) @@ -2095,47 +2136,6 @@ EFL_ADD_FEATURE([EVAS], [dither-mask], [${build_evas_dither_mask}]) EFL_LIB_END([Evas]) #### End of Evas -#### Ector - -EFL_LIB_START([Ector]) - - -### Default values - -### Additional options to configure - -### Checks for programs - -### Checks for libraries - -## Compatibility layers - -EFL_PLATFORM_DEPEND([ECTOR], [evil]) - -EFL_INTERNAL_DEPEND_PKG([ECTOR], [eina]) -EFL_INTERNAL_DEPEND_PKG([ECTOR], [eo]) -EFL_INTERNAL_DEPEND_PKG([ECTOR], [efl]) - -EFL_EVAL_PKGS([ECTOR]) - -### Checks for header files - -### Checks for types - -### Checks for structures - -### Checks for compiler characteristics - -### Checks for linker characteristics - -### Checks for library functions - -### Check availability - -EFL_LIB_END([ECTOR]) - -#### End of Ector - #### Edje CXX EFL_LIB_START([Evas_Cxx]) diff --git a/src/Makefile.am b/src/Makefile.am index df0026cd88..77403a7d87 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -35,6 +35,7 @@ include Makefile_Efl.am include Makefile_Emile.am include Makefile_Eet.am include Makefile_Eolian.am +include Makefile_Ector.am include Makefile_Evas.am include Makefile_Ecore.am include Makefile_Ecore_Con.am @@ -56,7 +57,6 @@ include Makefile_Ecore_Evas.am include Makefile_Ecore_Audio.am include Makefile_Ecore_Audio_Cxx.am include Makefile_Ecore_Avahi.am -include Makefile_Ector.am include Makefile_Embryo.am include Makefile_Eio.am include Makefile_Eldbus.am From 3e95f90b135251d080095abab11cf555dd450c3c Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:22:25 +0200 Subject: [PATCH 064/251] ecore_evas: fix little typo. --- src/bin/ecore_evas/ecore_evas_svg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bin/ecore_evas/ecore_evas_svg.c b/src/bin/ecore_evas/ecore_evas_svg.c index 6e2f2eb70a..379aaae44e 100644 --- a/src/bin/ecore_evas/ecore_evas_svg.c +++ b/src/bin/ecore_evas/ecore_evas_svg.c @@ -165,7 +165,7 @@ main(int argc, char *argv[]) efl_file_set(argv[arg_index], NULL)); ecore_evas_object_associate(ee, vg, ECORE_EVAS_OBJECT_ASSOCIATE_BASE); - if (!display) + if (display) { ecore_evas_show(ee); From 81760ea5d9e3be65d1ab77e3a8d31b8e9a6fba34 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:22:26 +0200 Subject: [PATCH 065/251] evas: also allow Evas_VG and NULL as parent. I have yet to be sure of the Evas_VG one. --- src/lib/evas/canvas/evas_vg_node.c | 64 +++++++++++++++++++++--------- 1 file changed, 46 insertions(+), 18 deletions(-) diff --git a/src/lib/evas/canvas/evas_vg_node.c b/src/lib/evas/canvas/evas_vg_node.c index b6d3f01f78..633718a01d 100644 --- a/src/lib/evas/canvas/evas_vg_node.c +++ b/src/lib/evas/canvas/evas_vg_node.c @@ -104,7 +104,8 @@ _evas_vg_node_mask_get(Eo *obj EINA_UNUSED, Evas_VG_Node_Data *pd) // Parent should be a container otherwise dismissing the stacking operation void -_evas_vg_node_eo_base_constructor(Eo *obj, Evas_VG_Node_Data *pd EINA_UNUSED) +_evas_vg_node_eo_base_constructor(Eo *obj, + Evas_VG_Node_Data *pd EINA_UNUSED) { Evas_VG_Container_Data *cd; Eo *parent; @@ -112,13 +113,22 @@ _evas_vg_node_eo_base_constructor(Eo *obj, Evas_VG_Node_Data *pd EINA_UNUSED) eo_do_super(obj, MY_CLASS, eo_constructor()); eo_do(obj, parent = eo_parent_get()); - cd = eo_data_scope_get(parent, EVAS_VG_CONTAINER_CLASS); - if (!cd) + if (eo_isa(parent, EVAS_VG_CONTAINER_CLASS)) { - eo_error_set(obj); - return ; + cd = eo_data_scope_get(parent, EVAS_VG_CONTAINER_CLASS); + if (!cd) + { + ERR("Can't get EVAS_VG_CONTAINER_CLASS data."); + eo_error_set(obj); + return ; + } + cd->children = eina_list_append(cd->children, obj); + } + else if (parent != NULL && !eo_isa(parent, EVAS_VG_CLASS)) + { + ERR("Not even an EVAS_VG_CLASS."); + eo_error_set(obj); } - cd->children = eina_list_append(cd->children, obj); } void @@ -126,30 +136,48 @@ _evas_vg_node_eo_base_parent_set(Eo *obj, Evas_VG_Node_Data *pd EINA_UNUSED, Eo *parent) { - Evas_VG_Container_Data *cd; - Evas_VG_Container_Data *old_cd; + Evas_VG_Container_Data *cd = NULL; + Evas_VG_Container_Data *old_cd = NULL; Eo *old_parent; - cd = eo_data_scope_get(parent, EVAS_VG_CONTAINER_CLASS); - if (!cd) + if (eo_isa(parent, EVAS_VG_CONTAINER_CLASS)) { - eo_error_set(obj); - return ; + ERR("Can't get EVAS_VG_CONTAINER_CLASS data from %p.", parent); + cd = eo_data_scope_get(parent, EVAS_VG_CONTAINER_CLASS); + if (!cd) goto on_error; + } + else if (parent != NULL && !eo_isa(parent, EVAS_VG_CLASS)) + { + ERR("%p not even an EVAS_VG_CLASS.", parent); + goto on_error; } eo_do(obj, old_parent = eo_parent_get()); - old_cd = eo_data_scope_get(old_parent, EVAS_VG_CONTAINER_CLASS); - if (!old_cd) + if (eo_isa(old_parent, EVAS_VG_CONTAINER_CLASS)) { - eo_error_set(obj); - return ; + ERR("Can't get EVAS_VG_CONTAINER_CLASS data from %p.", old_parent); + old_cd = eo_data_scope_get(old_parent, EVAS_VG_CONTAINER_CLASS); + if (!old_cd) goto on_error; + } + else if (old_parent != NULL && !eo_isa(old_parent, EVAS_VG_CLASS)) + { + ERR("%p not even an EVAS_VG_CLASS.", old_parent); + goto on_error; } // FIXME: this may become slow with to much object - old_cd->children = eina_list_remove(old_cd->children, obj); + if (old_cd) + old_cd->children = eina_list_remove(old_cd->children, obj); eo_do_super(obj, MY_CLASS, eo_parent_set(parent)); - cd->children = eina_list_append(cd->children, obj); + if (cd) + cd->children = eina_list_append(cd->children, obj); + + return ; + + on_error: + eo_error_set(obj); + return ; } void From c1a189bf10177b68c85766d225735206fbf5c29e Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:22:27 +0200 Subject: [PATCH 066/251] evas: fix examples dependencies as they don't use the rest of the infra to discover it. --- src/examples/evas/Makefile.am | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/examples/evas/Makefile.am b/src/examples/evas/Makefile.am index 5e27afa438..ad1893c4f7 100644 --- a/src/examples/evas/Makefile.am +++ b/src/examples/evas/Makefile.am @@ -8,9 +8,11 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/src/lib/eina \ -I$(top_srcdir)/src/lib/eo \ -I$(top_srcdir)/src/lib/evas \ +-I$(top_srcdir)/src/lib/ector \ -I$(top_builddir)/src/lib/eina \ -I$(top_builddir)/src/lib/eo \ -I$(top_builddir)/src/lib/evas \ +-I$(top_builddir)/src/lib/ector \ @EVAS_CFLAGS@ EDCS = aspect.edc @@ -30,6 +32,7 @@ evas_init_shutdown_LDADD = $(top_builddir)/src/lib/evas/libevas.la @EVAS_LDFLAGS ECORE_EVAS_COMMON_CPPFLAGS = \ -I$(top_srcdir)/src/lib/eina \ -I$(top_srcdir)/src/lib/eo \ +-I$(top_srcdir)/src/lib/ector \ -I$(top_srcdir)/src/lib/evas \ -I$(top_srcdir)/src/lib/ecore \ -I$(top_srcdir)/src/lib/ecore_file \ @@ -38,6 +41,7 @@ ECORE_EVAS_COMMON_CPPFLAGS = \ -I$(top_builddir)/src/lib/efl \ -I$(top_builddir)/src/lib/eina \ -I$(top_builddir)/src/lib/eo \ +-I$(top_builddir)/src/lib/ector \ -I$(top_builddir)/src/lib/evas \ -I$(top_builddir)/src/lib/ecore \ -I$(top_builddir)/src/lib/ecore_file \ @@ -50,6 +54,7 @@ ECORE_EVAS_COMMON_LDADD = \ $(top_builddir)/src/lib/efl/libefl.la \ $(top_builddir)/src/lib/eina/libeina.la \ $(top_builddir)/src/lib/eo/libeo.la \ +$(top_builddir)/src/lib/ector/libector.la \ $(top_builddir)/src/lib/ecore/libecore.la \ $(top_builddir)/src/lib/ecore_file/libecore_file.la \ $(top_builddir)/src/lib/ecore_input/libecore_input.la \ @@ -91,6 +96,7 @@ EDJE_COMMON_LDADD = \ $(top_builddir)/src/lib/eina/libeina.la \ $(top_builddir)/src/lib/eo/libeo.la \ $(top_builddir)/src/lib/eet/libeet.la \ +$(top_builddir)/src/lib/ector/libector.la \ $(top_builddir)/src/lib/evas/libevas.la \ $(top_builddir)/src/lib/ecore/libecore.la \ $(top_builddir)/src/lib/ecore_evas/libecore_evas.la \ From 78bf41b223d2e3b22ecf7417572df5f94a4b007e Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:22:29 +0200 Subject: [PATCH 067/251] eina: add eina_simple_xml_attribute_w3c_parse to parse attribute value. --- src/lib/eina/eina_simple_xml_parser.c | 57 +++++++++++++++++++++++++++ src/lib/eina/eina_simple_xml_parser.h | 17 ++++++++ 2 files changed, 74 insertions(+) diff --git a/src/lib/eina/eina_simple_xml_parser.c b/src/lib/eina/eina_simple_xml_parser.c index 2ead2e2683..13dd5ee7b1 100644 --- a/src/lib/eina/eina_simple_xml_parser.c +++ b/src/lib/eina/eina_simple_xml_parser.c @@ -556,6 +556,63 @@ eina_simple_xml_attributes_parse(const char *buf, unsigned buflen, Eina_Simple_X return EINA_TRUE; } +EAPI Eina_Bool +eina_simple_xml_attribute_w3c_parse(const char *buf, Eina_Simple_XML_Attribute_Cb func, const void *data) +{ + const char *end; + char *key; + char *val; + char *next; + + if (!buf) return EINA_FALSE; + + end = buf + strlen(buf); + key = alloca(end - buf + 1); + val = alloca(end - buf + 1); + + if (buf == end) return EINA_TRUE; + + do + { + char *sep = strchr(buf, ':'); + next = strchr(buf, ';'); + + key[0] = '\0'; + val[0] = '\0'; + + if (next == NULL && sep != NULL) + { + memcpy(key, buf, sep - buf); + key[sep - buf] = '\0'; + + memcpy(val, sep + 1, end - sep - 1); + val[end - sep - 1] = '\0'; + } + else if (sep < next && sep != NULL) + { + memcpy(key, buf, sep - buf); + key[sep - buf] = '\0'; + + memcpy(val, sep + 1, next - sep - 1); + val[next - sep - 1] = '\0'; + } + else if (next) + { + memcpy(key, buf, next - buf); + key[next - buf] = '\0'; + } + + if (key[0]) + if (!func((void*) data, key, val)) + return EINA_FALSE; + + buf = next + 1; + } + while (next != NULL); + + return EINA_TRUE; +} + /* Node loader *************************************************************/ EAPI Eina_Simple_XML_Attribute * diff --git a/src/lib/eina/eina_simple_xml_parser.h b/src/lib/eina/eina_simple_xml_parser.h index 8f83c1e01a..365b2d0360 100644 --- a/src/lib/eina/eina_simple_xml_parser.h +++ b/src/lib/eina/eina_simple_xml_parser.h @@ -277,6 +277,23 @@ EAPI const char * eina_simple_xml_tag_attributes_find(const char *buf, unsigned EAPI Eina_Bool eina_simple_xml_attributes_parse(const char *buf, unsigned buflen, Eina_Simple_XML_Attribute_Cb func, const void *data); +/** + * Given a buffer with the xml value of an attributes, parse them to key:value pairs. + * + * @param buf the input string. Need to contain \0 terminator. + * @param func what to call back while parse to do some action. The + * first parameter is the given user @a data, the second is the + * key (null-terminated) and the last is the value (null + * terminated). These strings should not be modified and + * reference is just valid until the function return. + * @param data data to pass to the callback function. + * + * @return #EINA_TRUE on success or #EINA_FALSE if it was aborted by user or + * parsing error. + */ +EAPI Eina_Bool +eina_simple_xml_attribute_w3c_parse(const char *buf, Eina_Simple_XML_Attribute_Cb func, const void *data); + /** * Create (and append) new attribute to tag. * From 97714021d151134f769643645aecd8b523f751b3 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:22:37 +0200 Subject: [PATCH 068/251] evas: Evas_Object_VG should always create a root node. --- src/lib/evas/canvas/evas_object_vg.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/lib/evas/canvas/evas_object_vg.c b/src/lib/evas/canvas/evas_object_vg.c index 23cc4f7c77..de79791b93 100644 --- a/src/lib/evas/canvas/evas_object_vg.c +++ b/src/lib/evas/canvas/evas_object_vg.c @@ -102,7 +102,7 @@ _evas_vg_root_node_get(Eo *obj EINA_UNUSED, Evas_VG_Data *pd) } void -_evas_vg_eo_base_constructor(Eo *eo_obj, Evas_VG_Data *pd EINA_UNUSED) +_evas_vg_eo_base_constructor(Eo *eo_obj, Evas_VG_Data *pd) { Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS); Eo *parent = NULL; @@ -114,6 +114,9 @@ _evas_vg_eo_base_constructor(Eo *eo_obj, Evas_VG_Data *pd EINA_UNUSED) obj->private_data = eo_data_ref(eo_obj, MY_CLASS); obj->type = o_type; + /* root node */ + pd->root = eo_add(EVAS_VG_ROOT_NODE_CLASS, eo_obj); + eo_do(eo_obj, parent = eo_parent_get()); evas_object_inject(eo_obj, obj, evas_object_evas_get(parent)); } From 185eadf9adc2a8c36fe555648a2b4411710284cf Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:22:38 +0200 Subject: [PATCH 069/251] evas: fix typos in Evas_VG_Root_Node. --- src/lib/evas/canvas/evas_vg_root_node.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/evas/canvas/evas_vg_root_node.c b/src/lib/evas/canvas/evas_vg_root_node.c index d77c4c581f..10f23ee83a 100644 --- a/src/lib/evas/canvas/evas_vg_root_node.c +++ b/src/lib/evas/canvas/evas_vg_root_node.c @@ -18,7 +18,7 @@ _evas_vg_root_node_eo_base_parent_set(Eo *obj, Eo *parent) { // Nice little hack, jump over parent parent_set in Evas_VG_Root - eo_do_super(obj, EVAS_VG_NODE_CLASS, eo_constructor()); + eo_do_super(obj, EVAS_VG_NODE_CLASS, eo_parent_set(parent)); if (!eo_isa(parent, EVAS_VG_CLASS)) eo_error_set(obj); } From 40e3240e6e33f272673b751d1950c5551de72507 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:22:50 +0200 Subject: [PATCH 070/251] evas: fix copy and paste mistake. --- src/lib/evas/canvas/evas_object_vg.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/lib/evas/canvas/evas_object_vg.c b/src/lib/evas/canvas/evas_object_vg.c index de79791b93..ccf406a106 100644 --- a/src/lib/evas/canvas/evas_object_vg.c +++ b/src/lib/evas/canvas/evas_object_vg.c @@ -5,9 +5,8 @@ #define MY_CLASS EVAS_VG_CLASS - /* private magic number for rectangle objects */ -static const char o_type[] = "rectangle"; +static const char o_type[] = "vectors"; const char *o_vg_type = o_type; From 09d7ffe5207484146cbaa6d5dc95f8eaf32df004 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:22:51 +0200 Subject: [PATCH 071/251] evas: add fill and size definition for a VG scene graph. --- src/lib/evas/canvas/evas_object_vg.c | 38 ++++++++++++++++++- src/lib/evas/canvas/evas_vg.eo | 57 ++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+), 1 deletion(-) diff --git a/src/lib/evas/canvas/evas_object_vg.c b/src/lib/evas/canvas/evas_object_vg.c index ccf406a106..0ad5c06799 100644 --- a/src/lib/evas/canvas/evas_object_vg.c +++ b/src/lib/evas/canvas/evas_object_vg.c @@ -21,6 +21,10 @@ struct _Evas_VG_Data /* Opening an SVG file (could actually be inside an eet section */ Eina_File *f; const char *key; + + Eina_Rectangle fill; + + unsigned int width, height; }; static void evas_object_vg_render(Evas_Object *eo_obj, @@ -115,6 +119,7 @@ _evas_vg_eo_base_constructor(Eo *eo_obj, Evas_VG_Data *pd) /* root node */ pd->root = eo_add(EVAS_VG_ROOT_NODE_CLASS, eo_obj); + fprintf(stderr, "creating root node: %p\n", pd->root); eo_do(eo_obj, parent = eo_parent_get()); evas_object_inject(eo_obj, obj, evas_object_evas_get(parent)); @@ -379,8 +384,39 @@ _evas_vg_efl_file_file_get(Eo *obj, Evas_VG_Data *pd EINA_UNUSED, } void -_evas_vg_size_get(Eo *obj, Evas_VG_Data *pd, unsigned int *w, unsigned int *h) +_evas_vg_size_get(Eo *obj EINA_UNUSED, Evas_VG_Data *pd, + unsigned int *w, unsigned int *h) { + if (w) *w = pd->width; + if (h) *h = pd->height; +} + +void +_evas_vg_size_set(Eo *obj EINA_UNUSED, Evas_VG_Data *pd, + unsigned int w, unsigned int h) +{ + pd->width = w; + pd->height = h; +} + +void +_evas_vg_fill_set(Eo *obj EINA_UNUSED, Evas_VG_Data *pd, + Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h) +{ + pd->fill.x = x; + pd->fill.y = y; + pd->fill.w = w; + pd->fill.h = h; +} + +void +_evas_vg_fill_get(Eo *obj EINA_UNUSED, Evas_VG_Data *pd, + Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h) +{ + if (x) *x = pd->fill.x; + if (y) *y = pd->fill.y; + if (w) *w = pd->fill.w; + if (h) *h = pd->fill.h; } #include "evas_vg.eo.c" diff --git a/src/lib/evas/canvas/evas_vg.eo b/src/lib/evas/canvas/evas_vg.eo index dcf047bf07..bf4960e3c1 100644 --- a/src/lib/evas/canvas/evas_vg.eo +++ b/src/lib/evas/canvas/evas_vg.eo @@ -18,6 +18,13 @@ class Evas.VG (Evas.Object, Efl.File) object were added). */ } + set { + /*@ + Set the size defined in the original data + before any scaling (as in the file or when the + object were added). + */ + } values { uint w; uint h; @@ -53,6 +60,56 @@ class Evas.VG (Evas.Object, Efl.File) NULL, otherwise. */ } } + fill { + set { + /*@ + Set how to fill an image object's drawing rectangle given the + (real) image bound to it. + + Note that if @p w or @p h are smaller than the dimensions of + @p obj, the displayed image will be @b tiled around the object's + area. To have only one copy of the bound image drawn, @p x and @p y + must be 0 and @p w and @p h need to be the exact width and height + of the image object itself, respectively. + + See the following image to better understand the effects of this + call. On this diagram, both image object and original image source + have @c a x @c a dimensions and the image itself is a circle, with + empty space around it: + + @image html image-fill.png + @image rtf image-fill.png + @image latex image-fill.eps + + @warning The default values for the fill parameters are @p x = 0, + @p y = 0, @p w = 0 and @p h = 0. Thus, if you're not using the + evas_object_image_filled_add() helper and want your image + displayed, you'll have to set valid values with this function on + your object. + + @note evas_object_image_filled_set() is a helper function which + will @b override the values set here automatically, for you, in a + given way. */ + } + get { + /*@ + Retrieve how an image object is to fill its drawing rectangle, + given the (real) image bound to it. + + @note Use @c NULL pointers on the fill components you're not + interested in: they'll be ignored by the function. + + See @ref evas_object_image_fill_set() for more details. */ + } + values { + Evas_Coord x; /*@ The x coordinate (from the top left corner of the bound + image) to start drawing from. */ + Evas_Coord y; /*@ The y coordinate (from the top left corner of the bound + image) to start drawing from. */ + Evas_Coord w; /*@ The width the bound image will be displayed at. */ + Evas_Coord h; /*@ The height the bound image will be displayed at. */ + } + } } implements { Eo.Base.constructor; From f85f8135a0a4ddf65febabcb0af3e48ae25c8d74 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:22:53 +0200 Subject: [PATCH 072/251] evas: NULL is always needed as during destruction parent is set to NULL. --- src/lib/evas/canvas/evas_vg_root_node.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/evas/canvas/evas_vg_root_node.c b/src/lib/evas/canvas/evas_vg_root_node.c index 10f23ee83a..8fb8b311b2 100644 --- a/src/lib/evas/canvas/evas_vg_root_node.c +++ b/src/lib/evas/canvas/evas_vg_root_node.c @@ -19,7 +19,7 @@ _evas_vg_root_node_eo_base_parent_set(Eo *obj, { // Nice little hack, jump over parent parent_set in Evas_VG_Root eo_do_super(obj, EVAS_VG_NODE_CLASS, eo_parent_set(parent)); - if (!eo_isa(parent, EVAS_VG_CLASS)) + if (parent && !eo_isa(parent, EVAS_VG_CLASS)) eo_error_set(obj); } From 6071e71e980a03729213ffebfbd15d73c7560af5 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:22:54 +0200 Subject: [PATCH 073/251] evas: cleanup parent handling of Evas_VG_Node. --- src/lib/evas/canvas/evas_vg_node.c | 73 +++++++++++++++++------------- 1 file changed, 41 insertions(+), 32 deletions(-) diff --git a/src/lib/evas/canvas/evas_vg_node.c b/src/lib/evas/canvas/evas_vg_node.c index 633718a01d..95467a036d 100644 --- a/src/lib/evas/canvas/evas_vg_node.c +++ b/src/lib/evas/canvas/evas_vg_node.c @@ -103,32 +103,48 @@ _evas_vg_node_mask_get(Eo *obj EINA_UNUSED, Evas_VG_Node_Data *pd) } // Parent should be a container otherwise dismissing the stacking operation +static Eina_Bool +_evas_vg_node_parent_checked_get(Eo *obj, + Eo **parent, Evas_VG_Container_Data **cd) +{ + eo_do(obj, *parent = eo_parent_get()); + if (eo_isa(*parent, EVAS_VG_CONTAINER_CLASS)) + { + *cd = eo_data_scope_get(*parent, EVAS_VG_CONTAINER_CLASS); + if (!*cd) + { + ERR("Can't get EVAS_VG_CONTAINER_CLASS data."); + goto on_error; + } + } + else if (*parent != NULL) + { + ERR("Parent of unauthorized class."); + goto on_error; + } + + return EINA_TRUE; + + on_error: + *parent = NULL; + *cd = NULL; + return EINA_FALSE; +} + void _evas_vg_node_eo_base_constructor(Eo *obj, Evas_VG_Node_Data *pd EINA_UNUSED) { - Evas_VG_Container_Data *cd; + Evas_VG_Container_Data *cd = NULL; Eo *parent; eo_do_super(obj, MY_CLASS, eo_constructor()); - eo_do(obj, parent = eo_parent_get()); - if (eo_isa(parent, EVAS_VG_CONTAINER_CLASS)) - { - cd = eo_data_scope_get(parent, EVAS_VG_CONTAINER_CLASS); - if (!cd) - { - ERR("Can't get EVAS_VG_CONTAINER_CLASS data."); - eo_error_set(obj); - return ; - } - cd->children = eina_list_append(cd->children, obj); - } - else if (parent != NULL && !eo_isa(parent, EVAS_VG_CLASS)) - { - ERR("Not even an EVAS_VG_CLASS."); - eo_error_set(obj); - } + if (!_evas_vg_node_parent_checked_get(obj, &parent, &cd)) + eo_error_set(obj); + + if (cd) + cd->children = eina_list_append(cd->children, obj); } void @@ -142,9 +158,12 @@ _evas_vg_node_eo_base_parent_set(Eo *obj, if (eo_isa(parent, EVAS_VG_CONTAINER_CLASS)) { - ERR("Can't get EVAS_VG_CONTAINER_CLASS data from %p.", parent); cd = eo_data_scope_get(parent, EVAS_VG_CONTAINER_CLASS); - if (!cd) goto on_error; + if (!cd) + { + ERR("Can't get EVAS_VG_CONTAINER_CLASS data from %p.", parent); + goto on_error; + } } else if (parent != NULL && !eo_isa(parent, EVAS_VG_CLASS)) { @@ -152,18 +171,8 @@ _evas_vg_node_eo_base_parent_set(Eo *obj, goto on_error; } - eo_do(obj, old_parent = eo_parent_get()); - if (eo_isa(old_parent, EVAS_VG_CONTAINER_CLASS)) - { - ERR("Can't get EVAS_VG_CONTAINER_CLASS data from %p.", old_parent); - old_cd = eo_data_scope_get(old_parent, EVAS_VG_CONTAINER_CLASS); - if (!old_cd) goto on_error; - } - else if (old_parent != NULL && !eo_isa(old_parent, EVAS_VG_CLASS)) - { - ERR("%p not even an EVAS_VG_CLASS.", old_parent); - goto on_error; - } + if (!_evas_vg_node_parent_checked_get(obj, &old_parent, &old_cd)) + goto on_error; // FIXME: this may become slow with to much object if (old_cd) From a00b6219fa6b55981f9e290a42abd4e50c1efc87 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:22:56 +0200 Subject: [PATCH 074/251] evas: remove printf. --- src/lib/evas/canvas/evas_object_vg.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lib/evas/canvas/evas_object_vg.c b/src/lib/evas/canvas/evas_object_vg.c index 0ad5c06799..397a3f646b 100644 --- a/src/lib/evas/canvas/evas_object_vg.c +++ b/src/lib/evas/canvas/evas_object_vg.c @@ -119,7 +119,6 @@ _evas_vg_eo_base_constructor(Eo *eo_obj, Evas_VG_Data *pd) /* root node */ pd->root = eo_add(EVAS_VG_ROOT_NODE_CLASS, eo_obj); - fprintf(stderr, "creating root node: %p\n", pd->root); eo_do(eo_obj, parent = eo_parent_get()); evas_object_inject(eo_obj, obj, evas_object_evas_get(parent)); From 621d3b566024c357ce523857db211ab02a08af72 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:22:57 +0200 Subject: [PATCH 075/251] evas: those function should have been static. --- src/lib/evas/canvas/evas_vg_container.c | 4 +- src/lib/evas/canvas/evas_vg_gradient.c | 8 ++-- src/lib/evas/canvas/evas_vg_gradient_linear.c | 8 ++-- src/lib/evas/canvas/evas_vg_gradient_radial.c | 12 ++--- src/lib/evas/canvas/evas_vg_image.c | 12 ++--- src/lib/evas/canvas/evas_vg_private.h | 5 +- src/lib/evas/canvas/evas_vg_shape.c | 48 +++++++++---------- 7 files changed, 50 insertions(+), 47 deletions(-) diff --git a/src/lib/evas/canvas/evas_vg_container.c b/src/lib/evas/canvas/evas_vg_container.c index 3459f4ad50..c4b7f389a4 100644 --- a/src/lib/evas/canvas/evas_vg_container.c +++ b/src/lib/evas/canvas/evas_vg_container.c @@ -5,14 +5,14 @@ #define MY_CLASS EVAS_VG_CONTAINER_CLASS -void +static void _evas_vg_container_eo_base_constructor(Eo *obj, Evas_VG_Container_Data *pd EINA_UNUSED) { eo_do_super(obj, MY_CLASS, eo_constructor()); } -Eina_Bool +static Eina_Bool _evas_vg_container_evas_vg_node_bound_get(Eo *obj EINA_UNUSED, Evas_VG_Container_Data *pd, Eina_Rectangle *r) diff --git a/src/lib/evas/canvas/evas_vg_gradient.c b/src/lib/evas/canvas/evas_vg_gradient.c index 28ed57930e..acca97f629 100644 --- a/src/lib/evas/canvas/evas_vg_gradient.c +++ b/src/lib/evas/canvas/evas_vg_gradient.c @@ -13,7 +13,7 @@ struct _Evas_VG_Gradient_Data Efl_Graphics_Gradient_Spread s; }; -void +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, @@ -30,7 +30,7 @@ _evas_vg_gradient_efl_graphics_gradient_stop_set(Eo *obj EINA_UNUSED, pd->colors_count = length; } -void +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, @@ -40,7 +40,7 @@ _evas_vg_gradient_efl_graphics_gradient_stop_get(Eo *obj EINA_UNUSED, if (length) *length = pd->colors_count; } -void +static void _evas_vg_gradient_efl_graphics_gradient_spread_set(Eo *obj EINA_UNUSED, Evas_VG_Gradient_Data *pd, Efl_Graphics_Gradient_Spread s) @@ -48,7 +48,7 @@ _evas_vg_gradient_efl_graphics_gradient_spread_set(Eo *obj EINA_UNUSED, pd->s = s; } -Efl_Graphics_Gradient_Spread +static Efl_Graphics_Gradient_Spread _evas_vg_gradient_efl_graphics_gradient_spread_get(Eo *obj EINA_UNUSED, Evas_VG_Gradient_Data *pd) { diff --git a/src/lib/evas/canvas/evas_vg_gradient_linear.c b/src/lib/evas/canvas/evas_vg_gradient_linear.c index f60dc3b90f..035f6b1e29 100644 --- a/src/lib/evas/canvas/evas_vg_gradient_linear.c +++ b/src/lib/evas/canvas/evas_vg_gradient_linear.c @@ -11,7 +11,7 @@ struct _Evas_VG_Gradient_Linear_Data } start, end; }; -void +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) @@ -20,7 +20,7 @@ _evas_vg_gradient_linear_efl_graphics_gradient_linear_start_set(Eo *obj EINA_UNU pd->start.y = y; } -void +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) @@ -29,7 +29,7 @@ _evas_vg_gradient_linear_efl_graphics_gradient_linear_start_get(Eo *obj EINA_UNU if (y) *y = pd->start.y; } -void +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) @@ -38,7 +38,7 @@ _evas_vg_gradient_linear_efl_graphics_gradient_linear_end_set(Eo *obj EINA_UNUSE pd->end.y = y; } -void +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) diff --git a/src/lib/evas/canvas/evas_vg_gradient_radial.c b/src/lib/evas/canvas/evas_vg_gradient_radial.c index fecec50902..0e21565c6d 100644 --- a/src/lib/evas/canvas/evas_vg_gradient_radial.c +++ b/src/lib/evas/canvas/evas_vg_gradient_radial.c @@ -10,7 +10,7 @@ struct _Evas_VG_Gradient_Radial_Data double radius; }; -void +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) @@ -19,7 +19,7 @@ _evas_vg_gradient_radial_efl_graphics_gradient_radial_center_set(Eo *obj EINA_UN pd->center.y = y; } -void +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) @@ -28,7 +28,7 @@ _evas_vg_gradient_radial_efl_graphics_gradient_radial_center_get(Eo *obj EINA_UN if (y) *y = pd->center.y; } -void +static void _evas_vg_gradient_radial_efl_graphics_gradient_radial_radius_set(Eo *obj EINA_UNUSED, Evas_VG_Gradient_Radial_Data *pd, double r) @@ -36,14 +36,14 @@ _evas_vg_gradient_radial_efl_graphics_gradient_radial_radius_set(Eo *obj EINA_UN pd->radius = r; } -double +static double _evas_vg_gradient_radial_efl_graphics_gradient_radial_radius_get(Eo *obj EINA_UNUSED, Evas_VG_Gradient_Radial_Data *pd) { return pd->radius; } -void +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) @@ -52,7 +52,7 @@ _evas_vg_gradient_radial_efl_graphics_gradient_radial_focal_set(Eo *obj EINA_UNU pd->focal.y = y; } -void +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) diff --git a/src/lib/evas/canvas/evas_vg_image.c b/src/lib/evas/canvas/evas_vg_image.c index b93fc13f9e..21a7bbe19f 100644 --- a/src/lib/evas/canvas/evas_vg_image.c +++ b/src/lib/evas/canvas/evas_vg_image.c @@ -13,21 +13,21 @@ struct _Evas_VG_Image_Data unsigned int w, h; }; -void +static void _evas_vg_image_position_set(Eo *obj, Evas_VG_Image_Data *pd, int x, int y) { pd->x = x; pd->y = y; } -void +static void _evas_vg_image_position_get(Eo *obj, Evas_VG_Image_Data *pd, int *x, int *y) { if (x) *x = pd->x; if (y) *y = pd->y; } -void +static void _evas_vg_image_size_set(Eo *obj, Evas_VG_Image_Data *pd, unsigned int w, unsigned int h) { @@ -35,7 +35,7 @@ _evas_vg_image_size_set(Eo *obj, Evas_VG_Image_Data *pd, pd->h = h; } -void +static void _evas_vg_image_size_get(Eo *obj, Evas_VG_Image_Data *pd, unsigned int *w, unsigned int *h) { @@ -43,7 +43,7 @@ _evas_vg_image_size_get(Eo *obj, Evas_VG_Image_Data *pd, if (h) *h = pd->h; } -Eina_Bool +static Eina_Bool _evas_vg_image_efl_file_file_set(Eo *obj, Evas_VG_Image_Data *pd, const char *file, const char *key) { @@ -51,7 +51,7 @@ _evas_vg_image_efl_file_file_set(Eo *obj, Evas_VG_Image_Data *pd, eina_stringshare_replace(&pd->key, key); } -void +static void _evas_vg_image_efl_file_file_get(Eo *obj, Evas_VG_Image_Data *pd, const char **file, const char **key) { diff --git a/src/lib/evas/canvas/evas_vg_private.h b/src/lib/evas/canvas/evas_vg_private.h index 3358e5018d..6b83623517 100644 --- a/src/lib/evas/canvas/evas_vg_private.h +++ b/src/lib/evas/canvas/evas_vg_private.h @@ -9,10 +9,13 @@ struct _Evas_VG_Node_Data void (*render_pre)(void); void (*render)(void); + void *data; double x, y; int r, g, b, a; - Eina_Bool visibility; + + Eina_Bool visibility : 1; + Eina_Bool changed : 1; }; typedef struct _Evas_VG_Container_Data Evas_VG_Container_Data; diff --git a/src/lib/evas/canvas/evas_vg_shape.c b/src/lib/evas/canvas/evas_vg_shape.c index c062ccb8a0..b39a9efa06 100644 --- a/src/lib/evas/canvas/evas_vg_shape.c +++ b/src/lib/evas/canvas/evas_vg_shape.c @@ -34,7 +34,7 @@ struct _Evas_VG_Shape_Data unsigned int pts_counts; }; -Eina_Bool +static Eina_Bool _evas_vg_shape_efl_graphics_shape_path_set(Eo *obj EINA_UNUSED, Evas_VG_Shape_Data *pd, const Efl_Graphics_Path_Command *op, @@ -48,14 +48,14 @@ _evas_vg_shape_efl_graphics_shape_path_set(Eo *obj EINA_UNUSED, return efl_graphics_path_dup(&pd->op, &pd->points, op, points); } -Eina_Bool +static Eina_Bool _evas_vg_shape_bounds_get(Eo *obj, Evas_VG_Shape_Data *pd, Eina_Rectangle *r) { (void) obj; (void) pd; (void) r; return EINA_FALSE; } -void +static void _evas_vg_shape_eo_base_constructor(Eo *obj, Evas_VG_Shape_Data *pd EINA_UNUSED) { eo_do_super(obj, MY_CLASS, eo_constructor()); @@ -66,13 +66,13 @@ _evas_vg_shape_eo_base_constructor(Eo *obj, Evas_VG_Shape_Data *pd EINA_UNUSED) pd->stroke.centered = 0.5; } -void +static void _evas_vg_shape_eo_base_destructor(Eo *obj, Evas_VG_Shape_Data *pd EINA_UNUSED) { eo_do_super(obj, MY_CLASS, eo_destructor()); } -void +static void _evas_vg_shape_fill_set(Eo *obj EINA_UNUSED, Evas_VG_Shape_Data *pd, Evas_VG_Node *f) @@ -83,13 +83,13 @@ _evas_vg_shape_fill_set(Eo *obj EINA_UNUSED, eo_unref(tmp); } -Evas_VG_Node * +static Evas_VG_Node * _evas_vg_shape_fill_get(Eo *obj EINA_UNUSED, Evas_VG_Shape_Data *pd) { return pd->fill; } -void +static void _evas_vg_shape_efl_graphics_shape_stroke_scale_set(Eo *obj EINA_UNUSED, Evas_VG_Shape_Data *pd, double s) @@ -97,14 +97,14 @@ _evas_vg_shape_efl_graphics_shape_stroke_scale_set(Eo *obj EINA_UNUSED, pd->stroke.scale = s; } -double +static double _evas_vg_shape_efl_graphics_shape_stroke_scale_get(Eo *obj EINA_UNUSED, Evas_VG_Shape_Data *pd) { return pd->stroke.scale; } -void +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) @@ -115,7 +115,7 @@ _evas_vg_shape_efl_graphics_shape_stroke_color_set(Eo *obj EINA_UNUSED, pd->stroke.a = a; } -void +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) @@ -126,7 +126,7 @@ _evas_vg_shape_efl_graphics_shape_stroke_color_get(Eo *obj EINA_UNUSED, if (a) *a = pd->stroke.a; } -void +static void _evas_vg_shape_stroke_fill_set(Eo *obj EINA_UNUSED, Evas_VG_Shape_Data *pd, Evas_VG_Node *f) @@ -137,14 +137,14 @@ _evas_vg_shape_stroke_fill_set(Eo *obj EINA_UNUSED, eo_unref(tmp); } -Evas_VG_Node * +static Evas_VG_Node * _evas_vg_shape_stroke_fill_get(Eo *obj EINA_UNUSED, Evas_VG_Shape_Data *pd) { return pd->stroke.fill; } -void +static void _evas_vg_shape_efl_graphics_shape_stroke_width_set(Eo *obj EINA_UNUSED, Evas_VG_Shape_Data *pd, double w) @@ -152,14 +152,14 @@ _evas_vg_shape_efl_graphics_shape_stroke_width_set(Eo *obj EINA_UNUSED, pd->stroke.width = w; } -double +static double _evas_vg_shape_efl_graphics_shape_stroke_width_get(Eo *obj EINA_UNUSED, Evas_VG_Shape_Data *pd) { return pd->stroke.width; } -void +static void _evas_vg_shape_efl_graphics_shape_stroke_location_set(Eo *obj EINA_UNUSED, Evas_VG_Shape_Data *pd, double centered) @@ -167,14 +167,14 @@ _evas_vg_shape_efl_graphics_shape_stroke_location_set(Eo *obj EINA_UNUSED, pd->stroke.centered = centered; } -double +static double _evas_vg_shape_efl_graphics_shape_stroke_location_get(Eo *obj EINA_UNUSED, Evas_VG_Shape_Data *pd) { return pd->stroke.centered; } -void +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, @@ -191,7 +191,7 @@ _evas_vg_shape_efl_graphics_shape_stroke_dash_set(Eo *obj EINA_UNUSED, pd->stroke.dash_count = length; } -void +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, @@ -201,7 +201,7 @@ _evas_vg_shape_efl_graphics_shape_stroke_dash_get(Eo *obj EINA_UNUSED, if (length) *length = pd->stroke.dash_count; } -void +static void _evas_vg_shape_stroke_marker_set(Eo *obj EINA_UNUSED, Evas_VG_Shape_Data *pd, Evas_VG_Shape *m) @@ -212,14 +212,14 @@ _evas_vg_shape_stroke_marker_set(Eo *obj EINA_UNUSED, eo_unref(tmp); } -Evas_VG_Shape * +static Evas_VG_Shape * _evas_vg_shape_stroke_marker_get(Eo *obj EINA_UNUSED, Evas_VG_Shape_Data *pd) { return pd->stroke.marker; } -void +static void _evas_vg_shape_efl_graphics_shape_stroke_cap_set(Eo *obj EINA_UNUSED, Evas_VG_Shape_Data *pd, Efl_Graphics_Cap c) @@ -227,14 +227,14 @@ _evas_vg_shape_efl_graphics_shape_stroke_cap_set(Eo *obj EINA_UNUSED, pd->stroke.cap = c; } -Efl_Graphics_Cap +static Efl_Graphics_Cap _evas_vg_shape_efl_graphics_shape_stroke_cap_get(Eo *obj EINA_UNUSED, Evas_VG_Shape_Data *pd) { return pd->stroke.cap; } -void +static void _evas_vg_shape_efl_graphics_shape_stroke_join_set(Eo *obj EINA_UNUSED, Evas_VG_Shape_Data *pd, Efl_Graphics_Join j) @@ -242,7 +242,7 @@ _evas_vg_shape_efl_graphics_shape_stroke_join_set(Eo *obj EINA_UNUSED, pd->stroke.join = j; } -Efl_Graphics_Join +static Efl_Graphics_Join _evas_vg_shape_efl_graphics_shape_stroke_join_get(Eo *obj EINA_UNUSED, Evas_VG_Shape_Data *pd) { From 6097178ec32f56edf2a737a701ed55b673c29879 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:22:58 +0200 Subject: [PATCH 076/251] evas: start properly implementing render_pre for Evas_VG_Node. --- src/lib/evas/canvas/evas_object_vg.c | 11 +- src/lib/evas/canvas/evas_vg_container.c | 31 +++++- src/lib/evas/canvas/evas_vg_container.eo | 1 + src/lib/evas/canvas/evas_vg_gradient.c | 12 +-- src/lib/evas/canvas/evas_vg_gradient_linear.c | 49 +++++++++ .../evas/canvas/evas_vg_gradient_linear.eo | 2 + src/lib/evas/canvas/evas_vg_gradient_radial.c | 50 +++++++++ .../evas/canvas/evas_vg_gradient_radial.eo | 2 + src/lib/evas/canvas/evas_vg_image.c | 11 ++ src/lib/evas/canvas/evas_vg_image.eo | 2 + src/lib/evas/canvas/evas_vg_private.h | 29 ++++- src/lib/evas/canvas/evas_vg_shape.c | 100 +++++++++++++----- src/lib/evas/canvas/evas_vg_shape.eo | 1 + 13 files changed, 257 insertions(+), 44 deletions(-) diff --git a/src/lib/evas/canvas/evas_object_vg.c b/src/lib/evas/canvas/evas_object_vg.c index 397a3f646b..dba3c7a49f 100644 --- a/src/lib/evas/canvas/evas_object_vg.c +++ b/src/lib/evas/canvas/evas_object_vg.c @@ -1,6 +1,7 @@ #include "evas_common_private.h" #include "evas_private.h" +#include "evas_vg_private.h" #include "evas_vg_root_node.eo.h" #define MY_CLASS EVAS_VG_CLASS @@ -164,11 +165,17 @@ evas_object_vg_render(Evas_Object *eo_obj EINA_UNUSED, static void evas_object_vg_render_pre(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, - void *type_private_data EINA_UNUSED) + void *type_private_data) { + Evas_VG_Data *vd = type_private_data; + Evas_Public_Data *e = obj->layer->evas; int is_v, was_v; + Ector_Surface *s; - // FIXME: call all modified Ector_Renderer prepare fct + // FIXME: handle damage only on changed renderer. + s = e->engine.func->ector_get(e->engine.data.output); + if (vd->root && s) + _evas_vg_render_pre(vd->root, s); /* dont pre-render the obj twice! */ if (obj->pre_render_done) return; diff --git a/src/lib/evas/canvas/evas_vg_container.c b/src/lib/evas/canvas/evas_vg_container.c index c4b7f389a4..20ac001f95 100644 --- a/src/lib/evas/canvas/evas_vg_container.c +++ b/src/lib/evas/canvas/evas_vg_container.c @@ -6,10 +6,37 @@ #define MY_CLASS EVAS_VG_CONTAINER_CLASS static void -_evas_vg_container_eo_base_constructor(Eo *obj, - Evas_VG_Container_Data *pd EINA_UNUSED) +_evas_vg_container_render_pre(Eo *obj EINA_UNUSED, + Ector_Surface *s, + void *data, + Evas_VG_Node_Data *nd EINA_UNUSED) { + Evas_VG_Container_Data *pd = data; + Eina_List *l; + Eo *child; + + EINA_LIST_FOREACH(pd->children, l, child) + _evas_vg_render_pre(child, s); +} + +static void +_evas_vg_container_eo_base_constructor(Eo *obj, + Evas_VG_Container_Data *pd) +{ + Evas_VG_Node_Data *nd; + eo_do_super(obj, MY_CLASS, eo_constructor()); + + nd = eo_data_scope_get(obj, EVAS_VG_NODE_CLASS); + nd->render_pre = _evas_vg_container_render_pre; + nd->data = pd; +} + +static void +_evas_vg_container_eo_base_destructor(Eo *obj, + Evas_VG_Container_Data *pd EINA_UNUSED) +{ + eo_do_super(obj, MY_CLASS, eo_destructor()); } static Eina_Bool diff --git a/src/lib/evas/canvas/evas_vg_container.eo b/src/lib/evas/canvas/evas_vg_container.eo index 423a202bb1..0af3b00fc6 100644 --- a/src/lib/evas/canvas/evas_vg_container.eo +++ b/src/lib/evas/canvas/evas_vg_container.eo @@ -3,6 +3,7 @@ class Evas.VG_Container (Evas.VG_Node) eo_prefix: evas_vg_container; implements { Eo.Base.constructor; + Eo.Base.destructor; Evas.VG_Node.bound_get; } } diff --git a/src/lib/evas/canvas/evas_vg_gradient.c b/src/lib/evas/canvas/evas_vg_gradient.c index acca97f629..a63b636062 100644 --- a/src/lib/evas/canvas/evas_vg_gradient.c +++ b/src/lib/evas/canvas/evas_vg_gradient.c @@ -1,18 +1,10 @@ #include "evas_common_private.h" #include "evas_private.h" +#include "evas_vg_private.h" + #include -typedef struct _Evas_VG_Gradient_Data Evas_VG_Gradient_Data; -struct _Evas_VG_Gradient_Data -{ - // FIXME: Later on we should deduplicate it somehow (Using Ector ?). - Efl_Graphics_Gradient_Stop *colors; - unsigned int colors_count; - - Efl_Graphics_Gradient_Spread s; -}; - static void _evas_vg_gradient_efl_graphics_gradient_stop_set(Eo *obj EINA_UNUSED, Evas_VG_Gradient_Data *pd, diff --git a/src/lib/evas/canvas/evas_vg_gradient_linear.c b/src/lib/evas/canvas/evas_vg_gradient_linear.c index 035f6b1e29..156a5851ed 100644 --- a/src/lib/evas/canvas/evas_vg_gradient_linear.c +++ b/src/lib/evas/canvas/evas_vg_gradient_linear.c @@ -1,8 +1,12 @@ #include "evas_common_private.h" #include "evas_private.h" +#include "evas_vg_private.h" + #include +#define MY_CLASS EVAS_VG_GRADIENT_LINEAR_CLASS + typedef struct _Evas_VG_Gradient_Linear_Data Evas_VG_Gradient_Linear_Data; struct _Evas_VG_Gradient_Linear_Data { @@ -47,4 +51,49 @@ _evas_vg_gradient_linear_efl_graphics_gradient_linear_end_get(Eo *obj EINA_UNUSE if (y) *y = pd->end.y; } +static void +_evas_vg_gradient_linear_render_pre(Eo *obj, + Ector_Surface *s, + void *data, + Evas_VG_Node_Data *nd) +{ + Evas_VG_Gradient_Linear_Data *pd = data; + Evas_VG_Gradient_Data *gd = eo_data_scope_get(obj, EVAS_VG_GRADIENT_CLASS); + + if (!nd->renderer) + { + eo_do(s, nd->renderer = ector_surface_renderer_factory_new(ECTOR_RENDERER_GENERIC_GRADIENT_LINEAR_CLASS)); + } + + eo_do(nd->renderer, + ector_renderer_transformation_set(nd->m), + 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), + ector_renderer_prepare()); +} + +static void +_evas_vg_gradient_linear_eo_base_constructor(Eo *obj, + Evas_VG_Gradient_Linear_Data *pd) +{ + Evas_VG_Node_Data *nd; + + eo_do_super(obj, MY_CLASS, eo_constructor()); + + nd = eo_data_scope_get(obj, EVAS_VG_NODE_CLASS); + nd->render_pre = _evas_vg_gradient_linear_render_pre; + nd->data = pd; +} + +void +_evas_vg_gradient_linear_eo_base_destructor(Eo *obj, Evas_VG_Gradient_Linear_Data *pd EINA_UNUSED) +{ + eo_do_super(obj, MY_CLASS, eo_destructor()); +} + #include "evas_vg_gradient_linear.eo.c" diff --git a/src/lib/evas/canvas/evas_vg_gradient_linear.eo b/src/lib/evas/canvas/evas_vg_gradient_linear.eo index d513f10905..0ae1347d64 100644 --- a/src/lib/evas/canvas/evas_vg_gradient_linear.eo +++ b/src/lib/evas/canvas/evas_vg_gradient_linear.eo @@ -7,5 +7,7 @@ class Evas.VG_Gradient_Linear (Evas.VG_Gradient, Efl.Graphics.Gradient_Linear) Efl.Graphics.Gradient_Linear.start.get; Efl.Graphics.Gradient_Linear.end.set; Efl.Graphics.Gradient_Linear.end.get; + Eo.Base.constructor; + Eo.Base.destructor; } } diff --git a/src/lib/evas/canvas/evas_vg_gradient_radial.c b/src/lib/evas/canvas/evas_vg_gradient_radial.c index 0e21565c6d..c27430a340 100644 --- a/src/lib/evas/canvas/evas_vg_gradient_radial.c +++ b/src/lib/evas/canvas/evas_vg_gradient_radial.c @@ -1,6 +1,10 @@ #include "evas_common_private.h" #include "evas_private.h" +#include "evas_vg_private.h" + +#define MY_CLASS EVAS_VG_GRADIENT_RADIAL_CLASS + typedef struct _Evas_VG_Gradient_Radial_Data Evas_VG_Gradient_Radial_Data; struct _Evas_VG_Gradient_Radial_Data { @@ -61,4 +65,50 @@ _evas_vg_gradient_radial_efl_graphics_gradient_radial_focal_get(Eo *obj EINA_UNU if (y) *y = pd->focal.y; } +static void +_evas_vg_gradient_radial_render_pre(Eo *obj, + Ector_Surface *s, + void *data, + Evas_VG_Node_Data *nd) +{ + Evas_VG_Gradient_Radial_Data *pd = data; + Evas_VG_Gradient_Data *gd = eo_data_scope_get(obj, EVAS_VG_GRADIENT_CLASS); + + if (!nd->renderer) + { + eo_do(s, nd->renderer = ector_surface_renderer_factory_new(ECTOR_RENDERER_GENERIC_GRADIENT_RADIAL_CLASS)); + } + + eo_do(nd->renderer, + ector_renderer_transformation_set(nd->m), + 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), + ector_renderer_prepare()); +} + +static void +_evas_vg_gradient_radial_eo_base_constructor(Eo *obj, Evas_VG_Gradient_Radial_Data *pd) +{ + Evas_VG_Node_Data *nd; + + eo_do_super(obj, MY_CLASS, eo_constructor()); + + nd = eo_data_scope_get(obj, EVAS_VG_NODE_CLASS); + nd->render_pre = _evas_vg_gradient_radial_render_pre; + nd->data = pd; +} + +static void +_evas_vg_gradient_radial_eo_base_destructor(Eo *obj, + Evas_VG_Gradient_Radial_Data *pd EINA_UNUSED) +{ + eo_do_super(obj, MY_CLASS, eo_destructor()); +} + #include "evas_vg_gradient_radial.eo.c" diff --git a/src/lib/evas/canvas/evas_vg_gradient_radial.eo b/src/lib/evas/canvas/evas_vg_gradient_radial.eo index a6bfe70abd..0a06ae932d 100644 --- a/src/lib/evas/canvas/evas_vg_gradient_radial.eo +++ b/src/lib/evas/canvas/evas_vg_gradient_radial.eo @@ -9,5 +9,7 @@ class Evas.VG_Gradient_Radial (Evas.VG_Gradient, Efl.Graphics.Gradient_Radial) Efl.Graphics.Gradient_Radial.radius.get; Efl.Graphics.Gradient_Radial.focal.set; Efl.Graphics.Gradient_Radial.focal.get; + Eo.Base.constructor; + Eo.Base.destructor; } } diff --git a/src/lib/evas/canvas/evas_vg_image.c b/src/lib/evas/canvas/evas_vg_image.c index 21a7bbe19f..d47b94e94c 100644 --- a/src/lib/evas/canvas/evas_vg_image.c +++ b/src/lib/evas/canvas/evas_vg_image.c @@ -59,5 +59,16 @@ _evas_vg_image_efl_file_file_get(Eo *obj, Evas_VG_Image_Data *pd, if (key) *key = pd->key; } +static void +_evas_vg_image_eo_base_constructor(Eo *obj, Evas_VG_Image_Data *pd) +{ + eo_error_set(obj); +} + +static void +_evas_vg_image_eo_base_destructor(Eo *obj, Evas_VG_Image_Data *pd) +{ + eo_error_set(obj); +} #include "evas_vg_image.eo.c" diff --git a/src/lib/evas/canvas/evas_vg_image.eo b/src/lib/evas/canvas/evas_vg_image.eo index 6ed670e93e..33fe0b0272 100644 --- a/src/lib/evas/canvas/evas_vg_image.eo +++ b/src/lib/evas/canvas/evas_vg_image.eo @@ -28,5 +28,7 @@ class Evas.VG_Image (Evas.VG_Node, Efl.File) implements { Efl.File.file.set; Efl.File.file.get; + Eo.Base.constructor; + Eo.Base.destructor; } } \ No newline at end of file diff --git a/src/lib/evas/canvas/evas_vg_private.h b/src/lib/evas/canvas/evas_vg_private.h index 6b83623517..7d8f0691f4 100644 --- a/src/lib/evas/canvas/evas_vg_private.h +++ b/src/lib/evas/canvas/evas_vg_private.h @@ -1,14 +1,19 @@ #ifndef EVAS_VG_PRIVATE_H_ # define EVAS_VG_PRIVATE_H_ +#include + typedef struct _Evas_VG_Node_Data Evas_VG_Node_Data; +typedef struct _Evas_VG_Container_Data Evas_VG_Container_Data; +typedef struct _Evas_VG_Gradient_Data Evas_VG_Gradient_Data; + struct _Evas_VG_Node_Data { Eina_Matrix3 *m; Evas_VG_Node *mask; + Ector_Renderer *renderer; - void (*render_pre)(void); - void (*render)(void); + void (*render_pre)(Eo *obj, Ector_Surface *s, void *data, Evas_VG_Node_Data *nd); void *data; double x, y; @@ -18,10 +23,28 @@ struct _Evas_VG_Node_Data Eina_Bool changed : 1; }; -typedef struct _Evas_VG_Container_Data Evas_VG_Container_Data; struct _Evas_VG_Container_Data { Eina_List *children; }; +struct _Evas_VG_Gradient_Data +{ + // FIXME: Later on we should deduplicate it somehow (Using Ector ?). + Efl_Graphics_Gradient_Stop *colors; + unsigned int colors_count; + + Efl_Graphics_Gradient_Spread s; +}; + +static inline void +_evas_vg_render_pre(Evas_VG_Node *child, Ector_Surface *s) +{ + Evas_VG_Node_Data *child_nd; + + // FIXME: Prevent infinite loop + child_nd = eo_data_scope_get(child, EVAS_VG_NODE_CLASS); + child_nd->render_pre(child, s, child_nd->data, child_nd); +} + #endif diff --git a/src/lib/evas/canvas/evas_vg_shape.c b/src/lib/evas/canvas/evas_vg_shape.c index b39a9efa06..9e67710f16 100644 --- a/src/lib/evas/canvas/evas_vg_shape.c +++ b/src/lib/evas/canvas/evas_vg_shape.c @@ -8,7 +8,7 @@ typedef struct _Evas_VG_Shape_Data Evas_VG_Shape_Data; struct _Evas_VG_Shape_Data { - Efl_Graphics_Path_Command *op; + Efl_Graphics_Path_Command *ops; double *points; Evas_VG_Node *fill; @@ -29,49 +29,30 @@ struct _Evas_VG_Shape_Data Efl_Graphics_Cap cap; Efl_Graphics_Join join; } stroke; - - unsigned int op_count; - unsigned int pts_counts; }; static Eina_Bool _evas_vg_shape_efl_graphics_shape_path_set(Eo *obj EINA_UNUSED, Evas_VG_Shape_Data *pd, - const Efl_Graphics_Path_Command *op, + const Efl_Graphics_Path_Command *ops, const double *points) { free(pd->points); pd->points = NULL; - free(pd->op); - pd->op = NULL; + free(pd->ops); + pd->ops = NULL; - return efl_graphics_path_dup(&pd->op, &pd->points, op, points); + return efl_graphics_path_dup(&pd->ops, &pd->points, ops, points); } static Eina_Bool -_evas_vg_shape_bounds_get(Eo *obj, Evas_VG_Shape_Data *pd, Eina_Rectangle *r) +_evas_vg_shape_evas_vg_node_bound_get(Eo *obj, + Evas_VG_Shape_Data *pd, + Eina_Rectangle *r) { - (void) obj; (void) pd; (void) r; return EINA_FALSE; } -static void -_evas_vg_shape_eo_base_constructor(Eo *obj, Evas_VG_Shape_Data *pd EINA_UNUSED) -{ - eo_do_super(obj, MY_CLASS, eo_constructor()); - pd->stroke.cap = EFL_GRAPHICS_CAP_BUTT; - pd->stroke.join = EFL_GRAPHICS_JOIN_MITER; - pd->stroke.scale = 1; - pd->stroke.a = 1; - pd->stroke.centered = 0.5; -} - -static void -_evas_vg_shape_eo_base_destructor(Eo *obj, Evas_VG_Shape_Data *pd EINA_UNUSED) -{ - eo_do_super(obj, MY_CLASS, eo_destructor()); -} - static void _evas_vg_shape_fill_set(Eo *obj EINA_UNUSED, Evas_VG_Shape_Data *pd, @@ -249,4 +230,69 @@ _evas_vg_shape_efl_graphics_shape_stroke_join_get(Eo *obj EINA_UNUSED, return pd->stroke.join; } +static void +_evas_vg_shape_render_pre(Eo *obj EINA_UNUSED, + Ector_Surface *s, + void *data, + Evas_VG_Node_Data *nd) +{ + Evas_VG_Shape_Data *pd = data; + + _evas_vg_render_pre(pd->fill, s); + _evas_vg_render_pre(pd->stroke.fill, s); + _evas_vg_render_pre(pd->stroke.marker, s); + _evas_vg_render_pre(nd->mask, s); + + if (!nd->renderer) + { + eo_do(s, nd->renderer = ector_surface_renderer_factory_new(ECTOR_RENDERER_GENERIC_SHAPE_CLASS)); + } + + eo_do(nd->renderer, + ector_renderer_transformation_set(nd->m), + 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), + ector_renderer_mask_set(nd->mask), + ector_renderer_shape_fill_set(pd->fill), + ector_renderer_shape_stroke_fill_set(pd->stroke.fill), + ector_renderer_shape_stroke_marker_set(pd->stroke.marker), + 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), + ector_renderer_prepare()); +} + +static void +_evas_vg_shape_eo_base_constructor(Eo *obj, Evas_VG_Shape_Data *pd) +{ + Evas_VG_Node_Data *nd; + + eo_do_super(obj, MY_CLASS, eo_constructor()); + + pd->stroke.cap = EFL_GRAPHICS_CAP_BUTT; + pd->stroke.join = EFL_GRAPHICS_JOIN_MITER; + pd->stroke.scale = 1; + pd->stroke.a = 1; + pd->stroke.centered = 0.5; + + nd = eo_data_scope_get(obj, EVAS_VG_NODE_CLASS); + nd->render_pre = _evas_vg_shape_render_pre; + nd->data = pd; +} + +static void +_evas_vg_shape_eo_base_destructor(Eo *obj, Evas_VG_Shape_Data *pd EINA_UNUSED) +{ + eo_do_super(obj, MY_CLASS, eo_destructor()); +} + #include "evas_vg_shape.eo.c" diff --git a/src/lib/evas/canvas/evas_vg_shape.eo b/src/lib/evas/canvas/evas_vg_shape.eo index 0574b72118..41845b450e 100644 --- a/src/lib/evas/canvas/evas_vg_shape.eo +++ b/src/lib/evas/canvas/evas_vg_shape.eo @@ -40,6 +40,7 @@ class Evas.VG_Shape (Evas.VG_Node, Efl.Graphics.Shape) Efl.Graphics.Shape.stroke_cap; Efl.Graphics.Shape.stroke_join; Efl.Graphics.Shape.path_set; + Evas.VG_Node.bound_get; Eo.Base.constructor; Eo.Base.destructor; } From 7910870c2e1395b303d83eefe26c15b5bc43618f Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:22:59 +0200 Subject: [PATCH 077/251] ecore_evas_svg: actually make the Evas_Object_VG visible. --- src/bin/ecore_evas/ecore_evas_svg.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/bin/ecore_evas/ecore_evas_svg.c b/src/bin/ecore_evas/ecore_evas_svg.c index 379aaae44e..468311f10d 100644 --- a/src/bin/ecore_evas/ecore_evas_svg.c +++ b/src/bin/ecore_evas/ecore_evas_svg.c @@ -162,7 +162,8 @@ main(int argc, char *argv[]) ecore_evas_object_associate(ee, r, ECORE_EVAS_OBJECT_ASSOCIATE_BASE); vg = eo_add(EVAS_VG_CLASS, e, - efl_file_set(argv[arg_index], NULL)); + efl_file_set(argv[arg_index], NULL), + evas_obj_visibility_set(EINA_TRUE)); ecore_evas_object_associate(ee, vg, ECORE_EVAS_OBJECT_ASSOCIATE_BASE); if (display) From 2cae706ab6ca8ecbd561b752be49f4130672d19d Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:23:00 +0200 Subject: [PATCH 078/251] evas: start correctly implementing the render callback. --- src/lib/evas/canvas/evas_object_vg.c | 72 ++++++++++++++++++---------- 1 file changed, 47 insertions(+), 25 deletions(-) diff --git a/src/lib/evas/canvas/evas_object_vg.c b/src/lib/evas/canvas/evas_object_vg.c index dba3c7a49f..e48114b1fb 100644 --- a/src/lib/evas/canvas/evas_object_vg.c +++ b/src/lib/evas/canvas/evas_object_vg.c @@ -126,12 +126,39 @@ _evas_vg_eo_base_constructor(Eo *eo_obj, Evas_VG_Data *pd) } static void -evas_object_vg_render(Evas_Object *eo_obj EINA_UNUSED, - Evas_Object_Protected_Data *obj EINA_UNUSED, - void *type_private_data EINA_UNUSED, - void *output EINA_UNUSED, void *context EINA_UNUSED, void *surface EINA_UNUSED, - int x EINA_UNUSED, int y EINA_UNUSED, Eina_Bool do_async EINA_UNUSED) +_evas_vg_render(Evas_Object_Protected_Data *obj, + void *output, void *context, void *surface, Evas_VG_Node *n, + Eina_Array *clips, int x, int y, Eina_Bool do_async) { + Evas_VG_Container_Data *vd = eo_data_scope_get(n, EVAS_VG_CONTAINER_CLASS); + + if (vd) + { + Evas_VG_Node *child; + Eina_List *l; + + EINA_LIST_FOREACH(vd->children, l, child) + _evas_vg_render(obj, + output, context, surface, child, + clips, x, y, do_async); + } + else + { + Evas_VG_Node_Data *nd = eo_data_scope_get(n, EVAS_VG_NODE_CLASS); + + obj->layer->evas->engine.func->ector_draw(output, context, surface, nd->renderer, clips, x, y, do_async); + } +} + +static void +evas_object_vg_render(Evas_Object *eo_obj EINA_UNUSED, + Evas_Object_Protected_Data *obj, + void *type_private_data, + void *output, void *context, void *surface, + int x, int y, Eina_Bool do_async) +{ + Evas_VG_Data *vd = type_private_data; + // FIXME: Set context (that should affect Ector_Surface) and // then call Ector_Renderer render from bottom to top. Get the // Ector_Surface that match the output from Evas engine API. @@ -140,26 +167,21 @@ evas_object_vg_render(Evas_Object *eo_obj EINA_UNUSED, // child of the main Ector_Surface (necessary for Evas_Map). /* render object to surface with context, and offxet by x,y */ - /* obj->layer->evas->engine.func->context_color_set(output, */ - /* context, */ - /* obj->cur->cache.clip.r, */ - /* obj->cur->cache.clip.g, */ - /* obj->cur->cache.clip.b, */ - /* obj->cur->cache.clip.a); */ - /* obj->layer->evas->engine.func->context_anti_alias_set(output, context, */ - /* obj->cur->anti_alias); */ - /* obj->layer->evas->engine.func->context_multiplier_unset(output, */ - /* context); */ - /* obj->layer->evas->engine.func->context_render_op_set(output, context, */ - /* obj->cur->render_op); */ - /* obj->layer->evas->engine.func->rectangle_draw(output, */ - /* context, */ - /* surface, */ - /* obj->cur->geometry.x + x, */ - /* obj->cur->geometry.y + y, */ - /* obj->cur->geometry.w, */ - /* obj->cur->geometry.h, */ - /* do_async); */ + obj->layer->evas->engine.func->context_color_set(output, + context, + obj->cur->cache.clip.r, + obj->cur->cache.clip.g, + obj->cur->cache.clip.b, + obj->cur->cache.clip.a); + obj->layer->evas->engine.func->context_anti_alias_set(output, context, + obj->cur->anti_alias); + obj->layer->evas->engine.func->context_multiplier_unset(output, + context); + obj->layer->evas->engine.func->context_render_op_set(output, context, + obj->cur->render_op); + _evas_vg_render(obj, output, context, surface, vd->root, NULL, + obj->cur->geometry.x + x, obj->cur->geometry.y + y, + do_async); } static void From 0bb66ffedf7eff7b6da897a061ac158e310bb811 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:23:01 +0200 Subject: [PATCH 079/251] efl: add efl_graphics_path_interpolate and efl_graphics_path_equal_commands. This function will be handy to implement path interpolation in Edje later on. This would be usable by Edje if we do push an Evas_Object_Shape. Not really difficult to add at this stage. --- src/lib/efl/interfaces/efl_graphics_utils.c | 32 ++++++++++++++++++++- src/lib/efl/interfaces/efl_graphics_utils.h | 9 ++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/lib/efl/interfaces/efl_graphics_utils.c b/src/lib/efl/interfaces/efl_graphics_utils.c index 64d70885ce..3aa11c4fb6 100644 --- a/src/lib/efl/interfaces/efl_graphics_utils.c +++ b/src/lib/efl/interfaces/efl_graphics_utils.c @@ -4,7 +4,7 @@ #include -static unsigned int +static inline unsigned int efl_graphics_path_command_length(Efl_Graphics_Path_Command command) { switch (command) @@ -95,6 +95,36 @@ efl_graphics_path_dup(Efl_Graphics_Path_Command **out_cmd, double **out_pts, 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 void efl_graphics_path_append_move_to(Efl_Graphics_Path_Command **commands, double **points, double x, double y) diff --git a/src/lib/efl/interfaces/efl_graphics_utils.h b/src/lib/efl/interfaces/efl_graphics_utils.h index 1465e13387..6bf0974046 100644 --- a/src/lib/efl/interfaces/efl_graphics_utils.h +++ b/src/lib/efl/interfaces/efl_graphics_utils.h @@ -46,4 +46,13 @@ efl_graphics_path_append_circle(Efl_Graphics_Path_Command **commands, double **p double x, double y, double radius); +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); + #endif From 502ac459162589e95c57fa0ede376159044d4278 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:23:03 +0200 Subject: [PATCH 080/251] evas: properly propagate Eina_Matrix from the VG scene graph to the Ector_Renderer. --- src/lib/evas/canvas/evas_object_vg.c | 2 +- src/lib/evas/canvas/evas_vg_container.c | 6 +++-- src/lib/evas/canvas/evas_vg_gradient_linear.c | 4 +++- src/lib/evas/canvas/evas_vg_gradient_radial.c | 4 +++- src/lib/evas/canvas/evas_vg_private.h | 24 ++++++++++++++++--- src/lib/evas/canvas/evas_vg_shape.c | 12 ++++++---- 6 files changed, 39 insertions(+), 13 deletions(-) diff --git a/src/lib/evas/canvas/evas_object_vg.c b/src/lib/evas/canvas/evas_object_vg.c index e48114b1fb..f74e06e3e4 100644 --- a/src/lib/evas/canvas/evas_object_vg.c +++ b/src/lib/evas/canvas/evas_object_vg.c @@ -197,7 +197,7 @@ evas_object_vg_render_pre(Evas_Object *eo_obj, // FIXME: handle damage only on changed renderer. s = e->engine.func->ector_get(e->engine.data.output); if (vd->root && s) - _evas_vg_render_pre(vd->root, s); + _evas_vg_render_pre(vd->root, s, NULL); /* dont pre-render the obj twice! */ if (obj->pre_render_done) return; diff --git a/src/lib/evas/canvas/evas_vg_container.c b/src/lib/evas/canvas/evas_vg_container.c index 20ac001f95..cc679cd86e 100644 --- a/src/lib/evas/canvas/evas_vg_container.c +++ b/src/lib/evas/canvas/evas_vg_container.c @@ -7,16 +7,18 @@ static void _evas_vg_container_render_pre(Eo *obj EINA_UNUSED, + Eina_Matrix3 *parent, Ector_Surface *s, void *data, - Evas_VG_Node_Data *nd EINA_UNUSED) + Evas_VG_Node_Data *nd) { Evas_VG_Container_Data *pd = data; Eina_List *l; Eo *child; + EVAS_VG_COMPUTE_MATRIX(current, parent, nd); EINA_LIST_FOREACH(pd->children, l, child) - _evas_vg_render_pre(child, s); + _evas_vg_render_pre(child, s, current); } static void diff --git a/src/lib/evas/canvas/evas_vg_gradient_linear.c b/src/lib/evas/canvas/evas_vg_gradient_linear.c index 156a5851ed..5d0af64eb9 100644 --- a/src/lib/evas/canvas/evas_vg_gradient_linear.c +++ b/src/lib/evas/canvas/evas_vg_gradient_linear.c @@ -53,12 +53,14 @@ _evas_vg_gradient_linear_efl_graphics_gradient_linear_end_get(Eo *obj EINA_UNUSE static void _evas_vg_gradient_linear_render_pre(Eo *obj, + Eina_Matrix3 *parent, Ector_Surface *s, void *data, Evas_VG_Node_Data *nd) { Evas_VG_Gradient_Linear_Data *pd = data; Evas_VG_Gradient_Data *gd = eo_data_scope_get(obj, EVAS_VG_GRADIENT_CLASS); + EVAS_VG_COMPUTE_MATRIX(current, parent, nd); if (!nd->renderer) { @@ -66,7 +68,7 @@ _evas_vg_gradient_linear_render_pre(Eo *obj, } eo_do(nd->renderer, - ector_renderer_transformation_set(nd->m), + ector_renderer_transformation_set(current), 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), diff --git a/src/lib/evas/canvas/evas_vg_gradient_radial.c b/src/lib/evas/canvas/evas_vg_gradient_radial.c index c27430a340..e7adce17d9 100644 --- a/src/lib/evas/canvas/evas_vg_gradient_radial.c +++ b/src/lib/evas/canvas/evas_vg_gradient_radial.c @@ -67,12 +67,14 @@ _evas_vg_gradient_radial_efl_graphics_gradient_radial_focal_get(Eo *obj EINA_UNU static void _evas_vg_gradient_radial_render_pre(Eo *obj, + Eina_Matrix3 *parent, Ector_Surface *s, void *data, Evas_VG_Node_Data *nd) { Evas_VG_Gradient_Radial_Data *pd = data; Evas_VG_Gradient_Data *gd = eo_data_scope_get(obj, EVAS_VG_GRADIENT_CLASS); + EVAS_VG_COMPUTE_MATRIX(current, parent, nd); if (!nd->renderer) { @@ -80,7 +82,7 @@ _evas_vg_gradient_radial_render_pre(Eo *obj, } eo_do(nd->renderer, - ector_renderer_transformation_set(nd->m), + ector_renderer_transformation_set(current), 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), diff --git a/src/lib/evas/canvas/evas_vg_private.h b/src/lib/evas/canvas/evas_vg_private.h index 7d8f0691f4..80f8fe5e5b 100644 --- a/src/lib/evas/canvas/evas_vg_private.h +++ b/src/lib/evas/canvas/evas_vg_private.h @@ -13,7 +13,7 @@ struct _Evas_VG_Node_Data Evas_VG_Node *mask; Ector_Renderer *renderer; - void (*render_pre)(Eo *obj, Ector_Surface *s, void *data, Evas_VG_Node_Data *nd); + void (*render_pre)(Eo *obj, Eina_Matrix3 *parent, Ector_Surface *s, void *data, Evas_VG_Node_Data *nd); void *data; double x, y; @@ -38,13 +38,31 @@ struct _Evas_VG_Gradient_Data }; static inline void -_evas_vg_render_pre(Evas_VG_Node *child, Ector_Surface *s) +_evas_vg_render_pre(Evas_VG_Node *child, Ector_Surface *s, Eina_Matrix3 *m) { Evas_VG_Node_Data *child_nd; // FIXME: Prevent infinite loop child_nd = eo_data_scope_get(child, EVAS_VG_NODE_CLASS); - child_nd->render_pre(child, s, child_nd->data, child_nd); + child_nd->render_pre(child, m, s, child_nd->data, child_nd); } +#define EVAS_VG_COMPUTE_MATRIX(Current, Parent, Nd) \ + Eina_Matrix3 *Current = Nd->m; \ + Eina_Matrix3 _matrix_tmp; \ + \ + if (Parent) \ + { \ + if (Current) \ + { \ + eina_matrix3_compose(Parent, Current, &_matrix_tmp); \ + Current = &_matrix_tmp; \ + } \ + else \ + { \ + Current = Parent; \ + } \ + } + + #endif diff --git a/src/lib/evas/canvas/evas_vg_shape.c b/src/lib/evas/canvas/evas_vg_shape.c index 9e67710f16..49eac2d951 100644 --- a/src/lib/evas/canvas/evas_vg_shape.c +++ b/src/lib/evas/canvas/evas_vg_shape.c @@ -232,16 +232,18 @@ _evas_vg_shape_efl_graphics_shape_stroke_join_get(Eo *obj EINA_UNUSED, static void _evas_vg_shape_render_pre(Eo *obj EINA_UNUSED, + Eina_Matrix3 *parent, Ector_Surface *s, void *data, Evas_VG_Node_Data *nd) { Evas_VG_Shape_Data *pd = data; + EVAS_VG_COMPUTE_MATRIX(current, parent, nd); - _evas_vg_render_pre(pd->fill, s); - _evas_vg_render_pre(pd->stroke.fill, s); - _evas_vg_render_pre(pd->stroke.marker, s); - _evas_vg_render_pre(nd->mask, s); + _evas_vg_render_pre(pd->fill, s, current); + _evas_vg_render_pre(pd->stroke.fill, s, current); + _evas_vg_render_pre(pd->stroke.marker, s, current); + _evas_vg_render_pre(nd->mask, s, current); if (!nd->renderer) { @@ -249,7 +251,7 @@ _evas_vg_shape_render_pre(Eo *obj EINA_UNUSED, } eo_do(nd->renderer, - ector_renderer_transformation_set(nd->m), + ector_renderer_transformation_set(current), 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), From 5aafae94f171bd47f735fea234219c5217be84f7 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:23:04 +0200 Subject: [PATCH 081/251] evas: actually we want the Ector_Renderer, not the Evas_VG_Node. --- src/lib/evas/canvas/evas_vg_private.h | 12 ++++++++---- src/lib/evas/canvas/evas_vg_shape.c | 17 +++++++++-------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/lib/evas/canvas/evas_vg_private.h b/src/lib/evas/canvas/evas_vg_private.h index 80f8fe5e5b..a2b8aa94ee 100644 --- a/src/lib/evas/canvas/evas_vg_private.h +++ b/src/lib/evas/canvas/evas_vg_private.h @@ -37,14 +37,18 @@ struct _Evas_VG_Gradient_Data Efl_Graphics_Gradient_Spread s; }; -static inline void +static inline Evas_VG_Node * _evas_vg_render_pre(Evas_VG_Node *child, Ector_Surface *s, Eina_Matrix3 *m) { - Evas_VG_Node_Data *child_nd; + Evas_VG_Node_Data *child_nd = NULL; // FIXME: Prevent infinite loop - child_nd = eo_data_scope_get(child, EVAS_VG_NODE_CLASS); - child_nd->render_pre(child, m, s, child_nd->data, child_nd); + if (child) + child_nd = eo_data_scope_get(child, EVAS_VG_NODE_CLASS); + if (child_nd) + child_nd->render_pre(child, m, s, child_nd->data, child_nd); + + return child_nd; } #define EVAS_VG_COMPUTE_MATRIX(Current, Parent, Nd) \ diff --git a/src/lib/evas/canvas/evas_vg_shape.c b/src/lib/evas/canvas/evas_vg_shape.c index 49eac2d951..797712a6a4 100644 --- a/src/lib/evas/canvas/evas_vg_shape.c +++ b/src/lib/evas/canvas/evas_vg_shape.c @@ -238,12 +238,13 @@ _evas_vg_shape_render_pre(Eo *obj EINA_UNUSED, Evas_VG_Node_Data *nd) { Evas_VG_Shape_Data *pd = data; + Evas_VG_Node_Data *fill, *stroke_fill, *stroke_marker, *mask; EVAS_VG_COMPUTE_MATRIX(current, parent, nd); - _evas_vg_render_pre(pd->fill, s, current); - _evas_vg_render_pre(pd->stroke.fill, s, current); - _evas_vg_render_pre(pd->stroke.marker, s, current); - _evas_vg_render_pre(nd->mask, s, current); + fill = _evas_vg_render_pre(pd->fill, s, current); + stroke_fill = _evas_vg_render_pre(pd->stroke.fill, s, current); + stroke_marker = _evas_vg_render_pre(pd->stroke.marker, s, current); + mask = _evas_vg_render_pre(nd->mask, s, current); if (!nd->renderer) { @@ -255,10 +256,10 @@ _evas_vg_shape_render_pre(Eo *obj EINA_UNUSED, 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), - ector_renderer_mask_set(nd->mask), - ector_renderer_shape_fill_set(pd->fill), - ector_renderer_shape_stroke_fill_set(pd->stroke.fill), - ector_renderer_shape_stroke_marker_set(pd->stroke.marker), + ector_renderer_mask_set(mask->renderer), + ector_renderer_shape_fill_set(fill->renderer), + ector_renderer_shape_stroke_fill_set(stroke_fill->renderer), + ector_renderer_shape_stroke_marker_set(stroke_marker->renderer), efl_graphics_shape_stroke_scale_set(pd->stroke.scale), efl_graphics_shape_stroke_color_set(pd->stroke.r, pd->stroke.g, From ce4d4aac04ca7a093e5d2a81d67c7be67d179173 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:23:05 +0200 Subject: [PATCH 082/251] efl: fix typos that emitted the wrong PATH type. --- src/lib/efl/interfaces/efl_graphics_utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/efl/interfaces/efl_graphics_utils.c b/src/lib/efl/interfaces/efl_graphics_utils.c index 3aa11c4fb6..9edb75cad4 100644 --- a/src/lib/efl/interfaces/efl_graphics_utils.c +++ b/src/lib/efl/interfaces/efl_graphics_utils.c @@ -244,7 +244,7 @@ efl_graphics_path_append_close(Efl_Graphics_Path_Command **commands, double **po { double *offset_point; - efl_graphics_path_grow(EFL_GRAPHICS_PATH_COMMAND_TYPE_ARC_TO, + efl_graphics_path_grow(EFL_GRAPHICS_PATH_COMMAND_TYPE_CLOSE, commands, points, &offset_point); } From 4248bc2870eab45ffda8cc52f3465a1291e00c32 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:23:06 +0200 Subject: [PATCH 083/251] evas: actually return the right type and fix warnings. --- src/lib/evas/canvas/evas_vg_private.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/evas/canvas/evas_vg_private.h b/src/lib/evas/canvas/evas_vg_private.h index a2b8aa94ee..10e4b6c6c4 100644 --- a/src/lib/evas/canvas/evas_vg_private.h +++ b/src/lib/evas/canvas/evas_vg_private.h @@ -37,7 +37,7 @@ struct _Evas_VG_Gradient_Data Efl_Graphics_Gradient_Spread s; }; -static inline Evas_VG_Node * +static inline Evas_VG_Node_Data * _evas_vg_render_pre(Evas_VG_Node *child, Ector_Surface *s, Eina_Matrix3 *m) { Evas_VG_Node_Data *child_nd = NULL; From 5bb35d559863d490f1b261b92114a740227179b9 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:23:07 +0200 Subject: [PATCH 084/251] efl: simplify the enum to only use Cubic Bezier curve. So SVG support all kind of primitive, but really they are just sugar on top of the simpler cubic bezier curve. Let's simplify our backend by just supporting them and the simple line. We still provide all the sugar, but via helper function that do convert to the right number of Bezier curve. --- .../ector/cairo/ector_renderer_cairo_shape.c | 263 ----------------- src/lib/efl/Efl.h | 4 - src/lib/efl/interfaces/efl_graphics_utils.c | 273 +++++++++++++++--- src/lib/efl/interfaces/efl_graphics_utils.h | 9 +- 4 files changed, 244 insertions(+), 305 deletions(-) diff --git a/src/lib/ector/cairo/ector_renderer_cairo_shape.c b/src/lib/ector/cairo/ector_renderer_cairo_shape.c index d46cf54c2c..095fe02feb 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_shape.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_shape.c @@ -45,165 +45,6 @@ struct _Ector_Renderer_Cairo_Shape_Data cairo_path_t *path; }; -// This function come from librsvg rsvg-path.c -static void -_ector_arc_segment(Eo *obj, cairo_t* ctx, - double xc, double yc, - double th0, double th1, double rx, double ry, - double x_axis_rotation) -{ - double x1, y1, x2, y2, x3, y3; - double t; - double th_half; - double f, sinf, cosf; - - f = x_axis_rotation * 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)); - - USE(obj, cairo_curve_to, ); - - cairo_curve_to(ctx, - xc + cosf * x1 - sinf * y1, - yc + sinf * x1 + cosf * y1, - xc + cosf * x2 - sinf * y2, - yc + sinf * x2 + cosf * y2, - xc + cosf * x3 - sinf * y3, - yc + sinf * x3 + cosf * y3); -} - -// This function come from librsvg rsvg-path.c -static void -_ector_arc_to(Eo *obj, cairo_t* ctx, - double *current_x, double *current_y, - double rx, double ry, double x_axis_rotation, - Eina_Bool large_arc_flag, Eina_Bool sweep_flag, - double x, double y) -{ - /* 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; - - /* Start and end of path segment */ - x1 = *current_x; - y1 = *current_y; - - x2 = x; - y2 = y; - - if (x1 == x2 && y1 == y2) - return; - - /* X-axis */ - f = x_axis_rotation * 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)) { - USE(obj, cairo_line_to, ); - - cairo_line_to(ctx, x, y); - - *current_x = x; - *current_y = 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_flag == large_arc_flag) - 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_flag && delta_theta < 0) - delta_theta += M_PI*2; - else if (!sweep_flag && 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++) - _ector_arc_segment(obj, ctx, - cx, cy, - theta1 + i * delta_theta / n_segs, - theta1 + (i + 1) * delta_theta / n_segs, - rx, ry, x_axis_rotation); - - *current_x = x; - *current_y = y; -} - static Eina_Bool _ector_renderer_cairo_shape_ector_renderer_generic_base_prepare(Eo *obj, Ector_Renderer_Cairo_Shape_Data *pd) { @@ -230,8 +71,6 @@ _ector_renderer_cairo_shape_ector_renderer_generic_base_prepare(Eo *obj, Ector_R if (!pd->path && pd->shape->path.cmd) { double *pts; - double current_x = 0, current_y = 0; - double current_ctrl_x = 0, current_ctrl_y = 0; unsigned int i; USE(obj, cairo_new_path, EINA_FALSE); @@ -248,9 +87,6 @@ _ector_renderer_cairo_shape_ector_renderer_generic_base_prepare(Eo *obj, Ector_R cairo_move_to(pd->parent->cairo, pts[0], pts[1]); - current_ctrl_x = current_x = pts[0]; - current_ctrl_y = current_y = pts[1]; - pts += 2; break; case EFL_GRAPHICS_PATH_COMMAND_TYPE_LINE_TO: @@ -258,9 +94,6 @@ _ector_renderer_cairo_shape_ector_renderer_generic_base_prepare(Eo *obj, Ector_R cairo_line_to(pd->parent->cairo, pts[0], pts[1]); - current_ctrl_x = current_x = pts[0]; - current_ctrl_y = current_y = pts[1]; - pts += 2; break; case EFL_GRAPHICS_PATH_COMMAND_TYPE_CUBIC_TO: @@ -273,109 +106,13 @@ _ector_renderer_cairo_shape_ector_renderer_generic_base_prepare(Eo *obj, Ector_R pts[2], pts[3], pts[4], pts[5], // control points pts[0], pts[1]); // destination point - current_ctrl_x = pts[4]; - current_ctrl_y = pts[5]; - current_x = pts[0]; - current_y = pts[1]; - pts += 6; break; - case EFL_GRAPHICS_PATH_COMMAND_TYPE_ARC_TO: - _ector_arc_to(obj, pd->parent->cairo, - ¤t_x, ¤t_y, - pts[2], pts[3], pts[4], - 0, 0, // FIXME: need to get the large arc and sweep flag - pts[0], pts[1]); - - pts += 5; - break; case EFL_GRAPHICS_PATH_COMMAND_TYPE_CLOSE: USE(obj, cairo_close_path, EINA_FALSE); cairo_close_path(pd->parent->cairo); break; - case EFL_GRAPHICS_PATH_COMMAND_TYPE_QUADRATIC_TO: - { - double x1, y1, x2, y2, x3, y3; - // This code come from librsvg rsvg-path.c - // Be careful, we do have a different order than - // cairo, first is destination point, followed by - // the control point. The opposite of cairo. - /* raise quadratic bezier to cubic */ - x1 = (current_x + 2 * pts[2]) * (1.0 / 3.0); - y1 = (current_y + 2 * pts[3]) * (1.0 / 3.0); - x3 = pts[0]; - y3 = pts[1]; - x2 = (x3 + 2 * pts[2]) * (1.0 / 3.0); - y2 = (y3 + 2 * pts[3]) * (1.0 / 3.0); - - cairo_curve_to(pd->parent->cairo, - x1, y1, x2, y2, // control points - x3, y3); // destination point - - current_ctrl_x = pts[2]; - current_ctrl_y = pts[3]; - - current_x = x3; - current_y = y3; - break; - } - case EFL_GRAPHICS_PATH_COMMAND_TYPE_SQUADRATIC_TO: - { - // This code come from librsvg rsvg-path.c - // Smooth quadratic basically reusing the last control - // point in a meaningful way. - double xc, yc; /* quadratic control point */ - double x1, y1, x2, y2, x3, y3; - - xc = 2 * current_x - current_ctrl_x; - yc = 2 * current_y - current_ctrl_y; - /* generate a quadratic bezier with control point = xc, yc */ - x1 = (current_x + 2 * xc) * (1.0 / 3.0); - y1 = (current_y + 2 * yc) * (1.0 / 3.0); - x3 = pts[0]; - y3 = pts[1]; - x2 = (x3 + 2 * xc) * (1.0 / 3.0); - y2 = (y3 + 2 * yc) * (1.0 / 3.0); - - USE(obj, cairo_curve_to, EINA_FALSE); - - cairo_curve_to(pd->parent->cairo, - x1, y1, x2, y2, x3, y3); - - current_ctrl_x = xc; - current_ctrl_y = yc; - - current_x = x3; - current_y = y3; - - break; - } - case EFL_GRAPHICS_PATH_COMMAND_TYPE_SCUBIC_TO: - { - // This code come from librsvg rsvg-path.c - // Smooth cubic basically reusing the last control point - // in a meaningful way. - double x1, y1, x2, y2, x3, y3; - - x1 = 2 * current_x - current_ctrl_x; - y1 = 2 * current_y - current_ctrl_y; - x2 = pts[2]; - y2 = pts[3]; - x3 = pts[0]; - y3 = pts[1]; - - USE(obj, cairo_curve_to, EINA_FALSE); - - cairo_curve_to(pd->parent->cairo, - x1, y1, x2, y2, x3, y3); - - current_ctrl_x = x2; - current_ctrl_y = y2; - current_x = x3; - current_y = y3; - break; - } case EFL_GRAPHICS_PATH_COMMAND_TYPE_LAST: case EFL_GRAPHICS_PATH_COMMAND_TYPE_END: break; diff --git a/src/lib/efl/Efl.h b/src/lib/efl/Efl.h index bcbea5fbd6..d763967869 100644 --- a/src/lib/efl/Efl.h +++ b/src/lib/efl/Efl.h @@ -45,11 +45,7 @@ typedef enum _Efl_Graphics_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_QUADRATIC_TO, /**< A quadratic command type */ - EFL_GRAPHICS_PATH_COMMAND_TYPE_SQUADRATIC_TO, /**< A smooth quadratic command type */ EFL_GRAPHICS_PATH_COMMAND_TYPE_CUBIC_TO, /**< A cubic command type */ - EFL_GRAPHICS_PATH_COMMAND_TYPE_SCUBIC_TO, /**< A smooth cubic command type */ - EFL_GRAPHICS_PATH_COMMAND_TYPE_ARC_TO, /**< An arc 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; diff --git a/src/lib/efl/interfaces/efl_graphics_utils.c b/src/lib/efl/interfaces/efl_graphics_utils.c index 9edb75cad4..836bfd3bc5 100644 --- a/src/lib/efl/interfaces/efl_graphics_utils.c +++ b/src/lib/efl/interfaces/efl_graphics_utils.c @@ -4,6 +4,10 @@ #include +#include +#include +#include + static inline unsigned int efl_graphics_path_command_length(Efl_Graphics_Path_Command command) { @@ -12,11 +16,7 @@ efl_graphics_path_command_length(Efl_Graphics_Path_Command 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_QUADRATIC_TO: return 4; - case EFL_GRAPHICS_PATH_COMMAND_TYPE_SQUADRATIC_TO: return 2; case EFL_GRAPHICS_PATH_COMMAND_TYPE_CUBIC_TO: return 6; - case EFL_GRAPHICS_PATH_COMMAND_TYPE_SCUBIC_TO: return 4; - case EFL_GRAPHICS_PATH_COMMAND_TYPE_ARC_TO: return 5; case EFL_GRAPHICS_PATH_COMMAND_TYPE_CLOSE: return 0; case EFL_GRAPHICS_PATH_COMMAND_TYPE_LAST: return 0; } @@ -125,6 +125,52 @@ efl_graphics_path_interpolate(const Efl_Graphics_Path_Command *cmd, *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) @@ -157,30 +203,49 @@ 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 *offset_point; + double current_x = 0, current_y = 0; + double ctrl_x0, ctrl_y0, ctrl_x1, ctrl_y1; - if (!efl_graphics_path_grow(EFL_GRAPHICS_PATH_COMMAND_TYPE_QUADRATIC_TO, - commands, points, &offset_point)) + if (!efl_graphics_path_current_get(*commands, *points, + ¤t_x, ¤t_y, + NULL, NULL)) return ; - offset_point[0] = x; - offset_point[1] = y; - offset_point[2] = ctrl_x; - offset_point[3] = ctrl_y; + // 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 *offset_point; + 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_grow(EFL_GRAPHICS_PATH_COMMAND_TYPE_SQUADRATIC_TO, - commands, points, &offset_point)) + if (!efl_graphics_path_current_get(*commands, *points, + ¤t_x, ¤t_y, + ¤t_ctrl_x, ¤t_ctrl_y)) return ; - offset_point[0] = x; - offset_point[1] = y; + 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 @@ -208,35 +273,169 @@ efl_graphics_path_append_scubic_to(Efl_Graphics_Path_Command **commands, double double x, double y, double ctrl_x, double ctrl_y) { - double *offset_point; + 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_grow(EFL_GRAPHICS_PATH_COMMAND_TYPE_SCUBIC_TO, - commands, points, &offset_point)) + if (!efl_graphics_path_current_get(*commands, *points, + ¤t_x, ¤t_y, + ¤t_ctrl_x, ¤t_ctrl_y)) return ; - offset_point[0] = x; - offset_point[1] = y; - offset_point[2] = ctrl_x; - offset_point[3] = ctrl_y; + 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) + double rx, double ry, double angle, + Eina_Bool large_arc, Eina_Bool sweep) { - double *offset_point; + /* 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_grow(EFL_GRAPHICS_PATH_COMMAND_TYPE_ARC_TO, - commands, points, &offset_point)) + if (!efl_graphics_path_current_get(*commands, *points, + &x1, &y1, + NULL, NULL)) return ; - offset_point[0] = x; - offset_point[1] = y; - offset_point[2] = rx; - offset_point[3] = ry; - offset_point[4] = angle; + /* 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 @@ -253,8 +452,8 @@ efl_graphics_path_append_circle(Efl_Graphics_Path_Command **commands, double **p 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); - efl_graphics_path_append_arc_to(commands, points, x, y + radius, radius, radius, 0); - efl_graphics_path_append_arc_to(commands, points, x - radius, y, radius, radius, 0); - efl_graphics_path_append_arc_to(commands, points, x, y - radius, radius, radius, 0); + 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); } diff --git a/src/lib/efl/interfaces/efl_graphics_utils.h b/src/lib/efl/interfaces/efl_graphics_utils.h index 6bf0974046..eb87e85bfe 100644 --- a/src/lib/efl/interfaces/efl_graphics_utils.h +++ b/src/lib/efl/interfaces/efl_graphics_utils.h @@ -36,7 +36,8 @@ 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); + double angle, + Eina_Bool large_arc, Eina_Bool sweep); EAPI void efl_graphics_path_append_close(Efl_Graphics_Path_Command **commands, double **points); @@ -55,4 +56,10 @@ 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 From 125701c66799d33cee82f2f022da4e8047a523dd Mon Sep 17 00:00:00 2001 From: Subhransu Sekhar Mohanty Date: Fri, 3 Apr 2015 16:23:08 +0200 Subject: [PATCH 085/251] efl : fix append circle api in efl_graphics_utils --- src/lib/efl/interfaces/efl_graphics_utils.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/efl/interfaces/efl_graphics_utils.c b/src/lib/efl/interfaces/efl_graphics_utils.c index 836bfd3bc5..b1adf3415a 100644 --- a/src/lib/efl/interfaces/efl_graphics_utils.c +++ b/src/lib/efl/interfaces/efl_graphics_utils.c @@ -452,8 +452,8 @@ efl_graphics_path_append_circle(Efl_Graphics_Path_Command **commands, double **p 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); + 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); } From 091fd5f31d337c52bfb88a6a48632dc952b98284 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:23:09 +0200 Subject: [PATCH 086/251] evas: handle setting sub VG object to NULL. --- src/lib/evas/canvas/evas_vg_shape.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib/evas/canvas/evas_vg_shape.c b/src/lib/evas/canvas/evas_vg_shape.c index 797712a6a4..ac57eae56c 100644 --- a/src/lib/evas/canvas/evas_vg_shape.c +++ b/src/lib/evas/canvas/evas_vg_shape.c @@ -256,10 +256,10 @@ _evas_vg_shape_render_pre(Eo *obj EINA_UNUSED, 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), - ector_renderer_mask_set(mask->renderer), - ector_renderer_shape_fill_set(fill->renderer), - ector_renderer_shape_stroke_fill_set(stroke_fill->renderer), - ector_renderer_shape_stroke_marker_set(stroke_marker->renderer), + ector_renderer_mask_set(mask ? mask->renderer : NULL), + 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, From ba47b47eb23ba8633a71cdf44446df20a135ab0c Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:23:10 +0200 Subject: [PATCH 087/251] efl: make path a property actually. --- src/lib/ector/cairo/ector_renderer_cairo_shape.c | 14 +++++--------- src/lib/ector/cairo/ector_renderer_cairo_shape.eo | 2 +- src/lib/ector/ector_renderer_generic_shape.eo | 2 +- src/lib/ector/ector_renderer_shape.c | 14 ++++++++++++-- src/lib/efl/interfaces/efl_graphics_shape.eo | 15 ++++++++------- src/lib/evas/canvas/evas_vg_shape.c | 14 ++++++++++++-- src/lib/evas/canvas/evas_vg_shape.eo | 2 +- 7 files changed, 40 insertions(+), 23 deletions(-) diff --git a/src/lib/ector/cairo/ector_renderer_cairo_shape.c b/src/lib/ector/cairo/ector_renderer_cairo_shape.c index 095fe02feb..9bfe961d67 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_shape.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_shape.c @@ -180,20 +180,16 @@ _ector_renderer_cairo_shape_ector_renderer_cairo_base_fill(Eo *obj, Ector_Render // I need to read SVG specification and see how to map that with cairo. } -static Eina_Bool -_ector_renderer_cairo_shape_efl_graphics_shape_path_set(Eo *obj, Ector_Renderer_Cairo_Shape_Data *pd, - const Efl_Graphics_Path_Command *op, const double *points) +static void +_ector_renderer_cairo_shape_efl_gfx_shape_path_set(Eo *obj, Ector_Renderer_Cairo_Shape_Data *pd, + const Efl_Gfx_Path_Command *op, const double *points) { - Eina_Bool r; - - USE(obj, cairo_path_destroy, EINA_FALSE); + USE(obj, cairo_path_destroy, ); if (pd->path) cairo_path_destroy(pd->path); pd->path = NULL; - eo_do_super(obj, ECTOR_RENDERER_CAIRO_SHAPE_CLASS, r = efl_graphics_shape_path_set(op, points)); - - return r; + eo_do_super(obj, ECTOR_RENDERER_CAIRO_SHAPE_CLASS, efl_graphics_shape_path_set(op, points)); } diff --git a/src/lib/ector/cairo/ector_renderer_cairo_shape.eo b/src/lib/ector/cairo/ector_renderer_cairo_shape.eo index ea3e1b1295..3c29c3d326 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_shape.eo +++ b/src/lib/ector/cairo/ector_renderer_cairo_shape.eo @@ -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.Graphics.Shape.path.set; Eo.Base.constructor; Eo.Base.destructor; } diff --git a/src/lib/ector/ector_renderer_generic_shape.eo b/src/lib/ector/ector_renderer_generic_shape.eo index 20cad35771..61298b32af 100644 --- a/src/lib/ector/ector_renderer_generic_shape.eo +++ b/src/lib/ector/ector_renderer_generic_shape.eo @@ -39,7 +39,7 @@ class Ector.Renderer.Generic.Shape (Ector.Renderer.Generic.Base, Efl.Graphics.Sh Efl.Graphics.Shape.stroke_dash; Efl.Graphics.Shape.stroke_cap; Efl.Graphics.Shape.stroke_join; - Efl.Graphics.Shape.path_set; + Efl.Graphics.Shape.path; Eo.Base.constructor; Eo.Base.destructor; } diff --git a/src/lib/ector/ector_renderer_shape.c b/src/lib/ector/ector_renderer_shape.c index e171c4c0c2..aaf7baf505 100644 --- a/src/lib/ector/ector_renderer_shape.c +++ b/src/lib/ector/ector_renderer_shape.c @@ -183,7 +183,7 @@ _ector_renderer_generic_shape_efl_graphics_shape_stroke_join_get(Eo *obj EINA_UN return pd->stroke.join; } -static Eina_Bool +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, @@ -194,7 +194,17 @@ _ector_renderer_generic_shape_efl_graphics_shape_path_set(Eo *obj EINA_UNUSED, free(pd->path.pts); pd->path.pts = NULL; - return efl_graphics_path_dup(&pd->path.cmd, &pd->path.pts, cmd, points); + efl_graphics_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) +{ + if (op) *op = pd->path.cmd; + if (points) *points = pd->path.pts; } static void diff --git a/src/lib/efl/interfaces/efl_graphics_shape.eo b/src/lib/efl/interfaces/efl_graphics_shape.eo index 9e745d9c85..a0e31bf62f 100644 --- a/src/lib/efl/interfaces/efl_graphics_shape.eo +++ b/src/lib/efl/interfaces/efl_graphics_shape.eo @@ -69,13 +69,14 @@ interface Efl.Graphics.Shape Efl_Graphics_Join j; } } - } - methods { - path_set { - return: bool; - params { - @in const(Efl_Graphics_Path_Command) *op; - @in const(double) *points; + path { + set { + } + get { + } + values { + const(Efl_Graphics_Path_Command) *op; + const(double) *points; } } } diff --git a/src/lib/evas/canvas/evas_vg_shape.c b/src/lib/evas/canvas/evas_vg_shape.c index ac57eae56c..0c0572872d 100644 --- a/src/lib/evas/canvas/evas_vg_shape.c +++ b/src/lib/evas/canvas/evas_vg_shape.c @@ -31,7 +31,7 @@ struct _Evas_VG_Shape_Data } stroke; }; -static Eina_Bool +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, @@ -42,7 +42,17 @@ _evas_vg_shape_efl_graphics_shape_path_set(Eo *obj EINA_UNUSED, free(pd->ops); pd->ops = NULL; - return efl_graphics_path_dup(&pd->ops, &pd->points, ops, points); + efl_graphics_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) +{ + if (op) *op = pd->ops; + if (points) *points = pd->points; } static Eina_Bool diff --git a/src/lib/evas/canvas/evas_vg_shape.eo b/src/lib/evas/canvas/evas_vg_shape.eo index 41845b450e..e5ba2065c3 100644 --- a/src/lib/evas/canvas/evas_vg_shape.eo +++ b/src/lib/evas/canvas/evas_vg_shape.eo @@ -39,7 +39,7 @@ class Evas.VG_Shape (Evas.VG_Node, Efl.Graphics.Shape) Efl.Graphics.Shape.stroke_dash; Efl.Graphics.Shape.stroke_cap; Efl.Graphics.Shape.stroke_join; - Efl.Graphics.Shape.path_set; + Efl.Graphics.Shape.path; Evas.VG_Node.bound_get; Eo.Base.constructor; Eo.Base.destructor; From 28257ec8fe12a5e980b368fb0a228b5b79408818 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:23:12 +0200 Subject: [PATCH 088/251] evas: fix warning due to forgotten return. --- src/lib/evas/canvas/evas_vg_image.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lib/evas/canvas/evas_vg_image.c b/src/lib/evas/canvas/evas_vg_image.c index d47b94e94c..4529197d51 100644 --- a/src/lib/evas/canvas/evas_vg_image.c +++ b/src/lib/evas/canvas/evas_vg_image.c @@ -49,6 +49,8 @@ _evas_vg_image_efl_file_file_set(Eo *obj, Evas_VG_Image_Data *pd, { eina_stringshare_replace(&pd->file, file); eina_stringshare_replace(&pd->key, key); + + return EINA_FALSE; } static void From c2e75544e1b8f41353cc66715e9772184c036973 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:23:13 +0200 Subject: [PATCH 089/251] efl: move mmap API to be part of Efl_File class. --- src/lib/edje/Edje_Legacy.h | 37 ++++++++++++++++++++ src/lib/edje/edje_object.eo | 39 ++------------------- src/lib/edje/edje_smart.c | 22 ++++++++++-- src/lib/efl/interfaces/efl_file.eo | 31 +++++++++++++++++ src/lib/evas/Evas_Legacy.h | 34 ++++++++++++++++++ src/lib/evas/canvas/evas_3d_mesh.c | 33 +++++++++++++++--- src/lib/evas/canvas/evas_3d_mesh.eo | 18 ++-------- src/lib/evas/canvas/evas_image.eo | 31 ++--------------- src/lib/evas/canvas/evas_object_image.c | 29 ++++++++++++---- src/lib/evas/common/evas_model_load.c | 2 +- src/lib/evas/include/evas_private.h | 2 +- src/tests/evas/evas_test_mesh.c | 46 ++++++++++++------------- 12 files changed, 204 insertions(+), 120 deletions(-) diff --git a/src/lib/edje/Edje_Legacy.h b/src/lib/edje/Edje_Legacy.h index 0525120763..e5e980045a 100644 --- a/src/lib/edje/Edje_Legacy.h +++ b/src/lib/edje/Edje_Legacy.h @@ -212,5 +212,42 @@ Edje object */ EAPI void edje_object_file_get(const Eo *obj, const char **file, const char **group); + +/** + * + * @brief Sets the @b EDJ file (and group within it) to load an Edje + * object's contents from + * + * @return @c EINA_TRUE, on success or @c EINA_FALSE, on errors (check + * edje_object_load_error_get() after this call to get errors causes) + * + * Edje expects EDJ files, which are theming objects' descriptions and + * resources packed together in an EET file, to read Edje object + * definitions from. They usually are created with the @c .edj + * extension. EDJ files, in turn, are assembled from @b textual object + * description files, where one describes Edje objects declaratively + * -- the EDC files (see @ref edcref "the syntax" for those files). + * + * Those description files were designed so that many Edje object + * definitions -- also called @b groups (or collections) -- could be + * packed together in the same EDJ file, so that a whole + * application's theme could be packed in one file only. This is the + * reason for the @p group argument. + * + * Use this function after you instantiate a new Edje object, so that + * you can "give him life", telling where to get its contents from. + * + * @see edje_object_add() + * @see edje_object_file_get() + * @see edje_object_mmap_set() + * @since 1.8 + * + * @param[in] file The Eina.File pointing to the EDJ file to load @p from + * @param[in] group The name of the group, in @p file, which implements an +Edje object + */ +EAPI Eina_Bool edje_object_mmap_set(Eo *obj, const Eina_File *file, const char *group); + + #include "edje_object.eo.legacy.h" #include "edje_edit.eo.legacy.h" diff --git a/src/lib/edje/edje_object.eo b/src/lib/edje/edje_object.eo index ba8d9764a5..2653d72f65 100644 --- a/src/lib/edje/edje_object.eo +++ b/src/lib/edje/edje_object.eo @@ -182,43 +182,6 @@ class Edje.Object (Evas.Smart_Clipped, Efl.File) that means the edc file is made based on scale 1.0. */ } } - mmap { - set { - /*@ - @brief Sets the @b EDJ file (and group within it) to load an Edje - object's contents from - - @return @c EINA_TRUE, on success or @c EINA_FALSE, on errors (check - edje_object_load_error_get() after this call to get errors causes) - - Edje expects EDJ files, which are theming objects' descriptions and - resources packed together in an EET file, to read Edje object - definitions from. They usually are created with the @c .edj - extension. EDJ files, in turn, are assembled from @b textual object - description files, where one describes Edje objects declaratively - -- the EDC files (see @ref edcref "the syntax" for those files). - - Those description files were designed so that many Edje object - definitions -- also called @b groups (or collections) -- could be - packed together in the same EDJ file, so that a whole - application's theme could be packed in one file only. This is the - reason for the @p group argument. - - Use this function after you instantiate a new Edje object, so that - you can "give him life", telling where to get its contents from. - - @see edje_object_add() - @see edje_object_file_get() - @see edje_object_mmap_set() - @since 1.8 */ - return: bool; - } - values { - const(Eina.File)* file; /*@ The Eina.File pointing to the EDJ file to load @p from */ - const(char)* group; /*@ The name of the group, in @p file, which implements an - Edje object */ - } - } text_change_cb { set { /*@ @@ -2414,5 +2377,7 @@ class Edje.Object (Evas.Smart_Clipped, Efl.File) Evas.Object_Smart.resize; Efl.File.file.set; Efl.File.file.get; + Efl.File.mmap.set; + Efl.File.mmap.get; } } diff --git a/src/lib/edje/edje_smart.c b/src/lib/edje/edje_smart.c index 332b9586c9..0bf8399598 100644 --- a/src/lib/edje/edje_smart.c +++ b/src/lib/edje/edje_smart.c @@ -337,7 +337,8 @@ _edje_object_efl_file_file_set(Eo *obj, Edje *_pd EINA_UNUSED, const char *file, } EOLIAN static Eina_Bool -_edje_object_mmap_set(Eo *obj, Edje *_pd EINA_UNUSED, const Eina_File *f, const char *group) +_edje_object_efl_file_mmap_set(Eo *obj, Edje *pd EINA_UNUSED, + const Eina_File *f, const char *key) { Eina_Bool ret; Eina_Array *nested; @@ -346,7 +347,7 @@ _edje_object_mmap_set(Eo *obj, Edje *_pd EINA_UNUSED, const Eina_File *f, const nested = eina_array_new(8); - if (_edje_object_file_set_internal(obj, f, group, NULL, NULL, nested)) + if (_edje_object_file_set_internal(obj, f, key, NULL, NULL, nested)) ret = EINA_TRUE; eina_array_free(nested); @@ -355,6 +356,22 @@ _edje_object_mmap_set(Eo *obj, Edje *_pd EINA_UNUSED, const Eina_File *f, const return ret; } +EOLIAN static void +_edje_object_efl_file_mmap_get(Eo *obj EINA_UNUSED, Edje *pd, + const Eina_File **f, const char **key) +{ + if (f) *f = pd->file->f; + if (key) *key = pd->group; +} + +EAPI Eina_Bool +edje_object_mmap_set(Edje_Object *obj, const Eina_File *file, const char *group) +{ + Eina_Bool ret; + + return eo_do_ret((Edje_Object *)obj, ret, efl_file_mmap_set(file, group)); +} + EAPI Eina_Bool edje_object_file_set(Eo *obj, const char *file, const char *group) { @@ -370,4 +387,3 @@ edje_object_file_get(const Eo *obj, const char **file, const char **group) } #include "edje_object.eo.c" - diff --git a/src/lib/efl/interfaces/efl_file.eo b/src/lib/efl/interfaces/efl_file.eo index 0265344c8d..887d96f408 100644 --- a/src/lib/efl/interfaces/efl_file.eo +++ b/src/lib/efl/interfaces/efl_file.eo @@ -1,6 +1,37 @@ interface Efl.File { legacy_prefix: null; properties { + mmap { + set { + /*@ + Set the source mmaped file from where an image object must fetch the real + image data (it must be an Eina_File). + + If the file supports multiple data stored in it (as Eet files do), + you can specify the key to be used as the index of the image in + this file. + + @since 1.8 */ + + return: bool; + } + get { + /*@ + Get the source mmaped file from where an image object must fetch the real + image data (it must be an Eina_File). + + If the file supports multiple data stored in it (as Eet files do), + you can get the key to be used as the index of the image in + this file. + + @since 1.10 */ + } + values { + const(Eina.File)* f; /*@ The mmaped file */ + const(char)* key; /*@ The image key in @p file (if its an Eet one), or @c + NULL, otherwise. */ + } + } file { set { /*@ diff --git a/src/lib/evas/Evas_Legacy.h b/src/lib/evas/Evas_Legacy.h index ca746f8209..e23e2ae774 100644 --- a/src/lib/evas/Evas_Legacy.h +++ b/src/lib/evas/Evas_Legacy.h @@ -1576,6 +1576,40 @@ NULL, otherwise. */ EAPI void evas_object_image_file_get(const Eo *obj, const char **file, const char **key); +/** + * + * Set the source mmaped file from where an image object must fetch the real + * image data (it must be an Eina_File). + * + * If the file supports multiple data stored in it (as Eet files do), + * you can specify the key to be used as the index of the image in + * this file. + * + * @since 1.8 + * + * @param[in] f The mmaped file + * @param[in] key The image key in @p file (if its an Eet one), or @c +NULL, otherwise. + */ +EAPI void evas_object_image_mmap_set(Eo *obj, const Eina_File *f, const char *key); + +/** + * + * Get the source mmaped file from where an image object must fetch the real + * image data (it must be an Eina_File). + * + * If the file supports multiple data stored in it (as Eet files do), + * you can get the key to be used as the index of the image in + * this file. + * + * @since 1.10 + * + * @param[out] f The mmaped file + * @param[out] key The image key in @p file (if its an Eet one), or @c +NULL, otherwise. + */ +EAPI void evas_object_image_mmap_get(const Eo *obj, const Eina_File **f, const char **key); + /** * * Save the given image object's contents to an (image) file. diff --git a/src/lib/evas/canvas/evas_3d_mesh.c b/src/lib/evas/canvas/evas_3d_mesh.c index 52a71f2d66..f055da1317 100644 --- a/src/lib/evas/canvas/evas_3d_mesh.c +++ b/src/lib/evas/canvas/evas_3d_mesh.c @@ -840,16 +840,39 @@ _evas_3d_mesh_alpha_test_enable_get(Eo *obj EINA_UNUSED, Evas_3D_Mesh_Data *pd) return pd->alpha_test_enabled; } -EOLIAN static void -_evas_3d_mesh_mmap_set(Eo *obj, Evas_3D_Mesh_Data *pd, - Eina_File *file, const char *key EINA_UNUSED) +EOLIAN static Eina_Bool +_evas_3d_mesh_efl_file_mmap_set(Eo *obj, + Evas_3D_Mesh_Data *pd, + const Eina_File *f, const char *key EINA_UNUSED) { _mesh_fini(pd); _mesh_init(pd); - if (file == NULL) return; + if (f == NULL) return EINA_FALSE; - evas_common_load_model_from_eina_file(obj, file); + evas_common_load_model_from_eina_file(obj, f); + + return EINA_TRUE; +} + +EOLIAN static void +_evas_3d_mesh_efl_file_mmap_get(Eo *obj EINA_UNUSED, + Evas_3D_Mesh_Data *pd EINA_UNUSED, + const Eina_File **f EINA_UNUSED, + const char **key EINA_UNUSED) +{ + #warning "mmap get is not implemented on Evas_3D_Mesh." + ERR("mmap get is not implemented !"); +} + +EOLIAN static void +_evas_3d_mesh_efl_file_file_get(Eo *obj EINA_UNUSED, + Evas_3D_Mesh_Data *pd EINA_UNUSED, + const char **file EINA_UNUSED, + const char **key EINA_UNUSED) +{ + #warning "file get is not implemented on Evas_3D_Mesh." + ERR("file get is not implemented !"); } EOLIAN static Eina_Bool diff --git a/src/lib/evas/canvas/evas_3d_mesh.eo b/src/lib/evas/canvas/evas_3d_mesh.eo index 784f91a257..28022ee07f 100644 --- a/src/lib/evas/canvas/evas_3d_mesh.eo +++ b/src/lib/evas/canvas/evas_3d_mesh.eo @@ -4,21 +4,6 @@ class Evas_3D_Mesh (Evas_3D_Object, Evas.Common_Interface, Efl.File) data: Evas_3D_Mesh_Data; methods { - mmap_set { - /** - * Load mesh data from Eina_File. - * - * Loading a mesh from existing Eina_File is supported. Currently, only MD2, OBJ, - * PLY and EET file formats are supported. - * - * @ingroup Evas_3D_Mesh - */ - params { - @in Eina_File* file; /*@ Eina_File with mesh data. */ - @in const(char)* key; /*@ Key in the mesh file. */ - } - } - frame_vertex_data_set { /*@ Set the vertex data of the key frame of the given mesh. @@ -540,6 +525,9 @@ class Evas_3D_Mesh (Evas_3D_Object, Evas.Common_Interface, Efl.File) Evas_3D_Object.update_notify; Evas_3D_Object.change_notify; Efl.File.file.set; + Efl.File.file.get; + Efl.File.mmap.set; + Efl.File.mmap.get; Efl.File.save; } diff --git a/src/lib/evas/canvas/evas_image.eo b/src/lib/evas/canvas/evas_image.eo index df97e32525..7071d834e2 100644 --- a/src/lib/evas/canvas/evas_image.eo +++ b/src/lib/evas/canvas/evas_image.eo @@ -663,35 +663,6 @@ class Evas.Image (Evas.Object, Efl.File, Efl.Image) void *data; /*@ The data pointer to be passed to @a func. */ } } - mmap { - set { - /*@ - Set the source mmaped file from where an image object must fetch the real - image data (it must be an Eina_File). - - If the file supports multiple data stored in it (as Eet files do), - you can specify the key to be used as the index of the image in - this file. - - @since 1.8 */ - } - get { - /*@ - Get the source mmaped file from where an image object must fetch the real - image data (it must be an Eina_File). - - If the file supports multiple data stored in it (as Eet files do), - you can get the key to be used as the index of the image in - this file. - - @since 1.10 */ - } - values { - const(Eina.File)* f; /*@ The mmaped file */ - const(char)* key; /*@ The image key in @p file (if its an Eet one), or @c - NULL, otherwise. */ - } - } data_copy { set { /*@ @@ -1094,6 +1065,8 @@ class Evas.Image (Evas.Object, Efl.File, Efl.Image) Eo.Base.dbg_info_get; Efl.File.file.set; Efl.File.file.get; + Efl.File.mmap.set; + Efl.File.mmap.get; Efl.File.save; Efl.Image.animated.get; Efl.Image.load_size.set; diff --git a/src/lib/evas/canvas/evas_object_image.c b/src/lib/evas/canvas/evas_object_image.c index 90b3c49aa2..eaf17d6fd4 100644 --- a/src/lib/evas/canvas/evas_object_image.c +++ b/src/lib/evas/canvas/evas_object_image.c @@ -412,7 +412,7 @@ evas_object_image_memfile_set(Evas_Object *eo_obj, void *data, int size, char *f f = eina_file_virtualize(NULL, data, size, EINA_TRUE); if (!f) return ; - eo_do(eo_obj, evas_obj_image_mmap_set(f, key)); + eo_do(eo_obj, efl_file_mmap_set(f, key)); eina_file_close(f); } @@ -544,8 +544,10 @@ _image_done_set(Eo *eo_obj, Evas_Object_Protected_Data *obj, Evas_Image_Data *o) evas_object_change(eo_obj, obj); } -EOLIAN static void -_evas_image_mmap_set(Eo *eo_obj, Evas_Image_Data *o, const Eina_File *f, const char *key) +EOLIAN static Eina_Bool +_evas_image_efl_file_mmap_set(Eo *eo_obj, + Evas_Image_Data *o, + const Eina_File *f, const char *key) { Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS); Evas_Image_Load_Opts lo; @@ -553,18 +555,22 @@ _evas_image_mmap_set(Eo *eo_obj, Evas_Image_Data *o, const Eina_File *f, const c if (o->cur->u.f == f) { if ((!o->cur->key) && (!key)) - return; + return EINA_FALSE; if ((o->cur->key) && (key) && (!strcmp(o->cur->key, key))) - return; + return EINA_FALSE; } evas_object_async_block(obj); _image_init_set(f, NULL, key, eo_obj, obj, o, &lo); o->engine_data = ENFN->image_mmap(ENDT, o->cur->u.f, o->cur->key, &o->load_error, &lo); _image_done_set(eo_obj, obj, o); + + return EINA_TRUE; } EOLIAN static void -_evas_image_mmap_get(Eo *eo_obj EINA_UNUSED, Evas_Image_Data *o, const Eina_File **f, const char **key) +_evas_image_efl_file_mmap_get(Eo *eo_obj EINA_UNUSED, + Evas_Image_Data *o, + const Eina_File **f, const char **key) { if (f) *f = o->cur->mmaped_source ? o->cur->u.f : NULL; @@ -4915,6 +4921,17 @@ evas_object_image_file_get(const Eo *obj, const char **file, const char **key) eo_do((Eo *) obj, efl_file_get(file, key)); } +EAPI void +evas_object_image_mmap_set(Evas_Image *obj, const Eina_File *f, const char *key) +{ + eo_do((Evas_Image *)obj, efl_file_mmap_set(f, key)); +} + +EAPI void +evas_object_image_mmap_get(const Evas_Image *obj, const Eina_File **f, const char **key) +{ + eo_do((Evas_Image *)obj, efl_file_mmap_get(f, key)); +} EAPI Eina_Bool evas_object_image_save(const Eo *obj, const char *file, const char *key, const char *flags) diff --git a/src/lib/evas/common/evas_model_load.c b/src/lib/evas/common/evas_model_load.c index bef10ba28c..959cd71bc8 100644 --- a/src/lib/evas/common/evas_model_load.c +++ b/src/lib/evas/common/evas_model_load.c @@ -65,7 +65,7 @@ evas_common_load_model_from_file(Evas_3D_Mesh *model, const char *file) } void -evas_common_load_model_from_eina_file(Evas_3D_Mesh *model, Eina_File *file) +evas_common_load_model_from_eina_file(Evas_3D_Mesh *model, const Eina_File *file) { Eina_File *e_file = eina_file_dup(file); diff --git a/src/lib/evas/include/evas_private.h b/src/lib/evas/include/evas_private.h index 15b4c4bd40..a2a8093e44 100644 --- a/src/lib/evas/include/evas_private.h +++ b/src/lib/evas/include/evas_private.h @@ -1703,7 +1703,7 @@ void _evas_3d_eet_file_free(void); /* Temporary save/load functions */ void evas_common_load_model_from_file(Evas_3D_Mesh *model, const char *file); -void evas_common_load_model_from_eina_file(Evas_3D_Mesh *model, Eina_File *file); +void evas_common_load_model_from_eina_file(Evas_3D_Mesh *model, const Eina_File *file); void evas_common_save_model_to_file(Evas_3D_Mesh *model, const char *file, Evas_3D_Mesh_Frame *f); void evas_model_load_file_eet(Evas_3D_Mesh *mesh, Eina_File *file); void evas_model_load_file_md2(Evas_3D_Mesh *mesh, Eina_File *file); diff --git a/src/tests/evas/evas_test_mesh.c b/src/tests/evas/evas_test_mesh.c index 558dcfad20..440c31b28a 100644 --- a/src/tests/evas/evas_test_mesh.c +++ b/src/tests/evas/evas_test_mesh.c @@ -34,29 +34,29 @@ src2 += f2->vertices[a].element_count; \ } -#define CHECK_MESHES_IN_FOLDER(folder, ext) \ - it = eina_file_direct_ls(folder); \ - EINA_ITERATOR_FOREACH(it, file) \ - { \ - mesh = eo_add(EVAS_3D_MESH_CLASS, e); \ - mesh2 = eo_add(EVAS_3D_MESH_CLASS, e); \ - fail_if(mesh == NULL); \ - fail_if(mesh2 == NULL); \ - snprintf(buffer, PATH_MAX, "%s", ext); \ - eo_do(mesh, efl_file_set(file->path, NULL), \ - efl_file_save(buffer, NULL, NULL)); \ - eo_do(mesh2, efl_file_set(buffer, NULL)); \ - res = _compare_meshes(mesh, mesh2); \ - fail_if(res == 1); \ - eo_do(mesh, evas_3d_mesh_mmap_set(eina_file_open(file->path, 0), NULL), \ - efl_file_save(buffer, NULL, NULL)); \ - eo_do(mesh2, evas_3d_mesh_mmap_set(eina_file_open(buffer, 0), NULL)); \ - res = _compare_meshes(mesh, mesh2); \ - fail_if(res == 1); \ - eo_del(mesh2); \ - eo_del(mesh); \ - unlink(buffer); \ - } +#define CHECK_MESHES_IN_FOLDER(folder, ext) \ + it = eina_file_direct_ls(folder); \ + EINA_ITERATOR_FOREACH(it, file) \ + { \ + mesh = eo_add(EVAS_3D_MESH_CLASS, e); \ + mesh2 = eo_add(EVAS_3D_MESH_CLASS, e); \ + fail_if(mesh == NULL); \ + fail_if(mesh2 == NULL); \ + snprintf(buffer, PATH_MAX, "%s", ext); \ + eo_do(mesh, efl_file_set(file->path, NULL), \ + efl_file_save(buffer, NULL, NULL)); \ + eo_do(mesh2, efl_file_set(buffer, NULL)); \ + res = _compare_meshes(mesh, mesh2); \ + fail_if(res == 1); \ + eo_do(mesh, efl_file_mmap_set(eina_file_open(file->path, 0), NULL), \ + efl_file_save(buffer, NULL, NULL)); \ + eo_do(mesh2, efl_file_mmap_set(eina_file_open(buffer, 0), NULL)); \ + res = _compare_meshes(mesh, mesh2); \ + fail_if(res == 1); \ + eo_del(mesh2); \ + eo_del(mesh); \ + unlink(buffer); \ + } static Evas_3D_Mesh_Frame * return_zero_frame(Evas_3D_Mesh_Data *pd) From 2067e85d68915ee0e1fd4bbc0d196cc2be66b7ae Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:23:14 +0200 Subject: [PATCH 090/251] evas: use the new Efl_File mmap function correctly for Evas_VG API. --- src/lib/evas/canvas/evas_object_vg.c | 29 ++++++++++++++------ src/lib/evas/canvas/evas_vg.eo | 32 ++-------------------- src/lib/evas/canvas/evas_vg_image.c | 40 +++++++++++++++++++++++----- src/lib/evas/canvas/evas_vg_image.eo | 2 ++ 4 files changed, 58 insertions(+), 45 deletions(-) diff --git a/src/lib/evas/canvas/evas_object_vg.c b/src/lib/evas/canvas/evas_object_vg.c index f74e06e3e4..c6bc95a05c 100644 --- a/src/lib/evas/canvas/evas_object_vg.c +++ b/src/lib/evas/canvas/evas_object_vg.c @@ -361,13 +361,26 @@ evas_object_vg_was_opaque(Evas_Object *eo_obj EINA_UNUSED, static Eina_Bool -_evas_vg_mmap_set(Eo *obj EINA_UNUSED, Evas_VG_Data *pd, - const Eina_File *f, const char *key EINA_UNUSED) -// For now we don't handle eet section filled with SVG, that's for later +_evas_vg_efl_file_mmap_set(Eo *obj EINA_UNUSED, Evas_VG_Data *pd, + const Eina_File *f, const char *key) { Eina_File *tmp = f ? eina_file_dup(f) : NULL; - // Start parsing here. + if (f == pd->f && + ((key == NULL && pd->key == NULL) || + (key != NULL && pd->key != NULL && !strcmp(key, pd->key)))) + return EINA_FALSE; + + tmp = f ? eina_file_dup(f) : NULL; + + if (tmp) + { + if (!evas_vg_loader_svg(obj, tmp, NULL)) + { + eina_file_close(tmp); + return EINA_FALSE; + } + } // it succeeded. if (pd->f) eina_file_close(pd->f); @@ -377,8 +390,8 @@ _evas_vg_mmap_set(Eo *obj EINA_UNUSED, Evas_VG_Data *pd, } static void -_evas_vg_mmap_get(Eo *obj EINA_UNUSED, Evas_VG_Data *pd, - const Eina_File **f, const char **key) +_evas_vg_efl_file_mmap_get(Eo *obj EINA_UNUSED, Evas_VG_Data *pd, + const Eina_File **f, const char **key) { if (f) *f = pd->f; if (key) *key = pd->key; @@ -394,7 +407,7 @@ _evas_vg_efl_file_file_set(Eo *obj, Evas_VG_Data *pd EINA_UNUSED, f = eina_file_open(file, EINA_FALSE); if (!f) return EINA_FALSE; - eo_do(obj, r = evas_obj_vg_mmap_set(f, key)); + eo_do(obj, efl_file_mmap_set(f, key)); eina_file_close(f); return r; @@ -406,7 +419,7 @@ _evas_vg_efl_file_file_get(Eo *obj, Evas_VG_Data *pd EINA_UNUSED, { const Eina_File *f = NULL; - eo_do(obj, evas_obj_vg_mmap_get(&f, key)); + eo_do(obj, efl_file_mmap_get(&f, key)); if (file) *file = eina_file_filename_get(f); } diff --git a/src/lib/evas/canvas/evas_vg.eo b/src/lib/evas/canvas/evas_vg.eo index bf4960e3c1..24037d2384 100644 --- a/src/lib/evas/canvas/evas_vg.eo +++ b/src/lib/evas/canvas/evas_vg.eo @@ -30,36 +30,6 @@ class Evas.VG (Evas.Object, Efl.File) uint h; } } - mmap { - set { - /*@ - Set the source mmaped file from where an image object must fetch the real - image data (it must be an Eina_File). - - If the file supports multiple data stored in it (as Eet files do), - you can specify the key to be used as the index of the image in - this file. - - @since 1.14 */ - return: bool; - } - get { - /*@ - Get the source mmaped file from where an image object must fetch the real - image data (it must be an Eina_File). - - If the file supports multiple data stored in it (as Eet files do), - you can get the key to be used as the index of the image in - this file. - - @since 1.14 */ - } - values { - const(Eina.File)* f; /*@ The mmaped file */ - const(char)* key; /*@ The image key in @p file (if its an Eet one), or @c - NULL, otherwise. */ - } - } fill { set { /*@ @@ -115,5 +85,7 @@ class Evas.VG (Evas.Object, Efl.File) Eo.Base.constructor; Efl.File.file.set; Efl.File.file.get; + Efl.File.mmap.set; + Efl.File.mmap.get; } } \ No newline at end of file diff --git a/src/lib/evas/canvas/evas_vg_image.c b/src/lib/evas/canvas/evas_vg_image.c index 4529197d51..62f02ece28 100644 --- a/src/lib/evas/canvas/evas_vg_image.c +++ b/src/lib/evas/canvas/evas_vg_image.c @@ -7,7 +7,8 @@ typedef struct _Evas_VG_Image_Data Evas_VG_Image_Data; struct _Evas_VG_Image_Data { // FIXME: only manipulate Eina_File internally. - Eina_Stringshare *file, *key; + Eina_File *f; + Eina_Stringshare *key; int x, y; unsigned int w, h; @@ -44,20 +45,45 @@ _evas_vg_image_size_get(Eo *obj, Evas_VG_Image_Data *pd, } static Eina_Bool -_evas_vg_image_efl_file_file_set(Eo *obj, Evas_VG_Image_Data *pd, - const char *file, const char *key) +_evas_vg_image_efl_file_mmap_set(Eo *obj EINA_UNUSED, Evas_VG_Image_Data *pd, + const Eina_File *f, const char *key) { - eina_stringshare_replace(&pd->file, file); + Eina_File *tmp = pd->f; + + pd->f = eina_file_dup(f); + eina_file_close(tmp); eina_stringshare_replace(&pd->key, key); - return EINA_FALSE; + return EINA_TRUE; } static void -_evas_vg_image_efl_file_file_get(Eo *obj, Evas_VG_Image_Data *pd, +_evas_vg_image_efl_file_mmap_get(Eo *obj EINA_UNUSED, Evas_VG_Image_Data *pd, + const Eina_File **f, const char **key) +{ + if (f) *f = pd->f; + if (key) *key = pd->key; +} + +static Eina_Bool +_evas_vg_image_efl_file_file_set(Eo *obj, Evas_VG_Image_Data *pd, + const char *file, const char *key) +{ + Eina_File *tmp; + Eina_Bool r; + + tmp = eina_file_open(file, EINA_FALSE); + r = _evas_vg_image_efl_file_mmap_set(obj, pd, tmp, key); + eina_file_close(tmp); + + return r; +} + +static void +_evas_vg_image_efl_file_file_get(Eo *obj EINA_UNUSED, Evas_VG_Image_Data *pd, const char **file, const char **key) { - if (file) *file = pd->file; + if (file) *file = eina_file_filename_get(pd->f); if (key) *key = pd->key; } diff --git a/src/lib/evas/canvas/evas_vg_image.eo b/src/lib/evas/canvas/evas_vg_image.eo index 33fe0b0272..ff9ab8e965 100644 --- a/src/lib/evas/canvas/evas_vg_image.eo +++ b/src/lib/evas/canvas/evas_vg_image.eo @@ -28,6 +28,8 @@ class Evas.VG_Image (Evas.VG_Node, Efl.File) implements { Efl.File.file.set; Efl.File.file.get; + Efl.File.mmap.set; + Efl.File.mmap.get; Eo.Base.constructor; Eo.Base.destructor; } From dfd40467fcf770a6ecc1b5dad3e1c03d13007e22 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:23:15 +0200 Subject: [PATCH 091/251] efl: add a parser for SVG data path that generate EFL Path. --- src/lib/efl/interfaces/efl_graphics_utils.c | 514 ++++++++++++++++++++ src/lib/efl/interfaces/efl_graphics_utils.h | 2 + 2 files changed, 516 insertions(+) diff --git a/src/lib/efl/interfaces/efl_graphics_utils.c b/src/lib/efl/interfaces/efl_graphics_utils.c index b1adf3415a..0e34fb9f25 100644 --- a/src/lib/efl/interfaces/efl_graphics_utils.c +++ b/src/lib/efl/interfaces/efl_graphics_utils.c @@ -457,3 +457,517 @@ efl_graphics_path_append_circle(Efl_Graphics_Path_Command **commands, double **p 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; +} diff --git a/src/lib/efl/interfaces/efl_graphics_utils.h b/src/lib/efl/interfaces/efl_graphics_utils.h index eb87e85bfe..9d29e2521d 100644 --- a/src/lib/efl/interfaces/efl_graphics_utils.h +++ b/src/lib/efl/interfaces/efl_graphics_utils.h @@ -46,6 +46,8 @@ 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, From c000ee80994c701bfab5836fcc41f6756c02b8ed Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:23:16 +0200 Subject: [PATCH 092/251] efl: rename namespace Graphics to Gfx. --- src/Makefile_Efl.am | 14 +- .../ector_renderer_cairo_gradient_linear.c | 4 +- .../ector_renderer_cairo_gradient_linear.eo | 2 +- .../ector_renderer_cairo_gradient_radial.c | 4 +- .../ector_renderer_cairo_gradient_radial.eo | 2 +- .../ector/cairo/ector_renderer_cairo_shape.c | 16 +- .../ector/cairo/ector_renderer_cairo_shape.eo | 2 +- src/lib/ector/ector_private.h | 12 +- .../ector/ector_renderer_generic_gradient.eo | 10 +- .../ector_renderer_generic_gradient_linear.eo | 10 +- .../ector_renderer_generic_gradient_radial.eo | 14 +- src/lib/ector/ector_renderer_generic_shape.eo | 18 +- src/lib/ector/ector_renderer_gradient.c | 32 +- .../ector/ector_renderer_gradient_linear.c | 24 +- .../ector/ector_renderer_gradient_radial.c | 34 +- src/lib/ector/ector_renderer_shape.c | 106 +- src/lib/efl/Efl.h | 73 +- ...aphics_gradient.eo => efl_gfx_gradient.eo} | 6 +- ...t_linear.eo => efl_gfx_gradient_linear.eo} | 2 +- ...t_radial.eo => efl_gfx_gradient_radial.eo} | 2 +- ...efl_graphics_shape.eo => efl_gfx_shape.eo} | 10 +- src/lib/efl/interfaces/efl_gfx_utils.c | 973 ++++++++++++++++++ src/lib/efl/interfaces/efl_gfx_utils.h | 67 ++ src/lib/efl/interfaces/efl_graphics_utils.c | 973 ------------------ src/lib/efl/interfaces/efl_graphics_utils.h | 67 -- src/lib/efl/interfaces/efl_interfaces_main.c | 8 +- src/lib/evas/canvas/evas_vg_gradient.c | 32 +- src/lib/evas/canvas/evas_vg_gradient.eo | 10 +- src/lib/evas/canvas/evas_vg_gradient_linear.c | 32 +- .../evas/canvas/evas_vg_gradient_linear.eo | 10 +- src/lib/evas/canvas/evas_vg_gradient_radial.c | 44 +- .../evas/canvas/evas_vg_gradient_radial.eo | 14 +- src/lib/evas/canvas/evas_vg_private.h | 4 +- src/lib/evas/canvas/evas_vg_shape.c | 138 +-- src/lib/evas/canvas/evas_vg_shape.eo | 18 +- 35 files changed, 1394 insertions(+), 1393 deletions(-) rename src/lib/efl/interfaces/{efl_graphics_gradient.eo => efl_gfx_gradient.eo} (63%) rename src/lib/efl/interfaces/{efl_graphics_gradient_linear.eo => efl_gfx_gradient_linear.eo} (79%) rename src/lib/efl/interfaces/{efl_graphics_gradient_radial.eo => efl_gfx_gradient_radial.eo} (83%) rename src/lib/efl/interfaces/{efl_graphics_shape.eo => efl_gfx_shape.eo} (83%) create mode 100644 src/lib/efl/interfaces/efl_gfx_utils.c create mode 100644 src/lib/efl/interfaces/efl_gfx_utils.h delete mode 100644 src/lib/efl/interfaces/efl_graphics_utils.c delete mode 100644 src/lib/efl/interfaces/efl_graphics_utils.h diff --git a/src/Makefile_Efl.am b/src/Makefile_Efl.am index 618069706b..38f7ba8177 100644 --- a/src/Makefile_Efl.am +++ b/src/Makefile_Efl.am @@ -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 diff --git a/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c b/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c index 4df2b32a4b..d0a39f8718 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c @@ -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" diff --git a/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.eo b/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.eo index 61e8e28436..6007fd3575 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.eo +++ b/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.eo @@ -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; } } diff --git a/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c b/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c index fe8da9be25..84207ef0b9 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c @@ -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" diff --git a/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.eo b/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.eo index db179c91e5..ab9595f760 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.eo +++ b/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.eo @@ -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; } } diff --git a/src/lib/ector/cairo/ector_renderer_cairo_shape.c b/src/lib/ector/cairo/ector_renderer_cairo_shape.c index 9bfe961d67..dcdedea5e9 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_shape.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_shape.c @@ -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)); } diff --git a/src/lib/ector/cairo/ector_renderer_cairo_shape.eo b/src/lib/ector/cairo/ector_renderer_cairo_shape.eo index 3c29c3d326..55bd0495d1 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_shape.eo +++ b/src/lib/ector/cairo/ector_renderer_cairo_shape.eo @@ -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; } diff --git a/src/lib/ector/ector_private.h b/src/lib/ector/ector_private.h index 41b51d880c..896c849512 100644 --- a/src/lib/ector/ector_private.h +++ b/src/lib/ector/ector_private.h @@ -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; }; diff --git a/src/lib/ector/ector_renderer_generic_gradient.eo b/src/lib/ector/ector_renderer_generic_gradient.eo index bd6a9bb70a..4a34141912 100644 --- a/src/lib/ector/ector_renderer_generic_gradient.eo +++ b/src/lib/ector/ector_renderer_generic_gradient.eo @@ -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; } } diff --git a/src/lib/ector/ector_renderer_generic_gradient_linear.eo b/src/lib/ector/ector_renderer_generic_gradient_linear.eo index 45bb5e3729..89ab3e120d 100644 --- a/src/lib/ector/ector_renderer_generic_gradient_linear.eo +++ b/src/lib/ector/ector_renderer_generic_gradient_linear.eo @@ -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; } } diff --git a/src/lib/ector/ector_renderer_generic_gradient_radial.eo b/src/lib/ector/ector_renderer_generic_gradient_radial.eo index 50c35bcdb4..563c954caa 100644 --- a/src/lib/ector/ector_renderer_generic_gradient_radial.eo +++ b/src/lib/ector/ector_renderer_generic_gradient_radial.eo @@ -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; } } diff --git a/src/lib/ector/ector_renderer_generic_shape.eo b/src/lib/ector/ector_renderer_generic_shape.eo index 61298b32af..edbec7b46f 100644 --- a/src/lib/ector/ector_renderer_generic_shape.eo +++ b/src/lib/ector/ector_renderer_generic_shape.eo @@ -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; } diff --git a/src/lib/ector/ector_renderer_gradient.c b/src/lib/ector/ector_renderer_gradient.c index 4e6a1b0776..792f8393db 100644 --- a/src/lib/ector/ector_renderer_gradient.c +++ b/src/lib/ector/ector_renderer_gradient.c @@ -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; } diff --git a/src/lib/ector/ector_renderer_gradient_linear.c b/src/lib/ector/ector_renderer_gradient_linear.c index 475a1d9c04..925fb53951 100644 --- a/src/lib/ector/ector_renderer_gradient_linear.c +++ b/src/lib/ector/ector_renderer_gradient_linear.c @@ -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; diff --git a/src/lib/ector/ector_renderer_gradient_radial.c b/src/lib/ector/ector_renderer_gradient_radial.c index f23485b9fe..3c1782cf73 100644 --- a/src/lib/ector/ector_renderer_gradient_radial.c +++ b/src/lib/ector/ector_renderer_gradient_radial.c @@ -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; diff --git a/src/lib/ector/ector_renderer_shape.c b/src/lib/ector/ector_renderer_shape.c index aaf7baf505..990bee949d 100644 --- a/src/lib/ector/ector_renderer_shape.c +++ b/src/lib/ector/ector_renderer_shape.c @@ -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; diff --git a/src/lib/efl/Efl.h b/src/lib/efl/Efl.h index d763967869..9e35f2efe7 100644 --- a/src/lib/efl/Efl.h +++ b/src/lib/efl/Efl.h @@ -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 diff --git a/src/lib/efl/interfaces/efl_graphics_gradient.eo b/src/lib/efl/interfaces/efl_gfx_gradient.eo similarity index 63% rename from src/lib/efl/interfaces/efl_graphics_gradient.eo rename to src/lib/efl/interfaces/efl_gfx_gradient.eo index 378ffaf62f..3bd5bff3df 100644 --- a/src/lib/efl/interfaces/efl_graphics_gradient.eo +++ b/src/lib/efl/interfaces/efl_gfx_gradient.eo @@ -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; } } } diff --git a/src/lib/efl/interfaces/efl_graphics_gradient_linear.eo b/src/lib/efl/interfaces/efl_gfx_gradient_linear.eo similarity index 79% rename from src/lib/efl/interfaces/efl_graphics_gradient_linear.eo rename to src/lib/efl/interfaces/efl_gfx_gradient_linear.eo index 2c4f083121..8d7f398284 100644 --- a/src/lib/efl/interfaces/efl_graphics_gradient_linear.eo +++ b/src/lib/efl/interfaces/efl_gfx_gradient_linear.eo @@ -1,4 +1,4 @@ -interface Efl.Graphics.Gradient_Linear (Efl.Graphics.Gradient) +interface Efl.Gfx.Gradient_Linear (Efl.Gfx.Gradient) { legacy_prefix: null; properties { diff --git a/src/lib/efl/interfaces/efl_graphics_gradient_radial.eo b/src/lib/efl/interfaces/efl_gfx_gradient_radial.eo similarity index 83% rename from src/lib/efl/interfaces/efl_graphics_gradient_radial.eo rename to src/lib/efl/interfaces/efl_gfx_gradient_radial.eo index 8fd00c7291..6e930245e2 100644 --- a/src/lib/efl/interfaces/efl_graphics_gradient_radial.eo +++ b/src/lib/efl/interfaces/efl_gfx_gradient_radial.eo @@ -1,4 +1,4 @@ -interface Efl.Graphics.Gradient_Radial (Efl.Graphics.Gradient) +interface Efl.Gfx.Gradient_Radial (Efl.Gfx.Gradient) { legacy_prefix: null; properties { diff --git a/src/lib/efl/interfaces/efl_graphics_shape.eo b/src/lib/efl/interfaces/efl_gfx_shape.eo similarity index 83% rename from src/lib/efl/interfaces/efl_graphics_shape.eo rename to src/lib/efl/interfaces/efl_gfx_shape.eo index a0e31bf62f..2ee57c8c41 100644 --- a/src/lib/efl/interfaces/efl_graphics_shape.eo +++ b/src/lib/efl/interfaces/efl_gfx_shape.eo @@ -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; } } diff --git a/src/lib/efl/interfaces/efl_gfx_utils.c b/src/lib/efl/interfaces/efl_gfx_utils.c new file mode 100644 index 0000000000..b159b1fbbd --- /dev/null +++ b/src/lib/efl/interfaces/efl_gfx_utils.c @@ -0,0 +1,973 @@ +#ifdef HAVE_CONFIG_H +# include +#endif + +#include + +#include +#include +#include + +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; +} diff --git a/src/lib/efl/interfaces/efl_gfx_utils.h b/src/lib/efl/interfaces/efl_gfx_utils.h new file mode 100644 index 0000000000..3c0cbf8bb0 --- /dev/null +++ b/src/lib/efl/interfaces/efl_gfx_utils.h @@ -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 diff --git a/src/lib/efl/interfaces/efl_graphics_utils.c b/src/lib/efl/interfaces/efl_graphics_utils.c deleted file mode 100644 index 0e34fb9f25..0000000000 --- a/src/lib/efl/interfaces/efl_graphics_utils.c +++ /dev/null @@ -1,973 +0,0 @@ -#ifdef HAVE_CONFIG_H -# include -#endif - -#include - -#include -#include -#include - -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; -} diff --git a/src/lib/efl/interfaces/efl_graphics_utils.h b/src/lib/efl/interfaces/efl_graphics_utils.h deleted file mode 100644 index 9d29e2521d..0000000000 --- a/src/lib/efl/interfaces/efl_graphics_utils.h +++ /dev/null @@ -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 diff --git a/src/lib/efl/interfaces/efl_interfaces_main.c b/src/lib/efl/interfaces/efl_interfaces_main.c index eabc1e038d..9ede0fe7d2 100644 --- a/src/lib/efl/interfaces/efl_interfaces_main.c +++ b/src/lib/efl/interfaces/efl_interfaces_main.c @@ -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" diff --git a/src/lib/evas/canvas/evas_vg_gradient.c b/src/lib/evas/canvas/evas_vg_gradient.c index a63b636062..ffff936533 100644 --- a/src/lib/evas/canvas/evas_vg_gradient.c +++ b/src/lib/evas/canvas/evas_vg_gradient.c @@ -6,43 +6,43 @@ #include 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; } diff --git a/src/lib/evas/canvas/evas_vg_gradient.eo b/src/lib/evas/canvas/evas_vg_gradient.eo index a71a7e7dde..e2b49c3611 100644 --- a/src/lib/evas/canvas/evas_vg_gradient.eo +++ b/src/lib/evas/canvas/evas_vg_gradient.eo @@ -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; } } diff --git a/src/lib/evas/canvas/evas_vg_gradient_linear.c b/src/lib/evas/canvas/evas_vg_gradient_linear.c index 5d0af64eb9..71d5e0c712 100644 --- a/src/lib/evas/canvas/evas_vg_gradient_linear.c +++ b/src/lib/evas/canvas/evas_vg_gradient_linear.c @@ -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()); } diff --git a/src/lib/evas/canvas/evas_vg_gradient_linear.eo b/src/lib/evas/canvas/evas_vg_gradient_linear.eo index 0ae1347d64..05af5c80d6 100644 --- a/src/lib/evas/canvas/evas_vg_gradient_linear.eo +++ b/src/lib/evas/canvas/evas_vg_gradient_linear.eo @@ -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; } diff --git a/src/lib/evas/canvas/evas_vg_gradient_radial.c b/src/lib/evas/canvas/evas_vg_gradient_radial.c index e7adce17d9..ad199659a6 100644 --- a/src/lib/evas/canvas/evas_vg_gradient_radial.c +++ b/src/lib/evas/canvas/evas_vg_gradient_radial.c @@ -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()); } diff --git a/src/lib/evas/canvas/evas_vg_gradient_radial.eo b/src/lib/evas/canvas/evas_vg_gradient_radial.eo index 0a06ae932d..6fc9c6e42e 100644 --- a/src/lib/evas/canvas/evas_vg_gradient_radial.eo +++ b/src/lib/evas/canvas/evas_vg_gradient_radial.eo @@ -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; } diff --git a/src/lib/evas/canvas/evas_vg_private.h b/src/lib/evas/canvas/evas_vg_private.h index 10e4b6c6c4..58c1cfec01 100644 --- a/src/lib/evas/canvas/evas_vg_private.h +++ b/src/lib/evas/canvas/evas_vg_private.h @@ -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 * diff --git a/src/lib/evas/canvas/evas_vg_shape.c b/src/lib/evas/canvas/evas_vg_shape.c index 0c0572872d..504a34a06b 100644 --- a/src/lib/evas/canvas/evas_vg_shape.c +++ b/src/lib/evas/canvas/evas_vg_shape.c @@ -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; diff --git a/src/lib/evas/canvas/evas_vg_shape.eo b/src/lib/evas/canvas/evas_vg_shape.eo index e5ba2065c3..7285586a6b 100644 --- a/src/lib/evas/canvas/evas_vg_shape.eo +++ b/src/lib/evas/canvas/evas_vg_shape.eo @@ -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; From c08f8e26a6bc53bb5cdcf3c67f2214f64d0e9f63 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:23:17 +0200 Subject: [PATCH 093/251] efl: add Efl.Gfx.Base and fix inheritance for Evas_Object. --- src/Makefile_Efl.am | 1 + src/Makefile_Efl_Cxx.am | 3 +- src/lib/edje/edje_calc.c | 26 ++--- src/lib/edje/edje_text.c | 10 +- src/lib/efl/Efl.h | 1 + src/lib/efl/interfaces/efl_gfx_base.eo | 89 ++++++++++++++++++ src/lib/efl/interfaces/efl_interfaces_main.c | 1 + src/lib/evas/Evas_Legacy.h | 80 ++++++++++++++++ src/lib/evas/canvas/evas_object.eo | 99 ++------------------ src/lib/evas/canvas/evas_object_main.c | 90 +++++++++++++----- src/lib/evas/canvas/evas_object_text.c | 10 +- src/lib/evas/canvas/evas_text.eo | 2 +- src/tests/evas/evas_test_filters.c | 4 +- 13 files changed, 276 insertions(+), 140 deletions(-) create mode 100644 src/lib/efl/interfaces/efl_gfx_base.eo diff --git a/src/Makefile_Efl.am b/src/Makefile_Efl.am index 38f7ba8177..2525020156 100644 --- a/src/Makefile_Efl.am +++ b/src/Makefile_Efl.am @@ -5,6 +5,7 @@ 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_gfx_base.eo \ lib/efl/interfaces/efl_gfx_shape.eo \ lib/efl/interfaces/efl_gfx_gradient.eo \ lib/efl/interfaces/efl_gfx_gradient_linear.eo \ diff --git a/src/Makefile_Efl_Cxx.am b/src/Makefile_Efl_Cxx.am index 1ddd25dc49..6d28e97420 100644 --- a/src/Makefile_Efl_Cxx.am +++ b/src/Makefile_Efl_Cxx.am @@ -8,7 +8,8 @@ generated_efl_cxx_bindings = \ lib/efl/interfaces/efl_image.eo.hh \ lib/efl/interfaces/efl_player.eo.hh \ lib/efl/interfaces/efl_text.eo.hh \ - lib/efl/interfaces/efl_text_properties.eo.hh + lib/efl/interfaces/efl_text_properties.eo.hh \ + lib/efl/interfaces/efl_gfx_base.eo.hh lib/efl/Efl.hh: $(generated_efl_cxx_bindings) @echo @ECHO_E@ "#ifndef EFL_CXX_EDJE_HH\n#define EFL_CXX_EDJE_HH\n" > $(top_builddir)/src/lib/efl/Efl.hh diff --git a/src/lib/edje/edje_calc.c b/src/lib/edje/edje_calc.c index e9329d52ad..f1ea48c605 100644 --- a/src/lib/edje/edje_calc.c +++ b/src/lib/edje/edje_calc.c @@ -1422,7 +1422,7 @@ _edje_part_recalc_single_textblock(FLOAT_T sc, if (!chosen_desc->text.min_x) { eo_do(ep->object, - evas_obj_size_set(TO_INT(params->eval.w), TO_INT(params->eval.h)), + efl_gfx_size_set(TO_INT(params->eval.w), TO_INT(params->eval.h)), evas_obj_textblock_size_formatted_get(&tw, &th)); } else @@ -1450,7 +1450,7 @@ _edje_part_recalc_single_textblock(FLOAT_T sc, if (!chosen_desc->text.max_x) { eo_do(ep->object, - evas_obj_size_set(TO_INT(params->eval.w), TO_INT(params->eval.h)), + efl_gfx_size_set(TO_INT(params->eval.w), TO_INT(params->eval.h)), evas_obj_textblock_size_formatted_get(&tw, &th)); } else @@ -1538,7 +1538,7 @@ _edje_part_recalc_single_text(FLOAT_T sc EINA_UNUSED, return; // Note: No need to add padding to that, it's already in the geometry - eo_do(ep->object, evas_obj_size_get(&mw, &mh)); + eo_do(ep->object, efl_gfx_size_get(&mw, &mh)); if (chosen_desc->text.max_x) { @@ -1698,7 +1698,7 @@ _edje_part_recalc_single_text(FLOAT_T sc EINA_UNUSED, eo_do(ep->object, evas_obj_text_style_set(style), evas_obj_text_set(text), - evas_obj_size_get(&tw, &th)); + efl_gfx_size_get(&tw, &th)); if (chosen_desc->text.max_x) { int l, r; @@ -3918,7 +3918,7 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *sta /* visibility and color have no meaning on SWALLOW and GROUP part. */ #ifdef HAVE_EPHYSICS eo_do(ep->object, - evas_obj_size_set(pf->final.w, pf->final.h)); + efl_gfx_size_set(pf->final.w, pf->final.h)); if ((ep->part->physics_body) && (!ep->body)) { if (_edje_physics_world_geometry_check(ed->world)) @@ -3936,19 +3936,19 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *sta } else eo_do(ep->object, - evas_obj_position_set(ed->x + pf->final.x, ed->y + pf->final.y)); + efl_gfx_position_set(ed->x + pf->final.x, ed->y + pf->final.y)); #else eo_do(ep->object, - evas_obj_position_set(ed->x + pf->final.x, ed->y + pf->final.y), - evas_obj_size_set(pf->final.w, pf->final.h)); + efl_gfx_position_set(ed->x + pf->final.x, ed->y + pf->final.y), + efl_gfx_size_set(pf->final.w, pf->final.h)); #endif if (ep->nested_smart) { /* Move, Resize all nested parts */ /* Not really needed but will improve the bounding box evaluation done by Evas */ eo_do(ep->nested_smart, - evas_obj_position_set(ed->x + pf->final.x, ed->y + pf->final.y), - evas_obj_size_set(pf->final.w, pf->final.h)); + efl_gfx_position_set(ed->x + pf->final.x, ed->y + pf->final.y), + efl_gfx_size_set(pf->final.w, pf->final.h)); } if (ep->part->entry_mode > EDJE_ENTRY_EDIT_MODE_NONE) _edje_entry_real_part_configure(ed, ep); @@ -4012,9 +4012,9 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *sta if (ep->part->type == EDJE_PART_TYPE_GROUP) vis = evas_object_visible_get(ed->obj); eo_do(ep->typedata.swallow->swallowed_object, - evas_obj_position_set(ed->x + pf->final.x, ed->y + pf->final.y), - evas_obj_size_set(pf->final.w, pf->final.h), - evas_obj_visibility_set(vis)); + efl_gfx_position_set(ed->x + pf->final.x, ed->y + pf->final.y), + efl_gfx_size_set(pf->final.w, pf->final.h), + efl_gfx_visibility_set(vis)); } else evas_object_hide(ep->typedata.swallow->swallowed_object); mo = ep->typedata.swallow->swallowed_object; diff --git a/src/lib/edje/edje_text.c b/src/lib/edje/edje_text.c index e95feb580d..455c9837cf 100644 --- a/src/lib/edje/edje_text.c +++ b/src/lib/edje/edje_text.c @@ -18,7 +18,7 @@ static inline void part_get_geometry(Edje_Real_Part *rp, Evas_Coord *w, Evas_Coord *h) { if (!rp->part->use_alternate_font_metrics) - eo_do(rp->object, evas_obj_size_get(w, h)); + eo_do(rp->object, efl_gfx_size_get(w, h)); else { if (w) *w = evas_object_text_horiz_advance_get(rp->object); @@ -100,7 +100,7 @@ _edje_text_fit_x(Edje *ed, Edje_Real_Part *ep, evas_obj_text_ellipsis_set(chosen_desc->text.min_x ? -1 : params->type.text.ellipsis), efl_text_properties_font_set(font, size), efl_text_set(text), - evas_obj_size_set(sw, sh)); + efl_gfx_size_set(sw, sh)); return text; } @@ -519,10 +519,10 @@ arrange_text: if (!calc_only) { eo_do(ep->object, - evas_obj_position_set(ed->x + TO_INT(params->eval.x) + ep->typedata.text->offset.x, - ed->y + TO_INT(params->eval.y) + ep->typedata.text->offset.y); + efl_gfx_position_set(ed->x + TO_INT(params->eval.x) + ep->typedata.text->offset.x, + ed->y + TO_INT(params->eval.y) + ep->typedata.text->offset.y); - evas_obj_visibility_set(params->visible)); + efl_gfx_visibility_set(params->visible)); } diff --git a/src/lib/efl/Efl.h b/src/lib/efl/Efl.h index 9e35f2efe7..91d067cf39 100644 --- a/src/lib/efl/Efl.h +++ b/src/lib/efl/Efl.h @@ -123,6 +123,7 @@ typedef enum _Efl_Gfx_Gradient_Spread #include "interfaces/efl_gfx_utils.h" +#include "interfaces/efl_gfx_base.eo.h" #include "interfaces/efl_gfx_shape.eo.h" #include "interfaces/efl_gfx_gradient.eo.h" #include "interfaces/efl_gfx_gradient_linear.eo.h" diff --git a/src/lib/efl/interfaces/efl_gfx_base.eo b/src/lib/efl/interfaces/efl_gfx_base.eo new file mode 100644 index 0000000000..ea175b43ad --- /dev/null +++ b/src/lib/efl/interfaces/efl_gfx_base.eo @@ -0,0 +1,89 @@ +interface Efl.Gfx.Base { + legacy_prefix: null; + eo_prefix: efl_gfx; + properties { + position { + set { + /*@ Move the given Evas object to the given location inside its canvas' viewport. */ + } + get { + /*@ Retrieves the position of the given Evas object. */ + } + values { + int x; /*@ in */ + int y; /*@ in */ + } + } + size { + set { + /*@ Changes the size of the given Evas object. */ + } + get { + /*@ Retrieves the (rectangular) size of the given Evas object. */ + } + values { + int w; /*@ in */ + int h; /*@ in */ + } + } + color { + set { + /*@ + Sets the general/main color of the given Evas object to the given + one. + + @see evas_object_color_get() (for an example) + @note These color values are expected to be premultiplied by @p a. + + @ingroup Evas_Object_Group_Basic */ + } + get { + /*@ + Retrieves the general/main color of the given Evas object. + + Retrieves the “main” color's RGB component (and alpha channel) + values, which range from 0 to 255. For the alpha channel, + which defines the object's transparency level, 0 means totally + transparent, while 255 means opaque. These color values are + premultiplied by the alpha value. + + Usually you’ll use this attribute for text and rectangle objects, + where the “main” color is their unique one. If set for objects + which themselves have colors, like the images one, those colors get + modulated by this one. + + @note All newly created Evas rectangles get the default color + values of 255 255 255 255 (opaque white). + + @note Use @c NULL pointers on the components you're not interested + in: they'll be ignored by the function. + + Example: + @dontinclude evas-object-manipulation.c + @skip int alpha, r, g, b; + @until return + + See the full @ref Example_Evas_Object_Manipulation "example". + + @ingroup Evas_Object_Group_Basic */ + } + values { + int r; /*@ The red component of the given color. */ + int g; /*@ The green component of the given color. */ + int b; /*@ The blue component of the given color. */ + int a; /*@ The alpha component of the given color. */ + } + } + visibility { + set { + /*@ Makes the given Evas object visible or invisible. */ + } + get { + /*@ Retrieves whether or not the given Evas object is visible. */ + } + values { + bool v; /*@ @c EINA_TRUE if to make the object visible, @c EINA_FALSE otherwise */ + } + } + } +} diff --git a/src/lib/efl/interfaces/efl_interfaces_main.c b/src/lib/efl/interfaces/efl_interfaces_main.c index 9ede0fe7d2..3aecd653d5 100644 --- a/src/lib/efl/interfaces/efl_interfaces_main.c +++ b/src/lib/efl/interfaces/efl_interfaces_main.c @@ -11,6 +11,7 @@ #include "interfaces/efl_text.eo.c" #include "interfaces/efl_text_properties.eo.c" +#include "interfaces/efl_gfx_base.eo.c" #include "interfaces/efl_gfx_shape.eo.c" #include "interfaces/efl_gfx_gradient.eo.c" #include "interfaces/efl_gfx_gradient_linear.eo.c" diff --git a/src/lib/evas/Evas_Legacy.h b/src/lib/evas/Evas_Legacy.h index e23e2ae774..0c352ec4fd 100644 --- a/src/lib/evas/Evas_Legacy.h +++ b/src/lib/evas/Evas_Legacy.h @@ -568,6 +568,86 @@ EAPI void evas_object_show(Evas_Object *obj) EINA_ARG_NONNULL(1); EAPI void evas_object_hide(Evas_Object *obj) EINA_ARG_NONNULL(1); +/** + * + * Sets the general/main color of the given Evas object to the given + * one. + * + * @see evas_object_color_get() (for an example) + * @note These color values are expected to be premultiplied by @p a. + * + * @ingroup Evas_Object_Group_Basic + * + * @param[in] r The red component of the given color. + * @param[in] g The green component of the given color. + * @param[in] b The blue component of the given color. + * @param[in] a The alpha component of the given color. + */ +EAPI void evas_object_color_set(Evas_Object *obj, int r, int g, int b, int a); + +/** + * + * Retrieves the general/main color of the given Evas object. + * + * Retrieves the “main” color's RGB component (and alpha channel) + * values, which range from 0 to 255. For the alpha channel, + * which defines the object's transparency level, 0 means totally + * transparent, while 255 means opaque. These color values are + * premultiplied by the alpha value. + * + * Usually you’ll use this attribute for text and rectangle objects, + * where the “main” color is their unique one. If set for objects + * which themselves have colors, like the images one, those colors get + * modulated by this one. + * + * @note All newly created Evas rectangles get the default color + * values of 255 255 255 255 (opaque white). + * + * @note Use @c NULL pointers on the components you're not interested + * in: they'll be ignored by the function. + * + * Example: + * @dontinclude evas-object-manipulation.c + * @skip int alpha, r, g, b; + * @until return + * + * See the full @ref Example_Evas_Object_Manipulation "example". + * + * @ingroup Evas_Object_Group_Basic + * + * @param[out] r The red component of the given color. + * @param[out] g The green component of the given color. + * @param[out] b The blue component of the given color. + * @param[out] a The alpha component of the given color. + */ +EAPI void evas_object_color_get(const Evas_Object *obj, int *r, int *g, int *b, int *a); + +/** + * + * Move the given Evas object to the given location inside its canvas' viewport. + * + * @param[in] x in + * @param[in] y in + */ +EAPI void evas_object_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y); + +/** + * + * Changes the size of the given Evas object. + * + * @param[in] w in + * @param[in] h in + */ +EAPI void evas_object_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h); + +/** + * + * Retrieves whether or not the given Evas object is visible. + * + */ +EAPI Eina_Bool evas_object_visible_get(const Evas_Object *obj); + + #include "canvas/evas_common_interface.eo.legacy.h" #include "canvas/evas_object.eo.legacy.h" diff --git a/src/lib/evas/canvas/evas_object.eo b/src/lib/evas/canvas/evas_object.eo index afbaa27d5e..998e031cbf 100644 --- a/src/lib/evas/canvas/evas_object.eo +++ b/src/lib/evas/canvas/evas_object.eo @@ -1,4 +1,4 @@ -abstract Evas.Object (Eo.Base, Evas.Common_Interface) +abstract Evas.Object (Eo.Base, Evas.Common_Interface, Efl.Gfx.Base) { eo_prefix: evas_obj; data: Evas_Object_Protected_Data; @@ -80,19 +80,6 @@ abstract Evas.Object (Eo.Base, Evas.Common_Interface) Evas_Coord h; /*@ Integer to use as the preferred height hint. */ } } - visibility { - set { - /*@ Makes the given Evas object visible or invisible. */ - legacy: null; - } - get { - /*@ Retrieves whether or not the given Evas object is visible. */ - legacy: evas_object_visible_get; - } - values { - bool v; /*@ @c EINA_TRUE if to make the object visible, @c EINA_FALSE otherwise */ - } - } type { set { /*@ Sets the type of the given Evas object. */ @@ -745,20 +732,6 @@ abstract Evas.Object (Eo.Base, Evas.Common_Interface) clipper, @c EINA_FALSE otherwise. */ } } - size { - set { - /*@ Changes the size of the given Evas object. */ - legacy: evas_object_resize; - } - get { - /*@ Retrieves the (rectangular) size of the given Evas object. */ - legacy: null; - } - values { - Evas_Coord w; /*@ in */ - Evas_Coord h; /*@ in */ - } - } focus { set { /*@ @@ -1031,20 +1004,6 @@ abstract Evas.Object (Eo.Base, Evas.Common_Interface) (@c EINA_FALSE) */ } } - position { - set { - /*@ Move the given Evas object to the given location inside its canvas' viewport. */ - legacy: evas_object_move; - } - get { - /*@ Retrieves the position of the given Evas object. */ - legacy: null; - } - values { - Evas_Coord x; /*@ in */ - Evas_Coord y; /*@ in */ - } - } anti_alias { set { /*@ @@ -1062,54 +1021,6 @@ abstract Evas.Object (Eo.Base, Evas.Common_Interface) bool anti_alias; /*@ (@c EINA_TRUE) if the object is to be anti_aliased, (@c EINA_FALSE) otherwise. */ } } - color { - set { - /*@ - Sets the general/main color of the given Evas object to the given - one. - - @see evas_object_color_get() (for an example) - @note These color values are expected to be premultiplied by @p a. - - @ingroup Evas_Object_Group_Basic */ - } - get { - /*@ - Retrieves the general/main color of the given Evas object. - - Retrieves the “main” color's RGB component (and alpha channel) - values, which range from 0 to 255. For the alpha channel, - which defines the object's transparency level, 0 means totally - transparent, while 255 means opaque. These color values are - premultiplied by the alpha value. - - Usually you’ll use this attribute for text and rectangle objects, - where the “main” color is their unique one. If set for objects - which themselves have colors, like the images one, those colors get - modulated by this one. - - @note All newly created Evas rectangles get the default color - values of 255 255 255 255 (opaque white). - - @note Use @c NULL pointers on the components you're not interested - in: they'll be ignored by the function. - - Example: - @dontinclude evas-object-manipulation.c - @skip int alpha, r, g, b; - @until return - - See the full @ref Example_Evas_Object_Manipulation "example". - - @ingroup Evas_Object_Group_Basic */ - } - values { - int r; /*@ The red component of the given color. */ - int g; /*@ The green component of the given color. */ - int b; /*@ The blue component of the given color. */ - int a; /*@ The alpha component of the given color. */ - } - } smart_data { get { /*@ @@ -1522,6 +1433,14 @@ abstract Evas.Object (Eo.Base, Evas.Common_Interface) Eo.Base.destructor; Eo.Base.dbg_info_get; Evas.Common_Interface.evas.get; + Efl.Gfx.Base.visibility.set; + Efl.Gfx.Base.visibility.get; + Efl.Gfx.Base.position.set; + Efl.Gfx.Base.position.get; + Efl.Gfx.Base.color.set; + Efl.Gfx.Base.color.get; + Efl.Gfx.Base.size.set; + Efl.Gfx.Base.size.get; } events { mouse,in; /*@ Mouse In Event */ diff --git a/src/lib/evas/canvas/evas_object_main.c b/src/lib/evas/canvas/evas_object_main.c index d5a8a478bf..41893e8943 100644 --- a/src/lib/evas/canvas/evas_object_main.c +++ b/src/lib/evas/canvas/evas_object_main.c @@ -750,12 +750,19 @@ evas_object_geometry_set(Evas_Object *eo_obj, Evas_Coord x, Evas_Coord y, Evas_C return; MAGIC_CHECK_END(); eo_do(eo_obj, - evas_obj_position_set(x, y), - evas_obj_size_set(w, h)); + efl_gfx_position_set(x, y), + efl_gfx_size_set(w, h)); +} + +EAPI void +evas_object_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y) +{ + eo_do((Evas_Object *)obj, efl_gfx_position_set(x, y)); } EOLIAN static void -_evas_object_position_set(Eo *eo_obj, Evas_Object_Protected_Data *obj, Evas_Coord x, Evas_Coord y) +_evas_object_efl_gfx_base_position_set(Eo *eo_obj, Evas_Object_Protected_Data *obj, + Evas_Coord x, Evas_Coord y) { Eina_Bool is, was = EINA_FALSE; @@ -838,8 +845,15 @@ _evas_object_position_set(Eo *eo_obj, Evas_Object_Protected_Data *obj, Evas_Coor evas_object_inform_call_move(eo_obj, obj); } +EAPI void +evas_object_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h) +{ + eo_do((Evas_Object *)obj, efl_gfx_size_set(w, h)); +} + EOLIAN static void -_evas_object_size_set(Eo *eo_obj, Evas_Object_Protected_Data *obj, Evas_Coord w, Evas_Coord h) +_evas_object_efl_gfx_base_size_set(Eo *eo_obj, Evas_Object_Protected_Data *obj, + Evas_Coord w, Evas_Coord h) { Eina_Bool is, was = EINA_FALSE; Eina_Bool pass = EINA_FALSE, freeze = EINA_FALSE; @@ -923,33 +937,37 @@ evas_object_geometry_get(const Evas_Object *eo_obj, Evas_Coord *x, Evas_Coord *y if (x) *x = 0; if (y) *y = 0; if (w) *w = 0; if (h) *h = 0; return; MAGIC_CHECK_END(); - eo_do((Eo *)eo_obj, evas_obj_position_get(x, y), evas_obj_size_get(w, h)); + eo_do((Eo *)eo_obj, efl_gfx_position_get(x, y), efl_gfx_size_get(w, h)); } EOLIAN static void -_evas_object_position_get(Eo *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj, Evas_Coord *x, Evas_Coord *y) +_evas_object_efl_gfx_base_position_get(Eo *obj EINA_UNUSED, + Evas_Object_Protected_Data *pd, + Evas_Coord *x, Evas_Coord *y) { - if ((obj->delete_me) || (!obj->layer)) + if ((pd->delete_me) || (!pd->layer)) { if (x) *x = 0; if (y) *y = 0; return; } - if (x) *x = obj->cur->geometry.x; - if (y) *y = obj->cur->geometry.y; + if (x) *x = pd->cur->geometry.x; + if (y) *y = pd->cur->geometry.y; } EOLIAN static void -_evas_object_size_get(Eo *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj, Evas_Coord *w, Evas_Coord *h) +_evas_object_efl_gfx_base_size_get(Eo *obj EINA_UNUSED, + Evas_Object_Protected_Data *pd, + Evas_Coord *w, Evas_Coord *h) { - if (obj->delete_me) + if (pd->delete_me) { if (w) *w = 0; if (h) *h = 0; return; } - if (w) *w = obj->cur->geometry.w; - if (h) *h = obj->cur->geometry.h; + if (w) *w = pd->cur->geometry.w; + if (h) *h = pd->cur->geometry.h; } static void @@ -1186,18 +1204,28 @@ evas_object_show(Evas_Object *eo_obj) MAGIC_CHECK(eo_obj, Evas_Object, MAGIC_OBJ); return; MAGIC_CHECK_END(); - eo_do(eo_obj, evas_obj_visibility_set(EINA_TRUE)); + eo_do(eo_obj, efl_gfx_visibility_set(EINA_TRUE)); } EAPI void evas_object_hide(Evas_Object *eo_obj) { if (!eo_obj) return; - eo_do(eo_obj, evas_obj_visibility_set(EINA_FALSE)); + eo_do(eo_obj, efl_gfx_visibility_set(EINA_FALSE)); +} + +EAPI Eina_Bool +evas_object_visible_get(const Evas_Object *obj) +{ + Eina_Bool ret; + + return eo_do_ret((Evas_Object *)obj, ret, efl_gfx_visibility_get()); } static void -_evas_object_visibility_set(Eo *eo_obj, Evas_Object_Protected_Data *obj, Eina_Bool visible) +_evas_object_efl_gfx_base_visibility_set(Eo *eo_obj, + Evas_Object_Protected_Data *obj, + Eina_Bool visible) { evas_object_async_block(obj); if (visible) _show(eo_obj, obj); @@ -1373,14 +1401,22 @@ _hide(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj) } static Eina_Bool -_evas_object_visibility_get(Eo *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj) +_evas_object_efl_gfx_base_visibility_get(Eo *eo_obj EINA_UNUSED, + Evas_Object_Protected_Data *obj) { if (obj->delete_me) return EINA_FALSE; return obj->cur->visible; } +EAPI void +evas_object_color_set(Evas_Object *obj, int r, int g, int b, int a) +{ + eo_do((Evas_Object *)obj, efl_gfx_color_set(r, g, b, a)); +} + EOLIAN static void -_evas_object_color_set(Eo *eo_obj, Evas_Object_Protected_Data *obj, int r, int g, int b, int a) +_evas_object_efl_gfx_base_color_set(Eo *eo_obj, Evas_Object_Protected_Data *obj, + int r, int g, int b, int a) { if (obj->delete_me) return; if (r > 255) r = 255; if (r < 0) r = 0; @@ -1435,8 +1471,16 @@ _evas_object_color_set(Eo *eo_obj, Evas_Object_Protected_Data *obj, int r, int g evas_object_change(eo_obj, obj); } +EAPI void +evas_object_color_get(const Evas_Object *obj, int *r, int *g, int *b, int *a) +{ + eo_do((Evas_Object *)obj, efl_gfx_color_get(r, g, b, a)); +} + EOLIAN static void -_evas_object_color_get(Eo *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj, int *r, int *g, int *b, int *a) +_evas_object_efl_gfx_base_color_get(Eo *eo_obj EINA_UNUSED, + Evas_Object_Protected_Data *obj, + int *r, int *g, int *b, int *a) { if (obj->delete_me) { @@ -1546,18 +1590,18 @@ _evas_object_eo_base_dbg_info_get(Eo *eo_obj, Evas_Object_Protected_Data *obj EI Eina_Bool clipees_has; eo_do(eo_obj, - visible = evas_obj_visibility_get(), + visible = efl_gfx_visibility_get(), layer = evas_obj_layer_get(), name = evas_obj_name_get(), - evas_obj_position_get(&x, &y), - evas_obj_size_get(&w, &h), + efl_gfx_position_get(&x, &y), + efl_gfx_size_get(&w, &h), scale = evas_obj_scale_get(), evas_obj_size_hint_min_get(&minw, &minh), evas_obj_size_hint_max_get(&maxw, &maxh), evas_obj_size_hint_request_get(&requestw, &requesth), evas_obj_size_hint_align_get(&dblx, &dbly), evas_obj_size_hint_weight_get(&dblw, &dblh), - evas_obj_color_get(&r, &g, &b, &a), + efl_gfx_color_get(&r, &g, &b, &a), focus = evas_obj_focus_get(), m = evas_obj_pointer_mode_get(), pass_event = evas_obj_pass_events_get(), diff --git a/src/lib/evas/canvas/evas_object_text.c b/src/lib/evas/canvas/evas_object_text.c index e17bd63384..c053515e6d 100644 --- a/src/lib/evas/canvas/evas_object_text.c +++ b/src/lib/evas/canvas/evas_object_text.c @@ -926,7 +926,7 @@ _evas_object_text_layout(Evas_Object *eo_obj, Evas_Text_Data *o, Eina_Unicode *t } EOLIAN static void -_evas_text_evas_object_size_set(Eo *eo_obj, Evas_Text_Data *o, Evas_Coord w, Evas_Coord h) +_evas_text_efl_gfx_base_size_set(Eo *eo_obj, Evas_Text_Data *o, int w, int h) { Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS); @@ -1235,7 +1235,7 @@ _evas_text_style_set(Eo *eo_obj, Evas_Text_Data *o, Evas_Text_Style_Type style) h = obj->cur->geometry.h + (t - pt) + (b - pb); eo_do_super(eo_obj, MY_CLASS, - evas_obj_size_set(w, h)); + efl_gfx_size_set(w, h)); evas_object_change(eo_obj, obj); } @@ -2350,12 +2350,12 @@ _evas_object_text_recalc(Evas_Object *eo_obj, Eina_Unicode *text) min = w + l + r < obj->cur->geometry.w || obj->cur->geometry.w == 0 ? w + l + r : obj->cur->geometry.w; eo_do_super(eo_obj, MY_CLASS, - evas_obj_size_set(min, h + t + b)); + efl_gfx_size_set(min, h + t + b)); } else { eo_do_super(eo_obj, MY_CLASS, - evas_obj_size_set(w + l + r, h + t + b)); + efl_gfx_size_set(w + l + r, h + t + b)); } //// obj->cur->cache.geometry.validity = 0; } @@ -2369,7 +2369,7 @@ _evas_object_text_recalc(Evas_Object *eo_obj, Eina_Unicode *text) evas_filter_program_padding_get(o->cur.filter->chain, &l, &r, &t, &b); eo_do_super(eo_obj, MY_CLASS, - evas_obj_size_set(0, o->max_ascent + o->max_descent + t + b)); + efl_gfx_size_set(0, o->max_ascent + o->max_descent + t + b)); //// obj->cur->cache.geometry.validity = 0; } o->last_computed.w = obj->cur->geometry.w; diff --git a/src/lib/evas/canvas/evas_text.eo b/src/lib/evas/canvas/evas_text.eo index c6ddfe29a5..1d423335e8 100644 --- a/src/lib/evas/canvas/evas_text.eo +++ b/src/lib/evas/canvas/evas_text.eo @@ -362,7 +362,7 @@ class Evas.Text (Evas.Object, Efl.Text, Efl.Text_Properties) Eo.Base.constructor; Eo.Base.destructor; Eo.Base.dbg_info_get; - Evas.Object.size.set; + Efl.Gfx.Base.size.set; Efl.Text.text.set; Efl.Text.text.get; Efl.Text_Properties.font.get; diff --git a/src/tests/evas/evas_test_filters.c b/src/tests/evas/evas_test_filters.c index cb219056c0..b81edc3f7c 100644 --- a/src/tests/evas/evas_test_filters.c +++ b/src/tests/evas/evas_test_filters.c @@ -387,14 +387,14 @@ START_TEST(evas_filter_text_render_test) evas_object_resize(o, 10, 10); evas_object_show(o); eo_do(to, - evas_obj_color_set(255, 255, 255, 255), + efl_gfx_color_set(255, 255, 255, 255), evas_obj_text_filter_source_set(tc->source, o), evas_obj_text_filter_program_set(tc->code)); } else { eo_do(to, - evas_obj_color_set(255, 255, 255, 255), + efl_gfx_color_set(255, 255, 255, 255), evas_obj_text_filter_program_set(tc->code)); } From 2ca2a43916087e801b3f7891fdc421106cfea4c6 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:23:18 +0200 Subject: [PATCH 094/251] ecore_evas: fix with new naming. --- src/bin/ecore_evas/ecore_evas_svg.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/bin/ecore_evas/ecore_evas_svg.c b/src/bin/ecore_evas/ecore_evas_svg.c index 468311f10d..f8297b7c45 100644 --- a/src/bin/ecore_evas/ecore_evas_svg.c +++ b/src/bin/ecore_evas/ecore_evas_svg.c @@ -157,13 +157,13 @@ main(int argc, char *argv[]) r = eo_add(EVAS_RECTANGLE_CLASS, e, - evas_obj_color_set(color[0], color[1], color[2], alpha ? 0 : 255), - evas_obj_visibility_set(EINA_TRUE)); + efl_gfx_color_set(color[0], color[1], color[2], alpha ? 0 : 255), + efl_gfx_visibility_set(EINA_TRUE)); ecore_evas_object_associate(ee, r, ECORE_EVAS_OBJECT_ASSOCIATE_BASE); vg = eo_add(EVAS_VG_CLASS, e, efl_file_set(argv[arg_index], NULL), - evas_obj_visibility_set(EINA_TRUE)); + efl_gfx_visibility_set(EINA_TRUE)); ecore_evas_object_associate(ee, vg, ECORE_EVAS_OBJECT_ASSOCIATE_BASE); if (display) From 651436f410e6df1b92b163296fc9c88096edd9ea Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:23:19 +0200 Subject: [PATCH 095/251] efl: rename visibility to visible. After discussion bindings and people in general prefer visible. T2035 --- src/bin/ecore_evas/ecore_evas_svg.c | 4 ++-- src/lib/edje/edje_calc.c | 2 +- src/lib/edje/edje_text.c | 2 +- src/lib/efl/interfaces/efl_gfx_base.eo | 2 +- src/lib/evas/canvas/evas_object.eo | 4 ++-- src/lib/evas/canvas/evas_object_main.c | 16 ++++++++-------- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/bin/ecore_evas/ecore_evas_svg.c b/src/bin/ecore_evas/ecore_evas_svg.c index f8297b7c45..bd95a0618a 100644 --- a/src/bin/ecore_evas/ecore_evas_svg.c +++ b/src/bin/ecore_evas/ecore_evas_svg.c @@ -158,12 +158,12 @@ main(int argc, char *argv[]) r = eo_add(EVAS_RECTANGLE_CLASS, e, efl_gfx_color_set(color[0], color[1], color[2], alpha ? 0 : 255), - efl_gfx_visibility_set(EINA_TRUE)); + efl_gfx_visible_set(EINA_TRUE)); ecore_evas_object_associate(ee, r, ECORE_EVAS_OBJECT_ASSOCIATE_BASE); vg = eo_add(EVAS_VG_CLASS, e, efl_file_set(argv[arg_index], NULL), - efl_gfx_visibility_set(EINA_TRUE)); + efl_gfx_visible_set(EINA_TRUE)); ecore_evas_object_associate(ee, vg, ECORE_EVAS_OBJECT_ASSOCIATE_BASE); if (display) diff --git a/src/lib/edje/edje_calc.c b/src/lib/edje/edje_calc.c index f1ea48c605..570e96833f 100644 --- a/src/lib/edje/edje_calc.c +++ b/src/lib/edje/edje_calc.c @@ -4014,7 +4014,7 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *sta eo_do(ep->typedata.swallow->swallowed_object, efl_gfx_position_set(ed->x + pf->final.x, ed->y + pf->final.y), efl_gfx_size_set(pf->final.w, pf->final.h), - efl_gfx_visibility_set(vis)); + efl_gfx_visible_set(vis)); } else evas_object_hide(ep->typedata.swallow->swallowed_object); mo = ep->typedata.swallow->swallowed_object; diff --git a/src/lib/edje/edje_text.c b/src/lib/edje/edje_text.c index 455c9837cf..057d6d0a6e 100644 --- a/src/lib/edje/edje_text.c +++ b/src/lib/edje/edje_text.c @@ -522,7 +522,7 @@ arrange_text: efl_gfx_position_set(ed->x + TO_INT(params->eval.x) + ep->typedata.text->offset.x, ed->y + TO_INT(params->eval.y) + ep->typedata.text->offset.y); - efl_gfx_visibility_set(params->visible)); + efl_gfx_visible_set(params->visible)); } diff --git a/src/lib/efl/interfaces/efl_gfx_base.eo b/src/lib/efl/interfaces/efl_gfx_base.eo index ea175b43ad..e5b719cc25 100644 --- a/src/lib/efl/interfaces/efl_gfx_base.eo +++ b/src/lib/efl/interfaces/efl_gfx_base.eo @@ -74,7 +74,7 @@ interface Efl.Gfx.Base { int a; /*@ The alpha component of the given color. */ } } - visibility { + visible { set { /*@ Makes the given Evas object visible or invisible. */ } diff --git a/src/lib/evas/canvas/evas_object.eo b/src/lib/evas/canvas/evas_object.eo index 998e031cbf..d4823e31d3 100644 --- a/src/lib/evas/canvas/evas_object.eo +++ b/src/lib/evas/canvas/evas_object.eo @@ -1433,8 +1433,8 @@ abstract Evas.Object (Eo.Base, Evas.Common_Interface, Efl.Gfx.Base) Eo.Base.destructor; Eo.Base.dbg_info_get; Evas.Common_Interface.evas.get; - Efl.Gfx.Base.visibility.set; - Efl.Gfx.Base.visibility.get; + Efl.Gfx.Base.visible.set; + Efl.Gfx.Base.visible.get; Efl.Gfx.Base.position.set; Efl.Gfx.Base.position.get; Efl.Gfx.Base.color.set; diff --git a/src/lib/evas/canvas/evas_object_main.c b/src/lib/evas/canvas/evas_object_main.c index 41893e8943..f45f91fb2c 100644 --- a/src/lib/evas/canvas/evas_object_main.c +++ b/src/lib/evas/canvas/evas_object_main.c @@ -1204,14 +1204,14 @@ evas_object_show(Evas_Object *eo_obj) MAGIC_CHECK(eo_obj, Evas_Object, MAGIC_OBJ); return; MAGIC_CHECK_END(); - eo_do(eo_obj, efl_gfx_visibility_set(EINA_TRUE)); + eo_do(eo_obj, efl_gfx_visible_set(EINA_TRUE)); } EAPI void evas_object_hide(Evas_Object *eo_obj) { if (!eo_obj) return; - eo_do(eo_obj, efl_gfx_visibility_set(EINA_FALSE)); + eo_do(eo_obj, efl_gfx_visible_set(EINA_FALSE)); } EAPI Eina_Bool @@ -1219,13 +1219,13 @@ evas_object_visible_get(const Evas_Object *obj) { Eina_Bool ret; - return eo_do_ret((Evas_Object *)obj, ret, efl_gfx_visibility_get()); + return eo_do_ret((Evas_Object *)obj, ret, efl_gfx_visible_get()); } static void -_evas_object_efl_gfx_base_visibility_set(Eo *eo_obj, - Evas_Object_Protected_Data *obj, - Eina_Bool visible) +_evas_object_efl_gfx_base_visible_set(Eo *eo_obj, + Evas_Object_Protected_Data *obj, + Eina_Bool visible) { evas_object_async_block(obj); if (visible) _show(eo_obj, obj); @@ -1401,7 +1401,7 @@ _hide(Evas_Object *eo_obj, Evas_Object_Protected_Data *obj) } static Eina_Bool -_evas_object_efl_gfx_base_visibility_get(Eo *eo_obj EINA_UNUSED, +_evas_object_efl_gfx_base_visible_get(Eo *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj) { if (obj->delete_me) return EINA_FALSE; @@ -1590,7 +1590,7 @@ _evas_object_eo_base_dbg_info_get(Eo *eo_obj, Evas_Object_Protected_Data *obj EI Eina_Bool clipees_has; eo_do(eo_obj, - visible = efl_gfx_visibility_get(), + visible = efl_gfx_visible_get(), layer = evas_obj_layer_get(), name = evas_obj_name_get(), efl_gfx_position_get(&x, &y), From c1118e728210b249f9577ad87081ad241507361f Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:23:20 +0200 Subject: [PATCH 096/251] evas: implement Efl.Gfx.Base in Evas.VG_Node. --- src/lib/evas/canvas/evas_vg_node.c | 52 +++++++++++++++++++++++------ src/lib/evas/canvas/evas_vg_node.eo | 52 +++++------------------------ 2 files changed, 50 insertions(+), 54 deletions(-) diff --git a/src/lib/evas/canvas/evas_vg_node.c b/src/lib/evas/canvas/evas_vg_node.c index 95467a036d..fbe0a60a9f 100644 --- a/src/lib/evas/canvas/evas_vg_node.c +++ b/src/lib/evas/canvas/evas_vg_node.c @@ -4,6 +4,7 @@ #include "evas_vg_private.h" #include +#include #define MY_CLASS EVAS_VG_NODE_CLASS @@ -50,23 +51,42 @@ _evas_vg_node_origin_get(Eo *obj EINA_UNUSED, } void -_evas_vg_node_visibility_set(Eo *obj EINA_UNUSED, - Evas_VG_Node_Data *pd, - Eina_Bool v) +_evas_vg_node_efl_gfx_base_position_set(Eo *obj EINA_UNUSED, + Evas_VG_Node_Data *pd, + int x, int y) +{ + pd->x = lrint(x); + pd->y = lrint(y); +} + +void +_evas_vg_node_efl_gfx_base_position_get(Eo *obj EINA_UNUSED, + Evas_VG_Node_Data *pd, + int *x, int *y) +{ + if (x) *x = pd->x; + if (y) *y = pd->y; +} + +void +_evas_vg_node_efl_gfx_base_visible_set(Eo *obj EINA_UNUSED, + Evas_VG_Node_Data *pd, Eina_Bool v) { pd->visibility = v; } + Eina_Bool -_evas_vg_node_visibility_get(Eo *obj EINA_UNUSED, Evas_VG_Node_Data *pd) +_evas_vg_node_efl_gfx_base_visible_get(Eo *obj EINA_UNUSED, + Evas_VG_Node_Data *pd) { return pd->visibility; } void -_evas_vg_node_color_set(Eo *obj EINA_UNUSED, - Evas_VG_Node_Data *pd, - int r, int g, int b, int a) +_evas_vg_node_efl_gfx_base_color_set(Eo *obj EINA_UNUSED, + Evas_VG_Node_Data *pd, + int r, int g, int b, int a) { pd->r = r; pd->g = g; @@ -75,9 +95,9 @@ _evas_vg_node_color_set(Eo *obj EINA_UNUSED, } void -_evas_vg_node_color_get(Eo *obj EINA_UNUSED, - Evas_VG_Node_Data *pd, - int *r, int *g, int *b, int *a) +_evas_vg_node_efl_gfx_base_color_get(Eo *obj EINA_UNUSED, + Evas_VG_Node_Data *pd, + int *r, int *g, int *b, int *a) { if (r) *r = pd->r; if (g) *g = pd->g; @@ -102,6 +122,18 @@ _evas_vg_node_mask_get(Eo *obj EINA_UNUSED, Evas_VG_Node_Data *pd) return pd->mask; } +void +_evas_vg_node_efl_gfx_base_size_get(Eo *obj, + Evas_VG_Node_Data *pd EINA_UNUSED, + int *w, int *h) +{ + Eina_Rectangle bound = { 0, 0, 0, 0 }; + + eo_do(obj, evas_vg_node_bound_get(&bound)); + if (w) *w = bound.w; + if (h) *h = bound.h; +} + // Parent should be a container otherwise dismissing the stacking operation static Eina_Bool _evas_vg_node_parent_checked_get(Eo *obj, diff --git a/src/lib/evas/canvas/evas_vg_node.eo b/src/lib/evas/canvas/evas_vg_node.eo index b7df4693e9..108c2eb2c7 100644 --- a/src/lib/evas/canvas/evas_vg_node.eo +++ b/src/lib/evas/canvas/evas_vg_node.eo @@ -1,4 +1,4 @@ -abstract Evas.VG_Node (Eo.Base) +abstract Evas.VG_Node (Eo.Base, Efl.Gfx.Base) { eo_prefix: evas_vg_node; legacy_prefix: null; @@ -22,49 +22,6 @@ abstract Evas.VG_Node (Eo.Base) double y; } } - visibility { - set { - /*@ Makes the given Evas_VG node visible or invisible. */ - } - get { - /*@ Retrieves whether or not the given Evas_VG node is visible. */ - } - values { - Eina_Bool v; /*@ @c EINA_TRUE if to make the object visible, @c EINA_FALSE otherwise */ - } - } - color { - set { - /*@ - Sets the general/main color of the given Evas_VG node to the given - one. - - @note These color values are expected to be premultiplied by @p a. - - @ingroup Evas_VG_Node_Group */ - } - get { - /*@ - Retrieves the general/main color of the given Evas_VG node. - - Retrieves the “main” color's RGB component (and alpha channel) - values, which range from 0 to 255. For the alpha channel, - which defines the object's transparency level, 0 means totally - transparent, while 255 means opaque. These color values are - premultiplied by the alpha value. - - @note Use @c NULL pointers on the components you're not interested - in: they'll be ignored by the function. - - @ingroup Evas_VG_Node_Group */ - } - values { - int r; /*@ The red component of the given color. */ - int g; /*@ The green component of the given color. */ - int b; /*@ The blue component of the given color. */ - int a; /*@ The alpha component of the given color. */ - } - } mask { set { } @@ -173,6 +130,13 @@ abstract Evas.VG_Node (Eo.Base) implements { Eo.Base.parent.set; Eo.Base.constructor; + Efl.Gfx.Base.visible.set; + Efl.Gfx.Base.visible.get; + Efl.Gfx.Base.color.set; + Efl.Gfx.Base.color.get; + Efl.Gfx.Base.size.get; + Efl.Gfx.Base.position.set; + Efl.Gfx.Base.position.get; @virtual .bound_get; } } \ No newline at end of file From a77b27f82b56ceac4af15dd844e87056e543cc46 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:23:21 +0200 Subject: [PATCH 097/251] efl: generate headers for the new VG interface in C++ to. --- src/Makefile_Efl_Cxx.am | 6 +++++- src/Makefile_Evas_Cxx.am | 11 ++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/Makefile_Efl_Cxx.am b/src/Makefile_Efl_Cxx.am index 6d28e97420..e8c8462325 100644 --- a/src/Makefile_Efl_Cxx.am +++ b/src/Makefile_Efl_Cxx.am @@ -9,7 +9,11 @@ generated_efl_cxx_bindings = \ lib/efl/interfaces/efl_player.eo.hh \ lib/efl/interfaces/efl_text.eo.hh \ lib/efl/interfaces/efl_text_properties.eo.hh \ - lib/efl/interfaces/efl_gfx_base.eo.hh + lib/efl/interfaces/efl_gfx_base.eo.hh \ + lib/efl/interfaces/efl_gfx_shape.eo.hh \ + lib/efl/interfaces/efl_gfx_gradient.eo.hh \ + lib/efl/interfaces/efl_gfx_gradient_linear.eo.hh \ + lib/efl/interfaces/efl_gfx_gradient_radial.eo.hh lib/efl/Efl.hh: $(generated_efl_cxx_bindings) @echo @ECHO_E@ "#ifndef EFL_CXX_EDJE_HH\n#define EFL_CXX_EDJE_HH\n" > $(top_builddir)/src/lib/efl/Efl.hh diff --git a/src/Makefile_Evas_Cxx.am b/src/Makefile_Evas_Cxx.am index 59e0d35ba2..1a9683d407 100644 --- a/src/Makefile_Evas_Cxx.am +++ b/src/Makefile_Evas_Cxx.am @@ -33,7 +33,16 @@ lib/evas/canvas/evas_3d_mesh.eo.hh \ lib/evas/canvas/evas_3d_node.eo.hh \ lib/evas/canvas/evas_3d_object.eo.hh \ lib/evas/canvas/evas_3d_scene.eo.hh \ -lib/evas/canvas/evas_3d_texture.eo.hh +lib/evas/canvas/evas_3d_texture.eo.hh \ +lib/evas/canvas/evas_vg.eo.hh \ +lib/evas/canvas/evas_vg_node.eo.hh \ +lib/evas/canvas/evas_vg_container.eo.hh \ +lib/evas/canvas/evas_vg_shape.eo.hh \ +lib/evas/canvas/evas_vg_root_node.eo.hh \ +lib/evas/canvas/evas_vg_gradient.eo.hh \ +lib/evas/canvas/evas_vg_gradient_radial.eo.hh \ +lib/evas/canvas/evas_vg_gradient_linear.eo.hh \ +lib/evas/canvas/evas_vg_image.eo.hh lib/evas/Evas.hh: $(generated_evas_canvas_cxx_bindings) @echo @ECHO_E@ "#ifndef EFL_CXX_EVAS_HH\n#define EFL_CXX_EVAS_HH\n" > $(top_builddir)/src/lib/evas/Evas.hh From 500fe6ef1bcae21ccb9612bddf4aa40c22e0dae4 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:23:22 +0200 Subject: [PATCH 098/251] efl: add Efl.Gfx.Stack interface and update Evas_Object accordingly. --- src/Makefile_Efl.am | 1 + src/Makefile_Efl_Cxx.am | 1 + src/lib/efl/Efl.h | 1 + src/lib/efl/interfaces/efl_gfx_stack.eo | 154 ++++++++++++++++++ src/lib/efl/interfaces/efl_interfaces_main.c | 1 + src/lib/evas/Evas_Legacy.h | 158 ++++++++++++++++++- src/lib/evas/canvas/evas_layer.c | 21 ++- src/lib/evas/canvas/evas_object.eo | 157 ++---------------- src/lib/evas/canvas/evas_object_main.c | 2 +- src/lib/evas/canvas/evas_stack.c | 58 ++++++- 10 files changed, 394 insertions(+), 160 deletions(-) create mode 100644 src/lib/efl/interfaces/efl_gfx_stack.eo diff --git a/src/Makefile_Efl.am b/src/Makefile_Efl.am index 2525020156..6423b6a43d 100644 --- a/src/Makefile_Efl.am +++ b/src/Makefile_Efl.am @@ -6,6 +6,7 @@ efl_eolian_files = \ lib/efl/interfaces/efl_text.eo \ lib/efl/interfaces/efl_text_properties.eo \ lib/efl/interfaces/efl_gfx_base.eo \ + lib/efl/interfaces/efl_gfx_stack.eo \ lib/efl/interfaces/efl_gfx_shape.eo \ lib/efl/interfaces/efl_gfx_gradient.eo \ lib/efl/interfaces/efl_gfx_gradient_linear.eo \ diff --git a/src/Makefile_Efl_Cxx.am b/src/Makefile_Efl_Cxx.am index e8c8462325..bf06f781f1 100644 --- a/src/Makefile_Efl_Cxx.am +++ b/src/Makefile_Efl_Cxx.am @@ -10,6 +10,7 @@ generated_efl_cxx_bindings = \ lib/efl/interfaces/efl_text.eo.hh \ lib/efl/interfaces/efl_text_properties.eo.hh \ lib/efl/interfaces/efl_gfx_base.eo.hh \ + lib/efl/interfaces/efl_gfx_stack.eo.hh \ lib/efl/interfaces/efl_gfx_shape.eo.hh \ lib/efl/interfaces/efl_gfx_gradient.eo.hh \ lib/efl/interfaces/efl_gfx_gradient_linear.eo.hh \ diff --git a/src/lib/efl/Efl.h b/src/lib/efl/Efl.h index 91d067cf39..5332ff5619 100644 --- a/src/lib/efl/Efl.h +++ b/src/lib/efl/Efl.h @@ -124,6 +124,7 @@ typedef enum _Efl_Gfx_Gradient_Spread #include "interfaces/efl_gfx_utils.h" #include "interfaces/efl_gfx_base.eo.h" +#include "interfaces/efl_gfx_stack.eo.h" #include "interfaces/efl_gfx_shape.eo.h" #include "interfaces/efl_gfx_gradient.eo.h" #include "interfaces/efl_gfx_gradient_linear.eo.h" diff --git a/src/lib/efl/interfaces/efl_gfx_stack.eo b/src/lib/efl/interfaces/efl_gfx_stack.eo new file mode 100644 index 0000000000..a104d0d4ed --- /dev/null +++ b/src/lib/efl/interfaces/efl_gfx_stack.eo @@ -0,0 +1,154 @@ +interface Efl.Gfx.Stack { + legacy_prefix: null; + properties { + layer { + set { + /*@ + Sets the layer of its canvas that the given object will be part of. + + If you don't use this function, you'll be dealing with an @b unique + layer of objects, the default one. Additional layers are handy when + you don't want a set of objects to interfere with another set with + regard to @b stacking. Two layers are completely disjoint in that + matter. + + This is a low-level function, which you'd be using when something + should be always on top, for example. + + @warning Be careful, it doesn't make sense to change the layer of + smart objects' children. Smart objects have a layer of their own, + which should contain all their children objects. + + @see evas_object_layer_get() */ + } + get { + /*@ + Retrieves the layer of its canvas that the given object is part of. + + @return Number of its layer + + @see evas_object_layer_set() */ + } + values { + short l; /*@ The number of the layer to place the object on. + Must be between #EVAS_LAYER_MIN and #EVAS_LAYER_MAX. */ + } + } + below { + get { + /*@ + Get the Evas object stacked right below @p obj + + @return the #Efl_Gfx_Stack directly below @p obj, if any, or @c NULL, + if none + + This function will traverse layers in its search, if there are + objects on layers below the one @p obj is placed at. + + @see evas_object_layer_get() + @see evas_object_layer_set() + @see evas_object_below_get() */ + return: Efl_Gfx_Stack * @warn_unused; + } + } + above { + get { + /*@ + Get the Evas object stacked right above @p obj + + @return the #Efl_Gfx_Stack directly above @p obj, if any, or @c NULL, + if none + + This function will traverse layers in its search, if there are + objects on layers above the one @p obj is placed at. + + @see evas_object_layer_get() + @see evas_object_layer_set() + @see evas_object_below_get() */ + return: Efl_Gfx_Stack * @warn_unused; + } + } + } + methods { + stack_below { + /*@ + Stack @p obj immediately below @p below + + Objects, in a given canvas, are stacked in the order they get added + to it. This means that, if they overlap, the highest ones will + cover the lowest ones, in that order. This function is a way to + change the stacking order for the objects. + + This function is intended to be used with objects belonging to + the same layer in a given canvas, otherwise it will fail (and + accomplish nothing). + + If you have smart objects on your canvas and @p obj is a member of + one of them, then @p below must also be a member of the same + smart object. + + Similarly, if @p obj is not a member of a smart object, @p below + must not be either. + + @see evas_object_layer_get() + @see evas_object_layer_set() + @see evas_object_stack_below() */ + + params { + @in Efl_Gfx_Stack *below @nonull; /*@ the object below which to stack */ + } + } + raise { + /*@ + Raise @p obj to the top of its layer. + + @p obj will, then, be the highest one in the layer it belongs + to. Object on other layers won't get touched. + + @see evas_object_stack_above() + @see evas_object_stack_below() + @see evas_object_lower() */ + + } + stack_above { + /*@ + Stack @p obj immediately above @p above + + Objects, in a given canvas, are stacked in the order they get added + to it. This means that, if they overlap, the highest ones will + cover the lowest ones, in that order. This function is a way to + change the stacking order for the objects. + + This function is intended to be used with objects belonging to + the same layer in a given canvas, otherwise it will fail (and + accomplish nothing). + + If you have smart objects on your canvas and @p obj is a member of + one of them, then @p above must also be a member of the same + smart object. + + Similarly, if @p obj is not a member of a smart object, @p above + must not be either. + + @see evas_object_layer_get() + @see evas_object_layer_set() + @see evas_object_stack_below() */ + + params { + @in Efl_Gfx_Stack *above @nonull; /*@ the object above which to stack */ + } + } + lower { + /*@ + Lower @p obj to the bottom of its layer. + + @p obj will, then, be the lowest one in the layer it belongs + to. Objects on other layers won't get touched. + + @see evas_object_stack_above() + @see evas_object_stack_below() + @see evas_object_raise() */ + + } + } +} diff --git a/src/lib/efl/interfaces/efl_interfaces_main.c b/src/lib/efl/interfaces/efl_interfaces_main.c index 3aecd653d5..7a91b98b6b 100644 --- a/src/lib/efl/interfaces/efl_interfaces_main.c +++ b/src/lib/efl/interfaces/efl_interfaces_main.c @@ -12,6 +12,7 @@ #include "interfaces/efl_text_properties.eo.c" #include "interfaces/efl_gfx_base.eo.c" +#include "interfaces/efl_gfx_stack.eo.c" #include "interfaces/efl_gfx_shape.eo.c" #include "interfaces/efl_gfx_gradient.eo.c" #include "interfaces/efl_gfx_gradient_linear.eo.c" diff --git a/src/lib/evas/Evas_Legacy.h b/src/lib/evas/Evas_Legacy.h index 0c352ec4fd..45f918846d 100644 --- a/src/lib/evas/Evas_Legacy.h +++ b/src/lib/evas/Evas_Legacy.h @@ -567,7 +567,6 @@ EAPI void evas_object_show(Evas_Object *obj) EINA_ARG_NONNULL(1); */ EAPI void evas_object_hide(Evas_Object *obj) EINA_ARG_NONNULL(1); - /** * * Sets the general/main color of the given Evas object to the given @@ -647,6 +646,163 @@ EAPI void evas_object_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h); */ EAPI Eina_Bool evas_object_visible_get(const Evas_Object *obj); +/** + * + * Sets the layer of its canvas that the given object will be part of. + * + * If you don't use this function, you'll be dealing with an @b unique + * layer of objects, the default one. Additional layers are handy when + * you don't want a set of objects to interfere with another set with + * regard to @b stacking. Two layers are completely disjoint in that + * matter. + * + * This is a low-level function, which you'd be using when something + * should be always on top, for example. + * + * @warning Be careful, it doesn't make sense to change the layer of + * smart objects' children. Smart objects have a layer of their own, + * which should contain all their children objects. + * + * @see evas_object_layer_get() + * + * @param[in] l The number of the layer to place the object on. +Must be between #EVAS_LAYER_MIN and #EVAS_LAYER_MAX. + */ +EAPI void evas_object_layer_set(Evas_Object *obj, short l); + +/** + * + * Retrieves the layer of its canvas that the given object is part of. + * + * @return Number of its layer + * + * @see evas_object_layer_set() + * + */ +EAPI short evas_object_layer_get(const Evas_Object *obj); + +/** + * + * Get the Evas object stacked right below @p obj + * + * @return the #Evas_Object directly below @p obj, if any, or @c NULL, + * if none + * + * This function will traverse layers in its search, if there are + * objects on layers below the one @p obj is placed at. + * + * @see evas_object_layer_get() + * @see evas_object_layer_set() + * @see evas_object_below_get() + * + */ +EAPI Evas_Object *evas_object_below_get(const Evas_Object *obj) EINA_WARN_UNUSED_RESULT; + +/** + * + * Get the Evas object stacked right above @p obj + * + * @return the #Evas_Object directly above @p obj, if any, or @c NULL, + * if none + * + * This function will traverse layers in its search, if there are + * objects on layers above the one @p obj is placed at. + * + * @see evas_object_layer_get() + * @see evas_object_layer_set() + * @see evas_object_below_get() + * + */ +EAPI Evas_Object *evas_object_above_get(const Evas_Object *obj) EINA_WARN_UNUSED_RESULT; + +/** + * + * Stack @p obj immediately below @p below + * + * Objects, in a given canvas, are stacked in the order they get added + * to it. This means that, if they overlap, the highest ones will + * cover the lowest ones, in that order. This function is a way to + * change the stacking order for the objects. + * + * This function is intended to be used with objects belonging to + * the same layer in a given canvas, otherwise it will fail (and + * accomplish nothing). + * + * If you have smart objects on your canvas and @p obj is a member of + * one of them, then @p below must also be a member of the same + * smart object. + * + * Similarly, if @p obj is not a member of a smart object, @p below + * must not be either. + * + * @see evas_object_layer_get() + * @see evas_object_layer_set() + * @see evas_object_stack_below() + * + * + * @param[in] below the object below which to stack + */ +EAPI void evas_object_stack_below(Evas_Object *obj, Evas_Object *below) EINA_ARG_NONNULL(2); + +/** + * + * Raise @p obj to the top of its layer. + * + * @p obj will, then, be the highest one in the layer it belongs + * to. Object on other layers won't get touched. + * + * @see evas_object_stack_above() + * @see evas_object_stack_below() + * @see evas_object_lower() + * + * + */ +EAPI void evas_object_raise(Evas_Object *obj); + +/** + * + * Stack @p obj immediately above @p above + * + * Objects, in a given canvas, are stacked in the order they get added + * to it. This means that, if they overlap, the highest ones will + * cover the lowest ones, in that order. This function is a way to + * change the stacking order for the objects. + * + * This function is intended to be used with objects belonging to + * the same layer in a given canvas, otherwise it will fail (and + * accomplish nothing). + * + * If you have smart objects on your canvas and @p obj is a member of + * one of them, then @p above must also be a member of the same + * smart object. + * + * Similarly, if @p obj is not a member of a smart object, @p above + * must not be either. + * + * @see evas_object_layer_get() + * @see evas_object_layer_set() + * @see evas_object_stack_below() + * + * + * @param[in] above the object above which to stack + */ +EAPI void evas_object_stack_above(Evas_Object *obj, Evas_Object *above) EINA_ARG_NONNULL(2); + +/** + * + * Lower @p obj to the bottom of its layer. + * + * @p obj will, then, be the lowest one in the layer it belongs + * to. Objects on other layers won't get touched. + * + * @see evas_object_stack_above() + * @see evas_object_stack_below() + * @see evas_object_raise() + * + * + */ +EAPI void evas_object_lower(Evas_Object *obj); + #include "canvas/evas_common_interface.eo.legacy.h" #include "canvas/evas_object.eo.legacy.h" diff --git a/src/lib/evas/canvas/evas_layer.c b/src/lib/evas/canvas/evas_layer.c index e1baf63d7b..3731078a04 100644 --- a/src/lib/evas/canvas/evas_layer.c +++ b/src/lib/evas/canvas/evas_layer.c @@ -178,8 +178,16 @@ _evas_object_layer_set_child(Evas_Object *eo_obj, Evas_Object *par, short l) /* public functions */ +EAPI void +evas_object_layer_set(Evas_Object *obj, short l) +{ + eo_do((Evas_Object *)obj, efl_gfx_stack_layer_set(l)); +} + EOLIAN void -_evas_object_layer_set(Eo *eo_obj, Evas_Object_Protected_Data *obj EINA_UNUSED, short l) +_evas_object_efl_gfx_stack_layer_set(Eo *eo_obj, + Evas_Object_Protected_Data *obj, + short l) { Evas *eo_e; @@ -236,8 +244,17 @@ _evas_object_layer_set(Eo *eo_obj, Evas_Object_Protected_Data *obj EINA_UNUSED, evas_object_inform_call_restack(eo_obj); } +EAPI short +evas_object_layer_get(const Evas_Object *obj) +{ + short ret; + + return eo_do_ret((Evas_Object *)obj, ret, efl_gfx_stack_layer_get()); +} + EOLIAN short -_evas_object_layer_get(Eo *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj) +_evas_object_efl_gfx_stack_layer_get(Eo *eo_obj EINA_UNUSED, + Evas_Object_Protected_Data *obj) { if (obj->smart.parent) { diff --git a/src/lib/evas/canvas/evas_object.eo b/src/lib/evas/canvas/evas_object.eo index d4823e31d3..5caf894d74 100644 --- a/src/lib/evas/canvas/evas_object.eo +++ b/src/lib/evas/canvas/evas_object.eo @@ -1,4 +1,4 @@ -abstract Evas.Object (Eo.Base, Evas.Common_Interface, Efl.Gfx.Base) +abstract Evas.Object (Eo.Base, Evas.Common_Interface, Efl.Gfx.Base, Efl.Gfx.Stack) { eo_prefix: evas_obj; data: Evas_Object_Protected_Data; @@ -381,39 +381,6 @@ abstract Evas.Object (Eo.Base, Evas.Common_Interface, Efl.Gfx.Base) Evas_Coord h; /*@ Integer to use as aspect height ratio term. */ } } - layer { - set { - /*@ - Sets the layer of its canvas that the given object will be part of. - - If you don't use this function, you'll be dealing with an @b unique - layer of objects, the default one. Additional layers are handy when - you don't want a set of objects to interfere with another set with - regard to @b stacking. Two layers are completely disjoint in that - matter. - - This is a low-level function, which you'd be using when something - should be always on top, for example. - - @warning Be careful, it doesn't make sense to change the layer of - smart objects' children. Smart objects have a layer of their own, - which should contain all their children objects. - - @see evas_object_layer_get() */ - } - get { - /*@ - Retrieves the layer of its canvas that the given object is part of. - - @return Number of its layer - - @see evas_object_layer_set() */ - } - values { - short l; /*@ The number of the layer to place the object on. - Must be between #EVAS_LAYER_MIN and #EVAS_LAYER_MAX. */ - } - } clip { set { /*@ @@ -1050,23 +1017,6 @@ abstract Evas.Object (Eo.Base, Evas.Common_Interface, Efl.Gfx.Base) return: Evas_Object * @warn_unused; } } - below { - get { - /*@ - Get the Evas object stacked right below @p obj - - @return the #Evas_Object directly below @p obj, if any, or @c NULL, - if none - - This function will traverse layers in its search, if there are - objects on layers below the one @p obj is placed at. - - @see evas_object_layer_get() - @see evas_object_layer_set() - @see evas_object_below_get() */ - return: Evas_Object * @warn_unused; - } - } clipees { get { /*@ @@ -1121,23 +1071,6 @@ abstract Evas.Object (Eo.Base, Evas.Common_Interface, Efl.Gfx.Base) return: Evas_Object * @warn_unused; } } - above { - get { - /*@ - Get the Evas object stacked right above @p obj - - @return the #Evas_Object directly above @p obj, if any, or @c NULL, - if none - - This function will traverse layers in its search, if there are - objects on layers above the one @p obj is placed at. - - @see evas_object_layer_get() - @see evas_object_layer_set() - @see evas_object_below_get() */ - return: Evas_Object * @warn_unused; - } - } size_hint_display_mode { get { /*@ @@ -1221,74 +1154,6 @@ abstract Evas.Object (Eo.Base, Evas.Common_Interface, Efl.Gfx.Base) receiving the @p keyname events. */ } } - stack_below { - /*@ - Stack @p obj immediately below @p below - - Objects, in a given canvas, are stacked in the order they get added - to it. This means that, if they overlap, the highest ones will - cover the lowest ones, in that order. This function is a way to - change the stacking order for the objects. - - This function is intended to be used with objects belonging to - the same layer in a given canvas, otherwise it will fail (and - accomplish nothing). - - If you have smart objects on your canvas and @p obj is a member of - one of them, then @p below must also be a member of the same - smart object. - - Similarly, if @p obj is not a member of a smart object, @p below - must not be either. - - @see evas_object_layer_get() - @see evas_object_layer_set() - @see evas_object_stack_below() */ - - params { - @in Evas_Object *below @nonull; /*@ the object below which to stack */ - } - } - raise { - /*@ - Raise @p obj to the top of its layer. - - @p obj will, then, be the highest one in the layer it belongs - to. Object on other layers won't get touched. - - @see evas_object_stack_above() - @see evas_object_stack_below() - @see evas_object_lower() */ - - } - stack_above { - /*@ - Stack @p obj immediately above @p above - - Objects, in a given canvas, are stacked in the order they get added - to it. This means that, if they overlap, the highest ones will - cover the lowest ones, in that order. This function is a way to - change the stacking order for the objects. - - This function is intended to be used with objects belonging to - the same layer in a given canvas, otherwise it will fail (and - accomplish nothing). - - If you have smart objects on your canvas and @p obj is a member of - one of them, then @p above must also be a member of the same - smart object. - - Similarly, if @p obj is not a member of a smart object, @p above - must not be either. - - @see evas_object_layer_get() - @see evas_object_layer_set() - @see evas_object_stack_below() */ - - params { - @in Evas_Object *above @nonull; /*@ the object above which to stack */ - } - } smart_type_check @const { /*@ Checks whether a given smart object or any of its smart object @@ -1367,18 +1232,6 @@ abstract Evas.Object (Eo.Base, Evas.Common_Interface, Efl.Gfx.Base) present to trigger the event. */ } } - lower { - /*@ - Lower @p obj to the bottom of its layer. - - @p obj will, then, be the lowest one in the layer it belongs - to. Objects on other layers won't get touched. - - @see evas_object_stack_above() - @see evas_object_stack_below() - @see evas_object_raise() */ - - } clip_unset { /*@ Disable/cease clipping on a clipped @p obj object. @@ -1441,6 +1294,14 @@ abstract Evas.Object (Eo.Base, Evas.Common_Interface, Efl.Gfx.Base) Efl.Gfx.Base.color.get; Efl.Gfx.Base.size.set; Efl.Gfx.Base.size.get; + Efl.Gfx.Stack.layer.set; + Efl.Gfx.Stack.layer.get; + Efl.Gfx.Stack.below.get; + Efl.Gfx.Stack.above.get; + Efl.Gfx.Stack.stack_below; + Efl.Gfx.Stack.stack_above; + Efl.Gfx.Stack.raise; + Efl.Gfx.Stack.lower; } events { mouse,in; /*@ Mouse In Event */ diff --git a/src/lib/evas/canvas/evas_object_main.c b/src/lib/evas/canvas/evas_object_main.c index f45f91fb2c..4b44830020 100644 --- a/src/lib/evas/canvas/evas_object_main.c +++ b/src/lib/evas/canvas/evas_object_main.c @@ -1591,7 +1591,7 @@ _evas_object_eo_base_dbg_info_get(Eo *eo_obj, Evas_Object_Protected_Data *obj EI eo_do(eo_obj, visible = efl_gfx_visible_get(), - layer = evas_obj_layer_get(), + layer = efl_gfx_stack_layer_get(), name = evas_obj_name_get(), efl_gfx_position_get(&x, &y), efl_gfx_size_get(&w, &h), diff --git a/src/lib/evas/canvas/evas_stack.c b/src/lib/evas/canvas/evas_stack.c index 44508da022..84fa6d8a51 100644 --- a/src/lib/evas/canvas/evas_stack.c +++ b/src/lib/evas/canvas/evas_stack.c @@ -37,8 +37,14 @@ evas_object_below_get_internal(const Evas_Object_Protected_Data *obj) return NULL; } +EAPI void +evas_object_raise(Evas_Object *obj) +{ + eo_do((Evas_Object *)obj, efl_gfx_stack_raise()); +} + EOLIAN void -_evas_object_raise(Eo *eo_obj, Evas_Object_Protected_Data *obj) +_evas_object_efl_gfx_stack_raise(Eo *eo_obj, Evas_Object_Protected_Data *obj) { evas_object_async_block(obj); if (evas_object_intercept_call_raise(eo_obj, obj)) return; @@ -84,8 +90,14 @@ _evas_object_raise(Eo *eo_obj, Evas_Object_Protected_Data *obj) } } +EAPI void +evas_object_lower(Evas_Object *obj) +{ + eo_do((Evas_Object *)obj, efl_gfx_stack_lower()); +} + EOLIAN void -_evas_object_lower(Eo *eo_obj, Evas_Object_Protected_Data *obj) +_evas_object_efl_gfx_stack_lower(Eo *eo_obj, Evas_Object_Protected_Data *obj) { evas_object_async_block(obj); if (evas_object_intercept_call_lower(eo_obj, obj)) return; @@ -132,8 +144,14 @@ _evas_object_lower(Eo *eo_obj, Evas_Object_Protected_Data *obj) } } +EAPI void +evas_object_stack_above(Evas_Object *obj, Evas_Object *above) +{ + eo_do((Evas_Object *)obj, efl_gfx_stack_above(above)); +} + EOLIAN void -_evas_object_stack_above(Eo *eo_obj, Evas_Object_Protected_Data *obj, Evas_Object *eo_above) +_evas_object_efl_gfx_stack_stack_above(Eo *eo_obj, Evas_Object_Protected_Data *obj, Efl_Gfx_Stack *eo_above) { evas_object_async_block(obj); if (!eo_above) @@ -208,8 +226,14 @@ _evas_object_stack_above(Eo *eo_obj, Evas_Object_Protected_Data *obj, Evas_Objec } } +EAPI void +evas_object_stack_below(Evas_Object *obj, Evas_Object *below) +{ + eo_do((Evas_Object *)obj, efl_gfx_stack_below(below)); +} + EOLIAN void -_evas_object_stack_below(Eo *eo_obj, Evas_Object_Protected_Data *obj, Evas_Object *eo_below) +_evas_object_efl_gfx_stack_stack_below(Eo *eo_obj, Evas_Object_Protected_Data *obj, Efl_Gfx_Stack *eo_below) { evas_object_async_block(obj); if (!eo_below) @@ -284,8 +308,17 @@ _evas_object_stack_below(Eo *eo_obj, Evas_Object_Protected_Data *obj, Evas_Objec } } -EOLIAN Evas_Object * -_evas_object_above_get(Eo *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj) +EAPI Evas_Object * +evas_object_above_get(const Evas_Object *obj) +{ + Evas_Object *ret; + + return eo_do_ret((Evas_Object *)obj, ret, efl_gfx_stack_above_get()); +} + +EOLIAN Efl_Gfx_Stack * +_evas_object_efl_gfx_stack_above_get(Eo *eo_obj EINA_UNUSED, + Evas_Object_Protected_Data *obj) { if (obj->smart.parent) { @@ -306,8 +339,17 @@ _evas_object_above_get(Eo *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj) return NULL; } -EOLIAN Evas_Object * -_evas_object_below_get(Eo *eo_obj EINA_UNUSED, Evas_Object_Protected_Data *obj) +EAPI Evas_Object * +evas_object_below_get(const Evas_Object *obj) +{ + Evas_Object *ret; + + return eo_do_ret((Evas_Object *)obj, ret, efl_gfx_stack_below_get()); +} + +EOLIAN Efl_Gfx_Stack * +_evas_object_efl_gfx_stack_below_get(Eo *eo_obj EINA_UNUSED, + Evas_Object_Protected_Data *obj) { if (obj->smart.parent) { From a38c037953d64325543d116714b94e8ca081ece1 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:23:23 +0200 Subject: [PATCH 099/251] evas: make Evas.VG_Node inherit from Efl.Gfx.Stack. --- src/lib/evas/canvas/evas_vg_node.c | 30 ++++++++---- src/lib/evas/canvas/evas_vg_node.eo | 71 +++-------------------------- 2 files changed, 29 insertions(+), 72 deletions(-) diff --git a/src/lib/evas/canvas/evas_vg_node.c b/src/lib/evas/canvas/evas_vg_node.c index fbe0a60a9f..86b70f363c 100644 --- a/src/lib/evas/canvas/evas_vg_node.c +++ b/src/lib/evas/canvas/evas_vg_node.c @@ -222,7 +222,7 @@ _evas_vg_node_eo_base_parent_set(Eo *obj, } void -_evas_vg_node_raise(Eo *obj, Evas_VG_Node_Data *pd EINA_UNUSED) +_evas_vg_node_efl_gfx_stack_raise(Eo *obj, Evas_VG_Node_Data *pd EINA_UNUSED) { Evas_VG_Container_Data *cd; Eina_List *lookup, *next; @@ -249,9 +249,9 @@ _evas_vg_node_raise(Eo *obj, Evas_VG_Node_Data *pd EINA_UNUSED) } void -_evas_vg_node_stack_above(Eo *obj, - Evas_VG_Node_Data *pd EINA_UNUSED, - Evas_VG_Node *above) +_evas_vg_node_efl_gfx_stack_stack_above(Eo *obj, + Evas_VG_Node_Data *pd EINA_UNUSED, + Efl_Gfx_Stack *above) { Evas_VG_Container_Data *cd; Eina_List *lookup, *ref; @@ -278,9 +278,9 @@ _evas_vg_node_stack_above(Eo *obj, } void -_evas_vg_node_stack_below(Eo *obj, - Evas_VG_Node_Data *pd EINA_UNUSED, - Evas_Object *below) +_evas_vg_node_efl_gfx_stack_stack_below(Eo *obj, + Evas_VG_Node_Data *pd EINA_UNUSED, + Efl_Gfx_Stack *below) { Evas_VG_Container_Data *cd; Eina_List *lookup, *ref; @@ -307,7 +307,7 @@ _evas_vg_node_stack_below(Eo *obj, } void -_evas_vg_node_lower(Eo *obj, Evas_VG_Node_Data *pd EINA_UNUSED) +_evas_vg_node_efl_gfx_stack_lower(Eo *obj, Evas_VG_Node_Data *pd EINA_UNUSED) { Evas_VG_Container_Data *cd; Eina_List *lookup, *prev; @@ -333,6 +333,20 @@ _evas_vg_node_lower(Eo *obj, Evas_VG_Node_Data *pd EINA_UNUSED) eo_error_set(obj); } +Efl_Gfx_Stack * +_evas_vg_node_efl_gfx_stack_below_get(Eo *obj, Evas_VG_Node_Data *pd) +{ + // FIXME: need to implement bound_get + return NULL; +} + +Efl_Gfx_Stack * +_evas_vg_node_efl_gfx_stack_above_get(Eo *obj, Evas_VG_Node_Data *pd) +{ + // FIXME: need to implement bound_get + return NULL; +} + Eina_Bool _evas_vg_node_original_bound_get(Eo *obj, Evas_VG_Node_Data *pd, diff --git a/src/lib/evas/canvas/evas_vg_node.eo b/src/lib/evas/canvas/evas_vg_node.eo index 108c2eb2c7..d89a1cd7af 100644 --- a/src/lib/evas/canvas/evas_vg_node.eo +++ b/src/lib/evas/canvas/evas_vg_node.eo @@ -1,4 +1,4 @@ -abstract Evas.VG_Node (Eo.Base, Efl.Gfx.Base) +abstract Evas.VG_Node (Eo.Base, Efl.Gfx.Base, Efl.Gfx.Stack) { eo_prefix: evas_vg_node; legacy_prefix: null; @@ -63,69 +63,6 @@ abstract Evas.VG_Node (Eo.Base, Efl.Gfx.Base) @out Eina_Rectangle r; } } - - raise { - /*@ - Raise @p obj to the top of its layer. - - @p obj will, then, be the highest one in the layer it belongs - to. Object on other layers won't get touched. - - @see evas_vg_node_stack_above() - @see evas_vg_node_stack_below() - @see evas_vg_node_lower() */ - } - stack_above { - /*@ - Stack @p obj immediately above @p above - - Objects, in a given Evas_VG_Container, are stacked in the order they get added - to it. This means that, if they overlap, the highest ones will - cover the lowest ones, in that order. This function is a way to - change the stacking order for the objects. - - This function is intended to be used with objects belonging to - the same container, otherwise it will fail (and - accomplish nothing). - - @see evas_vg_node_stack_below() */ - - params { - @in Evas_VG_Node *above @nonull; /*@ the object above which to stack */ - } - } - stack_below { - /*@ - Stack @p obj immediately below @p below - - Objects, in a given container, are stacked in the order they get added - to it. This means that, if they overlap, the highest ones will - cover the lowest ones, in that order. This function is a way to - change the stacking order for the objects. - - This function is intended to be used with objects belonging to - the same container, otherwise it will fail (and - accomplish nothing). - - @see evas_vg_node_layer_get() - @see evas_vg_node_layer_set() - @see evas_vg_node_stack_below() */ - - params { - @in Evas_Object *below @nonull; /*@ the object below which to stack */ - } - } - lower { - /*@ - Lower @p obj to the bottom of its layer. - - @p obj will, then, be the lowest one in the layer it belongs - to. Objects on other layers won't get touched. - - @see evas_vg_node_stack_above() - @see evas_vg_node_stack_below() - @see evas_vg_node_raise() */ - } } implements { Eo.Base.parent.set; @@ -137,6 +74,12 @@ abstract Evas.VG_Node (Eo.Base, Efl.Gfx.Base) Efl.Gfx.Base.size.get; Efl.Gfx.Base.position.set; Efl.Gfx.Base.position.get; + Efl.Gfx.Stack.below.get; + Efl.Gfx.Stack.above.get; + Efl.Gfx.Stack.stack_below; + Efl.Gfx.Stack.stack_above; + Efl.Gfx.Stack.raise; + Efl.Gfx.Stack.lower; @virtual .bound_get; } } \ No newline at end of file From 7ba7ed4a1cc06ad1f65ef5ec64aa820c7d53f0f3 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:23:24 +0200 Subject: [PATCH 100/251] efl: add Efl.Gfx.Fill and migrate Evas.Image to it. --- src/Makefile_Efl.am | 1 + src/Makefile_Efl_Cxx.am | 1 + src/lib/edje/edje_calc.c | 14 ++-- src/lib/efl/Efl.h | 15 ++++ src/lib/efl/interfaces/efl_gfx_fill.eo | 72 ++++++++++++++++++ src/lib/efl/interfaces/efl_interfaces_main.c | 1 + src/lib/evas/Evas_Common.h | 16 ++-- src/lib/evas/Evas_Legacy.h | 78 +++++++++++++++++++- src/lib/evas/canvas/evas_image.eo | 73 ++---------------- src/lib/evas/canvas/evas_object_image.c | 44 +++++++++-- 10 files changed, 225 insertions(+), 90 deletions(-) create mode 100644 src/lib/efl/interfaces/efl_gfx_fill.eo diff --git a/src/Makefile_Efl.am b/src/Makefile_Efl.am index 6423b6a43d..4791e0d2d4 100644 --- a/src/Makefile_Efl.am +++ b/src/Makefile_Efl.am @@ -7,6 +7,7 @@ efl_eolian_files = \ lib/efl/interfaces/efl_text_properties.eo \ lib/efl/interfaces/efl_gfx_base.eo \ lib/efl/interfaces/efl_gfx_stack.eo \ + lib/efl/interfaces/efl_gfx_fill.eo \ lib/efl/interfaces/efl_gfx_shape.eo \ lib/efl/interfaces/efl_gfx_gradient.eo \ lib/efl/interfaces/efl_gfx_gradient_linear.eo \ diff --git a/src/Makefile_Efl_Cxx.am b/src/Makefile_Efl_Cxx.am index bf06f781f1..9fdbdfc32c 100644 --- a/src/Makefile_Efl_Cxx.am +++ b/src/Makefile_Efl_Cxx.am @@ -11,6 +11,7 @@ generated_efl_cxx_bindings = \ lib/efl/interfaces/efl_text_properties.eo.hh \ lib/efl/interfaces/efl_gfx_base.eo.hh \ lib/efl/interfaces/efl_gfx_stack.eo.hh \ + lib/efl/interfaces/efl_gfx_fill.eo.hh \ lib/efl/interfaces/efl_gfx_shape.eo.hh \ lib/efl/interfaces/efl_gfx_gradient.eo.hh \ lib/efl/interfaces/efl_gfx_gradient_linear.eo.hh \ diff --git a/src/lib/edje/edje_calc.c b/src/lib/edje/edje_calc.c index 570e96833f..58f7633a99 100644 --- a/src/lib/edje/edje_calc.c +++ b/src/lib/edje/edje_calc.c @@ -2686,10 +2686,10 @@ _edje_proxy_recalc_apply(Edje *ed, Edje_Real_Part *ep, Edje_Calc_Params *p3, Edj } eo_do(ep->object, - evas_obj_image_fill_set(p3->type.common.fill.x, - p3->type.common.fill.y, - p3->type.common.fill.w, - p3->type.common.fill.h), + efl_gfx_fill_set(p3->type.common.fill.x, + p3->type.common.fill.y, + p3->type.common.fill.w, + p3->type.common.fill.h), efl_image_smooth_scale_set(p3->smooth), evas_obj_image_source_visible_set(chosen_desc->proxy.source_visible), evas_obj_image_source_clip_set(chosen_desc->proxy.source_clip)); @@ -2727,9 +2727,9 @@ _edje_image_recalc_apply(Edje *ed, Edje_Real_Part *ep, Edje_Calc_Params *p3, Edj } eo_do(ep->object, - evas_obj_image_fill_set(p3->type.common.fill.x, p3->type.common.fill.y, - p3->type.common.fill.w, p3->type.common.fill.h), - efl_image_smooth_scale_set(p3->smooth)); + efl_gfx_fill_set(p3->type.common.fill.x, p3->type.common.fill.y, + p3->type.common.fill.w, p3->type.common.fill.h), + efl_image_smooth_scale_set(p3->smooth)); if (chosen_desc->image.border.scale) { if (p3->type.common.spec.image.border_scale_by > FROM_DOUBLE(0.0)) diff --git a/src/lib/efl/Efl.h b/src/lib/efl/Efl.h index 5332ff5619..4fb67f378d 100644 --- a/src/lib/efl/Efl.h +++ b/src/lib/efl/Efl.h @@ -111,6 +111,20 @@ typedef enum _Efl_Gfx_Gradient_Spread EFL_GFX_GRADIENT_SPREAD_LAST } Efl_Gfx_Gradient_Spread; +/** + * Type defining how an image content get filled. + * @since 1.13 + */ +typedef enum _Efl_Gfx_Fill_Spread +{ + EFL_GFX_FILL_REFLECT = 0, /**< image fill tiling mode - tiling reflects */ + EFL_GFX_FILL_REPEAT = 1, /**< tiling repeats */ + EFL_GFX_FILL_RESTRICT = 2, /**< tiling clamps - range offset ignored */ + EFL_GFX_FILL_RESTRICT_REFLECT = 3, /**< tiling clamps and any range offset reflects */ + EFL_GFX_FILL_RESTRICT_REPEAT = 4, /**< tiling clamps and any range offset repeats */ + EFL_GFX_FILL_PAD = 5 /**< tiling extends with end values */ +} Efl_Gfx_Fill_Spread; + #ifdef EFL_BETA_API_SUPPORT /* Interfaces */ @@ -125,6 +139,7 @@ typedef enum _Efl_Gfx_Gradient_Spread #include "interfaces/efl_gfx_base.eo.h" #include "interfaces/efl_gfx_stack.eo.h" +#include "interfaces/efl_gfx_fill.eo.h" #include "interfaces/efl_gfx_shape.eo.h" #include "interfaces/efl_gfx_gradient.eo.h" #include "interfaces/efl_gfx_gradient_linear.eo.h" diff --git a/src/lib/efl/interfaces/efl_gfx_fill.eo b/src/lib/efl/interfaces/efl_gfx_fill.eo new file mode 100644 index 0000000000..1ce4dd8b57 --- /dev/null +++ b/src/lib/efl/interfaces/efl_gfx_fill.eo @@ -0,0 +1,72 @@ +interface Efl.Gfx.Fill { + legacy_prefix: null; + properties { + fill_spread { + set { + /*@ + Sets the tiling mode for the given evas image object's fill. + EFL_GFX_FILL_RESTRICT, or EFL_GFX_FILL_PAD. */ + } + get { + /*@ + Retrieves the spread (tiling mode) for the given image object's + fill. + + @return The current spread mode of the image object. */ + } + values { + Efl_Gfx_Fill_Spread spread; /*@ One of EVAS_TEXTURE_REFLECT, EVAS_TEXTURE_REPEAT, */ + } + } + fill { + set { + /*@ + Set how to fill an image object's drawing rectangle given the + (real) image bound to it. + + Note that if @p w or @p h are smaller than the dimensions of + @p obj, the displayed image will be @b tiled around the object's + area. To have only one copy of the bound image drawn, @p x and @p y + must be 0 and @p w and @p h need to be the exact width and height + of the image object itself, respectively. + + See the following image to better understand the effects of this + call. On this diagram, both image object and original image source + have @c a x @c a dimensions and the image itself is a circle, with + empty space around it: + + @image html image-fill.png + @image rtf image-fill.png + @image latex image-fill.eps + + @warning The default values for the fill parameters are @p x = 0, + @p y = 0, @p w = 0 and @p h = 0. Thus, if you're not using the + evas_object_image_filled_add() helper and want your image + displayed, you'll have to set valid values with this function on + your object. + + @note evas_object_image_filled_set() is a helper function which + will @b override the values set here automatically, for you, in a + given way. */ + } + get { + /*@ + Retrieve how an image object is to fill its drawing rectangle, + given the (real) image bound to it. + + @note Use @c NULL pointers on the fill components you're not + interested in: they'll be ignored by the function. + + See @ref evas_object_image_fill_set() for more details. */ + } + values { + int x; /*@ The x coordinate (from the top left corner of the bound + image) to start drawing from. */ + int y; /*@ The y coordinate (from the top left corner of the bound + image) to start drawing from. */ + int w; /*@ The width the bound image will be displayed at. */ + int h; /*@ The height the bound image will be displayed at. */ + } + } + } +} diff --git a/src/lib/efl/interfaces/efl_interfaces_main.c b/src/lib/efl/interfaces/efl_interfaces_main.c index 7a91b98b6b..938b161866 100644 --- a/src/lib/efl/interfaces/efl_interfaces_main.c +++ b/src/lib/efl/interfaces/efl_interfaces_main.c @@ -13,6 +13,7 @@ #include "interfaces/efl_gfx_base.eo.c" #include "interfaces/efl_gfx_stack.eo.c" +#include "interfaces/efl_gfx_fill.eo.c" #include "interfaces/efl_gfx_shape.eo.c" #include "interfaces/efl_gfx_gradient.eo.c" #include "interfaces/efl_gfx_gradient_linear.eo.c" diff --git a/src/lib/evas/Evas_Common.h b/src/lib/evas/Evas_Common.h index 0a93f745d3..3a9633f617 100644 --- a/src/lib/evas/Evas_Common.h +++ b/src/lib/evas/Evas_Common.h @@ -432,15 +432,13 @@ typedef enum _Evas_Alloc_Error EVAS_ALLOC_ERROR_RECOVERED = 2 /**< Allocation succeeded, but extra memory had to be found by freeing up speculative resources */ } Evas_Alloc_Error; /**< Possible allocation errors returned by evas_alloc_error() */ -typedef enum _Evas_Fill_Spread -{ - EVAS_TEXTURE_REFLECT = 0, /**< image fill tiling mode - tiling reflects */ - EVAS_TEXTURE_REPEAT = 1, /**< tiling repeats */ - EVAS_TEXTURE_RESTRICT = 2, /**< tiling clamps - range offset ignored */ - EVAS_TEXTURE_RESTRICT_REFLECT = 3, /**< tiling clamps and any range offset reflects */ - EVAS_TEXTURE_RESTRICT_REPEAT = 4, /**< tiling clamps and any range offset repeats */ - EVAS_TEXTURE_PAD = 5 /**< tiling extends with end values */ -} Evas_Fill_Spread; /**< Fill types used for evas_object_image_fill_spread_set() */ +typedef Efl_Gfx_Fill_Spread Evas_Fill_Spread; +#define EVAS_TEXTURE_REFLECT EFL_GFX_FILL_REFLECT +#define EVAS_TEXTURE_REPEAT EFL_GFX_FILL_REPEAT +#define EVAS_TEXTURE_RESTRICT EFL_GFX_FILL_RESTRICT +#define EVAS_TEXTURE_RESTRICT_REFLECT EFL_GFX_FILL_RESTRICT_REFLECT +#define EVAS_TEXTURE_RESTRICT_REPEAT EFL_GFX_FILL_RESTRICT_REPEAT +#define EVAS_TEXTURE_PAD EFL_GFX_FILL_PAD typedef enum _Evas_Pixel_Import_Pixel_Format { diff --git a/src/lib/evas/Evas_Legacy.h b/src/lib/evas/Evas_Legacy.h index 45f918846d..a8b1c9f758 100644 --- a/src/lib/evas/Evas_Legacy.h +++ b/src/lib/evas/Evas_Legacy.h @@ -803,7 +803,6 @@ EAPI void evas_object_stack_above(Evas_Object *obj, Evas_Object *above) EINA_ARG */ EAPI void evas_object_lower(Evas_Object *obj); - #include "canvas/evas_common_interface.eo.legacy.h" #include "canvas/evas_object.eo.legacy.h" @@ -1990,6 +1989,83 @@ EAPI void evas_object_image_smooth_scale_set(Eo *obj, Eina_Bool smooth_scale); */ EAPI Eina_Bool evas_object_image_smooth_scale_get(const Eo *obj); +/** + * + * Sets the tiling mode for the given evas image object's fill. + * EVAS_TEXTURE_RESTRICT, or EVAS_TEXTURE_PAD. + * + * @param[in] spread One of EVAS_TEXTURE_REFLECT, EVAS_TEXTURE_REPEAT, + */ +EAPI void evas_object_image_fill_spread_set(Evas_Object *obj, Evas_Fill_Spread spread); + +/** + * + * Retrieves the spread (tiling mode) for the given image object's + * fill. + * + * @return The current spread mode of the image object. + * + */ +EAPI Evas_Fill_Spread evas_object_image_fill_spread_get(const Evas_Object *obj); + +/** + * + * Set how to fill an image object's drawing rectangle given the + * (real) image bound to it. + * + * Note that if @p w or @p h are smaller than the dimensions of + * @p obj, the displayed image will be @b tiled around the object's + * area. To have only one copy of the bound image drawn, @p x and @p y + * must be 0 and @p w and @p h need to be the exact width and height + * of the image object itself, respectively. + * + * See the following image to better understand the effects of this + * call. On this diagram, both image object and original image source + * have @c a x @c a dimensions and the image itself is a circle, with + * empty space around it: + * + * @image html image-fill.png + * @image rtf image-fill.png + * @image latex image-fill.eps + * + * @warning The default values for the fill parameters are @p x = 0, + * @p y = 0, @p w = 0 and @p h = 0. Thus, if you're not using the + * evas_object_image_filled_add() helper and want your image + * displayed, you'll have to set valid values with this function on + * your object. + * + * @note evas_object_image_filled_set() is a helper function which + * will @b override the values set here automatically, for you, in a + * given way. + * + * @param[in] x The x coordinate (from the top left corner of the bound +image) to start drawing from. + * @param[in] y The y coordinate (from the top left corner of the bound +image) to start drawing from. + * @param[in] w The width the bound image will be displayed at. + * @param[in] h The height the bound image will be displayed at. + */ +EAPI void evas_object_image_fill_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h); + +/** + * + * Retrieve how an image object is to fill its drawing rectangle, + * given the (real) image bound to it. + * + * @note Use @c NULL pointers on the fill components you're not + * interested in: they'll be ignored by the function. + * + * See @ref evas_object_image_fill_set() for more details. + * + * @param[out] x The x coordinate (from the top left corner of the bound +image) to start drawing from. + * @param[out] y The y coordinate (from the top left corner of the bound +image) to start drawing from. + * @param[out] w The width the bound image will be displayed at. + * @param[out] h The height the bound image will be displayed at. + */ +EAPI void evas_object_image_fill_get(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h); + #include "canvas/evas_image.eo.legacy.h" /** diff --git a/src/lib/evas/canvas/evas_image.eo b/src/lib/evas/canvas/evas_image.eo index 7071d834e2..7e44576319 100644 --- a/src/lib/evas/canvas/evas_image.eo +++ b/src/lib/evas/canvas/evas_image.eo @@ -1,4 +1,4 @@ -class Evas.Image (Evas.Object, Efl.File, Efl.Image) +class Evas.Image (Evas.Object, Efl.File, Efl.Image, Efl.Gfx.Fill) { legacy_prefix: evas_object_image; eo_prefix: evas_obj_image; @@ -362,23 +362,6 @@ class Evas.Image (Evas.Object, Efl.File, Efl.Image) bool enable; /*@ @c EINA_TRUE means that it should honor the orientation information */ } } - fill_spread { - set { - /*@ - Sets the tiling mode for the given evas image object's fill. - EVAS_TEXTURE_RESTRICT, or EVAS_TEXTURE_PAD. */ - } - get { - /*@ - Retrieves the spread (tiling mode) for the given image object's - fill. - - @return The current spread mode of the image object. */ - } - values { - Evas_Fill_Spread spread; /*@ One of EVAS_TEXTURE_REFLECT, EVAS_TEXTURE_REPEAT, */ - } - } border_center_fill { set { /*@ @@ -474,56 +457,6 @@ class Evas.Image (Evas.Object, Efl.File, Efl.Image) otherwise. */ } } - fill { - set { - /*@ - Set how to fill an image object's drawing rectangle given the - (real) image bound to it. - - Note that if @p w or @p h are smaller than the dimensions of - @p obj, the displayed image will be @b tiled around the object's - area. To have only one copy of the bound image drawn, @p x and @p y - must be 0 and @p w and @p h need to be the exact width and height - of the image object itself, respectively. - - See the following image to better understand the effects of this - call. On this diagram, both image object and original image source - have @c a x @c a dimensions and the image itself is a circle, with - empty space around it: - - @image html image-fill.png - @image rtf image-fill.png - @image latex image-fill.eps - - @warning The default values for the fill parameters are @p x = 0, - @p y = 0, @p w = 0 and @p h = 0. Thus, if you're not using the - evas_object_image_filled_add() helper and want your image - displayed, you'll have to set valid values with this function on - your object. - - @note evas_object_image_filled_set() is a helper function which - will @b override the values set here automatically, for you, in a - given way. */ - } - get { - /*@ - Retrieve how an image object is to fill its drawing rectangle, - given the (real) image bound to it. - - @note Use @c NULL pointers on the fill components you're not - interested in: they'll be ignored by the function. - - See @ref evas_object_image_fill_set() for more details. */ - } - values { - Evas_Coord x; /*@ The x coordinate (from the top left corner of the bound - image) to start drawing from. */ - Evas_Coord y; /*@ The y coordinate (from the top left corner of the bound - image) to start drawing from. */ - Evas_Coord w; /*@ The width the bound image will be displayed at. */ - Evas_Coord h; /*@ The height the bound image will be displayed at. */ - } - } native_surface { set { /*@ @@ -1073,5 +1006,9 @@ class Evas.Image (Evas.Object, Efl.File, Efl.Image) Efl.Image.load_size.get; Efl.Image.smooth_scale.set; Efl.Image.smooth_scale.get; + Efl.Gfx.Fill.fill_spread.set; + Efl.Gfx.Fill.fill_spread.get; + Efl.Gfx.Fill.fill.set; + Efl.Gfx.Fill.fill.get; } } diff --git a/src/lib/evas/canvas/evas_object_image.c b/src/lib/evas/canvas/evas_object_image.c index eaf17d6fd4..54fb8f647d 100644 --- a/src/lib/evas/canvas/evas_object_image.c +++ b/src/lib/evas/canvas/evas_object_image.c @@ -978,8 +978,17 @@ _evas_image_border_scale_get(Eo *eo_obj EINA_UNUSED, Evas_Image_Data *o) return o->cur->border.scale; } +EAPI void +evas_object_image_fill_set(Evas_Image *obj, + Evas_Coord x, Evas_Coord y, + Evas_Coord w, Evas_Coord h) +{ + eo_do((Evas_Image *)obj, efl_gfx_fill_set(x, y, w, h)); +} + EOLIAN static void -_evas_image_fill_set(Eo *eo_obj, Evas_Image_Data *o, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h) +_evas_image_efl_gfx_fill_fill_set(Eo *eo_obj, Evas_Image_Data *o, + int x, int y, int w, int h) { Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS); @@ -1008,8 +1017,17 @@ _evas_image_fill_set(Eo *eo_obj, Evas_Image_Data *o, Evas_Coord x, Evas_Coord y, evas_object_change(eo_obj, obj); } +EAPI void +evas_object_image_fill_get(const Evas_Image *obj, + Evas_Coord *x, Evas_Coord *y, + Evas_Coord *w, Evas_Coord *h) +{ + eo_do((Evas_Image *)obj, efl_gfx_fill_get(x, y, w, h)); +} + EOLIAN static void -_evas_image_fill_get(Eo *eo_obj EINA_UNUSED, Evas_Image_Data *o, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h) +_evas_image_efl_gfx_fill_fill_get(Eo *eo_obj EINA_UNUSED, Evas_Image_Data *o, + int *x, int *y, int *w, int *h) { if (x) *x = o->cur->fill.x; if (y) *y = o->cur->fill.y; @@ -1017,8 +1035,15 @@ _evas_image_fill_get(Eo *eo_obj EINA_UNUSED, Evas_Image_Data *o, Evas_Coord *x, if (h) *h = o->cur->fill.h; } +EAPI void +evas_object_image_fill_spread_set(Evas_Image *obj, Evas_Fill_Spread spread) +{ + eo_do((Evas_Image *)obj, efl_gfx_fill_spread_set(spread)); +} + EOLIAN static void -_evas_image_fill_spread_set(Eo *eo_obj, Evas_Image_Data *o, Evas_Fill_Spread spread) +_evas_image_efl_gfx_fill_fill_spread_set(Eo *eo_obj, Evas_Image_Data *o, + Efl_Gfx_Fill_Spread spread) { Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS); @@ -1033,8 +1058,17 @@ _evas_image_fill_spread_set(Eo *eo_obj, Evas_Image_Data *o, Evas_Fill_Spread spr evas_object_change(eo_obj, obj); } -EOLIAN static Evas_Fill_Spread -_evas_image_fill_spread_get(Eo *eo_obj EINA_UNUSED, Evas_Image_Data *o) +EAPI Evas_Fill_Spread +evas_object_image_fill_spread_get(const Evas_Image *obj) +{ + Evas_Fill_Spread ret; + + return eo_do_ret((Evas_Image *)obj, ret, efl_gfx_fill_spread_get()); +} + +EOLIAN static Efl_Gfx_Fill_Spread +_evas_image_efl_gfx_fill_fill_spread_get(Eo *eo_obj EINA_UNUSED, + Evas_Image_Data *o) { return (Evas_Fill_Spread)o->cur->spread;; } From 5f2527f791393ad30c2c19bbcb83dc68ef1872f8 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:23:25 +0200 Subject: [PATCH 101/251] evas: move Evas.VG to use Efl.Gfx.Fill. --- src/lib/evas/canvas/evas_object_vg.c | 8 ++-- src/lib/evas/canvas/evas_vg.eo | 56 ++-------------------------- 2 files changed, 8 insertions(+), 56 deletions(-) diff --git a/src/lib/evas/canvas/evas_object_vg.c b/src/lib/evas/canvas/evas_object_vg.c index c6bc95a05c..ed4fe0446f 100644 --- a/src/lib/evas/canvas/evas_object_vg.c +++ b/src/lib/evas/canvas/evas_object_vg.c @@ -441,8 +441,8 @@ _evas_vg_size_set(Eo *obj EINA_UNUSED, Evas_VG_Data *pd, } void -_evas_vg_fill_set(Eo *obj EINA_UNUSED, Evas_VG_Data *pd, - Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h) +_evas_vg_efl_gfx_fill_fill_set(Eo *obj EINA_UNUSED, Evas_VG_Data *pd, + int x, int y, int w, int h) { pd->fill.x = x; pd->fill.y = y; @@ -451,8 +451,8 @@ _evas_vg_fill_set(Eo *obj EINA_UNUSED, Evas_VG_Data *pd, } void -_evas_vg_fill_get(Eo *obj EINA_UNUSED, Evas_VG_Data *pd, - Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h) +_evas_vg_efl_gfx_fill_fill_get(Eo *obj EINA_UNUSED, Evas_VG_Data *pd, + int *x, int *y, int *w, int *h) { if (x) *x = pd->fill.x; if (y) *y = pd->fill.y; diff --git a/src/lib/evas/canvas/evas_vg.eo b/src/lib/evas/canvas/evas_vg.eo index 24037d2384..33e3daa0ef 100644 --- a/src/lib/evas/canvas/evas_vg.eo +++ b/src/lib/evas/canvas/evas_vg.eo @@ -1,4 +1,4 @@ -class Evas.VG (Evas.Object, Efl.File) +class Evas.VG (Evas.Object, Efl.File, Efl.Gfx.Fill) { legacy_prefix: evas_object_vg; eo_prefix: evas_obj_vg; @@ -30,62 +30,14 @@ class Evas.VG (Evas.Object, Efl.File) uint h; } } - fill { - set { - /*@ - Set how to fill an image object's drawing rectangle given the - (real) image bound to it. - - Note that if @p w or @p h are smaller than the dimensions of - @p obj, the displayed image will be @b tiled around the object's - area. To have only one copy of the bound image drawn, @p x and @p y - must be 0 and @p w and @p h need to be the exact width and height - of the image object itself, respectively. - - See the following image to better understand the effects of this - call. On this diagram, both image object and original image source - have @c a x @c a dimensions and the image itself is a circle, with - empty space around it: - - @image html image-fill.png - @image rtf image-fill.png - @image latex image-fill.eps - - @warning The default values for the fill parameters are @p x = 0, - @p y = 0, @p w = 0 and @p h = 0. Thus, if you're not using the - evas_object_image_filled_add() helper and want your image - displayed, you'll have to set valid values with this function on - your object. - - @note evas_object_image_filled_set() is a helper function which - will @b override the values set here automatically, for you, in a - given way. */ - } - get { - /*@ - Retrieve how an image object is to fill its drawing rectangle, - given the (real) image bound to it. - - @note Use @c NULL pointers on the fill components you're not - interested in: they'll be ignored by the function. - - See @ref evas_object_image_fill_set() for more details. */ - } - values { - Evas_Coord x; /*@ The x coordinate (from the top left corner of the bound - image) to start drawing from. */ - Evas_Coord y; /*@ The y coordinate (from the top left corner of the bound - image) to start drawing from. */ - Evas_Coord w; /*@ The width the bound image will be displayed at. */ - Evas_Coord h; /*@ The height the bound image will be displayed at. */ - } - } - } + } implements { Eo.Base.constructor; Efl.File.file.set; Efl.File.file.get; Efl.File.mmap.set; Efl.File.mmap.get; + Efl.Gfx.Fill.fill.set; + Efl.Gfx.Fill.fill.get; } } \ No newline at end of file From a395f5ded565f3578a138b061106884dee7d5e18 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:23:26 +0200 Subject: [PATCH 102/251] efl: add Efl.Gfx.View and use it in Evas.Image. --- src/Makefile_Efl.am | 1 + src/Makefile_Efl_Cxx.am | 1 + src/lib/efl/Efl.h | 1 + src/lib/efl/interfaces/efl_gfx_view.eo | 27 ++++++++++++++++++++ src/lib/efl/interfaces/efl_interfaces_main.c | 2 ++ src/lib/evas/Evas_Legacy.h | 26 +++++++++++++++++++ src/lib/evas/canvas/evas_image.eo | 26 +++---------------- src/lib/evas/canvas/evas_object_image.c | 18 +++++++++++-- 8 files changed, 77 insertions(+), 25 deletions(-) create mode 100644 src/lib/efl/interfaces/efl_gfx_view.eo diff --git a/src/Makefile_Efl.am b/src/Makefile_Efl.am index 4791e0d2d4..15429a241c 100644 --- a/src/Makefile_Efl.am +++ b/src/Makefile_Efl.am @@ -8,6 +8,7 @@ efl_eolian_files = \ lib/efl/interfaces/efl_gfx_base.eo \ lib/efl/interfaces/efl_gfx_stack.eo \ lib/efl/interfaces/efl_gfx_fill.eo \ + lib/efl/interfaces/efl_gfx_view.eo \ lib/efl/interfaces/efl_gfx_shape.eo \ lib/efl/interfaces/efl_gfx_gradient.eo \ lib/efl/interfaces/efl_gfx_gradient_linear.eo \ diff --git a/src/Makefile_Efl_Cxx.am b/src/Makefile_Efl_Cxx.am index 9fdbdfc32c..e2ed95a636 100644 --- a/src/Makefile_Efl_Cxx.am +++ b/src/Makefile_Efl_Cxx.am @@ -12,6 +12,7 @@ generated_efl_cxx_bindings = \ lib/efl/interfaces/efl_gfx_base.eo.hh \ lib/efl/interfaces/efl_gfx_stack.eo.hh \ lib/efl/interfaces/efl_gfx_fill.eo.hh \ + lib/efl/interfaces/efl_gfx_view.eo.hh \ lib/efl/interfaces/efl_gfx_shape.eo.hh \ lib/efl/interfaces/efl_gfx_gradient.eo.hh \ lib/efl/interfaces/efl_gfx_gradient_linear.eo.hh \ diff --git a/src/lib/efl/Efl.h b/src/lib/efl/Efl.h index 4fb67f378d..9b0dea2960 100644 --- a/src/lib/efl/Efl.h +++ b/src/lib/efl/Efl.h @@ -140,6 +140,7 @@ typedef enum _Efl_Gfx_Fill_Spread #include "interfaces/efl_gfx_base.eo.h" #include "interfaces/efl_gfx_stack.eo.h" #include "interfaces/efl_gfx_fill.eo.h" +#include "interfaces/efl_gfx_view.eo.h" #include "interfaces/efl_gfx_shape.eo.h" #include "interfaces/efl_gfx_gradient.eo.h" #include "interfaces/efl_gfx_gradient_linear.eo.h" diff --git a/src/lib/efl/interfaces/efl_gfx_view.eo b/src/lib/efl/interfaces/efl_gfx_view.eo new file mode 100644 index 0000000000..9d609d5cdb --- /dev/null +++ b/src/lib/efl/interfaces/efl_gfx_view.eo @@ -0,0 +1,27 @@ +interface Efl.Gfx.View { + legacy_prefix: null; + properties { + size { + set { + /*@ + Sets the size of the given image object. + + This function will scale down or crop the image so that it is + treated as if it were at the given size. If the size given is + smaller than the image, it will be cropped. If the size given is + larger, then the image will be treated as if it were in the upper + left hand corner of a larger image that is otherwise transparent. */ + } + get { + /*@ + Retrieves the size of the given image object. + + See @ref evas_object_image_size_set() for more details. */ + } + values { + int w; /*@ The new width of the image. */ + int h; /*@ The new height of the image. */ + } + } + } +} diff --git a/src/lib/efl/interfaces/efl_interfaces_main.c b/src/lib/efl/interfaces/efl_interfaces_main.c index 938b161866..d53bef8df9 100644 --- a/src/lib/efl/interfaces/efl_interfaces_main.c +++ b/src/lib/efl/interfaces/efl_interfaces_main.c @@ -14,6 +14,8 @@ #include "interfaces/efl_gfx_base.eo.c" #include "interfaces/efl_gfx_stack.eo.c" #include "interfaces/efl_gfx_fill.eo.c" +#include "interfaces/efl_gfx_view.eo.c" + #include "interfaces/efl_gfx_shape.eo.c" #include "interfaces/efl_gfx_gradient.eo.c" #include "interfaces/efl_gfx_gradient_linear.eo.c" diff --git a/src/lib/evas/Evas_Legacy.h b/src/lib/evas/Evas_Legacy.h index a8b1c9f758..3258613124 100644 --- a/src/lib/evas/Evas_Legacy.h +++ b/src/lib/evas/Evas_Legacy.h @@ -2066,6 +2066,32 @@ image) to start drawing from. */ EAPI void evas_object_image_fill_get(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h); +/** + * + * Sets the size of the given image object. + * + * This function will scale down or crop the image so that it is + * treated as if it were at the given size. If the size given is + * smaller than the image, it will be cropped. If the size given is + * larger, then the image will be treated as if it were in the upper + * left hand corner of a larger image that is otherwise transparent. + * + * @param[in] w The new width of the image. + * @param[in] h The new height of the image. + */ +EAPI void evas_object_image_size_set(Evas_Object *obj, int w, int h); + +/** + * + * Retrieves the size of the given image object. + * + * See @ref evas_object_image_size_set() for more details. + * + * @param[out] w The new width of the image. + * @param[out] h The new height of the image. + */ +EAPI void evas_object_image_size_get(const Evas_Object *obj, int *w, int *h); + #include "canvas/evas_image.eo.legacy.h" /** diff --git a/src/lib/evas/canvas/evas_image.eo b/src/lib/evas/canvas/evas_image.eo index 7e44576319..e6783b1400 100644 --- a/src/lib/evas/canvas/evas_image.eo +++ b/src/lib/evas/canvas/evas_image.eo @@ -1,4 +1,4 @@ -class Evas.Image (Evas.Object, Efl.File, Efl.Image, Efl.Gfx.Fill) +class Evas.Image (Evas.Object, Efl.File, Efl.Image, Efl.Gfx.Fill, Efl.Gfx.View) { legacy_prefix: evas_object_image; eo_prefix: evas_obj_image; @@ -393,28 +393,6 @@ class Evas.Image (Evas.Object, Efl.File, Efl.Image, Efl.Gfx.Fill) #Evas_Border_Fill_Mode). */ } } - size { - set { - /*@ - Sets the size of the given image object. - - This function will scale down or crop the image so that it is - treated as if it were at the given size. If the size given is - smaller than the image, it will be cropped. If the size given is - larger, then the image will be treated as if it were in the upper - left hand corner of a larger image that is otherwise transparent. */ - } - get { - /*@ - Retrieves the size of the given image object. - - See @ref evas_object_image_size_set() for more details. */ - } - values { - int w; /*@ The new width of the image. */ - int h; /*@ The new height of the image. */ - } - } source_visible { set { /*@ @@ -1010,5 +988,7 @@ class Evas.Image (Evas.Object, Efl.File, Efl.Image, Efl.Gfx.Fill) Efl.Gfx.Fill.fill_spread.get; Efl.Gfx.Fill.fill.set; Efl.Gfx.Fill.fill.get; + Efl.Gfx.View.size.set; + Efl.Gfx.View.size.get; } } diff --git a/src/lib/evas/canvas/evas_object_image.c b/src/lib/evas/canvas/evas_object_image.c index 54fb8f647d..ebd3292c99 100644 --- a/src/lib/evas/canvas/evas_object_image.c +++ b/src/lib/evas/canvas/evas_object_image.c @@ -1073,8 +1073,14 @@ _evas_image_efl_gfx_fill_fill_spread_get(Eo *eo_obj EINA_UNUSED, return (Evas_Fill_Spread)o->cur->spread;; } +EAPI void +evas_object_image_size_set(Evas_Image *obj, int w, int h) +{ + eo_do((Evas_Image *)obj, efl_gfx_view_size_set(w, h)); +} + EOLIAN static void -_evas_image_size_set(Eo *eo_obj, Evas_Image_Data *o, int w, int h) +_evas_image_efl_gfx_view_size_set(Eo *eo_obj, Evas_Image_Data *o, int w, int h) { Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS); @@ -1137,8 +1143,16 @@ _evas_image_size_set(Eo *eo_obj, Evas_Image_Data *o, int w, int h) evas_object_change(eo_obj, obj); } +EAPI void +evas_object_image_size_get(const Evas_Image *obj, int *w, int *h) +{ + eo_do((Evas_Image *)obj, efl_gfx_view_size_get(w, h)); +} + EOLIAN static void -_evas_image_size_get(Eo *eo_obj EINA_UNUSED, Evas_Image_Data *o, int *w, int *h) +_evas_image_efl_gfx_view_size_get(Eo *eo_obj EINA_UNUSED, + Evas_Image_Data *o, + int *w, int *h) { if (w) *w = o->cur->image.w; if (h) *h = o->cur->image.h; From 1fb52dbe714e0a39578c2fe111e2142ee632841e Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:23:27 +0200 Subject: [PATCH 103/251] evas: move Evas.VG to use Efl.Gfx.View. --- src/lib/evas/canvas/evas_object_vg.c | 8 ++++---- src/lib/evas/canvas/evas_vg.eo | 24 +++--------------------- 2 files changed, 7 insertions(+), 25 deletions(-) diff --git a/src/lib/evas/canvas/evas_object_vg.c b/src/lib/evas/canvas/evas_object_vg.c index ed4fe0446f..6907b103e3 100644 --- a/src/lib/evas/canvas/evas_object_vg.c +++ b/src/lib/evas/canvas/evas_object_vg.c @@ -425,16 +425,16 @@ _evas_vg_efl_file_file_get(Eo *obj, Evas_VG_Data *pd EINA_UNUSED, } void -_evas_vg_size_get(Eo *obj EINA_UNUSED, Evas_VG_Data *pd, - unsigned int *w, unsigned int *h) +_evas_vg_efl_gfx_view_size_get(Eo *obj EINA_UNUSED, Evas_VG_Data *pd, + int *w, int *h) { if (w) *w = pd->width; if (h) *h = pd->height; } void -_evas_vg_size_set(Eo *obj EINA_UNUSED, Evas_VG_Data *pd, - unsigned int w, unsigned int h) +_evas_vg_efl_gfx_view_size_set(Eo *obj EINA_UNUSED, Evas_VG_Data *pd, + int w, int h) { pd->width = w; pd->height = h; diff --git a/src/lib/evas/canvas/evas_vg.eo b/src/lib/evas/canvas/evas_vg.eo index 33e3daa0ef..97e38c53b3 100644 --- a/src/lib/evas/canvas/evas_vg.eo +++ b/src/lib/evas/canvas/evas_vg.eo @@ -1,4 +1,4 @@ -class Evas.VG (Evas.Object, Efl.File, Efl.Gfx.Fill) +class Evas.VG (Evas.Object, Efl.File, Efl.Gfx.Fill, Efl.Gfx.View) { legacy_prefix: evas_object_vg; eo_prefix: evas_obj_vg; @@ -10,26 +10,6 @@ class Evas.VG (Evas.Object, Efl.File, Efl.Gfx.Fill) Evas_VG_Node *container; } } - size { - get { - /*@ - Get the size as defined in the original data - before any scaling (as in the file or when the - object were added). - */ - } - set { - /*@ - Set the size defined in the original data - before any scaling (as in the file or when the - object were added). - */ - } - values { - uint w; - uint h; - } - } } implements { Eo.Base.constructor; @@ -39,5 +19,7 @@ class Evas.VG (Evas.Object, Efl.File, Efl.Gfx.Fill) Efl.File.mmap.get; Efl.Gfx.Fill.fill.set; Efl.Gfx.Fill.fill.get; + Efl.Gfx.View.size.set; + Efl.Gfx.View.size.get; } } \ No newline at end of file From ac8d923090f69a7cfe6397dd47df701aad421294 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:23:28 +0200 Subject: [PATCH 104/251] efl: add path operation to Efl.Gfx.Shape. --- src/Makefile_Efl.am | 6 +- .../ector/cairo/ector_renderer_cairo_shape.c | 14 +- src/lib/ector/ector_private.h | 5 - src/lib/ector/ector_renderer_generic_shape.eo | 1 - src/lib/ector/ector_renderer_shape.c | 23 - .../{efl_gfx_utils.c => efl_gfx_shape.c} | 674 +++++++++++------- src/lib/efl/interfaces/efl_gfx_shape.eo | 136 +++- src/lib/efl/interfaces/efl_gfx_utils.h | 67 -- src/lib/efl/interfaces/efl_interfaces_main.c | 1 - src/lib/evas/canvas/evas_vg_shape.c | 39 +- src/lib/evas/canvas/evas_vg_shape.eo | 1 - 11 files changed, 572 insertions(+), 395 deletions(-) rename src/lib/efl/interfaces/{efl_gfx_utils.c => efl_gfx_shape.c} (57%) delete mode 100644 src/lib/efl/interfaces/efl_gfx_utils.h diff --git a/src/Makefile_Efl.am b/src/Makefile_Efl.am index 15429a241c..440d41bb58 100644 --- a/src/Makefile_Efl.am +++ b/src/Makefile_Efl.am @@ -28,7 +28,6 @@ CLEANFILES += \ EXTRA_DIST += \ lib/efl/Efl_Config.h \ lib/efl/Efl.h \ - lib/efl/interfaces/efl_gfx_utils.h \ $(efl_eolian_files) efleolianfilesdir = $(datadir)/eolian/include/efl-@VMAJ@ @@ -38,7 +37,7 @@ lib_LTLIBRARIES += lib/efl/libefl.la lib_efl_libefl_la_SOURCES = \ lib/efl/interfaces/efl_interfaces_main.c \ -lib/efl/interfaces/efl_gfx_utils.c +lib/efl/interfaces/efl_gfx_shape.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@ @@ -52,8 +51,7 @@ dist_installed_eflheaders_DATA = \ installed_eflinterfacesdir = $(includedir)/efl-@VMAJ@/interfaces nodist_installed_eflinterfaces_DATA = \ -$(efl_eolian_files_h) \ -lib/efl/interfaces/efl_gfx_utils.h +$(efl_eolian_files_h) if HAVE_ELUA diff --git a/src/lib/ector/cairo/ector_renderer_cairo_shape.c b/src/lib/ector/cairo/ector_renderer_cairo_shape.c index dcdedea5e9..eeb366b0c0 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_shape.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_shape.c @@ -48,6 +48,9 @@ struct _Ector_Renderer_Cairo_Shape_Data static Eina_Bool _ector_renderer_cairo_shape_ector_renderer_generic_base_prepare(Eo *obj, Ector_Renderer_Cairo_Shape_Data *pd) { + const Efl_Gfx_Path_Command *cmds = NULL; + const double *pts = NULL; + // FIXME: shouldn't that be part of the shape generic implementation ? if (pd->shape->fill) eo_do(pd->shape->fill, ector_renderer_prepare()); @@ -68,19 +71,16 @@ _ector_renderer_cairo_shape_ector_renderer_generic_base_prepare(Eo *obj, Ector_R if (!pd->parent) return EINA_FALSE; } - if (!pd->path && pd->shape->path.cmd) + eo_do(obj, efl_gfx_shape_path_get(&cmds, &pts)); + if (!pd->path && cmds) { - double *pts; - unsigned int i; - USE(obj, cairo_new_path, EINA_FALSE); cairo_new_path(pd->parent->cairo); - pts = pd->shape->path.pts; - for (i = 0; pd->shape->path.cmd[i] != EFL_GFX_PATH_COMMAND_TYPE_END; i++) + for (; *cmds != EFL_GFX_PATH_COMMAND_TYPE_END; cmds++) { - switch (pd->shape->path.cmd[i]) + switch (*cmds) { case EFL_GFX_PATH_COMMAND_TYPE_MOVE_TO: USE(obj, cairo_move_to, EINA_FALSE); diff --git a/src/lib/ector/ector_private.h b/src/lib/ector/ector_private.h index 896c849512..2974b359ab 100644 --- a/src/lib/ector/ector_private.h +++ b/src/lib/ector/ector_private.h @@ -95,11 +95,6 @@ struct _Ector_Renderer_Generic_Gradient_Radial_Data struct _Ector_Renderer_Generic_Shape_Data { - struct { - Efl_Gfx_Path_Command *cmd; - double *pts; - } path; - Ector_Renderer *fill; struct { Ector_Renderer *fill; diff --git a/src/lib/ector/ector_renderer_generic_shape.eo b/src/lib/ector/ector_renderer_generic_shape.eo index edbec7b46f..7dd30d8506 100644 --- a/src/lib/ector/ector_renderer_generic_shape.eo +++ b/src/lib/ector/ector_renderer_generic_shape.eo @@ -39,7 +39,6 @@ class Ector.Renderer.Generic.Shape (Ector.Renderer.Generic.Base, Efl.Gfx.Shape) 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; } diff --git a/src/lib/ector/ector_renderer_shape.c b/src/lib/ector/ector_renderer_shape.c index 990bee949d..106333a747 100644 --- a/src/lib/ector/ector_renderer_shape.c +++ b/src/lib/ector/ector_renderer_shape.c @@ -183,29 +183,6 @@ _ector_renderer_generic_shape_efl_gfx_shape_stroke_join_get(Eo *obj EINA_UNUSED, return pd->stroke.join; } -static void -_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_gfx_path_dup(&pd->path.cmd, &pd->path.pts, cmd, points); -} - -void -_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; -} static void _ector_renderer_generic_shape_eo_base_constructor(Eo *obj, diff --git a/src/lib/efl/interfaces/efl_gfx_utils.c b/src/lib/efl/interfaces/efl_gfx_shape.c similarity index 57% rename from src/lib/efl/interfaces/efl_gfx_utils.c rename to src/lib/efl/interfaces/efl_gfx_shape.c index b159b1fbbd..d90ecd2bf5 100644 --- a/src/lib/efl/interfaces/efl_gfx_utils.c +++ b/src/lib/efl/interfaces/efl_gfx_shape.c @@ -2,14 +2,29 @@ # include #endif -#include - #include #include #include +#include + +typedef struct _Efl_Gfx_Shape_Data Efl_Gfx_Shape_Data; +struct _Efl_Gfx_Shape_Data +{ + struct { + double x; + double y; + } current, current_ctrl; + + Efl_Gfx_Path_Command *commands; + double *points; + + unsigned int commands_count; + unsigned int points_count; +}; + static inline unsigned int -efl_gfx_path_command_length(Efl_Gfx_Path_Command command) +_efl_gfx_path_command_length(Efl_Gfx_Path_Command command) { switch (command) { @@ -31,12 +46,12 @@ _efl_gfx_path_length(const Efl_Gfx_Path_Command *commands, if (commands) while (commands[*cmd_length] != EFL_GFX_PATH_COMMAND_TYPE_END) { - *pts_length += efl_gfx_path_command_length(commands[*cmd_length]); + *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++; + (*cmd_length)++; } static inline Eina_Bool @@ -50,14 +65,14 @@ efl_gfx_path_grow(Efl_Gfx_Path_Command command, _efl_gfx_path_length(*commands, &cmd_length, &pts_length); - if (efl_gfx_path_command_length(command)) + if (_efl_gfx_path_command_length(command)) { - pts_length += 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); + *offset_point = *points + pts_length - _efl_gfx_path_command_length(command); } cmd_tmp = realloc(*commands, @@ -73,63 +88,11 @@ efl_gfx_path_grow(Efl_Gfx_Path_Command command, 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) +static Eina_Bool +_efl_gfx_path_current_search(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; @@ -171,45 +134,305 @@ efl_gfx_path_current_get(const Efl_Gfx_Path_Command *cmd, return EINA_TRUE; } -EAPI void -efl_gfx_path_append_move_to(Efl_Gfx_Path_Command **commands, double **points, - double x, double y) +void +_efl_gfx_shape_path_set(Eo *obj EINA_UNUSED, Efl_Gfx_Shape_Data *pd, + const Efl_Gfx_Path_Command *commands, + const double *points) +{ + Efl_Gfx_Path_Command *cmds; + double *pts; + unsigned int cmds_length = 0, pts_length = 0; + + _efl_gfx_path_length(commands, &cmds_length, &pts_length); + + cmds = realloc(pd->commands, + sizeof (Efl_Gfx_Path_Command) * cmds_length); + if (!cmds) return ; + pd->commands = cmds; + + pts = realloc(pd->points, + sizeof (double) * pts_length); + if (!pts) return ; + pd->points = pts; + + pd->commands_count = cmds_length; + pd->points_count = pts_length; + + memcpy(pd->commands, commands, sizeof (Efl_Gfx_Path_Command) * cmds_length); + memcpy(pd->points, points, sizeof (double) * pts_length); + + _efl_gfx_path_current_search(pd->commands, pd->points, + &pd->current.x, &pd->current.y, + &pd->current_ctrl.x, &pd->current_ctrl.y); +} + +void +_efl_gfx_shape_path_get(Eo *obj EINA_UNUSED, Efl_Gfx_Shape_Data *pd, + const Efl_Gfx_Path_Command **commands, + const double **points) +{ + if (commands) *commands = pd->commands; + if (points) *points = pd->points; +} + +void +_efl_gfx_shape_path_length_get(Eo *obj EINA_UNUSED, Efl_Gfx_Shape_Data *pd, + unsigned int *commands, unsigned int *points) +{ + if (commands) *commands = pd->commands_count; + if (points) *points = pd->points_count; +} + +void +_efl_gfx_shape_current_get(Eo *obj EINA_UNUSED, Efl_Gfx_Shape_Data *pd, + double *x, double *y) +{ + if (x) *x = pd->current.x; + if (y) *y = pd->current.y; +} + +void +_efl_gfx_shape_current_ctrl_get(Eo *obj EINA_UNUSED, Efl_Gfx_Shape_Data *pd, + double *x, double *y) +{ + if (x) *x = pd->current_ctrl.x; + if (y) *y = pd->current_ctrl.y; +} + +static Eina_Bool +_efl_gfx_shape_equal_commands_internal(Efl_Gfx_Shape_Data *a, + Efl_Gfx_Shape_Data *b) +{ + unsigned int i; + + if (a->commands_count != b->commands_count) return EINA_FALSE; + + for (i = 0; a->commands[i] == b->commands[i] && + a->commands[i] != EFL_GFX_PATH_COMMAND_TYPE_END; i++) + ; + + return (a->commands[i] == b->commands[i]); +} + +static inline double +interpolate(double from, double to, double pos_map) +{ + return (from * pos_map) + (to * (1.0 - pos_map)); +} + +Eina_Bool +_efl_gfx_shape_interpolate(Eo *obj EINA_UNUSED, Efl_Gfx_Shape_Data *pd, + const Eo *from, const Eo *to, double pos_map) +{ + Efl_Gfx_Shape_Data *from_pd, *to_pd; + Efl_Gfx_Path_Command *cmds; + double *pts, *from_pts, *to_pts; + unsigned int i, j; + + from_pd = eo_data_scope_get(from, EFL_GFX_SHAPE_CLASS); + to_pd = eo_data_scope_get(to, EFL_GFX_SHAPE_CLASS); + if (!from_pd && !to_pd) return EINA_FALSE; + if (!_efl_gfx_shape_equal_commands_internal(from_pd, to_pd)) + return EINA_FALSE; + + cmds = realloc(pd->commands, + sizeof (Efl_Gfx_Path_Command) * from_pd->commands_count); + if (!cmds) return EINA_FALSE; + pd->commands = cmds; + + pts = realloc(pd->points, + sizeof (double) * from_pd->points_count); + if (!pts) return EINA_FALSE; + pd->points = pts; + + memcpy(cmds, from_pd->commands, + sizeof (Efl_Gfx_Path_Command) * from_pd->commands_count); + + to_pts = to_pd->points; + from_pts = from_pd->points; + + for (i = 0; cmds[i] != EFL_GFX_PATH_COMMAND_TYPE_END; i++) + for (j = 0; j < _efl_gfx_path_command_length(cmds[i]); j++) + { + *pts = interpolate(*from_pts, *to_pts, pos_map); + + pts++; + from_pts++; + to_pts++; + } + + pd->current.x = interpolate(from_pd->current.x, + to_pd->current.x, + pos_map); + pd->current.y = interpolate(from_pd->current.y, + to_pd->current.y, + pos_map); + pd->current_ctrl.x = interpolate(from_pd->current_ctrl.x, + to_pd->current_ctrl.x, + pos_map); + pd->current_ctrl.y = interpolate(from_pd->current_ctrl.y, + to_pd->current_ctrl.y, + pos_map); + + return EINA_TRUE; +} + +Eina_Bool +_efl_gfx_shape_equal_commands(Eo *obj EINA_UNUSED, + Efl_Gfx_Shape_Data *pd, + const Eo *with) +{ + Efl_Gfx_Shape_Data *with_pd; + + with_pd = eo_data_scope_get(with, EFL_GFX_SHAPE_CLASS); + if (!with_pd) return EINA_FALSE; + + return _efl_gfx_shape_equal_commands_internal(with_pd, pd); +} + +void +_efl_gfx_shape_dup(Eo *obj, Efl_Gfx_Shape_Data *pd, Eo *dup_from) +{ + const Efl_Gfx_Dash *dash = NULL; + Efl_Gfx_Shape_Data *from; + unsigned int dash_length = 0; + Efl_Gfx_Cap cap; + Efl_Gfx_Join j; + int sr, sg, sb, sa; + double scale, location; + double sw; + + if (obj == dup_from) return ; + from = eo_data_scope_get(dup_from, EFL_GFX_SHAPE_CLASS); + if (!from) return ; + + eo_do(dup_from, + scale = efl_gfx_shape_stroke_scale_get(), + efl_gfx_shape_stroke_color_get(&sr, &sg, &sb, &sa), + sw = efl_gfx_shape_stroke_width_get(), + location = efl_gfx_shape_stroke_location_get(), + efl_gfx_shape_stroke_dash_get(&dash, &dash_length), + cap = efl_gfx_shape_stroke_cap_get(), + j = efl_gfx_shape_stroke_join_get()); + eo_do(obj, + efl_gfx_shape_stroke_scale_set(scale), + efl_gfx_shape_stroke_color_set(sr, sg, sb, sa), + efl_gfx_shape_stroke_width_set(sw), + efl_gfx_shape_stroke_location_set(location), + efl_gfx_shape_stroke_dash_set(dash, dash_length), + efl_gfx_shape_stroke_cap_set(cap), + efl_gfx_shape_stroke_join_set(j)); + + _efl_gfx_shape_path_set(obj, pd, from->commands, from->points); +} + +void +_efl_gfx_shape_reset(Eo *obj EINA_UNUSED, Efl_Gfx_Shape_Data *pd) +{ + free(pd->commands); + pd->commands = NULL; + pd->commands_count = 0; + + free(pd->points); + pd->points = NULL; + pd->points_count = 0; + + pd->current.x = 0; + pd->current.y = 0; + pd->current_ctrl.x = 0; + pd->current_ctrl.y = 0; +} + +void +_efl_gfx_shape_append_move_to(Eo *obj EINA_UNUSED, Efl_Gfx_Shape_Data *pd, + double x, double y) { double *offset_point; if (!efl_gfx_path_grow(EFL_GFX_PATH_COMMAND_TYPE_MOVE_TO, - commands, points, &offset_point)) + &pd->commands, &pd->points, &offset_point)) return ; offset_point[0] = x; offset_point[1] = y; + + pd->current.x = x; + pd->current.y = y; } -EAPI void -efl_gfx_path_append_line_to(Efl_Gfx_Path_Command **commands, double **points, - double x, double y) +void +_efl_gfx_shape_append_line_to(Eo *obj EINA_UNUSED, Efl_Gfx_Shape_Data *pd, + double x, double y) { double *offset_point; if (!efl_gfx_path_grow(EFL_GFX_PATH_COMMAND_TYPE_LINE_TO, - commands, points, &offset_point)) + &pd->commands, &pd->points, &offset_point)) return ; offset_point[0] = x; offset_point[1] = y; + + pd->current.x = x; + pd->current.y = 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) +void +_efl_gfx_shape_append_cubic_to(Eo *obj EINA_UNUSED, Efl_Gfx_Shape_Data *pd, + 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, + &pd->commands, &pd->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; + + pd->current.x = x; + pd->current.y = y; + pd->current_ctrl.x = ctrl_x1; + pd->current_ctrl.y = ctrl_y1; +} + +void +_efl_gfx_shape_append_scubic_to(Eo *obj, Efl_Gfx_Shape_Data *pd, + 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; + + current_x = pd->current.x; + current_y = pd->current.x; + current_ctrl_x = pd->current_ctrl.x; + current_ctrl_y = pd->current_ctrl.y; + + ctrl_x0 = 2 * current_x - current_ctrl_x; + ctrl_y0 = 2 * current_y - current_ctrl_y; + + _efl_gfx_shape_append_cubic_to(obj, pd, x, y, + ctrl_x0, ctrl_y0, ctrl_x, ctrl_y); +} + +void +_efl_gfx_shape_append_quadratic_to(Eo *obj, Efl_Gfx_Shape_Data *pd, + 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 ; + current_x = pd->current.x; + current_y = pd->current.y; // Convert quadratic bezier to cubic ctrl_x0 = (current_x + 2 * ctrl_x) * (1.0 / 3.0); @@ -217,23 +440,23 @@ efl_gfx_path_append_quadratic_to(Efl_Gfx_Path_Command **commands, double **point 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); + _efl_gfx_shape_append_cubic_to(obj, pd, 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) +void +_efl_gfx_shape_append_squadratic_to(Eo *obj, Efl_Gfx_Shape_Data *pd, + 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 ; + current_x = pd->current.x; + current_y = pd->current.x; + current_ctrl_x = pd->current_ctrl.x; + current_ctrl_y = pd->current_ctrl.y; xc = 2 * current_x - current_ctrl_x; yc = 2 * current_y - current_ctrl_y; @@ -243,58 +466,17 @@ efl_gfx_path_append_squadratic_to(Efl_Gfx_Path_Command **commands, double **poin 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); + _efl_gfx_shape_append_cubic_to(obj, pd, x, y, + ctrl_x0, ctrl_y0, + ctrl_x1, ctrl_y1); } // 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) +_efl_gfx_shape_append_arc_segment(Eo *eo, Efl_Gfx_Shape_Data *pd, + double xc, double yc, + double th0, double th1, double rx, double ry, + double angle) { double x1, y1, x2, y2, x3, y3; double t; @@ -314,21 +496,22 @@ _efl_gfx_path_append_arc_segment(Efl_Gfx_Path_Command **commands, double **point 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); + _efl_gfx_shape_append_cubic_to(eo, pd, + 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) +void +_efl_gfx_shape_append_arc_to(Eo *obj, Efl_Gfx_Shape_Data *pd, + 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 */ @@ -341,10 +524,8 @@ efl_gfx_path_append_arc_to(Efl_Gfx_Path_Command **commands, double **points, double k1, k2, k3, k4, k5; int i, n_segs; - if (!efl_gfx_path_current_get(*commands, *points, - &x1, &y1, - NULL, NULL)) - return ; + x1 = pd->current.x; + y1 = pd->current.x; /* Start and end of path segment */ x2 = x; @@ -362,7 +543,7 @@ efl_gfx_path_append_arc_to(Efl_Gfx_Path_Command **commands, double **points, 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); + _efl_gfx_shape_append_line_to(obj, pd, x, y); return; } @@ -431,45 +612,45 @@ efl_gfx_path_append_arc_to(Efl_Gfx_Path_Command **commands, double **points, 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); + _efl_gfx_shape_append_arc_segment(obj, pd, + 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) +void +_efl_gfx_shape_append_close(Eo *obj EINA_UNUSED, Efl_Gfx_Shape_Data *pd) { double *offset_point; efl_gfx_path_grow(EFL_GFX_PATH_COMMAND_TYPE_CLOSE, - commands, points, &offset_point); + &pd->commands, &pd->points, &offset_point); } -EAPI void -efl_gfx_path_append_circle(Efl_Gfx_Path_Command **commands, double **points, - double x, double y, double radius) +void +_efl_gfx_shape_append_circle(Eo *obj, Efl_Gfx_Shape_Data *pd, + 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); + _efl_gfx_shape_append_move_to(obj, pd, x, y - radius); + _efl_gfx_shape_append_arc_to(obj, pd, x - radius, y, radius, radius, 0, EINA_FALSE, EINA_FALSE); + _efl_gfx_shape_append_arc_to(obj, pd, x, y + radius, radius, radius, 0, EINA_FALSE, EINA_FALSE); + _efl_gfx_shape_append_arc_to(obj, pd, x + radius, y, radius, radius, 0, EINA_FALSE, EINA_FALSE); + _efl_gfx_shape_append_arc_to(obj, pd, 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, +_efl_gfx_path_append_horizontal_to(Eo *obj, Efl_Gfx_Shape_Data *pd, double d, double current_x EINA_UNUSED, double current_y) { - efl_gfx_path_append_line_to(commands, points, d, current_y); + _efl_gfx_shape_append_line_to(obj, pd, d, current_y); } static void -_efl_gfx_path_append_vertical_to(Efl_Gfx_Path_Command **commands, double **points, +_efl_gfx_path_append_vertical_to(Eo *obj, Efl_Gfx_Shape_Data *pd, double d, double current_x, double current_y EINA_UNUSED) { - efl_gfx_path_append_line_to(commands, points, current_x, d); + _efl_gfx_shape_append_line_to(obj, pd, current_x, d); } static char * @@ -508,9 +689,9 @@ _efl_gfx_path_parse_pair(const char *content, char **end, double *x, double *y) static Eina_Bool _efl_gfx_path_parse_pair_to(const char *content, char **end, - Efl_Gfx_Path_Command **commands, double **points, + Eo *obj, Efl_Gfx_Shape_Data *pd, double *current_x, double *current_y, - void (*func)(Efl_Gfx_Path_Command **commands, double **points, double x, double y), + void (*func)(Eo *obj, Efl_Gfx_Shape_Data *pd, double x, double y), Eina_Bool rel) { double x, y; @@ -529,7 +710,7 @@ _efl_gfx_path_parse_pair_to(const char *content, char **end, y += *current_y; } - func(commands, points, x, y); + func(obj, pd, x, y); content = *end; *current_x = x; @@ -542,9 +723,9 @@ _efl_gfx_path_parse_pair_to(const char *content, char **end, static Eina_Bool _efl_gfx_path_parse_double_to(const char *content, char **end, - Efl_Gfx_Path_Command **commands, double **points, + Eo *obj, Efl_Gfx_Shape_Data *pd, 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), + void (*func)(Eo *obj, Efl_Gfx_Shape_Data *pd, double d, double current_x, double current_y), Eina_Bool rel) { double d; @@ -563,7 +744,7 @@ _efl_gfx_path_parse_double_to(const char *content, char **end, d += *current; } - func(commands, points, d, current_x, current_y); + func(obj, pd, d, current_x, current_y); content = *end; *current = d; @@ -608,9 +789,9 @@ _efl_gfx_path_parse_six(const char *content, char **end, static Eina_Bool _efl_gfx_path_parse_six_to(const char *content, char **end, - Efl_Gfx_Path_Command **commands, double **points, + Eo *obj, Efl_Gfx_Shape_Data *pd, 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), + void (*func)(Eo *obj, Efl_Gfx_Shape_Data *pd, 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; @@ -632,7 +813,7 @@ _efl_gfx_path_parse_six_to(const char *content, char **end, y += *current_y; } - func(commands, points, x, y, ctrl_x0, ctrl_y0, ctrl_x1, ctrl_y1); + func(obj, pd, x, y, ctrl_x0, ctrl_y0, ctrl_x1, ctrl_y1); content = *end; *current_x = x; @@ -671,9 +852,9 @@ _efl_gfx_path_parse_quad(const char *content, char **end, static Eina_Bool _efl_gfx_path_parse_quad_to(const char *content, char **end, - Efl_Gfx_Path_Command **commands, double **points, + Eo *obj, Efl_Gfx_Shape_Data *pd, double *current_x, double *current_y, - void (*func)(Efl_Gfx_Path_Command **commands, double **points, + void (*func)(Eo *obj, Efl_Gfx_Shape_Data *pd, double x, double y, double ctrl_x0, double ctrl_y0), Eina_Bool rel) { @@ -695,7 +876,7 @@ _efl_gfx_path_parse_quad_to(const char *content, char **end, y += *current_y; } - func(commands, points, x, y, ctrl_x0, ctrl_y0); + func(obj, pd, x, y, ctrl_x0, ctrl_y0); content = *end; *current_x = x; @@ -745,9 +926,9 @@ _efl_gfx_path_parse_arc(const char *content, char **end, static Eina_Bool _efl_gfx_path_parse_arc_to(const char *content, char **end, - Efl_Gfx_Path_Command **commands, double **points, + Eo *obj, Efl_Gfx_Shape_Data *pd, double *current_x, double *current_y, - void (*func)(Efl_Gfx_Path_Command **commands, double **points, + void (*func)(Eo *obj, Efl_Gfx_Shape_Data *pd, double x, double y, double rx, double ry, double angle, Eina_Bool large_arc, Eina_Bool sweep), Eina_Bool rel) @@ -773,7 +954,7 @@ _efl_gfx_path_parse_arc_to(const char *content, char **end, y += *current_y; } - func(commands, points, x, y, rx, ry, angle, large_arc, sweep); + func(obj, pd, x, y, rx, ry, angle, large_arc, sweep); content = *end; *current_x = x; @@ -784,13 +965,14 @@ _efl_gfx_path_parse_arc_to(const char *content, char **end, return EINA_TRUE; } -EAPI Eina_Bool -efl_gfx_path_append_svg_path(Efl_Gfx_Path_Command **commands, double **points, const char *svg_path_data) +void +_efl_gfx_shape_append_svg_path(Eo *obj, Efl_Gfx_Shape_Data *pd, + const char *svg_path_data) { double current_x = 0, current_y = 0; char *content = (char*) svg_path_data; - if (!content) return EINA_FALSE; + if (!content) return ; while (content[0] != '\0') { @@ -801,173 +983,173 @@ efl_gfx_path_append_svg_path(Efl_Gfx_Path_Command **commands, double **points, c case 'M': if (!_efl_gfx_path_parse_pair_to(&content[1], &content, - commands, points, + obj, pd, ¤t_x, ¤t_y, - efl_gfx_path_append_move_to, + _efl_gfx_shape_append_move_to, EINA_FALSE)) - return EINA_FALSE; + return ; break; case 'm': if (!_efl_gfx_path_parse_pair_to(&content[1], &content, - commands, points, + obj, pd, ¤t_x, ¤t_y, - efl_gfx_path_append_move_to, + _efl_gfx_shape_append_move_to, EINA_TRUE)) - return EINA_FALSE; + return ; break; case 'z': - efl_gfx_path_append_close(commands, points); + _efl_gfx_shape_append_close(obj, pd); content++; break; case 'L': if (!_efl_gfx_path_parse_pair_to(&content[1], &content, - commands, points, + obj, pd, ¤t_x, ¤t_y, - efl_gfx_path_append_line_to, + _efl_gfx_shape_append_line_to, EINA_FALSE)) - return EINA_FALSE; + return ; break; case 'l': if (!_efl_gfx_path_parse_pair_to(&content[1], &content, - commands, points, + obj, pd, ¤t_x, ¤t_y, - efl_gfx_path_append_line_to, + _efl_gfx_shape_append_line_to, EINA_TRUE)) - return EINA_FALSE; + return ; break; case 'H': if (!_efl_gfx_path_parse_double_to(&content[1], &content, - commands, points, + obj, pd, ¤t_x, current_x, current_y, _efl_gfx_path_append_horizontal_to, EINA_FALSE)) - return EINA_FALSE; + return ; break; case 'h': if (!_efl_gfx_path_parse_double_to(&content[1], &content, - commands, points, + obj, pd, ¤t_x, current_x, current_y, _efl_gfx_path_append_horizontal_to, EINA_TRUE)) - return EINA_FALSE; + return ; break; case 'V': if (!_efl_gfx_path_parse_double_to(&content[1], &content, - commands, points, + obj, pd, ¤t_y, current_x, current_y, _efl_gfx_path_append_vertical_to, EINA_FALSE)) - return EINA_FALSE; + return ; break; case 'v': if (!_efl_gfx_path_parse_double_to(&content[1], &content, - commands, points, + obj, pd, ¤t_y, current_x, current_y, _efl_gfx_path_append_vertical_to, EINA_TRUE)) - return EINA_FALSE; + return ; break; case 'C': if (!_efl_gfx_path_parse_six_to(&content[1], &content, - commands, points, + obj, pd, ¤t_x, ¤t_y, - efl_gfx_path_append_cubic_to, + _efl_gfx_shape_append_cubic_to, EINA_FALSE)) - return EINA_FALSE; + return ; break; case 'c': if (!_efl_gfx_path_parse_six_to(&content[1], &content, - commands, points, + obj, pd, ¤t_x, ¤t_y, - efl_gfx_path_append_cubic_to, + _efl_gfx_shape_append_cubic_to, EINA_TRUE)) - return EINA_FALSE; + return ; break; case 'S': if (!_efl_gfx_path_parse_quad_to(&content[1], &content, - commands, points, + obj, pd, ¤t_x, ¤t_y, - efl_gfx_path_append_scubic_to, + _efl_gfx_shape_append_scubic_to, EINA_FALSE)) - return EINA_FALSE; + return ; break; case 's': if (!_efl_gfx_path_parse_quad_to(&content[1], &content, - commands, points, + obj, pd, ¤t_x, ¤t_y, - efl_gfx_path_append_scubic_to, + _efl_gfx_shape_append_scubic_to, EINA_TRUE)) - return EINA_FALSE; + return ; break; case 'Q': if (!_efl_gfx_path_parse_quad_to(&content[1], &content, - commands, points, + obj, pd, ¤t_x, ¤t_y, - efl_gfx_path_append_quadratic_to, + _efl_gfx_shape_append_quadratic_to, EINA_FALSE)) - return EINA_FALSE; + return ; break; case 'q': if (!_efl_gfx_path_parse_quad_to(&content[1], &content, - commands, points, + obj, pd, ¤t_x, ¤t_y, - efl_gfx_path_append_quadratic_to, + _efl_gfx_shape_append_quadratic_to, EINA_TRUE)) - return EINA_FALSE; + return ; break; case 'T': if (!_efl_gfx_path_parse_pair_to(&content[1], &content, - commands, points, + obj, pd, ¤t_x, ¤t_y, - efl_gfx_path_append_squadratic_to, + _efl_gfx_shape_append_squadratic_to, EINA_FALSE)) - return EINA_FALSE; + return ; break; case 't': if (!_efl_gfx_path_parse_pair_to(&content[1], &content, - commands, points, + obj, pd, ¤t_x, ¤t_y, - efl_gfx_path_append_squadratic_to, + _efl_gfx_shape_append_squadratic_to, EINA_TRUE)) - return EINA_FALSE; + return ; break; case 'A': if (!_efl_gfx_path_parse_arc_to(&content[1], &content, - commands, points, + obj, pd, ¤t_x, ¤t_y, - efl_gfx_path_append_arc_to, + _efl_gfx_shape_append_arc_to, EINA_FALSE)) - return EINA_FALSE; + return ; break; case 'a': if (!_efl_gfx_path_parse_arc_to(&content[1], &content, - commands, points, + obj, pd, ¤t_x, ¤t_y, - efl_gfx_path_append_arc_to, + _efl_gfx_shape_append_arc_to, EINA_TRUE)) - return EINA_FALSE; + return ; break; default: - return EINA_FALSE; + return ; } } - - return EINA_TRUE; } + +#include "interfaces/efl_gfx_shape.eo.c" diff --git a/src/lib/efl/interfaces/efl_gfx_shape.eo b/src/lib/efl/interfaces/efl_gfx_shape.eo index 2ee57c8c41..0369283f68 100644 --- a/src/lib/efl/interfaces/efl_gfx_shape.eo +++ b/src/lib/efl/interfaces/efl_gfx_shape.eo @@ -1,4 +1,4 @@ -interface Efl.Gfx.Shape +class Efl.Gfx.Shape { legacy_prefix: null; properties { @@ -75,9 +75,141 @@ interface Efl.Gfx.Shape get { } values { - const(Efl_Gfx_Path_Command) *op; + const(Efl_Gfx_Path_Command) *commands; const(double) *points; } } + path_length { + get { + } + values { + uint commands; + uint points; + } + } + current { + get { + } + values { + double x; + double y; + } + } + current_ctrl { + get { + } + values { + double x; + double y; + } + } + } + methods { + dup { + params { + @in Eo *dup_from; + } + } + reset { + } + append_move_to { + params { + @in double x; + @in double y; + } + } + append_line_to { + params { + @in double x; + @in double y; + } + } + append_quadratic_to { + params { + @in double x; + @in double y; + @in double ctrl_x; + @in double ctrl_y; + } + } + append_squadratic_to { + params { + @in double x; + @in double y; + } + } + append_cubic_to { + params { + @in double x; + @in double y; + @in double ctrl_x0; + @in double ctrl_y0; + @in double ctrl_x1; + @in double ctrl_y1; + } + } + append_scubic_to { + params { + @in double x; + @in double y; + @in double ctrl_x; + @in double ctrl_y; + } + } + append_arc_to { + params { + @in double x; + @in double y; + @in double rx; + @in double ry; + @in double angle; + @in bool large_arc; + @in bool sweep; + } + } + append_close { + } + append_circle { + params { + @in double x; + @in double y; + @in double radius; + } + } + append_svg_path { + params { + @in const(char)* svg_path_data; + } + } + interpolate { + return: bool; + params { + @in const(Eo)* from; + @in const(Eo)* to; + @in double pos_map; + } + } + equal_commands { + return: bool; + params { + @in const(Eo)* with; + } + } + } + implements { + @virtual .stroke_scale.get; + @virtual .stroke_scale.set; + @virtual .stroke_color.get; + @virtual .stroke_color.set; + @virtual .stroke_width.get; + @virtual .stroke_width.set; + @virtual .stroke_location.get; + @virtual .stroke_location.set; + @virtual .stroke_dash.get; + @virtual .stroke_dash.set; + @virtual .stroke_cap.get; + @virtual .stroke_cap.set; + @virtual .stroke_join.get; + @virtual .stroke_join.set; } } diff --git a/src/lib/efl/interfaces/efl_gfx_utils.h b/src/lib/efl/interfaces/efl_gfx_utils.h deleted file mode 100644 index 3c0cbf8bb0..0000000000 --- a/src/lib/efl/interfaces/efl_gfx_utils.h +++ /dev/null @@ -1,67 +0,0 @@ -#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 diff --git a/src/lib/efl/interfaces/efl_interfaces_main.c b/src/lib/efl/interfaces/efl_interfaces_main.c index d53bef8df9..6c7740491f 100644 --- a/src/lib/efl/interfaces/efl_interfaces_main.c +++ b/src/lib/efl/interfaces/efl_interfaces_main.c @@ -16,7 +16,6 @@ #include "interfaces/efl_gfx_fill.eo.c" #include "interfaces/efl_gfx_view.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" diff --git a/src/lib/evas/canvas/evas_vg_shape.c b/src/lib/evas/canvas/evas_vg_shape.c index 504a34a06b..c6cee02e6e 100644 --- a/src/lib/evas/canvas/evas_vg_shape.c +++ b/src/lib/evas/canvas/evas_vg_shape.c @@ -8,9 +8,6 @@ typedef struct _Evas_VG_Shape_Data Evas_VG_Shape_Data; struct _Evas_VG_Shape_Data { - Efl_Gfx_Path_Command *ops; - double *points; - Evas_VG_Node *fill; struct { @@ -31,30 +28,6 @@ struct _Evas_VG_Shape_Data } stroke; }; -static void -_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_gfx_path_dup(&pd->ops, &pd->points, ops, points); -} - -static void -_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; -} - static Eina_Bool _evas_vg_shape_evas_vg_node_bound_get(Eo *obj, Evas_VG_Shape_Data *pd, @@ -270,17 +243,7 @@ _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_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), + efl_gfx_shape_dup(obj), ector_renderer_prepare()); } diff --git a/src/lib/evas/canvas/evas_vg_shape.eo b/src/lib/evas/canvas/evas_vg_shape.eo index 7285586a6b..dd1ce13482 100644 --- a/src/lib/evas/canvas/evas_vg_shape.eo +++ b/src/lib/evas/canvas/evas_vg_shape.eo @@ -39,7 +39,6 @@ class Evas.VG_Shape (Evas.VG_Node, Efl.Gfx.Shape) 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; From cd3f8db506379a770ef37134748a64adfae66ab3 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:30:32 +0200 Subject: [PATCH 105/251] efl: provide Efl.Gfx.Base.color_part and implement it in top Evas_Object. --- src/lib/efl/interfaces/efl_gfx_base.eo | 45 ++++++++++++++++++++++++++ src/lib/evas/canvas/evas_object.eo | 2 ++ src/lib/evas/canvas/evas_object_main.c | 23 +++++++++++++ 3 files changed, 70 insertions(+) diff --git a/src/lib/efl/interfaces/efl_gfx_base.eo b/src/lib/efl/interfaces/efl_gfx_base.eo index e5b719cc25..df9369c620 100644 --- a/src/lib/efl/interfaces/efl_gfx_base.eo +++ b/src/lib/efl/interfaces/efl_gfx_base.eo @@ -74,6 +74,51 @@ interface Efl.Gfx.Base { int a; /*@ The alpha component of the given color. */ } } + color_part { + set { + /*@ + Sets a specifc color of the given Efl.Gfx.Base object to the given + one. + + @see evas_object_color_get() (for an example) + @note These color values are expected to be premultiplied by @p a. + + */ + return: bool; + } + get { + /*@ + Retrieves a specific color of the given Evas object. + + Retrieves a specific color's RGB component (and alpha channel) + values, which range from 0 to 255. For the alpha channel, + which defines the object's transparency level, 0 means totally + transparent, while 255 means opaque. These color values are + premultiplied by the alpha value. + + The “main“ color being mapped to @c NULL. + + Usually you’ll use this attribute for text and rectangle objects, + where the “main” color is their unique one. If set for objects + which themselves have colors, like the images one, those colors get + modulated by this one. + + @note Use @c NULL pointers on the components you're not interested + in: they'll be ignored by the function. + + */ + return: bool; + } + keys { + const (char)* part; /*@ The part you are interested in. */ + } + values { + int r; /*@ The red component of the given color. */ + int g; /*@ The green component of the given color. */ + int b; /*@ The blue component of the given color. */ + int a; /*@ The alpha component of the given color. */ + } + } visible { set { /*@ Makes the given Evas object visible or invisible. */ diff --git a/src/lib/evas/canvas/evas_object.eo b/src/lib/evas/canvas/evas_object.eo index 5caf894d74..51b936933a 100644 --- a/src/lib/evas/canvas/evas_object.eo +++ b/src/lib/evas/canvas/evas_object.eo @@ -1292,6 +1292,8 @@ abstract Evas.Object (Eo.Base, Evas.Common_Interface, Efl.Gfx.Base, Efl.Gfx.Stac Efl.Gfx.Base.position.get; Efl.Gfx.Base.color.set; Efl.Gfx.Base.color.get; + Efl.Gfx.Base.color_part.set; + Efl.Gfx.Base.color_part.get; Efl.Gfx.Base.size.set; Efl.Gfx.Base.size.get; Efl.Gfx.Stack.layer.set; diff --git a/src/lib/evas/canvas/evas_object_main.c b/src/lib/evas/canvas/evas_object_main.c index 4b44830020..3c0c8d51f9 100644 --- a/src/lib/evas/canvas/evas_object_main.c +++ b/src/lib/evas/canvas/evas_object_main.c @@ -1471,6 +1471,17 @@ _evas_object_efl_gfx_base_color_set(Eo *eo_obj, Evas_Object_Protected_Data *obj, evas_object_change(eo_obj, obj); } +EOLIAN static Eina_Bool +_evas_object_efl_gfx_base_color_part_set(Eo *obj, Evas_Object_Protected_Data *pd, + const char *part, + int r, int g, int b, int a) +{ + if (part) return EINA_FALSE; + + _evas_object_efl_gfx_base_color_set(obj, pd, r, g, b, a); + return EINA_TRUE; +} + EAPI void evas_object_color_get(const Evas_Object *obj, int *r, int *g, int *b, int *a) { @@ -1493,6 +1504,18 @@ _evas_object_efl_gfx_base_color_get(Eo *eo_obj EINA_UNUSED, if (a) *a = obj->cur->color.a; } +EOLIAN static Eina_Bool +_evas_object_efl_gfx_base_color_part_get(Eo *obj, + Evas_Object_Protected_Data *pd, + const char *part, + int *r, int *g, int *b, int *a) +{ + if (part) return EINA_FALSE; + + _evas_object_efl_gfx_base_color_get(obj, pd, r, g, b, a); + return EINA_TRUE; +} + EOLIAN static void _evas_object_anti_alias_set(Eo *eo_obj, Evas_Object_Protected_Data *obj, Eina_Bool anti_alias) { From d7f434986edb133a39227491bf3b9e822f62c830 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:30:33 +0200 Subject: [PATCH 106/251] evas: use Efl.Gfx.Base.color_part in Evas.VG_Node. --- src/lib/evas/canvas/evas_vg_node.c | 22 ++++++++++++++++++++++ src/lib/evas/canvas/evas_vg_node.eo | 2 ++ 2 files changed, 24 insertions(+) diff --git a/src/lib/evas/canvas/evas_vg_node.c b/src/lib/evas/canvas/evas_vg_node.c index 86b70f363c..40166a6767 100644 --- a/src/lib/evas/canvas/evas_vg_node.c +++ b/src/lib/evas/canvas/evas_vg_node.c @@ -94,6 +94,17 @@ _evas_vg_node_efl_gfx_base_color_set(Eo *obj EINA_UNUSED, pd->a = a; } +Eina_Bool +_evas_vg_node_efl_gfx_base_color_part_set(Eo *obj, Evas_VG_Node_Data *pd, + const char *part, + int r, int g, int b, int a) +{ + if (part) return EINA_FALSE; + + _evas_vg_node_efl_gfx_base_color_set(obj, pd, r, g, b, a); + return EINA_TRUE; +} + void _evas_vg_node_efl_gfx_base_color_get(Eo *obj EINA_UNUSED, Evas_VG_Node_Data *pd, @@ -105,6 +116,17 @@ _evas_vg_node_efl_gfx_base_color_get(Eo *obj EINA_UNUSED, if (a) *a = pd->a; } +Eina_Bool +_evas_vg_node_efl_gfx_base_color_part_get(Eo *obj, Evas_VG_Node_Data *pd, + const char *part, + int *r, int *g, int *b, int *a) +{ + if (part) return EINA_FALSE; + + _evas_vg_node_efl_gfx_base_color_get(obj, pd, r, g, b, a); + return EINA_TRUE; +} + void _evas_vg_node_mask_set(Eo *obj EINA_UNUSED, Evas_VG_Node_Data *pd, diff --git a/src/lib/evas/canvas/evas_vg_node.eo b/src/lib/evas/canvas/evas_vg_node.eo index d89a1cd7af..e388442318 100644 --- a/src/lib/evas/canvas/evas_vg_node.eo +++ b/src/lib/evas/canvas/evas_vg_node.eo @@ -71,6 +71,8 @@ abstract Evas.VG_Node (Eo.Base, Efl.Gfx.Base, Efl.Gfx.Stack) Efl.Gfx.Base.visible.get; Efl.Gfx.Base.color.set; Efl.Gfx.Base.color.get; + Efl.Gfx.Base.color_part.set; + Efl.Gfx.Base.color_part.get; Efl.Gfx.Base.size.get; Efl.Gfx.Base.position.set; Efl.Gfx.Base.position.get; From 1e1863155498a0215c6ea34239a4e98184736c4a Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:30:34 +0200 Subject: [PATCH 107/251] evas: make Evas.VG_Shape use Efl.Gfx.Base.color_part for stroke. --- src/lib/evas/canvas/evas_vg_shape.c | 38 ++++++++++++++++++++++++++++ src/lib/evas/canvas/evas_vg_shape.eo | 2 ++ 2 files changed, 40 insertions(+) diff --git a/src/lib/evas/canvas/evas_vg_shape.c b/src/lib/evas/canvas/evas_vg_shape.c index c6cee02e6e..a560029dde 100644 --- a/src/lib/evas/canvas/evas_vg_shape.c +++ b/src/lib/evas/canvas/evas_vg_shape.c @@ -79,6 +79,25 @@ _evas_vg_shape_efl_gfx_shape_stroke_color_set(Eo *obj EINA_UNUSED, pd->stroke.a = a; } +static Eina_Bool +_evas_vg_shape_efl_gfx_base_color_part_set(Eo *obj, Evas_VG_Shape_Data *pd, + const char * part, + int r, int g, int b, int a) +{ + Eina_Bool ret; + + if (part && !strcmp(part, "stroke")) + { + _evas_vg_shape_efl_gfx_shape_stroke_color_set(obj, pd, r, g, b, a); + return EINA_TRUE; + } + + eo_do_super(obj, EFL_VG_SHAPE_CLASS, + ret = efl_gfx_color_part_set(part, r, g, b, a)); + + return ret; +} + static void _evas_vg_shape_efl_gfx_shape_stroke_color_get(Eo *obj EINA_UNUSED, Evas_VG_Shape_Data *pd, @@ -90,6 +109,25 @@ _evas_vg_shape_efl_gfx_shape_stroke_color_get(Eo *obj EINA_UNUSED, if (a) *a = pd->stroke.a; } +static Eina_Bool +_evas_vg_shape_efl_gfx_base_color_part_get(Eo *obj, Evas_VG_Shape_Data *pd, + const char * part, + int *r, int *g, int *b, int *a) +{ + Eina_Bool ret; + + if (part && !strcmp(part, "stroke")) + { + _evas_vg_shape_efl_gfx_shape_stroke_color_get(obj, pd, r, g, b, a); + return EINA_TRUE; + } + + eo_do_super(obj, EFL_VG_SHAPE_CLASS, + ret = efl_gfx_color_part_get(part, r, g, b, a)); + + return ret; +} + static void _evas_vg_shape_stroke_fill_set(Eo *obj EINA_UNUSED, Evas_VG_Shape_Data *pd, diff --git a/src/lib/evas/canvas/evas_vg_shape.eo b/src/lib/evas/canvas/evas_vg_shape.eo index dd1ce13482..9127241438 100644 --- a/src/lib/evas/canvas/evas_vg_shape.eo +++ b/src/lib/evas/canvas/evas_vg_shape.eo @@ -39,6 +39,8 @@ class Evas.VG_Shape (Evas.VG_Node, Efl.Gfx.Shape) Efl.Gfx.Shape.stroke_dash; Efl.Gfx.Shape.stroke_cap; Efl.Gfx.Shape.stroke_join; + Efl.Gfx.Base.color_part.set; + Efl.Gfx.Base.color_part.get; Evas.VG_Node.bound_get; Eo.Base.constructor; Eo.Base.destructor; From 32de8d9e5f8d5a306eee10fbfb4a9d10ebcfcb75 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:30:35 +0200 Subject: [PATCH 108/251] efl: move Efl.Gfx.Gradient_* to Efl.Gfx.Gradient.* much nicer for bindings. --- src/Makefile_Efl.am | 2 +- src/Makefile_Efl_Cxx.am | 2 +- .../ector/ector_renderer_generic_gradient.eo | 10 +++---- .../ector_renderer_generic_gradient_linear.eo | 10 +++---- .../ector_renderer_generic_gradient_radial.eo | 14 +++++----- src/lib/ector/ector_renderer_gradient.c | 26 +++++++++---------- src/lib/efl/Efl.h | 2 +- ...x_gradient.eo => efl_gfx_gradient_base.eo} | 3 ++- .../efl/interfaces/efl_gfx_gradient_linear.eo | 2 +- .../efl/interfaces/efl_gfx_gradient_radial.eo | 2 +- src/lib/efl/interfaces/efl_interfaces_main.c | 2 +- src/lib/evas/canvas/evas_vg_gradient.c | 26 +++++++++---------- src/lib/evas/canvas/evas_vg_gradient.eo | 10 +++---- .../evas/canvas/evas_vg_gradient_linear.eo | 10 +++---- .../evas/canvas/evas_vg_gradient_radial.eo | 14 +++++----- 15 files changed, 68 insertions(+), 67 deletions(-) rename src/lib/efl/interfaces/{efl_gfx_gradient.eo => efl_gfx_gradient_base.eo} (81%) diff --git a/src/Makefile_Efl.am b/src/Makefile_Efl.am index 440d41bb58..b65dafc406 100644 --- a/src/Makefile_Efl.am +++ b/src/Makefile_Efl.am @@ -10,7 +10,7 @@ efl_eolian_files = \ lib/efl/interfaces/efl_gfx_fill.eo \ lib/efl/interfaces/efl_gfx_view.eo \ lib/efl/interfaces/efl_gfx_shape.eo \ - lib/efl/interfaces/efl_gfx_gradient.eo \ + lib/efl/interfaces/efl_gfx_gradient_base.eo \ lib/efl/interfaces/efl_gfx_gradient_linear.eo \ lib/efl/interfaces/efl_gfx_gradient_radial.eo diff --git a/src/Makefile_Efl_Cxx.am b/src/Makefile_Efl_Cxx.am index e2ed95a636..fbcc5632ca 100644 --- a/src/Makefile_Efl_Cxx.am +++ b/src/Makefile_Efl_Cxx.am @@ -14,7 +14,7 @@ generated_efl_cxx_bindings = \ lib/efl/interfaces/efl_gfx_fill.eo.hh \ lib/efl/interfaces/efl_gfx_view.eo.hh \ lib/efl/interfaces/efl_gfx_shape.eo.hh \ - lib/efl/interfaces/efl_gfx_gradient.eo.hh \ + lib/efl/interfaces/efl_gfx_gradient_base.eo.hh \ lib/efl/interfaces/efl_gfx_gradient_linear.eo.hh \ lib/efl/interfaces/efl_gfx_gradient_radial.eo.hh diff --git a/src/lib/ector/ector_renderer_generic_gradient.eo b/src/lib/ector/ector_renderer_generic_gradient.eo index 4a34141912..bc50524abd 100644 --- a/src/lib/ector/ector_renderer_generic_gradient.eo +++ b/src/lib/ector/ector_renderer_generic_gradient.eo @@ -1,11 +1,11 @@ -abstract Ector.Renderer.Generic.Gradient (Ector.Renderer.Generic.Base, Efl.Gfx.Gradient) +abstract Ector.Renderer.Generic.Gradient (Ector.Renderer.Generic.Base, Efl.Gfx.Gradient.Base) { eo_prefix: ector_renderer_gradient; legacy_prefix: null; implements { - Efl.Gfx.Gradient.stop.set; - Efl.Gfx.Gradient.stop.get; - Efl.Gfx.Gradient.spread.set; - Efl.Gfx.Gradient.spread.get; + Efl.Gfx.Gradient.Base.stop.set; + Efl.Gfx.Gradient.Base.stop.get; + Efl.Gfx.Gradient.Base.spread.set; + Efl.Gfx.Gradient.Base.spread.get; } } diff --git a/src/lib/ector/ector_renderer_generic_gradient_linear.eo b/src/lib/ector/ector_renderer_generic_gradient_linear.eo index 89ab3e120d..82d560bba0 100644 --- a/src/lib/ector/ector_renderer_generic_gradient_linear.eo +++ b/src/lib/ector/ector_renderer_generic_gradient_linear.eo @@ -1,11 +1,11 @@ -abstract Ector.Renderer.Generic.Gradient_Linear (Ector.Renderer.Generic.Gradient, Efl.Gfx.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.Gfx.Gradient_Linear.start.set; - Efl.Gfx.Gradient_Linear.start.get; - Efl.Gfx.Gradient_Linear.end.set; - Efl.Gfx.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; } } diff --git a/src/lib/ector/ector_renderer_generic_gradient_radial.eo b/src/lib/ector/ector_renderer_generic_gradient_radial.eo index 563c954caa..5b53dadc01 100644 --- a/src/lib/ector/ector_renderer_generic_gradient_radial.eo +++ b/src/lib/ector/ector_renderer_generic_gradient_radial.eo @@ -1,13 +1,13 @@ -abstract Ector.Renderer.Generic.Gradient_Radial (Ector.Renderer.Generic.Gradient, Efl.Gfx.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.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; + 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; } } diff --git a/src/lib/ector/ector_renderer_gradient.c b/src/lib/ector/ector_renderer_gradient.c index 792f8393db..6cf676fbb0 100644 --- a/src/lib/ector/ector_renderer_gradient.c +++ b/src/lib/ector/ector_renderer_gradient.c @@ -8,10 +8,10 @@ #include "ector_private.h" static void -_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) +_ector_renderer_generic_gradient_efl_gfx_gradient_base_stop_set(Eo *obj EINA_UNUSED, + Ector_Renderer_Generic_Gradient_Data *pd, + const Efl_Gfx_Gradient_Stop *colors, + unsigned int length) { pd->colors = realloc(pd->colors, length * sizeof(Efl_Gfx_Gradient_Stop)); if (!pd->colors) @@ -25,26 +25,26 @@ _ector_renderer_generic_gradient_efl_gfx_gradient_stop_set(Eo *obj, } static void -_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) +_ector_renderer_generic_gradient_efl_gfx_gradient_base_stop_get(Eo *obj EINA_UNUSED, + 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_gfx_gradient_spread_set(Eo *obj, - Ector_Renderer_Generic_Gradient_Data *pd, - Efl_Gfx_Gradient_Spread s) +_ector_renderer_generic_gradient_efl_gfx_gradient_base_spread_set(Eo *obj EINA_UNUSED, + Ector_Renderer_Generic_Gradient_Data *pd, + Efl_Gfx_Gradient_Spread s) { pd->s = s; } static Efl_Gfx_Gradient_Spread -_ector_renderer_generic_gradient_efl_gfx_gradient_spread_get(Eo *obj, - Ector_Renderer_Generic_Gradient_Data *pd) +_ector_renderer_generic_gradient_efl_gfx_gradient_base_spread_get(Eo *obj EINA_UNUSED, + Ector_Renderer_Generic_Gradient_Data *pd) { return pd->s; } diff --git a/src/lib/efl/Efl.h b/src/lib/efl/Efl.h index 9b0dea2960..a4df2bf86d 100644 --- a/src/lib/efl/Efl.h +++ b/src/lib/efl/Efl.h @@ -142,7 +142,7 @@ typedef enum _Efl_Gfx_Fill_Spread #include "interfaces/efl_gfx_fill.eo.h" #include "interfaces/efl_gfx_view.eo.h" #include "interfaces/efl_gfx_shape.eo.h" -#include "interfaces/efl_gfx_gradient.eo.h" +#include "interfaces/efl_gfx_gradient_base.eo.h" #include "interfaces/efl_gfx_gradient_linear.eo.h" #include "interfaces/efl_gfx_gradient_radial.eo.h" diff --git a/src/lib/efl/interfaces/efl_gfx_gradient.eo b/src/lib/efl/interfaces/efl_gfx_gradient_base.eo similarity index 81% rename from src/lib/efl/interfaces/efl_gfx_gradient.eo rename to src/lib/efl/interfaces/efl_gfx_gradient_base.eo index 3bd5bff3df..bb5714f5fe 100644 --- a/src/lib/efl/interfaces/efl_gfx_gradient.eo +++ b/src/lib/efl/interfaces/efl_gfx_gradient_base.eo @@ -1,5 +1,6 @@ -interface Efl.Gfx.Gradient +interface Efl.Gfx.Gradient.Base { + eo_prefix: efl_gfx_gradient; legacy_prefix: null; properties { stop { diff --git a/src/lib/efl/interfaces/efl_gfx_gradient_linear.eo b/src/lib/efl/interfaces/efl_gfx_gradient_linear.eo index 8d7f398284..a8581d9e54 100644 --- a/src/lib/efl/interfaces/efl_gfx_gradient_linear.eo +++ b/src/lib/efl/interfaces/efl_gfx_gradient_linear.eo @@ -1,4 +1,4 @@ -interface Efl.Gfx.Gradient_Linear (Efl.Gfx.Gradient) +interface Efl.Gfx.Gradient.Linear (Efl.Gfx.Gradient.Base) { legacy_prefix: null; properties { diff --git a/src/lib/efl/interfaces/efl_gfx_gradient_radial.eo b/src/lib/efl/interfaces/efl_gfx_gradient_radial.eo index 6e930245e2..e499ed0a11 100644 --- a/src/lib/efl/interfaces/efl_gfx_gradient_radial.eo +++ b/src/lib/efl/interfaces/efl_gfx_gradient_radial.eo @@ -1,4 +1,4 @@ -interface Efl.Gfx.Gradient_Radial (Efl.Gfx.Gradient) +interface Efl.Gfx.Gradient.Radial (Efl.Gfx.Gradient.Base) { legacy_prefix: null; properties { diff --git a/src/lib/efl/interfaces/efl_interfaces_main.c b/src/lib/efl/interfaces/efl_interfaces_main.c index 6c7740491f..271bfb07d9 100644 --- a/src/lib/efl/interfaces/efl_interfaces_main.c +++ b/src/lib/efl/interfaces/efl_interfaces_main.c @@ -16,6 +16,6 @@ #include "interfaces/efl_gfx_fill.eo.c" #include "interfaces/efl_gfx_view.eo.c" -#include "interfaces/efl_gfx_gradient.eo.c" +#include "interfaces/efl_gfx_gradient_base.eo.c" #include "interfaces/efl_gfx_gradient_linear.eo.c" #include "interfaces/efl_gfx_gradient_radial.eo.c" diff --git a/src/lib/evas/canvas/evas_vg_gradient.c b/src/lib/evas/canvas/evas_vg_gradient.c index ffff936533..41f2ea98e0 100644 --- a/src/lib/evas/canvas/evas_vg_gradient.c +++ b/src/lib/evas/canvas/evas_vg_gradient.c @@ -6,10 +6,10 @@ #include static void -_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) +_evas_vg_gradient_efl_gfx_gradient_base_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_Gfx_Gradient_Stop)); if (!pd->colors) @@ -23,26 +23,26 @@ _evas_vg_gradient_efl_gfx_gradient_stop_set(Eo *obj EINA_UNUSED, } static void -_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) +_evas_vg_gradient_efl_gfx_gradient_base_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_gfx_gradient_spread_set(Eo *obj EINA_UNUSED, - Evas_VG_Gradient_Data *pd, - Efl_Gfx_Gradient_Spread s) +_evas_vg_gradient_efl_gfx_gradient_base_spread_set(Eo *obj EINA_UNUSED, + Evas_VG_Gradient_Data *pd, + Efl_Gfx_Gradient_Spread s) { pd->s = s; } static Efl_Gfx_Gradient_Spread -_evas_vg_gradient_efl_gfx_gradient_spread_get(Eo *obj EINA_UNUSED, - Evas_VG_Gradient_Data *pd) +_evas_vg_gradient_efl_gfx_gradient_base_spread_get(Eo *obj EINA_UNUSED, + Evas_VG_Gradient_Data *pd) { return pd->s; } diff --git a/src/lib/evas/canvas/evas_vg_gradient.eo b/src/lib/evas/canvas/evas_vg_gradient.eo index e2b49c3611..29f1de242b 100644 --- a/src/lib/evas/canvas/evas_vg_gradient.eo +++ b/src/lib/evas/canvas/evas_vg_gradient.eo @@ -1,11 +1,11 @@ -abstract Evas.VG_Gradient (Evas.VG_Node, Efl.Gfx.Gradient) +abstract Evas.VG_Gradient (Evas.VG_Node, Efl.Gfx.Gradient.Base) { eo_prefix: evas_vg_gradient; legacy_prefix: null; implements { - Efl.Gfx.Gradient.stop.set; - Efl.Gfx.Gradient.stop.get; - Efl.Gfx.Gradient.spread.set; - Efl.Gfx.Gradient.spread.get; + Efl.Gfx.Gradient.Base.stop.set; + Efl.Gfx.Gradient.Base.stop.get; + Efl.Gfx.Gradient.Base.spread.set; + Efl.Gfx.Gradient.Base.spread.get; } } diff --git a/src/lib/evas/canvas/evas_vg_gradient_linear.eo b/src/lib/evas/canvas/evas_vg_gradient_linear.eo index 05af5c80d6..95a773a0db 100644 --- a/src/lib/evas/canvas/evas_vg_gradient_linear.eo +++ b/src/lib/evas/canvas/evas_vg_gradient_linear.eo @@ -1,12 +1,12 @@ -class Evas.VG_Gradient_Linear (Evas.VG_Gradient, Efl.Gfx.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.Gfx.Gradient_Linear.start.set; - Efl.Gfx.Gradient_Linear.start.get; - Efl.Gfx.Gradient_Linear.end.set; - Efl.Gfx.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; } diff --git a/src/lib/evas/canvas/evas_vg_gradient_radial.eo b/src/lib/evas/canvas/evas_vg_gradient_radial.eo index 6fc9c6e42e..bab5282b9e 100644 --- a/src/lib/evas/canvas/evas_vg_gradient_radial.eo +++ b/src/lib/evas/canvas/evas_vg_gradient_radial.eo @@ -1,14 +1,14 @@ -class Evas.VG_Gradient_Radial (Evas.VG_Gradient, Efl.Gfx.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.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; + 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; } From dd587216133fd3938c44cc6c77ef525a5e077341 Mon Sep 17 00:00:00 2001 From: Subhransu Sekhar Mohanty Date: Fri, 3 Apr 2015 16:30:35 +0200 Subject: [PATCH 109/251] efl: add documentation for Efl.Gfx enums. --- src/lib/efl/Efl.h | 84 +++++++++++++++++++++++++++-------------------- 1 file changed, 48 insertions(+), 36 deletions(-) diff --git a/src/lib/efl/Efl.h b/src/lib/efl/Efl.h index a4df2bf86d..b2b9a82448 100644 --- a/src/lib/efl/Efl.h +++ b/src/lib/efl/Efl.h @@ -35,85 +35,97 @@ extern "C" #endif /* ! _WIN32 */ /** - * Path command enum. + * These values determine how the points are interpreted in a stream of points. * - * @since 1.13 - * @ingroup Efl_Gfx_Shape + * @since 1.14 */ typedef enum _Efl_Gfx_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_END = 0, /**< The end of stream , no more points to process. */ + EFL_GFX_PATH_COMMAND_TYPE_MOVE_TO, /**< The next point is the start point of a sub path */ + EFL_GFX_PATH_COMMAND_TYPE_LINE_TO, /**< The next point is used to draw a line from current point */ + EFL_GFX_PATH_COMMAND_TYPE_CUBIC_TO, /**< The next three point is used to draw a cubic bezier curve from current point */ + EFL_GFX_PATH_COMMAND_TYPE_CLOSE, /**< Close the curent subpath by drawing a line between current point and the first point of current subpath */ 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 + * + * @see efl_gfx_shape_stroke_dash_set() + * + * @since 1.14 */ typedef struct _Efl_Gfx_Dash Efl_Gfx_Dash; struct _Efl_Gfx_Dash { - double length; - double gap; + double length; /**< dash drawing length */ + double gap; /**< distance bettwen two dashes */ }; /** - * Type defining how a line end. - * @since 1.13 + * These values determine how the end of opened sub-paths are rendered in a + * stroke. + * + * @see efl_gfx_shape_stroke_cap_set() + * + * @since 1.14 */ typedef enum _Efl_Gfx_Cap { - EFL_GFX_CAP_BUTT, - EFL_GFX_CAP_ROUND, - EFL_GFX_CAP_SQUARE, - EFL_GFX_CAP_LAST + EFL_GFX_CAP_BUTT = 0, /**< The end of lines is rendered as a full stop on the last point itself */ + EFL_GFX_CAP_ROUND, /**< The end of lines is rendered as a half-circle around the last point */ + EFL_GFX_CAP_SQUARE, /**< The end of lines is rendered as a square around the last point */ + EFL_GFX_CAP_LAST /**< End of enum value */ } Efl_Gfx_Cap; /** - * Type defining how join between path are drawn. - * @since 1.13 + * These values determine how two joining lines are rendered in a stroker. + * + * @see efl_gfx_shape_stroke_join_set() + * + * @since 1.14 */ typedef enum _Efl_Gfx_Join { - EFL_GFX_JOIN_MITER, - EFL_GFX_JOIN_ROUND, - EFL_GFX_JOIN_BEVEL, - EFL_GFX_JOIN_LAST + EFL_GFX_JOIN_MITER = 0, /**< Used to render rounded line joins. Circular arcs are used to join two lines smoothly. */ + EFL_GFX_JOIN_ROUND, /**< Used to render beveled line joins. The outer corner of the joined lines is filled by enclosing the triangular region of the corner with a straight line between the outer corners of each stroke. */ + EFL_GFX_JOIN_BEVEL, /**< Used to render mitered line joins. The intersection of the strokes is clipped at a line perpendicular to the bisector of the angle between the strokes, at the distance from the intersection of the segments equal to the product of the miter limit value and the border radius. This prevents long spikes being created. */ + EFL_GFX_JOIN_LAST /**< End of enum value */ } Efl_Gfx_Join; /** * Type defining gradient stop. - * @since 1.13 + * @since 1.14 */ typedef struct _Efl_Gfx_Gradient_Stop Efl_Gfx_Gradient_Stop; struct _Efl_Gfx_Gradient_Stop { - double offset; - int r; - int g; - int b; - int a; + double offset; /**< The location of the gradient stop within the gradient vector*/ + int r; /**< The component R color of the gradient stop */ + int g; /**< The component G color of the gradient stop */ + int b; /**< The component B color of the graident stop */ + int a; /**< The component A color of the graident stop */ }; /** - * Type defining how the gradient spread after its limit. - * @since 1.13 + * Specifies how the area outside the gradient area should be filled. + * + * @see efl_gfx_gradient_spread_set() + * + * @since 1.14 */ typedef enum _Efl_Gfx_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_PAD, /**< The area is filled with the closest stop color. This is the default. */ + EFL_GFX_GRADIENT_SPREAD_REFLECT, /**< The gradient is reflected outside the gradient area. */ + EFL_GFX_GRADIENT_SPREAD_REPEAT, /**< The gradient is repeated outside the gradient area. */ + EFL_GFX_GRADIENT_SPREAD_LAST /**< End of enum value */ } Efl_Gfx_Gradient_Spread; /** * Type defining how an image content get filled. - * @since 1.13 + * @since 1.14 */ typedef enum _Efl_Gfx_Fill_Spread { From a068378c831926c9d95ae9d45a0b0bd6c33abac6 Mon Sep 17 00:00:00 2001 From: Subhransu Sekhar Mohanty Date: Fri, 3 Apr 2015 16:30:36 +0200 Subject: [PATCH 110/251] evas: add documentation for Evas_Object_VG --- src/lib/evas/Evas_Legacy.h | 97 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) diff --git a/src/lib/evas/Evas_Legacy.h b/src/lib/evas/Evas_Legacy.h index 3258613124..8f53493961 100644 --- a/src/lib/evas/Evas_Legacy.h +++ b/src/lib/evas/Evas_Legacy.h @@ -1621,6 +1621,103 @@ EAPI void *evas_object_intercept_focus_set_callback_del(Evas_Object *obj, Evas_O EAPI Evas_Object *evas_object_rectangle_add(Evas *e) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC; #include "canvas/evas_rectangle.eo.legacy.h" + +/** + * @} + */ + +/** + * @defgroup Evas_Object_Vg + * @ingroup Evas + * + * Evas_Object_Vg is the scene graph for managing vector graphics objects. + * User can create shape objects as well as fill objects and give it to the + * Evas_Object_Vg for drawing on the screen as well as managing the lifecycle + * of the objects. enabling reuse of shape objects. + * + * As Evas_Object_Vg is a Evas_Object all the operation that applicable to + * a Evas_Object can be performed on it(clipping , map, etc). + * + * To create any complex vector graphics you can create a hirarchy of shape + * and fill objects and give the hirarchy to Evas_Object which will be + * responsible for drawing and showing on the screen. + * + * As the shape object and fill object (linear and radial gradient) have + * retain mode API, you only have to create it once and set the properties + * and give it to evas_object_vg. + * + * Any change in the property of shape/fill object will automaticaly notified + * to the evas_object_vg which will trigger a redrawing to reflect the change. + * + * To create a vector path, you can give list of path commands to the shape + * object using efl_gfx_shape_path_set() API. + * + * Enabling graphical shapes to be constructed and reused. + * + * Below are the list of feature currently supported by Vector object. + * + * @li Drawing SVG Path. + * You can construct a path by using api in efl_gfx_utils.h + * + * @li Gradient filling and stroking. + * You can fill or stroke the path using linear or radial gradient. + * @see Evas_Vg_Gradient_Linear and Evas_Vg_Gradient_Radial + * + * @li Transformation support for path and gradient fill. You can apply + affin transformation on path object. + * @see Eina_Matrix. + * + * @note Below are the list of interface, classes can be used to draw vector + * graphics using vector object. + * + * @li Efl.Gfx.Shape + * @li Evas.VG_Shape + * @li Evas.VG_Node + * @li Efl.Gfx.Gradient + * @li Efl.Gfx.Gradient_Radial + * @li Efl.Gfx.Gradient_Linear + * + * Example: + * @code + * vector = evas_object_vg_add(canvas); + * root = evas_obj_vg_root_node_get(vector); + * shape = eo_add(EVAS_VG_SHAPE_CLASS, root); + * Efl_Gfx_Path_Command *path_cmd = NULL; + * double *points = NULL; + * efl_gfx_path_append_circle(&path_cmd, &points); + * eo_do(shape, + * evas_vg_node_origin_set(10, 10), + * efl_gfx_shape_stroke_width_set(1.0), + * evas_vg_node_color_set(128, 128, 128, 80), + * efl_gfx_shape_path_set(path_cmd, points)); + * @endcode + * + * @since 1.14 + */ + +/** + * Creates a new vector object on the given Evas @p e canvas. + * + * @param e The given canvas. + * @return The created vector object handle. + * + * The shape object hirarchy can be added to the evas_object_vg by accessing + * the rootnode of the vg canvas and adding the hirarchy as child to the root + * node. + * + * @see evas_obj_vg_root_node_get() + * @since 1.14 + */ +EAPI Evas_Object *evas_object_vg_add(Evas *e) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC; + +#include "canvas/evas_vg_node.eo.legacy.h" +#include "canvas/evas_vg.eo.legacy.h" +#include "canvas/evas_vg_shape.eo.legacy.h" +#include "canvas/evas_vg_gradient.eo.legacy.h" +#include "canvas/evas_vg_gradient_linear.eo.legacy.h" +#include "canvas/evas_vg_gradient_radial.eo.legacy.h" +#include "canvas/evas_vg_image.eo.legacy.h" + /** * @} */ From b108fe8a10c2096aef9539006572d8fd37c945b2 Mon Sep 17 00:00:00 2001 From: Subhransu Sekhar Mohanty Date: Fri, 3 Apr 2015 16:30:37 +0200 Subject: [PATCH 111/251] efl: add documentation for shape and gradient interface. --- .../efl/interfaces/efl_gfx_gradient_base.eo | 39 ++-- .../efl/interfaces/efl_gfx_gradient_linear.eo | 40 ++-- .../efl/interfaces/efl_gfx_gradient_radial.eo | 58 ++++-- src/lib/efl/interfaces/efl_gfx_shape.eo | 180 ++++++++++++------ 4 files changed, 216 insertions(+), 101 deletions(-) diff --git a/src/lib/efl/interfaces/efl_gfx_gradient_base.eo b/src/lib/efl/interfaces/efl_gfx_gradient_base.eo index bb5714f5fe..b50d7bca1b 100644 --- a/src/lib/efl/interfaces/efl_gfx_gradient_base.eo +++ b/src/lib/efl/interfaces/efl_gfx_gradient_base.eo @@ -5,23 +5,34 @@ interface Efl.Gfx.Gradient.Base properties { stop { set { - } - get { - } - values { - const(Efl_Gfx_Gradient_Stop) *colors; - uint length; - } + /*@ + Set the list of color stops for the gradient + */ + } + get { + /*@ + get the list of color stops. + */ + } + values { + const(Efl_Gfx_Gradient_Stop) *colors; /*@ color stops list*/ + uint length; /*@ length of the list */ + } } spread { set { - } - get { - } - values { - Efl_Gfx_Gradient_Spread s; - } + /*@ + Specifies the spread method that should be used for this gradient. + */ + } + get { + /*@ + Returns the spread method use by this gradient. The default is EFL_GFX_GRADIENT_SPREAD_PAD. + */ + } + values { + Efl_Gfx_Gradient_Spread s; /*@ spread type to be used */ + } } } - } diff --git a/src/lib/efl/interfaces/efl_gfx_gradient_linear.eo b/src/lib/efl/interfaces/efl_gfx_gradient_linear.eo index a8581d9e54..0d9299fe63 100644 --- a/src/lib/efl/interfaces/efl_gfx_gradient_linear.eo +++ b/src/lib/efl/interfaces/efl_gfx_gradient_linear.eo @@ -4,23 +4,35 @@ interface Efl.Gfx.Gradient.Linear (Efl.Gfx.Gradient.Base) properties { start { set { - } - get { - } - values { - double x; - double y; - } + /*@ + Sets the start point of this linear gradient. + */ + } + get { + /*@ + Gets the start point of this linear gradient. + */ + } + values { + double x; /*@ x co-ordinate of start point */ + double y; /*@ y co-ordinate of start point */ + } } end { set { - } - get { - } - values { - double x; - double y; - } + /*@ + Sets the end point of this linear gradient. + */ + } + get { + /*@ + Gets the end point of this linear gradient. + */ + } + values { + double x; /*@ x co-ordinate of end point */ + double y; /*@ y co-ordinate of end point */ + } } } } diff --git a/src/lib/efl/interfaces/efl_gfx_gradient_radial.eo b/src/lib/efl/interfaces/efl_gfx_gradient_radial.eo index e499ed0a11..b9eeb72830 100644 --- a/src/lib/efl/interfaces/efl_gfx_gradient_radial.eo +++ b/src/lib/efl/interfaces/efl_gfx_gradient_radial.eo @@ -4,32 +4,50 @@ interface Efl.Gfx.Gradient.Radial (Efl.Gfx.Gradient.Base) properties { center { set { - } - get { - } - values { - double x; - double y; - } + /*@ + Sets the center of this radial gradient. + */ + } + get { + /*@ + Gets the center of this radial gradient. + */ + } + values { + double x; /*@ x co-ordinate of center point */ + double y; /*@ y co-ordinate of center point */ + } } radius { set { - } - get { - } - values { - double r; - } + /*@ + Sets the center radius of this radial gradient. + */ + } + get { + /*@ + Gets the center radius of this radial gradient. + */ + } + values { + double r; /*@ center radius */ + } } focal { set { - } - get { - } - values { - double x; - double y; - } + /*@ + Sets the focal point of this radial gradient. + */ + } + get { + /*@ + Gets the focal point of this radial gradient. + */ + } + values { + double x; /*@ x co-ordinate of focal point */ + double y; /*@ y co-ordinate of focal point */ + } } } } diff --git a/src/lib/efl/interfaces/efl_gfx_shape.eo b/src/lib/efl/interfaces/efl_gfx_shape.eo index 0369283f68..52ca448da0 100644 --- a/src/lib/efl/interfaces/efl_gfx_shape.eo +++ b/src/lib/efl/interfaces/efl_gfx_shape.eo @@ -4,80 +4,154 @@ class Efl.Gfx.Shape properties { stroke_scale { set { - } - get { - } - values { - double s; - } + /*@ + Sets the stroke scale to be used for stroking the path. + the scale property will be used along with stroke width property. + @since 1.14 + */ + } + get { + /*@ + Get the stroke scaling factor used for stroking this path. + @since 1.14 + */ + } + values { + double s; /*@ stroke scale value */ + } } stroke_color { set { - } - get { - } - values { - int r; - int g; - int b; - int a; - } + /*@ + Sets the color to be used for stroking the path. + @since 1.14 + */ + } + get { + /*@ + Gets the color used for stroking the path. + @since 1.14 + */ + } + values { + int r; /*@ The red component of the given color. */ + int g; /*@ The green component of the given color. */ + int b; /*@ The blue component of the given color. */ + int a; /*@ The alpha component of the given color. */ + } } stroke_width { set { - } - get { - } - values { - double w; - } + /*@ + Sets the stroke width to be used for stroking the path. + @since 1.14 + */ + } + get { + /*@ + Gets the stroke width to be used for stroking the path. + @since 1.14 + */ + } + values { + double w; /*@ stroke width to be used */ + } } stroke_location { set { - } - get { - } - values { - double centered; - } + /*@ + Not Implemented + */ + } + get { + /*@ + Not Implemented + */ + } + values { + double centered; /*@ */ + } } stroke_dash { set { - } - get { - } - values { - const(Efl_Gfx_Dash) *dash; - uint length; - } + /*@ + Not Implemented + */ + } + get { + /*@ + Not Implemented + */ + } + values { + const(Efl_Gfx_Dash) *dash; /*@ */ + uint length; /*@ */ + } } stroke_cap { set { - } - get { - } - values { - Efl_Gfx_Cap c; - } + /*@ + Sets the cap style to be used for stroking the path. + The cap will be used for capping the end point of a + open subpath. + + @see Efl_Gfx_Cap + @since 1.14 + */ + } + get { + /*@ + Gets the cap style used for stroking path. + @since 1.14 + */ + } + values { + Efl_Gfx_Cap c; /*@ cap style to use , default is EFL_GFX_CAP_BUTT */ + } } stroke_join { set { - } - get { - } - values { - Efl_Gfx_Join j; - } + /*@ + Sets the join style to be used for stroking the path. + The join style will be used for joining the two line segment + while stroking teh path. + + @see Efl_Gfx_Join + @since 1.14 + */ + } + get { + /*@ + Gets the join style used for stroking path. + @since 1.14 + */ + } + values { + Efl_Gfx_Join j; /*@ join style to use , default is + EFL_GFX_JOIN_MITER */ + } } path { set { - } - get { - } - values { - const(Efl_Gfx_Path_Command) *commands; - const(double) *points; - } + /*@ + Set the list of commands and points to be used to create the + content of shape. + + @note see efl_gfx_path interface for how to create a command list. + @see Efl_Gfx_Path_Command + @since 1.14 + */ + } + get { + /*@ + Gets the command and points list + @since 1.14 + */ + } + values { + const(Efl_Gfx_Path_Command) *op; /*@ command list */ + const(double) *points; /*@ point list */ + } } path_length { get { From 7ee3f8d952dd2568aff2e2fd98af56012083d610 Mon Sep 17 00:00:00 2001 From: Subhransu Sekhar Mohanty Date: Fri, 3 Apr 2015 16:30:38 +0200 Subject: [PATCH 112/251] evas: add documentation for Evas_Object_Vg class. --- src/lib/evas/canvas/evas_vg.eo | 20 +++++--- src/lib/evas/canvas/evas_vg_node.eo | 75 ++++++++++++++++++----------- 2 files changed, 61 insertions(+), 34 deletions(-) diff --git a/src/lib/evas/canvas/evas_vg.eo b/src/lib/evas/canvas/evas_vg.eo index 97e38c53b3..f7e91c394c 100644 --- a/src/lib/evas/canvas/evas_vg.eo +++ b/src/lib/evas/canvas/evas_vg.eo @@ -4,13 +4,21 @@ class Evas.VG (Evas.Object, Efl.File, Efl.Gfx.Fill, Efl.Gfx.View) eo_prefix: evas_obj_vg; properties { root_node { - get { - } - values { - Evas_VG_Node *container; - } + get { + /*@ + Get the root node of the evas_object_vg. + + @note To manually create the shape object and show in the Vg + object canvas you must create the hirarchy and set the + parent as root node. + @since 1.14 + */ + } + values { + Evas_VG_Node *container; /*@ Root node of the VG canvas */ + } } - } + } implements { Eo.Base.constructor; Efl.File.file.set; diff --git a/src/lib/evas/canvas/evas_vg_node.eo b/src/lib/evas/canvas/evas_vg_node.eo index e388442318..83c7014ae1 100644 --- a/src/lib/evas/canvas/evas_vg_node.eo +++ b/src/lib/evas/canvas/evas_vg_node.eo @@ -5,22 +5,39 @@ abstract Evas.VG_Node (Eo.Base, Efl.Gfx.Base, Efl.Gfx.Stack) properties { transformation { set { - } - get { - } - values { - const(Eina_Matrix3) *m; - } + /*@ + Sets the transformation matrix to be used for this node object. + @since 1.14 + */ + } + get { + /*@ + Gets the transformation matrix used for this node object. + @since 1.14 + */ + } + values { + const(Eina_Matrix3) *m; /*@ transformation matrix */ + } } origin { set { - } - get { - } - values { - double x; - double y; - } + /*@ + Sets the origin position of this node object. This origin position + affects to node transformation + @since 1.14 + */ + } + get { + /*@ + Gets the origin position of this node object. + @since 1.14 + */ + } + values { + double x; /* @origin x position */ + double y; /* @origin y position */ + } } mask { set { @@ -43,25 +60,27 @@ abstract Evas.VG_Node (Eo.Base, Efl.Gfx.Base, Efl.Gfx.Stack) } methods { bound_get { - /*@ - Give the bounding box in screen coordinate as being drawn. - It will start as the control box until it is refined once - the shape is computed. - */ + /*@ + Give the bounding box in screen coordinate as being drawn. + It will start as the control box until it is refined once the shape + is computed. + @since 1.14 + */ return: bool @warn_unused; - params { - @out Eina_Rectangle r; - } + params { + @out Eina_Rectangle r; /*@ bounding box to be returned */ + } } original_bound_get { - /*@ - Give the bounding box in screen coordinate as defined in - the file or at the insertion of the object (before any scaling). - */ + /*@ + Give the bounding box in screen coordinate as defined in + the file or at the insertion of the object (before any scaling). + @since 1.14 + */ return: bool @warn_unused; - params { - @out Eina_Rectangle r; - } + params { + @out Eina_Rectangle r; /*@ original bounding box to be returned */ + } } } implements { From 94418f1cd50c33fb729b796ec9acf6f2cd731dc8 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:30:39 +0200 Subject: [PATCH 113/251] efl: add a changed event triggered when something affect the visual aspect of an object. --- src/lib/efl/Efl.h | 6 ++++-- src/lib/efl/interfaces/efl_interfaces_main.c | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/lib/efl/Efl.h b/src/lib/efl/Efl.h index b2b9a82448..4c17f3c545 100644 --- a/src/lib/efl/Efl.h +++ b/src/lib/efl/Efl.h @@ -139,6 +139,10 @@ typedef enum _Efl_Gfx_Fill_Spread #ifdef EFL_BETA_API_SUPPORT +EAPI extern const Eo_Event_Description _EFL_GFX_CHANGED; + +#define EFL_GFX_CHANGED (&(_EFL_GFX_CHANGED)) + /* Interfaces */ #include "interfaces/efl_control.eo.h" #include "interfaces/efl_file.eo.h" @@ -147,8 +151,6 @@ typedef enum _Efl_Gfx_Fill_Spread #include "interfaces/efl_text.eo.h" #include "interfaces/efl_text_properties.eo.h" -#include "interfaces/efl_gfx_utils.h" - #include "interfaces/efl_gfx_base.eo.h" #include "interfaces/efl_gfx_stack.eo.h" #include "interfaces/efl_gfx_fill.eo.h" diff --git a/src/lib/efl/interfaces/efl_interfaces_main.c b/src/lib/efl/interfaces/efl_interfaces_main.c index 271bfb07d9..dafda5bf7e 100644 --- a/src/lib/efl/interfaces/efl_interfaces_main.c +++ b/src/lib/efl/interfaces/efl_interfaces_main.c @@ -19,3 +19,6 @@ #include "interfaces/efl_gfx_gradient_base.eo.c" #include "interfaces/efl_gfx_gradient_linear.eo.c" #include "interfaces/efl_gfx_gradient_radial.eo.c" + +EAPI const Eo_Event_Description _EFL_GFX_CHANGED = + EO_EVENT_DESCRIPTION("Graphics changed", "The visual representation of the object changed"); From 9fd2b74b081fc86364a8fe635fe3c89035e1e7e2 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:30:40 +0200 Subject: [PATCH 114/251] efl: trigger EFL_GFX_CHANGED on path change. --- src/lib/efl/interfaces/efl_gfx_shape.c | 30 ++++++++++++++++++++------ 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/src/lib/efl/interfaces/efl_gfx_shape.c b/src/lib/efl/interfaces/efl_gfx_shape.c index d90ecd2bf5..0815671c9f 100644 --- a/src/lib/efl/interfaces/efl_gfx_shape.c +++ b/src/lib/efl/interfaces/efl_gfx_shape.c @@ -135,7 +135,7 @@ _efl_gfx_path_current_search(const Efl_Gfx_Path_Command *cmd, } void -_efl_gfx_shape_path_set(Eo *obj EINA_UNUSED, Efl_Gfx_Shape_Data *pd, +_efl_gfx_shape_path_set(Eo *obj, Efl_Gfx_Shape_Data *pd, const Efl_Gfx_Path_Command *commands, const double *points) { @@ -164,6 +164,8 @@ _efl_gfx_shape_path_set(Eo *obj EINA_UNUSED, Efl_Gfx_Shape_Data *pd, _efl_gfx_path_current_search(pd->commands, pd->points, &pd->current.x, &pd->current.y, &pd->current_ctrl.x, &pd->current_ctrl.y); + + eo_do(obj, eo_event_callback_call(EFX_GFX_CHANGED, NULL)); } void @@ -221,7 +223,7 @@ interpolate(double from, double to, double pos_map) } Eina_Bool -_efl_gfx_shape_interpolate(Eo *obj EINA_UNUSED, Efl_Gfx_Shape_Data *pd, +_efl_gfx_shape_interpolate(Eo *obj, Efl_Gfx_Shape_Data *pd, const Eo *from, const Eo *to, double pos_map) { Efl_Gfx_Shape_Data *from_pd, *to_pd; @@ -274,6 +276,8 @@ _efl_gfx_shape_interpolate(Eo *obj EINA_UNUSED, Efl_Gfx_Shape_Data *pd, to_pd->current_ctrl.y, pos_map); + eo_do(obj, eo_event_callback_call(EFX_GFX_CHANGED, NULL)); + return EINA_TRUE; } @@ -324,10 +328,12 @@ _efl_gfx_shape_dup(Eo *obj, Efl_Gfx_Shape_Data *pd, Eo *dup_from) efl_gfx_shape_stroke_join_set(j)); _efl_gfx_shape_path_set(obj, pd, from->commands, from->points); + + eo_do(obj, eo_event_callback_call(EFX_GFX_CHANGED, NULL)); } void -_efl_gfx_shape_reset(Eo *obj EINA_UNUSED, Efl_Gfx_Shape_Data *pd) +_efl_gfx_shape_reset(Eo *obj, Efl_Gfx_Shape_Data *pd) { free(pd->commands); pd->commands = NULL; @@ -341,10 +347,12 @@ _efl_gfx_shape_reset(Eo *obj EINA_UNUSED, Efl_Gfx_Shape_Data *pd) pd->current.y = 0; pd->current_ctrl.x = 0; pd->current_ctrl.y = 0; + + eo_do(obj, eo_event_callback_call(EFX_GFX_CHANGED, NULL)); } void -_efl_gfx_shape_append_move_to(Eo *obj EINA_UNUSED, Efl_Gfx_Shape_Data *pd, +_efl_gfx_shape_append_move_to(Eo *obj, Efl_Gfx_Shape_Data *pd, double x, double y) { double *offset_point; @@ -358,10 +366,12 @@ _efl_gfx_shape_append_move_to(Eo *obj EINA_UNUSED, Efl_Gfx_Shape_Data *pd, pd->current.x = x; pd->current.y = y; + + eo_do(obj, eo_event_callback_call(EFX_GFX_CHANGED, NULL)); } void -_efl_gfx_shape_append_line_to(Eo *obj EINA_UNUSED, Efl_Gfx_Shape_Data *pd, +_efl_gfx_shape_append_line_to(Eo *obj, Efl_Gfx_Shape_Data *pd, double x, double y) { double *offset_point; @@ -375,10 +385,12 @@ _efl_gfx_shape_append_line_to(Eo *obj EINA_UNUSED, Efl_Gfx_Shape_Data *pd, pd->current.x = x; pd->current.y = y; + + eo_do(obj, eo_event_callback_call(EFX_GFX_CHANGED, NULL)); } void -_efl_gfx_shape_append_cubic_to(Eo *obj EINA_UNUSED, Efl_Gfx_Shape_Data *pd, +_efl_gfx_shape_append_cubic_to(Eo *obj, Efl_Gfx_Shape_Data *pd, double x, double y, double ctrl_x0, double ctrl_y0, double ctrl_x1, double ctrl_y1) @@ -400,6 +412,8 @@ _efl_gfx_shape_append_cubic_to(Eo *obj EINA_UNUSED, Efl_Gfx_Shape_Data *pd, pd->current.y = y; pd->current_ctrl.x = ctrl_x1; pd->current_ctrl.y = ctrl_y1; + + eo_do(obj, eo_event_callback_call(EFX_GFX_CHANGED, NULL)); } void @@ -620,12 +634,14 @@ _efl_gfx_shape_append_arc_to(Eo *obj, Efl_Gfx_Shape_Data *pd, } void -_efl_gfx_shape_append_close(Eo *obj EINA_UNUSED, Efl_Gfx_Shape_Data *pd) +_efl_gfx_shape_append_close(Eo *obj, Efl_Gfx_Shape_Data *pd) { double *offset_point; efl_gfx_path_grow(EFL_GFX_PATH_COMMAND_TYPE_CLOSE, &pd->commands, &pd->points, &offset_point); + + eo_do(obj, eo_event_callback_call(EFX_GFX_CHANGED, NULL)); } void From 0f6328b04feca2e583a3d74b30d636af4f6b6965 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:30:42 +0200 Subject: [PATCH 115/251] efl: introduce EFL_GFX_CHANGED event and properly propagate up to Evas. --- .../ector_renderer_cairo_gradient_linear.c | 2 +- .../ector_renderer_cairo_gradient_linear.eo | 2 +- .../ector_renderer_cairo_gradient_radial.c | 2 +- .../ector_renderer_cairo_gradient_radial.eo | 2 +- src/lib/efl/interfaces/efl_gfx_shape.c | 16 +++--- src/lib/evas/canvas/evas_vg_container.c | 4 ++ src/lib/evas/canvas/evas_vg_gradient.c | 4 ++ src/lib/evas/canvas/evas_vg_gradient_linear.c | 11 +++- src/lib/evas/canvas/evas_vg_gradient_radial.c | 13 ++++- src/lib/evas/canvas/evas_vg_image.c | 8 +++ src/lib/evas/canvas/evas_vg_node.c | 53 +++++++++++++++---- src/lib/evas/canvas/evas_vg_private.h | 6 +++ src/lib/evas/canvas/evas_vg_root_node.c | 32 +++++++++-- src/lib/evas/canvas/evas_vg_shape.c | 24 +++++++++ 14 files changed, 151 insertions(+), 28 deletions(-) diff --git a/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c b/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c index d0a39f8718..8ca5457b89 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c @@ -116,7 +116,7 @@ _ector_renderer_cairo_gradient_linear_eo_base_destructor(Eo *obj, } void -_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) +_ector_renderer_cairo_gradient_linear_efl_gfx_gradient_base_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, ); diff --git a/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.eo b/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.eo index 6007fd3575..11914ab720 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.eo +++ b/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.eo @@ -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.Gfx.Gradient.stop.set; + Efl.Gfx.Gradient.Base.stop.set; } } diff --git a/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c b/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c index 84207ef0b9..c3d0463a6f 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c @@ -118,7 +118,7 @@ _ector_renderer_cairo_gradient_radial_eo_base_destructor(Eo *obj, } void -_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) +_ector_renderer_cairo_gradient_radial_efl_gfx_gradient_base_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, ); diff --git a/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.eo b/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.eo index ab9595f760..c3322f851b 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.eo +++ b/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.eo @@ -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.Gfx.Gradient.stop.set; + Efl.Gfx.Gradient.Base.stop.set; } } diff --git a/src/lib/efl/interfaces/efl_gfx_shape.c b/src/lib/efl/interfaces/efl_gfx_shape.c index 0815671c9f..87363d9b77 100644 --- a/src/lib/efl/interfaces/efl_gfx_shape.c +++ b/src/lib/efl/interfaces/efl_gfx_shape.c @@ -165,7 +165,7 @@ _efl_gfx_shape_path_set(Eo *obj, Efl_Gfx_Shape_Data *pd, &pd->current.x, &pd->current.y, &pd->current_ctrl.x, &pd->current_ctrl.y); - eo_do(obj, eo_event_callback_call(EFX_GFX_CHANGED, NULL)); + eo_do(obj, eo_event_callback_call(EFL_GFX_CHANGED, NULL)); } void @@ -276,7 +276,7 @@ _efl_gfx_shape_interpolate(Eo *obj, Efl_Gfx_Shape_Data *pd, to_pd->current_ctrl.y, pos_map); - eo_do(obj, eo_event_callback_call(EFX_GFX_CHANGED, NULL)); + eo_do(obj, eo_event_callback_call(EFL_GFX_CHANGED, NULL)); return EINA_TRUE; } @@ -329,7 +329,7 @@ _efl_gfx_shape_dup(Eo *obj, Efl_Gfx_Shape_Data *pd, Eo *dup_from) _efl_gfx_shape_path_set(obj, pd, from->commands, from->points); - eo_do(obj, eo_event_callback_call(EFX_GFX_CHANGED, NULL)); + eo_do(obj, eo_event_callback_call(EFL_GFX_CHANGED, NULL)); } void @@ -348,7 +348,7 @@ _efl_gfx_shape_reset(Eo *obj, Efl_Gfx_Shape_Data *pd) pd->current_ctrl.x = 0; pd->current_ctrl.y = 0; - eo_do(obj, eo_event_callback_call(EFX_GFX_CHANGED, NULL)); + eo_do(obj, eo_event_callback_call(EFL_GFX_CHANGED, NULL)); } void @@ -367,7 +367,7 @@ _efl_gfx_shape_append_move_to(Eo *obj, Efl_Gfx_Shape_Data *pd, pd->current.x = x; pd->current.y = y; - eo_do(obj, eo_event_callback_call(EFX_GFX_CHANGED, NULL)); + eo_do(obj, eo_event_callback_call(EFL_GFX_CHANGED, NULL)); } void @@ -386,7 +386,7 @@ _efl_gfx_shape_append_line_to(Eo *obj, Efl_Gfx_Shape_Data *pd, pd->current.x = x; pd->current.y = y; - eo_do(obj, eo_event_callback_call(EFX_GFX_CHANGED, NULL)); + eo_do(obj, eo_event_callback_call(EFL_GFX_CHANGED, NULL)); } void @@ -413,7 +413,7 @@ _efl_gfx_shape_append_cubic_to(Eo *obj, Efl_Gfx_Shape_Data *pd, pd->current_ctrl.x = ctrl_x1; pd->current_ctrl.y = ctrl_y1; - eo_do(obj, eo_event_callback_call(EFX_GFX_CHANGED, NULL)); + eo_do(obj, eo_event_callback_call(EFL_GFX_CHANGED, NULL)); } void @@ -641,7 +641,7 @@ _efl_gfx_shape_append_close(Eo *obj, Efl_Gfx_Shape_Data *pd) efl_gfx_path_grow(EFL_GFX_PATH_COMMAND_TYPE_CLOSE, &pd->commands, &pd->points, &offset_point); - eo_do(obj, eo_event_callback_call(EFX_GFX_CHANGED, NULL)); + eo_do(obj, eo_event_callback_call(EFL_GFX_CHANGED, NULL)); } void diff --git a/src/lib/evas/canvas/evas_vg_container.c b/src/lib/evas/canvas/evas_vg_container.c index cc679cd86e..3b368f03fe 100644 --- a/src/lib/evas/canvas/evas_vg_container.c +++ b/src/lib/evas/canvas/evas_vg_container.c @@ -15,6 +15,10 @@ _evas_vg_container_render_pre(Eo *obj EINA_UNUSED, Evas_VG_Container_Data *pd = data; Eina_List *l; Eo *child; + + if (!nd->changed) return ; + nd->changed = EINA_FALSE; + EVAS_VG_COMPUTE_MATRIX(current, parent, nd); EINA_LIST_FOREACH(pd->children, l, child) diff --git a/src/lib/evas/canvas/evas_vg_gradient.c b/src/lib/evas/canvas/evas_vg_gradient.c index 41f2ea98e0..4df0b255ff 100644 --- a/src/lib/evas/canvas/evas_vg_gradient.c +++ b/src/lib/evas/canvas/evas_vg_gradient.c @@ -20,6 +20,8 @@ _evas_vg_gradient_efl_gfx_gradient_base_stop_set(Eo *obj EINA_UNUSED, memcpy(pd->colors, colors, length * sizeof(Efl_Gfx_Gradient_Stop)); pd->colors_count = length; + + _evas_vg_node_changed(obj); } static void @@ -38,6 +40,8 @@ _evas_vg_gradient_efl_gfx_gradient_base_spread_set(Eo *obj EINA_UNUSED, Efl_Gfx_Gradient_Spread s) { pd->s = s; + + _evas_vg_node_changed(obj); } static Efl_Gfx_Gradient_Spread diff --git a/src/lib/evas/canvas/evas_vg_gradient_linear.c b/src/lib/evas/canvas/evas_vg_gradient_linear.c index 71d5e0c712..c1d8ffc461 100644 --- a/src/lib/evas/canvas/evas_vg_gradient_linear.c +++ b/src/lib/evas/canvas/evas_vg_gradient_linear.c @@ -22,6 +22,8 @@ _evas_vg_gradient_linear_efl_gfx_gradient_linear_start_set(Eo *obj EINA_UNUSED, { pd->start.x = x; pd->start.y = y; + + _evas_vg_node_changed(obj); } static void @@ -40,6 +42,8 @@ _evas_vg_gradient_linear_efl_gfx_gradient_linear_end_set(Eo *obj EINA_UNUSED, { pd->end.x = x; pd->end.y = y; + + _evas_vg_node_changed(obj); } static void @@ -59,7 +63,12 @@ _evas_vg_gradient_linear_render_pre(Eo *obj, Evas_VG_Node_Data *nd) { Evas_VG_Gradient_Linear_Data *pd = data; - Evas_VG_Gradient_Data *gd = eo_data_scope_get(obj, EVAS_VG_GRADIENT_CLASS); + Evas_VG_Gradient_Data *gd; + + if (!nd->changed) return ; + nd->changed = EINA_FALSE; + + gd = eo_data_scope_get(obj, EVAS_VG_GRADIENT_CLASS); EVAS_VG_COMPUTE_MATRIX(current, parent, nd); if (!nd->renderer) diff --git a/src/lib/evas/canvas/evas_vg_gradient_radial.c b/src/lib/evas/canvas/evas_vg_gradient_radial.c index ad199659a6..ead0a49d98 100644 --- a/src/lib/evas/canvas/evas_vg_gradient_radial.c +++ b/src/lib/evas/canvas/evas_vg_gradient_radial.c @@ -21,6 +21,8 @@ _evas_vg_gradient_radial_efl_gfx_gradient_radial_center_set(Eo *obj EINA_UNUSED, { pd->center.x = x; pd->center.y = y; + + _evas_vg_node_changed(obj); } static void @@ -38,6 +40,8 @@ _evas_vg_gradient_radial_efl_gfx_gradient_radial_radius_set(Eo *obj EINA_UNUSED, double r) { pd->radius = r; + + _evas_vg_node_changed(obj); } static double @@ -54,6 +58,8 @@ _evas_vg_gradient_radial_efl_gfx_gradient_radial_focal_set(Eo *obj EINA_UNUSED, { pd->focal.x = x; pd->focal.y = y; + + _evas_vg_node_changed(obj); } static void @@ -73,7 +79,12 @@ _evas_vg_gradient_radial_render_pre(Eo *obj, Evas_VG_Node_Data *nd) { Evas_VG_Gradient_Radial_Data *pd = data; - Evas_VG_Gradient_Data *gd = eo_data_scope_get(obj, EVAS_VG_GRADIENT_CLASS); + Evas_VG_Gradient_Data *gd; + + if (!nd->changed) return ; + nd->changed = EINA_FALSE; + + gd = eo_data_scope_get(obj, EVAS_VG_GRADIENT_CLASS); EVAS_VG_COMPUTE_MATRIX(current, parent, nd); if (!nd->renderer) diff --git a/src/lib/evas/canvas/evas_vg_image.c b/src/lib/evas/canvas/evas_vg_image.c index 62f02ece28..523c1fc098 100644 --- a/src/lib/evas/canvas/evas_vg_image.c +++ b/src/lib/evas/canvas/evas_vg_image.c @@ -3,6 +3,8 @@ #include +#include "evas_vg_private.h" + typedef struct _Evas_VG_Image_Data Evas_VG_Image_Data; struct _Evas_VG_Image_Data { @@ -19,6 +21,8 @@ _evas_vg_image_position_set(Eo *obj, Evas_VG_Image_Data *pd, int x, int y) { pd->x = x; pd->y = y; + + _evas_vg_node_changed(obj); } static void @@ -34,6 +38,8 @@ _evas_vg_image_size_set(Eo *obj, Evas_VG_Image_Data *pd, { pd->w = w; pd->h = h; + + _evas_vg_node_changed(obj); } static void @@ -54,6 +60,8 @@ _evas_vg_image_efl_file_mmap_set(Eo *obj EINA_UNUSED, Evas_VG_Image_Data *pd, eina_file_close(tmp); eina_stringshare_replace(&pd->key, key); + _evas_vg_node_changed(obj); + return EINA_TRUE; } diff --git a/src/lib/evas/canvas/evas_vg_node.c b/src/lib/evas/canvas/evas_vg_node.c index 40166a6767..c5ac1100b0 100644 --- a/src/lib/evas/canvas/evas_vg_node.c +++ b/src/lib/evas/canvas/evas_vg_node.c @@ -8,13 +8,22 @@ #define MY_CLASS EVAS_VG_NODE_CLASS -// FIXME: -// - share private structure with evas_object_vg -// - mark parent canvas evas_object dirty after any change on the object -// - add a virtual render function as part of the private data field +static Eina_Bool +_evas_vg_node_property_changed(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info) +{ + Evas_VG_Node_Data *pd = data; + Eo *parent; + + if (pd->changed) return EINA_TRUE; + pd->changed = EINA_TRUE; + + eo_do(obj, parent = eo_parent_get()); + eo_do(parent, eo_event_callback_call(desc, event_info)); + return EINA_TRUE; +} void -_evas_vg_node_transformation_set(Eo *obj EINA_UNUSED, +_evas_vg_node_transformation_set(Eo *obj, Evas_VG_Node_Data *pd, const Eina_Matrix3 *m) { @@ -24,6 +33,8 @@ _evas_vg_node_transformation_set(Eo *obj EINA_UNUSED, if (!pd->m) return ; } memcpy(pd->m, m, sizeof (Eina_Matrix3)); + + _evas_vg_node_changed(obj); } const Eina_Matrix3 * @@ -33,12 +44,14 @@ _evas_vg_node_transformation_get(Eo *obj EINA_UNUSED, Evas_VG_Node_Data *pd) } void -_evas_vg_node_origin_set(Eo *obj EINA_UNUSED, +_evas_vg_node_origin_set(Eo *obj, Evas_VG_Node_Data *pd, double x, double y) { pd->x = x; pd->y = y; + + _evas_vg_node_changed(obj); } void @@ -57,6 +70,8 @@ _evas_vg_node_efl_gfx_base_position_set(Eo *obj EINA_UNUSED, { pd->x = lrint(x); pd->y = lrint(y); + + _evas_vg_node_changed(obj); } void @@ -73,6 +88,8 @@ _evas_vg_node_efl_gfx_base_visible_set(Eo *obj EINA_UNUSED, Evas_VG_Node_Data *pd, Eina_Bool v) { pd->visibility = v; + + _evas_vg_node_changed(obj); } @@ -92,6 +109,8 @@ _evas_vg_node_efl_gfx_base_color_set(Eo *obj EINA_UNUSED, pd->g = g; pd->b = b; pd->a = a; + + _evas_vg_node_changed(obj); } Eina_Bool @@ -136,6 +155,8 @@ _evas_vg_node_mask_set(Eo *obj EINA_UNUSED, pd->mask = eo_ref(r); eo_unref(tmp); + + _evas_vg_node_changed(obj); } Evas_VG_Node* @@ -159,9 +180,12 @@ _evas_vg_node_efl_gfx_base_size_get(Eo *obj, // Parent should be a container otherwise dismissing the stacking operation static Eina_Bool _evas_vg_node_parent_checked_get(Eo *obj, - Eo **parent, Evas_VG_Container_Data **cd) + Eo **parent, + Evas_VG_Container_Data **cd) { + *cd = NULL; eo_do(obj, *parent = eo_parent_get()); + if (eo_isa(*parent, EVAS_VG_CONTAINER_CLASS)) { *cd = eo_data_scope_get(*parent, EVAS_VG_CONTAINER_CLASS); @@ -187,7 +211,7 @@ _evas_vg_node_parent_checked_get(Eo *obj, void _evas_vg_node_eo_base_constructor(Eo *obj, - Evas_VG_Node_Data *pd EINA_UNUSED) + Evas_VG_Node_Data *pd) { Evas_VG_Container_Data *cd = NULL; Eo *parent; @@ -199,6 +223,9 @@ _evas_vg_node_eo_base_constructor(Eo *obj, if (cd) cd->children = eina_list_append(cd->children, obj); + + eo_do(obj, eo_event_callback_add(EFL_GFX_CHANGED, _evas_vg_node_property_changed, pd)); + pd->changed = EINA_TRUE; } void @@ -219,7 +246,7 @@ _evas_vg_node_eo_base_parent_set(Eo *obj, goto on_error; } } - else if (parent != NULL && !eo_isa(parent, EVAS_VG_CLASS)) + else if (parent != NULL) { ERR("%p not even an EVAS_VG_CLASS.", parent); goto on_error; @@ -236,6 +263,10 @@ _evas_vg_node_eo_base_parent_set(Eo *obj, if (cd) cd->children = eina_list_append(cd->children, obj); + _evas_vg_node_changed(old_parent); + _evas_vg_node_changed(obj); + _evas_vg_node_changed(parent); + return ; on_error: @@ -264,6 +295,7 @@ _evas_vg_node_efl_gfx_stack_raise(Eo *obj, Evas_VG_Node_Data *pd EINA_UNUSED) cd->children = eina_list_remove_list(cd->children, lookup); cd->children = eina_list_append_relative_list(cd->children, obj, next); + _evas_vg_node_changed(parent); return ; on_error: @@ -293,6 +325,7 @@ _evas_vg_node_efl_gfx_stack_stack_above(Eo *obj, cd->children = eina_list_remove_list(cd->children, lookup); cd->children = eina_list_append_relative_list(cd->children, obj, ref); + _evas_vg_node_changed(parent); return ; on_error: @@ -322,6 +355,7 @@ _evas_vg_node_efl_gfx_stack_stack_below(Eo *obj, cd->children = eina_list_remove_list(cd->children, lookup); cd->children = eina_list_prepend_relative_list(cd->children, obj, ref); + _evas_vg_node_changed(parent); return ; on_error: @@ -349,6 +383,7 @@ _evas_vg_node_efl_gfx_stack_lower(Eo *obj, Evas_VG_Node_Data *pd EINA_UNUSED) cd->children = eina_list_remove_list(cd->children, lookup); cd->children = eina_list_prepend_relative_list(cd->children, obj, prev); + _evas_vg_node_changed(parent); return ; on_error: diff --git a/src/lib/evas/canvas/evas_vg_private.h b/src/lib/evas/canvas/evas_vg_private.h index 58c1cfec01..1c7d516615 100644 --- a/src/lib/evas/canvas/evas_vg_private.h +++ b/src/lib/evas/canvas/evas_vg_private.h @@ -51,6 +51,12 @@ _evas_vg_render_pre(Evas_VG_Node *child, Ector_Surface *s, Eina_Matrix3 *m) return child_nd; } +static inline void +_evas_vg_node_changed(Eo *obj) +{ + eo_do(obj, eo_event_callback_call(EFL_GFX_CHANGED, NULL)); +} + #define EVAS_VG_COMPUTE_MATRIX(Current, Parent, Nd) \ Eina_Matrix3 *Current = Nd->m; \ Eina_Matrix3 _matrix_tmp; \ diff --git a/src/lib/evas/canvas/evas_vg_root_node.c b/src/lib/evas/canvas/evas_vg_root_node.c index 8fb8b311b2..1566a18cfa 100644 --- a/src/lib/evas/canvas/evas_vg_root_node.c +++ b/src/lib/evas/canvas/evas_vg_root_node.c @@ -10,30 +10,52 @@ typedef struct _Evas_VG_Root_Node_Data Evas_VG_Root_Node_Data; struct _Evas_VG_Root_Node_Data { + Evas_Object *parent; + Evas_Object_Protected_Data *data; }; +static Eina_Bool +_evas_vg_root_node_changed(void *data, Eo *obj EINA_UNUSED, + const Eo_Event_Description *desc EINA_UNUSED, + void *event_info EINA_UNUSED) +{ + Evas_VG_Root_Node_Data *pd = data; + + evas_object_change(pd->parent, pd->data); + return EINA_TRUE; +} + void _evas_vg_root_node_eo_base_parent_set(Eo *obj, - Evas_VG_Root_Node_Data *pd EINA_UNUSED, + Evas_VG_Root_Node_Data *pd, Eo *parent) { // Nice little hack, jump over parent parent_set in Evas_VG_Root eo_do_super(obj, EVAS_VG_NODE_CLASS, eo_parent_set(parent)); if (parent && !eo_isa(parent, EVAS_VG_CLASS)) - eo_error_set(obj); + { + eo_error_set(obj); + } + else + { + pd->parent = parent; + pd->data = eo_data_scope_get(parent, EVAS_OBJECT_CLASS); + } } void _evas_vg_root_node_eo_base_constructor(Eo *obj, - Evas_VG_Root_Node_Data *pd EINA_UNUSED) + Evas_VG_Root_Node_Data *pd) { Eo *parent; - // Nice little hack, jump over parent constructor in Evas_VG_Root - eo_do_super(obj, EVAS_VG_NODE_CLASS, eo_constructor()); + // Nice little hack, jump over parent constructor in Efl_VG_Root + eo_do_super(obj, EFL_VG_BASE_CLASS, eo_constructor()); eo_do(obj, parent = eo_parent_get()); if (!eo_isa(parent, EVAS_VG_CLASS)) eo_error_set(obj); + + eo_do(obj, eo_event_callback_add(EFL_GFX_CHANGED, _evas_vg_root_node_changed, pd)); } #include "evas_vg_root_node.eo.c" diff --git a/src/lib/evas/canvas/evas_vg_shape.c b/src/lib/evas/canvas/evas_vg_shape.c index a560029dde..2a577b89be 100644 --- a/src/lib/evas/canvas/evas_vg_shape.c +++ b/src/lib/evas/canvas/evas_vg_shape.c @@ -45,6 +45,8 @@ _evas_vg_shape_fill_set(Eo *obj EINA_UNUSED, pd->fill = eo_ref(f); eo_unref(tmp); + + _evas_vg_node_changed(obj); } static Evas_VG_Node * @@ -59,6 +61,8 @@ _evas_vg_shape_efl_gfx_shape_stroke_scale_set(Eo *obj EINA_UNUSED, double s) { pd->stroke.scale = s; + + _evas_vg_node_changed(obj); } static double @@ -77,6 +81,8 @@ _evas_vg_shape_efl_gfx_shape_stroke_color_set(Eo *obj EINA_UNUSED, pd->stroke.g = g; pd->stroke.b = b; pd->stroke.a = a; + + _evas_vg_node_changed(obj); } static Eina_Bool @@ -137,6 +143,8 @@ _evas_vg_shape_stroke_fill_set(Eo *obj EINA_UNUSED, pd->stroke.fill = eo_ref(f); eo_unref(tmp); + + _evas_vg_node_changed(obj); } static Evas_VG_Node * @@ -152,6 +160,8 @@ _evas_vg_shape_efl_gfx_shape_stroke_width_set(Eo *obj EINA_UNUSED, double w) { pd->stroke.width = w; + + _evas_vg_node_changed(obj); } static double @@ -167,6 +177,8 @@ _evas_vg_shape_efl_gfx_shape_stroke_location_set(Eo *obj EINA_UNUSED, double centered) { pd->stroke.centered = centered; + + _evas_vg_node_changed(obj); } static double @@ -191,6 +203,8 @@ _evas_vg_shape_efl_gfx_shape_stroke_dash_set(Eo *obj EINA_UNUSED, memcpy(pd->stroke.dash, dash, sizeof (Efl_Gfx_Dash) * length); pd->stroke.dash_count = length; + + _evas_vg_node_changed(obj); } static void @@ -212,6 +226,8 @@ _evas_vg_shape_stroke_marker_set(Eo *obj EINA_UNUSED, pd->stroke.marker = eo_ref(m); eo_unref(tmp); + + _evas_vg_node_changed(obj); } static Evas_VG_Shape * @@ -227,6 +243,8 @@ _evas_vg_shape_efl_gfx_shape_stroke_cap_set(Eo *obj EINA_UNUSED, Efl_Gfx_Cap c) { pd->stroke.cap = c; + + _evas_vg_node_changed(obj); } static Efl_Gfx_Cap @@ -242,6 +260,8 @@ _evas_vg_shape_efl_gfx_shape_stroke_join_set(Eo *obj EINA_UNUSED, Efl_Gfx_Join j) { pd->stroke.join = j; + + _evas_vg_node_changed(obj); } static Efl_Gfx_Join @@ -260,6 +280,10 @@ _evas_vg_shape_render_pre(Eo *obj EINA_UNUSED, { Evas_VG_Shape_Data *pd = data; Evas_VG_Node_Data *fill, *stroke_fill, *stroke_marker, *mask; + + if (!nd->changed) return ; + nd->changed = EINA_FALSE; + EVAS_VG_COMPUTE_MATRIX(current, parent, nd); fill = _evas_vg_render_pre(pd->fill, s, current); From f2380b092006af5a641713b537eee7bca3f8866b Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:30:44 +0200 Subject: [PATCH 116/251] evas: introduce begin and end operation on an Ector surface. This is necessary for GL has you want to map once and run with it, but it will also help the software backend to not remap the surface all the time ! --- src/lib/evas/canvas/evas_object_vg.c | 4 +- src/lib/evas/include/evas_private.h | 4 +- .../engines/software_generic/evas_engine.c | 98 ++++++++++++++++--- 3 files changed, 91 insertions(+), 15 deletions(-) diff --git a/src/lib/evas/canvas/evas_object_vg.c b/src/lib/evas/canvas/evas_object_vg.c index 6907b103e3..8b1f5de76b 100644 --- a/src/lib/evas/canvas/evas_object_vg.c +++ b/src/lib/evas/canvas/evas_object_vg.c @@ -146,7 +146,7 @@ _evas_vg_render(Evas_Object_Protected_Data *obj, { Evas_VG_Node_Data *nd = eo_data_scope_get(n, EVAS_VG_NODE_CLASS); - obj->layer->evas->engine.func->ector_draw(output, context, surface, nd->renderer, clips, x, y, do_async); + obj->layer->evas->engine.func->ector_renderer_draw(output, context, surface, nd->renderer, clips, x, y, do_async); } } @@ -179,9 +179,11 @@ evas_object_vg_render(Evas_Object *eo_obj EINA_UNUSED, context); obj->layer->evas->engine.func->context_render_op_set(output, context, obj->cur->render_op); + obj->layer->evas->engine.func->ector_begin(output, context, surface, do_async); _evas_vg_render(obj, output, context, surface, vd->root, NULL, obj->cur->geometry.x + x, obj->cur->geometry.y + y, do_async); + obj->layer->evas->engine.func->ector_end(output, context, surface, do_async); } static void diff --git a/src/lib/evas/include/evas_private.h b/src/lib/evas/include/evas_private.h index a2a8093e44..d91e681a1c 100644 --- a/src/lib/evas/include/evas_private.h +++ b/src/lib/evas/include/evas_private.h @@ -1368,7 +1368,9 @@ struct _Evas_Func void (*texture_image_set) (void *data, void *texture, void *image); Ector_Surface *(*ector_get) (void *data); - void (*ector_draw) (void *data, void *context, void *surface, Ector_Renderer *r, Eina_Array *clips, int x, int y, Eina_Bool do_async); + void (*ector_begin) (void *data, void *context, void *surface, Eina_Bool do_async); + void (*ector_renderer_draw) (void *data, void *context, void *surface, Ector_Renderer *r, Eina_Array *clips, int x, int y, Eina_Bool do_async); + void (*ector_end) (void *data, void *context, void *surface, Eina_Bool do_async); }; struct _Evas_Image_Save_Func diff --git a/src/modules/evas/engines/software_generic/evas_engine.c b/src/modules/evas/engines/software_generic/evas_engine.c index b50f0f28d9..024a44eb95 100644 --- a/src/modules/evas/engines/software_generic/evas_engine.c +++ b/src/modules/evas/engines/software_generic/evas_engine.c @@ -297,6 +297,7 @@ typedef struct _Evas_Thread_Command_Font Evas_Thread_Command_Font; typedef struct _Evas_Thread_Command_Map Evas_Thread_Command_Map; typedef struct _Evas_Thread_Command_Multi_Font Evas_Thread_Command_Multi_Font; typedef struct _Evas_Thread_Command_Ector Evas_Thread_Command_Ector; +typedef struct _Evas_Thread_Command_Ector_Surface Evas_Thread_Command_Ector_Surface; struct _Evas_Thread_Command_Rect { @@ -390,7 +391,6 @@ struct _Evas_Thread_Command_Multi_Font struct _Evas_Thread_Command_Ector { - void *surface; Ector_Renderer *r; Eina_Array *clips; @@ -401,6 +401,11 @@ struct _Evas_Thread_Command_Ector Eina_Bool free_it; }; +struct _Evas_Thread_Command_Ector_Surface +{ + void *surface; +}; + Eina_Mempool *_mp_command_rect = NULL; Eina_Mempool *_mp_command_line = NULL; Eina_Mempool *_mp_command_polygon = NULL; @@ -409,6 +414,7 @@ Eina_Mempool *_mp_command_font = NULL; Eina_Mempool *_mp_command_map = NULL; Eina_Mempool *_mp_command_multi_font = NULL; Eina_Mempool *_mp_command_ector = NULL; +Eina_Mempool *_mp_command_ector_surface = NULL; /* ***** ** @@ -3489,16 +3495,6 @@ static void _draw_thread_ector_draw(void *data) { Evas_Thread_Command_Ector *ector = data; - RGBA_Image *surface = ector->surface; - void *pixels = evas_cache_image_pixels(&surface->cache_entry); - unsigned int w, h; - - w = surface->cache_entry.w; - h = surface->cache_entry.h; - - // FIXME: do not reset cairo context if not necessary - eo_do(_software_ector, - ector_cairo_software_surface_set(pixels, w, h)); eo_do(ector->r, ector_renderer_draw(ector->render_op, @@ -3557,7 +3553,6 @@ eng_ector_renderer_draw(void *data EINA_UNUSED, void *context, void *surface, Ec if (eina_array_count(c) == 0) eina_array_push(c, eina_rectangle_new(clip.x, clip.y, clip.w, clip.h)); - ector.surface = surface; ector.r = eo_ref(renderer); ector.clips = c; ector.render_op = _evas_render_op_to_ector_rop(dc->render_op); @@ -3588,6 +3583,78 @@ eng_ector_renderer_draw(void *data EINA_UNUSED, void *context, void *surface, Ec } } +static void +_draw_thread_ector_surface_set(void *data) +{ + Evas_Thread_Command_Ector_Surface *ector_surface = data; + RGBA_Image *surface = ector_surface->surface; + void *pixels = NULL; + unsigned int w = 0; + unsigned int h = 0; + + if (surface) + { + pixels = evas_cache_image_pixels(&surface->cache_entry); + w = surface->cache_entry.w; + h = surface->cache_entry.h; + } + + eo_do(_software_ector, + ector_cairo_software_surface_set(pixels, w, h)); + + eina_mempool_free(_mp_command_ector_surface, ector_surface); +} + +static void +eng_ector_begin(void *data EINA_UNUSED, void *context EINA_UNUSED, void *surface, Eina_Bool do_async) +{ + if (do_async) + { + Evas_Thread_Command_Ector_Surface *nes; + + nes = eina_mempool_malloc(_mp_command_ector_surface, sizeof (Evas_Thread_Command_Ector_Surface)); + if (!nes) return ; + + nes->surface = surface; + + evas_thread_cmd_enqueue(_draw_thread_ector_surface_set, nes); + } + else + { + RGBA_Image *sf = surface; + void *pixels = NULL; + unsigned int w = 0; + unsigned int h = 0; + + pixels = evas_cache_image_pixels(&sf->cache_entry); + w = sf->cache_entry.w; + h = sf->cache_entry.h; + + eo_do(_software_ector, + ector_cairo_software_surface_set(pixels, w, h)); + } +} + +static void +eng_ector_end(void *data EINA_UNUSED, void *context EINA_UNUSED, void *surface EINA_UNUSED, Eina_Bool do_async) +{ + if (do_async) + { + Evas_Thread_Command_Ector_Surface *nes; + + nes = eina_mempool_malloc(_mp_command_ector_surface, sizeof (Evas_Thread_Command_Ector_Surface)); + if (!nes) return ; + + nes->surface = NULL; + + evas_thread_cmd_enqueue(_draw_thread_ector_surface_set, nes); + } + else + { + eo_do(_software_ector, ector_cairo_software_surface_set(NULL, 0, 0)); + } +} + //------------------------------------------------// /* @@ -3770,7 +3837,9 @@ static Evas_Func func = NULL, // eng_texture_filter_get NULL, // eng_texture_image_set eng_ector_get, - eng_ector_renderer_draw + eng_ector_begin, + eng_ector_renderer_draw, + eng_ector_end /* FUTURE software generic calls go here */ }; @@ -4822,6 +4891,9 @@ module_open(Evas_Module *em) _mp_command_ector = eina_mempool_add("chained_mempool", "Evas_Thread_Command_Ector", NULL, sizeof(Evas_Thread_Command_Ector), 128); + _mp_command_ector_surface = + eina_mempool_add("chained_mempool", "Evas_Thread_Command_Ector_Surface", + NULL, sizeof(Evas_Thread_Command_Ector_Surface), 128); init_gl(); evas_common_pipe_init(); From 23c34b96d3fe25b75ab15e6ff6b2d0f7332c42e9 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:30:44 +0200 Subject: [PATCH 117/251] evas: add theoric GL backend support. --- src/Makefile_Evas.am | 8 +- .../ector_cairo_software_surface.eo | 18 ++ .../evas/engines/gl_generic/evas_engine.c | 216 ++++++++++++++++++ 3 files changed, 241 insertions(+), 1 deletion(-) create mode 100644 src/modules/evas/engines/gl_generic/ector_cairo_software_surface.eo diff --git a/src/Makefile_Evas.am b/src/Makefile_Evas.am index b5f42a52ac..34600fe7bf 100644 --- a/src/Makefile_Evas.am +++ b/src/Makefile_Evas.am @@ -519,7 +519,9 @@ lib/evas/filters/blur/blur_box_rgba_neon.c ### Engines if EVAS_STATIC_BUILD_SOFTWARE_GENERIC -evas_eolian_files += modules/evas/engines/software_generic/ector_cairo_software_surface.eo +BUILT_SOURCES += \ +modules/evas/engines/software_generic/ector_cairo_software_surface.eo.c \ +modules/evas/engines/software_generic/ector_cairo_software_surface.eo.h lib_evas_libevas_la_SOURCES += modules/evas/engines/software_generic/evas_engine.c modules/evas/engines/software_generic/Evas_Engine_Software_Generic.h lib_evas_libevas_la_LIBADD += else @@ -608,6 +610,10 @@ endif endif if BUILD_ENGINE_GL_COMMON +BUILT_SOURCES += \ +modules/evas/engines/gl_generic/ector_cairo_software_surface.eo.c \ +modules/evas/engines/gl_generic/ector_cairo_software_surface.eo.h + GL_COMMON_SOURCES = \ modules/evas/engines/gl_common/evas_gl_private.h \ modules/evas/engines/gl_common/evas_gl_common.h \ diff --git a/src/modules/evas/engines/gl_generic/ector_cairo_software_surface.eo b/src/modules/evas/engines/gl_generic/ector_cairo_software_surface.eo new file mode 100644 index 0000000000..d5070abccf --- /dev/null +++ b/src/modules/evas/engines/gl_generic/ector_cairo_software_surface.eo @@ -0,0 +1,18 @@ +class Ector.Cairo_Software.Surface (Ector.Cairo.Surface) +{ + eo_prefix: ector_cairo_software_surface; + legacy_prefix: null; + properties { + surface { + set { + } + get { + } + values { + void *pixels; + uint width; + uint height; + } + } + } +} diff --git a/src/modules/evas/engines/gl_generic/evas_engine.c b/src/modules/evas/engines/gl_generic/evas_engine.c index dac9232c5f..225a32b006 100644 --- a/src/modules/evas/engines/gl_generic/evas_engine.c +++ b/src/modules/evas/engines/gl_generic/evas_engine.c @@ -21,6 +21,10 @@ #include "evas_cs2_private.h" #endif +#include "cairo/Ector_Cairo.h" + +#include "ector_cairo_software_surface.eo.h" + #define EVAS_GL_NO_GL_H_CHECK 1 #include "Evas_GL.h" @@ -2087,6 +2091,127 @@ eng_texture_image_set(void *data EINA_UNUSED, void *texture, void *image) e3d_texture_import((E3D_Texture *)texture, im->tex->pt->texture); } +static Ector_Surface *_software_ector = NULL; + +static Ector_Surface * +eng_ector_get(void *data EINA_UNUSED) +{ + if (!_software_ector) + { + _software_ector = eo_add(ECTOR_CAIRO_SOFTWARE_SURFACE_CLASS, NULL); + } + return _software_ector; +} + +static Ector_Rop +_evas_render_op_to_ector_rop(Evas_Render_Op op) +{ + switch (op) + { + case EVAS_RENDER_BLEND: + return ECTOR_ROP_BLEND; + case EVAS_RENDER_COPY: + return ECTOR_ROP_COPY; + default: + return ECTOR_ROP_BLEND; + } +} + +static void +eng_ector_renderer_draw(void *data EINA_UNUSED, void *context, void *surface, Ector_Renderer *renderer, Eina_Array *clips, int x, int y, Eina_Bool do_async EINA_UNUSED) +{ + Evas_GL_Image *dst = surface; + Evas_Engine_GL_Context *gc = context; + Eina_Rectangle *r; + Eina_Array *c; + Eina_Rectangle clip; + Eina_Array_Iterator it; + unsigned int i; + + if (gc->dc->clip.use) + { + clip.x = gc->dc->clip.x; + clip.y = gc->dc->clip.y; + clip.w = gc->dc->clip.w; + clip.h = gc->dc->clip.h; + } + else + { + clip.x = 0; + clip.y = 0; + clip.w = dst->w; + clip.h = dst->h; + } + + c = eina_array_new(8); + EINA_ARRAY_ITER_NEXT(clips, i, r, it) + { + Eina_Rectangle *rc; + + rc = eina_rectangle_new(r->x, r->y, r->w, r->h); + if (!rc) continue; + + if (eina_rectangle_intersection(rc, &clip)) + eina_array_push(c, rc); + else + eina_rectangle_free(rc); + } + if (eina_array_count(c) == 0 && + eina_array_count(clips) > 0) + return ; + + if (eina_array_count(c) == 0) + eina_array_push(c, eina_rectangle_new(clip.x, clip.y, clip.w, clip.h)); + + eo_do(renderer, + ector_renderer_draw(_evas_render_op_to_ector_rop(gc->dc->render_op), + c, + x, + y, + // mul_col will be applied by GL during ector_end + 0xffffffff)); + + while ((r = eina_array_pop(c))) + eina_rectangle_free(r); + eina_array_free(c); +} + +static void *software_buffer = NULL; + +static void +eng_ector_begin(void *data EINA_UNUSED, void *context EINA_UNUSED, void *surface, Eina_Bool do_async EINA_UNUSED) +{ + Evas_GL_Image *dst = surface; + + software_buffer = realloc(software_buffer, sizeof (unsigned int) * dst->w * dst->h); + eo_do(_software_ector, + ector_cairo_software_surface_set(software_buffer, dst->w, dst->h)); +} + +static void +eng_ector_end(void *data, void *context, void *surface, Eina_Bool do_async) +{ + Evas_GL_Image *dst = surface; + Evas_GL_Image *im; + + eo_do(_software_ector, + ector_cairo_software_surface_set(NULL, 0, 0)); + + im = evas_gl_common_image_new_from_data(context, dst->w, dst->h, software_buffer, 1, EVAS_COLORSPACE_ARGB8888); + eng_image_draw(data, context, surface, im, + // We actually just bluntly push the pixel all over the + // destination surface. We don't have the actual information + // of the widget size. This is not a problem. + // Later on, we don't want that information and today when + // using GL backend, you just need to turn on Evas_Map on + // the Evas_Object_VG. + 0, 0, dst->w, dst->h, + 0, 0, dst->w, dst->h, 0, do_async); + + evas_common_rgba_image_free(software_buffer); + software_buffer = NULL; +} + static Evas_Func func, pfunc; static int @@ -2229,6 +2354,11 @@ module_open(Evas_Module *em) ORD(texture_filter_get); ORD(texture_image_set); + ORD(ector_get); + ORD(ector_begin); + ORD(ector_renderer_draw); + ORD(ector_end); + /* now advertise out own api */ em->functions = (void *)(&func); return 1; @@ -2257,3 +2387,89 @@ EVAS_MODULE_DEFINE(EVAS_MODULE_TYPE_ENGINE, engine, gl_generic); #ifndef EVAS_STATIC_BUILD_GL_COMMON EVAS_EINA_MODULE_DEFINE(engine, gl_generic); #endif + +#define USE(Obj, Sym, Error) \ + if (!Sym) _ector_cairo_symbol_get(Obj, #Sym); \ + if (!Sym) return Error; + +static inline void * +_ector_cairo_symbol_get(Eo *ector_surface, const char *name) +{ + void *sym; + + eo_do(ector_surface, + sym = ector_cairo_surface_symbol_get(name)); + return sym; +} + +typedef struct _cairo_surface_t cairo_surface_t; +typedef enum { + CAIRO_FORMAT_INVALID = -1, + CAIRO_FORMAT_ARGB32 = 0, + CAIRO_FORMAT_RGB24 = 1, + CAIRO_FORMAT_A8 = 2, + CAIRO_FORMAT_A1 = 3, + CAIRO_FORMAT_RGB16_565 = 4, + CAIRO_FORMAT_RGB30 = 5 +} cairo_format_t; + +static cairo_surface_t *(*cairo_image_surface_create_for_data)(unsigned char *data, + cairo_format_t format, + int width, + int height, + int stride) = NULL; +static void (*cairo_surface_destroy)(cairo_surface_t *surface) = NULL; +static cairo_t *(*cairo_create)(cairo_surface_t *target) = NULL; +static void (*cairo_destroy)(cairo_t *cr) = NULL; + +typedef struct _Ector_Cairo_Software_Surface_Data Ector_Cairo_Software_Surface_Data; +struct _Ector_Cairo_Software_Surface_Data +{ + cairo_surface_t *surface; + cairo_t *ctx; + + void *pixels; + + unsigned int width; + unsigned int height; +}; + +static void +_ector_cairo_software_surface_surface_set(Eo *obj, Ector_Cairo_Software_Surface_Data *pd, void *pixels, unsigned int width, unsigned int height) +{ + USE(obj, cairo_image_surface_create_for_data, ); + USE(obj, cairo_surface_destroy, ); + USE(obj, cairo_create, ); + USE(obj, cairo_destroy, ); + + cairo_surface_destroy(pd->surface); pd->surface = NULL; + cairo_destroy(pd->ctx); pd->ctx = NULL; + + pd->pixels = NULL; + pd->width = 0; + pd->height = 0; + + pd->surface = cairo_image_surface_create_for_data(pixels, CAIRO_FORMAT_ARGB32, width, height, width); + if (pd->surface) goto end; + + pd->ctx = cairo_create(pd->surface); + if (pd->ctx) + { + pd->pixels = pixels; + pd->width = width; + pd->height = height; + } + + end: + eo_do(obj, ector_cairo_surface_context_set(pd->ctx)); +} + +static void +_ector_cairo_software_surface_surface_get(Eo *obj EINA_UNUSED, Ector_Cairo_Software_Surface_Data *pd, void **pixels, unsigned int *width, unsigned int *height) +{ + if (pixels) *pixels = pd->pixels; + if (width) *width = pd->width; + if (height) *height = pd->height; +} + +#include "ector_cairo_software_surface.eo.c" From 5f2fda2c180fb8b76204f4efdebb66026e4e58ab Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:30:45 +0200 Subject: [PATCH 118/251] efl: all those interface are clearly BETA_API. --- src/lib/efl/Efl.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib/efl/Efl.h b/src/lib/efl/Efl.h index 4c17f3c545..87308782fc 100644 --- a/src/lib/efl/Efl.h +++ b/src/lib/efl/Efl.h @@ -139,10 +139,6 @@ typedef enum _Efl_Gfx_Fill_Spread #ifdef EFL_BETA_API_SUPPORT -EAPI extern const Eo_Event_Description _EFL_GFX_CHANGED; - -#define EFL_GFX_CHANGED (&(_EFL_GFX_CHANGED)) - /* Interfaces */ #include "interfaces/efl_control.eo.h" #include "interfaces/efl_file.eo.h" @@ -151,6 +147,10 @@ EAPI extern const Eo_Event_Description _EFL_GFX_CHANGED; #include "interfaces/efl_text.eo.h" #include "interfaces/efl_text_properties.eo.h" +EAPI extern const Eo_Event_Description _EFL_GFX_CHANGED; + +#define EFL_GFX_CHANGED (&(_EFL_GFX_CHANGED)) + #include "interfaces/efl_gfx_base.eo.h" #include "interfaces/efl_gfx_stack.eo.h" #include "interfaces/efl_gfx_fill.eo.h" From 09be34b82501fea8835299de72938cdf9c21c55a Mon Sep 17 00:00:00 2001 From: Vitor Sousa Date: Fri, 3 Apr 2015 16:30:46 +0200 Subject: [PATCH 119/251] eolian_cxx: fix build error for some generated C++ wrappers Name generation for some C++ wrapper functions were adding an illegal ":" in the function name. Fixed the logical error that was causing this to happens when converting namespaces to function prefixes. @fix --- src/lib/eolian_cxx/grammar/inheritance_base_generator.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/eolian_cxx/grammar/inheritance_base_generator.hh b/src/lib/eolian_cxx/grammar/inheritance_base_generator.hh index 82678496ee..38382d5092 100644 --- a/src/lib/eolian_cxx/grammar/inheritance_base_generator.hh +++ b/src/lib/eolian_cxx/grammar/inheritance_base_generator.hh @@ -21,7 +21,7 @@ _ns_as_prefix(eo_class const& cls) std::string::size_type found = s.find("::"); while (found != std::string::npos) { - s.replace(found, 1, "_"); + s.replace(found, 2, "_"); found = s.find("::"); } return s; From 3b97e3d9cd13b16d269b18df6d0b24f7b4d5e667 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:30:47 +0200 Subject: [PATCH 120/251] evas: fix example to follow new Efl.Gfx interface. --- src/examples/evas/evas-3d-aabb.c | 14 +++---- src/examples/evas/evas-3d-blending.c | 4 +- src/examples/evas/evas-3d-cube.c | 14 +++---- src/examples/evas/evas-3d-cube2.c | 14 +++---- src/examples/evas/evas-3d-eet.c | 14 +++---- src/examples/evas/evas-3d-md2.c | 14 +++---- src/examples/evas/evas-3d-mmap-set.c | 16 ++++---- src/examples/evas/evas-3d-obj.c | 14 +++---- src/examples/evas/evas-3d-pick.c | 10 ++--- src/examples/evas/evas-3d-ply.c | 14 +++---- src/examples/evas/evas-3d-proxy.c | 22 +++++----- src/examples/evas/evas-3d-shadows.c | 14 +++---- .../evas/evas-object-manipulation-eo.c | 40 +++++++++---------- src/examples/evas/evas_cxx_rectangle.cc | 2 +- 14 files changed, 103 insertions(+), 103 deletions(-) diff --git a/src/examples/evas/evas-3d-aabb.c b/src/examples/evas/evas-3d-aabb.c index 8791b755fb..9f9488a1e4 100644 --- a/src/examples/evas/evas-3d-aabb.c +++ b/src/examples/evas/evas-3d-aabb.c @@ -112,8 +112,8 @@ _on_canvas_resize(Ecore_Evas *ee) int w, h; ecore_evas_geometry_get(ee, NULL, NULL, &w, &h); - eo_do(background, evas_obj_size_set(w, h)); - eo_do(image, evas_obj_size_set(w, h)); + eo_do(background, efl_gfx_size_set(w, h)); + eo_do(image, efl_gfx_size_set(w, h)); } static Eina_Bool @@ -243,14 +243,14 @@ main(void) background = eo_add(EVAS_RECTANGLE_CLASS, evas); eo_do(background, - evas_obj_color_set(0, 0, 0, 255), - evas_obj_size_set(WIDTH, HEIGHT), - evas_obj_visibility_set(EINA_TRUE)); + efl_gfx_color_set(0, 0, 0, 255), + efl_gfx_size_set(WIDTH, HEIGHT), + efl_gfx_visible_set(EINA_TRUE)); image = evas_object_image_filled_add(evas); eo_do(image, - evas_obj_size_set(WIDTH, HEIGHT), - evas_obj_visibility_set(EINA_TRUE)); + efl_gfx_size_set(WIDTH, HEIGHT), + efl_gfx_visible_set(EINA_TRUE)); evas_object_focus_set(image, EINA_TRUE); eo_do(image, evas_obj_image_scene_set(scene)); diff --git a/src/examples/evas/evas-3d-blending.c b/src/examples/evas/evas-3d-blending.c index d45248362d..5e47739ee7 100644 --- a/src/examples/evas/evas-3d-blending.c +++ b/src/examples/evas/evas-3d-blending.c @@ -136,8 +136,8 @@ _on_canvas_resize(Ecore_Evas *ee) ecore_evas_geometry_get(ee, NULL, NULL, &w, &h); evas_object_resize(background, w, h); - eo_do(background, evas_obj_size_set(w, h)); - eo_do(image, evas_obj_size_set(w, h)); + eo_do(background, efl_gfx_size_set(w, h)); + eo_do(image, efl_gfx_size_set(w, h)); } static Eina_Bool diff --git a/src/examples/evas/evas-3d-cube.c b/src/examples/evas/evas-3d-cube.c index bfe57e8680..14a5ec8319 100644 --- a/src/examples/evas/evas-3d-cube.c +++ b/src/examples/evas/evas-3d-cube.c @@ -110,8 +110,8 @@ _on_canvas_resize(Ecore_Evas *ee) int w, h; ecore_evas_geometry_get(ee, NULL, NULL, &w, &h); - eo_do(background, evas_obj_size_set(w, h)); - eo_do(image, evas_obj_size_set(w, h)); + eo_do(background, efl_gfx_size_set(w, h)); + eo_do(image, efl_gfx_size_set(w, h)); } static Eina_Bool @@ -260,15 +260,15 @@ main(void) /* Add a background rectangle objects. */ background = eo_add(EVAS_RECTANGLE_CLASS, evas); eo_do(background, - evas_obj_color_set(0, 0, 0, 255), - evas_obj_size_set(WIDTH, HEIGHT), - evas_obj_visibility_set(EINA_TRUE)); + efl_gfx_color_set(0, 0, 0, 255), + efl_gfx_size_set(WIDTH, HEIGHT), + efl_gfx_visible_set(EINA_TRUE)); /* Add an image object for 3D scene rendering. */ image = evas_object_image_filled_add(evas); eo_do(image, - evas_obj_size_set(WIDTH, HEIGHT), - evas_obj_visibility_set(EINA_TRUE)); + efl_gfx_size_set(WIDTH, HEIGHT), + efl_gfx_visible_set(EINA_TRUE)); /* Set the image object as render target for 3D scene. */ eo_do(image, evas_obj_image_scene_set(data.scene)); diff --git a/src/examples/evas/evas-3d-cube2.c b/src/examples/evas/evas-3d-cube2.c index 4a1afaaf07..aff4fdbe68 100644 --- a/src/examples/evas/evas-3d-cube2.c +++ b/src/examples/evas/evas-3d-cube2.c @@ -79,8 +79,8 @@ _on_canvas_resize(Ecore_Evas *ee) int w, h; ecore_evas_geometry_get(ee, NULL, NULL, &w, &h); - eo_do(background, evas_obj_size_set(w, h)); - eo_do(image, evas_obj_size_set(w, h)); + eo_do(background, efl_gfx_size_set(w, h)); + eo_do(image, efl_gfx_size_set(w, h)); } static Eina_Bool @@ -259,15 +259,15 @@ main(void) /* Add a background rectangle objects. */ background = eo_add(EVAS_RECTANGLE_CLASS, evas); eo_do(background, - evas_obj_color_set(0, 0, 0, 255), - evas_obj_size_set(WIDTH, HEIGHT), - evas_obj_visibility_set(EINA_TRUE)); + efl_gfx_color_set(0, 0, 0, 255), + efl_gfx_size_set(WIDTH, HEIGHT), + efl_gfx_visible_set(EINA_TRUE)); /* Add an image object for 3D scene rendering. */ image = evas_object_image_filled_add(evas); eo_do(image, - evas_obj_size_set(WIDTH, HEIGHT), - evas_obj_visibility_set(EINA_TRUE)); + efl_gfx_size_set(WIDTH, HEIGHT), + efl_gfx_visible_set(EINA_TRUE)); /* Set the image object as render target for 3D scene. */ eo_do(image, evas_obj_image_scene_set(data.scene)); diff --git a/src/examples/evas/evas-3d-eet.c b/src/examples/evas/evas-3d-eet.c index 18dc2e4620..4178a4eff4 100644 --- a/src/examples/evas/evas-3d-eet.c +++ b/src/examples/evas/evas-3d-eet.c @@ -93,8 +93,8 @@ _on_canvas_resize(Ecore_Evas *ee) int w, h; ecore_evas_geometry_get(ee, NULL, NULL, &w, &h); - eo_do(background, evas_obj_size_set(w, h)); - eo_do(image, evas_obj_size_set(w, h)); + eo_do(background, efl_gfx_size_set(w, h)); + eo_do(image, efl_gfx_size_set(w, h)); } int @@ -214,15 +214,15 @@ main(void) /* Add a background rectangle objects. */ background = eo_add(EVAS_RECTANGLE_CLASS, evas); eo_do(background, - evas_obj_color_set(0, 0, 0, 255), - evas_obj_size_set(WIDTH, HEIGHT), - evas_obj_visibility_set(EINA_TRUE)); + efl_gfx_color_set(0, 0, 0, 255), + efl_gfx_size_set(WIDTH, HEIGHT), + efl_gfx_visible_set(EINA_TRUE)); /* Add an image object for 3D scene rendering. */ image = evas_object_image_filled_add(evas); eo_do(image, - evas_obj_size_set(WIDTH, HEIGHT), - evas_obj_visibility_set(EINA_TRUE)); + efl_gfx_size_set(WIDTH, HEIGHT), + efl_gfx_visible_set(EINA_TRUE)); /* Set the image object as render target for 3D scene. */ eo_do(image, evas_obj_image_scene_set(scene)); diff --git a/src/examples/evas/evas-3d-md2.c b/src/examples/evas/evas-3d-md2.c index d48926c9ee..428379da40 100644 --- a/src/examples/evas/evas-3d-md2.c +++ b/src/examples/evas/evas-3d-md2.c @@ -68,8 +68,8 @@ _on_canvas_resize(Ecore_Evas *ee) int w, h; ecore_evas_geometry_get(ee, NULL, NULL, &w, &h); - eo_do(background, evas_obj_size_set(w, h)); - eo_do(image, evas_obj_size_set(w, h)); + eo_do(background, efl_gfx_size_set(w, h)); + eo_do(image, efl_gfx_size_set(w, h)); } int @@ -178,15 +178,15 @@ main(void) /* Add a background rectangle objects. */ background = eo_add(EVAS_RECTANGLE_CLASS, evas); eo_do(background, - evas_obj_color_set(0, 0, 0, 255), - evas_obj_size_set(WIDTH, HEIGHT), - evas_obj_visibility_set(EINA_TRUE)); + efl_gfx_color_set(0, 0, 0, 255), + efl_gfx_size_set(WIDTH, HEIGHT), + efl_gfx_visible_set(EINA_TRUE)); /* Add an image object for 3D scene rendering. */ image = evas_object_image_filled_add(evas); eo_do(image, - evas_obj_size_set(WIDTH, HEIGHT), - evas_obj_visibility_set(EINA_TRUE)); + efl_gfx_size_set(WIDTH, HEIGHT), + efl_gfx_visible_set(EINA_TRUE)); /* Set the image object as render target for 3D scene. */ eo_do(image, evas_obj_image_scene_set(scene)); diff --git a/src/examples/evas/evas-3d-mmap-set.c b/src/examples/evas/evas-3d-mmap-set.c index 0855d7604c..ea9308101b 100644 --- a/src/examples/evas/evas-3d-mmap-set.c +++ b/src/examples/evas/evas-3d-mmap-set.c @@ -34,7 +34,7 @@ extention##_file = eina_file_open(buffer , 0); \ mesh_##extention = eo_add(EVAS_3D_MESH_CLASS, evas); \ eo_do(mesh_##extention, \ - evas_3d_mesh_mmap_set(extention##_file, NULL), \ + efl_file_mmap_set(extention##_file, NULL), \ evas_3d_mesh_frame_material_set(0, material), \ evas_3d_mesh_shade_mode_set(EVAS_3D_SHADE_MODE_PHONG)); \ node_##extention = eo_add(EVAS_3D_NODE_CLASS, evas, \ @@ -161,8 +161,8 @@ _on_canvas_resize(Ecore_Evas *ee) int w, h; ecore_evas_geometry_get(ee, NULL, NULL, &w, &h); - eo_do(background, evas_obj_size_set(w, h)); - eo_do(image, evas_obj_size_set(w, h)); + eo_do(background, efl_gfx_size_set(w, h)); + eo_do(image, efl_gfx_size_set(w, h)); } int @@ -258,15 +258,15 @@ main(void) /* Add a background rectangle objects. */ background = eo_add(EVAS_RECTANGLE_CLASS, evas); eo_do(background, - evas_obj_color_set(20, 20, 200, 255), - evas_obj_size_set(WIDTH, HEIGHT), - evas_obj_visibility_set(EINA_TRUE)); + efl_gfx_color_set(20, 20, 200, 255), + efl_gfx_size_set(WIDTH, HEIGHT), + efl_gfx_visible_set(EINA_TRUE)); /* Add an image object for 3D scene rendering. */ image = evas_object_image_filled_add(evas); eo_do(image, - evas_obj_size_set(WIDTH, HEIGHT), - evas_obj_visibility_set(EINA_TRUE)); + efl_gfx_size_set(WIDTH, HEIGHT), + efl_gfx_visible_set(EINA_TRUE)); /* Set the image object as render target for 3D scene. */ eo_do(image, evas_obj_image_scene_set(scene)); diff --git a/src/examples/evas/evas-3d-obj.c b/src/examples/evas/evas-3d-obj.c index 9676dff0af..406ac7fda0 100644 --- a/src/examples/evas/evas-3d-obj.c +++ b/src/examples/evas/evas-3d-obj.c @@ -139,8 +139,8 @@ _on_canvas_resize(Ecore_Evas *ee) int w, h; ecore_evas_geometry_get(ee, NULL, NULL, &w, &h); - eo_do(background, evas_obj_size_set(w, h)); - eo_do(image, evas_obj_size_set(w, h)); + eo_do(background, efl_gfx_size_set(w, h)); + eo_do(image, efl_gfx_size_set(w, h)); } int @@ -235,15 +235,15 @@ main(void) /* Add a background rectangle MESHES. */ background = eo_add(EVAS_RECTANGLE_CLASS, evas); eo_do(background, - evas_obj_color_set(0, 0, 0, 255), - evas_obj_size_set(WIDTH, HEIGHT), - evas_obj_visibility_set(EINA_TRUE)); + efl_gfx_color_set(0, 0, 0, 255), + efl_gfx_size_set(WIDTH, HEIGHT), + efl_gfx_visible_set(EINA_TRUE)); /* Add an image object for 3D scene rendering. */ image = evas_object_image_filled_add(evas); eo_do(image, - evas_obj_size_set(WIDTH, HEIGHT), - evas_obj_visibility_set(EINA_TRUE)); + efl_gfx_size_set(WIDTH, HEIGHT), + efl_gfx_visible_set(EINA_TRUE)); /* Set the image object as render target for 3D scene. */ eo_do(image, evas_obj_image_scene_set(scene)); diff --git a/src/examples/evas/evas-3d-pick.c b/src/examples/evas/evas-3d-pick.c index bcd9c8473e..49eda2ce20 100644 --- a/src/examples/evas/evas-3d-pick.c +++ b/src/examples/evas/evas-3d-pick.c @@ -199,15 +199,15 @@ main(void) /* Add evas objects. */ background = eo_add(EVAS_RECTANGLE_CLASS, evas); eo_do(background, - evas_obj_color_set(0, 0, 0, 255), - evas_obj_size_set(WIDTH, HEIGHT), - evas_obj_visibility_set(EINA_TRUE)); + efl_gfx_color_set(0, 0, 0, 255), + efl_gfx_size_set(WIDTH, HEIGHT), + efl_gfx_visible_set(EINA_TRUE)); image = evas_object_image_filled_add(evas); eo_do(image, evas_obj_image_scene_set(scene), - evas_obj_size_set(WIDTH, HEIGHT), - evas_obj_visibility_set(EINA_TRUE)); + efl_gfx_size_set(WIDTH, HEIGHT), + efl_gfx_visible_set(EINA_TRUE)); evas_object_event_callback_add(image, EVAS_CALLBACK_MOUSE_DOWN, _on_mouse_down, NULL); diff --git a/src/examples/evas/evas-3d-ply.c b/src/examples/evas/evas-3d-ply.c index a64263b0fb..502b3d6312 100644 --- a/src/examples/evas/evas-3d-ply.c +++ b/src/examples/evas/evas-3d-ply.c @@ -91,8 +91,8 @@ _on_canvas_resize(Ecore_Evas *ee) int w, h; ecore_evas_geometry_get(ee, NULL, NULL, &w, &h); - eo_do(background, evas_obj_size_set(w, h)); - eo_do(image, evas_obj_size_set(w, h)); + eo_do(background, efl_gfx_size_set(w, h)); + eo_do(image, efl_gfx_size_set(w, h)); } int @@ -227,15 +227,15 @@ main(void) /* Add a background rectangle objects. */ background = eo_add(EVAS_RECTANGLE_CLASS, evas); eo_do(background, - evas_obj_color_set(100, 100, 100, 255), - evas_obj_size_set(WIDTH, HEIGHT), - evas_obj_visibility_set(EINA_TRUE)); + efl_gfx_color_set(100, 100, 100, 255), + efl_gfx_size_set(WIDTH, HEIGHT), + efl_gfx_visible_set(EINA_TRUE)); /* Add an image object for 3D scene rendering. */ image = evas_object_image_filled_add(evas); eo_do(image, - evas_obj_size_set(WIDTH, HEIGHT), - evas_obj_visibility_set(EINA_TRUE)); + efl_gfx_size_set(WIDTH, HEIGHT), + efl_gfx_visible_set(EINA_TRUE)); /* Set the image object as render target for 3D scene. */ eo_do(image, evas_obj_image_scene_set(scene)); diff --git a/src/examples/evas/evas-3d-proxy.c b/src/examples/evas/evas-3d-proxy.c index 7fbe8e3096..71ef979faf 100644 --- a/src/examples/evas/evas-3d-proxy.c +++ b/src/examples/evas/evas-3d-proxy.c @@ -56,8 +56,8 @@ _on_canvas_resize(Ecore_Evas *ee) int w, h; ecore_evas_geometry_get(ee, NULL, NULL, &w, &h); - eo_do(background, evas_obj_size_set(w, h)); - eo_do(image, evas_obj_size_set(w, h)); + eo_do(background, efl_gfx_size_set(w, h)); + eo_do(image, efl_gfx_size_set(w, h)); } static Eina_Bool @@ -218,23 +218,23 @@ main(void) /* Add a background rectangle objects. */ background = eo_add(EVAS_RECTANGLE_CLASS, evas); eo_do(background, - evas_obj_color_set(0, 0, 0, 255), - evas_obj_size_set(WIDTH, HEIGHT), - evas_obj_visibility_set(EINA_TRUE)); + efl_gfx_color_set(0, 0, 0, 255), + efl_gfx_size_set(WIDTH, HEIGHT), + efl_gfx_visible_set(EINA_TRUE)); /* Add a background image. */ source = evas_object_image_filled_add(evas); eo_do(source, - evas_obj_image_size_set(IMG_WIDTH, IMG_HEIGHT), - evas_obj_position_set((WIDTH / 2), (HEIGHT / 2)), - evas_obj_size_set((WIDTH / 2), (HEIGHT / 2)), - evas_obj_visibility_set(EINA_TRUE)); + efl_gfx_view_size_set(IMG_WIDTH, IMG_HEIGHT), + efl_gfx_position_set((WIDTH / 2), (HEIGHT / 2)), + efl_gfx_size_set((WIDTH / 2), (HEIGHT / 2)), + efl_gfx_visible_set(EINA_TRUE)); /* Add an image object for 3D scene rendering. */ image = evas_object_image_filled_add(evas); eo_do(image, - evas_obj_size_set((WIDTH / 2), (HEIGHT / 2)), - evas_obj_visibility_set(EINA_TRUE)); + efl_gfx_size_set((WIDTH / 2), (HEIGHT / 2)), + efl_gfx_visible_set(EINA_TRUE)); /* Setup scene */ _scene_setup(&data); diff --git a/src/examples/evas/evas-3d-shadows.c b/src/examples/evas/evas-3d-shadows.c index d53f435127..c1eb0875d5 100644 --- a/src/examples/evas/evas-3d-shadows.c +++ b/src/examples/evas/evas-3d-shadows.c @@ -147,8 +147,8 @@ _on_canvas_resize(Ecore_Evas *ee) int w, h; ecore_evas_geometry_get(ee, NULL, NULL, &w, &h); - eo_do(background, evas_obj_size_set(w, h)); - eo_do(image, evas_obj_size_set(w, h)); + eo_do(background, efl_gfx_size_set(w, h)); + eo_do(image, efl_gfx_size_set(w, h)); } static void @@ -525,15 +525,15 @@ main(void) /* Add a background rectangle objects. */ background = eo_add(EVAS_RECTANGLE_CLASS, evas); eo_do(background, - evas_obj_color_set(0, 0, 0, 255), - evas_obj_size_set(WIDTH, HEIGHT), - evas_obj_visibility_set(EINA_TRUE)); + efl_gfx_color_set(0, 0, 0, 255), + efl_gfx_size_set(WIDTH, HEIGHT), + efl_gfx_visible_set(EINA_TRUE)); /* Add an image object for 3D scene rendering. */ image = evas_object_image_filled_add(evas); eo_do(image, - evas_obj_size_set(WIDTH, HEIGHT), - evas_obj_visibility_set(EINA_TRUE)); + efl_gfx_size_set(WIDTH, HEIGHT), + efl_gfx_visible_set(EINA_TRUE)); evas_object_focus_set(image, EINA_TRUE); /* Set the image object as render target for 3D scene. */ diff --git a/src/examples/evas/evas-object-manipulation-eo.c b/src/examples/evas/evas-object-manipulation-eo.c index 6bb2cbd978..9f17ee8313 100644 --- a/src/examples/evas/evas-object-manipulation-eo.c +++ b/src/examples/evas/evas-object-manipulation-eo.c @@ -59,7 +59,7 @@ _canvas_resize_cb(Ecore_Evas *ee) int w, h; ecore_evas_geometry_get(ee, NULL, NULL, &w, &h); - eo_do(d.bg, evas_obj_size_set(w, h)); + eo_do(d.bg, efl_gfx_size_set(w, h)); } static void @@ -80,7 +80,7 @@ _on_keydown(void *data EINA_UNUSED, { int alpha, r, g, b; - eo_do(d.clipper, evas_obj_color_get(&r, &g, &b, &alpha)); + eo_do(d.clipper, efl_gfx_color_get(&r, &g, &b, &alpha)); evas_color_argb_unpremul(alpha, &r, &g, &b); alpha -= 20; @@ -88,7 +88,7 @@ _on_keydown(void *data EINA_UNUSED, alpha = 255; evas_color_argb_premul(alpha, &r, &g, &b); - eo_do(d.clipper, evas_obj_color_set(r, g, b, alpha)); + eo_do(d.clipper, efl_gfx_color_set(r, g, b, alpha)); fprintf(stdout, "Changing clipper's opacity: %d%%\n", (int)((alpha / 255.0) * 100)); @@ -102,7 +102,7 @@ _on_keydown(void *data EINA_UNUSED, fprintf(stdout, "Changing clipper's color to"); - eo_do(d.clipper, evas_obj_color_get(&r, &g, &b, &alpha)); + eo_do(d.clipper, efl_gfx_color_get(&r, &g, &b, &alpha)); evas_color_argb_unpremul(alpha, &r, &g, &b); if (g > 0) @@ -117,7 +117,7 @@ _on_keydown(void *data EINA_UNUSED, } evas_color_argb_premul(alpha, &r, &g, &b); - eo_do(d.clipper, evas_obj_color_set(r, g, b, alpha)); + eo_do(d.clipper, efl_gfx_color_set(r, g, b, alpha)); return; } @@ -145,8 +145,8 @@ _on_keydown(void *data EINA_UNUSED, Eina_Bool visibility; /* Don't use "get"-"set" expressions in one eo_do call, * if you pass parameter to "set" by value. */ - eo_do(d.clipper, visibility = evas_obj_visibility_get()); - eo_do(d.clipper, evas_obj_visibility_set(!visibility)); + eo_do(d.clipper, visibility = efl_gfx_visible_get()); + eo_do(d.clipper, efl_gfx_visible_set(!visibility)); fprintf(stdout, "Clipper is now %s\n", visibility ? "hidden" : "visible"); return; } @@ -178,10 +178,10 @@ main(void) /* Eo-styled way to perform actions on an object*/ eo_do(d.bg, evas_obj_name_set("background rectangle"), - evas_obj_color_set(255, 255, 255, 255), /* white bg */ - evas_obj_position_set(0, 0), /* at canvas' origin */ - evas_obj_size_set(WIDTH, HEIGHT), /* covers full canvas */ - evas_obj_visibility_set(EINA_TRUE), + efl_gfx_color_set(255, 255, 255, 255), /* white bg */ + efl_gfx_position_set(0, 0), /* at canvas' origin */ + efl_gfx_size_set(WIDTH, HEIGHT), /* covers full canvas */ + efl_gfx_visible_set(EINA_TRUE), evas_obj_focus_set(EINA_TRUE)); evas_object_event_callback_add( @@ -204,9 +204,9 @@ main(void) } else { - eo_do(d.img, evas_obj_position_set(0, 0), - evas_obj_size_set(WIDTH, HEIGHT), - evas_obj_visibility_set(EINA_TRUE)); + eo_do(d.img, efl_gfx_position_set(0, 0), + efl_gfx_size_set(WIDTH, HEIGHT), + efl_gfx_visible_set(EINA_TRUE)); const char *type = NULL; eo_do(d.img, type = evas_obj_type_get()); @@ -228,9 +228,9 @@ main(void) eo_do(d.clipper_border, evas_obj_image_border_set(3, 3, 3, 3), evas_obj_image_border_center_fill_set(EVAS_BORDER_FILL_NONE), - evas_obj_position_set((WIDTH / 4) -3, (HEIGHT / 4) - 3), - evas_obj_size_set((WIDTH / 2) + 6, (HEIGHT / 2) + 6), - evas_obj_visibility_set(EINA_TRUE)); + efl_gfx_position_set((WIDTH / 4) -3, (HEIGHT / 4) - 3), + efl_gfx_size_set((WIDTH / 2) + 6, (HEIGHT / 2) + 6), + efl_gfx_visible_set(EINA_TRUE)); } /* solid white clipper (note that it's the default color for a * rectangle) - it won't change clippees' colors, then (multiplying @@ -238,9 +238,9 @@ main(void) d.clipper = eo_add(EVAS_RECTANGLE_CLASS, d.canvas); eo_do(d.clipper, - evas_obj_position_set( WIDTH / 4, HEIGHT / 4), - evas_obj_size_set(WIDTH / 2, HEIGHT / 2), - evas_obj_visibility_set(EINA_TRUE)); + efl_gfx_position_set( WIDTH / 4, HEIGHT / 4), + efl_gfx_size_set(WIDTH / 2, HEIGHT / 2), + efl_gfx_visible_set(EINA_TRUE)); eo_do(d.img, evas_obj_clip_set(d.clipper)); diff --git a/src/examples/evas/evas_cxx_rectangle.cc b/src/examples/evas/evas_cxx_rectangle.cc index d307200a8b..d41902f109 100644 --- a/src/examples/evas/evas_cxx_rectangle.cc +++ b/src/examples/evas/evas_cxx_rectangle.cc @@ -44,7 +44,7 @@ int main() rect.color_set(255, 0, 0, 255); rect.position_set(10, 10); rect.size_set(100, 100); - rect.visibility_set(true); + rect.visible_set(true); canvas.render(); } From 0de4a1a4f2d45ed6b2eda2007b8e8bb5d9b9d365 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:30:48 +0200 Subject: [PATCH 121/251] eolian_cxx: fix change visibility to visible. --- src/examples/eolian_cxx/eolian_cxx_complex_types_01.cc | 8 ++++---- src/examples/eolian_cxx/eolian_cxx_eo_events_01.cc | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/examples/eolian_cxx/eolian_cxx_complex_types_01.cc b/src/examples/eolian_cxx/eolian_cxx_complex_types_01.cc index 8dd5d29d87..fc488980ce 100644 --- a/src/examples/eolian_cxx/eolian_cxx_complex_types_01.cc +++ b/src/examples/eolian_cxx/eolian_cxx_complex_types_01.cc @@ -70,20 +70,20 @@ example_complex_types() bg.color_set(255, 255, 255, 255); bg.position_set(0, 0); bg.size_set(500, 250); - bg.visibility_set(true); + bg.visible_set(true); efl::evas::grid grid(efl::eo::parent = canvas); grid.position_set(0, 0); grid.object_smart::color_set(0, 0, 0, 255); grid.size_set(5, 5); - grid.visibility_set(true); + grid.visible_set(true); efl::evas::text text1(efl::eo::parent = canvas); text1.style_set(EVAS_TEXT_STYLE_OUTLINE); text1.color_set(255, 0, 0, 255); text1.font_set("DejaVu", 32); text1.text_set("EFL++ Examples"); - text1.visibility_set(true); + text1.visible_set(true); int t1w, t1h; text1.size_get(&t1w, &t1h); grid.pack(text1, 1, 1, t1w, t1h); @@ -96,7 +96,7 @@ example_complex_types() std::stringstream ss; ss << "version " << EFL_VERSION_MAJOR << "." << EFL_VERSION_MINOR; text2.text_set(ss.str().c_str()); - text2.visibility_set(true); + text2.visible_set(true); int t2w, t2h; text2.size_get(&t2w, &t2h); diff --git a/src/examples/eolian_cxx/eolian_cxx_eo_events_01.cc b/src/examples/eolian_cxx/eolian_cxx_eo_events_01.cc index 3cce90c655..ca9f28422e 100644 --- a/src/examples/eolian_cxx/eolian_cxx_eo_events_01.cc +++ b/src/examples/eolian_cxx/eolian_cxx_eo_events_01.cc @@ -73,7 +73,7 @@ example_complex_types() bg.color_set(255, 255, 255, 255); bg.position_set(0, 0); bg.size_set(500, 250); - bg.visibility_set(true); + bg.visible_set(true); efl::eo::signal_connection conn = bg.callback_mouse_down_add From df43ec94874ecb0b5e6ec26a86a464a7009af4af Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:30:48 +0200 Subject: [PATCH 122/251] ector: fix constructor/destructor of Ector_Cairo backend. --- src/lib/ector/cairo/ector_cairo_surface.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lib/ector/cairo/ector_cairo_surface.c b/src/lib/ector/cairo/ector_cairo_surface.c index c2d42a9b87..6a89282788 100644 --- a/src/lib/ector/cairo/ector_cairo_surface.c +++ b/src/lib/ector/cairo/ector_cairo_surface.c @@ -79,6 +79,7 @@ static void _ector_cairo_surface_eo_base_constructor(Eo *obj EINA_UNUSED, Ector_Cairo_Surface_Data *pd EINA_UNUSED) { + eo_do_super(obj, ECTOR_CAIRO_SURFACE_CLASS, eo_constructor()); _cairo_count++; } @@ -86,11 +87,12 @@ static void _ector_cairo_surface_eo_base_destructor(Eo *obj EINA_UNUSED, Ector_Cairo_Surface_Data *pd EINA_UNUSED) { + eo_do_super(obj, ECTOR_CAIRO_SURFACE_CLASS, eo_destructor()); + if (--_cairo_count) return ; if (_cairo_so) eina_module_free(_cairo_so); _cairo_so = NULL; } - #include "ector_cairo_surface.eo.c" #include "ector_renderer_cairo_base.eo.c" From 4e0b919a625e7e5c2fbf3139aeb24296fd739763 Mon Sep 17 00:00:00 2001 From: ChunEon Park Date: Fri, 3 Apr 2015 16:30:49 +0200 Subject: [PATCH 123/251] evas: ref/unref root node while it's being used by vg object. This also remove dead code. --- src/lib/evas/canvas/evas_object_vg.c | 18 ++++++++---------- src/lib/evas/canvas/evas_vg.eo | 3 ++- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/lib/evas/canvas/evas_object_vg.c b/src/lib/evas/canvas/evas_object_vg.c index 8b1f5de76b..a106dec6bb 100644 --- a/src/lib/evas/canvas/evas_object_vg.c +++ b/src/lib/evas/canvas/evas_object_vg.c @@ -89,22 +89,19 @@ evas_object_vg_add(Evas *e) return eo_obj; } -void -_evas_vg_root_node_set(Eo *obj EINA_UNUSED, Evas_VG_Data *pd, Evas_VG_Node *container) -{ - Evas_VG_Node *tmp; - - tmp = pd->root; - pd->root = eo_ref(container); - eo_unref(tmp); -} - Evas_VG_Node * _evas_vg_root_node_get(Eo *obj EINA_UNUSED, Evas_VG_Data *pd) { return pd->root; } +void +_evas_vg_eo_base_destructor(Eo *eo_obj, Evas_VG_Data *pd) +{ + eo_unref(pd->root); + eo_do_super(eo_obj, MY_CLASS, eo_destructor()); +} + void _evas_vg_eo_base_constructor(Eo *eo_obj, Evas_VG_Data *pd) { @@ -120,6 +117,7 @@ _evas_vg_eo_base_constructor(Eo *eo_obj, Evas_VG_Data *pd) /* root node */ pd->root = eo_add(EVAS_VG_ROOT_NODE_CLASS, eo_obj); + eo_ref(pd->root); eo_do(eo_obj, parent = eo_parent_get()); evas_object_inject(eo_obj, obj, evas_object_evas_get(parent)); diff --git a/src/lib/evas/canvas/evas_vg.eo b/src/lib/evas/canvas/evas_vg.eo index f7e91c394c..3caf177c88 100644 --- a/src/lib/evas/canvas/evas_vg.eo +++ b/src/lib/evas/canvas/evas_vg.eo @@ -21,6 +21,7 @@ class Evas.VG (Evas.Object, Efl.File, Efl.Gfx.Fill, Efl.Gfx.View) } implements { Eo.Base.constructor; + Eo.Base.destructor; Efl.File.file.set; Efl.File.file.get; Efl.File.mmap.set; @@ -30,4 +31,4 @@ class Evas.VG (Evas.Object, Efl.File, Efl.Gfx.Fill, Efl.Gfx.View) Efl.Gfx.View.size.set; Efl.Gfx.View.size.get; } -} \ No newline at end of file +} From 44d5a174850f9bb863fee9c0497ca1648ca0f78d Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:30:50 +0200 Subject: [PATCH 124/251] evas: eina array macro don't work well on NULL array. --- .../evas/engines/gl_generic/evas_engine.c | 26 +++++++++++-------- .../engines/software_generic/evas_engine.c | 26 +++++++++++-------- 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/src/modules/evas/engines/gl_generic/evas_engine.c b/src/modules/evas/engines/gl_generic/evas_engine.c index 225a32b006..d1d0ff15a9 100644 --- a/src/modules/evas/engines/gl_generic/evas_engine.c +++ b/src/modules/evas/engines/gl_generic/evas_engine.c @@ -2144,21 +2144,25 @@ eng_ector_renderer_draw(void *data EINA_UNUSED, void *context, void *surface, Ec } c = eina_array_new(8); - EINA_ARRAY_ITER_NEXT(clips, i, r, it) + if (clips) { - Eina_Rectangle *rc; + EINA_ARRAY_ITER_NEXT(clips, i, r, it) + { + Eina_Rectangle *rc; - rc = eina_rectangle_new(r->x, r->y, r->w, r->h); - if (!rc) continue; + rc = eina_rectangle_new(r->x, r->y, r->w, r->h); + if (!rc) continue; - if (eina_rectangle_intersection(rc, &clip)) - eina_array_push(c, rc); - else - eina_rectangle_free(rc); + if (eina_rectangle_intersection(rc, &clip)) + eina_array_push(c, rc); + else + eina_rectangle_free(rc); + } + + if (eina_array_count(c) == 0 && + eina_array_count(clips) > 0) + return ; } - if (eina_array_count(c) == 0 && - eina_array_count(clips) > 0) - return ; if (eina_array_count(c) == 0) eina_array_push(c, eina_rectangle_new(clip.x, clip.y, clip.w, clip.h)); diff --git a/src/modules/evas/engines/software_generic/evas_engine.c b/src/modules/evas/engines/software_generic/evas_engine.c index 024a44eb95..16130875b4 100644 --- a/src/modules/evas/engines/software_generic/evas_engine.c +++ b/src/modules/evas/engines/software_generic/evas_engine.c @@ -3534,21 +3534,25 @@ eng_ector_renderer_draw(void *data EINA_UNUSED, void *context, void *surface, Ec } c = eina_array_new(8); - EINA_ARRAY_ITER_NEXT(clips, i, r, it) + if (clips) { - Eina_Rectangle *rc; + EINA_ARRAY_ITER_NEXT(clips, i, r, it) + { + Eina_Rectangle *rc; - rc = eina_rectangle_new(r->x, r->y, r->w, r->h); - if (!rc) continue; + rc = eina_rectangle_new(r->x, r->y, r->w, r->h); + if (!rc) continue; - if (eina_rectangle_intersection(rc, &clip)) - eina_array_push(c, rc); - else - eina_rectangle_free(rc); + if (eina_rectangle_intersection(rc, &clip)) + eina_array_push(c, rc); + else + eina_rectangle_free(rc); + } + + if (eina_array_count(c) == 0 && + eina_array_count(clips) > 0) + return ; } - if (eina_array_count(c) == 0 && - eina_array_count(clips) > 0) - return ; if (eina_array_count(c) == 0) eina_array_push(c, eina_rectangle_new(clip.x, clip.y, clip.w, clip.h)); From 27f0399d0862757f2288d5ee927f47f0243957f7 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:30:51 +0200 Subject: [PATCH 125/251] efl: Efl.Gfx.Shape should actually be a mixin. --- src/lib/efl/interfaces/efl_gfx_shape.c | 8 ++++---- src/lib/efl/interfaces/efl_gfx_shape.eo | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/lib/efl/interfaces/efl_gfx_shape.c b/src/lib/efl/interfaces/efl_gfx_shape.c index 87363d9b77..dc03ae9d3d 100644 --- a/src/lib/efl/interfaces/efl_gfx_shape.c +++ b/src/lib/efl/interfaces/efl_gfx_shape.c @@ -231,8 +231,8 @@ _efl_gfx_shape_interpolate(Eo *obj, Efl_Gfx_Shape_Data *pd, double *pts, *from_pts, *to_pts; unsigned int i, j; - from_pd = eo_data_scope_get(from, EFL_GFX_SHAPE_CLASS); - to_pd = eo_data_scope_get(to, EFL_GFX_SHAPE_CLASS); + from_pd = eo_data_scope_get(from, EFL_GFX_SHAPE_MIXIN); + to_pd = eo_data_scope_get(to, EFL_GFX_SHAPE_MIXIN); if (!from_pd && !to_pd) return EINA_FALSE; if (!_efl_gfx_shape_equal_commands_internal(from_pd, to_pd)) return EINA_FALSE; @@ -288,7 +288,7 @@ _efl_gfx_shape_equal_commands(Eo *obj EINA_UNUSED, { Efl_Gfx_Shape_Data *with_pd; - with_pd = eo_data_scope_get(with, EFL_GFX_SHAPE_CLASS); + with_pd = eo_data_scope_get(with, EFL_GFX_SHAPE_MIXIN); if (!with_pd) return EINA_FALSE; return _efl_gfx_shape_equal_commands_internal(with_pd, pd); @@ -307,7 +307,7 @@ _efl_gfx_shape_dup(Eo *obj, Efl_Gfx_Shape_Data *pd, Eo *dup_from) double sw; if (obj == dup_from) return ; - from = eo_data_scope_get(dup_from, EFL_GFX_SHAPE_CLASS); + from = eo_data_scope_get(dup_from, EFL_GFX_SHAPE_MIXIN); if (!from) return ; eo_do(dup_from, diff --git a/src/lib/efl/interfaces/efl_gfx_shape.eo b/src/lib/efl/interfaces/efl_gfx_shape.eo index 52ca448da0..1ed3f8fcc0 100644 --- a/src/lib/efl/interfaces/efl_gfx_shape.eo +++ b/src/lib/efl/interfaces/efl_gfx_shape.eo @@ -1,4 +1,4 @@ -class Efl.Gfx.Shape +mixin Efl.Gfx.Shape { legacy_prefix: null; properties { From d6feb49c0c26daceaddcbb27a4c1bf1843bbe229 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:30:52 +0200 Subject: [PATCH 126/251] evas: don't duplicate entry in parent children list eo_parent_set is always called, even in the constructor. --- src/lib/evas/canvas/evas_vg_node.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/lib/evas/canvas/evas_vg_node.c b/src/lib/evas/canvas/evas_vg_node.c index c5ac1100b0..727091f8f2 100644 --- a/src/lib/evas/canvas/evas_vg_node.c +++ b/src/lib/evas/canvas/evas_vg_node.c @@ -221,9 +221,6 @@ _evas_vg_node_eo_base_constructor(Eo *obj, if (!_evas_vg_node_parent_checked_get(obj, &parent, &cd)) eo_error_set(obj); - if (cd) - cd->children = eina_list_append(cd->children, obj); - eo_do(obj, eo_event_callback_add(EFL_GFX_CHANGED, _evas_vg_node_property_changed, pd)); pd->changed = EINA_TRUE; } From 457e5506166acf145579947e86b780b90c7816ed Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:30:53 +0200 Subject: [PATCH 127/251] evas: implement render_pre due to our hack over Evas_VG_Container. --- src/lib/evas/canvas/evas_vg_root_node.c | 30 +++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/lib/evas/canvas/evas_vg_root_node.c b/src/lib/evas/canvas/evas_vg_root_node.c index 1566a18cfa..09834b418f 100644 --- a/src/lib/evas/canvas/evas_vg_root_node.c +++ b/src/lib/evas/canvas/evas_vg_root_node.c @@ -1,6 +1,7 @@ #include "evas_common_private.h" #include "evas_private.h" +#include "evas_vg_private.h" #include "evas_vg_root_node.eo.h" #include @@ -14,6 +15,26 @@ struct _Evas_VG_Root_Node_Data Evas_Object_Protected_Data *data; }; +static void +_evas_vg_root_node_render_pre(Eo *obj EINA_UNUSED, + Eina_Matrix3 *parent, + Ector_Surface *s, + void *data, + Evas_VG_Node_Data *nd) +{ + Evas_VG_Container_Data *pd = data; + Eina_List *l; + Eo *child; + + if (!nd->changed) return ; + nd->changed = EINA_FALSE; + + EVAS_VG_COMPUTE_MATRIX(current, parent, nd); + + EINA_LIST_FOREACH(pd->children, l, child) + _evas_vg_render_pre(child, s, current); +} + static Eina_Bool _evas_vg_root_node_changed(void *data, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, @@ -47,6 +68,8 @@ void _evas_vg_root_node_eo_base_constructor(Eo *obj, Evas_VG_Root_Node_Data *pd) { + Evas_VG_Container_Data *cd; + Evas_VG_Node_Data *nd; Eo *parent; // Nice little hack, jump over parent constructor in Efl_VG_Root @@ -55,6 +78,13 @@ _evas_vg_root_node_eo_base_constructor(Eo *obj, if (!eo_isa(parent, EVAS_VG_CLASS)) eo_error_set(obj); + cd = eo_data_scope_get(obj, EVAS_VG_CONTAINER_CLASS); + cd->children = NULL; + + nd = eo_data_scope_get(obj, EVAS_VG_NODE_CLASS); + nd->render_pre = _evas_vg_root_node_render_pre; + nd->data = cd; + eo_do(obj, eo_event_callback_add(EFL_GFX_CHANGED, _evas_vg_root_node_changed, pd)); } From 6a90d24aabc09b85a079e02d11432524d84816ba Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:30:53 +0200 Subject: [PATCH 128/251] evas: Evas_VG_Root_Node parent will be NULL during destructor. --- src/lib/evas/canvas/evas_vg_root_node.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/evas/canvas/evas_vg_root_node.c b/src/lib/evas/canvas/evas_vg_root_node.c index 09834b418f..d6f2c51a34 100644 --- a/src/lib/evas/canvas/evas_vg_root_node.c +++ b/src/lib/evas/canvas/evas_vg_root_node.c @@ -42,7 +42,7 @@ _evas_vg_root_node_changed(void *data, Eo *obj EINA_UNUSED, { Evas_VG_Root_Node_Data *pd = data; - evas_object_change(pd->parent, pd->data); + if (pd->parent) evas_object_change(pd->parent, pd->data); return EINA_TRUE; } @@ -60,7 +60,7 @@ _evas_vg_root_node_eo_base_parent_set(Eo *obj, else { pd->parent = parent; - pd->data = eo_data_scope_get(parent, EVAS_OBJECT_CLASS); + pd->data = parent ? eo_data_scope_get(parent, EVAS_OBJECT_CLASS) : NULL; } } From 0a27241f61ba711140d14b187b673d90c80596bc Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:30:54 +0200 Subject: [PATCH 129/251] evas: eo_data_scope_get will return random value in memory, need to always use eo_isa. --- src/lib/evas/canvas/evas_object_vg.c | 6 ++++-- src/lib/evas/canvas/evas_vg_node.c | 8 ++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/lib/evas/canvas/evas_object_vg.c b/src/lib/evas/canvas/evas_object_vg.c index a106dec6bb..7d227344f1 100644 --- a/src/lib/evas/canvas/evas_object_vg.c +++ b/src/lib/evas/canvas/evas_object_vg.c @@ -130,7 +130,7 @@ _evas_vg_render(Evas_Object_Protected_Data *obj, { Evas_VG_Container_Data *vd = eo_data_scope_get(n, EVAS_VG_CONTAINER_CLASS); - if (vd) + if (eo_isa(n, EVAS_VG_CONTAINER_CLASS)) { Evas_VG_Node *child; Eina_List *l; @@ -142,7 +142,9 @@ _evas_vg_render(Evas_Object_Protected_Data *obj, } else { - Evas_VG_Node_Data *nd = eo_data_scope_get(n, EVAS_VG_NODE_CLASS); + Evas_VG_Node_Data *nd; + + nd = eo_data_scope_get(n, EVAS_VG_NODE_CLASS); obj->layer->evas->engine.func->ector_renderer_draw(output, context, surface, nd->renderer, clips, x, y, do_async); } diff --git a/src/lib/evas/canvas/evas_vg_node.c b/src/lib/evas/canvas/evas_vg_node.c index 727091f8f2..76bec2500a 100644 --- a/src/lib/evas/canvas/evas_vg_node.c +++ b/src/lib/evas/canvas/evas_vg_node.c @@ -279,8 +279,8 @@ _evas_vg_node_efl_gfx_stack_raise(Eo *obj, Evas_VG_Node_Data *pd EINA_UNUSED) Eo *parent; eo_do(obj, parent = eo_parent_get()); + if (!eo_isa(parent, EVAS_VG_CONTAINER_CLASS)) goto on_error; cd = eo_data_scope_get(parent, EVAS_VG_CONTAINER_CLASS); - if (!cd) goto on_error; // FIXME: this could become slow with to much object lookup = eina_list_data_find_list(cd->children, obj); @@ -309,8 +309,8 @@ _evas_vg_node_efl_gfx_stack_stack_above(Eo *obj, Eo *parent; eo_do(obj, parent = eo_parent_get()); + if (!eo_isa(parent, EVAS_VG_CONTAINER_CLASS)) goto on_error; cd = eo_data_scope_get(parent, EVAS_VG_CONTAINER_CLASS); - if (!cd) goto on_error; // FIXME: this could become slow with to much object lookup = eina_list_data_find_list(cd->children, obj); @@ -339,8 +339,8 @@ _evas_vg_node_efl_gfx_stack_stack_below(Eo *obj, Eo *parent; eo_do(obj, parent = eo_parent_get()); + if (!eo_isa(parent, EVAS_VG_CONTAINER_CLASS)) goto on_error; cd = eo_data_scope_get(parent, EVAS_VG_CONTAINER_CLASS); - if (!cd) goto on_error; // FIXME: this could become slow with to much object lookup = eina_list_data_find_list(cd->children, obj); @@ -367,8 +367,8 @@ _evas_vg_node_efl_gfx_stack_lower(Eo *obj, Evas_VG_Node_Data *pd EINA_UNUSED) Eo *parent; eo_do(obj, parent = eo_parent_get()); + if (!eo_isa(parent, EVAS_VG_CONTAINER_CLASS)) goto on_error; cd = eo_data_scope_get(parent, EVAS_VG_CONTAINER_CLASS); - if (!cd) goto on_error; // FIXME: this could become slow with to much object lookup = eina_list_data_find_list(cd->children, obj); From dd1cae7329c933d48c488a99d297706d29d4521a Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:30:56 +0200 Subject: [PATCH 130/251] evas: initial implementation of a dumb SVG parser. This commit is experimental and may be rebased until usable. --- src/Makefile_Evas.am | 3 +- src/lib/evas/canvas/evas_object_vg.c | 3 +- src/lib/evas/canvas/evas_vg_loader_svg.c | 666 +++++++++++++++++++++++ src/lib/evas/include/evas_private.h | 2 + 4 files changed, 672 insertions(+), 2 deletions(-) create mode 100644 src/lib/evas/canvas/evas_vg_loader_svg.c diff --git a/src/Makefile_Evas.am b/src/Makefile_Evas.am index 34600fe7bf..e7d6e2448a 100644 --- a/src/Makefile_Evas.am +++ b/src/Makefile_Evas.am @@ -149,7 +149,8 @@ lib/evas/canvas/evas_stats.c \ lib/evas/canvas/evas_touch_point.c \ lib/evas/canvas/evas_map.c \ lib/evas/canvas/evas_gl.c \ -lib/evas/canvas/evas_out.c +lib/evas/canvas/evas_out.c \ +lib/evas/canvas/evas_vg_loader_svg.c # Cache lib_evas_libevas_la_SOURCES += \ diff --git a/src/lib/evas/canvas/evas_object_vg.c b/src/lib/evas/canvas/evas_object_vg.c index 7d227344f1..6f41d50ad1 100644 --- a/src/lib/evas/canvas/evas_object_vg.c +++ b/src/lib/evas/canvas/evas_object_vg.c @@ -366,7 +366,7 @@ static Eina_Bool _evas_vg_efl_file_mmap_set(Eo *obj EINA_UNUSED, Evas_VG_Data *pd, const Eina_File *f, const char *key) { - Eina_File *tmp = f ? eina_file_dup(f) : NULL; + Eina_File *tmp; if (f == pd->f && ((key == NULL && pd->key == NULL) || @@ -387,6 +387,7 @@ _evas_vg_efl_file_mmap_set(Eo *obj EINA_UNUSED, Evas_VG_Data *pd, // it succeeded. if (pd->f) eina_file_close(pd->f); pd->f = tmp; + eina_stringshare_replace(&pd->key, key); return EINA_TRUE; } diff --git a/src/lib/evas/canvas/evas_vg_loader_svg.c b/src/lib/evas/canvas/evas_vg_loader_svg.c new file mode 100644 index 0000000000..d173b2ae24 --- /dev/null +++ b/src/lib/evas/canvas/evas_vg_loader_svg.c @@ -0,0 +1,666 @@ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include + +#include +#include +#include "evas_common_private.h" + +typedef struct _Evas_SVG_Loader Evas_SVG_Loader; +struct _Evas_SVG_Loader +{ + Eina_Array *stack; + Eina_Hash *definition; + Evas_Object *vg; + Evas *e; + + unsigned int level; + + Eina_Bool svg : 1; + Eina_Bool defs : 1; + Eina_Bool result : 1; +}; + +static Eina_Bool +_evas_svg_loader_xml_attrs_parser(void *data, const char *key, const char *value) +{ + Evas_SVG_Loader *loader = data; + + fprintf(stderr, "{%s = %s}\n", key, value); + + return EINA_TRUE; +} + +static Eina_Bool +_attrs_id_parser(void *data, const char *key, const char *value) +{ + const char **id = data; + + if (!strcmp(key, "id")) *id = eina_stringshare_add(value); + return EINA_TRUE; +} + +static Eina_Bool +_attrs_size_parser(void *data, const char *key, const char *value) +{ + int width, height; + Evas_Object *vg = data; + Eina_Bool get_w = EINA_FALSE, get_h = EINA_FALSE; + + eo_do(vg, efl_gfx_view_size_get(&width, &height)); + if (!strcmp(key, "width")) + get_w = EINA_TRUE; + else if (!strcmp(key, "height")) + get_h = EINA_TRUE; + + if (get_w || get_h) + { + const char *end = NULL; + unsigned int r; + + r = strtol(value, &end, 10); + if (value != end) + { + if (get_w) width = r; + else if (get_h) height = r; + } + eo_do(vg, efl_gfx_view_size_set(width, height)); + } + + return EINA_TRUE; +} + +static Eina_Bool +_tag_svg_handler(Evas_SVG_Loader *loader, + const char *attrs EINA_UNUSED, + unsigned int attrs_length EINA_UNUSED) +{ + Eo *node; + + if (loader->level != 1) return EINA_FALSE; + + eina_simple_xml_attributes_parse(attrs, attrs_length, + _attrs_size_parser, loader->vg); + + eo_do(loader->vg, node = evas_obj_vg_root_node_get()); + eina_array_push(loader->stack, node); + + loader->svg = EINA_TRUE; + return EINA_TRUE; +} + +static Eina_Bool +_tag_defs_handler(Evas_SVG_Loader *loader, + const char *attrs EINA_UNUSED, + unsigned int attrs_length EINA_UNUSED) +{ + if (loader->level != 1) return EINA_FALSE; + + loader->defs = EINA_TRUE; + return EINA_TRUE; +} + +static Eina_Bool +_tag_linearGradient_handler(Evas_SVG_Loader *loader, + const char *attrs, + unsigned int attrs_length) +{ + const char *id = NULL; + Eo *node; + + if (loader->level < 2) return EINA_FALSE; + + eina_simple_xml_attributes_parse(attrs, attrs_length, + _attrs_id_parser, &id); + + if (!id) return EINA_FALSE; + node = eo_add(EVAS_VG_GRADIENT_LINEAR_CLASS, NULL); + if (!node) return EINA_FALSE; + + eina_hash_direct_add(loader->definition, id, node); + eina_array_push(loader->stack, node); + + return EINA_TRUE; +} + +static double +_attr_percent_parser(const char *value) +{ + char *tmp = NULL; + double r; + int neg = 1; + + r = strtod(value, &tmp); + while(tmp && *tmp == '%') tmp++; + + if (tmp && *tmp == '%') + r = r / 100; + + return r * neg; +} + +static unsigned char +_attr_color_component_parser(const char *value, char **end) +{ + double r; + + r = strtod(value + 4, end); + while (isspace(**end)) (*end)++; + if (**end == '%') + r = 255 * r / 100; + while (isspace(**end)) (*end)++; + + if (r < 0 || r > 255) + { + *end = NULL; + return 0; + } + + return lrint(r); +} + +static const struct { + const char *name; + unsigned int value; +} colors[] = { + { "aliceblue", 0xfff0f8ff }, + { "antiquewhite", 0xfffaebd7 }, + { "aqua", 0xff00ffff }, + { "aquamarine", 0xff7fffd4 }, + { "azure", 0xfff0ffff }, + { "beige", 0xfff5f5dc }, + { "bisque", 0xffffe4c4 }, + { "black", 0xff000000 }, + { "blanchedalmond", 0xffffebcd }, + { "blue", 0xff0000ff }, + { "blueviolet", 0xff8a2be2 }, + { "brown", 0xffa52a2a }, + { "burlywood", 0xffdeb887 }, + { "cadetblue", 0xff5f9ea0 }, + { "chartreuse", 0xff7fff00 }, + { "chocolate", 0xffd2691e }, + { "coral", 0xffff7f50 }, + { "cornflowerblue", 0xff6495ed }, + { "cornsilk", 0xfffff8dc }, + { "crimson", 0xffdc143c }, + { "cyan", 0xff00ffff }, + { "darkblue", 0xff00008b }, + { "darkcyan", 0xff008b8b }, + { "darkgoldenrod", 0xffb8860b }, + { "darkgray", 0xffa9a9a9 }, + { "darkgrey", 0xffa9a9a9 }, + { "darkgreen", 0xff006400 }, + { "darkkhaki", 0xffbdb76b }, + { "darkmagenta", 0xff8b008b }, + { "darkolivegreen", 0xff556b2f }, + { "darkorange", 0xffff8c00 }, + { "darkorchid", 0xff9932cc }, + { "darkred", 0xff8b0000 }, + { "darksalmon", 0xffe9967a }, + { "darkseagreen", 0xff8fbc8f }, + { "darkslateblue", 0xff483d8b }, + { "darkslategray", 0xff2f4f4f }, + { "darkslategrey", 0xff2f4f4f }, + { "darkturquoise", 0xff00ced1 }, + { "darkviolet", 0xff9400d3 }, + { "deeppink", 0xffff1493 }, + { "deepskyblue", 0xff00bfff }, + { "dimgray", 0xff696969 }, + { "dimgrey", 0xff696969 }, + { "dodgerblue", 0xff1e90ff }, + { "firebrick", 0xffb22222 }, + { "floralwhite", 0xfffffaf0 }, + { "forestgreen", 0xff228b22 }, + { "fuchsia", 0xffff00ff }, + { "gainsboro", 0xffdcdcdc }, + { "ghostwhite", 0xfff8f8ff }, + { "gold", 0xffffd700 }, + { "goldenrod", 0xffdaa520 }, + { "gray", 0xff808080 }, + { "grey", 0xff808080 }, + { "green", 0xff008000 }, + { "greenyellow", 0xffadff2f }, + { "honeydew", 0xfff0fff0 }, + { "hotpink", 0xffff69b4 }, + { "indianred", 0xffcd5c5c }, + { "indigo", 0xff4b0082 }, + { "ivory", 0xfffffff0 }, + { "khaki", 0xfff0e68c }, + { "lavender", 0xffe6e6fa }, + { "lavenderblush", 0xfffff0f5 }, + { "lawngreen", 0xff7cfc00 }, + { "lemonchiffon", 0xfffffacd }, + { "lightblue", 0xffadd8e6 }, + { "lightcoral", 0xfff08080 }, + { "lightcyan", 0xffe0ffff }, + { "lightgoldenrodyellow", 0xfffafad2 }, + { "lightgray", 0xffd3d3d3 }, + { "lightgrey", 0xffd3d3d3 }, + { "lightgreen", 0xff90ee90 }, + { "lightpink", 0xffffb6c1 }, + { "lightsalmon", 0xffffa07a }, + { "lightseagreen", 0xff20b2aa }, + { "lightskyblue", 0xff87cefa }, + { "lightslategray", 0xff778899 }, + { "lightslategrey", 0xff778899 }, + { "lightsteelblue", 0xffb0c4de }, + { "lightyellow", 0xffffffe0 }, + { "lime", 0xff00ff00 }, + { "limegreen", 0xff32cd32 }, + { "linen", 0xfffaf0e6 }, + { "magenta", 0xffff00ff }, + { "maroon", 0xff800000 }, + { "mediumaquamarine", 0xff66cdaa }, + { "mediumblue", 0xff0000cd }, + { "mediumorchid", 0xffba55d3 }, + { "mediumpurple", 0xff9370d8 }, + { "mediumseagreen", 0xff3cb371 }, + { "mediumslateblue", 0xff7b68ee }, + { "mediumspringgreen", 0xff00fa9a }, + { "mediumturquoise", 0xff48d1cc }, + { "mediumvioletred", 0xffc71585 }, + { "midnightblue", 0xff191970 }, + { "mintcream", 0xfff5fffa }, + { "mistyrose", 0xffffe4e1 }, + { "moccasin", 0xffffe4b5 }, + { "navajowhite", 0xffffdead }, + { "navy", 0xff000080 }, + { "oldlace", 0xfffdf5e6 }, + { "olive", 0xff808000 }, + { "olivedrab", 0xff6b8e23 }, + { "orange", 0xffffa500 }, + { "orangered", 0xffff4500 }, + { "orchid", 0xffda70d6 }, + { "palegoldenrod", 0xffeee8aa }, + { "palegreen", 0xff98fb98 }, + { "paleturquoise", 0xffafeeee }, + { "palevioletred", 0xffd87093 }, + { "papayawhip", 0xffffefd5 }, + { "peachpuff", 0xffffdab9 }, + { "peru", 0xffcd853f }, + { "pink", 0xffffc0cb }, + { "plum", 0xffdda0dd }, + { "powderblue", 0xffb0e0e6 }, + { "purple", 0xff800080 }, + { "red", 0xffff0000 }, + { "rosybrown", 0xffbc8f8f }, + { "royalblue", 0xff4169e1 }, + { "saddlebrown", 0xff8b4513 }, + { "salmon", 0xfffa8072 }, + { "sandybrown", 0xfff4a460 }, + { "seagreen", 0xff2e8b57 }, + { "seashell", 0xfffff5ee }, + { "sienna", 0xffa0522d }, + { "silver", 0xffc0c0c0 }, + { "skyblue", 0xff87ceeb }, + { "slateblue", 0xff6a5acd }, + { "slategray", 0xff708090 }, + { "slategrey", 0xff708090 }, + { "snow", 0xfffffafa }, + { "springgreen", 0xff00ff7f }, + { "steelblue", 0xff4682b4 }, + { "tan", 0xffd2b48c }, + { "teal", 0xff008080 }, + { "thistle", 0xffd8bfd8 }, + { "tomato", 0xffff6347 }, + { "turquoise", 0xff40e0d0 }, + { "violet", 0xffee82ee }, + { "wheat", 0xfff5deb3 }, + { "white", 0xffffffff }, + { "whitesmoke", 0xfff5f5f5 }, + { "yellow", 0xffffff00 }, + { "yellowgreen", 0xff9acd32 } +}; + +static Eina_Bool +_attr_color_parser(void *data, const char *key, const char *value) +{ + unsigned int *color = data; + unsigned char a = A_VAL(color); + unsigned char r = R_VAL(color); + unsigned char g = G_VAL(color); + unsigned char b = B_VAL(color); + + if (!strcmp(key, "stop-color")) + { + unsigned int len = strlen(value); + + if (len == 4 && value[0] == '#') + { + if (isxdigit(value[1]) && + isxdigit(value[2]) && + isxdigit(value[3])) + { + char tmp[2] = { '\0', '\0' }; + + tmp[0] = value[1]; r = strtol(tmp, NULL, 16); + tmp[0] = value[2]; g = strtol(tmp, NULL, 16); + tmp[0] = value[3]; b = strtol(tmp, NULL, 16); + } + } + else if (len == 7 && value[0] == '#') + { + if (isxdigit(value[1]) && + isxdigit(value[2]) && + isxdigit(value[3]) && + isxdigit(value[4]) && + isxdigit(value[5]) && + isxdigit(value[6])) + { + char tmp[3] = { '\0', '\0', '\0' }; + + tmp[0] = value[1]; tmp[1] = value[2]; r = strtol(tmp, NULL, 16); + tmp[0] = value[3]; tmp[1] = value[4]; g = strtol(tmp, NULL, 16); + tmp[0] = value[5]; tmp[1] = value[6]; b = strtol(tmp, NULL, 16); + } + } + else if (len >= 10 && + (value[0] == 'r' || value[0] == 'R') && + (value[1] == 'g' || value[1] == 'G') && + (value[2] == 'b' || value[2] == 'B') && + value[3] == '(' && + value[len - 1] == ')') + { + char *red, *green, *blue; + unsigned char tr, tg, tb; + + tr = _attr_color_component_parser(value + 4, &red); + if (red && *red == ',') + { + tg = _attr_color_component_parser(red + 1, &green); + if (green && *green == ',') + { + tb = _attr_color_component_parser(green + 1, &blue); + if (blue && blue[0] == ')' && blue[1] == '\0') + { + r = tr; g = tg; b = tb; + } + } + } + } + else + { + unsigned int i; + + for (i = 0; i < (sizeof (colors) / sizeof (colors[0])); i++) + if (!strcasecmp(colors[i].name, value)) + { + r = R_VAL(&(colors[i].value)); + g = G_VAL(&(colors[i].value)); + b = B_VAL(&(colors[i].value)); + } + } + } + else if (!strcmp(key, "stop-opacity")) + { + char *tmp = NULL; + double opacity = strtod(value, &tmp); + + if (*tmp == '\0') + a = lrint(opacity * 255); + } + + *color = ARGB_JOIN(a, r, g, b); + + return EINA_TRUE; +} + +static Eina_Bool +_attrs_stop_parser(void *data, const char *key, const char *value) +{ + Efl_Gfx_Gradient_Stop *stop = data; + + if (!strcmp(key, "style")) + { + unsigned int color = 0xFF000000; + + eina_simple_xml_attribute_w3c_parse(value, _attr_color_parser, &color); + + stop->r = R_VAL(&color); + stop->g = G_VAL(&color); + stop->b = B_VAL(&color); + stop->a = A_VAL(&color); + } + else if (!strcmp(key, "offset")) + { + stop->offset = _attr_percent_parser(value); + } + + return EINA_TRUE; +} + +static Eina_Bool +_tag_stop_handler(Evas_SVG_Loader *loader, + const char *attrs, + unsigned int attrs_length) +{ + Efl_Gfx_Gradient_Stop stop = { -1, 0, 0, 0, 0xFF }; + const Efl_Gfx_Gradient_Stop *old = NULL; + Efl_Gfx_Gradient_Stop *new; + unsigned int length = 0; + Eo *node; + + if (loader->level < 3) return EINA_FALSE; + if (((int)eina_array_count(loader->stack) - 1) < 0) return EINA_FALSE; + + node = eina_array_data_get(loader->stack, eina_array_count(loader->stack) - 1); + if (!eo_isa(node, EFL_GFX_GRADIENT_BASE_INTERFACE)) + return EINA_FALSE; + + eina_simple_xml_attributes_parse(attrs, attrs_length, + _attrs_stop_parser, &stop); + + if (stop.offset < 0) return EINA_FALSE; + + eo_do(node, + efl_gfx_gradient_stop_get(&old, &length); + length++; + new = malloc(sizeof (Efl_Gfx_Gradient_Stop) * length); + if (new) + { + if (length > 1) + memcpy(new, old, sizeof (Efl_Gfx_Gradient_Stop) * (length - 1)); + new[length - 1] = stop; + + efl_gfx_gradient_stop_set(new, length); + }); + + return EINA_TRUE; +} + +static Eina_Bool +_tag_g_handler(Evas_SVG_Loader *loader, + const char *attrs, + unsigned int attrs_length) +{ + Eo *node, *parent; + + if (loader->level < 1) return EINA_FALSE; + + parent = eina_array_data_get(loader->stack, eina_array_count(loader->stack) - 1); + + node = eo_add(EVAS_VG_CONTAINER_CLASS, parent); + eina_array_push(loader->stack, node); + + return EINA_TRUE; +} + +static Eina_Bool +_tag_rect_handler(Evas_SVG_Loader *loader, + const char *attrs, + unsigned int attrs_length) +{ + Eo *node, *parent; + + if (loader->level < 1) return EINA_FALSE; + + parent = eina_array_data_get(loader->stack, eina_array_count(loader->stack) - 1); + + fprintf(stderr, "recty !\n"); + eina_simple_xml_attributes_parse(attrs, attrs_length, + _evas_svg_loader_xml_attrs_parser, loader); + + return EINA_TRUE; +} + +#define TAG_DEF(Name) \ + { #Name, sizeof (#Name), _tag_##Name##_handler } + +static struct { + const char *tag; + int sz; + Eina_Bool (*tag_handler)(Evas_SVG_Loader *loader, const char *attrs, unsigned int attrs_length); +} open_tags[] = { + TAG_DEF(svg), + TAG_DEF(defs), + TAG_DEF(linearGradient), + TAG_DEF(stop), + TAG_DEF(g), + TAG_DEF(rect) +}; + +static void +_evas_svg_loader_xml_open_parser(Evas_SVG_Loader *loader, + const char *content, unsigned int length) +{ + const char *attrs = NULL; + unsigned int i; + int attrs_length = 0; + int sz = length; + + loader->level++; + + attrs = eina_simple_xml_tag_attributes_find(content, length); + if (attrs) + { + sz = attrs - content; + attrs_length = length - sz; + while ((sz > 0) && (isspace(content[sz - 1]))) + sz--; + } + + for (i = 0; i < sizeof (open_tags) / sizeof(open_tags[0]); i++) + if (open_tags[i].sz - 1 == sz && !strncmp(open_tags[i].tag, content, sz)) + { + if (!open_tags[i].tag_handler(loader, attrs, attrs_length)) + goto on_error; + return ; + } + + fprintf(stderr, "[%s]\n", strndupa(content, sz)); + + eina_simple_xml_attributes_parse(attrs, attrs_length, + _evas_svg_loader_xml_attrs_parser, loader); + + return ; + + on_error: + loader->result = EINA_FALSE; + return ; +} + +static const char *poping[] = { + "linearGradient", + "svg", + "g" +}; + +static void +_evas_svg_loader_xml_close_parser(Evas_SVG_Loader *loader, + const char *content, unsigned int length) +{ + unsigned int i; + Eina_Bool found = EINA_FALSE; + + loader->level--; + + for (i = 0; i < sizeof (poping) / sizeof (poping[0]); i++) + { + unsigned int l = strlen(poping[i]); + + if (!strncmp(content, poping[i], l) && + (content[l] == '\0' || + content[l] == '>' || + isspace(content[l]))) + { + found = EINA_TRUE; + eina_array_pop(loader->stack); + break; + } + } +} + +static Eina_Bool +_evas_svg_loader_parser(void *data, Eina_Simple_XML_Type type, + const char *content, + unsigned int offset EINA_UNUSED, unsigned int length) +{ + Evas_SVG_Loader *loader = data; + + switch (type) + { + case EINA_SIMPLE_XML_OPEN: + _evas_svg_loader_xml_open_parser(loader, content, length); + break; + case EINA_SIMPLE_XML_OPEN_EMPTY: + _evas_svg_loader_xml_open_parser(loader, content, length); + case EINA_SIMPLE_XML_CLOSE: + _evas_svg_loader_xml_close_parser(loader, content, length); + break; + case EINA_SIMPLE_XML_DATA: + case EINA_SIMPLE_XML_CDATA: + case EINA_SIMPLE_XML_DOCTYPE_CHILD: + break; + case EINA_SIMPLE_XML_IGNORED: + case EINA_SIMPLE_XML_COMMENT: + case EINA_SIMPLE_XML_DOCTYPE: + break; + + default: + break; + } + + return EINA_TRUE; +} + +Eina_Bool +evas_vg_loader_svg(Evas_Object *vg, + const Eina_File *f, const char *key EINA_UNUSED) +// For now we don't handle eet section filled with SVG, that's for later +{ + Evas_SVG_Loader loader = { + NULL, NULL, NULL, NULL, + EINA_FALSE, EINA_FALSE, EINA_TRUE + }; + const char *content; + Eina_File *tmp; + unsigned int length; + Eina_Bool r = EINA_FALSE; + + tmp = eina_file_dup(f); + if (!f || !tmp) return EINA_FALSE; + + length = eina_file_size_get(tmp); + content = eina_file_map_all(tmp, EINA_FILE_SEQUENTIAL); + + if (!content) goto on_error; + + loader.stack = eina_array_new(8); + loader.definition = eina_hash_stringshared_new(eo_del); + loader.vg = vg; + loader.e = evas_object_evas_get(vg); + + r = eina_simple_xml_parse(content, length, EINA_TRUE, + _evas_svg_loader_parser, &loader); + + eina_array_free(loader.stack); + eina_hash_free(loader.definition); + eina_file_map_free(tmp, (void*) content); + + on_error: + eina_file_close(tmp); + + return loader.result && r; +} diff --git a/src/lib/evas/include/evas_private.h b/src/lib/evas/include/evas_private.h index d91e681a1c..9fb51b4dc9 100644 --- a/src/lib/evas/include/evas_private.h +++ b/src/lib/evas/include/evas_private.h @@ -1787,6 +1787,8 @@ Evas_Device *_evas_device_top_get(const Evas *e); void _evas_device_ref(Evas_Device *dev); void _evas_device_unref(Evas_Device *dev); +Eina_Bool evas_vg_loader_svg(Evas_Object *vg, const Eina_File *f, const char *key EINA_UNUSED); + extern Eina_Cow *evas_object_proxy_cow; extern Eina_Cow *evas_object_map_cow; extern Eina_Cow *evas_object_state_cow; From eb2bd9a8d8ff79bb30a1888969bb5960e8fed066 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:30:59 +0200 Subject: [PATCH 131/251] evas: move Evas.VG_* to Efl.VG.* This also introduce legacy API for all of them. --- src/Makefile_Evas.am | 16 +- src/Makefile_Evas_Cxx.am | 16 +- src/lib/evas/Evas_Common.h | 5 + src/lib/evas/Evas_Eo.h | 19 +- src/lib/evas/Evas_Legacy.h | 78 +++- .../{evas_vg_node.eo => efl_vg_base.eo} | 8 +- src/lib/evas/canvas/efl_vg_container.eo | 9 + ...evas_vg_gradient.eo => efl_vg_gradient.eo} | 5 +- ...nt_linear.eo => efl_vg_gradient_linear.eo} | 5 +- ...nt_radial.eo => efl_vg_gradient_radial.eo} | 5 +- .../{evas_vg_image.eo => efl_vg_image.eo} | 5 +- src/lib/evas/canvas/efl_vg_root_node.eo | 8 + .../{evas_vg_shape.eo => efl_vg_shape.eo} | 13 +- src/lib/evas/canvas/evas_object_vg.c | 22 +- src/lib/evas/canvas/evas_vg.eo | 2 +- src/lib/evas/canvas/evas_vg_container.c | 42 +- src/lib/evas/canvas/evas_vg_container.eo | 9 - src/lib/evas/canvas/evas_vg_gradient.c | 58 ++- src/lib/evas/canvas/evas_vg_gradient_linear.c | 90 ++-- src/lib/evas/canvas/evas_vg_gradient_radial.c | 110 +++-- src/lib/evas/canvas/evas_vg_image.c | 34 +- src/lib/evas/canvas/evas_vg_loader_svg.c | 4 +- src/lib/evas/canvas/evas_vg_node.c | 278 +++++++----- src/lib/evas/canvas/evas_vg_private.h | 28 +- src/lib/evas/canvas/evas_vg_root_node.c | 40 +- src/lib/evas/canvas/evas_vg_root_node.eo | 8 - src/lib/evas/canvas/evas_vg_shape.c | 412 +++++++++++++----- 27 files changed, 878 insertions(+), 451 deletions(-) rename src/lib/evas/canvas/{evas_vg_node.eo => efl_vg_base.eo} (94%) create mode 100644 src/lib/evas/canvas/efl_vg_container.eo rename src/lib/evas/canvas/{evas_vg_gradient.eo => efl_vg_gradient.eo} (60%) rename src/lib/evas/canvas/{evas_vg_gradient_linear.eo => efl_vg_gradient_linear.eo} (63%) rename src/lib/evas/canvas/{evas_vg_gradient_radial.eo => efl_vg_gradient_radial.eo} (70%) rename src/lib/evas/canvas/{evas_vg_image.eo => efl_vg_image.eo} (81%) create mode 100644 src/lib/evas/canvas/efl_vg_root_node.eo rename src/lib/evas/canvas/{evas_vg_shape.eo => efl_vg_shape.eo} (75%) delete mode 100644 src/lib/evas/canvas/evas_vg_container.eo delete mode 100644 src/lib/evas/canvas/evas_vg_root_node.eo diff --git a/src/Makefile_Evas.am b/src/Makefile_Evas.am index e7d6e2448a..88aaf4eecb 100644 --- a/src/Makefile_Evas.am +++ b/src/Makefile_Evas.am @@ -33,14 +33,14 @@ evas_eolian_files = \ lib/evas/canvas/evas_3d_scene.eo\ lib/evas/canvas/evas_3d_object.eo \ lib/evas/canvas/evas_vg.eo \ - lib/evas/canvas/evas_vg_node.eo \ - lib/evas/canvas/evas_vg_container.eo \ - lib/evas/canvas/evas_vg_shape.eo \ - lib/evas/canvas/evas_vg_root_node.eo \ - lib/evas/canvas/evas_vg_gradient.eo \ - lib/evas/canvas/evas_vg_gradient_radial.eo \ - lib/evas/canvas/evas_vg_gradient_linear.eo \ - lib/evas/canvas/evas_vg_image.eo + lib/evas/canvas/efl_vg_base.eo \ + lib/evas/canvas/efl_vg_container.eo \ + lib/evas/canvas/efl_vg_shape.eo \ + lib/evas/canvas/efl_vg_root_node.eo \ + lib/evas/canvas/efl_vg_gradient.eo \ + lib/evas/canvas/efl_vg_gradient_radial.eo \ + lib/evas/canvas/efl_vg_gradient_linear.eo \ + lib/evas/canvas/efl_vg_image.eo evas_eolian_c = $(evas_eolian_files:%.eo=%.eo.c) evas_eolian_h = $(evas_eolian_files:%.eo=%.eo.h) \ diff --git a/src/Makefile_Evas_Cxx.am b/src/Makefile_Evas_Cxx.am index 1a9683d407..26848c4205 100644 --- a/src/Makefile_Evas_Cxx.am +++ b/src/Makefile_Evas_Cxx.am @@ -35,14 +35,14 @@ lib/evas/canvas/evas_3d_object.eo.hh \ lib/evas/canvas/evas_3d_scene.eo.hh \ lib/evas/canvas/evas_3d_texture.eo.hh \ lib/evas/canvas/evas_vg.eo.hh \ -lib/evas/canvas/evas_vg_node.eo.hh \ -lib/evas/canvas/evas_vg_container.eo.hh \ -lib/evas/canvas/evas_vg_shape.eo.hh \ -lib/evas/canvas/evas_vg_root_node.eo.hh \ -lib/evas/canvas/evas_vg_gradient.eo.hh \ -lib/evas/canvas/evas_vg_gradient_radial.eo.hh \ -lib/evas/canvas/evas_vg_gradient_linear.eo.hh \ -lib/evas/canvas/evas_vg_image.eo.hh +lib/evas/canvas/efl_vg_base.eo.hh \ +lib/evas/canvas/efl_vg_container.eo.hh \ +lib/evas/canvas/efl_vg_shape.eo.hh \ +lib/evas/canvas/efl_vg_root_node.eo.hh \ +lib/evas/canvas/efl_vg_gradient.eo.hh \ +lib/evas/canvas/efl_vg_gradient_radial.eo.hh \ +lib/evas/canvas/efl_vg_gradient_linear.eo.hh \ +lib/evas/canvas/efl_vg_image.eo.hh lib/evas/Evas.hh: $(generated_evas_canvas_cxx_bindings) @echo @ECHO_E@ "#ifndef EFL_CXX_EVAS_HH\n#define EFL_CXX_EVAS_HH\n" > $(top_builddir)/src/lib/evas/Evas.hh diff --git a/src/lib/evas/Evas_Common.h b/src/lib/evas/Evas_Common.h index 3a9633f617..5055561515 100644 --- a/src/lib/evas/Evas_Common.h +++ b/src/lib/evas/Evas_Common.h @@ -312,6 +312,11 @@ typedef Eo Evas_Object; /* This define is used in H files generated by Eolian */ #define _EVAS_OBJECT_EO_CLASS_TYPE +/** + * Type of abstract VG node + */ +typedef Eo Efl_VG; + typedef void Evas_Performance; /**< An Evas Performance handle */ typedef struct _Evas_Modifier Evas_Modifier; /**< An opaque type containing information on which modifier keys are registered in an Evas canvas */ typedef struct _Evas_Lock Evas_Lock; /**< An opaque type containing information on which lock keys are registered in an Evas canvas */ diff --git a/src/lib/evas/Evas_Eo.h b/src/lib/evas/Evas_Eo.h index 0209677fd3..49e1da2939 100644 --- a/src/lib/evas/Evas_Eo.h +++ b/src/lib/evas/Evas_Eo.h @@ -845,11 +845,6 @@ typedef enum _Evas_3D_Material_Attrib #include "canvas/evas_3d_object.eo.h" -/** - * Type of abstract VG node - */ -typedef Eo Evas_VG_Node; - /** * @ingroup Evas_Object_VG * @@ -860,10 +855,10 @@ typedef Eo Evas_VG_Node; * @} */ -#include "canvas/evas_vg_node.eo.h" -#include "canvas/evas_vg_container.eo.h" -#include "canvas/evas_vg_shape.eo.h" -#include "canvas/evas_vg_gradient.eo.h" -#include "canvas/evas_vg_gradient_linear.eo.h" -#include "canvas/evas_vg_gradient_radial.eo.h" -#include "canvas/evas_vg_image.eo.h" +#include "canvas/efl_vg_base.eo.h" +#include "canvas/efl_vg_container.eo.h" +#include "canvas/efl_vg_shape.eo.h" +#include "canvas/efl_vg_gradient.eo.h" +#include "canvas/efl_vg_gradient_linear.eo.h" +#include "canvas/efl_vg_gradient_radial.eo.h" +#include "canvas/efl_vg_image.eo.h" diff --git a/src/lib/evas/Evas_Legacy.h b/src/lib/evas/Evas_Legacy.h index 8f53493961..01d6706e2b 100644 --- a/src/lib/evas/Evas_Legacy.h +++ b/src/lib/evas/Evas_Legacy.h @@ -1710,13 +1710,79 @@ EAPI Evas_Object *evas_object_rectangle_add(Evas *e) EINA_WARN_UNUSED_RESULT EIN */ EAPI Evas_Object *evas_object_vg_add(Evas *e) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC; -#include "canvas/evas_vg_node.eo.legacy.h" #include "canvas/evas_vg.eo.legacy.h" -#include "canvas/evas_vg_shape.eo.legacy.h" -#include "canvas/evas_vg_gradient.eo.legacy.h" -#include "canvas/evas_vg_gradient_linear.eo.legacy.h" -#include "canvas/evas_vg_gradient_radial.eo.legacy.h" -#include "canvas/evas_vg_image.eo.legacy.h" + +EAPI Eina_Bool evas_vg_node_visible_get(Eo *obj); +EAPI void evas_vg_node_visible_set(Eo *obj, Eina_Bool v); +EAPI void evas_vg_node_color_get(Eo *obj, int *r, int *g, int *b, int *a); +EAPI void evas_vg_node_color_set(Eo *obj, int r, int g, int b, int a); +EAPI void evas_vg_node_geometry_get(Eo *obj, int *x, int *y, int *w, int *h); +EAPI void evas_vg_node_geometry_set(Eo *obj, int x, int y, int w, int h); +EAPI void evas_vg_node_stack_below(Eo *obj, Eo *below); +EAPI void evas_vg_node_stack_above(Eo *obj, Eo *above); +EAPI void evas_vg_node_raise(Eo *obj); +EAPI void evas_vg_node_lower(Eo *obj); + +#include "canvas/efl_vg_base.eo.legacy.h" + +EAPI double evas_vg_shape_stroke_scale_get(Eo *obj); +EAPI void evas_vg_shape_stroke_scale_set(Eo *obj, double s); +EAPI void evas_vg_shape_stroke_color_get(Eo *obj, int *r, int *g, int *b, int *a); +EAPI void evas_vg_shape_stroke_color_set(Eo *obj, int r, int g, int b, int a); +EAPI double evas_vg_shape_stroke_width_get(Eo *obj); +EAPI void evas_vg_shape_stroke_width_set(Eo *obj, double w); +EAPI double evas_vg_shape_stroke_location_get(Eo *obj); +EAPI void evas_vg_shape_stroke_location_set(Eo *obj, double centered); +EAPI void evas_vg_shape_stroke_dash_get(Eo *obj, const Efl_Gfx_Dash **dash, unsigned int *length); +EAPI void evas_vg_shape_stroke_dash_set(Eo *obj, const Efl_Gfx_Dash *dash, unsigned int length); +EAPI Efl_Gfx_Cap evas_vg_shape_stroke_cap_get(Eo *obj); +EAPI void evas_vg_shape_stroke_cap_set(Eo *obj, Efl_Gfx_Cap c); +EAPI Efl_Gfx_Join evas_vg_shape_stroke_join_get(Eo *obj); +EAPI void evas_vg_shape_stroke_join_set(Eo *obj, Efl_Gfx_Join j); +EAPI void evas_vg_shape_shape_path_set(Eo *obj, const Efl_Gfx_Path_Command *op, const double *points); +EAPI void evas_vg_shape_shape_path_get(Eo *obj, const Efl_Gfx_Path_Command **op, const double **points); +EAPI void evas_vg_shape_shape_path_length_get(Eo *obj, unsigned int *commands, unsigned int *points); +EAPI void evas_vg_shape_shape_current_get(Eo *obj, double *x, double *y); +EAPI void evas_vg_shape_shape_current_ctrl_get(Eo *obj, double *x, double *y); +EAPI void evas_vg_shape_shape_dup(Eo *obj, Eo *dup_from); +EAPI void evas_vg_shape_shape_reset(Eo *obj); +EAPI void evas_vg_shape_shape_append_move_to(Eo *obj, double x, double y); +EAPI void evas_vg_shape_shape_append_line_to(Eo *obj, double x, double y); +EAPI void evas_vg_shape_shape_append_quadratic_to(Eo *obj, double x, double y, double ctrl_x, double ctrl_y); +EAPI void evas_vg_shape_shape_append_squadratic_to(Eo *obj, double x, double y); +EAPI void evas_vg_shape_shape_append_cubic_to(Eo *obj, double x, double y, double ctrl_x0, double ctrl_y0, double ctrl_x1, double ctrl_y1); +EAPI void evas_vg_shape_shape_append_scubic_to(Eo *obj, double x, double y, double ctrl_x, double ctrl_y); +EAPI void evas_vg_shape_shape_append_arc_to(Eo *obj, double x, double y, double rx, double ry, double angle, Eina_Bool large_arc, Eina_Bool sweep); +EAPI void evas_vg_shape_shape_append_close(Eo *obj); +EAPI void evas_vg_shape_shape_append_circle(Eo *obj, double x, double y, double radius); +EAPI void evas_vg_shape_shape_append_svg_path(Eo *obj, const char *svg_path_data); +EAPI Eina_Bool evas_vg_shape_shape_interpolate(Eo *obj, const Eo *from, const Eo *to, double pos_map); +EAPI Eina_Bool evas_vg_shape_shape_equal_commands(Eo *obj, const Eo *with); + +#include "canvas/efl_vg_shape.eo.legacy.h" + +EAPI void evas_vg_gradient_stop_set(Eo *obj, const Efl_Gfx_Gradient_Stop *colors, unsigned int length); +EAPI void evas_vg_gradient_stop_get(Eo *obj, const Efl_Gfx_Gradient_Stop **colors, unsigned int *length); +EAPI void evas_vg_gradient_spread_set(Eo *obj, Efl_Gfx_Gradient_Spread s); +EAPI Efl_Gfx_Gradient_Spread evas_vg_gradient_spread_get(Eo *obj); + +#include "canvas/efl_vg_gradient.eo.legacy.h" + +EAPI void evas_vg_gradient_linear_start_set(Eo *obj, double x, double y); +EAPI void evas_vg_gradient_linear_start_get(Eo *obj, double *x, double *y); +EAPI void evas_vg_gradient_linear_end_set(Eo *obj, double x, double y); +EAPI void evas_vg_gradient_linear_end_get(Eo *obj, double *x, double *y); + +#include "canvas/efl_vg_gradient_linear.eo.legacy.h" + +EAPI void evas_vg_gradient_radial_center_set(Eo *obj, double x, double y); +EAPI void evas_vg_gradient_radial_center_get(Eo *obj, double *x, double *y); +EAPI void evas_vg_gradient_radial_radius_set(Eo *obj, double r); +EAPI double evas_vg_gradient_radial_radius_get(Eo *obj); +EAPI void evas_vg_gradient_radial_focal_set(Eo *obj, double x, double y); +EAPI void evas_vg_gradient_radial_focal_get(Eo *obj, double *x, double *y); + +#include "canvas/efl_vg_gradient_radial.eo.legacy.h" /** * @} diff --git a/src/lib/evas/canvas/evas_vg_node.eo b/src/lib/evas/canvas/efl_vg_base.eo similarity index 94% rename from src/lib/evas/canvas/evas_vg_node.eo rename to src/lib/evas/canvas/efl_vg_base.eo index 83c7014ae1..2b8d9e7e93 100644 --- a/src/lib/evas/canvas/evas_vg_node.eo +++ b/src/lib/evas/canvas/efl_vg_base.eo @@ -1,7 +1,7 @@ -abstract Evas.VG_Node (Eo.Base, Efl.Gfx.Base, Efl.Gfx.Stack) +abstract Efl.VG.Base (Eo.Base, Efl.Gfx.Base, Efl.Gfx.Stack) { - eo_prefix: evas_vg_node; - legacy_prefix: null; + eo_prefix: efl_vg; + legacy_prefix: evas_vg_node; properties { transformation { set { @@ -45,7 +45,7 @@ abstract Evas.VG_Node (Eo.Base, Efl.Gfx.Base, Efl.Gfx.Stack) get { } values { - Evas_VG_Node *m; + Efl_VG *m; } } /* quality { diff --git a/src/lib/evas/canvas/efl_vg_container.eo b/src/lib/evas/canvas/efl_vg_container.eo new file mode 100644 index 0000000000..4d8a0853c0 --- /dev/null +++ b/src/lib/evas/canvas/efl_vg_container.eo @@ -0,0 +1,9 @@ +class Efl.VG.Container (Efl.VG.Base) +{ + legacy_prefix: evas_vg_container; + implements { + Eo.Base.constructor; + Eo.Base.destructor; + Efl.VG.Base.bound_get; + } +} diff --git a/src/lib/evas/canvas/evas_vg_gradient.eo b/src/lib/evas/canvas/efl_vg_gradient.eo similarity index 60% rename from src/lib/evas/canvas/evas_vg_gradient.eo rename to src/lib/evas/canvas/efl_vg_gradient.eo index 29f1de242b..de78039adf 100644 --- a/src/lib/evas/canvas/evas_vg_gradient.eo +++ b/src/lib/evas/canvas/efl_vg_gradient.eo @@ -1,7 +1,6 @@ -abstract Evas.VG_Gradient (Evas.VG_Node, Efl.Gfx.Gradient.Base) +abstract Efl.VG.Gradient (Efl.VG.Base, Efl.Gfx.Gradient.Base) { - eo_prefix: evas_vg_gradient; - legacy_prefix: null; + legacy_prefix: evas_vg_gradient; implements { Efl.Gfx.Gradient.Base.stop.set; Efl.Gfx.Gradient.Base.stop.get; diff --git a/src/lib/evas/canvas/evas_vg_gradient_linear.eo b/src/lib/evas/canvas/efl_vg_gradient_linear.eo similarity index 63% rename from src/lib/evas/canvas/evas_vg_gradient_linear.eo rename to src/lib/evas/canvas/efl_vg_gradient_linear.eo index 95a773a0db..bc9c664168 100644 --- a/src/lib/evas/canvas/evas_vg_gradient_linear.eo +++ b/src/lib/evas/canvas/efl_vg_gradient_linear.eo @@ -1,7 +1,6 @@ -class Evas.VG_Gradient_Linear (Evas.VG_Gradient, Efl.Gfx.Gradient.Linear) +class Efl.VG.Gradient_Linear (Efl.VG.Gradient, Efl.Gfx.Gradient.Linear) { - eo_prefix: evas_vg_gradient_linear; - legacy_prefix: null; + legacy_prefix: evas_vg_gradient_linear; implements { Efl.Gfx.Gradient.Linear.start.set; Efl.Gfx.Gradient.Linear.start.get; diff --git a/src/lib/evas/canvas/evas_vg_gradient_radial.eo b/src/lib/evas/canvas/efl_vg_gradient_radial.eo similarity index 70% rename from src/lib/evas/canvas/evas_vg_gradient_radial.eo rename to src/lib/evas/canvas/efl_vg_gradient_radial.eo index bab5282b9e..0d60589d0a 100644 --- a/src/lib/evas/canvas/evas_vg_gradient_radial.eo +++ b/src/lib/evas/canvas/efl_vg_gradient_radial.eo @@ -1,7 +1,6 @@ -class Evas.VG_Gradient_Radial (Evas.VG_Gradient, Efl.Gfx.Gradient.Radial) +class Efl.VG.Gradient_Radial (Efl.VG.Gradient, Efl.Gfx.Gradient.Radial) { - eo_prefix: evas_vg_gradient_radial; - legacy_prefix: null; + legacy_prefix: evas_vg_gradient_radial; implements { Efl.Gfx.Gradient.Radial.center.set; Efl.Gfx.Gradient.Radial.center.get; diff --git a/src/lib/evas/canvas/evas_vg_image.eo b/src/lib/evas/canvas/efl_vg_image.eo similarity index 81% rename from src/lib/evas/canvas/evas_vg_image.eo rename to src/lib/evas/canvas/efl_vg_image.eo index ff9ab8e965..62d74510f4 100644 --- a/src/lib/evas/canvas/evas_vg_image.eo +++ b/src/lib/evas/canvas/efl_vg_image.eo @@ -1,7 +1,6 @@ -class Evas.VG_Image (Evas.VG_Node, Efl.File) +class Efl.VG.Image (Efl.VG.Base, Efl.File) { - eo_prefix: evas_vg_image; - legacy_prefix: null; + legacy_prefix: evas_vg_image; properties { position { set { diff --git a/src/lib/evas/canvas/efl_vg_root_node.eo b/src/lib/evas/canvas/efl_vg_root_node.eo new file mode 100644 index 0000000000..685bf7e134 --- /dev/null +++ b/src/lib/evas/canvas/efl_vg_root_node.eo @@ -0,0 +1,8 @@ +class Efl.VG.Root_Node (Efl.VG.Container) +{ + legacy_prefix: evas_vg_root_node; + implements { + Eo.Base.parent.set; + Eo.Base.constructor; + } +} diff --git a/src/lib/evas/canvas/evas_vg_shape.eo b/src/lib/evas/canvas/efl_vg_shape.eo similarity index 75% rename from src/lib/evas/canvas/evas_vg_shape.eo rename to src/lib/evas/canvas/efl_vg_shape.eo index 9127241438..ab6468cc90 100644 --- a/src/lib/evas/canvas/evas_vg_shape.eo +++ b/src/lib/evas/canvas/efl_vg_shape.eo @@ -1,7 +1,6 @@ -class Evas.VG_Shape (Evas.VG_Node, Efl.Gfx.Shape) +class Efl.VG.Shape (Efl.VG.Base, Efl.Gfx.Shape) { - eo_prefix: evas_vg_shape; - legacy_prefix: null; + legacy_prefix: evas_vg_shape; properties { fill { set { @@ -9,7 +8,7 @@ class Evas.VG_Shape (Evas.VG_Node, Efl.Gfx.Shape) get { } values { - Evas_VG_Node *f; + Efl_VG *f; } } stroke_fill { @@ -18,7 +17,7 @@ class Evas.VG_Shape (Evas.VG_Node, Efl.Gfx.Shape) get { } values { - Evas_VG_Node *f; + Efl_VG *f; } } stroke_marker { @@ -27,7 +26,7 @@ class Evas.VG_Shape (Evas.VG_Node, Efl.Gfx.Shape) get { } values { - Evas_VG_Node *m; + Efl_VG *m; } } } @@ -41,7 +40,7 @@ class Evas.VG_Shape (Evas.VG_Node, Efl.Gfx.Shape) Efl.Gfx.Shape.stroke_join; Efl.Gfx.Base.color_part.set; Efl.Gfx.Base.color_part.get; - Evas.VG_Node.bound_get; + Efl.VG.Base.bound_get; Eo.Base.constructor; Eo.Base.destructor; } diff --git a/src/lib/evas/canvas/evas_object_vg.c b/src/lib/evas/canvas/evas_object_vg.c index 6f41d50ad1..2336d9b6e5 100644 --- a/src/lib/evas/canvas/evas_object_vg.c +++ b/src/lib/evas/canvas/evas_object_vg.c @@ -2,7 +2,7 @@ #include "evas_private.h" #include "evas_vg_private.h" -#include "evas_vg_root_node.eo.h" +#include "efl_vg_root_node.eo.h" #define MY_CLASS EVAS_VG_CLASS @@ -16,8 +16,8 @@ typedef struct _Evas_VG_Data Evas_VG_Data; struct _Evas_VG_Data { - void *engine_data; - Evas_VG_Node *root; + void *engine_data; + Efl_VG *root; /* Opening an SVG file (could actually be inside an eet section */ Eina_File *f; @@ -89,7 +89,7 @@ evas_object_vg_add(Evas *e) return eo_obj; } -Evas_VG_Node * +Efl_VG * _evas_vg_root_node_get(Eo *obj EINA_UNUSED, Evas_VG_Data *pd) { return pd->root; @@ -116,7 +116,7 @@ _evas_vg_eo_base_constructor(Eo *eo_obj, Evas_VG_Data *pd) obj->type = o_type; /* root node */ - pd->root = eo_add(EVAS_VG_ROOT_NODE_CLASS, eo_obj); + pd->root = eo_add(EFL_VG_ROOT_NODE_CLASS, eo_obj); eo_ref(pd->root); eo_do(eo_obj, parent = eo_parent_get()); @@ -125,14 +125,14 @@ _evas_vg_eo_base_constructor(Eo *eo_obj, Evas_VG_Data *pd) static void _evas_vg_render(Evas_Object_Protected_Data *obj, - void *output, void *context, void *surface, Evas_VG_Node *n, + void *output, void *context, void *surface, Efl_VG *n, Eina_Array *clips, int x, int y, Eina_Bool do_async) { - Evas_VG_Container_Data *vd = eo_data_scope_get(n, EVAS_VG_CONTAINER_CLASS); + Efl_VG_Container_Data *vd = eo_data_scope_get(n, EFL_VG_CONTAINER_CLASS); - if (eo_isa(n, EVAS_VG_CONTAINER_CLASS)) + if (eo_isa(n, EFL_VG_CONTAINER_CLASS)) { - Evas_VG_Node *child; + Efl_VG *child; Eina_List *l; EINA_LIST_FOREACH(vd->children, l, child) @@ -142,9 +142,9 @@ _evas_vg_render(Evas_Object_Protected_Data *obj, } else { - Evas_VG_Node_Data *nd; + Efl_VG_Base_Data *nd; - nd = eo_data_scope_get(n, EVAS_VG_NODE_CLASS); + nd = eo_data_scope_get(n, EFL_VG_BASE_CLASS); obj->layer->evas->engine.func->ector_renderer_draw(output, context, surface, nd->renderer, clips, x, y, do_async); } diff --git a/src/lib/evas/canvas/evas_vg.eo b/src/lib/evas/canvas/evas_vg.eo index 3caf177c88..8247f46e44 100644 --- a/src/lib/evas/canvas/evas_vg.eo +++ b/src/lib/evas/canvas/evas_vg.eo @@ -15,7 +15,7 @@ class Evas.VG (Evas.Object, Efl.File, Efl.Gfx.Fill, Efl.Gfx.View) */ } values { - Evas_VG_Node *container; /*@ Root node of the VG canvas */ + Efl_VG *container; /*@ Root node of the VG canvas */ } } } diff --git a/src/lib/evas/canvas/evas_vg_container.c b/src/lib/evas/canvas/evas_vg_container.c index 3b368f03fe..fdf81244ad 100644 --- a/src/lib/evas/canvas/evas_vg_container.c +++ b/src/lib/evas/canvas/evas_vg_container.c @@ -3,52 +3,52 @@ #include "evas_vg_private.h" -#define MY_CLASS EVAS_VG_CONTAINER_CLASS +#define MY_CLASS EFL_VG_CONTAINER_CLASS static void -_evas_vg_container_render_pre(Eo *obj EINA_UNUSED, - Eina_Matrix3 *parent, - Ector_Surface *s, - void *data, - Evas_VG_Node_Data *nd) +_efl_vg_container_render_pre(Eo *obj EINA_UNUSED, + Eina_Matrix3 *parent, + Ector_Surface *s, + void *data, + Efl_VG_Base_Data *nd) { - Evas_VG_Container_Data *pd = data; + Efl_VG_Container_Data *pd = data; Eina_List *l; Eo *child; if (!nd->changed) return ; nd->changed = EINA_FALSE; - EVAS_VG_COMPUTE_MATRIX(current, parent, nd); + EFL_VG_COMPUTE_MATRIX(current, parent, nd); EINA_LIST_FOREACH(pd->children, l, child) _evas_vg_render_pre(child, s, current); } static void -_evas_vg_container_eo_base_constructor(Eo *obj, - Evas_VG_Container_Data *pd) +_efl_vg_container_eo_base_constructor(Eo *obj, + Efl_VG_Container_Data *pd) { - Evas_VG_Node_Data *nd; + Efl_VG_Base_Data *nd; eo_do_super(obj, MY_CLASS, eo_constructor()); - nd = eo_data_scope_get(obj, EVAS_VG_NODE_CLASS); - nd->render_pre = _evas_vg_container_render_pre; + nd = eo_data_scope_get(obj, EFL_VG_BASE_CLASS); + nd->render_pre = _efl_vg_container_render_pre; nd->data = pd; } static void -_evas_vg_container_eo_base_destructor(Eo *obj, - Evas_VG_Container_Data *pd EINA_UNUSED) +_efl_vg_container_eo_base_destructor(Eo *obj, + Efl_VG_Container_Data *pd EINA_UNUSED) { eo_do_super(obj, MY_CLASS, eo_destructor()); } static Eina_Bool -_evas_vg_container_evas_vg_node_bound_get(Eo *obj EINA_UNUSED, - Evas_VG_Container_Data *pd, - Eina_Rectangle *r) +_efl_vg_container_efl_vg_base_bound_get(Eo *obj EINA_UNUSED, + Efl_VG_Container_Data *pd, + Eina_Rectangle *r) { Eina_Rectangle s; Eina_Bool first = EINA_TRUE; @@ -63,12 +63,12 @@ _evas_vg_container_evas_vg_node_bound_get(Eo *obj EINA_UNUSED, { if (first) { - eo_do(child, evas_vg_node_bound_get(r)); + eo_do(child, efl_vg_bound_get(r)); first = EINA_FALSE; } else { - eo_do(child, evas_vg_node_bound_get(&s)); + eo_do(child, efl_vg_bound_get(&s)); eina_rectangle_union(r, &s); } } @@ -77,4 +77,4 @@ _evas_vg_container_evas_vg_node_bound_get(Eo *obj EINA_UNUSED, } -#include "evas_vg_container.eo.c" +#include "efl_vg_container.eo.c" diff --git a/src/lib/evas/canvas/evas_vg_container.eo b/src/lib/evas/canvas/evas_vg_container.eo deleted file mode 100644 index 0af3b00fc6..0000000000 --- a/src/lib/evas/canvas/evas_vg_container.eo +++ /dev/null @@ -1,9 +0,0 @@ -class Evas.VG_Container (Evas.VG_Node) -{ - eo_prefix: evas_vg_container; - implements { - Eo.Base.constructor; - Eo.Base.destructor; - Evas.VG_Node.bound_get; - } -} diff --git a/src/lib/evas/canvas/evas_vg_gradient.c b/src/lib/evas/canvas/evas_vg_gradient.c index 4df0b255ff..245b6fe334 100644 --- a/src/lib/evas/canvas/evas_vg_gradient.c +++ b/src/lib/evas/canvas/evas_vg_gradient.c @@ -6,10 +6,10 @@ #include static void -_evas_vg_gradient_efl_gfx_gradient_base_stop_set(Eo *obj EINA_UNUSED, - Evas_VG_Gradient_Data *pd, - const Efl_Gfx_Gradient_Stop *colors, - unsigned int length) +_efl_vg_gradient_efl_gfx_gradient_base_stop_set(Eo *obj EINA_UNUSED, + Efl_VG_Gradient_Data *pd, + const Efl_Gfx_Gradient_Stop *colors, + unsigned int length) { pd->colors = realloc(pd->colors, length * sizeof(Efl_Gfx_Gradient_Stop)); if (!pd->colors) @@ -21,34 +21,60 @@ _evas_vg_gradient_efl_gfx_gradient_base_stop_set(Eo *obj EINA_UNUSED, memcpy(pd->colors, colors, length * sizeof(Efl_Gfx_Gradient_Stop)); pd->colors_count = length; - _evas_vg_node_changed(obj); + _efl_vg_base_changed(obj); } static void -_evas_vg_gradient_efl_gfx_gradient_base_stop_get(Eo *obj EINA_UNUSED, - Evas_VG_Gradient_Data *pd, - const Efl_Gfx_Gradient_Stop **colors, - unsigned int *length) +_efl_vg_gradient_efl_gfx_gradient_base_stop_get(Eo *obj EINA_UNUSED, + Efl_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_gfx_gradient_base_spread_set(Eo *obj EINA_UNUSED, - Evas_VG_Gradient_Data *pd, - Efl_Gfx_Gradient_Spread s) +_efl_vg_gradient_efl_gfx_gradient_base_spread_set(Eo *obj EINA_UNUSED, + Efl_VG_Gradient_Data *pd, + Efl_Gfx_Gradient_Spread s) { pd->s = s; - _evas_vg_node_changed(obj); + _efl_vg_base_changed(obj); } static Efl_Gfx_Gradient_Spread -_evas_vg_gradient_efl_gfx_gradient_base_spread_get(Eo *obj EINA_UNUSED, - Evas_VG_Gradient_Data *pd) +_efl_vg_gradient_efl_gfx_gradient_base_spread_get(Eo *obj EINA_UNUSED, + Efl_VG_Gradient_Data *pd) { return pd->s; } -#include "evas_vg_gradient.eo.c" +EAPI void +evas_vg_gradient_stop_set(Eo *obj, const Efl_Gfx_Gradient_Stop *colors, unsigned int length) +{ + eo_do(obj, efl_gfx_gradient_stop_set(colors, length)); +} + +EAPI void +evas_vg_gradient_stop_get(Eo *obj, const Efl_Gfx_Gradient_Stop **colors, unsigned int *length) +{ + eo_do(obj, efl_gfx_gradient_stop_get(colors, length)); +} + +EAPI void +evas_vg_gradient_spread_set(Eo *obj, Efl_Gfx_Gradient_Spread s) +{ + eo_do(obj, efl_gfx_gradient_spread_set(s)); +} + +EAPI Efl_Gfx_Gradient_Spread +evas_vg_gradient_spread_get(Eo *obj) +{ + Efl_Gfx_Gradient_Spread ret; + + return eo_do_ret(obj, ret, efl_gfx_gradient_spread_get()); +} + +#include "efl_vg_gradient.eo.c" diff --git a/src/lib/evas/canvas/evas_vg_gradient_linear.c b/src/lib/evas/canvas/evas_vg_gradient_linear.c index c1d8ffc461..d29038c579 100644 --- a/src/lib/evas/canvas/evas_vg_gradient_linear.c +++ b/src/lib/evas/canvas/evas_vg_gradient_linear.c @@ -5,10 +5,10 @@ #include -#define MY_CLASS EVAS_VG_GRADIENT_LINEAR_CLASS +#define MY_CLASS EFL_VG_GRADIENT_LINEAR_CLASS -typedef struct _Evas_VG_Gradient_Linear_Data Evas_VG_Gradient_Linear_Data; -struct _Evas_VG_Gradient_Linear_Data +typedef struct _Efl_VG_Gradient_Linear_Data Efl_VG_Gradient_Linear_Data; +struct _Efl_VG_Gradient_Linear_Data { struct { double x, y; @@ -16,60 +16,60 @@ struct _Evas_VG_Gradient_Linear_Data }; static void -_evas_vg_gradient_linear_efl_gfx_gradient_linear_start_set(Eo *obj EINA_UNUSED, - Evas_VG_Gradient_Linear_Data *pd, - double x, double y) +_efl_vg_gradient_linear_efl_gfx_gradient_linear_start_set(Eo *obj EINA_UNUSED, + Efl_VG_Gradient_Linear_Data *pd, + double x, double y) { pd->start.x = x; pd->start.y = y; - _evas_vg_node_changed(obj); + _efl_vg_base_changed(obj); } static void -_evas_vg_gradient_linear_efl_gfx_gradient_linear_start_get(Eo *obj EINA_UNUSED, - Evas_VG_Gradient_Linear_Data *pd, - double *x, double *y) +_efl_vg_gradient_linear_efl_gfx_gradient_linear_start_get(Eo *obj EINA_UNUSED, + Efl_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_gfx_gradient_linear_end_set(Eo *obj EINA_UNUSED, - Evas_VG_Gradient_Linear_Data *pd, - double x, double y) +_efl_vg_gradient_linear_efl_gfx_gradient_linear_end_set(Eo *obj EINA_UNUSED, + Efl_VG_Gradient_Linear_Data *pd, + double x, double y) { pd->end.x = x; pd->end.y = y; - _evas_vg_node_changed(obj); + _efl_vg_base_changed(obj); } static void -_evas_vg_gradient_linear_efl_gfx_gradient_linear_end_get(Eo *obj EINA_UNUSED, - Evas_VG_Gradient_Linear_Data *pd, - double *x, double *y) +_efl_vg_gradient_linear_efl_gfx_gradient_linear_end_get(Eo *obj EINA_UNUSED, + Efl_VG_Gradient_Linear_Data *pd, + double *x, double *y) { if (x) *x = pd->end.x; if (y) *y = pd->end.y; } static void -_evas_vg_gradient_linear_render_pre(Eo *obj, - Eina_Matrix3 *parent, - Ector_Surface *s, - void *data, - Evas_VG_Node_Data *nd) +_efl_vg_gradient_linear_render_pre(Eo *obj, + Eina_Matrix3 *parent, + Ector_Surface *s, + void *data, + Efl_VG_Base_Data *nd) { - Evas_VG_Gradient_Linear_Data *pd = data; - Evas_VG_Gradient_Data *gd; + Efl_VG_Gradient_Linear_Data *pd = data; + Efl_VG_Gradient_Data *gd; if (!nd->changed) return ; nd->changed = EINA_FALSE; - gd = eo_data_scope_get(obj, EVAS_VG_GRADIENT_CLASS); - EVAS_VG_COMPUTE_MATRIX(current, parent, nd); + gd = eo_data_scope_get(obj, EFL_VG_GRADIENT_CLASS); + EFL_VG_COMPUTE_MATRIX(current, parent, nd); if (!nd->renderer) { @@ -89,22 +89,46 @@ _evas_vg_gradient_linear_render_pre(Eo *obj, } static void -_evas_vg_gradient_linear_eo_base_constructor(Eo *obj, - Evas_VG_Gradient_Linear_Data *pd) +_efl_vg_gradient_linear_eo_base_constructor(Eo *obj, + Efl_VG_Gradient_Linear_Data *pd) { - Evas_VG_Node_Data *nd; + Efl_VG_Base_Data *nd; eo_do_super(obj, MY_CLASS, eo_constructor()); - nd = eo_data_scope_get(obj, EVAS_VG_NODE_CLASS); - nd->render_pre = _evas_vg_gradient_linear_render_pre; + nd = eo_data_scope_get(obj, EFL_VG_BASE_CLASS); + nd->render_pre = _efl_vg_gradient_linear_render_pre; nd->data = pd; } void -_evas_vg_gradient_linear_eo_base_destructor(Eo *obj, Evas_VG_Gradient_Linear_Data *pd EINA_UNUSED) +_efl_vg_gradient_linear_eo_base_destructor(Eo *obj, Efl_VG_Gradient_Linear_Data *pd EINA_UNUSED) { eo_do_super(obj, MY_CLASS, eo_destructor()); } -#include "evas_vg_gradient_linear.eo.c" +EAPI void +evas_vg_gradient_linear_start_set(Eo *obj, double x, double y) +{ + eo_do(obj, efl_gfx_gradient_linear_start_set(x, y)); +} + +EAPI void +evas_vg_gradient_linear_start_get(Eo *obj, double *x, double *y) +{ + eo_do(obj, efl_gfx_gradient_linear_start_get(x, y)); +} + +EAPI void +evas_vg_gradient_linear_end_set(Eo *obj, double x, double y) +{ + eo_do(obj, efl_gfx_gradient_linear_end_set(x, y)); +} + +EAPI void +evas_vg_gradient_linear_end_get(Eo *obj, double *x, double *y) +{ + eo_do(obj, efl_gfx_gradient_linear_end_get(x, y)); +} + +#include "efl_vg_gradient_linear.eo.c" diff --git a/src/lib/evas/canvas/evas_vg_gradient_radial.c b/src/lib/evas/canvas/evas_vg_gradient_radial.c index ead0a49d98..b0743e5750 100644 --- a/src/lib/evas/canvas/evas_vg_gradient_radial.c +++ b/src/lib/evas/canvas/evas_vg_gradient_radial.c @@ -3,10 +3,10 @@ #include "evas_vg_private.h" -#define MY_CLASS EVAS_VG_GRADIENT_RADIAL_CLASS +#define MY_CLASS EFL_VG_GRADIENT_RADIAL_CLASS -typedef struct _Evas_VG_Gradient_Radial_Data Evas_VG_Gradient_Radial_Data; -struct _Evas_VG_Gradient_Radial_Data +typedef struct _Efl_VG_Gradient_Radial_Data Efl_VG_Gradient_Radial_Data; +struct _Efl_VG_Gradient_Radial_Data { struct { double x, y; @@ -15,77 +15,77 @@ struct _Evas_VG_Gradient_Radial_Data }; static void -_evas_vg_gradient_radial_efl_gfx_gradient_radial_center_set(Eo *obj EINA_UNUSED, - Evas_VG_Gradient_Radial_Data *pd, - double x, double y) +_efl_vg_gradient_radial_efl_gfx_gradient_radial_center_set(Eo *obj EINA_UNUSED, + Efl_VG_Gradient_Radial_Data *pd, + double x, double y) { pd->center.x = x; pd->center.y = y; - _evas_vg_node_changed(obj); + _efl_vg_base_changed(obj); } static void -_evas_vg_gradient_radial_efl_gfx_gradient_radial_center_get(Eo *obj EINA_UNUSED, - Evas_VG_Gradient_Radial_Data *pd, - double *x, double *y) +_efl_vg_gradient_radial_efl_gfx_gradient_radial_center_get(Eo *obj EINA_UNUSED, + Efl_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_gfx_gradient_radial_radius_set(Eo *obj EINA_UNUSED, - Evas_VG_Gradient_Radial_Data *pd, - double r) +_efl_vg_gradient_radial_efl_gfx_gradient_radial_radius_set(Eo *obj EINA_UNUSED, + Efl_VG_Gradient_Radial_Data *pd, + double r) { pd->radius = r; - _evas_vg_node_changed(obj); + _efl_vg_base_changed(obj); } static double -_evas_vg_gradient_radial_efl_gfx_gradient_radial_radius_get(Eo *obj EINA_UNUSED, - Evas_VG_Gradient_Radial_Data *pd) +_efl_vg_gradient_radial_efl_gfx_gradient_radial_radius_get(Eo *obj EINA_UNUSED, + Efl_VG_Gradient_Radial_Data *pd) { return pd->radius; } static void -_evas_vg_gradient_radial_efl_gfx_gradient_radial_focal_set(Eo *obj EINA_UNUSED, - Evas_VG_Gradient_Radial_Data *pd, - double x, double y) +_efl_vg_gradient_radial_efl_gfx_gradient_radial_focal_set(Eo *obj EINA_UNUSED, + Efl_VG_Gradient_Radial_Data *pd, + double x, double y) { pd->focal.x = x; pd->focal.y = y; - _evas_vg_node_changed(obj); + _efl_vg_base_changed(obj); } static void -_evas_vg_gradient_radial_efl_gfx_gradient_radial_focal_get(Eo *obj EINA_UNUSED, - Evas_VG_Gradient_Radial_Data *pd, - double *x, double *y) +_efl_vg_gradient_radial_efl_gfx_gradient_radial_focal_get(Eo *obj EINA_UNUSED, + Efl_VG_Gradient_Radial_Data *pd, + double *x, double *y) { if (x) *x = pd->focal.x; if (y) *y = pd->focal.y; } static void -_evas_vg_gradient_radial_render_pre(Eo *obj, +_efl_vg_gradient_radial_render_pre(Eo *obj, Eina_Matrix3 *parent, Ector_Surface *s, void *data, - Evas_VG_Node_Data *nd) + Efl_VG_Base_Data *nd) { - Evas_VG_Gradient_Radial_Data *pd = data; - Evas_VG_Gradient_Data *gd; + Efl_VG_Gradient_Radial_Data *pd = data; + Efl_VG_Gradient_Data *gd; if (!nd->changed) return ; nd->changed = EINA_FALSE; - gd = eo_data_scope_get(obj, EVAS_VG_GRADIENT_CLASS); - EVAS_VG_COMPUTE_MATRIX(current, parent, nd); + gd = eo_data_scope_get(obj, EFL_VG_GRADIENT_CLASS); + EFL_VG_COMPUTE_MATRIX(current, parent, nd); if (!nd->renderer) { @@ -106,22 +106,60 @@ _evas_vg_gradient_radial_render_pre(Eo *obj, } static void -_evas_vg_gradient_radial_eo_base_constructor(Eo *obj, Evas_VG_Gradient_Radial_Data *pd) +_efl_vg_gradient_radial_eo_base_constructor(Eo *obj, Efl_VG_Gradient_Radial_Data *pd) { - Evas_VG_Node_Data *nd; + Efl_VG_Base_Data *nd; eo_do_super(obj, MY_CLASS, eo_constructor()); - nd = eo_data_scope_get(obj, EVAS_VG_NODE_CLASS); - nd->render_pre = _evas_vg_gradient_radial_render_pre; + nd = eo_data_scope_get(obj, EFL_VG_BASE_CLASS); + nd->render_pre = _efl_vg_gradient_radial_render_pre; nd->data = pd; } static void -_evas_vg_gradient_radial_eo_base_destructor(Eo *obj, - Evas_VG_Gradient_Radial_Data *pd EINA_UNUSED) +_efl_vg_gradient_radial_eo_base_destructor(Eo *obj, + Efl_VG_Gradient_Radial_Data *pd EINA_UNUSED) { eo_do_super(obj, MY_CLASS, eo_destructor()); } -#include "evas_vg_gradient_radial.eo.c" +EAPI void +evas_vg_gradient_radial_center_set(Eo *obj, double x, double y) +{ + eo_do(obj, efl_gfx_gradient_radial_center_set(x, y)); +} + +EAPI void +evas_vg_gradient_radial_center_get(Eo *obj, double *x, double *y) +{ + eo_do(obj, efl_gfx_gradient_radial_center_get(x, y)); +} + +EAPI void +evas_vg_gradient_radial_radius_set(Eo *obj, double r) +{ + eo_do(obj, efl_gfx_gradient_radial_radius_set(r)); +} + +EAPI double +evas_vg_gradient_radial_radius_get(Eo *obj) +{ + double ret; + + return eo_do_ret(obj, ret, efl_gfx_gradient_radial_radius_get()); +} + +EAPI void +evas_vg_gradient_radial_focal_set(Eo *obj, double x, double y) +{ + eo_do(obj, efl_gfx_gradient_radial_focal_set(x, y)); +} + +EAPI void +evas_vg_gradient_radial_focal_get(Eo *obj, double *x, double *y) +{ + eo_do(obj, efl_gfx_gradient_radial_focal_get(x, y)); +} + +#include "efl_vg_gradient_radial.eo.c" diff --git a/src/lib/evas/canvas/evas_vg_image.c b/src/lib/evas/canvas/evas_vg_image.c index 523c1fc098..1bb0b1bc50 100644 --- a/src/lib/evas/canvas/evas_vg_image.c +++ b/src/lib/evas/canvas/evas_vg_image.c @@ -5,8 +5,8 @@ #include "evas_vg_private.h" -typedef struct _Evas_VG_Image_Data Evas_VG_Image_Data; -struct _Evas_VG_Image_Data +typedef struct _Efl_VG_Image_Data Efl_VG_Image_Data; +struct _Efl_VG_Image_Data { // FIXME: only manipulate Eina_File internally. Eina_File *f; @@ -17,33 +17,33 @@ struct _Evas_VG_Image_Data }; static void -_evas_vg_image_position_set(Eo *obj, Evas_VG_Image_Data *pd, int x, int y) +_efl_vg_image_position_set(Eo *obj, Efl_VG_Image_Data *pd, int x, int y) { pd->x = x; pd->y = y; - _evas_vg_node_changed(obj); + _efl_vg_base_changed(obj); } static void -_evas_vg_image_position_get(Eo *obj, Evas_VG_Image_Data *pd, int *x, int *y) +_efl_vg_image_position_get(Eo *obj, Efl_VG_Image_Data *pd, int *x, int *y) { if (x) *x = pd->x; if (y) *y = pd->y; } static void -_evas_vg_image_size_set(Eo *obj, Evas_VG_Image_Data *pd, +_efl_vg_image_size_set(Eo *obj, Efl_VG_Image_Data *pd, unsigned int w, unsigned int h) { pd->w = w; pd->h = h; - _evas_vg_node_changed(obj); + _efl_vg_base_changed(obj); } static void -_evas_vg_image_size_get(Eo *obj, Evas_VG_Image_Data *pd, +_efl_vg_image_size_get(Eo *obj, Efl_VG_Image_Data *pd, unsigned int *w, unsigned int *h) { if (w) *w = pd->w; @@ -51,7 +51,7 @@ _evas_vg_image_size_get(Eo *obj, Evas_VG_Image_Data *pd, } static Eina_Bool -_evas_vg_image_efl_file_mmap_set(Eo *obj EINA_UNUSED, Evas_VG_Image_Data *pd, +_efl_vg_image_efl_file_mmap_set(Eo *obj EINA_UNUSED, Efl_VG_Image_Data *pd, const Eina_File *f, const char *key) { Eina_File *tmp = pd->f; @@ -60,13 +60,13 @@ _evas_vg_image_efl_file_mmap_set(Eo *obj EINA_UNUSED, Evas_VG_Image_Data *pd, eina_file_close(tmp); eina_stringshare_replace(&pd->key, key); - _evas_vg_node_changed(obj); + _efl_vg_base_changed(obj); return EINA_TRUE; } static void -_evas_vg_image_efl_file_mmap_get(Eo *obj EINA_UNUSED, Evas_VG_Image_Data *pd, +_efl_vg_image_efl_file_mmap_get(Eo *obj EINA_UNUSED, Efl_VG_Image_Data *pd, const Eina_File **f, const char **key) { if (f) *f = pd->f; @@ -74,21 +74,21 @@ _evas_vg_image_efl_file_mmap_get(Eo *obj EINA_UNUSED, Evas_VG_Image_Data *pd, } static Eina_Bool -_evas_vg_image_efl_file_file_set(Eo *obj, Evas_VG_Image_Data *pd, +_efl_vg_image_efl_file_file_set(Eo *obj, Efl_VG_Image_Data *pd, const char *file, const char *key) { Eina_File *tmp; Eina_Bool r; tmp = eina_file_open(file, EINA_FALSE); - r = _evas_vg_image_efl_file_mmap_set(obj, pd, tmp, key); + r = _efl_vg_image_efl_file_mmap_set(obj, pd, tmp, key); eina_file_close(tmp); return r; } static void -_evas_vg_image_efl_file_file_get(Eo *obj EINA_UNUSED, Evas_VG_Image_Data *pd, +_efl_vg_image_efl_file_file_get(Eo *obj EINA_UNUSED, Efl_VG_Image_Data *pd, const char **file, const char **key) { if (file) *file = eina_file_filename_get(pd->f); @@ -96,15 +96,15 @@ _evas_vg_image_efl_file_file_get(Eo *obj EINA_UNUSED, Evas_VG_Image_Data *pd, } static void -_evas_vg_image_eo_base_constructor(Eo *obj, Evas_VG_Image_Data *pd) +_efl_vg_image_eo_base_constructor(Eo *obj, Efl_VG_Image_Data *pd) { eo_error_set(obj); } static void -_evas_vg_image_eo_base_destructor(Eo *obj, Evas_VG_Image_Data *pd) +_efl_vg_image_eo_base_destructor(Eo *obj, Efl_VG_Image_Data *pd) { eo_error_set(obj); } -#include "evas_vg_image.eo.c" +#include "efl_vg_image.eo.c" diff --git a/src/lib/evas/canvas/evas_vg_loader_svg.c b/src/lib/evas/canvas/evas_vg_loader_svg.c index d173b2ae24..bf726d504a 100644 --- a/src/lib/evas/canvas/evas_vg_loader_svg.c +++ b/src/lib/evas/canvas/evas_vg_loader_svg.c @@ -116,7 +116,7 @@ _tag_linearGradient_handler(Evas_SVG_Loader *loader, _attrs_id_parser, &id); if (!id) return EINA_FALSE; - node = eo_add(EVAS_VG_GRADIENT_LINEAR_CLASS, NULL); + node = eo_add(EFL_VG_GRADIENT_LINEAR_CLASS, NULL); if (!node) return EINA_FALSE; eina_hash_direct_add(loader->definition, id, node); @@ -481,7 +481,7 @@ _tag_g_handler(Evas_SVG_Loader *loader, parent = eina_array_data_get(loader->stack, eina_array_count(loader->stack) - 1); - node = eo_add(EVAS_VG_CONTAINER_CLASS, parent); + node = eo_add(EFL_VG_CONTAINER_CLASS, parent); eina_array_push(loader->stack, node); return EINA_TRUE; diff --git a/src/lib/evas/canvas/evas_vg_node.c b/src/lib/evas/canvas/evas_vg_node.c index 76bec2500a..c368634a5c 100644 --- a/src/lib/evas/canvas/evas_vg_node.c +++ b/src/lib/evas/canvas/evas_vg_node.c @@ -6,12 +6,12 @@ #include #include -#define MY_CLASS EVAS_VG_NODE_CLASS +#define MY_CLASS EFL_VG_BASE_CLASS static Eina_Bool -_evas_vg_node_property_changed(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info) +_efl_vg_base_property_changed(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info) { - Evas_VG_Node_Data *pd = data; + Efl_VG_Base_Data *pd = data; Eo *parent; if (pd->changed) return EINA_TRUE; @@ -23,9 +23,9 @@ _evas_vg_node_property_changed(void *data, Eo *obj, const Eo_Event_Description * } void -_evas_vg_node_transformation_set(Eo *obj, - Evas_VG_Node_Data *pd, - const Eina_Matrix3 *m) +_efl_vg_base_transformation_set(Eo *obj, + Efl_VG_Base_Data *pd, + const Eina_Matrix3 *m) { if (!pd->m) { @@ -34,100 +34,100 @@ _evas_vg_node_transformation_set(Eo *obj, } memcpy(pd->m, m, sizeof (Eina_Matrix3)); - _evas_vg_node_changed(obj); + _efl_vg_base_changed(obj); } const Eina_Matrix3 * -_evas_vg_node_transformation_get(Eo *obj EINA_UNUSED, Evas_VG_Node_Data *pd) +_efl_vg_base_transformation_get(Eo *obj EINA_UNUSED, Efl_VG_Base_Data *pd) { return pd->m; } void -_evas_vg_node_origin_set(Eo *obj, - Evas_VG_Node_Data *pd, - double x, double y) +_efl_vg_base_origin_set(Eo *obj, + Efl_VG_Base_Data *pd, + double x, double y) { pd->x = x; pd->y = y; - _evas_vg_node_changed(obj); + _efl_vg_base_changed(obj); } void -_evas_vg_node_origin_get(Eo *obj EINA_UNUSED, - Evas_VG_Node_Data *pd, - double *x, double *y) +_efl_vg_base_origin_get(Eo *obj EINA_UNUSED, + Efl_VG_Base_Data *pd, + double *x, double *y) { if (x) *x = pd->x; if (y) *y = pd->y; } void -_evas_vg_node_efl_gfx_base_position_set(Eo *obj EINA_UNUSED, - Evas_VG_Node_Data *pd, - int x, int y) +_efl_vg_base_efl_gfx_base_position_set(Eo *obj EINA_UNUSED, + Efl_VG_Base_Data *pd, + int x, int y) { pd->x = lrint(x); pd->y = lrint(y); - _evas_vg_node_changed(obj); + _efl_vg_base_changed(obj); } void -_evas_vg_node_efl_gfx_base_position_get(Eo *obj EINA_UNUSED, - Evas_VG_Node_Data *pd, - int *x, int *y) +_efl_vg_base_efl_gfx_base_position_get(Eo *obj EINA_UNUSED, + Efl_VG_Base_Data *pd, + int *x, int *y) { if (x) *x = pd->x; if (y) *y = pd->y; } void -_evas_vg_node_efl_gfx_base_visible_set(Eo *obj EINA_UNUSED, - Evas_VG_Node_Data *pd, Eina_Bool v) +_efl_vg_base_efl_gfx_base_visible_set(Eo *obj EINA_UNUSED, + Efl_VG_Base_Data *pd, Eina_Bool v) { pd->visibility = v; - _evas_vg_node_changed(obj); + _efl_vg_base_changed(obj); } Eina_Bool -_evas_vg_node_efl_gfx_base_visible_get(Eo *obj EINA_UNUSED, - Evas_VG_Node_Data *pd) +_efl_vg_base_efl_gfx_base_visible_get(Eo *obj EINA_UNUSED, + Efl_VG_Base_Data *pd) { return pd->visibility; } void -_evas_vg_node_efl_gfx_base_color_set(Eo *obj EINA_UNUSED, - Evas_VG_Node_Data *pd, - int r, int g, int b, int a) +_efl_vg_base_efl_gfx_base_color_set(Eo *obj EINA_UNUSED, + Efl_VG_Base_Data *pd, + int r, int g, int b, int a) { pd->r = r; pd->g = g; pd->b = b; pd->a = a; - _evas_vg_node_changed(obj); + _efl_vg_base_changed(obj); } Eina_Bool -_evas_vg_node_efl_gfx_base_color_part_set(Eo *obj, Evas_VG_Node_Data *pd, - const char *part, - int r, int g, int b, int a) +_efl_vg_base_efl_gfx_base_color_part_set(Eo *obj, Efl_VG_Base_Data *pd, + const char *part, + int r, int g, int b, int a) { if (part) return EINA_FALSE; - _evas_vg_node_efl_gfx_base_color_set(obj, pd, r, g, b, a); + _efl_vg_base_efl_gfx_base_color_set(obj, pd, r, g, b, a); return EINA_TRUE; } void -_evas_vg_node_efl_gfx_base_color_get(Eo *obj EINA_UNUSED, - Evas_VG_Node_Data *pd, - int *r, int *g, int *b, int *a) +_efl_vg_base_efl_gfx_base_color_get(Eo *obj EINA_UNUSED, + Efl_VG_Base_Data *pd, + int *r, int *g, int *b, int *a) { if (r) *r = pd->r; if (g) *g = pd->g; @@ -136,62 +136,62 @@ _evas_vg_node_efl_gfx_base_color_get(Eo *obj EINA_UNUSED, } Eina_Bool -_evas_vg_node_efl_gfx_base_color_part_get(Eo *obj, Evas_VG_Node_Data *pd, - const char *part, - int *r, int *g, int *b, int *a) +_efl_vg_base_efl_gfx_base_color_part_get(Eo *obj, Efl_VG_Base_Data *pd, + const char *part, + int *r, int *g, int *b, int *a) { if (part) return EINA_FALSE; - _evas_vg_node_efl_gfx_base_color_get(obj, pd, r, g, b, a); + _efl_vg_base_efl_gfx_base_color_get(obj, pd, r, g, b, a); return EINA_TRUE; } void -_evas_vg_node_mask_set(Eo *obj EINA_UNUSED, - Evas_VG_Node_Data *pd, - Evas_VG_Node *r) +_efl_vg_base_mask_set(Eo *obj EINA_UNUSED, + Efl_VG_Base_Data *pd, + Efl_VG_Base *r) { - Evas_VG_Node *tmp = pd->mask; + Efl_VG_Base *tmp = pd->mask; pd->mask = eo_ref(r); eo_unref(tmp); - _evas_vg_node_changed(obj); + _efl_vg_base_changed(obj); } -Evas_VG_Node* -_evas_vg_node_mask_get(Eo *obj EINA_UNUSED, Evas_VG_Node_Data *pd) +Efl_VG_Base* +_efl_vg_base_mask_get(Eo *obj EINA_UNUSED, Efl_VG_Base_Data *pd) { return pd->mask; } void -_evas_vg_node_efl_gfx_base_size_get(Eo *obj, - Evas_VG_Node_Data *pd EINA_UNUSED, - int *w, int *h) +_efl_vg_base_efl_gfx_base_size_get(Eo *obj, + Efl_VG_Base_Data *pd EINA_UNUSED, + int *w, int *h) { Eina_Rectangle bound = { 0, 0, 0, 0 }; - eo_do(obj, evas_vg_node_bound_get(&bound)); + eo_do(obj, efl_vg_bound_get(&bound)); if (w) *w = bound.w; if (h) *h = bound.h; } // Parent should be a container otherwise dismissing the stacking operation static Eina_Bool -_evas_vg_node_parent_checked_get(Eo *obj, - Eo **parent, - Evas_VG_Container_Data **cd) +_efl_vg_base_parent_checked_get(Eo *obj, + Eo **parent, + Efl_VG_Container_Data **cd) { *cd = NULL; eo_do(obj, *parent = eo_parent_get()); - if (eo_isa(*parent, EVAS_VG_CONTAINER_CLASS)) + if (eo_isa(*parent, EFL_VG_CONTAINER_CLASS)) { - *cd = eo_data_scope_get(*parent, EVAS_VG_CONTAINER_CLASS); + *cd = eo_data_scope_get(*parent, EFL_VG_CONTAINER_CLASS); if (!*cd) { - ERR("Can't get EVAS_VG_CONTAINER_CLASS data."); + ERR("Can't get EFL_VG_CONTAINER_CLASS data."); goto on_error; } } @@ -210,36 +210,36 @@ _evas_vg_node_parent_checked_get(Eo *obj, } void -_evas_vg_node_eo_base_constructor(Eo *obj, - Evas_VG_Node_Data *pd) +_efl_vg_base_eo_base_constructor(Eo *obj, + Efl_VG_Base_Data *pd) { - Evas_VG_Container_Data *cd = NULL; + Efl_VG_Container_Data *cd = NULL; Eo *parent; eo_do_super(obj, MY_CLASS, eo_constructor()); - if (!_evas_vg_node_parent_checked_get(obj, &parent, &cd)) + if (!_efl_vg_base_parent_checked_get(obj, &parent, &cd)) eo_error_set(obj); - eo_do(obj, eo_event_callback_add(EFL_GFX_CHANGED, _evas_vg_node_property_changed, pd)); + eo_do(obj, eo_event_callback_add(EFL_GFX_CHANGED, _efl_vg_base_property_changed, pd)); pd->changed = EINA_TRUE; } void -_evas_vg_node_eo_base_parent_set(Eo *obj, - Evas_VG_Node_Data *pd EINA_UNUSED, - Eo *parent) +_efl_vg_base_eo_base_parent_set(Eo *obj, + Efl_VG_Base_Data *pd EINA_UNUSED, + Eo *parent) { - Evas_VG_Container_Data *cd = NULL; - Evas_VG_Container_Data *old_cd = NULL; + Efl_VG_Container_Data *cd = NULL; + Efl_VG_Container_Data *old_cd = NULL; Eo *old_parent; - if (eo_isa(parent, EVAS_VG_CONTAINER_CLASS)) + if (eo_isa(parent, EFL_VG_CONTAINER_CLASS)) { - cd = eo_data_scope_get(parent, EVAS_VG_CONTAINER_CLASS); + cd = eo_data_scope_get(parent, EFL_VG_CONTAINER_CLASS); if (!cd) { - ERR("Can't get EVAS_VG_CONTAINER_CLASS data from %p.", parent); + ERR("Can't get EFL_VG_CONTAINER_CLASS data from %p.", parent); goto on_error; } } @@ -249,7 +249,7 @@ _evas_vg_node_eo_base_parent_set(Eo *obj, goto on_error; } - if (!_evas_vg_node_parent_checked_get(obj, &old_parent, &old_cd)) + if (!_efl_vg_base_parent_checked_get(obj, &old_parent, &old_cd)) goto on_error; // FIXME: this may become slow with to much object @@ -260,9 +260,9 @@ _evas_vg_node_eo_base_parent_set(Eo *obj, if (cd) cd->children = eina_list_append(cd->children, obj); - _evas_vg_node_changed(old_parent); - _evas_vg_node_changed(obj); - _evas_vg_node_changed(parent); + _efl_vg_base_changed(old_parent); + _efl_vg_base_changed(obj); + _efl_vg_base_changed(parent); return ; @@ -272,15 +272,15 @@ _evas_vg_node_eo_base_parent_set(Eo *obj, } void -_evas_vg_node_efl_gfx_stack_raise(Eo *obj, Evas_VG_Node_Data *pd EINA_UNUSED) +_efl_vg_base_efl_gfx_stack_raise(Eo *obj, Efl_VG_Base_Data *pd EINA_UNUSED) { - Evas_VG_Container_Data *cd; + Efl_VG_Container_Data *cd; Eina_List *lookup, *next; Eo *parent; eo_do(obj, parent = eo_parent_get()); - if (!eo_isa(parent, EVAS_VG_CONTAINER_CLASS)) goto on_error; - cd = eo_data_scope_get(parent, EVAS_VG_CONTAINER_CLASS); + if (!eo_isa(parent, EFL_VG_CONTAINER_CLASS)) goto on_error; + cd = eo_data_scope_get(parent, EFL_VG_CONTAINER_CLASS); // FIXME: this could become slow with to much object lookup = eina_list_data_find_list(cd->children, obj); @@ -292,7 +292,7 @@ _evas_vg_node_efl_gfx_stack_raise(Eo *obj, Evas_VG_Node_Data *pd EINA_UNUSED) cd->children = eina_list_remove_list(cd->children, lookup); cd->children = eina_list_append_relative_list(cd->children, obj, next); - _evas_vg_node_changed(parent); + _efl_vg_base_changed(parent); return ; on_error: @@ -300,17 +300,17 @@ _evas_vg_node_efl_gfx_stack_raise(Eo *obj, Evas_VG_Node_Data *pd EINA_UNUSED) } void -_evas_vg_node_efl_gfx_stack_stack_above(Eo *obj, - Evas_VG_Node_Data *pd EINA_UNUSED, - Efl_Gfx_Stack *above) +_efl_vg_base_efl_gfx_stack_stack_above(Eo *obj, + Efl_VG_Base_Data *pd EINA_UNUSED, + Efl_Gfx_Stack *above) { - Evas_VG_Container_Data *cd; + Efl_VG_Container_Data *cd; Eina_List *lookup, *ref; Eo *parent; eo_do(obj, parent = eo_parent_get()); - if (!eo_isa(parent, EVAS_VG_CONTAINER_CLASS)) goto on_error; - cd = eo_data_scope_get(parent, EVAS_VG_CONTAINER_CLASS); + if (!eo_isa(parent, EFL_VG_CONTAINER_CLASS)) goto on_error; + cd = eo_data_scope_get(parent, EFL_VG_CONTAINER_CLASS); // FIXME: this could become slow with to much object lookup = eina_list_data_find_list(cd->children, obj); @@ -322,7 +322,7 @@ _evas_vg_node_efl_gfx_stack_stack_above(Eo *obj, cd->children = eina_list_remove_list(cd->children, lookup); cd->children = eina_list_append_relative_list(cd->children, obj, ref); - _evas_vg_node_changed(parent); + _efl_vg_base_changed(parent); return ; on_error: @@ -330,17 +330,17 @@ _evas_vg_node_efl_gfx_stack_stack_above(Eo *obj, } void -_evas_vg_node_efl_gfx_stack_stack_below(Eo *obj, - Evas_VG_Node_Data *pd EINA_UNUSED, - Efl_Gfx_Stack *below) +_efl_vg_base_efl_gfx_stack_stack_below(Eo *obj, + Efl_VG_Base_Data *pd EINA_UNUSED, + Efl_Gfx_Stack *below) { - Evas_VG_Container_Data *cd; + Efl_VG_Container_Data *cd; Eina_List *lookup, *ref; Eo *parent; eo_do(obj, parent = eo_parent_get()); - if (!eo_isa(parent, EVAS_VG_CONTAINER_CLASS)) goto on_error; - cd = eo_data_scope_get(parent, EVAS_VG_CONTAINER_CLASS); + if (!eo_isa(parent, EFL_VG_CONTAINER_CLASS)) goto on_error; + cd = eo_data_scope_get(parent, EFL_VG_CONTAINER_CLASS); // FIXME: this could become slow with to much object lookup = eina_list_data_find_list(cd->children, obj); @@ -352,7 +352,7 @@ _evas_vg_node_efl_gfx_stack_stack_below(Eo *obj, cd->children = eina_list_remove_list(cd->children, lookup); cd->children = eina_list_prepend_relative_list(cd->children, obj, ref); - _evas_vg_node_changed(parent); + _efl_vg_base_changed(parent); return ; on_error: @@ -360,15 +360,15 @@ _evas_vg_node_efl_gfx_stack_stack_below(Eo *obj, } void -_evas_vg_node_efl_gfx_stack_lower(Eo *obj, Evas_VG_Node_Data *pd EINA_UNUSED) +_efl_vg_base_efl_gfx_stack_lower(Eo *obj, Efl_VG_Base_Data *pd EINA_UNUSED) { - Evas_VG_Container_Data *cd; + Efl_VG_Container_Data *cd; Eina_List *lookup, *prev; Eo *parent; eo_do(obj, parent = eo_parent_get()); - if (!eo_isa(parent, EVAS_VG_CONTAINER_CLASS)) goto on_error; - cd = eo_data_scope_get(parent, EVAS_VG_CONTAINER_CLASS); + if (!eo_isa(parent, EFL_VG_CONTAINER_CLASS)) goto on_error; + cd = eo_data_scope_get(parent, EFL_VG_CONTAINER_CLASS); // FIXME: this could become slow with to much object lookup = eina_list_data_find_list(cd->children, obj); @@ -380,7 +380,7 @@ _evas_vg_node_efl_gfx_stack_lower(Eo *obj, Evas_VG_Node_Data *pd EINA_UNUSED) cd->children = eina_list_remove_list(cd->children, lookup); cd->children = eina_list_prepend_relative_list(cd->children, obj, prev); - _evas_vg_node_changed(parent); + _efl_vg_base_changed(parent); return ; on_error: @@ -388,25 +388,91 @@ _evas_vg_node_efl_gfx_stack_lower(Eo *obj, Evas_VG_Node_Data *pd EINA_UNUSED) } Efl_Gfx_Stack * -_evas_vg_node_efl_gfx_stack_below_get(Eo *obj, Evas_VG_Node_Data *pd) +_efl_vg_base_efl_gfx_stack_below_get(Eo *obj, Efl_VG_Base_Data *pd) { // FIXME: need to implement bound_get return NULL; } Efl_Gfx_Stack * -_evas_vg_node_efl_gfx_stack_above_get(Eo *obj, Evas_VG_Node_Data *pd) +_efl_vg_base_efl_gfx_stack_above_get(Eo *obj, Efl_VG_Base_Data *pd) { // FIXME: need to implement bound_get return NULL; } Eina_Bool -_evas_vg_node_original_bound_get(Eo *obj, - Evas_VG_Node_Data *pd, - Eina_Rectangle *r) +_efl_vg_base_original_bound_get(Eo *obj, + Efl_VG_Base_Data *pd, + Eina_Rectangle *r) { return EINA_FALSE; } -#include "evas_vg_node.eo.c" +EAPI Eina_Bool +evas_vg_node_visible_get(Eo *obj) +{ + Eina_Bool ret; + + return eo_do_ret(obj, ret, efl_gfx_visible_get()); +} + +EAPI void +evas_vg_node_visible_set(Eo *obj, Eina_Bool v) +{ + eo_do(obj, efl_gfx_visible_set(v)); +} + +EAPI void +evas_vg_node_color_get(Eo *obj, int *r, int *g, int *b, int *a) +{ + eo_do(obj, efl_gfx_color_get(r, g, b, a)); +} + +EAPI void +evas_vg_node_color_set(Eo *obj, int r, int g, int b, int a) +{ + eo_do(obj, efl_gfx_color_set(r, g, b, a)); +} + +EAPI void +evas_vg_node_geometry_get(Eo *obj, int *x, int *y, int *w, int *h) +{ + eo_do(obj, + efl_gfx_position_get(x, y), + efl_gfx_size_get(w, h)); +} + +EAPI void +evas_vg_node_geometry_set(Eo *obj, int x, int y, int w, int h) +{ + eo_do(obj, + efl_gfx_position_set(x, y), + efl_gfx_size_set(w, h)); +} + +EAPI void +evas_vg_node_stack_below(Eo *obj, Eo *below) +{ + eo_do(obj, efl_gfx_stack_below(below)); +} + +EAPI void +evas_vg_node_stack_above(Eo *obj, Eo *above) +{ + eo_do(obj, efl_gfx_stack_above(above)); +} + +EAPI void +evas_vg_node_raise(Eo *obj) +{ + eo_do(obj, efl_gfx_stack_raise()); +} + +EAPI void +evas_vg_node_lower(Eo *obj) +{ + eo_do(obj, efl_gfx_stack_lower()); +} + +#include "efl_vg_base.eo.c" diff --git a/src/lib/evas/canvas/evas_vg_private.h b/src/lib/evas/canvas/evas_vg_private.h index 1c7d516615..8db3396c02 100644 --- a/src/lib/evas/canvas/evas_vg_private.h +++ b/src/lib/evas/canvas/evas_vg_private.h @@ -3,17 +3,17 @@ #include -typedef struct _Evas_VG_Node_Data Evas_VG_Node_Data; -typedef struct _Evas_VG_Container_Data Evas_VG_Container_Data; -typedef struct _Evas_VG_Gradient_Data Evas_VG_Gradient_Data; +typedef struct _Efl_VG_Base_Data Efl_VG_Base_Data; +typedef struct _Efl_VG_Container_Data Efl_VG_Container_Data; +typedef struct _Efl_VG_Gradient_Data Efl_VG_Gradient_Data; -struct _Evas_VG_Node_Data +struct _Efl_VG_Base_Data { Eina_Matrix3 *m; - Evas_VG_Node *mask; + Efl_VG *mask; Ector_Renderer *renderer; - void (*render_pre)(Eo *obj, Eina_Matrix3 *parent, Ector_Surface *s, void *data, Evas_VG_Node_Data *nd); + void (*render_pre)(Eo *obj, Eina_Matrix3 *parent, Ector_Surface *s, void *data, Efl_VG_Base_Data *nd); void *data; double x, y; @@ -23,12 +23,12 @@ struct _Evas_VG_Node_Data Eina_Bool changed : 1; }; -struct _Evas_VG_Container_Data +struct _Efl_VG_Container_Data { Eina_List *children; }; -struct _Evas_VG_Gradient_Data +struct _Efl_VG_Gradient_Data { // FIXME: Later on we should deduplicate it somehow (Using Ector ?). Efl_Gfx_Gradient_Stop *colors; @@ -37,14 +37,14 @@ struct _Evas_VG_Gradient_Data Efl_Gfx_Gradient_Spread s; }; -static inline Evas_VG_Node_Data * -_evas_vg_render_pre(Evas_VG_Node *child, Ector_Surface *s, Eina_Matrix3 *m) +static inline Efl_VG_Base_Data * +_evas_vg_render_pre(Efl_VG *child, Ector_Surface *s, Eina_Matrix3 *m) { - Evas_VG_Node_Data *child_nd = NULL; + Efl_VG_Base_Data *child_nd = NULL; // FIXME: Prevent infinite loop if (child) - child_nd = eo_data_scope_get(child, EVAS_VG_NODE_CLASS); + child_nd = eo_data_scope_get(child, EFL_VG_BASE_CLASS); if (child_nd) child_nd->render_pre(child, m, s, child_nd->data, child_nd); @@ -52,12 +52,12 @@ _evas_vg_render_pre(Evas_VG_Node *child, Ector_Surface *s, Eina_Matrix3 *m) } static inline void -_evas_vg_node_changed(Eo *obj) +_efl_vg_base_changed(Eo *obj) { eo_do(obj, eo_event_callback_call(EFL_GFX_CHANGED, NULL)); } -#define EVAS_VG_COMPUTE_MATRIX(Current, Parent, Nd) \ +#define EFL_VG_COMPUTE_MATRIX(Current, Parent, Nd) \ Eina_Matrix3 *Current = Nd->m; \ Eina_Matrix3 _matrix_tmp; \ \ diff --git a/src/lib/evas/canvas/evas_vg_root_node.c b/src/lib/evas/canvas/evas_vg_root_node.c index d6f2c51a34..75a304d6de 100644 --- a/src/lib/evas/canvas/evas_vg_root_node.c +++ b/src/lib/evas/canvas/evas_vg_root_node.c @@ -2,14 +2,14 @@ #include "evas_private.h" #include "evas_vg_private.h" -#include "evas_vg_root_node.eo.h" +#include "efl_vg_root_node.eo.h" #include -#define MY_CLASS EVAS_VG_ROOT_NODE_CLASS +#define MY_CLASS EFL_VG_ROOT_NODE_CLASS -typedef struct _Evas_VG_Root_Node_Data Evas_VG_Root_Node_Data; -struct _Evas_VG_Root_Node_Data +typedef struct _Efl_VG_Root_Node_Data Efl_VG_Root_Node_Data; +struct _Efl_VG_Root_Node_Data { Evas_Object *parent; Evas_Object_Protected_Data *data; @@ -20,16 +20,16 @@ _evas_vg_root_node_render_pre(Eo *obj EINA_UNUSED, Eina_Matrix3 *parent, Ector_Surface *s, void *data, - Evas_VG_Node_Data *nd) + Efl_VG_Base_Data *nd) { - Evas_VG_Container_Data *pd = data; + Efl_VG_Container_Data *pd = data; Eina_List *l; Eo *child; if (!nd->changed) return ; nd->changed = EINA_FALSE; - EVAS_VG_COMPUTE_MATRIX(current, parent, nd); + EFL_VG_COMPUTE_MATRIX(current, parent, nd); EINA_LIST_FOREACH(pd->children, l, child) _evas_vg_render_pre(child, s, current); @@ -40,19 +40,19 @@ _evas_vg_root_node_changed(void *data, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED) { - Evas_VG_Root_Node_Data *pd = data; + Efl_VG_Root_Node_Data *pd = data; if (pd->parent) evas_object_change(pd->parent, pd->data); return EINA_TRUE; } void -_evas_vg_root_node_eo_base_parent_set(Eo *obj, - Evas_VG_Root_Node_Data *pd, - Eo *parent) +_efl_vg_root_node_eo_base_parent_set(Eo *obj, + Efl_VG_Root_Node_Data *pd, + Eo *parent) { - // Nice little hack, jump over parent parent_set in Evas_VG_Root - eo_do_super(obj, EVAS_VG_NODE_CLASS, eo_parent_set(parent)); + // Nice little hack, jump over parent parent_set in Efl_VG_Root + eo_do_super(obj, EFL_VG_BASE_CLASS, eo_parent_set(parent)); if (parent && !eo_isa(parent, EVAS_VG_CLASS)) { eo_error_set(obj); @@ -65,11 +65,11 @@ _evas_vg_root_node_eo_base_parent_set(Eo *obj, } void -_evas_vg_root_node_eo_base_constructor(Eo *obj, - Evas_VG_Root_Node_Data *pd) +_efl_vg_root_node_eo_base_constructor(Eo *obj, + Efl_VG_Root_Node_Data *pd) { - Evas_VG_Container_Data *cd; - Evas_VG_Node_Data *nd; + Efl_VG_Container_Data *cd; + Efl_VG_Base_Data *nd; Eo *parent; // Nice little hack, jump over parent constructor in Efl_VG_Root @@ -78,14 +78,14 @@ _evas_vg_root_node_eo_base_constructor(Eo *obj, if (!eo_isa(parent, EVAS_VG_CLASS)) eo_error_set(obj); - cd = eo_data_scope_get(obj, EVAS_VG_CONTAINER_CLASS); + cd = eo_data_scope_get(obj, EFL_VG_CONTAINER_CLASS); cd->children = NULL; - nd = eo_data_scope_get(obj, EVAS_VG_NODE_CLASS); + nd = eo_data_scope_get(obj, EFL_VG_BASE_CLASS); nd->render_pre = _evas_vg_root_node_render_pre; nd->data = cd; eo_do(obj, eo_event_callback_add(EFL_GFX_CHANGED, _evas_vg_root_node_changed, pd)); } -#include "evas_vg_root_node.eo.c" +#include "efl_vg_root_node.eo.c" diff --git a/src/lib/evas/canvas/evas_vg_root_node.eo b/src/lib/evas/canvas/evas_vg_root_node.eo deleted file mode 100644 index 9489c7388f..0000000000 --- a/src/lib/evas/canvas/evas_vg_root_node.eo +++ /dev/null @@ -1,8 +0,0 @@ -class Evas.VG_Root_Node (Evas.VG_Container) -{ - eo_prefix: evas_vg_root_node; - implements { - Eo.Base.parent.set; - Eo.Base.constructor; - } -} diff --git a/src/lib/evas/canvas/evas_vg_shape.c b/src/lib/evas/canvas/evas_vg_shape.c index 2a577b89be..fd63594c2c 100644 --- a/src/lib/evas/canvas/evas_vg_shape.c +++ b/src/lib/evas/canvas/evas_vg_shape.c @@ -3,17 +3,17 @@ #include "evas_vg_private.h" -#define MY_CLASS EVAS_VG_SHAPE_CLASS +#define MY_CLASS EFL_VG_SHAPE_CLASS -typedef struct _Evas_VG_Shape_Data Evas_VG_Shape_Data; -struct _Evas_VG_Shape_Data +typedef struct _Efl_VG_Shape_Data Efl_VG_Shape_Data; +struct _Efl_VG_Shape_Data { - Evas_VG_Node *fill; + Efl_VG *fill; struct { Efl_Gfx_Dash *dash; - Evas_VG_Node *fill; - Evas_VG_Node *marker; + Efl_VG *fill; + Efl_VG *marker; double scale; double width; @@ -29,72 +29,72 @@ struct _Evas_VG_Shape_Data }; static Eina_Bool -_evas_vg_shape_evas_vg_node_bound_get(Eo *obj, - Evas_VG_Shape_Data *pd, - Eina_Rectangle *r) +_efl_vg_shape_efl_vg_base_bound_get(Eo *obj, + Efl_VG_Shape_Data *pd, + Eina_Rectangle *r) { return EINA_FALSE; } static void -_evas_vg_shape_fill_set(Eo *obj EINA_UNUSED, - Evas_VG_Shape_Data *pd, - Evas_VG_Node *f) +_efl_vg_shape_fill_set(Eo *obj EINA_UNUSED, + Efl_VG_Shape_Data *pd, + Efl_VG *f) { - Evas_VG_Node *tmp = pd->fill; + Efl_VG *tmp = pd->fill; pd->fill = eo_ref(f); eo_unref(tmp); - _evas_vg_node_changed(obj); + _efl_vg_base_changed(obj); } -static Evas_VG_Node * -_evas_vg_shape_fill_get(Eo *obj EINA_UNUSED, Evas_VG_Shape_Data *pd) +static Efl_VG * +_efl_vg_shape_fill_get(Eo *obj EINA_UNUSED, Efl_VG_Shape_Data *pd) { return pd->fill; } static void -_evas_vg_shape_efl_gfx_shape_stroke_scale_set(Eo *obj EINA_UNUSED, - Evas_VG_Shape_Data *pd, - double s) +_efl_vg_shape_efl_gfx_shape_stroke_scale_set(Eo *obj EINA_UNUSED, + Efl_VG_Shape_Data *pd, + double s) { pd->stroke.scale = s; - _evas_vg_node_changed(obj); + _efl_vg_base_changed(obj); } static double -_evas_vg_shape_efl_gfx_shape_stroke_scale_get(Eo *obj EINA_UNUSED, - Evas_VG_Shape_Data *pd) +_efl_vg_shape_efl_gfx_shape_stroke_scale_get(Eo *obj EINA_UNUSED, + Efl_VG_Shape_Data *pd) { return pd->stroke.scale; } static void -_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) +_efl_vg_shape_efl_gfx_shape_stroke_color_set(Eo *obj EINA_UNUSED, + Efl_VG_Shape_Data *pd, + int r, int g, int b, int a) { pd->stroke.r = r; pd->stroke.g = g; pd->stroke.b = b; pd->stroke.a = a; - _evas_vg_node_changed(obj); + _efl_vg_base_changed(obj); } static Eina_Bool -_evas_vg_shape_efl_gfx_base_color_part_set(Eo *obj, Evas_VG_Shape_Data *pd, - const char * part, - int r, int g, int b, int a) +_efl_vg_shape_efl_gfx_base_color_part_set(Eo *obj, Efl_VG_Shape_Data *pd, + const char * part, + int r, int g, int b, int a) { Eina_Bool ret; if (part && !strcmp(part, "stroke")) { - _evas_vg_shape_efl_gfx_shape_stroke_color_set(obj, pd, r, g, b, a); + _efl_vg_shape_efl_gfx_shape_stroke_color_set(obj, pd, r, g, b, a); return EINA_TRUE; } @@ -105,9 +105,9 @@ _evas_vg_shape_efl_gfx_base_color_part_set(Eo *obj, Evas_VG_Shape_Data *pd, } static void -_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) +_efl_vg_shape_efl_gfx_shape_stroke_color_get(Eo *obj EINA_UNUSED, + Efl_VG_Shape_Data *pd, + int *r, int *g, int *b, int *a) { if (r) *r = pd->stroke.r; if (g) *g = pd->stroke.g; @@ -116,15 +116,15 @@ _evas_vg_shape_efl_gfx_shape_stroke_color_get(Eo *obj EINA_UNUSED, } static Eina_Bool -_evas_vg_shape_efl_gfx_base_color_part_get(Eo *obj, Evas_VG_Shape_Data *pd, - const char * part, - int *r, int *g, int *b, int *a) +_efl_vg_shape_efl_gfx_base_color_part_get(Eo *obj, Efl_VG_Shape_Data *pd, + const char * part, + int *r, int *g, int *b, int *a) { Eina_Bool ret; if (part && !strcmp(part, "stroke")) { - _evas_vg_shape_efl_gfx_shape_stroke_color_get(obj, pd, r, g, b, a); + _efl_vg_shape_efl_gfx_shape_stroke_color_get(obj, pd, r, g, b, a); return EINA_TRUE; } @@ -135,64 +135,64 @@ _evas_vg_shape_efl_gfx_base_color_part_get(Eo *obj, Evas_VG_Shape_Data *pd, } static void -_evas_vg_shape_stroke_fill_set(Eo *obj EINA_UNUSED, - Evas_VG_Shape_Data *pd, - Evas_VG_Node *f) +_efl_vg_shape_stroke_fill_set(Eo *obj EINA_UNUSED, + Efl_VG_Shape_Data *pd, + Efl_VG *f) { - Evas_VG_Node *tmp = pd->fill; + Efl_VG *tmp = pd->fill; pd->stroke.fill = eo_ref(f); eo_unref(tmp); - _evas_vg_node_changed(obj); + _efl_vg_base_changed(obj); } -static Evas_VG_Node * -_evas_vg_shape_stroke_fill_get(Eo *obj EINA_UNUSED, - Evas_VG_Shape_Data *pd) +static Efl_VG * +_efl_vg_shape_stroke_fill_get(Eo *obj EINA_UNUSED, + Efl_VG_Shape_Data *pd) { return pd->stroke.fill; } static void -_evas_vg_shape_efl_gfx_shape_stroke_width_set(Eo *obj EINA_UNUSED, - Evas_VG_Shape_Data *pd, - double w) +_efl_vg_shape_efl_gfx_shape_stroke_width_set(Eo *obj EINA_UNUSED, + Efl_VG_Shape_Data *pd, + double w) { pd->stroke.width = w; - _evas_vg_node_changed(obj); + _efl_vg_base_changed(obj); } static double -_evas_vg_shape_efl_gfx_shape_stroke_width_get(Eo *obj EINA_UNUSED, - Evas_VG_Shape_Data *pd) +_efl_vg_shape_efl_gfx_shape_stroke_width_get(Eo *obj EINA_UNUSED, + Efl_VG_Shape_Data *pd) { return pd->stroke.width; } static void -_evas_vg_shape_efl_gfx_shape_stroke_location_set(Eo *obj EINA_UNUSED, - Evas_VG_Shape_Data *pd, - double centered) +_efl_vg_shape_efl_gfx_shape_stroke_location_set(Eo *obj EINA_UNUSED, + Efl_VG_Shape_Data *pd, + double centered) { pd->stroke.centered = centered; - _evas_vg_node_changed(obj); + _efl_vg_base_changed(obj); } static double -_evas_vg_shape_efl_gfx_shape_stroke_location_get(Eo *obj EINA_UNUSED, - Evas_VG_Shape_Data *pd) +_efl_vg_shape_efl_gfx_shape_stroke_location_get(Eo *obj EINA_UNUSED, + Efl_VG_Shape_Data *pd) { return pd->stroke.centered; } static void -_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) +_efl_vg_shape_efl_gfx_shape_stroke_dash_set(Eo *obj EINA_UNUSED, + Efl_VG_Shape_Data *pd, + const Efl_Gfx_Dash *dash, + unsigned int length) { free(pd->stroke.dash); pd->stroke.dash = NULL; @@ -204,87 +204,87 @@ _evas_vg_shape_efl_gfx_shape_stroke_dash_set(Eo *obj EINA_UNUSED, memcpy(pd->stroke.dash, dash, sizeof (Efl_Gfx_Dash) * length); pd->stroke.dash_count = length; - _evas_vg_node_changed(obj); + _efl_vg_base_changed(obj); } static void -_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) +_efl_vg_shape_efl_gfx_shape_stroke_dash_get(Eo *obj EINA_UNUSED, + Efl_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; } static void -_evas_vg_shape_stroke_marker_set(Eo *obj EINA_UNUSED, - Evas_VG_Shape_Data *pd, - Evas_VG_Shape *m) +_efl_vg_shape_stroke_marker_set(Eo *obj EINA_UNUSED, + Efl_VG_Shape_Data *pd, + Efl_VG_Shape *m) { - Evas_VG_Node *tmp = pd->stroke.marker; + Efl_VG *tmp = pd->stroke.marker; pd->stroke.marker = eo_ref(m); eo_unref(tmp); - _evas_vg_node_changed(obj); + _efl_vg_base_changed(obj); } -static Evas_VG_Shape * -_evas_vg_shape_stroke_marker_get(Eo *obj EINA_UNUSED, - Evas_VG_Shape_Data *pd) +static Efl_VG_Shape * +_efl_vg_shape_stroke_marker_get(Eo *obj EINA_UNUSED, + Efl_VG_Shape_Data *pd) { return pd->stroke.marker; } static void -_evas_vg_shape_efl_gfx_shape_stroke_cap_set(Eo *obj EINA_UNUSED, - Evas_VG_Shape_Data *pd, - Efl_Gfx_Cap c) +_efl_vg_shape_efl_gfx_shape_stroke_cap_set(Eo *obj EINA_UNUSED, + Efl_VG_Shape_Data *pd, + Efl_Gfx_Cap c) { pd->stroke.cap = c; - _evas_vg_node_changed(obj); + _efl_vg_base_changed(obj); } static Efl_Gfx_Cap -_evas_vg_shape_efl_gfx_shape_stroke_cap_get(Eo *obj EINA_UNUSED, - Evas_VG_Shape_Data *pd) +_efl_vg_shape_efl_gfx_shape_stroke_cap_get(Eo *obj EINA_UNUSED, + Efl_VG_Shape_Data *pd) { return pd->stroke.cap; } static void -_evas_vg_shape_efl_gfx_shape_stroke_join_set(Eo *obj EINA_UNUSED, - Evas_VG_Shape_Data *pd, - Efl_Gfx_Join j) +_efl_vg_shape_efl_gfx_shape_stroke_join_set(Eo *obj EINA_UNUSED, + Efl_VG_Shape_Data *pd, + Efl_Gfx_Join j) { pd->stroke.join = j; - _evas_vg_node_changed(obj); + _efl_vg_base_changed(obj); } static Efl_Gfx_Join -_evas_vg_shape_efl_gfx_shape_stroke_join_get(Eo *obj EINA_UNUSED, - Evas_VG_Shape_Data *pd) +_efl_vg_shape_efl_gfx_shape_stroke_join_get(Eo *obj EINA_UNUSED, + Efl_VG_Shape_Data *pd) { return pd->stroke.join; } static void -_evas_vg_shape_render_pre(Eo *obj EINA_UNUSED, - Eina_Matrix3 *parent, - Ector_Surface *s, - void *data, - Evas_VG_Node_Data *nd) +_efl_vg_shape_render_pre(Eo *obj EINA_UNUSED, + Eina_Matrix3 *parent, + Ector_Surface *s, + void *data, + Efl_VG_Base_Data *nd) { - Evas_VG_Shape_Data *pd = data; - Evas_VG_Node_Data *fill, *stroke_fill, *stroke_marker, *mask; + Efl_VG_Shape_Data *pd = data; + Efl_VG_Base_Data *fill, *stroke_fill, *stroke_marker, *mask; if (!nd->changed) return ; nd->changed = EINA_FALSE; - EVAS_VG_COMPUTE_MATRIX(current, parent, nd); + EFL_VG_COMPUTE_MATRIX(current, parent, nd); fill = _evas_vg_render_pre(pd->fill, s, current); stroke_fill = _evas_vg_render_pre(pd->stroke.fill, s, current); @@ -310,9 +310,9 @@ _evas_vg_shape_render_pre(Eo *obj EINA_UNUSED, } static void -_evas_vg_shape_eo_base_constructor(Eo *obj, Evas_VG_Shape_Data *pd) +_efl_vg_shape_eo_base_constructor(Eo *obj, Efl_VG_Shape_Data *pd) { - Evas_VG_Node_Data *nd; + Efl_VG_Base_Data *nd; eo_do_super(obj, MY_CLASS, eo_constructor()); @@ -322,15 +322,227 @@ _evas_vg_shape_eo_base_constructor(Eo *obj, Evas_VG_Shape_Data *pd) pd->stroke.a = 1; pd->stroke.centered = 0.5; - nd = eo_data_scope_get(obj, EVAS_VG_NODE_CLASS); - nd->render_pre = _evas_vg_shape_render_pre; + nd = eo_data_scope_get(obj, EFL_VG_BASE_CLASS); + nd->render_pre = _efl_vg_shape_render_pre; nd->data = pd; } static void -_evas_vg_shape_eo_base_destructor(Eo *obj, Evas_VG_Shape_Data *pd EINA_UNUSED) +_efl_vg_shape_eo_base_destructor(Eo *obj, Efl_VG_Shape_Data *pd EINA_UNUSED) { eo_do_super(obj, MY_CLASS, eo_destructor()); } -#include "evas_vg_shape.eo.c" +EAPI double +evas_vg_shape_stroke_scale_get(Eo *obj) +{ + double ret; + + return eo_do_ret(obj, ret, efl_gfx_shape_stroke_scale_get()); +} + +EAPI void +evas_vg_shape_stroke_scale_set(Eo *obj, double s) +{ + eo_do(obj, efl_gfx_shape_stroke_scale_set(s)); +} + +EAPI void +evas_vg_shape_stroke_color_get(Eo *obj, int *r, int *g, int *b, int *a) +{ + eo_do(obj, efl_gfx_shape_stroke_color_get(r, g, b, a)); +} + +EAPI void +evas_vg_shape_stroke_color_set(Eo *obj, int r, int g, int b, int a) +{ + eo_do(obj, efl_gfx_shape_stroke_color_set(r, g, b, a)); +} + +EAPI double +evas_vg_shape_stroke_width_get(Eo *obj) +{ + double ret; + + return eo_do_ret(obj, ret, efl_gfx_shape_stroke_width_get()); +} + +EAPI void +evas_vg_shape_stroke_width_set(Eo *obj, double w) +{ + eo_do(obj, efl_gfx_shape_stroke_width_set(w)); +} + +EAPI double +evas_vg_shape_stroke_location_get(Eo *obj) +{ + double ret; + + return eo_do_ret(obj, ret, efl_gfx_shape_stroke_location_get()); +} + +EAPI void +evas_vg_shape_stroke_location_set(Eo *obj, double centered) +{ + eo_do(obj, efl_gfx_shape_stroke_location_set(centered)); +} + +EAPI void +evas_vg_shape_stroke_dash_get(Eo *obj, const Efl_Gfx_Dash **dash, unsigned int *length) +{ + eo_do(obj, efl_gfx_shape_stroke_dash_get(dash, length)); +} + +EAPI void +evas_vg_shape_stroke_dash_set(Eo *obj, const Efl_Gfx_Dash *dash, unsigned int length) +{ + eo_do(obj, efl_gfx_shape_stroke_dash_set(dash, length)); +} + +EAPI Efl_Gfx_Cap +evas_vg_shape_stroke_cap_get(Eo *obj) +{ + Efl_Gfx_Cap ret; + + return eo_do_ret(obj, ret, efl_gfx_shape_stroke_cap_get()); +} + +EAPI void +evas_vg_shape_stroke_cap_set(Eo *obj, Efl_Gfx_Cap c) +{ + eo_do(obj, efl_gfx_shape_stroke_cap_set(c)); +} + +EAPI Efl_Gfx_Join +evas_vg_shape_stroke_join_get(Eo *obj) +{ + Efl_Gfx_Join ret; + + return eo_do_ret(obj, ret, efl_gfx_shape_stroke_join_get()); +} + +EAPI void +evas_vg_shape_stroke_join_set(Eo *obj, Efl_Gfx_Join j) +{ + eo_do(obj, efl_gfx_shape_stroke_join_set(j)); +} + +EAPI void +evas_vg_shape_shape_path_set(Eo *obj, const Efl_Gfx_Path_Command *op, const double *points) +{ + eo_do(obj, efl_gfx_shape_path_set(op, points)); +} + +EAPI void +evas_vg_shape_shape_path_get(Eo *obj, const Efl_Gfx_Path_Command **op, const double **points) +{ + eo_do(obj, efl_gfx_shape_path_get(op, points)); +} + +EAPI void +evas_vg_shape_shape_path_length_get(Eo *obj, unsigned int *commands, unsigned int *points) +{ + eo_do(obj, efl_gfx_shape_path_length_get(commands, points)); +} + +EAPI void +evas_vg_shape_shape_current_get(Eo *obj, double *x, double *y) +{ + eo_do(obj, efl_gfx_shape_current_get(x, y)); +} + +EAPI void +evas_vg_shape_shape_current_ctrl_get(Eo *obj, double *x, double *y) +{ + eo_do(obj, efl_gfx_shape_current_ctrl_get(x, y)); +} + +EAPI void +evas_vg_shape_shape_dup(Eo *obj, Eo *dup_from) +{ + eo_do(obj, efl_gfx_shape_dup(dup_from)); +} + +EAPI void +evas_vg_shape_shape_reset(Eo *obj) +{ + eo_do(obj, efl_gfx_shape_reset()); +} + +EAPI void +evas_vg_shape_shape_append_move_to(Eo *obj, double x, double y) +{ + eo_do(obj, efl_gfx_shape_append_move_to(x, y)); +} + +EAPI void +evas_vg_shape_shape_append_line_to(Eo *obj, double x, double y) +{ + eo_do(obj, efl_gfx_shape_append_line_to(x, y)); +} + +EAPI void +evas_vg_shape_shape_append_quadratic_to(Eo *obj, double x, double y, double ctrl_x, double ctrl_y) +{ + eo_do(obj, efl_gfx_shape_append_quadratic_to(x, y, ctrl_x, ctrl_y)); +} + +EAPI void +evas_vg_shape_shape_append_squadratic_to(Eo *obj, double x, double y) +{ + eo_do(obj, efl_gfx_shape_append_squadratic_to(x, y)); +} + +EAPI void +evas_vg_shape_shape_append_cubic_to(Eo *obj, double x, double y, double ctrl_x0, double ctrl_y0, double ctrl_x1, double ctrl_y1) +{ + eo_do(obj, efl_gfx_shape_append_cubic_to(x, y, ctrl_x0, ctrl_y0, ctrl_x1, ctrl_y1)); +} + +EAPI void +evas_vg_shape_shape_append_scubic_to(Eo *obj, double x, double y, double ctrl_x, double ctrl_y) +{ + eo_do(obj, efl_gfx_shape_append_scubic_to(x, y, ctrl_x, ctrl_y)); +} + +EAPI void +evas_vg_shape_shape_append_arc_to(Eo *obj, double x, double y, double rx, double ry, double angle, Eina_Bool large_arc, Eina_Bool sweep) +{ + eo_do(obj, efl_gfx_shape_append_arc_to(x, y, rx, ry, angle, large_arc, sweep)); +} + +EAPI void +evas_vg_shape_shape_append_close(Eo *obj) +{ + eo_do(obj, efl_gfx_shape_append_close()); +} + +EAPI void +evas_vg_shape_shape_append_circle(Eo *obj, double x, double y, double radius) +{ + eo_do(obj, efl_gfx_shape_append_circle(x, y, radius)); +} + +EAPI void +evas_vg_shape_shape_append_svg_path(Eo *obj, const char *svg_path_data) +{ + eo_do(obj, efl_gfx_shape_append_svg_path(svg_path_data)); +} + +EAPI Eina_Bool +evas_vg_shape_shape_interpolate(Eo *obj, const Eo *from, const Eo *to, double pos_map) +{ + Eina_Bool ret; + + return eo_do_ret(obj, ret, efl_gfx_shape_interpolate(from, to, pos_map)); +} + +EAPI Eina_Bool +evas_vg_shape_shape_equal_commands(Eo *obj, const Eo *with) +{ + Eina_Bool ret; + + return eo_do_ret(obj, ret, efl_gfx_shape_equal_commands(with)); +} + +#include "efl_vg_shape.eo.c" From ab1f6f79842bfce4f6f9e4f05196850655a6bcb0 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:31:00 +0200 Subject: [PATCH 132/251] evas: set alpha to zero for Efl.VG.Shape.stroke_color. --- src/lib/evas/canvas/evas_vg_shape.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lib/evas/canvas/evas_vg_shape.c b/src/lib/evas/canvas/evas_vg_shape.c index fd63594c2c..35a7d9660b 100644 --- a/src/lib/evas/canvas/evas_vg_shape.c +++ b/src/lib/evas/canvas/evas_vg_shape.c @@ -319,7 +319,6 @@ _efl_vg_shape_eo_base_constructor(Eo *obj, Efl_VG_Shape_Data *pd) 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; nd = eo_data_scope_get(obj, EFL_VG_BASE_CLASS); From 514406dc47b91006ffdbbd6cc8b918096fbf7780 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:31:07 +0200 Subject: [PATCH 133/251] evas: fix switch from MMX to FPU. --- src/modules/evas/engines/software_generic/evas_engine.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/modules/evas/engines/software_generic/evas_engine.c b/src/modules/evas/engines/software_generic/evas_engine.c index 16130875b4..bd40f6d4f4 100644 --- a/src/modules/evas/engines/software_generic/evas_engine.c +++ b/src/modules/evas/engines/software_generic/evas_engine.c @@ -3606,6 +3606,8 @@ _draw_thread_ector_surface_set(void *data) eo_do(_software_ector, ector_cairo_software_surface_set(pixels, w, h)); + evas_common_cpu_end_opt(); + eina_mempool_free(_mp_command_ector_surface, ector_surface); } @@ -3656,6 +3658,8 @@ eng_ector_end(void *data EINA_UNUSED, void *context EINA_UNUSED, void *surface E else { eo_do(_software_ector, ector_cairo_software_surface_set(NULL, 0, 0)); + + evas_common_cpu_end_opt(); } } From ebfcfed59ba273827d69da3067de11dd686f48d3 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:31:08 +0200 Subject: [PATCH 134/251] evas: fix coding style. --- src/lib/evas/canvas/evas_vg_shape.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/evas/canvas/evas_vg_shape.c b/src/lib/evas/canvas/evas_vg_shape.c index 35a7d9660b..627f819069 100644 --- a/src/lib/evas/canvas/evas_vg_shape.c +++ b/src/lib/evas/canvas/evas_vg_shape.c @@ -293,7 +293,7 @@ _efl_vg_shape_render_pre(Eo *obj EINA_UNUSED, if (!nd->renderer) { - eo_do(s, nd->renderer = ector_surface_renderer_factory_new(ECTOR_RENDERER_GENERIC_SHAPE_CLASS)); + nd->renderer = eo_do(s, ector_surface_renderer_factory_new(ECTOR_RENDERER_GENERIC_SHAPE_CLASS)); } eo_do(nd->renderer, From 986704dfb4f70aa4f9b62db0299a21ee57595467 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:31:09 +0200 Subject: [PATCH 135/251] evas: do not track change on root node. --- src/lib/evas/canvas/evas_vg_root_node.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/lib/evas/canvas/evas_vg_root_node.c b/src/lib/evas/canvas/evas_vg_root_node.c index 75a304d6de..b0d93c307c 100644 --- a/src/lib/evas/canvas/evas_vg_root_node.c +++ b/src/lib/evas/canvas/evas_vg_root_node.c @@ -26,9 +26,6 @@ _evas_vg_root_node_render_pre(Eo *obj EINA_UNUSED, Eina_List *l; Eo *child; - if (!nd->changed) return ; - nd->changed = EINA_FALSE; - EFL_VG_COMPUTE_MATRIX(current, parent, nd); EINA_LIST_FOREACH(pd->children, l, child) From 61c1e7d10335e354d85b388887fdb1cd81f22f14 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:31:11 +0200 Subject: [PATCH 136/251] evas: fix initialisation of cairo context in software backend. --- .../engines/software_generic/evas_engine.c | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/modules/evas/engines/software_generic/evas_engine.c b/src/modules/evas/engines/software_generic/evas_engine.c index bd40f6d4f4..04628dbc3a 100644 --- a/src/modules/evas/engines/software_generic/evas_engine.c +++ b/src/modules/evas/engines/software_generic/evas_engine.c @@ -4953,8 +4953,8 @@ void evas_engine_software_generic_shutdown(void) EVAS_EINA_MODULE_DEFINE(engine, software_generic); #endif -#define USE(Obj, Sym, Error) \ - if (!Sym) _ector_cairo_symbol_get(Obj, #Sym); \ +#define USE(Obj, Sym, Error) \ + if (!Sym) Sym = _ector_cairo_symbol_get(Obj, #Sym); \ if (!Sym) return Error; static inline void * @@ -5007,24 +5007,28 @@ _ector_cairo_software_surface_surface_set(Eo *obj, Ector_Cairo_Software_Surface_ USE(obj, cairo_create, ); USE(obj, cairo_destroy, ); - cairo_surface_destroy(pd->surface); pd->surface = NULL; - cairo_destroy(pd->ctx); pd->ctx = NULL; + if (pd->surface) cairo_surface_destroy(pd->surface); pd->surface = NULL; + if (pd->ctx) cairo_destroy(pd->ctx); pd->ctx = NULL; pd->pixels = NULL; pd->width = 0; pd->height = 0; - pd->surface = cairo_image_surface_create_for_data(pixels, CAIRO_FORMAT_ARGB32, width, height, width); - if (pd->surface) goto end; - - pd->ctx = cairo_create(pd->surface); - if (pd->ctx) + if (pixels) { - pd->pixels = pixels; - pd->width = width; - pd->height = height; + pd->surface = cairo_image_surface_create_for_data(pixels, + CAIRO_FORMAT_ARGB32, + width, height, width); + if (!pd->surface) goto end; + + pd->ctx = cairo_create(pd->surface); + if (!pd->ctx) goto end; } + pd->pixels = pixels; + pd->width = width; + pd->height = height; + end: eo_do(obj, ector_cairo_surface_context_set(pd->ctx)); } From fbc22610485ce3c9ff85185c93dc57a00222f0ac Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:31:12 +0200 Subject: [PATCH 137/251] evas: fix creation of cairo context with GL backend. --- .../evas/engines/gl_generic/evas_engine.c | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/modules/evas/engines/gl_generic/evas_engine.c b/src/modules/evas/engines/gl_generic/evas_engine.c index d1d0ff15a9..f3d329d4ec 100644 --- a/src/modules/evas/engines/gl_generic/evas_engine.c +++ b/src/modules/evas/engines/gl_generic/evas_engine.c @@ -2392,8 +2392,8 @@ EVAS_MODULE_DEFINE(EVAS_MODULE_TYPE_ENGINE, engine, gl_generic); EVAS_EINA_MODULE_DEFINE(engine, gl_generic); #endif -#define USE(Obj, Sym, Error) \ - if (!Sym) _ector_cairo_symbol_get(Obj, #Sym); \ +#define USE(Obj, Sym, Error) \ + if (!Sym) Sym = _ector_cairo_symbol_get(Obj, #Sym); \ if (!Sym) return Error; static inline void * @@ -2446,23 +2446,26 @@ _ector_cairo_software_surface_surface_set(Eo *obj, Ector_Cairo_Software_Surface_ USE(obj, cairo_create, ); USE(obj, cairo_destroy, ); - cairo_surface_destroy(pd->surface); pd->surface = NULL; - cairo_destroy(pd->ctx); pd->ctx = NULL; + if (pd->surface) cairo_surface_destroy(pd->surface); pd->surface = NULL; + if (pd->ctx) cairo_destroy(pd->ctx); pd->ctx = NULL; pd->pixels = NULL; pd->width = 0; pd->height = 0; - pd->surface = cairo_image_surface_create_for_data(pixels, CAIRO_FORMAT_ARGB32, width, height, width); - if (pd->surface) goto end; - - pd->ctx = cairo_create(pd->surface); - if (pd->ctx) + if (pixels) { - pd->pixels = pixels; - pd->width = width; - pd->height = height; + pd->surface = cairo_image_surface_create_for_data(pixels, + CAIRO_FORMAT_ARGB32, + width, height, width); + if (!pd->surface) goto end; + + pd->ctx = cairo_create(pd->surface); + if (!pd->ctx) goto end; } + pd->pixels = pixels; + pd->width = width; + pd->height = height; end: eo_do(obj, ector_cairo_surface_context_set(pd->ctx)); From fbeca90de45513e78aaf978929e0031e9815d403 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:31:13 +0200 Subject: [PATCH 138/251] ector: fix Eina_Log domain to be usable outside of main. --- src/lib/ector/ector_main.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/lib/ector/ector_main.c b/src/lib/ector/ector_main.c index 5f09214bf4..fa7413eb37 100644 --- a/src/lib/ector/ector_main.c +++ b/src/lib/ector/ector_main.c @@ -22,7 +22,7 @@ #include #include "ector_private.h" -int _ector_log_dom = 0; +int _ector_log_dom_global = 0; static int _ector_main_count = 0; @@ -35,8 +35,8 @@ ector_init(void) eina_init(); eo_init(); - _ector_log_dom = eina_log_domain_register("ector", ECTOR_DEFAULT_LOG_COLOR); - if (_ector_log_dom < 0) + _ector_log_dom_global = eina_log_domain_register("ector", ECTOR_DEFAULT_LOG_COLOR); + if (_ector_log_dom_global < 0) { EINA_LOG_ERR("Could not register log domain: ector"); goto on_error; @@ -44,7 +44,7 @@ ector_init(void) _ector_main_count = 1; - eina_log_timing(_ector_log_dom, EINA_LOG_STATE_STOP, EINA_LOG_STATE_INIT); + eina_log_timing(_ector_log_dom_global, EINA_LOG_STATE_STOP, EINA_LOG_STATE_INIT); return _ector_main_count; @@ -68,13 +68,13 @@ ector_shutdown(void) if (EINA_LIKELY(_ector_main_count > 0)) return _ector_main_count; - eina_log_timing(_ector_log_dom, + eina_log_timing(_ector_log_dom_global, EINA_LOG_STATE_START, EINA_LOG_STATE_SHUTDOWN); eo_shutdown(); - eina_log_domain_unregister(_ector_log_dom); + eina_log_domain_unregister(_ector_log_dom_global); eina_shutdown(); return _ector_main_count; From e4330ea220535c3201dd6d78f262be6ad572f746 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:31:15 +0200 Subject: [PATCH 139/251] ector: fix inheritance of Ector.Generic.Shape. --- src/lib/ector/ector_renderer_generic_shape.eo | 1 + src/lib/ector/ector_renderer_shape.c | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/lib/ector/ector_renderer_generic_shape.eo b/src/lib/ector/ector_renderer_generic_shape.eo index 7dd30d8506..06baac6aad 100644 --- a/src/lib/ector/ector_renderer_generic_shape.eo +++ b/src/lib/ector/ector_renderer_generic_shape.eo @@ -32,6 +32,7 @@ class Ector.Renderer.Generic.Shape (Ector.Renderer.Generic.Base, Efl.Gfx.Shape) } } implements { + Ector.Renderer.Generic.Base.prepare; Efl.Gfx.Shape.stroke_scale; Efl.Gfx.Shape.stroke_color; Efl.Gfx.Shape.stroke_width; diff --git a/src/lib/ector/ector_renderer_shape.c b/src/lib/ector/ector_renderer_shape.c index 106333a747..f76a5c71c9 100644 --- a/src/lib/ector/ector_renderer_shape.c +++ b/src/lib/ector/ector_renderer_shape.c @@ -183,16 +183,30 @@ _ector_renderer_generic_shape_efl_gfx_shape_stroke_join_get(Eo *obj EINA_UNUSED, return pd->stroke.join; } +static Eina_Bool +_ector_renderer_generic_shape_ector_renderer_generic_base_prepare(Eo *obj, + Ector_Renderer_Generic_Shape_Data *pd) +{ + if (pd->fill) + eo_do(pd->fill, ector_renderer_prepare()); + if (pd->stroke.fill) + eo_do(pd->stroke.fill, ector_renderer_prepare()); + if (pd->stroke.marker) + eo_do(pd->stroke.marker, ector_renderer_prepare()); +} + static void _ector_renderer_generic_shape_eo_base_constructor(Eo *obj, Ector_Renderer_Generic_Shape_Data *pd) { + eo_do_super(obj, ECTOR_RENDERER_GENERIC_SHAPE_CLASS, eo_constructor()); } static void _ector_renderer_generic_shape_eo_base_destructor(Eo *obj, Ector_Renderer_Generic_Shape_Data *pd) { + eo_do_super(obj, ECTOR_RENDERER_GENERIC_SHAPE_CLASS, eo_destructor()); } #include "ector_renderer_generic_shape.eo.c" From 5ef81292a16155fc88592fa88d2882e08542378a Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:31:17 +0200 Subject: [PATCH 140/251] ector: fix setting context to always have one available. --- src/lib/ector/cairo/ector_cairo_private.h | 6 ++- src/lib/ector/cairo/ector_cairo_surface.c | 45 ++++++++++++++++++++--- 2 files changed, 43 insertions(+), 8 deletions(-) diff --git a/src/lib/ector/cairo/ector_cairo_private.h b/src/lib/ector/cairo/ector_cairo_private.h index eef2d10436..14277a744b 100644 --- a/src/lib/ector/cairo/ector_cairo_private.h +++ b/src/lib/ector/cairo/ector_cairo_private.h @@ -7,12 +7,14 @@ typedef struct _Ector_Cairo_Surface_Data Ector_Cairo_Surface_Data; struct _Ector_Cairo_Surface_Data { cairo_t *cairo; + + Eina_Bool internal : 1; }; #define CHECK_CAIRO(Parent) (!(Parent && Parent->cairo)) -#define USE(Obj, Sym, Error) \ - if (!Sym) _ector_cairo_symbol_get(Obj, #Sym); \ +#define USE(Obj, Sym, Error) \ + if (!Sym) Sym = _ector_cairo_symbol_get(Obj, #Sym); \ if (!Sym) return Error; static inline void * diff --git a/src/lib/ector/cairo/ector_cairo_surface.c b/src/lib/ector/cairo/ector_cairo_surface.c index 6a89282788..2cb9cb0a32 100644 --- a/src/lib/ector/cairo/ector_cairo_surface.c +++ b/src/lib/ector/cairo/ector_cairo_surface.c @@ -45,26 +45,57 @@ _ector_cairo_surface_symbol_get(Eo *obj EINA_UNUSED, return eina_module_symbol_get(_cairo_so, name); } +#undef USE +#define USE(Obj, Sym, Error) \ + if (!Sym) Sym = _ector_cairo_surface_symbol_get(Obj, NULL, #Sym); \ + if (!Sym) return Error; static Ector_Renderer * _ector_cairo_surface_ector_generic_surface_renderer_factory_new(Eo *obj, Ector_Cairo_Surface_Data *pd EINA_UNUSED, const Eo_Class *type) { - if (eo_isa(type, ECTOR_RENDERER_CAIRO_SHAPE_CLASS)) + if (type == ECTOR_RENDERER_GENERIC_SHAPE_CLASS) return eo_add(ECTOR_RENDERER_CAIRO_SHAPE_CLASS, obj); - else if (eo_isa(type, ECTOR_RENDERER_CAIRO_GRADIENT_LINEAR_CLASS)) + else if (type == ECTOR_RENDERER_GENERIC_GRADIENT_LINEAR_CLASS) return eo_add(ECTOR_RENDERER_CAIRO_GRADIENT_LINEAR_CLASS, obj); - else if (eo_isa(type, ECTOR_RENDERER_CAIRO_GRADIENT_RADIAL_CLASS)) + else if (type == ECTOR_RENDERER_GENERIC_GRADIENT_RADIAL_CLASS) return eo_add(ECTOR_RENDERER_CAIRO_GRADIENT_RADIAL_CLASS, obj); return NULL; } +typedef struct _cairo_surface_t cairo_surface_t; + +static void (*cairo_destroy)(cairo_t *cr) = NULL; +static cairo_surface_t *(*cairo_image_surface_create)(int format, + int width, + int height) = NULL; +static cairo_t *(*cairo_create)(cairo_surface_t *target) = NULL; + +static cairo_surface_t *internal = NULL; + static void -_ector_cairo_surface_context_set(Eo *obj EINA_UNUSED, +_ector_cairo_surface_context_set(Eo *obj, Ector_Cairo_Surface_Data *pd, cairo_t *ctx) { + if (pd->internal) + { + USE(obj, cairo_destroy, ); + + if (pd->cairo) cairo_destroy(pd->cairo); + pd->internal = EINA_FALSE; + } + if (!ctx) + { + USE(obj, cairo_image_surface_create, ); + USE(obj, cairo_create, ); + + fprintf(stderr, "tada\n"); + + if (!internal) internal = cairo_image_surface_create(0, 1, 1); + ctx = cairo_create(internal); + } pd->cairo = ctx; } @@ -76,11 +107,13 @@ _ector_cairo_surface_context_get(Eo *obj EINA_UNUSED, } static void -_ector_cairo_surface_eo_base_constructor(Eo *obj EINA_UNUSED, - Ector_Cairo_Surface_Data *pd EINA_UNUSED) +_ector_cairo_surface_eo_base_constructor(Eo *obj, + Ector_Cairo_Surface_Data *pd) { eo_do_super(obj, ECTOR_CAIRO_SURFACE_CLASS, eo_constructor()); _cairo_count++; + + _ector_cairo_surface_context_set(obj, pd, NULL); } static void From 4f98cab04dc653904235eb2637d1bed9e14a23f3 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:31:18 +0200 Subject: [PATCH 141/251] ector: fix inheritance in cairo backend. --- .../ector/cairo/ector_renderer_cairo_gradient_linear.eo | 2 +- .../ector/cairo/ector_renderer_cairo_gradient_radial.eo | 2 +- src/lib/ector/cairo/ector_renderer_cairo_shape.c | 9 ++------- src/lib/ector/cairo/ector_renderer_cairo_shape.eo | 2 +- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.eo b/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.eo index 11914ab720..c7a6a5842d 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.eo +++ b/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.eo @@ -1,4 +1,4 @@ -class Ector.Renderer.Cairo.Gradient_Linear (Ector.Renderer.Cairo.Base, Ector.Renderer.Generic.Gradient_Linear) +class Ector.Renderer.Cairo.Gradient_Linear (Ector.Renderer.Generic.Gradient_Linear, Ector.Renderer.Cairo.Base) { eo_prefix: ector_renderer_cairo_gradient_linear; legacy_prefix: null; diff --git a/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.eo b/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.eo index c3322f851b..91a2f42c6a 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.eo +++ b/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.eo @@ -1,4 +1,4 @@ -class Ector.Renderer.Cairo.Gradient_Radial (Ector.Renderer.Cairo.Base, Ector.Renderer.Generic.Gradient_Radial) +class Ector.Renderer.Cairo.Gradient_Radial (Ector.Renderer.Generic.Gradient_Radial, Ector.Renderer.Cairo.Base) { eo_prefix: ector_renderer_cairo_gradient_radial; legacy_prefix: null; diff --git a/src/lib/ector/cairo/ector_renderer_cairo_shape.c b/src/lib/ector/cairo/ector_renderer_cairo_shape.c index eeb366b0c0..efbb4ca76a 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_shape.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_shape.c @@ -51,13 +51,6 @@ _ector_renderer_cairo_shape_ector_renderer_generic_base_prepare(Eo *obj, Ector_R const Efl_Gfx_Path_Command *cmds = NULL; const double *pts = NULL; - // FIXME: shouldn't that be part of the shape generic implementation ? - if (pd->shape->fill) - eo_do(pd->shape->fill, ector_renderer_prepare()); - if (pd->shape->stroke.fill) - eo_do(pd->shape->stroke.fill, ector_renderer_prepare()); - if (pd->shape->stroke.marker) - eo_do(pd->shape->stroke.marker, ector_renderer_prepare()); eo_do_super(obj, ECTOR_RENDERER_CAIRO_SHAPE_CLASS, ector_renderer_prepare()); // shouldn't that be moved to the cairo base object @@ -178,6 +171,8 @@ _ector_renderer_cairo_shape_ector_renderer_cairo_base_fill(Eo *obj, Ector_Render { // FIXME: let's find out how to fill a shape with a shape later. // I need to read SVG specification and see how to map that with cairo. + ERR("fill with shape not implemented\n"); + return EINA_FALSE; } static void diff --git a/src/lib/ector/cairo/ector_renderer_cairo_shape.eo b/src/lib/ector/cairo/ector_renderer_cairo_shape.eo index 55bd0495d1..ed16848e5f 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_shape.eo +++ b/src/lib/ector/cairo/ector_renderer_cairo_shape.eo @@ -1,4 +1,4 @@ -class Ector.Renderer.Cairo.Shape (Ector.Renderer.Cairo.Base, Ector.Renderer.Generic.Shape) +class Ector.Renderer.Cairo.Shape (Ector.Renderer.Generic.Shape, Ector.Renderer.Cairo.Base) { eo_prefix: ector_renderer_cairo_shape; legacy_prefix: null; From 99166ff5f60fd61dec8191b5681f766563c9f67d Mon Sep 17 00:00:00 2001 From: ChunEon Park Date: Fri, 3 Apr 2015 16:31:20 +0200 Subject: [PATCH 142/251] evas: add evas_vg_simple example. Signed-off-by: Cedric BAIL --- src/examples/evas/Makefile.am | 17 +- src/examples/evas/evas-vg-simple.c | 617 +++++++++++++++++++++++++++++ 2 files changed, 629 insertions(+), 5 deletions(-) create mode 100644 src/examples/evas/evas-vg-simple.c diff --git a/src/examples/evas/Makefile.am b/src/examples/evas/Makefile.am index ad1893c4f7..165d789852 100644 --- a/src/examples/evas/Makefile.am +++ b/src/examples/evas/Makefile.am @@ -7,12 +7,12 @@ AM_CPPFLAGS = \ -I$(top_builddir)/src/lib/efl/interfaces \ -I$(top_srcdir)/src/lib/eina \ -I$(top_srcdir)/src/lib/eo \ --I$(top_srcdir)/src/lib/evas \ -I$(top_srcdir)/src/lib/ector \ +-I$(top_srcdir)/src/lib/evas \ -I$(top_builddir)/src/lib/eina \ -I$(top_builddir)/src/lib/eo \ --I$(top_builddir)/src/lib/evas \ -I$(top_builddir)/src/lib/ector \ +-I$(top_builddir)/src/lib/evas \ @EVAS_CFLAGS@ EDCS = aspect.edc @@ -54,11 +54,11 @@ ECORE_EVAS_COMMON_LDADD = \ $(top_builddir)/src/lib/efl/libefl.la \ $(top_builddir)/src/lib/eina/libeina.la \ $(top_builddir)/src/lib/eo/libeo.la \ -$(top_builddir)/src/lib/ector/libector.la \ $(top_builddir)/src/lib/ecore/libecore.la \ $(top_builddir)/src/lib/ecore_file/libecore_file.la \ $(top_builddir)/src/lib/ecore_input/libecore_input.la \ $(top_builddir)/src/lib/ecore_evas/libecore_evas.la \ +$(top_builddir)/src/lib/ector/libector.la \ $(top_builddir)/src/lib/evas/libevas.la \ @EVAS_LDFLAGS@ -lm @@ -71,7 +71,9 @@ EDJE_COMMON_CPPFLAGS = \ -I$(top_builddir)/src/lib/eo \ -I$(top_srcdir)/src/lib/eet \ -I$(top_builddir)/src/lib/eet \ +-I$(top_srcdir)/src/lib/ector \ -I$(top_srcdir)/src/lib/evas \ +-I$(top_builddir)/src/lib/ector \ -I$(top_builddir)/src/lib/evas \ -I$(top_srcdir)/src/lib/ecore \ -I$(top_builddir)/src/lib/ecore \ @@ -96,7 +98,6 @@ EDJE_COMMON_LDADD = \ $(top_builddir)/src/lib/eina/libeina.la \ $(top_builddir)/src/lib/eo/libeo.la \ $(top_builddir)/src/lib/eet/libeet.la \ -$(top_builddir)/src/lib/ector/libector.la \ $(top_builddir)/src/lib/evas/libevas.la \ $(top_builddir)/src/lib/ecore/libecore.la \ $(top_builddir)/src/lib/ecore_evas/libecore_evas.la \ @@ -288,6 +289,11 @@ evas_gl_SOURCES = evas-gl.c evas_gl_LDADD = $(ECORE_EVAS_COMMON_LDADD) @EFL_PTHREAD_LIBS@ evas_gl_CPPFLAGS = $(ECORE_EVAS_COMMON_CPPFLAGS) +EXTRA_PROGRAMS += evas_vg_simple +evas_vg_simple_SOURCES = evas-vg-simple.c +evas_vg_simple_LDADD = $(ECORE_EVAS_COMMON_LDADD) +evas_vg_simple_CPPFLAGS = $(ECORE_EVAS_COMMON_CPPFLAGS) + .edc.edj: $(AM_V_EDJ)$(EDJE_CC) $(EDJE_CC_FLAGS) $< $(builddir)/$(@F) @@ -330,7 +336,8 @@ evas-smart-object.c \ evas-stacking.c \ evas-table.c \ evas-multi-touch.c \ -evas-text.c +evas-text.c \ +evas-vg-simple.c DATA_FILES = \ resources/images/enlightenment.png \ diff --git a/src/examples/evas/evas-vg-simple.c b/src/examples/evas/evas-vg-simple.c new file mode 100644 index 0000000000..d90932faf5 --- /dev/null +++ b/src/examples/evas/evas-vg-simple.c @@ -0,0 +1,617 @@ +/** + * Simple Evas example illustrating a custom Evas box object + * + * You'll need at least one engine built for it (excluding the buffer + * one). See stdout/stderr for output. + * + * @verbatim + * gcc -o evas-box evas-box.c `pkg-config --libs --cflags evas ecore ecore-evas eina ector eo efl` + * @endverbatim + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#else +#define PACKAGE_EXAMPLES_DIR "." +#endif + +#define WIDTH 400 +#define HEIGHT 400 + +#ifndef EFL_BETA_API_SUPPORT +#define EFL_BETA_API_SUPPORT 1 +#endif + +#ifndef EFL_EO_API_SUPPORT +#define EFL_EO_API_SUPPORT 1 +#endif + +#include +#include +#include +#include +#include + + +#include +#include + +#define PATH_KAPPA 0.5522847498 +#define PI 3.1415926535 + +typedef struct _Bezier +{ +float x1, y1, x2, y2, x3, y3, x4, y4; +}Bezier; + +typedef struct _Point +{ + int x; + int y; +}Point; + +static +Bezier bezierFromPoints(Point p1, Point p2, + Point p3, Point p4) +{ + Bezier b; + b.x1 = p1.x; + b.y1 = p1.y; + b.x2 = p2.x; + b.y2 = p2.y; + b.x3 = p3.x; + b.y3 = p3.y; + b.x4 = p4.x; + b.y4 = p4.y; + return b; +} + +inline void +parameterSplitLeft(Bezier *b, float t, Bezier *left) +{ + left->x1 = b->x1; + left->y1 = b->y1; + + left->x2 = b->x1 + t * ( b->x2 - b->x1 ); + left->y2 = b->y1 + t * ( b->y2 - b->y1 ); + + left->x3 = b->x2 + t * ( b->x3 - b->x2 ); // temporary holding spot + left->y3 = b->y2 + t * ( b->y3 - b->y2 ); // temporary holding spot + + b->x3 = b->x3 + t * ( b->x4 - b->x3 ); + b->y3 = b->y3 + t * ( b->y4 - b->y3 ); + + b->x2 = left->x3 + t * ( b->x3 - left->x3); + b->y2 = left->y3 + t * ( b->y3 - left->y3); + + left->x3 = left->x2 + t * ( left->x3 - left->x2 ); + left->y3 = left->y2 + t * ( left->y3 - left->y2 ); + + left->x4 = b->x1 = left->x3 + t * (b->x2 - left->x3); + left->y4 = b->y1 = left->y3 + t * (b->y2 - left->y3); +} +static +Bezier bezierOnInterval(Bezier *b, float t0, float t1) +{ + if (t0 == 0 && t1 == 1) + return *b; + + Bezier result; + parameterSplitLeft(b, t0, &result); + float trueT = (t1-t0)/(1-t0); + parameterSplitLeft(b, trueT, &result); + + return result; +} + +inline void +_bezier_coefficients(float t, float *ap, float *bp, float *cp, float *dp) +{ + float a,b,c,d; + float m_t = 1. - t; + b = m_t * m_t; + c = t * t; + d = c * t; + a = b * m_t; + b *= 3. * t; + c *= 3. * m_t; + *ap = a; + *bp = b; + *cp = c; + *dp = d; +} + +static +float _t_for_arc_angle(float angle) +{ + if (angle < 0.00001) + return 0; + + if (angle == 90.0) + return 1; + + float radians = PI * angle / 180; + float cosAngle = cos(radians); + float sinAngle = sin(radians); + + // initial guess + float tc = angle / 90; + // do some iterations of newton's method to approximate cosAngle + // finds the zero of the function b.pointAt(tc).x() - cosAngle + tc -= ((((2-3*PATH_KAPPA) * tc + 3*(PATH_KAPPA-1)) * tc) * tc + 1 - cosAngle) // value + / (((6-9*PATH_KAPPA) * tc + 6*(PATH_KAPPA-1)) * tc); // derivative + tc -= ((((2-3*PATH_KAPPA) * tc + 3*(PATH_KAPPA-1)) * tc) * tc + 1 - cosAngle) // value + / (((6-9*PATH_KAPPA) * tc + 6*(PATH_KAPPA-1)) * tc); // derivative + + // initial guess + float ts = tc; + // do some iterations of newton's method to approximate sinAngle + // finds the zero of the function b.pointAt(tc).y() - sinAngle + ts -= ((((3*PATH_KAPPA-2) * ts - 6*PATH_KAPPA + 3) * ts + 3*PATH_KAPPA) * ts - sinAngle) + / (((9*PATH_KAPPA-6) * ts + 12*PATH_KAPPA - 6) * ts + 3*PATH_KAPPA); + ts -= ((((3*PATH_KAPPA-2) * ts - 6*PATH_KAPPA + 3) * ts + 3*PATH_KAPPA) * ts - sinAngle) + / (((9*PATH_KAPPA-6) * ts + 12*PATH_KAPPA - 6) * ts + 3*PATH_KAPPA); + + // use the average of the t that best approximates cosAngle + // and the t that best approximates sinAngle + float t = 0.5 * (tc + ts); + return t; +} + +static void +_find_ellipse_coords(int x, int y, int w, int h, float angle, float length, + Point* startPoint, Point *endPoint) +{ + if (!w || !h ) { + if (startPoint) + startPoint->x = 0 , startPoint->y = 0; + if (endPoint) + endPoint->x = 0 , endPoint->y = 0; + return; + } + + int w2 = w / 2; + int h2 = h / 2; + + float angles[2] = { angle, angle + length }; + Point *points[2] = { startPoint, endPoint }; + int i =0; + for (i = 0; i < 2; ++i) { + if (!points[i]) + continue; + + float theta = angles[i] - 360 * floor(angles[i] / 360); + float t = theta / 90; + // truncate + int quadrant = (int)t; + t -= quadrant; + + t = _t_for_arc_angle(90 * t); + + // swap x and y? + if (quadrant & 1) + t = 1 - t; + + float a, b, c, d; + _bezier_coefficients(t, &a, &b, &c, &d); + float px = a + b + c*PATH_KAPPA; + float py = d + c + b*PATH_KAPPA; + + // left quadrants + if (quadrant == 1 || quadrant == 2) + px = -px; + + // top quadrants + if (quadrant == 0 || quadrant == 1) + py = -py; + int cx = x+w/2; + int cy = y+h/2; + points[i]->x = cx + w2 * px; + points[i]->y = cy + h2 * py; + } +} + + +//// The return value is the starting point of the arc +static +Point _curves_for_arc(int x, int y, int w, int h, + float startAngle, float sweepLength, + Point *curves, int *point_count) +{ + *point_count = 0; + int w2 = w / 2; + int w2k = w2 * PATH_KAPPA; + + int h2 = h / 2; + int h2k = h2 * PATH_KAPPA; + + Point points[16] = + { + // start point + x + w, y + h2, + + // 0 -> 270 degrees + x + w, y + h2 + h2k, + x + w2 + w2k, y + h, + x + w2, y + h, + + // 270 -> 180 degrees + x + w2 - w2k, y + h, + x, y + h2 + h2k, + x, y + h2, + + // 180 -> 90 degrees + x, y + h2 - h2k, + x + w2 - w2k, y, + x + w2, y, + + // 90 -> 0 degrees + x + w2 + w2k, y, + x + w, y + h2 - h2k, + x + w, y + h2 + }; + + if (sweepLength > 360) sweepLength = 360; + else if (sweepLength < -360) sweepLength = -360; + + // Special case fast paths + if (startAngle == 0) { + if (sweepLength == 360) { + int i; + for (i = 11; i >= 0; --i) + curves[(*point_count)++] = points[i]; + return points[12]; + } else if (sweepLength == -360) { + int i ; + for (i = 1; i <= 12; ++i) + curves[(*point_count)++] = points[i]; + return points[0]; + } + } + + int startSegment = (int)(floor(startAngle / 90)); + int endSegment = (int)(floor((startAngle + sweepLength) / 90)); + + float startT = (startAngle - startSegment * 90) / 90; + float endT = (startAngle + sweepLength - endSegment * 90) / 90; + + int delta = sweepLength > 0 ? 1 : -1; + if (delta < 0) { + startT = 1 - startT; + endT = 1 - endT; + } + + // avoid empty start segment + if (startT == 1.0) { + startT = 0; + startSegment += delta; + } + + // avoid empty end segment + if (endT == 0) { + endT = 1; + endSegment -= delta; + } + + startT = _t_for_arc_angle(startT * 90); + endT = _t_for_arc_angle(endT * 90); + + Eina_Bool splitAtStart = !(fabs(startT) <= 0.00001f); + Eina_Bool splitAtEnd = !(fabs(endT - 1.0) <= 0.00001f); + + const int end = endSegment + delta; + + // empty arc? + if (startSegment == end) { + const int quadrant = 3 - ((startSegment % 4) + 4) % 4; + const int j = 3 * quadrant; + return delta > 0 ? points[j + 3] : points[j]; + } + + + Point startPoint, endPoint; + _find_ellipse_coords(x, y, w, h, startAngle, sweepLength, &startPoint, &endPoint); + int i; + for (i = startSegment; i != end; i += delta) { + const int quadrant = 3 - ((i % 4) + 4) % 4; + const int j = 3 * quadrant; + + Bezier b; + if (delta > 0) + b = bezierFromPoints(points[j + 3], points[j + 2], points[j + 1], points[j]); + else + b = bezierFromPoints(points[j], points[j + 1], points[j + 2], points[j + 3]); + + // empty arc? + if (startSegment == endSegment && (startT == endT)) + return startPoint; + + if (i == startSegment) { + if (i == endSegment && splitAtEnd) + b = bezierOnInterval(&b, startT, endT); + else if (splitAtStart) + b = bezierOnInterval(&b, startT, 1); + } else if (i == endSegment && splitAtEnd) { + b = bezierOnInterval(&b, 0, endT); + } + + // push control points + curves[(*point_count)].x = b.x2; + curves[(*point_count)++].y = b.y2; + curves[(*point_count)].x = b.x3; + curves[(*point_count)++].y = b.y3; + curves[(*point_count)].x = b.x4; + curves[(*point_count)++].y = b.y4; + } + + curves[*(point_count)-1] = endPoint; + + return startPoint; +} + +void _arcto(Efl_Graphics_Path_Command **path_cmd, double **points,int x, int y, int width, int height, int startAngle, int sweepLength) +{ + int point_count; + + Point pts[15]; + Point curve_start = _curves_for_arc(x,y,width,height, startAngle, sweepLength, pts, &point_count); + int cx = x + (width)/2; + int cy = y + (height)/2; + + efl_gfx_path_append_move_to(path_cmd, points, cx, cy); + + efl_gfx_path_append_line_to(path_cmd, points, curve_start.x, curve_start.y); + int i; + for (i=0; i Date: Fri, 3 Apr 2015 16:31:23 +0200 Subject: [PATCH 143/251] evas: fix Evas_VG examples to match new API. --- src/examples/evas/evas-vg-simple.c | 208 ++++++++++++----------------- 1 file changed, 82 insertions(+), 126 deletions(-) diff --git a/src/examples/evas/evas-vg-simple.c b/src/examples/evas/evas-vg-simple.c index d90932faf5..698db11151 100644 --- a/src/examples/evas/evas-vg-simple.c +++ b/src/examples/evas/evas-vg-simple.c @@ -227,28 +227,28 @@ Point _curves_for_arc(int x, int y, int w, int h, Point points[16] = { - // start point - x + w, y + h2, + // start point + { x + w, y + h2 }, - // 0 -> 270 degrees - x + w, y + h2 + h2k, - x + w2 + w2k, y + h, - x + w2, y + h, + // 0 -> 270 degrees + { x + w, y + h2 + h2k }, + { x + w2 + w2k, y + h }, + { x + w2, y + h }, - // 270 -> 180 degrees - x + w2 - w2k, y + h, - x, y + h2 + h2k, - x, y + h2, + // 270 -> 180 degrees + { x + w2 - w2k, y + h }, + { x, y + h2 + h2k }, + { x, y + h2 }, - // 180 -> 90 degrees - x, y + h2 - h2k, - x + w2 - w2k, y, - x + w2, y, + // 180 -> 90 degrees + { x, y + h2 - h2k }, + { x + w2 - w2k, y }, + { x + w2, y }, - // 90 -> 0 degrees - x + w2 + w2k, y, - x + w, y + h2 - h2k, - x + w, y + h2 + // 90 -> 0 degrees + { x + w2 + w2k, y }, + { x + w, y + h2 - h2k }, + { x + w, y + h2 } }; if (sweepLength > 360) sweepLength = 360; @@ -349,35 +349,37 @@ Point _curves_for_arc(int x, int y, int w, int h, return startPoint; } -void _arcto(Efl_Graphics_Path_Command **path_cmd, double **points,int x, int y, int width, int height, int startAngle, int sweepLength) +void _arcto(Evas_VG_Node *obj, int x, int y, int width, int height, int startAngle, int sweepLength) { int point_count; Point pts[15]; - Point curve_start = _curves_for_arc(x,y,width,height, startAngle, sweepLength, pts, &point_count); + Point curve_start = _curves_for_arc(x, y, width, height, startAngle, sweepLength, pts, &point_count); int cx = x + (width)/2; int cy = y + (height)/2; - - efl_gfx_path_append_move_to(path_cmd, points, cx, cy); - - efl_gfx_path_append_line_to(path_cmd, points, curve_start.x, curve_start.y); int i; - for (i=0; i Date: Fri, 3 Apr 2015 16:31:27 +0200 Subject: [PATCH 144/251] evas: migrate Efl.VG example to legacy API. --- src/examples/evas/evas-vg-simple.c | 137 +++++++++++++---------------- 1 file changed, 62 insertions(+), 75 deletions(-) diff --git a/src/examples/evas/evas-vg-simple.c b/src/examples/evas/evas-vg-simple.c index 698db11151..168bb426b1 100644 --- a/src/examples/evas/evas-vg-simple.c +++ b/src/examples/evas/evas-vg-simple.c @@ -349,7 +349,7 @@ Point _curves_for_arc(int x, int y, int w, int h, return startPoint; } -void _arcto(Evas_VG_Node *obj, int x, int y, int width, int height, int startAngle, int sweepLength) +void _arcto(Efl_VG *obj, int x, int y, int width, int height, int startAngle, int sweepLength) { int point_count; @@ -359,27 +359,25 @@ void _arcto(Evas_VG_Node *obj, int x, int y, int width, int height, int startAng int cy = y + (height)/2; int i; - eo_do(obj, - efl_gfx_shape_append_move_to(cx, cy); - - efl_gfx_shape_append_line_to(curve_start.x, curve_start.y); - for (i = 0; i < point_count; i += 3) - { - efl_gfx_shape_append_cubic_to(pts[i+2].x, pts[i+2].y, + evas_vg_shape_shape_append_move_to(obj, cx, cy); + evas_vg_shape_shape_append_line_to(obj, curve_start.x, curve_start.y); + for (i = 0; i < point_count; i += 3) + { + evas_vg_shape_shape_append_cubic_to(obj, + pts[i+2].x, pts[i+2].y, pts[i].x, pts[i].y, pts[i+1].x, pts[i+1].y); - } - efl_gfx_shape_append_close()); + } + evas_vg_shape_shape_append_close(obj); } -void _rect_add(Evas_VG_Node *obj, int x, int y, int w, int h) +void _rect_add(Efl_VG *obj, int x, int y, int w, int h) { - eo_do(obj, - efl_gfx_shape_append_move_to(x, y); - efl_gfx_shape_append_line_to(x + w, y); - efl_gfx_shape_append_line_to(x + w, y +h); - efl_gfx_shape_append_line_to(x, y +h); - efl_gfx_shape_append_close()); + evas_vg_shape_shape_append_move_to(obj, x, y); + evas_vg_shape_shape_append_line_to(obj, x + w, y); + evas_vg_shape_shape_append_line_to(obj, x + w, y +h); + evas_vg_shape_shape_append_line_to(obj, x, y +h); + evas_vg_shape_shape_append_close(obj); } @@ -441,19 +439,18 @@ vector_set(int x, int y, int w, int h) Eina_Matrix3 matrix; eina_matrix3_rotate(&matrix, radian); - Evas_VG_Node *root = evas_object_vg_root_node_get(d.vg); + Efl_VG *root = evas_object_vg_root_node_get(d.vg); //eo_do(root, evas_vg_node_transformation_set(&matrix)); - Evas_VG_Node *bg = eo_add(EVAS_VG_SHAPE_CLASS, root); + Efl_VG *bg = eo_add(EFL_VG_SHAPE_CLASS, root); _rect_add(bg, 0, 0 , vg_w, vg_h); - eo_do(bg, - evas_vg_node_origin_set(0, 0), - efl_gfx_shape_stroke_width_set(1.0), - efl_gfx_color_set(128, 128, 128, 80)); + evas_vg_node_origin_set(bg, 0,0); + evas_vg_shape_stroke_width_set(bg, 1.0); + evas_vg_node_color_set(bg, 80, 80, 80, 80); - Evas_VG_Node *shape = eo_add(EVAS_VG_SHAPE_CLASS, root); - Evas_VG_Node *rgradient = eo_add(EVAS_VG_GRADIENT_RADIAL_CLASS, root); - Evas_VG_Node *lgradient = eo_add(EVAS_VG_GRADIENT_LINEAR_CLASS, root); + Efl_VG *shape = eo_add(EFL_VG_SHAPE_CLASS, root); + Efl_VG *rgradient = eo_add(EFL_VG_GRADIENT_RADIAL_CLASS, root); + Efl_VG *lgradient = eo_add(EFL_VG_GRADIENT_LINEAR_CLASS, root); _arcto(shape, 0, 0, 100, 100, 25, 330); @@ -474,65 +471,56 @@ vector_set(int x, int y, int w, int h) stops[2].a = 255; stops[2].offset = 1; - eo_do(rgradient, - evas_vg_node_origin_set(10,10), - efl_gfx_gradient_stop_set(stops, 3), - efl_gfx_gradient_spread_set(EFL_GFX_GRADIENT_SPREAD_REFLECT), - efl_gfx_gradient_stop_set(stops, 3), - efl_gfx_gradient_radial_center_set(30, 30), - efl_gfx_gradient_radial_radius_set(80)); + evas_vg_node_origin_set(rgradient, 10, 10); + evas_vg_gradient_spread_set(rgradient, EFL_GFX_GRADIENT_SPREAD_REFLECT); + evas_vg_gradient_stop_set(rgradient, stops, 3); + evas_vg_gradient_radial_center_set(rgradient, 30, 30); + evas_vg_gradient_radial_radius_set(rgradient, 80); - eo_do(lgradient, - evas_vg_node_origin_set(10,10), - efl_gfx_gradient_stop_set(stops, 3), - efl_gfx_gradient_spread_set(EFL_GFX_GRADIENT_SPREAD_REFLECT), - efl_gfx_gradient_stop_set(stops, 3), - efl_gfx_gradient_linear_start_set(10,10), - efl_gfx_gradient_linear_end_set(50,50)); + evas_vg_node_origin_set(lgradient, 10, 10); + evas_vg_gradient_stop_set(lgradient, stops, 3); + evas_vg_gradient_spread_set(lgradient, EFL_GFX_GRADIENT_SPREAD_REFLECT); + evas_vg_gradient_stop_set(lgradient, stops, 3); + evas_vg_gradient_linear_start_set(lgradient, 10, 10); + evas_vg_gradient_linear_end_set(lgradient, 50, 50); - eo_do(shape, - evas_vg_node_origin_set(10, 10), - evas_vg_shape_fill_set(rgradient), - efl_gfx_shape_stroke_scale_set(2.0), - efl_gfx_shape_stroke_width_set(1.0), - efl_gfx_color_set(0, 0, 255, 255), - efl_gfx_shape_stroke_color_set(0, 0, 255, 128)); + evas_vg_node_origin_set(shape, 10, 10); + evas_vg_shape_fill_set(shape, rgradient); + evas_vg_shape_stroke_scale_set(shape, 2.0); + evas_vg_shape_stroke_width_set(shape, 1.0); + evas_vg_node_color_set(shape, 0, 0, 255, 255); + evas_vg_shape_stroke_color_set(shape, 0, 0, 255, 128); - Evas_VG_Node *rect = eo_add(EVAS_VG_SHAPE_CLASS, root); + Efl_VG *rect = eo_add(EFL_VG_SHAPE_CLASS, root); _rect_add(rect, 0, 0, 100, 100); - eo_do(rect, - evas_vg_node_origin_set(100, 100), - evas_vg_shape_fill_set(lgradient), - efl_gfx_shape_stroke_width_set(2.0), - efl_gfx_shape_stroke_join_set(EFL_GFX_JOIN_ROUND), - efl_gfx_shape_stroke_color_set(255, 255, 255, 255)); + evas_vg_node_origin_set(rect, 100, 100); + evas_vg_shape_fill_set(rect, lgradient); + evas_vg_shape_stroke_width_set(rect, 2.0); + evas_vg_shape_stroke_join_set(rect, EFL_GFX_JOIN_ROUND); + evas_vg_shape_stroke_color_set(rect, 255, 255, 255, 255); - - Evas_VG_Node *rect1 = eo_add(EVAS_VG_SHAPE_CLASS, root); + Efl_VG *rect1 = eo_add(EFL_VG_SHAPE_CLASS, root); _rect_add(rect1, 0, 0, 70, 70); - eo_do(rect1, - evas_vg_node_origin_set(50, 70), - efl_gfx_shape_stroke_scale_set(2), - efl_gfx_shape_stroke_width_set(8.0), - efl_gfx_shape_stroke_join_set(EFL_GFX_JOIN_ROUND), - efl_gfx_shape_stroke_color_set(0, 100, 80, 100)); + evas_vg_node_origin_set(rect1, 50, 70); + evas_vg_shape_stroke_scale_set(rect1, 2); + evas_vg_shape_stroke_width_set(rect1, 8.0); + evas_vg_shape_stroke_join_set(rect1, EFL_GFX_JOIN_ROUND); + evas_vg_shape_stroke_color_set(rect1, 0, 100, 80, 100); - Evas_VG_Node *circle = eo_add(EVAS_VG_SHAPE_CLASS, root); + Efl_VG *circle = eo_add(EFL_VG_SHAPE_CLASS, root); _arcto(circle, 0, 0, 250, 100, 30, 300); - eo_do(circle, - evas_vg_shape_fill_set(lgradient), - //evas_vg_node_transformation_set(&matrix), - evas_vg_node_origin_set(50,50), - efl_gfx_color_set(50, 0, 0, 50)); + evas_vg_shape_fill_set(circle, lgradient); + //evas_vg_node_transformation_set(&matrix), + evas_vg_node_origin_set(circle, 50,50); + evas_vg_node_color_set(circle, 50, 0, 0, 50); // Foreground - Evas_VG_Node *fg = eo_add(EVAS_VG_SHAPE_CLASS, root); + Efl_VG *fg = eo_add(EFL_VG_SHAPE_CLASS, root); _rect_add(fg, 0, 0, vg_w, vg_h); - eo_do(fg, - evas_vg_node_origin_set(0, 0), - efl_gfx_shape_stroke_width_set(5.0), - efl_gfx_shape_stroke_join_set(EFL_GFX_JOIN_ROUND), - efl_gfx_shape_stroke_color_set(70, 70, 0, 70)); + evas_vg_node_origin_set(fg, 0, 0); + evas_vg_shape_stroke_width_set(fg, 5.0); + evas_vg_shape_stroke_join_set(fg, EFL_GFX_JOIN_ROUND); + evas_vg_shape_stroke_color_set(fg, 70, 70, 0, 70); } int @@ -570,4 +558,3 @@ error: ecore_evas_shutdown(); return -1; } - From 3dea7dbfaf49705e13e2a20f207190a32f6f2de8 Mon Sep 17 00:00:00 2001 From: Subhransu Sekhar Mohanty Date: Fri, 3 Apr 2015 16:31:29 +0200 Subject: [PATCH 145/251] evas: update and propagate Evas_VG_Base transformation. --- src/lib/evas/canvas/evas_vg_private.h | 14 +++++++++----- src/lib/evas/canvas/evas_vg_shape.c | 5 ++++- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/lib/evas/canvas/evas_vg_private.h b/src/lib/evas/canvas/evas_vg_private.h index 8db3396c02..8f5bf4f98b 100644 --- a/src/lib/evas/canvas/evas_vg_private.h +++ b/src/lib/evas/canvas/evas_vg_private.h @@ -57,10 +57,10 @@ _efl_vg_base_changed(Eo *obj) eo_do(obj, eo_event_callback_call(EFL_GFX_CHANGED, NULL)); } -#define EFL_VG_COMPUTE_MATRIX(Current, Parent, Nd) \ - Eina_Matrix3 *Current = Nd->m; \ - Eina_Matrix3 _matrix_tmp; \ - \ +#define EFL_VG_COMPUTE_MATRIX(Current, Parent, Nd) \ + Eina_Matrix3 *Current = Nd->m; \ + Eina_Matrix3 _matrix_tmp, translate; \ + \ if (Parent) \ { \ if (Current) \ @@ -70,7 +70,11 @@ _efl_vg_base_changed(Eo *obj) } \ else \ { \ - Current = Parent; \ + eina_matrix3_translate(&translate, -(Nd->x), -(Nd->y)); \ + eina_matrix3_compose(Parent, &translate, &_matrix_tmp); \ + eina_matrix3_translate(&translate, (Nd->x), (Nd->y)); \ + eina_matrix3_compose(&_matrix_tmp, &translate, &_matrix_tmp); \ + Current = &_matrix_tmp; \ } \ } diff --git a/src/lib/evas/canvas/evas_vg_shape.c b/src/lib/evas/canvas/evas_vg_shape.c index 627f819069..8c1caee8dd 100644 --- a/src/lib/evas/canvas/evas_vg_shape.c +++ b/src/lib/evas/canvas/evas_vg_shape.c @@ -280,10 +280,13 @@ _efl_vg_shape_render_pre(Eo *obj EINA_UNUSED, { Efl_VG_Shape_Data *pd = data; Efl_VG_Base_Data *fill, *stroke_fill, *stroke_marker, *mask; + double xn = nd->x, yn = nd->y ; if (!nd->changed) return ; nd->changed = EINA_FALSE; + if(parent) eina_matrix3_point_transform(parent, nd->x, nd->y, &xn, &yn); + EFL_VG_COMPUTE_MATRIX(current, parent, nd); fill = _evas_vg_render_pre(pd->fill, s, current); @@ -298,7 +301,7 @@ _efl_vg_shape_render_pre(Eo *obj EINA_UNUSED, eo_do(nd->renderer, ector_renderer_transformation_set(current), - ector_renderer_origin_set(nd->x, nd->y), + ector_renderer_origin_set(xn, yn), ector_renderer_color_set(nd->r, nd->g, nd->b, nd->a), ector_renderer_visibility_set(nd->visibility), ector_renderer_mask_set(mask ? mask->renderer : NULL), From 9967da56cabc889d85dee6039c311f854be592af Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:31:31 +0200 Subject: [PATCH 146/251] ector: remove useless printf ! --- src/lib/ector/cairo/ector_cairo_surface.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/lib/ector/cairo/ector_cairo_surface.c b/src/lib/ector/cairo/ector_cairo_surface.c index 2cb9cb0a32..9207a0dffd 100644 --- a/src/lib/ector/cairo/ector_cairo_surface.c +++ b/src/lib/ector/cairo/ector_cairo_surface.c @@ -91,8 +91,6 @@ _ector_cairo_surface_context_set(Eo *obj, USE(obj, cairo_image_surface_create, ); USE(obj, cairo_create, ); - fprintf(stderr, "tada\n"); - if (!internal) internal = cairo_image_surface_create(0, 1, 1); ctx = cairo_create(internal); } From 2821fd58dbf64befdfea55b6b86d95769c8f59a7 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:31:32 +0200 Subject: [PATCH 147/251] ector: on shutdown our ability to find cairo symbol may no be there anymore. --- src/lib/ector/cairo/ector_renderer_cairo_shape.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/lib/ector/cairo/ector_renderer_cairo_shape.c b/src/lib/ector/cairo/ector_renderer_cairo_shape.c index efbb4ca76a..a85cbc0aab 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_shape.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_shape.c @@ -201,15 +201,16 @@ _ector_renderer_cairo_shape_eo_base_destructor(Eo *obj, Ector_Renderer_Cairo_Sha { Eo *parent; - USE(obj, cairo_path_destroy, ); - if (pd->path) cairo_path_destroy(pd->path); - eo_do(obj, parent = eo_parent_get()); eo_data_xunref(parent, pd->parent, obj); eo_data_xunref(obj, pd->shape, obj); eo_data_xunref(obj, pd->base, obj); + eo_do_super(obj, ECTOR_RENDERER_CAIRO_SHAPE_CLASS, eo_destructor()); + + USE(obj, cairo_path_destroy, ); + if (pd->path) cairo_path_destroy(pd->path); } From f41884153f4f9adccdc5af521cc39baf3b41663f Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:31:33 +0200 Subject: [PATCH 148/251] ector: slightly better implementation for gradient radial draw. --- .../ector_renderer_cairo_gradient_radial.c | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c b/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c index c3d0463a6f..69d9155074 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c @@ -15,9 +15,10 @@ static cairo_pattern_t *(*cairo_pattern_create_radial)(double cx0, double cy0, double radius1) = NULL; static void (*cairo_set_source)(cairo_t *cr, cairo_pattern_t *source) = NULL; static void (*cairo_fill)(cairo_t *cr) = NULL; -static void (*cairo_rectangle)(cairo_t *cr, - double x, double y, - double width, double height) = NULL; +static void (*cairo_arc)(cairo_t *cr, + double xc, double yc, + double radius, + double angle1, double angle2) = NULL; static void (*cairo_pattern_add_color_stop_rgba)(cairo_pattern_t *pattern, double offset, double red, double green, double blue, double alpha) = NULL; static void (*cairo_pattern_destroy)(cairo_pattern_t *pattern) = NULL; @@ -71,16 +72,19 @@ _ector_renderer_cairo_gradient_radial_ector_renderer_generic_base_prepare(Eo *ob static Eina_Bool _ector_renderer_cairo_gradient_radial_ector_renderer_generic_base_draw(Eo *obj, Ector_Renderer_Cairo_Gradient_Radial_Data *pd, Ector_Rop op, Eina_Array *clips, int x, int y, unsigned int mul_col) { - Ector_Renderer_Generic_Gradient_Linear_Data *gld; + Ector_Renderer_Generic_Gradient_Radial_Data *gld; // FIXME: don't ignore clipping ! - gld = eo_data_scope_get(obj, ECTOR_RENDERER_GENERIC_GRADIENT_LINEAR_CLASS); - if (!pd->pat || !gld || CHECK_CAIRO(pd->parent)) return EINA_FALSE; + gld = eo_data_scope_get(obj, ECTOR_RENDERER_GENERIC_GRADIENT_RADIAL_CLASS); + if (!pd->pat || !gld) return EINA_FALSE; - USE(obj, cairo_rectangle, EINA_FALSE); + USE(obj, cairo_arc, EINA_FALSE); + USE(obj, cairo_fill, EINA_FALSE); - cairo_rectangle(pd->parent->cairo, gld->start.x - x, gld->start.y - y, - gld->end.x - gld->start.x, gld->end.y - gld->start.y); + cairo_arc(pd->parent->cairo, + gld->radial.x - x, gld->radial.y - y, + gld->radius, + 0, 2 * M_PI); eo_do(obj, ector_renderer_cairo_base_fill()); cairo_fill(pd->parent->cairo); From 976e9de88a90019a02ae5000cf0cf147d66a9959 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:31:35 +0200 Subject: [PATCH 149/251] ector: call eo_do_super on the right gradient class in Ector.Renderer.Cairo.Gradient_Radial. --- src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c b/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c index 69d9155074..fc3ee0c5b0 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c @@ -129,7 +129,7 @@ _ector_renderer_cairo_gradient_radial_efl_gfx_gradient_base_stop_set(Eo *obj, Ec if (pd->pat) cairo_pattern_destroy(pd->pat); pd->pat = NULL; - eo_do_super(obj, ECTOR_RENDERER_CAIRO_GRADIENT_LINEAR_CLASS, + eo_do_super(obj, ECTOR_RENDERER_CAIRO_GRADIENT_RADIAL_CLASS, efl_gfx_gradient_stop_set(colors, length)); } From 98b13ec944af1f987378b9454d0154cb211d741d Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:31:36 +0200 Subject: [PATCH 150/251] ector: do not forget to get cairo symbol in Ector.Renderer.Cairo.Gradient_Linear. --- src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c b/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c index 8ca5457b89..53e6b474d6 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c @@ -75,6 +75,7 @@ _ector_renderer_cairo_gradient_linear_ector_renderer_generic_base_draw(Eo *obj, if (!pd->pat || !gld || CHECK_CAIRO(pd->parent)) return EINA_FALSE; USE(obj, cairo_rectangle, EINA_FALSE); + USE(obj, cairo_fill, EINA_FALSE); cairo_rectangle(pd->parent->cairo, gld->start.x - x, gld->start.y - y, gld->end.x - gld->start.x, From b54897dc27810026d46d7ef48815dea37770504f Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:31:37 +0200 Subject: [PATCH 151/251] ector: remove unecessary check for cairo context. We now maintain an always available context. --- src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c | 4 ++-- src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c b/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c index 53e6b474d6..5f9f9b55df 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c @@ -72,7 +72,7 @@ _ector_renderer_cairo_gradient_linear_ector_renderer_generic_base_draw(Eo *obj, // FIXME: don't ignore clipping ! gld = eo_data_scope_get(obj, ECTOR_RENDERER_GENERIC_GRADIENT_LINEAR_CLASS); - if (!pd->pat || !gld || CHECK_CAIRO(pd->parent)) return EINA_FALSE; + if (!pd->pat || !gld) return EINA_FALSE; USE(obj, cairo_rectangle, EINA_FALSE); USE(obj, cairo_fill, EINA_FALSE); @@ -90,7 +90,7 @@ static Eina_Bool _ector_renderer_cairo_gradient_linear_ector_renderer_cairo_base_fill(Eo *obj, Ector_Renderer_Cairo_Gradient_Linear_Data *pd) { - if (!pd->pat || CHECK_CAIRO(pd->parent)) return EINA_FALSE; + if (!pd->pat) return EINA_FALSE; USE(obj, cairo_set_source, EINA_FALSE); diff --git a/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c b/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c index fc3ee0c5b0..e5fec89006 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c @@ -95,7 +95,7 @@ _ector_renderer_cairo_gradient_radial_ector_renderer_generic_base_draw(Eo *obj, static Eina_Bool _ector_renderer_cairo_gradient_radial_ector_renderer_cairo_base_fill(Eo *obj, Ector_Renderer_Cairo_Gradient_Radial_Data *pd) { - if (!pd->pat || CHECK_CAIRO(pd->parent)) return EINA_FALSE; + if (!pd->pat) return EINA_FALSE; USE(obj, cairo_set_source, EINA_FALSE); From cd1f09d35978f03772814f72cff370e7fa3dfb30 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:31:39 +0200 Subject: [PATCH 152/251] evas: all color in evas are premultiplied, enforce with warning when not. --- src/lib/evas/canvas/evas_vg_node.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/lib/evas/canvas/evas_vg_node.c b/src/lib/evas/canvas/evas_vg_node.c index c368634a5c..c5e96b8dc0 100644 --- a/src/lib/evas/canvas/evas_vg_node.c +++ b/src/lib/evas/canvas/evas_vg_node.c @@ -105,6 +105,26 @@ _efl_vg_base_efl_gfx_base_color_set(Eo *obj EINA_UNUSED, Efl_VG_Base_Data *pd, int r, int g, int b, int a) { + if (r > 255) r = 255; if (r < 0) r = 0; + if (g > 255) g = 255; if (g < 0) g = 0; + if (b > 255) b = 255; if (b < 0) b = 0; + if (a > 255) a = 255; if (a < 0) a = 0; + if (r > a) + { + r = a; + ERR("Evas only handles pre multiplied colors!"); + } + if (g > a) + { + g = a; + ERR("Evas only handles pre multiplied colors!"); + } + if (b > a) + { + b = a; + ERR("Evas only handles pre multiplied colors!"); + } + pd->r = r; pd->g = g; pd->b = b; From af11e81a51d3165fc0393bcf61a654eb697c71a2 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:31:40 +0200 Subject: [PATCH 153/251] ector: remove useless constructor. --- src/lib/ector/ector_renderer_generic_shape.eo | 2 -- src/lib/ector/ector_renderer_shape.c | 15 +-------------- 2 files changed, 1 insertion(+), 16 deletions(-) diff --git a/src/lib/ector/ector_renderer_generic_shape.eo b/src/lib/ector/ector_renderer_generic_shape.eo index 06baac6aad..c4d2bead10 100644 --- a/src/lib/ector/ector_renderer_generic_shape.eo +++ b/src/lib/ector/ector_renderer_generic_shape.eo @@ -40,7 +40,5 @@ class Ector.Renderer.Generic.Shape (Ector.Renderer.Generic.Base, Efl.Gfx.Shape) Efl.Gfx.Shape.stroke_dash; Efl.Gfx.Shape.stroke_cap; Efl.Gfx.Shape.stroke_join; - Eo.Base.constructor; - Eo.Base.destructor; } } \ No newline at end of file diff --git a/src/lib/ector/ector_renderer_shape.c b/src/lib/ector/ector_renderer_shape.c index f76a5c71c9..be662b0f16 100644 --- a/src/lib/ector/ector_renderer_shape.c +++ b/src/lib/ector/ector_renderer_shape.c @@ -193,20 +193,7 @@ _ector_renderer_generic_shape_ector_renderer_generic_base_prepare(Eo *obj, eo_do(pd->stroke.fill, ector_renderer_prepare()); if (pd->stroke.marker) eo_do(pd->stroke.marker, ector_renderer_prepare()); -} - - -static void -_ector_renderer_generic_shape_eo_base_constructor(Eo *obj, - Ector_Renderer_Generic_Shape_Data *pd) -{ - eo_do_super(obj, ECTOR_RENDERER_GENERIC_SHAPE_CLASS, eo_constructor()); -} - -static void -_ector_renderer_generic_shape_eo_base_destructor(Eo *obj, Ector_Renderer_Generic_Shape_Data *pd) -{ - eo_do_super(obj, ECTOR_RENDERER_GENERIC_SHAPE_CLASS, eo_destructor()); + return EINA_TRUE; } #include "ector_renderer_generic_shape.eo.c" From 7d480ac8580b8555cdbb576330a6989a8d760cd7 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:31:41 +0200 Subject: [PATCH 154/251] evas: fix missing initialisation of engine function call. --- src/modules/evas/engines/software_generic/evas_engine.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/modules/evas/engines/software_generic/evas_engine.c b/src/modules/evas/engines/software_generic/evas_engine.c index 04628dbc3a..1ef1f3f2a3 100644 --- a/src/modules/evas/engines/software_generic/evas_engine.c +++ b/src/modules/evas/engines/software_generic/evas_engine.c @@ -3832,7 +3832,10 @@ static Evas_Func func = NULL, // eng_drawable_free NULL, // eng_drawable_size_get NULL, // eng_image_drawable_set - NULL, // eng_drawable_render_scene + NULL, // eng_drawable_scene_render + NULL, // eng_drawable_scene_render_to_texture + NULL, // eng_drawable_texture_color_pick_id_get + NULL, // eng_drawable_texture_pixel_color_get NULL, // eng_texture_new NULL, // eng_texture_free NULL, // eng_texture_data_set From bc016aa27766ac2ec93fff96e4dfdc741cd55347 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:31:43 +0200 Subject: [PATCH 155/251] ector: implement a simple virtual to prepare the mask in Ector.Renderer.Generic.Base. --- src/lib/ector/ector_renderer_base.c | 7 +++++++ src/lib/ector/ector_renderer_generic_base.eo | 1 - 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/lib/ector/ector_renderer_base.c b/src/lib/ector/ector_renderer_base.c index 70b636b861..6db31d352d 100644 --- a/src/lib/ector/ector_renderer_base.c +++ b/src/lib/ector/ector_renderer_base.c @@ -123,4 +123,11 @@ _ector_renderer_generic_base_quality_get(Eo *obj EINA_UNUSED, return pd->q; } +static Eina_Bool +_ector_renderer_generic_base_prepare(Eo *obj, Ector_Renderer_Generic_Base_Data *pd) +{ + if (pd->mask) + eo_do(pd->mask, ector_renderer_prepare()); +} + #include "ector_renderer_generic_base.eo.c" diff --git a/src/lib/ector/ector_renderer_generic_base.eo b/src/lib/ector/ector_renderer_generic_base.eo index 91275d55ee..5e5d6aa3b9 100644 --- a/src/lib/ector/ector_renderer_generic_base.eo +++ b/src/lib/ector/ector_renderer_generic_base.eo @@ -113,7 +113,6 @@ abstract Ector.Renderer.Generic.Base (Eo.Base) implements { @virtual .draw; @virtual .bounds_get; - @virtual .prepare; @virtual .done; } } From e99774946cf596b4527dcba92bbf17798eee9260 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:31:44 +0200 Subject: [PATCH 156/251] ector: implementation of some common code in Ector.Renderer.Cairo.Base. This require to make some class mixin instead of interface or abstract. So a lot of class renaming is also necessary here. --- src/Makefile_Ector.am | 1 + src/lib/ector/cairo/ector_cairo_surface.c | 8 +- .../ector/cairo/ector_renderer_cairo_base.c | 196 ++++++++++++++++++ .../ector/cairo/ector_renderer_cairo_base.eo | 11 +- .../ector_renderer_cairo_gradient_linear.c | 12 +- .../ector_renderer_cairo_gradient_linear.eo | 2 +- .../ector_renderer_cairo_gradient_radial.c | 12 +- .../ector_renderer_cairo_gradient_radial.eo | 2 +- .../ector/cairo/ector_renderer_cairo_shape.c | 16 +- .../ector/cairo/ector_renderer_cairo_shape.eo | 2 +- src/lib/ector/ector_private.h | 46 ++++ .../ector/ector_renderer_generic_gradient.eo | 2 +- .../ector_renderer_generic_gradient_linear.eo | 2 +- .../ector_renderer_generic_gradient_radial.eo | 2 +- src/lib/ector/ector_renderer_generic_shape.eo | 3 +- src/lib/ector/ector_renderer_shape.c | 13 -- src/lib/evas/canvas/evas_vg_gradient_linear.c | 2 +- src/lib/evas/canvas/evas_vg_gradient_radial.c | 2 +- src/lib/evas/canvas/evas_vg_shape.c | 2 +- 19 files changed, 295 insertions(+), 41 deletions(-) create mode 100644 src/lib/ector/cairo/ector_renderer_cairo_base.c diff --git a/src/Makefile_Ector.am b/src/Makefile_Ector.am index 5b0fbd1411..ea063ee6c0 100644 --- a/src/Makefile_Ector.am +++ b/src/Makefile_Ector.am @@ -50,6 +50,7 @@ lib_ector_libector_la_SOURCES += \ lib/ector/cairo/ector_renderer_cairo_gradient_linear.c \ lib/ector/cairo/ector_renderer_cairo_gradient_radial.c \ lib/ector/cairo/ector_renderer_cairo_shape.c \ +lib/ector/cairo/ector_renderer_cairo_base.c \ lib/ector/cairo/ector_cairo_surface.c lib_ector_libector_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl \ diff --git a/src/lib/ector/cairo/ector_cairo_surface.c b/src/lib/ector/cairo/ector_cairo_surface.c index 9207a0dffd..7204eedaf4 100644 --- a/src/lib/ector/cairo/ector_cairo_surface.c +++ b/src/lib/ector/cairo/ector_cairo_surface.c @@ -55,12 +55,13 @@ _ector_cairo_surface_ector_generic_surface_renderer_factory_new(Eo *obj, Ector_Cairo_Surface_Data *pd EINA_UNUSED, const Eo_Class *type) { - if (type == ECTOR_RENDERER_GENERIC_SHAPE_CLASS) + if (type == ECTOR_RENDERER_GENERIC_SHAPE_MIXIN) return eo_add(ECTOR_RENDERER_CAIRO_SHAPE_CLASS, obj); - else if (type == ECTOR_RENDERER_GENERIC_GRADIENT_LINEAR_CLASS) + else if (type == ECTOR_RENDERER_GENERIC_GRADIENT_LINEAR_MIXIN) return eo_add(ECTOR_RENDERER_CAIRO_GRADIENT_LINEAR_CLASS, obj); - else if (type == ECTOR_RENDERER_GENERIC_GRADIENT_RADIAL_CLASS) + else if (type == ECTOR_RENDERER_GENERIC_GRADIENT_RADIAL_MIXIN) return eo_add(ECTOR_RENDERER_CAIRO_GRADIENT_RADIAL_CLASS, obj); + ERR("Couldn't find class for type: %s\n", eo_class_name_get(type)); return NULL; } @@ -126,4 +127,3 @@ _ector_cairo_surface_eo_base_destructor(Eo *obj EINA_UNUSED, } #include "ector_cairo_surface.eo.c" -#include "ector_renderer_cairo_base.eo.c" diff --git a/src/lib/ector/cairo/ector_renderer_cairo_base.c b/src/lib/ector/cairo/ector_renderer_cairo_base.c new file mode 100644 index 0000000000..02d256f001 --- /dev/null +++ b/src/lib/ector/cairo/ector_renderer_cairo_base.c @@ -0,0 +1,196 @@ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include + +#include +#include +#include + +#include "ector_private.h" +#include "ector_cairo_private.h" + +typedef struct { + double xx; double yx; + double xy; double yy; + double x0; double y0; +} cairo_matrix_t; + +typedef enum { + CAIRO_OPERATOR_CLEAR, + + CAIRO_OPERATOR_SOURCE, + CAIRO_OPERATOR_OVER, + CAIRO_OPERATOR_IN, + CAIRO_OPERATOR_OUT, + CAIRO_OPERATOR_ATOP, + + CAIRO_OPERATOR_DEST, + CAIRO_OPERATOR_DEST_OVER, + CAIRO_OPERATOR_DEST_IN, + CAIRO_OPERATOR_DEST_OUT, + CAIRO_OPERATOR_DEST_ATOP, + + CAIRO_OPERATOR_XOR, + CAIRO_OPERATOR_ADD, + CAIRO_OPERATOR_SATURATE, + + CAIRO_OPERATOR_MULTIPLY, + CAIRO_OPERATOR_SCREEN, + CAIRO_OPERATOR_OVERLAY, + CAIRO_OPERATOR_DARKEN, + CAIRO_OPERATOR_LIGHTEN, + CAIRO_OPERATOR_COLOR_DODGE, + CAIRO_OPERATOR_COLOR_BURN, + CAIRO_OPERATOR_HARD_LIGHT, + CAIRO_OPERATOR_SOFT_LIGHT, + CAIRO_OPERATOR_DIFFERENCE, + CAIRO_OPERATOR_EXCLUSION, + CAIRO_OPERATOR_HSL_HUE, + CAIRO_OPERATOR_HSL_SATURATION, + CAIRO_OPERATOR_HSL_COLOR, + CAIRO_OPERATOR_HSL_LUMINOSITY +} cairo_operator_t; + +static void (*cairo_translate)(cairo_t *cr, double tx, double ty) = NULL; +static void (*cairo_matrix_init)(cairo_matrix_t *matrix, + double xx, double yx, + double xy, double yy, + double x0, double y0) = NULL; +static void (*cairo_transform)(cairo_t *cr, const cairo_matrix_t *matrix) = NULL; +static void (*cairo_set_source_rgba)(cairo_t *cr, + double red, double green, double blue, + double alpha) = NULL; +static void (*cairo_set_operator)(cairo_t *cr, cairo_operator_t op) = NULL; + +typedef struct _Ector_Renderer_Cairo_Base_Data Ector_Renderer_Cairo_Base_Data; +struct _Ector_Renderer_Cairo_Base_Data +{ + Ector_Cairo_Surface_Data *parent; + Ector_Renderer_Generic_Base_Data *generic; + + cairo_matrix_t *m; +}; + +// Cairo need unpremul color, so force unpremul here +void +_ector_renderer_cairo_base_ector_renderer_generic_base_color_set(Eo *obj EINA_UNUSED, + Ector_Renderer_Cairo_Base_Data *pd, + int r, int g, int b, int a) +{ + ector_color_argb_unpremul(a, &r ,&g, &b); + pd->generic->color.r = r; + pd->generic->color.g = g; + pd->generic->color.b = b; + pd->generic->color.a = a; +} + +void +_ector_renderer_cairo_base_ector_renderer_generic_base_color_get(Eo *obj EINA_UNUSED, + Ector_Renderer_Cairo_Base_Data *pd, + int *r, int *g, int *b, int *a) +{ + if (r) *r = pd->generic->color.r; + if (g) *g = pd->generic->color.g; + if (b) *b = pd->generic->color.b; + if (a) *a = pd->generic->color.a; + + ector_color_argb_premul(pd->generic->color.a, r, g, b); +} + +static Eina_Bool +_ector_renderer_cairo_base_ector_renderer_generic_base_prepare(Eo *obj, Ector_Renderer_Cairo_Base_Data *pd) +{ + if (!pd->parent) + { + Eo *parent; + + eo_do(obj, parent = eo_parent_get()); + if (!parent) return EINA_FALSE; + pd->parent = eo_data_xref(parent, ECTOR_CAIRO_SURFACE_CLASS, obj); + } + if (pd->generic->m) + { + USE(obj, cairo_matrix_init, EINA_FALSE); + + if (!pd->m) pd->m = malloc(sizeof (cairo_matrix_t)); + cairo_matrix_init(pd->m, + pd->generic->m->xx, pd->generic->m->yx, + pd->generic->m->xy, pd->generic->m->yy, + pd->generic->m->xz, pd->generic->m->yz); + } + else + { + free(pd->m); + pd->m = NULL; + } + + return EINA_TRUE; +} + +static Eina_Bool +_ector_renderer_cairo_base_ector_renderer_generic_base_draw(Eo *obj, + Ector_Renderer_Cairo_Base_Data *pd, + Ector_Rop op, + Eina_Array *clips EINA_UNUSED, + int x, int y, + unsigned int mul_col) +{ + double r, g, b, a; + cairo_operator_t cop; + + USE(obj, cairo_translate, EINA_FALSE); + USE(obj, cairo_set_source_rgba, EINA_FALSE); + USE(obj, cairo_transform, EINA_FALSE); + USE(obj, cairo_set_operator, EINA_FALSE); + + switch (op) + { + case ECTOR_ROP_BLEND: + cop = CAIRO_OPERATOR_OVER; + break; + case ECTOR_ROP_COPY: + default: + cop = CAIRO_OPERATOR_SOURCE; + break; + } + + r = ((double)((pd->generic->color.r * R_VAL(&mul_col)) / 255)) / 255; + g = ((double)((pd->generic->color.g * G_VAL(&mul_col)) / 255)) / 255; + b = ((double)((pd->generic->color.b * B_VAL(&mul_col)) / 255)) / 255; + a = ((double)((pd->generic->color.a * A_VAL(&mul_col)) / 255)) / 255; + + cairo_set_operator(pd->parent->cairo, cop); + cairo_translate(pd->parent->cairo, pd->generic->origin.x - x, pd->generic->origin.y - y); + cairo_set_source_rgba(pd->parent->cairo, r, g, b, a); + if (pd->m) cairo_transform(pd->parent->cairo, pd->m); + else cairo_transform(pd->parent->cairo, NULL); + + return EINA_TRUE; +} + +static void +_ector_renderer_cairo_base_eo_base_constructor(Eo *obj, Ector_Renderer_Cairo_Base_Data *pd EINA_UNUSED) +{ + eo_do_super(obj, ECTOR_RENDERER_CAIRO_BASE_CLASS, eo_constructor()); + + pd->generic = eo_data_xref(obj, ECTOR_RENDERER_GENERIC_BASE_CLASS, obj); +} + +static void +_ector_renderer_cairo_base_eo_base_destructor(Eo *obj, Ector_Renderer_Cairo_Base_Data *pd) +{ + Eo *parent; + + free(pd->m); + + eo_do(obj, parent = eo_parent_get()); + eo_data_xunref(parent, pd->parent, obj); + eo_data_xunref(obj, pd->generic, obj); + + eo_do_super(obj, ECTOR_RENDERER_CAIRO_BASE_CLASS, eo_destructor()); +} + +#include "ector_renderer_cairo_base.eo.c" diff --git a/src/lib/ector/cairo/ector_renderer_cairo_base.eo b/src/lib/ector/cairo/ector_renderer_cairo_base.eo index 70757108ff..c34b9a847b 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_base.eo +++ b/src/lib/ector/cairo/ector_renderer_cairo_base.eo @@ -1,4 +1,4 @@ -interface Ector.Renderer.Cairo.Base +abstract Ector.Renderer.Cairo.Base (Ector.Renderer.Generic.Base) { legacy_prefix: null; methods { @@ -6,4 +6,13 @@ interface Ector.Renderer.Cairo.Base return: bool; } } + implements { + @virtual .fill; + Ector.Renderer.Generic.Base.prepare; + Ector.Renderer.Generic.Base.draw; + Ector.Renderer.Generic.Base.color.set; + Ector.Renderer.Generic.Base.color.get; + Eo.Base.constructor; + Eo.Base.destructor; + } } diff --git a/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c b/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c index 5f9f9b55df..e00ed6d8c0 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c @@ -35,10 +35,12 @@ _ector_renderer_cairo_gradient_linear_ector_renderer_generic_base_prepare(Eo *ob Ector_Renderer_Generic_Gradient_Data *gd; unsigned int i; + eo_do_super(obj, ECTOR_RENDERER_CAIRO_GRADIENT_LINEAR_CLASS, ector_renderer_prepare()); + if (pd->pat) return EINA_FALSE; - gld = eo_data_scope_get(obj, ECTOR_RENDERER_GENERIC_GRADIENT_LINEAR_CLASS); - gd = eo_data_scope_get(obj, ECTOR_RENDERER_GENERIC_GRADIENT_CLASS); + gld = eo_data_scope_get(obj, ECTOR_RENDERER_GENERIC_GRADIENT_LINEAR_MIXIN); + gd = eo_data_scope_get(obj, ECTOR_RENDERER_GENERIC_GRADIENT_MIXIN); if (!gld || !gd) return EINA_FALSE; USE(obj, cairo_pattern_create_linear, EINA_FALSE); @@ -71,13 +73,15 @@ _ector_renderer_cairo_gradient_linear_ector_renderer_generic_base_draw(Eo *obj, Ector_Renderer_Generic_Gradient_Linear_Data *gld; // FIXME: don't ignore clipping ! - gld = eo_data_scope_get(obj, ECTOR_RENDERER_GENERIC_GRADIENT_LINEAR_CLASS); + gld = eo_data_scope_get(obj, ECTOR_RENDERER_GENERIC_GRADIENT_LINEAR_MIXIN); if (!pd->pat || !gld) return EINA_FALSE; + eo_do_super(obj, ECTOR_RENDERER_CAIRO_GRADIENT_LINEAR_CLASS, ector_renderer_draw(op, clips, x, y, mul_col)); + USE(obj, cairo_rectangle, EINA_FALSE); USE(obj, cairo_fill, EINA_FALSE); - cairo_rectangle(pd->parent->cairo, gld->start.x - x, gld->start.y - y, + cairo_rectangle(pd->parent->cairo, gld->start.x, gld->start.y, gld->end.x - gld->start.x, gld->end.y - gld->start.y); eo_do(obj, ector_renderer_cairo_base_fill()); diff --git a/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.eo b/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.eo index c7a6a5842d..3d4ed9a5d1 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.eo +++ b/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.eo @@ -1,4 +1,4 @@ -class Ector.Renderer.Cairo.Gradient_Linear (Ector.Renderer.Generic.Gradient_Linear, Ector.Renderer.Cairo.Base) +class Ector.Renderer.Cairo.Gradient_Linear (Ector.Renderer.Cairo.Base, Ector.Renderer.Generic.Gradient, Ector.Renderer.Generic.Gradient_Linear) { eo_prefix: ector_renderer_cairo_gradient_linear; legacy_prefix: null; diff --git a/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c b/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c index e5fec89006..a219375f93 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c @@ -40,10 +40,12 @@ _ector_renderer_cairo_gradient_radial_ector_renderer_generic_base_prepare(Eo *ob Ector_Renderer_Generic_Gradient_Data *gd; unsigned int i; + eo_do_super(obj, ECTOR_RENDERER_CAIRO_GRADIENT_RADIAL_CLASS, ector_renderer_prepare()); + if (pd->pat) return EINA_FALSE; - grd = eo_data_scope_get(obj, ECTOR_RENDERER_GENERIC_GRADIENT_RADIAL_CLASS); - gd = eo_data_scope_get(obj, ECTOR_RENDERER_GENERIC_GRADIENT_CLASS); + grd = eo_data_scope_get(obj, ECTOR_RENDERER_GENERIC_GRADIENT_RADIAL_MIXIN); + gd = eo_data_scope_get(obj, ECTOR_RENDERER_GENERIC_GRADIENT_MIXIN); if (!grd || !gd) return EINA_FALSE; USE(obj, cairo_pattern_create_radial, EINA_FALSE); @@ -75,14 +77,16 @@ _ector_renderer_cairo_gradient_radial_ector_renderer_generic_base_draw(Eo *obj, Ector_Renderer_Generic_Gradient_Radial_Data *gld; // FIXME: don't ignore clipping ! - gld = eo_data_scope_get(obj, ECTOR_RENDERER_GENERIC_GRADIENT_RADIAL_CLASS); + gld = eo_data_scope_get(obj, ECTOR_RENDERER_GENERIC_GRADIENT_RADIAL_MIXIN); if (!pd->pat || !gld) return EINA_FALSE; + eo_do_super(obj, ECTOR_RENDERER_CAIRO_GRADIENT_RADIAL_CLASS, ector_renderer_draw(op, clips, x, y, mul_col)); + USE(obj, cairo_arc, EINA_FALSE); USE(obj, cairo_fill, EINA_FALSE); cairo_arc(pd->parent->cairo, - gld->radial.x - x, gld->radial.y - y, + gld->radial.x, gld->radial.y, gld->radius, 0, 2 * M_PI); eo_do(obj, ector_renderer_cairo_base_fill()); diff --git a/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.eo b/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.eo index 91a2f42c6a..fb79bec7d5 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.eo +++ b/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.eo @@ -1,4 +1,4 @@ -class Ector.Renderer.Cairo.Gradient_Radial (Ector.Renderer.Generic.Gradient_Radial, Ector.Renderer.Cairo.Base) +class Ector.Renderer.Cairo.Gradient_Radial (Ector.Renderer.Cairo.Base, Ector.Renderer.Generic.Gradient, Ector.Renderer.Generic.Gradient_Radial) { eo_prefix: ector_renderer_cairo_gradient_radial; legacy_prefix: null; diff --git a/src/lib/ector/cairo/ector_renderer_cairo_shape.c b/src/lib/ector/cairo/ector_renderer_cairo_shape.c index a85cbc0aab..a3fd1070c2 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_shape.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_shape.c @@ -53,6 +53,13 @@ _ector_renderer_cairo_shape_ector_renderer_generic_base_prepare(Eo *obj, Ector_R eo_do_super(obj, ECTOR_RENDERER_CAIRO_SHAPE_CLASS, ector_renderer_prepare()); + if (pd->shape->fill) + eo_do(pd->shape->fill, ector_renderer_prepare()); + if (pd->shape->stroke.fill) + eo_do(pd->shape->stroke.fill, ector_renderer_prepare()); + if (pd->shape->stroke.marker) + eo_do(pd->shape->stroke.marker, ector_renderer_prepare()); + // shouldn't that be moved to the cairo base object if (!pd->parent) { @@ -125,8 +132,7 @@ _ector_renderer_cairo_shape_ector_renderer_generic_base_draw(Eo *obj, Ector_Rend { if (pd->path == NULL) return EINA_FALSE; - // FIXME: find a way to offset the drawing and setting multiple clips - + // FIXME: find a way to set multiple clips eo_do_super(obj, ECTOR_RENDERER_CAIRO_SHAPE_CLASS, ector_renderer_draw(op, clips, x, y, mul_col)); USE(obj, cairo_new_path, EINA_FALSE); @@ -167,10 +173,12 @@ _ector_renderer_cairo_shape_ector_renderer_generic_base_draw(Eo *obj, Ector_Rend } static Eina_Bool -_ector_renderer_cairo_shape_ector_renderer_cairo_base_fill(Eo *obj, Ector_Renderer_Cairo_Shape_Data *pd) +_ector_renderer_cairo_shape_ector_renderer_cairo_base_fill(Eo *obj EINA_UNUSED, + Ector_Renderer_Cairo_Shape_Data *pd EINA_UNUSED) { // FIXME: let's find out how to fill a shape with a shape later. // I need to read SVG specification and see how to map that with cairo. +#warning "fill for a shape object is unhandled at this moment in cairo backend." ERR("fill with shape not implemented\n"); return EINA_FALSE; } @@ -192,7 +200,7 @@ void _ector_renderer_cairo_shape_eo_base_constructor(Eo *obj, Ector_Renderer_Cairo_Shape_Data *pd) { eo_do_super(obj, ECTOR_RENDERER_CAIRO_SHAPE_CLASS, eo_constructor()); - pd->shape = eo_data_xref(obj, ECTOR_RENDERER_GENERIC_SHAPE_CLASS, obj); + pd->shape = eo_data_xref(obj, ECTOR_RENDERER_GENERIC_SHAPE_MIXIN, obj); pd->base = eo_data_xref(obj, ECTOR_RENDERER_GENERIC_BASE_CLASS, obj); } diff --git a/src/lib/ector/cairo/ector_renderer_cairo_shape.eo b/src/lib/ector/cairo/ector_renderer_cairo_shape.eo index ed16848e5f..55bd0495d1 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_shape.eo +++ b/src/lib/ector/cairo/ector_renderer_cairo_shape.eo @@ -1,4 +1,4 @@ -class Ector.Renderer.Cairo.Shape (Ector.Renderer.Generic.Shape, Ector.Renderer.Cairo.Base) +class Ector.Renderer.Cairo.Shape (Ector.Renderer.Cairo.Base, Ector.Renderer.Generic.Shape) { eo_prefix: ector_renderer_cairo_shape; legacy_prefix: null; diff --git a/src/lib/ector/ector_private.h b/src/lib/ector/ector_private.h index 2974b359ab..49f772b9c0 100644 --- a/src/lib/ector/ector_private.h +++ b/src/lib/ector/ector_private.h @@ -36,6 +36,52 @@ extern int _ector_log_dom_global; #endif /* ifdef CRI */ #define CRI(...) EINA_LOG_DOM_CRIT(_ector_log_dom_global, __VA_ARGS__) +typedef unsigned char DATA8; +typedef unsigned short DATA16; + +#ifndef WORDS_BIGENDIAN +/* x86 */ +#define A_VAL(p) (((DATA8 *)(p))[3]) +#define R_VAL(p) (((DATA8 *)(p))[2]) +#define G_VAL(p) (((DATA8 *)(p))[1]) +#define B_VAL(p) (((DATA8 *)(p))[0]) +#define AR_VAL(p) ((DATA16 *)(p)[1]) +#define GB_VAL(p) ((DATA16 *)(p)[0]) +#else +/* ppc */ +#define A_VAL(p) (((DATA8 *)(p))[0]) +#define R_VAL(p) (((DATA8 *)(p))[1]) +#define G_VAL(p) (((DATA8 *)(p))[2]) +#define B_VAL(p) (((DATA8 *)(p))[3]) +#define AR_VAL(p) ((DATA16 *)(p)[0]) +#define GB_VAL(p) ((DATA16 *)(p)[1]) +#endif + +#define RGB_JOIN(r,g,b) \ + (((r) << 16) + ((g) << 8) + (b)) + +#define ARGB_JOIN(a,r,g,b) \ + (((a) << 24) + ((r) << 16) + ((g) << 8) + (b)) + +static inline void +ector_color_argb_premul(int a, int *r, int *g, int *b) +{ + a++; + if (r) { *r = (a * *r) >> 8; } + if (g) { *g = (a * *g) >> 8; } + if (b) { *b = (a * *b) >> 8; } +} + +static inline void +ector_color_argb_unpremul(int a, int *r, int *g, int *b) +{ + if (!a) return; + if (r) { *r = (255 * *r) / a; } + if (g) { *g = (255 * *g) / a; } + if (b) { *b = (255 * *b) / a; } +} + + static inline void _ector_renderer_replace(Ector_Renderer **d, const Ector_Renderer *s) { diff --git a/src/lib/ector/ector_renderer_generic_gradient.eo b/src/lib/ector/ector_renderer_generic_gradient.eo index bc50524abd..2c0cc83894 100644 --- a/src/lib/ector/ector_renderer_generic_gradient.eo +++ b/src/lib/ector/ector_renderer_generic_gradient.eo @@ -1,4 +1,4 @@ -abstract Ector.Renderer.Generic.Gradient (Ector.Renderer.Generic.Base, Efl.Gfx.Gradient.Base) +mixin Ector.Renderer.Generic.Gradient (Efl.Gfx.Gradient.Base) { eo_prefix: ector_renderer_gradient; legacy_prefix: null; diff --git a/src/lib/ector/ector_renderer_generic_gradient_linear.eo b/src/lib/ector/ector_renderer_generic_gradient_linear.eo index 82d560bba0..13ab2e6bfc 100644 --- a/src/lib/ector/ector_renderer_generic_gradient_linear.eo +++ b/src/lib/ector/ector_renderer_generic_gradient_linear.eo @@ -1,4 +1,4 @@ -abstract Ector.Renderer.Generic.Gradient_Linear (Ector.Renderer.Generic.Gradient, Efl.Gfx.Gradient.Linear) +mixin Ector.Renderer.Generic.Gradient_Linear (Efl.Gfx.Gradient.Linear) { eo_prefix: ector_renderer_gradient_linear; legacy_prefix: null; diff --git a/src/lib/ector/ector_renderer_generic_gradient_radial.eo b/src/lib/ector/ector_renderer_generic_gradient_radial.eo index 5b53dadc01..cef25eb953 100644 --- a/src/lib/ector/ector_renderer_generic_gradient_radial.eo +++ b/src/lib/ector/ector_renderer_generic_gradient_radial.eo @@ -1,4 +1,4 @@ -abstract Ector.Renderer.Generic.Gradient_Radial (Ector.Renderer.Generic.Gradient, Efl.Gfx.Gradient.Radial) +mixin Ector.Renderer.Generic.Gradient_Radial (Efl.Gfx.Gradient.Radial) { eo_prefix: ector_renderer_gradient_radial; legacy_prefix: null; diff --git a/src/lib/ector/ector_renderer_generic_shape.eo b/src/lib/ector/ector_renderer_generic_shape.eo index c4d2bead10..2205b7985c 100644 --- a/src/lib/ector/ector_renderer_generic_shape.eo +++ b/src/lib/ector/ector_renderer_generic_shape.eo @@ -1,4 +1,4 @@ -class Ector.Renderer.Generic.Shape (Ector.Renderer.Generic.Base, Efl.Gfx.Shape) +mixin Ector.Renderer.Generic.Shape (Efl.Gfx.Shape) { eo_prefix: ector_renderer_shape; legacy_prefix: null; @@ -32,7 +32,6 @@ class Ector.Renderer.Generic.Shape (Ector.Renderer.Generic.Base, Efl.Gfx.Shape) } } implements { - Ector.Renderer.Generic.Base.prepare; Efl.Gfx.Shape.stroke_scale; Efl.Gfx.Shape.stroke_color; Efl.Gfx.Shape.stroke_width; diff --git a/src/lib/ector/ector_renderer_shape.c b/src/lib/ector/ector_renderer_shape.c index be662b0f16..f60e832068 100644 --- a/src/lib/ector/ector_renderer_shape.c +++ b/src/lib/ector/ector_renderer_shape.c @@ -183,17 +183,4 @@ _ector_renderer_generic_shape_efl_gfx_shape_stroke_join_get(Eo *obj EINA_UNUSED, return pd->stroke.join; } -static Eina_Bool -_ector_renderer_generic_shape_ector_renderer_generic_base_prepare(Eo *obj, - Ector_Renderer_Generic_Shape_Data *pd) -{ - if (pd->fill) - eo_do(pd->fill, ector_renderer_prepare()); - if (pd->stroke.fill) - eo_do(pd->stroke.fill, ector_renderer_prepare()); - if (pd->stroke.marker) - eo_do(pd->stroke.marker, ector_renderer_prepare()); - return EINA_TRUE; -} - #include "ector_renderer_generic_shape.eo.c" diff --git a/src/lib/evas/canvas/evas_vg_gradient_linear.c b/src/lib/evas/canvas/evas_vg_gradient_linear.c index d29038c579..814bd478df 100644 --- a/src/lib/evas/canvas/evas_vg_gradient_linear.c +++ b/src/lib/evas/canvas/evas_vg_gradient_linear.c @@ -73,7 +73,7 @@ _efl_vg_gradient_linear_render_pre(Eo *obj, if (!nd->renderer) { - eo_do(s, nd->renderer = ector_surface_renderer_factory_new(ECTOR_RENDERER_GENERIC_GRADIENT_LINEAR_CLASS)); + eo_do(s, nd->renderer = ector_surface_renderer_factory_new(ECTOR_RENDERER_GENERIC_GRADIENT_LINEAR_MIXIN)); } eo_do(nd->renderer, diff --git a/src/lib/evas/canvas/evas_vg_gradient_radial.c b/src/lib/evas/canvas/evas_vg_gradient_radial.c index b0743e5750..d28f9f4c2f 100644 --- a/src/lib/evas/canvas/evas_vg_gradient_radial.c +++ b/src/lib/evas/canvas/evas_vg_gradient_radial.c @@ -89,7 +89,7 @@ _efl_vg_gradient_radial_render_pre(Eo *obj, if (!nd->renderer) { - eo_do(s, nd->renderer = ector_surface_renderer_factory_new(ECTOR_RENDERER_GENERIC_GRADIENT_RADIAL_CLASS)); + eo_do(s, nd->renderer = ector_surface_renderer_factory_new(ECTOR_RENDERER_GENERIC_GRADIENT_RADIAL_MIXIN)); } eo_do(nd->renderer, diff --git a/src/lib/evas/canvas/evas_vg_shape.c b/src/lib/evas/canvas/evas_vg_shape.c index 8c1caee8dd..392d2981c3 100644 --- a/src/lib/evas/canvas/evas_vg_shape.c +++ b/src/lib/evas/canvas/evas_vg_shape.c @@ -296,7 +296,7 @@ _efl_vg_shape_render_pre(Eo *obj EINA_UNUSED, if (!nd->renderer) { - nd->renderer = eo_do(s, ector_surface_renderer_factory_new(ECTOR_RENDERER_GENERIC_SHAPE_CLASS)); + eo_do(s, nd->renderer = ector_surface_renderer_factory_new(ECTOR_RENDERER_GENERIC_SHAPE_MIXIN)); } eo_do(nd->renderer, From 891ec145857c717105deb2481d224174b1c966ac Mon Sep 17 00:00:00 2001 From: Subhransu Sekhar Mohanty Date: Fri, 3 Apr 2015 16:31:45 +0200 Subject: [PATCH 157/251] ector: add software backend using FreeType rasterizer. --- src/lib/ector/software/Ector_Software.h | 15 + src/lib/ector/software/ector_blend_private.h | 117 + .../software/ector_renderer_software_base.eo | 12 + .../ector_renderer_software_gradient_linear.c | 109 + ...ector_renderer_software_gradient_linear.eo | 14 + .../ector_renderer_software_gradient_radial.c | 117 + ...ector_renderer_software_gradient_radial.eo | 14 + .../software/ector_renderer_software_shape.c | 373 +++ .../software/ector_renderer_software_shape.eo | 13 + .../ector/software/ector_software_gradient.c | 269 ++ .../ector/software/ector_software_private.h | 150 ++ .../software/ector_software_rasterizer.c | 437 ++++ .../ector/software/ector_software_surface.c | 94 + .../ector/software/ector_software_surface.eo | 33 + src/lib/ector/software/sw_ft_math.c | 528 ++++ src/lib/ector/software/sw_ft_math.h | 438 ++++ src/lib/ector/software/sw_ft_raster.c | 1846 +++++++++++++ src/lib/ector/software/sw_ft_raster.h | 607 +++++ src/lib/ector/software/sw_ft_stroker.c | 2292 +++++++++++++++++ src/lib/ector/software/sw_ft_stroker.h | 325 +++ src/lib/ector/software/sw_ft_types.h | 160 ++ 21 files changed, 7963 insertions(+) create mode 100644 src/lib/ector/software/Ector_Software.h create mode 100644 src/lib/ector/software/ector_blend_private.h create mode 100644 src/lib/ector/software/ector_renderer_software_base.eo create mode 100644 src/lib/ector/software/ector_renderer_software_gradient_linear.c create mode 100644 src/lib/ector/software/ector_renderer_software_gradient_linear.eo create mode 100644 src/lib/ector/software/ector_renderer_software_gradient_radial.c create mode 100644 src/lib/ector/software/ector_renderer_software_gradient_radial.eo create mode 100644 src/lib/ector/software/ector_renderer_software_shape.c create mode 100644 src/lib/ector/software/ector_renderer_software_shape.eo create mode 100644 src/lib/ector/software/ector_software_gradient.c create mode 100644 src/lib/ector/software/ector_software_private.h create mode 100644 src/lib/ector/software/ector_software_rasterizer.c create mode 100644 src/lib/ector/software/ector_software_surface.c create mode 100644 src/lib/ector/software/ector_software_surface.eo create mode 100755 src/lib/ector/software/sw_ft_math.c create mode 100755 src/lib/ector/software/sw_ft_math.h create mode 100644 src/lib/ector/software/sw_ft_raster.c create mode 100755 src/lib/ector/software/sw_ft_raster.h create mode 100755 src/lib/ector/software/sw_ft_stroker.c create mode 100755 src/lib/ector/software/sw_ft_stroker.h create mode 100755 src/lib/ector/software/sw_ft_types.h diff --git a/src/lib/ector/software/Ector_Software.h b/src/lib/ector/software/Ector_Software.h new file mode 100644 index 0000000000..7d003cc3ff --- /dev/null +++ b/src/lib/ector/software/Ector_Software.h @@ -0,0 +1,15 @@ +#ifndef ECTOR_SOFTWARE_H_ +#define ECTOR_SOFTWARE_H_ + +#include + +typedef Eo Ector_Software_Surface; +typedef struct _Software_Rasterizer Software_Rasterizer; + +#include "software/ector_software_surface.eo.h" +#include "software/ector_renderer_software_base.eo.h" +#include "software/ector_renderer_software_shape.eo.h" +#include "software/ector_renderer_software_gradient_linear.eo.h" +#include "software/ector_renderer_software_gradient_radial.eo.h" + +#endif diff --git a/src/lib/ector/software/ector_blend_private.h b/src/lib/ector/software/ector_blend_private.h new file mode 100644 index 0000000000..ba48a03349 --- /dev/null +++ b/src/lib/ector/software/ector_blend_private.h @@ -0,0 +1,117 @@ +#ifndef ECTOR_BLEND_PRIVATE_H +#define ECTOR_BLEND_PRIVATE_H + +#ifndef MIN +#define MIN( a, b ) ( (a) < (b) ? (a) : (b) ) +#endif + +#ifndef MAX +#define MAX( a, b ) ( (a) > (b) ? (a) : (b) ) +#endif + +#define ECTOR_ARGB_JOIN(a,r,g,b) \ + (((a) << 24) + ((r) << 16) + ((g) << 8) + (b)) + +#define ECTOR_MUL4_SYM(x, y) \ + ( ((((((x) >> 16) & 0xff00) * (((y) >> 16) & 0xff00)) + 0xff0000) & 0xff000000) + \ + ((((((x) >> 8) & 0xff00) * (((y) >> 16) & 0xff)) + 0xff00) & 0xff0000) + \ + ((((((x) & 0xff00) * ((y) & 0xff00)) + 0xff0000) >> 16) & 0xff00) + \ + (((((x) & 0xff) * ((y) & 0xff)) + 0xff) >> 8) ) + +#define ECTOR_MUL_256(c, a) \ + ( (((((c) >> 8) & 0x00ff00ff) * (a)) & 0xff00ff00) + \ + (((((c) & 0x00ff00ff) * (a)) >> 8) & 0x00ff00ff) ) + + +static inline void +_ector_memfill(DATA32 *dest, uint value, int count) +{ + if (!count) + return; + + int n = (count + 7) / 8; + switch (count & 0x07) + { + case 0: do { *dest++ = value; + case 7: *dest++ = value; + case 6: *dest++ = value; + case 5: *dest++ = value; + case 4: *dest++ = value; + case 3: *dest++ = value; + case 2: *dest++ = value; + case 1: *dest++ = value; + } while (--n > 0); + } +} + + +static inline void +_ector_comp_func_source_over_mul_c(uint *dest, uint *src, DATA32 c, int length, uint const_alpha) +{ + if (const_alpha == 255) { + for (int i = 0; i < length; ++i) { + uint s = src[i]; + DATA32 sc = ECTOR_MUL4_SYM(c, s); + uint a = (~sc) >> 24; + dest[i] = sc + ECTOR_MUL_256(dest[i], a); + } + } else { + for (int i = 0; i < length; ++i) { + uint s = src[i]; + DATA32 sc = ECTOR_MUL4_SYM(c, s); + sc = ECTOR_MUL_256(sc, const_alpha); + uint a = (~sc) >> 24; + dest[i] = sc + ECTOR_MUL_256(dest[i], a); + } + } +} + + +static inline void +_ector_comp_func_source_over(uint *dest, uint *src, int length, uint const_alpha) +{ + if (const_alpha == 255) { + for (int i = 0; i < length; ++i) { + uint s = src[i]; + if (s >= 0xff000000) + dest[i] = s; + else if (s != 0) { + uint a = (~s) >> 24; + dest[i] = s + ECTOR_MUL_256(dest[i], a); + } + } + } else { + for (int i = 0; i < length; ++i) { + uint s = ECTOR_MUL_256(src[i], const_alpha); + uint a = (~s) >> 24; + dest[i] = s + ECTOR_MUL_256(dest[i], a); + } + } +} + + +static inline uint +_ector_premultiply(uint data) +{ + DATA32 a = 1 + (data >> 24); + data = ( data & 0xff000000) + + (((((data) >> 8) & 0xff) * a) & 0xff00) + + (((((data) & 0x00ff00ff) * a) >> 8) & 0x00ff00ff); + + return data; +} + +static inline uint +INTERPOLATE_PIXEL_256(uint x, uint a, uint y, uint b) { + uint t = (x & 0xff00ff) * a + (y & 0xff00ff) * b; + t >>= 8; + t &= 0xff00ff; + + x = ((x >> 8) & 0xff00ff) * a + ((y >> 8) & 0xff00ff) * b; + x &= 0xff00ff00; + x |= t; + return x; +} + + +#endif \ No newline at end of file diff --git a/src/lib/ector/software/ector_renderer_software_base.eo b/src/lib/ector/software/ector_renderer_software_base.eo new file mode 100644 index 0000000000..6055be585c --- /dev/null +++ b/src/lib/ector/software/ector_renderer_software_base.eo @@ -0,0 +1,12 @@ +class Ector.Renderer.Software.Base (Ector.Renderer.Generic.Base) +{ + legacy_prefix: null; + methods { + fill { + return: bool; + } + } + implements { + @virtual .fill; + } +} diff --git a/src/lib/ector/software/ector_renderer_software_gradient_linear.c b/src/lib/ector/software/ector_renderer_software_gradient_linear.c new file mode 100644 index 0000000000..8bbf23d73a --- /dev/null +++ b/src/lib/ector/software/ector_renderer_software_gradient_linear.c @@ -0,0 +1,109 @@ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include +#include + +#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) +{ + if (!pd->surface) + { + Eo *parent; + + eo_do(obj, parent = eo_parent_get()); + if (!parent) return EINA_FALSE; + pd->surface = eo_data_xref(parent, ECTOR_SOFTWARE_SURFACE_CLASS, obj); + } + + _update_linear_data(pd); + + + return EINA_FALSE; +} + +static Eina_Bool +_ector_renderer_software_gradient_linear_ector_renderer_generic_base_draw(Eo *obj EINA_UNUSED, + Ector_Renderer_Software_Gradient_Data *pd EINA_UNUSED, + Ector_Rop op EINA_UNUSED, Eina_Array *clips EINA_UNUSED, + int x EINA_UNUSED, int y EINA_UNUSED, unsigned int mul_col EINA_UNUSED) +{ + return EINA_TRUE; +} + +static Eina_Bool +_ector_renderer_software_gradient_linear_ector_renderer_software_base_fill(Eo *obj EINA_UNUSED, + Ector_Renderer_Software_Gradient_Data *pd) +{ + ector_software_rasterizer_linear_gradient_set(pd->surface->software, pd); + + return EINA_TRUE; +} + +void +_ector_renderer_software_gradient_linear_eo_base_constructor(Eo *obj, + Ector_Renderer_Software_Gradient_Data *pd) +{ + eo_do_super(obj, ECTOR_RENDERER_SOFTWARE_GRADIENT_LINEAR_CLASS, eo_constructor()); + pd->gd = eo_data_xref(obj, ECTOR_RENDERER_GENERIC_GRADIENT_MIXIN, obj); + pd->gld = eo_data_xref(obj, ECTOR_RENDERER_GENERIC_GRADIENT_LINEAR_MIXIN, obj); +} + +void +_ector_renderer_software_gradient_linear_eo_base_destructor(Eo *obj, + Ector_Renderer_Software_Gradient_Data *pd) +{ + Eo *parent; + + destroy_color_table(pd); + + eo_do(obj, parent = eo_parent_get()); + eo_data_xunref(parent, pd->surface, obj); + + eo_data_xunref(obj, pd->gd, obj); + eo_data_xunref(obj, pd->gld, obj); + + eo_do_super(obj, ECTOR_RENDERER_SOFTWARE_GRADIENT_LINEAR_CLASS, eo_destructor()); +} + +void +_ector_renderer_software_gradient_linear_efl_gfx_gradient_base_stop_set(Eo *obj, Ector_Renderer_Software_Gradient_Data *pd, const Efl_Gfx_Gradient_Stop *colors, unsigned int length) +{ + eo_do_super(obj, ECTOR_RENDERER_SOFTWARE_GRADIENT_LINEAR_CLASS, + efl_gfx_gradient_stop_set(colors, length)); + + destroy_color_table(pd); +} + +#include "ector_renderer_software_gradient_linear.eo.c" diff --git a/src/lib/ector/software/ector_renderer_software_gradient_linear.eo b/src/lib/ector/software/ector_renderer_software_gradient_linear.eo new file mode 100644 index 0000000000..32f83df016 --- /dev/null +++ b/src/lib/ector/software/ector_renderer_software_gradient_linear.eo @@ -0,0 +1,14 @@ +class Ector.Renderer.Software.Gradient_Linear (Ector.Renderer.Software.Base, Ector.Renderer.Generic.Gradient, Ector.Renderer.Generic.Gradient_Linear) +{ + eo_prefix: ector_renderer_software_gradient_linear; + legacy_prefix: null; + data: Ector_Renderer_Software_Gradient_Data; + implements { + Ector.Renderer.Generic.Base.prepare; + Ector.Renderer.Generic.Base.draw; + Ector.Renderer.Software.Base.fill; + Eo.Base.constructor; + Eo.Base.destructor; + Efl.Gfx.Gradient.Base.stop.set; + } +} diff --git a/src/lib/ector/software/ector_renderer_software_gradient_radial.c b/src/lib/ector/software/ector_renderer_software_gradient_radial.c new file mode 100644 index 0000000000..4bcf2a1594 --- /dev/null +++ b/src/lib/ector/software/ector_renderer_software_gradient_radial.c @@ -0,0 +1,117 @@ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include +#include + +#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) +{ + if (!pd->surface) + { + Eo *parent; + + eo_do(obj, parent = eo_parent_get()); + if (!parent) return EINA_FALSE; + pd->surface = eo_data_xref(parent, ECTOR_SOFTWARE_SURFACE_CLASS, obj); + } + + _update_radial_data(pd); + return EINA_FALSE; +} + +// Clearly duplicated and should be in a common place... +static Eina_Bool +_ector_renderer_software_gradient_radial_ector_renderer_generic_base_draw(Eo *obj EINA_UNUSED, + Ector_Renderer_Software_Gradient_Data *pd EINA_UNUSED, + Ector_Rop op EINA_UNUSED, Eina_Array *clips EINA_UNUSED, + int x EINA_UNUSED, int y EINA_UNUSED, unsigned int mul_col EINA_UNUSED) +{ + return EINA_TRUE; +} + +// Clearly duplicated and should be in a common place... +static Eina_Bool +_ector_renderer_software_gradient_radial_ector_renderer_software_base_fill(Eo *obj EINA_UNUSED, Ector_Renderer_Software_Gradient_Data *pd) +{ + ector_software_rasterizer_radial_gradient_set(pd->surface->software, pd); + return EINA_TRUE; +} + +void +_ector_renderer_software_gradient_radial_eo_base_constructor(Eo *obj, + Ector_Renderer_Software_Gradient_Data *pd) +{ + eo_do_super(obj, ECTOR_RENDERER_SOFTWARE_GRADIENT_RADIAL_CLASS, eo_constructor()); + pd->gd = eo_data_xref(obj, ECTOR_RENDERER_GENERIC_GRADIENT_MIXIN, obj); + pd->gld = eo_data_xref(obj, ECTOR_RENDERER_GENERIC_GRADIENT_RADIAL_MIXIN, obj); +} + +void +_ector_renderer_software_gradient_radial_eo_base_destructor(Eo *obj, + Ector_Renderer_Software_Gradient_Data *pd) +{ + Eo *parent; + + destroy_color_table(pd); + + eo_do(obj, parent = eo_parent_get()); + eo_data_xunref(parent, pd->surface, obj); + + eo_data_xunref(obj, pd->gd, obj); + eo_data_xunref(obj, pd->gld, obj); + + eo_do_super(obj, ECTOR_RENDERER_SOFTWARE_GRADIENT_RADIAL_CLASS, eo_destructor()); +} + +void +_ector_renderer_software_gradient_radial_efl_gfx_gradient_base_stop_set(Eo *obj, Ector_Renderer_Software_Gradient_Data *pd, const Efl_Gfx_Gradient_Stop *colors, unsigned int length) +{ + eo_do_super(obj, ECTOR_RENDERER_SOFTWARE_GRADIENT_RADIAL_CLASS, + efl_gfx_gradient_stop_set(colors, length)); + + destroy_color_table(pd); +} + +#include "ector_renderer_software_gradient_radial.eo.c" diff --git a/src/lib/ector/software/ector_renderer_software_gradient_radial.eo b/src/lib/ector/software/ector_renderer_software_gradient_radial.eo new file mode 100644 index 0000000000..85625f341f --- /dev/null +++ b/src/lib/ector/software/ector_renderer_software_gradient_radial.eo @@ -0,0 +1,14 @@ +class Ector.Renderer.Software.Gradient_Radial (Ector.Renderer.Software.Base, Ector.Renderer.Generic.Gradient, Ector.Renderer.Generic.Gradient_Radial) +{ + eo_prefix: ector_renderer_software_gradient_radial; + legacy_prefix: null; + data: Ector_Renderer_Software_Gradient_Data; + implements { + Ector.Renderer.Generic.Base.prepare; + Ector.Renderer.Generic.Base.draw; + Ector.Renderer.Software.Base.fill; + Eo.Base.constructor; + Eo.Base.destructor; + Efl.Gfx.Gradient.Base.stop.set; + } +} diff --git a/src/lib/ector/software/ector_renderer_software_shape.c b/src/lib/ector/software/ector_renderer_software_shape.c new file mode 100644 index 0000000000..cdecce9e87 --- /dev/null +++ b/src/lib/ector/software/ector_renderer_software_shape.c @@ -0,0 +1,373 @@ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include + +#include +#include +#include + +#include "ector_private.h" +#include "ector_software_private.h" + + +typedef struct _Ector_Renderer_Software_Shape_Data Ector_Renderer_Software_Shape_Data; +struct _Ector_Renderer_Software_Shape_Data +{ + Ector_Software_Surface_Data *surface; + Ector_Renderer_Generic_Shape_Data *shape; + Ector_Renderer_Generic_Base_Data *base; + Shape_Rle_Data *shape_data; + Shape_Rle_Data *outline_data; +}; + +typedef struct _Outline +{ + SW_FT_Outline ft_outline; + int points_alloc; + int contours_alloc; +}Outline; + +static Outline * +_outline_create() +{ + Outline *outline = (Outline *) calloc(1, sizeof(Outline)); + + outline->ft_outline.points = (SW_FT_Vector *) calloc(50, sizeof(SW_FT_Vector)); + outline->ft_outline.tags = (char *) calloc(50, sizeof(char)); + + outline->ft_outline.contours = (short *) calloc(5, sizeof(short)); + + outline->points_alloc = 50; + outline->contours_alloc = 5; + return outline; +} + +static +void _outline_destroy(Outline *outline) +{ + if (outline) + { + free(outline->ft_outline.points); + free(outline->ft_outline.tags); + free(outline->ft_outline.contours); + free(outline); + outline = NULL; + } +} + +static void +_outline_move_to(Outline *outline, double x, double y) +{ + SW_FT_Outline *ft_outline = &outline->ft_outline; + + if (ft_outline->n_contours == outline->contours_alloc) + { + outline->contours_alloc += 5; + ft_outline->contours = (short *) realloc(ft_outline->contours, outline->contours_alloc * sizeof(short)); + } + ft_outline->points[ft_outline->n_points].x = x; + ft_outline->points[ft_outline->n_points].y = y; + ft_outline->tags[ft_outline->n_points] = SW_FT_CURVE_TAG_ON; + + if (ft_outline->n_points) + { + ft_outline->contours[ft_outline->n_contours] = ft_outline->n_points - 1; + ft_outline->n_contours++; + } + + ft_outline->n_points++; +} + +static void +_outline_end(Outline *outline) +{ + SW_FT_Outline *ft_outline = &outline->ft_outline; + + if (ft_outline->n_contours == outline->contours_alloc) + { + outline->contours_alloc += 1; + ft_outline->contours = (short *) realloc(ft_outline->contours, outline->contours_alloc * sizeof(short)); + } + + if (ft_outline->n_points) + { + ft_outline->contours[ft_outline->n_contours] = ft_outline->n_points - 1; + ft_outline->n_contours++; + } +} + + +static void _outline_line_to(Outline *outline, double x, double y) +{ + SW_FT_Outline *ft_outline = &outline->ft_outline; + + if (ft_outline->n_points == outline->points_alloc) + { + outline->points_alloc += 50; + ft_outline->points = (SW_FT_Vector *) realloc(ft_outline->points, outline->points_alloc * sizeof(SW_FT_Vector)); + ft_outline->tags = (char *) realloc(ft_outline->tags, outline->points_alloc * sizeof(char)); + } + ft_outline->points[ft_outline->n_points].x = x; + ft_outline->points[ft_outline->n_points].y = y; + ft_outline->tags[ft_outline->n_points] = SW_FT_CURVE_TAG_ON; + ft_outline->n_points++; +} + + +static Eina_Bool +_outline_close_path(Outline *outline) +{ + SW_FT_Outline *ft_outline = &outline->ft_outline; + int index ; + + if (ft_outline->n_contours) + { + index = ft_outline->contours[ft_outline->n_contours - 1] + 1; + } + else + { + // first path + index = 0; + } + + // make sure there is atleast one point in the current path + if (ft_outline->n_points == index) return EINA_FALSE; + + _outline_line_to(outline, ft_outline->points[index].x, ft_outline->points[index].y); + return EINA_TRUE; +} + + +static void _outline_cubic_to(Outline *outline, double cx1, double cy1, double cx2, double cy2, double x, double y) +{ + SW_FT_Outline *ft_outline = &outline->ft_outline; + + if (ft_outline->n_points == outline->points_alloc) + { + outline->points_alloc += 50; + ft_outline->points = (SW_FT_Vector *) realloc(ft_outline->points, outline->points_alloc * sizeof(SW_FT_Vector)); + ft_outline->tags = (char *) realloc(ft_outline->tags, outline->points_alloc * sizeof(char)); + } + + ft_outline->points[ft_outline->n_points].x = cx1; + ft_outline->points[ft_outline->n_points].y = cy1; + ft_outline->tags[ft_outline->n_points] = SW_FT_CURVE_TAG_CUBIC; + ft_outline->n_points++; + + ft_outline->points[ft_outline->n_points].x = cx2; + ft_outline->points[ft_outline->n_points].y = cy2; + ft_outline->tags[ft_outline->n_points] = SW_FT_CURVE_TAG_CUBIC; + ft_outline->n_points++; + + ft_outline->points[ft_outline->n_points].x = x; + ft_outline->points[ft_outline->n_points].y = y; + ft_outline->tags[ft_outline->n_points] = SW_FT_CURVE_TAG_ON; + ft_outline->n_points++; +} + +static void _outline_transform(Outline *outline, Eina_Matrix3 *m) +{ + int i; + SW_FT_Outline *ft_outline = &outline->ft_outline; + + if (m) + { + double x, y; + for (i = 0; i < ft_outline->n_points ; i++) + { + eina_matrix3_point_transform(m, ft_outline->points[i].x, ft_outline->points[i].y, &x, &y); + ft_outline->points[i].x = (int)(x * 64);// to freetype 26.6 coordinate. + ft_outline->points[i].y = (int)(y * 64); + } + } + else + { + for (i = 0; i < ft_outline->n_points ; i++) + { + ft_outline->points[i].x = ft_outline->points[i].x <<6;// to freetype 26.6 coordinate. + ft_outline->points[i].y = ft_outline->points[i].y <<6; + } + } +} + + +static Eina_Bool +_ector_renderer_software_shape_ector_renderer_generic_base_prepare(Eo *obj, Ector_Renderer_Software_Shape_Data *pd) +{ + const Efl_Gfx_Path_Command *cmds = NULL; + const double *pts = NULL; + + // FIXME: shouldn't that be part of the shape generic implementation ? + if (pd->shape->fill) + eo_do(pd->shape->fill, ector_renderer_prepare()); + if (pd->shape->stroke.fill) + eo_do(pd->shape->stroke.fill, ector_renderer_prepare()); + if (pd->shape->stroke.marker) + eo_do(pd->shape->stroke.marker, ector_renderer_prepare()); + + // shouldn't that be moved to the software base object + if (!pd->surface) + { + Eo *parent; + eo_do(obj, parent = eo_parent_get()); + if (!parent) return EINA_FALSE; + pd->surface = eo_data_xref(parent, ECTOR_SOFTWARE_SURFACE_CLASS, obj); + if (!pd->surface) return EINA_FALSE; + } + + eo_do(obj, efl_gfx_shape_path_get(&cmds, &pts)); + if (!pd->shape_data && cmds) + { + Eina_Bool close_path = EINA_FALSE; + Outline * outline = _outline_create(); + + for (; *cmds != EFL_GFX_PATH_COMMAND_TYPE_END; cmds++) + { + switch (*cmds) + { + case EFL_GFX_PATH_COMMAND_TYPE_MOVE_TO: + + _outline_move_to(outline, pts[0], pts[1]); + + pts += 2; + break; + case EFL_GFX_PATH_COMMAND_TYPE_LINE_TO: + + _outline_line_to(outline, pts[0], pts[1]); + + pts += 2; + break; + case EFL_GFX_PATH_COMMAND_TYPE_CUBIC_TO: + + // Be careful, we do have a different order than + // cairo, first is destination point, followed by + // the control point. The opposite of cairo. + _outline_cubic_to(outline, + pts[2], pts[3], pts[4], pts[5], // control points + pts[0], pts[1]); // destination point + pts += 6; + break; + + case EFL_GFX_PATH_COMMAND_TYPE_CLOSE: + + close_path = _outline_close_path(outline); + break; + + case EFL_GFX_PATH_COMMAND_TYPE_LAST: + case EFL_GFX_PATH_COMMAND_TYPE_END: + break; + } + } + + _outline_end(outline); + _outline_transform(outline, pd->base->m); + + // generate the shape data. + pd->shape_data = ector_software_rasterizer_generate_rle_data(pd->surface->software, &outline->ft_outline); + if (!pd->outline_data) + { + ector_software_rasterizer_stroke_set(pd->surface->software, (pd->shape->stroke.width * pd->shape->stroke.scale), pd->shape->stroke.cap, + pd->shape->stroke.join); + pd->outline_data = ector_software_rasterizer_generate_stroke_rle_data(pd->surface->software, &outline->ft_outline, close_path); + } + + _outline_destroy(outline); + } + + return EINA_TRUE; +} + +static Eina_Bool +_ector_renderer_software_shape_ector_renderer_generic_base_draw(Eo *obj EINA_UNUSED, Ector_Renderer_Software_Shape_Data *pd, Ector_Rop op, Eina_Array *clips, int x, int y, unsigned int mul_col) +{ + // adjust the offset + x = x + (int)pd->base->origin.x; + y = y + (int)pd->base->origin.y; + + // fill the span_data structure + ector_software_rasterizer_clip_rect_set(pd->surface->software, clips); + ector_software_rasterizer_transform_set(pd->surface->software, pd->base->m); + + if (pd->shape->fill) + { + eo_do(pd->shape->fill, ector_renderer_software_base_fill()); + ector_software_rasterizer_draw_rle_data(pd->surface->software, x, y, mul_col, op, pd->shape_data); + } + else + { + if (pd->base->color.a > 0) + { + ector_software_rasterizer_color_set(pd->surface->software, pd->base->color.r, pd->base->color.g, pd->base->color.b, pd->base->color.a); + ector_software_rasterizer_draw_rle_data(pd->surface->software, x, y, mul_col, op, pd->shape_data); + } + } + + if (pd->shape->stroke.fill) + { + eo_do(pd->shape->stroke.fill, ector_renderer_software_base_fill()); + ector_software_rasterizer_draw_rle_data(pd->surface->software, x, y, mul_col, op, pd->outline_data); + } + else + { + if (pd->shape->stroke.color.a > 0) + { + ector_software_rasterizer_color_set(pd->surface->software, + pd->shape->stroke.color.r, pd->shape->stroke.color.g, + pd->shape->stroke.color.b, pd->shape->stroke.color.a); + ector_software_rasterizer_draw_rle_data(pd->surface->software, x, y, mul_col, op, pd->outline_data); + } + } + + return EINA_TRUE; +} + +static Eina_Bool +_ector_renderer_software_shape_ector_renderer_software_base_fill(Eo *obj EINA_UNUSED, Ector_Renderer_Software_Shape_Data *pd EINA_UNUSED) +{ + // FIXME: let's find out how to fill a shape with a shape later. + // I need to read SVG specification and see how to map that with software. + return EINA_FALSE; +} + +static void +_ector_renderer_software_shape_efl_gfx_shape_path_set(Eo *obj, Ector_Renderer_Software_Shape_Data *pd, + const Efl_Gfx_Path_Command *op, const double *points) +{ + if(pd->shape_data) ector_software_rasterizer_destroy_rle_data(pd->shape_data); + if(pd->outline_data) ector_software_rasterizer_destroy_rle_data(pd->outline_data); + pd->shape_data = NULL; + pd->outline_data = NULL; + + eo_do_super(obj, ECTOR_RENDERER_SOFTWARE_SHAPE_CLASS, efl_gfx_shape_path_set(op, points)); +} + + +void +_ector_renderer_software_shape_eo_base_constructor(Eo *obj, Ector_Renderer_Software_Shape_Data *pd) +{ + eo_do_super(obj, ECTOR_RENDERER_SOFTWARE_SHAPE_CLASS, eo_constructor()); + pd->shape = eo_data_xref(obj, ECTOR_RENDERER_GENERIC_SHAPE_MIXIN, obj); + pd->base = eo_data_xref(obj, ECTOR_RENDERER_GENERIC_BASE_CLASS, obj); +} + +void +_ector_renderer_software_shape_eo_base_destructor(Eo *obj, Ector_Renderer_Software_Shape_Data *pd) +{ + Eo *parent; + + if(pd->shape_data) ector_software_rasterizer_destroy_rle_data(pd->shape_data); + if(pd->outline_data) ector_software_rasterizer_destroy_rle_data(pd->outline_data); + + eo_do(obj, parent = eo_parent_get()); + eo_data_xunref(parent, pd->surface, obj); + + eo_data_xunref(obj, pd->shape, obj); + eo_data_xunref(obj, pd->base, obj); + eo_do_super(obj, ECTOR_RENDERER_SOFTWARE_SHAPE_CLASS, eo_destructor()); +} + + +#include "ector_renderer_software_shape.eo.c" diff --git a/src/lib/ector/software/ector_renderer_software_shape.eo b/src/lib/ector/software/ector_renderer_software_shape.eo new file mode 100644 index 0000000000..267ef7cc7e --- /dev/null +++ b/src/lib/ector/software/ector_renderer_software_shape.eo @@ -0,0 +1,13 @@ +class Ector.Renderer.Software.Shape (Ector.Renderer.Software.Base, Ector.Renderer.Generic.Shape) +{ + eo_prefix: ector_renderer_software_shape; + legacy_prefix: null; + implements { + Ector.Renderer.Generic.Base.prepare; + Ector.Renderer.Generic.Base.draw; + Ector.Renderer.Software.Base.fill; + Efl.Gfx.Shape.path.set; + Eo.Base.constructor; + Eo.Base.destructor; + } +} diff --git a/src/lib/ector/software/ector_software_gradient.c b/src/lib/ector/software/ector_software_gradient.c new file mode 100644 index 0000000000..ed2b9fe985 --- /dev/null +++ b/src/lib/ector/software/ector_software_gradient.c @@ -0,0 +1,269 @@ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +//Remove +#include + +#include +#include + +#include +#include +#include + +#include "ector_private.h" +#include "ector_software_private.h" +#include "ector_blend_private.h" + + +#define GRADIENT_STOPTABLE_SIZE 1024 +#define FIXPT_BITS 8 +#define FIXPT_SIZE (1<gd->s == EFL_GFX_GRADIENT_SPREAD_REPEAT) + { + ipos = ipos % GRADIENT_STOPTABLE_SIZE; + ipos = ipos < 0 ? GRADIENT_STOPTABLE_SIZE + ipos : ipos; + } + else if (data->gd->s == EFL_GFX_GRADIENT_SPREAD_REFLECT) + { + const int limit = GRADIENT_STOPTABLE_SIZE * 2; + ipos = ipos % limit; + ipos = ipos < 0 ? limit + ipos : ipos; + ipos = ipos >= GRADIENT_STOPTABLE_SIZE ? limit - 1 - ipos : ipos; + } + else + { + if (ipos < 0) + ipos = 0; + else if (ipos >= GRADIENT_STOPTABLE_SIZE) + ipos = GRADIENT_STOPTABLE_SIZE-1; + } + + return ipos; +} + + +static uint +_gradient_pixel_fixed(const Ector_Renderer_Software_Gradient_Data *data, int fixed_pos) +{ + int ipos = (fixed_pos + (FIXPT_SIZE / 2)) >> FIXPT_BITS; + return data->colorTable[_gradient_clamp(data, ipos)]; +} + +static inline uint +_gradient_pixel(const Ector_Renderer_Software_Gradient_Data *data, float pos) +{ + int ipos = (int)(pos * (GRADIENT_STOPTABLE_SIZE - 1) + (float)(0.5)); + return data->colorTable[_gradient_clamp(data, ipos)]; +} + +typedef double (*BLEND_FUNC)(double progress); + +static double +_ease_linear(double t) +{ + return t; +} + +static void +_generate_gradient_color_table(Efl_Gfx_Gradient_Stop *gradient_stops, int stop_count, uint *colorTable, int size) +{ + int pos = 0; + Efl_Gfx_Gradient_Stop *curr, *next; + assert(stop_count > 0); + + curr = gradient_stops; + uint current_color = ECTOR_ARGB_JOIN(curr->a, curr->r, curr->g, curr->b); + double incr = 1.0 / (double)size; + double fpos = 1.5 * incr; + current_color = _ector_premultiply(current_color); + + colorTable[pos++] = current_color; + + while (fpos <= curr->offset) + { + colorTable[pos] = colorTable[pos - 1]; + pos++; + fpos += incr; + } + + for (int i = 0; i < stop_count - 1; ++i) + { + curr = (gradient_stops + i); + next = (gradient_stops + i + 1); + double delta = 1/(next->offset - curr->offset); + uint next_color = ECTOR_ARGB_JOIN(next->a, next->r, next->g, next->b); + next_color = _ector_premultiply(next_color); + BLEND_FUNC func = &_ease_linear; + while (fpos < next->offset && pos < size) + { + double t = func((fpos - curr->offset) * delta); + int dist = (int)(256 * t); + int idist = 256 - dist; + colorTable[pos] = INTERPOLATE_PIXEL_256(current_color, idist, next_color, dist); + ++pos; + fpos += incr; + } + current_color = next_color; + } + + uint last_color = _ector_premultiply(current_color); + for (;pos < size; ++pos) + colorTable[pos] = last_color; + + // Make sure the last color stop is represented at the end of the table + colorTable[size-1] = last_color; +} + + +void +update_color_table(Ector_Renderer_Software_Gradient_Data *gdata) +{ + if(gdata->colorTable) return; + + gdata->colorTable = malloc(GRADIENT_STOPTABLE_SIZE * 4); + _generate_gradient_color_table(gdata->gd->colors, gdata->gd->colors_count, gdata->colorTable, GRADIENT_STOPTABLE_SIZE); +} + +void +destroy_color_table(Ector_Renderer_Software_Gradient_Data *gdata) +{ + if (gdata->colorTable) + { + free(gdata->colorTable); + gdata->colorTable = NULL; + } +} + + +void +fetch_linear_gradient(uint *buffer, Span_Data *data, int y, int x, int length) +{ + Ector_Renderer_Software_Gradient_Data *g_data = data->gradient; + float t, inc; + float rx=0, ry=0; + + if (g_data->linear.l == 0) + { + t = inc = 0; + } + else + { + rx = data->inv.xy * (y + (float)0.5) + data->inv.xz + data->inv.xx * (x + (float)0.5); + ry = data->inv.yy * (y + (float)0.5) + data->inv.yz + data->inv.yx * (x + (float)0.5); + t = g_data->linear.dx*rx + g_data->linear.dy*ry + g_data->linear.off; + inc = g_data->linear.dx * data->inv.xx + g_data->linear.dx * data->inv.yx; + + t *= (GRADIENT_STOPTABLE_SIZE - 1); + inc *= (GRADIENT_STOPTABLE_SIZE - 1); + } + + uint *end = buffer + length; + if (inc > (float)(-1e-5) && inc < (float)(1e-5)) + { + _ector_memfill(buffer, _gradient_pixel_fixed(g_data, (int)(t * FIXPT_SIZE)), length); + } + else + { + if (t + inc*length < (float)(INT_MAX >> (FIXPT_BITS + 1)) && + t+inc*length > (float)(INT_MIN >> (FIXPT_BITS + 1))) + { + // we can use fixed point math + int t_fixed = (int)(t * FIXPT_SIZE); + int inc_fixed = (int)(inc * FIXPT_SIZE); + // #ifdef BUILD_SSE3 + // if (evas_common_cpu_has_feature(CPU_FEATURE_SSE3)) { + // _fetch_linear_sse3(buffer, length, g_data, t_fixed, inc_fixed); + // } else + // #endif + { + while (buffer < end) + { + *buffer++ = _gradient_pixel_fixed(g_data, t_fixed); + t_fixed += inc_fixed; + } + } + } + else + { + // we have to fall back to float math + while (buffer < end) { + *buffer++ = _gradient_pixel(g_data, t/GRADIENT_STOPTABLE_SIZE); + t += inc; + } + } + } +} + +static void +_radial_helper_generic(uint *buffer, int length, Ector_Renderer_Software_Gradient_Data *g_data, float det, + float delta_det, float delta_delta_det, float b, float delta_b) +{ + for (int i = 0 ; i < length ; i++) + { + *buffer++ = _gradient_pixel(g_data, sqrt(det) - b); + det += delta_det; + delta_det += delta_delta_det; + b += delta_b; + } +} + +void +fetch_radial_gradient(uint *buffer, Span_Data *data, int y, int x, int length) +{ + Ector_Renderer_Software_Gradient_Data *g_data = data->gradient; + + // avoid division by zero + if (abs(g_data->radial.a) <= 0.00001f) + { + _ector_memfill(buffer, 0, length); + return; + } + + float rx = data->inv.xy * (y + (float)0.5) + data->inv.xz + data->inv.xx * (x + (float)0.5); + float ry = data->inv.yy * (y + (float)0.5) + data->inv.yz + data->inv.yx * (x + (float)0.5); + + rx -= g_data->radial.fx; + ry -= g_data->radial.fy; + + float inv_a = 1 / (float)(2 * g_data->radial.a); + + const float delta_rx = data->inv.xx; + const float delta_ry = data->inv.yx; + + float b = 2*(g_data->radial.dr*g_data->radial.fradius + rx * g_data->radial.dx + ry * g_data->radial.dy); + float delta_b = 2*(delta_rx * g_data->radial.dx + delta_ry * g_data->radial.dy); + const float b_delta_b = 2 * b * delta_b; + const float delta_b_delta_b = 2 * delta_b * delta_b; + + const float bb = b * b; + const float delta_bb = delta_b * delta_b; + b *= inv_a; + delta_b *= inv_a; + + const float rxrxryry = rx * rx + ry * ry; + const float delta_rxrxryry = delta_rx * delta_rx + delta_ry * delta_ry; + const float rx_plus_ry = 2*(rx * delta_rx + ry * delta_ry); + const float delta_rx_plus_ry = 2 * delta_rxrxryry; + + inv_a *= inv_a; + + float det = (bb - 4 * g_data->radial.a * (g_data->radial.sqrfr - rxrxryry)) * inv_a; + float delta_det = (b_delta_b + delta_bb + 4 * g_data->radial.a * (rx_plus_ry + delta_rxrxryry)) * inv_a; + const float delta_delta_det = (delta_b_delta_b + 4 * g_data->radial.a * delta_rx_plus_ry) * inv_a; + + // #ifdef BUILD_SSE3 + // if (evas_common_cpu_has_feature(CPU_FEATURE_SSE3)) { + // _radial_helper_sse3(buffer, length, g_data, det, delta_det, delta_delta_det, b, delta_b); + // } else + // #endif + { // generic fallback + _radial_helper_generic(buffer, length, g_data, det, delta_det, delta_delta_det, b, delta_b); + } +} diff --git a/src/lib/ector/software/ector_software_private.h b/src/lib/ector/software/ector_software_private.h new file mode 100644 index 0000000000..b43dcfea06 --- /dev/null +++ b/src/lib/ector/software/ector_software_private.h @@ -0,0 +1,150 @@ +#ifndef ECTOR_SOFTWARE_PRIVATE_H_ +# define ECTOR_SOFTWARE_PRIVATE_H_ + +#include "sw_ft_raster.h" +#include "sw_ft_stroker.h" + +#ifndef DATA32 +typedef unsigned int DATA32; +#endif + +#ifndef uint +typedef unsigned int uint; +#endif + +typedef struct _Ector_Software_Surface_Data Ector_Software_Surface_Data; + +#define CHECK_SOFTWARE(Parent) (!(Parent && Parent->software)) + +// Gradient related structure +typedef struct _Software_Gradient_Linear_Data +{ + float x1, y1, x2, y2; + float dx, dy, l, off; +} Software_Gradient_Linear_Data; + +typedef struct _Software_Gradient_Radial_Data +{ + float cx, cy, fx, fy, cradius, fradius; + float dx, dy, dr, sqrfr, a, inv2a; + Eina_Bool extended; +} Software_Gradient_Radial_Data; + +typedef struct _Ector_Renderer_Software_Gradient_Data +{ + Ector_Software_Surface_Data *surface; + Ector_Renderer_Generic_Gradient_Data *gd; + union { + Ector_Renderer_Generic_Gradient_Linear_Data *gld; + Ector_Renderer_Generic_Gradient_Radial_Data *grd; + }; + union { + Software_Gradient_Linear_Data linear; + Software_Gradient_Radial_Data radial; + }; + uint* colorTable; +} Ector_Renderer_Software_Gradient_Data; + + +// Rasterizer related structure +typedef struct _Raster_Buffer +{ + int width; + int height; + DATA32 *buffer; +} Raster_Buffer; + +typedef struct _Shape_Rle_Data +{ + unsigned short alloc; + unsigned short size; + SW_FT_Span *spans;// array of Scanlines. +} Shape_Rle_Data; + +typedef struct _Clip_Data +{ + Eina_Array *clips; //Eina_Rectangle + Shape_Rle_Data *path; + unsigned int enabled : 1; + unsigned int hasRectClip : 1; + unsigned int hasPathClip : 1; +} Clip_Data; + + +typedef enum _Span_Data_Type { + None, + Solid, + LinearGradient, + RadialGradient, + Image +} Span_Data_Type; + +typedef struct _Span_Data +{ + Raster_Buffer raster_buffer; + + SW_FT_SpanFunc blend; + SW_FT_SpanFunc unclipped_blend; + + int offx, offy; + Clip_Data clip; + Eina_Matrix3 inv; + Span_Data_Type type; + Eina_Bool fast_matrix ; + DATA32 mul_col; + Ector_Rop op; + union { + DATA32 color; + Ector_Renderer_Software_Gradient_Data *gradient; + //ImageData texture; + }; +} Span_Data; + +typedef struct _Software_Rasterizer +{ + SW_FT_Raster raster; + SW_FT_Stroker stroker; + + Span_Data fillData; + Eina_Matrix3 *transform; + Eina_Rectangle systemClip; + +} Software_Rasterizer; + +struct _Ector_Software_Surface_Data +{ + Software_Rasterizer *software; +}; + + +void ector_software_rasterizer_init(Software_Rasterizer *rasterizer); +void ector_software_rasterizer_done(Software_Rasterizer *rasterizer); + +void ector_software_rasterizer_stroke_set(Software_Rasterizer *rasterizer, double width, + Efl_Gfx_Cap cap_style, Efl_Gfx_Join join_style); + +void ector_software_rasterizer_transform_set(Software_Rasterizer *rasterizer, Eina_Matrix3 *t); +void ector_software_rasterizer_color_set(Software_Rasterizer *rasterizer, int r, int g, int b, int a); +void ector_software_rasterizer_linear_gradient_set(Software_Rasterizer *rasterizer, Ector_Renderer_Software_Gradient_Data *linear); +void ector_software_rasterizer_radial_gradient_set(Software_Rasterizer *rasterizer, Ector_Renderer_Software_Gradient_Data *radial); +void ector_software_rasterizer_clip_rect_set(Software_Rasterizer *rasterizer, Eina_Array *clips); +void ector_software_rasterizer_clip_shape_set(Software_Rasterizer *rasterizer, Shape_Rle_Data *clip); + + + +Shape_Rle_Data * ector_software_rasterizer_generate_rle_data(Software_Rasterizer *rasterizer, SW_FT_Outline *outline); +Shape_Rle_Data * ector_software_rasterizer_generate_stroke_rle_data(Software_Rasterizer *rasterizer, SW_FT_Outline *outline, Eina_Bool closePath); + +void ector_software_rasterizer_draw_rle_data(Software_Rasterizer *rasterizer, int x, int y, uint mul_col, Ector_Rop op, Shape_Rle_Data* rle); + +void ector_software_rasterizer_destroy_rle_data(Shape_Rle_Data *rle); + + + +// Gradient Api +void update_color_table(Ector_Renderer_Software_Gradient_Data *gdata); +void destroy_color_table(Ector_Renderer_Software_Gradient_Data *gdata); +void fetch_linear_gradient(uint *buffer, Span_Data *data, int y, int x, int length); +void fetch_radial_gradient(uint *buffer, Span_Data *data, int y, int x, int length); + +#endif diff --git a/src/lib/ector/software/ector_software_rasterizer.c b/src/lib/ector/software/ector_software_rasterizer.c new file mode 100644 index 0000000000..c1f6cae026 --- /dev/null +++ b/src/lib/ector/software/ector_software_rasterizer.c @@ -0,0 +1,437 @@ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include +#include + +#include "ector_private.h" +#include "ector_software_private.h" +#include "ector_blend_private.h" + +static void +_blend_color_argb(int count, const SW_FT_Span *spans, void *userData) +{ + Span_Data *data = (Span_Data *)(userData); + + // multiply the color with mul_col if any + uint color = ECTOR_MUL4_SYM(data->color, data->mul_col); + Eina_Bool solidSource = ((color >> 24) == 255); + + // move to the offset location + uint *buffer = data->raster_buffer.buffer + (data->raster_buffer.width * data->offy + data->offx); + + if (solidSource) + { + while (count--) + { + uint *target = buffer + (data->raster_buffer.width * spans->y + spans->x); + if (spans->coverage == 255) + { + _ector_memfill(target, color, spans->len); + } + else + { + uint c = ECTOR_MUL_256(color, spans->coverage); + int ialpha = 255 - spans->coverage; + for (int i = 0; i < spans->len; ++i) + target[i] = c + ECTOR_MUL_256(target[i], ialpha); + } + ++spans; + } + return; + } + + while (count--) + { + uint *target = buffer + (data->raster_buffer.width * spans->y + spans->x); + uint c = ECTOR_MUL_256(color, spans->coverage); + int ialpha = (~c) >> 24; + + for (int i = 0; i < spans->len; ++i) + target[i] = c + ECTOR_MUL_256(target[i], ialpha); + ++spans; + } +} + +int buffer_size = 2048; + +typedef void (*src_fetch) (unsigned int *buffer, Span_Data *data, int y, int x, int length); + +static void +_blend_gradient(int count, const SW_FT_Span *spans, void *userData) +{ + Span_Data *data = (Span_Data *)(userData); + src_fetch fetchfunc = NULL; + + if(data->type == LinearGradient) fetchfunc = &fetch_linear_gradient; + if(data->type == RadialGradient) fetchfunc = &fetch_radial_gradient; + + unsigned int buffer[buffer_size]; + + // move to the offset location + unsigned int *destbuffer = data->raster_buffer.buffer + (data->raster_buffer.width * data->offy + data->offx); + + while (count--) + { + unsigned int *target = destbuffer + (data->raster_buffer.width * spans->y + spans->x); + int length = spans->len; + while (length) + { + int l = MIN(length, buffer_size); + fetchfunc(buffer, data, spans->y, spans->x, l); + if (data->mul_col == 0xffffffff) + _ector_comp_func_source_over(target, buffer, l, spans->coverage); // TODO use proper composition func + else + _ector_comp_func_source_over_mul_c(target, buffer, data->mul_col, l, spans->coverage); + target += l; + length -= l; + } + ++spans; + } +} + + +/*! + \internal + spans must be sorted on y +*/ +static const +SW_FT_Span *_intersect_spans_rect(const Eina_Rectangle *clip, const SW_FT_Span *spans, const SW_FT_Span *end, + SW_FT_Span **outSpans, int available) +{ + SW_FT_Span *out = *outSpans; + const short minx = clip->x; + const short miny = clip->y; + const short maxx = minx + clip->w - 1; + const short maxy = miny + clip->h - 1; + + while (available && spans < end ) + { + if (spans->y > maxy) + { + spans = end;// update spans so that we can breakout + break; + } + if (spans->y < miny + || spans->x > maxx + || spans->x + spans->len <= minx) + { + ++spans; + continue; + } + if (spans->x < minx) + { + out->len = MIN(spans->len - (minx - spans->x), maxx - minx + 1); + out->x = minx; + } + else + { + out->x = spans->x; + out->len = MIN(spans->len, (maxx - spans->x + 1)); + } + if (out->len != 0) + { + out->y = spans->y; + out->coverage = spans->coverage; + ++out; + } + + ++spans; + --available; + } + + *outSpans = out; + + return spans; +} + +static void +_span_fill_clipRect(int spanCount, const SW_FT_Span *spans, void *userData) +{ + const int NSPANS = 256; + int clip_count, i; + SW_FT_Span cspans[NSPANS]; + Span_Data *fillData = (Span_Data *) userData; + Clip_Data clip = fillData->clip; + + clip_count = eina_array_count(clip.clips); + for (i = 0; i < clip_count ; i ++) + { + Eina_Rectangle *rect = (Eina_Rectangle *)eina_array_data_get(clip.clips, i); + Eina_Rectangle tmpRect; + + // invert transform the offset + tmpRect.x = rect->x - fillData->offx; + tmpRect.y = rect->y - fillData->offy; + tmpRect.w = rect->w; + tmpRect.h = rect->h; + //printf("Clip after Offset : %d , %d ,%d , %d\n",tmpRect.x, tmpRect.y, tmpRect.w, tmpRect.h); + //printf("Offset = %d , %d \n", fillData->offx, fillData->offy); + const SW_FT_Span *end = spans + spanCount; + + while (spans < end) + { + SW_FT_Span *clipped = cspans; + spans = _intersect_spans_rect(&tmpRect,spans, end, &clipped, NSPANS); + if (clipped - cspans) + fillData->unclipped_blend(clipped - cspans, cspans, fillData); + } + } +} + +static void +_adjust_span_fill_methods(Span_Data *spdata) +{ + switch(spdata->type) + { + case None: + spdata->unclipped_blend = 0; + break; + case Solid: + spdata->unclipped_blend = &_blend_color_argb; + break; + case LinearGradient: + case RadialGradient: + spdata->unclipped_blend = &_blend_gradient; + break; + case Image: + spdata->unclipped_blend = 0;//&_blend_image; + break; + } + + // setup clipping + if (!spdata->unclipped_blend) + { + spdata->blend = 0; + } + else if (!spdata->clip.enabled) + { + spdata->blend = spdata->unclipped_blend; + } + else if (spdata->clip.hasRectClip) + { + spdata->blend = &_span_fill_clipRect; + } + else + { + spdata->blend = &_span_fill_clipRect; //TODO change when do path clipping + } +} + + + +void ector_software_rasterizer_init(Software_Rasterizer *rasterizer) +{ + // initialize the rasterizer and stroker + unsigned char* renderPool = (unsigned char*) malloc(1024 * 100); + sw_ft_grays_raster.raster_new(&rasterizer->raster); + sw_ft_grays_raster.raster_reset(rasterizer->raster, renderPool, 1024*100); + + SW_FT_Stroker_New(&rasterizer->stroker); + SW_FT_Stroker_Set(rasterizer->stroker, 1<<6,SW_FT_STROKER_LINECAP_BUTT,SW_FT_STROKER_LINEJOIN_MITER,0); + + //initialize the span data. + rasterizer->fillData.raster_buffer.buffer = NULL; + rasterizer->fillData.clip.enabled = EINA_FALSE; + rasterizer->fillData.unclipped_blend = 0; + rasterizer->fillData.blend = 0; +} + +void ector_software_rasterizer_done(Software_Rasterizer *rasterizer) +{ + sw_ft_grays_raster.raster_done(rasterizer->raster); + SW_FT_Stroker_Done(rasterizer->stroker); + //TODO free the pool memory +} + + +void ector_software_rasterizer_stroke_set(Software_Rasterizer *rasterizer, double width, + Efl_Gfx_Cap cap_style, Efl_Gfx_Join join_style) +{ + SW_FT_Stroker_LineCap cap; + SW_FT_Stroker_LineJoin join; + + switch (cap_style) + { + case EFL_GFX_CAP_SQUARE: + cap = SW_FT_STROKER_LINECAP_SQUARE; + break; + case EFL_GFX_CAP_ROUND: + cap = SW_FT_STROKER_LINECAP_ROUND; + break; + default: + cap = SW_FT_STROKER_LINECAP_BUTT; + break; + } + + switch (join_style) + { + case EFL_GFX_JOIN_BEVEL: + join = SW_FT_STROKER_LINEJOIN_BEVEL; + break; + case EFL_GFX_JOIN_ROUND: + join = SW_FT_STROKER_LINEJOIN_ROUND; + break; + default: + join = SW_FT_STROKER_LINEJOIN_MITER; + break; + } + + int stroke_width = (int)(width * 64); + SW_FT_Stroker_Set(rasterizer->stroker, stroke_width, cap, join, 0); +} + +static void +_rle_generation_cb( int count, const SW_FT_Span* spans,void *user) +{ + Shape_Rle_Data *rle = (Shape_Rle_Data *) user; + int newsize = rle->size + count; + + // allocate enough memory for new spans + // alloc is required to prevent free and reallocation + // when the rle needs to be regenerated because of attribute change. + if(rle->alloc < newsize) + { + rle->spans = (SW_FT_Span *) realloc(rle->spans, newsize * sizeof(SW_FT_Span)); + rle->alloc = newsize; + } + + // copy the new spans to the allocated memory + SW_FT_Span *lastspan = (rle->spans + rle->size); + memcpy(lastspan,spans, count * sizeof(SW_FT_Span)); + + // update the size + rle->size = newsize; +} + +Shape_Rle_Data * +ector_software_rasterizer_generate_rle_data(Software_Rasterizer *rasterizer, SW_FT_Outline *outline) +{ + Shape_Rle_Data *rle_data = (Shape_Rle_Data *) calloc(1, sizeof(Shape_Rle_Data)); + SW_FT_Raster_Params params; + + params.flags = SW_FT_RASTER_FLAG_DIRECT | SW_FT_RASTER_FLAG_AA ; + params.gray_spans = &_rle_generation_cb; + params.user = rle_data; + params.source = outline; + + sw_ft_grays_raster.raster_render(rasterizer->raster, ¶ms); + + return rle_data; +} + +Shape_Rle_Data * +ector_software_rasterizer_generate_stroke_rle_data(Software_Rasterizer *rasterizer, SW_FT_Outline *outline, Eina_Bool closePath) +{ + uint points,contors; + + SW_FT_Stroker_ParseOutline(rasterizer->stroker, outline, !closePath); + SW_FT_Stroker_GetCounts(rasterizer->stroker,&points, &contors); + + SW_FT_Outline strokeOutline = {0}; + strokeOutline.points = (SW_FT_Vector *) calloc(points, sizeof(SW_FT_Vector)); + strokeOutline.tags = (char *) calloc(points, sizeof(char)); + strokeOutline.contours = (short *) calloc(contors, sizeof(short)); + + SW_FT_Stroker_Export(rasterizer->stroker, &strokeOutline); + + Shape_Rle_Data *rle_data = ector_software_rasterizer_generate_rle_data(rasterizer, &strokeOutline); + + // cleanup the outline data. + free(strokeOutline.points); + free(strokeOutline.tags); + free(strokeOutline.contours); + + return rle_data; +} + +void ector_software_rasterizer_destroy_rle_data(Shape_Rle_Data *rle) +{ + if (rle) + { + if (rle->spans) + free(rle->spans); + free(rle); + } +} + +static +void _setup_span_fill_matrix(Software_Rasterizer *rasterizer) +{ + if (rasterizer->transform) + { + eina_matrix3_inverse(rasterizer->transform, &rasterizer->fillData.inv); + } + else + { + eina_matrix3_identity(&rasterizer->fillData.inv); + eina_matrix3_identity(&rasterizer->fillData.inv); + } +} + +void ector_software_rasterizer_transform_set(Software_Rasterizer *rasterizer, Eina_Matrix3 *t) +{ + rasterizer->transform = t; +} + +void ector_software_rasterizer_clip_rect_set(Software_Rasterizer *rasterizer, Eina_Array *clips) +{ + if (clips) + { + rasterizer->fillData.clip.clips = clips; + rasterizer->fillData.clip.hasRectClip = EINA_TRUE; + rasterizer->fillData.clip.enabled = EINA_TRUE; + } + else + { + rasterizer->fillData.clip.clips = NULL; + rasterizer->fillData.clip.hasRectClip = EINA_FALSE; + rasterizer->fillData.clip.enabled = EINA_FALSE; + } +} + +void ector_software_rasterizer_clip_shape_set(Software_Rasterizer *rasterizer, Shape_Rle_Data *clip) +{ + rasterizer->fillData.clip.path = clip; + rasterizer->fillData.clip.hasPathClip = EINA_TRUE; + rasterizer->fillData.clip.enabled = EINA_TRUE; +} + +void ector_software_rasterizer_color_set(Software_Rasterizer *rasterizer, int r, int g, int b, int a) +{ + uint color = ECTOR_ARGB_JOIN(a, r, g, b); + + rasterizer->fillData.color = _ector_premultiply(color); + rasterizer->fillData.type = Solid; +} +void ector_software_rasterizer_linear_gradient_set(Software_Rasterizer *rasterizer, Ector_Renderer_Software_Gradient_Data *linear) +{ + rasterizer->fillData.gradient = linear; + rasterizer->fillData.type = LinearGradient; +} +void ector_software_rasterizer_radial_gradient_set(Software_Rasterizer *rasterizer, Ector_Renderer_Software_Gradient_Data *radial) +{ + rasterizer->fillData.gradient = radial; + rasterizer->fillData.type = RadialGradient; +} + + +void ector_software_rasterizer_draw_rle_data(Software_Rasterizer *rasterizer, + int x, int y, uint mul_col, Ector_Rop op, Shape_Rle_Data* rle) +{ + // check for NULL rle data + if (!rle) return; + + rasterizer->fillData.offx = x; + rasterizer->fillData.offy = y; + rasterizer->fillData.mul_col = mul_col; + rasterizer->fillData.op = op; + + _setup_span_fill_matrix(rasterizer); + _adjust_span_fill_methods(&rasterizer->fillData); + + if(rasterizer->fillData.blend) + rasterizer->fillData.blend(rle->size, rle->spans, &rasterizer->fillData); +} diff --git a/src/lib/ector/software/ector_software_surface.c b/src/lib/ector/software/ector_software_surface.c new file mode 100644 index 0000000000..e32477ecc0 --- /dev/null +++ b/src/lib/ector/software/ector_software_surface.c @@ -0,0 +1,94 @@ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include + +#include "ector_private.h" +#include "ector_software_private.h" + +static unsigned int _software_count = 0; + +typedef struct _Ector_Renderer_Software_Base_Data Ector_Renderer_Software_Base_Data; +struct _Ector_Renderer_Software_Base_Data +{ +}; + +static Ector_Renderer * +_ector_software_surface_ector_generic_surface_renderer_factory_new(Eo *obj, + Ector_Software_Surface_Data *pd EINA_UNUSED, + const Eo_Class *type) +{ + if (type == ECTOR_RENDERER_GENERIC_SHAPE_MIXIN) + return eo_add(ECTOR_RENDERER_SOFTWARE_SHAPE_CLASS, obj); + else if (type == ECTOR_RENDERER_GENERIC_GRADIENT_LINEAR_MIXIN) + return eo_add(ECTOR_RENDERER_SOFTWARE_GRADIENT_LINEAR_CLASS, obj); + else if (type == ECTOR_RENDERER_GENERIC_GRADIENT_RADIAL_MIXIN) + return eo_add(ECTOR_RENDERER_SOFTWARE_GRADIENT_RADIAL_CLASS, obj); + ERR("Couldn't find class for type: %s\n", eo_class_name_get(type)); + return NULL; +} + +static void +_ector_software_surface_context_set(Eo *obj EINA_UNUSED, + Ector_Software_Surface_Data *pd, + Software_Rasterizer *ctx) +{ + pd->software = ctx; +} + +static Software_Rasterizer * +_ector_software_surface_context_get(Eo *obj EINA_UNUSED, + Ector_Software_Surface_Data *pd) +{ + return pd->software; +} + +void +_ector_software_surface_surface_set(Eo *obj EINA_UNUSED, + Ector_Software_Surface_Data *pd, + void *pixels, unsigned int width, unsigned int height) +{ + pd->software->fillData.raster_buffer.buffer = pixels; + pd->software->fillData.raster_buffer.width = width; + pd->software->fillData.raster_buffer.height = height; +} + +void +_ector_software_surface_surface_get(Eo *obj EINA_UNUSED, + Ector_Software_Surface_Data *pd, + void **pixels, unsigned int *width, unsigned int *height) +{ + *pixels = pd->software->fillData.raster_buffer.buffer; + *width = pd->software->fillData.raster_buffer.width; + *height = pd->software->fillData.raster_buffer.height; +} + +static void +_ector_software_surface_eo_base_constructor(Eo *obj, + Ector_Software_Surface_Data *pd EINA_UNUSED) +{ + eo_do_super(obj, ECTOR_SOFTWARE_SURFACE_CLASS, eo_constructor()); + if(_software_count == 0) + { + pd->software = (Software_Rasterizer *) calloc(1, sizeof(Software_Rasterizer)); + ector_software_rasterizer_init(pd->software); + } + _software_count++; +} + +static void +_ector_software_surface_eo_base_destructor(Eo *obj EINA_UNUSED, + Ector_Software_Surface_Data *pd EINA_UNUSED) +{ + --_software_count; + if (_software_count > 0) return; + ector_software_rasterizer_done(pd->software); + free(pd->software); + pd->software = NULL; + eo_do_super(obj, ECTOR_SOFTWARE_SURFACE_CLASS, eo_destructor()); +} + +#include "ector_software_surface.eo.c" +#include "ector_renderer_software_base.eo.c" diff --git a/src/lib/ector/software/ector_software_surface.eo b/src/lib/ector/software/ector_software_surface.eo new file mode 100644 index 0000000000..58a6a771f6 --- /dev/null +++ b/src/lib/ector/software/ector_software_surface.eo @@ -0,0 +1,33 @@ +class Ector.Software.Surface (Ector.Generic.Surface) +{ + eo_prefix: ector_software_surface; + legacy_prefix: null; + properties { + context { + set { + } + get { + } + values { + Software_Rasterizer *ctx; + } + } + surface { + set { + } + get { + } + values { + void *pixels; + uint width; + uint height; + } + } + } + + implements { + Ector.Generic.Surface.renderer_factory_new; + Eo.Base.destructor; + Eo.Base.constructor; + } +} diff --git a/src/lib/ector/software/sw_ft_math.c b/src/lib/ector/software/sw_ft_math.c new file mode 100755 index 0000000000..9b3894ff8d --- /dev/null +++ b/src/lib/ector/software/sw_ft_math.c @@ -0,0 +1,528 @@ +/***************************************************************************/ +/* */ +/* fttrigon.c */ +/* */ +/* FreeType trigonometric functions (body). */ +/* */ +/* Copyright 2001-2005, 2012-2013 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + +#include +#include "sw_ft_math.h" + + +#define SW_FT_MSB( x ) ( 31 - __builtin_clz( x ) ) + +#define SW_FT_PAD_FLOOR( x, n ) ( (x) & ~((n)-1) ) +#define SW_FT_PAD_ROUND( x, n ) SW_FT_PAD_FLOOR( (x) + ((n)/2), n ) +#define SW_FT_PAD_CEIL( x, n ) SW_FT_PAD_FLOOR( (x) + ((n)-1), n ) + + +#define SW_FT_BEGIN_STMNT do { +#define SW_FT_END_STMNT } while ( 0 ) +/* transfer sign leaving a positive number */ +#define SW_FT_MOVE_SIGN( x, s ) \ +SW_FT_BEGIN_STMNT \ + if ( x < 0 ) \ + { \ + x = -x; \ + s = -s; \ + } \ +SW_FT_END_STMNT + + + + +SW_FT_Long +SW_FT_MulFix( SW_FT_Long a, + SW_FT_Long b ) +{ + SW_FT_Int s = 1; + SW_FT_Long c; + + + SW_FT_MOVE_SIGN( a, s ); + SW_FT_MOVE_SIGN( b, s ); + + c = (SW_FT_Long)( ( (SW_FT_Int64)a * b + 0x8000L ) >> 16 ); + + return ( s > 0 ) ? c : -c; +} + +SW_FT_Long +SW_FT_MulDiv( SW_FT_Long a, + SW_FT_Long b, + SW_FT_Long c ) +{ + SW_FT_Int s = 1; + SW_FT_Long d; + + + SW_FT_MOVE_SIGN( a, s ); + SW_FT_MOVE_SIGN( b, s ); + SW_FT_MOVE_SIGN( c, s ); + + d = (SW_FT_Long)( c > 0 ? ( (SW_FT_Int64)a * b + ( c >> 1 ) ) / c + : 0x7FFFFFFFL ); + + return ( s > 0 ) ? d : -d; +} + +SW_FT_Long +SW_FT_DivFix( SW_FT_Long a, + SW_FT_Long b ) +{ + SW_FT_Int s = 1; + SW_FT_Long q; + + + SW_FT_MOVE_SIGN( a, s ); + SW_FT_MOVE_SIGN( b, s ); + + q = (SW_FT_Long)( b > 0 ? ( ( (SW_FT_UInt64)a << 16 ) + ( b >> 1 ) ) / b + : 0x7FFFFFFFL ); + + return ( s < 0 ? -q : q ); +} + + +/*************************************************************************/ +/* */ +/* This is a fixed-point CORDIC implementation of trigonometric */ +/* functions as well as transformations between Cartesian and polar */ +/* coordinates. The angles are represented as 16.16 fixed-point values */ +/* in degrees, i.e., the angular resolution is 2^-16 degrees. Note that */ +/* only vectors longer than 2^16*180/pi (or at least 22 bits) on a */ +/* discrete Cartesian grid can have the same or better angular */ +/* resolution. Therefore, to maintain this precision, some functions */ +/* require an interim upscaling of the vectors, whereas others operate */ +/* with 24-bit long vectors directly. */ +/* */ +/*************************************************************************/ + + /* the Cordic shrink factor 0.858785336480436 * 2^32 */ +#define SW_FT_TRIG_SCALE 0xDBD95B16UL + + /* the highest bit in overflow-safe vector components, */ + /* MSB of 0.858785336480436 * sqrt(0.5) * 2^30 */ +#define SW_FT_TRIG_SAFE_MSB 29 + + /* this table was generated for SW_FT_PI = 180L << 16, i.e. degrees */ +#define SW_FT_TRIG_MAX_ITERS 23 + + static const SW_FT_Fixed + ft_trig_arctan_table[] = + { + 1740967L, 919879L, 466945L, 234379L, 117304L, 58666L, 29335L, + 14668L, 7334L, 3667L, 1833L, 917L, 458L, 229L, 115L, + 57L, 29L, 14L, 7L, 4L, 2L, 1L + }; + + /* multiply a given value by the CORDIC shrink factor */ + static SW_FT_Fixed + ft_trig_downscale( SW_FT_Fixed val ) + { + SW_FT_Fixed s; + SW_FT_Int64 v; + + + s = val; + val = SW_FT_ABS( val ); + + v = ( val * (SW_FT_Int64)SW_FT_TRIG_SCALE ) + 0x100000000UL; + val = (SW_FT_Fixed)( v >> 32 ); + + return ( s >= 0 ) ? val : -val; + } + + + + /* undefined and never called for zero vector */ + static SW_FT_Int + ft_trig_prenorm( SW_FT_Vector* vec ) + { + SW_FT_Pos x, y; + SW_FT_Int shift; + + + x = vec->x; + y = vec->y; + + shift = SW_FT_MSB( SW_FT_ABS( x ) | SW_FT_ABS( y ) ); + + if ( shift <= SW_FT_TRIG_SAFE_MSB ) + { + shift = SW_FT_TRIG_SAFE_MSB - shift; + vec->x = (SW_FT_Pos)( (SW_FT_ULong)x << shift ); + vec->y = (SW_FT_Pos)( (SW_FT_ULong)y << shift ); + } + else + { + shift -= SW_FT_TRIG_SAFE_MSB; + vec->x = x >> shift; + vec->y = y >> shift; + shift = -shift; + } + + return shift; + } + + + static void + ft_trig_pseudo_rotate( SW_FT_Vector* vec, + SW_FT_Angle theta ) + { + SW_FT_Int i; + SW_FT_Fixed x, y, xtemp, b; + const SW_FT_Fixed *arctanptr; + + + x = vec->x; + y = vec->y; + + /* Rotate inside [-PI/4,PI/4] sector */ + while ( theta < -SW_FT_ANGLE_PI4 ) + { + xtemp = y; + y = -x; + x = xtemp; + theta += SW_FT_ANGLE_PI2; + } + + while ( theta > SW_FT_ANGLE_PI4 ) + { + xtemp = -y; + y = x; + x = xtemp; + theta -= SW_FT_ANGLE_PI2; + } + + arctanptr = ft_trig_arctan_table; + + /* Pseudorotations, with right shifts */ + for ( i = 1, b = 1; i < SW_FT_TRIG_MAX_ITERS; b <<= 1, i++ ) + { + if ( theta < 0 ) + { + xtemp = x + ( ( y + b ) >> i ); + y = y - ( ( x + b ) >> i ); + x = xtemp; + theta += *arctanptr++; + } + else + { + xtemp = x - ( ( y + b ) >> i ); + y = y + ( ( x + b ) >> i ); + x = xtemp; + theta -= *arctanptr++; + } + } + + vec->x = x; + vec->y = y; + } + + + static void + ft_trig_pseudo_polarize( SW_FT_Vector* vec ) + { + SW_FT_Angle theta; + SW_FT_Int i; + SW_FT_Fixed x, y, xtemp, b; + const SW_FT_Fixed *arctanptr; + + + x = vec->x; + y = vec->y; + + /* Get the vector into [-PI/4,PI/4] sector */ + if ( y > x ) + { + if ( y > -x ) + { + theta = SW_FT_ANGLE_PI2; + xtemp = y; + y = -x; + x = xtemp; + } + else + { + theta = y > 0 ? SW_FT_ANGLE_PI : -SW_FT_ANGLE_PI; + x = -x; + y = -y; + } + } + else + { + if ( y < -x ) + { + theta = -SW_FT_ANGLE_PI2; + xtemp = -y; + y = x; + x = xtemp; + } + else + { + theta = 0; + } + } + + arctanptr = ft_trig_arctan_table; + + /* Pseudorotations, with right shifts */ + for ( i = 1, b = 1; i < SW_FT_TRIG_MAX_ITERS; b <<= 1, i++ ) + { + if ( y > 0 ) + { + xtemp = x + ( ( y + b ) >> i ); + y = y - ( ( x + b ) >> i ); + x = xtemp; + theta += *arctanptr++; + } + else + { + xtemp = x - ( ( y + b ) >> i ); + y = y + ( ( x + b ) >> i ); + x = xtemp; + theta -= *arctanptr++; + } + } + + /* round theta */ + if ( theta >= 0 ) + theta = SW_FT_PAD_ROUND( theta, 32 ); + else + theta = -SW_FT_PAD_ROUND( -theta, 32 ); + + vec->x = x; + vec->y = theta; + } + + + /* documentation is in fttrigon.h */ + + SW_FT_Fixed + SW_FT_Cos( SW_FT_Angle angle ) + { + SW_FT_Vector v; + + + v.x = SW_FT_TRIG_SCALE >> 8; + v.y = 0; + ft_trig_pseudo_rotate( &v, angle ); + + return ( v.x + 0x80L ) >> 8; + } + + + /* documentation is in fttrigon.h */ + + SW_FT_Fixed + SW_FT_Sin( SW_FT_Angle angle ) + { + return SW_FT_Cos( SW_FT_ANGLE_PI2 - angle ); + } + + + /* documentation is in fttrigon.h */ + + SW_FT_Fixed + SW_FT_Tan( SW_FT_Angle angle ) + { + SW_FT_Vector v; + + + v.x = SW_FT_TRIG_SCALE >> 8; + v.y = 0; + ft_trig_pseudo_rotate( &v, angle ); + + return SW_FT_DivFix( v.y, v.x ); + } + + + /* documentation is in fttrigon.h */ + + SW_FT_Angle + SW_FT_Atan2( SW_FT_Fixed dx, + SW_FT_Fixed dy ) + { + SW_FT_Vector v; + + + if ( dx == 0 && dy == 0 ) + return 0; + + v.x = dx; + v.y = dy; + ft_trig_prenorm( &v ); + ft_trig_pseudo_polarize( &v ); + + return v.y; + } + + + /* documentation is in fttrigon.h */ + + void + SW_FT_Vector_Unit( SW_FT_Vector* vec, + SW_FT_Angle angle ) + { + vec->x = SW_FT_TRIG_SCALE >> 8; + vec->y = 0; + ft_trig_pseudo_rotate( vec, angle ); + vec->x = ( vec->x + 0x80L ) >> 8; + vec->y = ( vec->y + 0x80L ) >> 8; + } + + + /* these macros return 0 for positive numbers, + and -1 for negative ones */ +#define SW_FT_SIGN_LONG( x ) ( (x) >> ( SW_FT_SIZEOF_LONG * 8 - 1 ) ) +#define SW_FT_SIGN_INT( x ) ( (x) >> ( SW_FT_SIZEOF_INT * 8 - 1 ) ) +#define SW_FT_SIGN_INT32( x ) ( (x) >> 31 ) +#define SW_FT_SIGN_INT16( x ) ( (x) >> 15 ) + + + /* documentation is in fttrigon.h */ + + void + SW_FT_Vector_Rotate( SW_FT_Vector* vec, + SW_FT_Angle angle ) + { + SW_FT_Int shift; + SW_FT_Vector v; + + + v.x = vec->x; + v.y = vec->y; + + if ( angle && ( v.x != 0 || v.y != 0 ) ) + { + shift = ft_trig_prenorm( &v ); + ft_trig_pseudo_rotate( &v, angle ); + v.x = ft_trig_downscale( v.x ); + v.y = ft_trig_downscale( v.y ); + + if ( shift > 0 ) + { + SW_FT_Int32 half = (SW_FT_Int32)1L << ( shift - 1 ); + + + vec->x = ( v.x + half + SW_FT_SIGN_LONG( v.x ) ) >> shift; + vec->y = ( v.y + half + SW_FT_SIGN_LONG( v.y ) ) >> shift; + } + else + { + shift = -shift; + vec->x = (SW_FT_Pos)( (SW_FT_ULong)v.x << shift ); + vec->y = (SW_FT_Pos)( (SW_FT_ULong)v.y << shift ); + } + } + } + + + /* documentation is in fttrigon.h */ + + SW_FT_Fixed + SW_FT_Vector_Length( SW_FT_Vector* vec ) + { + SW_FT_Int shift; + SW_FT_Vector v; + + + v = *vec; + + /* handle trivial cases */ + if ( v.x == 0 ) + { + return SW_FT_ABS( v.y ); + } + else if ( v.y == 0 ) + { + return SW_FT_ABS( v.x ); + } + + /* general case */ + shift = ft_trig_prenorm( &v ); + ft_trig_pseudo_polarize( &v ); + + v.x = ft_trig_downscale( v.x ); + + if ( shift > 0 ) + return ( v.x + ( 1 << ( shift - 1 ) ) ) >> shift; + + return (SW_FT_Fixed)( (SW_FT_UInt32)v.x << -shift ); + } + + + /* documentation is in fttrigon.h */ + + void + SW_FT_Vector_Polarize( SW_FT_Vector* vec, + SW_FT_Fixed *length, + SW_FT_Angle *angle ) + { + SW_FT_Int shift; + SW_FT_Vector v; + + + v = *vec; + + if ( v.x == 0 && v.y == 0 ) + return; + + shift = ft_trig_prenorm( &v ); + ft_trig_pseudo_polarize( &v ); + + v.x = ft_trig_downscale( v.x ); + + *length = ( shift >= 0 ) ? ( v.x >> shift ) + : (SW_FT_Fixed)( (SW_FT_UInt32)v.x << -shift ); + *angle = v.y; + } + + + /* documentation is in fttrigon.h */ + + void + SW_FT_Vector_From_Polar( SW_FT_Vector* vec, + SW_FT_Fixed length, + SW_FT_Angle angle ) + { + vec->x = length; + vec->y = 0; + + SW_FT_Vector_Rotate( vec, angle ); + } + + + /* documentation is in fttrigon.h */ + + SW_FT_Angle + SW_FT_Angle_Diff( SW_FT_Angle angle1, + SW_FT_Angle angle2 ) + { + SW_FT_Angle delta = angle2 - angle1; + + + delta %= SW_FT_ANGLE_2PI; + if ( delta < 0 ) + delta += SW_FT_ANGLE_2PI; + + if ( delta > SW_FT_ANGLE_PI ) + delta -= SW_FT_ANGLE_2PI; + + return delta; + } + + +/* END */ + diff --git a/src/lib/ector/software/sw_ft_math.h b/src/lib/ector/software/sw_ft_math.h new file mode 100755 index 0000000000..b844834a3b --- /dev/null +++ b/src/lib/ector/software/sw_ft_math.h @@ -0,0 +1,438 @@ +#ifndef SW_FT_MATH_H +#define SW_FT_MATH_H + +/***************************************************************************/ +/* */ +/* fttrigon.h */ +/* */ +/* FreeType trigonometric functions (specification). */ +/* */ +/* Copyright 2001, 2003, 2005, 2007, 2013 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + +#include "sw_ft_types.h" + + +/*************************************************************************/ +/* */ +/* The min and max functions missing in C. As usual, be careful not to */ +/* write things like SW_FT_MIN( a++, b++ ) to avoid side effects. */ +/* */ +#define SW_FT_MIN( a, b ) ( (a) < (b) ? (a) : (b) ) +#define SW_FT_MAX( a, b ) ( (a) > (b) ? (a) : (b) ) + +#define SW_FT_ABS( a ) ( (a) < 0 ? -(a) : (a) ) + +/* + * Approximate sqrt(x*x+y*y) using the `alpha max plus beta min' + * algorithm. We use alpha = 1, beta = 3/8, giving us results with a + * largest error less than 7% compared to the exact value. + */ +#define SW_FT_HYPOT( x, y ) \ + ( x = SW_FT_ABS( x ), \ + y = SW_FT_ABS( y ), \ + x > y ? x + ( 3 * y >> 3 ) \ + : y + ( 3 * x >> 3 ) ) + +/*************************************************************************/ +/* */ +/* */ +/* SW_FT_MulFix */ +/* */ +/* */ +/* A very simple function used to perform the computation */ +/* `(a*b)/0x10000' with maximum accuracy. Most of the time this is */ +/* used to multiply a given value by a 16.16 fixed-point factor. */ +/* */ +/* */ +/* a :: The first multiplier. */ +/* b :: The second multiplier. Use a 16.16 factor here whenever */ +/* possible (see note below). */ +/* */ +/* */ +/* The result of `(a*b)/0x10000'. */ +/* */ +/* */ +/* This function has been optimized for the case where the absolute */ +/* value of `a' is less than 2048, and `b' is a 16.16 scaling factor. */ +/* As this happens mainly when scaling from notional units to */ +/* fractional pixels in FreeType, it resulted in noticeable speed */ +/* improvements between versions 2.x and 1.x. */ +/* */ +/* As a conclusion, always try to place a 16.16 factor as the */ +/* _second_ argument of this function; this can make a great */ +/* difference. */ +/* */ +SW_FT_Long +SW_FT_MulFix( SW_FT_Long a, + SW_FT_Long b ); + +/*************************************************************************/ +/* */ +/* */ +/* SW_FT_MulDiv */ +/* */ +/* */ +/* A very simple function used to perform the computation `(a*b)/c' */ +/* with maximum accuracy (it uses a 64-bit intermediate integer */ +/* whenever necessary). */ +/* */ +/* This function isn't necessarily as fast as some processor specific */ +/* operations, but is at least completely portable. */ +/* */ +/* */ +/* a :: The first multiplier. */ +/* b :: The second multiplier. */ +/* c :: The divisor. */ +/* */ +/* */ +/* The result of `(a*b)/c'. This function never traps when trying to */ +/* divide by zero; it simply returns `MaxInt' or `MinInt' depending */ +/* on the signs of `a' and `b'. */ +/* */ +SW_FT_Long +SW_FT_MulDiv( SW_FT_Long a, + SW_FT_Long b, + SW_FT_Long c ); + +/*************************************************************************/ +/* */ +/* */ +/* SW_FT_DivFix */ +/* */ +/* */ +/* A very simple function used to perform the computation */ +/* `(a*0x10000)/b' with maximum accuracy. Most of the time, this is */ +/* used to divide a given value by a 16.16 fixed-point factor. */ +/* */ +/* */ +/* a :: The numerator. */ +/* b :: The denominator. Use a 16.16 factor here. */ +/* */ +/* */ +/* The result of `(a*0x10000)/b'. */ +/* */ +SW_FT_Long +SW_FT_DivFix( SW_FT_Long a, + SW_FT_Long b ); + + + + /*************************************************************************/ + /* */ + /*
*/ + /* computations */ + /* */ + /*************************************************************************/ + + + /************************************************************************* + * + * @type: + * SW_FT_Angle + * + * @description: + * This type is used to model angle values in FreeType. Note that the + * angle is a 16.16 fixed-point value expressed in degrees. + * + */ + typedef SW_FT_Fixed SW_FT_Angle; + + + /************************************************************************* + * + * @macro: + * SW_FT_ANGLE_PI + * + * @description: + * The angle pi expressed in @SW_FT_Angle units. + * + */ +#define SW_FT_ANGLE_PI ( 180L << 16 ) + + + /************************************************************************* + * + * @macro: + * SW_FT_ANGLE_2PI + * + * @description: + * The angle 2*pi expressed in @SW_FT_Angle units. + * + */ +#define SW_FT_ANGLE_2PI ( SW_FT_ANGLE_PI * 2 ) + + + /************************************************************************* + * + * @macro: + * SW_FT_ANGLE_PI2 + * + * @description: + * The angle pi/2 expressed in @SW_FT_Angle units. + * + */ +#define SW_FT_ANGLE_PI2 ( SW_FT_ANGLE_PI / 2 ) + + + /************************************************************************* + * + * @macro: + * SW_FT_ANGLE_PI4 + * + * @description: + * The angle pi/4 expressed in @SW_FT_Angle units. + * + */ +#define SW_FT_ANGLE_PI4 ( SW_FT_ANGLE_PI / 4 ) + + + /************************************************************************* + * + * @function: + * SW_FT_Sin + * + * @description: + * Return the sinus of a given angle in fixed-point format. + * + * @input: + * angle :: + * The input angle. + * + * @return: + * The sinus value. + * + * @note: + * If you need both the sinus and cosinus for a given angle, use the + * function @SW_FT_Vector_Unit. + * + */ + SW_FT_Fixed + SW_FT_Sin( SW_FT_Angle angle ); + + + /************************************************************************* + * + * @function: + * SW_FT_Cos + * + * @description: + * Return the cosinus of a given angle in fixed-point format. + * + * @input: + * angle :: + * The input angle. + * + * @return: + * The cosinus value. + * + * @note: + * If you need both the sinus and cosinus for a given angle, use the + * function @SW_FT_Vector_Unit. + * + */ + SW_FT_Fixed + SW_FT_Cos( SW_FT_Angle angle ); + + + /************************************************************************* + * + * @function: + * SW_FT_Tan + * + * @description: + * Return the tangent of a given angle in fixed-point format. + * + * @input: + * angle :: + * The input angle. + * + * @return: + * The tangent value. + * + */ + SW_FT_Fixed + SW_FT_Tan( SW_FT_Angle angle ); + + + /************************************************************************* + * + * @function: + * SW_FT_Atan2 + * + * @description: + * Return the arc-tangent corresponding to a given vector (x,y) in + * the 2d plane. + * + * @input: + * x :: + * The horizontal vector coordinate. + * + * y :: + * The vertical vector coordinate. + * + * @return: + * The arc-tangent value (i.e. angle). + * + */ + SW_FT_Angle + SW_FT_Atan2( SW_FT_Fixed x, + SW_FT_Fixed y ); + + + /************************************************************************* + * + * @function: + * SW_FT_Angle_Diff + * + * @description: + * Return the difference between two angles. The result is always + * constrained to the ]-PI..PI] interval. + * + * @input: + * angle1 :: + * First angle. + * + * angle2 :: + * Second angle. + * + * @return: + * Constrained value of `value2-value1'. + * + */ + SW_FT_Angle + SW_FT_Angle_Diff( SW_FT_Angle angle1, + SW_FT_Angle angle2 ); + + + /************************************************************************* + * + * @function: + * SW_FT_Vector_Unit + * + * @description: + * Return the unit vector corresponding to a given angle. After the + * call, the value of `vec.x' will be `sin(angle)', and the value of + * `vec.y' will be `cos(angle)'. + * + * This function is useful to retrieve both the sinus and cosinus of a + * given angle quickly. + * + * @output: + * vec :: + * The address of target vector. + * + * @input: + * angle :: + * The input angle. + * + */ + void + SW_FT_Vector_Unit( SW_FT_Vector* vec, + SW_FT_Angle angle ); + + + /************************************************************************* + * + * @function: + * SW_FT_Vector_Rotate + * + * @description: + * Rotate a vector by a given angle. + * + * @inout: + * vec :: + * The address of target vector. + * + * @input: + * angle :: + * The input angle. + * + */ + void + SW_FT_Vector_Rotate( SW_FT_Vector* vec, + SW_FT_Angle angle ); + + + /************************************************************************* + * + * @function: + * SW_FT_Vector_Length + * + * @description: + * Return the length of a given vector. + * + * @input: + * vec :: + * The address of target vector. + * + * @return: + * The vector length, expressed in the same units that the original + * vector coordinates. + * + */ + SW_FT_Fixed + SW_FT_Vector_Length( SW_FT_Vector* vec ); + + + /************************************************************************* + * + * @function: + * SW_FT_Vector_Polarize + * + * @description: + * Compute both the length and angle of a given vector. + * + * @input: + * vec :: + * The address of source vector. + * + * @output: + * length :: + * The vector length. + * + * angle :: + * The vector angle. + * + */ + void + SW_FT_Vector_Polarize( SW_FT_Vector* vec, + SW_FT_Fixed *length, + SW_FT_Angle *angle ); + + + /************************************************************************* + * + * @function: + * SW_FT_Vector_From_Polar + * + * @description: + * Compute vector coordinates from a length and angle. + * + * @output: + * vec :: + * The address of source vector. + * + * @input: + * length :: + * The vector length. + * + * angle :: + * The vector angle. + * + */ + void + SW_FT_Vector_From_Polar( SW_FT_Vector* vec, + SW_FT_Fixed length, + SW_FT_Angle angle ); + + +#endif // SW_FT_MATH_H diff --git a/src/lib/ector/software/sw_ft_raster.c b/src/lib/ector/software/sw_ft_raster.c new file mode 100644 index 0000000000..2956123b10 --- /dev/null +++ b/src/lib/ector/software/sw_ft_raster.c @@ -0,0 +1,1846 @@ +/***************************************************************************/ +/* */ +/* ftgrays.c */ +/* */ +/* A new `perfect' anti-aliasing renderer (body). */ +/* */ +/* Copyright 2000-2003, 2005-2014 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + /*************************************************************************/ + /* */ + /* This is a new anti-aliasing scan-converter for FreeType 2. The */ + /* algorithm used here is _very_ different from the one in the standard */ + /* `ftraster' module. Actually, `ftgrays' computes the _exact_ */ + /* coverage of the outline on each pixel cell. */ + /* */ + /* It is based on ideas that I initially found in Raph Levien's */ + /* excellent LibArt graphics library (see http://www.levien.com/libart */ + /* for more information, though the web pages do not tell anything */ + /* about the renderer; you'll have to dive into the source code to */ + /* understand how it works). */ + /* */ + /* Note, however, that this is a _very_ different implementation */ + /* compared to Raph's. Coverage information is stored in a very */ + /* different way, and I don't use sorted vector paths. Also, it doesn't */ + /* use floating point values. */ + /* */ + /* This renderer has the following advantages: */ + /* */ + /* - It doesn't need an intermediate bitmap. Instead, one can supply a */ + /* callback function that will be called by the renderer to draw gray */ + /* spans on any target surface. You can thus do direct composition on */ + /* any kind of bitmap, provided that you give the renderer the right */ + /* callback. */ + /* */ + /* - A perfect anti-aliaser, i.e., it computes the _exact_ coverage on */ + /* each pixel cell. */ + /* */ + /* - It performs a single pass on the outline (the `standard' FT2 */ + /* renderer makes two passes). */ + /* */ + /* - It can easily be modified to render to _any_ number of gray levels */ + /* cheaply. */ + /* */ + /* - For small (< 20) pixel sizes, it is faster than the standard */ + /* renderer. */ + /* */ + /*************************************************************************/ + + +#include "sw_ft_raster.h" +#include "sw_ft_math.h" + + /* Auxiliary macros for token concatenation. */ +#define SW_FT_ERR_XCAT( x, y ) x ## y +#define SW_FT_ERR_CAT( x, y ) SW_FT_ERR_XCAT( x, y ) + +#define SW_FT_BEGIN_STMNT do { +#define SW_FT_END_STMNT } while ( 0 ) + + +#include +#include +#include +#include +#define SW_FT_UINT_MAX UINT_MAX +#define SW_FT_INT_MAX INT_MAX + +#define ft_memset memset + +#define ft_setjmp setjmp +#define ft_longjmp longjmp +#define ft_jmp_buf jmp_buf + +typedef ptrdiff_t SW_FT_PtrDist; + + +#define ErrRaster_Invalid_Mode -2 +#define ErrRaster_Invalid_Outline -1 +#define ErrRaster_Invalid_Argument -3 +#define ErrRaster_Memory_Overflow -4 + +#define SW_FT_BEGIN_HEADER +#define SW_FT_END_HEADER + + + /* This macro is used to indicate that a function parameter is unused. */ + /* Its purpose is simply to reduce compiler warnings. Note also that */ + /* simply defining it as `(void)x' doesn't avoid warnings with certain */ + /* ANSI compilers (e.g. LCC). */ +#define SW_FT_UNUSED( x ) (x) = (x) + + +#define SW_FT_TRACE5( x ) do { } while ( 0 ) /* nothing */ +#define SW_FT_TRACE7( x ) do { } while ( 0 ) /* nothing */ +#define SW_FT_ERROR( x ) do { } while ( 0 ) /* nothing */ +#define SW_FT_THROW( e ) SW_FT_ERR_CAT( ErrRaster_, e ) + + + +typedef int +(*SW_FT_Outline_MoveToFunc)( const SW_FT_Vector* to, + void* user ); + +#define SW_FT_Outline_MoveTo_Func SW_FT_Outline_MoveToFunc + +typedef int +(*SW_FT_Outline_LineToFunc)( const SW_FT_Vector* to, + void* user ); + +#define SW_FT_Outline_LineTo_Func SW_FT_Outline_LineToFunc + + +typedef int +(*SW_FT_Outline_ConicToFunc)( const SW_FT_Vector* control, + const SW_FT_Vector* to, + void* user ); + +#define SW_FT_Outline_ConicTo_Func SW_FT_Outline_ConicToFunc + +typedef int +(*SW_FT_Outline_CubicToFunc)( const SW_FT_Vector* control1, + const SW_FT_Vector* control2, + const SW_FT_Vector* to, + void* user ); + +#define SW_FT_Outline_CubicTo_Func SW_FT_Outline_CubicToFunc + +typedef struct SW_FT_Outline_Funcs_ +{ + SW_FT_Outline_MoveToFunc move_to; + SW_FT_Outline_LineToFunc line_to; + SW_FT_Outline_ConicToFunc conic_to; + SW_FT_Outline_CubicToFunc cubic_to; + + int shift; + SW_FT_Pos delta; + +} SW_FT_Outline_Funcs; + + + +#define SW_FT_DEFINE_OUTLINE_FUNCS( class_, \ + move_to_, line_to_, \ + conic_to_, cubic_to_, \ + shift_, delta_ ) \ + static const SW_FT_Outline_Funcs class_ = \ + { \ + move_to_, \ + line_to_, \ + conic_to_, \ + cubic_to_, \ + shift_, \ + delta_ \ + }; + +#define SW_FT_DEFINE_RASTER_FUNCS( class_, \ + raster_new_, raster_reset_, \ + raster_render_, \ + raster_done_ ) \ + const SW_FT_Raster_Funcs class_ = \ + { \ + raster_new_, \ + raster_reset_, \ + raster_render_, \ + raster_done_ \ + }; + + +#ifndef SW_FT_MEM_SET +#define SW_FT_MEM_SET( d, s, c ) ft_memset( d, s, c ) +#endif + +#ifndef SW_FT_MEM_ZERO +#define SW_FT_MEM_ZERO( dest, count ) SW_FT_MEM_SET( dest, 0, count ) +#endif + + /* as usual, for the speed hungry :-) */ + +#undef RAS_ARG +#undef RAS_ARG_ +#undef RAS_VAR +#undef RAS_VAR_ + +#ifndef SW_FT_STATIC_RASTER + +#define RAS_ARG gray_PWorker worker +#define RAS_ARG_ gray_PWorker worker, + +#define RAS_VAR worker +#define RAS_VAR_ worker, + +#else /* SW_FT_STATIC_RASTER */ + +#define RAS_ARG /* empty */ +#define RAS_ARG_ /* empty */ +#define RAS_VAR /* empty */ +#define RAS_VAR_ /* empty */ + +#endif /* SW_FT_STATIC_RASTER */ + + + /* must be at least 6 bits! */ +#define PIXEL_BITS 5 + +#undef FLOOR +#undef CEILING +#undef TRUNC +#undef SCALED + +#define ONE_PIXEL ( 1L << PIXEL_BITS ) +#define PIXEL_MASK ( -1L << PIXEL_BITS ) +#define TRUNC( x ) ( (TCoord)( (x) >> PIXEL_BITS ) ) +#define SUBPIXELS( x ) ( (TPos)(x) << PIXEL_BITS ) +#define FLOOR( x ) ( (x) & -ONE_PIXEL ) +#define CEILING( x ) ( ( (x) + ONE_PIXEL - 1 ) & -ONE_PIXEL ) +#define ROUND( x ) ( ( (x) + ONE_PIXEL / 2 ) & -ONE_PIXEL ) + +#if PIXEL_BITS >= 6 +#define UPSCALE( x ) ( (x) << ( PIXEL_BITS - 6 ) ) +#define DOWNSCALE( x ) ( (x) >> ( PIXEL_BITS - 6 ) ) +#else +#define UPSCALE( x ) ( (x) >> ( 6 - PIXEL_BITS ) ) +#define DOWNSCALE( x ) ( (x) << ( 6 - PIXEL_BITS ) ) +#endif + + + /* Compute `dividend / divisor' and return both its quotient and */ + /* remainder, cast to a specific type. This macro also ensures that */ + /* the remainder is always positive. */ +#define SW_FT_DIV_MOD( type, dividend, divisor, quotient, remainder ) \ + SW_FT_BEGIN_STMNT \ + (quotient) = (type)( (dividend) / (divisor) ); \ + (remainder) = (type)( (dividend) % (divisor) ); \ + if ( (remainder) < 0 ) \ + { \ + (quotient)--; \ + (remainder) += (type)(divisor); \ + } \ + SW_FT_END_STMNT + +#ifdef __arm__ + /* Work around a bug specific to GCC which make the compiler fail to */ + /* optimize a division and modulo operation on the same parameters */ + /* into a single call to `__aeabi_idivmod'. See */ + /* */ + /* http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43721 */ +#undef SW_FT_DIV_MOD +#define SW_FT_DIV_MOD( type, dividend, divisor, quotient, remainder ) \ + SW_FT_BEGIN_STMNT \ + (quotient) = (type)( (dividend) / (divisor) ); \ + (remainder) = (type)( (dividend) - (quotient) * (divisor) ); \ + if ( (remainder) < 0 ) \ + { \ + (quotient)--; \ + (remainder) += (type)(divisor); \ + } \ + SW_FT_END_STMNT +#endif /* __arm__ */ + + + /*************************************************************************/ + /* */ + /* TYPE DEFINITIONS */ + /* */ + + /* don't change the following types to SW_FT_Int or SW_FT_Pos, since we might */ + /* need to define them to "float" or "double" when experimenting with */ + /* new algorithms */ + + typedef long TCoord; /* integer scanline/pixel coordinate */ + typedef long TPos; /* sub-pixel coordinate */ + + /* determine the type used to store cell areas. This normally takes at */ + /* least PIXEL_BITS*2 + 1 bits. On 16-bit systems, we need to use */ + /* `long' instead of `int', otherwise bad things happen */ + +#if PIXEL_BITS <= 7 + + typedef int TArea; + +#else /* PIXEL_BITS >= 8 */ + + /* approximately determine the size of integers using an ANSI-C header */ +#if SW_FT_UINT_MAX == 0xFFFFU + typedef long TArea; +#else + typedef int TArea; +#endif + +#endif /* PIXEL_BITS >= 8 */ + + + /* maximum number of gray spans in a call to the span callback */ +#define SW_FT_MAX_GRAY_SPANS 256 + + + typedef struct TCell_* PCell; + + typedef struct TCell_ + { + TPos x; /* same with gray_TWorker.ex */ + TCoord cover; /* same with gray_TWorker.cover */ + TArea area; + PCell next; + + } TCell; + + +#if defined( _MSC_VER ) /* Visual C++ (and Intel C++) */ + /* We disable the warning `structure was padded due to */ + /* __declspec(align())' in order to compile cleanly with */ + /* the maximum level of warnings. */ +#pragma warning( push ) +#pragma warning( disable : 4324 ) +#endif /* _MSC_VER */ + + typedef struct gray_TWorker_ + { + TCoord ex, ey; + TPos min_ex, max_ex; + TPos min_ey, max_ey; + TPos count_ex, count_ey; + + TArea area; + TCoord cover; + int invalid; + + PCell cells; + SW_FT_PtrDist max_cells; + SW_FT_PtrDist num_cells; + + TCoord cx, cy; + TPos x, y; + + TPos last_ey; + + SW_FT_Vector bez_stack[32 * 3 + 1]; + int lev_stack[32]; + + SW_FT_Outline outline; + SW_FT_BBox clip_box; + + SW_FT_Span gray_spans[SW_FT_MAX_GRAY_SPANS]; + int num_gray_spans; + + SW_FT_Raster_Span_Func render_span; + void* render_span_data; + int span_y; + + int band_size; + int band_shoot; + + ft_jmp_buf jump_buffer; + + void* buffer; + long buffer_size; + + PCell* ycells; + TPos ycount; + + } gray_TWorker, *gray_PWorker; + +#if defined( _MSC_VER ) +#pragma warning( pop ) +#endif + + +#ifndef SW_FT_STATIC_RASTER +#define ras (*worker) +#else + static gray_TWorker ras; +#endif + + + typedef struct gray_TRaster_ + { + void* buffer; + long buffer_size; + int band_size; + void* memory; + gray_PWorker worker; + + } gray_TRaster, *gray_PRaster; + + + + /*************************************************************************/ + /* */ + /* Initialize the cells table. */ + /* */ + static void + gray_init_cells( RAS_ARG_ void* buffer, + long byte_size ) + { + ras.buffer = buffer; + ras.buffer_size = byte_size; + + ras.ycells = (PCell*) buffer; + ras.cells = NULL; + ras.max_cells = 0; + ras.num_cells = 0; + ras.area = 0; + ras.cover = 0; + ras.invalid = 1; + } + + + /*************************************************************************/ + /* */ + /* Compute the outline bounding box. */ + /* */ + static void + gray_compute_cbox( RAS_ARG ) + { + SW_FT_Outline* outline = &ras.outline; + SW_FT_Vector* vec = outline->points; + SW_FT_Vector* limit = vec + outline->n_points; + + + if ( outline->n_points <= 0 ) + { + ras.min_ex = ras.max_ex = 0; + ras.min_ey = ras.max_ey = 0; + return; + } + + ras.min_ex = ras.max_ex = vec->x; + ras.min_ey = ras.max_ey = vec->y; + + vec++; + + for ( ; vec < limit; vec++ ) + { + TPos x = vec->x; + TPos y = vec->y; + + + if ( x < ras.min_ex ) ras.min_ex = x; + if ( x > ras.max_ex ) ras.max_ex = x; + if ( y < ras.min_ey ) ras.min_ey = y; + if ( y > ras.max_ey ) ras.max_ey = y; + } + + /* truncate the bounding box to integer pixels */ + ras.min_ex = ras.min_ex >> 6; + ras.min_ey = ras.min_ey >> 6; + ras.max_ex = ( ras.max_ex + 63 ) >> 6; + ras.max_ey = ( ras.max_ey + 63 ) >> 6; + } + + + /*************************************************************************/ + /* */ + /* Record the current cell in the table. */ + /* */ + static PCell + gray_find_cell( RAS_ARG ) + { + PCell *pcell, cell; + TPos x = ras.ex; + + + if ( x > ras.count_ex ) + x = ras.count_ex; + + pcell = &ras.ycells[ras.ey]; + for (;;) + { + cell = *pcell; + if ( cell == NULL || cell->x > x ) + break; + + if ( cell->x == x ) + goto Exit; + + pcell = &cell->next; + } + + if ( ras.num_cells >= ras.max_cells ) + ft_longjmp( ras.jump_buffer, 1 ); + + cell = ras.cells + ras.num_cells++; + cell->x = x; + cell->area = 0; + cell->cover = 0; + + cell->next = *pcell; + *pcell = cell; + + Exit: + return cell; + } + + + static void + gray_record_cell( RAS_ARG ) + { + if ( ras.area | ras.cover ) + { + PCell cell = gray_find_cell( RAS_VAR ); + + + cell->area += ras.area; + cell->cover += ras.cover; + } + } + + + /*************************************************************************/ + /* */ + /* Set the current cell to a new position. */ + /* */ + static void + gray_set_cell( RAS_ARG_ TCoord ex, + TCoord ey ) + { + /* Move the cell pointer to a new position. We set the `invalid' */ + /* flag to indicate that the cell isn't part of those we're interested */ + /* in during the render phase. This means that: */ + /* */ + /* . the new vertical position must be within min_ey..max_ey-1. */ + /* . the new horizontal position must be strictly less than max_ex */ + /* */ + /* Note that if a cell is to the left of the clipping region, it is */ + /* actually set to the (min_ex-1) horizontal position. */ + + /* All cells that are on the left of the clipping region go to the */ + /* min_ex - 1 horizontal position. */ + ey -= ras.min_ey; + + if ( ex > ras.max_ex ) + ex = ras.max_ex; + + ex -= ras.min_ex; + if ( ex < 0 ) + ex = -1; + + /* are we moving to a different cell ? */ + if ( ex != ras.ex || ey != ras.ey ) + { + /* record the current one if it is valid */ + if ( !ras.invalid ) + gray_record_cell( RAS_VAR ); + + ras.area = 0; + ras.cover = 0; + ras.ex = ex; + ras.ey = ey; + } + + ras.invalid = ( (unsigned)ey >= (unsigned)ras.count_ey || + ex >= ras.count_ex ); + } + + + /*************************************************************************/ + /* */ + /* Start a new contour at a given cell. */ + /* */ + static void + gray_start_cell( RAS_ARG_ TCoord ex, + TCoord ey ) + { + if ( ex > ras.max_ex ) + ex = (TCoord)( ras.max_ex ); + + if ( ex < ras.min_ex ) + ex = (TCoord)( ras.min_ex - 1 ); + + ras.area = 0; + ras.cover = 0; + ras.ex = ex - ras.min_ex; + ras.ey = ey - ras.min_ey; + ras.last_ey = SUBPIXELS( ey ); + ras.invalid = 0; + + gray_set_cell( RAS_VAR_ ex, ey ); + } + + + /*************************************************************************/ + /* */ + /* Render a scanline as one or more cells. */ + /* */ + static void + gray_render_scanline( RAS_ARG_ TCoord ey, + TPos x1, + TCoord y1, + TPos x2, + TCoord y2 ) + { + TCoord ex1, ex2, fx1, fx2, delta, mod; + long p, first, dx; + int incr; + + + dx = x2 - x1; + + ex1 = TRUNC( x1 ); + ex2 = TRUNC( x2 ); + fx1 = (TCoord)( x1 - SUBPIXELS( ex1 ) ); + fx2 = (TCoord)( x2 - SUBPIXELS( ex2 ) ); + + /* trivial case. Happens often */ + if ( y1 == y2 ) + { + gray_set_cell( RAS_VAR_ ex2, ey ); + return; + } + + /* everything is located in a single cell. That is easy! */ + /* */ + if ( ex1 == ex2 ) + { + delta = y2 - y1; + ras.area += (TArea)(( fx1 + fx2 ) * delta); + ras.cover += delta; + return; + } + + /* ok, we'll have to render a run of adjacent cells on the same */ + /* scanline... */ + /* */ + p = ( ONE_PIXEL - fx1 ) * ( y2 - y1 ); + first = ONE_PIXEL; + incr = 1; + + if ( dx < 0 ) + { + p = fx1 * ( y2 - y1 ); + first = 0; + incr = -1; + dx = -dx; + } + + SW_FT_DIV_MOD( TCoord, p, dx, delta, mod ); + + ras.area += (TArea)(( fx1 + first ) * delta); + ras.cover += delta; + + ex1 += incr; + gray_set_cell( RAS_VAR_ ex1, ey ); + y1 += delta; + + if ( ex1 != ex2 ) + { + TCoord lift, rem; + + + p = ONE_PIXEL * ( y2 - y1 + delta ); + SW_FT_DIV_MOD( TCoord, p, dx, lift, rem ); + + mod -= (int)dx; + + while ( ex1 != ex2 ) + { + delta = lift; + mod += rem; + if ( mod >= 0 ) + { + mod -= (TCoord)dx; + delta++; + } + + ras.area += (TArea)(ONE_PIXEL * delta); + ras.cover += delta; + y1 += delta; + ex1 += incr; + gray_set_cell( RAS_VAR_ ex1, ey ); + } + } + + delta = y2 - y1; + ras.area += (TArea)(( fx2 + ONE_PIXEL - first ) * delta); + ras.cover += delta; + } + + + /*************************************************************************/ + /* */ + /* Render a given line as a series of scanlines. */ + /* */ + static void + gray_render_line( RAS_ARG_ TPos to_x, + TPos to_y ) + { + TCoord ey1, ey2, fy1, fy2, mod; + TPos dx, dy, x, x2; + long p, first; + int delta, rem, lift, incr; + + + ey1 = TRUNC( ras.last_ey ); + ey2 = TRUNC( to_y ); /* if (ey2 >= ras.max_ey) ey2 = ras.max_ey-1; */ + fy1 = (TCoord)( ras.y - ras.last_ey ); + fy2 = (TCoord)( to_y - SUBPIXELS( ey2 ) ); + + dx = to_x - ras.x; + dy = to_y - ras.y; + + /* perform vertical clipping */ + { + TCoord min, max; + + + min = ey1; + max = ey2; + if ( ey1 > ey2 ) + { + min = ey2; + max = ey1; + } + if ( min >= ras.max_ey || max < ras.min_ey ) + goto End; + } + + /* everything is on a single scanline */ + if ( ey1 == ey2 ) + { + gray_render_scanline( RAS_VAR_ ey1, ras.x, fy1, to_x, fy2 ); + goto End; + } + + /* vertical line - avoid calling gray_render_scanline */ + incr = 1; + + if ( dx == 0 ) + { + TCoord ex = TRUNC( ras.x ); + TCoord two_fx = (TCoord)( ( ras.x - SUBPIXELS( ex ) ) << 1 ); + TArea area; + + + first = ONE_PIXEL; + if ( dy < 0 ) + { + first = 0; + incr = -1; + } + + delta = (int)( first - fy1 ); + ras.area += (TArea)two_fx * delta; + ras.cover += delta; + ey1 += incr; + + gray_set_cell( RAS_VAR_ ex, ey1 ); + + delta = (int)( first + first - ONE_PIXEL ); + area = (TArea)two_fx * delta; + while ( ey1 != ey2 ) + { + ras.area += area; + ras.cover += delta; + ey1 += incr; + + gray_set_cell( RAS_VAR_ ex, ey1 ); + } + + delta = (int)( fy2 - ONE_PIXEL + first ); + ras.area += (TArea)two_fx * delta; + ras.cover += delta; + + goto End; + } + + /* ok, we have to render several scanlines */ + p = ( ONE_PIXEL - fy1 ) * dx; + first = ONE_PIXEL; + incr = 1; + + if ( dy < 0 ) + { + p = fy1 * dx; + first = 0; + incr = -1; + dy = -dy; + } + + SW_FT_DIV_MOD( int, p, dy, delta, mod ); + + x = ras.x + delta; + gray_render_scanline( RAS_VAR_ ey1, ras.x, fy1, x, (TCoord)first ); + + ey1 += incr; + gray_set_cell( RAS_VAR_ TRUNC( x ), ey1 ); + + if ( ey1 != ey2 ) + { + p = ONE_PIXEL * dx; + SW_FT_DIV_MOD( int, p, dy, lift, rem ); + mod -= (int)dy; + + while ( ey1 != ey2 ) + { + delta = lift; + mod += rem; + if ( mod >= 0 ) + { + mod -= (int)dy; + delta++; + } + + x2 = x + delta; + gray_render_scanline( RAS_VAR_ ey1, x, + (TCoord)( ONE_PIXEL - first ), x2, + (TCoord)first ); + x = x2; + + ey1 += incr; + gray_set_cell( RAS_VAR_ TRUNC( x ), ey1 ); + } + } + + gray_render_scanline( RAS_VAR_ ey1, x, + (TCoord)( ONE_PIXEL - first ), to_x, + fy2 ); + + End: + ras.x = to_x; + ras.y = to_y; + ras.last_ey = SUBPIXELS( ey2 ); + } + + + static void + gray_split_conic( SW_FT_Vector* base ) + { + TPos a, b; + + + base[4].x = base[2].x; + b = base[1].x; + a = base[3].x = ( base[2].x + b ) / 2; + b = base[1].x = ( base[0].x + b ) / 2; + base[2].x = ( a + b ) / 2; + + base[4].y = base[2].y; + b = base[1].y; + a = base[3].y = ( base[2].y + b ) / 2; + b = base[1].y = ( base[0].y + b ) / 2; + base[2].y = ( a + b ) / 2; + } + + + static void + gray_render_conic( RAS_ARG_ const SW_FT_Vector* control, + const SW_FT_Vector* to ) + { + TPos dx, dy; + TPos min, max, y; + int top, level; + int* levels; + SW_FT_Vector* arc; + + + levels = ras.lev_stack; + + arc = ras.bez_stack; + arc[0].x = UPSCALE( to->x ); + arc[0].y = UPSCALE( to->y ); + arc[1].x = UPSCALE( control->x ); + arc[1].y = UPSCALE( control->y ); + arc[2].x = ras.x; + arc[2].y = ras.y; + top = 0; + + dx = SW_FT_ABS( arc[2].x + arc[0].x - 2 * arc[1].x ); + dy = SW_FT_ABS( arc[2].y + arc[0].y - 2 * arc[1].y ); + if ( dx < dy ) + dx = dy; + + if ( dx < ONE_PIXEL / 4 ) + goto Draw; + + /* short-cut the arc that crosses the current band */ + min = max = arc[0].y; + + y = arc[1].y; + if ( y < min ) min = y; + if ( y > max ) max = y; + + y = arc[2].y; + if ( y < min ) min = y; + if ( y > max ) max = y; + + if ( TRUNC( min ) >= ras.max_ey || TRUNC( max ) < ras.min_ey ) + goto Draw; + + level = 0; + do + { + dx >>= 2; + level++; + } while ( dx > ONE_PIXEL / 4 ); + + levels[0] = level; + + do + { + level = levels[top]; + if ( level > 0 ) + { + gray_split_conic( arc ); + arc += 2; + top++; + levels[top] = levels[top - 1] = level - 1; + continue; + } + + Draw: + gray_render_line( RAS_VAR_ arc[0].x, arc[0].y ); + top--; + arc -= 2; + + } while ( top >= 0 ); + } + + + static void + gray_split_cubic( SW_FT_Vector* base ) + { + TPos a, b, c, d; + + + base[6].x = base[3].x; + c = base[1].x; + d = base[2].x; + base[1].x = a = ( base[0].x + c ) / 2; + base[5].x = b = ( base[3].x + d ) / 2; + c = ( c + d ) / 2; + base[2].x = a = ( a + c ) / 2; + base[4].x = b = ( b + c ) / 2; + base[3].x = ( a + b ) / 2; + + base[6].y = base[3].y; + c = base[1].y; + d = base[2].y; + base[1].y = a = ( base[0].y + c ) / 2; + base[5].y = b = ( base[3].y + d ) / 2; + c = ( c + d ) / 2; + base[2].y = a = ( a + c ) / 2; + base[4].y = b = ( b + c ) / 2; + base[3].y = ( a + b ) / 2; + } + + + static void + gray_render_cubic( RAS_ARG_ const SW_FT_Vector* control1, + const SW_FT_Vector* control2, + const SW_FT_Vector* to ) + { + SW_FT_Vector* arc; + TPos min, max, y; + + + arc = ras.bez_stack; + arc[0].x = UPSCALE( to->x ); + arc[0].y = UPSCALE( to->y ); + arc[1].x = UPSCALE( control2->x ); + arc[1].y = UPSCALE( control2->y ); + arc[2].x = UPSCALE( control1->x ); + arc[2].y = UPSCALE( control1->y ); + arc[3].x = ras.x; + arc[3].y = ras.y; + + /* Short-cut the arc that crosses the current band. */ + min = max = arc[0].y; + + y = arc[1].y; + if ( y < min ) + min = y; + if ( y > max ) + max = y; + + y = arc[2].y; + if ( y < min ) + min = y; + if ( y > max ) + max = y; + + y = arc[3].y; + if ( y < min ) + min = y; + if ( y > max ) + max = y; + + if ( TRUNC( min ) >= ras.max_ey || TRUNC( max ) < ras.min_ey ) + goto Draw; + + for (;;) + { + /* Decide whether to split or draw. See `Rapid Termination */ + /* Evaluation for Recursive Subdivision of Bezier Curves' by Thomas */ + /* F. Hain, at */ + /* http://www.cis.southalabama.edu/~hain/general/Publications/Bezier/Camera-ready%20CISST02%202.pdf */ + + { + TPos dx, dy, dx_, dy_; + TPos dx1, dy1, dx2, dy2; + TPos L, s, s_limit; + + + /* dx and dy are x and y components of the P0-P3 chord vector. */ + dx = dx_ = arc[3].x - arc[0].x; + dy = dy_ = arc[3].y - arc[0].y; + + L = SW_FT_HYPOT( dx_, dy_ ); + + /* Avoid possible arithmetic overflow below by splitting. */ + if ( L > 32767 ) + goto Split; + + /* Max deviation may be as much as (s/L) * 3/4 (if Hain's v = 1). */ + s_limit = L * (TPos)( ONE_PIXEL / 6 ); + + /* s is L * the perpendicular distance from P1 to the line P0-P3. */ + dx1 = arc[1].x - arc[0].x; + dy1 = arc[1].y - arc[0].y; + s = SW_FT_ABS( dy * dx1 - dx * dy1 ); + + if ( s > s_limit ) + goto Split; + + /* s is L * the perpendicular distance from P2 to the line P0-P3. */ + dx2 = arc[2].x - arc[0].x; + dy2 = arc[2].y - arc[0].y; + s = SW_FT_ABS( dy * dx2 - dx * dy2 ); + + if ( s > s_limit ) + goto Split; + + /* Split super curvy segments where the off points are so far + from the chord that the angles P0-P1-P3 or P0-P2-P3 become + acute as detected by appropriate dot products. */ + if ( dx1 * ( dx1 - dx ) + dy1 * ( dy1 - dy ) > 0 || + dx2 * ( dx2 - dx ) + dy2 * ( dy2 - dy ) > 0 ) + goto Split; + + /* No reason to split. */ + goto Draw; + } + + Split: + gray_split_cubic( arc ); + arc += 3; + continue; + + Draw: + gray_render_line( RAS_VAR_ arc[0].x, arc[0].y ); + + if ( arc == ras.bez_stack ) + return; + + arc -= 3; + } + } + + + static int + gray_move_to( const SW_FT_Vector* to, + gray_PWorker worker ) + { + TPos x, y; + + + /* record current cell, if any */ + if ( !ras.invalid ) + gray_record_cell( RAS_VAR ); + + /* start to a new position */ + x = UPSCALE( to->x ); + y = UPSCALE( to->y ); + + gray_start_cell( RAS_VAR_ TRUNC( x ), TRUNC( y ) ); + + worker->x = x; + worker->y = y; + return 0; + } + + + static int + gray_line_to( const SW_FT_Vector* to, + gray_PWorker worker ) + { + gray_render_line( RAS_VAR_ UPSCALE( to->x ), UPSCALE( to->y ) ); + return 0; + } + + + static int + gray_conic_to( const SW_FT_Vector* control, + const SW_FT_Vector* to, + gray_PWorker worker ) + { + gray_render_conic( RAS_VAR_ control, to ); + return 0; + } + + + static int + gray_cubic_to( const SW_FT_Vector* control1, + const SW_FT_Vector* control2, + const SW_FT_Vector* to, + gray_PWorker worker ) + { + gray_render_cubic( RAS_VAR_ control1, control2, to ); + return 0; + } + + + static void + gray_hline( RAS_ARG_ TCoord x, + TCoord y, + TPos area, + TCoord acount ) + { + int coverage; + + + /* compute the coverage line's coverage, depending on the */ + /* outline fill rule */ + /* */ + /* the coverage percentage is area/(PIXEL_BITS*PIXEL_BITS*2) */ + /* */ + coverage = (int)( area >> ( PIXEL_BITS * 2 + 1 - 8 ) ); + /* use range 0..256 */ + if ( coverage < 0 ) + coverage = -coverage; + + if ( ras.outline.flags & SW_FT_OUTLINE_EVEN_ODD_FILL ) + { + coverage &= 511; + + if ( coverage > 256 ) + coverage = 512 - coverage; + else if ( coverage == 256 ) + coverage = 255; + } + else + { + /* normal non-zero winding rule */ + if ( coverage >= 256 ) + coverage = 255; + } + + y += (TCoord)ras.min_ey; + x += (TCoord)ras.min_ex; + + /* SW_FT_Span.x is a 16-bit short, so limit our coordinates appropriately */ + if ( x >= 32767 ) + x = 32767; + + /* SW_FT_Span.y is an integer, so limit our coordinates appropriately */ + if ( y >= SW_FT_INT_MAX ) + y = SW_FT_INT_MAX; + + if ( coverage ) + { + SW_FT_Span* span; + int count; + + + /* see whether we can add this span to the current list */ + count = ras.num_gray_spans; + span = ras.gray_spans + count - 1; + if ( count > 0 && + ras.span_y == y && + (int)span->x + span->len == (int)x && + span->coverage == coverage ) + { + span->len = (unsigned short)( span->len + acount ); + return; + } + + if ( count >= SW_FT_MAX_GRAY_SPANS ) + { + if ( ras.render_span && count > 0 ) + ras.render_span(count, ras.gray_spans, + ras.render_span_data ); + + #ifdef DEBUG_GRAYS + + if ( 1 ) + { + int n; + + + fprintf( stderr, "count = %3d ", count ); + span = ras.gray_spans; + for ( n = 0; n < count; n++, span++ ) + fprintf( stderr, "[%d , %d..%d] : %d ", + span->y, span->x, span->x + span->len - 1, span->coverage ); + fprintf( stderr, "\n" ); + } + + #endif /* DEBUG_GRAYS */ + + ras.num_gray_spans = 0; + //ras.span_y = (int)y; + + span = ras.gray_spans; + } + else + span++; + + /* add a gray span to the current list */ + span->x = (short)x; + span->y = (short)y; + span->len = (unsigned short)acount; + span->coverage = (unsigned char)coverage; + + ras.num_gray_spans++; + } + } + + static void + gray_sweep( RAS_ARG) + { + int yindex; + + if ( ras.num_cells == 0 ) + return; + + ras.num_gray_spans = 0; + + for ( yindex = 0; yindex < ras.ycount; yindex++ ) + { + PCell cell = ras.ycells[yindex]; + TCoord cover = 0; + TCoord x = 0; + + + for ( ; cell != NULL; cell = cell->next ) + { + TPos area; + + + if ( cell->x > x && cover != 0 ) + gray_hline( RAS_VAR_ x, yindex, cover * ( ONE_PIXEL * 2 ), + cell->x - x ); + + cover += cell->cover; + area = cover * ( ONE_PIXEL * 2 ) - cell->area; + + if ( area != 0 && cell->x >= 0 ) + gray_hline( RAS_VAR_ cell->x, yindex, area, 1 ); + + x = cell->x + 1; + } + + if ( cover != 0 ) + gray_hline( RAS_VAR_ x, yindex, cover * ( ONE_PIXEL * 2 ), + ras.count_ex - x ); + } + + if ( ras.render_span && ras.num_gray_spans > 0 ) + ras.render_span(ras.num_gray_spans, + ras.gray_spans, ras.render_span_data ); + } + + + /*************************************************************************/ + /* */ + /* The following function should only compile in stand-alone mode, */ + /* i.e., when building this component without the rest of FreeType. */ + /* */ + /*************************************************************************/ + + /*************************************************************************/ + /* */ + /* */ + /* SW_FT_Outline_Decompose */ + /* */ + /* */ + /* Walk over an outline's structure to decompose it into individual */ + /* segments and Bézier arcs. This function is also able to emit */ + /* `move to' and `close to' operations to indicate the start and end */ + /* of new contours in the outline. */ + /* */ + /* */ + /* outline :: A pointer to the source target. */ + /* */ + /* func_interface :: A table of `emitters', i.e., function pointers */ + /* called during decomposition to indicate path */ + /* operations. */ + /* */ + /* */ + /* user :: A typeless pointer which is passed to each */ + /* emitter during the decomposition. It can be */ + /* used to store the state during the */ + /* decomposition. */ + /* */ + /* */ + /* Error code. 0 means success. */ + /* */ + static int + SW_FT_Outline_Decompose( const SW_FT_Outline* outline, + const SW_FT_Outline_Funcs* func_interface, + void* user ) + { +#undef SCALED +#define SCALED( x ) ( ( (x) << shift ) - delta ) + + SW_FT_Vector v_last; + SW_FT_Vector v_control; + SW_FT_Vector v_start; + + SW_FT_Vector* point; + SW_FT_Vector* limit; + char* tags; + + int error; + + int n; /* index of contour in outline */ + int first; /* index of first point in contour */ + char tag; /* current point's state */ + + int shift; + TPos delta; + + + if ( !outline || !func_interface ) + return SW_FT_THROW( Invalid_Argument ); + + shift = func_interface->shift; + delta = func_interface->delta; + first = 0; + + for ( n = 0; n < outline->n_contours; n++ ) + { + int last; /* index of last point in contour */ + + + SW_FT_TRACE5(( "SW_FT_Outline_Decompose: Outline %d\n", n )); + + last = outline->contours[n]; + if ( last < 0 ) + goto Invalid_Outline; + limit = outline->points + last; + + v_start = outline->points[first]; + v_start.x = SCALED( v_start.x ); + v_start.y = SCALED( v_start.y ); + + v_last = outline->points[last]; + v_last.x = SCALED( v_last.x ); + v_last.y = SCALED( v_last.y ); + + v_control = v_start; + + point = outline->points + first; + tags = outline->tags + first; + tag = SW_FT_CURVE_TAG( tags[0] ); + + /* A contour cannot start with a cubic control point! */ + if ( tag == SW_FT_CURVE_TAG_CUBIC ) + goto Invalid_Outline; + + /* check first point to determine origin */ + if ( tag == SW_FT_CURVE_TAG_CONIC ) + { + /* first point is conic control. Yes, this happens. */ + if ( SW_FT_CURVE_TAG( outline->tags[last] ) == SW_FT_CURVE_TAG_ON ) + { + /* start at last point if it is on the curve */ + v_start = v_last; + limit--; + } + else + { + /* if both first and last points are conic, */ + /* start at their middle and record its position */ + /* for closure */ + v_start.x = ( v_start.x + v_last.x ) / 2; + v_start.y = ( v_start.y + v_last.y ) / 2; + + v_last = v_start; + } + point--; + tags--; + } + + SW_FT_TRACE5(( " move to (%.2f, %.2f)\n", + v_start.x / 64.0, v_start.y / 64.0 )); + error = func_interface->move_to( &v_start, user ); + if ( error ) + goto Exit; + + while ( point < limit ) + { + point++; + tags++; + + tag = SW_FT_CURVE_TAG( tags[0] ); + switch ( tag ) + { + case SW_FT_CURVE_TAG_ON: /* emit a single line_to */ + { + SW_FT_Vector vec; + + + vec.x = SCALED( point->x ); + vec.y = SCALED( point->y ); + + SW_FT_TRACE5(( " line to (%.2f, %.2f)\n", + vec.x / 64.0, vec.y / 64.0 )); + error = func_interface->line_to( &vec, user ); + if ( error ) + goto Exit; + continue; + } + + case SW_FT_CURVE_TAG_CONIC: /* consume conic arcs */ + v_control.x = SCALED( point->x ); + v_control.y = SCALED( point->y ); + + Do_Conic: + if ( point < limit ) + { + SW_FT_Vector vec; + SW_FT_Vector v_middle; + + + point++; + tags++; + tag = SW_FT_CURVE_TAG( tags[0] ); + + vec.x = SCALED( point->x ); + vec.y = SCALED( point->y ); + + if ( tag == SW_FT_CURVE_TAG_ON ) + { + SW_FT_TRACE5(( " conic to (%.2f, %.2f)" + " with control (%.2f, %.2f)\n", + vec.x / 64.0, vec.y / 64.0, + v_control.x / 64.0, v_control.y / 64.0 )); + error = func_interface->conic_to( &v_control, &vec, user ); + if ( error ) + goto Exit; + continue; + } + + if ( tag != SW_FT_CURVE_TAG_CONIC ) + goto Invalid_Outline; + + v_middle.x = ( v_control.x + vec.x ) / 2; + v_middle.y = ( v_control.y + vec.y ) / 2; + + SW_FT_TRACE5(( " conic to (%.2f, %.2f)" + " with control (%.2f, %.2f)\n", + v_middle.x / 64.0, v_middle.y / 64.0, + v_control.x / 64.0, v_control.y / 64.0 )); + error = func_interface->conic_to( &v_control, &v_middle, user ); + if ( error ) + goto Exit; + + v_control = vec; + goto Do_Conic; + } + + SW_FT_TRACE5(( " conic to (%.2f, %.2f)" + " with control (%.2f, %.2f)\n", + v_start.x / 64.0, v_start.y / 64.0, + v_control.x / 64.0, v_control.y / 64.0 )); + error = func_interface->conic_to( &v_control, &v_start, user ); + goto Close; + + default: /* SW_FT_CURVE_TAG_CUBIC */ + { + SW_FT_Vector vec1, vec2; + + + if ( point + 1 > limit || + SW_FT_CURVE_TAG( tags[1] ) != SW_FT_CURVE_TAG_CUBIC ) + goto Invalid_Outline; + + point += 2; + tags += 2; + + vec1.x = SCALED( point[-2].x ); + vec1.y = SCALED( point[-2].y ); + + vec2.x = SCALED( point[-1].x ); + vec2.y = SCALED( point[-1].y ); + + if ( point <= limit ) + { + SW_FT_Vector vec; + + + vec.x = SCALED( point->x ); + vec.y = SCALED( point->y ); + + SW_FT_TRACE5(( " cubic to (%.2f, %.2f)" + " with controls (%.2f, %.2f) and (%.2f, %.2f)\n", + vec.x / 64.0, vec.y / 64.0, + vec1.x / 64.0, vec1.y / 64.0, + vec2.x / 64.0, vec2.y / 64.0 )); + error = func_interface->cubic_to( &vec1, &vec2, &vec, user ); + if ( error ) + goto Exit; + continue; + } + + SW_FT_TRACE5(( " cubic to (%.2f, %.2f)" + " with controls (%.2f, %.2f) and (%.2f, %.2f)\n", + v_start.x / 64.0, v_start.y / 64.0, + vec1.x / 64.0, vec1.y / 64.0, + vec2.x / 64.0, vec2.y / 64.0 )); + error = func_interface->cubic_to( &vec1, &vec2, &v_start, user ); + goto Close; + } + } + } + + /* close the contour with a line segment */ + SW_FT_TRACE5(( " line to (%.2f, %.2f)\n", + v_start.x / 64.0, v_start.y / 64.0 )); + error = func_interface->line_to( &v_start, user ); + + Close: + if ( error ) + goto Exit; + + first = last + 1; + } + + SW_FT_TRACE5(( "SW_FT_Outline_Decompose: Done\n", n )); + return 0; + + Exit: + SW_FT_TRACE5(( "SW_FT_Outline_Decompose: Error %d\n", error )); + return error; + + Invalid_Outline: + return SW_FT_THROW( Invalid_Outline ); + } + + + typedef struct gray_TBand_ + { + TPos min, max; + + } gray_TBand; + + + + SW_FT_DEFINE_OUTLINE_FUNCS(func_interface, + (SW_FT_Outline_MoveTo_Func) gray_move_to, + (SW_FT_Outline_LineTo_Func) gray_line_to, + (SW_FT_Outline_ConicTo_Func)gray_conic_to, + (SW_FT_Outline_CubicTo_Func)gray_cubic_to, + 0, + 0 + ) + + static int + gray_convert_glyph_inner( RAS_ARG ) + { + + volatile int error = 0; + + if ( ft_setjmp( ras.jump_buffer ) == 0 ) + { + error = SW_FT_Outline_Decompose( &ras.outline, &func_interface, &ras ); + if ( !ras.invalid ) + gray_record_cell( RAS_VAR ); + } + else + error = SW_FT_THROW( Memory_Overflow ); + + return error; + } + + + static int + gray_convert_glyph( RAS_ARG ) + { + gray_TBand bands[40]; + gray_TBand* volatile band; + int volatile n, num_bands; + TPos volatile min, max, max_y; + SW_FT_BBox* clip; + + + /* Set up state in the raster object */ + gray_compute_cbox( RAS_VAR ); + + /* clip to target bitmap, exit if nothing to do */ + clip = &ras.clip_box; + + if ( ras.max_ex <= clip->xMin || ras.min_ex >= clip->xMax || + ras.max_ey <= clip->yMin || ras.min_ey >= clip->yMax ) + return 0; + + if ( ras.min_ex < clip->xMin ) ras.min_ex = clip->xMin; + if ( ras.min_ey < clip->yMin ) ras.min_ey = clip->yMin; + + if ( ras.max_ex > clip->xMax ) ras.max_ex = clip->xMax; + if ( ras.max_ey > clip->yMax ) ras.max_ey = clip->yMax; + + ras.count_ex = ras.max_ex - ras.min_ex; + ras.count_ey = ras.max_ey - ras.min_ey; + + /* set up vertical bands */ + num_bands = (int)( ( ras.max_ey - ras.min_ey ) / ras.band_size ); + if ( num_bands == 0 ) + num_bands = 1; + if ( num_bands >= 39 ) + num_bands = 39; + + ras.band_shoot = 0; + + min = ras.min_ey; + max_y = ras.max_ey; + + for ( n = 0; n < num_bands; n++, min = max ) + { + max = min + ras.band_size; + if ( n == num_bands - 1 || max > max_y ) + max = max_y; + + bands[0].min = min; + bands[0].max = max; + band = bands; + + while ( band >= bands ) + { + TPos bottom, top, middle; + int error; + + { + PCell cells_max; + int yindex; + long cell_start, cell_end, cell_mod; + + + ras.ycells = (PCell*)ras.buffer; + ras.ycount = band->max - band->min; + + cell_start = sizeof ( PCell ) * ras.ycount; + cell_mod = cell_start % sizeof ( TCell ); + if ( cell_mod > 0 ) + cell_start += sizeof ( TCell ) - cell_mod; + + cell_end = ras.buffer_size; + cell_end -= cell_end % sizeof ( TCell ); + + cells_max = (PCell)( (char*)ras.buffer + cell_end ); + ras.cells = (PCell)( (char*)ras.buffer + cell_start ); + if ( ras.cells >= cells_max ) + goto ReduceBands; + + ras.max_cells = cells_max - ras.cells; + if ( ras.max_cells < 2 ) + goto ReduceBands; + + for ( yindex = 0; yindex < ras.ycount; yindex++ ) + ras.ycells[yindex] = NULL; + } + + ras.num_cells = 0; + ras.invalid = 1; + ras.min_ey = band->min; + ras.max_ey = band->max; + ras.count_ey = band->max - band->min; + + error = gray_convert_glyph_inner( RAS_VAR ); + + if ( !error ) + { + gray_sweep( RAS_VAR); + band--; + continue; + } + else if ( error != ErrRaster_Memory_Overflow ) + return 1; + + ReduceBands: + /* render pool overflow; we will reduce the render band by half */ + bottom = band->min; + top = band->max; + middle = bottom + ( ( top - bottom ) >> 1 ); + + /* This is too complex for a single scanline; there must */ + /* be some problems. */ + if ( middle == bottom ) + { +#ifdef SW_FT_DEBUG_LEVEL_TRACE + SW_FT_TRACE7(( "gray_convert_glyph: rotten glyph\n" )); +#endif + return 1; + } + + if ( bottom-top >= ras.band_size ) + ras.band_shoot++; + + band[1].min = bottom; + band[1].max = middle; + band[0].min = middle; + band[0].max = top; + band++; + } + } + + if ( ras.band_shoot > 8 && ras.band_size > 16 ) + ras.band_size = ras.band_size / 2; + + return 0; + } + + + static int + gray_raster_render( gray_PRaster raster, + const SW_FT_Raster_Params* params ) + { + const SW_FT_Outline* outline = (const SW_FT_Outline*)params->source; + gray_PWorker worker; + + + if ( !raster || !raster->buffer || !raster->buffer_size ) + return SW_FT_THROW( Invalid_Argument ); + + if ( !outline ) + return SW_FT_THROW( Invalid_Outline ); + + /* return immediately if the outline is empty */ + if ( outline->n_points == 0 || outline->n_contours <= 0 ) + return 0; + + if ( !outline->contours || !outline->points ) + return SW_FT_THROW( Invalid_Outline ); + + if ( outline->n_points != + outline->contours[outline->n_contours - 1] + 1 ) + return SW_FT_THROW( Invalid_Outline ); + + worker = raster->worker; + + /* this version does not support monochrome rendering */ + if ( !( params->flags & SW_FT_RASTER_FLAG_AA ) ) + return SW_FT_THROW( Invalid_Mode ); + + if ( params->flags & SW_FT_RASTER_FLAG_CLIP ) + ras.clip_box = params->clip_box; + else + { + ras.clip_box.xMin = -32768L; + ras.clip_box.yMin = -32768L; + ras.clip_box.xMax = 32767L; + ras.clip_box.yMax = 32767L; + } + + gray_init_cells( RAS_VAR_ raster->buffer, raster->buffer_size ); + + ras.outline = *outline; + ras.num_cells = 0; + ras.invalid = 1; + ras.band_size = raster->band_size; + ras.num_gray_spans = 0; + + ras.render_span = (SW_FT_Raster_Span_Func)params->gray_spans; + ras.render_span_data = params->user; + + return gray_convert_glyph( RAS_VAR ); + } + + + /**** RASTER OBJECT CREATION: In stand-alone mode, we simply use *****/ + /**** a static object. *****/ + + static int + gray_raster_new(SW_FT_Raster* araster ) + { + static gray_TRaster the_raster; + + *araster = (SW_FT_Raster)&the_raster; + SW_FT_MEM_ZERO( &the_raster, sizeof ( the_raster ) ); + + return 0; + } + + + static void + gray_raster_done( SW_FT_Raster raster ) + { + /* nothing */ + SW_FT_UNUSED( raster ); + } + + static void + gray_raster_reset( SW_FT_Raster raster, + char* pool_base, + long pool_size ) + { + gray_PRaster rast = (gray_PRaster)raster; + + + if ( raster ) + { + if ( pool_base && pool_size >= (long)sizeof ( gray_TWorker ) + 2048 ) + { + gray_PWorker worker = (gray_PWorker)pool_base; + + + rast->worker = worker; + rast->buffer = pool_base + + ( ( sizeof ( gray_TWorker ) + + sizeof ( TCell ) - 1 ) & + ~( sizeof ( TCell ) - 1 ) ); + rast->buffer_size = (long)( ( pool_base + pool_size ) - + (char*)rast->buffer ) & + ~( sizeof ( TCell ) - 1 ); + rast->band_size = (int)( rast->buffer_size / + ( sizeof ( TCell ) * 8 ) ); + } + else + { + rast->buffer = NULL; + rast->buffer_size = 0; + rast->worker = NULL; + } + } + } + + + SW_FT_DEFINE_RASTER_FUNCS(sw_ft_grays_raster, + + (SW_FT_Raster_New_Func) gray_raster_new, + (SW_FT_Raster_Reset_Func) gray_raster_reset, + (SW_FT_Raster_Render_Func) gray_raster_render, + (SW_FT_Raster_Done_Func) gray_raster_done + ) + + +/* END */ diff --git a/src/lib/ector/software/sw_ft_raster.h b/src/lib/ector/software/sw_ft_raster.h new file mode 100755 index 0000000000..cb323d030c --- /dev/null +++ b/src/lib/ector/software/sw_ft_raster.h @@ -0,0 +1,607 @@ +#ifndef SW_FT_IMG_H +#define SW_FT_IMG_H +/***************************************************************************/ +/* */ +/* ftimage.h */ +/* */ +/* FreeType glyph image formats and default raster interface */ +/* (specification). */ +/* */ +/* Copyright 1996-2010, 2013 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + /*************************************************************************/ + /* */ + /* Note: A `raster' is simply a scan-line converter, used to render */ + /* SW_FT_Outlines into SW_FT_Bitmaps. */ + /* */ + /*************************************************************************/ + +#include "sw_ft_types.h" + + /*************************************************************************/ + /* */ + /* */ + /* FT_BBox */ + /* */ + /* */ + /* A structure used to hold an outline's bounding box, i.e., the */ + /* coordinates of its extrema in the horizontal and vertical */ + /* directions. */ + /* */ + /* */ + /* xMin :: The horizontal minimum (left-most). */ + /* */ + /* yMin :: The vertical minimum (bottom-most). */ + /* */ + /* xMax :: The horizontal maximum (right-most). */ + /* */ + /* yMax :: The vertical maximum (top-most). */ + /* */ + /* */ + /* The bounding box is specified with the coordinates of the lower */ + /* left and the upper right corner. In PostScript, those values are */ + /* often called (llx,lly) and (urx,ury), respectively. */ + /* */ + /* If `yMin' is negative, this value gives the glyph's descender. */ + /* Otherwise, the glyph doesn't descend below the baseline. */ + /* Similarly, if `ymax' is positive, this value gives the glyph's */ + /* ascender. */ + /* */ + /* `xMin' gives the horizontal distance from the glyph's origin to */ + /* the left edge of the glyph's bounding box. If `xMin' is negative, */ + /* the glyph extends to the left of the origin. */ + /* */ + typedef struct SW_FT_BBox_ + { + SW_FT_Pos xMin, yMin; + SW_FT_Pos xMax, yMax; + + } SW_FT_BBox; + +/*************************************************************************/ +/* */ +/* */ +/* SW_FT_Outline */ +/* */ +/* */ +/* This structure is used to describe an outline to the scan-line */ +/* converter. */ +/* */ +/* */ +/* n_contours :: The number of contours in the outline. */ +/* */ +/* n_points :: The number of points in the outline. */ +/* */ +/* points :: A pointer to an array of `n_points' @SW_FT_Vector */ +/* elements, giving the outline's point coordinates. */ +/* */ +/* tags :: A pointer to an array of `n_points' chars, giving */ +/* each outline point's type. */ +/* */ +/* If bit~0 is unset, the point is `off' the curve, */ +/* i.e., a Bézier control point, while it is `on' if */ +/* set. */ +/* */ +/* Bit~1 is meaningful for `off' points only. If set, */ +/* it indicates a third-order Bézier arc control point; */ +/* and a second-order control point if unset. */ +/* */ +/* If bit~2 is set, bits 5-7 contain the drop-out mode */ +/* (as defined in the OpenType specification; the value */ +/* is the same as the argument to the SCANMODE */ +/* instruction). */ +/* */ +/* Bits 3 and~4 are reserved for internal purposes. */ +/* */ +/* contours :: An array of `n_contours' shorts, giving the end */ +/* point of each contour within the outline. For */ +/* example, the first contour is defined by the points */ +/* `0' to `contours[0]', the second one is defined by */ +/* the points `contours[0]+1' to `contours[1]', etc. */ +/* */ +/* flags :: A set of bit flags used to characterize the outline */ +/* and give hints to the scan-converter and hinter on */ +/* how to convert/grid-fit it. See @SW_FT_OUTLINE_FLAGS.*/ +/* */ +typedef struct SW_FT_Outline_ +{ + short n_contours; /* number of contours in glyph */ + short n_points; /* number of points in the glyph */ + + SW_FT_Vector* points; /* the outline's points */ + char* tags; /* the points flags */ + short* contours; /* the contour end points */ + + int flags; /* outline masks */ + +} SW_FT_Outline; + + + /*************************************************************************/ + /* */ + /* */ + /* SW_FT_OUTLINE_FLAGS */ + /* */ + /* */ + /* A list of bit-field constants use for the flags in an outline's */ + /* `flags' field. */ + /* */ + /* */ + /* SW_FT_OUTLINE_NONE :: */ + /* Value~0 is reserved. */ + /* */ + /* SW_FT_OUTLINE_OWNER :: */ + /* If set, this flag indicates that the outline's field arrays */ + /* (i.e., `points', `flags', and `contours') are `owned' by the */ + /* outline object, and should thus be freed when it is destroyed. */ + /* */ + /* SW_FT_OUTLINE_EVEN_ODD_FILL :: */ + /* By default, outlines are filled using the non-zero winding rule. */ + /* If set to 1, the outline will be filled using the even-odd fill */ + /* rule (only works with the smooth rasterizer). */ + /* */ + /* SW_FT_OUTLINE_REVERSE_FILL :: */ + /* By default, outside contours of an outline are oriented in */ + /* clock-wise direction, as defined in the TrueType specification. */ + /* This flag is set if the outline uses the opposite direction */ + /* (typically for Type~1 fonts). This flag is ignored by the scan */ + /* converter. */ + /* */ + /* */ + /* */ + /* There exists a second mechanism to pass the drop-out mode to the */ + /* B/W rasterizer; see the `tags' field in @SW_FT_Outline. */ + /* */ + /* Please refer to the description of the `SCANTYPE' instruction in */ + /* the OpenType specification (in file `ttinst1.doc') how simple */ + /* drop-outs, smart drop-outs, and stubs are defined. */ + /* */ +#define SW_FT_OUTLINE_NONE 0x0 +#define SW_FT_OUTLINE_OWNER 0x1 +#define SW_FT_OUTLINE_EVEN_ODD_FILL 0x2 +#define SW_FT_OUTLINE_REVERSE_FILL 0x4 + + /* */ + +#define SW_FT_CURVE_TAG( flag ) ( flag & 3 ) + +#define SW_FT_CURVE_TAG_ON 1 +#define SW_FT_CURVE_TAG_CONIC 0 +#define SW_FT_CURVE_TAG_CUBIC 2 + + +#define SW_FT_Curve_Tag_On SW_FT_CURVE_TAG_ON +#define SW_FT_Curve_Tag_Conic SW_FT_CURVE_TAG_CONIC +#define SW_FT_Curve_Tag_Cubic SW_FT_CURVE_TAG_CUBIC + + /*************************************************************************/ + /* */ + /* A raster is a scan converter, in charge of rendering an outline into */ + /* a a bitmap. This section contains the public API for rasters. */ + /* */ + /* Note that in FreeType 2, all rasters are now encapsulated within */ + /* specific modules called `renderers'. See `ftrender.h' for more */ + /* details on renderers. */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* */ + /* SW_FT_Raster */ + /* */ + /* */ + /* A handle (pointer) to a raster object. Each object can be used */ + /* independently to convert an outline into a bitmap or pixmap. */ + /* */ + typedef struct SW_FT_RasterRec_* SW_FT_Raster; + + + /*************************************************************************/ + /* */ + /* */ + /* SW_FT_Span */ + /* */ + /* */ + /* A structure used to model a single span of gray (or black) pixels */ + /* when rendering a monochrome or anti-aliased bitmap. */ + /* */ + /* */ + /* x :: The span's horizontal start position. */ + /* */ + /* len :: The span's length in pixels. */ + /* */ + /* coverage :: The span color/coverage, ranging from 0 (background) */ + /* to 255 (foreground). Only used for anti-aliased */ + /* rendering. */ + /* */ + /* */ + /* This structure is used by the span drawing callback type named */ + /* @SW_FT_SpanFunc that takes the y~coordinate of the span as a */ + /* parameter. */ + /* */ + /* The coverage value is always between 0 and 255. If you want less */ + /* gray values, the callback function has to reduce them. */ + /* */ + typedef struct SW_FT_Span_ + { + short x; + short y; + unsigned short len; + unsigned char coverage; + + } SW_FT_Span; + + + /*************************************************************************/ + /* */ + /* */ + /* SW_FT_SpanFunc */ + /* */ + /* */ + /* A function used as a call-back by the anti-aliased renderer in */ + /* order to let client applications draw themselves the gray pixel */ + /* spans on each scan line. */ + /* */ + /* */ + /* y :: The scanline's y~coordinate. */ + /* */ + /* count :: The number of spans to draw on this scanline. */ + /* */ + /* spans :: A table of `count' spans to draw on the scanline. */ + /* */ + /* user :: User-supplied data that is passed to the callback. */ + /* */ + /* */ + /* This callback allows client applications to directly render the */ + /* gray spans of the anti-aliased bitmap to any kind of surfaces. */ + /* */ + /* This can be used to write anti-aliased outlines directly to a */ + /* given background bitmap, and even perform translucency. */ + /* */ + /* Note that the `count' field cannot be greater than a fixed value */ + /* defined by the `SW_FT_MAX_GRAY_SPANS' configuration macro in */ + /* `ftoption.h'. By default, this value is set to~32, which means */ + /* that if there are more than 32~spans on a given scanline, the */ + /* callback is called several times with the same `y' parameter in */ + /* order to draw all callbacks. */ + /* */ + /* Otherwise, the callback is only called once per scan-line, and */ + /* only for those scanlines that do have `gray' pixels on them. */ + /* */ + typedef void + (*SW_FT_SpanFunc)( int count, + const SW_FT_Span* spans, + void* user ); + +#define SW_FT_Raster_Span_Func SW_FT_SpanFunc + + + + /*************************************************************************/ + /* */ + /* */ + /* SW_FT_RASTER_FLAG_XXX */ + /* */ + /* */ + /* A list of bit flag constants as used in the `flags' field of a */ + /* @SW_FT_Raster_Params structure. */ + /* */ + /* */ + /* SW_FT_RASTER_FLAG_DEFAULT :: This value is 0. */ + /* */ + /* SW_FT_RASTER_FLAG_AA :: This flag is set to indicate that an */ + /* anti-aliased glyph image should be */ + /* generated. Otherwise, it will be */ + /* monochrome (1-bit). */ + /* */ + /* SW_FT_RASTER_FLAG_DIRECT :: This flag is set to indicate direct */ + /* rendering. In this mode, client */ + /* applications must provide their own span */ + /* callback. This lets them directly */ + /* draw or compose over an existing bitmap. */ + /* If this bit is not set, the target */ + /* pixmap's buffer _must_ be zeroed before */ + /* rendering. */ + /* */ + /* Note that for now, direct rendering is */ + /* only possible with anti-aliased glyphs. */ + /* */ + /* SW_FT_RASTER_FLAG_CLIP :: This flag is only used in direct */ + /* rendering mode. If set, the output will */ + /* be clipped to a box specified in the */ + /* `clip_box' field of the */ + /* @SW_FT_Raster_Params structure. */ + /* */ + /* Note that by default, the glyph bitmap */ + /* is clipped to the target pixmap, except */ + /* in direct rendering mode where all spans */ + /* are generated if no clipping box is set. */ + /* */ +#define SW_FT_RASTER_FLAG_DEFAULT 0x0 +#define SW_FT_RASTER_FLAG_AA 0x1 +#define SW_FT_RASTER_FLAG_DIRECT 0x2 +#define SW_FT_RASTER_FLAG_CLIP 0x4 + + /* deprecated */ +#define ft_raster_flag_default SW_FT_RASTER_FLAG_DEFAULT +#define ft_raster_flag_aa SW_FT_RASTER_FLAG_AA +#define ft_raster_flag_direct SW_FT_RASTER_FLAG_DIRECT +#define ft_raster_flag_clip SW_FT_RASTER_FLAG_CLIP + + + /*************************************************************************/ + /* */ + /* */ + /* SW_FT_Raster_Params */ + /* */ + /* */ + /* A structure to hold the arguments used by a raster's render */ + /* function. */ + /* */ + /* */ + /* target :: The target bitmap. */ + /* */ + /* source :: A pointer to the source glyph image (e.g., an */ + /* @SW_FT_Outline). */ + /* */ + /* flags :: The rendering flags. */ + /* */ + /* gray_spans :: The gray span drawing callback. */ + /* */ + /* black_spans :: The black span drawing callback. UNIMPLEMENTED! */ + /* */ + /* bit_test :: The bit test callback. UNIMPLEMENTED! */ + /* */ + /* bit_set :: The bit set callback. UNIMPLEMENTED! */ + /* */ + /* user :: User-supplied data that is passed to each drawing */ + /* callback. */ + /* */ + /* clip_box :: An optional clipping box. It is only used in */ + /* direct rendering mode. Note that coordinates here */ + /* should be expressed in _integer_ pixels (and not in */ + /* 26.6 fixed-point units). */ + /* */ + /* */ + /* An anti-aliased glyph bitmap is drawn if the @SW_FT_RASTER_FLAG_AA */ + /* bit flag is set in the `flags' field, otherwise a monochrome */ + /* bitmap is generated. */ + /* */ + /* If the @SW_FT_RASTER_FLAG_DIRECT bit flag is set in `flags', the */ + /* raster will call the `gray_spans' callback to draw gray pixel */ + /* spans, in the case of an aa glyph bitmap, it will call */ + /* `black_spans', and `bit_test' and `bit_set' in the case of a */ + /* monochrome bitmap. This allows direct composition over a */ + /* pre-existing bitmap through user-provided callbacks to perform the */ + /* span drawing/composition. */ + /* */ + /* Note that the `bit_test' and `bit_set' callbacks are required when */ + /* rendering a monochrome bitmap, as they are crucial to implement */ + /* correct drop-out control as defined in the TrueType specification. */ + /* */ + typedef struct SW_FT_Raster_Params_ + { + const void* source; + int flags; + SW_FT_SpanFunc gray_spans; + void* user; + SW_FT_BBox clip_box; + + } SW_FT_Raster_Params; + + +/*************************************************************************/ +/* */ +/* */ +/* SW_FT_Outline_Check */ +/* */ +/* */ +/* Check the contents of an outline descriptor. */ +/* */ +/* */ +/* outline :: A handle to a source outline. */ +/* */ +/* */ +/* FreeType error code. 0~means success. */ +/* */ +SW_FT_Error +SW_FT_Outline_Check( SW_FT_Outline* outline ); + + +/*************************************************************************/ +/* */ +/* */ +/* SW_FT_Outline_Get_CBox */ +/* */ +/* */ +/* Return an outline's `control box'. The control box encloses all */ +/* the outline's points, including Bézier control points. Though it */ +/* coincides with the exact bounding box for most glyphs, it can be */ +/* slightly larger in some situations (like when rotating an outline */ +/* that contains Bézier outside arcs). */ +/* */ +/* Computing the control box is very fast, while getting the bounding */ +/* box can take much more time as it needs to walk over all segments */ +/* and arcs in the outline. To get the latter, you can use the */ +/* `ftbbox' component, which is dedicated to this single task. */ +/* */ +/* */ +/* outline :: A pointer to the source outline descriptor. */ +/* */ +/* */ +/* acbox :: The outline's control box. */ +/* */ +/* */ +/* See @SW_FT_Glyph_Get_CBox for a discussion of tricky fonts. */ +/* */ +void +SW_FT_Outline_Get_CBox( const SW_FT_Outline* outline, + SW_FT_BBox *acbox ); + + + /*************************************************************************/ + /* */ + /* */ + /* SW_FT_Raster_NewFunc */ + /* */ + /* */ + /* A function used to create a new raster object. */ + /* */ + /* */ + /* memory :: A handle to the memory allocator. */ + /* */ + /* */ + /* raster :: A handle to the new raster object. */ + /* */ + /* */ + /* Error code. 0~means success. */ + /* */ + /* */ + /* The `memory' parameter is a typeless pointer in order to avoid */ + /* un-wanted dependencies on the rest of the FreeType code. In */ + /* practice, it is an @SW_FT_Memory object, i.e., a handle to the */ + /* standard FreeType memory allocator. However, this field can be */ + /* completely ignored by a given raster implementation. */ + /* */ + typedef int + (*SW_FT_Raster_NewFunc)( SW_FT_Raster* raster ); + +#define SW_FT_Raster_New_Func SW_FT_Raster_NewFunc + + + /*************************************************************************/ + /* */ + /* */ + /* SW_FT_Raster_DoneFunc */ + /* */ + /* */ + /* A function used to destroy a given raster object. */ + /* */ + /* */ + /* raster :: A handle to the raster object. */ + /* */ + typedef void + (*SW_FT_Raster_DoneFunc)( SW_FT_Raster raster ); + +#define SW_FT_Raster_Done_Func SW_FT_Raster_DoneFunc + + + /*************************************************************************/ + /* */ + /* */ + /* SW_FT_Raster_ResetFunc */ + /* */ + /* */ + /* FreeType provides an area of memory called the `render pool', */ + /* available to all registered rasters. This pool can be freely used */ + /* during a given scan-conversion but is shared by all rasters. Its */ + /* content is thus transient. */ + /* */ + /* This function is called each time the render pool changes, or just */ + /* after a new raster object is created. */ + /* */ + /* */ + /* raster :: A handle to the new raster object. */ + /* */ + /* pool_base :: The address in memory of the render pool. */ + /* */ + /* pool_size :: The size in bytes of the render pool. */ + /* */ + /* */ + /* Rasters can ignore the render pool and rely on dynamic memory */ + /* allocation if they want to (a handle to the memory allocator is */ + /* passed to the raster constructor). However, this is not */ + /* recommended for efficiency purposes. */ + /* */ + typedef void + (*SW_FT_Raster_ResetFunc)( SW_FT_Raster raster, + unsigned char* pool_base, + unsigned long pool_size ); + +#define SW_FT_Raster_Reset_Func SW_FT_Raster_ResetFunc + + + /*************************************************************************/ + /* */ + /* */ + /* SW_FT_Raster_RenderFunc */ + /* */ + /* */ + /* Invoke a given raster to scan-convert a given glyph image into a */ + /* target bitmap. */ + /* */ + /* */ + /* raster :: A handle to the raster object. */ + /* */ + /* params :: A pointer to an @SW_FT_Raster_Params structure used to */ + /* store the rendering parameters. */ + /* */ + /* */ + /* Error code. 0~means success. */ + /* */ + /* */ + /* The exact format of the source image depends on the raster's glyph */ + /* format defined in its @SW_FT_Raster_Funcs structure. It can be an */ + /* @SW_FT_Outline or anything else in order to support a large array of */ + /* glyph formats. */ + /* */ + /* Note also that the render function can fail and return a */ + /* `SW_FT_Err_Unimplemented_Feature' error code if the raster used does */ + /* not support direct composition. */ + /* */ + /* XXX: For now, the standard raster doesn't support direct */ + /* composition but this should change for the final release (see */ + /* the files `demos/src/ftgrays.c' and `demos/src/ftgrays2.c' */ + /* for examples of distinct implementations that support direct */ + /* composition). */ + /* */ + typedef int + (*SW_FT_Raster_RenderFunc)( SW_FT_Raster raster, + const SW_FT_Raster_Params* params ); + +#define SW_FT_Raster_Render_Func SW_FT_Raster_RenderFunc + + + /*************************************************************************/ + /* */ + /* */ + /* SW_FT_Raster_Funcs */ + /* */ + /* */ + /* A structure used to describe a given raster class to the library. */ + /* */ + /* */ + /* glyph_format :: The supported glyph format for this raster. */ + /* */ + /* raster_new :: The raster constructor. */ + /* */ + /* raster_reset :: Used to reset the render pool within the raster. */ + /* */ + /* raster_render :: A function to render a glyph into a given bitmap. */ + /* */ + /* raster_done :: The raster destructor. */ + /* */ + typedef struct SW_FT_Raster_Funcs_ + { + SW_FT_Raster_NewFunc raster_new; + SW_FT_Raster_ResetFunc raster_reset; + SW_FT_Raster_RenderFunc raster_render; + SW_FT_Raster_DoneFunc raster_done; + + } SW_FT_Raster_Funcs; + + +extern const SW_FT_Raster_Funcs sw_ft_grays_raster; + +#endif // SW_FT_IMG_H diff --git a/src/lib/ector/software/sw_ft_stroker.c b/src/lib/ector/software/sw_ft_stroker.c new file mode 100755 index 0000000000..d1c31e8b10 --- /dev/null +++ b/src/lib/ector/software/sw_ft_stroker.c @@ -0,0 +1,2292 @@ + +/***************************************************************************/ +/* */ +/* ftstroke.c */ +/* */ +/* FreeType path stroker (body). */ +/* */ +/* Copyright 2002-2006, 2008-2011, 2013 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#include "sw_ft_math.h" +#include "sw_ft_stroker.h" +#include +#include +#include + + + /*************************************************************************/ + /*************************************************************************/ + /***** *****/ + /***** BEZIER COMPUTATIONS *****/ + /***** *****/ + /*************************************************************************/ + /*************************************************************************/ + +#define SW_FT_SMALL_CONIC_THRESHOLD ( SW_FT_ANGLE_PI / 6 ) +#define SW_FT_SMALL_CUBIC_THRESHOLD ( SW_FT_ANGLE_PI / 8 ) + +#define SW_FT_EPSILON 2 + +#define SW_FT_IS_SMALL( x ) ( (x) > -SW_FT_EPSILON && (x) < SW_FT_EPSILON ) + + + static SW_FT_Pos + ft_pos_abs( SW_FT_Pos x ) + { + return x >= 0 ? x : -x; + } + + + static void + ft_conic_split( SW_FT_Vector* base ) + { + SW_FT_Pos a, b; + + + base[4].x = base[2].x; + b = base[1].x; + a = base[3].x = ( base[2].x + b ) / 2; + b = base[1].x = ( base[0].x + b ) / 2; + base[2].x = ( a + b ) / 2; + + base[4].y = base[2].y; + b = base[1].y; + a = base[3].y = ( base[2].y + b ) / 2; + b = base[1].y = ( base[0].y + b ) / 2; + base[2].y = ( a + b ) / 2; + } + + + static SW_FT_Bool + ft_conic_is_small_enough( SW_FT_Vector* base, + SW_FT_Angle *angle_in, + SW_FT_Angle *angle_out ) + { + SW_FT_Vector d1, d2; + SW_FT_Angle theta; + SW_FT_Int close1, close2; + + + d1.x = base[1].x - base[2].x; + d1.y = base[1].y - base[2].y; + d2.x = base[0].x - base[1].x; + d2.y = base[0].y - base[1].y; + + close1 = SW_FT_IS_SMALL( d1.x ) && SW_FT_IS_SMALL( d1.y ); + close2 = SW_FT_IS_SMALL( d2.x ) && SW_FT_IS_SMALL( d2.y ); + + if ( close1 ) + { + if ( close2 ) + { + /* basically a point; */ + /* do nothing to retain original direction */ + } + else + { + *angle_in = + *angle_out = SW_FT_Atan2( d2.x, d2.y ); + } + } + else /* !close1 */ + { + if ( close2 ) + { + *angle_in = + *angle_out = SW_FT_Atan2( d1.x, d1.y ); + } + else + { + *angle_in = SW_FT_Atan2( d1.x, d1.y ); + *angle_out = SW_FT_Atan2( d2.x, d2.y ); + } + } + + theta = ft_pos_abs( SW_FT_Angle_Diff( *angle_in, *angle_out ) ); + + return SW_FT_BOOL( theta < SW_FT_SMALL_CONIC_THRESHOLD ); + } + + + static void + ft_cubic_split( SW_FT_Vector* base ) + { + SW_FT_Pos a, b, c, d; + + + base[6].x = base[3].x; + c = base[1].x; + d = base[2].x; + base[1].x = a = ( base[0].x + c ) / 2; + base[5].x = b = ( base[3].x + d ) / 2; + c = ( c + d ) / 2; + base[2].x = a = ( a + c ) / 2; + base[4].x = b = ( b + c ) / 2; + base[3].x = ( a + b ) / 2; + + base[6].y = base[3].y; + c = base[1].y; + d = base[2].y; + base[1].y = a = ( base[0].y + c ) / 2; + base[5].y = b = ( base[3].y + d ) / 2; + c = ( c + d ) / 2; + base[2].y = a = ( a + c ) / 2; + base[4].y = b = ( b + c ) / 2; + base[3].y = ( a + b ) / 2; + } + + + /* Return the average of `angle1' and `angle2'. */ + /* This gives correct result even if `angle1' and `angle2' */ + /* have opposite signs. */ + static SW_FT_Angle + ft_angle_mean( SW_FT_Angle angle1, + SW_FT_Angle angle2 ) + { + return angle1 + SW_FT_Angle_Diff( angle1, angle2 ) / 2; + } + + + static SW_FT_Bool + ft_cubic_is_small_enough( SW_FT_Vector* base, + SW_FT_Angle *angle_in, + SW_FT_Angle *angle_mid, + SW_FT_Angle *angle_out ) + { + SW_FT_Vector d1, d2, d3; + SW_FT_Angle theta1, theta2; + SW_FT_Int close1, close2, close3; + + + d1.x = base[2].x - base[3].x; + d1.y = base[2].y - base[3].y; + d2.x = base[1].x - base[2].x; + d2.y = base[1].y - base[2].y; + d3.x = base[0].x - base[1].x; + d3.y = base[0].y - base[1].y; + + close1 = SW_FT_IS_SMALL( d1.x ) && SW_FT_IS_SMALL( d1.y ); + close2 = SW_FT_IS_SMALL( d2.x ) && SW_FT_IS_SMALL( d2.y ); + close3 = SW_FT_IS_SMALL( d3.x ) && SW_FT_IS_SMALL( d3.y ); + + if ( close1 ) + { + if ( close2 ) + { + if ( close3 ) + { + /* basically a point; */ + /* do nothing to retain original direction */ + } + else /* !close3 */ + { + *angle_in = + *angle_mid = + *angle_out = SW_FT_Atan2( d3.x, d3.y ); + } + } + else /* !close2 */ + { + if ( close3 ) + { + *angle_in = + *angle_mid = + *angle_out = SW_FT_Atan2( d2.x, d2.y ); + } + else /* !close3 */ + { + *angle_in = + *angle_mid = SW_FT_Atan2( d2.x, d2.y ); + *angle_out = SW_FT_Atan2( d3.x, d3.y ); + } + } + } + else /* !close1 */ + { + if ( close2 ) + { + if ( close3 ) + { + *angle_in = + *angle_mid = + *angle_out = SW_FT_Atan2( d1.x, d1.y ); + } + else /* !close3 */ + { + *angle_in = SW_FT_Atan2( d1.x, d1.y ); + *angle_out = SW_FT_Atan2( d3.x, d3.y ); + *angle_mid = ft_angle_mean( *angle_in, *angle_out ); + } + } + else /* !close2 */ + { + if ( close3 ) + { + *angle_in = SW_FT_Atan2( d1.x, d1.y ); + *angle_mid = + *angle_out = SW_FT_Atan2( d2.x, d2.y ); + } + else /* !close3 */ + { + *angle_in = SW_FT_Atan2( d1.x, d1.y ); + *angle_mid = SW_FT_Atan2( d2.x, d2.y ); + *angle_out = SW_FT_Atan2( d3.x, d3.y ); + } + } + } + + theta1 = ft_pos_abs( SW_FT_Angle_Diff( *angle_in, *angle_mid ) ); + theta2 = ft_pos_abs( SW_FT_Angle_Diff( *angle_mid, *angle_out ) ); + + return SW_FT_BOOL( theta1 < SW_FT_SMALL_CUBIC_THRESHOLD && + theta2 < SW_FT_SMALL_CUBIC_THRESHOLD ); + } + + + /*************************************************************************/ + /*************************************************************************/ + /***** *****/ + /***** STROKE BORDERS *****/ + /***** *****/ + /*************************************************************************/ + /*************************************************************************/ + + typedef enum SW_FT_StrokeTags_ + { + SW_FT_STROKE_TAG_ON = 1, /* on-curve point */ + SW_FT_STROKE_TAG_CUBIC = 2, /* cubic off-point */ + SW_FT_STROKE_TAG_BEGIN = 4, /* sub-path start */ + SW_FT_STROKE_TAG_END = 8 /* sub-path end */ + + } SW_FT_StrokeTags; + +#define SW_FT_STROKE_TAG_BEGIN_END ( SW_FT_STROKE_TAG_BEGIN | SW_FT_STROKE_TAG_END ) + + typedef struct SW_FT_StrokeBorderRec_ + { + SW_FT_UInt num_points; + SW_FT_UInt max_points; + SW_FT_Vector* points; + SW_FT_Byte* tags; + SW_FT_Bool movable; /* TRUE for ends of lineto borders */ + SW_FT_Int start; /* index of current sub-path start point */ + SW_FT_Bool valid; + + } SW_FT_StrokeBorderRec, *SW_FT_StrokeBorder; + + + + SW_FT_Error + SW_FT_Outline_Check( SW_FT_Outline* outline ) + { + if ( outline ) + { + SW_FT_Int n_points = outline->n_points; + SW_FT_Int n_contours = outline->n_contours; + SW_FT_Int end0, end; + SW_FT_Int n; + + + /* empty glyph? */ + if ( n_points == 0 && n_contours == 0 ) + return 0; + + /* check point and contour counts */ + if ( n_points <= 0 || n_contours <= 0 ) + goto Bad; + + end0 = end = -1; + for ( n = 0; n < n_contours; n++ ) + { + end = outline->contours[n]; + + /* note that we don't accept empty contours */ + if ( end <= end0 || end >= n_points ) + goto Bad; + + end0 = end; + } + + if ( end != n_points - 1 ) + goto Bad; + + /* XXX: check the tags array */ + return 0; + } + + Bad: + return -1;//SW_FT_THROW( Invalid_Argument ); + } + + + + void + SW_FT_Outline_Get_CBox( const SW_FT_Outline* outline, + SW_FT_BBox *acbox ) + { + SW_FT_Pos xMin, yMin, xMax, yMax; + + + if ( outline && acbox ) + { + if ( outline->n_points == 0 ) + { + xMin = 0; + yMin = 0; + xMax = 0; + yMax = 0; + } + else + { + SW_FT_Vector* vec = outline->points; + SW_FT_Vector* limit = vec + outline->n_points; + + + xMin = xMax = vec->x; + yMin = yMax = vec->y; + vec++; + + for ( ; vec < limit; vec++ ) + { + SW_FT_Pos x, y; + + + x = vec->x; + if ( x < xMin ) xMin = x; + if ( x > xMax ) xMax = x; + + y = vec->y; + if ( y < yMin ) yMin = y; + if ( y > yMax ) yMax = y; + } + } + acbox->xMin = xMin; + acbox->xMax = xMax; + acbox->yMin = yMin; + acbox->yMax = yMax; + } + } + + + + static SW_FT_Error + ft_stroke_border_grow( SW_FT_StrokeBorder border, + SW_FT_UInt new_points ) + { + SW_FT_UInt old_max = border->max_points; + SW_FT_UInt new_max = border->num_points + new_points; + SW_FT_Error error = 0; + + + if ( new_max > old_max ) + { + SW_FT_UInt cur_max = old_max; + + + while ( cur_max < new_max ) + cur_max += ( cur_max >> 1 ) + 16; + + border->points = (SW_FT_Vector *) realloc(border->points, cur_max * sizeof(SW_FT_Vector)); + border->tags = (SW_FT_Byte *) realloc(border->tags, cur_max * sizeof(SW_FT_Byte)); + + if ( !border->points || !border->tags) + goto Exit; + + border->max_points = cur_max; + } + + Exit: + return error; + } + + + static void + ft_stroke_border_close( SW_FT_StrokeBorder border, + SW_FT_Bool reverse ) + { + SW_FT_UInt start = border->start; + SW_FT_UInt count = border->num_points; + + + assert( border->start >= 0 ); + + /* don't record empty paths! */ + if ( count <= start + 1U ) + border->num_points = start; + else + { + /* copy the last point to the start of this sub-path, since */ + /* it contains the `adjusted' starting coordinates */ + border->num_points = --count; + border->points[start] = border->points[count]; + + if ( reverse ) + { + /* reverse the points */ + { + SW_FT_Vector* vec1 = border->points + start + 1; + SW_FT_Vector* vec2 = border->points + count - 1; + + + for ( ; vec1 < vec2; vec1++, vec2-- ) + { + SW_FT_Vector tmp; + + + tmp = *vec1; + *vec1 = *vec2; + *vec2 = tmp; + } + } + + /* then the tags */ + { + SW_FT_Byte* tag1 = border->tags + start + 1; + SW_FT_Byte* tag2 = border->tags + count - 1; + + + for ( ; tag1 < tag2; tag1++, tag2-- ) + { + SW_FT_Byte tmp; + + + tmp = *tag1; + *tag1 = *tag2; + *tag2 = tmp; + } + } + } + + border->tags[start ] |= SW_FT_STROKE_TAG_BEGIN; + border->tags[count - 1] |= SW_FT_STROKE_TAG_END; + } + + border->start = -1; + border->movable = FALSE; + } + + + static SW_FT_Error + ft_stroke_border_lineto( SW_FT_StrokeBorder border, + SW_FT_Vector* to, + SW_FT_Bool movable ) + { + SW_FT_Error error = 0; + + + assert( border->start >= 0 ); + + if ( border->movable ) + { + /* move last point */ + border->points[border->num_points - 1] = *to; + } + else + { + /* don't add zero-length lineto */ + if ( border->num_points > 0 && + SW_FT_IS_SMALL( border->points[border->num_points - 1].x - to->x ) && + SW_FT_IS_SMALL( border->points[border->num_points - 1].y - to->y ) ) + return error; + + /* add one point */ + error = ft_stroke_border_grow( border, 1 ); + if ( !error ) + { + SW_FT_Vector* vec = border->points + border->num_points; + SW_FT_Byte* tag = border->tags + border->num_points; + + + vec[0] = *to; + tag[0] = SW_FT_STROKE_TAG_ON; + + border->num_points += 1; + } + } + border->movable = movable; + return error; + } + + + static SW_FT_Error + ft_stroke_border_conicto( SW_FT_StrokeBorder border, + SW_FT_Vector* control, + SW_FT_Vector* to ) + { + SW_FT_Error error; + + + assert( border->start >= 0 ); + + error = ft_stroke_border_grow( border, 2 ); + if ( !error ) + { + SW_FT_Vector* vec = border->points + border->num_points; + SW_FT_Byte* tag = border->tags + border->num_points; + + + vec[0] = *control; + vec[1] = *to; + + tag[0] = 0; + tag[1] = SW_FT_STROKE_TAG_ON; + + border->num_points += 2; + } + + border->movable = FALSE; + + return error; + } + + + static SW_FT_Error + ft_stroke_border_cubicto( SW_FT_StrokeBorder border, + SW_FT_Vector* control1, + SW_FT_Vector* control2, + SW_FT_Vector* to ) + { + SW_FT_Error error; + + + assert( border->start >= 0 ); + + error = ft_stroke_border_grow( border, 3 ); + if ( !error ) + { + SW_FT_Vector* vec = border->points + border->num_points; + SW_FT_Byte* tag = border->tags + border->num_points; + + + vec[0] = *control1; + vec[1] = *control2; + vec[2] = *to; + + tag[0] = SW_FT_STROKE_TAG_CUBIC; + tag[1] = SW_FT_STROKE_TAG_CUBIC; + tag[2] = SW_FT_STROKE_TAG_ON; + + border->num_points += 3; + } + + border->movable = FALSE; + + return error; + } + + +#define SW_FT_ARC_CUBIC_ANGLE ( SW_FT_ANGLE_PI / 2 ) + + + static SW_FT_Error + ft_stroke_border_arcto( SW_FT_StrokeBorder border, + SW_FT_Vector* center, + SW_FT_Fixed radius, + SW_FT_Angle angle_start, + SW_FT_Angle angle_diff ) + { + SW_FT_Angle total, angle, step, rotate, next, theta; + SW_FT_Vector a, b, a2, b2; + SW_FT_Fixed length; + SW_FT_Error error = 0; + + + /* compute start point */ + SW_FT_Vector_From_Polar( &a, radius, angle_start ); + a.x += center->x; + a.y += center->y; + + total = angle_diff; + angle = angle_start; + rotate = ( angle_diff >= 0 ) ? SW_FT_ANGLE_PI2 : -SW_FT_ANGLE_PI2; + + while ( total != 0 ) + { + step = total; + if ( step > SW_FT_ARC_CUBIC_ANGLE ) + step = SW_FT_ARC_CUBIC_ANGLE; + + else if ( step < -SW_FT_ARC_CUBIC_ANGLE ) + step = -SW_FT_ARC_CUBIC_ANGLE; + + next = angle + step; + theta = step; + if ( theta < 0 ) + theta = -theta; + + theta >>= 1; + + /* compute end point */ + SW_FT_Vector_From_Polar( &b, radius, next ); + b.x += center->x; + b.y += center->y; + + /* compute first and second control points */ + length = SW_FT_MulDiv( radius, SW_FT_Sin( theta ) * 4, + ( 0x10000L + SW_FT_Cos( theta ) ) * 3 ); + + SW_FT_Vector_From_Polar( &a2, length, angle + rotate ); + a2.x += a.x; + a2.y += a.y; + + SW_FT_Vector_From_Polar( &b2, length, next - rotate ); + b2.x += b.x; + b2.y += b.y; + + /* add cubic arc */ + error = ft_stroke_border_cubicto( border, &a2, &b2, &b ); + if ( error ) + break; + + /* process the rest of the arc ?? */ + a = b; + total -= step; + angle = next; + } + + return error; + } + + + static SW_FT_Error + ft_stroke_border_moveto( SW_FT_StrokeBorder border, + SW_FT_Vector* to ) + { + /* close current open path if any ? */ + if ( border->start >= 0 ) + ft_stroke_border_close( border, FALSE ); + + border->start = border->num_points; + border->movable = FALSE; + + return ft_stroke_border_lineto( border, to, FALSE ); + } + + + static void + ft_stroke_border_init( SW_FT_StrokeBorder border) + { + border->points = NULL; + border->tags = NULL; + + border->num_points = 0; + border->max_points = 0; + border->start = -1; + border->valid = FALSE; + } + + + static void + ft_stroke_border_reset( SW_FT_StrokeBorder border ) + { + border->num_points = 0; + border->start = -1; + border->valid = FALSE; + } + + + static void + ft_stroke_border_done( SW_FT_StrokeBorder border ) + { + + free( border->points ); + free( border->tags ); + + border->num_points = 0; + border->max_points = 0; + border->start = -1; + border->valid = FALSE; + } + + + static SW_FT_Error + ft_stroke_border_get_counts( SW_FT_StrokeBorder border, + SW_FT_UInt *anum_points, + SW_FT_UInt *anum_contours ) + { + SW_FT_Error error = 0; + SW_FT_UInt num_points = 0; + SW_FT_UInt num_contours = 0; + + SW_FT_UInt count = border->num_points; + SW_FT_Vector* point = border->points; + SW_FT_Byte* tags = border->tags; + SW_FT_Int in_contour = 0; + + + for ( ; count > 0; count--, num_points++, point++, tags++ ) + { + if ( tags[0] & SW_FT_STROKE_TAG_BEGIN ) + { + if ( in_contour != 0 ) + goto Fail; + + in_contour = 1; + } + else if ( in_contour == 0 ) + goto Fail; + + if ( tags[0] & SW_FT_STROKE_TAG_END ) + { + in_contour = 0; + num_contours++; + } + } + + if ( in_contour != 0 ) + goto Fail; + + border->valid = TRUE; + + Exit: + *anum_points = num_points; + *anum_contours = num_contours; + return error; + + Fail: + num_points = 0; + num_contours = 0; + goto Exit; + } + + + static void + ft_stroke_border_export( SW_FT_StrokeBorder border, + SW_FT_Outline* outline ) + { + /* copy point locations */ + memcpy( outline->points + outline->n_points, + border->points, + border->num_points * sizeof(SW_FT_Vector)); + + /* copy tags */ + { + SW_FT_UInt count = border->num_points; + SW_FT_Byte* read = border->tags; + SW_FT_Byte* write = (SW_FT_Byte*)outline->tags + outline->n_points; + + + for ( ; count > 0; count--, read++, write++ ) + { + if ( *read & SW_FT_STROKE_TAG_ON ) + *write = SW_FT_CURVE_TAG_ON; + else if ( *read & SW_FT_STROKE_TAG_CUBIC ) + *write = SW_FT_CURVE_TAG_CUBIC; + else + *write = SW_FT_CURVE_TAG_CONIC; + } + } + + /* copy contours */ + { + SW_FT_UInt count = border->num_points; + SW_FT_Byte* tags = border->tags; + SW_FT_Short* write = outline->contours + outline->n_contours; + SW_FT_Short idx = (SW_FT_Short)outline->n_points; + + + for ( ; count > 0; count--, tags++, idx++ ) + { + if ( *tags & SW_FT_STROKE_TAG_END ) + { + *write++ = idx; + outline->n_contours++; + } + } + } + + outline->n_points = (short)( outline->n_points + border->num_points ); + + assert( SW_FT_Outline_Check( outline ) == 0 ); + } + + + /*************************************************************************/ + /*************************************************************************/ + /***** *****/ + /***** STROKER *****/ + /***** *****/ + /*************************************************************************/ + /*************************************************************************/ + +#define SW_FT_SIDE_TO_ROTATE( s ) ( SW_FT_ANGLE_PI2 - (s) * SW_FT_ANGLE_PI ) + + typedef struct SW_FT_StrokerRec_ + { + SW_FT_Angle angle_in; /* direction into curr join */ + SW_FT_Angle angle_out; /* direction out of join */ + SW_FT_Vector center; /* current position */ + SW_FT_Fixed line_length; /* length of last lineto */ + SW_FT_Bool first_point; /* is this the start? */ + SW_FT_Bool subpath_open; /* is the subpath open? */ + SW_FT_Angle subpath_angle; /* subpath start direction */ + SW_FT_Vector subpath_start; /* subpath start position */ + SW_FT_Fixed subpath_line_length; /* subpath start lineto len */ + SW_FT_Bool handle_wide_strokes; /* use wide strokes logic? */ + + SW_FT_Stroker_LineCap line_cap; + SW_FT_Stroker_LineJoin line_join; + SW_FT_Stroker_LineJoin line_join_saved; + SW_FT_Fixed miter_limit; + SW_FT_Fixed radius; + + SW_FT_StrokeBorderRec borders[2]; + } SW_FT_StrokerRec; + + + /* documentation is in ftstroke.h */ + + SW_FT_Error + SW_FT_Stroker_New( SW_FT_Stroker *astroker ) + { + SW_FT_Error error = 0; /* assigned in SW_FT_NEW */ + SW_FT_Stroker stroker = NULL; + + + stroker = (SW_FT_StrokerRec *) calloc(1, sizeof(SW_FT_StrokerRec)); + if ( stroker ) + { + + ft_stroke_border_init( &stroker->borders[0]); + ft_stroke_border_init( &stroker->borders[1]); + } + + *astroker = stroker; + + return error; + } + + void + SW_FT_Stroker_Rewind( SW_FT_Stroker stroker ) + { + if ( stroker ) + { + ft_stroke_border_reset( &stroker->borders[0] ); + ft_stroke_border_reset( &stroker->borders[1] ); + } + } + + + /* documentation is in ftstroke.h */ + + void + SW_FT_Stroker_Set( SW_FT_Stroker stroker, + SW_FT_Fixed radius, + SW_FT_Stroker_LineCap line_cap, + SW_FT_Stroker_LineJoin line_join, + SW_FT_Fixed miter_limit ) + { + stroker->radius = radius; + stroker->line_cap = line_cap; + stroker->line_join = line_join; + stroker->miter_limit = miter_limit; + + /* ensure miter limit has sensible value */ + if ( stroker->miter_limit < 0x10000 ) + stroker->miter_limit = 0x10000; + + /* save line join style: */ + /* line join style can be temporarily changed when stroking curves */ + stroker->line_join_saved = line_join; + + SW_FT_Stroker_Rewind( stroker ); + } + + /* documentation is in ftstroke.h */ + + void + SW_FT_Stroker_Done( SW_FT_Stroker stroker ) + { + if ( stroker ) + { + + ft_stroke_border_done( &stroker->borders[0] ); + ft_stroke_border_done( &stroker->borders[1] ); + + free( stroker ); + } + } + + + /* create a circular arc at a corner or cap */ + static SW_FT_Error + ft_stroker_arcto( SW_FT_Stroker stroker, + SW_FT_Int side ) + { + SW_FT_Angle total, rotate; + SW_FT_Fixed radius = stroker->radius; + SW_FT_Error error = 0; + SW_FT_StrokeBorder border = stroker->borders + side; + + + rotate = SW_FT_SIDE_TO_ROTATE( side ); + + total = SW_FT_Angle_Diff( stroker->angle_in, stroker->angle_out ); + if ( total == SW_FT_ANGLE_PI ) + total = -rotate * 2; + + error = ft_stroke_border_arcto( border, + &stroker->center, + radius, + stroker->angle_in + rotate, + total ); + border->movable = FALSE; + return error; + } + + + /* add a cap at the end of an opened path */ + static SW_FT_Error + ft_stroker_cap( SW_FT_Stroker stroker, + SW_FT_Angle angle, + SW_FT_Int side ) + { + SW_FT_Error error = 0; + + + if ( stroker->line_cap == SW_FT_STROKER_LINECAP_ROUND ) + { + /* add a round cap */ + stroker->angle_in = angle; + stroker->angle_out = angle + SW_FT_ANGLE_PI; + + error = ft_stroker_arcto( stroker, side ); + } + else if ( stroker->line_cap == SW_FT_STROKER_LINECAP_SQUARE ) + { + /* add a square cap */ + SW_FT_Vector delta, delta2; + SW_FT_Angle rotate = SW_FT_SIDE_TO_ROTATE( side ); + SW_FT_Fixed radius = stroker->radius; + SW_FT_StrokeBorder border = stroker->borders + side; + + + SW_FT_Vector_From_Polar( &delta2, radius, angle + rotate ); + SW_FT_Vector_From_Polar( &delta, radius, angle ); + + delta.x += stroker->center.x + delta2.x; + delta.y += stroker->center.y + delta2.y; + + error = ft_stroke_border_lineto( border, &delta, FALSE ); + if ( error ) + goto Exit; + + SW_FT_Vector_From_Polar( &delta2, radius, angle - rotate ); + SW_FT_Vector_From_Polar( &delta, radius, angle ); + + delta.x += delta2.x + stroker->center.x; + delta.y += delta2.y + stroker->center.y; + + error = ft_stroke_border_lineto( border, &delta, FALSE ); + } + else if ( stroker->line_cap == SW_FT_STROKER_LINECAP_BUTT ) + { + /* add a butt ending */ + SW_FT_Vector delta; + SW_FT_Angle rotate = SW_FT_SIDE_TO_ROTATE( side ); + SW_FT_Fixed radius = stroker->radius; + SW_FT_StrokeBorder border = stroker->borders + side; + + + SW_FT_Vector_From_Polar( &delta, radius, angle + rotate ); + + delta.x += stroker->center.x; + delta.y += stroker->center.y; + + error = ft_stroke_border_lineto( border, &delta, FALSE ); + if ( error ) + goto Exit; + + SW_FT_Vector_From_Polar( &delta, radius, angle - rotate ); + + delta.x += stroker->center.x; + delta.y += stroker->center.y; + + error = ft_stroke_border_lineto( border, &delta, FALSE ); + } + + Exit: + return error; + } + + + /* process an inside corner, i.e. compute intersection */ + static SW_FT_Error + ft_stroker_inside( SW_FT_Stroker stroker, + SW_FT_Int side, + SW_FT_Fixed line_length ) + { + SW_FT_StrokeBorder border = stroker->borders + side; + SW_FT_Angle phi, theta, rotate; + SW_FT_Fixed length, thcos; + SW_FT_Vector delta; + SW_FT_Error error = 0; + SW_FT_Bool intersect; /* use intersection of lines? */ + + + rotate = SW_FT_SIDE_TO_ROTATE( side ); + + theta = SW_FT_Angle_Diff( stroker->angle_in, stroker->angle_out ) / 2; + + /* Only intersect borders if between two lineto's and both */ + /* lines are long enough (line_length is zero for curves). */ + if ( !border->movable || line_length == 0 ) + intersect = FALSE; + else + { + /* compute minimum required length of lines */ + SW_FT_Fixed min_length = ft_pos_abs( SW_FT_MulFix( stroker->radius, + SW_FT_Tan( theta ) ) ); + + + intersect = SW_FT_BOOL( stroker->line_length >= min_length && + line_length >= min_length ); + } + + if ( !intersect ) + { + SW_FT_Vector_From_Polar( &delta, stroker->radius, + stroker->angle_out + rotate ); + delta.x += stroker->center.x; + delta.y += stroker->center.y; + + border->movable = FALSE; + } + else + { + /* compute median angle */ + phi = stroker->angle_in + theta; + + thcos = SW_FT_Cos( theta ); + + length = SW_FT_DivFix( stroker->radius, thcos ); + + SW_FT_Vector_From_Polar( &delta, length, phi + rotate ); + delta.x += stroker->center.x; + delta.y += stroker->center.y; + } + + error = ft_stroke_border_lineto( border, &delta, FALSE ); + + return error; + } + + + /* process an outside corner, i.e. compute bevel/miter/round */ + static SW_FT_Error + ft_stroker_outside( SW_FT_Stroker stroker, + SW_FT_Int side, + SW_FT_Fixed line_length ) + { + SW_FT_StrokeBorder border = stroker->borders + side; + SW_FT_Error error; + SW_FT_Angle rotate; + + + if ( stroker->line_join == SW_FT_STROKER_LINEJOIN_ROUND ) + error = ft_stroker_arcto( stroker, side ); + else + { + /* this is a mitered (pointed) or beveled (truncated) corner */ + SW_FT_Fixed sigma = 0, radius = stroker->radius; + SW_FT_Angle theta = 0, phi = 0; + SW_FT_Fixed thcos = 0; + SW_FT_Bool bevel, fixed_bevel; + + + rotate = SW_FT_SIDE_TO_ROTATE( side ); + + bevel = + SW_FT_BOOL( stroker->line_join == SW_FT_STROKER_LINEJOIN_BEVEL ); + + fixed_bevel = + SW_FT_BOOL( stroker->line_join != SW_FT_STROKER_LINEJOIN_MITER_VARIABLE ); + + if ( !bevel ) + { + theta = SW_FT_Angle_Diff( stroker->angle_in, stroker->angle_out ); + + if ( theta == SW_FT_ANGLE_PI ) + { + theta = rotate; + phi = stroker->angle_in; + } + else + { + theta /= 2; + phi = stroker->angle_in + theta + rotate; + } + + thcos = SW_FT_Cos( theta ); + sigma = SW_FT_MulFix( stroker->miter_limit, thcos ); + + /* is miter limit exceeded? */ + if ( sigma < 0x10000L ) + { + /* don't create variable bevels for very small deviations; */ + /* SW_FT_Sin(x) = 0 for x <= 57 */ + if ( fixed_bevel || ft_pos_abs( theta ) > 57 ) + bevel = TRUE; + } + } + + if ( bevel ) /* this is a bevel (broken angle) */ + { + if ( fixed_bevel ) + { + /* the outer corners are simply joined together */ + SW_FT_Vector delta; + + + /* add bevel */ + SW_FT_Vector_From_Polar( &delta, + radius, + stroker->angle_out + rotate ); + delta.x += stroker->center.x; + delta.y += stroker->center.y; + + border->movable = FALSE; + error = ft_stroke_border_lineto( border, &delta, FALSE ); + } + else /* variable bevel */ + { + /* the miter is truncated */ + SW_FT_Vector middle, delta; + SW_FT_Fixed length; + + + /* compute middle point */ + SW_FT_Vector_From_Polar( &middle, + SW_FT_MulFix( radius, stroker->miter_limit ), + phi ); + middle.x += stroker->center.x; + middle.y += stroker->center.y; + + /* compute first angle point */ + length = SW_FT_MulDiv( radius, 0x10000L - sigma, + ft_pos_abs( SW_FT_Sin( theta ) ) ); + + SW_FT_Vector_From_Polar( &delta, length, phi + rotate ); + delta.x += middle.x; + delta.y += middle.y; + + error = ft_stroke_border_lineto( border, &delta, FALSE ); + if ( error ) + goto Exit; + + /* compute second angle point */ + SW_FT_Vector_From_Polar( &delta, length, phi - rotate ); + delta.x += middle.x; + delta.y += middle.y; + + error = ft_stroke_border_lineto( border, &delta, FALSE ); + if ( error ) + goto Exit; + + /* finally, add an end point; only needed if not lineto */ + /* (line_length is zero for curves) */ + if ( line_length == 0 ) + { + SW_FT_Vector_From_Polar( &delta, + radius, + stroker->angle_out + rotate ); + + delta.x += stroker->center.x; + delta.y += stroker->center.y; + + error = ft_stroke_border_lineto( border, &delta, FALSE ); + } + } + } + else /* this is a miter (intersection) */ + { + SW_FT_Fixed length; + SW_FT_Vector delta; + + + length = SW_FT_DivFix( stroker->radius, thcos ); + + SW_FT_Vector_From_Polar( &delta, length, phi ); + delta.x += stroker->center.x; + delta.y += stroker->center.y; + + error = ft_stroke_border_lineto( border, &delta, FALSE ); + if ( error ) + goto Exit; + + /* now add an end point; only needed if not lineto */ + /* (line_length is zero for curves) */ + if ( line_length == 0 ) + { + SW_FT_Vector_From_Polar( &delta, + stroker->radius, + stroker->angle_out + rotate ); + delta.x += stroker->center.x; + delta.y += stroker->center.y; + + error = ft_stroke_border_lineto( border, &delta, FALSE ); + } + } + } + + Exit: + return error; + } + + + static SW_FT_Error + ft_stroker_process_corner( SW_FT_Stroker stroker, + SW_FT_Fixed line_length ) + { + SW_FT_Error error = 0; + SW_FT_Angle turn; + SW_FT_Int inside_side; + + + turn = SW_FT_Angle_Diff( stroker->angle_in, stroker->angle_out ); + + /* no specific corner processing is required if the turn is 0 */ + if ( turn == 0 ) + goto Exit; + + /* when we turn to the right, the inside side is 0 */ + inside_side = 0; + + /* otherwise, the inside side is 1 */ + if ( turn < 0 ) + inside_side = 1; + + /* process the inside side */ + error = ft_stroker_inside( stroker, inside_side, line_length ); + if ( error ) + goto Exit; + + /* process the outside side */ + error = ft_stroker_outside( stroker, 1 - inside_side, line_length ); + + Exit: + return error; + } + + + /* add two points to the left and right borders corresponding to the */ + /* start of the subpath */ + static SW_FT_Error + ft_stroker_subpath_start( SW_FT_Stroker stroker, + SW_FT_Angle start_angle, + SW_FT_Fixed line_length ) + { + SW_FT_Vector delta; + SW_FT_Vector point; + SW_FT_Error error; + SW_FT_StrokeBorder border; + + + SW_FT_Vector_From_Polar( &delta, stroker->radius, + start_angle + SW_FT_ANGLE_PI2 ); + + point.x = stroker->center.x + delta.x; + point.y = stroker->center.y + delta.y; + + border = stroker->borders; + error = ft_stroke_border_moveto( border, &point ); + if ( error ) + goto Exit; + + point.x = stroker->center.x - delta.x; + point.y = stroker->center.y - delta.y; + + border++; + error = ft_stroke_border_moveto( border, &point ); + + /* save angle, position, and line length for last join */ + /* (line_length is zero for curves) */ + stroker->subpath_angle = start_angle; + stroker->first_point = FALSE; + stroker->subpath_line_length = line_length; + + Exit: + return error; + } + + + /* documentation is in ftstroke.h */ + + SW_FT_Error + SW_FT_Stroker_LineTo( SW_FT_Stroker stroker, + SW_FT_Vector* to ) + { + SW_FT_Error error = 0; + SW_FT_StrokeBorder border; + SW_FT_Vector delta; + SW_FT_Angle angle; + SW_FT_Int side; + SW_FT_Fixed line_length; + + + delta.x = to->x - stroker->center.x; + delta.y = to->y - stroker->center.y; + + /* a zero-length lineto is a no-op; avoid creating a spurious corner */ + if ( delta.x == 0 && delta.y == 0 ) + goto Exit; + + /* compute length of line */ + line_length = SW_FT_Vector_Length( &delta ); + + angle = SW_FT_Atan2( delta.x, delta.y ); + SW_FT_Vector_From_Polar( &delta, stroker->radius, angle + SW_FT_ANGLE_PI2 ); + + /* process corner if necessary */ + if ( stroker->first_point ) + { + /* This is the first segment of a subpath. We need to */ + /* add a point to each border at their respective starting */ + /* point locations. */ + error = ft_stroker_subpath_start( stroker, angle, line_length ); + if ( error ) + goto Exit; + } + else + { + /* process the current corner */ + stroker->angle_out = angle; + error = ft_stroker_process_corner( stroker, line_length ); + if ( error ) + goto Exit; + } + + /* now add a line segment to both the `inside' and `outside' paths */ + for ( border = stroker->borders, side = 1; side >= 0; side--, border++ ) + { + SW_FT_Vector point; + + + point.x = to->x + delta.x; + point.y = to->y + delta.y; + + /* the ends of lineto borders are movable */ + error = ft_stroke_border_lineto( border, &point, TRUE ); + if ( error ) + goto Exit; + + delta.x = -delta.x; + delta.y = -delta.y; + } + + stroker->angle_in = angle; + stroker->center = *to; + stroker->line_length = line_length; + + Exit: + return error; + } + + + /* documentation is in ftstroke.h */ + + SW_FT_Error + SW_FT_Stroker_ConicTo( SW_FT_Stroker stroker, + SW_FT_Vector* control, + SW_FT_Vector* to ) + { + SW_FT_Error error = 0; + SW_FT_Vector bez_stack[34]; + SW_FT_Vector* arc; + SW_FT_Vector* limit = bez_stack + 30; + SW_FT_Bool first_arc = TRUE; + + + /* if all control points are coincident, this is a no-op; */ + /* avoid creating a spurious corner */ + if ( SW_FT_IS_SMALL( stroker->center.x - control->x ) && + SW_FT_IS_SMALL( stroker->center.y - control->y ) && + SW_FT_IS_SMALL( control->x - to->x ) && + SW_FT_IS_SMALL( control->y - to->y ) ) + { + stroker->center = *to; + goto Exit; + } + + arc = bez_stack; + arc[0] = *to; + arc[1] = *control; + arc[2] = stroker->center; + + while ( arc >= bez_stack ) + { + SW_FT_Angle angle_in, angle_out; + + + /* initialize with current direction */ + angle_in = angle_out = stroker->angle_in; + + if ( arc < limit && + !ft_conic_is_small_enough( arc, &angle_in, &angle_out ) ) + { + if ( stroker->first_point ) + stroker->angle_in = angle_in; + + ft_conic_split( arc ); + arc += 2; + continue; + } + + if ( first_arc ) + { + first_arc = FALSE; + + /* process corner if necessary */ + if ( stroker->first_point ) + error = ft_stroker_subpath_start( stroker, angle_in, 0 ); + else + { + stroker->angle_out = angle_in; + error = ft_stroker_process_corner( stroker, 0 ); + } + } + else if ( ft_pos_abs( SW_FT_Angle_Diff( stroker->angle_in, angle_in ) ) > + SW_FT_SMALL_CONIC_THRESHOLD / 4 ) + { + /* if the deviation from one arc to the next is too great, */ + /* add a round corner */ + stroker->center = arc[2]; + stroker->angle_out = angle_in; + stroker->line_join = SW_FT_STROKER_LINEJOIN_ROUND; + + error = ft_stroker_process_corner( stroker, 0 ); + + /* reinstate line join style */ + stroker->line_join = stroker->line_join_saved; + } + + if ( error ) + goto Exit; + + /* the arc's angle is small enough; we can add it directly to each */ + /* border */ + { + SW_FT_Vector ctrl, end; + SW_FT_Angle theta, phi, rotate, alpha0 = 0; + SW_FT_Fixed length; + SW_FT_StrokeBorder border; + SW_FT_Int side; + + + theta = SW_FT_Angle_Diff( angle_in, angle_out ) / 2; + phi = angle_in + theta; + length = SW_FT_DivFix( stroker->radius, SW_FT_Cos( theta ) ); + + /* compute direction of original arc */ + if ( stroker->handle_wide_strokes ) + alpha0 = SW_FT_Atan2( arc[0].x - arc[2].x, arc[0].y - arc[2].y ); + + for ( border = stroker->borders, side = 0; + side <= 1; + side++, border++ ) + { + rotate = SW_FT_SIDE_TO_ROTATE( side ); + + /* compute control point */ + SW_FT_Vector_From_Polar( &ctrl, length, phi + rotate ); + ctrl.x += arc[1].x; + ctrl.y += arc[1].y; + + /* compute end point */ + SW_FT_Vector_From_Polar( &end, stroker->radius, angle_out + rotate ); + end.x += arc[0].x; + end.y += arc[0].y; + + if ( stroker->handle_wide_strokes ) + { + SW_FT_Vector start; + SW_FT_Angle alpha1; + + + /* determine whether the border radius is greater than the */ + /* radius of curvature of the original arc */ + start = border->points[border->num_points - 1]; + + alpha1 = SW_FT_Atan2( end.x - start.x, end.y - start.y ); + + /* is the direction of the border arc opposite to */ + /* that of the original arc? */ + if ( ft_pos_abs( SW_FT_Angle_Diff( alpha0, alpha1 ) ) > + SW_FT_ANGLE_PI / 2 ) + { + SW_FT_Angle beta, gamma; + SW_FT_Vector bvec, delta; + SW_FT_Fixed blen, sinA, sinB, alen; + + + /* use the sine rule to find the intersection point */ + beta = SW_FT_Atan2( arc[2].x - start.x, arc[2].y - start.y ); + gamma = SW_FT_Atan2( arc[0].x - end.x, arc[0].y - end.y ); + + bvec.x = end.x - start.x; + bvec.y = end.y - start.y; + + blen = SW_FT_Vector_Length( &bvec ); + + sinA = ft_pos_abs( SW_FT_Sin( alpha1 - gamma ) ); + sinB = ft_pos_abs( SW_FT_Sin( beta - gamma ) ); + + alen = SW_FT_MulDiv( blen, sinA, sinB ); + + SW_FT_Vector_From_Polar( &delta, alen, beta ); + delta.x += start.x; + delta.y += start.y; + + /* circumnavigate the negative sector backwards */ + border->movable = FALSE; + error = ft_stroke_border_lineto( border, &delta, FALSE ); + if ( error ) + goto Exit; + error = ft_stroke_border_lineto( border, &end, FALSE ); + if ( error ) + goto Exit; + error = ft_stroke_border_conicto( border, &ctrl, &start ); + if ( error ) + goto Exit; + /* and then move to the endpoint */ + error = ft_stroke_border_lineto( border, &end, FALSE ); + if ( error ) + goto Exit; + + continue; + } + + /* else fall through */ + } + + /* simply add an arc */ + error = ft_stroke_border_conicto( border, &ctrl, &end ); + if ( error ) + goto Exit; + } + } + + arc -= 2; + + stroker->angle_in = angle_out; + } + + stroker->center = *to; + + Exit: + return error; + } + + + /* documentation is in ftstroke.h */ + + SW_FT_Error + SW_FT_Stroker_CubicTo( SW_FT_Stroker stroker, + SW_FT_Vector* control1, + SW_FT_Vector* control2, + SW_FT_Vector* to ) + { + SW_FT_Error error = 0; + SW_FT_Vector bez_stack[37]; + SW_FT_Vector* arc; + SW_FT_Vector* limit = bez_stack + 32; + SW_FT_Bool first_arc = TRUE; + + + /* if all control points are coincident, this is a no-op; */ + /* avoid creating a spurious corner */ + if ( SW_FT_IS_SMALL( stroker->center.x - control1->x ) && + SW_FT_IS_SMALL( stroker->center.y - control1->y ) && + SW_FT_IS_SMALL( control1->x - control2->x ) && + SW_FT_IS_SMALL( control1->y - control2->y ) && + SW_FT_IS_SMALL( control2->x - to->x ) && + SW_FT_IS_SMALL( control2->y - to->y ) ) + { + stroker->center = *to; + goto Exit; + } + + arc = bez_stack; + arc[0] = *to; + arc[1] = *control2; + arc[2] = *control1; + arc[3] = stroker->center; + + while ( arc >= bez_stack ) + { + SW_FT_Angle angle_in, angle_mid, angle_out; + + + /* initialize with current direction */ + angle_in = angle_out = angle_mid = stroker->angle_in; + + if ( arc < limit && + !ft_cubic_is_small_enough( arc, &angle_in, + &angle_mid, &angle_out ) ) + { + if ( stroker->first_point ) + stroker->angle_in = angle_in; + + ft_cubic_split( arc ); + arc += 3; + continue; + } + + if ( first_arc ) + { + first_arc = FALSE; + + /* process corner if necessary */ + if ( stroker->first_point ) + error = ft_stroker_subpath_start( stroker, angle_in, 0 ); + else + { + stroker->angle_out = angle_in; + error = ft_stroker_process_corner( stroker, 0 ); + } + } + else if ( ft_pos_abs( SW_FT_Angle_Diff( stroker->angle_in, angle_in ) ) > + SW_FT_SMALL_CUBIC_THRESHOLD / 4 ) + { + /* if the deviation from one arc to the next is too great, */ + /* add a round corner */ + stroker->center = arc[3]; + stroker->angle_out = angle_in; + stroker->line_join = SW_FT_STROKER_LINEJOIN_ROUND; + + error = ft_stroker_process_corner( stroker, 0 ); + + /* reinstate line join style */ + stroker->line_join = stroker->line_join_saved; + } + + if ( error ) + goto Exit; + + /* the arc's angle is small enough; we can add it directly to each */ + /* border */ + { + SW_FT_Vector ctrl1, ctrl2, end; + SW_FT_Angle theta1, phi1, theta2, phi2, rotate, alpha0 = 0; + SW_FT_Fixed length1, length2; + SW_FT_StrokeBorder border; + SW_FT_Int side; + + + theta1 = SW_FT_Angle_Diff( angle_in, angle_mid ) / 2; + theta2 = SW_FT_Angle_Diff( angle_mid, angle_out ) / 2; + phi1 = ft_angle_mean( angle_in, angle_mid ); + phi2 = ft_angle_mean( angle_mid, angle_out ); + length1 = SW_FT_DivFix( stroker->radius, SW_FT_Cos( theta1 ) ); + length2 = SW_FT_DivFix( stroker->radius, SW_FT_Cos( theta2 ) ); + + /* compute direction of original arc */ + if ( stroker->handle_wide_strokes ) + alpha0 = SW_FT_Atan2( arc[0].x - arc[3].x, arc[0].y - arc[3].y ); + + for ( border = stroker->borders, side = 0; + side <= 1; + side++, border++ ) + { + rotate = SW_FT_SIDE_TO_ROTATE( side ); + + /* compute control points */ + SW_FT_Vector_From_Polar( &ctrl1, length1, phi1 + rotate ); + ctrl1.x += arc[2].x; + ctrl1.y += arc[2].y; + + SW_FT_Vector_From_Polar( &ctrl2, length2, phi2 + rotate ); + ctrl2.x += arc[1].x; + ctrl2.y += arc[1].y; + + /* compute end point */ + SW_FT_Vector_From_Polar( &end, stroker->radius, angle_out + rotate ); + end.x += arc[0].x; + end.y += arc[0].y; + + if ( stroker->handle_wide_strokes ) + { + SW_FT_Vector start; + SW_FT_Angle alpha1; + + + /* determine whether the border radius is greater than the */ + /* radius of curvature of the original arc */ + start = border->points[border->num_points - 1]; + + alpha1 = SW_FT_Atan2( end.x - start.x, end.y - start.y ); + + /* is the direction of the border arc opposite to */ + /* that of the original arc? */ + if ( ft_pos_abs( SW_FT_Angle_Diff( alpha0, alpha1 ) ) > + SW_FT_ANGLE_PI / 2 ) + { + SW_FT_Angle beta, gamma; + SW_FT_Vector bvec, delta; + SW_FT_Fixed blen, sinA, sinB, alen; + + + /* use the sine rule to find the intersection point */ + beta = SW_FT_Atan2( arc[3].x - start.x, arc[3].y - start.y ); + gamma = SW_FT_Atan2( arc[0].x - end.x, arc[0].y - end.y ); + + bvec.x = end.x - start.x; + bvec.y = end.y - start.y; + + blen = SW_FT_Vector_Length( &bvec ); + + sinA = ft_pos_abs( SW_FT_Sin( alpha1 - gamma ) ); + sinB = ft_pos_abs( SW_FT_Sin( beta - gamma ) ); + + alen = SW_FT_MulDiv( blen, sinA, sinB ); + + SW_FT_Vector_From_Polar( &delta, alen, beta ); + delta.x += start.x; + delta.y += start.y; + + /* circumnavigate the negative sector backwards */ + border->movable = FALSE; + error = ft_stroke_border_lineto( border, &delta, FALSE ); + if ( error ) + goto Exit; + error = ft_stroke_border_lineto( border, &end, FALSE ); + if ( error ) + goto Exit; + error = ft_stroke_border_cubicto( border, + &ctrl2, + &ctrl1, + &start ); + if ( error ) + goto Exit; + /* and then move to the endpoint */ + error = ft_stroke_border_lineto( border, &end, FALSE ); + if ( error ) + goto Exit; + + continue; + } + + /* else fall through */ + } + + /* simply add an arc */ + error = ft_stroke_border_cubicto( border, &ctrl1, &ctrl2, &end ); + if ( error ) + goto Exit; + } + } + + arc -= 3; + + stroker->angle_in = angle_out; + } + + stroker->center = *to; + + Exit: + return error; + } + + + /* documentation is in ftstroke.h */ + + SW_FT_Error + SW_FT_Stroker_BeginSubPath( SW_FT_Stroker stroker, + SW_FT_Vector* to, + SW_FT_Bool open ) + { + /* We cannot process the first point, because there is not enough */ + /* information regarding its corner/cap. The latter will be processed */ + /* in the `SW_FT_Stroker_EndSubPath' routine. */ + /* */ + stroker->first_point = TRUE; + stroker->center = *to; + stroker->subpath_open = open; + + /* Determine if we need to check whether the border radius is greater */ + /* than the radius of curvature of a curve, to handle this case */ + /* specially. This is only required if bevel joins or butt caps may */ + /* be created, because round & miter joins and round & square caps */ + /* cover the negative sector created with wide strokes. */ + stroker->handle_wide_strokes = + SW_FT_BOOL( stroker->line_join != SW_FT_STROKER_LINEJOIN_ROUND || + ( stroker->subpath_open && + stroker->line_cap == SW_FT_STROKER_LINECAP_BUTT ) ); + + /* record the subpath start point for each border */ + stroker->subpath_start = *to; + + stroker->angle_in = 0; + + return 0; + } + + + static SW_FT_Error + ft_stroker_add_reverse_left( SW_FT_Stroker stroker, + SW_FT_Bool open ) + { + SW_FT_StrokeBorder right = stroker->borders + 0; + SW_FT_StrokeBorder left = stroker->borders + 1; + SW_FT_Int new_points; + SW_FT_Error error = 0; + + + assert( left->start >= 0 ); + + new_points = left->num_points - left->start; + if ( new_points > 0 ) + { + error = ft_stroke_border_grow( right, (SW_FT_UInt)new_points ); + if ( error ) + goto Exit; + + { + SW_FT_Vector* dst_point = right->points + right->num_points; + SW_FT_Byte* dst_tag = right->tags + right->num_points; + SW_FT_Vector* src_point = left->points + left->num_points - 1; + SW_FT_Byte* src_tag = left->tags + left->num_points - 1; + + + while ( src_point >= left->points + left->start ) + { + *dst_point = *src_point; + *dst_tag = *src_tag; + + if ( open ) + dst_tag[0] &= ~SW_FT_STROKE_TAG_BEGIN_END; + else + { + SW_FT_Byte ttag = + (SW_FT_Byte)( dst_tag[0] & SW_FT_STROKE_TAG_BEGIN_END ); + + + /* switch begin/end tags if necessary */ + if ( ttag == SW_FT_STROKE_TAG_BEGIN || + ttag == SW_FT_STROKE_TAG_END ) + dst_tag[0] ^= SW_FT_STROKE_TAG_BEGIN_END; + } + + src_point--; + src_tag--; + dst_point++; + dst_tag++; + } + } + + left->num_points = left->start; + right->num_points += new_points; + + right->movable = FALSE; + left->movable = FALSE; + } + + Exit: + return error; + } + + + /* documentation is in ftstroke.h */ + + /* there's a lot of magic in this function! */ + SW_FT_Error + SW_FT_Stroker_EndSubPath( SW_FT_Stroker stroker ) + { + SW_FT_Error error = 0; + + + if ( stroker->subpath_open ) + { + SW_FT_StrokeBorder right = stroker->borders; + + + /* All right, this is an opened path, we need to add a cap between */ + /* right & left, add the reverse of left, then add a final cap */ + /* between left & right. */ + error = ft_stroker_cap( stroker, stroker->angle_in, 0 ); + if ( error ) + goto Exit; + + /* add reversed points from `left' to `right' */ + error = ft_stroker_add_reverse_left( stroker, TRUE ); + if ( error ) + goto Exit; + + /* now add the final cap */ + stroker->center = stroker->subpath_start; + error = ft_stroker_cap( stroker, + stroker->subpath_angle + SW_FT_ANGLE_PI, 0 ); + if ( error ) + goto Exit; + + /* Now end the right subpath accordingly. The left one is */ + /* rewind and doesn't need further processing. */ + ft_stroke_border_close( right, FALSE ); + } + else + { + SW_FT_Angle turn; + SW_FT_Int inside_side; + + + /* close the path if needed */ + if ( stroker->center.x != stroker->subpath_start.x || + stroker->center.y != stroker->subpath_start.y ) + { + error = SW_FT_Stroker_LineTo( stroker, &stroker->subpath_start ); + if ( error ) + goto Exit; + } + + /* process the corner */ + stroker->angle_out = stroker->subpath_angle; + turn = SW_FT_Angle_Diff( stroker->angle_in, + stroker->angle_out ); + + /* no specific corner processing is required if the turn is 0 */ + if ( turn != 0 ) + { + /* when we turn to the right, the inside side is 0 */ + inside_side = 0; + + /* otherwise, the inside side is 1 */ + if ( turn < 0 ) + inside_side = 1; + + error = ft_stroker_inside( stroker, + inside_side, + stroker->subpath_line_length ); + if ( error ) + goto Exit; + + /* process the outside side */ + error = ft_stroker_outside( stroker, + 1 - inside_side, + stroker->subpath_line_length ); + if ( error ) + goto Exit; + } + + /* then end our two subpaths */ + ft_stroke_border_close( stroker->borders + 0, FALSE ); + ft_stroke_border_close( stroker->borders + 1, TRUE ); + } + + Exit: + return error; + } + + + /* documentation is in ftstroke.h */ + + SW_FT_Error + SW_FT_Stroker_GetBorderCounts( SW_FT_Stroker stroker, + SW_FT_StrokerBorder border, + SW_FT_UInt *anum_points, + SW_FT_UInt *anum_contours ) + { + SW_FT_UInt num_points = 0, num_contours = 0; + SW_FT_Error error; + + + if ( !stroker || border > 1 ) + { + error = -1;//SW_FT_THROW( Invalid_Argument ); + goto Exit; + } + + error = ft_stroke_border_get_counts( stroker->borders + border, + &num_points, &num_contours ); + Exit: + if ( anum_points ) + *anum_points = num_points; + + if ( anum_contours ) + *anum_contours = num_contours; + + return error; + } + + + /* documentation is in ftstroke.h */ + + SW_FT_Error + SW_FT_Stroker_GetCounts( SW_FT_Stroker stroker, + SW_FT_UInt *anum_points, + SW_FT_UInt *anum_contours ) + { + SW_FT_UInt count1, count2, num_points = 0; + SW_FT_UInt count3, count4, num_contours = 0; + SW_FT_Error error; + + + error = ft_stroke_border_get_counts( stroker->borders + 0, + &count1, &count2 ); + if ( error ) + goto Exit; + + error = ft_stroke_border_get_counts( stroker->borders + 1, + &count3, &count4 ); + if ( error ) + goto Exit; + + num_points = count1 + count3; + num_contours = count2 + count4; + + Exit: + *anum_points = num_points; + *anum_contours = num_contours; + return error; + } + + + /* documentation is in ftstroke.h */ + + void + SW_FT_Stroker_ExportBorder( SW_FT_Stroker stroker, + SW_FT_StrokerBorder border, + SW_FT_Outline* outline ) + { + if ( border == SW_FT_STROKER_BORDER_LEFT || + border == SW_FT_STROKER_BORDER_RIGHT ) + { + SW_FT_StrokeBorder sborder = & stroker->borders[border]; + + + if ( sborder->valid ) + ft_stroke_border_export( sborder, outline ); + } + } + + + /* documentation is in ftstroke.h */ + + void + SW_FT_Stroker_Export( SW_FT_Stroker stroker, + SW_FT_Outline* outline ) + { + SW_FT_Stroker_ExportBorder( stroker, SW_FT_STROKER_BORDER_LEFT, outline ); + SW_FT_Stroker_ExportBorder( stroker, SW_FT_STROKER_BORDER_RIGHT, outline ); + } + + + /* documentation is in ftstroke.h */ + + /* + * The following is very similar to SW_FT_Outline_Decompose, except + * that we do support opened paths, and do not scale the outline. + */ + SW_FT_Error + SW_FT_Stroker_ParseOutline( SW_FT_Stroker stroker, + SW_FT_Outline* outline, + SW_FT_Bool opened ) + { + SW_FT_Vector v_last; + SW_FT_Vector v_control; + SW_FT_Vector v_start; + + SW_FT_Vector* point; + SW_FT_Vector* limit; + char* tags; + + SW_FT_Error error; + + SW_FT_Int n; /* index of contour in outline */ + SW_FT_UInt first; /* index of first point in contour */ + SW_FT_Int tag; /* current point's state */ + + + if ( !outline || !stroker ) + return -1;//SW_FT_THROW( Invalid_Argument ); + + SW_FT_Stroker_Rewind( stroker ); + + first = 0; + + for ( n = 0; n < outline->n_contours; n++ ) + { + SW_FT_UInt last; /* index of last point in contour */ + + + last = outline->contours[n]; + limit = outline->points + last; + + /* skip empty points; we don't stroke these */ + if ( last <= first ) + { + first = last + 1; + continue; + } + + v_start = outline->points[first]; + v_last = outline->points[last]; + + v_control = v_start; + + point = outline->points + first; + tags = outline->tags + first; + tag = SW_FT_CURVE_TAG( tags[0] ); + + /* A contour cannot start with a cubic control point! */ + if ( tag == SW_FT_CURVE_TAG_CUBIC ) + goto Invalid_Outline; + + /* check first point to determine origin */ + if ( tag == SW_FT_CURVE_TAG_CONIC ) + { + /* First point is conic control. Yes, this happens. */ + if ( SW_FT_CURVE_TAG( outline->tags[last] ) == SW_FT_CURVE_TAG_ON ) + { + /* start at last point if it is on the curve */ + v_start = v_last; + limit--; + } + else + { + /* if both first and last points are conic, */ + /* start at their middle */ + v_start.x = ( v_start.x + v_last.x ) / 2; + v_start.y = ( v_start.y + v_last.y ) / 2; + } + point--; + tags--; + } + + error = SW_FT_Stroker_BeginSubPath( stroker, &v_start, opened ); + if ( error ) + goto Exit; + + while ( point < limit ) + { + point++; + tags++; + + tag = SW_FT_CURVE_TAG( tags[0] ); + switch ( tag ) + { + case SW_FT_CURVE_TAG_ON: /* emit a single line_to */ + { + SW_FT_Vector vec; + + + vec.x = point->x; + vec.y = point->y; + + error = SW_FT_Stroker_LineTo( stroker, &vec ); + if ( error ) + goto Exit; + continue; + } + + case SW_FT_CURVE_TAG_CONIC: /* consume conic arcs */ + v_control.x = point->x; + v_control.y = point->y; + + Do_Conic: + if ( point < limit ) + { + SW_FT_Vector vec; + SW_FT_Vector v_middle; + + + point++; + tags++; + tag = SW_FT_CURVE_TAG( tags[0] ); + + vec = point[0]; + + if ( tag == SW_FT_CURVE_TAG_ON ) + { + error = SW_FT_Stroker_ConicTo( stroker, &v_control, &vec ); + if ( error ) + goto Exit; + continue; + } + + if ( tag != SW_FT_CURVE_TAG_CONIC ) + goto Invalid_Outline; + + v_middle.x = ( v_control.x + vec.x ) / 2; + v_middle.y = ( v_control.y + vec.y ) / 2; + + error = SW_FT_Stroker_ConicTo( stroker, &v_control, &v_middle ); + if ( error ) + goto Exit; + + v_control = vec; + goto Do_Conic; + } + + error = SW_FT_Stroker_ConicTo( stroker, &v_control, &v_start ); + goto Close; + + default: /* SW_FT_CURVE_TAG_CUBIC */ + { + SW_FT_Vector vec1, vec2; + + + if ( point + 1 > limit || + SW_FT_CURVE_TAG( tags[1] ) != SW_FT_CURVE_TAG_CUBIC ) + goto Invalid_Outline; + + point += 2; + tags += 2; + + vec1 = point[-2]; + vec2 = point[-1]; + + if ( point <= limit ) + { + SW_FT_Vector vec; + + + vec = point[0]; + + error = SW_FT_Stroker_CubicTo( stroker, &vec1, &vec2, &vec ); + if ( error ) + goto Exit; + continue; + } + + error = SW_FT_Stroker_CubicTo( stroker, &vec1, &vec2, &v_start ); + goto Close; + } + } + } + + Close: + if ( error ) + goto Exit; + + /* don't try to end the path if no segments have been generated */ + if ( !stroker->first_point ) + { + error = SW_FT_Stroker_EndSubPath( stroker ); + if ( error ) + goto Exit; + } + + first = last + 1; + } + + return 0; + + Exit: + return error; + + Invalid_Outline: + return -2;//SW_FT_THROW( Invalid_Outline ); + } + + +/* END */ diff --git a/src/lib/ector/software/sw_ft_stroker.h b/src/lib/ector/software/sw_ft_stroker.h new file mode 100755 index 0000000000..75830fb25c --- /dev/null +++ b/src/lib/ector/software/sw_ft_stroker.h @@ -0,0 +1,325 @@ +#ifndef SW_FT_STROKER_H +#define SW_FT_STROKER_H +/***************************************************************************/ +/* */ +/* ftstroke.h */ +/* */ +/* FreeType path stroker (specification). */ +/* */ +/* Copyright 2002-2006, 2008, 2009, 2011-2012 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + +#include "sw_ft_raster.h" + + /************************************************************** + * + * @type: + * SW_FT_Stroker + * + * @description: + * Opaque handler to a path stroker object. + */ + typedef struct SW_FT_StrokerRec_* SW_FT_Stroker; + + + /************************************************************** + * + * @enum: + * SW_FT_Stroker_LineJoin + * + * @description: + * These values determine how two joining lines are rendered + * in a stroker. + * + * @values: + * SW_FT_STROKER_LINEJOIN_ROUND :: + * Used to render rounded line joins. Circular arcs are used + * to join two lines smoothly. + * + * SW_FT_STROKER_LINEJOIN_BEVEL :: + * Used to render beveled line joins. The outer corner of + * the joined lines is filled by enclosing the triangular + * region of the corner with a straight line between the + * outer corners of each stroke. + * + * SW_FT_STROKER_LINEJOIN_MITER_FIXED :: + * Used to render mitered line joins, with fixed bevels if the + * miter limit is exceeded. The outer edges of the strokes + * for the two segments are extended until they meet at an + * angle. If the segments meet at too sharp an angle (such + * that the miter would extend from the intersection of the + * segments a distance greater than the product of the miter + * limit value and the border radius), then a bevel join (see + * above) is used instead. This prevents long spikes being + * created. SW_FT_STROKER_LINEJOIN_MITER_FIXED generates a miter + * line join as used in PostScript and PDF. + * + * SW_FT_STROKER_LINEJOIN_MITER_VARIABLE :: + * SW_FT_STROKER_LINEJOIN_MITER :: + * Used to render mitered line joins, with variable bevels if + * the miter limit is exceeded. The intersection of the + * strokes is clipped at a line perpendicular to the bisector + * of the angle between the strokes, at the distance from the + * intersection of the segments equal to the product of the + * miter limit value and the border radius. This prevents + * long spikes being created. + * SW_FT_STROKER_LINEJOIN_MITER_VARIABLE generates a mitered line + * join as used in XPS. SW_FT_STROKER_LINEJOIN_MITER is an alias + * for SW_FT_STROKER_LINEJOIN_MITER_VARIABLE, retained for + * backwards compatibility. + */ + typedef enum SW_FT_Stroker_LineJoin_ + { + SW_FT_STROKER_LINEJOIN_ROUND = 0, + SW_FT_STROKER_LINEJOIN_BEVEL = 1, + SW_FT_STROKER_LINEJOIN_MITER_VARIABLE = 2, + SW_FT_STROKER_LINEJOIN_MITER = SW_FT_STROKER_LINEJOIN_MITER_VARIABLE, + SW_FT_STROKER_LINEJOIN_MITER_FIXED = 3 + + } SW_FT_Stroker_LineJoin; + + + /************************************************************** + * + * @enum: + * SW_FT_Stroker_LineCap + * + * @description: + * These values determine how the end of opened sub-paths are + * rendered in a stroke. + * + * @values: + * SW_FT_STROKER_LINECAP_BUTT :: + * The end of lines is rendered as a full stop on the last + * point itself. + * + * SW_FT_STROKER_LINECAP_ROUND :: + * The end of lines is rendered as a half-circle around the + * last point. + * + * SW_FT_STROKER_LINECAP_SQUARE :: + * The end of lines is rendered as a square around the + * last point. + */ + typedef enum SW_FT_Stroker_LineCap_ + { + SW_FT_STROKER_LINECAP_BUTT = 0, + SW_FT_STROKER_LINECAP_ROUND, + SW_FT_STROKER_LINECAP_SQUARE + + } SW_FT_Stroker_LineCap; + + + /************************************************************** + * + * @enum: + * SW_FT_StrokerBorder + * + * @description: + * These values are used to select a given stroke border + * in @SW_FT_Stroker_GetBorderCounts and @SW_FT_Stroker_ExportBorder. + * + * @values: + * SW_FT_STROKER_BORDER_LEFT :: + * Select the left border, relative to the drawing direction. + * + * SW_FT_STROKER_BORDER_RIGHT :: + * Select the right border, relative to the drawing direction. + * + * @note: + * Applications are generally interested in the `inside' and `outside' + * borders. However, there is no direct mapping between these and the + * `left' and `right' ones, since this really depends on the glyph's + * drawing orientation, which varies between font formats. + * + * You can however use @SW_FT_Outline_GetInsideBorder and + * @SW_FT_Outline_GetOutsideBorder to get these. + */ + typedef enum SW_FT_StrokerBorder_ + { + SW_FT_STROKER_BORDER_LEFT = 0, + SW_FT_STROKER_BORDER_RIGHT + + } SW_FT_StrokerBorder; + + + /************************************************************** + * + * @function: + * SW_FT_Stroker_New + * + * @description: + * Create a new stroker object. + * + * @input: + * library :: + * FreeType library handle. + * + * @output: + * astroker :: + * A new stroker object handle. NULL in case of error. + * + * @return: + * FreeType error code. 0~means success. + */ + SW_FT_Error + SW_FT_Stroker_New( SW_FT_Stroker *astroker ); + + + /************************************************************** + * + * @function: + * SW_FT_Stroker_Set + * + * @description: + * Reset a stroker object's attributes. + * + * @input: + * stroker :: + * The target stroker handle. + * + * radius :: + * The border radius. + * + * line_cap :: + * The line cap style. + * + * line_join :: + * The line join style. + * + * miter_limit :: + * The miter limit for the SW_FT_STROKER_LINEJOIN_MITER_FIXED and + * SW_FT_STROKER_LINEJOIN_MITER_VARIABLE line join styles, + * expressed as 16.16 fixed-point value. + * + * @note: + * The radius is expressed in the same units as the outline + * coordinates. + */ + void + SW_FT_Stroker_Set( SW_FT_Stroker stroker, + SW_FT_Fixed radius, + SW_FT_Stroker_LineCap line_cap, + SW_FT_Stroker_LineJoin line_join, + SW_FT_Fixed miter_limit ); + + /************************************************************** + * + * @function: + * SW_FT_Stroker_ParseOutline + * + * @description: + * A convenience function used to parse a whole outline with + * the stroker. The resulting outline(s) can be retrieved + * later by functions like @SW_FT_Stroker_GetCounts and @SW_FT_Stroker_Export. + * + * @input: + * stroker :: + * The target stroker handle. + * + * outline :: + * The source outline. + * + * opened :: + * A boolean. If~1, the outline is treated as an open path instead + * of a closed one. + * + * @return: + * FreeType error code. 0~means success. + * + * @note: + * If `opened' is~0 (the default), the outline is treated as a closed + * path, and the stroker generates two distinct `border' outlines. + * + * If `opened' is~1, the outline is processed as an open path, and the + * stroker generates a single `stroke' outline. + * + * This function calls @SW_FT_Stroker_Rewind automatically. + */ + SW_FT_Error + SW_FT_Stroker_ParseOutline( SW_FT_Stroker stroker, + SW_FT_Outline* outline, + SW_FT_Bool opened ); + + + /************************************************************** + * + * @function: + * SW_FT_Stroker_GetCounts + * + * @description: + * Call this function once you have finished parsing your paths + * with the stroker. It returns the number of points and + * contours necessary to export all points/borders from the stroked + * outline/path. + * + * @input: + * stroker :: + * The target stroker handle. + * + * @output: + * anum_points :: + * The number of points. + * + * anum_contours :: + * The number of contours. + * + * @return: + * FreeType error code. 0~means success. + */ + SW_FT_Error + SW_FT_Stroker_GetCounts( SW_FT_Stroker stroker, + SW_FT_UInt *anum_points, + SW_FT_UInt *anum_contours ); + + + /************************************************************** + * + * @function: + * SW_FT_Stroker_Export + * + * @description: + * Call this function after @SW_FT_Stroker_GetBorderCounts to + * export all borders to your own @SW_FT_Outline structure. + * + * Note that this function appends the border points and + * contours to your outline, but does not try to resize its + * arrays. + * + * @input: + * stroker :: + * The target stroker handle. + * + * outline :: + * The target outline handle. + */ + void + SW_FT_Stroker_Export( SW_FT_Stroker stroker, + SW_FT_Outline* outline ); + + + /************************************************************** + * + * @function: + * SW_FT_Stroker_Done + * + * @description: + * Destroy a stroker object. + * + * @input: + * stroker :: + * A stroker handle. Can be NULL. + */ + void + SW_FT_Stroker_Done( SW_FT_Stroker stroker ); + + +#endif // SW_FT_STROKER_H diff --git a/src/lib/ector/software/sw_ft_types.h b/src/lib/ector/software/sw_ft_types.h new file mode 100755 index 0000000000..1e8b865233 --- /dev/null +++ b/src/lib/ector/software/sw_ft_types.h @@ -0,0 +1,160 @@ +#ifndef SW_FT_TYPES_H +#define SW_FT_TYPES_H + +/*************************************************************************/ +/* */ +/* */ +/* SW_FT_Fixed */ +/* */ +/* */ +/* This type is used to store 16.16 fixed-point values, like scaling */ +/* values or matrix coefficients. */ +/* */ +typedef signed long SW_FT_Fixed; + + +/*************************************************************************/ +/* */ +/* */ +/* SW_FT_Int */ +/* */ +/* */ +/* A typedef for the int type. */ +/* */ +typedef signed int SW_FT_Int; + + +/*************************************************************************/ +/* */ +/* */ +/* SW_FT_UInt */ +/* */ +/* */ +/* A typedef for the unsigned int type. */ +/* */ +typedef unsigned int SW_FT_UInt; + + +/*************************************************************************/ +/* */ +/* */ +/* SW_FT_Long */ +/* */ +/* */ +/* A typedef for signed long. */ +/* */ +typedef signed long SW_FT_Long; + + +/*************************************************************************/ +/* */ +/* */ +/* SW_FT_ULong */ +/* */ +/* */ +/* A typedef for unsigned long. */ +/* */ +typedef unsigned long SW_FT_ULong; + +/*************************************************************************/ +/* */ +/* */ +/* SW_FT_Short */ +/* */ +/* */ +/* A typedef for signed short. */ +/* */ +typedef signed short SW_FT_Short; + + +/*************************************************************************/ +/* */ +/* */ +/* SW_FT_Byte */ +/* */ +/* */ +/* A simple typedef for the _unsigned_ char type. */ +/* */ +typedef unsigned char SW_FT_Byte; + + +/*************************************************************************/ +/* */ +/* */ +/* SW_FT_Bool */ +/* */ +/* */ +/* A typedef of unsigned char, used for simple booleans. As usual, */ +/* values 1 and~0 represent true and false, respectively. */ +/* */ +typedef unsigned char SW_FT_Bool; + + + +/*************************************************************************/ +/* */ +/* */ +/* SW_FT_Error */ +/* */ +/* */ +/* The FreeType error code type. A value of~0 is always interpreted */ +/* as a successful operation. */ +/* */ +typedef int SW_FT_Error; + + +/*************************************************************************/ +/* */ +/* */ +/* SW_FT_Pos */ +/* */ +/* */ +/* The type SW_FT_Pos is used to store vectorial coordinates. Depending */ +/* on the context, these can represent distances in integer font */ +/* units, or 16.16, or 26.6 fixed-point pixel coordinates. */ +/* */ +typedef signed long SW_FT_Pos; + + +/*************************************************************************/ +/* */ +/* */ +/* SW_FT_Vector */ +/* */ +/* */ +/* A simple structure used to store a 2D vector; coordinates are of */ +/* the SW_FT_Pos type. */ +/* */ +/* */ +/* x :: The horizontal coordinate. */ +/* y :: The vertical coordinate. */ +/* */ +typedef struct SW_FT_Vector_ +{ + SW_FT_Pos x; + SW_FT_Pos y; + +} SW_FT_Vector; + + +typedef long long int SW_FT_Int64; +typedef unsigned long long int SW_FT_UInt64; + +typedef signed int SW_FT_Int32; +typedef unsigned int SW_FT_UInt32; + + +#define SW_FT_BOOL( x ) ( (SW_FT_Bool)( x ) ) + +#define SW_FT_SIZEOF_LONG 4 + +#ifndef TRUE +#define TRUE 1 +#endif + +#ifndef FALSE +#define FALSE 0 +#endif + + +#endif // SW_FT_TYPES_H From b5c0b676e2a6dd85f26582a032caa3ce7f343ac6 Mon Sep 17 00:00:00 2001 From: Subhransu Sekhar Mohanty Date: Fri, 3 Apr 2015 16:31:47 +0200 Subject: [PATCH 158/251] ector: build FreeType software backend. --- src/Makefile_Ector.am | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/src/Makefile_Ector.am b/src/Makefile_Ector.am index ea063ee6c0..11ed70cdf3 100644 --- a/src/Makefile_Ector.am +++ b/src/Makefile_Ector.am @@ -16,6 +16,14 @@ ector_eolian_files += \ lib/ector/cairo/ector_renderer_cairo_gradient_linear.eo \ lib/ector/cairo/ector_renderer_cairo_gradient_radial.eo +# Handle FreeType rasterizer +ector_eolian_files += \ + lib/ector/software/ector_software_surface.eo \ + lib/ector/software/ector_renderer_software_base.eo \ + lib/ector/software/ector_renderer_software_shape.eo \ + lib/ector/software/ector_renderer_software_gradient_radial.eo \ + lib/ector/software/ector_renderer_software_gradient_linear.eo + ector_eolian_c = $(ector_eolian_files:%.eo=%.eo.c) ector_eolian_h = $(ector_eolian_files:%.eo=%.eo.h) @@ -32,9 +40,10 @@ lib_LTLIBRARIES += lib/ector/libector.la installed_ectormainheadersdir = $(includedir)/ector-@VMAJ@ dist_installed_ectormainheaders_DATA = \ lib/ector/Ector.h \ -lib/ector/cairo/Ector_Cairo.h +lib/ector/cairo/Ector_Cairo.h \ +lib/ector/software/Ector_Software.h -# And the cairo header +# And the generic implementation lib_ector_libector_la_SOURCES = \ lib/ector/ector_main.c \ @@ -53,6 +62,19 @@ lib/ector/cairo/ector_renderer_cairo_shape.c \ lib/ector/cairo/ector_renderer_cairo_base.c \ lib/ector/cairo/ector_cairo_surface.c +# And the Freetype rasterizer + +lib_ector_libector_la_SOURCES += \ +lib/ector/software/ector_renderer_software_gradient_linear.c \ +lib/ector/software/ector_renderer_software_gradient_radial.c \ +lib/ector/software/ector_renderer_software_shape.c \ +lib/ector/software/ector_software_gradient.c \ +lib/ector/software/ector_software_rasterizer.c \ +lib/ector/software/ector_software_surface.c \ +lib/ector/software/sw_ft_math.c \ +lib/ector/software/sw_ft_raster.c \ +lib/ector/software/sw_ft_stroker.c + lib_ector_libector_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl \ @ECTOR_CFLAGS@ \ -DPACKAGE_BIN_DIR=\"$(bindir)\" \ @@ -96,4 +118,10 @@ endif EXTRA_DIST += \ src/lib/ector/ector_private.h \ -src/lib/ector/cairo/ector_cairo_private,h +src/lib/ector/cairo/ector_cairo_private.h \ +src/lib/ector/software/ector_blend_private.h \ +src/lib/ector/software/ector_software_private.h \ +src/lib/ector/software/sw_ft_math.h \ +src/lib/ector/software/sw_ft_raster.h \ +src/lib/ector/software/sw_ft_stroker.h \ +src/lib/ector/software/sw_ft_types.h From e4b5167861a7391e60738bc59df86ae06301da7e Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:31:48 +0200 Subject: [PATCH 159/251] evas: add support for alternate Ector rasterizer based on FreeType. --- .../engines/software_generic/evas_engine.c | 28 +++++++++++++++++-- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/src/modules/evas/engines/software_generic/evas_engine.c b/src/modules/evas/engines/software_generic/evas_engine.c index 1ef1f3f2a3..557ff2622e 100644 --- a/src/modules/evas/engines/software_generic/evas_engine.c +++ b/src/modules/evas/engines/software_generic/evas_engine.c @@ -19,6 +19,7 @@ #include "Evas_Engine_Software_Generic.h" #include "cairo/Ector_Cairo.h" +#include "software/Ector_Software.h" #include "ector_cairo_software_surface.eo.h" @@ -3452,13 +3453,26 @@ eng_output_idle_flush(void *data) } static Ector_Surface *_software_ector = NULL; +static Eina_Bool use_cairo; static Ector_Surface * eng_ector_get(void *data EINA_UNUSED) { if (!_software_ector) { - _software_ector = eo_add(ECTOR_CAIRO_SOFTWARE_SURFACE_CLASS, NULL); + const char *ector_backend; + + ector_backend = getenv("ECTOR_BACKEND"); + if (ector_backend && !strcasecmp(ector_backend, "freetype")) + { + _software_ector = eo_add(ECTOR_SOFTWARE_SURFACE_CLASS, NULL); + use_cairo = EINA_FALSE; + } + else + { + _software_ector = eo_add(ECTOR_CAIRO_SOFTWARE_SURFACE_CLASS, NULL); + use_cairo = EINA_TRUE; + } } return _software_ector; } @@ -3603,8 +3617,16 @@ _draw_thread_ector_surface_set(void *data) h = surface->cache_entry.h; } - eo_do(_software_ector, - ector_cairo_software_surface_set(pixels, w, h)); + if (use_cairo) + { + eo_do(_software_ector, + ector_cairo_software_surface_set(pixels, w, h)); + } + else + { + eo_do(_software_ector, + ector_software_surface_set(pixels, w, h)); + } evas_common_cpu_end_opt(); From f8cd006b2f07ca76cdec360be2adf9dd00bce243 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:31:49 +0200 Subject: [PATCH 160/251] evas: and now fix Evas GL backend to display Evas_Object_VG correctly. --- .../evas/engines/gl_generic/evas_engine.c | 89 ++++++++++++++----- 1 file changed, 66 insertions(+), 23 deletions(-) diff --git a/src/modules/evas/engines/gl_generic/evas_engine.c b/src/modules/evas/engines/gl_generic/evas_engine.c index f3d329d4ec..5865d4ba25 100644 --- a/src/modules/evas/engines/gl_generic/evas_engine.c +++ b/src/modules/evas/engines/gl_generic/evas_engine.c @@ -22,6 +22,7 @@ #endif #include "cairo/Ector_Cairo.h" +#include "software/Ector_Software.h" #include "ector_cairo_software_surface.eo.h" @@ -2092,13 +2093,26 @@ eng_texture_image_set(void *data EINA_UNUSED, void *texture, void *image) } static Ector_Surface *_software_ector = NULL; +static Eina_Bool use_cairo; static Ector_Surface * eng_ector_get(void *data EINA_UNUSED) { if (!_software_ector) { - _software_ector = eo_add(ECTOR_CAIRO_SOFTWARE_SURFACE_CLASS, NULL); + const char *ector_backend; + + ector_backend = getenv("ECTOR_BACKEND"); + if (ector_backend && !strcasecmp(ector_backend, "freetype")) + { + _software_ector = eo_add(ECTOR_SOFTWARE_SURFACE_CLASS, NULL); + use_cairo = EINA_FALSE; + } + else + { + _software_ector = eo_add(ECTOR_CAIRO_SOFTWARE_SURFACE_CLASS, NULL); + use_cairo = EINA_TRUE; + } } return _software_ector; } @@ -2118,16 +2132,18 @@ _evas_render_op_to_ector_rop(Evas_Render_Op op) } static void -eng_ector_renderer_draw(void *data EINA_UNUSED, void *context, void *surface, Ector_Renderer *renderer, Eina_Array *clips, int x, int y, Eina_Bool do_async EINA_UNUSED) +eng_ector_renderer_draw(void *data, void *context EINA_UNUSED, void *surface, Ector_Renderer *renderer, Eina_Array *clips, int x, int y, Eina_Bool do_async EINA_UNUSED) { Evas_GL_Image *dst = surface; - Evas_Engine_GL_Context *gc = context; + Evas_Engine_GL_Context *gc; + Render_Engine_GL_Generic *re = data; Eina_Rectangle *r; Eina_Array *c; Eina_Rectangle clip; Eina_Array_Iterator it; unsigned int i; + gc = re->window_gl_context_get(re->software.ob); if (gc->dc->clip.use) { clip.x = gc->dc->clip.x; @@ -2185,35 +2201,62 @@ static void *software_buffer = NULL; static void eng_ector_begin(void *data EINA_UNUSED, void *context EINA_UNUSED, void *surface, Eina_Bool do_async EINA_UNUSED) { - Evas_GL_Image *dst = surface; + Evas_Engine_GL_Context *gl_context; + Render_Engine_GL_Generic *re = data; + int w, h; - software_buffer = realloc(software_buffer, sizeof (unsigned int) * dst->w * dst->h); - eo_do(_software_ector, - ector_cairo_software_surface_set(software_buffer, dst->w, dst->h)); + re->window_use(re->software.ob); + gl_context = re->window_gl_context_get(re->software.ob); + evas_gl_common_context_target_surface_set(gl_context, surface); + gl_context->dc = context; + + w = gl_context->w; h = gl_context->h; + + software_buffer = realloc(software_buffer, sizeof (unsigned int) * w * h); + if (use_cairo) + { + eo_do(_software_ector, + ector_cairo_software_surface_set(software_buffer, w, h)); + } + else + { + eo_do(_software_ector, + ector_software_surface_set(software_buffer, w, h)); + } } static void -eng_ector_end(void *data, void *context, void *surface, Eina_Bool do_async) +eng_ector_end(void *data, void *context EINA_UNUSED, void *surface EINA_UNUSED, Eina_Bool do_async EINA_UNUSED) { - Evas_GL_Image *dst = surface; + Evas_Engine_GL_Context *gl_context; + Render_Engine_GL_Generic *re = data; Evas_GL_Image *im; + int w, h; - eo_do(_software_ector, - ector_cairo_software_surface_set(NULL, 0, 0)); + gl_context = re->window_gl_context_get(re->software.ob); + w = gl_context->w; h = gl_context->h; - im = evas_gl_common_image_new_from_data(context, dst->w, dst->h, software_buffer, 1, EVAS_COLORSPACE_ARGB8888); - eng_image_draw(data, context, surface, im, - // We actually just bluntly push the pixel all over the - // destination surface. We don't have the actual information - // of the widget size. This is not a problem. - // Later on, we don't want that information and today when - // using GL backend, you just need to turn on Evas_Map on - // the Evas_Object_VG. - 0, 0, dst->w, dst->h, - 0, 0, dst->w, dst->h, 0, do_async); + if (use_cairo) + { + eo_do(_software_ector, + ector_cairo_software_surface_set(NULL, 0, 0)); + } + else + { + eo_do(_software_ector, + ector_software_surface_set(NULL, 0, 0)); + } - evas_common_rgba_image_free(software_buffer); - software_buffer = NULL; + im = evas_gl_common_image_new_from_copied_data(gl_context, w, h, software_buffer, 1, EVAS_COLORSPACE_ARGB8888); + // We actually just bluntly push the pixel all over the + // destination surface. We don't have the actual information + // of the widget size. This is not a problem. + // Later on, we don't want that information and today when + // using GL backend, you just need to turn on Evas_Map on + // the Evas_Object_VG. + evas_gl_common_image_draw(gl_context, im, 0, 0, w, h, 0, 0, w, h, 0); + + evas_gl_common_image_free(im); } static Evas_Func func, pfunc; From 8e05c58f2b01bafe65bb89401fb6fb736adbe726 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:31:50 +0200 Subject: [PATCH 161/251] ector: use shift instead of divide when possible. --- src/lib/ector/cairo/ector_renderer_cairo_base.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib/ector/cairo/ector_renderer_cairo_base.c b/src/lib/ector/cairo/ector_renderer_cairo_base.c index 02d256f001..18511a518d 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_base.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_base.c @@ -157,10 +157,10 @@ _ector_renderer_cairo_base_ector_renderer_generic_base_draw(Eo *obj, break; } - r = ((double)((pd->generic->color.r * R_VAL(&mul_col)) / 255)) / 255; - g = ((double)((pd->generic->color.g * G_VAL(&mul_col)) / 255)) / 255; - b = ((double)((pd->generic->color.b * B_VAL(&mul_col)) / 255)) / 255; - a = ((double)((pd->generic->color.a * A_VAL(&mul_col)) / 255)) / 255; + r = ((double)((pd->generic->color.r * R_VAL(&mul_col)) >> 8)) / 255; + g = ((double)((pd->generic->color.g * G_VAL(&mul_col)) >> 8)) / 255; + b = ((double)((pd->generic->color.b * B_VAL(&mul_col)) >> 8)) / 255; + a = ((double)((pd->generic->color.a * A_VAL(&mul_col)) >> 8)) / 255; cairo_set_operator(pd->parent->cairo, cop); cairo_translate(pd->parent->cairo, pd->generic->origin.x - x, pd->generic->origin.y - y); From 1b4647bee895280167391a54d136499a18b5249d Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:31:51 +0200 Subject: [PATCH 162/251] evas: multiply the parent color with the object color. It is necessary to actually propagate the Evas_Object_VG own color to all its Evas_VG_Base object. --- .../evas/engines/software_generic/evas_engine.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/modules/evas/engines/software_generic/evas_engine.c b/src/modules/evas/engines/software_generic/evas_engine.c index 557ff2622e..74dd7c46c3 100644 --- a/src/modules/evas/engines/software_generic/evas_engine.c +++ b/src/modules/evas/engines/software_generic/evas_engine.c @@ -3530,7 +3530,7 @@ eng_ector_renderer_draw(void *data EINA_UNUSED, void *context, void *surface, Ec Eina_Rectangle *r; Eina_Rectangle clip; Eina_Array_Iterator it; - unsigned int i; + unsigned int i, col; if (dc->clip.use) { @@ -3571,10 +3571,21 @@ eng_ector_renderer_draw(void *data EINA_UNUSED, void *context, void *surface, Ec if (eina_array_count(c) == 0) eina_array_push(c, eina_rectangle_new(clip.x, clip.y, clip.w, clip.h)); + { + unsigned int mul_col = dc->mul.use ? dc->mul.col : 0xffffffff; + int r, g, b, a; + + r = (R_VAL(&mul_col) * R_VAL(&dc->col.col)) >> 8; + g = (G_VAL(&mul_col) * G_VAL(&dc->col.col)) >> 8; + b = (B_VAL(&mul_col) * B_VAL(&dc->col.col)) >> 8; + a = (A_VAL(&mul_col) * A_VAL(&dc->col.col)) >> 8; + col = ARGB_JOIN(r, g, b, a); + } + ector.r = eo_ref(renderer); ector.clips = c; ector.render_op = _evas_render_op_to_ector_rop(dc->render_op); - ector.mul_col = dc->mul.use ? dc->mul.col : 0xffffffff; + ector.mul_col = col; ector.x = x; ector.y = y; ector.free_it = EINA_FALSE; From 59635cd4920ca5d0d53919a29cfaf065aad802ca Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:31:52 +0200 Subject: [PATCH 163/251] efl: handle path forced reset to NULL. --- src/lib/efl/interfaces/efl_gfx_shape.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/lib/efl/interfaces/efl_gfx_shape.c b/src/lib/efl/interfaces/efl_gfx_shape.c index dc03ae9d3d..f4839ef00d 100644 --- a/src/lib/efl/interfaces/efl_gfx_shape.c +++ b/src/lib/efl/interfaces/efl_gfx_shape.c @@ -143,6 +143,15 @@ _efl_gfx_shape_path_set(Eo *obj, Efl_Gfx_Shape_Data *pd, double *pts; unsigned int cmds_length = 0, pts_length = 0; + if (!commands) + { + free(pd->commands); pd->commands = NULL; + free(pd->points); pd->points = NULL; + pd->current.x = pd->current.y = 0; + pd->current_ctrl.x = pd->current_ctrl.y = 0; + goto end; + } + _efl_gfx_path_length(commands, &cmds_length, &pts_length); cmds = realloc(pd->commands, @@ -165,6 +174,7 @@ _efl_gfx_shape_path_set(Eo *obj, Efl_Gfx_Shape_Data *pd, &pd->current.x, &pd->current.y, &pd->current_ctrl.x, &pd->current_ctrl.y); + end: eo_do(obj, eo_event_callback_call(EFL_GFX_CHANGED, NULL)); } From 9f8c35002b997760bf813ccde274305d1fcb3746 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:31:53 +0200 Subject: [PATCH 164/251] efl: add Efl.Gfx.Shape.append_rect following SVG specification. SVG rectangle can have rounded corner. --- src/lib/efl/interfaces/efl_gfx_shape.c | 20 ++++++++++++++++++++ src/lib/efl/interfaces/efl_gfx_shape.eo | 10 ++++++++++ src/lib/evas/Evas_Legacy.h | 1 + src/lib/evas/canvas/evas_vg_shape.c | 6 ++++++ 4 files changed, 37 insertions(+) diff --git a/src/lib/efl/interfaces/efl_gfx_shape.c b/src/lib/efl/interfaces/efl_gfx_shape.c index f4839ef00d..b436643e1c 100644 --- a/src/lib/efl/interfaces/efl_gfx_shape.c +++ b/src/lib/efl/interfaces/efl_gfx_shape.c @@ -665,6 +665,26 @@ _efl_gfx_shape_append_circle(Eo *obj, Efl_Gfx_Shape_Data *pd, _efl_gfx_shape_append_arc_to(obj, pd, x, y - radius, radius, radius, 0, EINA_FALSE, EINA_FALSE); } +void +_efl_gfx_shape_append_rect(Eo *obj, Efl_Gfx_Shape_Data *pd, + double x, double y, double w, double h, + double rx, double ry) +{ + _efl_gfx_shape_append_move_to(obj, pd, x, y + ry); + // Top left corner + _efl_gfx_shape_append_arc_to(obj, pd, x + rx, y, rx, ry, 0, EINA_FALSE, EINA_TRUE); + _efl_gfx_shape_append_line_to(obj, pd, x + w - rx, y); + // Top right corner + _efl_gfx_shape_append_arc_to(obj, pd, x + w, y + ry, rx, ry, 0, EINA_FALSE, EINA_TRUE); + _efl_gfx_shape_append_line_to(obj, pd, x + w, y + h - ry); + // Bottom right corner + _efl_gfx_shape_append_arc_to(obj, pd, x + w - rx, y + h, rx, ry, 0, EINA_FALSE, EINA_TRUE); + _efl_gfx_shape_append_line_to(obj, pd, x + rx, y + h); + // Bottom left corner + _efl_gfx_shape_append_arc_to(obj, pd, x, y + h - ry, rx, ry, 0, EINA_FALSE, EINA_TRUE); + _efl_gfx_shape_append_line_to(obj, pd, x, y - ry); +} + static void _efl_gfx_path_append_horizontal_to(Eo *obj, Efl_Gfx_Shape_Data *pd, double d, double current_x EINA_UNUSED, double current_y) diff --git a/src/lib/efl/interfaces/efl_gfx_shape.eo b/src/lib/efl/interfaces/efl_gfx_shape.eo index 1ed3f8fcc0..8547dc58b2 100644 --- a/src/lib/efl/interfaces/efl_gfx_shape.eo +++ b/src/lib/efl/interfaces/efl_gfx_shape.eo @@ -250,6 +250,16 @@ mixin Efl.Gfx.Shape @in double radius; } } + append_rect { + params { + @in double x; + @in double y; + @in double w; + @in double h; + @in double rx; + @in double ry; + } + } append_svg_path { params { @in const(char)* svg_path_data; diff --git a/src/lib/evas/Evas_Legacy.h b/src/lib/evas/Evas_Legacy.h index 01d6706e2b..7fef29513f 100644 --- a/src/lib/evas/Evas_Legacy.h +++ b/src/lib/evas/Evas_Legacy.h @@ -1755,6 +1755,7 @@ EAPI void evas_vg_shape_shape_append_scubic_to(Eo *obj, double x, double y, doub EAPI void evas_vg_shape_shape_append_arc_to(Eo *obj, double x, double y, double rx, double ry, double angle, Eina_Bool large_arc, Eina_Bool sweep); EAPI void evas_vg_shape_shape_append_close(Eo *obj); EAPI void evas_vg_shape_shape_append_circle(Eo *obj, double x, double y, double radius); +EAPI void evas_vg_shape_shape_append_rect(Eo *obj, double x, double y, double w, double h, double rx, double ry); EAPI void evas_vg_shape_shape_append_svg_path(Eo *obj, const char *svg_path_data); EAPI Eina_Bool evas_vg_shape_shape_interpolate(Eo *obj, const Eo *from, const Eo *to, double pos_map); EAPI Eina_Bool evas_vg_shape_shape_equal_commands(Eo *obj, const Eo *with); diff --git a/src/lib/evas/canvas/evas_vg_shape.c b/src/lib/evas/canvas/evas_vg_shape.c index 392d2981c3..c1584805c3 100644 --- a/src/lib/evas/canvas/evas_vg_shape.c +++ b/src/lib/evas/canvas/evas_vg_shape.c @@ -525,6 +525,12 @@ evas_vg_shape_shape_append_circle(Eo *obj, double x, double y, double radius) eo_do(obj, efl_gfx_shape_append_circle(x, y, radius)); } +EAPI void +evas_vg_shape_shape_append_rect(Eo *obj, double x, double y, double w, double h, double rx, double ry) +{ + eo_do(obj, efl_gfx_shape_append_rect(x, y, w, h, rx, ry)); +} + EAPI void evas_vg_shape_shape_append_svg_path(Eo *obj, const char *svg_path_data) { From 983e80b2adec71d1b4f1c39e5fa832de41d689e6 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:31:54 +0200 Subject: [PATCH 165/251] efl: correct Efl.Gfx.Shape.append_circle to follow SVG specification. --- src/lib/efl/interfaces/efl_gfx_shape.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/lib/efl/interfaces/efl_gfx_shape.c b/src/lib/efl/interfaces/efl_gfx_shape.c index b436643e1c..7e2576d41a 100644 --- a/src/lib/efl/interfaces/efl_gfx_shape.c +++ b/src/lib/efl/interfaces/efl_gfx_shape.c @@ -658,11 +658,11 @@ void _efl_gfx_shape_append_circle(Eo *obj, Efl_Gfx_Shape_Data *pd, double x, double y, double radius) { - _efl_gfx_shape_append_move_to(obj, pd, x, y - radius); - _efl_gfx_shape_append_arc_to(obj, pd, x - radius, y, radius, radius, 0, EINA_FALSE, EINA_FALSE); - _efl_gfx_shape_append_arc_to(obj, pd, x, y + radius, radius, radius, 0, EINA_FALSE, EINA_FALSE); - _efl_gfx_shape_append_arc_to(obj, pd, x + radius, y, radius, radius, 0, EINA_FALSE, EINA_FALSE); - _efl_gfx_shape_append_arc_to(obj, pd, x, y - radius, radius, radius, 0, EINA_FALSE, EINA_FALSE); + _efl_gfx_shape_append_move_to(obj, pd, x - radius, y); + _efl_gfx_shape_append_arc_to(obj, pd, x + radius, y, radius, radius, 0, EINA_FALSE, EINA_TRUE); + _efl_gfx_shape_append_arc_to(obj, pd, x, y + radius, radius, radius, 0, EINA_FALSE, EINA_TRUE); + _efl_gfx_shape_append_arc_to(obj, pd, x - radius, y, radius, radius, 0, EINA_FALSE, EINA_TRUE); + _efl_gfx_shape_append_arc_to(obj, pd, x, y - radius, radius, radius, 0, EINA_FALSE, EINA_TRUE); } void From 69b64e948a2a6aa90200767117b0c00aac8ecfae Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:32:56 +0200 Subject: [PATCH 166/251] evas: check rect and circle rendering with SVG specification in Evas_VG example. --- src/examples/evas/evas-vg-simple.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/examples/evas/evas-vg-simple.c b/src/examples/evas/evas-vg-simple.c index 168bb426b1..a1922108d4 100644 --- a/src/examples/evas/evas-vg-simple.c +++ b/src/examples/evas/evas-vg-simple.c @@ -521,6 +521,18 @@ vector_set(int x, int y, int w, int h) evas_vg_shape_stroke_width_set(fg, 5.0); evas_vg_shape_stroke_join_set(fg, EFL_GFX_JOIN_ROUND); evas_vg_shape_stroke_color_set(fg, 70, 70, 0, 70); + + Efl_VG *tst = eo_add(EFL_VG_SHAPE_CLASS, root); + evas_vg_shape_shape_append_rect(tst, 50, 25, 200, 200, 3, 5); + evas_vg_node_color_set(tst, 0, 0, 200, 200); + evas_vg_shape_stroke_width_set(tst, 2); + evas_vg_shape_stroke_color_set(tst, 255, 0, 0, 255); + + Efl_VG *vc = eo_add(EFL_VG_SHAPE_CLASS, root); + evas_vg_shape_shape_append_circle(vc, 100, 100, 23); + evas_vg_node_color_set(vc, 0, 200, 0, 255); + evas_vg_shape_stroke_width_set(vc, 4); + evas_vg_shape_stroke_color_set(vc, 255, 0, 0, 255); } int From 83557d7175d6c8772861aedca13a3df969c84a29 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:32:59 +0200 Subject: [PATCH 167/251] evas: correctly define stride for Ector Cairo backend. --- src/modules/evas/engines/software_generic/evas_engine.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/evas/engines/software_generic/evas_engine.c b/src/modules/evas/engines/software_generic/evas_engine.c index 74dd7c46c3..f5a7d1b52a 100644 --- a/src/modules/evas/engines/software_generic/evas_engine.c +++ b/src/modules/evas/engines/software_generic/evas_engine.c @@ -5054,7 +5054,7 @@ _ector_cairo_software_surface_surface_set(Eo *obj, Ector_Cairo_Software_Surface_ { pd->surface = cairo_image_surface_create_for_data(pixels, CAIRO_FORMAT_ARGB32, - width, height, width); + width, height, width * sizeof (int)); if (!pd->surface) goto end; pd->ctx = cairo_create(pd->surface); From f5fe46ec3c3eea6b8b2c3e0a082a09e92d720a25 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:33:00 +0200 Subject: [PATCH 168/251] ector: cairo require an identity matrix to be set instead of NULL. NULL mean crash :-D --- src/lib/ector/cairo/ector_renderer_cairo_base.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/lib/ector/cairo/ector_renderer_cairo_base.c b/src/lib/ector/cairo/ector_renderer_cairo_base.c index 18511a518d..550d248f52 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_base.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_base.c @@ -64,6 +64,7 @@ static void (*cairo_set_source_rgba)(cairo_t *cr, double red, double green, double blue, double alpha) = NULL; static void (*cairo_set_operator)(cairo_t *cr, cairo_operator_t op) = NULL; +static void (*cairo_matrix_init_identity)(cairo_matrix_t *matrix) = NULL; typedef struct _Ector_Renderer_Cairo_Base_Data Ector_Renderer_Cairo_Base_Data; struct _Ector_Renderer_Cairo_Base_Data @@ -74,6 +75,8 @@ struct _Ector_Renderer_Cairo_Base_Data cairo_matrix_t *m; }; +static cairo_matrix_t identity; + // Cairo need unpremul color, so force unpremul here void _ector_renderer_cairo_base_ector_renderer_generic_base_color_set(Eo *obj EINA_UNUSED, @@ -166,7 +169,7 @@ _ector_renderer_cairo_base_ector_renderer_generic_base_draw(Eo *obj, cairo_translate(pd->parent->cairo, pd->generic->origin.x - x, pd->generic->origin.y - y); cairo_set_source_rgba(pd->parent->cairo, r, g, b, a); if (pd->m) cairo_transform(pd->parent->cairo, pd->m); - else cairo_transform(pd->parent->cairo, NULL); + else cairo_transform(pd->parent->cairo, &identity); return EINA_TRUE; } @@ -177,6 +180,10 @@ _ector_renderer_cairo_base_eo_base_constructor(Eo *obj, Ector_Renderer_Cairo_Bas eo_do_super(obj, ECTOR_RENDERER_CAIRO_BASE_CLASS, eo_constructor()); pd->generic = eo_data_xref(obj, ECTOR_RENDERER_GENERIC_BASE_CLASS, obj); + + USE(obj, cairo_matrix_init_identity, ); + + cairo_matrix_init_identity(&identity); } static void From 472f3a72ff797858587eaf18b2dff98f474b66aa Mon Sep 17 00:00:00 2001 From: Jose Gonzalez Date: Fri, 3 Apr 2015 16:33:01 +0200 Subject: [PATCH 169/251] ector: correct implementation for color multiplication. --- src/Makefile_Ector.am | 1 + src/lib/ector/Ector.h | 1 + src/lib/ector/ector_util.h | 13 +++++++++++++ 3 files changed, 15 insertions(+) create mode 100644 src/lib/ector/ector_util.h diff --git a/src/Makefile_Ector.am b/src/Makefile_Ector.am index 11ed70cdf3..fd0810f29f 100644 --- a/src/Makefile_Ector.am +++ b/src/Makefile_Ector.am @@ -40,6 +40,7 @@ lib_LTLIBRARIES += lib/ector/libector.la installed_ectormainheadersdir = $(includedir)/ector-@VMAJ@ dist_installed_ectormainheaders_DATA = \ lib/ector/Ector.h \ +lib/ector/ector_util.h \ lib/ector/cairo/Ector_Cairo.h \ lib/ector/software/Ector_Software.h diff --git a/src/lib/ector/Ector.h b/src/lib/ector/Ector.h index fe8d13c62e..0a53facc20 100644 --- a/src/lib/ector/Ector.h +++ b/src/lib/ector/Ector.h @@ -174,6 +174,7 @@ EAPI int ector_shutdown(void); #include "ector_surface.h" #include "ector_renderer.h" +#include "ector_util.h" #endif diff --git a/src/lib/ector/ector_util.h b/src/lib/ector/ector_util.h new file mode 100644 index 0000000000..664fdb2b6d --- /dev/null +++ b/src/lib/ector/ector_util.h @@ -0,0 +1,13 @@ +#ifndef ECTOR_UTIL_H +# define ECTOR_UTIL_H + +static inline unsigned int +ector_color_multiply(unsigned int c1, unsigned int c2) +{ + return ( ((((((c1) >> 16) & 0xff00) * (((c2) >> 16) & 0xff00)) + 0xff0000) & 0xff000000) + + ((((((c1) >> 8) & 0xff00) * (((c2) >> 16) & 0xff)) + 0xff00) & 0xff0000) + + ((((((c1) & 0xff00) * ((c2) & 0xff00)) + 0xff00) >> 16) & 0xff00) + + (((((c1) & 0xff) * ((c2) & 0xff)) + 0xff) >> 8) ); +} + +#endif From 084fb9f87eef52e40cf41e2c5f02adb4b06eb076 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:33:03 +0200 Subject: [PATCH 170/251] evas: use the correct method to multiply color. --- .../evas/engines/software_generic/evas_engine.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/src/modules/evas/engines/software_generic/evas_engine.c b/src/modules/evas/engines/software_generic/evas_engine.c index f5a7d1b52a..6323ba43ca 100644 --- a/src/modules/evas/engines/software_generic/evas_engine.c +++ b/src/modules/evas/engines/software_generic/evas_engine.c @@ -3530,7 +3530,7 @@ eng_ector_renderer_draw(void *data EINA_UNUSED, void *context, void *surface, Ec Eina_Rectangle *r; Eina_Rectangle clip; Eina_Array_Iterator it; - unsigned int i, col; + unsigned int i; if (dc->clip.use) { @@ -3571,21 +3571,11 @@ eng_ector_renderer_draw(void *data EINA_UNUSED, void *context, void *surface, Ec if (eina_array_count(c) == 0) eina_array_push(c, eina_rectangle_new(clip.x, clip.y, clip.w, clip.h)); - { - unsigned int mul_col = dc->mul.use ? dc->mul.col : 0xffffffff; - int r, g, b, a; - - r = (R_VAL(&mul_col) * R_VAL(&dc->col.col)) >> 8; - g = (G_VAL(&mul_col) * G_VAL(&dc->col.col)) >> 8; - b = (B_VAL(&mul_col) * B_VAL(&dc->col.col)) >> 8; - a = (A_VAL(&mul_col) * A_VAL(&dc->col.col)) >> 8; - col = ARGB_JOIN(r, g, b, a); - } - ector.r = eo_ref(renderer); ector.clips = c; ector.render_op = _evas_render_op_to_ector_rop(dc->render_op); - ector.mul_col = col; + ector.mul_col = ector_color_multiply(dc->mul.use ? dc->mul.col : 0xffffffff, + dc->col.col);; ector.x = x; ector.y = y; ector.free_it = EINA_FALSE; From cb1226ad4125ea1ef392d89c641ffd9f9ef52944 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:33:04 +0200 Subject: [PATCH 171/251] ector: set the transformation matrix before any translation ! --- src/lib/ector/cairo/ector_renderer_cairo_base.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/ector/cairo/ector_renderer_cairo_base.c b/src/lib/ector/cairo/ector_renderer_cairo_base.c index 550d248f52..a9eb99a38b 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_base.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_base.c @@ -166,10 +166,10 @@ _ector_renderer_cairo_base_ector_renderer_generic_base_draw(Eo *obj, a = ((double)((pd->generic->color.a * A_VAL(&mul_col)) >> 8)) / 255; cairo_set_operator(pd->parent->cairo, cop); - cairo_translate(pd->parent->cairo, pd->generic->origin.x - x, pd->generic->origin.y - y); - cairo_set_source_rgba(pd->parent->cairo, r, g, b, a); if (pd->m) cairo_transform(pd->parent->cairo, pd->m); else cairo_transform(pd->parent->cairo, &identity); + cairo_translate(pd->parent->cairo, pd->generic->origin.x - x, pd->generic->origin.y - y); + cairo_set_source_rgba(pd->parent->cairo, r, g, b, a); return EINA_TRUE; } From 10dca9f68e00a3157afb4e68a5a584e1c2e1d4f3 Mon Sep 17 00:00:00 2001 From: Subhransu Sekhar Mohanty Date: Fri, 3 Apr 2015 16:33:05 +0200 Subject: [PATCH 172/251] ector : add path cliping feature in FreeType software backend. --- .../software/ector_software_rasterizer.c | 87 ++++++++++++++++++- 1 file changed, 84 insertions(+), 3 deletions(-) diff --git a/src/lib/ector/software/ector_software_rasterizer.c b/src/lib/ector/software/ector_software_rasterizer.c index c1f6cae026..dca87e3bba 100644 --- a/src/lib/ector/software/ector_software_rasterizer.c +++ b/src/lib/ector/software/ector_software_rasterizer.c @@ -147,6 +147,68 @@ SW_FT_Span *_intersect_spans_rect(const Eina_Rectangle *clip, const SW_FT_Span * return spans; } +static inline int +_div_255(int x) { return (x + (x>>8) + 0x80) >> 8; } + +static const +SW_FT_Span *_intersect_spans_region(const Shape_Rle_Data *clip, int *currentClip, + const SW_FT_Span *spans, const SW_FT_Span *end, + SW_FT_Span **outSpans, int available) +{ + SW_FT_Span *out = *outSpans; + + const SW_FT_Span *clipSpans = clip->spans + *currentClip; + const SW_FT_Span *clipEnd = clip->spans + clip->size; + + while (available && spans < end ) { + if (clipSpans >= clipEnd) { + spans = end; + break; + } + if (clipSpans->y > spans->y) { + ++spans; + continue; + } + if (spans->y != clipSpans->y) { + ++clipSpans; + continue; + } + //assert(spans->y == clipSpans->y); + + int sx1 = spans->x; + int sx2 = sx1 + spans->len; + int cx1 = clipSpans->x; + int cx2 = cx1 + clipSpans->len; + + if (cx1 < sx1 && cx2 < sx1) { + ++clipSpans; + continue; + } else if (sx1 < cx1 && sx2 < cx1) { + ++spans; + continue; + } + int x = MAX(sx1, cx1); + int len = MIN(sx2, cx2) - x; + if (len) { + out->x = MAX(sx1, cx1); + out->len = MIN(sx2, cx2) - out->x; + out->y = spans->y; + out->coverage = _div_255(spans->coverage * clipSpans->coverage); + ++out; + --available; + } + if (sx2 < cx2) { + ++spans; + } else { + ++clipSpans; + } + } + + *outSpans = out; + *currentClip = clipSpans - clip->spans; + return spans; +} + static void _span_fill_clipRect(int spanCount, const SW_FT_Span *spans, void *userData) { @@ -167,8 +229,6 @@ _span_fill_clipRect(int spanCount, const SW_FT_Span *spans, void *userData) tmpRect.y = rect->y - fillData->offy; tmpRect.w = rect->w; tmpRect.h = rect->h; - //printf("Clip after Offset : %d , %d ,%d , %d\n",tmpRect.x, tmpRect.y, tmpRect.w, tmpRect.h); - //printf("Offset = %d , %d \n", fillData->offx, fillData->offy); const SW_FT_Span *end = spans + spanCount; while (spans < end) @@ -181,6 +241,27 @@ _span_fill_clipRect(int spanCount, const SW_FT_Span *spans, void *userData) } } +static void +_span_fill_clipPath(int spanCount, const SW_FT_Span *spans, void *userData) +{ + const int NSPANS = 256; + int current_clip = 0; + SW_FT_Span cspans[NSPANS]; + Span_Data *fillData = (Span_Data *) userData; + Clip_Data clip = fillData->clip; + + //TODO take clip path offset into account. + + const SW_FT_Span *end = spans + spanCount; + while (spans < end) + { + SW_FT_Span *clipped = cspans; + spans = _intersect_spans_region(clip.path, ¤t_clip, spans, end, &clipped, NSPANS); + if (clipped - cspans) + fillData->unclipped_blend(clipped - cspans, cspans, fillData); + } +} + static void _adjust_span_fill_methods(Span_Data *spdata) { @@ -216,7 +297,7 @@ _adjust_span_fill_methods(Span_Data *spdata) } else { - spdata->blend = &_span_fill_clipRect; //TODO change when do path clipping + spdata->blend = &_span_fill_clipPath; } } From ee955fbd989189e6c314fd149392688843984683 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:33:06 +0200 Subject: [PATCH 173/251] evas: fix Evas_3D examples with new Efl interface API. --- src/examples/evas/evas-3d-colorpick.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/examples/evas/evas-3d-colorpick.c b/src/examples/evas/evas-3d-colorpick.c index 9a7b5ff1cc..3fb7adb9a4 100644 --- a/src/examples/evas/evas-3d-colorpick.c +++ b/src/examples/evas/evas-3d-colorpick.c @@ -121,8 +121,8 @@ _on_canvas_resize(Ecore_Evas *ee) int w, h; ecore_evas_geometry_get(ee, NULL, NULL, &w, &h); - eo_do(bg, evas_obj_size_set(w, h)); - eo_do(image, evas_obj_size_set(w, h)); + eo_do(bg, efl_gfx_size_set(w, h)); + eo_do(image, efl_gfx_size_set(w, h)); } static Eina_Bool @@ -409,8 +409,8 @@ int main(int argc, char **argv) image = evas_object_image_filled_add(evas); eo_do(image, - evas_obj_size_set(WIDTH, HEIGHT), - evas_obj_visibility_set(EINA_TRUE)); + efl_gfx_size_set(WIDTH, HEIGHT), + efl_gfx_visible_set(EINA_TRUE)); evas_object_focus_set(image, EINA_TRUE); eo_do(image, evas_obj_image_scene_set(globalscene.scene)); From 5613ca50ae8c674a3965ff01bb193cbce1cd0b2b Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:33:07 +0200 Subject: [PATCH 174/251] ector: remember last position and translate to Ector_Renderer origin position. --- src/lib/ector/cairo/ector_cairo_private.h | 3 +++ src/lib/ector/cairo/ector_cairo_surface.c | 1 + src/lib/ector/cairo/ector_renderer_cairo_base.c | 10 ++++++++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/lib/ector/cairo/ector_cairo_private.h b/src/lib/ector/cairo/ector_cairo_private.h index 14277a744b..07446a82c2 100644 --- a/src/lib/ector/cairo/ector_cairo_private.h +++ b/src/lib/ector/cairo/ector_cairo_private.h @@ -7,6 +7,9 @@ typedef struct _Ector_Cairo_Surface_Data Ector_Cairo_Surface_Data; struct _Ector_Cairo_Surface_Data { cairo_t *cairo; + struct { + double x, y; + } current; Eina_Bool internal : 1; }; diff --git a/src/lib/ector/cairo/ector_cairo_surface.c b/src/lib/ector/cairo/ector_cairo_surface.c index 7204eedaf4..ff30135714 100644 --- a/src/lib/ector/cairo/ector_cairo_surface.c +++ b/src/lib/ector/cairo/ector_cairo_surface.c @@ -95,6 +95,7 @@ _ector_cairo_surface_context_set(Eo *obj, if (!internal) internal = cairo_image_surface_create(0, 1, 1); ctx = cairo_create(internal); } + pd->current.x = pd->current.y = 0; pd->cairo = ctx; } diff --git a/src/lib/ector/cairo/ector_renderer_cairo_base.c b/src/lib/ector/cairo/ector_renderer_cairo_base.c index a9eb99a38b..5e1c0606cc 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_base.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_base.c @@ -143,6 +143,7 @@ _ector_renderer_cairo_base_ector_renderer_generic_base_draw(Eo *obj, { double r, g, b, a; cairo_operator_t cop; + double cx, cy; USE(obj, cairo_translate, EINA_FALSE); USE(obj, cairo_set_source_rgba, EINA_FALSE); @@ -166,9 +167,14 @@ _ector_renderer_cairo_base_ector_renderer_generic_base_draw(Eo *obj, a = ((double)((pd->generic->color.a * A_VAL(&mul_col)) >> 8)) / 255; cairo_set_operator(pd->parent->cairo, cop); + cairo_transform(pd->parent->cairo, &identity); if (pd->m) cairo_transform(pd->parent->cairo, pd->m); - else cairo_transform(pd->parent->cairo, &identity); - cairo_translate(pd->parent->cairo, pd->generic->origin.x - x, pd->generic->origin.y - y); + cx = pd->generic->origin.x - pd->parent->current.x; + cy = pd->generic->origin.y - pd->parent->current.y; + cairo_translate(pd->parent->cairo, cx, cy); + pd->parent->current.x = pd->generic->origin.x; + pd->parent->current.y = pd->generic->origin.y; + cairo_set_source_rgba(pd->parent->cairo, r, g, b, a); return EINA_TRUE; From afc2b3b17aa178a937ed757b6bbc50f2334b2bcc Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:33:09 +0200 Subject: [PATCH 175/251] evas: fix example with new namespace. --- src/examples/evas/evas-3d-parallax-occlusion.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/examples/evas/evas-3d-parallax-occlusion.c b/src/examples/evas/evas-3d-parallax-occlusion.c index ca08c55b8b..60af0d181e 100644 --- a/src/examples/evas/evas-3d-parallax-occlusion.c +++ b/src/examples/evas/evas-3d-parallax-occlusion.c @@ -80,8 +80,8 @@ _on_canvas_resize(Ecore_Evas *ee) int w, h; ecore_evas_geometry_get(ee, NULL, NULL, &w, &h); - eo_do(background, evas_obj_size_set(w, h)); - eo_do(image, evas_obj_size_set(w, h)); + eo_do(background, efl_gfx_size_set(w, h)); + eo_do(image, efl_gfx_size_set(w, h)); } static Eina_Bool @@ -259,15 +259,15 @@ main(void) /* Add a background rectangle objects. */ background = eo_add(EVAS_RECTANGLE_CLASS, evas); eo_do(background, - evas_obj_color_set(0, 0, 0, 255), - evas_obj_size_set(WIDTH, HEIGHT), - evas_obj_visibility_set(EINA_TRUE)); + efl_gfx_color_set(0, 0, 0, 255), + efl_gfx_size_set(WIDTH, HEIGHT), + efl_gfx_visible_set(EINA_TRUE)); /* Add an image object for 3D scene rendering. */ image = evas_object_image_filled_add(evas); eo_do(image, - evas_obj_size_set(WIDTH, HEIGHT), - evas_obj_visibility_set(EINA_TRUE), + efl_gfx_size_set(WIDTH, HEIGHT), + efl_gfx_visible_set(EINA_TRUE), evas_object_focus_set(image, EINA_TRUE)); /* Set the image object as render target for 3D scene. */ From f603f5ed21977be80f5577ae667c42b42e3669fb Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:33:11 +0200 Subject: [PATCH 176/251] gitignore: don't track generated examples. --- src/examples/evas/.gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/src/examples/evas/.gitignore b/src/examples/evas/.gitignore index 05fc412455..d146578d6e 100644 --- a/src/examples/evas/.gitignore +++ b/src/examples/evas/.gitignore @@ -39,3 +39,4 @@ /evas_3d_mmap /evas_3d_shadows /evas_3d_parallax_occlusion +/evas_vg_simple From de08a3bc0422a157ed60072710f1fa0a5508cf2a Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:33:19 +0200 Subject: [PATCH 177/251] ector: add reference point to define (0, 0) and don't repeat the same value everywhere. --- src/lib/ector/cairo/ector_cairo_surface.c | 13 +++++++ src/lib/ector/cairo/ector_cairo_surface.eo | 1 + .../ector/cairo/ector_renderer_cairo_base.c | 1 - .../ector_renderer_cairo_gradient_linear.c | 4 +-- .../ector_renderer_cairo_gradient_radial.c | 4 +-- .../ector/cairo/ector_renderer_cairo_shape.c | 4 +-- src/lib/ector/ector_generic_surface.eo | 10 ++++++ src/lib/ector/ector_renderer_generic_base.eo | 2 -- .../ector_renderer_software_gradient_linear.c | 2 +- .../ector_renderer_software_gradient_radial.c | 2 +- .../software/ector_renderer_software_shape.c | 8 +++-- .../ector/software/ector_software_private.h | 2 ++ .../ector/software/ector_software_surface.c | 9 +++++ .../ector/software/ector_software_surface.eo | 1 + src/lib/evas/canvas/evas_object_vg.c | 11 +++--- src/lib/evas/include/evas_private.h | 4 +-- .../evas/engines/gl_generic/evas_engine.c | 12 +++---- .../engines/software_generic/evas_engine.c | 36 +++++++++++++------ 18 files changed, 88 insertions(+), 38 deletions(-) diff --git a/src/lib/ector/cairo/ector_cairo_surface.c b/src/lib/ector/cairo/ector_cairo_surface.c index ff30135714..8e7b1043f6 100644 --- a/src/lib/ector/cairo/ector_cairo_surface.c +++ b/src/lib/ector/cairo/ector_cairo_surface.c @@ -67,6 +67,7 @@ _ector_cairo_surface_ector_generic_surface_renderer_factory_new(Eo *obj, typedef struct _cairo_surface_t cairo_surface_t; +static void (*cairo_translate)(cairo_t *cr, double tx, double ty) = NULL; static void (*cairo_destroy)(cairo_t *cr) = NULL; static cairo_surface_t *(*cairo_image_surface_create)(int format, int width, @@ -106,6 +107,18 @@ _ector_cairo_surface_context_get(Eo *obj EINA_UNUSED, return pd->cairo; } +static void +_ector_cairo_surface_ector_generic_surface_reference_point_set(Eo *obj EINA_UNUSED, + Ector_Cairo_Surface_Data *pd, + int x, int y) +{ + if (pd->cairo) + { + USE(obj, cairo_translate, ); + cairo_translate(pd->cairo, x, y); + } +} + static void _ector_cairo_surface_eo_base_constructor(Eo *obj, Ector_Cairo_Surface_Data *pd) diff --git a/src/lib/ector/cairo/ector_cairo_surface.eo b/src/lib/ector/cairo/ector_cairo_surface.eo index 10f6d9f30e..298c681d78 100644 --- a/src/lib/ector/cairo/ector_cairo_surface.eo +++ b/src/lib/ector/cairo/ector_cairo_surface.eo @@ -23,6 +23,7 @@ class Ector.Cairo.Surface (Ector.Generic.Surface) } implements { Ector.Generic.Surface.renderer_factory_new; + Ector.Generic.Surface.reference_point.set; Eo.Base.destructor; Eo.Base.constructor; } diff --git a/src/lib/ector/cairo/ector_renderer_cairo_base.c b/src/lib/ector/cairo/ector_renderer_cairo_base.c index 5e1c0606cc..190fb8a090 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_base.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_base.c @@ -138,7 +138,6 @@ _ector_renderer_cairo_base_ector_renderer_generic_base_draw(Eo *obj, Ector_Renderer_Cairo_Base_Data *pd, Ector_Rop op, Eina_Array *clips EINA_UNUSED, - int x, int y, unsigned int mul_col) { double r, g, b, a; diff --git a/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c b/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c index e00ed6d8c0..19f30558a3 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c @@ -68,7 +68,7 @@ _ector_renderer_cairo_gradient_linear_ector_renderer_generic_base_prepare(Eo *ob static Eina_Bool _ector_renderer_cairo_gradient_linear_ector_renderer_generic_base_draw(Eo *obj, Ector_Renderer_Cairo_Gradient_Linear_Data *pd, - Ector_Rop op, Eina_Array *clips, int x, int y, unsigned int mul_col) + Ector_Rop op, Eina_Array *clips, unsigned int mul_col) { Ector_Renderer_Generic_Gradient_Linear_Data *gld; @@ -76,7 +76,7 @@ _ector_renderer_cairo_gradient_linear_ector_renderer_generic_base_draw(Eo *obj, gld = eo_data_scope_get(obj, ECTOR_RENDERER_GENERIC_GRADIENT_LINEAR_MIXIN); if (!pd->pat || !gld) return EINA_FALSE; - eo_do_super(obj, ECTOR_RENDERER_CAIRO_GRADIENT_LINEAR_CLASS, ector_renderer_draw(op, clips, x, y, mul_col)); + eo_do_super(obj, ECTOR_RENDERER_CAIRO_GRADIENT_LINEAR_CLASS, ector_renderer_draw(op, clips, mul_col)); USE(obj, cairo_rectangle, EINA_FALSE); USE(obj, cairo_fill, EINA_FALSE); diff --git a/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c b/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c index a219375f93..521b06da9e 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c @@ -72,7 +72,7 @@ _ector_renderer_cairo_gradient_radial_ector_renderer_generic_base_prepare(Eo *ob // Clearly duplicated and should be in a common place... static Eina_Bool -_ector_renderer_cairo_gradient_radial_ector_renderer_generic_base_draw(Eo *obj, Ector_Renderer_Cairo_Gradient_Radial_Data *pd, Ector_Rop op, Eina_Array *clips, int x, int y, unsigned int mul_col) +_ector_renderer_cairo_gradient_radial_ector_renderer_generic_base_draw(Eo *obj, Ector_Renderer_Cairo_Gradient_Radial_Data *pd, Ector_Rop op, Eina_Array *clips, unsigned int mul_col) { Ector_Renderer_Generic_Gradient_Radial_Data *gld; @@ -80,7 +80,7 @@ _ector_renderer_cairo_gradient_radial_ector_renderer_generic_base_draw(Eo *obj, gld = eo_data_scope_get(obj, ECTOR_RENDERER_GENERIC_GRADIENT_RADIAL_MIXIN); if (!pd->pat || !gld) return EINA_FALSE; - eo_do_super(obj, ECTOR_RENDERER_CAIRO_GRADIENT_RADIAL_CLASS, ector_renderer_draw(op, clips, x, y, mul_col)); + eo_do_super(obj, ECTOR_RENDERER_CAIRO_GRADIENT_RADIAL_CLASS, ector_renderer_draw(op, clips, mul_col)); USE(obj, cairo_arc, EINA_FALSE); USE(obj, cairo_fill, EINA_FALSE); diff --git a/src/lib/ector/cairo/ector_renderer_cairo_shape.c b/src/lib/ector/cairo/ector_renderer_cairo_shape.c index a3fd1070c2..497c59d52f 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_shape.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_shape.c @@ -128,12 +128,12 @@ _ector_renderer_cairo_shape_ector_renderer_generic_base_prepare(Eo *obj, Ector_R } static Eina_Bool -_ector_renderer_cairo_shape_ector_renderer_generic_base_draw(Eo *obj, Ector_Renderer_Cairo_Shape_Data *pd, Ector_Rop op, Eina_Array *clips, int x, int y, unsigned int mul_col) +_ector_renderer_cairo_shape_ector_renderer_generic_base_draw(Eo *obj, Ector_Renderer_Cairo_Shape_Data *pd, Ector_Rop op, Eina_Array *clips, unsigned int mul_col) { if (pd->path == NULL) return EINA_FALSE; // FIXME: find a way to set multiple clips - eo_do_super(obj, ECTOR_RENDERER_CAIRO_SHAPE_CLASS, ector_renderer_draw(op, clips, x, y, mul_col)); + eo_do_super(obj, ECTOR_RENDERER_CAIRO_SHAPE_CLASS, ector_renderer_draw(op, clips, mul_col)); USE(obj, cairo_new_path, EINA_FALSE); USE(obj, cairo_append_path, EINA_FALSE); diff --git a/src/lib/ector/ector_generic_surface.eo b/src/lib/ector/ector_generic_surface.eo index 18ebd47c60..42a5f3e8a3 100644 --- a/src/lib/ector/ector_generic_surface.eo +++ b/src/lib/ector/ector_generic_surface.eo @@ -14,6 +14,15 @@ abstract Ector.Generic.Surface (Eo.Base) int h; /*@ in */ } } + reference_point { + set { + /*@ This define where is (0,0) in pixels coordinate inside the surface */ + } + values { + int x; + int y; + } + } } methods { renderer_factory_new { @@ -35,5 +44,6 @@ abstract Ector.Generic.Surface (Eo.Base) } implements { @virtual .renderer_factory_new; + @virtual .reference_point.set; } } diff --git a/src/lib/ector/ector_renderer_generic_base.eo b/src/lib/ector/ector_renderer_generic_base.eo index 5e5d6aa3b9..50e7e94cdc 100644 --- a/src/lib/ector/ector_renderer_generic_base.eo +++ b/src/lib/ector/ector_renderer_generic_base.eo @@ -96,8 +96,6 @@ abstract Ector.Renderer.Generic.Base (Eo.Base) params { @in Ector_Rop op; @in array *clips; /*@ array of Eina_Rectangle clip */ - @in int x; - @in int y; @in uint mul_col; } } diff --git a/src/lib/ector/software/ector_renderer_software_gradient_linear.c b/src/lib/ector/software/ector_renderer_software_gradient_linear.c index 8bbf23d73a..a6e32b008b 100644 --- a/src/lib/ector/software/ector_renderer_software_gradient_linear.c +++ b/src/lib/ector/software/ector_renderer_software_gradient_linear.c @@ -57,7 +57,7 @@ static Eina_Bool _ector_renderer_software_gradient_linear_ector_renderer_generic_base_draw(Eo *obj EINA_UNUSED, Ector_Renderer_Software_Gradient_Data *pd EINA_UNUSED, Ector_Rop op EINA_UNUSED, Eina_Array *clips EINA_UNUSED, - int x EINA_UNUSED, int y EINA_UNUSED, unsigned int mul_col EINA_UNUSED) + unsigned int mul_col EINA_UNUSED) { return EINA_TRUE; } diff --git a/src/lib/ector/software/ector_renderer_software_gradient_radial.c b/src/lib/ector/software/ector_renderer_software_gradient_radial.c index 4bcf2a1594..41d24cbf11 100644 --- a/src/lib/ector/software/ector_renderer_software_gradient_radial.c +++ b/src/lib/ector/software/ector_renderer_software_gradient_radial.c @@ -66,7 +66,7 @@ static Eina_Bool _ector_renderer_software_gradient_radial_ector_renderer_generic_base_draw(Eo *obj EINA_UNUSED, Ector_Renderer_Software_Gradient_Data *pd EINA_UNUSED, Ector_Rop op EINA_UNUSED, Eina_Array *clips EINA_UNUSED, - int x EINA_UNUSED, int y EINA_UNUSED, unsigned int mul_col EINA_UNUSED) + unsigned int mul_col EINA_UNUSED) { return EINA_TRUE; } diff --git a/src/lib/ector/software/ector_renderer_software_shape.c b/src/lib/ector/software/ector_renderer_software_shape.c index cdecce9e87..8793c527cf 100644 --- a/src/lib/ector/software/ector_renderer_software_shape.c +++ b/src/lib/ector/software/ector_renderer_software_shape.c @@ -281,11 +281,13 @@ _ector_renderer_software_shape_ector_renderer_generic_base_prepare(Eo *obj, Ecto } static Eina_Bool -_ector_renderer_software_shape_ector_renderer_generic_base_draw(Eo *obj EINA_UNUSED, Ector_Renderer_Software_Shape_Data *pd, Ector_Rop op, Eina_Array *clips, int x, int y, unsigned int mul_col) +_ector_renderer_software_shape_ector_renderer_generic_base_draw(Eo *obj EINA_UNUSED, Ector_Renderer_Software_Shape_Data *pd, Ector_Rop op, Eina_Array *clips, unsigned int mul_col) { + int x, y; + // adjust the offset - x = x + (int)pd->base->origin.x; - y = y + (int)pd->base->origin.y; + x = pd->surface->x + (int)pd->base->origin.x; + y = pd->surface->y + (int)pd->base->origin.y; // fill the span_data structure ector_software_rasterizer_clip_rect_set(pd->surface->software, clips); diff --git a/src/lib/ector/software/ector_software_private.h b/src/lib/ector/software/ector_software_private.h index b43dcfea06..bf2adf6998 100644 --- a/src/lib/ector/software/ector_software_private.h +++ b/src/lib/ector/software/ector_software_private.h @@ -114,6 +114,8 @@ typedef struct _Software_Rasterizer struct _Ector_Software_Surface_Data { Software_Rasterizer *software; + int x; + int y; }; diff --git a/src/lib/ector/software/ector_software_surface.c b/src/lib/ector/software/ector_software_surface.c index e32477ecc0..1999feae68 100644 --- a/src/lib/ector/software/ector_software_surface.c +++ b/src/lib/ector/software/ector_software_surface.c @@ -90,5 +90,14 @@ _ector_software_surface_eo_base_destructor(Eo *obj EINA_UNUSED, eo_do_super(obj, ECTOR_SOFTWARE_SURFACE_CLASS, eo_destructor()); } +static void +_ector_software_surface_ector_generic_surface_reference_point_set(Eo *obj EINA_UNUSED, + Ector_Software_Surface_Data *pd, + int x, int y) +{ + pd->x = x; + pd->y = y; +} + #include "ector_software_surface.eo.c" #include "ector_renderer_software_base.eo.c" diff --git a/src/lib/ector/software/ector_software_surface.eo b/src/lib/ector/software/ector_software_surface.eo index 58a6a771f6..3ed863c0c8 100644 --- a/src/lib/ector/software/ector_software_surface.eo +++ b/src/lib/ector/software/ector_software_surface.eo @@ -27,6 +27,7 @@ class Ector.Software.Surface (Ector.Generic.Surface) implements { Ector.Generic.Surface.renderer_factory_new; + Ector.Generic.Surface.reference_point.set; Eo.Base.destructor; Eo.Base.constructor; } diff --git a/src/lib/evas/canvas/evas_object_vg.c b/src/lib/evas/canvas/evas_object_vg.c index 2336d9b6e5..fa682af234 100644 --- a/src/lib/evas/canvas/evas_object_vg.c +++ b/src/lib/evas/canvas/evas_object_vg.c @@ -126,7 +126,7 @@ _evas_vg_eo_base_constructor(Eo *eo_obj, Evas_VG_Data *pd) static void _evas_vg_render(Evas_Object_Protected_Data *obj, void *output, void *context, void *surface, Efl_VG *n, - Eina_Array *clips, int x, int y, Eina_Bool do_async) + Eina_Array *clips, Eina_Bool do_async) { Efl_VG_Container_Data *vd = eo_data_scope_get(n, EFL_VG_CONTAINER_CLASS); @@ -138,7 +138,7 @@ _evas_vg_render(Evas_Object_Protected_Data *obj, EINA_LIST_FOREACH(vd->children, l, child) _evas_vg_render(obj, output, context, surface, child, - clips, x, y, do_async); + clips, do_async); } else { @@ -146,7 +146,7 @@ _evas_vg_render(Evas_Object_Protected_Data *obj, nd = eo_data_scope_get(n, EFL_VG_BASE_CLASS); - obj->layer->evas->engine.func->ector_renderer_draw(output, context, surface, nd->renderer, clips, x, y, do_async); + obj->layer->evas->engine.func->ector_renderer_draw(output, context, surface, nd->renderer, clips, do_async); } } @@ -179,9 +179,10 @@ evas_object_vg_render(Evas_Object *eo_obj EINA_UNUSED, context); obj->layer->evas->engine.func->context_render_op_set(output, context, obj->cur->render_op); - obj->layer->evas->engine.func->ector_begin(output, context, surface, do_async); + obj->layer->evas->engine.func->ector_begin(output, context, surface, + obj->cur->geometry.x + x, obj->cur->geometry.y + y, + do_async); _evas_vg_render(obj, output, context, surface, vd->root, NULL, - obj->cur->geometry.x + x, obj->cur->geometry.y + y, do_async); obj->layer->evas->engine.func->ector_end(output, context, surface, do_async); } diff --git a/src/lib/evas/include/evas_private.h b/src/lib/evas/include/evas_private.h index 9fb51b4dc9..e45565c9b2 100644 --- a/src/lib/evas/include/evas_private.h +++ b/src/lib/evas/include/evas_private.h @@ -1368,8 +1368,8 @@ struct _Evas_Func void (*texture_image_set) (void *data, void *texture, void *image); Ector_Surface *(*ector_get) (void *data); - void (*ector_begin) (void *data, void *context, void *surface, Eina_Bool do_async); - void (*ector_renderer_draw) (void *data, void *context, void *surface, Ector_Renderer *r, Eina_Array *clips, int x, int y, Eina_Bool do_async); + void (*ector_begin) (void *data, void *context, void *surface, int x, int y, Eina_Bool do_async); + void (*ector_renderer_draw) (void *data, void *context, void *surface, Ector_Renderer *r, Eina_Array *clips, Eina_Bool do_async); void (*ector_end) (void *data, void *context, void *surface, Eina_Bool do_async); }; diff --git a/src/modules/evas/engines/gl_generic/evas_engine.c b/src/modules/evas/engines/gl_generic/evas_engine.c index 5865d4ba25..871ffbb67f 100644 --- a/src/modules/evas/engines/gl_generic/evas_engine.c +++ b/src/modules/evas/engines/gl_generic/evas_engine.c @@ -2132,7 +2132,7 @@ _evas_render_op_to_ector_rop(Evas_Render_Op op) } static void -eng_ector_renderer_draw(void *data, void *context EINA_UNUSED, void *surface, Ector_Renderer *renderer, Eina_Array *clips, int x, int y, Eina_Bool do_async EINA_UNUSED) +eng_ector_renderer_draw(void *data, void *context EINA_UNUSED, void *surface, Ector_Renderer *renderer, Eina_Array *clips, Eina_Bool do_async EINA_UNUSED) { Evas_GL_Image *dst = surface; Evas_Engine_GL_Context *gc; @@ -2186,8 +2186,6 @@ eng_ector_renderer_draw(void *data, void *context EINA_UNUSED, void *surface, Ec eo_do(renderer, ector_renderer_draw(_evas_render_op_to_ector_rop(gc->dc->render_op), c, - x, - y, // mul_col will be applied by GL during ector_end 0xffffffff)); @@ -2199,7 +2197,7 @@ eng_ector_renderer_draw(void *data, void *context EINA_UNUSED, void *surface, Ec static void *software_buffer = NULL; static void -eng_ector_begin(void *data EINA_UNUSED, void *context EINA_UNUSED, void *surface, Eina_Bool do_async EINA_UNUSED) +eng_ector_begin(void *data EINA_UNUSED, void *context EINA_UNUSED, void *surface, int x, int y, Eina_Bool do_async EINA_UNUSED) { Evas_Engine_GL_Context *gl_context; Render_Engine_GL_Generic *re = data; @@ -2216,12 +2214,14 @@ eng_ector_begin(void *data EINA_UNUSED, void *context EINA_UNUSED, void *surface if (use_cairo) { eo_do(_software_ector, - ector_cairo_software_surface_set(software_buffer, w, h)); + ector_cairo_software_surface_set(software_buffer, w, h), + ector_surface_reference_point_set(x, y)); } else { eo_do(_software_ector, - ector_software_surface_set(software_buffer, w, h)); + ector_software_surface_set(software_buffer, w, h), + ector_surface_reference_point_set(x, y)); } } diff --git a/src/modules/evas/engines/software_generic/evas_engine.c b/src/modules/evas/engines/software_generic/evas_engine.c index 6323ba43ca..88475d6504 100644 --- a/src/modules/evas/engines/software_generic/evas_engine.c +++ b/src/modules/evas/engines/software_generic/evas_engine.c @@ -397,7 +397,6 @@ struct _Evas_Thread_Command_Ector DATA32 mul_col; Ector_Rop render_op; - int x, y; Eina_Bool free_it; }; @@ -405,6 +404,7 @@ struct _Evas_Thread_Command_Ector struct _Evas_Thread_Command_Ector_Surface { void *surface; + int x, y; }; Eina_Mempool *_mp_command_rect = NULL; @@ -3513,15 +3513,13 @@ _draw_thread_ector_draw(void *data) eo_do(ector->r, ector_renderer_draw(ector->render_op, ector->clips, - ector->x, - ector->y, ector->mul_col)); _draw_thread_ector_cleanup(ector); } static void -eng_ector_renderer_draw(void *data EINA_UNUSED, void *context, void *surface, Ector_Renderer *renderer, Eina_Array *clips, int x, int y, Eina_Bool do_async) +eng_ector_renderer_draw(void *data EINA_UNUSED, void *context, void *surface, Ector_Renderer *renderer, Eina_Array *clips, Eina_Bool do_async) { RGBA_Image *dst = surface; RGBA_Draw_Context *dc = context; @@ -3576,8 +3574,6 @@ eng_ector_renderer_draw(void *data EINA_UNUSED, void *context, void *surface, Ec ector.render_op = _evas_render_op_to_ector_rop(dc->render_op); ector.mul_col = ector_color_multiply(dc->mul.use ? dc->mul.col : 0xffffffff, dc->col.col);; - ector.x = x; - ector.y = y; ector.free_it = EINA_FALSE; if (do_async) @@ -3610,23 +3606,29 @@ _draw_thread_ector_surface_set(void *data) void *pixels = NULL; unsigned int w = 0; unsigned int h = 0; + unsigned int x = 0; + unsigned int y = 0; if (surface) { pixels = evas_cache_image_pixels(&surface->cache_entry); w = surface->cache_entry.w; h = surface->cache_entry.h; + x = ector_surface->x; + y = ector_surface->y; } if (use_cairo) { eo_do(_software_ector, - ector_cairo_software_surface_set(pixels, w, h)); + ector_cairo_software_surface_set(pixels, w, h), + ector_surface_reference_point_set(x, y)); } else { eo_do(_software_ector, - ector_software_surface_set(pixels, w, h)); + ector_software_surface_set(pixels, w, h), + ector_surface_reference_point_set(x, y)); } evas_common_cpu_end_opt(); @@ -3635,7 +3637,7 @@ _draw_thread_ector_surface_set(void *data) } static void -eng_ector_begin(void *data EINA_UNUSED, void *context EINA_UNUSED, void *surface, Eina_Bool do_async) +eng_ector_begin(void *data EINA_UNUSED, void *context EINA_UNUSED, void *surface, int x, int y, Eina_Bool do_async) { if (do_async) { @@ -3645,6 +3647,8 @@ eng_ector_begin(void *data EINA_UNUSED, void *context EINA_UNUSED, void *surface if (!nes) return ; nes->surface = surface; + nes->x = x; + nes->y = y; evas_thread_cmd_enqueue(_draw_thread_ector_surface_set, nes); } @@ -3659,8 +3663,18 @@ eng_ector_begin(void *data EINA_UNUSED, void *context EINA_UNUSED, void *surface w = sf->cache_entry.w; h = sf->cache_entry.h; - eo_do(_software_ector, - ector_cairo_software_surface_set(pixels, w, h)); + if (use_cairo) + { + eo_do(_software_ector, + ector_cairo_software_surface_set(pixels, w, h), + ector_surface_reference_point_set(x, y)); + } + else + { + eo_do(_software_ector, + ector_software_surface_set(pixels, w, h), + ector_surface_reference_point_set(x, y)); + } } } From 8029e67c24679dedfb7f17af19c8f2d8873a0bd3 Mon Sep 17 00:00:00 2001 From: Jorge Luis Zapata Muga Date: Fri, 3 Apr 2015 16:33:22 +0200 Subject: [PATCH 178/251] efl: use enesim/moonlight path normalizer. This fix issue with rounded rectangle. --- src/lib/efl/interfaces/efl_gfx_shape.c | 266 ++++++++++++++----------- 1 file changed, 153 insertions(+), 113 deletions(-) diff --git a/src/lib/efl/interfaces/efl_gfx_shape.c b/src/lib/efl/interfaces/efl_gfx_shape.c index 7e2576d41a..94854d1242 100644 --- a/src/lib/efl/interfaces/efl_gfx_shape.c +++ b/src/lib/efl/interfaces/efl_gfx_shape.c @@ -495,41 +495,9 @@ _efl_gfx_shape_append_squadratic_to(Eo *obj, Efl_Gfx_Shape_Data *pd, ctrl_x1, ctrl_y1); } -// This function come from librsvg rsvg-path.c -static void -_efl_gfx_shape_append_arc_segment(Eo *eo, Efl_Gfx_Shape_Data *pd, - 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_shape_append_cubic_to(eo, pd, - 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 +/* + * code adapted from enesim which was adapted from moonlight sources + */ void _efl_gfx_shape_append_arc_to(Eo *obj, Efl_Gfx_Shape_Data *pd, double x, double y, @@ -537,110 +505,182 @@ _efl_gfx_shape_append_arc_to(Eo *obj, Efl_Gfx_Shape_Data *pd, 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 cxp, cyp, cx, cy; + double sx, sy; + double cos_phi, sin_phi; + double dx2, dy2; + double x1p, y1p; + double x1p2, y1p2; + double rx2, ry2; + double lambda; + double c; + double at; double theta1, delta_theta; - double k1, k2, k3, k4, k5; - int i, n_segs; + double nat; + double delta, bcp; + double cos_phi_rx, cos_phi_ry; + double sin_phi_rx, sin_phi_ry; + double cos_theta1, sin_theta1; + int segments, i; - x1 = pd->current.x; - y1 = pd->current.x; + // some helpful stuff is available here: + // http://www.w3.org/TR/SVG/implnote.html#ArcImplementationNotes + sx = pd->current.x; + sy = pd->current.y; - /* Start and end of path segment */ - x2 = x; - y2 = y; - - if (x1 == x2 && y1 == y2) + // if start and end points are identical, then no arc is drawn + if ((fabs(x - sx) < (1 / 256.0)) && (fabs(y - sy) < (1 / 256.0))) 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)) + // Correction of out-of-range radii, see F6.6.1 (step 2) + rx = fabs(rx); + ry = fabs(ry); + if ((rx < 0.5) || (ry < 0.5)) { _efl_gfx_shape_append_line_to(obj, pd, x, y); return; } - if (rx < 0) rx = -rx; - if (ry < 0) ry = -ry; + angle = angle * M_PI / 180.0; + cos_phi = cos(angle); + sin_phi = sin(angle); + dx2 = (sx - x) / 2.0; + dy2 = (sy - y) / 2.0; + x1p = cos_phi * dx2 + sin_phi * dy2; + y1p = cos_phi * dy2 - sin_phi * dx2; + x1p2 = x1p * x1p; + y1p2 = y1p * y1p; + rx2 = rx * rx; + ry2 = ry * ry; + lambda = (x1p2 / rx2) + (y1p2 / ry2); - 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) + // Correction of out-of-range radii, see F6.6.2 (step 4) + if (lambda > 1.0) { - rx *= sqrt(gamma); - ry *= sqrt(gamma); + // see F6.6.3 + double lambda_root = sqrt(lambda); + + rx *= lambda_root; + ry *= lambda_root; + // update rx2 and ry2 + rx2 = rx * rx; + ry2 = ry * ry; } - /* Compute the center */ - k1 = rx * rx * y1_ * y1_ + ry * ry * x1_ * x1_; - if (k1 == 0) return; + c = (rx2 * ry2) - (rx2 * y1p2) - (ry2 * x1p2); - k1 = sqrt(fabs((rx * rx * ry * ry) / k1 - 1)); - if (sweep == large_arc) - k1 = -k1; + // check if there is no possible solution + // (i.e. we can't do a square root of a negative value) + if (c < 0.0) + { + // scale uniformly until we have a single solution + // (see F6.2) i.e. when c == 0.0 + double scale = sqrt(1.0 - c / (rx2 * ry2)); + rx *= scale; + ry *= scale; + // update rx2 and ry2 + rx2 = rx * rx; + ry2 = ry * ry; - cx_ = k1 * rx * y1_ / ry; - cy_ = -k1 * ry * x1_ / rx; + // step 2 (F6.5.2) - simplified since c == 0.0 + cxp = 0.0; + cyp = 0.0; + // step 3 (F6.5.3 first part) - simplified since cxp and cyp == 0.0 + cx = 0.0; + cy = 0.0; + } + else + { + // complete c calculation + c = sqrt(c / ((rx2 * y1p2) + (ry2 * x1p2))); + // inverse sign if Fa == Fs + if (large_arc == sweep) + c = -c; - cx = cosf * cx_ - sinf * cy_ + (x1 + x2) / 2; - cy = sinf * cx_ + cosf * cy_ + (y1 + y2) / 2; + // step 2 (F6.5.2) + cxp = c * ( rx * y1p / ry); + cyp = c * (-ry * x1p / rx); - /* Compute start angle */ - k1 = (x1_ - cx_) / rx; - k2 = (y1_ - cy_) / ry; - k3 = (-x1_ - cx_) / rx; - k4 = (-y1_ - cy_) / ry; + // step 3 (F6.5.3 first part) + cx = cos_phi * cxp - sin_phi * cyp; + cy = sin_phi * cxp + cos_phi * cyp; + } - k5 = sqrt(fabs(k1 * k1 + k2 * k2)); - if (k5 == 0) return; + // step 3 (F6.5.3 second part) we now have the center point of the ellipse + cx += (sx + x) / 2.0; + cy += (sy + y) / 2.0; - k5 = k1 / k5; - if (k5 < -1) k5 = -1; - else if(k5 > 1) k5 = 1; + // step 4 (F6.5.4) + // we dont' use arccos (as per w3c doc), + // see http://www.euclideanspace.com/maths/algebra/vectors/angleBetween/index.htm + // note: atan2 (0.0, 1.0) == 0.0 + at = atan2(((y1p - cyp) / ry), ((x1p - cxp) / rx)); + theta1 = (at < 0.0) ? 2.0 * M_PI + at : at; - theta1 = acos(k5); - if(k2 < 0) theta1 = -theta1; + nat = atan2(((-y1p - cyp) / ry), ((-x1p - cxp) / rx)); + delta_theta = (nat < at) ? 2.0 * M_PI - at + nat : nat - at; - /* Compute delta_theta */ - k5 = sqrt(fabs((k1 * k1 + k2 * k2) * (k3 * k3 + k4 * k4))); - if (k5 == 0) return; + if (sweep) + { + // ensure delta theta < 0 or else add 360 degrees + if (delta_theta < 0.0) + delta_theta += 2.0 * M_PI; + } + else + { + // ensure delta theta > 0 or else substract 360 degrees + if (delta_theta > 0.0) + delta_theta -= 2.0 * M_PI; + } - 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; + // add several cubic bezier to approximate the arc + // (smaller than 90 degrees) + // we add one extra segment because we want something + // smaller than 90deg (i.e. not 90 itself) + segments = (int) (fabs(delta_theta / M_PI_2)) + 1; + delta = delta_theta / segments; - if (sweep && delta_theta < 0) - delta_theta += M_PI*2; - else if (!sweep && delta_theta > 0) - delta_theta -= M_PI*2; + // http://www.stillhq.com/ctpfaq/2001/comp.text.pdf-faq-2001-04.txt (section 2.13) + bcp = 4.0 / 3 * (1 - cos(delta / 2)) / sin(delta / 2); - /* Now draw the arc */ - n_segs = ceil(fabs(delta_theta / (M_PI * 0.5 + 0.001))); + cos_phi_rx = cos_phi * rx; + cos_phi_ry = cos_phi * ry; + sin_phi_rx = sin_phi * rx; + sin_phi_ry = sin_phi * ry; - for (i = 0; i < n_segs; i++) - _efl_gfx_shape_append_arc_segment(obj, pd, - cx, cy, - theta1 + i * delta_theta / n_segs, - theta1 + (i + 1) * delta_theta / n_segs, - rx, ry, angle); + cos_theta1 = cos(theta1); + sin_theta1 = sin(theta1); + + for (i = 0; i < segments; ++i) + { + // end angle (for this segment) = current + delta + double c1x, c1y, ex, ey, c2x, c2y; + double theta2 = theta1 + delta; + double cos_theta2 = cos(theta2); + double sin_theta2 = sin(theta2); + + // first control point (based on start point sx,sy) + c1x = sx - bcp * (cos_phi_rx * sin_theta1 + sin_phi_ry * cos_theta1); + c1y = sy + bcp * (cos_phi_ry * cos_theta1 - sin_phi_rx * sin_theta1); + + // end point (for this segment) + ex = cx + (cos_phi_rx * cos_theta2 - sin_phi_ry * sin_theta2); + ey = cy + (sin_phi_rx * cos_theta2 + cos_phi_ry * sin_theta2); + + // second control point (based on end point ex,ey) + c2x = ex + bcp * (cos_phi_rx * sin_theta2 + sin_phi_ry * cos_theta2); + c2y = ey + bcp * (sin_phi_rx * sin_theta2 - cos_phi_ry * cos_theta2); + + _efl_gfx_shape_append_cubic_to(obj, pd, ex, ey, c1x, c1y, c2x, c2y); + + // next start point is the current end point (same for angle) + sx = ex; + sy = ey; + theta1 = theta2; + // avoid recomputations + cos_theta1 = cos_theta2; + sin_theta1 = sin_theta2; + } } void From 0e18880efebc16305c803066961979c45a6f34f0 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:33:26 +0200 Subject: [PATCH 179/251] ector: fix forgotten return value. --- src/lib/ector/ector_renderer_base.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/lib/ector/ector_renderer_base.c b/src/lib/ector/ector_renderer_base.c index 6db31d352d..4f45542f70 100644 --- a/src/lib/ector/ector_renderer_base.c +++ b/src/lib/ector/ector_renderer_base.c @@ -124,10 +124,13 @@ _ector_renderer_generic_base_quality_get(Eo *obj EINA_UNUSED, } static Eina_Bool -_ector_renderer_generic_base_prepare(Eo *obj, Ector_Renderer_Generic_Base_Data *pd) +_ector_renderer_generic_base_prepare(Eo *obj EINA_UNUSED, + Ector_Renderer_Generic_Base_Data *pd) { if (pd->mask) eo_do(pd->mask, ector_renderer_prepare()); + + return EINA_TRUE; } #include "ector_renderer_generic_base.eo.c" From bc7833e785b99bf7b70510b107754b9ab16c42d1 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:33:28 +0200 Subject: [PATCH 180/251] efl: fix rectangle shape to finish at the right position. --- src/lib/efl/interfaces/efl_gfx_shape.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/efl/interfaces/efl_gfx_shape.c b/src/lib/efl/interfaces/efl_gfx_shape.c index 94854d1242..626bd6f70b 100644 --- a/src/lib/efl/interfaces/efl_gfx_shape.c +++ b/src/lib/efl/interfaces/efl_gfx_shape.c @@ -722,7 +722,7 @@ _efl_gfx_shape_append_rect(Eo *obj, Efl_Gfx_Shape_Data *pd, _efl_gfx_shape_append_line_to(obj, pd, x + rx, y + h); // Bottom left corner _efl_gfx_shape_append_arc_to(obj, pd, x, y + h - ry, rx, ry, 0, EINA_FALSE, EINA_TRUE); - _efl_gfx_shape_append_line_to(obj, pd, x, y - ry); + _efl_gfx_shape_append_line_to(obj, pd, x, y + ry); } static void From 5753b4381229cb7b5930766ace4dfc547b90e9bf Mon Sep 17 00:00:00 2001 From: Subhransu Sekhar Mohanty Date: Fri, 3 Apr 2015 16:33:29 +0200 Subject: [PATCH 181/251] ector: fix pre multiplied color issue with FreeType backend. Signed-off-by: Cedric BAIL --- src/lib/ector/software/ector_blend_private.h | 12 ------------ src/lib/ector/software/ector_software_gradient.c | 7 ++----- src/lib/ector/software/ector_software_rasterizer.c | 4 +--- 3 files changed, 3 insertions(+), 20 deletions(-) diff --git a/src/lib/ector/software/ector_blend_private.h b/src/lib/ector/software/ector_blend_private.h index ba48a03349..0082baa5eb 100644 --- a/src/lib/ector/software/ector_blend_private.h +++ b/src/lib/ector/software/ector_blend_private.h @@ -89,18 +89,6 @@ _ector_comp_func_source_over(uint *dest, uint *src, int length, uint const_alpha } } - -static inline uint -_ector_premultiply(uint data) -{ - DATA32 a = 1 + (data >> 24); - data = ( data & 0xff000000) + - (((((data) >> 8) & 0xff) * a) & 0xff00) + - (((((data) & 0x00ff00ff) * a) >> 8) & 0x00ff00ff); - - return data; -} - static inline uint INTERPOLATE_PIXEL_256(uint x, uint a, uint y, uint b) { uint t = (x & 0xff00ff) * a + (y & 0xff00ff) * b; diff --git a/src/lib/ector/software/ector_software_gradient.c b/src/lib/ector/software/ector_software_gradient.c index ed2b9fe985..fd842dd4cd 100644 --- a/src/lib/ector/software/ector_software_gradient.c +++ b/src/lib/ector/software/ector_software_gradient.c @@ -82,7 +82,6 @@ _generate_gradient_color_table(Efl_Gfx_Gradient_Stop *gradient_stops, int stop_c uint current_color = ECTOR_ARGB_JOIN(curr->a, curr->r, curr->g, curr->b); double incr = 1.0 / (double)size; double fpos = 1.5 * incr; - current_color = _ector_premultiply(current_color); colorTable[pos++] = current_color; @@ -99,7 +98,6 @@ _generate_gradient_color_table(Efl_Gfx_Gradient_Stop *gradient_stops, int stop_c next = (gradient_stops + i + 1); double delta = 1/(next->offset - curr->offset); uint next_color = ECTOR_ARGB_JOIN(next->a, next->r, next->g, next->b); - next_color = _ector_premultiply(next_color); BLEND_FUNC func = &_ease_linear; while (fpos < next->offset && pos < size) { @@ -113,12 +111,11 @@ _generate_gradient_color_table(Efl_Gfx_Gradient_Stop *gradient_stops, int stop_c current_color = next_color; } - uint last_color = _ector_premultiply(current_color); for (;pos < size; ++pos) - colorTable[pos] = last_color; + colorTable[pos] = current_color; // Make sure the last color stop is represented at the end of the table - colorTable[size-1] = last_color; + colorTable[size-1] = current_color; } diff --git a/src/lib/ector/software/ector_software_rasterizer.c b/src/lib/ector/software/ector_software_rasterizer.c index dca87e3bba..a0c5b3f151 100644 --- a/src/lib/ector/software/ector_software_rasterizer.c +++ b/src/lib/ector/software/ector_software_rasterizer.c @@ -482,9 +482,7 @@ void ector_software_rasterizer_clip_shape_set(Software_Rasterizer *rasterizer, S void ector_software_rasterizer_color_set(Software_Rasterizer *rasterizer, int r, int g, int b, int a) { - uint color = ECTOR_ARGB_JOIN(a, r, g, b); - - rasterizer->fillData.color = _ector_premultiply(color); + rasterizer->fillData.color = ECTOR_ARGB_JOIN(a, r, g, b); rasterizer->fillData.type = Solid; } void ector_software_rasterizer_linear_gradient_set(Software_Rasterizer *rasterizer, Ector_Renderer_Software_Gradient_Data *linear) From d02bb67da0ce708cf37e20faa93c8482be3e75fc Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:33:31 +0200 Subject: [PATCH 182/251] efl: actually update command and points length. --- src/lib/efl/interfaces/efl_gfx_shape.c | 27 +++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/lib/efl/interfaces/efl_gfx_shape.c b/src/lib/efl/interfaces/efl_gfx_shape.c index 626bd6f70b..986c4dcc2a 100644 --- a/src/lib/efl/interfaces/efl_gfx_shape.c +++ b/src/lib/efl/interfaces/efl_gfx_shape.c @@ -56,29 +56,34 @@ _efl_gfx_path_length(const Efl_Gfx_Path_Command *commands, static inline Eina_Bool efl_gfx_path_grow(Efl_Gfx_Path_Command command, - Efl_Gfx_Path_Command **commands, double **points, + Efl_Gfx_Shape_Data *pd, 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); + cmd_length = pd->commands_count ? pd->commands_count : 1; + pts_length = pd->points_count; if (_efl_gfx_path_command_length(command)) { pts_length += _efl_gfx_path_command_length(command); - pts_tmp = realloc(*points, pts_length * sizeof (double)); + pts_tmp = realloc(pd->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); + pd->points = pts_tmp; + *offset_point = pd->points + + pts_length - _efl_gfx_path_command_length(command); } - cmd_tmp = realloc(*commands, + cmd_tmp = realloc(pd->commands, (cmd_length + 1) * sizeof (Efl_Gfx_Path_Command)); if (!cmd_tmp) return EINA_FALSE; - *commands = cmd_tmp; + pd->commands = cmd_tmp; + + pd->commands_count = cmd_length + 1; + pd->points_count = pts_length; // Append the command cmd_tmp[cmd_length - 1] = command; @@ -368,7 +373,7 @@ _efl_gfx_shape_append_move_to(Eo *obj, Efl_Gfx_Shape_Data *pd, double *offset_point; if (!efl_gfx_path_grow(EFL_GFX_PATH_COMMAND_TYPE_MOVE_TO, - &pd->commands, &pd->points, &offset_point)) + pd, &offset_point)) return ; offset_point[0] = x; @@ -387,7 +392,7 @@ _efl_gfx_shape_append_line_to(Eo *obj, Efl_Gfx_Shape_Data *pd, double *offset_point; if (!efl_gfx_path_grow(EFL_GFX_PATH_COMMAND_TYPE_LINE_TO, - &pd->commands, &pd->points, &offset_point)) + pd, &offset_point)) return ; offset_point[0] = x; @@ -408,7 +413,7 @@ _efl_gfx_shape_append_cubic_to(Eo *obj, Efl_Gfx_Shape_Data *pd, double *offset_point; if (!efl_gfx_path_grow(EFL_GFX_PATH_COMMAND_TYPE_CUBIC_TO, - &pd->commands, &pd->points, &offset_point)) + pd, &offset_point)) return ; offset_point[0] = x; @@ -689,7 +694,7 @@ _efl_gfx_shape_append_close(Eo *obj, Efl_Gfx_Shape_Data *pd) double *offset_point; efl_gfx_path_grow(EFL_GFX_PATH_COMMAND_TYPE_CLOSE, - &pd->commands, &pd->points, &offset_point); + pd, &offset_point); eo_do(obj, eo_event_callback_call(EFL_GFX_CHANGED, NULL)); } From 05014235a3976b51e5f7fcb10e05d8dd17e6dba3 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:33:32 +0200 Subject: [PATCH 183/251] evas: correct evas_vg_simple header description. --- src/examples/evas/evas-vg-simple.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/examples/evas/evas-vg-simple.c b/src/examples/evas/evas-vg-simple.c index a1922108d4..b125e3f2a0 100644 --- a/src/examples/evas/evas-vg-simple.c +++ b/src/examples/evas/evas-vg-simple.c @@ -1,11 +1,11 @@ /** - * Simple Evas example illustrating a custom Evas box object + * Simple Evas example illustrating a Evas_VG basic node usage. * * You'll need at least one engine built for it (excluding the buffer * one). See stdout/stderr for output. * * @verbatim - * gcc -o evas-box evas-box.c `pkg-config --libs --cflags evas ecore ecore-evas eina ector eo efl` + * gcc -o evas_vg_simple evas-vg-simple.c `pkg-config --libs --cflags evas ecore ecore-evas eina ector eo efl` * @endverbatim */ From 988b9cdcbc6db75aaaf7b5a5d89ad7defe848d7a Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:33:33 +0200 Subject: [PATCH 184/251] efl: make efl_gfx_shape_interpolate more resistant to bogus request. --- src/lib/efl/interfaces/efl_gfx_shape.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lib/efl/interfaces/efl_gfx_shape.c b/src/lib/efl/interfaces/efl_gfx_shape.c index 986c4dcc2a..52beef1a05 100644 --- a/src/lib/efl/interfaces/efl_gfx_shape.c +++ b/src/lib/efl/interfaces/efl_gfx_shape.c @@ -249,17 +249,18 @@ _efl_gfx_shape_interpolate(Eo *obj, Efl_Gfx_Shape_Data *pd, from_pd = eo_data_scope_get(from, EFL_GFX_SHAPE_MIXIN); to_pd = eo_data_scope_get(to, EFL_GFX_SHAPE_MIXIN); if (!from_pd && !to_pd) return EINA_FALSE; + if (pd == from_pd || pd == to_pd) return EINA_FALSE; if (!_efl_gfx_shape_equal_commands_internal(from_pd, to_pd)) return EINA_FALSE; cmds = realloc(pd->commands, sizeof (Efl_Gfx_Path_Command) * from_pd->commands_count); - if (!cmds) return EINA_FALSE; + if (!cmds && from_pd->commands_count) return EINA_FALSE; pd->commands = cmds; pts = realloc(pd->points, sizeof (double) * from_pd->points_count); - if (!pts) return EINA_FALSE; + if (!pts && from_pd->points_count) return EINA_FALSE; pd->points = pts; memcpy(cmds, from_pd->commands, From 4bdda2db5a70e4e6dd457641df4f08c396aba614 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:33:35 +0200 Subject: [PATCH 185/251] efl: fix parsing of SVG path data. --- src/lib/efl/interfaces/efl_gfx_shape.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/lib/efl/interfaces/efl_gfx_shape.c b/src/lib/efl/interfaces/efl_gfx_shape.c index 52beef1a05..9806018675 100644 --- a/src/lib/efl/interfaces/efl_gfx_shape.c +++ b/src/lib/efl/interfaces/efl_gfx_shape.c @@ -856,24 +856,24 @@ _efl_gfx_path_parse_six(const char *content, char **end, char *end1 = NULL; char *end2 = NULL; - *x = strtod(content, &end1); + *ctrl_x0 = strtod(content, &end1); end1 = _strcomma(end1); if (!end1) return EINA_FALSE; - *y = strtod(end1, &end2); + *ctrl_y0 = 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); + *ctrl_x1 = strtod(end2, &end2); end2 = _strcomma(end2); if (!end2) return EINA_FALSE; *ctrl_y1 = strtod(end2, &end1); if (end1 == end2) return EINA_FALSE; + *x = strtod(end1, &end2); + end2 = _strcomma(end2); + if (!end2) return EINA_FALSE; + *y = strtod(end2, &end1); + if (end1 == end2) return EINA_FALSE; + *end = end1; return EINA_TRUE; @@ -925,16 +925,16 @@ _efl_gfx_path_parse_quad(const char *content, char **end, char *end1 = NULL; char *end2 = NULL; - *x = strtod(content, &end1); + *ctrl_x0 = strtod(content, &end1); end1 = _strcomma(end1); if (!end1) return EINA_FALSE; - *y = strtod(end1, &end2); + *ctrl_y0 = strtod(end1, &end2); if (end1 == end2) return EINA_FALSE; - *ctrl_x0 = strtod(end2, &end1); + *x = strtod(end2, &end1); end1 = _strcomma(end2); if (!end1) return EINA_FALSE; - *ctrl_y0 = strtod(end1, &end2); + *y = strtod(end1, &end2); if (end1 == end2) return EINA_FALSE; *end = end2; From f5f48a826553b05cddd55ab14aaf926a81684bc4 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:33:37 +0200 Subject: [PATCH 186/251] ector: correctly handle case with NULL being set for efl_gfx_shape_stroke_dash_set. --- src/lib/ector/ector_renderer_shape.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/ector/ector_renderer_shape.c b/src/lib/ector/ector_renderer_shape.c index f60e832068..cda749d1dc 100644 --- a/src/lib/ector/ector_renderer_shape.c +++ b/src/lib/ector/ector_renderer_shape.c @@ -136,7 +136,7 @@ _ector_renderer_generic_shape_efl_gfx_shape_stroke_dash_set(Eo *obj EINA_UNUSED, } tmp = realloc(pd->stroke.dash, length * sizeof (Efl_Gfx_Dash)); - if (!tmp) return ; + if (!tmp && length) return ; memcpy(tmp, dash, length * sizeof (Efl_Gfx_Dash)); pd->stroke.dash = tmp; From d14f805793e5aaebd4a7a490a088d019d8481128 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:33:38 +0200 Subject: [PATCH 187/251] efl: notify when the path change. This is an easier and safer way than forcing all object inheriting this class to override all function that modify the path. --- src/lib/efl/Efl.h | 2 ++ src/lib/efl/interfaces/efl_gfx_shape.c | 32 +++++++++++++++----- src/lib/efl/interfaces/efl_interfaces_main.c | 3 ++ 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/src/lib/efl/Efl.h b/src/lib/efl/Efl.h index 87308782fc..5a0b3eb949 100644 --- a/src/lib/efl/Efl.h +++ b/src/lib/efl/Efl.h @@ -148,8 +148,10 @@ typedef enum _Efl_Gfx_Fill_Spread #include "interfaces/efl_text_properties.eo.h" EAPI extern const Eo_Event_Description _EFL_GFX_CHANGED; +EAPI extern const Eo_Event_Description _EFL_GFX_PATH_CHANGED; #define EFL_GFX_CHANGED (&(_EFL_GFX_CHANGED)) +#define EFL_GFX_PATH_CHANGED (&(_EFL_GFX_PATH_CHANGED)) #include "interfaces/efl_gfx_base.eo.h" #include "interfaces/efl_gfx_stack.eo.h" diff --git a/src/lib/efl/interfaces/efl_gfx_shape.c b/src/lib/efl/interfaces/efl_gfx_shape.c index 9806018675..abb56611f9 100644 --- a/src/lib/efl/interfaces/efl_gfx_shape.c +++ b/src/lib/efl/interfaces/efl_gfx_shape.c @@ -180,7 +180,9 @@ _efl_gfx_shape_path_set(Eo *obj, Efl_Gfx_Shape_Data *pd, &pd->current_ctrl.x, &pd->current_ctrl.y); end: - eo_do(obj, eo_event_callback_call(EFL_GFX_CHANGED, NULL)); + eo_do(obj, + eo_event_callback_call(EFL_GFX_PATH_CHANGED, NULL), + eo_event_callback_call(EFL_GFX_CHANGED, NULL)); } void @@ -292,7 +294,9 @@ _efl_gfx_shape_interpolate(Eo *obj, Efl_Gfx_Shape_Data *pd, to_pd->current_ctrl.y, pos_map); - eo_do(obj, eo_event_callback_call(EFL_GFX_CHANGED, NULL)); + eo_do(obj, + eo_event_callback_call(EFL_GFX_PATH_CHANGED, NULL), + eo_event_callback_call(EFL_GFX_CHANGED, NULL)); return EINA_TRUE; } @@ -345,7 +349,9 @@ _efl_gfx_shape_dup(Eo *obj, Efl_Gfx_Shape_Data *pd, Eo *dup_from) _efl_gfx_shape_path_set(obj, pd, from->commands, from->points); - eo_do(obj, eo_event_callback_call(EFL_GFX_CHANGED, NULL)); + eo_do(obj, + eo_event_callback_call(EFL_GFX_PATH_CHANGED, NULL), + eo_event_callback_call(EFL_GFX_CHANGED, NULL)); } void @@ -364,7 +370,9 @@ _efl_gfx_shape_reset(Eo *obj, Efl_Gfx_Shape_Data *pd) pd->current_ctrl.x = 0; pd->current_ctrl.y = 0; - eo_do(obj, eo_event_callback_call(EFL_GFX_CHANGED, NULL)); + eo_do(obj, + eo_event_callback_call(EFL_GFX_PATH_CHANGED, NULL), + eo_event_callback_call(EFL_GFX_CHANGED, NULL)); } void @@ -383,7 +391,9 @@ _efl_gfx_shape_append_move_to(Eo *obj, Efl_Gfx_Shape_Data *pd, pd->current.x = x; pd->current.y = y; - eo_do(obj, eo_event_callback_call(EFL_GFX_CHANGED, NULL)); + eo_do(obj, + eo_event_callback_call(EFL_GFX_PATH_CHANGED, NULL), + eo_event_callback_call(EFL_GFX_CHANGED, NULL)); } void @@ -402,7 +412,9 @@ _efl_gfx_shape_append_line_to(Eo *obj, Efl_Gfx_Shape_Data *pd, pd->current.x = x; pd->current.y = y; - eo_do(obj, eo_event_callback_call(EFL_GFX_CHANGED, NULL)); + eo_do(obj, + eo_event_callback_call(EFL_GFX_PATH_CHANGED, NULL), + eo_event_callback_call(EFL_GFX_CHANGED, NULL)); } void @@ -429,7 +441,9 @@ _efl_gfx_shape_append_cubic_to(Eo *obj, Efl_Gfx_Shape_Data *pd, pd->current_ctrl.x = ctrl_x1; pd->current_ctrl.y = ctrl_y1; - eo_do(obj, eo_event_callback_call(EFL_GFX_CHANGED, NULL)); + eo_do(obj, + eo_event_callback_call(EFL_GFX_PATH_CHANGED, NULL), + eo_event_callback_call(EFL_GFX_CHANGED, NULL)); } void @@ -697,7 +711,9 @@ _efl_gfx_shape_append_close(Eo *obj, Efl_Gfx_Shape_Data *pd) efl_gfx_path_grow(EFL_GFX_PATH_COMMAND_TYPE_CLOSE, pd, &offset_point); - eo_do(obj, eo_event_callback_call(EFL_GFX_CHANGED, NULL)); + eo_do(obj, + eo_event_callback_call(EFL_GFX_PATH_CHANGED, NULL), + eo_event_callback_call(EFL_GFX_CHANGED, NULL)); } void diff --git a/src/lib/efl/interfaces/efl_interfaces_main.c b/src/lib/efl/interfaces/efl_interfaces_main.c index dafda5bf7e..6ae1cb3ea4 100644 --- a/src/lib/efl/interfaces/efl_interfaces_main.c +++ b/src/lib/efl/interfaces/efl_interfaces_main.c @@ -22,3 +22,6 @@ EAPI const Eo_Event_Description _EFL_GFX_CHANGED = EO_EVENT_DESCRIPTION("Graphics changed", "The visual representation of the object changed"); + +EAPI const Eo_Event_Description _EFL_GFX_PATH_CHANGED = + EO_EVENT_DESCRIPTION("Graphics path changed", "The path of a shape object changed"); From 728fa26409f886c0bdbfff0a809b2b7b8dc0137e Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:33:40 +0200 Subject: [PATCH 188/251] ector: use the new infrastructure to detect changed path for Cairo backend. --- .../ector/cairo/ector_renderer_cairo_shape.c | 29 ++++++++++--------- .../ector/cairo/ector_renderer_cairo_shape.eo | 1 - 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/lib/ector/cairo/ector_renderer_cairo_shape.c b/src/lib/ector/cairo/ector_renderer_cairo_shape.c index 497c59d52f..babf113e18 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_shape.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_shape.c @@ -45,6 +45,19 @@ struct _Ector_Renderer_Cairo_Shape_Data cairo_path_t *path; }; +static Eina_Bool +_ector_renderer_cairo_shape_path_changed(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info) +{ + Ector_Renderer_Cairo_Shape_Data *pd = data; + + USE(obj, cairo_path_destroy, EINA_TRUE); + + if (pd->path) cairo_path_destroy(pd->path); + pd->path = NULL; + + return EINA_TRUE; +} + static Eina_Bool _ector_renderer_cairo_shape_ector_renderer_generic_base_prepare(Eo *obj, Ector_Renderer_Cairo_Shape_Data *pd) { @@ -183,25 +196,15 @@ _ector_renderer_cairo_shape_ector_renderer_cairo_base_fill(Eo *obj EINA_UNUSED, return EINA_FALSE; } -static void -_ector_renderer_cairo_shape_efl_gfx_shape_path_set(Eo *obj, Ector_Renderer_Cairo_Shape_Data *pd, - const Efl_Gfx_Path_Command *op, const double *points) -{ - USE(obj, cairo_path_destroy, ); - - if (pd->path) cairo_path_destroy(pd->path); - pd->path = NULL; - - eo_do_super(obj, ECTOR_RENDERER_CAIRO_SHAPE_CLASS, efl_gfx_shape_path_set(op, points)); -} - - void _ector_renderer_cairo_shape_eo_base_constructor(Eo *obj, Ector_Renderer_Cairo_Shape_Data *pd) { eo_do_super(obj, ECTOR_RENDERER_CAIRO_SHAPE_CLASS, eo_constructor()); pd->shape = eo_data_xref(obj, ECTOR_RENDERER_GENERIC_SHAPE_MIXIN, obj); pd->base = eo_data_xref(obj, ECTOR_RENDERER_GENERIC_BASE_CLASS, obj); + + eo_do(obj, + eo_event_callback_add(EFL_GFX_PATH_CHANGED, _ector_renderer_cairo_shape_path_changed, pd)); } void diff --git a/src/lib/ector/cairo/ector_renderer_cairo_shape.eo b/src/lib/ector/cairo/ector_renderer_cairo_shape.eo index 55bd0495d1..7dd1b3141e 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_shape.eo +++ b/src/lib/ector/cairo/ector_renderer_cairo_shape.eo @@ -6,7 +6,6 @@ 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.Gfx.Shape.path.set; Eo.Base.constructor; Eo.Base.destructor; } From 29aefe04ad8f2a609474ca25bc89eb1a96963604 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:33:42 +0200 Subject: [PATCH 189/251] evas: correctly handle redraw of changed tree of Evas_VG_Node. --- src/lib/evas/canvas/evas_object_vg.c | 23 ++++++++++++++++++----- src/lib/evas/canvas/evas_vg_root_node.c | 6 +++++- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/lib/evas/canvas/evas_object_vg.c b/src/lib/evas/canvas/evas_object_vg.c index fa682af234..afbe045b02 100644 --- a/src/lib/evas/canvas/evas_object_vg.c +++ b/src/lib/evas/canvas/evas_object_vg.c @@ -193,18 +193,15 @@ evas_object_vg_render_pre(Evas_Object *eo_obj, void *type_private_data) { Evas_VG_Data *vd = type_private_data; + Efl_VG_Base_Data *rnd; Evas_Public_Data *e = obj->layer->evas; int is_v, was_v; Ector_Surface *s; - // FIXME: handle damage only on changed renderer. - s = e->engine.func->ector_get(e->engine.data.output); - if (vd->root && s) - _evas_vg_render_pre(vd->root, s, NULL); - /* dont pre-render the obj twice! */ if (obj->pre_render_done) return; obj->pre_render_done = EINA_TRUE; + /* pre-render phase. this does anything an object needs to do just before */ /* rendering. this could mean loading the image data, retrieving it from */ /* elsewhere, decoding video etc. */ @@ -224,6 +221,22 @@ evas_object_vg_render_pre(Evas_Object *eo_obj, is_v = evas_object_is_visible(eo_obj, obj); was_v = evas_object_was_visible(eo_obj,obj); if (!(is_v | was_v)) goto done; + + // FIXME: handle damage only on changed renderer. + s = e->engine.func->ector_get(e->engine.data.output); + if (vd->root && s) + _evas_vg_render_pre(vd->root, s, NULL); + + // FIXME: for now the walking Evas_VG_Node tree doesn't trigger any damage + // So just forcing it here if necessary + rnd = eo_data_scope_get(vd->root, EFL_VG_BASE_CLASS); + if (rnd->changed) + { + rnd->changed = EINA_FALSE; + evas_object_render_pre_prev_cur_add(&obj->layer->evas->clip_changes, eo_obj, obj); + goto done; + } + if (is_v != was_v) { evas_object_render_pre_visible_change(&obj->layer->evas->clip_changes, eo_obj, is_v, was_v); diff --git a/src/lib/evas/canvas/evas_vg_root_node.c b/src/lib/evas/canvas/evas_vg_root_node.c index b0d93c307c..8362dfde6d 100644 --- a/src/lib/evas/canvas/evas_vg_root_node.c +++ b/src/lib/evas/canvas/evas_vg_root_node.c @@ -33,11 +33,15 @@ _evas_vg_root_node_render_pre(Eo *obj EINA_UNUSED, } static Eina_Bool -_evas_vg_root_node_changed(void *data, Eo *obj EINA_UNUSED, +_evas_vg_root_node_changed(void *data, Eo *obj, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED) { Efl_VG_Root_Node_Data *pd = data; + Efl_VG_Base_Data *bd = eo_data_scope_get(obj, EFL_VG_BASE_CLASS); + + if (bd->changed) return EINA_TRUE; + bd->changed = EINA_TRUE; if (pd->parent) evas_object_change(pd->parent, pd->data); return EINA_TRUE; From fbeb5dd618c031d96d37a3e62611f625dd855e8d Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:33:43 +0200 Subject: [PATCH 190/251] evas: call batman to the rescue ! The animation is not pretty yet, but definitively a nice demo of a changing shape with current Evas_VG API. --- src/examples/evas/Makefile.am | 8 +- src/examples/evas/evas-vg-batman.c | 176 +++++++++++++++++++++++++++++ 2 files changed, 183 insertions(+), 1 deletion(-) create mode 100644 src/examples/evas/evas-vg-batman.c diff --git a/src/examples/evas/Makefile.am b/src/examples/evas/Makefile.am index 165d789852..0218472979 100644 --- a/src/examples/evas/Makefile.am +++ b/src/examples/evas/Makefile.am @@ -294,6 +294,11 @@ evas_vg_simple_SOURCES = evas-vg-simple.c evas_vg_simple_LDADD = $(ECORE_EVAS_COMMON_LDADD) evas_vg_simple_CPPFLAGS = $(ECORE_EVAS_COMMON_CPPFLAGS) +EXTRA_PROGRAMS += evas_vg_batman +evas_vg_batman_SOURCES = evas-vg-batman.c +evas_vg_batman_LDADD = $(ECORE_EVAS_COMMON_LDADD) +evas_vg_batman_CPPFLAGS = $(ECORE_EVAS_COMMON_CPPFLAGS) + .edc.edj: $(AM_V_EDJ)$(EDJE_CC) $(EDJE_CC_FLAGS) $< $(builddir)/$(@F) @@ -337,7 +342,8 @@ evas-stacking.c \ evas-table.c \ evas-multi-touch.c \ evas-text.c \ -evas-vg-simple.c +evas-vg-simple.c \ +evas-vg-batman.c DATA_FILES = \ resources/images/enlightenment.png \ diff --git a/src/examples/evas/evas-vg-batman.c b/src/examples/evas/evas-vg-batman.c new file mode 100644 index 0000000000..dabefe6df9 --- /dev/null +++ b/src/examples/evas/evas-vg-batman.c @@ -0,0 +1,176 @@ +/** + * Simple Evas example illustrating the use of Evas_VG animation + * + * You'll need at least one engine built for it (excluding the buffer + * one). See stdout/stderr for output. + * + * @verbatim + * gcc -o evas_vg_batman evas-vg-batman.c `pkg-config --libs --cflags evas ecore ecore-evas eina ector eo efl` + * @endverbatim + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#else +#define PACKAGE_EXAMPLES_DIR "." +#endif + +#define WIDTH 800 +#define HEIGHT 600 + +#ifndef EFL_BETA_API_SUPPORT +#define EFL_BETA_API_SUPPORT 1 +#endif + +#ifndef EFL_EO_API_SUPPORT +#define EFL_EO_API_SUPPORT 1 +#endif + +#include +#include +#include +#include +#include + +#include +#include + +static Evas_Object *background = NULL; +static Evas_Object *vg = NULL; +static Efl_VG *batman = NULL; + +static int animation_position = 0; +static Ecore_Animator *animation = NULL; + +static Efl_VG **batmans_vg = NULL; +static const char *batmans_path[] = { + "M 256,213 C 245,181 206,187 234,262 147,181 169,71.2 233,18 220,56 235,81 283,88 285,78.7 286,69.3 288,60 289,61.3 290,62.7 291,64 291,64 297,63 300,63 303,63 309,64 309,64 310,62.7 311,61.3 312,60 314,69.3 315,78.7 317,88 365,82 380,56 367,18 431,71 453,181 366,262 394,187 356,181 344,213 328,185 309,184 300,284 291,184 272,185 256,213 Z", + "M 212,220 C 197,171 156,153 123,221 109,157 120,109 159,63.6 190,114 234,115 254,89.8 260,82.3 268,69.6 270,60.3 273,66.5 275,71.6 280,75.6 286,79.5 294,79.8 300,79.8 306,79.8 314,79.5 320,75.6 325,71.6 327,66.5 330,60.3 332,69.6 340,82.3 346,89.8 366,115 410,114 441,63.6 480,109 491,157 477,221 444,153 403,171 388,220 366,188 316,200 300,248 284,200 234,188 212,220 Z", + "M 212,220 C 197,171 156,153 123,221 109,157 120,109 159,63.6 190,114 234,115 254,89.8 260,82.3 268,69.6 270,60.3 273,66.5 275,71.6 280,75.6 286,79.5 294,79.8 300,79.8 306,79.8 314,79.5 320,75.6 325,71.6 327,66.5 330,60.3 332,69.6 340,82.3 346,89.8 366,115 410,114 441,63.6 480,109 491,157 477,221 444,153 403,171 388,220 366,188 316,200 300,248 284,200 234,188 212,220 Z", + "M 213,222 C 219,150 165,139 130,183 125,123 171,73.8 247,51.6 205,78 236,108 280,102 281,90.3 282,79 286,68.2 287,72 288,75.8 289,79.7 293,79.7 296,79.7 300,79.7 304,79.7 307,79.7 311,79.7 312,75.8 313,72 314,68.2 318,79 319,90.3 320,102 364,108 395,78 353,51.6 429,73.8 475,123 470,183 435,139 381,150 387,222 364,176 315,172 300,248 285,172 236,176 213,222 Z", + "M 213,222 C 219,150 165,139 130,183 125,123 171,73.8 247,51.6 205,78 236,108 280,102 281,90.3 282,79 286,68.2 287,72 288,75.8 289,79.7 293,79.7 296,79.7 300,79.7 304,79.7 307,79.7 311,79.7 312,75.8 313,72 314,68.2 318,79 319,90.3 320,102 364,108 395,78 353,51.6 429,73.8 475,123 470,183 435,139 381,150 387,222 364,176 315,172 300,248 285,172 236,176 213,222 Z", + "M 218,231 C 191,238 165,252 140,266 144,209 156,153 193,93.7 218,106 249,105 280,102 282,90.3 284,78.6 289,67.8 290,71.6 291,75.8 292,79.7 292,79.7 297,79.7 300,79.7 303,79.7 308,79.7 308,79.7 309,75.8 310,71.6 311,67.8 316,78.6 318,90.3 320,102 351,105 382,106 407,93.7 444,153 456,209 460,266 435,252 409,238 382,231 355,224 328,223 300,223 272,223 245,224 218,231 Z", + "M 218,231 C 191,238 165,252 140,266 144,209 156,153 193,93.7 218,106 249,105 280,102 282,90.3 284,78.6 289,67.8 290,71.6 291,75.8 292,79.7 292,79.7 297,79.7 300,79.7 303,79.7 308,79.7 308,79.7 309,75.8 310,71.6 311,67.8 316,78.6 318,90.3 320,102 351,105 382,106 407,93.7 444,153 456,209 460,266 435,252 409,238 382,231 355,224 328,223 300,223 272,223 245,224 218,231 Z", + "M 258,243 C 220,201 221,220 253,281 154,243 150,108 229,61.9 242,83 257,98.1 275,110 278,88 282,65.8 285,43.6 287,49.9 288,56.2 290,62.5 293,62.7 297,62.9 300,62.9 303,62.9 307,62.7 310,62.5 312,56.2 313,49.9 315,43.6 318,65.8 322,88 325,110 343,98.1 358,83 371,61.9 450,108 446,243 347,281 379,220 380,201 342,243 330,187 329,202 300,271 271,202 270,187 258,243 Z", + "M 258,243 C 220,201 221,220 253,281 154,243 150,108 229,61.9 242,83 257,98.1 275,110 278,88 282,65.8 285,43.6 287,49.9 288,56.2 290,62.5 293,62.7 297,62.9 300,62.9 303,62.9 307,62.7 310,62.5 312,56.2 313,49.9 315,43.6 318,65.8 322,88 325,110 343,98.1 358,83 371,61.9 450,108 446,243 347,281 379,220 380,201 342,243 330,187 329,202 300,271 271,202 270,187 258,243 Z", + "M 235,210 C 214,139 143,145 183,229 108,175 135,70.1 242,48.3 190,85.6 245,142 278,95.5 281,80.2 281,62.7 284,48.7 287,53.9 287,59.1 289,64.5 292,64.7 297,64.2 300,64.2 303,64.2 308,64.7 311,64.5 313,59.1 313,53.9 316,48.7 319,62.7 319,80.2 322,95.5 355,142 410,85.6 358,48.3 465,70.1 492,175 417,229 457,145 386,139 365,210 357,147 309,190 300,271 291,190 243,147 235,210 Z", + "M 235,210 C 214,139 143,145 183,229 108,175 135,70.1 242,48.3 190,85.6 245,142 278,95.5 281,80.2 281,62.7 284,48.7 287,53.9 287,59.1 289,64.5 292,64.7 297,64.2 300,64.2 303,64.2 308,64.7 311,64.5 313,59.1 313,53.9 316,48.7 319,62.7 319,80.2 322,95.5 355,142 410,85.6 358,48.3 465,70.1 492,175 417,229 457,145 386,139 365,210 357,147 309,190 300,271 291,190 243,147 235,210 Z", + "M 249,157 C 214,157 201,203 273,255 157,221 157,69 274,32.8 188,87.2 211,140 256,140 291,140 289,128 291,98.1 293,107 293,116 295,125 297,125 298,125 300,125 302,125 305,125 305,125 307,116 307,107 309,98.1 311,128 309,140 344,140 389,140 412,87.2 326,32.8 443,69 443,221 327,255 399,203 386,157 351,157 317,157 300,195 300,238 300,195 283,157 249,157 Z", + "M 249,157 C 214,157 201,203 273,255 157,221 157,69 274,32.8 188,87.2 211,140 256,140 291,140 289,128 291,98.1 293,107 293,116 295,125 297,125 298,125 300,125 302,125 305,125 305,125 307,116 307,107 309,98.1 311,128 309,140 344,140 389,140 412,87.2 326,32.8 443,69 443,221 327,255 399,203 386,157 351,157 317,157 300,195 300,238 300,195 283,157 249,157 Z", + "M 264,212 C 213,138 150,171 232,244 101,217 112,55.1 257,36.9 182,86.6 222,106 266,106 285,106 284,66.7 286,36.8 288,42.6 289,48.4 291,54.2 291,54.2 297,54.2 300,54.2 303,54.2 309,54.2 309,54.2 311,48.4 312,42.6 314,36.8 316,66.7 315,106 334,106 378,106 418,86.6 343,36.9 488,55.1 499,217 368,244 450,171 387,138 336,212 354,161 300,163 300,249 300,163 246,161 264,212 Z", + "M 264,212 C 213,138 150,171 232,244 101,217 112,55.1 257,36.9 182,86.6 222,106 266,106 285,106 284,66.7 286,36.8 288,42.6 289,48.4 291,54.2 291,54.2 297,54.2 300,54.2 303,54.2 309,54.2 309,54.2 311,48.4 312,42.6 314,36.8 316,66.7 315,106 334,106 378,106 418,86.6 343,36.9 488,55.1 499,217 368,244 450,171 387,138 336,212 354,161 300,163 300,249 300,163 246,161 264,212 Z", + "M 223,217 C 194,153 165,168 133,219 143,158 161,99.2 189,38.4 214,69.8 241,84.7 272,86.2 272,70.2 273,53.5 273,37.5 275,47.9 278,58.4 280,68.8 287,64.9 292,62.4 300,62.4 308,62.4 313,64.9 320,68.8 322,58.4 325,47.9 327,37.5 327,53.5 328,70.2 328,86.2 359,84.7 386,69.8 411,38.4 439,99.2 457,158 467,219 435,168 406,153 377,217 350,162 319,176 300,245 281,176 250,162 223,217 Z", + "M 223,217 C 194,153 165,168 133,219 143,158 161,99.2 189,38.4 214,69.8 241,84.7 272,86.2 272,70.2 273,53.5 273,37.5 275,47.9 278,58.4 280,68.8 287,64.9 292,62.4 300,62.4 308,62.4 313,64.9 320,68.8 322,58.4 325,47.9 327,37.5 327,53.5 328,70.2 328,86.2 359,84.7 386,69.8 411,38.4 439,99.2 457,158 467,219 435,168 406,153 377,217 350,162 319,176 300,245 281,176 250,162 223,217 Z", + "M 231,185 C 186,159 161,180 190,215 86.2,180 92.6,99.6 211,68.9 195,112 254,141 279,96.7 279,83.2 279,69.8 279,56.3 283,63.6 288,70.8 292,78.1 295,78.1 297,78.1 300,78.1 303,78.1 305,78.1 308,78.1 312,70.8 317,63.6 321,56.3 321,69.8 321,83.2 321,96.7 346,141 405,112 389,68.9 507,99.6 514,180 410,215 439,180 414,159 369,185 351,165 324,167 300,216 276,167 249,165 231,185 Z", + "M 231,185 C 186,159 161,180 190,215 86.2,180 92.6,99.6 211,68.9 195,112 254,141 279,96.7 279,83.2 279,69.8 279,56.3 283,63.6 288,70.8 292,78.1 295,78.1 297,78.1 300,78.1 303,78.1 305,78.1 308,78.1 312,70.8 317,63.6 321,56.3 321,69.8 321,83.2 321,96.7 346,141 405,112 389,68.9 507,99.6 514,180 410,215 439,180 414,159 369,185 351,165 324,167 300,216 276,167 249,165 231,185 Z", + "M 194,146 C 192,107 164,76.4 136,45.6 166,55.7 196,65.7 226,75.8 238,107 265,163 279,136 282,130 281,108 281,94.8 285,103 288,111 293,115 295,116 298,117 300,117 302,117 305,116 307,115 312,111 315,103 319,94.8 319,108 318,130 321,136 335,163 362,107 374,75.8 404,65.7 434,55.7 464,45.6 436,76.4 408,107 406,146 355,158 323,189 300,231 277,189 245,158 194,146 Z", + "M 194,146 C 192,107 164,76.4 136,45.6 166,55.7 196,65.7 226,75.8 238,107 265,163 279,136 282,130 281,108 281,94.8 285,103 288,111 293,115 295,116 298,117 300,117 302,117 305,116 307,115 312,111 315,103 319,94.8 319,108 318,130 321,136 335,163 362,107 374,75.8 404,65.7 434,55.7 464,45.6 436,76.4 408,107 406,146 355,158 323,189 300,231 277,189 245,158 194,146 Z", + "M 209,182 C 184,132 176,138 113,161 140,136 168,111 196,86.5 221,104 247,115 278,115 281,99.9 285,85.5 287,70.2 289,78.5 292,88.4 294,96.7 296,96.7 298,96.7 300,96.7 302,96.7 304,96.7 306,96.7 308,88.4 311,78.5 313,70.2 315,85.5 319,99.9 322,115 353,115 379,104 404,86.5 432,111 460,136 487,161 424,138 416,132 391,182 332,150 341,161 300,214 259,161 268,150 209,182 Z", + "M 209,182 C 184,132 176,138 113,161 140,136 168,111 196,86.5 221,104 247,115 278,115 281,99.9 285,85.5 287,70.2 289,78.5 292,88.4 294,96.7 296,96.7 298,96.7 300,96.7 302,96.7 304,96.7 306,96.7 308,88.4 311,78.5 313,70.2 315,85.5 319,99.9 322,115 353,115 379,104 404,86.5 432,111 460,136 487,161 424,138 416,132 391,182 332,150 341,161 300,214 259,161 268,150 209,182 Z", + "M 198,171 C 189,131 150,120 113,140 142,104 182,74.4 249,70.2 208,89 248,125 278,106 285,101 286,93.5 286,74.2 288,78.1 291,81.5 294,83.2 296,84.2 298,84.7 300,84.7 302,84.7 304,84.2 306,83.2 309,81.5 312,78.1 314,74.2 314,93.5 315,101 322,106 352,125 392,89 351,70.2 418,74.4 458,104 487,140 450,120 411,131 402,171 357,147 322,171 300,214 278,171 243,147 198,171 Z", + "M 198,171 C 189,131 150,120 113,140 142,104 182,74.4 249,70.2 208,89 248,125 278,106 285,101 286,93.5 286,74.2 288,78.1 291,81.5 294,83.2 296,84.2 298,84.7 300,84.7 302,84.7 304,84.2 306,83.2 309,81.5 312,78.1 314,74.2 314,93.5 315,101 322,106 352,125 392,89 351,70.2 418,74.4 458,104 487,140 450,120 411,131 402,171 357,147 322,171 300,214 278,171 243,147 198,171 Z", + "M 202,170 C 188,115 157,108 124,105 146,84.3 171,71.5 199,70.2 211,98.6 243,103 277,106 279,99.3 281,92.6 283,86 285,91.9 287,97.9 290,104 293,104 297,104 300,104 303,104 307,104 310,104 313,97.9 315,91.9 317,86 319,92.6 321,99.3 323,106 357,103 389,98.6 401,70.2 429,71.5 454,84.3 476,105 443,108 412,115 398,170 349,157 318,175 300,214 282,175 251,157 202,170 Z", + "M 202,170 C 188,115 157,108 124,105 146,84.3 171,71.5 199,70.2 211,98.6 243,103 277,106 279,99.3 281,92.6 283,86 285,91.9 287,97.9 290,104 293,104 297,104 300,104 303,104 307,104 310,104 313,97.9 315,91.9 317,86 319,92.6 321,99.3 323,106 357,103 389,98.6 401,70.2 429,71.5 454,84.3 476,105 443,108 412,115 398,170 349,157 318,175 300,214 282,175 251,157 202,170 Z", + "M 220,179 C 200,127 150,130 123,175 122,110 160,85.1 201,64 208,99.2 243,111 268,92.9 278,86.1 284,68.2 287,40.7 289,49.6 292,58.4 294,67.3 296,67.3 298,67.3 300,67.3 302,67.3 304,67.3 306,67.3 308,58.4 311,49.6 313,40.7 316,68.2 322,86.1 332,92.9 357,111 392,99.3 399,64 440,85.1 478,110 477,175 450,130 400,127 380,179 355,155 305,208 300,247 295,208 245,155 220,179 Z", + "M 220,179 C 200,127 150,130 123,175 122,110 160,85.1 201,64 208,99.2 243,111 268,92.9 278,86.1 284,68.2 287,40.7 289,49.6 292,58.4 294,67.3 296,67.3 298,67.3 300,67.3 302,67.3 304,67.3 306,67.3 308,58.4 311,49.6 313,40.7 316,68.2 322,86.1 332,92.9 357,111 392,99.3 399,64 440,85.1 478,110 477,175 450,130 400,127 380,179 355,155 305,208 300,247 295,208 245,155 220,179 Z", + "M 166,154 C 179,119 154,95.4 114,79.3 155,79.1 197,78.9 239,78.7 242,103 250,109 283,109 289,109 290,93.9 291,83.7 292,88.3 292,92.9 293,97.5 295,97.5 298,97.5 300,97.5 302,97.5 305,97.5 307,97.5 308,92.9 308,88.3 309,83.7 310,93.9 311,109 317,109 350,109 358,103 361,78.7 403,78.9 445,79.1 486,79.3 446,95.4 421,119 434,154 377,151 320,151 300,207 280,151 223,151 166,154 Z", + "M 166,154 C 179,119 154,95.4 114,79.3 155,79.1 197,78.9 239,78.7 242,103 250,109 283,109 289,109 290,93.9 291,83.7 292,88.3 292,92.9 293,97.5 295,97.5 298,97.5 300,97.5 302,97.5 305,97.5 307,97.5 308,92.9 308,88.3 309,83.7 310,93.9 311,109 317,109 350,109 358,103 361,78.7 403,78.9 445,79.1 486,79.3 446,95.4 421,119 434,154 377,151 320,151 300,207 280,151 223,151 166,154 Z", + "M 256,213 C 245,181 206,187 234,262 147,181 169,71.2 233,18 220,56 235,81 283,88 285,78.7 286,69.3 288,60 289,61.3 290,62.7 291,64 291,64 297,63 300,63 303,63 309,64 309,64 310,62.7 311,61.3 312,60 314,69.3 315,78.7 317,88 365,82 380,56 367,18 431,71 453,181 366,262 394,187 356,181 344,213 328,185 309,184 300,284 291,184 272,185 256,213 Z", + "M 256,213 C 245,181 206,187 234,262 147,181 169,71.2 233,18 220,56 235,81 283,88 285,78.7 286,69.3 288,60 289,61.3 290,62.7 291,64 291,64 297,63 300,63 303,63 309,64 309,64 310,62.7 311,61.3 312,60 314,69.3 315,78.7 317,88 365,82 380,56 367,18 431,71 453,181 366,262 394,187 356,181 344,213 328,185 309,184 300,284 291,184 272,185 256,213 Z" +}; + +static void +_on_delete(Ecore_Evas *ee EINA_UNUSED) +{ + ecore_main_loop_quit(); +} + +static void +_on_resize(Ecore_Evas *ee) +{ + int w, h; + + ecore_evas_geometry_get(ee, NULL, NULL, &w, &h); + evas_object_resize(background, w, h); + evas_object_resize(vg, w, h); +} + +static Eina_Bool +_animator(void *data EINA_UNUSED, double pos) +{ + int next = (animation_position + 1) % (sizeof (batmans_path) / sizeof (batmans_path[0])); + + evas_vg_shape_shape_interpolate(batman, + batmans_vg[animation_position], + batmans_vg[next], + ecore_animator_pos_map(pos, ECORE_POS_MAP_SINUSOIDAL, 0.0, 0.0)); + + if (pos == 1.0) + { + animation_position = next; + animation = ecore_animator_timeline_add(5, _animator, NULL); + } + + return EINA_TRUE; +} + +int +main(void) +{ + Ecore_Evas *ee; + Evas *e; + Efl_VG *circle; + Efl_VG *root; + unsigned int i; + + if (!ecore_evas_init()) + return -1; + + ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL); + if (!ee) return -1; + + ecore_evas_callback_delete_request_set(ee, _on_delete); + ecore_evas_callback_resize_set(ee, _on_resize); + ecore_evas_show(ee); + + e = ecore_evas_get(ee); + background = evas_object_rectangle_add(e); + evas_object_color_set(background, 70, 70, 70, 255); + evas_object_show(background); + + vg = evas_object_vg_add(e); + evas_object_show(vg); + + _on_resize(ee); + + batmans_vg = malloc(sizeof (Efl_VG*) * + sizeof (batmans_path) / sizeof (batmans_path[0])); + if (!batmans_vg) return -1; + + for (i = 0; i < sizeof (batmans_path) / sizeof (batmans_path[0]); i++) + { + batmans_vg[i] = eo_add(EFL_VG_SHAPE_CLASS, NULL); + evas_vg_shape_shape_append_svg_path(batmans_vg[i], batmans_path[i]); + } + + animation = ecore_animator_timeline_add(5, _animator, NULL); + + root = evas_object_vg_root_node_get(vg); + + circle = eo_add(EFL_VG_SHAPE_CLASS, root); + evas_vg_shape_shape_append_circle(circle, WIDTH / 2, HEIGHT / 2, 200); + evas_vg_node_color_set(circle, 255, 255, 255, 255); + evas_vg_shape_stroke_color_set(circle, 0, 0, 0, 0); + + batman = eo_add(EFL_VG_SHAPE_CLASS, root); + evas_vg_node_origin_set(batman, 100, 150); + evas_vg_node_color_set(batman, 0, 0, 0, 255); + evas_vg_shape_stroke_color_set(batman, 0, 0, 0, 0); + evas_vg_shape_shape_append_move_to(batman, 256, 213); + evas_vg_shape_shape_dup(batman, batmans_vg[0]); + + ecore_main_loop_begin(); + + ecore_evas_shutdown(); + return 0; +} From 9f88fd068cb28d4cb0643a63f60d4ffebed22010 Mon Sep 17 00:00:00 2001 From: Subhransu Sekhar Mohanty Date: Fri, 3 Apr 2015 16:33:44 +0200 Subject: [PATCH 191/251] ector: add handling of EFL_GFX_PATH_CHANGED signal to Freetype backend. Signed-off-by: Cedric BAIL --- .../software/ector_renderer_software_shape.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/lib/ector/software/ector_renderer_software_shape.c b/src/lib/ector/software/ector_renderer_software_shape.c index 8793c527cf..b8090917a9 100644 --- a/src/lib/ector/software/ector_renderer_software_shape.c +++ b/src/lib/ector/software/ector_renderer_software_shape.c @@ -347,12 +347,29 @@ _ector_renderer_software_shape_efl_gfx_shape_path_set(Eo *obj, Ector_Renderer_So } +static Eina_Bool +_ector_renderer_software_shape_path_changed(void *data, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, + void *event_info EINA_UNUSED) +{ + Ector_Renderer_Software_Shape_Data *pd = data; + + if(pd->shape_data) ector_software_rasterizer_destroy_rle_data(pd->shape_data); + if(pd->outline_data) ector_software_rasterizer_destroy_rle_data(pd->outline_data); + + pd->shape_data = NULL; + pd->outline_data = NULL; + + return EINA_TRUE; +} + void _ector_renderer_software_shape_eo_base_constructor(Eo *obj, Ector_Renderer_Software_Shape_Data *pd) { eo_do_super(obj, ECTOR_RENDERER_SOFTWARE_SHAPE_CLASS, eo_constructor()); pd->shape = eo_data_xref(obj, ECTOR_RENDERER_GENERIC_SHAPE_MIXIN, obj); pd->base = eo_data_xref(obj, ECTOR_RENDERER_GENERIC_BASE_CLASS, obj); + eo_do(obj, + eo_event_callback_add(EFL_GFX_PATH_CHANGED, _ector_renderer_software_shape_path_changed, pd)); } void From ae3df1d225d6f4ea073ee6356fed890a3da9b8a7 Mon Sep 17 00:00:00 2001 From: Subhransu Sekhar Mohanty Date: Fri, 3 Apr 2015 16:33:46 +0200 Subject: [PATCH 192/251] evas: remove duplicated shape data and modified animation time in evas-vg-batman. Signed-off-by: Cedric BAIL --- src/examples/evas/evas-vg-batman.c | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/src/examples/evas/evas-vg-batman.c b/src/examples/evas/evas-vg-batman.c index dabefe6df9..1d1a5f373c 100644 --- a/src/examples/evas/evas-vg-batman.c +++ b/src/examples/evas/evas-vg-batman.c @@ -46,37 +46,21 @@ static Efl_VG **batmans_vg = NULL; static const char *batmans_path[] = { "M 256,213 C 245,181 206,187 234,262 147,181 169,71.2 233,18 220,56 235,81 283,88 285,78.7 286,69.3 288,60 289,61.3 290,62.7 291,64 291,64 297,63 300,63 303,63 309,64 309,64 310,62.7 311,61.3 312,60 314,69.3 315,78.7 317,88 365,82 380,56 367,18 431,71 453,181 366,262 394,187 356,181 344,213 328,185 309,184 300,284 291,184 272,185 256,213 Z", "M 212,220 C 197,171 156,153 123,221 109,157 120,109 159,63.6 190,114 234,115 254,89.8 260,82.3 268,69.6 270,60.3 273,66.5 275,71.6 280,75.6 286,79.5 294,79.8 300,79.8 306,79.8 314,79.5 320,75.6 325,71.6 327,66.5 330,60.3 332,69.6 340,82.3 346,89.8 366,115 410,114 441,63.6 480,109 491,157 477,221 444,153 403,171 388,220 366,188 316,200 300,248 284,200 234,188 212,220 Z", - "M 212,220 C 197,171 156,153 123,221 109,157 120,109 159,63.6 190,114 234,115 254,89.8 260,82.3 268,69.6 270,60.3 273,66.5 275,71.6 280,75.6 286,79.5 294,79.8 300,79.8 306,79.8 314,79.5 320,75.6 325,71.6 327,66.5 330,60.3 332,69.6 340,82.3 346,89.8 366,115 410,114 441,63.6 480,109 491,157 477,221 444,153 403,171 388,220 366,188 316,200 300,248 284,200 234,188 212,220 Z", - "M 213,222 C 219,150 165,139 130,183 125,123 171,73.8 247,51.6 205,78 236,108 280,102 281,90.3 282,79 286,68.2 287,72 288,75.8 289,79.7 293,79.7 296,79.7 300,79.7 304,79.7 307,79.7 311,79.7 312,75.8 313,72 314,68.2 318,79 319,90.3 320,102 364,108 395,78 353,51.6 429,73.8 475,123 470,183 435,139 381,150 387,222 364,176 315,172 300,248 285,172 236,176 213,222 Z", "M 213,222 C 219,150 165,139 130,183 125,123 171,73.8 247,51.6 205,78 236,108 280,102 281,90.3 282,79 286,68.2 287,72 288,75.8 289,79.7 293,79.7 296,79.7 300,79.7 304,79.7 307,79.7 311,79.7 312,75.8 313,72 314,68.2 318,79 319,90.3 320,102 364,108 395,78 353,51.6 429,73.8 475,123 470,183 435,139 381,150 387,222 364,176 315,172 300,248 285,172 236,176 213,222 Z", "M 218,231 C 191,238 165,252 140,266 144,209 156,153 193,93.7 218,106 249,105 280,102 282,90.3 284,78.6 289,67.8 290,71.6 291,75.8 292,79.7 292,79.7 297,79.7 300,79.7 303,79.7 308,79.7 308,79.7 309,75.8 310,71.6 311,67.8 316,78.6 318,90.3 320,102 351,105 382,106 407,93.7 444,153 456,209 460,266 435,252 409,238 382,231 355,224 328,223 300,223 272,223 245,224 218,231 Z", - "M 218,231 C 191,238 165,252 140,266 144,209 156,153 193,93.7 218,106 249,105 280,102 282,90.3 284,78.6 289,67.8 290,71.6 291,75.8 292,79.7 292,79.7 297,79.7 300,79.7 303,79.7 308,79.7 308,79.7 309,75.8 310,71.6 311,67.8 316,78.6 318,90.3 320,102 351,105 382,106 407,93.7 444,153 456,209 460,266 435,252 409,238 382,231 355,224 328,223 300,223 272,223 245,224 218,231 Z", - "M 258,243 C 220,201 221,220 253,281 154,243 150,108 229,61.9 242,83 257,98.1 275,110 278,88 282,65.8 285,43.6 287,49.9 288,56.2 290,62.5 293,62.7 297,62.9 300,62.9 303,62.9 307,62.7 310,62.5 312,56.2 313,49.9 315,43.6 318,65.8 322,88 325,110 343,98.1 358,83 371,61.9 450,108 446,243 347,281 379,220 380,201 342,243 330,187 329,202 300,271 271,202 270,187 258,243 Z", "M 258,243 C 220,201 221,220 253,281 154,243 150,108 229,61.9 242,83 257,98.1 275,110 278,88 282,65.8 285,43.6 287,49.9 288,56.2 290,62.5 293,62.7 297,62.9 300,62.9 303,62.9 307,62.7 310,62.5 312,56.2 313,49.9 315,43.6 318,65.8 322,88 325,110 343,98.1 358,83 371,61.9 450,108 446,243 347,281 379,220 380,201 342,243 330,187 329,202 300,271 271,202 270,187 258,243 Z", "M 235,210 C 214,139 143,145 183,229 108,175 135,70.1 242,48.3 190,85.6 245,142 278,95.5 281,80.2 281,62.7 284,48.7 287,53.9 287,59.1 289,64.5 292,64.7 297,64.2 300,64.2 303,64.2 308,64.7 311,64.5 313,59.1 313,53.9 316,48.7 319,62.7 319,80.2 322,95.5 355,142 410,85.6 358,48.3 465,70.1 492,175 417,229 457,145 386,139 365,210 357,147 309,190 300,271 291,190 243,147 235,210 Z", - "M 235,210 C 214,139 143,145 183,229 108,175 135,70.1 242,48.3 190,85.6 245,142 278,95.5 281,80.2 281,62.7 284,48.7 287,53.9 287,59.1 289,64.5 292,64.7 297,64.2 300,64.2 303,64.2 308,64.7 311,64.5 313,59.1 313,53.9 316,48.7 319,62.7 319,80.2 322,95.5 355,142 410,85.6 358,48.3 465,70.1 492,175 417,229 457,145 386,139 365,210 357,147 309,190 300,271 291,190 243,147 235,210 Z", - "M 249,157 C 214,157 201,203 273,255 157,221 157,69 274,32.8 188,87.2 211,140 256,140 291,140 289,128 291,98.1 293,107 293,116 295,125 297,125 298,125 300,125 302,125 305,125 305,125 307,116 307,107 309,98.1 311,128 309,140 344,140 389,140 412,87.2 326,32.8 443,69 443,221 327,255 399,203 386,157 351,157 317,157 300,195 300,238 300,195 283,157 249,157 Z", "M 249,157 C 214,157 201,203 273,255 157,221 157,69 274,32.8 188,87.2 211,140 256,140 291,140 289,128 291,98.1 293,107 293,116 295,125 297,125 298,125 300,125 302,125 305,125 305,125 307,116 307,107 309,98.1 311,128 309,140 344,140 389,140 412,87.2 326,32.8 443,69 443,221 327,255 399,203 386,157 351,157 317,157 300,195 300,238 300,195 283,157 249,157 Z", "M 264,212 C 213,138 150,171 232,244 101,217 112,55.1 257,36.9 182,86.6 222,106 266,106 285,106 284,66.7 286,36.8 288,42.6 289,48.4 291,54.2 291,54.2 297,54.2 300,54.2 303,54.2 309,54.2 309,54.2 311,48.4 312,42.6 314,36.8 316,66.7 315,106 334,106 378,106 418,86.6 343,36.9 488,55.1 499,217 368,244 450,171 387,138 336,212 354,161 300,163 300,249 300,163 246,161 264,212 Z", - "M 264,212 C 213,138 150,171 232,244 101,217 112,55.1 257,36.9 182,86.6 222,106 266,106 285,106 284,66.7 286,36.8 288,42.6 289,48.4 291,54.2 291,54.2 297,54.2 300,54.2 303,54.2 309,54.2 309,54.2 311,48.4 312,42.6 314,36.8 316,66.7 315,106 334,106 378,106 418,86.6 343,36.9 488,55.1 499,217 368,244 450,171 387,138 336,212 354,161 300,163 300,249 300,163 246,161 264,212 Z", - "M 223,217 C 194,153 165,168 133,219 143,158 161,99.2 189,38.4 214,69.8 241,84.7 272,86.2 272,70.2 273,53.5 273,37.5 275,47.9 278,58.4 280,68.8 287,64.9 292,62.4 300,62.4 308,62.4 313,64.9 320,68.8 322,58.4 325,47.9 327,37.5 327,53.5 328,70.2 328,86.2 359,84.7 386,69.8 411,38.4 439,99.2 457,158 467,219 435,168 406,153 377,217 350,162 319,176 300,245 281,176 250,162 223,217 Z", "M 223,217 C 194,153 165,168 133,219 143,158 161,99.2 189,38.4 214,69.8 241,84.7 272,86.2 272,70.2 273,53.5 273,37.5 275,47.9 278,58.4 280,68.8 287,64.9 292,62.4 300,62.4 308,62.4 313,64.9 320,68.8 322,58.4 325,47.9 327,37.5 327,53.5 328,70.2 328,86.2 359,84.7 386,69.8 411,38.4 439,99.2 457,158 467,219 435,168 406,153 377,217 350,162 319,176 300,245 281,176 250,162 223,217 Z", "M 231,185 C 186,159 161,180 190,215 86.2,180 92.6,99.6 211,68.9 195,112 254,141 279,96.7 279,83.2 279,69.8 279,56.3 283,63.6 288,70.8 292,78.1 295,78.1 297,78.1 300,78.1 303,78.1 305,78.1 308,78.1 312,70.8 317,63.6 321,56.3 321,69.8 321,83.2 321,96.7 346,141 405,112 389,68.9 507,99.6 514,180 410,215 439,180 414,159 369,185 351,165 324,167 300,216 276,167 249,165 231,185 Z", - "M 231,185 C 186,159 161,180 190,215 86.2,180 92.6,99.6 211,68.9 195,112 254,141 279,96.7 279,83.2 279,69.8 279,56.3 283,63.6 288,70.8 292,78.1 295,78.1 297,78.1 300,78.1 303,78.1 305,78.1 308,78.1 312,70.8 317,63.6 321,56.3 321,69.8 321,83.2 321,96.7 346,141 405,112 389,68.9 507,99.6 514,180 410,215 439,180 414,159 369,185 351,165 324,167 300,216 276,167 249,165 231,185 Z", - "M 194,146 C 192,107 164,76.4 136,45.6 166,55.7 196,65.7 226,75.8 238,107 265,163 279,136 282,130 281,108 281,94.8 285,103 288,111 293,115 295,116 298,117 300,117 302,117 305,116 307,115 312,111 315,103 319,94.8 319,108 318,130 321,136 335,163 362,107 374,75.8 404,65.7 434,55.7 464,45.6 436,76.4 408,107 406,146 355,158 323,189 300,231 277,189 245,158 194,146 Z", "M 194,146 C 192,107 164,76.4 136,45.6 166,55.7 196,65.7 226,75.8 238,107 265,163 279,136 282,130 281,108 281,94.8 285,103 288,111 293,115 295,116 298,117 300,117 302,117 305,116 307,115 312,111 315,103 319,94.8 319,108 318,130 321,136 335,163 362,107 374,75.8 404,65.7 434,55.7 464,45.6 436,76.4 408,107 406,146 355,158 323,189 300,231 277,189 245,158 194,146 Z", "M 209,182 C 184,132 176,138 113,161 140,136 168,111 196,86.5 221,104 247,115 278,115 281,99.9 285,85.5 287,70.2 289,78.5 292,88.4 294,96.7 296,96.7 298,96.7 300,96.7 302,96.7 304,96.7 306,96.7 308,88.4 311,78.5 313,70.2 315,85.5 319,99.9 322,115 353,115 379,104 404,86.5 432,111 460,136 487,161 424,138 416,132 391,182 332,150 341,161 300,214 259,161 268,150 209,182 Z", - "M 209,182 C 184,132 176,138 113,161 140,136 168,111 196,86.5 221,104 247,115 278,115 281,99.9 285,85.5 287,70.2 289,78.5 292,88.4 294,96.7 296,96.7 298,96.7 300,96.7 302,96.7 304,96.7 306,96.7 308,88.4 311,78.5 313,70.2 315,85.5 319,99.9 322,115 353,115 379,104 404,86.5 432,111 460,136 487,161 424,138 416,132 391,182 332,150 341,161 300,214 259,161 268,150 209,182 Z", - "M 198,171 C 189,131 150,120 113,140 142,104 182,74.4 249,70.2 208,89 248,125 278,106 285,101 286,93.5 286,74.2 288,78.1 291,81.5 294,83.2 296,84.2 298,84.7 300,84.7 302,84.7 304,84.2 306,83.2 309,81.5 312,78.1 314,74.2 314,93.5 315,101 322,106 352,125 392,89 351,70.2 418,74.4 458,104 487,140 450,120 411,131 402,171 357,147 322,171 300,214 278,171 243,147 198,171 Z", "M 198,171 C 189,131 150,120 113,140 142,104 182,74.4 249,70.2 208,89 248,125 278,106 285,101 286,93.5 286,74.2 288,78.1 291,81.5 294,83.2 296,84.2 298,84.7 300,84.7 302,84.7 304,84.2 306,83.2 309,81.5 312,78.1 314,74.2 314,93.5 315,101 322,106 352,125 392,89 351,70.2 418,74.4 458,104 487,140 450,120 411,131 402,171 357,147 322,171 300,214 278,171 243,147 198,171 Z", "M 202,170 C 188,115 157,108 124,105 146,84.3 171,71.5 199,70.2 211,98.6 243,103 277,106 279,99.3 281,92.6 283,86 285,91.9 287,97.9 290,104 293,104 297,104 300,104 303,104 307,104 310,104 313,97.9 315,91.9 317,86 319,92.6 321,99.3 323,106 357,103 389,98.6 401,70.2 429,71.5 454,84.3 476,105 443,108 412,115 398,170 349,157 318,175 300,214 282,175 251,157 202,170 Z", - "M 202,170 C 188,115 157,108 124,105 146,84.3 171,71.5 199,70.2 211,98.6 243,103 277,106 279,99.3 281,92.6 283,86 285,91.9 287,97.9 290,104 293,104 297,104 300,104 303,104 307,104 310,104 313,97.9 315,91.9 317,86 319,92.6 321,99.3 323,106 357,103 389,98.6 401,70.2 429,71.5 454,84.3 476,105 443,108 412,115 398,170 349,157 318,175 300,214 282,175 251,157 202,170 Z", - "M 220,179 C 200,127 150,130 123,175 122,110 160,85.1 201,64 208,99.2 243,111 268,92.9 278,86.1 284,68.2 287,40.7 289,49.6 292,58.4 294,67.3 296,67.3 298,67.3 300,67.3 302,67.3 304,67.3 306,67.3 308,58.4 311,49.6 313,40.7 316,68.2 322,86.1 332,92.9 357,111 392,99.3 399,64 440,85.1 478,110 477,175 450,130 400,127 380,179 355,155 305,208 300,247 295,208 245,155 220,179 Z", "M 220,179 C 200,127 150,130 123,175 122,110 160,85.1 201,64 208,99.2 243,111 268,92.9 278,86.1 284,68.2 287,40.7 289,49.6 292,58.4 294,67.3 296,67.3 298,67.3 300,67.3 302,67.3 304,67.3 306,67.3 308,58.4 311,49.6 313,40.7 316,68.2 322,86.1 332,92.9 357,111 392,99.3 399,64 440,85.1 478,110 477,175 450,130 400,127 380,179 355,155 305,208 300,247 295,208 245,155 220,179 Z", "M 166,154 C 179,119 154,95.4 114,79.3 155,79.1 197,78.9 239,78.7 242,103 250,109 283,109 289,109 290,93.9 291,83.7 292,88.3 292,92.9 293,97.5 295,97.5 298,97.5 300,97.5 302,97.5 305,97.5 307,97.5 308,92.9 308,88.3 309,83.7 310,93.9 311,109 317,109 350,109 358,103 361,78.7 403,78.9 445,79.1 486,79.3 446,95.4 421,119 434,154 377,151 320,151 300,207 280,151 223,151 166,154 Z", - "M 166,154 C 179,119 154,95.4 114,79.3 155,79.1 197,78.9 239,78.7 242,103 250,109 283,109 289,109 290,93.9 291,83.7 292,88.3 292,92.9 293,97.5 295,97.5 298,97.5 300,97.5 302,97.5 305,97.5 307,97.5 308,92.9 308,88.3 309,83.7 310,93.9 311,109 317,109 350,109 358,103 361,78.7 403,78.9 445,79.1 486,79.3 446,95.4 421,119 434,154 377,151 320,151 300,207 280,151 223,151 166,154 Z", - "M 256,213 C 245,181 206,187 234,262 147,181 169,71.2 233,18 220,56 235,81 283,88 285,78.7 286,69.3 288,60 289,61.3 290,62.7 291,64 291,64 297,63 300,63 303,63 309,64 309,64 310,62.7 311,61.3 312,60 314,69.3 315,78.7 317,88 365,82 380,56 367,18 431,71 453,181 366,262 394,187 356,181 344,213 328,185 309,184 300,284 291,184 272,185 256,213 Z", - "M 256,213 C 245,181 206,187 234,262 147,181 169,71.2 233,18 220,56 235,81 283,88 285,78.7 286,69.3 288,60 289,61.3 290,62.7 291,64 291,64 297,63 300,63 303,63 309,64 309,64 310,62.7 311,61.3 312,60 314,69.3 315,78.7 317,88 365,82 380,56 367,18 431,71 453,181 366,262 394,187 356,181 344,213 328,185 309,184 300,284 291,184 272,185 256,213 Z" + "M 166,154 C 179,119 154,95.4 114,79.3 155,79.1 197,78.9 239,78.7 242,103 250,109 283,109 289,109 290,93.9 291,83.7 292,88.3 292,92.9 293,97.5 295,97.5 298,97.5 300,97.5 302,97.5 305,97.5 307,97.5 308,92.9 308,88.3 309,83.7 310,93.9 311,109 317,109 350,109 358,103 361,78.7 403,78.9 445,79.1 486,79.3 446,95.4 421,119 434,154 377,151 320,151 300,207 280,151 223,151 166,154 Z" }; static void @@ -101,14 +85,14 @@ _animator(void *data EINA_UNUSED, double pos) int next = (animation_position + 1) % (sizeof (batmans_path) / sizeof (batmans_path[0])); evas_vg_shape_shape_interpolate(batman, + batmans_vg[next], batmans_vg[animation_position], - batmans_vg[next], ecore_animator_pos_map(pos, ECORE_POS_MAP_SINUSOIDAL, 0.0, 0.0)); if (pos == 1.0) { animation_position = next; - animation = ecore_animator_timeline_add(5, _animator, NULL); + animation = ecore_animator_timeline_add(1, _animator, NULL); } return EINA_TRUE; @@ -153,7 +137,7 @@ main(void) evas_vg_shape_shape_append_svg_path(batmans_vg[i], batmans_path[i]); } - animation = ecore_animator_timeline_add(5, _animator, NULL); + animation = ecore_animator_timeline_add(1, _animator, NULL); root = evas_object_vg_root_node_get(vg); From 5e5b3750c79b67878c5c13344d2769186eb3fda2 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:33:48 +0200 Subject: [PATCH 193/251] ector: add warning if library is not found. We use the system configuration to find it. So if it doesn't find it, adjust your system. --- src/lib/ector/cairo/ector_cairo_surface.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/lib/ector/cairo/ector_cairo_surface.c b/src/lib/ector/cairo/ector_cairo_surface.c index 8e7b1043f6..8875c04ce7 100644 --- a/src/lib/ector/cairo/ector_cairo_surface.c +++ b/src/lib/ector/cairo/ector_cairo_surface.c @@ -42,6 +42,12 @@ _ector_cairo_surface_symbol_get(Eo *obj EINA_UNUSED, #undef LOAD } + if (!_cairo_so) + { + ERR("Couldn't find cairo library. Please make sure that your system can locate it."); + return NULL; + } + return eina_module_symbol_get(_cairo_so, name); } From 1d0ce5bc05fb6658f2ede82c20f62687a4dc8d3e Mon Sep 17 00:00:00 2001 From: Subhransu Sekhar Mohanty Date: Fri, 3 Apr 2015 16:33:49 +0200 Subject: [PATCH 194/251] ector: fix ector_color_multiply() function --- src/lib/ector/ector_util.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/ector/ector_util.h b/src/lib/ector/ector_util.h index 664fdb2b6d..af8b5917d5 100644 --- a/src/lib/ector/ector_util.h +++ b/src/lib/ector/ector_util.h @@ -6,7 +6,7 @@ ector_color_multiply(unsigned int c1, unsigned int c2) { return ( ((((((c1) >> 16) & 0xff00) * (((c2) >> 16) & 0xff00)) + 0xff0000) & 0xff000000) + ((((((c1) >> 8) & 0xff00) * (((c2) >> 16) & 0xff)) + 0xff00) & 0xff0000) + - ((((((c1) & 0xff00) * ((c2) & 0xff00)) + 0xff00) >> 16) & 0xff00) + + ((((((c1) & 0xff00) * ((c2) & 0xff00)) + 0xff0000) >> 16) & 0xff00) + (((((c1) & 0xff) * ((c2) & 0xff)) + 0xff) >> 8) ); } From 0ec75ca05f23fc586ca3372fa3f87ef3cf2412a0 Mon Sep 17 00:00:00 2001 From: Subhransu Sekhar Mohanty Date: Fri, 3 Apr 2015 16:33:50 +0200 Subject: [PATCH 195/251] ector: fix coding style of freetype backend. --- .../ector_renderer_software_gradient_radial.c | 52 ++++----- .../software/ector_renderer_software_shape.c | 16 +-- .../ector/software/ector_software_gradient.c | 28 ++--- .../ector/software/ector_software_private.h | 10 +- .../software/ector_software_rasterizer.c | 108 +++++++++--------- .../ector/software/ector_software_surface.c | 12 +- 6 files changed, 113 insertions(+), 113 deletions(-) diff --git a/src/lib/ector/software/ector_renderer_software_gradient_radial.c b/src/lib/ector/software/ector_renderer_software_gradient_radial.c index 41d24cbf11..a05b4874f4 100644 --- a/src/lib/ector/software/ector_renderer_software_gradient_radial.c +++ b/src/lib/ector/software/ector_renderer_software_gradient_radial.c @@ -12,36 +12,36 @@ static void _update_radial_data(Ector_Renderer_Software_Gradient_Data *gdata) { - update_color_table(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; + 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.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; + 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.fradius = 0; - gdata->radial.dx = gdata->radial.cx - gdata->radial.fx; - gdata->radial.dy = gdata->radial.cy - gdata->radial.fy; + 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.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.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; + gdata->radial.extended = (gdata->radial.fradius >= 0.00001f) || gdata->radial.a >= 0.00001f; } @@ -64,9 +64,9 @@ _ector_renderer_software_gradient_radial_ector_renderer_generic_base_prepare(Eo // Clearly duplicated and should be in a common place... static Eina_Bool _ector_renderer_software_gradient_radial_ector_renderer_generic_base_draw(Eo *obj EINA_UNUSED, - Ector_Renderer_Software_Gradient_Data *pd EINA_UNUSED, - Ector_Rop op EINA_UNUSED, Eina_Array *clips EINA_UNUSED, - unsigned int mul_col EINA_UNUSED) + Ector_Renderer_Software_Gradient_Data *pd EINA_UNUSED, + Ector_Rop op EINA_UNUSED, Eina_Array *clips EINA_UNUSED, + unsigned int mul_col EINA_UNUSED) { return EINA_TRUE; } @@ -75,7 +75,7 @@ _ector_renderer_software_gradient_radial_ector_renderer_generic_base_draw(Eo *ob static Eina_Bool _ector_renderer_software_gradient_radial_ector_renderer_software_base_fill(Eo *obj EINA_UNUSED, Ector_Renderer_Software_Gradient_Data *pd) { - ector_software_rasterizer_radial_gradient_set(pd->surface->software, pd); + ector_software_rasterizer_radial_gradient_set(pd->surface->software, pd); return EINA_TRUE; } diff --git a/src/lib/ector/software/ector_renderer_software_shape.c b/src/lib/ector/software/ector_renderer_software_shape.c index b8090917a9..2e4fbea5aa 100644 --- a/src/lib/ector/software/ector_renderer_software_shape.c +++ b/src/lib/ector/software/ector_renderer_software_shape.c @@ -176,7 +176,7 @@ static void _outline_transform(Outline *outline, Eina_Matrix3 *m) if (m) { double x, y; - for (i = 0; i < ft_outline->n_points ; i++) + for (i = 0; i < ft_outline->n_points; i++) { eina_matrix3_point_transform(m, ft_outline->points[i].x, ft_outline->points[i].y, &x, &y); ft_outline->points[i].x = (int)(x * 64);// to freetype 26.6 coordinate. @@ -185,7 +185,7 @@ static void _outline_transform(Outline *outline, Eina_Matrix3 *m) } else { - for (i = 0; i < ft_outline->n_points ; i++) + for (i = 0; i < ft_outline->n_points; i++) { ft_outline->points[i].x = ft_outline->points[i].x <<6;// to freetype 26.6 coordinate. ft_outline->points[i].y = ft_outline->points[i].y <<6; @@ -338,8 +338,8 @@ static void _ector_renderer_software_shape_efl_gfx_shape_path_set(Eo *obj, Ector_Renderer_Software_Shape_Data *pd, const Efl_Gfx_Path_Command *op, const double *points) { - if(pd->shape_data) ector_software_rasterizer_destroy_rle_data(pd->shape_data); - if(pd->outline_data) ector_software_rasterizer_destroy_rle_data(pd->outline_data); + if (pd->shape_data) ector_software_rasterizer_destroy_rle_data(pd->shape_data); + if (pd->outline_data) ector_software_rasterizer_destroy_rle_data(pd->outline_data); pd->shape_data = NULL; pd->outline_data = NULL; @@ -353,8 +353,8 @@ _ector_renderer_software_shape_path_changed(void *data, Eo *obj EINA_UNUSED, con { Ector_Renderer_Software_Shape_Data *pd = data; - if(pd->shape_data) ector_software_rasterizer_destroy_rle_data(pd->shape_data); - if(pd->outline_data) ector_software_rasterizer_destroy_rle_data(pd->outline_data); + if (pd->shape_data) ector_software_rasterizer_destroy_rle_data(pd->shape_data); + if (pd->outline_data) ector_software_rasterizer_destroy_rle_data(pd->outline_data); pd->shape_data = NULL; pd->outline_data = NULL; @@ -377,8 +377,8 @@ _ector_renderer_software_shape_eo_base_destructor(Eo *obj, Ector_Renderer_Softwa { Eo *parent; - if(pd->shape_data) ector_software_rasterizer_destroy_rle_data(pd->shape_data); - if(pd->outline_data) ector_software_rasterizer_destroy_rle_data(pd->outline_data); + if (pd->shape_data) ector_software_rasterizer_destroy_rle_data(pd->shape_data); + if (pd->outline_data) ector_software_rasterizer_destroy_rle_data(pd->outline_data); eo_do(obj, parent = eo_parent_get()); eo_data_xunref(parent, pd->surface, obj); diff --git a/src/lib/ector/software/ector_software_gradient.c b/src/lib/ector/software/ector_software_gradient.c index fd842dd4cd..5c3bcde3b4 100644 --- a/src/lib/ector/software/ector_software_gradient.c +++ b/src/lib/ector/software/ector_software_gradient.c @@ -53,14 +53,14 @@ static uint _gradient_pixel_fixed(const Ector_Renderer_Software_Gradient_Data *data, int fixed_pos) { int ipos = (fixed_pos + (FIXPT_SIZE / 2)) >> FIXPT_BITS; - return data->colorTable[_gradient_clamp(data, ipos)]; + return data->color_table[_gradient_clamp(data, ipos)]; } static inline uint _gradient_pixel(const Ector_Renderer_Software_Gradient_Data *data, float pos) { int ipos = (int)(pos * (GRADIENT_STOPTABLE_SIZE - 1) + (float)(0.5)); - return data->colorTable[_gradient_clamp(data, ipos)]; + return data->color_table[_gradient_clamp(data, ipos)]; } typedef double (*BLEND_FUNC)(double progress); @@ -72,7 +72,7 @@ _ease_linear(double t) } static void -_generate_gradient_color_table(Efl_Gfx_Gradient_Stop *gradient_stops, int stop_count, uint *colorTable, int size) +_generate_gradient_color_table(Efl_Gfx_Gradient_Stop *gradient_stops, int stop_count, uint *color_table, int size) { int pos = 0; Efl_Gfx_Gradient_Stop *curr, *next; @@ -83,11 +83,11 @@ _generate_gradient_color_table(Efl_Gfx_Gradient_Stop *gradient_stops, int stop_c double incr = 1.0 / (double)size; double fpos = 1.5 * incr; - colorTable[pos++] = current_color; + color_table[pos++] = current_color; while (fpos <= curr->offset) { - colorTable[pos] = colorTable[pos - 1]; + color_table[pos] = color_table[pos - 1]; pos++; fpos += incr; } @@ -104,7 +104,7 @@ _generate_gradient_color_table(Efl_Gfx_Gradient_Stop *gradient_stops, int stop_c double t = func((fpos - curr->offset) * delta); int dist = (int)(256 * t); int idist = 256 - dist; - colorTable[pos] = INTERPOLATE_PIXEL_256(current_color, idist, next_color, dist); + color_table[pos] = INTERPOLATE_PIXEL_256(current_color, idist, next_color, dist); ++pos; fpos += incr; } @@ -112,29 +112,29 @@ _generate_gradient_color_table(Efl_Gfx_Gradient_Stop *gradient_stops, int stop_c } for (;pos < size; ++pos) - colorTable[pos] = current_color; + color_table[pos] = current_color; // Make sure the last color stop is represented at the end of the table - colorTable[size-1] = current_color; + color_table[size-1] = current_color; } void update_color_table(Ector_Renderer_Software_Gradient_Data *gdata) { - if(gdata->colorTable) return; + if(gdata->color_table) return; - gdata->colorTable = malloc(GRADIENT_STOPTABLE_SIZE * 4); - _generate_gradient_color_table(gdata->gd->colors, gdata->gd->colors_count, gdata->colorTable, GRADIENT_STOPTABLE_SIZE); + gdata->color_table = malloc(GRADIENT_STOPTABLE_SIZE * 4); + _generate_gradient_color_table(gdata->gd->colors, gdata->gd->colors_count, gdata->color_table, GRADIENT_STOPTABLE_SIZE); } void destroy_color_table(Ector_Renderer_Software_Gradient_Data *gdata) { - if (gdata->colorTable) + if (gdata->color_table) { - free(gdata->colorTable); - gdata->colorTable = NULL; + free(gdata->color_table); + gdata->color_table = NULL; } } diff --git a/src/lib/ector/software/ector_software_private.h b/src/lib/ector/software/ector_software_private.h index bf2adf6998..2e1ca1ce8a 100644 --- a/src/lib/ector/software/ector_software_private.h +++ b/src/lib/ector/software/ector_software_private.h @@ -42,7 +42,7 @@ typedef struct _Ector_Renderer_Software_Gradient_Data Software_Gradient_Linear_Data linear; Software_Gradient_Radial_Data radial; }; - uint* colorTable; + uint* color_table; } Ector_Renderer_Software_Gradient_Data; @@ -66,8 +66,8 @@ typedef struct _Clip_Data Eina_Array *clips; //Eina_Rectangle Shape_Rle_Data *path; unsigned int enabled : 1; - unsigned int hasRectClip : 1; - unsigned int hasPathClip : 1; + unsigned int has_rect_clip : 1; + unsigned int has_path_clip : 1; } Clip_Data; @@ -105,9 +105,9 @@ typedef struct _Software_Rasterizer SW_FT_Raster raster; SW_FT_Stroker stroker; - Span_Data fillData; + Span_Data fill_data; Eina_Matrix3 *transform; - Eina_Rectangle systemClip; + Eina_Rectangle system_clip; } Software_Rasterizer; diff --git a/src/lib/ector/software/ector_software_rasterizer.c b/src/lib/ector/software/ector_software_rasterizer.c index a0c5b3f151..71eaa1f688 100644 --- a/src/lib/ector/software/ector_software_rasterizer.c +++ b/src/lib/ector/software/ector_software_rasterizer.c @@ -11,18 +11,18 @@ #include "ector_blend_private.h" static void -_blend_color_argb(int count, const SW_FT_Span *spans, void *userData) +_blend_color_argb(int count, const SW_FT_Span *spans, void *user_data) { - Span_Data *data = (Span_Data *)(userData); + Span_Data *data = (Span_Data *)(user_data); // multiply the color with mul_col if any uint color = ECTOR_MUL4_SYM(data->color, data->mul_col); - Eina_Bool solidSource = ((color >> 24) == 255); + Eina_Bool solid_source = ((color >> 24) == 255); // move to the offset location uint *buffer = data->raster_buffer.buffer + (data->raster_buffer.width * data->offy + data->offx); - if (solidSource) + if (solid_source) { while (count--) { @@ -60,9 +60,9 @@ int buffer_size = 2048; typedef void (*src_fetch) (unsigned int *buffer, Span_Data *data, int y, int x, int length); static void -_blend_gradient(int count, const SW_FT_Span *spans, void *userData) +_blend_gradient(int count, const SW_FT_Span *spans, void *user_data) { - Span_Data *data = (Span_Data *)(userData); + Span_Data *data = (Span_Data *)(user_data); src_fetch fetchfunc = NULL; if(data->type == LinearGradient) fetchfunc = &fetch_linear_gradient; @@ -99,9 +99,9 @@ _blend_gradient(int count, const SW_FT_Span *spans, void *userData) */ static const SW_FT_Span *_intersect_spans_rect(const Eina_Rectangle *clip, const SW_FT_Span *spans, const SW_FT_Span *end, - SW_FT_Span **outSpans, int available) + SW_FT_Span **out_spans, int available) { - SW_FT_Span *out = *outSpans; + SW_FT_Span *out = *out_spans; const short minx = clip->x; const short miny = clip->y; const short maxx = minx + clip->w - 1; @@ -142,7 +142,7 @@ SW_FT_Span *_intersect_spans_rect(const Eina_Rectangle *clip, const SW_FT_Span * --available; } - *outSpans = out; + *out_spans = out; return spans; } @@ -153,9 +153,9 @@ _div_255(int x) { return (x + (x>>8) + 0x80) >> 8; } static const SW_FT_Span *_intersect_spans_region(const Shape_Rle_Data *clip, int *currentClip, const SW_FT_Span *spans, const SW_FT_Span *end, - SW_FT_Span **outSpans, int available) + SW_FT_Span **out_spans, int available) { - SW_FT_Span *out = *outSpans; + SW_FT_Span *out = *out_spans; const SW_FT_Span *clipSpans = clip->spans + *currentClip; const SW_FT_Span *clipEnd = clip->spans + clip->size; @@ -204,19 +204,19 @@ SW_FT_Span *_intersect_spans_region(const Shape_Rle_Data *clip, int *currentClip } } - *outSpans = out; + *out_spans = out; *currentClip = clipSpans - clip->spans; return spans; } static void -_span_fill_clipRect(int spanCount, const SW_FT_Span *spans, void *userData) +_span_fill_clipRect(int span_count, const SW_FT_Span *spans, void *user_data) { const int NSPANS = 256; int clip_count, i; SW_FT_Span cspans[NSPANS]; - Span_Data *fillData = (Span_Data *) userData; - Clip_Data clip = fillData->clip; + Span_Data *fill_data = (Span_Data *) user_data; + Clip_Data clip = fill_data->clip; clip_count = eina_array_count(clip.clips); for (i = 0; i < clip_count ; i ++) @@ -225,40 +225,40 @@ _span_fill_clipRect(int spanCount, const SW_FT_Span *spans, void *userData) Eina_Rectangle tmpRect; // invert transform the offset - tmpRect.x = rect->x - fillData->offx; - tmpRect.y = rect->y - fillData->offy; + tmpRect.x = rect->x - fill_data->offx; + tmpRect.y = rect->y - fill_data->offy; tmpRect.w = rect->w; tmpRect.h = rect->h; - const SW_FT_Span *end = spans + spanCount; + const SW_FT_Span *end = spans + span_count; while (spans < end) { SW_FT_Span *clipped = cspans; spans = _intersect_spans_rect(&tmpRect,spans, end, &clipped, NSPANS); if (clipped - cspans) - fillData->unclipped_blend(clipped - cspans, cspans, fillData); + fill_data->unclipped_blend(clipped - cspans, cspans, fill_data); } } } static void -_span_fill_clipPath(int spanCount, const SW_FT_Span *spans, void *userData) +_span_fill_clipPath(int span_count, const SW_FT_Span *spans, void *user_data) { const int NSPANS = 256; int current_clip = 0; SW_FT_Span cspans[NSPANS]; - Span_Data *fillData = (Span_Data *) userData; - Clip_Data clip = fillData->clip; + Span_Data *fill_data = (Span_Data *) user_data; + Clip_Data clip = fill_data->clip; //TODO take clip path offset into account. - const SW_FT_Span *end = spans + spanCount; + const SW_FT_Span *end = spans + span_count; while (spans < end) { SW_FT_Span *clipped = cspans; spans = _intersect_spans_region(clip.path, ¤t_clip, spans, end, &clipped, NSPANS); if (clipped - cspans) - fillData->unclipped_blend(clipped - cspans, cspans, fillData); + fill_data->unclipped_blend(clipped - cspans, cspans, fill_data); } } @@ -291,7 +291,7 @@ _adjust_span_fill_methods(Span_Data *spdata) { spdata->blend = spdata->unclipped_blend; } - else if (spdata->clip.hasRectClip) + else if (spdata->clip.has_rect_clip) { spdata->blend = &_span_fill_clipRect; } @@ -314,10 +314,10 @@ void ector_software_rasterizer_init(Software_Rasterizer *rasterizer) SW_FT_Stroker_Set(rasterizer->stroker, 1<<6,SW_FT_STROKER_LINECAP_BUTT,SW_FT_STROKER_LINEJOIN_MITER,0); //initialize the span data. - rasterizer->fillData.raster_buffer.buffer = NULL; - rasterizer->fillData.clip.enabled = EINA_FALSE; - rasterizer->fillData.unclipped_blend = 0; - rasterizer->fillData.blend = 0; + rasterizer->fill_data.raster_buffer.buffer = NULL; + rasterizer->fill_data.clip.enabled = EINA_FALSE; + rasterizer->fill_data.unclipped_blend = 0; + rasterizer->fill_data.blend = 0; } void ector_software_rasterizer_done(Software_Rasterizer *rasterizer) @@ -443,12 +443,12 @@ void _setup_span_fill_matrix(Software_Rasterizer *rasterizer) { if (rasterizer->transform) { - eina_matrix3_inverse(rasterizer->transform, &rasterizer->fillData.inv); + eina_matrix3_inverse(rasterizer->transform, &rasterizer->fill_data.inv); } else { - eina_matrix3_identity(&rasterizer->fillData.inv); - eina_matrix3_identity(&rasterizer->fillData.inv); + eina_matrix3_identity(&rasterizer->fill_data.inv); + eina_matrix3_identity(&rasterizer->fill_data.inv); } } @@ -461,39 +461,39 @@ void ector_software_rasterizer_clip_rect_set(Software_Rasterizer *rasterizer, Ei { if (clips) { - rasterizer->fillData.clip.clips = clips; - rasterizer->fillData.clip.hasRectClip = EINA_TRUE; - rasterizer->fillData.clip.enabled = EINA_TRUE; + rasterizer->fill_data.clip.clips = clips; + rasterizer->fill_data.clip.has_rect_clip = EINA_TRUE; + rasterizer->fill_data.clip.enabled = EINA_TRUE; } else { - rasterizer->fillData.clip.clips = NULL; - rasterizer->fillData.clip.hasRectClip = EINA_FALSE; - rasterizer->fillData.clip.enabled = EINA_FALSE; + rasterizer->fill_data.clip.clips = NULL; + rasterizer->fill_data.clip.has_rect_clip = EINA_FALSE; + rasterizer->fill_data.clip.enabled = EINA_FALSE; } } void ector_software_rasterizer_clip_shape_set(Software_Rasterizer *rasterizer, Shape_Rle_Data *clip) { - rasterizer->fillData.clip.path = clip; - rasterizer->fillData.clip.hasPathClip = EINA_TRUE; - rasterizer->fillData.clip.enabled = EINA_TRUE; + rasterizer->fill_data.clip.path = clip; + rasterizer->fill_data.clip.has_path_clip = EINA_TRUE; + rasterizer->fill_data.clip.enabled = EINA_TRUE; } void ector_software_rasterizer_color_set(Software_Rasterizer *rasterizer, int r, int g, int b, int a) { - rasterizer->fillData.color = ECTOR_ARGB_JOIN(a, r, g, b); - rasterizer->fillData.type = Solid; + rasterizer->fill_data.color = ECTOR_ARGB_JOIN(a, r, g, b); + rasterizer->fill_data.type = Solid; } void ector_software_rasterizer_linear_gradient_set(Software_Rasterizer *rasterizer, Ector_Renderer_Software_Gradient_Data *linear) { - rasterizer->fillData.gradient = linear; - rasterizer->fillData.type = LinearGradient; + rasterizer->fill_data.gradient = linear; + rasterizer->fill_data.type = LinearGradient; } void ector_software_rasterizer_radial_gradient_set(Software_Rasterizer *rasterizer, Ector_Renderer_Software_Gradient_Data *radial) { - rasterizer->fillData.gradient = radial; - rasterizer->fillData.type = RadialGradient; + rasterizer->fill_data.gradient = radial; + rasterizer->fill_data.type = RadialGradient; } @@ -503,14 +503,14 @@ void ector_software_rasterizer_draw_rle_data(Software_Rasterizer *rasterizer, // check for NULL rle data if (!rle) return; - rasterizer->fillData.offx = x; - rasterizer->fillData.offy = y; - rasterizer->fillData.mul_col = mul_col; - rasterizer->fillData.op = op; + rasterizer->fill_data.offx = x; + rasterizer->fill_data.offy = y; + rasterizer->fill_data.mul_col = mul_col; + rasterizer->fill_data.op = op; _setup_span_fill_matrix(rasterizer); - _adjust_span_fill_methods(&rasterizer->fillData); + _adjust_span_fill_methods(&rasterizer->fill_data); - if(rasterizer->fillData.blend) - rasterizer->fillData.blend(rle->size, rle->spans, &rasterizer->fillData); + if(rasterizer->fill_data.blend) + rasterizer->fill_data.blend(rle->size, rle->spans, &rasterizer->fill_data); } diff --git a/src/lib/ector/software/ector_software_surface.c b/src/lib/ector/software/ector_software_surface.c index 1999feae68..02d93c39df 100644 --- a/src/lib/ector/software/ector_software_surface.c +++ b/src/lib/ector/software/ector_software_surface.c @@ -50,9 +50,9 @@ _ector_software_surface_surface_set(Eo *obj EINA_UNUSED, Ector_Software_Surface_Data *pd, void *pixels, unsigned int width, unsigned int height) { - pd->software->fillData.raster_buffer.buffer = pixels; - pd->software->fillData.raster_buffer.width = width; - pd->software->fillData.raster_buffer.height = height; + pd->software->fill_data.raster_buffer.buffer = pixels; + pd->software->fill_data.raster_buffer.width = width; + pd->software->fill_data.raster_buffer.height = height; } void @@ -60,9 +60,9 @@ _ector_software_surface_surface_get(Eo *obj EINA_UNUSED, Ector_Software_Surface_Data *pd, void **pixels, unsigned int *width, unsigned int *height) { - *pixels = pd->software->fillData.raster_buffer.buffer; - *width = pd->software->fillData.raster_buffer.width; - *height = pd->software->fillData.raster_buffer.height; + *pixels = pd->software->fill_data.raster_buffer.buffer; + *width = pd->software->fill_data.raster_buffer.width; + *height = pd->software->fill_data.raster_buffer.height; } static void From 105b375f68a836484a88b0708a26ebabb3d18ad1 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:33:51 +0200 Subject: [PATCH 196/251] efl: interpolate stroke also. --- src/lib/efl/interfaces/efl_gfx_shape.c | 72 +++++++++++++++++++++++++- 1 file changed, 71 insertions(+), 1 deletion(-) diff --git a/src/lib/efl/interfaces/efl_gfx_shape.c b/src/lib/efl/interfaces/efl_gfx_shape.c index abb56611f9..9cb718cf64 100644 --- a/src/lib/efl/interfaces/efl_gfx_shape.c +++ b/src/lib/efl/interfaces/efl_gfx_shape.c @@ -239,6 +239,38 @@ interpolate(double from, double to, double pos_map) return (from * pos_map) + (to * (1.0 - pos_map)); } +static inline int +interpolatei(int from, int to, double pos_map) +{ + return (from * pos_map) + (to * (1.0 - pos_map)); +} + +typedef struct _Efl_Gfx_Stroke Efl_Gfx_Stroke; +struct _Efl_Gfx_Stroke +{ + double scale; + int r, g, b, a; + double w; + double centered; + const Efl_Gfx_Dash *dash; + unsigned int dash_length; + Efl_Gfx_Cap c; + Efl_Gfx_Join j; +}; + +static inline void +stroke_get(const Eo *obj, Efl_Gfx_Stroke *stroke) +{ + eo_do(obj, + stroke->scale = efl_gfx_shape_stroke_scale_get(), + efl_gfx_shape_stroke_color_get(&stroke->r, &stroke->g, &stroke->b, &stroke->a), + stroke->w = efl_gfx_shape_stroke_width_get(), + stroke->centered = efl_gfx_shape_stroke_location_get(), + efl_gfx_shape_stroke_dash_get(&stroke->dash, &stroke->dash_length), + stroke->c = efl_gfx_shape_stroke_cap_get(), + stroke->j = efl_gfx_shape_stroke_join_get()); +} + Eina_Bool _efl_gfx_shape_interpolate(Eo *obj, Efl_Gfx_Shape_Data *pd, const Eo *from, const Eo *to, double pos_map) @@ -247,14 +279,22 @@ _efl_gfx_shape_interpolate(Eo *obj, Efl_Gfx_Shape_Data *pd, Efl_Gfx_Path_Command *cmds; double *pts, *from_pts, *to_pts; unsigned int i, j; + Efl_Gfx_Stroke stroke_from, stroke_to; + Efl_Gfx_Dash *dash; from_pd = eo_data_scope_get(from, EFL_GFX_SHAPE_MIXIN); to_pd = eo_data_scope_get(to, EFL_GFX_SHAPE_MIXIN); - if (!from_pd && !to_pd) return EINA_FALSE; + if (!eo_isa(from, EFL_GFX_SHAPE_MIXIN) || + !eo_isa(to, EFL_GFX_SHAPE_MIXIN)) return EINA_FALSE; if (pd == from_pd || pd == to_pd) return EINA_FALSE; if (!_efl_gfx_shape_equal_commands_internal(from_pd, to_pd)) return EINA_FALSE; + stroke_get(from, &stroke_from); + stroke_get(to, &stroke_to); + + if (stroke_from.dash_length != stroke_to.dash_length) return EINA_FALSE; + cmds = realloc(pd->commands, sizeof (Efl_Gfx_Path_Command) * from_pd->commands_count); if (!cmds && from_pd->commands_count) return EINA_FALSE; @@ -281,6 +321,9 @@ _efl_gfx_shape_interpolate(Eo *obj, Efl_Gfx_Shape_Data *pd, to_pts++; } + pd->points_count = from_pd->points_count; + pd->commands_count = from_pd->commands_count; + pd->current.x = interpolate(from_pd->current.x, to_pd->current.x, pos_map); @@ -294,7 +337,34 @@ _efl_gfx_shape_interpolate(Eo *obj, Efl_Gfx_Shape_Data *pd, to_pd->current_ctrl.y, pos_map); + dash = malloc(sizeof (Efl_Gfx_Dash) * stroke_to.dash_length); + if (dash) + { + for (i = 0; i < stroke_to.dash_length; i++) + { + dash[i].length = interpolate(stroke_from.dash[i].length, + stroke_to.dash[i].length, pos_map); + dash[i].gap = interpolate(stroke_from.dash[i].gap, + stroke_to.dash[i].gap, pos_map); + } + } + else + { + stroke_to.dash_length = 0; + } + eo_do(obj, + efl_gfx_shape_stroke_scale_set(interpolate(stroke_to.scale, stroke_from.scale, pos_map)), + efl_gfx_shape_stroke_color_set(interpolatei(stroke_to.r, stroke_from.r, pos_map), + interpolatei(stroke_to.g, stroke_from.g, pos_map), + interpolatei(stroke_to.b, stroke_from.b, pos_map), + interpolatei(stroke_to.a, stroke_from.a, pos_map)), + efl_gfx_shape_stroke_width_set(interpolate(stroke_to.w, stroke_from.w, pos_map)), + efl_gfx_shape_stroke_location_set(interpolate(stroke_to.centered, stroke_from.centered, pos_map)), + efl_gfx_shape_stroke_dash_set(dash, stroke_to.dash_length), + efl_gfx_shape_stroke_cap_set(pos_map < 0.5 ? stroke_from.c : stroke_to.c), + efl_gfx_shape_stroke_join_set(pos_map < 0.5 ? stroke_from.j : stroke_to.j), + eo_event_callback_call(EFL_GFX_PATH_CHANGED, NULL), eo_event_callback_call(EFL_GFX_CHANGED, NULL)); From 9838b98f0bbe3cbe7e623a4eae5aa62f2419ca07 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:33:52 +0200 Subject: [PATCH 197/251] evas: add helper surface for cairo vector rendering. --- src/Makefile_Evas.am | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Makefile_Evas.am b/src/Makefile_Evas.am index 88aaf4eecb..32f001bca8 100644 --- a/src/Makefile_Evas.am +++ b/src/Makefile_Evas.am @@ -516,6 +516,11 @@ lib/evas/filters/blur/blur_box_rgba_i386.c \ lib/evas/filters/blur/blur_box_rgba_sse3.c \ lib/evas/filters/blur/blur_box_rgba_neon.c +### Vector surface helper + +EXTRA_DIST += \ +modules/evas/engines/software_generic/ector_cairo_software_surface.eo \ +modules/evas/engines/gl_generic/ector_cairo_software_surface.eo ### Engines From 67beb8d250180ca0dbeaf6c24194c90948a0abd8 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:33:52 +0200 Subject: [PATCH 198/251] ector: fix make distcheck. --- src/Makefile_Ector.am | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/Makefile_Ector.am b/src/Makefile_Ector.am index fd0810f29f..a39c3f7cca 100644 --- a/src/Makefile_Ector.am +++ b/src/Makefile_Ector.am @@ -35,12 +35,19 @@ CLEANFILES += \ $(ector_eolian_c) \ $(ector_eolian_h) +ectoreolianfilesdir = $(datadir)/eolian/include/ector-@VMAJ@ +ectoreolianfiles_DATA = $(ector_eolian_files) + +EXTRA_DIST += $(ectoreolianfiles_DATA) + lib_LTLIBRARIES += lib/ector/libector.la installed_ectormainheadersdir = $(includedir)/ector-@VMAJ@ dist_installed_ectormainheaders_DATA = \ lib/ector/Ector.h \ lib/ector/ector_util.h \ +lib/ector/ector_surface.h \ +lib/ector/ector_renderer.h \ lib/ector/cairo/Ector_Cairo.h \ lib/ector/software/Ector_Software.h @@ -77,6 +84,9 @@ lib/ector/software/sw_ft_raster.c \ lib/ector/software/sw_ft_stroker.c lib_ector_libector_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl \ +-I$(top_builddir)/src/lib/ector \ +-I$(top_builddir)/src/lib/ector/cairo \ +-I$(top_builddir)/src/lib/ector/software \ @ECTOR_CFLAGS@ \ -DPACKAGE_BIN_DIR=\"$(bindir)\" \ -DPACKAGE_LIB_DIR=\"$(libdir)\" \ @@ -118,11 +128,11 @@ tests_ector_ector_suite_DEPENDENCIES = @USE_ECTOR_INTERNAL_LIBS@ endif EXTRA_DIST += \ -src/lib/ector/ector_private.h \ -src/lib/ector/cairo/ector_cairo_private.h \ -src/lib/ector/software/ector_blend_private.h \ -src/lib/ector/software/ector_software_private.h \ -src/lib/ector/software/sw_ft_math.h \ -src/lib/ector/software/sw_ft_raster.h \ -src/lib/ector/software/sw_ft_stroker.h \ -src/lib/ector/software/sw_ft_types.h +lib/ector/ector_private.h \ +lib/ector/cairo/ector_cairo_private.h \ +lib/ector/software/ector_blend_private.h \ +lib/ector/software/ector_software_private.h \ +lib/ector/software/sw_ft_math.h \ +lib/ector/software/sw_ft_raster.h \ +lib/ector/software/sw_ft_stroker.h \ +lib/ector/software/sw_ft_types.h From 9cce54d4dfe44f11e5b776fe3d54da550f0d53f3 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:33:53 +0200 Subject: [PATCH 199/251] evas: fix make distcheck. --- src/Makefile_Evas.am | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Makefile_Evas.am b/src/Makefile_Evas.am index 32f001bca8..77d1721412 100644 --- a/src/Makefile_Evas.am +++ b/src/Makefile_Evas.am @@ -85,7 +85,8 @@ lib/evas/include/evas_macros.h \ lib/evas/include/evas_mmx.h \ lib/evas/include/evas_common_private.h \ lib/evas/include/evas_blend_ops.h \ -lib/evas/include/evas_filter.h +lib/evas/include/evas_filter.h \ +lib/evas/canvas/evas_vg_private.h # Linebreak @@ -317,6 +318,9 @@ lib_evas_libevas_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl \ -I$(top_srcdir)/src/lib/evas/file \ -I$(top_srcdir)/src/lib/evas/include \ -I$(top_srcdir)/src/static_libs/libunibreak \ +-I$(top_builddir)/src/lib/evas/canvas \ +-I$(top_builddir)/src/modules/evas/engines/software_generic \ +-I$(top_builddir)/src/modules/evas/engines/gl_generic \ -DPACKAGE_BIN_DIR=\"$(bindir)\" \ -DPACKAGE_LIB_DIR=\"$(libdir)\" \ -DPACKAGE_DATA_DIR=\"$(datadir)/evas\" \ @@ -543,6 +547,7 @@ modules_evas_engines_software_generic_module_la_SOURCES = modules/evas/engines/s modules_evas_engines_software_generic_module_la_CPPFLAGS = -I$(top_builddir)/src/lib/efl \ -I$(top_srcdir)/src/lib/evas/include \ -I$(top_srcdir)/src/lib/evas/cserve2 \ +-I$(top_builddir)/src/modules/evas/engines/software_generic \ @EVAS_CFLAGS@ modules_evas_engines_software_generic_module_la_LIBADD = @USE_EVAS_LIBS@ modules_evas_engines_software_generic_module_la_DEPENDENCIES = @USE_EVAS_INTERNAL_LIBS@ @@ -731,6 +736,7 @@ modules_evas_engines_gl_generic_module_la_CFLAGS = \ -I$(top_srcdir)/src/lib/evas/include \ -I$(top_srcdir)/src/lib/evas/cserve2 \ -I$(top_srcdir)/src/modules/evas/engines/gl_common \ +-I$(top_builddir)/src/modules/evas/engines/gl_generic \ @evas_engine_gl_common_cflags@ \ @EVAS_CFLAGS@ modules_evas_engines_gl_generic_module_la_LIBADD = \ From da1cf1a9939764340574a8a526290a057dc01b0c Mon Sep 17 00:00:00 2001 From: ChunEon Park Date: Fri, 3 Apr 2015 16:33:54 +0200 Subject: [PATCH 200/251] efl: actually depend on math library. --- configure.ac | 2 ++ 1 file changed, 2 insertions(+) diff --git a/configure.ac b/configure.ac index f5f8d4404e..3f37393e7a 100644 --- a/configure.ac +++ b/configure.ac @@ -1212,6 +1212,8 @@ EFL_PLATFORM_DEPEND([EFL], [evil]) EFL_INTERNAL_DEPEND_PKG([EFL], [eina]) EFL_INTERNAL_DEPEND_PKG([EFL], [eo]) +EFL_ADD_LIBS([EFL], [-lm]) + EFL_LIB_END([Efl]) #### End of Efl From e530fc521c39749e1fa66fad24b4dc79bfbcba7d Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:33:56 +0200 Subject: [PATCH 201/251] ector: actually depend on math library. --- configure.ac | 2 ++ 1 file changed, 2 insertions(+) diff --git a/configure.ac b/configure.ac index 3f37393e7a..9f4b269a6e 100644 --- a/configure.ac +++ b/configure.ac @@ -1238,6 +1238,8 @@ EFL_INTERNAL_DEPEND_PKG([ECTOR], [eina]) EFL_INTERNAL_DEPEND_PKG([ECTOR], [eo]) EFL_INTERNAL_DEPEND_PKG([ECTOR], [efl]) +EFL_ADD_LIBS([ECTOR], [-lm]) + EFL_EVAL_PKGS([ECTOR]) ### Checks for header files From 40b9eea3cb3ade5212e1bfba86ef88a3c70ed30f Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:33:57 +0200 Subject: [PATCH 202/251] ector: expose more useful immediate rendering functions to the outside world. --- src/lib/ector/ector_private.h | 21 ++------------------- src/lib/ector/ector_util.h | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/src/lib/ector/ector_private.h b/src/lib/ector/ector_private.h index 49f772b9c0..ff97f77a81 100644 --- a/src/lib/ector/ector_private.h +++ b/src/lib/ector/ector_private.h @@ -36,6 +36,8 @@ extern int _ector_log_dom_global; #endif /* ifdef CRI */ #define CRI(...) EINA_LOG_DOM_CRIT(_ector_log_dom_global, __VA_ARGS__) +/* The following macro are internal to Ector only at this stage */ + typedef unsigned char DATA8; typedef unsigned short DATA16; @@ -63,25 +65,6 @@ typedef unsigned short DATA16; #define ARGB_JOIN(a,r,g,b) \ (((a) << 24) + ((r) << 16) + ((g) << 8) + (b)) -static inline void -ector_color_argb_premul(int a, int *r, int *g, int *b) -{ - a++; - if (r) { *r = (a * *r) >> 8; } - if (g) { *g = (a * *g) >> 8; } - if (b) { *b = (a * *b) >> 8; } -} - -static inline void -ector_color_argb_unpremul(int a, int *r, int *g, int *b) -{ - if (!a) return; - if (r) { *r = (255 * *r) / a; } - if (g) { *g = (255 * *g) / a; } - if (b) { *b = (255 * *b) / a; } -} - - static inline void _ector_renderer_replace(Ector_Renderer **d, const Ector_Renderer *s) { diff --git a/src/lib/ector/ector_util.h b/src/lib/ector/ector_util.h index af8b5917d5..2dafaafae1 100644 --- a/src/lib/ector/ector_util.h +++ b/src/lib/ector/ector_util.h @@ -1,6 +1,25 @@ #ifndef ECTOR_UTIL_H # define ECTOR_UTIL_H +static inline void +ector_color_argb_premul(int a, int *r, int *g, int *b) +{ + a++; + if (r) { *r = (a * *r) >> 8; } + if (g) { *g = (a * *g) >> 8; } + if (b) { *b = (a * *b) >> 8; } +} + +static inline void +ector_color_argb_unpremul(int a, int *r, int *g, int *b) +{ + if (!a) return; + if (r) { *r = (255 * *r) / a; } + if (g) { *g = (255 * *g) / a; } + if (b) { *b = (255 * *b) / a; } +} + + static inline unsigned int ector_color_multiply(unsigned int c1, unsigned int c2) { From c1c6b7effca2fe33885a84dfd9e9adbb9c054dfc Mon Sep 17 00:00:00 2001 From: Subhransu Sekhar Mohanty Date: Fri, 3 Apr 2015 16:33:58 +0200 Subject: [PATCH 203/251] efl: force close of rect shape to prevent to avoid join showing with non rounded rectangle. Signed-off-by: Cedric BAIL --- src/lib/efl/interfaces/efl_gfx_shape.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/efl/interfaces/efl_gfx_shape.c b/src/lib/efl/interfaces/efl_gfx_shape.c index 9cb718cf64..ef0c2a7ac9 100644 --- a/src/lib/efl/interfaces/efl_gfx_shape.c +++ b/src/lib/efl/interfaces/efl_gfx_shape.c @@ -814,7 +814,7 @@ _efl_gfx_shape_append_rect(Eo *obj, Efl_Gfx_Shape_Data *pd, _efl_gfx_shape_append_line_to(obj, pd, x + rx, y + h); // Bottom left corner _efl_gfx_shape_append_arc_to(obj, pd, x, y + h - ry, rx, ry, 0, EINA_FALSE, EINA_TRUE); - _efl_gfx_shape_append_line_to(obj, pd, x, y + ry); + _efl_gfx_shape_append_close(obj, pd); } static void From b1e663b3688c1288236c39ec047487eb634c455a Mon Sep 17 00:00:00 2001 From: Subhransu Sekhar Mohanty Date: Fri, 3 Apr 2015 16:33:59 +0200 Subject: [PATCH 204/251] efl: fix efl_gfx_append_rect to clamp radius to always fit inside of the rectangle. Signed-off-by: Cedric BAIL --- src/lib/efl/interfaces/efl_gfx_shape.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lib/efl/interfaces/efl_gfx_shape.c b/src/lib/efl/interfaces/efl_gfx_shape.c index ef0c2a7ac9..632c5bf979 100644 --- a/src/lib/efl/interfaces/efl_gfx_shape.c +++ b/src/lib/efl/interfaces/efl_gfx_shape.c @@ -802,6 +802,10 @@ _efl_gfx_shape_append_rect(Eo *obj, Efl_Gfx_Shape_Data *pd, double x, double y, double w, double h, double rx, double ry) { + // clamp the x and y radius value. + if (rx > w/2) rx = w/2; + if (ry > h/2) ry = h/2; + _efl_gfx_shape_append_move_to(obj, pd, x, y + ry); // Top left corner _efl_gfx_shape_append_arc_to(obj, pd, x + rx, y, rx, ry, 0, EINA_FALSE, EINA_TRUE); From e80a7591396b0b1cbf1e87f020c11d5997cb09dc Mon Sep 17 00:00:00 2001 From: Subhransu Sekhar Mohanty Date: Fri, 3 Apr 2015 16:34:00 +0200 Subject: [PATCH 205/251] evas: add legacy api for creating vg_shape and vg_container object. Signed-off-by: Cedric BAIL --- src/lib/evas/Evas_Legacy.h | 20 ++++++++++++++++++++ src/lib/evas/canvas/evas_vg_container.c | 6 ++++++ src/lib/evas/canvas/evas_vg_shape.c | 6 ++++++ 3 files changed, 32 insertions(+) diff --git a/src/lib/evas/Evas_Legacy.h b/src/lib/evas/Evas_Legacy.h index 7fef29513f..0b337e9cb1 100644 --- a/src/lib/evas/Evas_Legacy.h +++ b/src/lib/evas/Evas_Legacy.h @@ -1712,6 +1712,26 @@ EAPI Evas_Object *evas_object_vg_add(Evas *e) EINA_WARN_UNUSED_RESULT EINA_ARG_N #include "canvas/evas_vg.eo.legacy.h" +/** + * Creates a new vector shape object \. + * + * @param parent The given vector container object. + * @return The created vector shape object handle. + * + * @since 1.14 + */ +EAPI Efl_VG* evas_vg_shape_add(Efl_VG *parent); + +/** + * Creates a new vector container object \. + * + * @param parent The given vector container object. + * @return The created vector container object handle. + * + * @since 1.14 + */ +EAPI Efl_VG* evas_vg_container_add(Efl_VG *parent); + EAPI Eina_Bool evas_vg_node_visible_get(Eo *obj); EAPI void evas_vg_node_visible_set(Eo *obj, Eina_Bool v); EAPI void evas_vg_node_color_get(Eo *obj, int *r, int *g, int *b, int *a); diff --git a/src/lib/evas/canvas/evas_vg_container.c b/src/lib/evas/canvas/evas_vg_container.c index fdf81244ad..e85ff3b4ad 100644 --- a/src/lib/evas/canvas/evas_vg_container.c +++ b/src/lib/evas/canvas/evas_vg_container.c @@ -76,5 +76,11 @@ _efl_vg_container_efl_vg_base_bound_get(Eo *obj EINA_UNUSED, return first ? EINA_FALSE : EINA_TRUE; } +EAPI Efl_VG* +evas_vg_container_add(Efl_VG *parent) +{ + return eo_add(EFL_VG_CONTAINER_CLASS, parent); +} + #include "efl_vg_container.eo.c" diff --git a/src/lib/evas/canvas/evas_vg_shape.c b/src/lib/evas/canvas/evas_vg_shape.c index c1584805c3..c33c6a864c 100644 --- a/src/lib/evas/canvas/evas_vg_shape.c +++ b/src/lib/evas/canvas/evas_vg_shape.c @@ -553,4 +553,10 @@ evas_vg_shape_shape_equal_commands(Eo *obj, const Eo *with) return eo_do_ret(obj, ret, efl_gfx_shape_equal_commands(with)); } +EAPI Efl_VG* +evas_vg_shape_add(Efl_VG *parent) +{ + return eo_add(EFL_VG_SHAPE_CLASS, parent); +} + #include "efl_vg_shape.eo.c" From f8938fe5ce04f370a73135f09965ac144afebf50 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:34:01 +0200 Subject: [PATCH 206/251] evas: use legacy API for VG example. --- src/examples/evas/evas-vg-batman.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/examples/evas/evas-vg-batman.c b/src/examples/evas/evas-vg-batman.c index 1d1a5f373c..87a1f6d57b 100644 --- a/src/examples/evas/evas-vg-batman.c +++ b/src/examples/evas/evas-vg-batman.c @@ -22,10 +22,6 @@ #define EFL_BETA_API_SUPPORT 1 #endif -#ifndef EFL_EO_API_SUPPORT -#define EFL_EO_API_SUPPORT 1 -#endif - #include #include #include @@ -133,7 +129,7 @@ main(void) for (i = 0; i < sizeof (batmans_path) / sizeof (batmans_path[0]); i++) { - batmans_vg[i] = eo_add(EFL_VG_SHAPE_CLASS, NULL); + batmans_vg[i] = evas_vg_shape_add(NULL); evas_vg_shape_shape_append_svg_path(batmans_vg[i], batmans_path[i]); } @@ -141,12 +137,12 @@ main(void) root = evas_object_vg_root_node_get(vg); - circle = eo_add(EFL_VG_SHAPE_CLASS, root); + circle = evas_vg_shape_add(root); evas_vg_shape_shape_append_circle(circle, WIDTH / 2, HEIGHT / 2, 200); evas_vg_node_color_set(circle, 255, 255, 255, 255); evas_vg_shape_stroke_color_set(circle, 0, 0, 0, 0); - batman = eo_add(EFL_VG_SHAPE_CLASS, root); + batman = evas_vg_shape_add(root); evas_vg_node_origin_set(batman, 100, 150); evas_vg_node_color_set(batman, 0, 0, 0, 255); evas_vg_shape_stroke_color_set(batman, 0, 0, 0, 0); From f73352adec79555285ff51669caf5c063e8fce64 Mon Sep 17 00:00:00 2001 From: Subhransu Sekhar Mohanty Date: Fri, 3 Apr 2015 16:34:02 +0200 Subject: [PATCH 207/251] evas : add documentation to legacy vector api's. Signed-off-by: Cedric BAIL --- src/lib/efl/interfaces/efl_gfx_shape.eo | 272 ++++++---- src/lib/evas/Evas_Legacy.h | 637 ++++++++++++++++++++++++ 2 files changed, 821 insertions(+), 88 deletions(-) diff --git a/src/lib/efl/interfaces/efl_gfx_shape.eo b/src/lib/efl/interfaces/efl_gfx_shape.eo index 8547dc58b2..7452fe610e 100644 --- a/src/lib/efl/interfaces/efl_gfx_shape.eo +++ b/src/lib/efl/interfaces/efl_gfx_shape.eo @@ -154,130 +154,226 @@ mixin Efl.Gfx.Shape } } path_length { - get { - } - values { - uint commands; - uint points; - } + get { + } + values { + uint commands; + uint points; + } } current { - get { - } - values { - double x; - double y; - } + get { + } + values { + double x; + double y; + } } current_ctrl { - get { - } - values { - double x; - double y; - } + get { + } + values { + double x; + double y; + } } } methods { dup { - params { - @in Eo *dup_from; - } + /*@ + Copy the shape data from the object specified . + + @since 1.14 + */ + params { + @in Eo *dup_from; /*@ Shape object from where data will be copied.*/ + } } reset { + /*@ + Reset the shape data of the shape object. + + @since 1.14 + */ } append_move_to { - params { - @in double x; - @in double y; - } + /*@ + Moves the current point to the given point, + implicitly starting a new subpath and closing the previous one. + + @see efl_gfx_path_append_close() + @since 1.14 + */ + params { + @in double x; /*@ X co-ordinate of the current point.*/ + @in double y; /*@ Y co-ordinate of the current point.*/ + } } append_line_to { - params { - @in double x; - @in double y; - } + /*@ + Adds a straight line from the current position to the given endPoint. + After the line is drawn, the current position is updated to be at the end + point of the line. + + @note if no current position present, it draws a line to itself, basically + a point. + + @see efl_gfx_path_append_move_to() + @since 1.14 + */ + params { + @in double x; /*@ X co-ordinate of end point of the line.*/ + @in double y; /*@ Y co-ordinate of end point of the line.*/ + } } append_quadratic_to { - params { - @in double x; - @in double y; - @in double ctrl_x; - @in double ctrl_y; - } + /*@ + Adds a quadratic Bezier curve between the current position and the + given end point (x,y) using the control points specified by (ctrl_x, ctrl_y). + After the path is drawn, the current position is updated to be at the end + point of the path. + + @since 1.14 + */ + params { + @in double x; /*@ X co-ordinate of end point of the line.*/ + @in double y; /*@ Y co-ordinate of end point of the line.*/ + @in double ctrl_x; /*@ X co-ordinate of control point.*/ + @in double ctrl_y; /*@ Y co-ordinate of control point.*/ + } } append_squadratic_to { - params { - @in double x; - @in double y; - } + /*@ + Same as efl_gfx_path_append_quadratic_to() api only difference is that it + uses the current control point to draw the bezier. + + @see efl_gfx_path_append_quadratic_to() + @since 1.14 + */ + params { + @in double x; /*@ X co-ordinate of end point of the line.*/ + @in double y; /*@ Y co-ordinate of end point of the line.*/ + } } append_cubic_to { - params { - @in double x; - @in double y; - @in double ctrl_x0; - @in double ctrl_y0; - @in double ctrl_x1; - @in double ctrl_y1; - } + /*@ + Adds a cubic Bezier curve between the current position and the + given end point (x,y) using the control points specified by + (ctrl_x0, ctrl_y0), and (ctrl_x1, ctrl_y1). After the path is drawn, + the current position is updated to be at the end point of the path. + + @since 1.14 + */ + params { + @in double x; /*@ X co-ordinate of end point of the line.*/ + @in double y; /*@ Y co-ordinate of end point of the line.*/ + @in double ctrl_x0; /*@ X co-ordinate of 1st control point.*/ + @in double ctrl_y0; /*@ Y co-ordinate of 1st control point.*/ + @in double ctrl_x1; /*@ X co-ordinate of 2nd control point.*/ + @in double ctrl_y1; /*@ Y co-ordinate of 2nd control point.*/ + } } append_scubic_to { - params { - @in double x; - @in double y; - @in double ctrl_x; - @in double ctrl_y; - } + /*@ + Same as efl_gfx_path_append_cubic_to() api only difference is that it uses + the current control point to draw the bezier. + + @see efl_gfx_path_append_cubic_to() + + @since 1.14 + */ + params { + @in double x; /*@ X co-ordinate of end point of the line.*/ + @in double y; /*@ Y co-ordinate of end point of the line.*/ + @in double ctrl_x; /*@ X co-ordinate of 2nd control point.*/ + @in double ctrl_y; /*@ Y co-ordinate of 2nd control point.*/ + } } append_arc_to { - params { - @in double x; - @in double y; - @in double rx; - @in double ry; - @in double angle; - @in bool large_arc; - @in bool sweep; - } + /*@ + Append an arc that connects from the current point int the point list + to the given point (x,y). The arc is defined by the given radius in + x-direction (rx) and radius in y direction (ry) . + + @note Use this api if you know the end point's of the arc otherwise + use more convenient function efl_gfx_path_append_arc_to() + + @see efl_gfx_path_append_arc_to() + @since 1.14 + */ + params { + @in double x; /*@ X co-ordinate of end point of the arc.*/ + @in double y; /*@ Y co-ordinate of end point of the arc.*/ + @in double rx; /*@ radius of arc in x direction.*/ + @in double ry; /*@ radius of arc in y direction.*/ + @in double angle; /*@ x-axis rotation , normally 0.*/ + @in bool large_arc; /*@ Defines whether to draw the larger arc or smaller arc joining two point.*/ + @in bool sweep; /*@ Defines whether the arc will be drawn counter-clockwise or clockwise from current point to the end point taking into account the large_arc property.*/ + } } append_close { + /*@ + Closes the current subpath by drawing a line to the beginning of the subpath, + automatically starting a new path. The current point of the new path is + (0, 0). + + @note If the subpath does not contain any points, this function does nothing. + + @since 1.14 + */ } append_circle { - params { - @in double x; - @in double y; - @in double radius; - } + /*@ + Append a circle with given center and radius. + + @since 1.14 + */ + params { + @in double x; /*@ X co-ordinate of the center of the circle.*/ + @in double y; /*@ Y co-ordinate of the center of the circle.*/ + @in double radius; /*@ radius of the circle.*/ + } } append_rect { - params { - @in double x; - @in double y; - @in double w; - @in double h; - @in double rx; - @in double ry; - } + /*@ + Append the given rectangle with rounded corner to the path. + + The xr and yr arguments specify the radii of the ellipses defining the + corners of the rounded rectangle. + + @note xr and yr are specified in terms of width and height respectively. + + @note if xr and yr are 0, then it will draw a rectangle without rounded corner. + + @since 1.14 + */ + params { + @in double x; /*@ X co-ordinate of the rectangle.*/ + @in double y; /*@ Y co-ordinate of the rectangle.*/ + @in double w; /*@ Width of the rectangle.*/ + @in double h; /*@ Height of the rectangle.*/ + @in double rx; /*@ The x radius of the rounded corner and should be in range [ 0 to w/2 ]*/ + @in double ry; /*@ The y radius of the rounded corner and should be in range [ 0 to h/2 ]*/ + } } append_svg_path { - params { - @in const(char)* svg_path_data; - } + params { + @in const(char)* svg_path_data; + } } interpolate { - return: bool; - params { - @in const(Eo)* from; - @in const(Eo)* to; - @in double pos_map; - } + return: bool; + params { + @in const(Eo)* from; + @in const(Eo)* to; + @in double pos_map; + } } equal_commands { - return: bool; - params { - @in const(Eo)* with; - } + return: bool; + params { + @in const(Eo)* with; + } } } implements { diff --git a/src/lib/evas/Evas_Legacy.h b/src/lib/evas/Evas_Legacy.h index 0b337e9cb1..ca63600de7 100644 --- a/src/lib/evas/Evas_Legacy.h +++ b/src/lib/evas/Evas_Legacy.h @@ -1730,77 +1730,714 @@ EAPI Efl_VG* evas_vg_shape_add(Efl_VG *parent); * * @since 1.14 */ + EAPI Efl_VG* evas_vg_container_add(Efl_VG *parent); +/** + * + * Retrieves whether or not the given Efl_Vg object is visible. + * + * + */ EAPI Eina_Bool evas_vg_node_visible_get(Eo *obj); + +/** + * + * Makes the given Efl_Vg object visible or invisible. + * + * @param[in] v @c EINA_TRUE if to make the object visible, @c EINA_FALSE otherwise + * + */ EAPI void evas_vg_node_visible_set(Eo *obj, Eina_Bool v); + +/** + * + * Retrieves the general/main color of the given Efl_Vg object. + * + * Retrieves the “main” color's RGB component (and alpha channel) + * values, which range from 0 to 255. For the alpha channel, + * which defines the object's transparency level, 0 means totally + * transparent, while 255 means opaque. These color values are + * premultiplied by the alpha value. + * + * + * @note Use @c NULL pointers on the components you're not interested + * in: they'll be ignored by the function. + * + * @param[out] r The red component of the given color. + * @param[out] g The green component of the given color. + * @param[out] b The blue component of the given color. + * @param[out] a The alpha component of the given color. + * + */ EAPI void evas_vg_node_color_get(Eo *obj, int *r, int *g, int *b, int *a); + +/** + * + * Sets the general/main color of the given Efl_Vg object to the given + * one. + * + * @see evas_vg_node_color_get() (for an example) + * @note These color values are expected to be premultiplied by @p a. + * + * @ingroup Evas_Object_Group_Basic + * + * @param[in] r The red component of the given color. + * @param[in] g The green component of the given color. + * @param[in] b The blue component of the given color. + * @param[in] a The alpha component of the given color. + * + */ EAPI void evas_vg_node_color_set(Eo *obj, int r, int g, int b, int a); + +/** + * + * Retrieves the geometry of the given Efl_Vg object. + * + * @param[out] x in + * @param[out] y in + * @param[out] w in + * @param[out] h in + * + */ EAPI void evas_vg_node_geometry_get(Eo *obj, int *x, int *y, int *w, int *h); + +/** + * + * Changes the geometry of the given Efl_Vg object. + * + * @param[in] x in + * @param[in] y in + * @param[in] w in + * @param[in] h in + * + */ EAPI void evas_vg_node_geometry_set(Eo *obj, int x, int y, int w, int h); + +/** + * + * Stack @p obj immediately below @p below + * + * Objects, in a given canvas, are stacked in the order they get added + * to it. This means that, if they overlap, the highest ones will + * cover the lowest ones, in that order. This function is a way to + * change the stacking order for the objects. + * + * This function is intended to be used with objects belonging to + * the same layer in a given canvas, otherwise it will fail (and + * accomplish nothing). + * + * If you have smart objects on your canvas and @p obj is a member of + * one of them, then @p below must also be a member of the same + * smart object. + * + * Similarly, if @p obj is not a member of a smart object, @p below + * must not be either. + * + * @see evas_object_layer_get() + * @see evas_object_layer_set() + * @see evas_object_stack_below() + * + * + * @param[in] below the object below which to stack + * + */ EAPI void evas_vg_node_stack_below(Eo *obj, Eo *below); + +/** + * + * Stack @p obj immediately above @p above + * + * Objects, in a given canvas, are stacked in the order they get added + * to it. This means that, if they overlap, the highest ones will + * cover the lowest ones, in that order. This function is a way to + * change the stacking order for the objects. + * + * This function is intended to be used with objects belonging to + * the same layer in a given canvas, otherwise it will fail (and + * accomplish nothing). + * + * If you have smart objects on your canvas and @p obj is a member of + * one of them, then @p above must also be a member of the same + * smart object. + * + * Similarly, if @p obj is not a member of a smart object, @p above + * must not be either. + * + * @see evas_object_layer_get() + * @see evas_object_layer_set() + * @see evas_object_stack_below() + * + * + * @param[in] above the object above which to stack + * + */ EAPI void evas_vg_node_stack_above(Eo *obj, Eo *above); + +/** + * + * Raise @p obj to the top of its layer. + * + * @p obj will, then, be the highest one in the layer it belongs + * to. Object on other layers won't get touched. + * + * @see evas_object_stack_above() + * @see evas_object_stack_below() + * @see evas_object_lower() + * + */ EAPI void evas_vg_node_raise(Eo *obj); + +/** + * + * Lower @p obj to the bottom of its layer. + * + * @p obj will, then, be the lowest one in the layer it belongs + * to. Objects on other layers won't get touched. + * + * @see evas_object_stack_above() + * @see evas_object_stack_below() + * @see evas_object_raise() + * + * + * + */ EAPI void evas_vg_node_lower(Eo *obj); #include "canvas/efl_vg_base.eo.legacy.h" +/** + * + * Get the stroke scaling factor used for stroking this path. + * @since 1.14 + * + * + */ EAPI double evas_vg_shape_stroke_scale_get(Eo *obj); + +/** + * + * Sets the stroke scale to be used for stroking the path. + * the scale property will be used along with stroke width property. + * @since 1.14 + * + * @param[in] s stroke scale value + * + */ EAPI void evas_vg_shape_stroke_scale_set(Eo *obj, double s); + +/** + * + * Gets the color used for stroking the path. + * @since 1.14 + * + * @param[out] r The red component of the given color. + * @param[out] g The green component of the given color. + * @param[out] b The blue component of the given color. + * @param[out] a The alpha component of the given color. + * + */ EAPI void evas_vg_shape_stroke_color_get(Eo *obj, int *r, int *g, int *b, int *a); + +/** + * + * Sets the color to be used for stroking the path. + * @since 1.14 + * + * @param[in] r The red component of the given color. + * @param[in] g The green component of the given color. + * @param[in] b The blue component of the given color. + * @param[in] a The alpha component of the given color. + * + */ EAPI void evas_vg_shape_stroke_color_set(Eo *obj, int r, int g, int b, int a); + +/** + * + * Gets the stroke width to be used for stroking the path. + * @since 1.14 + * + * + */ EAPI double evas_vg_shape_stroke_width_get(Eo *obj); + +/** + * + * Sets the stroke width to be used for stroking the path. + * @since 1.14 + * + * @param[in] w stroke width to be used + * + */ EAPI void evas_vg_shape_stroke_width_set(Eo *obj, double w); + +/** + * + * Not Implemented + * + * + */ EAPI double evas_vg_shape_stroke_location_get(Eo *obj); + +/** + * + * Not Implemented + * + * @param[in] centered + * + */ EAPI void evas_vg_shape_stroke_location_set(Eo *obj, double centered); + +/** + * + * Not Implemented + * + * @param[out] dash + * @param[out] length + * + */ EAPI void evas_vg_shape_stroke_dash_get(Eo *obj, const Efl_Gfx_Dash **dash, unsigned int *length); + +/** + * + * Not Implemented + * + * @param[in] dash + * @param[in] length + * + */ EAPI void evas_vg_shape_stroke_dash_set(Eo *obj, const Efl_Gfx_Dash *dash, unsigned int length); + +/** + * + * Gets the cap style used for stroking path. + * @since 1.14 + * + * + */ EAPI Efl_Gfx_Cap evas_vg_shape_stroke_cap_get(Eo *obj); + +/** + * + * Sets the cap style to be used for stroking the path. + * The cap will be used for capping the end point of a + * open subpath. + * + * @see Efl_Gfx_Cap + * @since 1.14 + * + * @param[in] c cap style to use , default is EFL_GFX_CAP_BUTT + * + */ EAPI void evas_vg_shape_stroke_cap_set(Eo *obj, Efl_Gfx_Cap c); + +/** + * + * Gets the join style used for stroking path. + * @since 1.14 + * + * + */ EAPI Efl_Gfx_Join evas_vg_shape_stroke_join_get(Eo *obj); + +/** + * + * Sets the join style to be used for stroking the path. + * The join style will be used for joining the two line segment + * while stroking teh path. + * + * @see Efl_Gfx_Join + * @since 1.14 + * + * @param[in] j join style to use , default is +EFL_GFX_JOIN_MITER + * + */ EAPI void evas_vg_shape_stroke_join_set(Eo *obj, Efl_Gfx_Join j); + +/** + * + * Set the list of commands and points to be used to create the + * content of shape. + * + * @note see efl_gfx_path interface for how to create a command list. + * @see Efl_Gfx_Path_Command + * @since 1.14 + * + * @param[in] op command list + * @param[in] points point list + * + */ EAPI void evas_vg_shape_shape_path_set(Eo *obj, const Efl_Gfx_Path_Command *op, const double *points); + +/** + * + * Gets the command and points list + * @since 1.14 + * + * @param[out] op command list + * @param[out] points point list + * + */ + EAPI void evas_vg_shape_shape_path_get(Eo *obj, const Efl_Gfx_Path_Command **op, const double **points); EAPI void evas_vg_shape_shape_path_length_get(Eo *obj, unsigned int *commands, unsigned int *points); EAPI void evas_vg_shape_shape_current_get(Eo *obj, double *x, double *y); EAPI void evas_vg_shape_shape_current_ctrl_get(Eo *obj, double *x, double *y); + +/** + * + * Copy the shape data from the object specified . + * + * @since 1.14 + * + * + * @param[in] dup_from Shape object from where data will be copied. + * + */ EAPI void evas_vg_shape_shape_dup(Eo *obj, Eo *dup_from); + +/** + * + * Reset the shape data of the shape object. + * + * @since 1.14 + * + * + * + */ EAPI void evas_vg_shape_shape_reset(Eo *obj); + +/** + * + * Moves the current point to the given point, + * implicitly starting a new subpath and closing the previous one. + * + * @see efl_gfx_path_append_close() + * @since 1.14 + * + * + * @param[in] x X co-ordinate of the current point. + * @param[in] y Y co-ordinate of the current point. + * + */ EAPI void evas_vg_shape_shape_append_move_to(Eo *obj, double x, double y); + +/** + * + * Adds a straight line from the current position to the given endPoint. + * After the line is drawn, the current position is updated to be at the end + * point of the line. + * + * @note if no current position present, it draws a line to itself, basically + * a point. + * + * @see efl_gfx_path_append_move_to() + * @since 1.14 + * + * + * @param[in] x X co-ordinate of end point of the line. + * @param[in] y Y co-ordinate of end point of the line. + * + */ EAPI void evas_vg_shape_shape_append_line_to(Eo *obj, double x, double y); + +/** + * + * Adds a quadratic Bezier curve between the current position and the + * given end point (x,y) using the control points specified by (ctrl_x, ctrl_y). + * After the path is drawn, the current position is updated to be at the end + * point of the path. + * + * @since 1.14 + * + * + * @param[in] x X co-ordinate of end point of the line. + * @param[in] y Y co-ordinate of end point of the line. + * @param[in] ctrl_x X co-ordinate of control point. + * @param[in] ctrl_y Y co-ordinate of control point. + * + */ EAPI void evas_vg_shape_shape_append_quadratic_to(Eo *obj, double x, double y, double ctrl_x, double ctrl_y); + +/** + * + * Same as efl_gfx_path_append_quadratic_to() api only difference is that it + * uses the current control point to draw the bezier. + * + * @see efl_gfx_path_append_quadratic_to() + * @since 1.14 + * + * + * @param[in] x X co-ordinate of end point of the line. + * @param[in] y Y co-ordinate of end point of the line. + * + */ EAPI void evas_vg_shape_shape_append_squadratic_to(Eo *obj, double x, double y); + +/** + * + * Adds a cubic Bezier curve between the current position and the + * given end point (x,y) using the control points specified by + * (ctrl_x0, ctrl_y0), and (ctrl_x1, ctrl_y1). After the path is drawn, + * the current position is updated to be at the end point of the path. + * + * @since 1.14 + * + * + * @param[in] x X co-ordinate of end point of the line. + * @param[in] y Y co-ordinate of end point of the line. + * @param[in] ctrl_x0 X co-ordinate of 1st control point. + * @param[in] ctrl_y0 Y co-ordinate of 1st control point. + * @param[in] ctrl_x1 X co-ordinate of 2nd control point. + * @param[in] ctrl_y1 Y co-ordinate of 2nd control point. + * + */ EAPI void evas_vg_shape_shape_append_cubic_to(Eo *obj, double x, double y, double ctrl_x0, double ctrl_y0, double ctrl_x1, double ctrl_y1); + +/** + * + * Same as efl_gfx_path_append_cubic_to() api only difference is that it uses + * the current control point to draw the bezier. + * + * @see efl_gfx_path_append_cubic_to() + * + * @since 1.14 + * + * + * @param[in] x X co-ordinate of end point of the line. + * @param[in] y Y co-ordinate of end point of the line. + * @param[in] ctrl_x X co-ordinate of 2nd control point. + * @param[in] ctrl_y Y co-ordinate of 2nd control point. + * + */ EAPI void evas_vg_shape_shape_append_scubic_to(Eo *obj, double x, double y, double ctrl_x, double ctrl_y); + +/** + * + * Append an arc that connects from the current point int the point list + * to the given point (x,y). The arc is defined by the given radius in + * x-direction (rx) and radius in y direction (ry) . + * + * @note Use this api if you know the end point's of the arc otherwise + * use more convenient function efl_gfx_path_append_arc_to() + * + * @see efl_gfx_path_append_arc_to() + * @since 1.14 + * + * + * @param[in] x X co-ordinate of end point of the arc. + * @param[in] y Y co-ordinate of end point of the arc. + * @param[in] rx radius of arc in x direction. + * @param[in] ry radius of arc in y direction. + * @param[in] angle x-axis rotation , normally 0. + * @param[in] large_arc Defines whether to draw the larger arc or smaller arc joining two point. + * @param[in] sweep Defines whether the arc will be drawn counter-clockwise or clockwise from current point to the end point taking into account the large_arc property. + * + */ EAPI void evas_vg_shape_shape_append_arc_to(Eo *obj, double x, double y, double rx, double ry, double angle, Eina_Bool large_arc, Eina_Bool sweep); + +/** + * + * Closes the current subpath by drawing a line to the beginning of the subpath, + * automatically starting a new path. The current point of the new path is + * (0, 0). + * + * @note If the subpath does not contain any points, this function does nothing. + * + * @since 1.14 + * + * + * + */ EAPI void evas_vg_shape_shape_append_close(Eo *obj); + +/** + * + * Append a circle with given center and radius. + * + * @see efl_gfx_path_append_arc() + * @since 1.14 + * + * + * @param[in] x X co-ordinate of the center of the circle. + * @param[in] y Y co-ordinate of the center of the circle. + * @param[in] radius radius of the circle. + * + */ EAPI void evas_vg_shape_shape_append_circle(Eo *obj, double x, double y, double radius); + +/** + * + * Append the given rectangle with rounded corner to the path. + * + * The xr and yr arguments specify the radii of the ellipses defining the + * corners of the rounded rectangle. + * + * @note xr and yr are specified in terms of width and height respectively. + * + * @note if xr and yr are 0, then it will draw a rectangle without rounded corner. + * + * @since 1.14 + * + * + * @param[in] x X co-ordinate of the rectangle. + * @param[in] y Y co-ordinate of the rectangle. + * @param[in] w Width of the rectangle. + * @param[in] h Height of the rectangle. + * @param[in] rx The x radius of the rounded corner and should be in range [ 0 to w/2 ] + * @param[in] ry The y radius of the rounded corner and should be in range [ 0 to h/2 ] + * + */ EAPI void evas_vg_shape_shape_append_rect(Eo *obj, double x, double y, double w, double h, double rx, double ry); + EAPI void evas_vg_shape_shape_append_svg_path(Eo *obj, const char *svg_path_data); EAPI Eina_Bool evas_vg_shape_shape_interpolate(Eo *obj, const Eo *from, const Eo *to, double pos_map); EAPI Eina_Bool evas_vg_shape_shape_equal_commands(Eo *obj, const Eo *with); #include "canvas/efl_vg_shape.eo.legacy.h" +/** + * + * Set the list of color stops for the gradient + * @since 1.14 + * + * @param[in] colors color stops list + * @param[in] length length of the list + * + */ EAPI void evas_vg_gradient_stop_set(Eo *obj, const Efl_Gfx_Gradient_Stop *colors, unsigned int length); + +/** + * + * get the list of color stops. + * @since 1.14 + * + * @param[out] colors color stops list + * @param[out] length length of the list + * + */ EAPI void evas_vg_gradient_stop_get(Eo *obj, const Efl_Gfx_Gradient_Stop **colors, unsigned int *length); + +/** + * + * Specifies the spread method that should be used for this gradient. + * @since 1.14 + * + * @param[in] s spread type to be used + * + */ EAPI void evas_vg_gradient_spread_set(Eo *obj, Efl_Gfx_Gradient_Spread s); + +/** + * + * Returns the spread method use by this gradient. The default is + * EFL_GFX_GRADIENT_SPREAD_PAD. + * @since 1.14 + * + * + */ EAPI Efl_Gfx_Gradient_Spread evas_vg_gradient_spread_get(Eo *obj); #include "canvas/efl_vg_gradient.eo.legacy.h" +/** + * + * Sets the start point of this linear gradient. + * + * @param[in] x x co-ordinate of start point + * @param[in] y y co-ordinate of start point + * + */ EAPI void evas_vg_gradient_linear_start_set(Eo *obj, double x, double y); + +/** + * + * Gets the start point of this linear gradient. + * + * @param[out] x x co-ordinate of start point + * @param[out] y y co-ordinate of start point + * + */ EAPI void evas_vg_gradient_linear_start_get(Eo *obj, double *x, double *y); + +/** + * + * Sets the end point of this linear gradient. + * + * @param[in] x x co-ordinate of end point + * @param[in] y y co-ordinate of end point + * + */ EAPI void evas_vg_gradient_linear_end_set(Eo *obj, double x, double y); + +/** + * + * Gets the end point of this linear gradient. + * + * @param[out] x x co-ordinate of end point + * @param[out] y y co-ordinate of end point + * + */ EAPI void evas_vg_gradient_linear_end_get(Eo *obj, double *x, double *y); #include "canvas/efl_vg_gradient_linear.eo.legacy.h" +/** + * + * Sets the center of this radial gradient. + * + * @param[in] x x co-ordinate of center point + * @param[in] y y co-ordinate of center point + * + */ EAPI void evas_vg_gradient_radial_center_set(Eo *obj, double x, double y); + +/** + * + * Gets the center of this radial gradient. + * + * @param[out] x x co-ordinate of center point + * @param[out] y y co-ordinate of center point + * + */ EAPI void evas_vg_gradient_radial_center_get(Eo *obj, double *x, double *y); + +/** + * + * Sets the center radius of this radial gradient. + * + * @param[in] r center radius + * + */ EAPI void evas_vg_gradient_radial_radius_set(Eo *obj, double r); + +/** + * + * Gets the center radius of this radial gradient. + * + * + */ EAPI double evas_vg_gradient_radial_radius_get(Eo *obj); + +/** + * + * Sets the focal point of this radial gradient. + * + * @param[in] x x co-ordinate of focal point + * @param[in] y y co-ordinate of focal point + * + */ EAPI void evas_vg_gradient_radial_focal_set(Eo *obj, double x, double y); + +/** + * + * Gets the focal point of this radial gradient. + * + * @param[out] x x co-ordinate of focal point + * @param[out] y y co-ordinate of focal point + * + */ EAPI void evas_vg_gradient_radial_focal_get(Eo *obj, double *x, double *y); #include "canvas/efl_vg_gradient_radial.eo.legacy.h" From f1e48f8de8b82f376542af8611c4bd1bd5fa76dd Mon Sep 17 00:00:00 2001 From: Subhransu Mohanty Date: Fri, 3 Apr 2015 16:34:03 +0200 Subject: [PATCH 208/251] ector: don't draw the gradient if its used as fill object in Cairo backend. Signed-off-by: Cedric BAIL --- src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c | 2 ++ src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c b/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c index 19f30558a3..1b02c35e66 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c @@ -70,6 +70,8 @@ _ector_renderer_cairo_gradient_linear_ector_renderer_generic_base_draw(Eo *obj, Ector_Renderer_Cairo_Gradient_Linear_Data *pd, Ector_Rop op, Eina_Array *clips, unsigned int mul_col) { + if (pd->pat) return EINA_FALSE; + Ector_Renderer_Generic_Gradient_Linear_Data *gld; // FIXME: don't ignore clipping ! diff --git a/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c b/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c index 521b06da9e..b20256e93f 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c @@ -74,6 +74,8 @@ _ector_renderer_cairo_gradient_radial_ector_renderer_generic_base_prepare(Eo *ob static Eina_Bool _ector_renderer_cairo_gradient_radial_ector_renderer_generic_base_draw(Eo *obj, Ector_Renderer_Cairo_Gradient_Radial_Data *pd, Ector_Rop op, Eina_Array *clips, unsigned int mul_col) { + if (pd->pat) return EINA_FALSE; + Ector_Renderer_Generic_Gradient_Radial_Data *gld; // FIXME: don't ignore clipping ! From e22752d1eb20b0e83108664edf052ef427fd037c Mon Sep 17 00:00:00 2001 From: Subhransu Mohanty Date: Fri, 3 Apr 2015 16:34:05 +0200 Subject: [PATCH 209/251] ector: use line width, join and cap style while stoking the path for Cairo backend. Signed-off-by: Cedric BAIL --- src/lib/ector/cairo/ector_renderer_cairo_shape.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/lib/ector/cairo/ector_renderer_cairo_shape.c b/src/lib/ector/cairo/ector_renderer_cairo_shape.c index babf113e18..54f6962a63 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_shape.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_shape.c @@ -36,6 +36,12 @@ static void (*cairo_path_destroy)(cairo_path_t *path) = NULL; static void (*cairo_new_path)(cairo_t *cr) = NULL; static void (*cairo_append_path)(cairo_t *cr, const cairo_path_t *path) = NULL; +typedef enum _cairo_line_cap_t{lie_cap}cairo_line_cap_t; +typedef enum _cairo_line_join_t{line_join}cairo_line_join_t; +static void (*cairo_set_line_width)(cairo_t *cr, double width) = NULL; +static void (*cairo_set_line_cap)(cairo_t *cr, cairo_line_cap_t line_cap) = NULL; +static void (*cairo_set_line_join)(cairo_t *cr, cairo_line_join_t line_join) = NULL; + typedef struct _Ector_Renderer_Cairo_Shape_Data Ector_Renderer_Cairo_Shape_Data; struct _Ector_Renderer_Cairo_Shape_Data { @@ -162,6 +168,9 @@ _ector_renderer_cairo_shape_ector_renderer_generic_base_draw(Eo *obj, Ector_Rend USE(obj, cairo_fill_preserve, EINA_FALSE); USE(obj, cairo_set_source_rgba, EINA_FALSE); USE(obj, cairo_stroke, EINA_FALSE); + USE(obj, cairo_set_line_width, EINA_FALSE); + USE(obj, cairo_set_line_cap, EINA_FALSE); + USE(obj, cairo_set_line_join, EINA_FALSE); cairo_fill_preserve(pd->parent->cairo); @@ -174,6 +183,9 @@ _ector_renderer_cairo_shape_ector_renderer_generic_base_draw(Eo *obj, Ector_Rend if (pd->shape->stroke.fill) eo_do(pd->shape->stroke.fill, ector_renderer_cairo_base_fill()); // Set dash, cap and join + cairo_set_line_width(pd->parent->cairo, (pd->shape->stroke.width * pd->shape->stroke.scale)); + cairo_set_line_cap(pd->parent->cairo, pd->shape->stroke.cap); + cairo_set_line_join(pd->parent->cairo, pd->shape->stroke.join); cairo_stroke(pd->parent->cairo); } else From 26d8641381093828b586e760328bf770a2046bdd Mon Sep 17 00:00:00 2001 From: Subhransu Mohanty Date: Fri, 3 Apr 2015 16:34:06 +0200 Subject: [PATCH 210/251] ector: gradient now uses spread while filling a shape for Cairo backend. Signed-off-by: Cedric BAIL --- src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c | 6 ++++++ src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c b/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c index 1b02c35e66..0764062082 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c @@ -20,6 +20,9 @@ static void (*cairo_pattern_add_color_stop_rgba)(cairo_pattern_t *pattern, doubl double red, double green, double blue, double alpha) = NULL; static void (*cairo_pattern_destroy)(cairo_pattern_t *pattern) = NULL; +typedef enum _cairo_extend_t{cairo_extend}cairo_extend_t; +static void (*cairo_pattern_set_extend)(cairo_pattern_t *pattern, cairo_extend_t extend) = NULL; + typedef struct _Ector_Renderer_Cairo_Gradient_Linear_Data Ector_Renderer_Cairo_Gradient_Linear_Data; struct _Ector_Renderer_Cairo_Gradient_Linear_Data { @@ -53,6 +56,9 @@ _ector_renderer_cairo_gradient_linear_ector_renderer_generic_base_prepare(Eo *ob gd->colors[i].r, gd->colors[i].g, gd->colors[i].b, gd->colors[i].a); + USE(obj, cairo_pattern_set_extend, EINA_FALSE); + cairo_pattern_set_extend(pd->pat, gd->s); + if (!pd->parent) { Eo *parent; diff --git a/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c b/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c index b20256e93f..cb84c53e38 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c @@ -23,6 +23,8 @@ static void (*cairo_pattern_add_color_stop_rgba)(cairo_pattern_t *pattern, doubl double red, double green, double blue, double alpha) = NULL; static void (*cairo_pattern_destroy)(cairo_pattern_t *pattern) = NULL; +typedef enum _cairo_extend_t{cairo_extend}cairo_extend_t; +static void (*cairo_pattern_set_extend)(cairo_pattern_t *pattern, cairo_extend_t extend) = NULL; // FIXME: as long as it is not possible to directly access the parent structure // this will be duplicated from the linear gradient renderer @@ -58,6 +60,9 @@ _ector_renderer_cairo_gradient_radial_ector_renderer_generic_base_prepare(Eo *ob gd->colors[i].r, gd->colors[i].g, gd->colors[i].b, gd->colors[i].a); + USE(obj, cairo_pattern_set_extend, EINA_FALSE); + cairo_pattern_set_extend(pd->pat, gd->s); + if (!pd->parent) { Eo *parent; From a500249b69f2d5f0b4af5e00a23bd43a38ac4718 Mon Sep 17 00:00:00 2001 From: Subhransu Mohanty Date: Fri, 3 Apr 2015 16:34:07 +0200 Subject: [PATCH 211/251] ector: add clipping support for Cairo backend. Signed-off-by: Cedric BAIL --- .../ector/cairo/ector_renderer_cairo_base.c | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/lib/ector/cairo/ector_renderer_cairo_base.c b/src/lib/ector/cairo/ector_renderer_cairo_base.c index 190fb8a090..4396817cd7 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_base.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_base.c @@ -66,6 +66,11 @@ static void (*cairo_set_source_rgba)(cairo_t *cr, static void (*cairo_set_operator)(cairo_t *cr, cairo_operator_t op) = NULL; static void (*cairo_matrix_init_identity)(cairo_matrix_t *matrix) = NULL; +static void (*cairo_new_path)(cairo_t *cr) = NULL; +static void (*cairo_rectangle)(cairo_t *cr, double x, double y, double width, double height) = NULL; +static void (*cairo_clip)(cairo_t *cr) = NULL; +static void (*cairo_device_to_user)(cairo_t *cr, double *x, double *y) = NULL; + typedef struct _Ector_Renderer_Cairo_Base_Data Ector_Renderer_Cairo_Base_Data; struct _Ector_Renderer_Cairo_Base_Data { @@ -176,6 +181,27 @@ _ector_renderer_cairo_base_ector_renderer_generic_base_draw(Eo *obj, cairo_set_source_rgba(pd->parent->cairo, r, g, b, a); + USE(obj, cairo_new_path, EINA_FALSE); + USE(obj, cairo_rectangle, EINA_FALSE); + USE(obj, cairo_clip, EINA_FALSE); + USE(obj, cairo_device_to_user, EINA_FALSE); + if (clips) + { + int clip_count = eina_array_count(clips); + int i=0; + for (; i < clip_count ; i++) + { + Eina_Rectangle *clip = (Eina_Rectangle *)eina_array_data_get(clips, i); + double x = (double)clip->x; + double y = (double)clip->y; + + cairo_new_path(pd->parent->cairo); + cairo_device_to_user(pd->parent->cairo, &x, &y); + cairo_rectangle(pd->parent->cairo, x, y, clip->w, clip->h); + } + cairo_clip(pd->parent->cairo); + } + return EINA_TRUE; } From c9aaa12c07f70f5dec7e6227422868edce740b40 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:34:09 +0200 Subject: [PATCH 212/251] evas: force cpu end opt when switching to Cairo rendering. --- src/modules/evas/engines/software_generic/evas_engine.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/modules/evas/engines/software_generic/evas_engine.c b/src/modules/evas/engines/software_generic/evas_engine.c index 88475d6504..bf711334f0 100644 --- a/src/modules/evas/engines/software_generic/evas_engine.c +++ b/src/modules/evas/engines/software_generic/evas_engine.c @@ -5070,6 +5070,8 @@ _ector_cairo_software_surface_surface_set(Eo *obj, Ector_Cairo_Software_Surface_ pd->height = height; end: + evas_common_cpu_end_opt(); + eo_do(obj, ector_cairo_surface_context_set(pd->ctx)); } From 1f624659162e79c6a70a53866180edc5e7f400a5 Mon Sep 17 00:00:00 2001 From: Subhransu Mohanty Date: Fri, 3 Apr 2015 16:34:10 +0200 Subject: [PATCH 213/251] ector: add mul_col feature in Cairo backend and fixed color handling issue. Signed-off-by: Cedric BAIL --- .../ector/cairo/ector_renderer_cairo_base.c | 16 +++++----- .../ector_renderer_cairo_gradient_linear.c | 12 ++++++-- .../ector_renderer_cairo_gradient_radial.c | 13 ++++++-- .../ector/cairo/ector_renderer_cairo_shape.c | 30 +++++++++++-------- 4 files changed, 43 insertions(+), 28 deletions(-) diff --git a/src/lib/ector/cairo/ector_renderer_cairo_base.c b/src/lib/ector/cairo/ector_renderer_cairo_base.c index 4396817cd7..fad9016244 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_base.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_base.c @@ -88,7 +88,6 @@ _ector_renderer_cairo_base_ector_renderer_generic_base_color_set(Eo *obj EINA_UN Ector_Renderer_Cairo_Base_Data *pd, int r, int g, int b, int a) { - ector_color_argb_unpremul(a, &r ,&g, &b); pd->generic->color.r = r; pd->generic->color.g = g; pd->generic->color.b = b; @@ -104,8 +103,6 @@ _ector_renderer_cairo_base_ector_renderer_generic_base_color_get(Eo *obj EINA_UN if (g) *g = pd->generic->color.g; if (b) *b = pd->generic->color.b; if (a) *a = pd->generic->color.a; - - ector_color_argb_premul(pd->generic->color.a, r, g, b); } static Eina_Bool @@ -145,7 +142,7 @@ _ector_renderer_cairo_base_ector_renderer_generic_base_draw(Eo *obj, Eina_Array *clips EINA_UNUSED, unsigned int mul_col) { - double r, g, b, a; + int r, g, b, a; cairo_operator_t cop; double cx, cy; @@ -165,10 +162,11 @@ _ector_renderer_cairo_base_ector_renderer_generic_base_draw(Eo *obj, break; } - r = ((double)((pd->generic->color.r * R_VAL(&mul_col)) >> 8)) / 255; - g = ((double)((pd->generic->color.g * G_VAL(&mul_col)) >> 8)) / 255; - b = ((double)((pd->generic->color.b * B_VAL(&mul_col)) >> 8)) / 255; - a = ((double)((pd->generic->color.a * A_VAL(&mul_col)) >> 8)) / 255; + r = ((pd->generic->color.r * R_VAL(&mul_col)) >> 8); + g = ((pd->generic->color.g * G_VAL(&mul_col)) >> 8); + b = ((pd->generic->color.b * B_VAL(&mul_col)) >> 8); + a = ((pd->generic->color.a * A_VAL(&mul_col)) >> 8); + ector_color_argb_unpremul(a, &r, &g, &b); cairo_set_operator(pd->parent->cairo, cop); cairo_transform(pd->parent->cairo, &identity); @@ -179,7 +177,7 @@ _ector_renderer_cairo_base_ector_renderer_generic_base_draw(Eo *obj, pd->parent->current.x = pd->generic->origin.x; pd->parent->current.y = pd->generic->origin.y; - cairo_set_source_rgba(pd->parent->cairo, r, g, b, a); + cairo_set_source_rgba(pd->parent->cairo, r/255.0, g/255.0, b/255.0, a/255.0); USE(obj, cairo_new_path, EINA_FALSE); USE(obj, cairo_rectangle, EINA_FALSE); diff --git a/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c b/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c index 0764062082..ce4097bb7f 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c @@ -51,10 +51,16 @@ _ector_renderer_cairo_gradient_linear_ector_renderer_generic_base_prepare(Eo *ob pd->pat = cairo_pattern_create_linear(gld->start.x, gld->start.y, gld->end.x, gld->end.y); + int r,g,b,a; for (i = 0; i < gd->colors_count; i++) - cairo_pattern_add_color_stop_rgba(pd->pat, gd->colors[i].offset, - gd->colors[i].r, gd->colors[i].g, - gd->colors[i].b, gd->colors[i].a); + { + r = gd->colors[i].r; + g = gd->colors[i].g; + b = gd->colors[i].b; + a = gd->colors[i].a; + ector_color_argb_unpremul(a, &r, &g, &b); + cairo_pattern_add_color_stop_rgba(pd->pat, gd->colors[i].offset, r/255.0, g/255.0, b/255.0, a/255.0); + } USE(obj, cairo_pattern_set_extend, EINA_FALSE); cairo_pattern_set_extend(pd->pat, gd->s); diff --git a/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c b/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c index cb84c53e38..4e07754f40 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c @@ -55,10 +55,17 @@ _ector_renderer_cairo_gradient_radial_ector_renderer_generic_base_prepare(Eo *ob pd->pat = cairo_pattern_create_radial(grd->focal.x, grd->focal.y, 0, grd->radial.x, grd->radial.y, grd->radius); + + int r,g,b,a; for (i = 0; i < gd->colors_count; i++) - cairo_pattern_add_color_stop_rgba(pd->pat, gd->colors[i].offset, - gd->colors[i].r, gd->colors[i].g, - gd->colors[i].b, gd->colors[i].a); + { + r = gd->colors[i].r; + g = gd->colors[i].g; + b = gd->colors[i].b; + a = gd->colors[i].a; + ector_color_argb_unpremul(a, &r, &g, &b); + cairo_pattern_add_color_stop_rgba(pd->pat, gd->colors[i].offset, r/255.0, g/255.0, b/255.0, a/255.0); + } USE(obj, cairo_pattern_set_extend, EINA_FALSE); cairo_pattern_set_extend(pd->pat, gd->s); diff --git a/src/lib/ector/cairo/ector_renderer_cairo_shape.c b/src/lib/ector/cairo/ector_renderer_cairo_shape.c index 54f6962a63..b064a5a18c 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_shape.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_shape.c @@ -149,9 +149,9 @@ _ector_renderer_cairo_shape_ector_renderer_generic_base_prepare(Eo *obj, Ector_R static Eina_Bool _ector_renderer_cairo_shape_ector_renderer_generic_base_draw(Eo *obj, Ector_Renderer_Cairo_Shape_Data *pd, Ector_Rop op, Eina_Array *clips, unsigned int mul_col) { + int r, g, b, a; if (pd->path == NULL) return EINA_FALSE; - // FIXME: find a way to set multiple clips eo_do_super(obj, ECTOR_RENDERER_CAIRO_SHAPE_CLASS, ector_renderer_draw(op, clips, mul_col)); USE(obj, cairo_new_path, EINA_FALSE); @@ -163,7 +163,7 @@ _ector_renderer_cairo_shape_ector_renderer_generic_base_draw(Eo *obj, Ector_Rend if (pd->shape->fill) eo_do(pd->shape->fill, ector_renderer_cairo_base_fill()); - if (pd->shape->stroke.color.a > 0) + if (pd->shape->stroke.fill || pd->shape->stroke.color.a > 0) { USE(obj, cairo_fill_preserve, EINA_FALSE); USE(obj, cairo_set_source_rgba, EINA_FALSE); @@ -174,19 +174,23 @@ _ector_renderer_cairo_shape_ector_renderer_generic_base_draw(Eo *obj, Ector_Rend cairo_fill_preserve(pd->parent->cairo); - cairo_set_source_rgba(pd->parent->cairo, - pd->shape->stroke.color.r / 255.0, - pd->shape->stroke.color.g / 255.0, - pd->shape->stroke.color.b / 255.0, - pd->shape->stroke.color.a / 255.0); - if (pd->shape->stroke.fill) eo_do(pd->shape->stroke.fill, ector_renderer_cairo_base_fill()); - // Set dash, cap and join - cairo_set_line_width(pd->parent->cairo, (pd->shape->stroke.width * pd->shape->stroke.scale)); - cairo_set_line_cap(pd->parent->cairo, pd->shape->stroke.cap); - cairo_set_line_join(pd->parent->cairo, pd->shape->stroke.join); - cairo_stroke(pd->parent->cairo); + else + { + r = (((pd->shape->stroke.color.r * R_VAL(&mul_col)) + 0xff) >> 8); + g = (((pd->shape->stroke.color.g * G_VAL(&mul_col)) + 0xff) >> 8); + b = (((pd->shape->stroke.color.b * B_VAL(&mul_col)) + 0xff) >> 8); + a = (((pd->shape->stroke.color.a * A_VAL(&mul_col)) + 0xff) >> 8); + ector_color_argb_unpremul(a, &r, &g, &b); + cairo_set_source_rgba(pd->parent->cairo, r/255.0, g/255.0, b/255.0, a/255.0); + } + + // Set dash, cap and join + cairo_set_line_width(pd->parent->cairo, (pd->shape->stroke.width * pd->shape->stroke.scale * 2)); + cairo_set_line_cap(pd->parent->cairo, pd->shape->stroke.cap); + cairo_set_line_join(pd->parent->cairo, pd->shape->stroke.join); + cairo_stroke(pd->parent->cairo); } else { From 097f46a047a737f5c3ab69060f0a07d1670c42c1 Mon Sep 17 00:00:00 2001 From: Subhransu Mohanty Date: Fri, 3 Apr 2015 16:34:11 +0200 Subject: [PATCH 214/251] evas: flush cpu pipeline before ector drawing. Signed-off-by: Cedric BAIL --- src/modules/evas/engines/software_generic/evas_engine.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/modules/evas/engines/software_generic/evas_engine.c b/src/modules/evas/engines/software_generic/evas_engine.c index bf711334f0..92eb22bd6e 100644 --- a/src/modules/evas/engines/software_generic/evas_engine.c +++ b/src/modules/evas/engines/software_generic/evas_engine.c @@ -3609,6 +3609,9 @@ _draw_thread_ector_surface_set(void *data) unsigned int x = 0; unsigned int y = 0; + // flush the cpu pipeline before ector drawing. + evas_common_cpu_end_opt(); + if (surface) { pixels = evas_cache_image_pixels(&surface->cache_entry); @@ -3631,8 +3634,6 @@ _draw_thread_ector_surface_set(void *data) ector_surface_reference_point_set(x, y)); } - evas_common_cpu_end_opt(); - eina_mempool_free(_mp_command_ector_surface, ector_surface); } From 21ee9897bd1be5ae31e2b343310935acd79e367d Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:34:12 +0200 Subject: [PATCH 215/251] evas: don't track generated content. --- src/examples/evas/.gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/src/examples/evas/.gitignore b/src/examples/evas/.gitignore index d146578d6e..129d8dfc4d 100644 --- a/src/examples/evas/.gitignore +++ b/src/examples/evas/.gitignore @@ -40,3 +40,4 @@ /evas_3d_shadows /evas_3d_parallax_occlusion /evas_vg_simple +/evas_vg_batman From 03c5e052e84c3bf984b80263b3e13236da20ce81 Mon Sep 17 00:00:00 2001 From: Subhransu Mohanty Date: Fri, 3 Apr 2015 16:34:14 +0200 Subject: [PATCH 216/251] efl: simplify append_circle() api implementation. Signed-off-by: Cedric BAIL --- src/lib/efl/interfaces/efl_gfx_shape.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/lib/efl/interfaces/efl_gfx_shape.c b/src/lib/efl/interfaces/efl_gfx_shape.c index 632c5bf979..35683ac010 100644 --- a/src/lib/efl/interfaces/efl_gfx_shape.c +++ b/src/lib/efl/interfaces/efl_gfx_shape.c @@ -788,13 +788,11 @@ _efl_gfx_shape_append_close(Eo *obj, Efl_Gfx_Shape_Data *pd) void _efl_gfx_shape_append_circle(Eo *obj, Efl_Gfx_Shape_Data *pd, - double x, double y, double radius) + double xc, double yc, double radius) { - _efl_gfx_shape_append_move_to(obj, pd, x - radius, y); - _efl_gfx_shape_append_arc_to(obj, pd, x + radius, y, radius, radius, 0, EINA_FALSE, EINA_TRUE); - _efl_gfx_shape_append_arc_to(obj, pd, x, y + radius, radius, radius, 0, EINA_FALSE, EINA_TRUE); - _efl_gfx_shape_append_arc_to(obj, pd, x - radius, y, radius, radius, 0, EINA_FALSE, EINA_TRUE); - _efl_gfx_shape_append_arc_to(obj, pd, x, y - radius, radius, radius, 0, EINA_FALSE, EINA_TRUE); + _efl_gfx_shape_append_move_to(obj, pd, xc - radius, yc); + _efl_gfx_shape_append_arc_to(obj, pd, xc + radius, yc, radius, radius, 0, EINA_TRUE, EINA_TRUE); + _efl_gfx_shape_append_arc_to(obj, pd, xc - radius, yc, radius, radius, 0, EINA_TRUE, EINA_TRUE); } void From 1c093f3660aa8c9ddff4e795ca6a7c73cbdfa1bc Mon Sep 17 00:00:00 2001 From: Subhransu Mohanty Date: Fri, 3 Apr 2015 16:34:15 +0200 Subject: [PATCH 217/251] evas: fix EVAS_RENDERER_DEBUG_TIMING implementation for async rendering Signed-off-by: Cedric BAIL --- src/lib/evas/canvas/evas_render.c | 37 ++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/src/lib/evas/canvas/evas_render.c b/src/lib/evas/canvas/evas_render.c index b761bbe00d..5032b49541 100644 --- a/src/lib/evas/canvas/evas_render.c +++ b/src/lib/evas/canvas/evas_render.c @@ -107,7 +107,7 @@ _time_get() } struct accumulator { - double total, min, max; + double total, min, max, draw_start_time; int samples; const char *what; }; @@ -128,8 +128,27 @@ static struct accumulator sync_accumulator = { }; static void -_accumulate_time(double before, struct accumulator *acc) +_accumulate_time(double before, Eina_Bool async) { + static Eina_Bool async_start = EINA_TRUE; + static double cache_before; + struct accumulator *acc = &sync_accumulator; + if (async) + { + acc = &async_accumulator; + if (async_start) + { + async_start = EINA_FALSE; + cache_before = before; + return; + } + else + { + async_start = EINA_TRUE; + before = cache_before; + } + } + double diff = _time_get() - before; acc->total += diff; @@ -2084,9 +2103,7 @@ evas_render_updates_internal(Evas *eo_e, int redraw_all = 0; Eina_Bool haveup = 0; Evas_Render_Mode render_mode = EVAS_RENDER_MODE_UNDEF; -#ifdef EVAS_RENDER_DEBUG_TIMING - double start_time = _time_get(); -#endif + Eina_Rectangle clip_rect; MAGIC_CHECK(eo_e, Evas, MAGIC_EVAS); @@ -2109,6 +2126,10 @@ evas_render_updates_internal(Evas *eo_e, } } +#ifdef EVAS_RENDER_DEBUG_TIMING + double start_time = _time_get(); +#endif + #ifdef EVAS_CSERVE2 if (evas_cserve2_use_get()) evas_cserve2_dispatch(); @@ -2639,7 +2660,7 @@ evas_render_updates_internal(Evas *eo_e, RD(0, "---]\n"); #ifdef EVAS_RENDER_DEBUG_TIMING - _accumulate_time(start_time, do_async ? &async_accumulator : &sync_accumulator); + _accumulate_time(start_time, do_async); #endif return EINA_TRUE; @@ -2725,6 +2746,10 @@ evas_render_wakeup(Evas *eo_e) evas_render_updates_free(ret_updates); eo_unref(eo_e); + +#ifdef EVAS_RENDER_DEBUG_TIMING + _accumulate_time(0, EINA_TRUE); +#endif } static void From b20872bf68378807e62d14939777ed912bf4bc89 Mon Sep 17 00:00:00 2001 From: Subhransu Mohanty Date: Fri, 3 Apr 2015 16:34:16 +0200 Subject: [PATCH 218/251] ector: add cairo_save() and cairo_restore() to fix the transformation issue. Signed-off-by: Cedric BAIL --- src/lib/ector/cairo/ector_renderer_cairo_base.c | 4 +++- src/lib/ector/cairo/ector_renderer_cairo_shape.c | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/lib/ector/cairo/ector_renderer_cairo_base.c b/src/lib/ector/cairo/ector_renderer_cairo_base.c index fad9016244..bb4aa1f607 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_base.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_base.c @@ -170,10 +170,12 @@ _ector_renderer_cairo_base_ector_renderer_generic_base_draw(Eo *obj, cairo_set_operator(pd->parent->cairo, cop); cairo_transform(pd->parent->cairo, &identity); - if (pd->m) cairo_transform(pd->parent->cairo, pd->m); cx = pd->generic->origin.x - pd->parent->current.x; cy = pd->generic->origin.y - pd->parent->current.y; cairo_translate(pd->parent->cairo, cx, cy); + + if (pd->m) cairo_transform(pd->parent->cairo, pd->m); + pd->parent->current.x = pd->generic->origin.x; pd->parent->current.y = pd->generic->origin.y; diff --git a/src/lib/ector/cairo/ector_renderer_cairo_shape.c b/src/lib/ector/cairo/ector_renderer_cairo_shape.c index b064a5a18c..4e705d9d0b 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_shape.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_shape.c @@ -42,6 +42,9 @@ static void (*cairo_set_line_width)(cairo_t *cr, double width) = NULL; static void (*cairo_set_line_cap)(cairo_t *cr, cairo_line_cap_t line_cap) = NULL; static void (*cairo_set_line_join)(cairo_t *cr, cairo_line_join_t line_join) = NULL; +static void (*cairo_save)(cairo_t *cr) = NULL; +static void (*cairo_restore)(cairo_t *cr) = NULL; + typedef struct _Ector_Renderer_Cairo_Shape_Data Ector_Renderer_Cairo_Shape_Data; struct _Ector_Renderer_Cairo_Shape_Data { @@ -152,6 +155,9 @@ _ector_renderer_cairo_shape_ector_renderer_generic_base_draw(Eo *obj, Ector_Rend int r, g, b, a; if (pd->path == NULL) return EINA_FALSE; + USE(obj, cairo_save, EINA_FALSE); + cairo_save(pd->parent->cairo); + eo_do_super(obj, ECTOR_RENDERER_CAIRO_SHAPE_CLASS, ector_renderer_draw(op, clips, mul_col)); USE(obj, cairo_new_path, EINA_FALSE); @@ -198,6 +204,8 @@ _ector_renderer_cairo_shape_ector_renderer_generic_base_draw(Eo *obj, Ector_Rend cairo_fill(pd->parent->cairo); } + USE(obj, cairo_restore, EINA_FALSE); + cairo_restore(pd->parent->cairo); return EINA_TRUE; } From 72967efd9d7ac098f2197a0c535dc5f322e2067d Mon Sep 17 00:00:00 2001 From: Subhransu Mohanty Date: Fri, 3 Apr 2015 16:34:17 +0200 Subject: [PATCH 219/251] evas: update batman example with transformation and opengl. Signed-off-by: Cedric BAIL --- src/examples/evas/evas-vg-batman.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/examples/evas/evas-vg-batman.c b/src/examples/evas/evas-vg-batman.c index 87a1f6d57b..17ea3a460c 100644 --- a/src/examples/evas/evas-vg-batman.c +++ b/src/examples/evas/evas-vg-batman.c @@ -105,7 +105,7 @@ main(void) if (!ecore_evas_init()) return -1; - + //setenv("ECORE_EVAS_ENGINE", "opengl_x11", 1); ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL); if (!ee) return -1; @@ -137,6 +137,11 @@ main(void) root = evas_object_vg_root_node_get(vg); + Eina_Matrix3 matrix; + eina_matrix3_scale(&matrix, 1.1, 1.1); + evas_vg_node_transformation_set(root, &matrix); + + circle = evas_vg_shape_add(root); evas_vg_shape_shape_append_circle(circle, WIDTH / 2, HEIGHT / 2, 200); evas_vg_node_color_set(circle, 255, 255, 255, 255); From 6c64f2db7405ce7c0cd96603097144b32b2771c9 Mon Sep 17 00:00:00 2001 From: Subhransu Mohanty Date: Fri, 3 Apr 2015 16:34:19 +0200 Subject: [PATCH 220/251] ector: fix transform issue in cairo backend. Signed-off-by: Cedric BAIL --- src/lib/ector/cairo/ector_cairo_surface.c | 8 ++------ src/lib/ector/cairo/ector_renderer_cairo_base.c | 8 +++----- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/lib/ector/cairo/ector_cairo_surface.c b/src/lib/ector/cairo/ector_cairo_surface.c index 8875c04ce7..377fbbd0ca 100644 --- a/src/lib/ector/cairo/ector_cairo_surface.c +++ b/src/lib/ector/cairo/ector_cairo_surface.c @@ -73,7 +73,6 @@ _ector_cairo_surface_ector_generic_surface_renderer_factory_new(Eo *obj, typedef struct _cairo_surface_t cairo_surface_t; -static void (*cairo_translate)(cairo_t *cr, double tx, double ty) = NULL; static void (*cairo_destroy)(cairo_t *cr) = NULL; static cairo_surface_t *(*cairo_image_surface_create)(int format, int width, @@ -118,11 +117,8 @@ _ector_cairo_surface_ector_generic_surface_reference_point_set(Eo *obj EINA_UNUS Ector_Cairo_Surface_Data *pd, int x, int y) { - if (pd->cairo) - { - USE(obj, cairo_translate, ); - cairo_translate(pd->cairo, x, y); - } + pd->current.x = x; + pd->current.y = y; } static void diff --git a/src/lib/ector/cairo/ector_renderer_cairo_base.c b/src/lib/ector/cairo/ector_renderer_cairo_base.c index bb4aa1f607..5a51aae651 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_base.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_base.c @@ -170,15 +170,13 @@ _ector_renderer_cairo_base_ector_renderer_generic_base_draw(Eo *obj, cairo_set_operator(pd->parent->cairo, cop); cairo_transform(pd->parent->cairo, &identity); - cx = pd->generic->origin.x - pd->parent->current.x; - cy = pd->generic->origin.y - pd->parent->current.y; + cx = pd->generic->origin.x + pd->parent->current.x; + cy = pd->generic->origin.y + pd->parent->current.y; + cairo_translate(pd->parent->cairo, cx, cy); if (pd->m) cairo_transform(pd->parent->cairo, pd->m); - pd->parent->current.x = pd->generic->origin.x; - pd->parent->current.y = pd->generic->origin.y; - cairo_set_source_rgba(pd->parent->cairo, r/255.0, g/255.0, b/255.0, a/255.0); USE(obj, cairo_new_path, EINA_FALSE); From 7d0944bda5a8ff1e44813bfd98edebeabd9fd78b Mon Sep 17 00:00:00 2001 From: Subhransu Mohanty Date: Fri, 3 Apr 2015 16:34:21 +0200 Subject: [PATCH 221/251] evas: handle mul_col for ector drawing in gl backend. Signed-off-by: Cedric BAIL --- src/modules/evas/engines/gl_generic/evas_engine.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/modules/evas/engines/gl_generic/evas_engine.c b/src/modules/evas/engines/gl_generic/evas_engine.c index 871ffbb67f..4fddbe7b44 100644 --- a/src/modules/evas/engines/gl_generic/evas_engine.c +++ b/src/modules/evas/engines/gl_generic/evas_engine.c @@ -2232,9 +2232,11 @@ eng_ector_end(void *data, void *context EINA_UNUSED, void *surface EINA_UNUSED, Render_Engine_GL_Generic *re = data; Evas_GL_Image *im; int w, h; + Eina_Bool mul_use; gl_context = re->window_gl_context_get(re->software.ob); w = gl_context->w; h = gl_context->h; + mul_use = gl_context->dc->mul.use; if (use_cairo) { @@ -2248,6 +2250,14 @@ eng_ector_end(void *data, void *context EINA_UNUSED, void *surface EINA_UNUSED, } im = evas_gl_common_image_new_from_copied_data(gl_context, w, h, software_buffer, 1, EVAS_COLORSPACE_ARGB8888); + + if (!mul_use) + { + // @hack as image_draw uses below fields to do colour multiplication. + gl_context->dc->mul.col = ector_color_multiply(0xffffffff,gl_context->dc->col.col); + gl_context->dc->mul.use = EINA_TRUE; + } + // We actually just bluntly push the pixel all over the // destination surface. We don't have the actual information // of the widget size. This is not a problem. @@ -2257,6 +2267,9 @@ eng_ector_end(void *data, void *context EINA_UNUSED, void *surface EINA_UNUSED, evas_gl_common_image_draw(gl_context, im, 0, 0, w, h, 0, 0, w, h, 0); evas_gl_common_image_free(im); + + // restore gl state + gl_context->dc->mul.use = mul_use; } static Evas_Func func, pfunc; From b18b1e89ffc758e6cbca344605bc444fd3cb07e6 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:34:22 +0200 Subject: [PATCH 222/251] evas: fix Windows build. --- src/lib/evas/include/evas_common_private.h | 1 + src/lib/evas/include/evas_private.h | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/lib/evas/include/evas_common_private.h b/src/lib/evas/include/evas_common_private.h index e3d6b07956..6b4cf5e623 100644 --- a/src/lib/evas/include/evas_common_private.h +++ b/src/lib/evas/include/evas_common_private.h @@ -49,6 +49,7 @@ #include #include +#include #ifdef BUILD_LOADER_EET # include diff --git a/src/lib/evas/include/evas_private.h b/src/lib/evas/include/evas_private.h index e45565c9b2..c44a240e5e 100644 --- a/src/lib/evas/include/evas_private.h +++ b/src/lib/evas/include/evas_private.h @@ -5,9 +5,6 @@ # include #endif -#include -#include - #include "Evas.h" #include "../file/evas_module.h" From 0d95e539321315d80f9e7f8aa06b47ca042aa2df Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:34:23 +0200 Subject: [PATCH 223/251] ector: remove useless function for now. --- src/lib/ector/ector_generic_surface.eo | 10 ---------- src/lib/ector/ector_surface.c | 13 ------------- 2 files changed, 23 deletions(-) diff --git a/src/lib/ector/ector_generic_surface.eo b/src/lib/ector/ector_generic_surface.eo index 42a5f3e8a3..5415079906 100644 --- a/src/lib/ector/ector_generic_surface.eo +++ b/src/lib/ector/ector_generic_surface.eo @@ -31,16 +31,6 @@ abstract Ector.Generic.Surface (Eo.Base) @in const(Eo_Class) * type @nonull; } } - update_push { - return: bool; - params { - @in const(Eina_Rectangle) * r @nonull; - @in Ector_Update_Type type; - } - } - update_reset { - return: bool; - } } implements { @virtual .renderer_factory_new; diff --git a/src/lib/ector/ector_surface.c b/src/lib/ector/ector_surface.c index eda912fffe..2f2bf649ca 100644 --- a/src/lib/ector/ector_surface.c +++ b/src/lib/ector/ector_surface.c @@ -26,17 +26,4 @@ _ector_generic_surface_size_get(Eo *obj, { } -Eina_Bool -_ector_generic_surface_update_push(Eo *obj, - Ector_Generic_Surface_Data *pd, - const Eina_Rectangle *r, - Ector_Update_Type type) -{ -} - -Eina_Bool -_ector_generic_surface_update_reset(Eo *obj, Ector_Generic_Surface_Data *pd) -{ -} - #include "ector_generic_surface.eo.c" From 39f7ce192ce46e6df7b659aaf00233251144c4e0 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:34:24 +0200 Subject: [PATCH 224/251] ector: implement surface size property. --- src/lib/ector/ector_surface.c | 9 +++++++-- src/modules/evas/engines/gl_generic/evas_engine.c | 4 +++- src/modules/evas/engines/software_generic/evas_engine.c | 4 +++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/lib/ector/ector_surface.c b/src/lib/ector/ector_surface.c index 2f2bf649ca..23ad7eb2fd 100644 --- a/src/lib/ector/ector_surface.c +++ b/src/lib/ector/ector_surface.c @@ -10,20 +10,25 @@ typedef struct _Ector_Generic_Surface_Data Ector_Generic_Surface_Data; struct _Ector_Generic_Surface_Data { + int w, h; }; void -_ector_generic_surface_size_set(Eo *obj, +_ector_generic_surface_size_set(Eo *obj EINA_UNUSED, Ector_Generic_Surface_Data *pd, int w, int h) { + pd->w = w; + pd->h = h; } void -_ector_generic_surface_size_get(Eo *obj, +_ector_generic_surface_size_get(Eo *obj EINA_UNUSED, Ector_Generic_Surface_Data *pd, int *w, int *h) { + if (w) *w = pd->w; + if (h) *h = pd->h; } #include "ector_generic_surface.eo.c" diff --git a/src/modules/evas/engines/gl_generic/evas_engine.c b/src/modules/evas/engines/gl_generic/evas_engine.c index 4fddbe7b44..45e8ded8f1 100644 --- a/src/modules/evas/engines/gl_generic/evas_engine.c +++ b/src/modules/evas/engines/gl_generic/evas_engine.c @@ -2524,7 +2524,9 @@ _ector_cairo_software_surface_surface_set(Eo *obj, Ector_Cairo_Software_Surface_ pd->height = height; end: - eo_do(obj, ector_cairo_surface_context_set(pd->ctx)); + eo_do(obj, + ector_cairo_surface_context_set(pd->ctx), + ector_surface_size_set(pd->width, pd->height)); } static void diff --git a/src/modules/evas/engines/software_generic/evas_engine.c b/src/modules/evas/engines/software_generic/evas_engine.c index 92eb22bd6e..fb276b9c9d 100644 --- a/src/modules/evas/engines/software_generic/evas_engine.c +++ b/src/modules/evas/engines/software_generic/evas_engine.c @@ -5073,7 +5073,9 @@ _ector_cairo_software_surface_surface_set(Eo *obj, Ector_Cairo_Software_Surface_ end: evas_common_cpu_end_opt(); - eo_do(obj, ector_cairo_surface_context_set(pd->ctx)); + eo_do(obj, + ector_cairo_surface_context_set(pd->ctx), + ector_surface_size_set(pd->width, pd->height)); } void From 5310a3ea9c002bcf376e32db01f59c552412bf25 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:34:25 +0200 Subject: [PATCH 225/251] ector: remove some warning from the Cairo backend. --- src/lib/ector/cairo/ector_renderer_cairo_shape.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/ector/cairo/ector_renderer_cairo_shape.c b/src/lib/ector/cairo/ector_renderer_cairo_shape.c index 4e705d9d0b..61be4ecd19 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_shape.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_shape.c @@ -55,7 +55,7 @@ struct _Ector_Renderer_Cairo_Shape_Data }; static Eina_Bool -_ector_renderer_cairo_shape_path_changed(void *data, Eo *obj, const Eo_Event_Description *desc, void *event_info) +_ector_renderer_cairo_shape_path_changed(void *data, Eo *obj, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED) { Ector_Renderer_Cairo_Shape_Data *pd = data; From 013b18ea6a5aa643a5e3aa759ea868ea1782632f Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:34:26 +0200 Subject: [PATCH 226/251] evas: removing the ability to load file in Evas_Object_VG for now. Without events and animation it is not really useful and that can only be done with a library on top of Ecore. --- src/Makefile_Evas.am | 3 +- src/lib/evas/canvas/evas_object_vg.c | 70 ---------------------------- src/lib/evas/canvas/evas_vg.eo | 6 +-- 3 files changed, 2 insertions(+), 77 deletions(-) diff --git a/src/Makefile_Evas.am b/src/Makefile_Evas.am index 77d1721412..2183302912 100644 --- a/src/Makefile_Evas.am +++ b/src/Makefile_Evas.am @@ -150,8 +150,7 @@ lib/evas/canvas/evas_stats.c \ lib/evas/canvas/evas_touch_point.c \ lib/evas/canvas/evas_map.c \ lib/evas/canvas/evas_gl.c \ -lib/evas/canvas/evas_out.c \ -lib/evas/canvas/evas_vg_loader_svg.c +lib/evas/canvas/evas_out.c # Cache lib_evas_libevas_la_SOURCES += \ diff --git a/src/lib/evas/canvas/evas_object_vg.c b/src/lib/evas/canvas/evas_object_vg.c index afbe045b02..57d4090d68 100644 --- a/src/lib/evas/canvas/evas_object_vg.c +++ b/src/lib/evas/canvas/evas_object_vg.c @@ -19,10 +19,6 @@ struct _Evas_VG_Data void *engine_data; Efl_VG *root; - /* Opening an SVG file (could actually be inside an eet section */ - Eina_File *f; - const char *key; - Eina_Rectangle fill; unsigned int width, height; @@ -375,72 +371,6 @@ evas_object_vg_was_opaque(Evas_Object *eo_obj EINA_UNUSED, return 0; } - -static Eina_Bool -_evas_vg_efl_file_mmap_set(Eo *obj EINA_UNUSED, Evas_VG_Data *pd, - const Eina_File *f, const char *key) -{ - Eina_File *tmp; - - if (f == pd->f && - ((key == NULL && pd->key == NULL) || - (key != NULL && pd->key != NULL && !strcmp(key, pd->key)))) - return EINA_FALSE; - - tmp = f ? eina_file_dup(f) : NULL; - - if (tmp) - { - if (!evas_vg_loader_svg(obj, tmp, NULL)) - { - eina_file_close(tmp); - return EINA_FALSE; - } - } - - // it succeeded. - if (pd->f) eina_file_close(pd->f); - pd->f = tmp; - eina_stringshare_replace(&pd->key, key); - - return EINA_TRUE; -} - -static void -_evas_vg_efl_file_mmap_get(Eo *obj EINA_UNUSED, Evas_VG_Data *pd, - const Eina_File **f, const char **key) -{ - if (f) *f = pd->f; - if (key) *key = pd->key; -} - -Eina_Bool -_evas_vg_efl_file_file_set(Eo *obj, Evas_VG_Data *pd EINA_UNUSED, - const char *file, const char *key) -{ - Eina_File *f; - Eina_Bool r = EINA_FALSE; - - f = eina_file_open(file, EINA_FALSE); - if (!f) return EINA_FALSE; - - eo_do(obj, efl_file_mmap_set(f, key)); - - eina_file_close(f); - return r; -} - -void -_evas_vg_efl_file_file_get(Eo *obj, Evas_VG_Data *pd EINA_UNUSED, - const char **file, const char **key) -{ - const Eina_File *f = NULL; - - eo_do(obj, efl_file_mmap_get(&f, key)); - - if (file) *file = eina_file_filename_get(f); -} - void _evas_vg_efl_gfx_view_size_get(Eo *obj EINA_UNUSED, Evas_VG_Data *pd, int *w, int *h) diff --git a/src/lib/evas/canvas/evas_vg.eo b/src/lib/evas/canvas/evas_vg.eo index 8247f46e44..8c6d3526e1 100644 --- a/src/lib/evas/canvas/evas_vg.eo +++ b/src/lib/evas/canvas/evas_vg.eo @@ -1,4 +1,4 @@ -class Evas.VG (Evas.Object, Efl.File, Efl.Gfx.Fill, Efl.Gfx.View) +class Evas.VG (Evas.Object, Efl.Gfx.Fill, Efl.Gfx.View) { legacy_prefix: evas_object_vg; eo_prefix: evas_obj_vg; @@ -22,10 +22,6 @@ class Evas.VG (Evas.Object, Efl.File, Efl.Gfx.Fill, Efl.Gfx.View) implements { Eo.Base.constructor; Eo.Base.destructor; - Efl.File.file.set; - Efl.File.file.get; - Efl.File.mmap.set; - Efl.File.mmap.get; Efl.Gfx.Fill.fill.set; Efl.Gfx.Fill.fill.get; Efl.Gfx.View.size.set; From 8288e0a880bc2022d1180b6f9680a1dd4a41141e Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:34:27 +0200 Subject: [PATCH 227/251] evas: remove SVG loader code. --- src/lib/evas/canvas/evas_vg_loader_svg.c | 666 ----------------------- 1 file changed, 666 deletions(-) delete mode 100644 src/lib/evas/canvas/evas_vg_loader_svg.c diff --git a/src/lib/evas/canvas/evas_vg_loader_svg.c b/src/lib/evas/canvas/evas_vg_loader_svg.c deleted file mode 100644 index bf726d504a..0000000000 --- a/src/lib/evas/canvas/evas_vg_loader_svg.c +++ /dev/null @@ -1,666 +0,0 @@ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include - -#include -#include -#include "evas_common_private.h" - -typedef struct _Evas_SVG_Loader Evas_SVG_Loader; -struct _Evas_SVG_Loader -{ - Eina_Array *stack; - Eina_Hash *definition; - Evas_Object *vg; - Evas *e; - - unsigned int level; - - Eina_Bool svg : 1; - Eina_Bool defs : 1; - Eina_Bool result : 1; -}; - -static Eina_Bool -_evas_svg_loader_xml_attrs_parser(void *data, const char *key, const char *value) -{ - Evas_SVG_Loader *loader = data; - - fprintf(stderr, "{%s = %s}\n", key, value); - - return EINA_TRUE; -} - -static Eina_Bool -_attrs_id_parser(void *data, const char *key, const char *value) -{ - const char **id = data; - - if (!strcmp(key, "id")) *id = eina_stringshare_add(value); - return EINA_TRUE; -} - -static Eina_Bool -_attrs_size_parser(void *data, const char *key, const char *value) -{ - int width, height; - Evas_Object *vg = data; - Eina_Bool get_w = EINA_FALSE, get_h = EINA_FALSE; - - eo_do(vg, efl_gfx_view_size_get(&width, &height)); - if (!strcmp(key, "width")) - get_w = EINA_TRUE; - else if (!strcmp(key, "height")) - get_h = EINA_TRUE; - - if (get_w || get_h) - { - const char *end = NULL; - unsigned int r; - - r = strtol(value, &end, 10); - if (value != end) - { - if (get_w) width = r; - else if (get_h) height = r; - } - eo_do(vg, efl_gfx_view_size_set(width, height)); - } - - return EINA_TRUE; -} - -static Eina_Bool -_tag_svg_handler(Evas_SVG_Loader *loader, - const char *attrs EINA_UNUSED, - unsigned int attrs_length EINA_UNUSED) -{ - Eo *node; - - if (loader->level != 1) return EINA_FALSE; - - eina_simple_xml_attributes_parse(attrs, attrs_length, - _attrs_size_parser, loader->vg); - - eo_do(loader->vg, node = evas_obj_vg_root_node_get()); - eina_array_push(loader->stack, node); - - loader->svg = EINA_TRUE; - return EINA_TRUE; -} - -static Eina_Bool -_tag_defs_handler(Evas_SVG_Loader *loader, - const char *attrs EINA_UNUSED, - unsigned int attrs_length EINA_UNUSED) -{ - if (loader->level != 1) return EINA_FALSE; - - loader->defs = EINA_TRUE; - return EINA_TRUE; -} - -static Eina_Bool -_tag_linearGradient_handler(Evas_SVG_Loader *loader, - const char *attrs, - unsigned int attrs_length) -{ - const char *id = NULL; - Eo *node; - - if (loader->level < 2) return EINA_FALSE; - - eina_simple_xml_attributes_parse(attrs, attrs_length, - _attrs_id_parser, &id); - - if (!id) return EINA_FALSE; - node = eo_add(EFL_VG_GRADIENT_LINEAR_CLASS, NULL); - if (!node) return EINA_FALSE; - - eina_hash_direct_add(loader->definition, id, node); - eina_array_push(loader->stack, node); - - return EINA_TRUE; -} - -static double -_attr_percent_parser(const char *value) -{ - char *tmp = NULL; - double r; - int neg = 1; - - r = strtod(value, &tmp); - while(tmp && *tmp == '%') tmp++; - - if (tmp && *tmp == '%') - r = r / 100; - - return r * neg; -} - -static unsigned char -_attr_color_component_parser(const char *value, char **end) -{ - double r; - - r = strtod(value + 4, end); - while (isspace(**end)) (*end)++; - if (**end == '%') - r = 255 * r / 100; - while (isspace(**end)) (*end)++; - - if (r < 0 || r > 255) - { - *end = NULL; - return 0; - } - - return lrint(r); -} - -static const struct { - const char *name; - unsigned int value; -} colors[] = { - { "aliceblue", 0xfff0f8ff }, - { "antiquewhite", 0xfffaebd7 }, - { "aqua", 0xff00ffff }, - { "aquamarine", 0xff7fffd4 }, - { "azure", 0xfff0ffff }, - { "beige", 0xfff5f5dc }, - { "bisque", 0xffffe4c4 }, - { "black", 0xff000000 }, - { "blanchedalmond", 0xffffebcd }, - { "blue", 0xff0000ff }, - { "blueviolet", 0xff8a2be2 }, - { "brown", 0xffa52a2a }, - { "burlywood", 0xffdeb887 }, - { "cadetblue", 0xff5f9ea0 }, - { "chartreuse", 0xff7fff00 }, - { "chocolate", 0xffd2691e }, - { "coral", 0xffff7f50 }, - { "cornflowerblue", 0xff6495ed }, - { "cornsilk", 0xfffff8dc }, - { "crimson", 0xffdc143c }, - { "cyan", 0xff00ffff }, - { "darkblue", 0xff00008b }, - { "darkcyan", 0xff008b8b }, - { "darkgoldenrod", 0xffb8860b }, - { "darkgray", 0xffa9a9a9 }, - { "darkgrey", 0xffa9a9a9 }, - { "darkgreen", 0xff006400 }, - { "darkkhaki", 0xffbdb76b }, - { "darkmagenta", 0xff8b008b }, - { "darkolivegreen", 0xff556b2f }, - { "darkorange", 0xffff8c00 }, - { "darkorchid", 0xff9932cc }, - { "darkred", 0xff8b0000 }, - { "darksalmon", 0xffe9967a }, - { "darkseagreen", 0xff8fbc8f }, - { "darkslateblue", 0xff483d8b }, - { "darkslategray", 0xff2f4f4f }, - { "darkslategrey", 0xff2f4f4f }, - { "darkturquoise", 0xff00ced1 }, - { "darkviolet", 0xff9400d3 }, - { "deeppink", 0xffff1493 }, - { "deepskyblue", 0xff00bfff }, - { "dimgray", 0xff696969 }, - { "dimgrey", 0xff696969 }, - { "dodgerblue", 0xff1e90ff }, - { "firebrick", 0xffb22222 }, - { "floralwhite", 0xfffffaf0 }, - { "forestgreen", 0xff228b22 }, - { "fuchsia", 0xffff00ff }, - { "gainsboro", 0xffdcdcdc }, - { "ghostwhite", 0xfff8f8ff }, - { "gold", 0xffffd700 }, - { "goldenrod", 0xffdaa520 }, - { "gray", 0xff808080 }, - { "grey", 0xff808080 }, - { "green", 0xff008000 }, - { "greenyellow", 0xffadff2f }, - { "honeydew", 0xfff0fff0 }, - { "hotpink", 0xffff69b4 }, - { "indianred", 0xffcd5c5c }, - { "indigo", 0xff4b0082 }, - { "ivory", 0xfffffff0 }, - { "khaki", 0xfff0e68c }, - { "lavender", 0xffe6e6fa }, - { "lavenderblush", 0xfffff0f5 }, - { "lawngreen", 0xff7cfc00 }, - { "lemonchiffon", 0xfffffacd }, - { "lightblue", 0xffadd8e6 }, - { "lightcoral", 0xfff08080 }, - { "lightcyan", 0xffe0ffff }, - { "lightgoldenrodyellow", 0xfffafad2 }, - { "lightgray", 0xffd3d3d3 }, - { "lightgrey", 0xffd3d3d3 }, - { "lightgreen", 0xff90ee90 }, - { "lightpink", 0xffffb6c1 }, - { "lightsalmon", 0xffffa07a }, - { "lightseagreen", 0xff20b2aa }, - { "lightskyblue", 0xff87cefa }, - { "lightslategray", 0xff778899 }, - { "lightslategrey", 0xff778899 }, - { "lightsteelblue", 0xffb0c4de }, - { "lightyellow", 0xffffffe0 }, - { "lime", 0xff00ff00 }, - { "limegreen", 0xff32cd32 }, - { "linen", 0xfffaf0e6 }, - { "magenta", 0xffff00ff }, - { "maroon", 0xff800000 }, - { "mediumaquamarine", 0xff66cdaa }, - { "mediumblue", 0xff0000cd }, - { "mediumorchid", 0xffba55d3 }, - { "mediumpurple", 0xff9370d8 }, - { "mediumseagreen", 0xff3cb371 }, - { "mediumslateblue", 0xff7b68ee }, - { "mediumspringgreen", 0xff00fa9a }, - { "mediumturquoise", 0xff48d1cc }, - { "mediumvioletred", 0xffc71585 }, - { "midnightblue", 0xff191970 }, - { "mintcream", 0xfff5fffa }, - { "mistyrose", 0xffffe4e1 }, - { "moccasin", 0xffffe4b5 }, - { "navajowhite", 0xffffdead }, - { "navy", 0xff000080 }, - { "oldlace", 0xfffdf5e6 }, - { "olive", 0xff808000 }, - { "olivedrab", 0xff6b8e23 }, - { "orange", 0xffffa500 }, - { "orangered", 0xffff4500 }, - { "orchid", 0xffda70d6 }, - { "palegoldenrod", 0xffeee8aa }, - { "palegreen", 0xff98fb98 }, - { "paleturquoise", 0xffafeeee }, - { "palevioletred", 0xffd87093 }, - { "papayawhip", 0xffffefd5 }, - { "peachpuff", 0xffffdab9 }, - { "peru", 0xffcd853f }, - { "pink", 0xffffc0cb }, - { "plum", 0xffdda0dd }, - { "powderblue", 0xffb0e0e6 }, - { "purple", 0xff800080 }, - { "red", 0xffff0000 }, - { "rosybrown", 0xffbc8f8f }, - { "royalblue", 0xff4169e1 }, - { "saddlebrown", 0xff8b4513 }, - { "salmon", 0xfffa8072 }, - { "sandybrown", 0xfff4a460 }, - { "seagreen", 0xff2e8b57 }, - { "seashell", 0xfffff5ee }, - { "sienna", 0xffa0522d }, - { "silver", 0xffc0c0c0 }, - { "skyblue", 0xff87ceeb }, - { "slateblue", 0xff6a5acd }, - { "slategray", 0xff708090 }, - { "slategrey", 0xff708090 }, - { "snow", 0xfffffafa }, - { "springgreen", 0xff00ff7f }, - { "steelblue", 0xff4682b4 }, - { "tan", 0xffd2b48c }, - { "teal", 0xff008080 }, - { "thistle", 0xffd8bfd8 }, - { "tomato", 0xffff6347 }, - { "turquoise", 0xff40e0d0 }, - { "violet", 0xffee82ee }, - { "wheat", 0xfff5deb3 }, - { "white", 0xffffffff }, - { "whitesmoke", 0xfff5f5f5 }, - { "yellow", 0xffffff00 }, - { "yellowgreen", 0xff9acd32 } -}; - -static Eina_Bool -_attr_color_parser(void *data, const char *key, const char *value) -{ - unsigned int *color = data; - unsigned char a = A_VAL(color); - unsigned char r = R_VAL(color); - unsigned char g = G_VAL(color); - unsigned char b = B_VAL(color); - - if (!strcmp(key, "stop-color")) - { - unsigned int len = strlen(value); - - if (len == 4 && value[0] == '#') - { - if (isxdigit(value[1]) && - isxdigit(value[2]) && - isxdigit(value[3])) - { - char tmp[2] = { '\0', '\0' }; - - tmp[0] = value[1]; r = strtol(tmp, NULL, 16); - tmp[0] = value[2]; g = strtol(tmp, NULL, 16); - tmp[0] = value[3]; b = strtol(tmp, NULL, 16); - } - } - else if (len == 7 && value[0] == '#') - { - if (isxdigit(value[1]) && - isxdigit(value[2]) && - isxdigit(value[3]) && - isxdigit(value[4]) && - isxdigit(value[5]) && - isxdigit(value[6])) - { - char tmp[3] = { '\0', '\0', '\0' }; - - tmp[0] = value[1]; tmp[1] = value[2]; r = strtol(tmp, NULL, 16); - tmp[0] = value[3]; tmp[1] = value[4]; g = strtol(tmp, NULL, 16); - tmp[0] = value[5]; tmp[1] = value[6]; b = strtol(tmp, NULL, 16); - } - } - else if (len >= 10 && - (value[0] == 'r' || value[0] == 'R') && - (value[1] == 'g' || value[1] == 'G') && - (value[2] == 'b' || value[2] == 'B') && - value[3] == '(' && - value[len - 1] == ')') - { - char *red, *green, *blue; - unsigned char tr, tg, tb; - - tr = _attr_color_component_parser(value + 4, &red); - if (red && *red == ',') - { - tg = _attr_color_component_parser(red + 1, &green); - if (green && *green == ',') - { - tb = _attr_color_component_parser(green + 1, &blue); - if (blue && blue[0] == ')' && blue[1] == '\0') - { - r = tr; g = tg; b = tb; - } - } - } - } - else - { - unsigned int i; - - for (i = 0; i < (sizeof (colors) / sizeof (colors[0])); i++) - if (!strcasecmp(colors[i].name, value)) - { - r = R_VAL(&(colors[i].value)); - g = G_VAL(&(colors[i].value)); - b = B_VAL(&(colors[i].value)); - } - } - } - else if (!strcmp(key, "stop-opacity")) - { - char *tmp = NULL; - double opacity = strtod(value, &tmp); - - if (*tmp == '\0') - a = lrint(opacity * 255); - } - - *color = ARGB_JOIN(a, r, g, b); - - return EINA_TRUE; -} - -static Eina_Bool -_attrs_stop_parser(void *data, const char *key, const char *value) -{ - Efl_Gfx_Gradient_Stop *stop = data; - - if (!strcmp(key, "style")) - { - unsigned int color = 0xFF000000; - - eina_simple_xml_attribute_w3c_parse(value, _attr_color_parser, &color); - - stop->r = R_VAL(&color); - stop->g = G_VAL(&color); - stop->b = B_VAL(&color); - stop->a = A_VAL(&color); - } - else if (!strcmp(key, "offset")) - { - stop->offset = _attr_percent_parser(value); - } - - return EINA_TRUE; -} - -static Eina_Bool -_tag_stop_handler(Evas_SVG_Loader *loader, - const char *attrs, - unsigned int attrs_length) -{ - Efl_Gfx_Gradient_Stop stop = { -1, 0, 0, 0, 0xFF }; - const Efl_Gfx_Gradient_Stop *old = NULL; - Efl_Gfx_Gradient_Stop *new; - unsigned int length = 0; - Eo *node; - - if (loader->level < 3) return EINA_FALSE; - if (((int)eina_array_count(loader->stack) - 1) < 0) return EINA_FALSE; - - node = eina_array_data_get(loader->stack, eina_array_count(loader->stack) - 1); - if (!eo_isa(node, EFL_GFX_GRADIENT_BASE_INTERFACE)) - return EINA_FALSE; - - eina_simple_xml_attributes_parse(attrs, attrs_length, - _attrs_stop_parser, &stop); - - if (stop.offset < 0) return EINA_FALSE; - - eo_do(node, - efl_gfx_gradient_stop_get(&old, &length); - length++; - new = malloc(sizeof (Efl_Gfx_Gradient_Stop) * length); - if (new) - { - if (length > 1) - memcpy(new, old, sizeof (Efl_Gfx_Gradient_Stop) * (length - 1)); - new[length - 1] = stop; - - efl_gfx_gradient_stop_set(new, length); - }); - - return EINA_TRUE; -} - -static Eina_Bool -_tag_g_handler(Evas_SVG_Loader *loader, - const char *attrs, - unsigned int attrs_length) -{ - Eo *node, *parent; - - if (loader->level < 1) return EINA_FALSE; - - parent = eina_array_data_get(loader->stack, eina_array_count(loader->stack) - 1); - - node = eo_add(EFL_VG_CONTAINER_CLASS, parent); - eina_array_push(loader->stack, node); - - return EINA_TRUE; -} - -static Eina_Bool -_tag_rect_handler(Evas_SVG_Loader *loader, - const char *attrs, - unsigned int attrs_length) -{ - Eo *node, *parent; - - if (loader->level < 1) return EINA_FALSE; - - parent = eina_array_data_get(loader->stack, eina_array_count(loader->stack) - 1); - - fprintf(stderr, "recty !\n"); - eina_simple_xml_attributes_parse(attrs, attrs_length, - _evas_svg_loader_xml_attrs_parser, loader); - - return EINA_TRUE; -} - -#define TAG_DEF(Name) \ - { #Name, sizeof (#Name), _tag_##Name##_handler } - -static struct { - const char *tag; - int sz; - Eina_Bool (*tag_handler)(Evas_SVG_Loader *loader, const char *attrs, unsigned int attrs_length); -} open_tags[] = { - TAG_DEF(svg), - TAG_DEF(defs), - TAG_DEF(linearGradient), - TAG_DEF(stop), - TAG_DEF(g), - TAG_DEF(rect) -}; - -static void -_evas_svg_loader_xml_open_parser(Evas_SVG_Loader *loader, - const char *content, unsigned int length) -{ - const char *attrs = NULL; - unsigned int i; - int attrs_length = 0; - int sz = length; - - loader->level++; - - attrs = eina_simple_xml_tag_attributes_find(content, length); - if (attrs) - { - sz = attrs - content; - attrs_length = length - sz; - while ((sz > 0) && (isspace(content[sz - 1]))) - sz--; - } - - for (i = 0; i < sizeof (open_tags) / sizeof(open_tags[0]); i++) - if (open_tags[i].sz - 1 == sz && !strncmp(open_tags[i].tag, content, sz)) - { - if (!open_tags[i].tag_handler(loader, attrs, attrs_length)) - goto on_error; - return ; - } - - fprintf(stderr, "[%s]\n", strndupa(content, sz)); - - eina_simple_xml_attributes_parse(attrs, attrs_length, - _evas_svg_loader_xml_attrs_parser, loader); - - return ; - - on_error: - loader->result = EINA_FALSE; - return ; -} - -static const char *poping[] = { - "linearGradient", - "svg", - "g" -}; - -static void -_evas_svg_loader_xml_close_parser(Evas_SVG_Loader *loader, - const char *content, unsigned int length) -{ - unsigned int i; - Eina_Bool found = EINA_FALSE; - - loader->level--; - - for (i = 0; i < sizeof (poping) / sizeof (poping[0]); i++) - { - unsigned int l = strlen(poping[i]); - - if (!strncmp(content, poping[i], l) && - (content[l] == '\0' || - content[l] == '>' || - isspace(content[l]))) - { - found = EINA_TRUE; - eina_array_pop(loader->stack); - break; - } - } -} - -static Eina_Bool -_evas_svg_loader_parser(void *data, Eina_Simple_XML_Type type, - const char *content, - unsigned int offset EINA_UNUSED, unsigned int length) -{ - Evas_SVG_Loader *loader = data; - - switch (type) - { - case EINA_SIMPLE_XML_OPEN: - _evas_svg_loader_xml_open_parser(loader, content, length); - break; - case EINA_SIMPLE_XML_OPEN_EMPTY: - _evas_svg_loader_xml_open_parser(loader, content, length); - case EINA_SIMPLE_XML_CLOSE: - _evas_svg_loader_xml_close_parser(loader, content, length); - break; - case EINA_SIMPLE_XML_DATA: - case EINA_SIMPLE_XML_CDATA: - case EINA_SIMPLE_XML_DOCTYPE_CHILD: - break; - case EINA_SIMPLE_XML_IGNORED: - case EINA_SIMPLE_XML_COMMENT: - case EINA_SIMPLE_XML_DOCTYPE: - break; - - default: - break; - } - - return EINA_TRUE; -} - -Eina_Bool -evas_vg_loader_svg(Evas_Object *vg, - const Eina_File *f, const char *key EINA_UNUSED) -// For now we don't handle eet section filled with SVG, that's for later -{ - Evas_SVG_Loader loader = { - NULL, NULL, NULL, NULL, - EINA_FALSE, EINA_FALSE, EINA_TRUE - }; - const char *content; - Eina_File *tmp; - unsigned int length; - Eina_Bool r = EINA_FALSE; - - tmp = eina_file_dup(f); - if (!f || !tmp) return EINA_FALSE; - - length = eina_file_size_get(tmp); - content = eina_file_map_all(tmp, EINA_FILE_SEQUENTIAL); - - if (!content) goto on_error; - - loader.stack = eina_array_new(8); - loader.definition = eina_hash_stringshared_new(eo_del); - loader.vg = vg; - loader.e = evas_object_evas_get(vg); - - r = eina_simple_xml_parse(content, length, EINA_TRUE, - _evas_svg_loader_parser, &loader); - - eina_array_free(loader.stack); - eina_hash_free(loader.definition); - eina_file_map_free(tmp, (void*) content); - - on_error: - eina_file_close(tmp); - - return loader.result && r; -} From 30e2b8398ecd5dc2ecd54113e0066fd4e4a20b84 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:34:28 +0200 Subject: [PATCH 228/251] efl: add path bounding box computation. This code does compute the largest possible bounding box not a minimal one. --- src/lib/efl/interfaces/efl_gfx_shape.c | 30 +++++++++++++++++++++++++ src/lib/efl/interfaces/efl_gfx_shape.eo | 10 +++++++++ 2 files changed, 40 insertions(+) diff --git a/src/lib/efl/interfaces/efl_gfx_shape.c b/src/lib/efl/interfaces/efl_gfx_shape.c index 35683ac010..97a1e38e36 100644 --- a/src/lib/efl/interfaces/efl_gfx_shape.c +++ b/src/lib/efl/interfaces/efl_gfx_shape.c @@ -202,6 +202,36 @@ _efl_gfx_shape_path_length_get(Eo *obj EINA_UNUSED, Efl_Gfx_Shape_Data *pd, if (points) *points = pd->points_count; } +void +_efl_gfx_shape_bounding_box_get(Eo *obj EINA_UNUSED, + Efl_Gfx_Shape_Data *pd, + Eina_Rectangle *r) +{ + double minx, miny, maxx, maxy; + unsigned int i; + + EINA_RECTANGLE_SET(r, 0, 0, 0, 0); + + if (pd->points_count <= 0) return ; + + minx = pd->points[0]; + miny = pd->points[1]; + maxx = pd->points[0]; + maxy = pd->points[1]; + + for (i = 1; i < pd->points_count; i += 2) + { + minx = minx < pd->points[i] ? minx : pd->points[i]; + miny = miny < pd->points[i + 1] ? miny : pd->points[i + 1]; + maxx = maxx > pd->points[i] ? maxx : pd->points[i]; + maxy = maxy > pd->points[i + 1] ? maxy : pd->points[i + 1]; + } + + EINA_RECTANGLE_SET(r, + minx, miny, + maxx - minx, maxy - miny); +} + void _efl_gfx_shape_current_get(Eo *obj EINA_UNUSED, Efl_Gfx_Shape_Data *pd, double *x, double *y) diff --git a/src/lib/efl/interfaces/efl_gfx_shape.eo b/src/lib/efl/interfaces/efl_gfx_shape.eo index 7452fe610e..9340fe0604 100644 --- a/src/lib/efl/interfaces/efl_gfx_shape.eo +++ b/src/lib/efl/interfaces/efl_gfx_shape.eo @@ -189,6 +189,16 @@ mixin Efl.Gfx.Shape @in Eo *dup_from; /*@ Shape object from where data will be copied.*/ } } + bounding_box_get { + /*@ + Compute and return the bounding box of the currently set path + + @since 1.14 + */ + params { + @out Eina_Rectangle r; /*@ Contain the bounding box of the currently set path */ + } + } reset { /*@ Reset the shape data of the shape object. From 7bca6c00f427e5d636d6988d0b637bead49017e3 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:34:29 +0200 Subject: [PATCH 229/251] ector: fix the return type of ector_renderer_bounds_get. --- src/lib/ector/ector_renderer_generic_base.eo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/ector/ector_renderer_generic_base.eo b/src/lib/ector/ector_renderer_generic_base.eo index 50e7e94cdc..38d6bef0cc 100644 --- a/src/lib/ector/ector_renderer_generic_base.eo +++ b/src/lib/ector/ector_renderer_generic_base.eo @@ -88,7 +88,7 @@ abstract Ector.Renderer.Generic.Base (Eo.Base) bounds_get { return: bool @warn_unused; params { - @out Eina_Rectangle *r; + @out Eina_Rectangle r; } } draw { From 2d9bccbfdc3c35ea85bb1424cac165f46f12e1c7 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:34:30 +0200 Subject: [PATCH 230/251] ector: implements bounds_get for Ector_Renderer_Cairo_Shape. --- .../ector/cairo/ector_renderer_cairo_shape.c | 17 +++++++++++++++++ .../ector/cairo/ector_renderer_cairo_shape.eo | 1 + 2 files changed, 18 insertions(+) diff --git a/src/lib/ector/cairo/ector_renderer_cairo_shape.c b/src/lib/ector/cairo/ector_renderer_cairo_shape.c index 61be4ecd19..055d2447ff 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_shape.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_shape.c @@ -220,6 +220,23 @@ _ector_renderer_cairo_shape_ector_renderer_cairo_base_fill(Eo *obj EINA_UNUSED, return EINA_FALSE; } +static Eina_Bool +_ector_renderer_cairo_shape_ector_renderer_generic_base_bounds_get(Eo *obj, + Ector_Renderer_Cairo_Shape_Data *pd EINA_UNUSED, + Eina_Rectangle *r) +{ + Ector_Renderer_Cairo_Base_Data *bd; + + // FIXME: It should be possible to actually ask cairo about that + eo_do(obj, efl_gfx_shape_bounding_box_get(r)); + + bd = eo_data_scope_get(obj, ECTOR_RENDERER_CAIRO_BASE_CLASS); + r->x += bd->generic->origin.x; + r->y += bd->generic->origin.y; + + return EINA_TRUE; +} + void _ector_renderer_cairo_shape_eo_base_constructor(Eo *obj, Ector_Renderer_Cairo_Shape_Data *pd) { diff --git a/src/lib/ector/cairo/ector_renderer_cairo_shape.eo b/src/lib/ector/cairo/ector_renderer_cairo_shape.eo index 7dd1b3141e..e9d4a173c7 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_shape.eo +++ b/src/lib/ector/cairo/ector_renderer_cairo_shape.eo @@ -5,6 +5,7 @@ class Ector.Renderer.Cairo.Shape (Ector.Renderer.Cairo.Base, Ector.Renderer.Gene implements { Ector.Renderer.Generic.Base.prepare; Ector.Renderer.Generic.Base.draw; + Ector.Renderer.Generic.Base.bounds_get; Ector.Renderer.Cairo.Base.fill; Eo.Base.constructor; Eo.Base.destructor; From 510a3e42e84859d6e883c19c08c9e8ed06ac0d78 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:37:55 +0200 Subject: [PATCH 231/251] ector: implements bounds_get for gradients in Cairo backend. --- src/lib/ector/cairo/ector_cairo_private.h | 16 ++++++++++++++++ .../ector/cairo/ector_renderer_cairo_base.c | 15 --------------- .../ector_renderer_cairo_gradient_linear.c | 19 +++++++++++++++++++ .../ector_renderer_cairo_gradient_linear.eo | 1 + .../ector_renderer_cairo_gradient_radial.c | 18 ++++++++++++++++++ .../ector_renderer_cairo_gradient_radial.eo | 1 + 6 files changed, 55 insertions(+), 15 deletions(-) diff --git a/src/lib/ector/cairo/ector_cairo_private.h b/src/lib/ector/cairo/ector_cairo_private.h index 07446a82c2..486f9addd8 100644 --- a/src/lib/ector/cairo/ector_cairo_private.h +++ b/src/lib/ector/cairo/ector_cairo_private.h @@ -3,7 +3,15 @@ typedef void cairo_pattern_t; +typedef struct { + double xx; double yx; + double xy; double yy; + double x0; double y0; +} cairo_matrix_t; + typedef struct _Ector_Cairo_Surface_Data Ector_Cairo_Surface_Data; +typedef struct _Ector_Renderer_Cairo_Base_Data Ector_Renderer_Cairo_Base_Data; + struct _Ector_Cairo_Surface_Data { cairo_t *cairo; @@ -14,6 +22,14 @@ struct _Ector_Cairo_Surface_Data Eina_Bool internal : 1; }; +struct _Ector_Renderer_Cairo_Base_Data +{ + Ector_Cairo_Surface_Data *parent; + Ector_Renderer_Generic_Base_Data *generic; + + cairo_matrix_t *m; +}; + #define CHECK_CAIRO(Parent) (!(Parent && Parent->cairo)) #define USE(Obj, Sym, Error) \ diff --git a/src/lib/ector/cairo/ector_renderer_cairo_base.c b/src/lib/ector/cairo/ector_renderer_cairo_base.c index 5a51aae651..795b57cce5 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_base.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_base.c @@ -12,12 +12,6 @@ #include "ector_private.h" #include "ector_cairo_private.h" -typedef struct { - double xx; double yx; - double xy; double yy; - double x0; double y0; -} cairo_matrix_t; - typedef enum { CAIRO_OPERATOR_CLEAR, @@ -71,15 +65,6 @@ static void (*cairo_rectangle)(cairo_t *cr, double x, double y, double width, do static void (*cairo_clip)(cairo_t *cr) = NULL; static void (*cairo_device_to_user)(cairo_t *cr, double *x, double *y) = NULL; -typedef struct _Ector_Renderer_Cairo_Base_Data Ector_Renderer_Cairo_Base_Data; -struct _Ector_Renderer_Cairo_Base_Data -{ - Ector_Cairo_Surface_Data *parent; - Ector_Renderer_Generic_Base_Data *generic; - - cairo_matrix_t *m; -}; - static cairo_matrix_t identity; // Cairo need unpremul color, so force unpremul here diff --git a/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c b/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c index ce4097bb7f..e44734c15b 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c @@ -117,6 +117,25 @@ _ector_renderer_cairo_gradient_linear_ector_renderer_cairo_base_fill(Eo *obj, return EINA_TRUE; } +static Eina_Bool +_ector_renderer_cairo_gradient_linear_ector_renderer_generic_base_bounds_get(Eo *obj, + Ector_Renderer_Cairo_Gradient_Linear_Data *pd EINA_UNUSED, + Eina_Rectangle *r) +{ + Ector_Renderer_Generic_Gradient_Linear_Data *gld; + Ector_Renderer_Cairo_Base_Data *bd; + + gld = eo_data_scope_get(obj, ECTOR_RENDERER_GENERIC_GRADIENT_RADIAL_MIXIN); + bd = eo_data_scope_get(obj, ECTOR_RENDERER_CAIRO_BASE_CLASS); + EINA_RECTANGLE_SET(r, + bd->generic->origin.x + gld->start.x, + bd->generic->origin.y + gld->start.y, + gld->end.x - gld->start.x, + gld->end.y - gld->start.x); + + return EINA_TRUE; +} + void _ector_renderer_cairo_gradient_linear_eo_base_destructor(Eo *obj, Ector_Renderer_Cairo_Gradient_Linear_Data *pd) diff --git a/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.eo b/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.eo index 3d4ed9a5d1..64c60561c5 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.eo +++ b/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.eo @@ -5,6 +5,7 @@ class Ector.Renderer.Cairo.Gradient_Linear (Ector.Renderer.Cairo.Base, Ector.Ren implements { Ector.Renderer.Generic.Base.prepare; Ector.Renderer.Generic.Base.draw; + Ector.Renderer.Generic.Base.bounds_get; Ector.Renderer.Cairo.Base.fill; Eo.Base.destructor; Efl.Gfx.Gradient.Base.stop.set; diff --git a/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c b/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c index 4e07754f40..1f4ac8e6cf 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c @@ -122,6 +122,24 @@ _ector_renderer_cairo_gradient_radial_ector_renderer_cairo_base_fill(Eo *obj, Ec return EINA_TRUE; } +static Eina_Bool +_ector_renderer_cairo_gradient_radial_ector_renderer_generic_base_bounds_get(Eo *obj EINA_UNUSED, + Ector_Renderer_Cairo_Gradient_Radial_Data *pd EINA_UNUSED, + Eina_Rectangle *r) +{ + Ector_Renderer_Generic_Gradient_Radial_Data *gld; + Ector_Renderer_Cairo_Base_Data *bd; + + gld = eo_data_scope_get(obj, ECTOR_RENDERER_GENERIC_GRADIENT_RADIAL_MIXIN); + bd = eo_data_scope_get(obj, ECTOR_RENDERER_CAIRO_BASE_CLASS); + EINA_RECTANGLE_SET(r, + bd->generic->origin.x + gld->radial.x - gld->radius, + bd->generic->origin.y + gld->radial.y - gld->radius, + gld->radius * 2, gld->radius * 2); + + return EINA_TRUE; +} + void _ector_renderer_cairo_gradient_radial_eo_base_destructor(Eo *obj, Ector_Renderer_Cairo_Gradient_Radial_Data *pd) diff --git a/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.eo b/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.eo index fb79bec7d5..c05ad9ea05 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.eo +++ b/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.eo @@ -5,6 +5,7 @@ class Ector.Renderer.Cairo.Gradient_Radial (Ector.Renderer.Cairo.Base, Ector.Ren implements { Ector.Renderer.Generic.Base.prepare; Ector.Renderer.Generic.Base.draw; + Ector.Renderer.Generic.Base.bounds_get; Ector.Renderer.Cairo.Base.fill; Eo.Base.destructor; Efl.Gfx.Gradient.Base.stop.set; From 9e3cfef8d7e94675b6162b5b406a11397345362e Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:37:56 +0200 Subject: [PATCH 232/251] evas: add missing boung_get and above/below get. --- src/lib/evas/canvas/efl_vg_gradient_linear.eo | 1 + src/lib/evas/canvas/efl_vg_gradient_radial.eo | 1 + src/lib/evas/canvas/evas_vg_container.c | 1 - src/lib/evas/canvas/evas_vg_gradient_linear.c | 7 ++++++- src/lib/evas/canvas/evas_vg_gradient_radial.c | 5 +++++ src/lib/evas/canvas/evas_vg_node.c | 6 +++--- 6 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/lib/evas/canvas/efl_vg_gradient_linear.eo b/src/lib/evas/canvas/efl_vg_gradient_linear.eo index bc9c664168..8e323090a7 100644 --- a/src/lib/evas/canvas/efl_vg_gradient_linear.eo +++ b/src/lib/evas/canvas/efl_vg_gradient_linear.eo @@ -6,6 +6,7 @@ class Efl.VG.Gradient_Linear (Efl.VG.Gradient, Efl.Gfx.Gradient.Linear) Efl.Gfx.Gradient.Linear.start.get; Efl.Gfx.Gradient.Linear.end.set; Efl.Gfx.Gradient.Linear.end.get; + Efl.VG.Base.bound_get; Eo.Base.constructor; Eo.Base.destructor; } diff --git a/src/lib/evas/canvas/efl_vg_gradient_radial.eo b/src/lib/evas/canvas/efl_vg_gradient_radial.eo index 0d60589d0a..acf0d3b50d 100644 --- a/src/lib/evas/canvas/efl_vg_gradient_radial.eo +++ b/src/lib/evas/canvas/efl_vg_gradient_radial.eo @@ -8,6 +8,7 @@ class Efl.VG.Gradient_Radial (Efl.VG.Gradient, Efl.Gfx.Gradient.Radial) Efl.Gfx.Gradient.Radial.radius.get; Efl.Gfx.Gradient.Radial.focal.set; Efl.Gfx.Gradient.Radial.focal.get; + Efl.VG.Base.bound_get; Eo.Base.constructor; Eo.Base.destructor; } diff --git a/src/lib/evas/canvas/evas_vg_container.c b/src/lib/evas/canvas/evas_vg_container.c index e85ff3b4ad..5b5d60e22b 100644 --- a/src/lib/evas/canvas/evas_vg_container.c +++ b/src/lib/evas/canvas/evas_vg_container.c @@ -82,5 +82,4 @@ evas_vg_container_add(Efl_VG *parent) return eo_add(EFL_VG_CONTAINER_CLASS, parent); } - #include "efl_vg_container.eo.c" diff --git a/src/lib/evas/canvas/evas_vg_gradient_linear.c b/src/lib/evas/canvas/evas_vg_gradient_linear.c index 814bd478df..8c152dac66 100644 --- a/src/lib/evas/canvas/evas_vg_gradient_linear.c +++ b/src/lib/evas/canvas/evas_vg_gradient_linear.c @@ -101,12 +101,17 @@ _efl_vg_gradient_linear_eo_base_constructor(Eo *obj, nd->data = pd; } -void +static void _efl_vg_gradient_linear_eo_base_destructor(Eo *obj, Efl_VG_Gradient_Linear_Data *pd EINA_UNUSED) { eo_do_super(obj, MY_CLASS, eo_destructor()); } +static Eina_Bool +_efl_vg_gradient_linear_efl_vg_base_bound_get(Eo *obj, Efl_VG_Gradient_Linear_Data *pd, Eina_Rectangle *r) +{ +} + EAPI void evas_vg_gradient_linear_start_set(Eo *obj, double x, double y) { diff --git a/src/lib/evas/canvas/evas_vg_gradient_radial.c b/src/lib/evas/canvas/evas_vg_gradient_radial.c index d28f9f4c2f..fe4bb789c3 100644 --- a/src/lib/evas/canvas/evas_vg_gradient_radial.c +++ b/src/lib/evas/canvas/evas_vg_gradient_radial.c @@ -124,6 +124,11 @@ _efl_vg_gradient_radial_eo_base_destructor(Eo *obj, eo_do_super(obj, MY_CLASS, eo_destructor()); } +static Eina_Bool +_efl_vg_gradient_radial_efl_vg_base_bound_get(Eo *obj, Efl_VG_Gradient_Radial_Data *pd, Eina_Rectangle *r) +{ +} + EAPI void evas_vg_gradient_radial_center_set(Eo *obj, double x, double y) { diff --git a/src/lib/evas/canvas/evas_vg_node.c b/src/lib/evas/canvas/evas_vg_node.c index c5e96b8dc0..7197f891ff 100644 --- a/src/lib/evas/canvas/evas_vg_node.c +++ b/src/lib/evas/canvas/evas_vg_node.c @@ -408,16 +408,16 @@ _efl_vg_base_efl_gfx_stack_lower(Eo *obj, Efl_VG_Base_Data *pd EINA_UNUSED) } Efl_Gfx_Stack * -_efl_vg_base_efl_gfx_stack_below_get(Eo *obj, Efl_VG_Base_Data *pd) +_efl_vg_base_efl_gfx_stack_below_get(Eo *obj EINA_UNUSED, Efl_VG_Base_Data *pd EINA_UNUSED) { - // FIXME: need to implement bound_get + // Actually a VG base node won't have any children so nothing stacked below it. return NULL; } Efl_Gfx_Stack * _efl_vg_base_efl_gfx_stack_above_get(Eo *obj, Efl_VG_Base_Data *pd) { - // FIXME: need to implement bound_get + // FIXME bound get every child of my parent and go up until vg root return NULL; } From 1821aef0c6be069176eaea4d84fd91d82fdb84de Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:37:57 +0200 Subject: [PATCH 233/251] evas: add forgotten static in some Efl_VG object. --- src/lib/evas/canvas/evas_vg_node.c | 46 ++++++++++++------------- src/lib/evas/canvas/evas_vg_root_node.c | 4 +-- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/lib/evas/canvas/evas_vg_node.c b/src/lib/evas/canvas/evas_vg_node.c index 7197f891ff..93be7670c5 100644 --- a/src/lib/evas/canvas/evas_vg_node.c +++ b/src/lib/evas/canvas/evas_vg_node.c @@ -22,7 +22,7 @@ _efl_vg_base_property_changed(void *data, Eo *obj, const Eo_Event_Description *d return EINA_TRUE; } -void +static void _efl_vg_base_transformation_set(Eo *obj, Efl_VG_Base_Data *pd, const Eina_Matrix3 *m) @@ -43,7 +43,7 @@ _efl_vg_base_transformation_get(Eo *obj EINA_UNUSED, Efl_VG_Base_Data *pd) return pd->m; } -void +static void _efl_vg_base_origin_set(Eo *obj, Efl_VG_Base_Data *pd, double x, double y) @@ -54,7 +54,7 @@ _efl_vg_base_origin_set(Eo *obj, _efl_vg_base_changed(obj); } -void +static void _efl_vg_base_origin_get(Eo *obj EINA_UNUSED, Efl_VG_Base_Data *pd, double *x, double *y) @@ -63,7 +63,7 @@ _efl_vg_base_origin_get(Eo *obj EINA_UNUSED, if (y) *y = pd->y; } -void +static void _efl_vg_base_efl_gfx_base_position_set(Eo *obj EINA_UNUSED, Efl_VG_Base_Data *pd, int x, int y) @@ -74,7 +74,7 @@ _efl_vg_base_efl_gfx_base_position_set(Eo *obj EINA_UNUSED, _efl_vg_base_changed(obj); } -void +static void _efl_vg_base_efl_gfx_base_position_get(Eo *obj EINA_UNUSED, Efl_VG_Base_Data *pd, int *x, int *y) @@ -83,7 +83,7 @@ _efl_vg_base_efl_gfx_base_position_get(Eo *obj EINA_UNUSED, if (y) *y = pd->y; } -void +static void _efl_vg_base_efl_gfx_base_visible_set(Eo *obj EINA_UNUSED, Efl_VG_Base_Data *pd, Eina_Bool v) { @@ -93,14 +93,14 @@ _efl_vg_base_efl_gfx_base_visible_set(Eo *obj EINA_UNUSED, } -Eina_Bool +static Eina_Bool _efl_vg_base_efl_gfx_base_visible_get(Eo *obj EINA_UNUSED, Efl_VG_Base_Data *pd) { return pd->visibility; } -void +static void _efl_vg_base_efl_gfx_base_color_set(Eo *obj EINA_UNUSED, Efl_VG_Base_Data *pd, int r, int g, int b, int a) @@ -133,7 +133,7 @@ _efl_vg_base_efl_gfx_base_color_set(Eo *obj EINA_UNUSED, _efl_vg_base_changed(obj); } -Eina_Bool +static Eina_Bool _efl_vg_base_efl_gfx_base_color_part_set(Eo *obj, Efl_VG_Base_Data *pd, const char *part, int r, int g, int b, int a) @@ -144,7 +144,7 @@ _efl_vg_base_efl_gfx_base_color_part_set(Eo *obj, Efl_VG_Base_Data *pd, return EINA_TRUE; } -void +static void _efl_vg_base_efl_gfx_base_color_get(Eo *obj EINA_UNUSED, Efl_VG_Base_Data *pd, int *r, int *g, int *b, int *a) @@ -155,7 +155,7 @@ _efl_vg_base_efl_gfx_base_color_get(Eo *obj EINA_UNUSED, if (a) *a = pd->a; } -Eina_Bool +static Eina_Bool _efl_vg_base_efl_gfx_base_color_part_get(Eo *obj, Efl_VG_Base_Data *pd, const char *part, int *r, int *g, int *b, int *a) @@ -166,7 +166,7 @@ _efl_vg_base_efl_gfx_base_color_part_get(Eo *obj, Efl_VG_Base_Data *pd, return EINA_TRUE; } -void +static void _efl_vg_base_mask_set(Eo *obj EINA_UNUSED, Efl_VG_Base_Data *pd, Efl_VG_Base *r) @@ -179,13 +179,13 @@ _efl_vg_base_mask_set(Eo *obj EINA_UNUSED, _efl_vg_base_changed(obj); } -Efl_VG_Base* +static Efl_VG_Base* _efl_vg_base_mask_get(Eo *obj EINA_UNUSED, Efl_VG_Base_Data *pd) { return pd->mask; } -void +static void _efl_vg_base_efl_gfx_base_size_get(Eo *obj, Efl_VG_Base_Data *pd EINA_UNUSED, int *w, int *h) @@ -229,7 +229,7 @@ _efl_vg_base_parent_checked_get(Eo *obj, return EINA_FALSE; } -void +static void _efl_vg_base_eo_base_constructor(Eo *obj, Efl_VG_Base_Data *pd) { @@ -245,7 +245,7 @@ _efl_vg_base_eo_base_constructor(Eo *obj, pd->changed = EINA_TRUE; } -void +static void _efl_vg_base_eo_base_parent_set(Eo *obj, Efl_VG_Base_Data *pd EINA_UNUSED, Eo *parent) @@ -291,7 +291,7 @@ _efl_vg_base_eo_base_parent_set(Eo *obj, return ; } -void +static void _efl_vg_base_efl_gfx_stack_raise(Eo *obj, Efl_VG_Base_Data *pd EINA_UNUSED) { Efl_VG_Container_Data *cd; @@ -319,7 +319,7 @@ _efl_vg_base_efl_gfx_stack_raise(Eo *obj, Efl_VG_Base_Data *pd EINA_UNUSED) eo_error_set(obj); } -void +static void _efl_vg_base_efl_gfx_stack_stack_above(Eo *obj, Efl_VG_Base_Data *pd EINA_UNUSED, Efl_Gfx_Stack *above) @@ -349,7 +349,7 @@ _efl_vg_base_efl_gfx_stack_stack_above(Eo *obj, eo_error_set(obj); } -void +static void _efl_vg_base_efl_gfx_stack_stack_below(Eo *obj, Efl_VG_Base_Data *pd EINA_UNUSED, Efl_Gfx_Stack *below) @@ -379,7 +379,7 @@ _efl_vg_base_efl_gfx_stack_stack_below(Eo *obj, eo_error_set(obj); } -void +static void _efl_vg_base_efl_gfx_stack_lower(Eo *obj, Efl_VG_Base_Data *pd EINA_UNUSED) { Efl_VG_Container_Data *cd; @@ -407,21 +407,21 @@ _efl_vg_base_efl_gfx_stack_lower(Eo *obj, Efl_VG_Base_Data *pd EINA_UNUSED) eo_error_set(obj); } -Efl_Gfx_Stack * +static Efl_Gfx_Stack * _efl_vg_base_efl_gfx_stack_below_get(Eo *obj EINA_UNUSED, Efl_VG_Base_Data *pd EINA_UNUSED) { // Actually a VG base node won't have any children so nothing stacked below it. return NULL; } -Efl_Gfx_Stack * +static Efl_Gfx_Stack * _efl_vg_base_efl_gfx_stack_above_get(Eo *obj, Efl_VG_Base_Data *pd) { // FIXME bound get every child of my parent and go up until vg root return NULL; } -Eina_Bool +static Eina_Bool _efl_vg_base_original_bound_get(Eo *obj, Efl_VG_Base_Data *pd, Eina_Rectangle *r) diff --git a/src/lib/evas/canvas/evas_vg_root_node.c b/src/lib/evas/canvas/evas_vg_root_node.c index 8362dfde6d..65dbb0220f 100644 --- a/src/lib/evas/canvas/evas_vg_root_node.c +++ b/src/lib/evas/canvas/evas_vg_root_node.c @@ -47,7 +47,7 @@ _evas_vg_root_node_changed(void *data, Eo *obj, return EINA_TRUE; } -void +static void _efl_vg_root_node_eo_base_parent_set(Eo *obj, Efl_VG_Root_Node_Data *pd, Eo *parent) @@ -65,7 +65,7 @@ _efl_vg_root_node_eo_base_parent_set(Eo *obj, } } -void +static void _efl_vg_root_node_eo_base_constructor(Eo *obj, Efl_VG_Root_Node_Data *pd) { From 0eeb19d688b68f10c2b4379e6b7c868b6ba33870 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:37:58 +0200 Subject: [PATCH 234/251] evas: implement stack below and above get for Efl.VG object. --- src/lib/evas/canvas/evas_vg_node.c | 111 +++++++++++++++++++++++++++-- 1 file changed, 104 insertions(+), 7 deletions(-) diff --git a/src/lib/evas/canvas/evas_vg_node.c b/src/lib/evas/canvas/evas_vg_node.c index 93be7670c5..2b274e54ce 100644 --- a/src/lib/evas/canvas/evas_vg_node.c +++ b/src/lib/evas/canvas/evas_vg_node.c @@ -2,6 +2,7 @@ #include "evas_private.h" #include "evas_vg_private.h" +#include "efl_vg_root_node.eo.h" #include #include @@ -407,18 +408,114 @@ _efl_vg_base_efl_gfx_stack_lower(Eo *obj, Efl_VG_Base_Data *pd EINA_UNUSED) eo_error_set(obj); } -static Efl_Gfx_Stack * -_efl_vg_base_efl_gfx_stack_below_get(Eo *obj EINA_UNUSED, Efl_VG_Base_Data *pd EINA_UNUSED) +static Eo * +_efl_vg_base_root_parent_get(Eo *obj) { - // Actually a VG base node won't have any children so nothing stacked below it. - return NULL; + Eo *parent; + + if (eo_isa(obj, EFL_VG_ROOT_NODE_CLASS)) + return obj; + + eo_do(obj, parent = eo_parent_get()); + + if (!parent) return NULL; + return _efl_vg_base_root_parent_get(parent); +} + +static void +_efl_vg_base_walk_down_at(Eo *root, Eina_Array *a, Eina_Rectangle *r) +{ + Eina_Rectangle bound; + + eo_do(root, efl_vg_bound_get(&bound)); + if (!eina_rectangles_intersect(&bound, r)) return ; + + eina_array_push(a, root); + + if (eo_isa(root, EFL_VG_CONTAINER_CLASS)) + { + Efl_VG_Container_Data *cd; + Eina_List *l; + Eo *child; + + cd = eo_data_scope_get(root, EFL_VG_CONTAINER_CLASS); + EINA_LIST_FOREACH(cd->children, l, child) + _efl_vg_base_walk_down_at(child, a, r); + } +} + +static void +_efl_vg_base_object_at(Eo *obj, Eina_Array *a, Eina_Rectangle *r) +{ + Eo *root; + + root = _efl_vg_base_root_parent_get(obj); + if (!root) return ; + + _efl_vg_base_walk_down_at(root, a, r); } static Efl_Gfx_Stack * -_efl_vg_base_efl_gfx_stack_above_get(Eo *obj, Efl_VG_Base_Data *pd) +_efl_vg_base_efl_gfx_stack_below_get(Eo *obj, Efl_VG_Base_Data *pd EINA_UNUSED) { - // FIXME bound get every child of my parent and go up until vg root - return NULL; + Eina_Rectangle r; + Eina_Array a; + Eo *current; + Eo *below = NULL; + Eina_Array_Iterator iterator; + unsigned int i; + + eo_do(obj, efl_vg_bound_get(&r)); + + eina_array_step_set(&a, sizeof (Eina_Array), 8); + + _efl_vg_base_object_at(obj, &a, &r); + + EINA_ARRAY_ITER_NEXT(&a, i, current, iterator) + if (current == obj) + break; + + if (current == obj) + { + i++; + if (i < eina_array_count(&a)) + below = eina_array_data_get(&a, i); + } + + eina_array_flush(&a); + + return below; +} + +static Efl_Gfx_Stack * +_efl_vg_base_efl_gfx_stack_above_get(Eo *obj, Efl_VG_Base_Data *pd EINA_UNUSED) +{ + Eina_Rectangle r; + Eina_Array a; + Eo *current; + Eo *above = NULL; + Eina_Array_Iterator iterator; + unsigned int i; + + eo_do(obj, efl_vg_bound_get(&r)); + + eina_array_step_set(&a, sizeof (Eina_Array), 8); + + _efl_vg_base_object_at(obj, &a, &r); + + EINA_ARRAY_ITER_NEXT(&a, i, current, iterator) + if (current == obj) + break; + + if (current == obj) + { + if (i > 0) + above = eina_array_data_get(&a, i - 1); + } + + eina_array_flush(&a); + + return above; } static Eina_Bool From 2613d17844245172d17a88bd321f53237fa9b5bc Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:37:59 +0200 Subject: [PATCH 235/251] evas: remove unused function, no need for untested code. --- src/lib/evas/canvas/efl_vg_base.eo | 11 ----------- src/lib/evas/canvas/evas_vg_node.c | 8 -------- 2 files changed, 19 deletions(-) diff --git a/src/lib/evas/canvas/efl_vg_base.eo b/src/lib/evas/canvas/efl_vg_base.eo index 2b8d9e7e93..e522b5d760 100644 --- a/src/lib/evas/canvas/efl_vg_base.eo +++ b/src/lib/evas/canvas/efl_vg_base.eo @@ -71,17 +71,6 @@ abstract Efl.VG.Base (Eo.Base, Efl.Gfx.Base, Efl.Gfx.Stack) @out Eina_Rectangle r; /*@ bounding box to be returned */ } } - original_bound_get { - /*@ - Give the bounding box in screen coordinate as defined in - the file or at the insertion of the object (before any scaling). - @since 1.14 - */ - return: bool @warn_unused; - params { - @out Eina_Rectangle r; /*@ original bounding box to be returned */ - } - } } implements { Eo.Base.parent.set; diff --git a/src/lib/evas/canvas/evas_vg_node.c b/src/lib/evas/canvas/evas_vg_node.c index 2b274e54ce..c2b791f405 100644 --- a/src/lib/evas/canvas/evas_vg_node.c +++ b/src/lib/evas/canvas/evas_vg_node.c @@ -518,14 +518,6 @@ _efl_vg_base_efl_gfx_stack_above_get(Eo *obj, Efl_VG_Base_Data *pd EINA_UNUSED) return above; } -static Eina_Bool -_efl_vg_base_original_bound_get(Eo *obj, - Efl_VG_Base_Data *pd, - Eina_Rectangle *r) -{ - return EINA_FALSE; -} - EAPI Eina_Bool evas_vg_node_visible_get(Eo *obj) { From c1836b97edd63f65f5e655faa18d61b4e745326c Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:38:00 +0200 Subject: [PATCH 236/251] evas: remove Efl.VG.Image for now as it was not implemented. --- src/Makefile_Evas.am | 4 +- src/lib/evas/Evas_Eo.h | 1 - src/lib/evas/canvas/efl_vg_image.eo | 35 --------- src/lib/evas/canvas/evas_vg_image.c | 110 ---------------------------- 4 files changed, 1 insertion(+), 149 deletions(-) delete mode 100644 src/lib/evas/canvas/efl_vg_image.eo delete mode 100644 src/lib/evas/canvas/evas_vg_image.c diff --git a/src/Makefile_Evas.am b/src/Makefile_Evas.am index 2183302912..af8343ff9d 100644 --- a/src/Makefile_Evas.am +++ b/src/Makefile_Evas.am @@ -39,8 +39,7 @@ evas_eolian_files = \ lib/evas/canvas/efl_vg_root_node.eo \ lib/evas/canvas/efl_vg_gradient.eo \ lib/evas/canvas/efl_vg_gradient_radial.eo \ - lib/evas/canvas/efl_vg_gradient_linear.eo \ - lib/evas/canvas/efl_vg_image.eo + lib/evas/canvas/efl_vg_gradient_linear.eo evas_eolian_c = $(evas_eolian_files:%.eo=%.eo.c) evas_eolian_h = $(evas_eolian_files:%.eo=%.eo.h) \ @@ -222,7 +221,6 @@ lib/evas/canvas/evas_vg_gradient.c \ lib/evas/canvas/evas_vg_gradient_linear.c \ lib/evas/canvas/evas_vg_gradient_radial.c \ lib/evas/canvas/evas_vg_utils.c \ -lib/evas/canvas/evas_vg_image.c \ lib/evas/canvas/evas_vg_shape.c # Engine diff --git a/src/lib/evas/Evas_Eo.h b/src/lib/evas/Evas_Eo.h index 49e1da2939..1e1c639bb0 100644 --- a/src/lib/evas/Evas_Eo.h +++ b/src/lib/evas/Evas_Eo.h @@ -861,4 +861,3 @@ typedef enum _Evas_3D_Material_Attrib #include "canvas/efl_vg_gradient.eo.h" #include "canvas/efl_vg_gradient_linear.eo.h" #include "canvas/efl_vg_gradient_radial.eo.h" -#include "canvas/efl_vg_image.eo.h" diff --git a/src/lib/evas/canvas/efl_vg_image.eo b/src/lib/evas/canvas/efl_vg_image.eo deleted file mode 100644 index 62d74510f4..0000000000 --- a/src/lib/evas/canvas/efl_vg_image.eo +++ /dev/null @@ -1,35 +0,0 @@ -class Efl.VG.Image (Efl.VG.Base, Efl.File) -{ - legacy_prefix: evas_vg_image; - properties { - position { - set { - } - get { - } - values { - int x; - int y; - } - } - size { - set { - } - get { - } - values { - uint w; - uint h; - } - } - // FIXME: add aspect ratio following SVG specification - } - implements { - Efl.File.file.set; - Efl.File.file.get; - Efl.File.mmap.set; - Efl.File.mmap.get; - Eo.Base.constructor; - Eo.Base.destructor; - } -} \ No newline at end of file diff --git a/src/lib/evas/canvas/evas_vg_image.c b/src/lib/evas/canvas/evas_vg_image.c deleted file mode 100644 index 1bb0b1bc50..0000000000 --- a/src/lib/evas/canvas/evas_vg_image.c +++ /dev/null @@ -1,110 +0,0 @@ -#include "evas_common_private.h" -#include "evas_private.h" - -#include - -#include "evas_vg_private.h" - -typedef struct _Efl_VG_Image_Data Efl_VG_Image_Data; -struct _Efl_VG_Image_Data -{ - // FIXME: only manipulate Eina_File internally. - Eina_File *f; - Eina_Stringshare *key; - - int x, y; - unsigned int w, h; -}; - -static void -_efl_vg_image_position_set(Eo *obj, Efl_VG_Image_Data *pd, int x, int y) -{ - pd->x = x; - pd->y = y; - - _efl_vg_base_changed(obj); -} - -static void -_efl_vg_image_position_get(Eo *obj, Efl_VG_Image_Data *pd, int *x, int *y) -{ - if (x) *x = pd->x; - if (y) *y = pd->y; -} - -static void -_efl_vg_image_size_set(Eo *obj, Efl_VG_Image_Data *pd, - unsigned int w, unsigned int h) -{ - pd->w = w; - pd->h = h; - - _efl_vg_base_changed(obj); -} - -static void -_efl_vg_image_size_get(Eo *obj, Efl_VG_Image_Data *pd, - unsigned int *w, unsigned int *h) -{ - if (w) *w = pd->w; - if (h) *h = pd->h; -} - -static Eina_Bool -_efl_vg_image_efl_file_mmap_set(Eo *obj EINA_UNUSED, Efl_VG_Image_Data *pd, - const Eina_File *f, const char *key) -{ - Eina_File *tmp = pd->f; - - pd->f = eina_file_dup(f); - eina_file_close(tmp); - eina_stringshare_replace(&pd->key, key); - - _efl_vg_base_changed(obj); - - return EINA_TRUE; -} - -static void -_efl_vg_image_efl_file_mmap_get(Eo *obj EINA_UNUSED, Efl_VG_Image_Data *pd, - const Eina_File **f, const char **key) -{ - if (f) *f = pd->f; - if (key) *key = pd->key; -} - -static Eina_Bool -_efl_vg_image_efl_file_file_set(Eo *obj, Efl_VG_Image_Data *pd, - const char *file, const char *key) -{ - Eina_File *tmp; - Eina_Bool r; - - tmp = eina_file_open(file, EINA_FALSE); - r = _efl_vg_image_efl_file_mmap_set(obj, pd, tmp, key); - eina_file_close(tmp); - - return r; -} - -static void -_efl_vg_image_efl_file_file_get(Eo *obj EINA_UNUSED, Efl_VG_Image_Data *pd, - const char **file, const char **key) -{ - if (file) *file = eina_file_filename_get(pd->f); - if (key) *key = pd->key; -} - -static void -_efl_vg_image_eo_base_constructor(Eo *obj, Efl_VG_Image_Data *pd) -{ - eo_error_set(obj); -} - -static void -_efl_vg_image_eo_base_destructor(Eo *obj, Efl_VG_Image_Data *pd) -{ - eo_error_set(obj); -} - -#include "efl_vg_image.eo.c" From 600e69d226e8cdb960fb88e4d30a0af5d4277cd1 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:38:04 +0200 Subject: [PATCH 237/251] evas: implements efl_vg_bound_get in all Efl.VG object. --- src/lib/evas/canvas/evas_vg_gradient_linear.c | 7 +++++++ src/lib/evas/canvas/evas_vg_gradient_radial.c | 8 ++++++++ src/lib/evas/canvas/evas_vg_shape.c | 6 ++++-- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/lib/evas/canvas/evas_vg_gradient_linear.c b/src/lib/evas/canvas/evas_vg_gradient_linear.c index 8c152dac66..dee38f4ca4 100644 --- a/src/lib/evas/canvas/evas_vg_gradient_linear.c +++ b/src/lib/evas/canvas/evas_vg_gradient_linear.c @@ -110,6 +110,13 @@ _efl_vg_gradient_linear_eo_base_destructor(Eo *obj, Efl_VG_Gradient_Linear_Data static Eina_Bool _efl_vg_gradient_linear_efl_vg_base_bound_get(Eo *obj, Efl_VG_Gradient_Linear_Data *pd, Eina_Rectangle *r) { + Efl_VG_Base_Data *nd; + + nd = eo_data_scope_get(obj, EFL_VG_BASE_CLASS); + EINA_RECTANGLE_SET(r, + nd->x + pd->start.x, nd->y + pd->start.y, + pd->end.x - pd->start.x, pd->end.y - pd->start.x); + return EINA_TRUE; } EAPI void diff --git a/src/lib/evas/canvas/evas_vg_gradient_radial.c b/src/lib/evas/canvas/evas_vg_gradient_radial.c index fe4bb789c3..9b8495312b 100644 --- a/src/lib/evas/canvas/evas_vg_gradient_radial.c +++ b/src/lib/evas/canvas/evas_vg_gradient_radial.c @@ -127,6 +127,14 @@ _efl_vg_gradient_radial_eo_base_destructor(Eo *obj, static Eina_Bool _efl_vg_gradient_radial_efl_vg_base_bound_get(Eo *obj, Efl_VG_Gradient_Radial_Data *pd, Eina_Rectangle *r) { + Efl_VG_Base_Data *nd; + + nd = eo_data_scope_get(obj, EFL_VG_BASE_CLASS); + EINA_RECTANGLE_SET(r, + nd->x + pd->center.x - pd->radius, + nd->y + pd->center.y - pd->radius, + pd->radius * 2, pd->radius * 2); + return EINA_TRUE; } EAPI void diff --git a/src/lib/evas/canvas/evas_vg_shape.c b/src/lib/evas/canvas/evas_vg_shape.c index c33c6a864c..62c64497fa 100644 --- a/src/lib/evas/canvas/evas_vg_shape.c +++ b/src/lib/evas/canvas/evas_vg_shape.c @@ -30,10 +30,12 @@ struct _Efl_VG_Shape_Data static Eina_Bool _efl_vg_shape_efl_vg_base_bound_get(Eo *obj, - Efl_VG_Shape_Data *pd, + Efl_VG_Shape_Data *pd EINA_UNUSED, Eina_Rectangle *r) { - return EINA_FALSE; + // FIXME: Use the renderer bounding box when it has been created instead of an estimation + eo_do(obj, efl_gfx_shape_bounding_box_get(r)); + return EINA_TRUE; } static void From 65fb92831b8572b41b8b5c50ebc2e8586ed2140b Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:38:06 +0200 Subject: [PATCH 238/251] ector: there is no need for bounds get to return a Eina_Bool. --- src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c | 4 +--- src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c | 4 +--- src/lib/ector/cairo/ector_renderer_cairo_shape.c | 4 +--- src/lib/ector/ector_renderer_generic_base.eo | 1 - 4 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c b/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c index e44734c15b..4fb05ceae9 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c @@ -117,7 +117,7 @@ _ector_renderer_cairo_gradient_linear_ector_renderer_cairo_base_fill(Eo *obj, return EINA_TRUE; } -static Eina_Bool +static void _ector_renderer_cairo_gradient_linear_ector_renderer_generic_base_bounds_get(Eo *obj, Ector_Renderer_Cairo_Gradient_Linear_Data *pd EINA_UNUSED, Eina_Rectangle *r) @@ -132,8 +132,6 @@ _ector_renderer_cairo_gradient_linear_ector_renderer_generic_base_bounds_get(Eo bd->generic->origin.y + gld->start.y, gld->end.x - gld->start.x, gld->end.y - gld->start.x); - - return EINA_TRUE; } void diff --git a/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c b/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c index 1f4ac8e6cf..f3332c76db 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c @@ -122,7 +122,7 @@ _ector_renderer_cairo_gradient_radial_ector_renderer_cairo_base_fill(Eo *obj, Ec return EINA_TRUE; } -static Eina_Bool +static void _ector_renderer_cairo_gradient_radial_ector_renderer_generic_base_bounds_get(Eo *obj EINA_UNUSED, Ector_Renderer_Cairo_Gradient_Radial_Data *pd EINA_UNUSED, Eina_Rectangle *r) @@ -136,8 +136,6 @@ _ector_renderer_cairo_gradient_radial_ector_renderer_generic_base_bounds_get(Eo bd->generic->origin.x + gld->radial.x - gld->radius, bd->generic->origin.y + gld->radial.y - gld->radius, gld->radius * 2, gld->radius * 2); - - return EINA_TRUE; } void diff --git a/src/lib/ector/cairo/ector_renderer_cairo_shape.c b/src/lib/ector/cairo/ector_renderer_cairo_shape.c index 055d2447ff..e4706ea710 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_shape.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_shape.c @@ -220,7 +220,7 @@ _ector_renderer_cairo_shape_ector_renderer_cairo_base_fill(Eo *obj EINA_UNUSED, return EINA_FALSE; } -static Eina_Bool +static void _ector_renderer_cairo_shape_ector_renderer_generic_base_bounds_get(Eo *obj, Ector_Renderer_Cairo_Shape_Data *pd EINA_UNUSED, Eina_Rectangle *r) @@ -233,8 +233,6 @@ _ector_renderer_cairo_shape_ector_renderer_generic_base_bounds_get(Eo *obj, bd = eo_data_scope_get(obj, ECTOR_RENDERER_CAIRO_BASE_CLASS); r->x += bd->generic->origin.x; r->y += bd->generic->origin.y; - - return EINA_TRUE; } void diff --git a/src/lib/ector/ector_renderer_generic_base.eo b/src/lib/ector/ector_renderer_generic_base.eo index 38d6bef0cc..e82b0223f9 100644 --- a/src/lib/ector/ector_renderer_generic_base.eo +++ b/src/lib/ector/ector_renderer_generic_base.eo @@ -86,7 +86,6 @@ abstract Ector.Renderer.Generic.Base (Eo.Base) } methods { bounds_get { - return: bool @warn_unused; params { @out Eina_Rectangle r; } From 990c088f6b7833b3052b90a5b5aec3de4f44ddd2 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:38:07 +0200 Subject: [PATCH 239/251] evas: align naming with ector, use bounds. --- src/lib/evas/canvas/efl_vg_base.eo | 5 ++--- src/lib/evas/canvas/efl_vg_container.eo | 2 +- src/lib/evas/canvas/efl_vg_gradient_linear.eo | 2 +- src/lib/evas/canvas/efl_vg_gradient_radial.eo | 2 +- src/lib/evas/canvas/efl_vg_shape.eo | 2 +- src/lib/evas/canvas/evas_vg_container.c | 12 ++++-------- src/lib/evas/canvas/evas_vg_gradient_linear.c | 5 ++--- src/lib/evas/canvas/evas_vg_gradient_radial.c | 5 ++--- src/lib/evas/canvas/evas_vg_node.c | 18 +++++++++--------- src/lib/evas/canvas/evas_vg_shape.c | 5 ++--- 10 files changed, 25 insertions(+), 33 deletions(-) diff --git a/src/lib/evas/canvas/efl_vg_base.eo b/src/lib/evas/canvas/efl_vg_base.eo index e522b5d760..e54256771e 100644 --- a/src/lib/evas/canvas/efl_vg_base.eo +++ b/src/lib/evas/canvas/efl_vg_base.eo @@ -59,14 +59,13 @@ abstract Efl.VG.Base (Eo.Base, Efl.Gfx.Base, Efl.Gfx.Stack) } */ } methods { - bound_get { + bounds_get { /*@ Give the bounding box in screen coordinate as being drawn. It will start as the control box until it is refined once the shape is computed. @since 1.14 */ - return: bool @warn_unused; params { @out Eina_Rectangle r; /*@ bounding box to be returned */ } @@ -90,6 +89,6 @@ abstract Efl.VG.Base (Eo.Base, Efl.Gfx.Base, Efl.Gfx.Stack) Efl.Gfx.Stack.stack_above; Efl.Gfx.Stack.raise; Efl.Gfx.Stack.lower; - @virtual .bound_get; + @virtual .bounds_get; } } \ No newline at end of file diff --git a/src/lib/evas/canvas/efl_vg_container.eo b/src/lib/evas/canvas/efl_vg_container.eo index 4d8a0853c0..0c954e2696 100644 --- a/src/lib/evas/canvas/efl_vg_container.eo +++ b/src/lib/evas/canvas/efl_vg_container.eo @@ -4,6 +4,6 @@ class Efl.VG.Container (Efl.VG.Base) implements { Eo.Base.constructor; Eo.Base.destructor; - Efl.VG.Base.bound_get; + Efl.VG.Base.bounds_get; } } diff --git a/src/lib/evas/canvas/efl_vg_gradient_linear.eo b/src/lib/evas/canvas/efl_vg_gradient_linear.eo index 8e323090a7..4aaddd4fd7 100644 --- a/src/lib/evas/canvas/efl_vg_gradient_linear.eo +++ b/src/lib/evas/canvas/efl_vg_gradient_linear.eo @@ -6,7 +6,7 @@ class Efl.VG.Gradient_Linear (Efl.VG.Gradient, Efl.Gfx.Gradient.Linear) Efl.Gfx.Gradient.Linear.start.get; Efl.Gfx.Gradient.Linear.end.set; Efl.Gfx.Gradient.Linear.end.get; - Efl.VG.Base.bound_get; + Efl.VG.Base.bounds_get; Eo.Base.constructor; Eo.Base.destructor; } diff --git a/src/lib/evas/canvas/efl_vg_gradient_radial.eo b/src/lib/evas/canvas/efl_vg_gradient_radial.eo index acf0d3b50d..62eb0868d2 100644 --- a/src/lib/evas/canvas/efl_vg_gradient_radial.eo +++ b/src/lib/evas/canvas/efl_vg_gradient_radial.eo @@ -8,7 +8,7 @@ class Efl.VG.Gradient_Radial (Efl.VG.Gradient, Efl.Gfx.Gradient.Radial) Efl.Gfx.Gradient.Radial.radius.get; Efl.Gfx.Gradient.Radial.focal.set; Efl.Gfx.Gradient.Radial.focal.get; - Efl.VG.Base.bound_get; + Efl.VG.Base.bounds_get; Eo.Base.constructor; Eo.Base.destructor; } diff --git a/src/lib/evas/canvas/efl_vg_shape.eo b/src/lib/evas/canvas/efl_vg_shape.eo index ab6468cc90..ee43e83d04 100644 --- a/src/lib/evas/canvas/efl_vg_shape.eo +++ b/src/lib/evas/canvas/efl_vg_shape.eo @@ -40,7 +40,7 @@ class Efl.VG.Shape (Efl.VG.Base, Efl.Gfx.Shape) Efl.Gfx.Shape.stroke_join; Efl.Gfx.Base.color_part.set; Efl.Gfx.Base.color_part.get; - Efl.VG.Base.bound_get; + Efl.VG.Base.bounds_get; Eo.Base.constructor; Eo.Base.destructor; } diff --git a/src/lib/evas/canvas/evas_vg_container.c b/src/lib/evas/canvas/evas_vg_container.c index 5b5d60e22b..ba0eeec8ca 100644 --- a/src/lib/evas/canvas/evas_vg_container.c +++ b/src/lib/evas/canvas/evas_vg_container.c @@ -45,8 +45,8 @@ _efl_vg_container_eo_base_destructor(Eo *obj, eo_do_super(obj, MY_CLASS, eo_destructor()); } -static Eina_Bool -_efl_vg_container_efl_vg_base_bound_get(Eo *obj EINA_UNUSED, +static void +_efl_vg_container_efl_vg_base_bounds_get(Eo *obj EINA_UNUSED, Efl_VG_Container_Data *pd, Eina_Rectangle *r) { @@ -55,25 +55,21 @@ _efl_vg_container_efl_vg_base_bound_get(Eo *obj EINA_UNUSED, Eina_List *l; Eo *child; - if (!r) return EINA_FALSE; - EINA_RECTANGLE_SET(&s, -1, -1, 0, 0); EINA_LIST_FOREACH(pd->children, l, child) { if (first) { - eo_do(child, efl_vg_bound_get(r)); + eo_do(child, efl_vg_bounds_get(r)); first = EINA_FALSE; } else { - eo_do(child, efl_vg_bound_get(&s)); + eo_do(child, efl_vg_bounds_get(&s)); eina_rectangle_union(r, &s); } } - // returning EINA_FALSE if no bouding box was found - return first ? EINA_FALSE : EINA_TRUE; } EAPI Efl_VG* diff --git a/src/lib/evas/canvas/evas_vg_gradient_linear.c b/src/lib/evas/canvas/evas_vg_gradient_linear.c index dee38f4ca4..9f05fac4ad 100644 --- a/src/lib/evas/canvas/evas_vg_gradient_linear.c +++ b/src/lib/evas/canvas/evas_vg_gradient_linear.c @@ -107,8 +107,8 @@ _efl_vg_gradient_linear_eo_base_destructor(Eo *obj, Efl_VG_Gradient_Linear_Data eo_do_super(obj, MY_CLASS, eo_destructor()); } -static Eina_Bool -_efl_vg_gradient_linear_efl_vg_base_bound_get(Eo *obj, Efl_VG_Gradient_Linear_Data *pd, Eina_Rectangle *r) +static void +_efl_vg_gradient_linear_efl_vg_base_bounds_get(Eo *obj, Efl_VG_Gradient_Linear_Data *pd, Eina_Rectangle *r) { Efl_VG_Base_Data *nd; @@ -116,7 +116,6 @@ _efl_vg_gradient_linear_efl_vg_base_bound_get(Eo *obj, Efl_VG_Gradient_Linear_Da EINA_RECTANGLE_SET(r, nd->x + pd->start.x, nd->y + pd->start.y, pd->end.x - pd->start.x, pd->end.y - pd->start.x); - return EINA_TRUE; } EAPI void diff --git a/src/lib/evas/canvas/evas_vg_gradient_radial.c b/src/lib/evas/canvas/evas_vg_gradient_radial.c index 9b8495312b..e79f4fde2d 100644 --- a/src/lib/evas/canvas/evas_vg_gradient_radial.c +++ b/src/lib/evas/canvas/evas_vg_gradient_radial.c @@ -124,8 +124,8 @@ _efl_vg_gradient_radial_eo_base_destructor(Eo *obj, eo_do_super(obj, MY_CLASS, eo_destructor()); } -static Eina_Bool -_efl_vg_gradient_radial_efl_vg_base_bound_get(Eo *obj, Efl_VG_Gradient_Radial_Data *pd, Eina_Rectangle *r) +static void +_efl_vg_gradient_radial_efl_vg_base_bounds_get(Eo *obj, Efl_VG_Gradient_Radial_Data *pd, Eina_Rectangle *r) { Efl_VG_Base_Data *nd; @@ -134,7 +134,6 @@ _efl_vg_gradient_radial_efl_vg_base_bound_get(Eo *obj, Efl_VG_Gradient_Radial_Da nd->x + pd->center.x - pd->radius, nd->y + pd->center.y - pd->radius, pd->radius * 2, pd->radius * 2); - return EINA_TRUE; } EAPI void diff --git a/src/lib/evas/canvas/evas_vg_node.c b/src/lib/evas/canvas/evas_vg_node.c index c2b791f405..4254e5909a 100644 --- a/src/lib/evas/canvas/evas_vg_node.c +++ b/src/lib/evas/canvas/evas_vg_node.c @@ -191,11 +191,11 @@ _efl_vg_base_efl_gfx_base_size_get(Eo *obj, Efl_VG_Base_Data *pd EINA_UNUSED, int *w, int *h) { - Eina_Rectangle bound = { 0, 0, 0, 0 }; + Eina_Rectangle r = { 0, 0, 0, 0 }; - eo_do(obj, efl_vg_bound_get(&bound)); - if (w) *w = bound.w; - if (h) *h = bound.h; + eo_do(obj, efl_vg_bounds_get(&r)); + if (w) *w = r.w; + if (h) *h = r.h; } // Parent should be a container otherwise dismissing the stacking operation @@ -425,10 +425,10 @@ _efl_vg_base_root_parent_get(Eo *obj) static void _efl_vg_base_walk_down_at(Eo *root, Eina_Array *a, Eina_Rectangle *r) { - Eina_Rectangle bound; + Eina_Rectangle bounds; - eo_do(root, efl_vg_bound_get(&bound)); - if (!eina_rectangles_intersect(&bound, r)) return ; + eo_do(root, efl_vg_bounds_get(&bounds)); + if (!eina_rectangles_intersect(&bounds, r)) return ; eina_array_push(a, root); @@ -465,7 +465,7 @@ _efl_vg_base_efl_gfx_stack_below_get(Eo *obj, Efl_VG_Base_Data *pd EINA_UNUSED) Eina_Array_Iterator iterator; unsigned int i; - eo_do(obj, efl_vg_bound_get(&r)); + eo_do(obj, efl_vg_bounds_get(&r)); eina_array_step_set(&a, sizeof (Eina_Array), 8); @@ -497,7 +497,7 @@ _efl_vg_base_efl_gfx_stack_above_get(Eo *obj, Efl_VG_Base_Data *pd EINA_UNUSED) Eina_Array_Iterator iterator; unsigned int i; - eo_do(obj, efl_vg_bound_get(&r)); + eo_do(obj, efl_vg_bounds_get(&r)); eina_array_step_set(&a, sizeof (Eina_Array), 8); diff --git a/src/lib/evas/canvas/evas_vg_shape.c b/src/lib/evas/canvas/evas_vg_shape.c index 62c64497fa..644f9e6002 100644 --- a/src/lib/evas/canvas/evas_vg_shape.c +++ b/src/lib/evas/canvas/evas_vg_shape.c @@ -28,14 +28,13 @@ struct _Efl_VG_Shape_Data } stroke; }; -static Eina_Bool -_efl_vg_shape_efl_vg_base_bound_get(Eo *obj, +static void +_efl_vg_shape_efl_vg_base_bounds_get(Eo *obj, Efl_VG_Shape_Data *pd EINA_UNUSED, Eina_Rectangle *r) { // FIXME: Use the renderer bounding box when it has been created instead of an estimation eo_do(obj, efl_gfx_shape_bounding_box_get(r)); - return EINA_TRUE; } static void From 41a75f0b07df2be4fbb017f99a01827dc3bdb5b6 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:38:08 +0200 Subject: [PATCH 240/251] efl: follow Efl.VG naming by using bounds_get as an API name. --- src/lib/ector/cairo/ector_renderer_cairo_shape.c | 2 +- src/lib/efl/interfaces/efl_gfx_shape.c | 6 +++--- src/lib/efl/interfaces/efl_gfx_shape.eo | 2 +- src/lib/evas/canvas/evas_vg_shape.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/lib/ector/cairo/ector_renderer_cairo_shape.c b/src/lib/ector/cairo/ector_renderer_cairo_shape.c index e4706ea710..523bd7ed57 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_shape.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_shape.c @@ -228,7 +228,7 @@ _ector_renderer_cairo_shape_ector_renderer_generic_base_bounds_get(Eo *obj, Ector_Renderer_Cairo_Base_Data *bd; // FIXME: It should be possible to actually ask cairo about that - eo_do(obj, efl_gfx_shape_bounding_box_get(r)); + eo_do(obj, efl_gfx_shape_bounds_get(r)); bd = eo_data_scope_get(obj, ECTOR_RENDERER_CAIRO_BASE_CLASS); r->x += bd->generic->origin.x; diff --git a/src/lib/efl/interfaces/efl_gfx_shape.c b/src/lib/efl/interfaces/efl_gfx_shape.c index 97a1e38e36..64700739bf 100644 --- a/src/lib/efl/interfaces/efl_gfx_shape.c +++ b/src/lib/efl/interfaces/efl_gfx_shape.c @@ -203,9 +203,9 @@ _efl_gfx_shape_path_length_get(Eo *obj EINA_UNUSED, Efl_Gfx_Shape_Data *pd, } void -_efl_gfx_shape_bounding_box_get(Eo *obj EINA_UNUSED, - Efl_Gfx_Shape_Data *pd, - Eina_Rectangle *r) +_efl_gfx_shape_bounds_get(Eo *obj EINA_UNUSED, + Efl_Gfx_Shape_Data *pd, + Eina_Rectangle *r) { double minx, miny, maxx, maxy; unsigned int i; diff --git a/src/lib/efl/interfaces/efl_gfx_shape.eo b/src/lib/efl/interfaces/efl_gfx_shape.eo index 9340fe0604..37d0abd3ec 100644 --- a/src/lib/efl/interfaces/efl_gfx_shape.eo +++ b/src/lib/efl/interfaces/efl_gfx_shape.eo @@ -189,7 +189,7 @@ mixin Efl.Gfx.Shape @in Eo *dup_from; /*@ Shape object from where data will be copied.*/ } } - bounding_box_get { + bounds_get { /*@ Compute and return the bounding box of the currently set path diff --git a/src/lib/evas/canvas/evas_vg_shape.c b/src/lib/evas/canvas/evas_vg_shape.c index 644f9e6002..7b7ec01f06 100644 --- a/src/lib/evas/canvas/evas_vg_shape.c +++ b/src/lib/evas/canvas/evas_vg_shape.c @@ -34,7 +34,7 @@ _efl_vg_shape_efl_vg_base_bounds_get(Eo *obj, Eina_Rectangle *r) { // FIXME: Use the renderer bounding box when it has been created instead of an estimation - eo_do(obj, efl_gfx_shape_bounding_box_get(r)); + eo_do(obj, efl_gfx_shape_bounds_get(r)); } static void From c44aa8f05d536c6e07f82c7ebf3d851ebf3c8864 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:38:08 +0200 Subject: [PATCH 241/251] efl: all those function should have been static already. --- src/lib/efl/interfaces/efl_gfx_shape.c | 42 +++++++++++++------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/lib/efl/interfaces/efl_gfx_shape.c b/src/lib/efl/interfaces/efl_gfx_shape.c index 64700739bf..9b2c1087e8 100644 --- a/src/lib/efl/interfaces/efl_gfx_shape.c +++ b/src/lib/efl/interfaces/efl_gfx_shape.c @@ -139,7 +139,7 @@ _efl_gfx_path_current_search(const Efl_Gfx_Path_Command *cmd, return EINA_TRUE; } -void +static void _efl_gfx_shape_path_set(Eo *obj, Efl_Gfx_Shape_Data *pd, const Efl_Gfx_Path_Command *commands, const double *points) @@ -185,7 +185,7 @@ _efl_gfx_shape_path_set(Eo *obj, Efl_Gfx_Shape_Data *pd, eo_event_callback_call(EFL_GFX_CHANGED, NULL)); } -void +static void _efl_gfx_shape_path_get(Eo *obj EINA_UNUSED, Efl_Gfx_Shape_Data *pd, const Efl_Gfx_Path_Command **commands, const double **points) @@ -194,7 +194,7 @@ _efl_gfx_shape_path_get(Eo *obj EINA_UNUSED, Efl_Gfx_Shape_Data *pd, if (points) *points = pd->points; } -void +static void _efl_gfx_shape_path_length_get(Eo *obj EINA_UNUSED, Efl_Gfx_Shape_Data *pd, unsigned int *commands, unsigned int *points) { @@ -202,7 +202,7 @@ _efl_gfx_shape_path_length_get(Eo *obj EINA_UNUSED, Efl_Gfx_Shape_Data *pd, if (points) *points = pd->points_count; } -void +static void _efl_gfx_shape_bounds_get(Eo *obj EINA_UNUSED, Efl_Gfx_Shape_Data *pd, Eina_Rectangle *r) @@ -232,7 +232,7 @@ _efl_gfx_shape_bounds_get(Eo *obj EINA_UNUSED, maxx - minx, maxy - miny); } -void +static void _efl_gfx_shape_current_get(Eo *obj EINA_UNUSED, Efl_Gfx_Shape_Data *pd, double *x, double *y) { @@ -240,7 +240,7 @@ _efl_gfx_shape_current_get(Eo *obj EINA_UNUSED, Efl_Gfx_Shape_Data *pd, if (y) *y = pd->current.y; } -void +static void _efl_gfx_shape_current_ctrl_get(Eo *obj EINA_UNUSED, Efl_Gfx_Shape_Data *pd, double *x, double *y) { @@ -301,7 +301,7 @@ stroke_get(const Eo *obj, Efl_Gfx_Stroke *stroke) stroke->j = efl_gfx_shape_stroke_join_get()); } -Eina_Bool +static Eina_Bool _efl_gfx_shape_interpolate(Eo *obj, Efl_Gfx_Shape_Data *pd, const Eo *from, const Eo *to, double pos_map) { @@ -401,7 +401,7 @@ _efl_gfx_shape_interpolate(Eo *obj, Efl_Gfx_Shape_Data *pd, return EINA_TRUE; } -Eina_Bool +static Eina_Bool _efl_gfx_shape_equal_commands(Eo *obj EINA_UNUSED, Efl_Gfx_Shape_Data *pd, const Eo *with) @@ -414,7 +414,7 @@ _efl_gfx_shape_equal_commands(Eo *obj EINA_UNUSED, return _efl_gfx_shape_equal_commands_internal(with_pd, pd); } -void +static void _efl_gfx_shape_dup(Eo *obj, Efl_Gfx_Shape_Data *pd, Eo *dup_from) { const Efl_Gfx_Dash *dash = NULL; @@ -454,7 +454,7 @@ _efl_gfx_shape_dup(Eo *obj, Efl_Gfx_Shape_Data *pd, Eo *dup_from) eo_event_callback_call(EFL_GFX_CHANGED, NULL)); } -void +static void _efl_gfx_shape_reset(Eo *obj, Efl_Gfx_Shape_Data *pd) { free(pd->commands); @@ -475,7 +475,7 @@ _efl_gfx_shape_reset(Eo *obj, Efl_Gfx_Shape_Data *pd) eo_event_callback_call(EFL_GFX_CHANGED, NULL)); } -void +static void _efl_gfx_shape_append_move_to(Eo *obj, Efl_Gfx_Shape_Data *pd, double x, double y) { @@ -496,7 +496,7 @@ _efl_gfx_shape_append_move_to(Eo *obj, Efl_Gfx_Shape_Data *pd, eo_event_callback_call(EFL_GFX_CHANGED, NULL)); } -void +static void _efl_gfx_shape_append_line_to(Eo *obj, Efl_Gfx_Shape_Data *pd, double x, double y) { @@ -517,7 +517,7 @@ _efl_gfx_shape_append_line_to(Eo *obj, Efl_Gfx_Shape_Data *pd, eo_event_callback_call(EFL_GFX_CHANGED, NULL)); } -void +static void _efl_gfx_shape_append_cubic_to(Eo *obj, Efl_Gfx_Shape_Data *pd, double x, double y, double ctrl_x0, double ctrl_y0, @@ -546,7 +546,7 @@ _efl_gfx_shape_append_cubic_to(Eo *obj, Efl_Gfx_Shape_Data *pd, eo_event_callback_call(EFL_GFX_CHANGED, NULL)); } -void +static void _efl_gfx_shape_append_scubic_to(Eo *obj, Efl_Gfx_Shape_Data *pd, double x, double y, double ctrl_x, double ctrl_y) @@ -567,7 +567,7 @@ _efl_gfx_shape_append_scubic_to(Eo *obj, Efl_Gfx_Shape_Data *pd, ctrl_x0, ctrl_y0, ctrl_x, ctrl_y); } -void +static void _efl_gfx_shape_append_quadratic_to(Eo *obj, Efl_Gfx_Shape_Data *pd, double x, double y, double ctrl_x, double ctrl_y) @@ -588,7 +588,7 @@ _efl_gfx_shape_append_quadratic_to(Eo *obj, Efl_Gfx_Shape_Data *pd, ctrl_x0, ctrl_y0, ctrl_x1, ctrl_y1); } -void +static void _efl_gfx_shape_append_squadratic_to(Eo *obj, Efl_Gfx_Shape_Data *pd, double x, double y) { @@ -618,7 +618,7 @@ _efl_gfx_shape_append_squadratic_to(Eo *obj, Efl_Gfx_Shape_Data *pd, /* * code adapted from enesim which was adapted from moonlight sources */ -void +static void _efl_gfx_shape_append_arc_to(Eo *obj, Efl_Gfx_Shape_Data *pd, double x, double y, double rx, double ry, @@ -803,7 +803,7 @@ _efl_gfx_shape_append_arc_to(Eo *obj, Efl_Gfx_Shape_Data *pd, } } -void +static void _efl_gfx_shape_append_close(Eo *obj, Efl_Gfx_Shape_Data *pd) { double *offset_point; @@ -816,7 +816,7 @@ _efl_gfx_shape_append_close(Eo *obj, Efl_Gfx_Shape_Data *pd) eo_event_callback_call(EFL_GFX_CHANGED, NULL)); } -void +static void _efl_gfx_shape_append_circle(Eo *obj, Efl_Gfx_Shape_Data *pd, double xc, double yc, double radius) { @@ -825,7 +825,7 @@ _efl_gfx_shape_append_circle(Eo *obj, Efl_Gfx_Shape_Data *pd, _efl_gfx_shape_append_arc_to(obj, pd, xc - radius, yc, radius, radius, 0, EINA_TRUE, EINA_TRUE); } -void +static void _efl_gfx_shape_append_rect(Eo *obj, Efl_Gfx_Shape_Data *pd, double x, double y, double w, double h, double rx, double ry) @@ -1175,7 +1175,7 @@ _efl_gfx_path_parse_arc_to(const char *content, char **end, return EINA_TRUE; } -void +static void _efl_gfx_shape_append_svg_path(Eo *obj, Efl_Gfx_Shape_Data *pd, const char *svg_path_data) { From 470d64c85e97ed8f36b305633359e02fc2bb2255 Mon Sep 17 00:00:00 2001 From: Subhransu Mohanty Date: Fri, 3 Apr 2015 16:38:10 +0200 Subject: [PATCH 242/251] efl: update efl_gfx_shape interpolation to use fill color. Signed-off-by: Cedric BAIL --- src/lib/efl/interfaces/efl_gfx_shape.c | 68 ++++++++++++++------------ 1 file changed, 37 insertions(+), 31 deletions(-) diff --git a/src/lib/efl/interfaces/efl_gfx_shape.c b/src/lib/efl/interfaces/efl_gfx_shape.c index 9b2c1087e8..726d5715ce 100644 --- a/src/lib/efl/interfaces/efl_gfx_shape.c +++ b/src/lib/efl/interfaces/efl_gfx_shape.c @@ -275,11 +275,12 @@ interpolatei(int from, int to, double pos_map) return (from * pos_map) + (to * (1.0 - pos_map)); } -typedef struct _Efl_Gfx_Stroke Efl_Gfx_Stroke; -struct _Efl_Gfx_Stroke +typedef struct _Efl_Gfx_Property Efl_Gfx_Property; +struct _Efl_Gfx_Property { double scale; int r, g, b, a; + int fr, fg, fb, fa; double w; double centered; const Efl_Gfx_Dash *dash; @@ -289,16 +290,17 @@ struct _Efl_Gfx_Stroke }; static inline void -stroke_get(const Eo *obj, Efl_Gfx_Stroke *stroke) +gfx_property_get(const Eo *obj, Efl_Gfx_Property *property) { eo_do(obj, - stroke->scale = efl_gfx_shape_stroke_scale_get(), - efl_gfx_shape_stroke_color_get(&stroke->r, &stroke->g, &stroke->b, &stroke->a), - stroke->w = efl_gfx_shape_stroke_width_get(), - stroke->centered = efl_gfx_shape_stroke_location_get(), - efl_gfx_shape_stroke_dash_get(&stroke->dash, &stroke->dash_length), - stroke->c = efl_gfx_shape_stroke_cap_get(), - stroke->j = efl_gfx_shape_stroke_join_get()); + property->scale = efl_gfx_shape_stroke_scale_get(), + efl_gfx_shape_stroke_color_get(&property->r, &property->g, &property->b, &property->a), + efl_gfx_color_get(&property->fr, &property->fg, &property->fb, &property->fa), + property->w = efl_gfx_shape_stroke_width_get(), + property->centered = efl_gfx_shape_stroke_location_get(), + efl_gfx_shape_stroke_dash_get(&property->dash, &property->dash_length), + property->c = efl_gfx_shape_stroke_cap_get(), + property->j = efl_gfx_shape_stroke_join_get()); } static Eina_Bool @@ -309,7 +311,7 @@ _efl_gfx_shape_interpolate(Eo *obj, Efl_Gfx_Shape_Data *pd, Efl_Gfx_Path_Command *cmds; double *pts, *from_pts, *to_pts; unsigned int i, j; - Efl_Gfx_Stroke stroke_from, stroke_to; + Efl_Gfx_Property property_from, property_to; Efl_Gfx_Dash *dash; from_pd = eo_data_scope_get(from, EFL_GFX_SHAPE_MIXIN); @@ -320,10 +322,10 @@ _efl_gfx_shape_interpolate(Eo *obj, Efl_Gfx_Shape_Data *pd, if (!_efl_gfx_shape_equal_commands_internal(from_pd, to_pd)) return EINA_FALSE; - stroke_get(from, &stroke_from); - stroke_get(to, &stroke_to); + gfx_property_get(from, &property_from); + gfx_property_get(to, &property_to); - if (stroke_from.dash_length != stroke_to.dash_length) return EINA_FALSE; + if (property_from.dash_length != property_to.dash_length) return EINA_FALSE; cmds = realloc(pd->commands, sizeof (Efl_Gfx_Path_Command) * from_pd->commands_count); @@ -367,33 +369,37 @@ _efl_gfx_shape_interpolate(Eo *obj, Efl_Gfx_Shape_Data *pd, to_pd->current_ctrl.y, pos_map); - dash = malloc(sizeof (Efl_Gfx_Dash) * stroke_to.dash_length); + dash = malloc(sizeof (Efl_Gfx_Dash) * property_to.dash_length); if (dash) { - for (i = 0; i < stroke_to.dash_length; i++) + for (i = 0; i < property_to.dash_length; i++) { - dash[i].length = interpolate(stroke_from.dash[i].length, - stroke_to.dash[i].length, pos_map); - dash[i].gap = interpolate(stroke_from.dash[i].gap, - stroke_to.dash[i].gap, pos_map); + dash[i].length = interpolate(property_from.dash[i].length, + property_to.dash[i].length, pos_map); + dash[i].gap = interpolate(property_from.dash[i].gap, + property_to.dash[i].gap, pos_map); } } else { - stroke_to.dash_length = 0; + property_to.dash_length = 0; } eo_do(obj, - efl_gfx_shape_stroke_scale_set(interpolate(stroke_to.scale, stroke_from.scale, pos_map)), - efl_gfx_shape_stroke_color_set(interpolatei(stroke_to.r, stroke_from.r, pos_map), - interpolatei(stroke_to.g, stroke_from.g, pos_map), - interpolatei(stroke_to.b, stroke_from.b, pos_map), - interpolatei(stroke_to.a, stroke_from.a, pos_map)), - efl_gfx_shape_stroke_width_set(interpolate(stroke_to.w, stroke_from.w, pos_map)), - efl_gfx_shape_stroke_location_set(interpolate(stroke_to.centered, stroke_from.centered, pos_map)), - efl_gfx_shape_stroke_dash_set(dash, stroke_to.dash_length), - efl_gfx_shape_stroke_cap_set(pos_map < 0.5 ? stroke_from.c : stroke_to.c), - efl_gfx_shape_stroke_join_set(pos_map < 0.5 ? stroke_from.j : stroke_to.j), + efl_gfx_shape_stroke_scale_set(interpolate(property_to.scale, property_from.scale, pos_map)), + efl_gfx_shape_stroke_color_set(interpolatei(property_to.r, property_from.r, pos_map), + interpolatei(property_to.g, property_from.g, pos_map), + interpolatei(property_to.b, property_from.b, pos_map), + interpolatei(property_to.a, property_from.a, pos_map)), + efl_gfx_color_set(interpolatei(property_to.fr, property_from.fr, pos_map), + interpolatei(property_to.fg, property_from.fg, pos_map), + interpolatei(property_to.fb, property_from.fb, pos_map), + interpolatei(property_to.fa, property_from.fa, pos_map)), + efl_gfx_shape_stroke_width_set(interpolate(property_to.w, property_from.w, pos_map)), + efl_gfx_shape_stroke_location_set(interpolate(property_to.centered, property_from.centered, pos_map)), + efl_gfx_shape_stroke_dash_set(dash, property_to.dash_length), + efl_gfx_shape_stroke_cap_set(pos_map < 0.5 ? property_from.c : property_to.c), + efl_gfx_shape_stroke_join_set(pos_map < 0.5 ? property_from.j : property_to.j), eo_event_callback_call(EFL_GFX_PATH_CHANGED, NULL), eo_event_callback_call(EFL_GFX_CHANGED, NULL)); From 2d74a4efb23513645e74fbc5b2b6c0fc4cab60c0 Mon Sep 17 00:00:00 2001 From: Subhransu Mohanty Date: Fri, 3 Apr 2015 16:38:11 +0200 Subject: [PATCH 243/251] efl: fix svg path parsing to handle Z also. Signed-off-by: Cedric BAIL --- src/lib/efl/interfaces/efl_gfx_shape.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib/efl/interfaces/efl_gfx_shape.c b/src/lib/efl/interfaces/efl_gfx_shape.c index 726d5715ce..ee94396d9b 100644 --- a/src/lib/efl/interfaces/efl_gfx_shape.c +++ b/src/lib/efl/interfaces/efl_gfx_shape.c @@ -1215,6 +1215,7 @@ _efl_gfx_shape_append_svg_path(Eo *obj, Efl_Gfx_Shape_Data *pd, return ; break; case 'z': + case 'Z': _efl_gfx_shape_append_close(obj, pd); content++; break; From 4ad8b3ab521f8ea69e34211c818f276740889e5b Mon Sep 17 00:00:00 2001 From: Subhransu Mohanty Date: Fri, 3 Apr 2015 16:38:13 +0200 Subject: [PATCH 244/251] evas: update batman example with shape property interpolation Signed-off-by: Cedric BAIL --- src/examples/evas/evas-vg-batman.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/examples/evas/evas-vg-batman.c b/src/examples/evas/evas-vg-batman.c index 17ea3a460c..116150ae2f 100644 --- a/src/examples/evas/evas-vg-batman.c +++ b/src/examples/evas/evas-vg-batman.c @@ -56,7 +56,6 @@ static const char *batmans_path[] = { "M 202,170 C 188,115 157,108 124,105 146,84.3 171,71.5 199,70.2 211,98.6 243,103 277,106 279,99.3 281,92.6 283,86 285,91.9 287,97.9 290,104 293,104 297,104 300,104 303,104 307,104 310,104 313,97.9 315,91.9 317,86 319,92.6 321,99.3 323,106 357,103 389,98.6 401,70.2 429,71.5 454,84.3 476,105 443,108 412,115 398,170 349,157 318,175 300,214 282,175 251,157 202,170 Z", "M 220,179 C 200,127 150,130 123,175 122,110 160,85.1 201,64 208,99.2 243,111 268,92.9 278,86.1 284,68.2 287,40.7 289,49.6 292,58.4 294,67.3 296,67.3 298,67.3 300,67.3 302,67.3 304,67.3 306,67.3 308,58.4 311,49.6 313,40.7 316,68.2 322,86.1 332,92.9 357,111 392,99.3 399,64 440,85.1 478,110 477,175 450,130 400,127 380,179 355,155 305,208 300,247 295,208 245,155 220,179 Z", "M 166,154 C 179,119 154,95.4 114,79.3 155,79.1 197,78.9 239,78.7 242,103 250,109 283,109 289,109 290,93.9 291,83.7 292,88.3 292,92.9 293,97.5 295,97.5 298,97.5 300,97.5 302,97.5 305,97.5 307,97.5 308,92.9 308,88.3 309,83.7 310,93.9 311,109 317,109 350,109 358,103 361,78.7 403,78.9 445,79.1 486,79.3 446,95.4 421,119 434,154 377,151 320,151 300,207 280,151 223,151 166,154 Z", - "M 166,154 C 179,119 154,95.4 114,79.3 155,79.1 197,78.9 239,78.7 242,103 250,109 283,109 289,109 290,93.9 291,83.7 292,88.3 292,92.9 293,97.5 295,97.5 298,97.5 300,97.5 302,97.5 305,97.5 307,97.5 308,92.9 308,88.3 309,83.7 310,93.9 311,109 317,109 350,109 358,103 361,78.7 403,78.9 445,79.1 486,79.3 446,95.4 421,119 434,154 377,151 320,151 300,207 280,151 223,151 166,154 Z" }; static void @@ -130,6 +129,17 @@ main(void) for (i = 0; i < sizeof (batmans_path) / sizeof (batmans_path[0]); i++) { batmans_vg[i] = evas_vg_shape_add(NULL); + evas_vg_node_color_set(batmans_vg[i], 0, 0, 0, 255); + evas_vg_shape_stroke_color_set(batmans_vg[i], 128, 10,10, 128); + evas_vg_shape_stroke_width_set(batmans_vg[i], 4.0); + evas_vg_shape_stroke_join_set(batmans_vg[i], EFL_GFX_JOIN_MITER); + if(i % 2) + { + evas_vg_shape_stroke_color_set(batmans_vg[i], 10, 10,128, 128); + evas_vg_shape_stroke_width_set(batmans_vg[i], 2.0); + evas_vg_node_color_set(batmans_vg[i], 120, 120, 120, 255); + evas_vg_shape_stroke_join_set(batmans_vg[i], EFL_GFX_JOIN_ROUND); + } evas_vg_shape_shape_append_svg_path(batmans_vg[i], batmans_path[i]); } @@ -145,12 +155,12 @@ main(void) circle = evas_vg_shape_add(root); evas_vg_shape_shape_append_circle(circle, WIDTH / 2, HEIGHT / 2, 200); evas_vg_node_color_set(circle, 255, 255, 255, 255); - evas_vg_shape_stroke_color_set(circle, 0, 0, 0, 0); + evas_vg_shape_stroke_width_set(circle, 1); + evas_vg_shape_stroke_color_set(circle, 255, 0, 0, 255); batman = evas_vg_shape_add(root); - evas_vg_node_origin_set(batman, 100, 150); evas_vg_node_color_set(batman, 0, 0, 0, 255); - evas_vg_shape_stroke_color_set(batman, 0, 0, 0, 0); + evas_vg_node_origin_set(batman, 100, 150); evas_vg_shape_shape_append_move_to(batman, 256, 213); evas_vg_shape_shape_dup(batman, batmans_vg[0]); From 5c31036249ed5c21f249387d785fb85d97b5926e Mon Sep 17 00:00:00 2001 From: Subhransu Mohanty Date: Fri, 3 Apr 2015 16:38:14 +0200 Subject: [PATCH 245/251] evas/canvas : bail out in case of empty or null dash. Signed-off-by: Cedric BAIL --- src/lib/evas/canvas/evas_vg_shape.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/lib/evas/canvas/evas_vg_shape.c b/src/lib/evas/canvas/evas_vg_shape.c index 7b7ec01f06..e67c3b5675 100644 --- a/src/lib/evas/canvas/evas_vg_shape.c +++ b/src/lib/evas/canvas/evas_vg_shape.c @@ -199,6 +199,9 @@ _efl_vg_shape_efl_gfx_shape_stroke_dash_set(Eo *obj EINA_UNUSED, pd->stroke.dash = NULL; pd->stroke.dash_count = 0; + // check for null or empty dash + if (!dash || !length) return; + pd->stroke.dash = malloc(sizeof (Efl_Gfx_Dash) * length); if (!pd->stroke.dash) return ; From 8d584dff34c67716dd68c87e40c09d41bd67864b Mon Sep 17 00:00:00 2001 From: Subhransu Mohanty Date: Fri, 3 Apr 2015 16:38:15 +0200 Subject: [PATCH 246/251] efl: fix memory leak in efl_gfx_shape_interpolate(). Signed-off-by: Cedric BAIL --- src/lib/efl/interfaces/efl_gfx_shape.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/lib/efl/interfaces/efl_gfx_shape.c b/src/lib/efl/interfaces/efl_gfx_shape.c index ee94396d9b..efbc9d5ea9 100644 --- a/src/lib/efl/interfaces/efl_gfx_shape.c +++ b/src/lib/efl/interfaces/efl_gfx_shape.c @@ -312,7 +312,7 @@ _efl_gfx_shape_interpolate(Eo *obj, Efl_Gfx_Shape_Data *pd, double *pts, *from_pts, *to_pts; unsigned int i, j; Efl_Gfx_Property property_from, property_to; - Efl_Gfx_Dash *dash; + Efl_Gfx_Dash *dash = NULL; from_pd = eo_data_scope_get(from, EFL_GFX_SHAPE_MIXIN); to_pd = eo_data_scope_get(to, EFL_GFX_SHAPE_MIXIN); @@ -369,9 +369,11 @@ _efl_gfx_shape_interpolate(Eo *obj, Efl_Gfx_Shape_Data *pd, to_pd->current_ctrl.y, pos_map); - dash = malloc(sizeof (Efl_Gfx_Dash) * property_to.dash_length); - if (dash) + if (property_to.dash_length) { + dash = malloc(sizeof (Efl_Gfx_Dash) * property_to.dash_length); + if (!dash) return EINA_FALSE; + for (i = 0; i < property_to.dash_length; i++) { dash[i].length = interpolate(property_from.dash[i].length, @@ -380,10 +382,7 @@ _efl_gfx_shape_interpolate(Eo *obj, Efl_Gfx_Shape_Data *pd, property_to.dash[i].gap, pos_map); } } - else - { - property_to.dash_length = 0; - } + eo_do(obj, efl_gfx_shape_stroke_scale_set(interpolate(property_to.scale, property_from.scale, pos_map)), From f4d325ee78fd0de7bc0390b1755c1c29f8e728e3 Mon Sep 17 00:00:00 2001 From: Subhransu Mohanty Date: Fri, 3 Apr 2015 16:38:17 +0200 Subject: [PATCH 247/251] evas: fix memory leak in Efl.Vg.Base class. --- src/lib/evas/canvas/efl_vg_base.eo | 1 + src/lib/evas/canvas/evas_vg_node.c | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/src/lib/evas/canvas/efl_vg_base.eo b/src/lib/evas/canvas/efl_vg_base.eo index e54256771e..ebd0dce3c9 100644 --- a/src/lib/evas/canvas/efl_vg_base.eo +++ b/src/lib/evas/canvas/efl_vg_base.eo @@ -74,6 +74,7 @@ abstract Efl.VG.Base (Eo.Base, Efl.Gfx.Base, Efl.Gfx.Stack) implements { Eo.Base.parent.set; Eo.Base.constructor; + Eo.Base.destructor; Efl.Gfx.Base.visible.set; Efl.Gfx.Base.visible.get; Efl.Gfx.Base.color.set; diff --git a/src/lib/evas/canvas/evas_vg_node.c b/src/lib/evas/canvas/evas_vg_node.c index 4254e5909a..6757771262 100644 --- a/src/lib/evas/canvas/evas_vg_node.c +++ b/src/lib/evas/canvas/evas_vg_node.c @@ -246,6 +246,17 @@ _efl_vg_base_eo_base_constructor(Eo *obj, pd->changed = EINA_TRUE; } +static void +_efl_vg_base_eo_base_destructor(Eo *obj, Efl_VG_Base_Data *pd) +{ + if (pd->m) + { + free(pd->m); + pd->m = NULL; + } + eo_do_super(obj, MY_CLASS, eo_destructor()); +} + static void _efl_vg_base_eo_base_parent_set(Eo *obj, Efl_VG_Base_Data *pd EINA_UNUSED, From c8764e9279ea47a75d60e39bdbcc4727e0236758 Mon Sep 17 00:00:00 2001 From: Subhransu Mohanty Date: Fri, 3 Apr 2015 16:38:18 +0200 Subject: [PATCH 248/251] ector: fix memory leak in Ector.Renderer.Generic.Base class Signed-off-by: Cedric BAIL --- src/lib/ector/ector_renderer_base.c | 22 +++++++++++--------- src/lib/ector/ector_renderer_generic_base.eo | 1 + 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/lib/ector/ector_renderer_base.c b/src/lib/ector/ector_renderer_base.c index 4f45542f70..b4c44c9801 100644 --- a/src/lib/ector/ector_renderer_base.c +++ b/src/lib/ector/ector_renderer_base.c @@ -7,28 +7,30 @@ #include "ector_private.h" +static void +_ector_renderer_generic_base_eo_base_destructor(Eo *obj, Ector_Renderer_Generic_Base_Data *pd) +{ + if (pd->m) free(pd->m); + eo_do_super(obj, ECTOR_RENDERER_GENERIC_BASE_CLASS, eo_destructor()); +} + static void _ector_renderer_generic_base_transformation_set(Eo *obj EINA_UNUSED, Ector_Renderer_Generic_Base_Data *pd, const Eina_Matrix3 *m) { - Eina_Matrix3 *tmp = pd->m; - - pd->m = NULL; if (!m) { - free(tmp); - tmp = NULL; + free(pd->m); + pd->m = NULL; } else { - if (!tmp) tmp = malloc(sizeof (Eina_Matrix3)); - if (!tmp) return ; + if (!pd->m) pd->m = malloc(sizeof (Eina_Matrix3)); + if (!pd->m) return ; - memcpy(tmp, m, sizeof (Eina_Matrix3)); + memcpy(pd->m, m, sizeof (Eina_Matrix3)); } - - pd->m = tmp; } static const Eina_Matrix3 * diff --git a/src/lib/ector/ector_renderer_generic_base.eo b/src/lib/ector/ector_renderer_generic_base.eo index e82b0223f9..2e42feaa98 100644 --- a/src/lib/ector/ector_renderer_generic_base.eo +++ b/src/lib/ector/ector_renderer_generic_base.eo @@ -108,6 +108,7 @@ abstract Ector.Renderer.Generic.Base (Eo.Base) } } implements { + Eo.Base.destructor; @virtual .draw; @virtual .bounds_get; @virtual .done; From 85312d56c69a6aa6795ac0d452a70bd9d4405d0d Mon Sep 17 00:00:00 2001 From: Subhransu Mohanty Date: Fri, 3 Apr 2015 16:38:19 +0200 Subject: [PATCH 249/251] ector: update cairo enum definitions and fix gradient spread issue. Signed-off-by: Cedric BAIL --- src/lib/ector/cairo/ector_cairo_private.h | 23 +++++++++++++++++++ .../ector_renderer_cairo_gradient_linear.c | 3 +-- .../ector_renderer_cairo_gradient_radial.c | 3 +-- .../ector/cairo/ector_renderer_cairo_shape.c | 14 +++++++++-- 4 files changed, 37 insertions(+), 6 deletions(-) diff --git a/src/lib/ector/cairo/ector_cairo_private.h b/src/lib/ector/cairo/ector_cairo_private.h index 486f9addd8..b5782ffafc 100644 --- a/src/lib/ector/cairo/ector_cairo_private.h +++ b/src/lib/ector/cairo/ector_cairo_private.h @@ -30,6 +30,29 @@ struct _Ector_Renderer_Cairo_Base_Data cairo_matrix_t *m; }; +typedef enum _cairo_extend { + CAIRO_EXTEND_NONE, + CAIRO_EXTEND_REPEAT, + CAIRO_EXTEND_REFLECT, + CAIRO_EXTEND_PAD +} cairo_extend_t; + +static inline cairo_extend_t +_ector_cairo_extent_get(Efl_Gfx_Gradient_Spread s) +{ + switch (s) + { + case EFL_GFX_GRADIENT_SPREAD_PAD: + return CAIRO_EXTEND_PAD; + case EFL_GFX_GRADIENT_SPREAD_REFLECT: + return CAIRO_EXTEND_REFLECT; + case EFL_GFX_GRADIENT_SPREAD_REPEAT: + return CAIRO_EXTEND_REPEAT; + default: + return CAIRO_EXTEND_NONE; + } +} + #define CHECK_CAIRO(Parent) (!(Parent && Parent->cairo)) #define USE(Obj, Sym, Error) \ diff --git a/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c b/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c index 4fb05ceae9..15b4e42c31 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_gradient_linear.c @@ -20,7 +20,6 @@ static void (*cairo_pattern_add_color_stop_rgba)(cairo_pattern_t *pattern, doubl double red, double green, double blue, double alpha) = NULL; static void (*cairo_pattern_destroy)(cairo_pattern_t *pattern) = NULL; -typedef enum _cairo_extend_t{cairo_extend}cairo_extend_t; static void (*cairo_pattern_set_extend)(cairo_pattern_t *pattern, cairo_extend_t extend) = NULL; typedef struct _Ector_Renderer_Cairo_Gradient_Linear_Data Ector_Renderer_Cairo_Gradient_Linear_Data; @@ -63,7 +62,7 @@ _ector_renderer_cairo_gradient_linear_ector_renderer_generic_base_prepare(Eo *ob } USE(obj, cairo_pattern_set_extend, EINA_FALSE); - cairo_pattern_set_extend(pd->pat, gd->s); + cairo_pattern_set_extend(pd->pat, _ector_cairo_extent_get(gd->s)); if (!pd->parent) { diff --git a/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c b/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c index f3332c76db..34a6d707f5 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c @@ -23,7 +23,6 @@ static void (*cairo_pattern_add_color_stop_rgba)(cairo_pattern_t *pattern, doubl double red, double green, double blue, double alpha) = NULL; static void (*cairo_pattern_destroy)(cairo_pattern_t *pattern) = NULL; -typedef enum _cairo_extend_t{cairo_extend}cairo_extend_t; static void (*cairo_pattern_set_extend)(cairo_pattern_t *pattern, cairo_extend_t extend) = NULL; // FIXME: as long as it is not possible to directly access the parent structure @@ -68,7 +67,7 @@ _ector_renderer_cairo_gradient_radial_ector_renderer_generic_base_prepare(Eo *ob } USE(obj, cairo_pattern_set_extend, EINA_FALSE); - cairo_pattern_set_extend(pd->pat, gd->s); + cairo_pattern_set_extend(pd->pat, _ector_cairo_extent_get(gd->s)); if (!pd->parent) { diff --git a/src/lib/ector/cairo/ector_renderer_cairo_shape.c b/src/lib/ector/cairo/ector_renderer_cairo_shape.c index 523bd7ed57..de6aa6d184 100644 --- a/src/lib/ector/cairo/ector_renderer_cairo_shape.c +++ b/src/lib/ector/cairo/ector_renderer_cairo_shape.c @@ -14,6 +14,18 @@ typedef struct _cairo_path_t cairo_path_t; +typedef enum _cairo_line_cap { + CAIRO_LINE_CAP_BUTT, + CAIRO_LINE_CAP_ROUND, + CAIRO_LINE_CAP_SQUARE +} cairo_line_cap_t; + +typedef enum _cairo_line_join { + CAIRO_LINE_JOIN_MITER, + CAIRO_LINE_JOIN_ROUND, + CAIRO_LINE_JOIN_BEVEL +} cairo_line_join_t; + static void (*cairo_move_to)(cairo_t *cr, double x, double y) = NULL; static void (*cairo_line_to)(cairo_t *cr, double x, double y) = NULL; static void (*cairo_curve_to)(cairo_t *cr, @@ -36,8 +48,6 @@ static void (*cairo_path_destroy)(cairo_path_t *path) = NULL; static void (*cairo_new_path)(cairo_t *cr) = NULL; static void (*cairo_append_path)(cairo_t *cr, const cairo_path_t *path) = NULL; -typedef enum _cairo_line_cap_t{lie_cap}cairo_line_cap_t; -typedef enum _cairo_line_join_t{line_join}cairo_line_join_t; static void (*cairo_set_line_width)(cairo_t *cr, double width) = NULL; static void (*cairo_set_line_cap)(cairo_t *cr, cairo_line_cap_t line_cap) = NULL; static void (*cairo_set_line_join)(cairo_t *cr, cairo_line_join_t line_join) = NULL; From 899b70d3dcb4bc7ca7de0fe3ec79ccae0577b48a Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:57:35 +0200 Subject: [PATCH 250/251] evas: mark Evas VG API as beta API to. --- src/lib/evas/Evas_Legacy.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lib/evas/Evas_Legacy.h b/src/lib/evas/Evas_Legacy.h index ca63600de7..a3ee6e0f2f 100644 --- a/src/lib/evas/Evas_Legacy.h +++ b/src/lib/evas/Evas_Legacy.h @@ -1712,6 +1712,8 @@ EAPI Evas_Object *evas_object_vg_add(Evas *e) EINA_WARN_UNUSED_RESULT EINA_ARG_N #include "canvas/evas_vg.eo.legacy.h" +#ifdef EFL_BETA_API_SUPPORT + /** * Creates a new vector shape object \. * @@ -2442,6 +2444,8 @@ EAPI void evas_vg_gradient_radial_focal_get(Eo *obj, double *x, double *y); #include "canvas/efl_vg_gradient_radial.eo.legacy.h" +#endif + /** * @} */ From 6a52271a8617071b0e6a0e512d97012616c8b9fc Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Fri, 3 Apr 2015 16:57:55 +0200 Subject: [PATCH 251/251] ector: make sure that all of Ector is a beta API. --- src/lib/ector/Ector.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/ector/Ector.h b/src/lib/ector/Ector.h index 0a53facc20..e08c2ed4bc 100644 --- a/src/lib/ector/Ector.h +++ b/src/lib/ector/Ector.h @@ -92,6 +92,8 @@ extern "C" { * @{ */ +#ifdef EFL_BETA_API_SUPPORT + /** * @typedef Ector_Surface * The base type to render content into. @@ -154,8 +156,6 @@ typedef enum _Ector_Update_Type ECTOR_UPDATE_OPAQUE = 8 /* Pushing some opaque pixels (this means that their is no need to read the under layer when blitting this surface) */ } Ector_Update_Type; -#ifdef EFL_BETA_API_SUPPORT - /** * @brief Init the ector subsystem * @return @c EINA_TRUE on success.