zap qemu_egl_has_ext in include/ui/egl-helpers.h
[qemu/kevin.git] / hw / display / milkymist-vgafb_template.h
blob48837809eb0c43844dc2599192f0f75c6277c0b4
1 /*
2 * QEMU model of the Milkymist VGA framebuffer.
4 * Copyright (c) 2010 Michael Walle <michael@walle.cc>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
21 #if BITS == 8
22 #define COPY_PIXEL(to, r, g, b) \
23 do { \
24 *to = rgb_to_pixel8(r, g, b); \
25 to += 1; \
26 } while (0)
27 #elif BITS == 15
28 #define COPY_PIXEL(to, r, g, b) \
29 do { \
30 *(uint16_t *)to = rgb_to_pixel15(r, g, b); \
31 to += 2; \
32 } while (0)
33 #elif BITS == 16
34 #define COPY_PIXEL(to, r, g, b) \
35 do { \
36 *(uint16_t *)to = rgb_to_pixel16(r, g, b); \
37 to += 2; \
38 } while (0)
39 #elif BITS == 24
40 #define COPY_PIXEL(to, r, g, b) \
41 do { \
42 uint32_t tmp = rgb_to_pixel24(r, g, b); \
43 *(to++) = tmp & 0xff; \
44 *(to++) = (tmp >> 8) & 0xff; \
45 *(to++) = (tmp >> 16) & 0xff; \
46 } while (0)
47 #elif BITS == 32
48 #define COPY_PIXEL(to, r, g, b) \
49 do { \
50 *(uint32_t *)to = rgb_to_pixel32(r, g, b); \
51 to += 4; \
52 } while (0)
53 #else
54 #error unknown bit depth
55 #endif
57 static void glue(draw_line_, BITS)(void *opaque, uint8_t *d, const uint8_t *s,
58 int width, int deststep)
60 uint16_t rgb565;
61 uint8_t r, g, b;
63 while (width--) {
64 rgb565 = lduw_be_p(s);
65 r = ((rgb565 >> 11) & 0x1f) << 3;
66 g = ((rgb565 >> 5) & 0x3f) << 2;
67 b = ((rgb565 >> 0) & 0x1f) << 3;
68 COPY_PIXEL(d, r, g, b);
69 s += 2;
73 #undef BITS
74 #undef COPY_PIXEL