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 4d97054a669a9060142863a6004144d993270c13 (commit) via 4df5151ae9400f76567697fd5c88917d9ee79229 (commit) via 31bfb14e08456f70a7823efa3832ad4e3ffbb9d3 (commit) from 5815d26c3a7e2a3be30f5d075c4ca064092734a3 (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/4d97054a669a9060142863a6004144d993270...
commit 4d97054a669a9060142863a6004144d993270c13 Author: Cyril Hrubis metan@ucw.cz Date: Mon Apr 25 15:45:19 2011 +0200
Simplified drawing API and unified context check.
* The API now returns void (where it makes sense) * Now we use GP_CHECK_CONTEXT() before we touch the context itself
However the GP_CHECK_CONTEXT() as it is now is not as good as it should be. That is left for future now.
diff --git a/core/GP_Circle.c b/core/GP_Circle.c index 19718bb..354405e 100644 --- a/core/GP_Circle.c +++ b/core/GP_Circle.c @@ -36,26 +36,21 @@ DEF_CIRCLE_FN(GP_Circle16bpp, GP_Context *, GP_Pixel, GP_PutPixel16bpp) DEF_CIRCLE_FN(GP_Circle24bpp, GP_Context *, GP_Pixel, GP_PutPixel24bpp) DEF_CIRCLE_FN(GP_Circle32bpp, GP_Context *, GP_Pixel, GP_PutPixel32bpp)
-GP_RetCode GP_Circle(GP_Context *context, int xcenter, int ycenter, - unsigned int r, GP_Pixel pixel) +void GP_Circle(GP_Context *context, int xcenter, int ycenter, + unsigned int r, GP_Pixel pixel) { - if (!context) - return GP_ENULLPTR; - if (!GP_IS_CONTEXT_VALID(context)) - return GP_EBADCONTEXT; + GP_CHECK_CONTEXT(context);
GP_FN_PER_BPP(GP_Circle, context, xcenter, ycenter, r, pixel); }
-GP_RetCode GP_TCircle(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) { - if (!context) - return GP_ENULLPTR; - if (!GP_IS_CONTEXT_VALID(context)) - return GP_EBADCONTEXT; - + GP_CHECK_CONTEXT(context); + /* Just recalculate center point */ GP_TRANSFORM_POINT(context, xcenter, ycenter); - return GP_Circle(context, xcenter, ycenter, r, pixel); + + GP_Circle(context, xcenter, ycenter, r, pixel); } diff --git a/core/GP_Circle.h b/core/GP_Circle.h index 7c4bdbe..9c2d4ea 100644 --- a/core/GP_Circle.h +++ b/core/GP_Circle.h @@ -28,10 +28,10 @@
#include "GP_Context.h"
-GP_RetCode GP_Circle(GP_Context *context, int xcenter, int ycenter, - unsigned int r, GP_Pixel pixel); +void GP_Circle(GP_Context *context, int xcenter, int ycenter, + unsigned int r, GP_Pixel pixel);
-GP_RetCode GP_TCircle(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);
#endif /* GP_CIRCLE_H */ diff --git a/core/GP_Context.h b/core/GP_Context.h index f9f8155..65c14d0 100644 --- a/core/GP_Context.h +++ b/core/GP_Context.h @@ -71,15 +71,6 @@ inline GP_PixelType GP_GetContextPixelType(const GP_Context *context); ((GP_PixelSize(pixel_type) * width) / 8 + !!((GP_PixelSize(pixel_type) * width) % 8))
-/* Evaluates to true if the context is valid (sane), false otherwise. */ -#define GP_IS_CONTEXT_VALID(context) ( - context->w > 0 && context->h > 0 - && context->clip_w_min <= context->clip_w_max - && context->clip_w_max < context->w - && context->clip_h_min <= context->clip_h_max - && context->clip_h_max < context->h - ) - /* Performs a series of sanity checks on context, aborting if any fails. */ #define GP_CHECK_CONTEXT(context) do { GP_CHECK(context != NULL); diff --git a/core/GP_Ellipse.c b/core/GP_Ellipse.c index cf89cc6..d499501 100644 --- a/core/GP_Ellipse.c +++ b/core/GP_Ellipse.c @@ -36,27 +36,22 @@ DEF_ELLIPSE_FN(GP_Ellipse16bpp, GP_Context *, GP_Pixel, GP_PutPixel16bpp); DEF_ELLIPSE_FN(GP_Ellipse24bpp, GP_Context *, GP_Pixel, GP_PutPixel24bpp); DEF_ELLIPSE_FN(GP_Ellipse32bpp, GP_Context *, GP_Pixel, GP_PutPixel32bpp);
-GP_RetCode GP_Ellipse(GP_Context *context, int xcenter, int ycenter, - unsigned int a, unsigned int b, GP_Pixel pixel) +void GP_Ellipse(GP_Context *context, int xcenter, int ycenter, + unsigned int a, unsigned int b, GP_Pixel pixel) { - if (!context) - return GP_ENULLPTR; - if (!GP_IS_CONTEXT_VALID(context)) - return GP_EBADCONTEXT; + GP_CHECK_CONTEXT(context);
GP_FN_PER_BPP(GP_Ellipse, context, xcenter, ycenter, a, b, pixel); }
-GP_RetCode GP_TEllipse(GP_Context *context, int xcenter, int ycenter, - unsigned int a, unsigned int b, GP_Pixel pixel) +void GP_TEllipse(GP_Context *context, int xcenter, int ycenter, + unsigned int a, unsigned int b, GP_Pixel pixel) { - if (!context) - return GP_ENULLPTR; - if (!GP_IS_CONTEXT_VALID(context)) - return GP_EBADCONTEXT; - + GP_CHECK_CONTEXT(context); + /* recalculate center point and swap a and b when axes are swapped */ GP_TRANSFORM_POINT(context, xcenter, ycenter); GP_TRANSFORM_SWAP(context, a, b); - return GP_Ellipse(context, xcenter, ycenter, a, b, pixel); + + GP_Ellipse(context, xcenter, ycenter, a, b, pixel); } diff --git a/core/GP_Ellipse.h b/core/GP_Ellipse.h index 73b68fa..5f29458 100644 --- a/core/GP_Ellipse.h +++ b/core/GP_Ellipse.h @@ -28,10 +28,10 @@
#include "GP_Context.h"
-GP_RetCode GP_Ellipse(GP_Context *context, int xcenter, int ycenter, - unsigned int a, unsigned int b, GP_Pixel pixel); +void GP_Ellipse(GP_Context *context, int xcenter, int ycenter, + unsigned int a, unsigned int b, GP_Pixel pixel);
-GP_RetCode GP_TEllipse(GP_Context *context, int xcenter, int ycenter, - unsigned int a, unsigned int b, GP_Pixel pixel); +void GP_TEllipse(GP_Context *context, int xcenter, int ycenter, + unsigned int a, unsigned int b, GP_Pixel pixel);
#endif /* GP_ELLIPSE_H */ diff --git a/core/GP_Fill.c b/core/GP_Fill.c index 94316cb..65065cc 100644 --- a/core/GP_Fill.c +++ b/core/GP_Fill.c @@ -28,9 +28,11 @@
#include "GP.h"
-GP_RetCode GP_Fill(GP_Context *context, GP_Pixel pixel) +void GP_Fill(GP_Context *context, GP_Pixel pixel) { - return GP_FillRect(context, 0, 0, context->w, context->h, pixel); + GP_CHECK_CONTEXT(context); + + GP_FillRect(context, 0, 0, context->w, context->h, pixel); }
#endif /* GP_FILL_H */ diff --git a/core/GP_Fill.h b/core/GP_Fill.h index aac358b..87af0d4 100644 --- a/core/GP_Fill.h +++ b/core/GP_Fill.h @@ -28,6 +28,6 @@
#include "GP_Context.h"
-GP_RetCode GP_Fill(GP_Context *context, GP_Pixel pixel); +void GP_Fill(GP_Context *context, GP_Pixel pixel);
#endif /* GP_FILL_H */ diff --git a/core/GP_FillCircle.c b/core/GP_FillCircle.c index df58838..e2a0f1f 100644 --- a/core/GP_FillCircle.c +++ b/core/GP_FillCircle.c @@ -36,25 +36,20 @@ DEF_FILLCIRCLE_FN(GP_FillCircle16bpp, GP_Context *, GP_Pixel, GP_HLine16bpp) DEF_FILLCIRCLE_FN(GP_FillCircle24bpp, GP_Context *, GP_Pixel, GP_HLine24bpp) DEF_FILLCIRCLE_FN(GP_FillCircle32bpp, GP_Context *, GP_Pixel, GP_HLine32bpp)
-GP_RetCode GP_FillCircle(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) { - if (!context) - return GP_ENULLPTR; - if (!GP_IS_CONTEXT_VALID(context)) - return GP_EBADCONTEXT; + GP_CHECK_CONTEXT(context);
GP_FN_PER_BPP(GP_FillCircle, context, xcenter, ycenter, r, pixel); }
-GP_RetCode GP_TFillCircle(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) { - if (!context) - return GP_ENULLPTR; - if (!GP_IS_CONTEXT_VALID(context)) - return GP_EBADCONTEXT; - + GP_CHECK_CONTEXT(context); + GP_TRANSFORM_POINT(context, xcenter, ycenter); - return GP_FillCircle(context, xcenter, ycenter, r, pixel); + + GP_FillCircle(context, xcenter, ycenter, r, pixel); } diff --git a/core/GP_FillCircle.h b/core/GP_FillCircle.h index 802eba6..208a6b8 100644 --- a/core/GP_FillCircle.h +++ b/core/GP_FillCircle.h @@ -28,10 +28,10 @@
#include "GP_Context.h"
-GP_RetCode GP_FillCircle(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);
-GP_RetCode GP_TFillCircle(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_FILLCIRCLE_H */ diff --git a/core/GP_FillEllipse.c b/core/GP_FillEllipse.c index c781e70..79df163 100644 --- a/core/GP_FillEllipse.c +++ b/core/GP_FillEllipse.c @@ -36,26 +36,21 @@ DEF_FILLELLIPSE_FN(GP_FillEllipse16bpp, GP_Context *, GP_Pixel, GP_HLine16bpp) DEF_FILLELLIPSE_FN(GP_FillEllipse24bpp, GP_Context *, GP_Pixel, GP_HLine24bpp) DEF_FILLELLIPSE_FN(GP_FillEllipse32bpp, GP_Context *, GP_Pixel, GP_HLine32bpp)
-GP_RetCode GP_FillEllipse(GP_Context *context, int xcenter, int ycenter, - unsigned int a, unsigned int b, GP_Pixel pixel) +void GP_FillEllipse(GP_Context *context, int xcenter, int ycenter, + unsigned int a, unsigned int b, GP_Pixel pixel) { - if (!context) - return GP_ENULLPTR; - if (!GP_IS_CONTEXT_VALID(context)) - return GP_EBADCONTEXT; + GP_CHECK_CONTEXT(context);
GP_FN_PER_BPP(GP_FillEllipse, context, xcenter, ycenter, a, b, pixel); }
-GP_RetCode GP_TFillEllipse(GP_Context *context, int xcenter, int ycenter, - unsigned int a, unsigned int b, GP_Pixel pixel) +void GP_TFillEllipse(GP_Context *context, int xcenter, int ycenter, + unsigned int a, unsigned int b, GP_Pixel pixel) { - if (!context) - return GP_ENULLPTR; - if (!GP_IS_CONTEXT_VALID(context)) - return GP_EBADCONTEXT; - + GP_CHECK_CONTEXT(context); + GP_TRANSFORM_POINT(context, xcenter, ycenter); GP_TRANSFORM_SWAP(context, a, b); - return GP_FillEllipse(context, xcenter, ycenter, a, b, pixel); + + GP_FillEllipse(context, xcenter, ycenter, a, b, pixel); } diff --git a/core/GP_FillEllipse.h b/core/GP_FillEllipse.h index d35e39f..cf0c7c5 100644 --- a/core/GP_FillEllipse.h +++ b/core/GP_FillEllipse.h @@ -30,10 +30,10 @@
#include <stdint.h>
-GP_RetCode GP_FillEllipse(GP_Context *context, int xcenter, int ycenter, - unsigned int a, unsigned int b, GP_Pixel pixel); +void GP_FillEllipse(GP_Context *context, int xcenter, int ycenter, + unsigned int a, unsigned int b, GP_Pixel pixel);
-GP_RetCode GP_TFillEllipse(GP_Context *context, int xcenter, int ycenter, - unsigned int a, unsigned int b, GP_Pixel pixel); +void GP_TFillEllipse(GP_Context *context, int xcenter, int ycenter, + unsigned int a, unsigned int b, GP_Pixel pixel);
#endif /* GP_FILLELLIPSE_H */ diff --git a/core/GP_FillRect.c b/core/GP_FillRect.c index aab4bd4..05f7c65 100644 --- a/core/GP_FillRect.c +++ b/core/GP_FillRect.c @@ -25,15 +25,10 @@
#include "GP.h"
-#include <stdint.h> - -GP_RetCode GP_FillRectXYXY(GP_Context *context, int x0, int y0, int x1, int y1, - GP_Pixel pixel) +void GP_FillRectXYXY(GP_Context *context, int x0, int y0, int x1, int y1, + GP_Pixel pixel) { - if (!context) - return GP_ENULLPTR; - if (!GP_IS_CONTEXT_VALID(context)) - return GP_EBADCONTEXT; + GP_CHECK_CONTEXT(context);
if (y0 > y1) GP_SWAP(y0, y1); @@ -41,37 +36,35 @@ GP_RetCode GP_FillRectXYXY(GP_Context *context, int x0, int y0, int x1, int y1, int y; for (y = y0; y <= y1; y++) GP_HLine(context, x0, x1, y, pixel); - - return GP_ESUCCESS; }
-GP_RetCode GP_FillRectXYWH(GP_Context *context, int x, int y, - unsigned int w, unsigned int h, GP_Pixel pixel) +void GP_FillRectXYWH(GP_Context *context, int x, int y, + unsigned int w, unsigned int h, GP_Pixel pixel) { + /* zero width/height: draw nothing */ if (w == 0 || h == 0) - return GP_ESUCCESS; /* zero width/height: draw nothing */ + return;
return GP_FillRectXYXY(context, x, y, x + w - 1, y + h - 1, pixel); }
-GP_RetCode GP_TFillRectXYXY(GP_Context *context, int x0, int y0, - int x1, int y1, GP_Pixel pixel) +void GP_TFillRectXYXY(GP_Context *context, int x0, int y0, + int x1, int y1, GP_Pixel pixel) { - if (!context) - return GP_ENULLPTR; - if (!GP_IS_CONTEXT_VALID(context)) - return GP_EBADCONTEXT; - + GP_CHECK_CONTEXT(context); + GP_TRANSFORM_POINT(context, x0, y0); GP_TRANSFORM_POINT(context, x1, y1); - return GP_FillRect(context, x0, y0, x1, y1, pixel); + + GP_FillRect(context, x0, y0, x1, y1, pixel); }
-GP_RetCode GP_TFillRectXYWH(GP_Context *context, int x, int y, - unsigned int w, unsigned int h, GP_Pixel pixel) +void GP_TFillRectXYWH(GP_Context *context, int x, int y, + unsigned int w, unsigned int h, GP_Pixel pixel) { + /* zero width/height: draw nothing */ if (w == 0 || h == 0) - return GP_ESUCCESS; /* zero width/height: draw nothing */ + return;
- return GP_TFillRectXYXY(context, x, y, x + w - 1, y + h - 1, pixel); + GP_TFillRectXYXY(context, x, y, x + w - 1, y + h - 1, pixel); } diff --git a/core/GP_FillRect.h b/core/GP_FillRect.h index 2740bd0..c12f57e 100644 --- a/core/GP_FillRect.h +++ b/core/GP_FillRect.h @@ -28,17 +28,17 @@
#include "GP_Context.h"
-GP_RetCode GP_FillRectXYXY(GP_Context *context, int x0, int y0, int x1, int y1, - GP_Pixel pixel); +void GP_FillRectXYXY(GP_Context *context, int x0, int y0, int x1, int y1, + GP_Pixel pixel);
-GP_RetCode GP_FillRectXYWH(GP_Context *context, int x, int y, - unsigned int w, unsigned int h, GP_Pixel pixel); +void GP_FillRectXYWH(GP_Context *context, int x, int y, + unsigned int w, unsigned int h, GP_Pixel pixel);
-GP_RetCode GP_TFillRectXYXY(GP_Context *context, int x0, int y0, int x1, int y1, - GP_Pixel pixel); +void GP_TFillRectXYXY(GP_Context *context, int x0, int y0, int x1, int y1, + GP_Pixel pixel);
-GP_RetCode GP_TFillRectXYWH(GP_Context *context, int x, int y, - unsigned int w, unsigned int h, GP_Pixel pixel); +void GP_TFillRectXYWH(GP_Context *context, int x, int y, + unsigned int w, unsigned int h, GP_Pixel pixel);
#define GP_FillRect GP_FillRectXYXY #define GP_TFillRect GP_TFillRectXYXY diff --git a/core/GP_FillTetragon.c b/core/GP_FillTetragon.c index 1b29b49..9f7e36a 100644 --- a/core/GP_FillTetragon.c +++ b/core/GP_FillTetragon.c @@ -25,33 +25,25 @@
#include "GP.h"
-GP_RetCode GP_FillTetragon(GP_Context * context, int x0, int y0, int x1, int y1, - int x2, int y2, int x3, int y3, GP_Pixel pixel) +void GP_FillTetragon(GP_Context * context, int x0, int y0, int x1, int y1, + int x2, int y2, int x3, int y3, GP_Pixel pixel) { - if (!context) - return GP_ENULLPTR; - if (!GP_IS_CONTEXT_VALID(context)) - return GP_EBADCONTEXT; + GP_CHECK_CONTEXT(context);
//TODO: fix this! GP_FillTriangle(context, x0, y0, x1, y1, x2, y2, pixel); GP_FillTriangle(context, x3, y3, x1, y1, x2, y2, pixel); - - return GP_ESUCCESS; }
-GP_RetCode GP_TFillTetragon(GP_Context* context, int x0, int y0, int x1, int y1, - int x2, int y2, int x3, int y3, GP_Pixel pixel) +void GP_TFillTetragon(GP_Context* context, int x0, int y0, int x1, int y1, + int x2, int y2, int x3, int y3, GP_Pixel pixel) { - if (!context) - return GP_ENULLPTR; - if (!GP_IS_CONTEXT_VALID(context)) - return GP_EBADCONTEXT; - + GP_CHECK_CONTEXT(context); + GP_TRANSFORM_POINT(context, x0, y0); GP_TRANSFORM_POINT(context, x1, y1); GP_TRANSFORM_POINT(context, x2, y2); GP_TRANSFORM_POINT(context, x3, y3);
- return GP_FillTetragon(context, x0, y0, x1, y1, x2, y2, x3, y3, pixel); + GP_FillTetragon(context, x0, y0, x1, y1, x2, y2, x3, y3, pixel); } diff --git a/core/GP_FillTetragon.h b/core/GP_FillTetragon.h index b8ff2d3..0335648 100644 --- a/core/GP_FillTetragon.h +++ b/core/GP_FillTetragon.h @@ -28,11 +28,10 @@
#include "GP_Context.h"
-GP_RetCode GP_FillTetragon(GP_Context *context, int x0, int y0, int x1, int y1, - int x2, int y2, int x3, int y3, GP_Pixel pixel); +void GP_FillTetragon(GP_Context *context, int x0, int y0, int x1, int y1, + int x2, int y2, int x3, int y3, GP_Pixel pixel);
-GP_RetCode GP_TFillTetragon(GP_Context *context, int x0, int y0, - int x1, int y1, int x2, int y2, int x3, int y3, - GP_Pixel pixel); +void GP_TFillTetragon(GP_Context *context, int x0, int y0, int x1, int y1, + int x2, int y2, int x3, int y3, GP_Pixel pixel);
#endif /* GP_FILLTETRAGON_H */ diff --git a/core/GP_FillTriangle.c b/core/GP_FillTriangle.c index ea196dc..3b483d6 100644 --- a/core/GP_FillTriangle.c +++ b/core/GP_FillTriangle.c @@ -39,27 +39,22 @@ DEF_FILLTRIANGLE_FN(GP_FillTriangle16bpp, GP_Context *, GP_Pixel, GP_HLine16bpp, DEF_FILLTRIANGLE_FN(GP_FillTriangle24bpp, GP_Context *, GP_Pixel, GP_HLine24bpp, GP_PutPixel24bpp) DEF_FILLTRIANGLE_FN(GP_FillTriangle32bpp, GP_Context *, GP_Pixel, GP_HLine32bpp, GP_PutPixel32bpp)
-GP_RetCode GP_FillTriangle(GP_Context * context, int x0, int y0, int x1, int y1, - int x2, int y2, GP_Pixel pixel) +void GP_FillTriangle(GP_Context * context, int x0, int y0, int x1, int y1, + int x2, int y2, GP_Pixel pixel) { - if (!context) - return GP_ENULLPTR; - if (!GP_IS_CONTEXT_VALID(context)) - return GP_EBADCONTEXT; + GP_CHECK_CONTEXT(context);
GP_FN_PER_BPP(GP_FillTriangle, context, x0, y0, x1, y1, x2, y2, pixel); }
-GP_RetCode GP_TFillTriangle(GP_Context* context, int x0, int y0, int x1, int y1, - int x2, int y2, GP_Pixel pixel) +void GP_TFillTriangle(GP_Context* context, int x0, int y0, int x1, int y1, + int x2, int y2, GP_Pixel pixel) { - if (!context) - return GP_ENULLPTR; - if (!GP_IS_CONTEXT_VALID(context)) - return GP_EBADCONTEXT; - + GP_CHECK_CONTEXT(context); + GP_TRANSFORM_POINT(context, x0, y0); GP_TRANSFORM_POINT(context, x1, y1); GP_TRANSFORM_POINT(context, x2, y2); - return GP_FillTriangle(context, x0, y0, x1, y1, x2, y2, pixel); + + GP_FillTriangle(context, x0, y0, x1, y1, x2, y2, pixel); } diff --git a/core/GP_FillTriangle.h b/core/GP_FillTriangle.h index c6a31e5..11e0b4f 100644 --- a/core/GP_FillTriangle.h +++ b/core/GP_FillTriangle.h @@ -29,10 +29,10 @@ #include "GP_Context.h" #include "GP_Common.h"
-GP_RetCode GP_FillTriangle(GP_Context *context, int x0, int y0, int x1, - int y1, int x2, int y2, GP_Pixel pixel); +void GP_FillTriangle(GP_Context *context, int x0, int y0, int x1, int y1, + int x2, int y2, GP_Pixel pixel);
-GP_RetCode GP_TFillTriangle(GP_Context *context, int x0, int y0, int x1, - int y1, int x2, int y2, GP_Pixel pixel); +void GP_TFillTriangle(GP_Context *context, int x0, int y0, int x1, int y1, + int x2, int y2, GP_Pixel pixel);
#endif /* GP_FILLTRIANGLE_H */ diff --git a/core/GP_FnPerBpp.h b/core/GP_FnPerBpp.h index 4b5a6e8..712d3b0 100644 --- a/core/GP_FnPerBpp.h +++ b/core/GP_FnPerBpp.h @@ -61,10 +61,8 @@ FN_NAME##32bpp(__VA_ARGS__); break; default: - return GP_ENOIMPL; + break; } -- return GP_ESUCCESS;
#define GP_FN_RET_PER_BPP(FN_NAME, ...) diff --git a/core/GP_HLine.c b/core/GP_HLine.c index 16a2df1..9e14052 100644 --- a/core/GP_HLine.c +++ b/core/GP_HLine.c @@ -36,50 +36,46 @@ DEF_HLINE_FN(GP_HLine16bpp, GP_Context *, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixel DEF_HLINE_FN(GP_HLine24bpp, GP_Context *, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels24bpp) DEF_HLINE_FN(GP_HLine32bpp, GP_Context *, GP_Pixel, GP_PIXEL_ADDR, GP_WritePixels32bpp)
-GP_RetCode GP_HLineXXY(GP_Context *context, int x0, int x1, int y, GP_Pixel pixel) +void GP_HLineXXY(GP_Context *context, int x0, int x1, int y, GP_Pixel pixel) { - if (!context) - return GP_ENULLPTR; - if (!GP_IS_CONTEXT_VALID(context)) - return GP_EBADCONTEXT; - + GP_CHECK_CONTEXT(context); + GP_FN_PER_BPP(GP_HLine, context, x0, x1, y, pixel); }
-GP_RetCode GP_HLineXYW(GP_Context *context, int x, int y, unsigned int w, - GP_Pixel pixel) +void GP_HLineXYW(GP_Context *context, int x, int y, unsigned int w, + GP_Pixel pixel) { + /* zero width: do not draw anything */ if (w == 0) - return GP_ESUCCESS; /* zero width: do not draw anything */ + return;
- return GP_HLineXXY(context, x, x + w - 1, y, pixel); + GP_HLineXXY(context, x, x + w - 1, y, pixel); }
-GP_RetCode GP_THLineXXY(GP_Context *context, int x0, int x1, int y, GP_Pixel pixel) +void GP_THLineXXY(GP_Context *context, int x0, int x1, int y, GP_Pixel pixel) { - if (!context) - return GP_ENULLPTR; - if (!GP_IS_CONTEXT_VALID(context)) - return GP_EBADCONTEXT; - + GP_CHECK_CONTEXT(context); + if (context->axes_swap) { GP_TRANSFORM_Y(context, x0); GP_TRANSFORM_Y(context, x1); GP_TRANSFORM_X(context, y); - return GP_VLine(context, y, x0, x1, pixel); + GP_VLine(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_TRANSFORM_X(context, x0); - GP_TRANSFORM_X(context, x1); - GP_TRANSFORM_Y(context, y); - return GP_HLine(context, x0, x1, y, pixel); }
-GP_RetCode GP_THLineXYW(GP_Context *context, int x, int y, unsigned int w, - GP_Pixel pixel) +void GP_THLineXYW(GP_Context *context, int x, int y, unsigned int w, + GP_Pixel pixel) { + /* zero width: do not draw anything */ if (w == 0) - return GP_ESUCCESS; /* zero width: do not draw anything */ + return;
- return GP_THLineXXY(context, x, x + w - 1, y, pixel); + GP_THLineXXY(context, x, x + w - 1, y, pixel); } diff --git a/core/GP_HLine.h b/core/GP_HLine.h index b625b84..7cdd11c 100644 --- a/core/GP_HLine.h +++ b/core/GP_HLine.h @@ -38,17 +38,15 @@ void GP_HLine16bpp(GP_Context *context, int x0, int x1, int y, GP_Pixel pixel); void GP_HLine24bpp(GP_Context *context, int x0, int x1, int y, GP_Pixel pixel); void GP_HLine32bpp(GP_Context *context, int x0, int x1, int y, GP_Pixel pixel);
-GP_RetCode GP_HLineXXY(GP_Context *context, int x0, int x1, int y, - GP_Pixel pixel); +void GP_HLineXXY(GP_Context *context, int x0, int x1, int y, GP_Pixel pixel);
-GP_RetCode GP_HLineXYW(GP_Context *context, int x, int y, unsigned int w, - GP_Pixel pixel); +void GP_HLineXYW(GP_Context *context, int x, int y, unsigned int w, + GP_Pixel pixel);
-GP_RetCode GP_THLineXXY(GP_Context *context, int x0, int x1, int y, - GP_Pixel pixel); +void GP_THLineXXY(GP_Context *context, int x0, int x1, int y, GP_Pixel pixel);
-GP_RetCode GP_THLineXYW(GP_Context *context, int x, int y, unsigned int w, - GP_Pixel pixel); +void GP_THLineXYW(GP_Context *context, int x, int y, unsigned int w, + GP_Pixel pixel);
/* default argument set is XXY */ #define GP_HLine GP_HLineXXY diff --git a/core/GP_Line.c b/core/GP_Line.c index dd6af18..d8f495f 100644 --- a/core/GP_Line.c +++ b/core/GP_Line.c @@ -36,26 +36,21 @@ DEF_LINE_FN(GP_Line16bpp, GP_Context *, GP_Pixel, GP_PutPixel16bpp) DEF_LINE_FN(GP_Line24bpp, GP_Context *, GP_Pixel, GP_PutPixel24bpp) DEF_LINE_FN(GP_Line32bpp, GP_Context *, GP_Pixel, GP_PutPixel32bpp)
-GP_RetCode GP_Line(GP_Context *context, int x0, int y0, int x1, int y1, - GP_Pixel pixel) +void GP_Line(GP_Context *context, int x0, int y0, int x1, int y1, + GP_Pixel pixel) { - if (!context) - return GP_ENULLPTR; - if (!GP_IS_CONTEXT_VALID(context)) - return GP_EBADCONTEXT; + GP_CHECK_CONTEXT(context);
GP_FN_PER_BPP(GP_Line, context, x0, y0, x1, y1, pixel); }
-GP_RetCode GP_TLine(GP_Context *context, int x0, int y0, int x1, int y1, - GP_Pixel pixel) +void GP_TLine(GP_Context *context, int x0, int y0, int x1, int y1, + GP_Pixel pixel) { - if (!context) - return GP_ENULLPTR; - if (!GP_IS_CONTEXT_VALID(context)) - return GP_EBADCONTEXT; - + GP_CHECK_CONTEXT(context); + GP_TRANSFORM_POINT(context, x0, y0); GP_TRANSFORM_POINT(context, x1, y1); - return GP_Line(context, x0, y0, x1, y1, pixel); + + GP_Line(context, x0, y0, x1, y1, pixel); } diff --git a/core/GP_Line.h b/core/GP_Line.h index 2c72f29..38c0290 100644 --- a/core/GP_Line.h +++ b/core/GP_Line.h @@ -39,10 +39,10 @@ void GP_Line24bpp(GP_Context *context, int x0, int y0, int x1, int y1, void GP_Line32bpp(GP_Context *context, int x0, int y0, int x1, int y1, GP_Pixel pixel);
-GP_RetCode GP_Line(GP_Context *context, int x0, int y0, int x1, int y1, - GP_Pixel pixel); +void GP_Line(GP_Context *context, int x0, int y0, int x1, int y1, + GP_Pixel pixel);
-GP_RetCode GP_TLine(GP_Context *context, int x0, int y0, int x1, int y1, - GP_Pixel pixel); +void GP_TLine(GP_Context *context, int x0, int y0, int x1, int y1, + GP_Pixel pixel);
#endif /* GP_LINE_H */ diff --git a/core/GP_PutPixel.c b/core/GP_PutPixel.c index 32108da..5e62a5b 100644 --- a/core/GP_PutPixel.c +++ b/core/GP_PutPixel.c @@ -28,14 +28,12 @@ #include "GP_FnPerBpp.h"
#define DO_PUTPIXEL(bits) -GP_RetCode GP_PutPixel##bits##bpp(GP_Context *context, int x, int y, GP_Pixel pixel) +void GP_PutPixel##bits##bpp(GP_Context *context, int x, int y, GP_Pixel pixel) { if (GP_PIXEL_IS_CLIPPED(context, x, y)) - return GP_ESUCCESS; + return; GP_PUTPIXEL_##bits##BPP(context, x, y, pixel); -- return GP_ESUCCESS; } DO_PUTPIXEL(1) @@ -50,23 +48,18 @@ DO_PUTPIXEL(32) * A generic PutPixel call that automatically determines the number of * bits per pixel. */ -GP_RetCode GP_PutPixel(GP_Context *context, int x, int y, GP_Pixel pixel) +void GP_PutPixel(GP_Context *context, int x, int y, GP_Pixel pixel) { - if (!context) - return GP_ENULLPTR; - if (!GP_IS_CONTEXT_VALID(context)) - return GP_EBADCONTEXT; + GP_CHECK_CONTEXT(context);
GP_FN_PER_BPP(GP_PutPixel, context, x, y, pixel); }
-GP_RetCode GP_TPutPixel(GP_Context *context, int x, int y, GP_Pixel pixel) +void GP_TPutPixel(GP_Context *context, int x, int y, GP_Pixel pixel) { - if (!context) - return GP_ENULLPTR; - if (!GP_IS_CONTEXT_VALID(context)) - return GP_EBADCONTEXT; + GP_CHECK_CONTEXT(context);
GP_TRANSFORM_POINT(context, x, y); - return GP_PutPixel(context, x, y, pixel); + + GP_PutPixel(context, x, y, pixel); } diff --git a/core/GP_PutPixel.h b/core/GP_PutPixel.h index c0be692..fe5b219 100644 --- a/core/GP_PutPixel.h +++ b/core/GP_PutPixel.h @@ -88,22 +88,22 @@ /* * Safe functions, that checks clipping. */ -GP_RetCode GP_PutPixel1bpp(GP_Context *context, int x, int y, GP_Pixel pixel); -GP_RetCode GP_PutPixel2bpp(GP_Context *context, int x, int y, GP_Pixel pixel); -GP_RetCode GP_PutPixel4bpp(GP_Context *context, int x, int y, GP_Pixel pixel); -GP_RetCode GP_PutPixel8bpp(GP_Context *context, int x, int y, GP_Pixel pixel); -GP_RetCode GP_PutPixel16bpp(GP_Context *context, int x, int y, GP_Pixel pixel); -GP_RetCode GP_PutPixel24bpp(GP_Context *context, int x, int y, GP_Pixel pixel); -GP_RetCode GP_PutPixel32bpp(GP_Context *context, int x, int y, GP_Pixel pixel); +void GP_PutPixel1bpp(GP_Context *context, int x, int y, GP_Pixel pixel); +void GP_PutPixel2bpp(GP_Context *context, int x, int y, GP_Pixel pixel); +void GP_PutPixel4bpp(GP_Context *context, int x, int y, GP_Pixel pixel); +void GP_PutPixel8bpp(GP_Context *context, int x, int y, GP_Pixel pixel); +void GP_PutPixel16bpp(GP_Context *context, int x, int y, GP_Pixel pixel); +void GP_PutPixel24bpp(GP_Context *context, int x, int y, GP_Pixel pixel); +void GP_PutPixel32bpp(GP_Context *context, int x, int y, GP_Pixel pixel);
/* * General putpixel. */ -GP_RetCode GP_PutPixel(GP_Context *context, int x, int y, GP_Pixel pixel); +void GP_PutPixel(GP_Context *context, int x, int y, GP_Pixel pixel);
/* * General rotated putpixel. */ -GP_RetCode GP_TPutPixel(GP_Context *context, int x, int y, GP_Pixel pixel); +void GP_TPutPixel(GP_Context *context, int x, int y, GP_Pixel pixel);
#endif /* GP_PUTPIXEL_H */ diff --git a/core/GP_Rect.c b/core/GP_Rect.c index ffeb886..08cecc1 100644 --- a/core/GP_Rect.c +++ b/core/GP_Rect.c @@ -25,51 +25,41 @@
#include "GP.h"
-GP_RetCode GP_RectXYXY(GP_Context *context, int x0, int y0, int x1, int y1, - GP_Pixel pixel) +void GP_RectXYXY(GP_Context *context, int x0, int y0, int x1, int y1, + GP_Pixel pixel) { - if (!context) - return GP_ENULLPTR; - if (!GP_IS_CONTEXT_VALID(context)) - return GP_EBADCONTEXT; + 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); - - return GP_ESUCCESS; }
-GP_RetCode GP_RectXYWH(GP_Context *context, int x, int y, - unsigned int w, unsigned int h, GP_Pixel pixel) +void GP_RectXYWH(GP_Context *context, int x, int y, + unsigned int w, unsigned int h, GP_Pixel pixel) { - if (!context) - return GP_ENULLPTR; - if (!GP_IS_CONTEXT_VALID(context)) - return GP_EBADCONTEXT; + 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); - - return GP_ESUCCESS; }
-GP_RetCode GP_TRectXYXY(GP_Context *context, int x0, int y0, int x1, int y1, - GP_Pixel pixel) +void GP_TRectXYXY(GP_Context *context, int x0, int y0, int x1, int y1, + GP_Pixel pixel) { + GP_CHECK_CONTEXT(context); + GP_TRANSFORM_POINT(context, x0, y0); GP_TRANSFORM_POINT(context, x1, y1); - return GP_Rect(context, x0, y0, x1, y1, pixel); + + GP_RectXYXY(context, x0, y0, x1, y1, pixel); }
-GP_RetCode GP_TRectXYWH(GP_Context *context, int x, int y, - unsigned int w, unsigned int h, GP_Pixel pixel) +void GP_TRectXYWH(GP_Context *context, int x, int y, + unsigned int w, unsigned int h, GP_Pixel pixel) { - int x1 = x + w; - int y1 = y + h; - return GP_TRect(context, x, y, x1, y1, pixel); + GP_TRectXYXY(context, x, y, x + w, y + h, pixel); } - diff --git a/core/GP_Rect.h b/core/GP_Rect.h index 4e97a90..63ef486 100644 --- a/core/GP_Rect.h +++ b/core/GP_Rect.h @@ -28,17 +28,17 @@
#include "GP_Context.h"
-GP_RetCode GP_RectXYXY(GP_Context *context, int x0, int y0, int x1, int y1, - GP_Pixel pixel); +void GP_RectXYXY(GP_Context *context, int x0, int y0, int x1, int y1, + GP_Pixel pixel);
-GP_RetCode GP_RectXYWH(GP_Context *context, int x, int y, - unsigned int w, unsigned int h, GP_Pixel pixel); +void GP_RectXYWH(GP_Context *context, int x, int y, + unsigned int w, unsigned int h, GP_Pixel pixel);
-GP_RetCode GP_TRectXYXY(GP_Context *context, int x0, int y0, int x1, int y1, - GP_Pixel pixel); +void GP_TRectXYXY(GP_Context *context, int x0, int y0, int x1, int y1, + GP_Pixel pixel);
-GP_RetCode GP_TRectXYWH(GP_Context *context, int x, int y, - unsigned int w, unsigned int h, GP_Pixel pixel); +void GP_TRectXYWH(GP_Context *context, int x, int y, + unsigned int w, unsigned int h, GP_Pixel pixel);
/* The XYXY argument set is the default */ #define GP_Rect GP_RectXYXY diff --git a/core/GP_Symbol.c b/core/GP_Symbol.c index 4b35c6e..95bd3b8 100644 --- a/core/GP_Symbol.c +++ b/core/GP_Symbol.c @@ -53,31 +53,23 @@
#define DO_DECREMENT(a) do { if ((a) == 0) - return GP_ESUCCESS; + return; (a)--; } while (0)
/* * Generate code for triangle */ -#define TRIANGLE(context, base, x, y, w, h, fn_pref, - TRIANGLE_PARAMS, TETRAGON_PARAMS, pixel) do { - if (base % 2) - return fn_pref##Tetragon(context, - TETRAGON_PARAMS(x, y, w, h), - pixel); - else - return fn_pref##Triangle(context, - TRIANGLE_PARAMS(x, y, w, h), - pixel); +#define TRIANGLE(context, base, x, y, w, h, fn_pref, + TRIANGLE_PARAMS, TETRAGON_PARAMS, pixel) do { + if (base % 2) + fn_pref##Tetragon(context, TETRAGON_PARAMS(x, y, w, h), pixel) ;+ else + fn_pref##Triangle(context, TRIANGLE_PARAMS(x, y, w, h), pixel); } while (0)
-/* - * TODO: even sizes should have two pixes at the top to became symetrical - */ -GP_RetCode GP_Symbol(GP_Context *context, GP_SymbolType sym, - int x, int y, int w, int h, - GP_Pixel pixel) +void GP_Symbol(GP_Context *context, GP_SymbolType sym, + int x, int y, int w, int h, GP_Pixel pixel) { DO_DECREMENT(w); DO_DECREMENT(h); @@ -86,23 +78,26 @@ GP_RetCode GP_Symbol(GP_Context *context, GP_SymbolType sym, case GP_SYM_TRIANGLE_UP: 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_, 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); + break; case GP_SYM_TRIANGLE_RIGHT: TRIANGLE(context, h, x, y, w, h, GP_, DO_TRIANGLE_RIGHT, DO_TETRAGON_RIGHT, pixel); + break; default: - return GP_ENOIMPL; + break; } }
-GP_RetCode GP_FillSymbol(GP_Context *context, GP_SymbolType sym, - int x, int y, int w, int h, - GP_Pixel pixel) +void GP_FillSymbol(GP_Context *context, GP_SymbolType sym, + int x, int y, int w, int h, GP_Pixel pixel) { DO_DECREMENT(w); DO_DECREMENT(h); @@ -111,23 +106,26 @@ GP_RetCode GP_FillSymbol(GP_Context *context, GP_SymbolType sym, case GP_SYM_TRIANGLE_UP: 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_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); + break; case GP_SYM_TRIANGLE_RIGHT: TRIANGLE(context, h, x, y, w, h, GP_Fill, DO_TRIANGLE_RIGHT, DO_TETRAGON_RIGHT, pixel); + break; default: - return GP_ENOIMPL; + break; } }
-GP_RetCode GP_TSymbol(GP_Context *context, GP_SymbolType sym, - int x, int y, int w, int h, - GP_Pixel pixel) +void GP_TSymbol(GP_Context *context, GP_SymbolType sym, + int x, int y, int w, int h, GP_Pixel pixel) { DO_DECREMENT(w); DO_DECREMENT(h); @@ -136,23 +134,26 @@ GP_RetCode GP_TSymbol(GP_Context *context, GP_SymbolType sym, case GP_SYM_TRIANGLE_UP: TRIANGLE(context, w, x, y, w, h, GP_T, DO_TRIANGLE_UP, DO_TETRAGON_UP, pixel); + break; case GP_SYM_TRIANGLE_DOWN: TRIANGLE(context, w, x, y, w, h, GP_T, DO_TRIANGLE_DOWN, DO_TETRAGON_DOWN, pixel); + break; case GP_SYM_TRIANGLE_LEFT: TRIANGLE(context, h, x, y, w, h, GP_T, DO_TRIANGLE_LEFT, DO_TETRAGON_LEFT, pixel); + break; case GP_SYM_TRIANGLE_RIGHT: TRIANGLE(context, h, x, y, w, h, GP_T, DO_TRIANGLE_RIGHT, DO_TETRAGON_RIGHT, pixel); + break; default: - return GP_ENOIMPL; + break; } }
-GP_RetCode GP_TFillSymbol(GP_Context *context, GP_SymbolType sym, - int x, int y, int w, int h, - GP_Pixel pixel) +void GP_TFillSymbol(GP_Context *context, GP_SymbolType sym, + int x, int y, int w, int h, GP_Pixel pixel) { DO_DECREMENT(w); DO_DECREMENT(h); @@ -161,16 +162,20 @@ GP_RetCode GP_TFillSymbol(GP_Context *context, GP_SymbolType sym, case GP_SYM_TRIANGLE_UP: TRIANGLE(context, w, x, y, w, h, GP_TFill, DO_TRIANGLE_UP, DO_TETRAGON_UP, pixel); + break; case GP_SYM_TRIANGLE_DOWN: TRIANGLE(context, w, x, y, w, h, GP_TFill, DO_TRIANGLE_DOWN, DO_TETRAGON_DOWN, pixel); + break; case GP_SYM_TRIANGLE_LEFT: TRIANGLE(context, h, x, y, w, h, GP_TFill, DO_TRIANGLE_LEFT, DO_TETRAGON_LEFT, pixel); + break; case GP_SYM_TRIANGLE_RIGHT: TRIANGLE(context, h, x, y, w, h, GP_TFill, DO_TRIANGLE_RIGHT, DO_TETRAGON_RIGHT, pixel); + break; default: - return GP_ENOIMPL; + break; } } diff --git a/core/GP_Symbol.h b/core/GP_Symbol.h index 606ccc3..259bddb 100644 --- a/core/GP_Symbol.h +++ b/core/GP_Symbol.h @@ -42,20 +42,16 @@ typedef enum GP_SymbolType { GP_SYM_MAX, } GP_SymbolType;
-GP_RetCode GP_Symbol(GP_Context *context, GP_SymbolType sym, - int x, int y, int w, int h, - GP_Pixel pixel); +void GP_Symbol(GP_Context *context, GP_SymbolType sym, + int x, int y, int w, int h, GP_Pixel pixel);
-GP_RetCode GP_TSymbol(GP_Context *context, GP_SymbolType sym, - int x, int y, int w, int h, - GP_Pixel pixel); +void GP_TSymbol(GP_Context *context, GP_SymbolType sym, + int x, int y, int w, int h, GP_Pixel pixel);
-GP_RetCode GP_FillSymbol(GP_Context *context, GP_SymbolType sym, - int x, int y, int w, int h, - GP_Pixel pixel); +void GP_FillSymbol(GP_Context *context, GP_SymbolType sym, + int x, int y, int w, int h, GP_Pixel pixel);
-GP_RetCode GP_TFillSymbol(GP_Context *context, GP_SymbolType sym, - int x, int y, int w, int h, - GP_Pixel pixel); +void GP_TFillSymbol(GP_Context *context, GP_SymbolType sym, + int x, int y, int w, int h, GP_Pixel pixel);
#endif /* GP_SYMBOL_H */ diff --git a/core/GP_Tetragon.c b/core/GP_Tetragon.c index d85e862..4618002 100644 --- a/core/GP_Tetragon.c +++ b/core/GP_Tetragon.c @@ -25,34 +25,26 @@
#include "GP.h"
-GP_RetCode GP_Tetragon(GP_Context *context, int x0, int y0, int x1, int y1, - int x2, int y2, int x3, int y3, GP_Pixel pixel) +void GP_Tetragon(GP_Context *context, int x0, int y0, int x1, int y1, + int x2, int y2, int x3, int y3, GP_Pixel pixel) { - if (!context) - return GP_ENULLPTR; - if (!GP_IS_CONTEXT_VALID(context)) - return GP_EBADCONTEXT; + 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); - - return GP_ESUCCESS; }
-GP_RetCode GP_TTetragon(GP_Context *context, int x0, int y0, int x1, int y1, - int x2, int y2, int x3, int y3, GP_Pixel pixel) +void GP_TTetragon(GP_Context *context, int x0, int y0, int x1, int y1, + int x2, int y2, int x3, int y3, GP_Pixel pixel) { - if (!context) - return GP_ENULLPTR; - if (!GP_IS_CONTEXT_VALID(context)) - return GP_EBADCONTEXT; - + GP_CHECK_CONTEXT(context); + GP_TRANSFORM_POINT(context, x0, y0); GP_TRANSFORM_POINT(context, x1, y1); GP_TRANSFORM_POINT(context, x2, y2); GP_TRANSFORM_POINT(context, x3, y3);
- return GP_Tetragon(context, x0, y0, x1, y1, x2, y2, x3, y3, pixel); + GP_Tetragon(context, x0, y0, x1, y1, x2, y2, x3, y3, pixel); } diff --git a/core/GP_Tetragon.h b/core/GP_Tetragon.h index e5e380f..5ed30d0 100644 --- a/core/GP_Tetragon.h +++ b/core/GP_Tetragon.h @@ -28,10 +28,10 @@
#include "GP_Context.h"
-GP_RetCode GP_Tetragon(GP_Context *context, int x0, int y0, int x1, int y1, - int x2, int y2, int x3, int y3, GP_Pixel pixel); +void GP_Tetragon(GP_Context *context, int x0, int y0, int x1, int y1, + int x2, int y2, int x3, int y3, GP_Pixel pixel);
-GP_RetCode GP_TTetragon(GP_Context *context, int x0, int y0, int x1, int y1, - int x2, int y2, int x3, int y3, GP_Pixel pixel); +void GP_TTetragon(GP_Context *context, int x0, int y0, int x1, int y1, + int x2, int y2, int x3, int y3, GP_Pixel pixel);
#endif /* GP_TETRAGON_H */ diff --git a/core/GP_Text.c b/core/GP_Text.c index a057b45..e3bcbb2 100644 --- a/core/GP_Text.c +++ b/core/GP_Text.c @@ -42,12 +42,13 @@ 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_CHECK_CONTEXT(context); + if (style != NULL && style->font == NULL) return GP_ENULLPTR; - if (!context || !str) + if (str == NULL) return GP_ENULLPTR; - if (!GP_IS_CONTEXT_VALID(context)) - return GP_EBADCONTEXT; +
if (style == NULL) style = &DefaultStyle; @@ -87,18 +88,20 @@ GP_RetCode GP_Text(GP_Context *context, const GP_TextStyle *style, }
GP_FN_PER_BPP(GP_Text, 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) { + GP_CHECK_CONTEXT(context); + if (style != NULL && style->font == NULL) return GP_ENULLPTR; - if (!context || !str) + if (str == NULL) return GP_ENULLPTR; - if (!GP_IS_CONTEXT_VALID(context)) - return GP_EBADCONTEXT; - + if (style == NULL) style = &DefaultStyle;
@@ -143,13 +146,12 @@ GP_RetCode GP_TText(GP_Context *context, const GP_TextStyle *style, 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_CHECK_CONTEXT(context);
if (style != NULL && style->font == NULL) return GP_ENULLPTR; - if (!context || !str) + if (str == NULL) return GP_ENULLPTR; - if (!GP_IS_CONTEXT_VALID(context)) - return GP_EBADCONTEXT;
if (style == NULL) style = &DefaultStyle; @@ -167,13 +169,12 @@ GP_RetCode GP_BoxCenteredText(GP_Context *context, const GP_TextStyle *style, 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_CHECK_CONTEXT(context);
if (style != NULL && style->font == NULL) return GP_ENULLPTR; - if (!context || !str) + if (str == NULL) return GP_ENULLPTR; - if (!GP_IS_CONTEXT_VALID(context)) - return GP_EBADCONTEXT;
if (style == NULL) style = &DefaultStyle; diff --git a/core/GP_TextStyle.c b/core/GP_TextStyle.c index 5149c01..3c7fc00 100644 --- a/core/GP_TextStyle.c +++ b/core/GP_TextStyle.c @@ -25,16 +25,12 @@
#include "GP.h"
-GP_RetCode GP_DefaultTextStyle(GP_TextStyle *style) +void GP_DefaultTextStyle(GP_TextStyle *style) { - if (!style) - return GP_ENULLPTR; - style->font = &GP_default_console_font; style->pixel_xspace = 0; style->pixel_yspace = 0; style->pixel_xmul = 1; style->pixel_ymul = 1; style->char_xspace = 0; - return GP_ESUCCESS; } diff --git a/core/GP_TextStyle.h b/core/GP_TextStyle.h index 75c8719..7327ae4 100644 --- a/core/GP_TextStyle.h +++ b/core/GP_TextStyle.h @@ -60,6 +60,6 @@ typedef struct { /* * Initalize text style to the default values. */ -GP_RetCode GP_DefaultTextStyle(GP_TextStyle *style); +void GP_DefaultTextStyle(GP_TextStyle *style);
#endif /* GP_TEXTSTYLE_H */ diff --git a/core/GP_Triangle.c b/core/GP_Triangle.c index 041d35d..82caa55 100644 --- a/core/GP_Triangle.c +++ b/core/GP_Triangle.c @@ -25,32 +25,24 @@
#include "GP.h"
-GP_RetCode GP_Triangle(GP_Context *context, int x0, int y0, int x1, int y1, - int x2, int y2, GP_Pixel pixel) +void GP_Triangle(GP_Context *context, int x0, int y0, int x1, int y1, + int x2, int y2, GP_Pixel pixel) { - if (!context) - return GP_ENULLPTR; - if (!GP_IS_CONTEXT_VALID(context)) - return GP_EBADCONTEXT; + 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); - - return GP_ESUCCESS; }
-GP_RetCode GP_TTriangle(GP_Context *context, int x0, int y0, int x1, int y1, - int x2, int y2, GP_Pixel pixel) +void GP_TTriangle(GP_Context *context, int x0, int y0, int x1, int y1, + int x2, int y2, GP_Pixel pixel) { - if (!context) - return GP_ENULLPTR; - if (!GP_IS_CONTEXT_VALID(context)) - return GP_EBADCONTEXT; - + GP_CHECK_CONTEXT(context); + GP_TRANSFORM_POINT(context, x0, y0); GP_TRANSFORM_POINT(context, x1, y1); GP_TRANSFORM_POINT(context, x2, y2);
- return GP_Triangle(context, x0, y0, x1, y1, x2, y2, pixel); + GP_Triangle(context, x0, y0, x1, y1, x2, y2, pixel); } diff --git a/core/GP_Triangle.h b/core/GP_Triangle.h index c44294a..3684b11 100644 --- a/core/GP_Triangle.h +++ b/core/GP_Triangle.h @@ -28,10 +28,10 @@
#include "GP_Context.h"
-GP_RetCode GP_Triangle(GP_Context *context, int x0, int y0, int x1, int y1, - int x2, int y2, GP_Pixel pixel); +void GP_Triangle(GP_Context *context, int x0, int y0, int x1, int y1, + int x2, int y2, GP_Pixel pixel);
-GP_RetCode GP_TTriangle(GP_Context *context, int x0, int y0, int x1, int y1, - int x2, int y2, GP_Pixel pixel); +void GP_TTriangle(GP_Context *context, int x0, int y0, int x1, int y1, + int x2, int y2, GP_Pixel pixel);
#endif /* GP_TRIANGLE_H */ diff --git a/core/GP_VLine.c b/core/GP_VLine.c index 73aab05..91e59b3 100644 --- a/core/GP_VLine.c +++ b/core/GP_VLine.c @@ -36,50 +36,46 @@ DEF_VLINE_FN(GP_VLine16bpp, GP_Context *, GP_Pixel, GP_PutPixel16bpp) DEF_VLINE_FN(GP_VLine24bpp, GP_Context *, GP_Pixel, GP_PutPixel24bpp) DEF_VLINE_FN(GP_VLine32bpp, GP_Context *, GP_Pixel, GP_PutPixel32bpp)
-GP_RetCode GP_VLineXYY(GP_Context *context, int x, int y0, int y1, GP_Pixel pixel) +void GP_VLineXYY(GP_Context *context, int x, int y0, int y1, GP_Pixel pixel) { - if (!context) - return GP_ENULLPTR; - if (!GP_IS_CONTEXT_VALID(context)) - return GP_EBADCONTEXT; + GP_CHECK_CONTEXT(context);
GP_FN_PER_BPP(GP_VLine, context, x, y0, y1, pixel); }
-GP_RetCode GP_VLineXYH(GP_Context *context, int x, int y, unsigned int height, - GP_Pixel pixel) +void GP_VLineXYH(GP_Context *context, int x, int y, unsigned int height, + GP_Pixel pixel) { + /* zero height: do not draw anything */ if (height == 0) - return GP_ESUCCESS; /* zero height: do not draw anything */ + return;
- return GP_VLineXYY(context, x, y, y + height - 1, pixel); + GP_VLineXYY(context, x, y, y + height - 1, pixel); }
-GP_RetCode GP_TVLineXYY(GP_Context *context, int x, int y0, int y1, GP_Pixel pixel) +void GP_TVLineXYY(GP_Context *context, int x, int y0, int y1, GP_Pixel pixel) { - if (!context) - return GP_ENULLPTR; - if (!GP_IS_CONTEXT_VALID(context)) - return GP_EBADCONTEXT; - + GP_CHECK_CONTEXT(context); + if (context->axes_swap) { GP_TRANSFORM_Y(context, x); GP_TRANSFORM_X(context, y0); GP_TRANSFORM_X(context, y1); - return GP_HLine(context, y0, y1, x, pixel); + GP_HLine(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_TRANSFORM_X(context, x); - GP_TRANSFORM_Y(context, y0); - GP_TRANSFORM_Y(context, y1); - return GP_VLine(context, x, y0, y1, pixel); }
-GP_RetCode GP_TVLineXYH(GP_Context *context, int x, int y, unsigned int height, - GP_Pixel pixel) +void GP_TVLineXYH(GP_Context *context, int x, int y, unsigned int height, + GP_Pixel pixel) { + /* zero height: do not draw anything */ if (height == 0) - return GP_ESUCCESS; /* zero height: do not draw anything */ + return;
- return GP_TVLineXYY(context, x, y, y + height - 1, pixel); + GP_TVLineXYY(context, x, y, y + height - 1, pixel); } diff --git a/core/GP_VLine.h b/core/GP_VLine.h index f5458d6..3f943ec 100644 --- a/core/GP_VLine.h +++ b/core/GP_VLine.h @@ -28,17 +28,15 @@
#include "GP_Context.h"
-GP_RetCode GP_VLineXYY(GP_Context *context, int x, int y0, int y1, - GP_Pixel pixel); +void GP_VLineXYY(GP_Context *context, int x, int y0, int y1, GP_Pixel pixel);
-GP_RetCode GP_VLineXYH(GP_Context *context, int x, int y, - unsigned int height, GP_Pixel pixel); +void GP_VLineXYH(GP_Context *context, int x, int y, + unsigned int height, GP_Pixel pixel);
-GP_RetCode GP_TVLineXYY(GP_Context *context, int x, int y0, int y1, - GP_Pixel pixel); +void GP_TVLineXYY(GP_Context *context, int x, int y0, int y1, GP_Pixel pixel);
-GP_RetCode GP_TVLineXYH(GP_Context *context, int x, int y, - unsigned int height, GP_Pixel pixel); +void GP_TVLineXYH(GP_Context *context, int x, int y, + unsigned int height, GP_Pixel pixel);
/* default argument set is XYY */ #define GP_VLine GP_VLineXYY diff --git a/filters/GP_Rotate.c b/filters/GP_Rotate.c index 7586cc3..0d46a9c 100644 --- a/filters/GP_Rotate.c +++ b/filters/GP_Rotate.c @@ -78,6 +78,8 @@ GP_RetCode GP_MirrorV(GP_Context *context) return GP_ENULLPTR;
GP_FN_PER_BPP(GP_MirrorV, context); + + return GP_ESUCCESS; }
DEF_ROTATECW_FN(GP_RotateCW1bpp, GP_Context *, GP_PUTPIXEL_1BPP, GP_GETPIXEL_1BPP)
http://repo.or.cz/w/gfxprim.git/commit/4df5151ae9400f76567697fd5c88917d9ee79...
commit 4df5151ae9400f76567697fd5c88917d9ee79229 Author: Cyril Hrubis metan@ucw.cz Date: Mon Apr 25 15:31:22 2011 +0200
The filled triangle should use GP_TPutPixel() not GP_PutPixel().
diff --git a/targets/sdl/tests/shapetest.c b/targets/sdl/tests/shapetest.c index 806135f..6e17cc1 100644 --- a/targets/sdl/tests/shapetest.c +++ b/targets/sdl/tests/shapetest.c @@ -129,9 +129,9 @@ 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_PutPixel(&context, x0, y0, green); - GP_PutPixel(&context, x1, y1, green); - GP_PutPixel(&context, x2, y2, green); + GP_TPutPixel(&context, x0, y0, green); + GP_TPutPixel(&context, x1, y1, green); + GP_TPutPixel(&context, x2, y2, green);
if (outline == 1) GP_TTriangle(&context, x0, y0, x1, y1, x2, y2, yellow);
http://repo.or.cz/w/gfxprim.git/commit/31bfb14e08456f70a7823efa3832ad4e3ffbb...
commit 31bfb14e08456f70a7823efa3832ad4e3ffbb9d3 Author: Cyril Hrubis metan@ucw.cz Date: Mon Apr 25 14:53:40 2011 +0200
Remove unused macros.
diff --git a/core/GP_WritePixel.h b/core/GP_WritePixel.h index 292e05f..2910111 100644 --- a/core/GP_WritePixel.h +++ b/core/GP_WritePixel.h @@ -31,43 +31,6 @@ #include <unistd.h>
/* - * Macros for writing a single pixel value to the specified address, - * provided that the target buffer has 8, 16, 24, or 32 bytes per pixel. - */ - -#define GP_WritePixel8bpp(ptr, pixel) { - *((uint8_t *) ptr) = (uint8_t) pixel; -} - -#define GP_WritePixel16bpp(ptr, pixel) { - *((uint16_t *) ptr) = (uint16_t) pixel; -} - -#if __BYTE_ORDER == __BIG_ENDIAN - -#define GP_WritePixel24bpp(ptr, pixel) { - ((uint8_t *) ptr)[0] = (pixel >> 16) & 0xff; - ((uint8_t *) ptr)[1] = (pixel >> 8) & 0xff; - ((uint8_t *) ptr)[2] = pixel & 0xff; -} - -#elif __BYTE_ORDER == __LITTLE_ENDIAN - -#define GP_WritePixel24bpp(ptr, pixel) { - ((uint8_t *) ptr)[0] = pixel & 0xff; - ((uint8_t *) ptr)[1] = (pixel >> 8) & 0xff; - ((uint8_t *) ptr)[2] = (pixel >> 16) & 0xff; -} - -#else -#error "Could not detect machine endianity" -#endif - -#define GP_WritePixel32bpp(ptr, pixel) { - *((uint32_t *) ptr) = (uint32_t) pixel; -} - -/* * Calls for writing a linear block of pixels. */
-----------------------------------------------------------------------
Summary of changes: core/GP_Circle.c | 23 ++++++--------- core/GP_Circle.h | 8 ++-- core/GP_Context.h | 9 ------ core/GP_Ellipse.c | 23 ++++++--------- core/GP_Ellipse.h | 8 ++-- core/GP_Fill.c | 6 ++- core/GP_Fill.h | 2 +- core/GP_FillCircle.c | 23 ++++++--------- core/GP_FillCircle.h | 8 ++-- core/GP_FillEllipse.c | 23 ++++++--------- core/GP_FillEllipse.h | 8 ++-- core/GP_FillRect.c | 43 +++++++++++---------------- core/GP_FillRect.h | 16 +++++----- core/GP_FillTetragon.c | 24 +++++---------- core/GP_FillTetragon.h | 9 ++--- core/GP_FillTriangle.c | 23 ++++++--------- core/GP_FillTriangle.h | 8 ++-- core/GP_FnPerBpp.h | 4 +-- core/GP_HLine.c | 48 ++++++++++++++---------------- core/GP_HLine.h | 14 ++++----- core/GP_Line.c | 23 ++++++--------- core/GP_Line.h | 8 ++-- core/GP_PutPixel.c | 23 +++++--------- core/GP_PutPixel.h | 18 ++++++------ core/GP_Rect.c | 40 +++++++++---------------- core/GP_Rect.h | 16 +++++----- core/GP_Symbol.c | 65 ++++++++++++++++++++++------------------- core/GP_Symbol.h | 20 +++++------- core/GP_Tetragon.c | 24 +++++---------- core/GP_Tetragon.h | 8 ++-- core/GP_Text.c | 27 +++++++++-------- core/GP_TextStyle.c | 6 +--- core/GP_TextStyle.h | 2 +- core/GP_Triangle.c | 24 +++++---------- core/GP_Triangle.h | 8 ++-- core/GP_VLine.c | 46 +++++++++++++---------------- core/GP_VLine.h | 14 ++++----- core/GP_WritePixel.h | 37 ----------------------- filters/GP_Rotate.c | 2 + targets/sdl/tests/shapetest.c | 6 ++-- 40 files changed, 305 insertions(+), 442 deletions(-)
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.