Disable database/opensearch
[oi-userland.git] / components / library / gtk+ / patches / 11-dlopen-medialib.patch
blob8714bfd07d45cab0c28546902a498a1781a17df1
1 --- gtk+-2.24.33/configure.ac.orig
2 +++ gtk+-2.24.33/configure.ac
3 @@ -887,27 +887,18 @@
4 AC_DEFINE(HAVE_SYS_SYSINFO_H, 1,
5 [Define to 1 if sys/sysinfo.h is available]))
7 -AC_MSG_CHECKING(for mediaLib 2.3)
8 -use_mlib25=no
9 -# Check for a mediaLib 2.3 function since that is what the GTK+ mediaLib
10 +# Check for a mediaLib 2.5 function since that is what the GTK+ mediaLib
11 # patch requires.
12 -AC_CHECK_LIB(mlib, mlib_ImageSetStruct, use_mlib=yes, use_mlib=no)
13 +AC_MSG_CHECKING(for mediaLib 2.5)
14 +use_mlib=no
15 +# Check for a mediaLib 2.5 function since that is what is needed for
16 +# gdk_rgb_convert integration.
17 +AC_CHECK_LIB(mlib, mlib_VideoColorRGBint_to_BGRAint, use_mlib=yes, use_mlib=no)
18 if test $use_mlib = yes; then
19 AC_DEFINE(USE_MEDIALIB, 1,
20 - [Define to 1 if medialib is available and should be used])
21 - MEDIA_LIB=-lmlib
23 - AC_MSG_CHECKING(for mediaLib 2.5)
24 - # Check for a mediaLib 2.5 function since that is what is needed for
25 - # gdk_rgb_convert integration.
26 - AC_CHECK_LIB(mlib, mlib_VideoColorRGBint_to_BGRAint, use_mlib25=yes, use_mlib25=no)
27 - if test $use_mlib25 = yes; then
28 - AC_DEFINE(USE_MEDIALIB25, 1,
29 - [Define to 1 if medialib 2.5 is available])
30 - fi
31 + [Define to 1 if medialib 2.5 is available])
33 AM_CONDITIONAL(USE_MEDIALIB, test $use_mlib = yes)
34 -AM_CONDITIONAL(USE_MEDIALIB25, test $use_mlib25 = yes)
36 dnl Look for a host system's gdk-pixbuf-csource if we are cross-compiling
38 --- gtk+-2.24.33/gdk/gdkdraw.c.orig
39 +++ gtk+-2.24.33/gdk/gdkdraw.c
40 @@ -1474,26 +1474,26 @@
42 mlib_image img_src, img_dst;
44 - mlib_ImageSetStruct (&img_dst,
45 - MLIB_BYTE,
46 - 4,
47 - width,
48 - height,
49 - dest_rowstride,
50 - dest_buf);
51 + medialib_ImageSetStruct (&img_dst,
52 + MLIB_BYTE,
53 + 4,
54 + width,
55 + height,
56 + dest_rowstride,
57 + dest_buf);
59 - mlib_ImageSetStruct (&img_src,
60 - MLIB_BYTE,
61 - 4,
62 - width,
63 - height,
64 - src_rowstride,
65 - src_buf);
66 + medialib_ImageSetStruct (&img_src,
67 + MLIB_BYTE,
68 + 4,
69 + width,
70 + height,
71 + src_rowstride,
72 + src_buf);
74 if (dest_byte_order == GDK_LSB_FIRST)
75 - mlib_ImageBlendRGBA2BGRA (&img_dst, &img_src);
76 + medialib_BlendRGBA2BGRA (&img_dst, &img_src);
77 else
78 - mlib_ImageBlendRGBA2ARGB (&img_dst, &img_src);
79 + medialib_BlendRGBA2ARGB (&img_dst, &img_src);
81 #endif
83 --- gtk+-2.24.33/gdk/gdkmedialib.c.orig
84 +++ gtk+-2.24.33/gdk/gdkmedialib.c
85 @@ -46,29 +46,56 @@
87 #include "gdkmedialib.h"
89 -typedef char * (*ml_version) (void);
90 +ml_ImageSetStruct medialib_ImageSetStruct = NULL;
91 +ml_BlendRGBA2BGRA medialib_BlendRGBA2BGRA = NULL;
92 +ml_BlendRGBA2ARGB medialib_BlendRGBA2ARGB = NULL;
93 +ml_ColorRGBint_to_BGRAint medialib_ColorRGBint_to_BGRAint = NULL;
95 -static ml_version medialib_version = mlib_version;
96 +static void *
97 +dlopen_mlib (void)
99 + void *handle = NULL;
101 -gboolean
102 -_gdk_use_medialib (void)
103 + if ((handle = dlopen ("libmlib.so.2", RTLD_LAZY)) != NULL)
104 + return handle;
105 + if ((handle = dlopen ("/usr/lib/libmlib.so.2", RTLD_LAZY)) != NULL)
106 + return handle;
108 + return NULL;
111 +static gboolean
112 +initialize_mediaLib (void *handle)
114 + medialib_ImageSetStruct = (ml_ImageSetStruct)dlsym (handle,
115 + "mlib_ImageSetStruct");
116 + medialib_BlendRGBA2BGRA = (ml_BlendRGBA2BGRA)dlsym (handle,
117 + "mlib_ImageBlendRGBA2BGRA");
118 + medialib_BlendRGBA2ARGB = (ml_BlendRGBA2ARGB)dlsym (handle,
119 + "mlib_ImageBlendRGBA2ARGB");
120 + medialib_ColorRGBint_to_BGRAint = (ml_ColorRGBint_to_BGRAint)dlsym (
121 + handle,
122 + "mlib_VideoColorRGBint_to_BGRAint");
123 + if (medialib_ImageSetStruct == NULL || medialib_BlendRGBA2BGRA == NULL ||
124 + medialib_BlendRGBA2ARGB == NULL || medialib_ColorRGBint_to_BGRAint == NULL)
125 + return FALSE;
127 + return TRUE;
130 +static gboolean
131 +mlib_x86_checks (void *handle)
133 + typedef char * (*ml_version) (void);
134 + ml_version medialib_version;
135 char *mlib_version_string;
136 - char sys_info[257];
137 - long count;
138 + char *mlib_target_isa;
140 - /*
141 - * Sun mediaLib(tm) support.
143 - * http://www.sun.com/processors/vis/mlib.html
145 - */
146 - if (getenv ("GDK_DISABLE_MEDIALIB"))
147 + medialib_version = (ml_version)dlsym (handle, "mlib_version");
148 + if (medialib_version == NULL)
149 return FALSE;
152 - * The imaging functions we want to use were added in mediaLib version 2.
153 - * So turn off mediaLib support if the user has an older version.
154 * mlib_version returns a string in this format:
156 * mediaLib:0210:20011101:v8plusa
157 @@ -78,43 +105,83 @@
159 * The first 2 digits of the version are the major version. The 3rd digit
160 * is the minor version, and the 4th digit is the micro version. So the
161 - * above string corresponds to version 2.1.0.In the following test we only
162 - * care about the major version.
163 + * above string corresponds to version 2.1.0.
165 - mlib_version_string = medialib_version ();
166 + mlib_version_string = medialib_version ();
167 + mlib_target_isa = &mlib_version_string[23];
169 - count = sysinfo (SI_ARCHITECTURE, &sys_info[0], 257);
170 + /*
171 + * For x86 processors mediaLib generic C implementation
172 + * does not give any performance advantage so disable it.
173 + */
174 + if (strncmp (mlib_target_isa, "sse", 3) != 0)
175 + return FALSE;
177 + /*
178 + * For x86 processors use of libumem conflicts with
179 + * mediaLib, so avoid using it.
180 + */
181 + if (dlsym (RTLD_PROBE, "umem_alloc") != NULL)
182 + return FALSE;
184 + return TRUE;
188 + * Sun mediaLib(tm) support.
190 + * http://www.sun.com/processors/vis/mlib.html
192 + */
193 +gboolean
194 +_gdk_use_medialib (void)
196 + static gboolean medialib_initialized = FALSE;
197 + static gboolean use_medialib = TRUE;
198 + void *medialib_handle = NULL;
199 + char sys_info[257];
200 + long count;
202 + if (medialib_initialized == TRUE)
203 + return TRUE;
205 + if (use_medialib == FALSE)
206 + return FALSE;
208 + if (getenv ("GDK_DISABLE_MEDIALIB"))
210 + use_medialib = FALSE;
211 + return FALSE;
214 + medialib_handle = dlopen_mlib ();
215 + if (medialib_handle == NULL)
216 + goto fail;
218 + count = sysinfo (SI_ARCHITECTURE, &sys_info[0], 257);
220 - if (count != -1)
222 - if (strcmp (sys_info, "i386") == 0)
224 - char *mlib_target_isa = &mlib_version_string[23];
226 - /*
227 - * For x86 processors mediaLib generic C implementation
228 - * does not give any performance advantage so disable it.
229 - */
230 - if (strncmp (mlib_target_isa, "sse", 3) != 0)
232 - return FALSE;
235 - /*
236 - * For x86 processors use of libumem conflicts with
237 - * mediaLib, so avoid using it.
238 - */
239 - if (dlsym (RTLD_PROBE, "umem_alloc") != NULL)
241 - return FALSE;
245 - else
247 - /* Failed to get system architecture, disable mediaLib */
248 - return FALSE;
250 + if (count != -1)
252 + if (strcmp (sys_info, "i386") == 0)
254 + if (mlib_x86_checks (medialib_handle) == FALSE)
255 + goto fail;
258 + else
260 + /* Failed to get system architecture, disable mediaLib */
261 + goto fail;
264 + if (initialize_mediaLib (medialib_handle) == FALSE)
265 + goto fail;
267 + medialib_initialized = TRUE;
268 return TRUE;
270 +fail:
271 + dlclose (medialib_handle);
272 + use_medialib = FALSE;
273 + return FALSE;
275 --- gtk+-2.24.33/gdk/gdkmedialib.h.orig
276 +++ gtk+-2.24.33/gdk/gdkmedialib.h
277 @@ -36,6 +36,32 @@
279 G_BEGIN_DECLS
281 +typedef mlib_image* (*ml_ImageSetStruct) (mlib_image *image,
282 + mlib_type type,
283 + mlib_s32 channels,
284 + mlib_s32 width,
285 + mlib_s32 height,
286 + mlib_s32 stride,
287 + const void *data);
288 +typedef mlib_status (*ml_BlendRGBA2BGRA) (mlib_image *dst,
289 + const mlib_image *src);
290 +typedef mlib_status (*ml_BlendRGBA2ARGB) (mlib_image *dst,
291 + const mlib_image *src);
292 +typedef void (*ml_ColorRGBint_to_BGRAint) (mlib_u8 *bgra,
293 + const mlib_u8 *rgb,
294 + const mlib_u8 *a_array,
295 + mlib_u8 a_const,
296 + mlib_s32 w,
297 + mlib_s32 h,
298 + mlib_s32 dlb,
299 + mlib_s32 slb,
300 + mlib_s32 alb);
302 +extern ml_ColorRGBint_to_BGRAint medialib_ColorRGBint_to_BGRAint;
303 +extern ml_ImageSetStruct medialib_ImageSetStruct;
304 +extern ml_BlendRGBA2BGRA medialib_BlendRGBA2BGRA;
305 +extern ml_BlendRGBA2ARGB medialib_BlendRGBA2ARGB;
307 gboolean _gdk_use_medialib (void);
309 G_END_DECLS
310 --- gtk+-2.24.33/gdk/gdkrgb.c.orig
311 +++ gtk+-2.24.33/gdk/gdkrgb.c
312 @@ -2155,7 +2155,7 @@
316 -#ifdef USE_MEDIALIB25
317 +#ifdef USE_MEDIALIB
318 /* convert 24-bit packed to 32-bit unpacked */
319 static void
320 gdk_rgb_convert_0888_medialib (GdkRgbInfo *image_info, GdkImage *image,
321 @@ -2172,9 +2172,9 @@
322 bpl = image->bpl;
323 obuf = ((guchar *)image->mem) + y0 * bpl + x0 * 4;
325 - mlib_VideoColorRGBint_to_BGRAint (obuf, bptr, NULL, 0xff,
326 - width, height, bpl,
327 - rowstride, 0);
328 + medialib_ColorRGBint_to_BGRAint (obuf, bptr, NULL, 0xff,
329 + width, height, bpl,
330 + rowstride, 0);
332 #endif
334 @@ -3158,7 +3158,7 @@
335 vtype == GDK_VISUAL_TRUE_COLOR &&
336 (mask_rgb && byte_order == GDK_LSB_FIRST))
338 -#ifdef USE_MEDIALIB25
339 +#ifdef USE_MEDIALIB
340 if (_gdk_use_medialib ())
341 conv = gdk_rgb_convert_0888_medialib;
342 else
343 @@ -3185,7 +3185,7 @@
344 else if (bpp == 32 && depth == 32 && vtype == GDK_VISUAL_TRUE_COLOR &&
345 (mask_rgb && byte_order == GDK_LSB_FIRST))
347 -#ifdef USE_MEDIALIB25
348 +#ifdef USE_MEDIALIB
349 if (_gdk_use_medialib ())
350 conv = gdk_rgb_convert_0888_medialib;
351 else