aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2015-09-15 07:36:00 +0200
committerCedric BAIL <cedric@osg.samsung.com>2015-09-21 22:50:34 +0200
commit4d75e359ff8cd0c434b784fd22ce56bac2438a16 (patch)
tree24da2a9532d3a845e61fafec12d299ccc7503e0c /src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c
parentevas: node that are used for a fill should not have a parent or they are goin... (diff)
downloadefl-4d75e359ff8cd0c434b784fd22ce56bac2438a16.tar.gz
ector: fix cairo backend to properly multiply gradient color.
@fix
Diffstat (limited to 'src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c')
-rw-r--r--src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c112
1 files changed, 57 insertions, 55 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 34a6d707f5..508632b073 100644
--- a/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c
+++ b/src/lib/ector/cairo/ector_renderer_cairo_gradient_radial.c
@@ -19,8 +19,6 @@ 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;
static void (*cairo_pattern_set_extend)(cairo_pattern_t *pattern, cairo_extend_t extend) = NULL;
@@ -31,44 +29,13 @@ typedef struct _Ector_Renderer_Cairo_Gradient_Radial_Data Ector_Renderer_Cairo_G
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_Renderer_Generic_Gradient_Radial_Data *grd;
- 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_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);
- 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);
-
- int r,g,b,a;
- for (i = 0; i < gd->colors_count; i++)
- {
- 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, _ector_cairo_extent_get(gd->s));
-
if (!pd->parent)
{
Eo *parent;
@@ -81,42 +48,84 @@ _ector_renderer_cairo_gradient_radial_ector_renderer_generic_base_prepare(Eo *ob
return EINA_FALSE;
}
+static cairo_pattern_t *
+_ector_renderer_cairo_gradient_radial_prepare(Eo *obj,
+ Ector_Renderer_Generic_Gradient_Radial_Data *grd,
+ Ector_Renderer_Generic_Gradient_Data *gd,
+ unsigned int mul_col)
+{
+ cairo_pattern_t *pat;
+
+ USE(obj, cairo_pattern_create_radial, EINA_FALSE);
+
+ pat = cairo_pattern_create_radial(grd->focal.x, grd->focal.y, 0,
+ grd->radial.x, grd->radial.y, grd->radius);
+ if (!pat) return NULL;
+
+ _ector_renderer_cairo_gradient_prepare(obj, pat, gd, mul_col);
+
+ USE(obj, cairo_pattern_set_extend, EINA_FALSE);
+ cairo_pattern_set_extend(pat, _ector_cairo_extent_get(gd->s));
+
+ return pat;
+}
+
// 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, unsigned int mul_col)
{
- if (pd->pat) return EINA_FALSE;
+ Ector_Renderer_Generic_Gradient_Radial_Data *grd;
+ Ector_Renderer_Generic_Gradient_Data *gd;
+ cairo_pattern_t *pat;
- Ector_Renderer_Generic_Gradient_Radial_Data *gld;
+ // FIXME: Handle clipping and generally make it work :-)
+ 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;
- // FIXME: don't ignore clipping !
- gld = eo_data_scope_get(obj, ECTOR_RENDERER_GENERIC_GRADIENT_RADIAL_MIXIN);
- if (!pd->pat || !gld) return EINA_FALSE;
+ pat = _ector_renderer_cairo_gradient_radial_prepare(obj, grd, gd, mul_col);
+ if (!pat) return EINA_FALSE;
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);
+ USE(obj, cairo_set_source, EINA_FALSE);
+ USE(obj, cairo_pattern_destroy, EINA_FALSE);
cairo_arc(pd->parent->cairo,
- gld->radial.x, gld->radial.y,
- gld->radius,
+ grd->radial.x, grd->radial.y,
+ grd->radius,
0, 2 * M_PI);
- eo_do(obj, ector_renderer_cairo_base_fill());
+ cairo_set_source(pd->parent->cairo, pat);
cairo_fill(pd->parent->cairo);
+ cairo_pattern_destroy(pat);
return EINA_TRUE;
}
// 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)
+_ector_renderer_cairo_gradient_radial_ector_renderer_cairo_base_fill(Eo *obj,
+ Ector_Renderer_Cairo_Gradient_Radial_Data *pd,
+ unsigned int mul_col)
{
- if (!pd->pat) return EINA_FALSE;
+ Ector_Renderer_Generic_Gradient_Radial_Data *grd;
+ Ector_Renderer_Generic_Gradient_Data *gd;
+ cairo_pattern_t *pat;
+
+ 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;
+
+ pat = _ector_renderer_cairo_gradient_radial_prepare(obj, grd, gd, mul_col);
+ if (!pat) return EINA_FALSE;
USE(obj, cairo_set_source, EINA_FALSE);
+ USE(obj, cairo_pattern_destroy, EINA_FALSE);
- cairo_set_source(pd->parent->cairo, pd->pat);
+ cairo_set_source(pd->parent->cairo, pat);
+ cairo_pattern_destroy(pat);
return EINA_TRUE;
}
@@ -143,11 +152,6 @@ _ector_renderer_cairo_gradient_radial_eo_base_destructor(Eo *obj,
{
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);
@@ -155,13 +159,11 @@ _ector_renderer_cairo_gradient_radial_eo_base_destructor(Eo *obj,
}
void
-_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)
+_ector_renderer_cairo_gradient_radial_efl_gfx_gradient_base_stop_set(Eo *obj,
+ Ector_Renderer_Cairo_Gradient_Radial_Data *pd EINA_UNUSED,
+ const Efl_Gfx_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_RADIAL_CLASS,
efl_gfx_gradient_stop_set(colors, length));
}