From db367d0c14e037e9af24ba00bc8bfd4f4309a507 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Thu, 8 Oct 2020 16:37:39 +0900 Subject: [PATCH] common shape: fix reset() bug. (#99) Previous reset() doesn't implemented properly. It resets only path data. Now Shape resets all drawing properties. --- src/lib/tvgShape.cpp | 4 +--- src/lib/tvgShapeImpl.h | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/lib/tvgShape.cpp b/src/lib/tvgShape.cpp index 7b43cdb0..70f17578 100644 --- a/src/lib/tvgShape.cpp +++ b/src/lib/tvgShape.cpp @@ -51,9 +51,7 @@ unique_ptr Shape::gen() noexcept Result Shape::reset() noexcept { - pImpl->path->reset(); - - pImpl->flag |= RenderUpdateFlag::Path; + pImpl->reset(); return Result::Success; } diff --git a/src/lib/tvgShapeImpl.h b/src/lib/tvgShapeImpl.h index ee0110ad..e238c0d1 100644 --- a/src/lib/tvgShapeImpl.h +++ b/src/lib/tvgShapeImpl.h @@ -305,6 +305,24 @@ struct Shape::Impl return true; } + void reset() + { + path->reset(); + + if (fill) { + delete(fill); + fill = nullptr; + } + if (stroke) { + delete(stroke); + stroke = nullptr; + } + + color[0] = color[1] = color[2] = color[3] = 0; + + flag = RenderUpdateFlag::All; + } + Paint* duplicate() { auto ret = Shape::gen();