1 #pragma once
3 #include <kms++/kms++.h>
5 #include <kms++util/color.h>
6 #include <kms++util/strhelpers.h>
7 #include <kms++util/cpuframebuffer.h>
8 #include <kms++util/extcpuframebuffer.h>
9 #include <kms++util/stopwatch.h>
10 #include <kms++util/opts.h>
11 #include <kms++util/resourcemanager.h>
13 #include <cstdio>
14 #include <cstdlib>
16 namespace kms
17 {
18 class IMappedFramebuffer;
20 void draw_rgb_pixel(IMappedFramebuffer& buf, unsigned x, unsigned y, RGB color);
21 void draw_yuv422_macropixel(IMappedFramebuffer& buf, unsigned x, unsigned y, YUV yuv1, YUV yuv2);
22 void draw_yuv420_macropixel(IMappedFramebuffer& buf, unsigned x, unsigned y,
23 YUV yuv1, YUV yuv2, YUV yuv3, YUV yuv4);
24 void draw_rect(IMappedFramebuffer &fb, uint32_t x, uint32_t y, uint32_t w, uint32_t h, RGB color);
25 void draw_text(IMappedFramebuffer& buf, uint32_t x, uint32_t y, const std::string& str, RGB color);
27 void draw_color_bar(IMappedFramebuffer& buf, int old_xpos, int xpos, int width);
29 void draw_test_pattern(IMappedFramebuffer &fb);
30 }
32 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
34 #define unlikely(x) __builtin_expect(!!(x), 0)
36 /* __STRING(x) is a glibcism (i.e. not standard), which happens to also
37 * be available in uClibc. However, musl does not define it. Do it here.
38 */
39 #ifndef __STRING
40 #define __STRING(x) #x
41 #endif
43 #define ASSERT(x) \
44 if (unlikely(!(x))) { \
45 fprintf(stderr, "%s:%d: %s: ASSERT(%s) failed\n", __FILE__, __LINE__, __PRETTY_FUNCTION__, __STRING(x)); \
46 abort(); \
47 }
49 #define FAIL(fmt, ...) \
50 do { \
51 fprintf(stderr, "%s:%d: %s:\n" fmt "\n", __FILE__, __LINE__, __PRETTY_FUNCTION__, ##__VA_ARGS__); \
52 abort(); \
53 } while(0)
55 #define FAIL_IF(x, fmt, ...) \
56 if (unlikely(x)) { \
57 fprintf(stderr, "%s:%d: %s:\n" fmt "\n", __FILE__, __LINE__, __PRETTY_FUNCTION__, ##__VA_ARGS__); \
58 abort(); \
59 }
61 #define EXIT(fmt, ...) \
62 do { \
63 fprintf(stderr, fmt "\n", ##__VA_ARGS__); \
64 exit(-1); \
65 } while(0)