svgloader: fixing linear gradient transformation

Gradient stop points were incorrectly transformed when building
the scene in the SVG loader.
This commit is contained in:
Mira Grudzinska 2021-03-04 01:07:42 +01:00 committed by JunsuChoi
parent cb425fa4bb
commit a173b16ed5

View file

@ -77,17 +77,15 @@ unique_ptr<LinearGradient> _applyLinearGradientProperty(SvgStyleGradient* g, con
} }
if (g->transform) { if (g->transform) {
float cy = ((float) rh) * 0.5 + ry; //Calc start point
float cx = ((float) rw) * 0.5 + rx; auto x = g->linear->x1;
g->linear->x1 = x * g->transform->e11 + g->linear->y1 * g->transform->e12 + g->transform->e13;
g->linear->y1 = x * g->transform->e21 + g->linear->y1 * g->transform->e22 + g->transform->e23;
//= T(x - cx, y - cy) x g->transform x T(cx, cy) //Calc end point
//Calc start point x = g->linear->x2;
g->linear->x1 = (g->transform->e11 * cx) + (g->transform->e12 * cy) + g->linear->x1 + g->transform->e13 - cx; g->linear->x2 = x * g->transform->e11 + g->linear->y2 * g->transform->e12 + g->transform->e13;
g->linear->y1 = (g->transform->e21 * cx) + (g->transform->e22 * cy) + g->linear->y1 + g->transform->e23 - cy; g->linear->y2 = x * g->transform->e21 + g->linear->y2 * g->transform->e22 + g->transform->e23;
//Calc end point
g->linear->x2 = (g->transform->e11 * cx) + (g->transform->e12 * cy) + g->linear->x2 + g->transform->e13 - cx;
g->linear->y2 = (g->transform->e21 * cx) + (g->transform->e22 * cy) + g->linear->y2 + g->transform->e23 - cy;
} }
fillGrad->linear(g->linear->x1, g->linear->y1, g->linear->x2, g->linear->y2); fillGrad->linear(g->linear->x1, g->linear->y1, g->linear->x2, g->linear->y2);
@ -276,7 +274,7 @@ void _applyProperty(SvgNode* node, Shape* vg, float vx, float vy, float vw, floa
vg->composite(move(comp), CompositeMethod::ClipPath); vg->composite(move(comp), CompositeMethod::ClipPath);
} }
} }
//Composite Alpha Mask //Composite Alpha Mask
if (((int)style->comp.flags & (int)SvgCompositeFlags::AlphaMask)) { if (((int)style->comp.flags & (int)SvgCompositeFlags::AlphaMask)) {
auto compNode = style->comp.node; auto compNode = style->comp.node;
if (compNode->child.count > 0) { if (compNode->child.count > 0) {