mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-14 12:04:29 +00:00
svg_loader: currentColor - inheritance from a parent
The 'currentColor' attribute value was not inherited. Fixed.
This commit is contained in:
parent
520d6e7bbd
commit
feb71ff36c
2 changed files with 15 additions and 1 deletions
|
@ -781,6 +781,7 @@ static void _handlePaintAttr(SvgPaint* paint, const char* value)
|
|||
static void _handleColorAttr(TVG_UNUSED SvgLoaderData* loader, SvgNode* node, const char* value)
|
||||
{
|
||||
SvgStyleProperty* style = node->style;
|
||||
style->curColorSet = true;
|
||||
_toColor(value, &style->r, &style->g, &style->b, nullptr);
|
||||
}
|
||||
|
||||
|
@ -1034,7 +1035,9 @@ static SvgNode* _createNode(SvgNode* parent, SvgNodeType type)
|
|||
//Default fill opacity is 1
|
||||
node->style->fill.opacity = 255;
|
||||
node->style->opacity = 255;
|
||||
|
||||
//Default current color is not set
|
||||
node->style->fill.paint.curColor = false;
|
||||
node->style->curColorSet = false;
|
||||
//Default fill rule is nonzero
|
||||
node->style->fill.fillRule = SvgFillRule::Winding;
|
||||
|
||||
|
@ -1042,6 +1045,8 @@ static SvgNode* _createNode(SvgNode* parent, SvgNodeType type)
|
|||
node->style->stroke.paint.none = true;
|
||||
//Default stroke opacity is 1
|
||||
node->style->stroke.opacity = 255;
|
||||
//Default stroke current color is not set
|
||||
node->style->stroke.paint.curColor = false;
|
||||
//Default stroke width is 1
|
||||
node->style->stroke.width = 1;
|
||||
//Default line cap is butt
|
||||
|
@ -2287,6 +2292,10 @@ static void _styleInherit(SvgStyleProperty* child, const SvgStyleProperty* paren
|
|||
child->fill.paint.none = parent->fill.paint.none;
|
||||
child->fill.paint.curColor = parent->fill.paint.curColor;
|
||||
if (parent->fill.paint.url) child->fill.paint.url = _copyId(parent->fill.paint.url->c_str());
|
||||
} else if (child->fill.paint.curColor && !child->curColorSet) {
|
||||
child->r = parent->r;
|
||||
child->g = parent->g;
|
||||
child->b = parent->b;
|
||||
}
|
||||
if (!((int)child->fill.flags & (int)SvgFillFlags::Opacity)) {
|
||||
child->fill.opacity = parent->fill.opacity;
|
||||
|
@ -2302,6 +2311,10 @@ static void _styleInherit(SvgStyleProperty* child, const SvgStyleProperty* paren
|
|||
child->stroke.paint.none = parent->stroke.paint.none;
|
||||
child->stroke.paint.curColor = parent->stroke.paint.curColor;
|
||||
child->stroke.paint.url = parent->stroke.paint.url ? _copyId(parent->stroke.paint.url->c_str()) : nullptr;
|
||||
} else if (child->stroke.paint.curColor && !child->curColorSet) {
|
||||
child->r = parent->r;
|
||||
child->g = parent->g;
|
||||
child->b = parent->b;
|
||||
}
|
||||
if (!((int)child->stroke.flags & (int)SvgStrokeFlags::Opacity)) {
|
||||
child->stroke.opacity = parent->stroke.opacity;
|
||||
|
|
|
@ -289,6 +289,7 @@ struct SvgStyleProperty
|
|||
uint8_t r;
|
||||
uint8_t g;
|
||||
uint8_t b;
|
||||
bool curColorSet;
|
||||
};
|
||||
|
||||
struct SvgNode
|
||||
|
|
Loading…
Add table
Reference in a new issue