From: "Yordan Karadzhov (VMware)" <y.karadz@gmail.com>
To: rostedt@goodmis.org
Cc: linux-trace-devel@vger.kernel.org,
"Yordan Karadzhov (VMware)" <y.karadz@gmail.com>
Subject: [PATCH 3/4] kernel-shark: Add ksplot_draw_polyline()
Date: Fri, 20 Nov 2020 11:50:30 +0200 [thread overview]
Message-ID: <20201120095031.271735-4-y.karadz@gmail.com> (raw)
In-Reply-To: <20201120095031.271735-1-y.karadz@gmail.com>
The method draws continuous line between an ordered array of
points (poly-line).
Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
---
src/libkshark-plot.c | 32 ++++++++++++++++++++++++++------
src/libkshark-plot.h | 5 +++++
2 files changed, 31 insertions(+), 6 deletions(-)
diff --git a/src/libkshark-plot.c b/src/libkshark-plot.c
index f2c5be30..dc49fbd9 100644
--- a/src/libkshark-plot.c
+++ b/src/libkshark-plot.c
@@ -150,6 +150,30 @@ void ksplot_draw_line(const struct ksplot_point *a,
glEnd();
}
+/**
+ * @brief Draw the a polyline.
+ *
+ * @param points: Input location for the array of points defining the polyline.
+ * @param n_points: The size of the array of points.
+ * @param col: The color of the polyline.
+ * @param size: The size of the polyline.
+ */
+void ksplot_draw_polyline(const struct ksplot_point *points,
+ size_t n_points,
+ const struct ksplot_color *col,
+ float size)
+{
+ if (!points || !n_points || !col || size < .5f)
+ return;
+
+ /* Loop over the points of the polygon and draw connecting lines. */
+ for(size_t i = 1; i < n_points; ++i)
+ ksplot_draw_line(&points[i - 1],
+ &points[i],
+ col,
+ size);
+}
+
/**
* @brief Draw a polygon.
*
@@ -211,12 +235,8 @@ void ksplot_draw_polygon_contour(const struct ksplot_point *points,
if (!points || !n_points || !col || size < .5f)
return;
- /* Loop over the points of the polygon and draw connecting lines. */
- for(size_t i = 1; i < n_points; ++i)
- ksplot_draw_line(&points[i - 1],
- &points[i],
- col,
- size);
+ /* Loop over the points of the polygon and draw a polyline. */
+ ksplot_draw_polyline(points, n_points, col, size);
/* Close the contour. */
ksplot_draw_line(&points[0],
diff --git a/src/libkshark-plot.h b/src/libkshark-plot.h
index 063740d9..d881b20a 100644
--- a/src/libkshark-plot.h
+++ b/src/libkshark-plot.h
@@ -72,6 +72,11 @@ void ksplot_draw_line(const struct ksplot_point *a,
const struct ksplot_color *col,
float size);
+void ksplot_draw_polyline(const struct ksplot_point *points,
+ size_t n_points,
+ const struct ksplot_color *col,
+ float size);
+
void ksplot_draw_polygon(const struct ksplot_point *points,
size_t n_points,
const struct ksplot_color *col,
--
2.25.1
next prev parent reply other threads:[~2020-11-20 9:51 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-20 9:50 [PATCH 0/4] Upgrade the OpenGL wrapper for KernelShark v2.0 Yordan Karadzhov (VMware)
2020-11-20 9:50 ` [PATCH 1/4] kernel-shark: Add support for drawing text Yordan Karadzhov (VMware)
2020-12-04 23:31 ` Steven Rostedt
2020-12-09 13:30 ` Yordan Karadzhov (VMware)
2020-12-09 14:14 ` Yordan Karadzhov (VMware)
2020-12-09 16:34 ` Steven Rostedt
2020-11-20 9:50 ` [PATCH 2/4] kernel-shark: Make GLUT optional dependency Yordan Karadzhov (VMware)
2020-11-20 9:50 ` Yordan Karadzhov (VMware) [this message]
2020-11-20 9:50 ` [PATCH 4/4] kernel-shark: Optimize ksplot_draw_polygon() Yordan Karadzhov (VMware)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201120095031.271735-4-y.karadz@gmail.com \
--to=y.karadz@gmail.com \
--cc=linux-trace-devel@vger.kernel.org \
--cc=rostedt@goodmis.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).