Gfxprim
Threads by month
- ----- 2026 -----
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- 929 discussions
[repo.or.cz] gfxprim.git branch generate updated: 8a21bc6f957aa940853da65d443afdb21be9b891
by metan 24 Jul '11
by metan 24 Jul '11
24 Jul '11
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project gfxprim.git.
The branch, generate has been updated
via 8a21bc6f957aa940853da65d443afdb21be9b891 (commit)
via a6b989fc9c386a6e7422277784cd13140af7e286 (commit)
from 9af82e35bed6a38c5599afcd4d0e0ac3450299a5 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://repo.or.cz/w/gfxprim.git/commit/8a21bc6f957aa940853da65d443afdb21be9…
commit 8a21bc6f957aa940853da65d443afdb21be9b891
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Jul 24 19:00:23 2011 +0200
API change for gfx library.
Make the default functions honour transformations. The functions that
doesn't honour transformations are now with _Raw suffix.
diff --git a/include/core/GP_DefFnPerBpp.h b/include/core/GP_DefFnPerBpp.h
index 534a451..bedc3b0 100644
--- a/include/core/GP_DefFnPerBpp.h
+++ b/include/core/GP_DefFnPerBpp.h
@@ -34,7 +34,7 @@
GP_DEF_FN_PER_BPP(fname, MACRO_NAME, GP_PutPixel_Raw_)
#define GP_DEF_FILL_FN_PER_BPP(fname, MACRO_NAME) - GP_DEF_FN_PER_BPP(fname, MACRO_NAME, GP_HLine_)
+ GP_DEF_FN_PER_BPP(fname, MACRO_NAME, GP_HLine_Raw_)
#define GP_DEF_FN_FOR_BPP(fname, MACRO_NAME, fdraw, bpp) MACRO_NAME(fname##_##bpp, GP_Context *, GP_Pixel, fdraw##bpp)
diff --git a/include/gfx/GP_Circle.h b/include/gfx/GP_Circle.h
index 482cd51..8f9f4de 100644
--- a/include/gfx/GP_Circle.h
+++ b/include/gfx/GP_Circle.h
@@ -16,10 +16,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
+ * Copyright (C) 2009-2011 Jiri "BlueBear" Dluhos *
* <jiri.bluebear.dluhos(a)gmail.com> *
* *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
@@ -28,22 +28,36 @@
#include "core/GP_Context.h"
+/* Circle */
+
void GP_Circle(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
GP_Size r, GP_Pixel pixel);
-void GP_TCircle(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
- GP_Size r, GP_Pixel pixel);
+void GP_Circle_Raw(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
+ GP_Size r, GP_Pixel pixel);
+
+/* Filled Circle */
void GP_FillCircle(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
GP_Size r, GP_Pixel pixel);
-void GP_TFillCircle(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
- GP_Size r, GP_Pixel pixel);
+void GP_FillCircle_Raw(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
+ GP_Size r, GP_Pixel pixel);
+
+/* Ring */
+
+void GP_Ring(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
+ GP_Size r1, GP_Size r2, GP_Pixel pixel);
+
+void GP_Ring_Raw(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
+ GP_Size r1, GP_Size r2, GP_Pixel pixel);
+
+/* Filled Ring */
void GP_FillRing(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
- GP_Size r1, GP_Size r2, GP_Pixel pixel);
+ GP_Size r1, GP_Size r2, GP_Pixel pixel);
-void GP_TFillRing(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
- GP_Size r1, GP_Size r2, GP_Pixel pixel);
+void GP_FillRing_Raw(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
+ GP_Size r1, GP_Size r2, GP_Pixel pixel);
#endif /* GP_CIRCLE_H */
diff --git a/include/gfx/GP_Ellipse.h b/include/gfx/GP_Ellipse.h
index ef10808..6a86a47 100644
--- a/include/gfx/GP_Ellipse.h
+++ b/include/gfx/GP_Ellipse.h
@@ -16,10 +16,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
+ * Copyright (C) 2009-2011 Jiri "BlueBear" Dluhos *
* <jiri.bluebear.dluhos(a)gmail.com> *
* *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
@@ -28,17 +28,20 @@
#include "core/GP_Context.h"
+/* Ellipse */
+
void GP_Ellipse(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
GP_Size a, GP_Size b, GP_Pixel pixel);
-void GP_TEllipse(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
- GP_Size a, GP_Size b, GP_Pixel pixel);
+void GP_Ellipse_Raw(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
+ GP_Size a, GP_Size b, GP_Pixel pixel);
+
+/* Filled Ellipse */
void GP_FillEllipse(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
GP_Size a, GP_Size b, GP_Pixel pixel);
-void GP_TFillEllipse(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
- GP_Size a, GP_Size b, GP_Pixel pixel);
-
+void GP_FillEllipse_Raw(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
+ GP_Size a, GP_Size b, GP_Pixel pixel);
#endif /* GP_ELLIPSE_H */
diff --git a/include/gfx/GP_Fill.h b/include/gfx/GP_Fill.h
index 6b6139d..2a8ba8b 100644
--- a/include/gfx/GP_Fill.h
+++ b/include/gfx/GP_Fill.h
@@ -16,18 +16,21 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
+ * Copyright (C) 2009-2011 Jiri "BlueBear" Dluhos *
* <jiri.bluebear.dluhos(a)gmail.com> *
* *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
#ifndef GP_FILL_H
#define GP_FILL_H
-#include "core/GP_Context.h"
+#include "GP_Rect.h"
-void GP_Fill(GP_Context *context, GP_Pixel pixel);
+static inline void GP_Fill(GP_Context *context, GP_Pixel pixel)
+{
+ GP_FillRect_Raw(context, 0, 0, context->w, context->h, pixel);
+}
#endif /* GP_FILL_H */
diff --git a/include/gfx/GP_HLine.h b/include/gfx/GP_HLine.h
index 66e2b79..96b66de 100644
--- a/include/gfx/GP_HLine.h
+++ b/include/gfx/GP_HLine.h
@@ -16,10 +16,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
+ * Copyright (C) 2009-2011 Jiri "BlueBear" Dluhos *
* <jiri.bluebear.dluhos(a)gmail.com> *
* *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
@@ -28,59 +28,63 @@
#include "core/GP_Context.h"
-void GP_HLine_1BPP_LE(GP_Context *context, GP_Coord x0, GP_Coord x1,
- GP_Coord y, GP_Pixel pixel);
+/* Raw per BPP HLines */
-void GP_HLine_1BPP_BE(GP_Context *context, GP_Coord x0, GP_Coord x1,
- GP_Coord y, GP_Pixel pixel);
+void GP_HLine_Raw_1BPP_LE(GP_Context *context, GP_Coord x0, GP_Coord x1,
+ GP_Coord y, GP_Pixel pixel);
-void GP_HLine_2BPP_LE(GP_Context *context, GP_Coord x0, GP_Coord x1,
- GP_Coord y, GP_Pixel pixel);
+void GP_HLine_Raw_1BPP_BE(GP_Context *context, GP_Coord x0, GP_Coord x1,
+ GP_Coord y, GP_Pixel pixel);
-void GP_HLine_2BPP_BE(GP_Context *context, GP_Coord x0, GP_Coord x1,
- GP_Coord y, GP_Pixel pixel);
+void GP_HLine_Raw_2BPP_LE(GP_Context *context, GP_Coord x0, GP_Coord x1,
+ GP_Coord y, GP_Pixel pixel);
-void GP_HLine_4BPP_LE(GP_Context *context, GP_Coord x0, GP_Coord x1,
- GP_Coord y, GP_Pixel pixel);
+void GP_HLine_Raw_2BPP_BE(GP_Context *context, GP_Coord x0, GP_Coord x1,
+ GP_Coord y, GP_Pixel pixel);
-void GP_HLine_4BPP_BE(GP_Context *context, GP_Coord x0, GP_Coord x1,
- GP_Coord y, GP_Pixel pixel);
+void GP_HLine_Raw_4BPP_LE(GP_Context *context, GP_Coord x0, GP_Coord x1,
+ GP_Coord y, GP_Pixel pixel);
-void GP_HLine_8BPP(GP_Context *context, GP_Coord x0, GP_Coord x1,
- GP_Coord y, GP_Pixel pixel);
+void GP_HLine_Raw_4BPP_BE(GP_Context *context, GP_Coord x0, GP_Coord x1,
+ GP_Coord y, GP_Pixel pixel);
-void GP_HLine_16BPP(GP_Context *context, GP_Coord x0, GP_Coord x1,
- GP_Coord y, GP_Pixel pixel);
+void GP_HLine_Raw_8BPP(GP_Context *context, GP_Coord x0, GP_Coord x1,
+ GP_Coord y, GP_Pixel pixel);
-void GP_HLine_24BPP(GP_Context *context, GP_Coord x0, GP_Coord x1,
- GP_Coord y, GP_Pixel pixel);
+void GP_HLine_Raw_16BPP(GP_Context *context, GP_Coord x0, GP_Coord x1,
+ GP_Coord y, GP_Pixel pixel);
-void GP_HLine_32BPP(GP_Context *context, GP_Coord x0, GP_Coord x1,
- GP_Coord y, GP_Pixel pixel);
+void GP_HLine_Raw_24BPP(GP_Context *context, GP_Coord x0, GP_Coord x1,
+ GP_Coord y, GP_Pixel pixel);
-void GP_HLineXXY(GP_Context *context, GP_Coord x0, GP_Coord x1,
- GP_Coord y, GP_Pixel pixel);
+void GP_HLine_Raw_32BPP(GP_Context *context, GP_Coord x0, GP_Coord x1,
+ GP_Coord y, GP_Pixel pixel);
-void GP_HLineXYW(GP_Context *context, GP_Coord x, GP_Coord y, GP_Size w,
+/* Generic HLines */
+
+void GP_HLineXXY(GP_Context *context, GP_Coord x0, GP_Coord x1, GP_Coord y,
GP_Pixel pixel);
-void GP_THLineXXY(GP_Context *context, GP_Coord x0, GP_Coord x1,
- GP_Coord y, GP_Pixel pixel);
+void GP_HLineXXY_Raw(GP_Context *context, GP_Coord x0, GP_Coord x1,
+ GP_Coord y, GP_Pixel pixel);
+
+void GP_HLineXYW(GP_Context *context, GP_Coord x, GP_Coord y, GP_Size w,
+ GP_Pixel pixel);
-void GP_THLineXYW(GP_Context *context, GP_Coord x, GP_Coord y, GP_Size w,
- GP_Pixel pixel);
+void GP_HLineXYW_Raw(GP_Context *context, GP_Coord x, GP_Coord y, GP_Size w,
+ GP_Pixel pixel);
/* default argument set is XXY */
-static inline void GP_HLine(GP_Context *context, GP_Coord x0, GP_Coord x1,
- GP_Coord y, GP_Pixel p)
+static inline void GP_HLine_Raw(GP_Context *context, GP_Coord x0, GP_Coord x1,
+ GP_Coord y, GP_Pixel p)
{
- GP_HLineXXY(context, x0, x1, y, p);
+ GP_HLineXXY_Raw(context, x0, x1, y, p);
}
-static inline void GP_THLine(GP_Context *context, GP_Coord x0, GP_Coord x1,
- GP_Coord y, GP_Pixel p)
+static inline void GP_HLine(GP_Context *context, GP_Coord x0, GP_Coord x1,
+ GP_Coord y, GP_Pixel p)
{
- GP_THLineXXY(context, x0, x1, y, p);
+ GP_HLineXXY(context, x0, x1, y, p);
}
#endif /* GP_HLINE_H */
diff --git a/include/gfx/GP_Line.h b/include/gfx/GP_Line.h
index be0b67f..c131c7a 100644
--- a/include/gfx/GP_Line.h
+++ b/include/gfx/GP_Line.h
@@ -16,10 +16,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
+ * Copyright (C) 2009-2011 Jiri "BlueBear" Dluhos *
* <jiri.bluebear.dluhos(a)gmail.com> *
* *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
@@ -28,22 +28,10 @@
#include "core/GP_Context.h"
-void GP_Line8bpp(GP_Context *context, GP_Coord x0, GP_Coord y0,
- GP_Coord x1, GP_Coord y1, GP_Pixel pixel);
-
-void GP_Line16bpp(GP_Context *context, GP_Coord x0, GP_Coord y0,
- GP_Coord x1, GP_Coord y1, GP_Pixel pixel);
-
-void GP_Line24bpp(GP_Context *context, GP_Coord x0, GP_Coord y0,
- GP_Coord x1, GP_Coord y1, GP_Pixel pixel);
-
-void GP_Line32bpp(GP_Context *context, GP_Coord x0, GP_Coord y0,
- GP_Coord x1, GP_Coord y1, GP_Pixel pixel);
-
void GP_Line(GP_Context *context, GP_Coord x0, GP_Coord y0,
- GP_Coord x1, GP_Coord y1, GP_Pixel pixel);
-
-void GP_TLine(GP_Context *context, GP_Coord x0, GP_Coord y0,
GP_Coord x1, GP_Coord y1, GP_Pixel pixel);
+void GP_Line_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0,
+ GP_Coord x1, GP_Coord y1, GP_Pixel pixel);
+
#endif /* GP_LINE_H */
diff --git a/include/gfx/GP_Polygon.h b/include/gfx/GP_Polygon.h
index eee3bcc..8874a53 100644
--- a/include/gfx/GP_Polygon.h
+++ b/include/gfx/GP_Polygon.h
@@ -16,10 +16,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
+ * Copyright (C) 2009-2011 Jiri "BlueBear" Dluhos *
* <jiri.bluebear.dluhos(a)gmail.com> *
* *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
@@ -28,7 +28,7 @@
#include "core/GP_Context.h"
-void GP_FillPolygon(GP_Context *context, int vertex_count, const GP_Coord *xy,
- GP_Pixel pixel);
+void GP_FillPolygon_Raw(GP_Context *context, int vertex_count,
+ const GP_Coord *xy, GP_Pixel pixel);
#endif /* GP_POLYGON_H */
diff --git a/include/gfx/GP_Rect.h b/include/gfx/GP_Rect.h
index 984e0ee..5a3d57f 100644
--- a/include/gfx/GP_Rect.h
+++ b/include/gfx/GP_Rect.h
@@ -16,10 +16,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
+ * Copyright (C) 2009-2011 Jiri "BlueBear" Dluhos *
* <jiri.bluebear.dluhos(a)gmail.com> *
* *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
@@ -28,35 +28,59 @@
#include "core/GP_Context.h"
+/* Rectangle */
+
void GP_RectXYXY(GP_Context *context, GP_Coord x0, GP_Coord y0,
GP_Coord x1, GP_Coord y1, GP_Pixel pixel);
+void GP_RectXYXY_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0,
+ GP_Coord x1, GP_Coord y1, GP_Pixel pixel);
+
void GP_RectXYWH(GP_Context *context, GP_Coord x, GP_Coord y,
GP_Size w, GP_Size h, GP_Pixel pixel);
-void GP_TRectXYXY(GP_Context *context, GP_Coord x0, GP_Coord y0,
- GP_Coord x1, GP_Coord y1, GP_Pixel pixel);
-
-void GP_TRectXYWH(GP_Context *context, GP_Coord x, GP_Coord y,
- GP_Size w, GP_Size h, GP_Pixel pixel);
+void GP_RectXYWH_Raw(GP_Context *context, GP_Coord x, GP_Coord y,
+ GP_Size w, GP_Size h, GP_Pixel pixel);
/* The XYXY argument set is the default */
-#define GP_Rect GP_RectXYXY
-#define GP_TRect GP_TRectXYXY
+static inline void GP_Rect(GP_Context *context, GP_Coord x0, GP_Coord y0,
+ GP_Coord x1, GP_Coord y1, GP_Pixel pixel)
+{
+ GP_RectXYXY(context, x0, y0, x1, y1, pixel);
+}
+
+static inline void GP_Rect_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0,
+ GP_Coord x1, GP_Coord y1, GP_Pixel pixel)
+{
+ GP_RectXYXY_Raw(context, x0, y0, x1, y1, pixel);
+}
+
+/* Filled Rectangle */
void GP_FillRectXYXY(GP_Context *context, GP_Coord x0, GP_Coord y0,
GP_Coord x1, GP_Coord y1, GP_Pixel pixel);
+void GP_FillRectXYXY_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0,
+ GP_Coord x1, GP_Coord y1, GP_Pixel pixel);
+
void GP_FillRectXYWH(GP_Context *context, GP_Coord x, GP_Coord y,
- GP_Size w, GP_Size h, GP_Pixel pixel);
+ GP_Size w, GP_Size h, GP_Pixel pixel);
-void GP_TFillRectXYXY(GP_Context *context, GP_Coord x0, GP_Coord y0,
- GP_Coord x1, GP_Coord y1, GP_Pixel pixel);
+void GP_FillRectXYWH_Raw(GP_Context *context, GP_Coord x, GP_Coord y,
+ GP_Size w, GP_Size h, GP_Pixel pixel);
-void GP_TFillRectXYWH(GP_Context *context, GP_Coord x, GP_Coord y,
- GP_Size w, GP_Size h, GP_Pixel pixel);
+/* The XYXY argument set is the default */
+static inline void GP_FillRect(GP_Context *context, GP_Coord x0, GP_Coord y0,
+ GP_Coord x1, GP_Coord y1, GP_Pixel pixel)
+{
+ GP_FillRectXYXY(context, x0, y0, x1, y1, pixel);
+}
-#define GP_FillRect GP_FillRectXYXY
-#define GP_TFillRect GP_TFillRectXYXY
+static inline void GP_FillRect_Raw(GP_Context *context,
+ GP_Coord x0, GP_Coord y0,
+ GP_Coord x1, GP_Coord y1, GP_Pixel pixel)
+{
+ GP_FillRectXYXY_Raw(context, x0, y0, x1, y1, pixel);
+}
#endif /* GP_RECT_H */
diff --git a/include/gfx/GP_Symbol.h b/include/gfx/GP_Symbol.h
index 648a11e..8a9f2df 100644
--- a/include/gfx/GP_Symbol.h
+++ b/include/gfx/GP_Symbol.h
@@ -16,10 +16,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
+ * Copyright (C) 2009-2011 Jiri "BlueBear" Dluhos *
* <jiri.bluebear.dluhos(a)gmail.com> *
* *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
@@ -40,20 +40,24 @@ typedef enum GP_SymbolType {
GP_SYM_MAX,
} GP_SymbolType;
+/* Symbol */
+
void GP_Symbol(GP_Context *context, GP_SymbolType sym,
GP_Coord x, GP_Coord y,
- GP_Size w, GP_Size h, GP_Pixel pixel);
+ GP_Size w, GP_Size h, GP_Pixel pixel);
+
+void GP_Symbol_Raw(GP_Context *context, GP_SymbolType sym,
+ GP_Coord x, GP_Coord y,
+ GP_Size w, GP_Size h, GP_Pixel pixel);
-void GP_TSymbol(GP_Context *context, GP_SymbolType sym,
- GP_Coord x, GP_Coord y,
- GP_Size w, GP_Size h, GP_Pixel pixel);
+/* Filled Symbol */
void GP_FillSymbol(GP_Context *context, GP_SymbolType sym,
GP_Coord x, GP_Coord y,
GP_Size w, GP_Size h, GP_Pixel pixel);
-void GP_TFillSymbol(GP_Context *context, GP_SymbolType sym,
- GP_Coord x, GP_Coord y,
- GP_Size w, GP_Size h, GP_Pixel pixel);
+void GP_FillSymbol_Raw(GP_Context *context, GP_SymbolType sym,
+ GP_Coord x, GP_Coord y,
+ GP_Size w, GP_Size h, GP_Pixel pixel);
#endif /* GP_SYMBOL_H */
diff --git a/include/gfx/GP_Tetragon.h b/include/gfx/GP_Tetragon.h
index 687ed7e..c6307c3 100644
--- a/include/gfx/GP_Tetragon.h
+++ b/include/gfx/GP_Tetragon.h
@@ -16,10 +16,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
+ * Copyright (C) 2009-2011 Jiri "BlueBear" Dluhos *
* <jiri.bluebear.dluhos(a)gmail.com> *
* *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
@@ -28,20 +28,24 @@
#include "core/GP_Context.h"
+/* Tetragon */
+
void GP_Tetragon(GP_Context *context, GP_Coord x0, GP_Coord y0,
GP_Coord x1, GP_Coord y1, GP_Coord x2, GP_Coord y2,
- GP_Coord x3, GP_Coord y3, GP_Pixel pixel);
+ GP_Coord x3, GP_Coord y3, GP_Pixel pixel);
+
+void GP_Tetragon_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0,
+ GP_Coord x1, GP_Coord y1, GP_Coord x2, GP_Coord y2,
+ GP_Coord x3, GP_Coord y3, GP_Pixel pixel);
-void GP_TTetragon(GP_Context *context, GP_Coord x0, GP_Coord y0,
- GP_Coord x1, GP_Coord y1, GP_Coord x2, GP_Coord y2,
- GP_Coord x3, GP_Coord y3, GP_Pixel pixel);
+/* Filled Tetragon */
void GP_FillTetragon(GP_Context *context, GP_Coord x0, GP_Coord y0,
GP_Coord x1, GP_Coord y1, GP_Coord x2, GP_Coord y2,
GP_Coord x3, GP_Coord y3, GP_Pixel pixel);
-void GP_TFillTetragon(GP_Context *context, GP_Coord x0, GP_Coord y0,
- GP_Coord x1, GP_Coord y1, GP_Coord x2, GP_Coord y2,
- GP_Coord x3, GP_Coord y3, GP_Pixel pixel);
+void GP_FillTetragon_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0,
+ GP_Coord x1, GP_Coord y1, GP_Coord x2, GP_Coord y2,
+ GP_Coord x3, GP_Coord y3, GP_Pixel pixel);
#endif /* GP_TETRAGON_H */
diff --git a/include/gfx/GP_Triangle.h b/include/gfx/GP_Triangle.h
index 7703a5f..2496d89 100644
--- a/include/gfx/GP_Triangle.h
+++ b/include/gfx/GP_Triangle.h
@@ -16,10 +16,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
+ * Copyright (C) 2009-2011 Jiri "BlueBear" Dluhos *
* <jiri.bluebear.dluhos(a)gmail.com> *
* *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
@@ -28,20 +28,24 @@
#include "core/GP_Context.h"
+/* Triangle */
+
void GP_Triangle(GP_Context *context, GP_Coord x0, GP_Coord y0,
GP_Coord x1, GP_Coord y1,
- GP_Coord x2, GP_Coord y2, GP_Pixel pixel);
+ GP_Coord x2, GP_Coord y2, GP_Pixel pixel);
+
+void GP_Triangle_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0,
+ GP_Coord x1, GP_Coord y1,
+ GP_Coord x2, GP_Coord y2, GP_Pixel pixel);
-void GP_TTriangle(GP_Context *context, GP_Coord x0, GP_Coord y0,
- GP_Coord x1, GP_Coord y1,
- GP_Coord x2, GP_Coord y2, GP_Pixel pixel);
+/* Filled Triangle */
void GP_FillTriangle(GP_Context *context, GP_Coord x0, GP_Coord y0,
GP_Coord x1, GP_Coord y1,
GP_Coord x2, GP_Coord y2, GP_Pixel pixel);
-void GP_TFillTriangle(GP_Context *context, GP_Coord x0, GP_Coord y0,
- GP_Coord x1, GP_Coord y1,
- GP_Coord x2, GP_Coord y2, GP_Pixel pixel);
+void GP_FillTriangle_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0,
+ GP_Coord x1, GP_Coord y1,
+ GP_Coord x2, GP_Coord y2, GP_Pixel pixel);
#endif /* GP_TRIANGLE_H */
diff --git a/include/gfx/GP_VLine.h b/include/gfx/GP_VLine.h
index 3cf6085..ea5a576 100644
--- a/include/gfx/GP_VLine.h
+++ b/include/gfx/GP_VLine.h
@@ -16,10 +16,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
+ * Copyright (C) 2009-2011 Jiri "BlueBear" Dluhos *
* <jiri.bluebear.dluhos(a)gmail.com> *
* *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
@@ -31,17 +31,26 @@
void GP_VLineXYY(GP_Context *context, GP_Coord x, GP_Coord y0,
GP_Coord y1, GP_Pixel pixel);
+void GP_VLineXYY_Raw(GP_Context *context, GP_Coord x, GP_Coord y0,
+ GP_Coord y1, GP_Pixel pixel);
+
void GP_VLineXYH(GP_Context *context, GP_Coord x, GP_Coord y,
GP_Size height, GP_Pixel pixel);
-void GP_TVLineXYY(GP_Context *context, GP_Coord x, GP_Coord y0,
- GP_Coord y1, GP_Pixel pixel);
-
-void GP_TVLineXYH(GP_Context *context, GP_Coord x, GP_Coord y,
- GP_Size height, GP_Pixel pixel);
+void GP_VLineXYH_Raw(GP_Context *context, GP_Coord x, GP_Coord y,
+ GP_Size height, GP_Pixel pixel);
/* default argument set is XYY */
-#define GP_VLine GP_VLineXYY
-#define GP_TVLine GP_TVLineXYY
+static inline void GP_VLine(GP_Context *context, GP_Coord x,
+ GP_Coord y0, GP_Coord y1, GP_Pixel pixel)
+{
+ GP_VLineXYY(context, x, y0, y1, pixel);
+}
+
+static inline void GP_VLine_Raw(GP_Context *context, GP_Coord x,
+ GP_Coord y0, GP_Coord y1, GP_Pixel pixel)
+{
+ GP_VLineXYY_Raw(context, x, y0, y1, pixel);
+}
#endif /* GP_VLINE_H */
diff --git a/include/text/GP_Text.h b/include/text/GP_Text.h
index e1144fa..2c0177e 100644
--- a/include/text/GP_Text.h
+++ b/include/text/GP_Text.h
@@ -16,10 +16,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
+ * Copyright (C) 2009-2011 Jiri "BlueBear" Dluhos *
* <jiri.bluebear.dluhos(a)gmail.com> *
* *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
@@ -54,18 +54,20 @@ typedef enum GP_TextAlign {
GP_VALIGN_BOTTOM = GP_VALIGN_BELOW,
} GP_TextAlign;
+GP_RetCode GP_Text_Raw(GP_Context *context, const GP_TextStyle *style,
+ GP_Coord x, GP_Coord y, int align,
+ const char *str, GP_Pixel pixel);
+
GP_RetCode GP_Text(GP_Context *context, const GP_TextStyle *style,
- int x, int y, int align, const char *str, GP_Pixel pixel);
+ GP_Coord x, GP_Coord y, int align,
+ const char *str, GP_Pixel pixel);
-GP_RetCode GP_TText(GP_Context *context, const GP_TextStyle *style,
- int x, int y, int align, const char *str, GP_Pixel pixel);
+GP_RetCode GP_BoxCenteredText_Raw(GP_Context *context, const GP_TextStyle *style,
+ GP_Coord x, GP_Coord y, GP_Size w, GP_Size h,
+ const char *str, GP_Pixel pixel);
GP_RetCode GP_BoxCenteredText(GP_Context *context, const GP_TextStyle *style,
- int x, int y, int w, int h, const char *str,
- GP_Pixel pixel);
-
-GP_RetCode GP_TBoxCenteredText(GP_Context *context, const GP_TextStyle *style,
- int x, int y, int w, int h, const char *str,
- GP_Pixel pixel);
+ GP_Coord x, GP_Coord y, GP_Size w, GP_Size h,
+ const char *str, GP_Pixel pixel);
#endif /* GP_TEXT_H */
diff --git a/libs/gfx/GP_Circle.c b/libs/gfx/GP_Circle.c
index 9af9f43..95e685f 100644
--- a/libs/gfx/GP_Circle.c
+++ b/libs/gfx/GP_Circle.c
@@ -16,10 +16,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
+ * Copyright (C) 2009-2011 Jiri "BlueBear" Dluhos *
* <jiri.bluebear.dluhos(a)gmail.com> *
* *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
@@ -30,71 +30,88 @@
#include "algo/Circle.algo.h"
/* Generate drawing functions for various bit depths. */
-GP_DEF_DRAW_FN_PER_BPP(GP_Circle, DEF_CIRCLE_FN)
+GP_DEF_DRAW_FN_PER_BPP(GP_Circle_Raw, DEF_CIRCLE_FN)
-void GP_Circle(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
- GP_Size r, GP_Pixel pixel)
+void GP_Circle_Raw(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
+ GP_Size r, GP_Pixel pixel)
{
GP_CHECK_CONTEXT(context);
- GP_FN_PER_BPP_CONTEXT(GP_Circle, context, context,
+ GP_FN_PER_BPP_CONTEXT(GP_Circle_Raw, context, context,
xcenter, ycenter, r, pixel);
}
-void GP_TCircle(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
- GP_Size r, GP_Pixel pixel)
+void GP_Circle(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
+ GP_Size r, GP_Pixel pixel)
{
GP_CHECK_CONTEXT(context);
GP_TRANSFORM_POINT(context, xcenter, ycenter);
- GP_Circle(context, xcenter, ycenter, r, pixel);
+ GP_Circle_Raw(context, xcenter, ycenter, r, pixel);
}
#include "algo/FillCircle.algo.h"
/* Generate drawing functions for various bit depths. */
-GP_DEF_FILL_FN_PER_BPP(GP_FillCircle, DEF_FILLCIRCLE_FN)
+GP_DEF_FILL_FN_PER_BPP(GP_FillCircle_Raw, DEF_FILLCIRCLE_FN)
-void GP_FillCircle(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
- GP_Size r, GP_Pixel pixel)
+void GP_FillCircle_Raw(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
+ GP_Size r, GP_Pixel pixel)
{
GP_CHECK_CONTEXT(context);
- GP_FN_PER_BPP_CONTEXT(GP_FillCircle, context, context,
+ GP_FN_PER_BPP_CONTEXT(GP_FillCircle_Raw, context, context,
xcenter, ycenter, r, pixel);
}
-void GP_TFillCircle(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
- GP_Size r, GP_Pixel pixel)
+void GP_FillCircle(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
+ GP_Size r, GP_Pixel pixel)
{
GP_CHECK_CONTEXT(context);
GP_TRANSFORM_POINT(context, xcenter, ycenter);
- GP_FillCircle(context, xcenter, ycenter, r, pixel);
+ GP_FillCircle_Raw(context, xcenter, ycenter, r, pixel);
+}
+
+void GP_Ring_Raw(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
+ GP_Size r1, GP_Size r2, GP_Pixel pixel)
+{
+ GP_Circle_Raw(context, xcenter, ycenter, r1, pixel);
+ GP_Circle_Raw(context, xcenter, ycenter, r2, pixel);
+}
+
+void GP_Ring(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
+ GP_Size r1, GP_Size r2, GP_Pixel pixel)
+{
+ GP_CHECK_CONTEXT(context);
+
+ GP_TRANSFORM_POINT(context, xcenter, ycenter);
+
+ GP_Ring_Raw(context, xcenter, ycenter, r1, r2, pixel);
}
#include "algo/FillRing.algo.h"
/* Generate drawing functions for various bit depths. */
-GP_DEF_FILL_FN_PER_BPP(GP_FillRing, DEF_FILLRING_FN)
+GP_DEF_FILL_FN_PER_BPP(GP_FillRing_Raw, DEF_FILLRING_FN)
-void GP_FillRing(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
- GP_Size r1, GP_Size r2, GP_Pixel pixel)
+void GP_FillRing_Raw(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
+ GP_Size r1, GP_Size r2, GP_Pixel pixel)
{
GP_CHECK_CONTEXT(context);
- GP_FN_PER_BPP_CONTEXT(GP_FillRing, context, context,
+ GP_FN_PER_BPP_CONTEXT(GP_FillRing_Raw, context, context,
xcenter, ycenter, r1, r2, pixel);
}
-void GP_TFillRing(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
- GP_Size r1, GP_Size r2, GP_Pixel pixel)
+void GP_FillRing(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
+ GP_Size r1, GP_Size r2, GP_Pixel pixel)
{
GP_CHECK_CONTEXT(context);
GP_TRANSFORM_POINT(context, xcenter, ycenter);
- GP_FillRing(context, xcenter, ycenter, r1, r2, pixel);
+ GP_FillRing_Raw(context, xcenter, ycenter, r1, r2, pixel);
}
diff --git a/libs/gfx/GP_Ellipse.c b/libs/gfx/GP_Ellipse.c
index bbd3bdf..66f33e0 100644
--- a/libs/gfx/GP_Ellipse.c
+++ b/libs/gfx/GP_Ellipse.c
@@ -16,10 +16,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
+ * Copyright (C) 2009-2011 Jiri "BlueBear" Dluhos *
* <jiri.bluebear.dluhos(a)gmail.com> *
* *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
@@ -30,50 +30,50 @@
#include "algo/Ellipse.algo.h"
/* Generate drawing functions for various bit depths. */
-GP_DEF_DRAW_FN_PER_BPP(GP_Ellipse, DEF_ELLIPSE_FN)
+GP_DEF_DRAW_FN_PER_BPP(GP_Ellipse_Raw, DEF_ELLIPSE_FN)
-void GP_Ellipse(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
- GP_Size a, GP_Size b, GP_Pixel pixel)
+void GP_Ellipse_Raw(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
+ GP_Size a, GP_Size b, GP_Pixel pixel)
{
GP_CHECK_CONTEXT(context);
- GP_FN_PER_BPP_CONTEXT(GP_Ellipse, context, context,
+ GP_FN_PER_BPP_CONTEXT(GP_Ellipse_Raw, context, context,
xcenter, ycenter, a, b, pixel);
}
-void GP_TEllipse(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
- GP_Size a, GP_Size b, GP_Pixel pixel)
+void GP_Ellipse(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
+ GP_Size a, GP_Size b, GP_Pixel pixel)
{
GP_CHECK_CONTEXT(context);
- /* recalculate center poGP_Coord and swap a and b when axes are swapped */
+ /* recalculate center point and swap a and b when axes are swapped */
GP_TRANSFORM_POINT(context, xcenter, ycenter);
GP_TRANSFORM_SWAP(context, a, b);
- GP_Ellipse(context, xcenter, ycenter, a, b, pixel);
+ GP_Ellipse_Raw(context, xcenter, ycenter, a, b, pixel);
}
#include "algo/FillEllipse.algo.h"
/* Generate drawing functions for various bit depths. */
-GP_DEF_FILL_FN_PER_BPP(GP_FillEllipse, DEF_FILLELLIPSE_FN)
+GP_DEF_FILL_FN_PER_BPP(GP_FillEllipse_Raw, DEF_FILLELLIPSE_FN)
-void GP_FillEllipse(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
- GP_Size a, GP_Size b, GP_Pixel pixel)
+void GP_FillEllipse_Raw(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
+ GP_Size a, GP_Size b, GP_Pixel pixel)
{
GP_CHECK_CONTEXT(context);
- GP_FN_PER_BPP_CONTEXT(GP_FillEllipse, context, context,
+ GP_FN_PER_BPP_CONTEXT(GP_FillEllipse_Raw, context, context,
xcenter, ycenter, a, b, pixel);
}
-void GP_TFillEllipse(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
- GP_Size a, GP_Size b, GP_Pixel pixel)
+void GP_FillEllipse(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
+ GP_Size a, GP_Size b, GP_Pixel pixel)
{
GP_CHECK_CONTEXT(context);
GP_TRANSFORM_POINT(context, xcenter, ycenter);
GP_TRANSFORM_SWAP(context, a, b);
- GP_FillEllipse(context, xcenter, ycenter, a, b, pixel);
+ GP_FillEllipse_Raw(context, xcenter, ycenter, a, b, pixel);
}
diff --git a/libs/gfx/GP_Fill.c b/libs/gfx/GP_Fill.c
deleted file mode 100644
index c99df23..0000000
--- a/libs/gfx/GP_Fill.c
+++ /dev/null
@@ -1,38 +0,0 @@
-/*****************************************************************************
- * This file is part of gfxprim library. *
- * *
- * Gfxprim is free software; you can redistribute it and/or *
- * modify it under the terms of the GNU Lesser General Public *
- * License as published by the Free Software Foundation; either *
- * version 2.1 of the License, or (at your option) any later version. *
- * *
- * Gfxprim is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with gfxprim; if not, write to the Free Software *
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
- * Boston, MA 02110-1301 USA *
- * *
- * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
- * <jiri.bluebear.dluhos(a)gmail.com> *
- * *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
- * *
- *****************************************************************************/
-
-#ifndef GP_FILL_H
-#define GP_FILL_H
-
-#include "GP_Gfx.h"
-
-void GP_Fill(GP_Context *context, GP_Pixel pixel)
-{
- GP_CHECK_CONTEXT(context);
-
- GP_FillRect(context, 0, 0, context->w, context->h, pixel);
-}
-
-#endif /* GP_FILL_H */
diff --git a/libs/gfx/GP_HLine.c b/libs/gfx/GP_HLine.c
index 3d51cc4..9154b45 100644
--- a/libs/gfx/GP_HLine.c
+++ b/libs/gfx/GP_HLine.c
@@ -16,10 +16,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
+ * Copyright (C) 2009-2011 Jiri "BlueBear" Dluhos *
* <jiri.bluebear.dluhos(a)gmail.com> *
* *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
@@ -30,38 +30,39 @@
/* Generate drawing functions for various bit depths. */
//TODO: BIT ENDIANESS
-DEF_HLINE_BU_FN(GP_HLine_1BPP_LE, GP_Context *, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels1bpp)
-DEF_HLINE_BU_FN(GP_HLine_1BPP_BE, GP_Context *, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels1bpp)
-DEF_HLINE_BU_FN(GP_HLine_2BPP_LE, GP_Context *, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels2bpp)
-DEF_HLINE_BU_FN(GP_HLine_2BPP_BE, GP_Context *, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels2bpp)
-DEF_HLINE_BU_FN(GP_HLine_4BPP_LE, GP_Context *, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels2bpp)
-DEF_HLINE_BU_FN(GP_HLine_4BPP_BE, GP_Context *, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels2bpp)
+DEF_HLINE_BU_FN(GP_HLine_Raw_1BPP_LE, GP_Context*, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels1bpp)
+DEF_HLINE_BU_FN(GP_HLine_Raw_1BPP_BE, GP_Context*, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels1bpp)
+DEF_HLINE_BU_FN(GP_HLine_Raw_2BPP_LE, GP_Context*, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels2bpp)
+DEF_HLINE_BU_FN(GP_HLine_Raw_2BPP_BE, GP_Context*, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels2bpp)
+DEF_HLINE_BU_FN(GP_HLine_Raw_4BPP_LE, GP_Context*, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels2bpp)
+DEF_HLINE_BU_FN(GP_HLine_Raw_4BPP_BE, GP_Context*, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels2bpp)
-DEF_HLINE_FN(GP_HLine_8BPP, GP_Context *, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels8bpp)
-DEF_HLINE_FN(GP_HLine_16BPP, GP_Context *, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels16bpp)
-DEF_HLINE_FN(GP_HLine_24BPP, GP_Context *, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels24bpp)
-DEF_HLINE_FN(GP_HLine_32BPP, GP_Context *, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels32bpp)
+DEF_HLINE_FN(GP_HLine_Raw_8BPP, GP_Context *, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels8bpp)
+DEF_HLINE_FN(GP_HLine_Raw_16BPP, GP_Context *, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels16bpp)
+DEF_HLINE_FN(GP_HLine_Raw_24BPP, GP_Context *, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels24bpp)
+DEF_HLINE_FN(GP_HLine_Raw_32BPP, GP_Context *, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels32bpp)
-void GP_HLineXXY(GP_Context *context, GP_Coord x0, GP_Coord x1,
- GP_Coord y, GP_Pixel pixel)
+void GP_HLineXXY_Raw(GP_Context *context, GP_Coord x0, GP_Coord x1,
+ GP_Coord y, GP_Pixel pixel)
{
GP_CHECK_CONTEXT(context);
- GP_FN_PER_BPP_CONTEXT(GP_HLine, context, context, x0, x1, y, pixel);
+ GP_FN_PER_BPP_CONTEXT(GP_HLine_Raw, context, context, x0, x1, y,
+ pixel);
}
-void GP_HLineXYW(GP_Context *context, GP_Coord x, GP_Coord y, GP_Size w,
- GP_Pixel pixel)
+void GP_HLineXYW_Raw(GP_Context *context, GP_Coord x, GP_Coord y, GP_Size w,
+ GP_Pixel pixel)
{
/* zero width: do not draw anything */
if (w == 0)
return;
- GP_HLineXXY(context, x, x + w - 1, y, pixel);
+ GP_HLineXXY_Raw(context, x, x + w - 1, y, pixel);
}
-void GP_THLineXXY(GP_Context *context, GP_Coord x0, GP_Coord x1,
- GP_Coord y, GP_Pixel pixel)
+void GP_HLineXXY(GP_Context *context, GP_Coord x0, GP_Coord x1, GP_Coord y,
+ GP_Pixel pixel)
{
GP_CHECK_CONTEXT(context);
@@ -69,21 +70,21 @@ void GP_THLineXXY(GP_Context *context, GP_Coord x0, GP_Coord x1,
GP_TRANSFORM_Y(context, x0);
GP_TRANSFORM_Y(context, x1);
GP_TRANSFORM_X(context, y);
- GP_VLine(context, y, x0, x1, pixel);
+ GP_VLine_Raw(context, y, x0, x1, pixel);
} else {
GP_TRANSFORM_X(context, x0);
GP_TRANSFORM_X(context, x1);
GP_TRANSFORM_Y(context, y);
- GP_HLine(context, x0, x1, y, pixel);
+ GP_HLine_Raw(context, x0, x1, y, pixel);
}
}
-void GP_THLineXYW(GP_Context *context, GP_Coord x, GP_Coord y, GP_Size w,
- GP_Pixel pixel)
+void GP_HLineXYW(GP_Context *context, GP_Coord x, GP_Coord y, GP_Size w,
+ GP_Pixel pixel)
{
/* zero width: do not draw anything */
if (w == 0)
return;
- GP_THLineXXY(context, x, x + w - 1, y, pixel);
+ GP_HLineXXY(context, x, x + w - 1, y, pixel);
}
diff --git a/libs/gfx/GP_Line.c b/libs/gfx/GP_Line.c
index d5dda97..4236ee8 100644
--- a/libs/gfx/GP_Line.c
+++ b/libs/gfx/GP_Line.c
@@ -30,23 +30,24 @@
#include "algo/Line.algo.h"
/* Generate drawing functions for various bit depths. */
-GP_DEF_DRAW_FN_PER_BPP(GP_Line, DEF_LINE_FN)
+GP_DEF_DRAW_FN_PER_BPP(GP_Line_Raw, DEF_LINE_FN)
-void GP_Line(GP_Context *context, GP_Coord x0, GP_Coord y0,
- GP_Coord x1, GP_Coord y1, GP_Pixel pixel)
+void GP_Line_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0,
+ GP_Coord x1, GP_Coord y1, GP_Pixel pixel)
{
GP_CHECK_CONTEXT(context);
- GP_FN_PER_BPP_CONTEXT(GP_Line, context, context, x0, y0, x1, y1, pixel);
+ GP_FN_PER_BPP_CONTEXT(GP_Line_Raw, context, context, x0, y0, x1, y1,
+ pixel);
}
-void GP_TLine(GP_Context *context, GP_Coord x0, GP_Coord y0,
- GP_Coord x1, GP_Coord y1, GP_Pixel pixel)
+void GP_Line(GP_Context *context, GP_Coord x0, GP_Coord y0,
+ GP_Coord x1, GP_Coord y1, GP_Pixel pixel)
{
GP_CHECK_CONTEXT(context);
GP_TRANSFORM_POINT(context, x0, y0);
GP_TRANSFORM_POINT(context, x1, y1);
- GP_Line(context, x0, y0, x1, y1, pixel);
+ GP_Line_Raw(context, x0, y0, x1, y1, pixel);
}
diff --git a/libs/gfx/GP_Polygon.c b/libs/gfx/GP_Polygon.c
index 1bf5dc7..cef18c0 100644
--- a/libs/gfx/GP_Polygon.c
+++ b/libs/gfx/GP_Polygon.c
@@ -16,10 +16,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
+ * Copyright (C) 2009-2011 Jiri "BlueBear" Dluhos *
* <jiri.bluebear.dluhos(a)gmail.com> *
* *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
@@ -79,7 +79,7 @@ static void GP_AddEdge(struct GP_Polygon *poly, GP_Coord x1, GP_Coord y1,
poly->ymax = GP_MAX(poly->ymax, edge->endy);
}
-static GP_Coord GP_CompareEdges(const void *edge1, const void *edge2)
+static int GP_CompareEdges(const void *edge1, const void *edge2)
{
struct GP_PolygonEdge *e1 = (struct GP_PolygonEdge *) edge1;
struct GP_PolygonEdge *e2 = (struct GP_PolygonEdge *) edge2;
@@ -153,8 +153,8 @@ static inline GP_Coord GP_FindIntersection(GP_Coord y, const struct GP_PolygonEd
return x;
}
-void GP_FillPolygon(GP_Context *context, GP_Coord vertex_count, const GP_Coord *xy,
- GP_Pixel pixel)
+void GP_FillPolygon_Raw(GP_Context *context, GP_Coord vertex_count,
+ const GP_Coord *xy, GP_Pixel pixel)
{
struct GP_Polygon poly = GP_POLYGON_INITIALIZER;
@@ -187,7 +187,7 @@ void GP_FillPolygon(GP_Context *context, GP_Coord vertex_count, const GP_Coord *
}
}
- GP_HLine(context, startx, endx, y, pixel);
+ GP_HLine_Raw(context, startx, endx, y, pixel);
startx_prev = startx;
endx_prev = endx;
diff --git a/libs/gfx/GP_Rect.c b/libs/gfx/GP_Rect.c
index 9f1fabe..eee96f5 100644
--- a/libs/gfx/GP_Rect.c
+++ b/libs/gfx/GP_Rect.c
@@ -16,56 +16,52 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
+ * Copyright (C) 2009-2011 Jiri "BlueBear" Dluhos *
* <jiri.bluebear.dluhos(a)gmail.com> *
* *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
#include "GP_Gfx.h"
-void GP_RectXYXY(GP_Context *context, GP_Coord x0, GP_Coord y0,
- GP_Coord x1, GP_Coord y1, GP_Pixel pixel)
+void GP_RectXYXY_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0,
+ GP_Coord x1, GP_Coord y1, GP_Pixel pixel)
{
- GP_CHECK_CONTEXT(context);
-
- GP_HLine(context, x0, x1, y0, pixel);
- GP_HLine(context, x0, x1, y1, pixel);
- GP_VLine(context, x0, y0, y1, pixel);
- GP_VLine(context, x1, y0, y1, pixel);
+ GP_HLine_Raw(context, x0, x1, y0, pixel);
+ GP_HLine_Raw(context, x0, x1, y1, pixel);
+ GP_VLine_Raw(context, x0, y0, y1, pixel);
+ GP_VLine_Raw(context, x1, y0, y1, pixel);
}
-void GP_RectXYWH(GP_Context *context, GP_Coord x, GP_Coord y,
- GP_Size w, GP_Size h, GP_Pixel pixel)
+void GP_RectXYWH_Raw(GP_Context *context, GP_Coord x, GP_Coord y,
+ GP_Size w, GP_Size h, GP_Pixel pixel)
{
- GP_CHECK_CONTEXT(context);
-
- GP_HLine(context, x, x + w, y, pixel);
- GP_HLine(context, x, x + w, y + h, pixel);
- GP_VLine(context, x, y, y + h, pixel);
- GP_VLine(context, x + w, y, y + h, pixel);
+ GP_HLine_Raw(context, x, x + w, y, pixel);
+ GP_HLine_Raw(context, x, x + w, y + h, pixel);
+ GP_VLine_Raw(context, x, y, y + h, pixel);
+ GP_VLine_Raw(context, x + w, y, y + h, pixel);
}
-void GP_TRectXYXY(GP_Context *context, GP_Coord x0, GP_Coord y0,
- GP_Coord x1, GP_Coord y1, GP_Pixel pixel)
+void GP_RectXYXY(GP_Context *context, GP_Coord x0, GP_Coord y0,
+ GP_Coord x1, GP_Coord y1, GP_Pixel pixel)
{
GP_CHECK_CONTEXT(context);
GP_TRANSFORM_POINT(context, x0, y0);
GP_TRANSFORM_POINT(context, x1, y1);
- GP_RectXYXY(context, x0, y0, x1, y1, pixel);
+ GP_RectXYXY_Raw(context, x0, y0, x1, y1, pixel);
}
-void GP_TRectXYWH(GP_Context *context, GP_Coord x, GP_Coord y,
- GP_Size w, GP_Size h, GP_Pixel pixel)
+void GP_RectXYWH(GP_Context *context, GP_Coord x, GP_Coord y,
+ GP_Size w, GP_Size h, GP_Pixel pixel)
{
- GP_TRectXYXY(context, x, y, x + w, y + h, pixel);
+ GP_RectXYXY(context, x, y, x + w, y + h, pixel);
}
-void GP_FillRectXYXY(GP_Context *context, GP_Coord x0, GP_Coord y0,
- GP_Coord x1, GP_Coord y1, GP_Pixel pixel)
+void GP_FillRectXYXY_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0,
+ GP_Coord x1, GP_Coord y1, GP_Pixel pixel)
{
GP_CHECK_CONTEXT(context);
@@ -74,36 +70,36 @@ void GP_FillRectXYXY(GP_Context *context, GP_Coord x0, GP_Coord y0,
GP_Coord y;
for (y = y0; y <= y1; y++)
- GP_HLine(context, x0, x1, y, pixel);
+ GP_HLine_Raw(context, x0, x1, y, pixel);
}
-void GP_FillRectXYWH(GP_Context *context, GP_Coord x, GP_Coord y,
- GP_Size w, GP_Size h, GP_Pixel pixel)
+void GP_FillRectXYWH_Raw(GP_Context *context, GP_Coord x, GP_Coord y,
+ GP_Size w, GP_Size h, GP_Pixel pixel)
{
/* zero width/height: draw nothing */
if (w == 0 || h == 0)
return;
- return GP_FillRectXYXY(context, x, y, x + w - 1, y + h - 1, pixel);
+ GP_FillRectXYXY_Raw(context, x, y, x + w - 1, y + h - 1, pixel);
}
-void GP_TFillRectXYXY(GP_Context *context, GP_Coord x0, GP_Coord y0,
- GP_Coord x1, GP_Coord y1, GP_Pixel pixel)
+void GP_FillRectXYXY(GP_Context *context, GP_Coord x0, GP_Coord y0,
+ GP_Coord x1, GP_Coord y1, GP_Pixel pixel)
{
GP_CHECK_CONTEXT(context);
GP_TRANSFORM_POINT(context, x0, y0);
GP_TRANSFORM_POINT(context, x1, y1);
- GP_FillRect(context, x0, y0, x1, y1, pixel);
+ GP_FillRect_Raw(context, x0, y0, x1, y1, pixel);
}
-void GP_TFillRectXYWH(GP_Context *context, GP_Coord x, GP_Coord y,
- GP_Size w, GP_Size h, GP_Pixel pixel)
+void GP_FillRectXYWH(GP_Context *context, GP_Coord x, GP_Coord y,
+ GP_Size w, GP_Size h, GP_Pixel pixel)
{
/* zero width/height: draw nothing */
if (w == 0 || h == 0)
return;
- GP_TFillRectXYXY(context, x, y, x + w - 1, y + h - 1, pixel);
+ GP_FillRectXYXY(context, x, y, x + w - 1, y + h - 1, pixel);
}
diff --git a/libs/gfx/GP_Symbol.c b/libs/gfx/GP_Symbol.c
index 7a7b44e..fcf61c7 100644
--- a/libs/gfx/GP_Symbol.c
+++ b/libs/gfx/GP_Symbol.c
@@ -68,83 +68,94 @@
fn_pref##Triangle(context, TRIANGLE_PARAMS(x, y, w, h), pixel); } while (0)
-void GP_Symbol(GP_Context *context, GP_SymbolType sym,
- GP_Coord x, GP_Coord y, GP_Size w, GP_Size h, GP_Pixel pixel)
+#define TRIANGLE_RAW(context, base, x, y, w, h, fn_pref, + TRIANGLE_PARAMS, TETRAGON_PARAMS, pixel) do { + if (base % 2) + fn_pref##Tetragon_Raw(context, TETRAGON_PARAMS(x, y, w, h), pixel);+ else + fn_pref##Triangle_Raw(context, TRIANGLE_PARAMS(x, y, w, h), pixel);+} while (0)
+
+void GP_Symbol_Raw(GP_Context *context, GP_SymbolType sym,
+ GP_Coord x, GP_Coord y, GP_Size w, GP_Size h,
+ GP_Pixel pixel)
{
DO_DECREMENT(w);
DO_DECREMENT(h);
switch (sym) {
case GP_SYM_TRIANGLE_UP:
- TRIANGLE(context, w, x, y, w, h, GP_,
- DO_TRIANGLE_UP, DO_TETRAGON_UP, pixel);
+ TRIANGLE_RAW(context, w, x, y, w, h, GP_,
+ DO_TRIANGLE_UP, DO_TETRAGON_UP, pixel);
break;
case GP_SYM_TRIANGLE_DOWN:
- TRIANGLE(context, w, x, y, w, h, GP_,
- DO_TRIANGLE_DOWN, DO_TETRAGON_DOWN, pixel);
+ TRIANGLE_RAW(context, w, x, y, w, h, GP_,
+ DO_TRIANGLE_DOWN, DO_TETRAGON_DOWN, pixel);
break;
case GP_SYM_TRIANGLE_LEFT:
- TRIANGLE(context, h, x, y, w, h, GP_,
- DO_TRIANGLE_LEFT, DO_TETRAGON_LEFT, pixel);
+ TRIANGLE_RAW(context, h, x, y, w, h, GP_,
+ DO_TRIANGLE_LEFT, DO_TETRAGON_LEFT, pixel);
break;
case GP_SYM_TRIANGLE_RIGHT:
- TRIANGLE(context, h, x, y, w, h, GP_,
- DO_TRIANGLE_RIGHT, DO_TETRAGON_RIGHT, pixel);
+ TRIANGLE_RAW(context, h, x, y, w, h, GP_,
+ DO_TRIANGLE_RIGHT, DO_TETRAGON_RIGHT, pixel);
break;
default:
break;
}
}
-void GP_FillSymbol(GP_Context *context, GP_SymbolType sym,
- GP_Coord x, GP_Coord y, GP_Size w, GP_Size h, GP_Pixel pixel)
+void GP_FillSymbol_Raw(GP_Context *context, GP_SymbolType sym,
+ GP_Coord x, GP_Coord y, GP_Size w, GP_Size h,
+ GP_Pixel pixel)
{
DO_DECREMENT(w);
DO_DECREMENT(h);
switch (sym) {
case GP_SYM_TRIANGLE_UP:
- TRIANGLE(context, w, x, y, w, h, GP_Fill,
- DO_TRIANGLE_UP, DO_TETRAGON_UP, pixel);
+ TRIANGLE_RAW(context, w, x, y, w, h, GP_Fill,
+ DO_TRIANGLE_UP, DO_TETRAGON_UP, pixel);
break;
case GP_SYM_TRIANGLE_DOWN:
- TRIANGLE(context, w, x, y, w, h, GP_Fill,
- DO_TRIANGLE_DOWN, DO_TETRAGON_DOWN, pixel);
+ TRIANGLE_RAW(context, w, x, y, w, h, GP_Fill,
+ DO_TRIANGLE_DOWN, DO_TETRAGON_DOWN, pixel);
break;
case GP_SYM_TRIANGLE_LEFT:
- TRIANGLE(context, h, x, y, w, h, GP_Fill,
- DO_TRIANGLE_LEFT, DO_TETRAGON_LEFT, pixel);
+ TRIANGLE_RAW(context, h, x, y, w, h, GP_Fill,
+ DO_TRIANGLE_LEFT, DO_TETRAGON_LEFT, pixel);
break;
case GP_SYM_TRIANGLE_RIGHT:
- TRIANGLE(context, h, x, y, w, h, GP_Fill,
- DO_TRIANGLE_RIGHT, DO_TETRAGON_RIGHT, pixel);
+ TRIANGLE_RAW(context, h, x, y, w, h, GP_Fill,
+ DO_TRIANGLE_RIGHT, DO_TETRAGON_RIGHT, pixel);
break;
default:
break;
}
}
-void GP_TSymbol(GP_Context *context, GP_SymbolType sym,
- GP_Coord x, GP_Coord y, GP_Size w, GP_Size h, GP_Pixel pixel)
+void GP_Symbol(GP_Context *context, GP_SymbolType sym,
+ GP_Coord x, GP_Coord y, GP_Size w, GP_Size h,
+ GP_Pixel pixel)
{
DO_DECREMENT(w);
DO_DECREMENT(h);
switch (sym) {
case GP_SYM_TRIANGLE_UP:
- TRIANGLE(context, w, x, y, w, h, GP_T,
+ TRIANGLE(context, w, x, y, w, h, GP_,
DO_TRIANGLE_UP, DO_TETRAGON_UP, pixel);
break;
case GP_SYM_TRIANGLE_DOWN:
- TRIANGLE(context, w, x, y, w, h, GP_T,
+ TRIANGLE(context, w, x, y, w, h, GP_,
DO_TRIANGLE_DOWN, DO_TETRAGON_DOWN, pixel);
break;
case GP_SYM_TRIANGLE_LEFT:
- TRIANGLE(context, h, x, y, w, h, GP_T,
+ TRIANGLE(context, h, x, y, w, h, GP_,
DO_TRIANGLE_LEFT, DO_TETRAGON_LEFT, pixel);
break;
case GP_SYM_TRIANGLE_RIGHT:
- TRIANGLE(context, h, x, y, w, h, GP_T,
+ TRIANGLE(context, h, x, y, w, h, GP_,
DO_TRIANGLE_RIGHT, DO_TETRAGON_RIGHT, pixel);
break;
default:
@@ -152,28 +163,28 @@ void GP_TSymbol(GP_Context *context, GP_SymbolType sym,
}
}
-void GP_TFillSymbol(GP_Context *context, GP_SymbolType sym,
- GP_Coord x, GP_Coord y,
- GP_Size w, GP_Size h, GP_Pixel pixel)
+void GP_FillSymbol(GP_Context *context, GP_SymbolType sym,
+ GP_Coord x, GP_Coord y,
+ GP_Size w, GP_Size h, GP_Pixel pixel)
{
DO_DECREMENT(w);
DO_DECREMENT(h);
switch (sym) {
case GP_SYM_TRIANGLE_UP:
- TRIANGLE(context, w, x, y, w, h, GP_TFill,
+ TRIANGLE(context, w, x, y, w, h, GP_Fill,
DO_TRIANGLE_UP, DO_TETRAGON_UP, pixel);
break;
case GP_SYM_TRIANGLE_DOWN:
- TRIANGLE(context, w, x, y, w, h, GP_TFill,
+ TRIANGLE(context, w, x, y, w, h, GP_Fill,
DO_TRIANGLE_DOWN, DO_TETRAGON_DOWN, pixel);
break;
case GP_SYM_TRIANGLE_LEFT:
- TRIANGLE(context, h, x, y, w, h, GP_TFill,
+ TRIANGLE(context, h, x, y, w, h, GP_Fill,
DO_TRIANGLE_LEFT, DO_TETRAGON_LEFT, pixel);
break;
case GP_SYM_TRIANGLE_RIGHT:
- TRIANGLE(context, h, x, y, w, h, GP_TFill,
+ TRIANGLE(context, h, x, y, w, h, GP_Fill,
DO_TRIANGLE_RIGHT, DO_TETRAGON_RIGHT, pixel);
break;
default:
diff --git a/libs/gfx/GP_Tetragon.c b/libs/gfx/GP_Tetragon.c
index f5f924a..8e31801 100644
--- a/libs/gfx/GP_Tetragon.c
+++ b/libs/gfx/GP_Tetragon.c
@@ -16,30 +16,30 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
+ * Copyright (C) 2009-2011 Jiri "BlueBear" Dluhos *
* <jiri.bluebear.dluhos(a)gmail.com> *
* *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
#include "GP_Gfx.h"
-void GP_Tetragon(GP_Context *context, GP_Coord x0, GP_Coord y0,
- GP_Coord x1, GP_Coord y1, GP_Coord x2, GP_Coord y2,
- GP_Coord x3, GP_Coord y3, GP_Pixel pixel)
+void GP_Tetragon_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0,
+ GP_Coord x1, GP_Coord y1, GP_Coord x2, GP_Coord y2,
+ GP_Coord x3, GP_Coord y3, GP_Pixel pixel)
{
GP_CHECK_CONTEXT(context);
- GP_Line(context, x0, y0, x1, y1, pixel);
- GP_Line(context, x1, y1, x2, y2, pixel);
- GP_Line(context, x2, y2, x3, y3, pixel);
- GP_Line(context, x3, y3, x0, y0, pixel);
+ GP_Line_Raw(context, x0, y0, x1, y1, pixel);
+ GP_Line_Raw(context, x1, y1, x2, y2, pixel);
+ GP_Line_Raw(context, x2, y2, x3, y3, pixel);
+ GP_Line_Raw(context, x3, y3, x0, y0, pixel);
}
-void GP_TTetragon(GP_Context *context, GP_Coord x0, GP_Coord y0,
- GP_Coord x1, GP_Coord y1, GP_Coord x2, GP_Coord y2,
- GP_Coord x3, GP_Coord y3, GP_Pixel pixel)
+void GP_Tetragon(GP_Context *context, GP_Coord x0, GP_Coord y0,
+ GP_Coord x1, GP_Coord y1, GP_Coord x2, GP_Coord y2,
+ GP_Coord x3, GP_Coord y3, GP_Pixel pixel)
{
GP_CHECK_CONTEXT(context);
@@ -48,22 +48,21 @@ void GP_TTetragon(GP_Context *context, GP_Coord x0, GP_Coord y0,
GP_TRANSFORM_POINT(context, x2, y2);
GP_TRANSFORM_POINT(context, x3, y3);
- GP_Tetragon(context, x0, y0, x1, y1, x2, y2, x3, y3, pixel);
+ GP_Tetragon_Raw(context, x0, y0, x1, y1, x2, y2, x3, y3, pixel);
}
-void GP_FillTetragon(GP_Context *context, GP_Coord x0, GP_Coord y0,
- GP_Coord x1, GP_Coord y1, GP_Coord x2, GP_Coord y2,
- GP_Coord x3, GP_Coord y3, GP_Pixel pixel)
+void GP_FillTetragon_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0,
+ GP_Coord x1, GP_Coord y1, GP_Coord x2, GP_Coord y2,
+ GP_Coord x3, GP_Coord y3, GP_Pixel pixel)
{
- GP_CHECK_CONTEXT(context);
-
- const GP_Coord xy[8] = { x0, y0, x1, y1, x2, y2, x3, y3 };
- GP_FillPolygon(context, 4, xy, pixel);
+ const GP_Coord xy[8] = {x0, y0, x1, y1, x2, y2, x3, y3};
+
+ GP_FillPolygon_Raw(context, 4, xy, pixel);
}
-void GP_TFillTetragon(GP_Context* context, GP_Coord x0, GP_Coord y0,
- GP_Coord x1, GP_Coord y1, GP_Coord x2, GP_Coord y2,
- GP_Coord x3, GP_Coord y3, GP_Pixel pixel)
+void GP_FillTetragon(GP_Context* context, GP_Coord x0, GP_Coord y0,
+ GP_Coord x1, GP_Coord y1, GP_Coord x2, GP_Coord y2,
+ GP_Coord x3, GP_Coord y3, GP_Pixel pixel)
{
GP_CHECK_CONTEXT(context);
@@ -72,6 +71,7 @@ void GP_TFillTetragon(GP_Context* context, GP_Coord x0, GP_Coord y0,
GP_TRANSFORM_POINT(context, x2, y2);
GP_TRANSFORM_POINT(context, x3, y3);
- const GP_Coord xy[8] = { x0, y0, x1, y1, x2, y2, x3, y3 };
- GP_FillPolygon(context, 4, xy, pixel);
+ const GP_Coord xy[8] = {x0, y0, x1, y1, x2, y2, x3, y3};
+
+ GP_FillPolygon_Raw(context, 4, xy, pixel);
}
diff --git a/libs/gfx/GP_Triangle.c b/libs/gfx/GP_Triangle.c
index 10725ec..863c9b0 100644
--- a/libs/gfx/GP_Triangle.c
+++ b/libs/gfx/GP_Triangle.c
@@ -16,29 +16,27 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
+ * Copyright (C) 2009-2011 Jiri "BlueBear" Dluhos *
* <jiri.bluebear.dluhos(a)gmail.com> *
* *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
#include "GP_Gfx.h"
-void GP_Triangle(GP_Context *context, GP_Coord x0, GP_Coord y0,
- GP_Coord x1, GP_Coord y1,
- GP_Coord x2, GP_Coord y2, GP_Pixel pixel)
+void GP_Triangle_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0,
+ GP_Coord x1, GP_Coord y1,
+ GP_Coord x2, GP_Coord y2, GP_Pixel pixel)
{
- GP_CHECK_CONTEXT(context);
-
- GP_Line(context, x0, y0, x1, y1, pixel);
- GP_Line(context, x0, y0, x2, y2, pixel);
- GP_Line(context, x1, y1, x2, y2, pixel);
+ GP_Line_Raw(context, x0, y0, x1, y1, pixel);
+ GP_Line_Raw(context, x0, y0, x2, y2, pixel);
+ GP_Line_Raw(context, x1, y1, x2, y2, pixel);
}
-void GP_TTriangle(GP_Context *context, GP_Coord x0, GP_Coord y0,
- GP_Coord x1, GP_Coord y1,
- GP_Coord x2, GP_Coord y2, GP_Pixel pixel)
+void GP_Triangle(GP_Context *context, GP_Coord x0, GP_Coord y0,
+ GP_Coord x1, GP_Coord y1,
+ GP_Coord x2, GP_Coord y2, GP_Pixel pixel)
{
GP_CHECK_CONTEXT(context);
@@ -46,29 +44,27 @@ void GP_TTriangle(GP_Context *context, GP_Coord x0, GP_Coord y0,
GP_TRANSFORM_POINT(context, x1, y1);
GP_TRANSFORM_POINT(context, x2, y2);
- GP_Triangle(context, x0, y0, x1, y1, x2, y2, pixel);
+ GP_Triangle_Raw(context, x0, y0, x1, y1, x2, y2, pixel);
}
-void GP_FillTriangle(GP_Context *context, GP_Coord x0, GP_Coord y0,
- GP_Coord x1, GP_Coord y1,
- GP_Coord x2, GP_Coord y2, GP_Pixel pixel)
+void GP_FillTriangle_Raw(GP_Context *context, GP_Coord x0, GP_Coord y0,
+ GP_Coord x1, GP_Coord y1,
+ GP_Coord x2, GP_Coord y2, GP_Pixel pixel)
{
- GP_CHECK_CONTEXT(context);
+ const GP_Coord coords[6] = {x0, y0, x1, y1, x2, y2};
- const GP_Coord coords[6] = { x0, y0, x1, y1, x2, y2 };
- GP_FillPolygon(context, 3, coords, pixel);
+ GP_FillPolygon_Raw(context, 3, coords, pixel);
}
-void GP_TFillTriangle(GP_Context* context, GP_Coord x0, GP_Coord y0,
- GP_Coord x1, GP_Coord y1,
- GP_Coord x2, GP_Coord y2, GP_Pixel pixel)
+void GP_FillTriangle(GP_Context* context, GP_Coord x0, GP_Coord y0,
+ GP_Coord x1, GP_Coord y1,
+ GP_Coord x2, GP_Coord y2, GP_Pixel pixel)
{
GP_CHECK_CONTEXT(context);
-
+
GP_TRANSFORM_POINT(context, x0, y0);
GP_TRANSFORM_POINT(context, x1, y1);
GP_TRANSFORM_POINT(context, x2, y2);
-
- const GP_Coord coords[6] = { x0, y0, x1, y1, x2, y2 };
- GP_FillPolygon(context, 3, coords, pixel);
+
+ GP_FillTriangle_Raw(context, x0, y0, x1, y1, x2, y2, pixel);
}
diff --git a/libs/gfx/GP_VLine.c b/libs/gfx/GP_VLine.c
index 91d26da..4fdb319 100644
--- a/libs/gfx/GP_VLine.c
+++ b/libs/gfx/GP_VLine.c
@@ -16,10 +16,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
+ * Copyright (C) 2009-2011 Jiri "BlueBear" Dluhos *
* <jiri.bluebear.dluhos(a)gmail.com> *
* *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
@@ -32,16 +32,16 @@
/* Generate drawing functions for various bit depths. */
GP_DEF_DRAW_FN_PER_BPP(GP_VLine, DEF_VLINE_FN)
-void GP_VLineXYY(GP_Context *context, GP_Coord x, GP_Coord y0,
- GP_Coord y1, GP_Pixel pixel)
+void GP_VLineXYY_Raw(GP_Context *context, GP_Coord x, GP_Coord y0,
+ GP_Coord y1, GP_Pixel pixel)
{
GP_CHECK_CONTEXT(context);
GP_FN_PER_BPP_CONTEXT(GP_VLine, context, context, x, y0, y1, pixel);
}
-void GP_VLineXYH(GP_Context *context, GP_Coord x, GP_Coord y,
- GP_Size height, GP_Pixel pixel)
+void GP_VLineXYH_Raw(GP_Context *context, GP_Coord x, GP_Coord y,
+ GP_Size height, GP_Pixel pixel)
{
/* zero height: do not draw anything */
if (height == 0)
@@ -50,7 +50,7 @@ void GP_VLineXYH(GP_Context *context, GP_Coord x, GP_Coord y,
GP_VLineXYY(context, x, y, y + height - 1, pixel);
}
-void GP_TVLineXYY(GP_Context *context, GP_Coord x, GP_Coord y0,
+void GP_VLineXYY(GP_Context *context, GP_Coord x, GP_Coord y0,
GP_Coord y1, GP_Pixel pixel)
{
GP_CHECK_CONTEXT(context);
@@ -59,21 +59,21 @@ void GP_TVLineXYY(GP_Context *context, GP_Coord x, GP_Coord y0,
GP_TRANSFORM_Y(context, x);
GP_TRANSFORM_X(context, y0);
GP_TRANSFORM_X(context, y1);
- GP_HLine(context, y0, y1, x, pixel);
+ GP_HLine_Raw(context, y0, y1, x, pixel);
} else {
GP_TRANSFORM_X(context, x);
GP_TRANSFORM_Y(context, y0);
GP_TRANSFORM_Y(context, y1);
- GP_VLine(context, x, y0, y1, pixel);
+ GP_VLine_Raw(context, x, y0, y1, pixel);
}
}
-void GP_TVLineXYH(GP_Context *context, GP_Coord x, GP_Coord y,
+void GP_VLineXYH(GP_Context *context, GP_Coord x, GP_Coord y,
GP_Size height, GP_Pixel pixel)
{
/* zero height: do not draw anything */
if (height == 0)
return;
- GP_TVLineXYY(context, x, y, y + height - 1, pixel);
+ GP_VLineXYY(context, x, y, y + height - 1, pixel);
}
diff --git a/libs/text/GP_Text.c b/libs/text/GP_Text.c
index 4ffae23..43bf6ed 100644
--- a/libs/text/GP_Text.c
+++ b/libs/text/GP_Text.c
@@ -16,7 +16,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
- * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
+ * Copyright (C) 2009-2011 Jiri "BlueBear" Dluhos *
* <jiri.bluebear.dluhos(a)gmail.com> *
* *
* Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
@@ -32,12 +32,11 @@
static GP_TextStyle DefaultStyle = GP_DEFAULT_TEXT_STYLE;
/* Generate drawing functions for various bit depths. */
-GP_DEF_FILL_FN_PER_BPP(GP_Text, DEF_TEXT_FN)
+GP_DEF_FILL_FN_PER_BPP(GP_Text_Raw, DEF_TEXT_FN)
-DEF_TEXT_FN(GP_TText_internal, GP_Context *, GP_Pixel, GP_THLine)
-
-GP_RetCode GP_Text(GP_Context *context, const GP_TextStyle *style,
- int x, int y, int align, const char *str, GP_Pixel pixel)
+GP_RetCode GP_Text_Raw(GP_Context *context, const GP_TextStyle *style,
+ GP_Coord x, GP_Coord y, int align,
+ const char *str, GP_Pixel pixel)
{
GP_CHECK_CONTEXT(context);
GP_CHECK_TEXT_STYLE(style);
@@ -45,7 +44,6 @@ GP_RetCode GP_Text(GP_Context *context, const GP_TextStyle *style,
if (str == NULL)
return GP_ENULLPTR;
-
if (style == NULL)
style = &DefaultStyle;
@@ -83,14 +81,17 @@ GP_RetCode GP_Text(GP_Context *context, const GP_TextStyle *style,
return GP_EINVAL;
}
- GP_FN_PER_BPP_CONTEXT(GP_Text, context, context,
- style, topleft_x, topleft_y, str, pixel);
+ GP_FN_PER_BPP_CONTEXT(GP_Text_Raw, context, context, style,
+ topleft_x, topleft_y, str, pixel);
return GP_ESUCCESS;
}
-GP_RetCode GP_TText(GP_Context *context, const GP_TextStyle *style,
- int x, int y, int align, const char *str, GP_Pixel pixel)
+DEF_TEXT_FN(GP_Text_internal, GP_Context *, GP_Pixel, GP_HLine)
+
+GP_RetCode GP_Text(GP_Context *context, const GP_TextStyle *style,
+ GP_Coord x, GP_Coord y, int align,
+ const char *str, GP_Pixel pixel)
{
GP_CHECK_CONTEXT(context);
GP_CHECK_TEXT_STYLE(style);
@@ -135,12 +136,13 @@ GP_RetCode GP_TText(GP_Context *context, const GP_TextStyle *style,
return GP_EINVAL;
}
- GP_TText_internal(context, style, topleft_x, topleft_y, str, pixel);
+ GP_Text_internal(context, style, topleft_x, topleft_y, str, pixel);
return GP_ESUCCESS;
}
-GP_RetCode GP_BoxCenteredText(GP_Context *context, const GP_TextStyle *style,
- int x, int y, int w, int h, const char *str, GP_Pixel pixel)
+GP_RetCode GP_BoxCenteredText_Raw(GP_Context *context, const GP_TextStyle *style,
+ GP_Coord x, GP_Coord y, GP_Size w, GP_Size h,
+ const char *str, GP_Pixel pixel)
{
GP_CHECK_CONTEXT(context);
GP_CHECK_TEXT_STYLE(style);
@@ -155,14 +157,15 @@ GP_RetCode GP_BoxCenteredText(GP_Context *context, const GP_TextStyle *style,
const int mid_y = y + h/2;
const int font_ascent = GP_TextAscent(style);
- return GP_Text(context, style, mid_x,
+ return GP_Text_Raw(context, style, mid_x,
mid_y + font_ascent/2,
GP_ALIGN_CENTER | GP_VALIGN_BASELINE,
str, pixel);
}
-GP_RetCode GP_TBoxCenteredText(GP_Context *context, const GP_TextStyle *style,
- int x, int y, int w, int h, const char *str, GP_Pixel pixel)
+GP_RetCode GP_BoxCenteredText(GP_Context *context, const GP_TextStyle *style,
+ GP_Coord x, GP_Coord y, GP_Size w, GP_Size h,
+ const char *str, GP_Pixel pixel)
{
GP_CHECK_CONTEXT(context);
GP_CHECK_TEXT_STYLE(style);
@@ -177,7 +180,7 @@ GP_RetCode GP_TBoxCenteredText(GP_Context *context, const GP_TextStyle *style,
const int mid_y = y + h/2;
const int font_ascent = GP_TextAscent(style);
- return GP_TText(context, style, mid_x,
+ return GP_Text(context, style, mid_x,
mid_y + font_ascent/2,
GP_ALIGN_CENTER | GP_VALIGN_BASELINE,
str, pixel);
diff --git a/tests/SDL/fileview.c b/tests/SDL/fileview.c
index 4bbe940..d4ceeda 100644
--- a/tests/SDL/fileview.c
+++ b/tests/SDL/fileview.c
@@ -180,12 +180,13 @@ void event_loop(void)
static int read_file_head(const char *filename)
{
FILE *f = fopen(filename, "r");
+ char buf[512];
+
if (f == NULL) {
fprintf(stderr, "Could not open file: %sn", filename);
return 0;
}
- char buf[512];
for (;;) {
if (fgets(buf, 511, f) == NULL)
diff --git a/tests/SDL/pixeltest.c b/tests/SDL/pixeltest.c
index 467a17b..7102074 100644
--- a/tests/SDL/pixeltest.c
+++ b/tests/SDL/pixeltest.c
@@ -89,9 +89,8 @@ void draw_pixels(void)
/* Draw some pixels (exact number is not important). */
int i;
- for (i = 0; i < 30; i++) {
+ for (i = 0; i < 30; i++)
draw_pixel();
- }
SDL_UnlockSurface(display);
}
@@ -101,15 +100,14 @@ void event_loop(void)
SDL_Event event;
while (SDL_WaitEvent(&event) > 0) {
-
switch (event.type) {
- case SDL_USEREVENT:
- draw_pixels();
- SDL_Flip(display);
- break;
- case SDL_KEYDOWN:
- case SDL_QUIT:
- return;
+ case SDL_USEREVENT:
+ draw_pixels();
+ SDL_Flip(display);
+ break;
+ case SDL_KEYDOWN:
+ case SDL_QUIT:
+ return;
}
}
}
@@ -122,8 +120,7 @@ int main(int argc, char **argv)
for (i = 1; i < argc; i++) {
if (strcmp(argv[i], "-16") == 0) {
display_bpp = 16;
- }
- else if (strcmp(argv[i], "-24") == 0) {
+ } else if (strcmp(argv[i], "-24") == 0) {
display_bpp = 24;
}
}
diff --git a/tests/SDL/shapetest.c b/tests/SDL/shapetest.c
index 1f6e44a..57cca2d 100644
--- a/tests/SDL/shapetest.c
+++ b/tests/SDL/shapetest.c
@@ -49,7 +49,7 @@ Uint32 timer_callback(__attribute__((unused)) Uint32 interval,
}
/* Basic colors in display-specific format. */
-GP_Pixel black, white, yellow, green, red, gray, darkgray;
+static GP_Pixel black, white, yellow, green, red, gray, darkgray;
/* Radius of the shape being drawn */
static int xradius = 5;
@@ -71,7 +71,8 @@ static int show_axes = 1;
#define SHAPE_RING 3
#define SHAPE_ELLIPSE 4
#define SHAPE_RECTANGLE 5
-#define SHAPE_LAST 5
+#define SHAPE_TETRAGON 6
+#define SHAPE_LAST 6
static int shape = SHAPE_FIRST;
/* Variants in coordinates, if applicable */
@@ -81,12 +82,15 @@ static int variant = 1;
static int xradius_add = 0;
static int yradius_add = 0;
-/* center of drawing */
-static int center_x = 320;
-static int center_y = 240;
+#define DISPLAY_W 640
+#define DISPLAY_H 480
+
+static int display_w = DISPLAY_W;
+static int display_h = DISPLAY_H;
-static int display_w = 640;
-static int display_h = 480;
+/* center of drawing */
+static int center_x = DISPLAY_W/2;
+static int center_y = DISPLAY_H/2;
void draw_testing_triangle(int x, int y, int xradius, int yradius)
{
@@ -130,68 +134,88 @@ void draw_testing_triangle(int x, int y, int xradius, int yradius)
/* draw the three vertices green; they should never be visible
* because the red triangle should cover them; if they are visible,
* it means we don't draw to the end */
- GP_TPutPixel(&context, x0, y0, green);
- GP_TPutPixel(&context, x1, y1, green);
- GP_TPutPixel(&context, x2, y2, green);
+ GP_PutPixel(&context, x0, y0, green);
+ GP_PutPixel(&context, x1, y1, green);
+ GP_PutPixel(&context, x2, y2, green);
if (outline == 1)
- GP_TTriangle(&context, x0, y0, x1, y1, x2, y2, yellow);
+ GP_Triangle(&context, x0, y0, x1, y1, x2, y2, yellow);
if (fill)
- GP_TFillTriangle(&context, x0, y0, x1, y1, x2, y2, red);
+ GP_FillTriangle(&context, x0, y0, x1, y1, x2, y2, red);
if (outline == 2)
- GP_TTriangle(&context, x0, y0, x1, y1, x2, y2, white);
+ GP_Triangle(&context, x0, y0, x1, y1, x2, y2, white);
}
void draw_testing_circle(int x, int y, int xradius,
__attribute__((unused)) int yradius)
{
if (outline == 1)
- GP_TCircle(&context, x, y, xradius, yellow);
+ GP_Circle(&context, x, y, xradius, yellow);
if (fill)
- GP_TFillCircle(&context, x, y, xradius, red);
+ GP_FillCircle(&context, x, y, xradius, red);
if (outline == 2)
- GP_TCircle(&context, x, y, xradius, white);
+ GP_Circle(&context, x, y, xradius, white);
}
void draw_testing_ring(int x, int y, int xradius,
__attribute__((unused)) int yradius)
{
if (outline == 1)
- GP_TCircle(&context, x, y, xradius, yellow);
+ GP_Ring(&context, x, y, xradius, yradius, yellow);
if (fill)
- GP_TFillRing(&context, x, y, xradius, yradius, red);
+ GP_FillRing(&context, x, y, xradius, yradius, red);
if (outline == 2)
- GP_TCircle(&context, x, y, xradius, white);
+ GP_Ring(&context, x, y, xradius, yradius, white);
}
void draw_testing_ellipse(int x, int y, int xradius, int yradius)
{
if (outline == 1)
- GP_TEllipse(&context, x, y, xradius, yradius, yellow);
+ GP_Ellipse(&context, x, y, xradius, yradius, yellow);
if (fill)
- GP_TFillEllipse(&context, x, y, xradius, yradius, red);
+ GP_FillEllipse(&context, x, y, xradius, yradius, red);
if (outline == 2)
- GP_TEllipse(&context, x, y, xradius, yradius, white);
+ GP_Ellipse(&context, x, y, xradius, yradius, white);
}
void draw_testing_rectangle(int x, int y, int xradius, int yradius)
{
+ int x0 = x - xradius, y0 = y - yradius;
+ int x1 = x + xradius, y1 = y + yradius;
+
if (outline == 1)
- GP_TRect(&context, x - xradius, y - yradius, x + xradius, y + yradius, yellow);
+ GP_Rect(&context, x0, y0, x1, y1, yellow);
+
+ if (fill)
+ GP_FillRect(&context, x0, y0, x1, y1, red);
+
+ if (outline == 2)
+ GP_Rect(&context, x0, y0, x1, y1, white);
+}
+void draw_testing_tetragon(int x, int y, int xradius, int yradius)
+{
+ int x0 = x - xradius, y0 = y - yradius;
+ int x1 = x + xradius, y1 = y;
+ int x2 = x + xradius, y2 = y + yradius/2;
+ int x3 = x, y3 = y + yradius;
+
+ if (outline == 1)
+ GP_Tetragon(&context, x0, y0, x1, y1, x2, y2, x3, y3, yellow);
+
if (fill)
- GP_TFillRect(&context, x - xradius, y - yradius, x + xradius, y + yradius, red);
+ GP_FillTetragon(&context, x0, y0, x1, y1, x2, y2, x3, y3, red);
if (outline == 2)
- GP_TRect(&context, x - xradius, y - yradius, x + xradius, y + yradius, white);
+ GP_Tetragon(&context, x0, y0, x1, y1, x2, y2, x3, y3, white);
}
void redraw_screen(void)
@@ -211,12 +235,12 @@ void redraw_screen(void)
/* axes */
if (show_axes) {
- GP_THLine(&context, 0, display_w, center_y, gray);
- GP_THLine(&context, 0, display_w, center_y-yradius, darkgray);
- GP_THLine(&context, 0, display_w, center_y+yradius, darkgray);
- GP_TVLine(&context, center_x, 0, display_h, gray);
- GP_TVLine(&context, center_x-xradius, 0, display_h, darkgray);
- GP_TVLine(&context, center_x+xradius, 0, display_h, darkgray);
+ GP_HLine(&context, 0, display_w, center_y, gray);
+ GP_HLine(&context, 0, display_w, center_y-yradius, darkgray);
+ GP_HLine(&context, 0, display_w, center_y+yradius, darkgray);
+ GP_VLine(&context, center_x, 0, display_h, gray);
+ GP_VLine(&context, center_x-xradius, 0, display_h, darkgray);
+ GP_VLine(&context, center_x+xradius, 0, display_h, darkgray);
}
/* the shape */
@@ -242,8 +266,14 @@ void redraw_screen(void)
draw_testing_rectangle(center_x, center_y, xradius, yradius);
title = "RECTANGLE";
break;
+ case SHAPE_TETRAGON:
+ draw_testing_tetragon(center_x, center_y, xradius, yradius);
+ title = "TETRAGON";
+ break;
}
- GP_TText(&context, &style, 16, 16, GP_ALIGN_RIGHT|GP_VALIGN_BELOW, title, white);
+
+ GP_Text(&context, &style, 16, 16, GP_ALIGN_RIGHT|GP_VALIGN_BELOW,
+ title, white);
SDL_UnlockSurface(display);
}
@@ -260,16 +290,20 @@ void event_loop(void)
switch (event.type) {
case SDL_USEREVENT:
- if (xradius + xradius_add > 1 && xradius + xradius_add < 400)
+ if (xradius + xradius_add > 1 &&
+ xradius + xradius_add < display_w)
xradius += xradius_add;
- if (yradius + yradius_add > 1 && yradius + yradius_add < 400)
+ if (yradius + yradius_add > 1 &&
+ yradius + yradius_add < display_h)
yradius += yradius_add;
- if (center_x + xcenter_add > 1 && center_x + xcenter_add < 320)
+ if (center_x + xcenter_add > 1 &&
+ center_x + xcenter_add < display_w/2)
center_x += xcenter_add;
- if (center_y + ycenter_add > 1 && center_y + ycenter_add < 240)
+ if (center_y + ycenter_add > 1 &&
+ center_y + ycenter_add < display_h/2)
center_y += ycenter_add;
redraw_screen();
@@ -290,14 +324,7 @@ void event_loop(void)
break;
case SDLK_r:
context.axes_swap = !context.axes_swap;
-
- if (context.axes_swap) {
- display_w = 480;
- display_h = 640;
- } else {
- display_w = 640;
- display_h = 480;
- }
+ GP_SWAP(display_w, display_h);
break;
case SDLK_f:
fill = !fill;
@@ -453,8 +480,7 @@ int main(int argc, char ** argv)
for (i = 1; i < argc; i++) {
if (strcmp(argv[i], "-16") == 0) {
display_bpp = 16;
- }
- else if (strcmp(argv[i], "-24") == 0) {
+ } else if (strcmp(argv[i], "-24") == 0) {
display_bpp = 24;
}
}
@@ -466,14 +492,14 @@ int main(int argc, char ** argv)
}
/* Create a window with a software back surface */
- display = SDL_SetVideoMode(640, 480, display_bpp, SDL_SWSURFACE);
+ display = SDL_SetVideoMode(display_w, display_h, display_bpp, SDL_SWSURFACE);
if (display == NULL) {
fprintf(stderr, "Could not open display: %sn", SDL_GetError());
goto fail;
}
/* Set up a clipping rectangle to exercise clipping */
- SDL_Rect clip_rect = {10, 10, 620, 460};
+ SDL_Rect clip_rect = {10, 10, display_w - 10, display_h - 10};
SDL_SetClipRect(display, &clip_rect);
GP_SDL_ContextFromSurface(&context, display);
@@ -494,13 +520,9 @@ int main(int argc, char ** argv)
goto fail;
}
- /* Print a short info how to use this test. */
print_instructions();
- /* Enter the event loop */
event_loop();
-
- /* We're done */
SDL_Quit();
return 0;
diff --git a/tests/SDL/textaligntest.c b/tests/SDL/textaligntest.c
index 66f97ed..0ecad33 100644
--- a/tests/SDL/textaligntest.c
+++ b/tests/SDL/textaligntest.c
@@ -42,8 +42,8 @@ static GP_Pixel black_pixel, red_pixel, yellow_pixel, green_pixel, blue_pixel,
static int flag_proportional = 0;
/* center of the screen */
-static int xcenter = 320;
-static int ycenter = 240;
+static int X = 640;
+static int Y = 480;
void redraw_screen(void)
{
@@ -52,8 +52,8 @@ void redraw_screen(void)
GP_Fill(&context, black_pixel);
/* draw axes intersecting in the middle, where text should be shown */
- GP_HLine(&context, 0, 640, 240, darkgray_pixel);
- GP_VLine(&context, 320, 0, 480, darkgray_pixel);
+ GP_HLine(&context, 0, X, Y/2, darkgray_pixel);
+ GP_VLine(&context, X/2, 0, Y, darkgray_pixel);
GP_TextStyle style = GP_DEFAULT_TEXT_STYLE;
@@ -65,20 +65,20 @@ void redraw_screen(void)
style.pixel_xspace = 4;
style.pixel_yspace = 4;
- GP_TBoxCenteredText(&context, &style, 0, 0, 640, 480,
- "Hello world!", darkgray_pixel);
+ GP_BoxCenteredText(&context, &style, 0, 0, X, Y,
+ "Hello world!", darkgray_pixel);
style.pixel_xspace = 0;
style.pixel_yspace = 0;
- GP_TText(&context, &style, xcenter, ycenter, GP_ALIGN_LEFT|GP_VALIGN_BELOW,
- "bottom left", yellow_pixel);
- GP_TText(&context, &style, xcenter, ycenter, GP_ALIGN_RIGHT|GP_VALIGN_BELOW,
- "bottom right", red_pixel);
- GP_TText(&context, &style, xcenter, ycenter, GP_ALIGN_RIGHT|GP_VALIGN_ABOVE,
- "top right", blue_pixel);
- GP_TText(&context, &style, xcenter, ycenter, GP_ALIGN_LEFT|GP_VALIGN_ABOVE,
- "top left", green_pixel);
+ GP_Text(&context, &style, X/2, Y/2, GP_ALIGN_LEFT|GP_VALIGN_BELOW,
+ "bottom left", yellow_pixel);
+ GP_Text(&context, &style, X/2, Y/2, GP_ALIGN_RIGHT|GP_VALIGN_BELOW,
+ "bottom right", red_pixel);
+ GP_Text(&context, &style, X/2, Y/2, GP_ALIGN_RIGHT|GP_VALIGN_ABOVE,
+ "top right", blue_pixel);
+ GP_Text(&context, &style, X/2, Y/2, GP_ALIGN_LEFT|GP_VALIGN_ABOVE,
+ "top left", green_pixel);
SDL_UnlockSurface(display);
}
@@ -108,7 +108,7 @@ void event_loop(void)
break;
case SDLK_r:
context.axes_swap = !context.axes_swap;
- GP_SWAP(xcenter, ycenter);
+ GP_SWAP(X, Y);
break;
default:
break;
@@ -143,7 +143,7 @@ int main(void)
}
/* Create a window with a software back surface */
- display = SDL_SetVideoMode(640, 480, 0, SDL_SWSURFACE);
+ display = SDL_SetVideoMode(X, Y, 0, SDL_SWSURFACE);
if (display == NULL) {
fprintf(stderr, "Could not open display: %sn", SDL_GetError());
goto fail;
@@ -152,7 +152,7 @@ int main(void)
print_instructions();
/* Set up a clipping rectangle to test proper clipping of pixels */
- SDL_Rect clip_rect = {10, 10, 620, 460};
+ SDL_Rect clip_rect = {10, 10, X-10, Y-10};
SDL_SetClipRect(display, &clip_rect);
/* Initialize a GP context from the SDL display */
http://repo.or.cz/w/gfxprim.git/commit/a6b989fc9c386a6e7422277784cd13140af7…
commit a6b989fc9c386a6e7422277784cd13140af7e286
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Jul 24 14:51:09 2011 +0200
Fix some overly long lines.
diff --git a/include/core/GP_Common.h b/include/core/GP_Common.h
index 3bae989..39b9ea9 100644
--- a/include/core/GP_Common.h
+++ b/include/core/GP_Common.h
@@ -65,31 +65,31 @@
/*
* Internal macros with common code for GP_ABORT, GP_ASSERT and GP_CHECK.
* GP_INTERNAL_ABORT takes a message that may contain % (e.g. assert condition)
- * and prints:
- * "*** gfxprim: __FILE__:__LINE__: in __FUNCTION__: str_abort_msg_" format(__VA_ARGS__) "n"
- *
- * GP_GENERAL_CHECK is a check with specified message prefix (for assert and check)
+ * and prints message and calls abort().
+ * GP_GENERAL_CHECK is a check with specified message prefix
+ * (for assert and check)
*/
#define GP_INTERNAL_ABORT(str_abort_msg_, ...) do { - fprintf(stderr, "*** gfxprim: %s:%d: in %s: %s", - __FILE__, __LINE__, __FUNCTION__, str_abort_msg_); - if (! (#__VA_ARGS__ [0])) - fprintf(stderr, "abort()"); - else - fprintf(stderr, " " __VA_ARGS__); - fprintf(stderr, "n"); - abort(); - } while (0)
+ fprintf(stderr, "*** gfxprim: %s:%d: in %s: %s", + __FILE__, __LINE__, __FUNCTION__, str_abort_msg_); + if (! (#__VA_ARGS__ [0])) + fprintf(stderr, "abort()"); + else + fprintf(stderr, " " __VA_ARGS__); + fprintf(stderr, "n"); + abort(); +} while (0)
#define GP_GENERAL_CHECK(check_cond_, check_message_, ...) do { - if (unlikely(!(check_cond_))) { - if (#__VA_ARGS__ [0]) - GP_INTERNAL_ABORT(check_message_ #check_cond_, "n" __VA_ARGS__); - else - GP_INTERNAL_ABORT(check_message_ #check_cond_, " "); - } - } while (0)
+ if (unlikely(!(check_cond_))) { + if (#__VA_ARGS__ [0]) + GP_INTERNAL_ABORT(check_message_ #check_cond_, + "n" __VA_ARGS__); + else + GP_INTERNAL_ABORT(check_message_ #check_cond_, " "); + } +} while (0)
/*
* Aborts and prints the message along with the location in code
@@ -138,12 +138,14 @@
* Return (shifted) count bits at offset of value
* Note: operates with value types same as val
*/
-#define GP_GET_BITS(offset, count, val) ( ( (val)>>(offset) ) & ( ((((typeof(val))1)<<(count)) - 1) ) )
+#define GP_GET_BITS(offset, count, val) + ( ( (val)>>(offset) ) & ( ((((typeof(val))1)<<(count)) - 1) ) )
/*
* Debugging version, evaluates args twice.
*/
-#define GP_GET_BITS_DBG(offset, count, val) ( printf("GET_BITS(%d, %d, 0x%x)=%d", offset, count, val, +#define GP_GET_BITS_DBG(offset, count, val) + ( printf("GET_BITS(%d, %d, 0x%x)=%d", offset, count, val, GP_GET_BITS(offset, count, val)), GP_GET_BITS(offset, count, val))
/*
@@ -157,7 +159,8 @@
* GP_CLEAR_BITS sets the target bits to zero
* GP_SET_BITS does both
*/
-#define GP_CLEAR_BITS(offset, count, dest) ( (dest) &= ~(((((typeof(dest))1) << (count)) - 1) << (offset)) )
+#define GP_CLEAR_BITS(offset, count, dest) + ( (dest) &= ~(((((typeof(dest))1) << (count)) - 1) << (offset)) )
#define GP_SET_BITS_OR(offset, dest, val) ( (dest) |= ((val)<<(offset)) )
@@ -170,8 +173,8 @@
* Debugging version, evaluates args twice.
*/
#define GP_SET_BITS_DBG(offset, count, dest, val) do { - GP_SET_BITS(offset, count, dest, val); - printf("SET_BITS(%d, %d, p, %d)n", offset, count, val); + GP_SET_BITS(offset, count, dest, val); + printf("SET_BITS(%d, %d, p, %d)n", offset, count, val); } while (0)
diff --git a/include/core/GP_Context.h b/include/core/GP_Context.h
index 35b8ae7..2e640da 100644
--- a/include/core/GP_Context.h
+++ b/include/core/GP_Context.h
@@ -78,21 +78,17 @@ static inline GP_PixelType GP_GetContextPixelType(const GP_Context *context)
/* Performs a series of sanity checks on context, aborting if any fails. */
#define GP_CHECK_CONTEXT(context) do { - GP_CHECK(context, - "NULL passed as context"); - GP_CHECK(context->pixels, - "invalid context: NULL image pointer"); - GP_CHECK(context->bpp <= 32, - "invalid context: unsupported bits-per-pixel count"); - GP_CHECK(context->w > 0 && context->h > 0, - "invalid context: invalid image size"); - GP_CHECK(context->clip_w_min <= context->clip_w_max - && context->clip_h_min <= context->clip_h_max, - "invalid context: invalid clipping rectangle"); - GP_CHECK(context->clip_w_max < context->w - && context->clip_h_max < context->h, - "invalid context: clipping rectangle larger than image"); - } while (0)
+ GP_CHECK(context, "NULL passed as context"); + GP_CHECK(context->pixels, "invalid context: NULL image pointer"); + GP_CHECK(context->bpp <= 32, "invalid context: unsupported bits-per-pixel count"); + GP_CHECK(context->w > 0 && context->h > 0, "invalid context: invalid image size"); + GP_CHECK(context->clip_w_min <= context->clip_w_max + && context->clip_h_min <= context->clip_h_max, + "invalid context: invalid clipping rectangle"); + GP_CHECK(context->clip_w_max < context->w + && context->clip_h_max < context->h, + "invalid context: clipping rectangle larger than image"); +} while (0)
/*
* Is true, when pixel is clipped.
diff --git a/include/core/GP_Convert.h b/include/core/GP_Convert.h
index 6dd9d61..d33d417 100644
--- a/include/core/GP_Convert.h
+++ b/include/core/GP_Convert.h
@@ -58,7 +58,8 @@ GP_Pixel GP_PixelToRGBA8888(GP_Pixel pixel, GP_PixelType type);
/*
* Converts a color specified by its R, G, B components to a specified type.
*/
-static inline GP_Pixel GP_RGBToPixel(uint8_t r, uint8_t g, uint8_t b, GP_PixelType type)
+static inline GP_Pixel GP_RGBToPixel(uint8_t r, uint8_t g, uint8_t b,
+ GP_PixelType type)
{
GP_Pixel p = GP_Pixel_CREATE_RGB888(r, g, b);
return GP_RGB888ToPixel(p, type);
@@ -67,7 +68,8 @@ static inline GP_Pixel GP_RGBToPixel(uint8_t r, uint8_t g, uint8_t b, GP_PixelTy
/*
* Converts a color specified by its R, G, B, A components to a specified type.
*/
-static inline GP_Pixel GP_RGBAToPixel(uint8_t r, uint8_t g, uint8_t b, uint8_t a, GP_PixelType type)
+static inline GP_Pixel GP_RGBAToPixel(uint8_t r, uint8_t g, uint8_t b,
+ uint8_t a, GP_PixelType type)
{
GP_Pixel p = GP_Pixel_CREATE_RGBA8888(r, g, b, a);
return GP_RGBA8888ToPixel(p, type);
@@ -87,7 +89,9 @@ static inline GP_Pixel GP_RGBToContextPixel(uint8_t r, uint8_t g, uint8_t b,
* Converts a color specified by its R, G, B, A components to a pixel value
* compatible with the specified context.
*/
-static inline GP_Pixel GP_RGBAToContextPixel(uint8_t r, uint8_t g, uint8_t b, uint8_t a, const GP_Context *context)
+static inline GP_Pixel GP_RGBAToContextPixel(uint8_t r, uint8_t g,
+ uint8_t b, uint8_t a,
+ const GP_Context *context)
{
return GP_RGBAToPixel(r, g, b, a, context->pixel_type);
}
@@ -95,18 +99,22 @@ static inline GP_Pixel GP_RGBAToContextPixel(uint8_t r, uint8_t g, uint8_t b, ui
/*
* Convert between any pixel types (excl. palette types) via RGBA8888
*/
-static inline GP_Pixel GP_ConvertPixel(GP_Pixel pixel, GP_PixelType from, GP_PixelType to)
+static inline GP_Pixel GP_ConvertPixel(GP_Pixel pixel, GP_PixelType from,
+ GP_PixelType to)
{
return GP_RGBA8888ToPixel(GP_PixelToRGBA8888(pixel, from), to);
}
/*
- * Convert between pixel types of given contexts (excl. palette types) via RGBA8888.
- *
+ * Convert between pixel types of given contexts (excl. palette types) via
+ * RGBA8888.
*/
-static inline GP_Pixel GP_ConvertContextPixel(GP_Pixel pixel, const GP_Context *from, const GP_Context *to)
+static inline GP_Pixel GP_ConvertContextPixel(GP_Pixel pixel,
+ const GP_Context *from,
+ const GP_Context *to)
{
- return GP_RGBA8888ToPixel(GP_PixelToRGBA8888(from->pixel_type, pixel), to->pixel_type);
+ return GP_RGBA8888ToPixel(GP_PixelToRGBA8888(from->pixel_type, pixel),
+ to->pixel_type);
}
#endif /* CORE_GP_CONVERT_H */
-----------------------------------------------------------------------
Summary of changes:
include/core/GP_Common.h | 53 +++++++++--------
include/core/GP_Context.h | 26 ++++-----
include/core/GP_Convert.h | 24 +++++---
include/core/GP_DefFnPerBpp.h | 2 +-
include/gfx/GP_Circle.h | 32 ++++++++---
include/gfx/GP_Ellipse.h | 17 +++--
include/gfx/GP_Fill.h | 11 ++-
include/gfx/GP_HLine.h | 74 +++++++++++++-----------
include/gfx/GP_Line.h | 22 ++------
include/gfx/GP_Polygon.h | 8 +-
include/gfx/GP_Rect.h | 56 +++++++++++++-----
include/gfx/GP_Symbol.h | 22 ++++---
include/gfx/GP_Tetragon.h | 22 ++++---
include/gfx/GP_Triangle.h | 22 ++++---
include/gfx/GP_VLine.h | 27 ++++++---
include/text/GP_Text.h | 24 ++++----
libs/gfx/GP_Circle.c | 63 +++++++++++++--------
libs/gfx/GP_Ellipse.c | 34 ++++++------
libs/gfx/GP_Fill.c | 38 ------------
libs/gfx/GP_HLine.c | 51 +++++++++--------
libs/gfx/GP_Line.c | 15 +++--
libs/gfx/GP_Polygon.c | 12 ++--
libs/gfx/GP_Rect.c | 68 ++++++++++------------
libs/gfx/GP_Symbol.c | 77 ++++++++++++++-----------
libs/gfx/GP_Tetragon.c | 50 ++++++++--------
libs/gfx/GP_Triangle.c | 50 ++++++++---------
libs/gfx/GP_VLine.c | 22 ++++----
libs/text/GP_Text.c | 39 +++++++------
tests/SDL/fileview.c | 3 +-
tests/SDL/pixeltest.c | 21 +++----
tests/SDL/shapetest.c | 126 ++++++++++++++++++++++++-----------------
tests/SDL/textaligntest.c | 34 ++++++------
32 files changed, 609 insertions(+), 536 deletions(-)
delete mode 100644 libs/gfx/GP_Fill.c
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
Hi!
As you may see I've fixed the generate branch to compile (that is good).
But still there are some problems that arised and needs to be fixed:
* The GP_SET_BITS() used in GP_PutPixel_Raw doesn't work correctly
unless you explicitly cast the result from GP_PIXEL_ADDR_32BPP()
to (uint32_t*) (and same for each pixel > 8BPP).
* The gfx part for now uses GP_PutPixel_Raw() (which is wrong because
we need to clip every pixel (at least for the more complicated shapes).
So variant without transformation but with clipping is needed too.
* The HLine for 1, 2 and 4 BPP for different bit endians is not written
at all.
* The GP_PutPixel and GP_GetPixel now uses transformation flags for default
but the rest of the library doesn't (eg. gfx part). Should we simply rename
GP_TLine to GP_Line and GP_Line to GP_Line_Raw and so?
And that's it for now, I guess.
--
metan
2
13
[repo.or.cz] gfxprim.git branch generate updated: 9af82e35bed6a38c5599afcd4d0e0ac3450299a5
by metan 18 Jul '11
by metan 18 Jul '11
18 Jul '11
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project gfxprim.git.
The branch, generate has been updated
via 9af82e35bed6a38c5599afcd4d0e0ac3450299a5 (commit)
via ad753048dfe4082af1e4573c2c5d19c4cd4c6026 (commit)
from e5540ad2e0e262ef503332e7aa03168ef6ac072e (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://repo.or.cz/w/gfxprim.git/commit/9af82e35bed6a38c5599afcd4d0e0ac34502…
commit 9af82e35bed6a38c5599afcd4d0e0ac3450299a5
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Mon Jul 18 11:08:24 2011 +0200
Fix off by one bug causing segfaults.
diff --git a/libs/gfx/algo/Line.algo.h b/libs/gfx/algo/Line.algo.h
index c1c2c2d..3eccb3a 100644
--- a/libs/gfx/algo/Line.algo.h
+++ b/libs/gfx/algo/Line.algo.h
@@ -66,10 +66,12 @@ void FN_NAME(CONTEXT_T context, int x0, int y0, int x1, int y1, int error = deltax / 2; int y = y0, x; int ystep = (y0 < y1) ? 1 : -1; - for (x = x0; x <= x1; x++) { + for (x = x0; x < x1; x++) { - if (steep) PUTPIXEL(context, y, x, pixval); - else PUTPIXEL(context, x, y, pixval); + if (steep) + PUTPIXEL(context, y, x, pixval); + else + PUTPIXEL(context, x, y, pixval); error = error - deltay; if (error < 0) {
http://repo.or.cz/w/gfxprim.git/commit/ad753048dfe4082af1e4573c2c5d19c4cd4c…
commit ad753048dfe4082af1e4573c2c5d19c4cd4c6026
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Mon Jul 18 10:59:03 2011 +0200
Coding style, typos.
diff --git a/include/core/GP_Common.h b/include/core/GP_Common.h
index cda1967..3bae989 100644
--- a/include/core/GP_Common.h
+++ b/include/core/GP_Common.h
@@ -164,7 +164,7 @@
#define GP_SET_BITS(offset, count, dest, val) do { GP_CLEAR_BITS(offset, count, dest); GP_SET_BITS_OR(offset, dest, val); - } while (0)
+} while (0)
/*
* Debugging version, evaluates args twice.
@@ -172,7 +172,7 @@
#define GP_SET_BITS_DBG(offset, count, dest, val) do { GP_SET_BITS(offset, count, dest, val); printf("SET_BITS(%d, %d, p, %d)n", offset, count, val); - } while (0)
+} while (0)
/* Determines the sign of the integer value; it is +1 if value is positive,
diff --git a/include/core/GP_GetPutPixel.h b/include/core/GP_GetPutPixel.h
index 12e9af4..9d9b7be 100644
--- a/include/core/GP_GetPutPixel.h
+++ b/include/core/GP_GetPutPixel.h
@@ -57,11 +57,10 @@ static inline GP_Pixel GP_GetPixel_Raw(const GP_Context *context, int x, int y)
*/
void GP_PutPixel(GP_Context *context, int x, int y, GP_Pixel p);
+//TODO: This is the same as GP_PutPixel
static inline void GP_TPutPixel(GP_Context *context, GP_Coord x, GP_Coord y,
GP_Pixel p)
{
- GP_TRANSFORM_POINT(context, x, y);
-
GP_PutPixel(context, x, y, p);
}
diff --git a/include/core/GP_Pixel.h b/include/core/GP_Pixel.h
index de2b4a5..99793f1 100644
--- a/include/core/GP_Pixel.h
+++ b/include/core/GP_Pixel.h
@@ -19,7 +19,7 @@
* Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
* <jiri.bluebear.dluhos(a)gmail.com> *
* *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
* *
* Copyright (C) 2011 Tomas Gavenciak <gavento(a)ucw.cz> *
* *
@@ -52,7 +52,7 @@ struct GP_Context;
* GP_Pixel is just uint32_t
*/
typedef uint32_t GP_Pixel;
-#define GP_PIXEL_BITS 32
+#define GP_PIXEL_BITS (sizeof(GP_Pixel) * 8)
/* Generated header */
#include "GP_Pixel.gen.h"
@@ -81,9 +81,9 @@ typedef enum {
*/
typedef struct {
- char name[8]; /* Channel name */
- uint8_t offset; /* Offset in bits */
- uint8_t size; /* Bit-size */
+ char name[8]; /* Channel name */
+ uint8_t offset; /* Offset in bits */
+ uint8_t size; /* Bit-size */
} GP_PixelTypeChannel;
/*
@@ -99,15 +99,15 @@ typedef struct {
*/
typedef struct {
- GP_PixelType type; /* Number of the type */
- const char name[16]; /* Name */
- uint8_t size; /* Size in bits */
- GP_BIT_ENDIAN bit_endian; /* Order of pixels in a byte */
- uint8_t numchannels; /* Number of channels */
- /* String describing the bit-representaton (as in "RRRRRGGGGGGBBBBB")*/
- const char bitmap[sizeof(GP_Pixel) * 8 + 1];
- /* Individual channels */
- const GP_PixelTypeChannel channels[GP_PIXELTYPE_MAX_CHANNELS];
+ GP_PixelType type; /* Number of the type */
+ const char name[16]; /* Name */
+ uint8_t size; /* Size in bits */
+ GP_BIT_ENDIAN bit_endian; /* Order of pixels in a byte */
+ uint8_t numchannels; /* Number of channels */
+ /* String describing the bit-representaton (as in "RRRRRGGGGGGBBBBB")*/
+ const char bitmap[sizeof(GP_Pixel) * 8 + 1];
+ /* Individual channels */
+ const GP_PixelTypeChannel channels[GP_PIXELTYPE_MAX_CHANNELS];
} GP_PixelTypeDescription;
/*
-----------------------------------------------------------------------
Summary of changes:
include/core/GP_Common.h | 4 ++--
include/core/GP_GetPutPixel.h | 3 +--
include/core/GP_Pixel.h | 28 ++++++++++++++--------------
libs/gfx/algo/Line.algo.h | 8 +++++---
4 files changed, 22 insertions(+), 21 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch generate updated: e5540ad2e0e262ef503332e7aa03168ef6ac072e
by metan 17 Jul '11
by metan 17 Jul '11
17 Jul '11
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project gfxprim.git.
The branch, generate has been updated
via e5540ad2e0e262ef503332e7aa03168ef6ac072e (commit)
from 7175cdaf66ca013f4ec1fd25e175adbeabd6501a (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://repo.or.cz/w/gfxprim.git/commit/e5540ad2e0e262ef503332e7aa03168ef6ac…
commit e5540ad2e0e262ef503332e7aa03168ef6ac072e
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Jul 17 22:32:00 2011 +0200
Fix previously forgotten color initializaiton.
diff --git a/tests/SDL/textaligntest.c b/tests/SDL/textaligntest.c
index f7872ac..66f97ed 100644
--- a/tests/SDL/textaligntest.c
+++ b/tests/SDL/textaligntest.c
@@ -162,6 +162,9 @@ int main(void)
black_pixel = GP_ColorToPixel(&context, GP_COL_BLACK);
red_pixel = GP_ColorToPixel(&context, GP_COL_RED);
blue_pixel = GP_ColorToPixel(&context, GP_COL_BLUE);
+ green_pixel = GP_ColorToPixel(&context, GP_COL_GREEN);
+ yellow_pixel = GP_ColorToPixel(&context, GP_COL_YELLOW);
+ darkgray_pixel = GP_ColorToPixel(&context, GP_COL_GRAY_DARK);
redraw_screen();
SDL_Flip(display);
-----------------------------------------------------------------------
Summary of changes:
tests/SDL/textaligntest.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch generate updated: 7175cdaf66ca013f4ec1fd25e175adbeabd6501a
by metan 17 Jul '11
by metan 17 Jul '11
17 Jul '11
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project gfxprim.git.
The branch, generate has been updated
via 7175cdaf66ca013f4ec1fd25e175adbeabd6501a (commit)
via 5ddc1f67228f0ce6195d0b52f67516f02511006d (commit)
via 37cb764fee13f5de90edebad64c54d22870590ea (commit)
from 7e70914d42f31e963a39ed92efe54f31cfce0782 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://repo.or.cz/w/gfxprim.git/commit/7175cdaf66ca013f4ec1fd25e175adbeabd6…
commit 7175cdaf66ca013f4ec1fd25e175adbeabd6501a
Merge: 5ddc1f6 37cb764
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Jul 17 22:17:46 2011 +0200
Merge branch 'master' into generate
Conflicts:
include/gfx/GP_Circle.h
libs/gfx/GP_Circle.c
tests/SDL/shapetest.c
diff --cc include/gfx/GP_Circle.h
index c82c346,e743abd..482cd51
--- a/include/gfx/GP_Circle.h
+++ b/include/gfx/GP_Circle.h
@@@ -28,22 -28,22 +28,22 @@@
#include "core/GP_Context.h"
-void GP_Circle(GP_Context *context, int xcenter, int ycenter,
- unsigned int r, GP_Pixel pixel);
+void GP_Circle(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
+ GP_Size r, GP_Pixel pixel);
-void GP_TCircle(GP_Context *context, int xcenter, int ycenter,
- unsigned int r, GP_Pixel pixel);
+void GP_TCircle(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
+ GP_Size r, GP_Pixel pixel);
-void GP_FillCircle(GP_Context *context, int xcenter, int ycenter,
- unsigned int r, GP_Pixel pixel);
+void GP_FillCircle(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
+ GP_Size r, GP_Pixel pixel);
-void GP_TFillCircle(GP_Context *context, int xcenter, int ycenter,
- unsigned int r, GP_Pixel pixel);
+void GP_TFillCircle(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
+ GP_Size r, GP_Pixel pixel);
-void GP_FillRing(GP_Context *context, int xcenter, int ycenter,
- unsigned int r1, unsigned int r2, GP_Pixel pixel);
+void GP_FillRing(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
- GP_Size outer_r, GP_Size inner_r, GP_Pixel pixel);
++ GP_Size r1, GP_Size r2, GP_Pixel pixel);
-void GP_TFillRing(GP_Context *context, int xcenter, int ycenter,
- unsigned int r1, unsigned int r2, GP_Pixel pixel);
+void GP_TFillRing(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
- GP_Size outer_r, GP_Size inner_r, GP_Pixel pixel);
++ GP_Size r1, GP_Size r2, GP_Pixel pixel);
#endif /* GP_CIRCLE_H */
diff --cc libs/gfx/GP_Circle.c
index 07b3955,b63fc98..9af9f43
--- a/libs/gfx/GP_Circle.c
+++ b/libs/gfx/GP_Circle.c
@@@ -78,19 -88,25 +78,19 @@@ void GP_TFillCircle(GP_Context *context
#include "algo/FillRing.algo.h"
/* Generate drawing functions for various bit depths. */
-DEF_FILLRING_FN(GP_FillRing1bpp, GP_Context *, GP_Pixel, GP_HLine1bpp)
-DEF_FILLRING_FN(GP_FillRing2bpp, GP_Context *, GP_Pixel, GP_HLine2bpp)
-DEF_FILLRING_FN(GP_FillRing4bpp, GP_Context *, GP_Pixel, GP_HLine4bpp)
-DEF_FILLRING_FN(GP_FillRing8bpp, GP_Context *, GP_Pixel, GP_HLine8bpp)
-DEF_FILLRING_FN(GP_FillRing16bpp, GP_Context *, GP_Pixel, GP_HLine16bpp)
-DEF_FILLRING_FN(GP_FillRing24bpp, GP_Context *, GP_Pixel, GP_HLine24bpp)
-DEF_FILLRING_FN(GP_FillRing32bpp, GP_Context *, GP_Pixel, GP_HLine32bpp)
-
-void GP_FillRing(GP_Context *context, int xcenter, int ycenter,
- unsigned int r1, unsigned int r2, GP_Pixel pixel)
+GP_DEF_FILL_FN_PER_BPP(GP_FillRing, DEF_FILLRING_FN)
+
+void GP_FillRing(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
- GP_Size outer_r, GP_Size inner_r, GP_Pixel pixel)
++ GP_Size r1, GP_Size r2, GP_Pixel pixel)
{
GP_CHECK_CONTEXT(context);
- GP_FN_PER_BPP(GP_FillRing, context->bpp, context,
- xcenter, ycenter, r1, r2, pixel);
+ GP_FN_PER_BPP_CONTEXT(GP_FillRing, context, context,
- xcenter, ycenter, outer_r, inner_r, pixel);
++ xcenter, ycenter, r1, r2, pixel);
}
-void GP_TFillRing(GP_Context *context, int xcenter, int ycenter,
- unsigned int r1, unsigned int r2, GP_Pixel pixel)
+void GP_TFillRing(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
- GP_Size outer_r, GP_Size inner_r, GP_Pixel pixel)
++ GP_Size r1, GP_Size r2, GP_Pixel pixel)
{
GP_CHECK_CONTEXT(context);
http://repo.or.cz/w/gfxprim.git/commit/5ddc1f67228f0ce6195d0b52f67516f02511…
commit 5ddc1f67228f0ce6195d0b52f67516f02511006d
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Jul 17 22:02:15 2011 +0200
Fix nasty Make system bug.
diff --git a/build/Makefile b/build/Makefile
index 5c24ac7..709dd08 100644
--- a/build/Makefile
+++ b/build/Makefile
@@ -10,7 +10,7 @@ else
@rm -f libGP.a libGP.so libGP.so.0
endif
-libGP.a: $(LIB_OBJECTS)
+libGP.a:
@. ./liblock.sh; spinlock .
ifdef VERBOSE
$(AR) rcs libGP.a $(LIB_OBJECTS)
@@ -20,7 +20,7 @@ else
endif
@. ./liblock.sh; spinunlock .
-libGP.so: $(LIB_OBJECTS)
+libGP.so:
@. ./liblock.sh; spinlock .
ifdef VERBOSE
$(CC) -fPIC -dPIC --shared -Wl,-soname -Wl,libGP.so.0 $(LIB_OBJECTS) -o libGP.so
-----------------------------------------------------------------------
Summary of changes:
build/Makefile | 4 ++--
include/gfx/GP_Circle.h | 4 ++--
libs/gfx/GP_Circle.c | 8 ++++----
libs/gfx/algo/FillRing.algo.h | 16 ++++++++--------
tests/SDL/shapetest.c | 9 ++-------
5 files changed, 18 insertions(+), 23 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch master updated: 37cb764fee13f5de90edebad64c54d22870590ea
by bluebear 17 Jul '11
by bluebear 17 Jul '11
17 Jul '11
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project gfxprim.git.
The branch, master has been updated
via 37cb764fee13f5de90edebad64c54d22870590ea (commit)
from b3779d6def780f74dc0dbaed7ed5f5172a9faa7c (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://repo.or.cz/w/gfxprim.git/commit/37cb764fee13f5de90edebad64c54d228705…
commit 37cb764fee13f5de90edebad64c54d22870590ea
Author: BlueBear <jiri.bluebear.dluhos(a)gmail.com>
Date: Sun Jul 17 21:59:51 2011 +0200
Fixed some +/-1 errors in Ring and improved API.
diff --git a/include/gfx/GP_Circle.h b/include/gfx/GP_Circle.h
index 57b5a0a..e743abd 100644
--- a/include/gfx/GP_Circle.h
+++ b/include/gfx/GP_Circle.h
@@ -41,9 +41,9 @@ void GP_TFillCircle(GP_Context *context, int xcenter, int ycenter,
unsigned int r, GP_Pixel pixel);
void GP_FillRing(GP_Context *context, int xcenter, int ycenter,
- unsigned int outer_r, unsigned int inner_r, GP_Pixel pixel);
+ unsigned int r1, unsigned int r2, GP_Pixel pixel);
void GP_TFillRing(GP_Context *context, int xcenter, int ycenter,
- unsigned int outer_r, unsigned int inner_r, GP_Pixel pixel);
+ unsigned int r1, unsigned int r2, GP_Pixel pixel);
#endif /* GP_CIRCLE_H */
diff --git a/libs/gfx/GP_Circle.c b/libs/gfx/GP_Circle.c
index 427a9ad..b63fc98 100644
--- a/libs/gfx/GP_Circle.c
+++ b/libs/gfx/GP_Circle.c
@@ -97,20 +97,20 @@ DEF_FILLRING_FN(GP_FillRing24bpp, GP_Context *, GP_Pixel, GP_HLine24bpp)
DEF_FILLRING_FN(GP_FillRing32bpp, GP_Context *, GP_Pixel, GP_HLine32bpp)
void GP_FillRing(GP_Context *context, int xcenter, int ycenter,
- unsigned int outer_r, unsigned int inner_r, GP_Pixel pixel)
+ unsigned int r1, unsigned int r2, GP_Pixel pixel)
{
GP_CHECK_CONTEXT(context);
GP_FN_PER_BPP(GP_FillRing, context->bpp, context,
- xcenter, ycenter, outer_r, inner_r, pixel);
+ xcenter, ycenter, r1, r2, pixel);
}
void GP_TFillRing(GP_Context *context, int xcenter, int ycenter,
- unsigned int outer_r, unsigned int inner_r, GP_Pixel pixel)
+ unsigned int r1, unsigned int r2, GP_Pixel pixel)
{
GP_CHECK_CONTEXT(context);
GP_TRANSFORM_POINT(context, xcenter, ycenter);
- GP_FillRing(context, xcenter, ycenter, outer_r, inner_r, pixel);
+ GP_FillRing(context, xcenter, ycenter, r1, r2, pixel);
}
diff --git a/libs/gfx/algo/FillRing.algo.h b/libs/gfx/algo/FillRing.algo.h
index 4458bec..96dfa79 100644
--- a/libs/gfx/algo/FillRing.algo.h
+++ b/libs/gfx/algo/FillRing.algo.h
@@ -37,10 +37,10 @@
*/
#define DEF_FILLRING_FN(FN_NAME, CONTEXT_T, PIXVAL_T, HLINE) void FN_NAME(CONTEXT_T context, int xcenter, int ycenter, - unsigned int outer_r, unsigned int inner_r, PIXVAL_T pixval) + unsigned int r1, unsigned int r2, PIXVAL_T pixval) { - if (inner_r >= outer_r) return; -+ int outer_r = (int) GP_MAX(r1, r2); + int inner_r = (int) GP_MIN(r1, r2); int outer_x = 0; int inner_x = 0; int y; @@ -54,17 +54,17 @@ void FN_NAME(CONTEXT_T context, int xcenter, int ycenter, } outer_error += -2*y + 1; - if (y < (int) inner_r && y > -((int) inner_r)) { + if (y <= (int) inner_r && y >= -((int) inner_r)) { while (inner_error < 0) { inner_error += 2*inner_x + 1; inner_x++; } inner_error += -2*y + 1; - HLINE(context, xcenter - outer_x + 1, xcenter - inner_x - 1, ycenter - y, pixval); - HLINE(context, xcenter + inner_x + 1, xcenter + outer_x - 1, ycenter - y, pixval); - HLINE(context, xcenter - outer_x + 1, xcenter - inner_x - 1, ycenter + y, pixva
l); - HLINE(context, xcenter + inner_x + 1, xcenter + outer_x - 1, ycenter + y, pixval); + HLINE(context, xcenter - outer_x + 1, xcenter - inner_x + 1, ycenter - y, pixval); + HLINE(context, xcenter + inner_x - 1, xcenter + outer_x - 1, ycenter - y, pixval); + HLINE(context, xcenter - outer_x + 1, xcenter - inner_x + 1, ycenter + y, pixval); + HLINE(context, xcenter + inner_x - 1, xcenter + outer_x - 1, ycenter + y, pixval); } else { HLINE(context, xcenter - outer_x + 1, xcenter + outer_x - 1, ycenter-y, pixval); HLINE(context, xcenter - outer_x + 1, xcenter + outer_x - 1, ycenter+y, pixval); diff --git a/tests/SDL/shapetest.c b/tests/SDL/shapetest.c
index d1009d9..0587c55 100644
--- a/tests/SDL/shapetest.c
+++ b/tests/SDL/shapetest.c
@@ -164,14 +164,8 @@ void draw_testing_ring(int x, int y, int xradius,
if (outline == 1)
GP_TCircle(&context, x, y, xradius, yellow);
- if (fill) {
- if (xradius == yradius) {
- GP_TFillRing(&context, x, y, xradius, xradius/2, red);
- } else {
- GP_TFillRing(&context, x, y, GP_MAX(xradius, yradius),
- GP_MIN(xradius, yradius), red);
- }
- }
+ if (fill)
+ GP_TFillRing(&context, x, y, xradius, yradius, red);
if (outline == 2)
GP_TCircle(&context, x, y, xradius, white);
-----------------------------------------------------------------------
Summary of changes:
include/gfx/GP_Circle.h | 4 ++--
libs/gfx/GP_Circle.c | 8 ++++----
libs/gfx/algo/FillRing.algo.h | 16 ++++++++--------
tests/SDL/shapetest.c | 10 ++--------
4 files changed, 16 insertions(+), 22 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch generate updated: 7e70914d42f31e963a39ed92efe54f31cfce0782
by metan 17 Jul '11
by metan 17 Jul '11
17 Jul '11
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project gfxprim.git.
The branch, generate has been updated
via 7e70914d42f31e963a39ed92efe54f31cfce0782 (commit)
via 740b7028f534fbd12a22257f701f28c1df603cbc (commit)
via b3779d6def780f74dc0dbaed7ed5f5172a9faa7c (commit)
from 2d34007fde18efe7a66079b899a16eae0bfd2dbc (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://repo.or.cz/w/gfxprim.git/commit/7e70914d42f31e963a39ed92efe54f31cfce…
commit 7e70914d42f31e963a39ed92efe54f31cfce0782
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Jul 17 20:53:34 2011 +0200
Fix merge.
diff --git a/include/gfx/GP_Circle.h b/include/gfx/GP_Circle.h
index 2ff4dac..c82c346 100644
--- a/include/gfx/GP_Circle.h
+++ b/include/gfx/GP_Circle.h
@@ -40,10 +40,10 @@ void GP_FillCircle(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
void GP_TFillCircle(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
GP_Size r, GP_Pixel pixel);
-void GP_FillRing(GP_Context *context, int xcenter, int ycenter,
- unsigned int outer_r, unsigned int inner_r, GP_Pixel pixel);
+void GP_FillRing(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
+ GP_Size outer_r, GP_Size inner_r, GP_Pixel pixel);
-void GP_TFillRing(GP_Context *context, int xcenter, int ycenter,
- unsigned int outer_r, unsigned int inner_r, GP_Pixel pixel);
+void GP_TFillRing(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
+ GP_Size outer_r, GP_Size inner_r, GP_Pixel pixel);
#endif /* GP_CIRCLE_H */
diff --git a/libs/gfx/GP_Circle.c b/libs/gfx/GP_Circle.c
index ade89f7..07b3955 100644
--- a/libs/gfx/GP_Circle.c
+++ b/libs/gfx/GP_Circle.c
@@ -78,25 +78,19 @@ void GP_TFillCircle(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
#include "algo/FillRing.algo.h"
/* Generate drawing functions for various bit depths. */
-DEF_FILLRING_FN(GP_FillRing1bpp, GP_Context *, GP_Pixel, GP_HLine1bpp)
-DEF_FILLRING_FN(GP_FillRing2bpp, GP_Context *, GP_Pixel, GP_HLine2bpp)
-DEF_FILLRING_FN(GP_FillRing4bpp, GP_Context *, GP_Pixel, GP_HLine4bpp)
-DEF_FILLRING_FN(GP_FillRing8bpp, GP_Context *, GP_Pixel, GP_HLine8bpp)
-DEF_FILLRING_FN(GP_FillRing16bpp, GP_Context *, GP_Pixel, GP_HLine16bpp)
-DEF_FILLRING_FN(GP_FillRing24bpp, GP_Context *, GP_Pixel, GP_HLine24bpp)
-DEF_FILLRING_FN(GP_FillRing32bpp, GP_Context *, GP_Pixel, GP_HLine32bpp)
-
-void GP_FillRing(GP_Context *context, int xcenter, int ycenter,
- unsigned int outer_r, unsigned int inner_r, GP_Pixel pixel)
+GP_DEF_FILL_FN_PER_BPP(GP_FillRing, DEF_FILLRING_FN)
+
+void GP_FillRing(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
+ GP_Size outer_r, GP_Size inner_r, GP_Pixel pixel)
{
GP_CHECK_CONTEXT(context);
- GP_FN_PER_BPP(GP_FillRing, context->bpp, context,
- xcenter, ycenter, outer_r, inner_r, pixel);
+ GP_FN_PER_BPP_CONTEXT(GP_FillRing, context, context,
+ xcenter, ycenter, outer_r, inner_r, pixel);
}
-void GP_TFillRing(GP_Context *context, int xcenter, int ycenter,
- unsigned int outer_r, unsigned int inner_r, GP_Pixel pixel)
+void GP_TFillRing(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
+ GP_Size outer_r, GP_Size inner_r, GP_Pixel pixel)
{
GP_CHECK_CONTEXT(context);
diff --git a/tests/SDL/shapetest.c b/tests/SDL/shapetest.c
index 4af2152..7f420c2 100644
--- a/tests/SDL/shapetest.c
+++ b/tests/SDL/shapetest.c
@@ -164,12 +164,11 @@ void draw_testing_ring(int x, int y, int xradius,
GP_TCircle(&context, x, y, xradius, yellow);
if (fill) {
- if (xradius == yradius) {
+ if (xradius == yradius)
GP_TFillRing(&context, x, y, xradius, xradius/2, red);
- } else {
+ else
GP_TFillRing(&context, x, y, GP_MAX(xradius, yradius),
GP_MIN(xradius, yradius), red);
- }
}
if (outline == 2)
http://repo.or.cz/w/gfxprim.git/commit/740b7028f534fbd12a22257f701f28c1df60…
commit 740b7028f534fbd12a22257f701f28c1df603cbc
Merge: 2d34007 b3779d6
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Jul 17 20:43:10 2011 +0200
Merge branch 'master' into generate
diff --cc include/gfx/GP_Circle.h
index aaab27a,57b5a0a..2ff4dac
--- a/include/gfx/GP_Circle.h
+++ b/include/gfx/GP_Circle.h
@@@ -28,16 -28,22 +28,22 @@@
#include "core/GP_Context.h"
-void GP_Circle(GP_Context *context, int xcenter, int ycenter,
- unsigned int r, GP_Pixel pixel);
+void GP_Circle(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
+ GP_Size r, GP_Pixel pixel);
-void GP_TCircle(GP_Context *context, int xcenter, int ycenter,
- unsigned int r, GP_Pixel pixel);
+void GP_TCircle(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
+ GP_Size r, GP_Pixel pixel);
-void GP_FillCircle(GP_Context *context, int xcenter, int ycenter,
- unsigned int r, GP_Pixel pixel);
+void GP_FillCircle(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
+ GP_Size r, GP_Pixel pixel);
-void GP_TFillCircle(GP_Context *context, int xcenter, int ycenter,
- unsigned int r, GP_Pixel pixel);
+void GP_TFillCircle(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
+ GP_Size r, GP_Pixel pixel);
+ void GP_FillRing(GP_Context *context, int xcenter, int ycenter,
+ unsigned int outer_r, unsigned int inner_r, GP_Pixel pixel);
+
+ void GP_TFillRing(GP_Context *context, int xcenter, int ycenter,
+ unsigned int outer_r, unsigned int inner_r, GP_Pixel pixel);
+
#endif /* GP_CIRCLE_H */
-----------------------------------------------------------------------
Summary of changes:
include/gfx/GP_Circle.h | 6 ++
libs/gfx/GP_Circle.c | 24 ++++++++++
.../algo/{FillCircle.algo.h => FillRing.algo.h} | 49 +++++++++++++-------
tests/SDL/shapetest.c | 29 ++++++++++-
4 files changed, 88 insertions(+), 20 deletions(-)
copy libs/gfx/algo/{FillCircle.algo.h => FillRing.algo.h} (66%)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch generate updated: 2d34007fde18efe7a66079b899a16eae0bfd2dbc
by metan 17 Jul '11
by metan 17 Jul '11
17 Jul '11
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project gfxprim.git.
The branch, generate has been updated
via 2d34007fde18efe7a66079b899a16eae0bfd2dbc (commit)
from f7289bd299e2a2414ab8b69f692f6e36f701a2e3 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://repo.or.cz/w/gfxprim.git/commit/2d34007fde18efe7a66079b899a16eae0bfd…
commit 2d34007fde18efe7a66079b899a16eae0bfd2dbc
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Jul 17 20:25:45 2011 +0200
Changed GP_Color api.
* GP_Color is now enum
* Color Name is string
diff --git a/include/core/GP_Color.h b/include/core/GP_Color.h
index 1fddae9..8bda861 100644
--- a/include/core/GP_Color.h
+++ b/include/core/GP_Color.h
@@ -23,13 +23,20 @@
* *
*****************************************************************************/
+ /*
+
+ Color.
+
+ */
+
#ifndef GP_COLOR_H
#define GP_COLOR_H
#include "GP_Context.h"
#include "GP_Pixel.h"
-typedef enum GP_ColorName {
+typedef enum GP_Color {
+ GP_COL_INVALID = -1,
GP_COL_BLACK,
GP_COL_RED,
GP_COL_GREEN,
@@ -42,8 +49,23 @@ typedef enum GP_ColorName {
GP_COL_PURPLE,
GP_COL_WHITE,
GP_COL_MAX,
-} GP_ColorName;
+} GP_Color;
+
+/*
+ * Converts Color to Pixel
+ */
+GP_Pixel GP_ColorToPixel(GP_Context *context, GP_Color col);
+
+/*
+ * Converts Color name to Color.
+ */
+GP_Color GP_ColorNameToColor(const char *color_name);
+
+const char *GP_ColorToColorName(GP_Color col);
-GP_Pixel GP_ColorNameToPixel(GP_Context *context, GP_ColorName name);
+/*
+ * Converts Color name to Pixel.
+ */
+GP_Pixel GP_ColorNameToPixel(GP_Context *context, const char *color_name);
#endif /* GP_COLOR_H */
diff --git a/libs/core/GP_Color.c b/libs/core/GP_Color.c
index 19906e3..b6981d9 100644
--- a/libs/core/GP_Color.c
+++ b/libs/core/GP_Color.c
@@ -28,40 +28,71 @@
#include "GP_Color.h"
#include <stdint.h>
+#include <string.h>
static char *color_names[] = {
- "black ",
- "red ",
- "green ",
- "blue ",
- "yellow ",
- "brown ",
- "orange ",
- "gray dark ",
- "gray light",
- "purple ",
- "white "
+ "Black",
+ "Red",
+ "Green",
+ "Blue",
+ "Yellow",
+ "Brown",
+ "Orange",
+ "DarkGray",
+ "LightGray",
+ "Purple",
+ "White"
};
static uint8_t rgb888_colors[][3] = {
- {0x00, 0x00, 0x00}, /* black */
- {0xff, 0x00, 0x00}, /* red */
- {0x00, 0xff, 0x00}, /* green */
- {0x00, 0x00, 0xff}, /* blue */
- {0xff, 0xff, 0x00}, /* yellow */
- {0xa5, 0x2a, 0x2a}, /* brown */
- {0xff, 0xa5, 0x00}, /* orange */
- {0x7f, 0x7f, 0x7f}, /* gray dark */
- {0xbe, 0xbe, 0xbe}, /* gray light */
- {0xa0, 0x20, 0xf0}, /* purple */
- {0xff, 0xff, 0xff}, /* white */
+ {0x00, 0x00, 0x00}, /* Black */
+ {0xff, 0x00, 0x00}, /* Red */
+ {0x00, 0xff, 0x00}, /* Green */
+ {0x00, 0x00, 0xff}, /* Blue */
+ {0xff, 0xff, 0x00}, /* Yellow */
+ {0xa5, 0x2a, 0x2a}, /* Brown */
+ {0xff, 0xa5, 0x00}, /* Orange */
+ {0x7f, 0x7f, 0x7f}, /* DarkGray */
+ {0xbe, 0xbe, 0xbe}, /* LigthGray */
+ {0xa0, 0x20, 0xf0}, /* Purple */
+ {0xff, 0xff, 0xff}, /* White */
};
-GP_Pixel GP_ColorNameToPixel(GP_Context *context, GP_ColorName name)
+GP_Pixel GP_ColorToPixel(GP_Context *context, GP_Color col)
{
- GP_ASSERT(name < GP_COL_MAX);
+ GP_ASSERT(col < GP_COL_MAX);
+ GP_ASSERT(col >= 0);
- return GP_RGBToPixel(rgb888_colors[name][0],
- rgb888_colors[name][1],
- rgb888_colors[name][2], context->pixel_type);
+ return GP_RGBToPixel(rgb888_colors[col][0],
+ rgb888_colors[col][1],
+ rgb888_colors[col][2], context->pixel_type);
+}
+
+GP_Color GP_ColorNameToColor(const char *color_name)
+{
+ unsigned int i;
+
+ for (i = 0; i < GP_COL_MAX; i++)
+ if (!strcasecmp(color_name, color_names[i]))
+ return i;
+
+ return -1;
+}
+
+const char *GP_ColorToColorName(GP_Color col)
+{
+ if (col < 0 || col >= GP_COL_MAX)
+ return NULL;
+
+ return color_names[col];
+}
+
+GP_Pixel GP_ColorNameToPixel(GP_Context *context, const char *color_name)
+{
+ GP_Color col = GP_ColorNameToColor(color_name);
+
+ if (col < 0)
+ return 0;
+
+ return GP_ColorToPixel(context, col);
}
diff --git a/tests/SDL/fileview.c b/tests/SDL/fileview.c
index d7eead9..4bbe940 100644
--- a/tests/SDL/fileview.c
+++ b/tests/SDL/fileview.c
@@ -237,12 +237,12 @@ int main(int argc, char *argv[])
GP_SDL_ContextFromSurface(&context, display);
/* Load colors suitable for the display */
- white_pixel = GP_ColorNameToPixel(&context, GP_COL_WHITE);
- gray_pixel = GP_ColorNameToPixel(&context, GP_COL_GRAY_LIGHT);
- dark_gray_pixel = GP_ColorNameToPixel(&context, GP_COL_GRAY_DARK);
- black_pixel = GP_ColorNameToPixel(&context, GP_COL_BLACK);
- red_pixel = GP_ColorNameToPixel(&context, GP_COL_RED);
- blue_pixel = GP_ColorNameToPixel(&context, GP_COL_BLUE);
+ white_pixel = GP_ColorToPixel(&context, GP_COL_WHITE);
+ gray_pixel = GP_ColorToPixel(&context, GP_COL_GRAY_LIGHT);
+ dark_gray_pixel = GP_ColorToPixel(&context, GP_COL_GRAY_DARK);
+ black_pixel = GP_ColorToPixel(&context, GP_COL_BLACK);
+ red_pixel = GP_ColorToPixel(&context, GP_COL_RED);
+ blue_pixel = GP_ColorToPixel(&context, GP_COL_BLUE);
redraw_screen();
SDL_Flip(display);
diff --git a/tests/SDL/fonttest.c b/tests/SDL/fonttest.c
index 788f652..91f42fc 100644
--- a/tests/SDL/fonttest.c
+++ b/tests/SDL/fonttest.c
@@ -231,12 +231,12 @@ int main(int argc, char *argv[])
GP_SDL_ContextFromSurface(&context, display);
/* Load colors suitable for the display */
- white_pixel = GP_ColorNameToPixel(&context, GP_COL_WHITE);
- gray_pixel = GP_ColorNameToPixel(&context, GP_COL_GRAY_LIGHT);
- dark_gray_pixel = GP_ColorNameToPixel(&context, GP_COL_GRAY_DARK);
- black_pixel = GP_ColorNameToPixel(&context, GP_COL_BLACK);
- red_pixel = GP_ColorNameToPixel(&context, GP_COL_RED);
- blue_pixel = GP_ColorNameToPixel(&context, GP_COL_BLUE);
+ white_pixel = GP_ColorToPixel(&context, GP_COL_WHITE);
+ gray_pixel = GP_ColorToPixel(&context, GP_COL_GRAY_LIGHT);
+ dark_gray_pixel = GP_ColorToPixel(&context, GP_COL_GRAY_DARK);
+ black_pixel = GP_ColorToPixel(&context, GP_COL_BLACK);
+ red_pixel = GP_ColorToPixel(&context, GP_COL_RED);
+ blue_pixel = GP_ColorToPixel(&context, GP_COL_BLUE);
redraw_screen();
SDL_Flip(display);
diff --git a/tests/SDL/linetest.c b/tests/SDL/linetest.c
index 7012804..245b1ce 100644
--- a/tests/SDL/linetest.c
+++ b/tests/SDL/linetest.c
@@ -124,8 +124,8 @@ int main(int argc, char **argv)
GP_SDL_ContextFromSurface(&context, display);
/* Load colors in display format */
- black = GP_ColorNameToPixel(&context, GP_COL_BLACK);
- white = GP_ColorNameToPixel(&context, GP_COL_WHITE);
+ black = GP_ColorToPixel(&context, GP_COL_BLACK);
+ white = GP_ColorToPixel(&context, GP_COL_WHITE);
/* Set up the refresh timer */
timer = SDL_AddTimer(30, timer_callback, NULL);
diff --git a/tests/SDL/pixeltest.c b/tests/SDL/pixeltest.c
index 5ea47a1..467a17b 100644
--- a/tests/SDL/pixeltest.c
+++ b/tests/SDL/pixeltest.c
@@ -156,10 +156,10 @@ int main(int argc, char **argv)
GP_SDL_ContextFromSurface(&context, display);
/* Load pixel values compatible with the display. */
- red_pixel = GP_ColorNameToPixel(&context, GP_COL_RED);
- green_pixel = GP_ColorNameToPixel(&context, GP_COL_GREEN);
- blue_pixel = GP_ColorNameToPixel(&context, GP_COL_BLUE);
- white_pixel = GP_ColorNameToPixel(&context, GP_COL_WHITE);
+ red_pixel = GP_ColorToPixel(&context, GP_COL_RED);
+ green_pixel = GP_ColorToPixel(&context, GP_COL_GREEN);
+ blue_pixel = GP_ColorToPixel(&context, GP_COL_BLUE);
+ white_pixel = GP_ColorToPixel(&context, GP_COL_WHITE);
/* Set up the refresh timer */
timer = SDL_AddTimer(30, timer_callback, NULL);
diff --git a/tests/SDL/randomshapetest.c b/tests/SDL/randomshapetest.c
index 61c9f6f..592d466 100644
--- a/tests/SDL/randomshapetest.c
+++ b/tests/SDL/randomshapetest.c
@@ -89,13 +89,11 @@ void draw_random_circle(GP_Pixel pixel)
random_point(display, &x, &y);
int r = random() % 50;
- if (fill_flag) {
+ if (fill_flag)
GP_FillCircle(&context, x, y, r, pixel);
- }
- if (outline_flag) {
+ if (outline_flag)
GP_Circle(&context, x, y, r, white);
- }
}
void draw_random_ellipse(GP_Pixel pixel)
@@ -105,13 +103,11 @@ void draw_random_ellipse(GP_Pixel pixel)
int rx = random() % 50;
int ry = random() % 50;
- if (fill_flag) {
+ if (fill_flag)
GP_FillEllipse(&context, x, y, rx, ry, pixel);
- }
- if (outline_flag) {
+ if (outline_flag)
GP_Ellipse(&context, x, y, rx, ry, white);
- }
}
void draw_random_triangle(GP_Pixel pixel)
@@ -121,13 +117,11 @@ void draw_random_triangle(GP_Pixel pixel)
random_point(display, &x1, &y1);
random_point(display, &x2, &y2);
- if (fill_flag) {
+ if (fill_flag)
GP_FillTriangle(&context, x0, y0, x1, y1, x2, y2, pixel);
- }
- if (outline_flag) {
+ if (outline_flag)
GP_Triangle(&context, x0, y0, x1, y1, x2, y2, white);
- }
}
void draw_random_rectangle(GP_Pixel pixel)
@@ -136,13 +130,11 @@ void draw_random_rectangle(GP_Pixel pixel)
random_point(display, &x0, &y0);
random_point(display, &x1, &y1);
- if (fill_flag) {
+ if (fill_flag)
GP_FillRect(&context, x0, y0, x1, y1, pixel);
- }
- if (outline_flag) {
+ if (outline_flag)
GP_Rect(&context, x0, y0, x1, y1, white);
- }
}
void draw_random_tetragon(GP_Pixel pixel)
@@ -153,13 +145,11 @@ void draw_random_tetragon(GP_Pixel pixel)
random_point(display, &x2, &y2);
random_point(display, &x3, &y3);
- if (fill_flag) {
+ if (fill_flag)
GP_FillTetragon(&context, x0, y0, x1, y1, x2, y2, x3, y3, pixel);
- }
- if (outline_flag) {
+ if (outline_flag)
GP_Tetragon(&context, x0, y0, x1, y1, x2, y2, x3, y3, pixel);
- }
}
void clear_screen(void)
@@ -178,7 +168,8 @@ void redraw_screen(void)
/* Pick a random color for drawing. */
GP_Pixel pixel;
- pixel = GP_RGBToPixel(&context, random() % 256, random() % 256, random() % 256);
+ pixel = GP_RGBToPixel(random() % 256, random() % 256,
+ random() % 256, context.pixel_type);
switch (shape) {
case SHAPE_CIRCLE:
@@ -309,8 +300,8 @@ int main(int argc, char *argv[])
GP_SDL_ContextFromSurface(&context, display);
- white = GP_ColorNameToPixel(&context, GP_COL_WHITE);
- black = GP_ColorNameToPixel(&context, GP_COL_BLACK);
+ white = GP_ColorToPixel(&context, GP_COL_WHITE);
+ black = GP_ColorToPixel(&context, GP_COL_BLACK);
/* Set up the refresh timer */
timer = SDL_AddTimer(60, timer_callback, NULL);
diff --git a/tests/SDL/shapetest.c b/tests/SDL/shapetest.c
index 44f04cf..f91d94e 100644
--- a/tests/SDL/shapetest.c
+++ b/tests/SDL/shapetest.c
@@ -136,9 +136,8 @@ void draw_testing_triangle(int x, int y, int xradius, int yradius)
if (outline == 1)
GP_TTriangle(&context, x0, y0, x1, y1, x2, y2, yellow);
- if (fill) {
+ if (fill)
GP_TFillTriangle(&context, x0, y0, x1, y1, x2, y2, red);
- }
if (outline == 2)
GP_TTriangle(&context, x0, y0, x1, y1, x2, y2, white);
@@ -284,17 +283,16 @@ void event_loop(void)
break;
case SDLK_f:
fill = !fill;
- if (!fill && !outline) {
+ if (!fill && !outline)
outline = 1;
- }
break;
case SDLK_o:
outline++;
- if (outline == 3) { outline = 0; }
- if (!fill && outline == 0) {
+ if (outline == 3)
+ outline = 0;
+ if (!fill && outline == 0)
fill = 1;
- }
break;
case SDLK_a:
@@ -463,13 +461,13 @@ int main(int argc, char ** argv)
GP_SDL_ContextFromSurface(&context, display);
/* Load colors compatible with the display */
- black = GP_ColorNameToPixel(&context, GP_COL_BLACK);
- white = GP_ColorNameToPixel(&context, GP_COL_WHITE);
- yellow = GP_ColorNameToPixel(&context, GP_COL_YELLOW);
- green = GP_ColorNameToPixel(&context, GP_COL_GREEN);
- red = GP_ColorNameToPixel(&context, GP_COL_RED);
- gray = GP_ColorNameToPixel(&context, GP_COL_GRAY_LIGHT);
- darkgray = GP_ColorNameToPixel(&context, GP_COL_GRAY_DARK);
+ black = GP_ColorToPixel(&context, GP_COL_BLACK);
+ white = GP_ColorToPixel(&context, GP_COL_WHITE);
+ yellow = GP_ColorToPixel(&context, GP_COL_YELLOW);
+ green = GP_ColorToPixel(&context, GP_COL_GREEN);
+ red = GP_ColorToPixel(&context, GP_COL_RED);
+ gray = GP_ColorToPixel(&context, GP_COL_GRAY_LIGHT);
+ darkgray = GP_ColorToPixel(&context, GP_COL_GRAY_DARK);
/* Set up the refresh timer */
timer = SDL_AddTimer(60, timer_callback, NULL);
diff --git a/tests/SDL/sierpinsky.c b/tests/SDL/sierpinsky.c
index 333107f..b2e6dd8 100644
--- a/tests/SDL/sierpinsky.c
+++ b/tests/SDL/sierpinsky.c
@@ -55,7 +55,7 @@ static void sierpinsky(double x1, double y1, double x4, double y4, int iter)
{
double x2, y2, x3, y3, x5, y5;
GP_Pixel pixel;
- pixel = GP_RGBToPixel(context, 0, 0, 255-16*iter);
+ pixel = GP_RGBToPixel(0, 0, 255-16*iter, context->pixel_type);
if (iter <= 0) {
if (draw_edge)
@@ -162,10 +162,10 @@ int main(void)
display = SDL_GetVideoSurface();
context = GP_GetBackendVideoContext();
- black = GP_ColorNameToPixel(context, GP_COL_BLACK);
- blue = GP_ColorNameToPixel(context, GP_COL_BLUE);
- gray = GP_ColorNameToPixel(context, GP_COL_GRAY_LIGHT);
- red = GP_ColorNameToPixel(context, GP_COL_RED);
+ black = GP_ColorToPixel(context, GP_COL_BLACK);
+ blue = GP_ColorToPixel(context, GP_COL_BLUE);
+ gray = GP_ColorToPixel(context, GP_COL_GRAY_LIGHT);
+ red = GP_ColorToPixel(context, GP_COL_RED);
iter = 0;
draw(display->w/2, display->h/2, l, iter);
diff --git a/tests/SDL/symbolstest.c b/tests/SDL/symbolstest.c
index 532c13a..e7fd0a3 100644
--- a/tests/SDL/symbolstest.c
+++ b/tests/SDL/symbolstest.c
@@ -172,7 +172,7 @@ int main(int argc, char *argv[])
GP_SDL_ContextFromSurface(&context, display);
- black = GP_ColorNameToPixel(&context, GP_COL_BLACK);
+ black = GP_ColorToPixel(&context, GP_COL_BLACK);
/* Set up the refresh timer */
timer = SDL_AddTimer(60, timer_callback, NULL);
diff --git a/tests/SDL/textaligntest.c b/tests/SDL/textaligntest.c
index 348eab7..f7872ac 100644
--- a/tests/SDL/textaligntest.c
+++ b/tests/SDL/textaligntest.c
@@ -159,9 +159,9 @@ int main(void)
GP_SDL_ContextFromSurface(&context, display);
/* Load colors suitable for the display */
- black_pixel = GP_ColorNameToPixel(&context, GP_COL_BLACK);
- red_pixel = GP_ColorNameToPixel(&context, GP_COL_RED);
- blue_pixel = GP_ColorNameToPixel(&context, GP_COL_BLUE);
+ black_pixel = GP_ColorToPixel(&context, GP_COL_BLACK);
+ red_pixel = GP_ColorToPixel(&context, GP_COL_RED);
+ blue_pixel = GP_ColorToPixel(&context, GP_COL_BLUE);
redraw_screen();
SDL_Flip(display);
diff --git a/tests/SDL/trianglefps.c b/tests/SDL/trianglefps.c
index 17c0604..cf163bf 100644
--- a/tests/SDL/trianglefps.c
+++ b/tests/SDL/trianglefps.c
@@ -159,8 +159,8 @@ int main(int argc, char ** argv)
GP_SDL_ContextFromSurface(&context, display);
- white = GP_ColorNameToPixel(&context, GP_COL_WHITE);
- black = GP_ColorNameToPixel(&context, GP_COL_BLACK);
+ white = GP_ColorToPixel(&context, GP_COL_WHITE);
+ black = GP_ColorToPixel(&context, GP_COL_BLACK);
/* Set up the timer */
timer = SDL_AddTimer(1000, timer_callback, NULL);
-----------------------------------------------------------------------
Summary of changes:
include/core/GP_Color.h | 28 +++++++++++++--
libs/core/GP_Color.c | 85 +++++++++++++++++++++++++++++--------------
tests/SDL/fileview.c | 12 +++---
tests/SDL/fonttest.c | 12 +++---
tests/SDL/linetest.c | 4 +-
tests/SDL/pixeltest.c | 8 ++--
tests/SDL/randomshapetest.c | 37 +++++++------------
tests/SDL/shapetest.c | 26 ++++++-------
tests/SDL/sierpinsky.c | 10 +++---
tests/SDL/symbolstest.c | 2 +-
tests/SDL/textaligntest.c | 6 ++--
tests/SDL/trianglefps.c | 4 +-
12 files changed, 138 insertions(+), 96 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch master updated: b3779d6def780f74dc0dbaed7ed5f5172a9faa7c
by bluebear 17 Jul '11
by bluebear 17 Jul '11
17 Jul '11
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project gfxprim.git.
The branch, master has been updated
via b3779d6def780f74dc0dbaed7ed5f5172a9faa7c (commit)
from 9d50a7192a8d4620a221c571092015891182f63a (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://repo.or.cz/w/gfxprim.git/commit/b3779d6def780f74dc0dbaed7ed5f5172a9f…
commit b3779d6def780f74dc0dbaed7ed5f5172a9faa7c
Author: BlueBear <jiri.bluebear.dluhos(a)gmail.com>
Date: Sun Jul 17 20:23:31 2011 +0200
Initial attempt on rings (only circular for now).
diff --git a/include/gfx/GP_Circle.h b/include/gfx/GP_Circle.h
index 6360e72..57b5a0a 100644
--- a/include/gfx/GP_Circle.h
+++ b/include/gfx/GP_Circle.h
@@ -40,4 +40,10 @@ void GP_FillCircle(GP_Context *context, int xcenter, int ycenter,
void GP_TFillCircle(GP_Context *context, int xcenter, int ycenter,
unsigned int r, GP_Pixel pixel);
+void GP_FillRing(GP_Context *context, int xcenter, int ycenter,
+ unsigned int outer_r, unsigned int inner_r, GP_Pixel pixel);
+
+void GP_TFillRing(GP_Context *context, int xcenter, int ycenter,
+ unsigned int outer_r, unsigned int inner_r, GP_Pixel pixel);
+
#endif /* GP_CIRCLE_H */
diff --git a/libs/gfx/GP_Circle.c b/libs/gfx/GP_Circle.c
index 4e92243..427a9ad 100644
--- a/libs/gfx/GP_Circle.c
+++ b/libs/gfx/GP_Circle.c
@@ -84,3 +84,33 @@ void GP_TFillCircle(GP_Context *context, int xcenter, int ycenter,
GP_FillCircle(context, xcenter, ycenter, r, pixel);
}
+
+#include "algo/FillRing.algo.h"
+
+/* Generate drawing functions for various bit depths. */
+DEF_FILLRING_FN(GP_FillRing1bpp, GP_Context *, GP_Pixel, GP_HLine1bpp)
+DEF_FILLRING_FN(GP_FillRing2bpp, GP_Context *, GP_Pixel, GP_HLine2bpp)
+DEF_FILLRING_FN(GP_FillRing4bpp, GP_Context *, GP_Pixel, GP_HLine4bpp)
+DEF_FILLRING_FN(GP_FillRing8bpp, GP_Context *, GP_Pixel, GP_HLine8bpp)
+DEF_FILLRING_FN(GP_FillRing16bpp, GP_Context *, GP_Pixel, GP_HLine16bpp)
+DEF_FILLRING_FN(GP_FillRing24bpp, GP_Context *, GP_Pixel, GP_HLine24bpp)
+DEF_FILLRING_FN(GP_FillRing32bpp, GP_Context *, GP_Pixel, GP_HLine32bpp)
+
+void GP_FillRing(GP_Context *context, int xcenter, int ycenter,
+ unsigned int outer_r, unsigned int inner_r, GP_Pixel pixel)
+{
+ GP_CHECK_CONTEXT(context);
+
+ GP_FN_PER_BPP(GP_FillRing, context->bpp, context,
+ xcenter, ycenter, outer_r, inner_r, pixel);
+}
+
+void GP_TFillRing(GP_Context *context, int xcenter, int ycenter,
+ unsigned int outer_r, unsigned int inner_r, GP_Pixel pixel)
+{
+ GP_CHECK_CONTEXT(context);
+
+ GP_TRANSFORM_POINT(context, xcenter, ycenter);
+
+ GP_FillRing(context, xcenter, ycenter, outer_r, inner_r, pixel);
+}
diff --git a/include/gfx/GP_Circle.h b/libs/gfx/algo/FillRing.algo.h
similarity index 53%
copy from include/gfx/GP_Circle.h
copy to libs/gfx/algo/FillRing.algo.h
index 6360e72..4458bec 100644
--- a/include/gfx/GP_Circle.h
+++ b/libs/gfx/algo/FillRing.algo.h
@@ -23,21 +23,51 @@
* *
*****************************************************************************/
-#ifndef GP_CIRCLE_H
-#define GP_CIRCLE_H
+/*
+ * A filled ring drawing algorithm.
+ */
-#include "core/GP_Context.h"
-
-void GP_Circle(GP_Context *context, int xcenter, int ycenter,
- unsigned int r, GP_Pixel pixel);
-
-void GP_TCircle(GP_Context *context, int xcenter, int ycenter,
- unsigned int r, GP_Pixel pixel);
-
-void GP_FillCircle(GP_Context *context, int xcenter, int ycenter,
- unsigned int r, GP_Pixel pixel);
-
-void GP_TFillCircle(GP_Context *context, int xcenter, int ycenter,
- unsigned int r, GP_Pixel pixel);
-
-#endif /* GP_CIRCLE_H */
+/*
+ * This macro defines a filled circle drawing function.
+ * Arguments:
+ * CONTEXT_T - user-defined type of drawing context (passed to HLINE)
+ * PIXVAL_T - user-defined pixel value type (passed to HLINE)
+ * HLINE - horizontal line drawing function f(context, x0, x1, y, pixval)
+ * FN_NAME - name of the function to be defined
+ */
+#define DEF_FILLRING_FN(FN_NAME, CONTEXT_T, PIXVAL_T, HLINE) +void FN_NAME(CONTEXT_T context, int xcenter, int ycenter, + unsigned int outer_r, unsigned int inner_r, PIXVAL_T pixval) +{ + if (inner_r >= outer_r) return; ++ int outer_x = 0; + int inner_x = 0; + int y; + int outer_error = -outer_r; + int inner_error = -inner_r; + for (y = outer_r; y >= 0; y--) { ++ while (outer_error < 0) { + outer_error += 2*outer_x + 1; + outer_x++; + } + outer_error += -2*y + 1; ++ if (y < (int) inner_r && y > -((int) inner_r)) { + while (inner_error < 0) { + inner_error += 2*inner_x + 1; + inner_x++; + } + inner_error += -2*y + 1; ++ HLINE(context, xcenter - outer_x + 1, xcenter - inner_x - 1, ycenter - y, pixval); + HLINE(context, xcenter + inner_x + 1, xcenter + outer_x - 1, ycenter - y, pixval); + HLINE(context, xcenter - outer_x + 1, xcenter - inner_x - 1, ycenter + y, pixval); + HLINE(context, xcenter + inner_x + 1, xcenter + outer_x - 1, ycenter + y, pixva
l); + } else { + HLINE(context, xcenter - outer_x + 1, xcenter + outer_x - 1, ycenter-y, pixval); + HLINE(context, xcenter - outer_x + 1, xcenter + outer_x - 1, ycenter+y, pixval); + } + } +}
diff --git a/tests/SDL/shapetest.c b/tests/SDL/shapetest.c
index fb85b2e..d1009d9 100644
--- a/tests/SDL/shapetest.c
+++ b/tests/SDL/shapetest.c
@@ -68,9 +68,10 @@ static int show_axes = 1;
#define SHAPE_FIRST 1
#define SHAPE_TRIANGLE 1
#define SHAPE_CIRCLE 2
-#define SHAPE_ELLIPSE 3
-#define SHAPE_RECTANGLE 4
-#define SHAPE_LAST 4
+#define SHAPE_RING 3
+#define SHAPE_ELLIPSE 4
+#define SHAPE_RECTANGLE 5
+#define SHAPE_LAST 5
static int shape = SHAPE_FIRST;
/* Variants in coordinates, if applicable */
@@ -157,6 +158,25 @@ void draw_testing_circle(int x, int y, int xradius,
GP_TCircle(&context, x, y, xradius, white);
}
+void draw_testing_ring(int x, int y, int xradius,
+ __attribute__((unused)) int yradius)
+{
+ if (outline == 1)
+ GP_TCircle(&context, x, y, xradius, yellow);
+
+ if (fill) {
+ if (xradius == yradius) {
+ GP_TFillRing(&context, x, y, xradius, xradius/2, red);
+ } else {
+ GP_TFillRing(&context, x, y, GP_MAX(xradius, yradius),
+ GP_MIN(xradius, yradius), red);
+ }
+ }
+
+ if (outline == 2)
+ GP_TCircle(&context, x, y, xradius, white);
+}
+
void draw_testing_ellipse(int x, int y, int xradius, int yradius)
{
if (outline == 1)
@@ -217,6 +237,10 @@ void redraw_screen(void)
draw_testing_circle(center_x, center_y, xradius, yradius);
title = "CIRCLE";
break;
+ case SHAPE_RING:
+ draw_testing_ring(center_x, center_y, xradius, yradius);
+ title = "RING";
+ break;
case SHAPE_ELLIPSE:
draw_testing_ellipse(center_x, center_y, xradius, yradius);
title = "ELLIPSE";
-----------------------------------------------------------------------
Summary of changes:
include/gfx/GP_Circle.h | 6 ++
libs/gfx/GP_Circle.c | 30 ++++++++++++
.../algo/{FillCircle.algo.h => FillRing.algo.h} | 49 +++++++++++++-------
tests/SDL/shapetest.c | 30 +++++++++++-
4 files changed, 95 insertions(+), 20 deletions(-)
copy libs/gfx/algo/{FillCircle.algo.h => FillRing.algo.h} (66%)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch generate updated: f7289bd299e2a2414ab8b69f692f6e36f701a2e3
by metan 17 Jul '11
by metan 17 Jul '11
17 Jul '11
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project gfxprim.git.
The branch, generate has been updated
via f7289bd299e2a2414ab8b69f692f6e36f701a2e3 (commit)
via d200a400aa94a961bec59b76e73979dfd6f22709 (commit)
via 16295ba207ab7fc7e05031ff3319b87a07884f5d (commit)
from f4f99af5bd7efbf8214eaf84a95dab162f763179 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://repo.or.cz/w/gfxprim.git/commit/f7289bd299e2a2414ab8b69f692f6e36f701…
commit f7289bd299e2a2414ab8b69f692f6e36f701a2e3
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Jul 17 15:53:42 2011 +0200
Fixed GP_Color and Pixel so that SDL demos compile.
diff --git a/include/core/GP_Color.h b/include/core/GP_Color.h
index 3f13f95..1fddae9 100644
--- a/include/core/GP_Color.h
+++ b/include/core/GP_Color.h
@@ -19,13 +19,16 @@
* Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
* <jiri.bluebear.dluhos(a)gmail.com> *
* *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
#ifndef GP_COLOR_H
#define GP_COLOR_H
+#include "GP_Context.h"
+#include "GP_Pixel.h"
+
typedef enum GP_ColorName {
GP_COL_BLACK,
GP_COL_RED,
@@ -41,4 +44,6 @@ typedef enum GP_ColorName {
GP_COL_MAX,
} GP_ColorName;
+GP_Pixel GP_ColorNameToPixel(GP_Context *context, GP_ColorName name);
+
#endif /* GP_COLOR_H */
diff --git a/include/core/GP_Core.h b/include/core/GP_Core.h
index 6d45291..f4d8e46 100644
--- a/include/core/GP_Core.h
+++ b/include/core/GP_Core.h
@@ -44,6 +44,9 @@
/* Pixeltypes */
#include "core/GP_Pixel.h"
+/* Pixel conversions */
+#include "core/GP_Convert.h"
+
/* Individual pixel access */
#include "core/GP_GetPutPixel.h"
diff --git a/include/core/GP_GetPutPixel.h b/include/core/GP_GetPutPixel.h
index 4f7a146..12e9af4 100644
--- a/include/core/GP_GetPutPixel.h
+++ b/include/core/GP_GetPutPixel.h
@@ -25,6 +25,7 @@
#define CORE_GP_GETPUTPIXEL_H
#include "GP_Context.h"
+#include "GP_Transform.h"
#include "GP_FnPerBpp.h"
#include "GP_Pixel.h"
@@ -56,6 +57,14 @@ static inline GP_Pixel GP_GetPixel_Raw(const GP_Context *context, int x, int y)
*/
void GP_PutPixel(GP_Context *context, int x, int y, GP_Pixel p);
+static inline void GP_TPutPixel(GP_Context *context, GP_Coord x, GP_Coord y,
+ GP_Pixel p)
+{
+ GP_TRANSFORM_POINT(context, x, y);
+
+ GP_PutPixel(context, x, y, p);
+}
+
/*
* Version of PutPixel without transformations nor border checking.
*/
diff --git a/include/core/GP_Pixel.h b/include/core/GP_Pixel.h
index 6282bf1..de2b4a5 100644
--- a/include/core/GP_Pixel.h
+++ b/include/core/GP_Pixel.h
@@ -31,7 +31,6 @@
#include <stdbool.h>
#include <stdint.h>
-#include "GP_Color.h"
#include "GP_Common.h"
#include "GP_RetCode.h"
#include "GP_FnPerBpp.h"
@@ -158,12 +157,13 @@ static inline void GP_PixelPrint(GP_Pixel pixel, GP_PixelType type)
}
/*
- * Match pixel type to known pixel types.
+ * Match pixel type to known pixel types, pixel_size is in bits.
*
* Returns either valid PixelType or GP_PIXEL_UNKNOWN
*/
GP_PixelType GP_PixelRGBMatch(GP_Pixel rmask, GP_Pixel gmask,
- GP_Pixel bmask, GP_Pixel amask);
+ GP_Pixel bmask, GP_Pixel amask,
+ uint8_t pixel_size);
#endif /* GP_PIXEL_H */
diff --git a/libs/SDL/GP_SDL_Context.c b/libs/SDL/GP_SDL_Context.c
index 021b6e6..e8b7500 100644
--- a/libs/SDL/GP_SDL_Context.c
+++ b/libs/SDL/GP_SDL_Context.c
@@ -38,7 +38,8 @@ GP_RetCode GP_SDL_ContextFromSurface(GP_Context *context, SDL_Surface *surf)
enum GP_PixelType pixeltype = GP_PixelRGBMatch(surf->format->Rmask,
surf->format->Gmask,
surf->format->Bmask,
- surf->format->Ashift);
+ surf->format->Ashift,
+ surf->format->BitsPerPixel);
if (pixeltype == GP_PIXEL_UNKNOWN)
return GP_ENOIMPL;
diff --git a/libs/backends/GP_Backend_SDL.c b/libs/backends/GP_Backend_SDL.c
index aac4a32..c3fd9ac 100644
--- a/libs/backends/GP_Backend_SDL.c
+++ b/libs/backends/GP_Backend_SDL.c
@@ -58,7 +58,8 @@ inline GP_RetCode GP_SDL_ContextFromSurface(
enum GP_PixelType pixeltype = GP_PixelRGBMatch(surf->format->Rmask,
surf->format->Gmask,
surf->format->Bmask,
- surf->format->Ashift);
+ surf->format->Ashift,
+ surf->format->BitsPerPixel);
if (pixeltype == GP_PIXEL_UNKNOWN)
return GP_ENOIMPL;
diff --git a/libs/core/GP_Color.c b/libs/core/GP_Color.c
index e6f2c53..19906e3 100644
--- a/libs/core/GP_Color.c
+++ b/libs/core/GP_Color.c
@@ -23,6 +23,10 @@
* *
*****************************************************************************/
+#include "GP_Convert.h"
+
+#include "GP_Color.h"
+
#include <stdint.h>
static char *color_names[] = {
@@ -53,3 +57,11 @@ static uint8_t rgb888_colors[][3] = {
{0xff, 0xff, 0xff}, /* white */
};
+GP_Pixel GP_ColorNameToPixel(GP_Context *context, GP_ColorName name)
+{
+ GP_ASSERT(name < GP_COL_MAX);
+
+ return GP_RGBToPixel(rgb888_colors[name][0],
+ rgb888_colors[name][1],
+ rgb888_colors[name][2], context->pixel_type);
+}
diff --git a/libs/core/GP_Pixel.c b/libs/core/GP_Pixel.c
index d6553b1..0132c7a 100644
--- a/libs/core/GP_Pixel.c
+++ b/libs/core/GP_Pixel.c
@@ -41,19 +41,24 @@ static const GP_PixelTypeChannel *get_channel(const GP_PixelTypeDescription *des
static int match(const GP_PixelTypeChannel *channel, GP_Pixel mask)
{
- if (channel == NULL)
+ if (channel == NULL) {
+ printf("%s gen %08x pass %08xn", channel->name, 0, mask);
return !mask;
+ }
GP_Pixel chmask = ~0;
chmask >>= (GP_PIXEL_BITS - channel->size);
chmask <<= channel->offset;
+
+ printf("%s gen %08x pass %08xn", channel->name, chmask, mask);
return (chmask == mask);
}
GP_PixelType GP_PixelRGBMatch(GP_Pixel rmask, GP_Pixel gmask,
- GP_Pixel bmask, GP_Pixel amask)
+ GP_Pixel bmask, GP_Pixel amask,
+ uint8_t pixel_size)
{
unsigned int i;
@@ -62,10 +67,27 @@ GP_PixelType GP_PixelRGBMatch(GP_Pixel rmask, GP_Pixel gmask,
const GP_PixelTypeChannel *r, *g, *b, *a;
+ if (GP_PixelTypes[i].size != pixel_size)
+ continue;
+
r = get_channel(&GP_PixelTypes[i], "R");
g = get_channel(&GP_PixelTypes[i], "G");
b = get_channel(&GP_PixelTypes[i], "B");
a = get_channel(&GP_PixelTypes[i], "A");
+
+ printf("------------------------ %s %un", GP_PixelTypes[i].name, pixel_size);
+
+ if (r)
+ printf("Matching R %i %in", r->size, r->offset);
+
+ if (g)
+ printf("Matching G %i %in", g->size, g->offset);
+
+ if (b)
+ printf("Matching B %i %in", b->size, b->offset);
+
+ if (a)
+ printf("Matching A %i %in", a->size, a->offset);
res = match(r, rmask) && match(g, gmask) &&
match(b, bmask) && match(a, amask);
diff --git a/tests/Makefile b/tests/Makefile
index 83de916..e002663 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -1,3 +1,3 @@
TOPDIR=..
-SUBDIRS=filters core SDL #loaders
+SUBDIRS=core SDL #loaders filters
include $(TOPDIR)/include.mk
diff --git a/tests/SDL/fileview.c b/tests/SDL/fileview.c
index c1660a0..d7eead9 100644
--- a/tests/SDL/fileview.c
+++ b/tests/SDL/fileview.c
@@ -237,12 +237,12 @@ int main(int argc, char *argv[])
GP_SDL_ContextFromSurface(&context, display);
/* Load colors suitable for the display */
- GP_ColorNameToPixel(&context, GP_COL_WHITE, &white_pixel);
- GP_ColorNameToPixel(&context, GP_COL_GRAY_LIGHT, &gray_pixel);
- GP_ColorNameToPixel(&context, GP_COL_GRAY_DARK, &dark_gray_pixel);
- GP_ColorNameToPixel(&context, GP_COL_BLACK, &black_pixel);
- GP_ColorNameToPixel(&context, GP_COL_RED, &red_pixel);
- GP_ColorNameToPixel(&context, GP_COL_BLUE, &blue_pixel);
+ white_pixel = GP_ColorNameToPixel(&context, GP_COL_WHITE);
+ gray_pixel = GP_ColorNameToPixel(&context, GP_COL_GRAY_LIGHT);
+ dark_gray_pixel = GP_ColorNameToPixel(&context, GP_COL_GRAY_DARK);
+ black_pixel = GP_ColorNameToPixel(&context, GP_COL_BLACK);
+ red_pixel = GP_ColorNameToPixel(&context, GP_COL_RED);
+ blue_pixel = GP_ColorNameToPixel(&context, GP_COL_BLUE);
redraw_screen();
SDL_Flip(display);
diff --git a/tests/SDL/fonttest.c b/tests/SDL/fonttest.c
index 756f01d..788f652 100644
--- a/tests/SDL/fonttest.c
+++ b/tests/SDL/fonttest.c
@@ -231,12 +231,12 @@ int main(int argc, char *argv[])
GP_SDL_ContextFromSurface(&context, display);
/* Load colors suitable for the display */
- GP_ColorNameToPixel(&context, GP_COL_WHITE, &white_pixel);
- GP_ColorNameToPixel(&context, GP_COL_GRAY_LIGHT, &gray_pixel);
- GP_ColorNameToPixel(&context, GP_COL_GRAY_DARK, &dark_gray_pixel);
- GP_ColorNameToPixel(&context, GP_COL_BLACK, &black_pixel);
- GP_ColorNameToPixel(&context, GP_COL_RED, &red_pixel);
- GP_ColorNameToPixel(&context, GP_COL_BLUE, &blue_pixel);
+ white_pixel = GP_ColorNameToPixel(&context, GP_COL_WHITE);
+ gray_pixel = GP_ColorNameToPixel(&context, GP_COL_GRAY_LIGHT);
+ dark_gray_pixel = GP_ColorNameToPixel(&context, GP_COL_GRAY_DARK);
+ black_pixel = GP_ColorNameToPixel(&context, GP_COL_BLACK);
+ red_pixel = GP_ColorNameToPixel(&context, GP_COL_RED);
+ blue_pixel = GP_ColorNameToPixel(&context, GP_COL_BLUE);
redraw_screen();
SDL_Flip(display);
diff --git a/tests/SDL/linetest.c b/tests/SDL/linetest.c
index d9925c8..7012804 100644
--- a/tests/SDL/linetest.c
+++ b/tests/SDL/linetest.c
@@ -72,7 +72,7 @@ void redraw_screen(void)
Uint8 b = 127.0 + 127.0 * sin(start_angle + angle);
GP_Pixel pixel;
- GP_RGBToPixel(&context, r, 0, b, &pixel);
+ pixel = GP_RGBToPixel(r, 0, b, context.pixel_type);
/*
* Draw the line forth and back to detect any pixel change
@@ -124,8 +124,8 @@ int main(int argc, char **argv)
GP_SDL_ContextFromSurface(&context, display);
/* Load colors in display format */
- GP_ColorNameToPixel(&context, GP_COL_BLACK, &black);
- GP_ColorNameToPixel(&context, GP_COL_WHITE, &white);
+ black = GP_ColorNameToPixel(&context, GP_COL_BLACK);
+ white = GP_ColorNameToPixel(&context, GP_COL_WHITE);
/* Set up the refresh timer */
timer = SDL_AddTimer(30, timer_callback, NULL);
diff --git a/tests/SDL/pixeltest.c b/tests/SDL/pixeltest.c
index 7b3ffe5..5ea47a1 100644
--- a/tests/SDL/pixeltest.c
+++ b/tests/SDL/pixeltest.c
@@ -53,7 +53,7 @@ Uint32 timer_callback(__attribute__((unused)) Uint32 interval,
void draw_pixel(void)
{
- GP_Color pixel, conv;
+// GP_Color pixel, conv;
int x = random() % 320;
int y = random() % 240;
@@ -156,10 +156,10 @@ int main(int argc, char **argv)
GP_SDL_ContextFromSurface(&context, display);
/* Load pixel values compatible with the display. */
- GP_ColorNameToPixel(&context, GP_COL_RED, &red_pixel);
- GP_ColorNameToPixel(&context, GP_COL_GREEN, &green_pixel);
- GP_ColorNameToPixel(&context, GP_COL_BLUE, &blue_pixel);
- GP_ColorNameToPixel(&context, GP_COL_WHITE, &white_pixel);
+ red_pixel = GP_ColorNameToPixel(&context, GP_COL_RED);
+ green_pixel = GP_ColorNameToPixel(&context, GP_COL_GREEN);
+ blue_pixel = GP_ColorNameToPixel(&context, GP_COL_BLUE);
+ white_pixel = GP_ColorNameToPixel(&context, GP_COL_WHITE);
/* Set up the refresh timer */
timer = SDL_AddTimer(30, timer_callback, NULL);
diff --git a/tests/SDL/randomshapetest.c b/tests/SDL/randomshapetest.c
index b46125d..61c9f6f 100644
--- a/tests/SDL/randomshapetest.c
+++ b/tests/SDL/randomshapetest.c
@@ -178,7 +178,7 @@ void redraw_screen(void)
/* Pick a random color for drawing. */
GP_Pixel pixel;
- GP_RGBToPixel(&context, random() % 256, random() % 256, random() % 256, &pixel);
+ pixel = GP_RGBToPixel(&context, random() % 256, random() % 256, random() % 256);
switch (shape) {
case SHAPE_CIRCLE:
@@ -309,8 +309,8 @@ int main(int argc, char *argv[])
GP_SDL_ContextFromSurface(&context, display);
- GP_ColorNameToPixel(&context, GP_COL_WHITE, &white);
- GP_ColorNameToPixel(&context, GP_COL_BLACK, &black);
+ white = GP_ColorNameToPixel(&context, GP_COL_WHITE);
+ black = GP_ColorNameToPixel(&context, GP_COL_BLACK);
/* Set up the refresh timer */
timer = SDL_AddTimer(60, timer_callback, NULL);
diff --git a/tests/SDL/shapetest.c b/tests/SDL/shapetest.c
index fb85b2e..44f04cf 100644
--- a/tests/SDL/shapetest.c
+++ b/tests/SDL/shapetest.c
@@ -463,13 +463,13 @@ int main(int argc, char ** argv)
GP_SDL_ContextFromSurface(&context, display);
/* Load colors compatible with the display */
- GP_ColorNameToPixel(&context, GP_COL_BLACK, &black);
- GP_ColorNameToPixel(&context, GP_COL_WHITE, &white);
- GP_ColorNameToPixel(&context, GP_COL_YELLOW, &yellow);
- GP_ColorNameToPixel(&context, GP_COL_GREEN, &green);
- GP_ColorNameToPixel(&context, GP_COL_RED, &red);
- GP_ColorNameToPixel(&context, GP_COL_GRAY_LIGHT, &gray);
- GP_ColorNameToPixel(&context, GP_COL_GRAY_DARK, &darkgray);
+ black = GP_ColorNameToPixel(&context, GP_COL_BLACK);
+ white = GP_ColorNameToPixel(&context, GP_COL_WHITE);
+ yellow = GP_ColorNameToPixel(&context, GP_COL_YELLOW);
+ green = GP_ColorNameToPixel(&context, GP_COL_GREEN);
+ red = GP_ColorNameToPixel(&context, GP_COL_RED);
+ gray = GP_ColorNameToPixel(&context, GP_COL_GRAY_LIGHT);
+ darkgray = GP_ColorNameToPixel(&context, GP_COL_GRAY_DARK);
/* Set up the refresh timer */
timer = SDL_AddTimer(60, timer_callback, NULL);
diff --git a/tests/SDL/sierpinsky.c b/tests/SDL/sierpinsky.c
index 1136a45..333107f 100644
--- a/tests/SDL/sierpinsky.c
+++ b/tests/SDL/sierpinsky.c
@@ -55,7 +55,7 @@ static void sierpinsky(double x1, double y1, double x4, double y4, int iter)
{
double x2, y2, x3, y3, x5, y5;
GP_Pixel pixel;
- GP_RGBToPixel(context, 0, 0, 255-16*iter, &pixel);
+ pixel = GP_RGBToPixel(context, 0, 0, 255-16*iter);
if (iter <= 0) {
if (draw_edge)
@@ -162,10 +162,10 @@ int main(void)
display = SDL_GetVideoSurface();
context = GP_GetBackendVideoContext();
- GP_ColorNameToPixel(context, GP_COL_BLACK, &black);
- GP_ColorNameToPixel(context, GP_COL_BLUE, &blue);
- GP_ColorNameToPixel(context, GP_COL_GRAY_LIGHT, &gray);
- GP_ColorNameToPixel(context, GP_COL_RED, &red);
+ black = GP_ColorNameToPixel(context, GP_COL_BLACK);
+ blue = GP_ColorNameToPixel(context, GP_COL_BLUE);
+ gray = GP_ColorNameToPixel(context, GP_COL_GRAY_LIGHT);
+ red = GP_ColorNameToPixel(context, GP_COL_RED);
iter = 0;
draw(display->w/2, display->h/2, l, iter);
diff --git a/tests/SDL/symbolstest.c b/tests/SDL/symbolstest.c
index 57a9722..532c13a 100644
--- a/tests/SDL/symbolstest.c
+++ b/tests/SDL/symbolstest.c
@@ -29,6 +29,8 @@
#include "GP_SDL.h"
+static GP_Pixel black;
+
/* The surface used as a display (in fact it is a software surface). */
SDL_Surface *display = NULL;
GP_Context context;
@@ -39,9 +41,6 @@ SDL_TimerID timer;
/* An event used for signaling that the timer was triggered. */
SDL_UserEvent timer_event;
-/* Globally used colors. */
-GP_Pixel white, black;
-
static int pause_flag = 0;
static int fill_flag = 0;
@@ -85,18 +84,14 @@ void clear_screen(void)
void redraw_screen(void)
{
- /* Random color. */
- GP_Color color = GP_RGB888_PACK(random() % 256,
- random() % 256,
- random() % 256);
-
if (pause_flag)
return;
SDL_LockSurface(display);
GP_Pixel pixel;
- GP_ColorToPixel(&context, color, &pixel);
+ pixel = GP_RGBToPixel(random() % 256, random() % 256,
+ random() % 256, context.pixel_type);
draw_random_symbol(pixel);
@@ -177,9 +172,8 @@ int main(int argc, char *argv[])
GP_SDL_ContextFromSurface(&context, display);
- GP_ColorNameToPixel(&context, GP_COL_WHITE, &white);
- GP_ColorNameToPixel(&context, GP_COL_BLACK, &black);
-
+ black = GP_ColorNameToPixel(&context, GP_COL_BLACK);
+
/* Set up the refresh timer */
timer = SDL_AddTimer(60, timer_callback, NULL);
if (timer == 0) {
diff --git a/tests/SDL/textaligntest.c b/tests/SDL/textaligntest.c
index 7731860..348eab7 100644
--- a/tests/SDL/textaligntest.c
+++ b/tests/SDL/textaligntest.c
@@ -159,12 +159,9 @@ int main(void)
GP_SDL_ContextFromSurface(&context, display);
/* Load colors suitable for the display */
- GP_ColorNameToPixel(&context, GP_COL_YELLOW, &yellow_pixel);
- GP_ColorNameToPixel(&context, GP_COL_BLUE, &blue_pixel);
- GP_ColorNameToPixel(&context, GP_COL_RED, &red_pixel);
- GP_ColorNameToPixel(&context, GP_COL_GREEN, &green_pixel);
- GP_ColorNameToPixel(&context, GP_COL_BLACK, &black_pixel);
- GP_ColorNameToPixel(&context, GP_COL_GRAY_DARK, &darkgray_pixel);
+ black_pixel = GP_ColorNameToPixel(&context, GP_COL_BLACK);
+ red_pixel = GP_ColorNameToPixel(&context, GP_COL_RED);
+ blue_pixel = GP_ColorNameToPixel(&context, GP_COL_BLUE);
redraw_screen();
SDL_Flip(display);
diff --git a/tests/SDL/trianglefps.c b/tests/SDL/trianglefps.c
index 8204521..17c0604 100644
--- a/tests/SDL/trianglefps.c
+++ b/tests/SDL/trianglefps.c
@@ -70,16 +70,15 @@ void draw_frame(void)
int y1 = random() % display->h;
int x2 = display->w/2;
int y2 = random() % display->h;
- GP_Color color = GP_RGB888_PACK(random() % 255, random() % 255, random() % 255);
GP_Pixel pixel;
- GP_ColorToPixel(&context, color, &pixel);
-
- if (filled) {
+ pixel = GP_RGBToPixel(random() % 255, random() % 255,
+ random() % 255, context.pixel_type);
+
+ if (filled)
GP_FillTriangle(&context, x0, y0, x1, y1, x2, y2, pixel);
- } else {
+ else
GP_Triangle(&context, x0, y0, x1, y1, x2, y2, pixel);
- }
}
void event_loop(void)
@@ -160,8 +159,8 @@ int main(int argc, char ** argv)
GP_SDL_ContextFromSurface(&context, display);
- GP_ColorNameToPixel(&context, GP_COL_WHITE, &white);
- GP_ColorNameToPixel(&context, GP_COL_BLACK, &black);
+ white = GP_ColorNameToPixel(&context, GP_COL_WHITE);
+ black = GP_ColorNameToPixel(&context, GP_COL_BLACK);
/* Set up the timer */
timer = SDL_AddTimer(1000, timer_callback, NULL);
http://repo.or.cz/w/gfxprim.git/commit/d200a400aa94a961bec59b76e73979dfd6f2…
commit d200a400aa94a961bec59b76e73979dfd6f22709
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Jul 17 15:41:30 2011 +0200
Fix the default types, offsets was backwards.
diff --git a/pylib/pixeltypes.py b/pylib/pixeltypes.py
index 4762255..b035b6a 100644
--- a/pylib/pixeltypes.py
+++ b/pylib/pixeltypes.py
@@ -4,6 +4,7 @@
#
# 2011 - Tomas Gavenciak <gavento(a)ucw.cz>
+# 2011 - Cyril Hrubis <metan(a)ucw.cz>
#
# Every call to PixelType defines one new GP_PixelType, order defines
# the numbering. Undefined type is defined automatically.
@@ -19,28 +20,28 @@
#
PixelType(name='RGBx8888', size=32, chanslist=[
- ('R', 0, 8),
+ ('R', 16, 8),
('G', 8, 8),
- ('B', 16, 8)])
+ ('B', 0, 8)])
PixelType(name='RGBA8888', size=32, chanslist=[
- ('R', 0, 8),
- ('G', 8, 8),
- ('B', 16, 8),
- ('A', 24, 8)])
+ ('R', 24, 8),
+ ('G', 16, 8),
+ ('B', 8, 8),
+ ('A', 0, 8)])
PixelType(name='RGB888', size=24, chanslist=[
- ('R', 0, 8),
+ ('R', 16, 8),
('G', 8, 8),
- ('B', 16, 8)])
+ ('B', 0, 8)])
PixelType(name='RGB565', size=16, chanslist=[
- ('R', 0, 5),
+ ('R', 11, 5),
('G', 5, 6),
- ('B', 11, 5)])
+ ('B', 0, 5)])
#
# Palette types
http://repo.or.cz/w/gfxprim.git/commit/16295ba207ab7fc7e05031ff3319b87a0788…
commit 16295ba207ab7fc7e05031ff3319b87a07884f5d
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Jul 17 15:37:45 2011 +0200
Delete debug lines.
diff --git a/pylib/Makefile b/pylib/Makefile
index af75868..2d01e96 100644
--- a/pylib/Makefile
+++ b/pylib/Makefile
@@ -8,7 +8,4 @@ CLEAN+=$(patsubst %.py, %.pyc, ${PYTHON_FILES})
include $(TOPDIR)/include.mk
all:
- ls $(PYLIBSDIR)
- echo $(PYTHON_FILES)
- echo $(CLEAN)
@true
-----------------------------------------------------------------------
Summary of changes:
include/core/GP_Color.h | 7 ++++++-
include/core/GP_Core.h | 3 +++
include/core/GP_GetPutPixel.h | 9 +++++++++
include/core/GP_Pixel.h | 6 +++---
libs/SDL/GP_SDL_Context.c | 3 ++-
libs/backends/GP_Backend_SDL.c | 3 ++-
libs/core/GP_Color.c | 12 ++++++++++++
libs/core/GP_Pixel.c | 26 ++++++++++++++++++++++++--
pylib/Makefile | 3 ---
pylib/pixeltypes.py | 21 +++++++++++----------
tests/Makefile | 2 +-
tests/SDL/fileview.c | 12 ++++++------
tests/SDL/fonttest.c | 12 ++++++------
tests/SDL/linetest.c | 6 +++---
tests/SDL/pixeltest.c | 10 +++++-----
tests/SDL/randomshapetest.c | 6 +++---
tests/SDL/shapetest.c | 14 +++++++-------
tests/SDL/sierpinsky.c | 10 +++++-----
tests/SDL/symbolstest.c | 18 ++++++------------
tests/SDL/textaligntest.c | 9 +++------
tests/SDL/trianglefps.c | 15 +++++++--------
21 files changed, 124 insertions(+), 83 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0