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/8a21bc6f957aa940853da65d443afdb21be9b...
commit 8a21bc6f957aa940853da65d443afdb21be9b891 Author: Cyril Hrubis metan@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@gmail.com * * * - * Copyright (C) 2009-2010 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2011 Cyril Hrubis metan@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@gmail.com * * * - * Copyright (C) 2009-2010 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2011 Cyril Hrubis metan@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@gmail.com * * * - * Copyright (C) 2009-2010 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2011 Cyril Hrubis metan@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@gmail.com * * * - * Copyright (C) 2009-2010 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2011 Cyril Hrubis metan@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@gmail.com * * * - * Copyright (C) 2009-2010 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2011 Cyril Hrubis metan@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@gmail.com * * * - * Copyright (C) 2009-2010 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2011 Cyril Hrubis metan@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@gmail.com * * * - * Copyright (C) 2009-2010 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2011 Cyril Hrubis metan@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@gmail.com * * * - * Copyright (C) 2009-2010 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2011 Cyril Hrubis metan@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@gmail.com * * * - * Copyright (C) 2009-2010 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2011 Cyril Hrubis metan@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@gmail.com * * * - * Copyright (C) 2009-2010 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2011 Cyril Hrubis metan@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@gmail.com * * * - * Copyright (C) 2009-2010 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2011 Cyril Hrubis metan@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@gmail.com * * * - * Copyright (C) 2009-2010 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2011 Cyril Hrubis metan@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@gmail.com * * * - * Copyright (C) 2009-2010 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2011 Cyril Hrubis metan@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@gmail.com * * * - * Copyright (C) 2009-2010 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2011 Cyril Hrubis metan@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@gmail.com * - * * - * Copyright (C) 2009-2010 Cyril Hrubis metan@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@gmail.com * * * - * Copyright (C) 2009-2010 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2011 Cyril Hrubis metan@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@gmail.com * * * - * Copyright (C) 2009-2010 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2011 Cyril Hrubis metan@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@gmail.com * * * - * Copyright (C) 2009-2010 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2011 Cyril Hrubis metan@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@gmail.com * * * - * Copyright (C) 2009-2010 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2011 Cyril Hrubis metan@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@gmail.com * * * - * Copyright (C) 2009-2010 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2011 Cyril Hrubis metan@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@gmail.com * * * - * Copyright (C) 2009-2010 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2011 Cyril Hrubis metan@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@gmail.com * * * * Copyright (C) 2009-2011 Cyril Hrubis metan@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/a6b989fc9c386a6e7422277784cd13140af7e...
commit a6b989fc9c386a6e7422277784cd13140af7e286 Author: Cyril Hrubis metan@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@gmail.com if you want to unsubscribe, or site admin admin@repo.or.cz if you receive no reply.