summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2015-04-05 10:32:11 -0600
committerGregory Nutt <gnutt@nuttx.org>2015-04-05 10:32:11 -0600
commitccb3dbd5c949c165913737f7ad5016803abb9fca (patch)
tree463065b298d7773ac9028f12f59965af6ca80be4
parentff2186634f52abca4b92839acd70ea1db529f0cb (diff)
downloadpx4-nuttx-ccb3dbd5c949c165913737f7ad5016803abb9fca.tar.gz
px4-nuttx-ccb3dbd5c949c165913737f7ad5016803abb9fca.tar.bz2
px4-nuttx-ccb3dbd5c949c165913737f7ad5016803abb9fca.zip
NX circular drawing. Reduce computations; line caps needed only on every other line segment
-rw-r--r--nuttx/libnx/nx/nx_drawcircle.c15
-rw-r--r--nuttx/libnx/nxtk/nxtk_drawcircletoolbar.c14
-rw-r--r--nuttx/libnx/nxtk/nxtk_drawcirclewindow.c14
3 files changed, 37 insertions, 6 deletions
diff --git a/nuttx/libnx/nx/nx_drawcircle.c b/nuttx/libnx/nx/nx_drawcircle.c
index ea279a45d..ab2c85ea9 100644
--- a/nuttx/libnx/nx/nx_drawcircle.c
+++ b/nuttx/libnx/nx/nx_drawcircle.c
@@ -113,6 +113,7 @@ int nx_drawcircle(NXWINDOW hwnd, FAR const struct nxgl_point_s *center,
{
struct nxgl_point_s pts[NCIRCLE_POINTS];
FAR struct nxgl_vector_s vector;
+ bool capped;
int i;
int ret;
@@ -122,17 +123,27 @@ int nx_drawcircle(NXWINDOW hwnd, FAR const struct nxgl_point_s *center,
/* Draw each pair of points as a vector */
+ capped = false;
for (i = POINT_0p0; i < POINT_337p5; i++)
{
+ /* Draw one line segment */
+
vector.pt1.x = pts[i].x;
vector.pt1.y = pts[i].y;
vector.pt2.x = pts[i+1].x;
vector.pt2.y = pts[i+1].y;
- ret = nx_drawline(hwnd, &vector, width, color, true);
+
+ ret = nx_drawline(hwnd, &vector, width, color, capped);
if (ret != OK)
{
return ret;
}
+
+ /* Every other line segment needs to have a circular line caps to join
+ * cleanly with the surround lines segments without line caps.
+ */
+
+ capped = !capped;
}
/* The final, closing vector is a special case */
@@ -141,5 +152,5 @@ int nx_drawcircle(NXWINDOW hwnd, FAR const struct nxgl_point_s *center,
vector.pt1.y = pts[POINT_337p5].y;
vector.pt2.x = pts[POINT_0p0].x;
vector.pt2.y = pts[POINT_0p0].y;
- return nx_drawline(hwnd, &vector, width, color, true);
+ return nx_drawline(hwnd, &vector, width, color, capped);
}
diff --git a/nuttx/libnx/nxtk/nxtk_drawcircletoolbar.c b/nuttx/libnx/nxtk/nxtk_drawcircletoolbar.c
index 3aab9fd6e..390e0e5b5 100644
--- a/nuttx/libnx/nxtk/nxtk_drawcircletoolbar.c
+++ b/nuttx/libnx/nxtk/nxtk_drawcircletoolbar.c
@@ -113,6 +113,7 @@ int nxtk_drawcircletoolbar(NXTKWINDOW hfwnd, FAR const struct nxgl_point_s *cent
{
struct nxgl_point_s pts[NCIRCLE_POINTS];
FAR struct nxgl_vector_s vector;
+ bool capped;
int i;
int ret;
@@ -124,15 +125,24 @@ int nxtk_drawcircletoolbar(NXTKWINDOW hfwnd, FAR const struct nxgl_point_s *cent
for (i = POINT_0p0; i < POINT_337p5; i++)
{
+ /* Draw one line segment */
+
vector.pt1.x = pts[i].x;
vector.pt1.y = pts[i].y;
vector.pt2.x = pts[i+1].x;
vector.pt2.y = pts[i+1].y;
- ret = nxtk_drawlinetoolbar(hfwnd, &vector, width, color, true);
+
+ ret = nxtk_drawlinetoolbar(hfwnd, &vector, width, color, capped);
if (ret != OK)
{
return ret;
}
+
+ /* Every other line segment needs to have a circular line caps to join
+ * cleanly with the surround lines segments without line caps.
+ */
+
+ capped = !capped;
}
/* The final, closing vector is a special case */
@@ -141,5 +151,5 @@ int nxtk_drawcircletoolbar(NXTKWINDOW hfwnd, FAR const struct nxgl_point_s *cent
vector.pt1.y = pts[POINT_337p5].y;
vector.pt2.x = pts[POINT_0p0].x;
vector.pt2.y = pts[POINT_0p0].y;
- return nxtk_drawlinetoolbar(hfwnd, &vector, width, color, true);
+ return nxtk_drawlinetoolbar(hfwnd, &vector, width, color, capped);
}
diff --git a/nuttx/libnx/nxtk/nxtk_drawcirclewindow.c b/nuttx/libnx/nxtk/nxtk_drawcirclewindow.c
index 38435d943..dadf4f41f 100644
--- a/nuttx/libnx/nxtk/nxtk_drawcirclewindow.c
+++ b/nuttx/libnx/nxtk/nxtk_drawcirclewindow.c
@@ -113,6 +113,7 @@ int nxtk_drawcirclewindow(NXTKWINDOW hfwnd, FAR const struct nxgl_point_s *cente
{
struct nxgl_point_s pts[NCIRCLE_POINTS];
FAR struct nxgl_vector_s vector;
+ bool capped;
int i;
int ret;
@@ -124,15 +125,24 @@ int nxtk_drawcirclewindow(NXTKWINDOW hfwnd, FAR const struct nxgl_point_s *cente
for (i = POINT_0p0; i < POINT_337p5; i++)
{
+ /* Draw one line segment */
+
vector.pt1.x = pts[i].x;
vector.pt1.y = pts[i].y;
vector.pt2.x = pts[i+1].x;
vector.pt2.y = pts[i+1].y;
- ret = nxtk_drawlinewindow(hfwnd, &vector, width, color, true);
+
+ ret = nxtk_drawlinewindow(hfwnd, &vector, width, color, capped);
if (ret != OK)
{
return ret;
}
+
+ /* Every other line segment needs to have a circular line caps to join
+ * cleanly with the surround lines segments without line caps.
+ */
+
+ capped = !capped;
}
/* The final, closing vector is a special case */
@@ -141,5 +151,5 @@ int nxtk_drawcirclewindow(NXTKWINDOW hfwnd, FAR const struct nxgl_point_s *cente
vector.pt1.y = pts[POINT_337p5].y;
vector.pt2.x = pts[POINT_0p0].x;
vector.pt2.y = pts[POINT_0p0].y;
- return nxtk_drawlinewindow(hfwnd, &vector, width, color, true);
+ return nxtk_drawlinewindow(hfwnd, &vector, width, color, capped);
}