Rename GP_Context -> GP_Pixmap
[gfxprim.git] / include / core / GP_FnPerBpp.h
blob08e161ba405682de20124ea8e758cea8639e7c82
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-2010 Jiri "BlueBear" Dluhos *
20 * <jiri.bluebear.dluhos@gmail.com> *
21 * *
22 * Copyright (C) 2009-2011 Cyril Hrubis <metan@ucw.cz> *
23 * *
24 *****************************************************************************/
27 * Macros that generate a switch-case block that calls various variants
28 * of the specified function depending on the bit depth (bpp).
30 * For function name y and x bpp, the function called will be
31 * y_xBPP, resp y_xBPP_LE (or _BE; the bit-endian) for x<8.
33 * The functions branch either on bpp and bit_endian, type of given
34 * GP_Pixmap or given GP_PixelType.
36 * Extra arguments are arguments to be passed to the function.
37 * Note that if the function takes the pixmap/type/bpp as an argument,
38 * you still need to provide it in __VA_ARGS__
40 * The GP_FN_PER_* variants ignore the return value of the called function.
41 * The GP_FN_RET_PER_* variants "return"s the value returned by the function.
44 #ifndef GP_FN_PER_BPP_H
45 #define GP_FN_PER_BPP_H
47 #include "GP_FnPerBpp.gen.h"
50 * Branch on GP_Pixmap argument.
52 #define GP_FN_PER_BPP_PIXMAP(FN_NAME, pixmap, ...) \
53 GP_FN_PER_BPP(FN_NAME, (pixmap)->bpp, (pixmap)->bit_endian, __VA_ARGS__)
56 * Branch on GP_PixelType argument.
58 #define GP_FN_PER_BPP_PIXELTYPE(FN_NAME, type, ...) \
59 GP_FN_PER_BPP(FN_NAME, GP_PixelTypes[type].size, GP_PixelTypes[type].bit_endian, __VA_ARGS__)
61 * Branch on GP_Pixmap argument.
63 #define GP_FN_RET_PER_BPP_PIXMAP(FN_NAME, pixmap, ...) \
64 GP_FN_RET_PER_BPP(FN_NAME, (pixmap)->bpp, (pixmap)->bit_endian, __VA_ARGS__)
67 * Branch on GP_PixelType argument.
69 #define GP_FN_RET_PER_BPP_PIXELTYPE(FN_NAME, type, ...) \
70 GP_FN_RET_PER_BPP(FN_NAME, GP_PixelTypes[type].size, GP_PixelTypes[type].bit_endian, __VA_ARGS__)
73 * Macros that gets MACRO template for drawing function and generates drawing
74 * functions for each BPP.
76 * This functions are later used by GP_FN_PER_BPP_PIXMAP() to generate one
77 * drawing function for all BPP Yay!
79 #define GP_DEF_DRAW_FN_PER_BPP(fname, MACRO_NAME) \
80 GP_DEF_FN_PER_BPP(fname, MACRO_NAME, GP_PutPixel_Raw_Clipped_)
82 #define GP_DEF_FILL_FN_PER_BPP(fname, MACRO_NAME) \
83 GP_DEF_FN_PER_BPP(fname, MACRO_NAME, GP_HLine_Raw_)
85 #define GP_DEF_FN_FOR_BPP(fname, MACRO_NAME, fdraw, bpp) \
86 MACRO_NAME(fname##_##bpp, GP_Pixmap *, GP_Pixel, fdraw##bpp)
88 #endif /* GP_FN_PER_BPP_H */