backends: Add support for timers to backends.
[gfxprim/pasky.git] / libs / gfx / GP_CircleSeg.c
blob4d7dc197298d1452d769166d87be328767a997a0
1 /*****************************************************************************
2 * This file is part of gfxprim library. *
3 * *
4 * Gfxprim is free software; you can redistribute it and/or *
5 * modify it under the terms of the GNU Lesser General Public *
6 * License as published by the Free Software Foundation; either *
7 * version 2.1 of the License, or (at your option) any later version. *
8 * *
9 * Gfxprim is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
12 * Lesser General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU Lesser General Public *
15 * License along with gfxprim; if not, write to the Free Software *
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
17 * Boston, MA 02110-1301 USA *
18 * *
19 * Copyright (C) 2009-2011 Jiri "BlueBear" Dluhos *
20 * <jiri.bluebear.dluhos@gmail.com> *
21 * *
22 * Copyright (C) 2009-2012 Cyril Hrubis <metan@ucw.cz> *
23 * *
24 *****************************************************************************/
26 #include "core/GP_GetPutPixel.h"
27 #include "core/GP_FnPerBpp.h"
29 #include "gfx/GP_CircleSeg.h"
30 #include "gfx/GP_HLine.h"
32 #include "algo/CircleSeg.algo.h"
34 static uint8_t transform_segments(GP_Context *context, uint8_t seg_flags)
36 uint8_t seg1 = seg_flags & GP_CIRCLE_SEG1;
37 uint8_t seg2 = seg_flags & GP_CIRCLE_SEG2;
38 uint8_t seg3 = seg_flags & GP_CIRCLE_SEG3;
39 uint8_t seg4 = seg_flags & GP_CIRCLE_SEG4;
41 if (context->axes_swap)
42 GP_SWAP(seg1, seg3);
44 if (context->x_swap) {
45 GP_SWAP(seg1, seg2);
46 GP_SWAP(seg3, seg4);
49 if (context->y_swap) {
50 GP_SWAP(seg1, seg4);
51 GP_SWAP(seg2, seg3);
54 seg1 = seg1 ? GP_CIRCLE_SEG1 : 0;
55 seg2 = seg2 ? GP_CIRCLE_SEG2 : 0;
56 seg3 = seg3 ? GP_CIRCLE_SEG3 : 0;
57 seg4 = seg4 ? GP_CIRCLE_SEG4 : 0;
59 return seg1|seg2|seg3|seg4;
62 /* Generate drawing functions for various bit depths. */
63 GP_DEF_DRAW_FN_PER_BPP(GP_CircleSeg_Raw, DEF_CIRCLE_SEG_FN)
65 void GP_CircleSeg_Raw(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
66 GP_Size r, uint8_t seg_flag, GP_Pixel pixel)
68 GP_CHECK_CONTEXT(context);
70 GP_FN_PER_BPP_CONTEXT(GP_CircleSeg_Raw, context, context,
71 xcenter, ycenter, r, seg_flag, pixel);
74 void GP_CircleSeg(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
75 GP_Size r, uint8_t seg_flag, GP_Pixel pixel)
77 GP_CHECK_CONTEXT(context);
79 GP_TRANSFORM_POINT(context, xcenter, ycenter);
81 GP_CircleSeg_Raw(context, xcenter, ycenter, r,
82 transform_segments(context, seg_flag), pixel);
86 #include "algo/FillCircle.algo.h"
88 GP_DEF_FILL_FN_PER_BPP(GP_FillCircle_Raw, DEF_FILLCIRCLE_FN)
90 void GP_FillCircle_Raw(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
91 GP_Size r, GP_Pixel pixel)
93 GP_CHECK_CONTEXT(context);
95 GP_FN_PER_BPP_CONTEXT(GP_FillCircle_Raw, context, context,
96 xcenter, ycenter, r, pixel);
99 void GP_FillCircle(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
100 GP_Size r, GP_Pixel pixel)
102 GP_CHECK_CONTEXT(context);
104 GP_TRANSFORM_POINT(context, xcenter, ycenter);
106 GP_FillCircle_Raw(context, xcenter, ycenter, r, pixel);