ector: remember last position and translate to Ector_Renderer origin position.

This commit is contained in:
Cedric BAIL 2015-04-03 16:33:07 +02:00
parent ee955fbd98
commit 5613ca50ae
3 changed files with 12 additions and 2 deletions

View File

@ -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;
};

View File

@ -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;
}

View File

@ -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;