Rename GP_Context -> GP_Pixmap
[gfxprim.git] / include / core / GP_Blit.h
blob10687e84b06e6d4a45bb09fefeffeda32554c8e8
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) 2011 Tomas Gavenciak <gavento@ucw.cz> *
20 * Copyright (C) 2011-2012 Cyril Hrubis <metan@ucw.cz> *
21 * *
22 *****************************************************************************/
26 These blits automatically converts pixel types, that's good (and fast), but
27 there is a catch. This works rather well when the number of colors per
28 pixel/color channel is increased (the gamma correction is still on TODO).
29 However when the number of colors is decreased it's generally better to use
30 dithering, which will yield into far better (you can use Floyd Steinberg
31 filter for that).
33 Also variants without the _Raw suffix do honor the rotation flags, that may
34 get a little tricky as the flags for rotation are put together but don't
35 worry althouth there is some algebra involved the result is quite intuitive.
39 #ifndef CORE_GP_BLIT_H
40 #define CORE_GP_BLIT_H
43 * Blits rectangle from src defined by x0, y0, x1, y1 (x1, y1 included) to dst
44 * starting on x2, y2.
46 void GP_BlitXYXY(const GP_Pixmap *src,
47 GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1,
48 GP_Pixmap *dst, GP_Coord x2, GP_Coord y2);
51 * Clipped variant. Could handle destination coordinates outside of the
52 * destination rectangle (both possitive and negative). Source larger than
53 * destination and so.
55 void GP_BlitXYXY_Clipped(const GP_Pixmap *src,
56 GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1,
57 GP_Pixmap *dst, GP_Coord x2, GP_Coord y2);
60 * Blits rectangle from src defined by x0, y0, w0, h0 (uses w0 x h0 pixels) to
61 * dst starting on x2, y2.
63 void GP_BlitXYWH(const GP_Pixmap *src,
64 GP_Coord x0, GP_Coord y0, GP_Size w0, GP_Size h0,
65 GP_Pixmap *dst, GP_Coord x1, GP_Coord y1);
68 * Clipped variant. Could handle destination coordinates outside of the
69 * destination rectangle (both possitive and negative). Source larger than
70 * destination and so.
72 void GP_BlitXYWH_Clipped(const GP_Pixmap *src,
73 GP_Coord x0, GP_Coord y0, GP_Size w0, GP_Size h0,
74 GP_Pixmap *dst, GP_Coord x1, GP_Coord y1);
76 /* The default is XYWH */
77 static inline void GP_Blit(const GP_Pixmap *src,
78 GP_Coord x0, GP_Coord y0,
79 GP_Size w0, GP_Size h0,
80 GP_Pixmap *dst, GP_Coord x1, GP_Coord y1)
82 GP_BlitXYWH(src, x0, y0, w0, h0, dst, x1, y1);
85 static inline void GP_Blit_Clipped(const GP_Pixmap *src,
86 GP_Coord x0, GP_Coord y0,
87 GP_Size w0, GP_Size h0,
88 GP_Pixmap *dst, GP_Coord x1, GP_Coord y1)
90 GP_BlitXYWH_Clipped(src, x0, y0, w0, h0, dst, x1, y1);
94 * Same as GP_BlitXYXY but doesn't respect rotations. Faster (for now).
96 void GP_BlitXYXY_Raw(const GP_Pixmap *src,
97 GP_Coord x0, GP_Coord y0, GP_Coord x1, GP_Coord y1,
98 GP_Pixmap *dst, GP_Coord x2, GP_Coord y2);
101 * Same as GP_BlitXYWH but doesn't respect rotations. Faster (for now).
103 void GP_BlitXYWH_Raw(const GP_Pixmap *src,
104 GP_Coord x0, GP_Coord y0, GP_Size w0, GP_Size h0,
105 GP_Pixmap *dst, GP_Coord x2, GP_Coord y2);
108 * Same as GP_Blit but doesn't respect rotations. Faster (for now).
110 static inline void GP_Blit_Raw(const GP_Pixmap *src,
111 GP_Coord x0, GP_Coord y0,
112 GP_Size w0, GP_Size h0,
113 GP_Pixmap *dst, GP_Coord x1, GP_Coord y1)
115 GP_BlitXYWH_Raw(src, x0, y0, w0, h0, dst, x1, y1);
120 #endif /* CORE_GP_BLIT_H */