1 | From d2490c25af5827e781b4b4bee39d060abc53ad22 Mon Sep 17 00:00:00 2001
|
---|
2 | From: Gerasim Troeglazov <3dEyes@gmail.com>
|
---|
3 | Date: Sun, 8 Aug 2021 22:34:39 +1000
|
---|
4 | Subject: Fix build for Haiku
|
---|
5 |
|
---|
6 |
|
---|
7 | diff --git a/src/egl/main/egldisplay.c b/src/egl/main/egldisplay.c
|
---|
8 | index 765618f..50de2da 100644
|
---|
9 | --- a/src/egl/main/egldisplay.c
|
---|
10 | +++ b/src/egl/main/egldisplay.c
|
---|
11 | @@ -53,6 +53,10 @@
|
---|
12 | #include "eglimage.h"
|
---|
13 | #include "eglsync.h"
|
---|
14 |
|
---|
15 | +#ifdef __HAIKU__
|
---|
16 | +#define static_assert _Static_assert
|
---|
17 | +#endif
|
---|
18 | +
|
---|
19 | /* Includes for _eglNativePlatformDetectNativeDisplay */
|
---|
20 | #ifdef HAVE_WAYLAND_PLATFORM
|
---|
21 | #include <wayland-client.h>
|
---|
22 | diff --git a/src/util/disk_cache_os.c b/src/util/disk_cache_os.c
|
---|
23 | index e93e8c6..5bef62c 100644
|
---|
24 | --- a/src/util/disk_cache_os.c
|
---|
25 | +++ b/src/util/disk_cache_os.c
|
---|
26 | @@ -164,10 +164,19 @@ choose_lru_file_matching(const char *dir_path,
|
---|
27 | if (dir == NULL)
|
---|
28 | return NULL;
|
---|
29 |
|
---|
30 | +#ifdef __HAIKU__
|
---|
31 | + struct stat info;
|
---|
32 | +#endif
|
---|
33 | +
|
---|
34 | /* First count the number of files in the directory */
|
---|
35 | unsigned total_file_count = 0;
|
---|
36 | while ((dir_ent = readdir(dir)) != NULL) {
|
---|
37 | +#ifdef __HAIKU__
|
---|
38 | + stat(dir_ent->d_name, &info);
|
---|
39 | + if (S_ISREG(info.st_mode)) {
|
---|
40 | +#else
|
---|
41 | if (dir_ent->d_type == DT_REG) { /* If the entry is a regular file */
|
---|
42 | +#endif
|
---|
43 | total_file_count++;
|
---|
44 | }
|
---|
45 | }
|
---|
46 | diff --git a/src/util/u_thread.h b/src/util/u_thread.h
|
---|
47 | index 013e8be..a80c2f7 100644
|
---|
48 | --- a/src/util/u_thread.h
|
---|
49 | +++ b/src/util/u_thread.h
|
---|
50 | @@ -43,10 +43,6 @@
|
---|
51 | #endif
|
---|
52 | #endif
|
---|
53 |
|
---|
54 | -#ifdef __HAIKU__
|
---|
55 | -#include <OS.h>
|
---|
56 | -#endif
|
---|
57 | -
|
---|
58 | #if DETECT_OS_LINUX && !defined(ANDROID)
|
---|
59 | #include <sched.h>
|
---|
60 | #elif defined(_WIN32) && !defined(__CYGWIN__) && _WIN32_WINNT >= 0x0600
|
---|
61 | @@ -61,6 +57,11 @@
|
---|
62 | #define cpu_set_t cpuset_t
|
---|
63 | #endif
|
---|
64 |
|
---|
65 | +#ifdef __HAIKU__
|
---|
66 | +#include <OS.h>
|
---|
67 | +#undef ALIGN
|
---|
68 | +#endif
|
---|
69 | +
|
---|
70 | /* For util_set_thread_affinity to size the mask. */
|
---|
71 | #define UTIL_MAX_CPUS 1024 /* this should be enough */
|
---|
72 | #define UTIL_MAX_L3_CACHES UTIL_MAX_CPUS
|
---|
73 | @@ -359,11 +360,13 @@ static inline void util_barrier_wait(util_barrier *barrier)
|
---|
74 | * way), so thread_id's provide an alternative mechanism
|
---|
75 | */
|
---|
76 |
|
---|
77 | +#ifndef __HAIKU__
|
---|
78 | #ifdef _WIN32
|
---|
79 | typedef DWORD thread_id;
|
---|
80 | #else
|
---|
81 | typedef thrd_t thread_id;
|
---|
82 | #endif
|
---|
83 | +#endif
|
---|
84 |
|
---|
85 | static inline thread_id
|
---|
86 | util_get_thread_id(void)
|
---|
87 | @@ -377,6 +380,8 @@ util_get_thread_id(void)
|
---|
88 | */
|
---|
89 | #ifdef _WIN32
|
---|
90 | return GetCurrentThreadId();
|
---|
91 | +#elif defined(__HAIKU__)
|
---|
92 | + return find_thread(NULL);
|
---|
93 | #else
|
---|
94 | return thrd_current();
|
---|
95 | #endif
|
---|
96 | @@ -386,7 +391,7 @@ util_get_thread_id(void)
|
---|
97 | static inline int
|
---|
98 | util_thread_id_equal(thread_id t1, thread_id t2)
|
---|
99 | {
|
---|
100 | -#ifdef _WIN32
|
---|
101 | +#if defined(_WIN32) || defined(__HAIKU__)
|
---|
102 | return t1 == t2;
|
---|
103 | #else
|
---|
104 | return thrd_equal(t1, t2);
|
---|
105 | --
|
---|
106 | 2.30.2
|
---|
107 |
|
---|
108 |
|
---|
109 | From 0a61d456530d46afae912b44ee8d823d3f498f36 Mon Sep 17 00:00:00 2001
|
---|
110 | From: Gerasim Troeglazov <3dEyes@gmail.com>
|
---|
111 | Date: Sun, 8 Aug 2021 22:35:54 +1000
|
---|
112 | Subject: Add any color_space support
|
---|
113 |
|
---|
114 |
|
---|
115 | diff --git a/src/gallium/targets/haiku-softpipe/SoftwareRenderer.cpp b/src/gallium/targets/haiku-softpipe/SoftwareRenderer.cpp
|
---|
116 | index 96f19ae..6939e53 100644
|
---|
117 | --- a/src/gallium/targets/haiku-softpipe/SoftwareRenderer.cpp
|
---|
118 | +++ b/src/gallium/targets/haiku-softpipe/SoftwareRenderer.cpp
|
---|
119 | @@ -14,6 +14,7 @@
|
---|
120 |
|
---|
121 | #include <Autolock.h>
|
---|
122 | #include <interface/DirectWindowPrivate.h>
|
---|
123 | +#include <interface/ColorConversion.h>
|
---|
124 | #include <GraphicsDefs.h>
|
---|
125 | #include <Screen.h>
|
---|
126 | #include <stdio.h>
|
---|
127 | @@ -40,44 +41,50 @@ instantiate_gl_renderer(BGLView *view, ulong opts)
|
---|
128 | return new SoftwareRenderer(view, opts);
|
---|
129 | }
|
---|
130 |
|
---|
131 | -struct RasBuf32
|
---|
132 | +struct RasBuffer
|
---|
133 | {
|
---|
134 | int32 width, height, stride;
|
---|
135 | int32 orgX, orgY;
|
---|
136 | - int32 *colors;
|
---|
137 | + void *colors;
|
---|
138 | + color_space pixel_format;
|
---|
139 | + int32 pixel_size;
|
---|
140 |
|
---|
141 | - RasBuf32(int32 width, int32 height, int32 stride, int32 orgX, int32 orgY, int32 *colors):
|
---|
142 | + RasBuffer(int32 width, int32 height, int32 stride, int32 orgX, int32 orgY, void *colors):
|
---|
143 | width(width), height(height), stride(stride), orgX(orgX), orgY(orgY), colors(colors)
|
---|
144 | {}
|
---|
145 |
|
---|
146 | - RasBuf32(BBitmap *bmp)
|
---|
147 | + RasBuffer(BBitmap *bmp)
|
---|
148 | {
|
---|
149 | width = bmp->Bounds().IntegerWidth() + 1;
|
---|
150 | height = bmp->Bounds().IntegerHeight() + 1;
|
---|
151 | - stride = bmp->BytesPerRow()/4;
|
---|
152 | + stride = bmp->BytesPerRow();
|
---|
153 | orgX = 0;
|
---|
154 | orgY = 0;
|
---|
155 | - colors = (int32*)bmp->Bits();
|
---|
156 | + pixel_format = bmp->ColorSpace();
|
---|
157 | + pixel_size = stride / width;
|
---|
158 | + colors = bmp->Bits();
|
---|
159 | }
|
---|
160 |
|
---|
161 | - RasBuf32(direct_buffer_info *info)
|
---|
162 | + RasBuffer(direct_buffer_info *info)
|
---|
163 | {
|
---|
164 | width = 0x7fffffff;
|
---|
165 | height = 0x7fffffff;
|
---|
166 | - stride = info->bytes_per_row/4;
|
---|
167 | + stride = info->bytes_per_row;
|
---|
168 | orgX = 0;
|
---|
169 | orgY = 0;
|
---|
170 | - colors = (int32*)info->bits;
|
---|
171 | + pixel_format = info->pixel_format;
|
---|
172 | + pixel_size = info->bits_per_pixel / 8;
|
---|
173 | + colors = info->bits;
|
---|
174 | }
|
---|
175 |
|
---|
176 | void ClipSize(int32 x, int32 y, int32 w, int32 h)
|
---|
177 | {
|
---|
178 | if (x < 0) {w += x; x = 0;}
|
---|
179 | if (y < 0) {h += y; y = 0;}
|
---|
180 | - if (x + w > width) {w = width - x;}
|
---|
181 | + if (x + w > width) {w = width - x;}
|
---|
182 | if (y + h > height) {h = height - y;}
|
---|
183 | if ((w > 0) && (h > 0)) {
|
---|
184 | - colors += y*stride + x;
|
---|
185 | + colors += (y * stride) + (x * pixel_size);
|
---|
186 | width = w;
|
---|
187 | height = h;
|
---|
188 | } else {
|
---|
189 | @@ -98,27 +105,21 @@ struct RasBuf32
|
---|
190 | orgY += dy;
|
---|
191 | }
|
---|
192 |
|
---|
193 | - void Clear(int32 color)
|
---|
194 | + void Blit(RasBuffer src)
|
---|
195 | {
|
---|
196 | - RasBuf32 dst = *this;
|
---|
197 | - dst.stride -= dst.width;
|
---|
198 | - for (; dst.height > 0; dst.height--) {
|
---|
199 | - for (int32 i = dst.width; i > 0; i--)
|
---|
200 | - *dst.colors++ = color;
|
---|
201 | - dst.colors += dst.stride;
|
---|
202 | - }
|
---|
203 | - }
|
---|
204 | -
|
---|
205 | - void Blit(RasBuf32 src)
|
---|
206 | - {
|
---|
207 | - RasBuf32 dst = *this;
|
---|
208 | + RasBuffer dst = *this;
|
---|
209 | int32 x, y;
|
---|
210 | x = src.orgX - orgX;
|
---|
211 | y = src.orgY - orgY;
|
---|
212 | dst.ClipSize(x, y, src.width, src.height);
|
---|
213 | src.ClipSize(-x, -y, width, height);
|
---|
214 | for (; dst.height > 0; dst.height--) {
|
---|
215 | - memcpy(dst.colors, src.colors, 4*dst.width);
|
---|
216 | + if (src.pixel_format == dst.pixel_format) {
|
---|
217 | + memcpy(dst.colors, src.colors, src.width * src.pixel_size);
|
---|
218 | + } else {
|
---|
219 | + BPrivate::ConvertBits(src.colors, dst.colors, src.stride, dst.stride,
|
---|
220 | + src.stride, dst.stride, src.pixel_format, dst.pixel_format, src.width, 1);
|
---|
221 | + }
|
---|
222 | dst.colors += dst.stride;
|
---|
223 | src.colors += src.stride;
|
---|
224 | }
|
---|
225 | @@ -228,11 +229,11 @@ SoftwareRenderer::Display(BBitmap *bitmap, BRect *updateRect)
|
---|
226 | } else {
|
---|
227 | BAutolock lock(fInfoLocker);
|
---|
228 | if (fInfo != NULL) {
|
---|
229 | - RasBuf32 srcBuf(bitmap);
|
---|
230 | - RasBuf32 dstBuf(fInfo);
|
---|
231 | + RasBuffer srcBuf(bitmap);
|
---|
232 | + RasBuffer dstBuf(fInfo);
|
---|
233 | for (uint32 i = 0; i < fInfo->clip_list_count; i++) {
|
---|
234 | clipping_rect *clip = &fInfo->clip_list[i];
|
---|
235 | - RasBuf32 dstClip = dstBuf;
|
---|
236 | + RasBuffer dstClip = dstBuf;
|
---|
237 | dstClip.ClipRect(clip->left, clip->top, clip->right + 1, clip->bottom + 1);
|
---|
238 | dstClip.Shift(-fInfo->window_bounds.left, -fInfo->window_bounds.top);
|
---|
239 | dstClip.Blit(srcBuf);
|
---|
240 | --
|
---|
241 | 2.30.2
|
---|
242 |
|
---|