diff options
Diffstat (limited to 'thirdparty/thorvg/src/lib/tvgShape.cpp')
-rw-r--r-- | thirdparty/thorvg/src/lib/tvgShape.cpp | 50 |
1 files changed, 34 insertions, 16 deletions
diff --git a/thirdparty/thorvg/src/lib/tvgShape.cpp b/thirdparty/thorvg/src/lib/tvgShape.cpp index a8354375c9..f32feb2133 100644 --- a/thirdparty/thorvg/src/lib/tvgShape.cpp +++ b/thirdparty/thorvg/src/lib/tvgShape.cpp @@ -32,7 +32,7 @@ constexpr auto PATH_KAPPA = 0.552284f; /* External Class Implementation */ /************************************************************************/ -Shape :: Shape() : pImpl(new Impl()) +Shape :: Shape() : pImpl(new Impl(this)) { Paint::pImpl->id = TVG_CLASS_ID_SHAPE; Paint::pImpl->method(new PaintMethod<Shape::Impl>(pImpl)); @@ -59,7 +59,10 @@ uint32_t Shape::identifier() noexcept Result Shape::reset() noexcept { - pImpl->reset(); + pImpl->rs.path.cmds.clear(); + pImpl->rs.path.pts.clear(); + + pImpl->flag = RenderUpdateFlag::Path; return Result::Success; } @@ -69,9 +72,8 @@ uint32_t Shape::pathCommands(const PathCommand** cmds) const noexcept { if (!cmds) return 0; - *cmds = pImpl->rs.path.cmds; - - return pImpl->rs.path.cmdCnt; + *cmds = pImpl->rs.path.cmds.data; + return pImpl->rs.path.cmds.count; } @@ -79,9 +81,8 @@ uint32_t Shape::pathCoords(const Point** pts) const noexcept { if (!pts) return 0; - *pts = pImpl->rs.path.pts; - - return pImpl->rs.path.ptsCnt; + *pts = pImpl->rs.path.pts.data; + return pImpl->rs.path.pts.count; } @@ -242,21 +243,22 @@ Result Shape::appendRect(float x, float y, float w, float h, float rx, float ry) } -//TODO: kill alpha at TVG 1.0, because we also have opacity Result Shape::fill(uint8_t r, uint8_t g, uint8_t b, uint8_t a) noexcept { - pImpl->rs.color[0] = r; - pImpl->rs.color[1] = g; - pImpl->rs.color[2] = b; - pImpl->rs.color[3] = a; - pImpl->flag |= RenderUpdateFlag::Color; - if (pImpl->rs.fill) { delete(pImpl->rs.fill); pImpl->rs.fill = nullptr; pImpl->flag |= RenderUpdateFlag::Gradient; } + if (r == pImpl->rs.color[0] && g == pImpl->rs.color[1] && b == pImpl->rs.color[2] && a == pImpl->rs.color[3]) return Result::Success; + + pImpl->rs.color[0] = r; + pImpl->rs.color[1] = g; + pImpl->rs.color[2] = b; + pImpl->rs.color[3] = a; + pImpl->flag |= RenderUpdateFlag::Color; + return Result::Success; } @@ -328,7 +330,7 @@ Result Shape::strokeColor(uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a) const Result Shape::stroke(unique_ptr<Fill> f) noexcept { - return pImpl->strokeFill(move(f)); + return pImpl->strokeFill(std::move(f)); } @@ -374,6 +376,17 @@ Result Shape::stroke(StrokeJoin join) noexcept return Result::Success; } +Result Shape::strokeMiterlimit(float miterlimit) noexcept +{ + // https://www.w3.org/TR/SVG2/painting.html#LineJoin + // - A negative value for stroke-miterlimit must be treated as an illegal value. + if (miterlimit < 0.0f) return Result::NonSupport; + // TODO Find out a reasonable max value. + if (!pImpl->strokeMiterlimit(miterlimit)) return Result::FailedAllocation; + + return Result::Success; +} + StrokeCap Shape::strokeCap() const noexcept { @@ -386,6 +399,11 @@ StrokeJoin Shape::strokeJoin() const noexcept return pImpl->rs.strokeJoin(); } +float Shape::strokeMiterlimit() const noexcept +{ + return pImpl->rs.strokeMiterlimit(); +} + Result Shape::fill(FillRule r) noexcept { |