This repository has been archived by the owner on Oct 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
libglitter_enable_acceleration.c
80 lines (66 loc) · 2.15 KB
/
libglitter_enable_acceleration.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/* See LICENSE file for copyright and license details. */
#include "common.h"
#ifndef TEST
int
libglitter_enable_acceleration(uint64_t features, int async, void (*callback)(int r, int e, void *u), void *userdata, void *unused)
{
(void) features;
(void) async;
(void) unused;
/* TODO add support for hardware acceleration */
if (callback)
callback(0, 0, userdata);
return 0;
}
#else
static size_t callback_calls = 0;
static void
callback(int ret, int err, void *user)
{
callback_calls++;
ASSERT(!ret);
ASSERT(!err);
ASSERT(user);
ASSERT(*(const char *)user == 'u');
}
static void
callback_null(int ret, int err, void *user)
{
callback_calls++;
ASSERT(!ret);
ASSERT(!err);
ASSERT(!user);
}
int
main(void)
{
#define ALL (~UINT64_C(0))
char data = 'u';
ASSERT(!libglitter_enable_acceleration(0, 0, NULL, NULL, NULL));
ASSERT(!libglitter_enable_acceleration(0, 1, NULL, NULL, NULL));
ASSERT(!libglitter_enable_acceleration(ALL, 0, NULL, NULL, NULL));
ASSERT(!libglitter_enable_acceleration(ALL, 1, NULL, NULL, NULL));
ASSERT(!libglitter_enable_acceleration(0, 0, NULL, &data, NULL));
ASSERT(!libglitter_enable_acceleration(0, 1, NULL, &data, NULL));
ASSERT(!libglitter_enable_acceleration(ALL, 0, NULL, &data, NULL));
ASSERT(!libglitter_enable_acceleration(ALL, 1, NULL, &data, NULL));
ASSERT(callback_calls == 0);
ASSERT(!libglitter_enable_acceleration(0, 0, callback, &data, NULL));
ASSERT(callback_calls == 1);
ASSERT(!libglitter_enable_acceleration(0, 1, callback, &data, NULL));
ASSERT(callback_calls == 2);
ASSERT(!libglitter_enable_acceleration(ALL, 0, callback, &data, NULL));
ASSERT(callback_calls == 3);
ASSERT(!libglitter_enable_acceleration(ALL, 1, callback, &data, NULL));
ASSERT(callback_calls == 4);
ASSERT(!libglitter_enable_acceleration(0, 0, callback_null, NULL, NULL));
ASSERT(callback_calls == 5);
ASSERT(!libglitter_enable_acceleration(0, 1, callback_null, NULL, NULL));
ASSERT(callback_calls == 6);
ASSERT(!libglitter_enable_acceleration(ALL, 0, callback_null, NULL, NULL));
ASSERT(callback_calls == 7);
ASSERT(!libglitter_enable_acceleration(ALL, 1, callback_null, NULL, NULL));
ASSERT(callback_calls == 8);
return 0;
}
#endif