From 94f304275e4251460d329e66275e1c23538b54b7 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Sun, 23 Jun 2024 14:12:15 +0900 Subject: [PATCH] renderer: minor optimization reduce the path flag writing --- src/renderer/tvgShape.cpp | 15 +++++++++++++++ src/renderer/tvgShape.h | 10 ---------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/renderer/tvgShape.cpp b/src/renderer/tvgShape.cpp index 8de343f3..d75b7096 100644 --- a/src/renderer/tvgShape.cpp +++ b/src/renderer/tvgShape.cpp @@ -88,6 +88,8 @@ Result Shape::appendPath(const PathCommand *cmds, uint32_t cmdCnt, const Point* pImpl->grow(cmdCnt, ptsCnt); pImpl->append(cmds, cmdCnt, pts, ptsCnt); + pImpl->flag |= RenderUpdateFlag::Path; + return Result::Success; } @@ -104,6 +106,8 @@ Result Shape::lineTo(float x, float y) noexcept { pImpl->lineTo(x, y); + pImpl->flag |= RenderUpdateFlag::Path; + return Result::Success; } @@ -112,6 +116,8 @@ Result Shape::cubicTo(float cx1, float cy1, float cx2, float cy2, float x, float { pImpl->cubicTo(cx1, cy1, cx2, cy2, x, y); + pImpl->flag |= RenderUpdateFlag::Path; + return Result::Success; } @@ -120,6 +126,8 @@ Result Shape::close() noexcept { pImpl->close(); + pImpl->flag |= RenderUpdateFlag::Path; + return Result::Success; } @@ -137,9 +145,12 @@ Result Shape::appendCircle(float cx, float cy, float rx, float ry) noexcept pImpl->cubicTo(cx + rxKappa, cy - ry, cx + rx, cy - ryKappa, cx + rx, cy); pImpl->close(); + pImpl->flag |= RenderUpdateFlag::Path; + return Result::Success; } + Result Shape::appendArc(float cx, float cy, float radius, float startAngle, float sweep, bool pie) noexcept { //just circle @@ -196,6 +207,8 @@ Result Shape::appendArc(float cx, float cy, float radius, float startAngle, floa if (pie) pImpl->close(); + pImpl->flag |= RenderUpdateFlag::Path; + return Result::Success; } @@ -234,6 +247,8 @@ Result Shape::appendRect(float x, float y, float w, float h, float rx, float ry) pImpl->close(); } + pImpl->flag |= RenderUpdateFlag::Path; + return Result::Success; } diff --git a/src/renderer/tvgShape.h b/src/renderer/tvgShape.h index ed3006e1..42945639 100644 --- a/src/renderer/tvgShape.h +++ b/src/renderer/tvgShape.h @@ -167,24 +167,18 @@ struct Shape::Impl memcpy(rs.path.pts.end(), pts, sizeof(Point) * ptsCnt); rs.path.cmds.count += cmdCnt; rs.path.pts.count += ptsCnt; - - flag |= RenderUpdateFlag::Path; } void moveTo(float x, float y) { rs.path.cmds.push(PathCommand::MoveTo); rs.path.pts.push({x, y}); - - flag |= RenderUpdateFlag::Path; } void lineTo(float x, float y) { rs.path.cmds.push(PathCommand::LineTo); rs.path.pts.push({x, y}); - - flag |= RenderUpdateFlag::Path; } void cubicTo(float cx1, float cy1, float cx2, float cy2, float x, float y) @@ -193,8 +187,6 @@ struct Shape::Impl rs.path.pts.push({cx1, cy1}); rs.path.pts.push({cx2, cy2}); rs.path.pts.push({x, y}); - - flag |= RenderUpdateFlag::Path; } void close() @@ -203,8 +195,6 @@ struct Shape::Impl if (rs.path.cmds.count > 0 && rs.path.cmds.last() == PathCommand::Close) return; rs.path.cmds.push(PathCommand::Close); - - flag |= RenderUpdateFlag::Path; } void strokeWidth(float width)