···3030 description = "Allows testing the fonts available in an X server";
3131 license = "free";
3232 maintainers = with stdenv.lib.maintainers; [viric];
3333- platforms = with stdenv.lib.platforms; linux;
3333+ platforms = with stdenv.lib.platforms; linux ++ darwin;
3434 };
3535}
+1-1
pkgs/applications/misc/xlsfonts/default.nix
···1818 description = "Lists the fonts available in the X server";
1919 license = "free";
2020 maintainers = with stdenv.lib.maintainers; [viric];
2121- platforms = with stdenv.lib.platforms; linux;
2121+ platforms = with stdenv.lib.platforms; linux ++ darwin;
2222 };
2323}
+1-1
pkgs/applications/misc/xterm/default.nix
···3636 homepage = http://invisible-island.net/xterm;
3737 license = "BSD";
3838 maintainers = with stdenv.lib.maintainers; [viric];
3939- platforms = with stdenv.lib.platforms; linux;
3939+ platforms = with stdenv.lib.platforms; linux ++ darwin;
4040 };
4141}
···11+/*
22+ * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
33+ * Copyright 2007-2008 Red Hat, Inc.
44+ * (C) Copyright IBM Corporation 2004
55+ * All Rights Reserved.
66+ *
77+ * Permission is hereby granted, free of charge, to any person obtaining a
88+ * copy of this software and associated documentation files (the "Software"),
99+ * to deal in the Software without restriction, including without limitation
1010+ * on the rights to use, copy, modify, merge, publish, distribute, sub
1111+ * license, and/or sell copies of the Software, and to permit persons to whom
1212+ * the Software is furnished to do so, subject to the following conditions:
1313+ *
1414+ * The above copyright notice and this permission notice (including the next
1515+ * paragraph) shall be included in all copies or substantial portions of the
1616+ * Software.
1717+ *
1818+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1919+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2020+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
2121+ * THE COPYRIGHT HOLDERS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
2222+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
2323+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
2424+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
2525+ */
2626+2727+/**
2828+ * \file dri_interface.h
2929+ *
3030+ * This file contains all the types and functions that define the interface
3131+ * between a DRI driver and driver loader. Currently, the most common driver
3232+ * loader is the XFree86 libGL.so. However, other loaders do exist, and in
3333+ * the future the server-side libglx.a will also be a loader.
3434+ *
3535+ * \author Kevin E. Martin <kevin@precisioninsight.com>
3636+ * \author Ian Romanick <idr@us.ibm.com>
3737+ * \author Kristian Høgsberg <krh@redhat.com>
3838+ */
3939+4040+#ifndef DRI_INTERFACE_H
4141+#define DRI_INTERFACE_H
4242+4343+/* For archs with no drm.h */
4444+#if defined(__APPLE__) || defined(__CYGWIN__) || defined(__GNU__)
4545+#ifndef __NOT_HAVE_DRM_H
4646+#define __NOT_HAVE_DRM_H
4747+#endif
4848+#endif
4949+5050+#ifndef __NOT_HAVE_DRM_H
5151+#include <drm.h>
5252+#else
5353+typedef unsigned int drm_context_t;
5454+typedef unsigned int drm_drawable_t;
5555+typedef struct drm_clip_rect drm_clip_rect_t;
5656+#endif
5757+5858+/**
5959+ * \name DRI interface structures
6060+ *
6161+ * The following structures define the interface between the GLX client
6262+ * side library and the DRI (direct rendering infrastructure).
6363+ */
6464+/*@{*/
6565+typedef struct __DRIdisplayRec __DRIdisplay;
6666+typedef struct __DRIscreenRec __DRIscreen;
6767+typedef struct __DRIcontextRec __DRIcontext;
6868+typedef struct __DRIdrawableRec __DRIdrawable;
6969+typedef struct __DRIconfigRec __DRIconfig;
7070+typedef struct __DRIframebufferRec __DRIframebuffer;
7171+typedef struct __DRIversionRec __DRIversion;
7272+7373+typedef struct __DRIcoreExtensionRec __DRIcoreExtension;
7474+typedef struct __DRIextensionRec __DRIextension;
7575+typedef struct __DRIcopySubBufferExtensionRec __DRIcopySubBufferExtension;
7676+typedef struct __DRIswapControlExtensionRec __DRIswapControlExtension;
7777+typedef struct __DRIframeTrackingExtensionRec __DRIframeTrackingExtension;
7878+typedef struct __DRImediaStreamCounterExtensionRec __DRImediaStreamCounterExtension;
7979+typedef struct __DRItexOffsetExtensionRec __DRItexOffsetExtension;
8080+typedef struct __DRItexBufferExtensionRec __DRItexBufferExtension;
8181+typedef struct __DRIlegacyExtensionRec __DRIlegacyExtension;
8282+typedef struct __DRIswrastExtensionRec __DRIswrastExtension;
8383+typedef struct __DRIbufferRec __DRIbuffer;
8484+typedef struct __DRIdri2ExtensionRec __DRIdri2Extension;
8585+typedef struct __DRIdri2LoaderExtensionRec __DRIdri2LoaderExtension;
8686+typedef struct __DRI2flushExtensionRec __DRI2flushExtension;
8787+typedef struct __DRI2throttleExtensionRec __DRI2throttleExtension;
8888+8989+9090+typedef struct __DRIimageLoaderExtensionRec __DRIimageLoaderExtension;
9191+typedef struct __DRIimageDriverExtensionRec __DRIimageDriverExtension;
9292+9393+/*@}*/
9494+9595+9696+/**
9797+ * Extension struct. Drivers 'inherit' from this struct by embedding
9898+ * it as the first element in the extension struct.
9999+ *
100100+ * We never break API in for a DRI extension. If we need to change
101101+ * the way things work in a non-backwards compatible manner, we
102102+ * introduce a new extension. During a transition period, we can
103103+ * leave both the old and the new extension in the driver, which
104104+ * allows us to move to the new interface without having to update the
105105+ * loader(s) in lock step.
106106+ *
107107+ * However, we can add entry points to an extension over time as long
108108+ * as we don't break the old ones. As we add entry points to an
109109+ * extension, we increase the version number. The corresponding
110110+ * #define can be used to guard code that accesses the new entry
111111+ * points at compile time and the version field in the extension
112112+ * struct can be used at run-time to determine how to use the
113113+ * extension.
114114+ */
115115+struct __DRIextensionRec {
116116+ const char *name;
117117+ int version;
118118+};
119119+120120+/**
121121+ * The first set of extension are the screen extensions, returned by
122122+ * __DRIcore::getExtensions(). This entry point will return a list of
123123+ * extensions and the loader can use the ones it knows about by
124124+ * casting them to more specific extensions and advertising any GLX
125125+ * extensions the DRI extensions enables.
126126+ */
127127+128128+/**
129129+ * Used by drivers to indicate support for setting the read drawable.
130130+ */
131131+#define __DRI_READ_DRAWABLE "DRI_ReadDrawable"
132132+#define __DRI_READ_DRAWABLE_VERSION 1
133133+134134+/**
135135+ * Used by drivers that implement the GLX_MESA_copy_sub_buffer extension.
136136+ */
137137+#define __DRI_COPY_SUB_BUFFER "DRI_CopySubBuffer"
138138+#define __DRI_COPY_SUB_BUFFER_VERSION 1
139139+struct __DRIcopySubBufferExtensionRec {
140140+ __DRIextension base;
141141+ void (*copySubBuffer)(__DRIdrawable *drawable, int x, int y, int w, int h);
142142+};
143143+144144+/**
145145+ * Used by drivers that implement the GLX_SGI_swap_control or
146146+ * GLX_MESA_swap_control extension.
147147+ */
148148+#define __DRI_SWAP_CONTROL "DRI_SwapControl"
149149+#define __DRI_SWAP_CONTROL_VERSION 1
150150+struct __DRIswapControlExtensionRec {
151151+ __DRIextension base;
152152+ void (*setSwapInterval)(__DRIdrawable *drawable, unsigned int inteval);
153153+ unsigned int (*getSwapInterval)(__DRIdrawable *drawable);
154154+};
155155+156156+/**
157157+ * Used by drivers that implement the GLX_MESA_swap_frame_usage extension.
158158+ */
159159+#define __DRI_FRAME_TRACKING "DRI_FrameTracking"
160160+#define __DRI_FRAME_TRACKING_VERSION 1
161161+struct __DRIframeTrackingExtensionRec {
162162+ __DRIextension base;
163163+164164+ /**
165165+ * Enable or disable frame usage tracking.
166166+ *
167167+ * \since Internal API version 20030317.
168168+ */
169169+ int (*frameTracking)(__DRIdrawable *drawable, GLboolean enable);
170170+171171+ /**
172172+ * Retrieve frame usage information.
173173+ *
174174+ * \since Internal API version 20030317.
175175+ */
176176+ int (*queryFrameTracking)(__DRIdrawable *drawable,
177177+ int64_t * sbc, int64_t * missedFrames,
178178+ float * lastMissedUsage, float * usage);
179179+};
180180+181181+182182+/**
183183+ * Used by drivers that implement the GLX_SGI_video_sync extension.
184184+ */
185185+#define __DRI_MEDIA_STREAM_COUNTER "DRI_MediaStreamCounter"
186186+#define __DRI_MEDIA_STREAM_COUNTER_VERSION 1
187187+struct __DRImediaStreamCounterExtensionRec {
188188+ __DRIextension base;
189189+190190+ /**
191191+ * Wait for the MSC to equal target_msc, or, if that has already passed,
192192+ * the next time (MSC % divisor) is equal to remainder. If divisor is
193193+ * zero, the function will return as soon as MSC is greater than or equal
194194+ * to target_msc.
195195+ */
196196+ int (*waitForMSC)(__DRIdrawable *drawable,
197197+ int64_t target_msc, int64_t divisor, int64_t remainder,
198198+ int64_t * msc, int64_t * sbc);
199199+200200+ /**
201201+ * Get the number of vertical refreshes since some point in time before
202202+ * this function was first called (i.e., system start up).
203203+ */
204204+ int (*getDrawableMSC)(__DRIscreen *screen, __DRIdrawable *drawable,
205205+ int64_t *msc);
206206+};
207207+208208+209209+#define __DRI_TEX_OFFSET "DRI_TexOffset"
210210+#define __DRI_TEX_OFFSET_VERSION 1
211211+struct __DRItexOffsetExtensionRec {
212212+ __DRIextension base;
213213+214214+ /**
215215+ * Method to override base texture image with a driver specific 'offset'.
216216+ * The depth passed in allows e.g. to ignore the alpha channel of texture
217217+ * images where the non-alpha components don't occupy a whole texel.
218218+ *
219219+ * For GLX_EXT_texture_from_pixmap with AIGLX.
220220+ */
221221+ void (*setTexOffset)(__DRIcontext *pDRICtx, GLint texname,
222222+ unsigned long long offset, GLint depth, GLuint pitch);
223223+};
224224+225225+226226+/* Valid values for format in the setTexBuffer2 function below. These
227227+ * values match the GLX tokens for compatibility reasons, but we
228228+ * define them here since the DRI interface can't depend on GLX. */
229229+#define __DRI_TEXTURE_FORMAT_NONE 0x20D8
230230+#define __DRI_TEXTURE_FORMAT_RGB 0x20D9
231231+#define __DRI_TEXTURE_FORMAT_RGBA 0x20DA
232232+233233+#define __DRI_TEX_BUFFER "DRI_TexBuffer"
234234+#define __DRI_TEX_BUFFER_VERSION 2
235235+struct __DRItexBufferExtensionRec {
236236+ __DRIextension base;
237237+238238+ /**
239239+ * Method to override base texture image with the contents of a
240240+ * __DRIdrawable.
241241+ *
242242+ * For GLX_EXT_texture_from_pixmap with AIGLX. Deprecated in favor of
243243+ * setTexBuffer2 in version 2 of this interface
244244+ */
245245+ void (*setTexBuffer)(__DRIcontext *pDRICtx,
246246+ GLint target,
247247+ __DRIdrawable *pDraw);
248248+249249+ /**
250250+ * Method to override base texture image with the contents of a
251251+ * __DRIdrawable, including the required texture format attribute.
252252+ *
253253+ * For GLX_EXT_texture_from_pixmap with AIGLX.
254254+ */
255255+ void (*setTexBuffer2)(__DRIcontext *pDRICtx,
256256+ GLint target,
257257+ GLint format,
258258+ __DRIdrawable *pDraw);
259259+ /**
260260+ * Method to release texture buffer in case some special platform
261261+ * need this.
262262+ *
263263+ * For GLX_EXT_texture_from_pixmap with AIGLX.
264264+ */
265265+ void (*releaseTexBuffer)(__DRIcontext *pDRICtx,
266266+ GLint target,
267267+ __DRIdrawable *pDraw);
268268+};
269269+270270+/**
271271+ * Used by drivers that implement DRI2
272272+ */
273273+#define __DRI2_FLUSH "DRI2_Flush"
274274+#define __DRI2_FLUSH_VERSION 4
275275+276276+#define __DRI2_FLUSH_DRAWABLE (1 << 0) /* the drawable should be flushed. */
277277+#define __DRI2_FLUSH_CONTEXT (1 << 1) /* glFlush should be called */
278278+279279+enum __DRI2throttleReason {
280280+ __DRI2_THROTTLE_SWAPBUFFER,
281281+ __DRI2_THROTTLE_COPYSUBBUFFER,
282282+ __DRI2_THROTTLE_FLUSHFRONT
283283+};
284284+285285+struct __DRI2flushExtensionRec {
286286+ __DRIextension base;
287287+ void (*flush)(__DRIdrawable *drawable);
288288+289289+ /**
290290+ * Ask the driver to call getBuffers/getBuffersWithFormat before
291291+ * it starts rendering again.
292292+ *
293293+ * \param drawable the drawable to invalidate
294294+ *
295295+ * \since 3
296296+ */
297297+ void (*invalidate)(__DRIdrawable *drawable);
298298+299299+ /**
300300+ * This function reduces the number of flushes in the driver by combining
301301+ * several operations into one call.
302302+ *
303303+ * It can:
304304+ * - throttle
305305+ * - flush a drawable
306306+ * - flush a context
307307+ *
308308+ * \param context the context
309309+ * \param drawable the drawable to flush
310310+ * \param flags a combination of _DRI2_FLUSH_xxx flags
311311+ * \param throttle_reason the reason for throttling, 0 = no throttling
312312+ *
313313+ * \since 4
314314+ */
315315+ void (*flush_with_flags)(__DRIcontext *ctx,
316316+ __DRIdrawable *drawable,
317317+ unsigned flags,
318318+ enum __DRI2throttleReason throttle_reason);
319319+};
320320+321321+322322+/**
323323+ * Extension that the driver uses to request
324324+ * throttle callbacks.
325325+ */
326326+327327+#define __DRI2_THROTTLE "DRI2_Throttle"
328328+#define __DRI2_THROTTLE_VERSION 1
329329+330330+struct __DRI2throttleExtensionRec {
331331+ __DRIextension base;
332332+ void (*throttle)(__DRIcontext *ctx,
333333+ __DRIdrawable *drawable,
334334+ enum __DRI2throttleReason reason);
335335+};
336336+337337+/*@}*/
338338+339339+/**
340340+ * The following extensions describe loader features that the DRI
341341+ * driver can make use of. Some of these are mandatory, such as the
342342+ * getDrawableInfo extension for DRI and the DRI Loader extensions for
343343+ * DRI2, while others are optional, and if present allow the driver to
344344+ * expose certain features. The loader pass in a NULL terminated
345345+ * array of these extensions to the driver in the createNewScreen
346346+ * constructor.
347347+ */
348348+349349+typedef struct __DRIgetDrawableInfoExtensionRec __DRIgetDrawableInfoExtension;
350350+typedef struct __DRIsystemTimeExtensionRec __DRIsystemTimeExtension;
351351+typedef struct __DRIdamageExtensionRec __DRIdamageExtension;
352352+typedef struct __DRIloaderExtensionRec __DRIloaderExtension;
353353+typedef struct __DRIswrastLoaderExtensionRec __DRIswrastLoaderExtension;
354354+355355+356356+/**
357357+ * Callback to getDrawableInfo protocol
358358+ */
359359+#define __DRI_GET_DRAWABLE_INFO "DRI_GetDrawableInfo"
360360+#define __DRI_GET_DRAWABLE_INFO_VERSION 1
361361+struct __DRIgetDrawableInfoExtensionRec {
362362+ __DRIextension base;
363363+364364+ /**
365365+ * This function is used to get information about the position, size, and
366366+ * clip rects of a drawable.
367367+ */
368368+ GLboolean (* getDrawableInfo) ( __DRIdrawable *drawable,
369369+ unsigned int * index, unsigned int * stamp,
370370+ int * x, int * y, int * width, int * height,
371371+ int * numClipRects, drm_clip_rect_t ** pClipRects,
372372+ int * backX, int * backY,
373373+ int * numBackClipRects, drm_clip_rect_t ** pBackClipRects,
374374+ void *loaderPrivate);
375375+};
376376+377377+/**
378378+ * Callback to get system time for media stream counter extensions.
379379+ */
380380+#define __DRI_SYSTEM_TIME "DRI_SystemTime"
381381+#define __DRI_SYSTEM_TIME_VERSION 1
382382+struct __DRIsystemTimeExtensionRec {
383383+ __DRIextension base;
384384+385385+ /**
386386+ * Get the 64-bit unadjusted system time (UST).
387387+ */
388388+ int (*getUST)(int64_t * ust);
389389+390390+ /**
391391+ * Get the media stream counter (MSC) rate.
392392+ *
393393+ * Matching the definition in GLX_OML_sync_control, this function returns
394394+ * the rate of the "media stream counter". In practical terms, this is
395395+ * the frame refresh rate of the display.
396396+ */
397397+ GLboolean (*getMSCRate)(__DRIdrawable *draw,
398398+ int32_t * numerator, int32_t * denominator,
399399+ void *loaderPrivate);
400400+};
401401+402402+/**
403403+ * Damage reporting
404404+ */
405405+#define __DRI_DAMAGE "DRI_Damage"
406406+#define __DRI_DAMAGE_VERSION 1
407407+struct __DRIdamageExtensionRec {
408408+ __DRIextension base;
409409+410410+ /**
411411+ * Reports areas of the given drawable which have been modified by the
412412+ * driver.
413413+ *
414414+ * \param drawable which the drawing was done to.
415415+ * \param rects rectangles affected, with the drawable origin as the
416416+ * origin.
417417+ * \param x X offset of the drawable within the screen (used in the
418418+ * front_buffer case)
419419+ * \param y Y offset of the drawable within the screen.
420420+ * \param front_buffer boolean flag for whether the drawing to the
421421+ * drawable was actually done directly to the front buffer (instead
422422+ * of backing storage, for example)
423423+ * \param loaderPrivate the data passed in at createNewDrawable time
424424+ */
425425+ void (*reportDamage)(__DRIdrawable *draw,
426426+ int x, int y,
427427+ drm_clip_rect_t *rects, int num_rects,
428428+ GLboolean front_buffer,
429429+ void *loaderPrivate);
430430+};
431431+432432+#define __DRI_SWRAST_IMAGE_OP_DRAW 1
433433+#define __DRI_SWRAST_IMAGE_OP_CLEAR 2
434434+#define __DRI_SWRAST_IMAGE_OP_SWAP 3
435435+436436+/**
437437+ * SWRast Loader extension.
438438+ */
439439+#define __DRI_SWRAST_LOADER "DRI_SWRastLoader"
440440+#define __DRI_SWRAST_LOADER_VERSION 1
441441+struct __DRIswrastLoaderExtensionRec {
442442+ __DRIextension base;
443443+444444+ /*
445445+ * Drawable position and size
446446+ */
447447+ void (*getDrawableInfo)(__DRIdrawable *drawable,
448448+ int *x, int *y, int *width, int *height,
449449+ void *loaderPrivate);
450450+451451+ /**
452452+ * Put image to drawable
453453+ */
454454+ void (*putImage)(__DRIdrawable *drawable, int op,
455455+ int x, int y, int width, int height,
456456+ char *data, void *loaderPrivate);
457457+458458+ /**
459459+ * Get image from readable
460460+ */
461461+ void (*getImage)(__DRIdrawable *readable,
462462+ int x, int y, int width, int height,
463463+ char *data, void *loaderPrivate);
464464+};
465465+466466+/**
467467+ * Invalidate loader extension. The presence of this extension
468468+ * indicates to the DRI driver that the loader will call invalidate in
469469+ * the __DRI2_FLUSH extension, whenever the needs to query for new
470470+ * buffers. This means that the DRI driver can drop the polling in
471471+ * glViewport().
472472+ *
473473+ * The extension doesn't provide any functionality, it's only use to
474474+ * indicate to the driver that it can use the new semantics. A DRI
475475+ * driver can use this to switch between the different semantics or
476476+ * just refuse to initialize if this extension isn't present.
477477+ */
478478+#define __DRI_USE_INVALIDATE "DRI_UseInvalidate"
479479+#define __DRI_USE_INVALIDATE_VERSION 1
480480+481481+typedef struct __DRIuseInvalidateExtensionRec __DRIuseInvalidateExtension;
482482+struct __DRIuseInvalidateExtensionRec {
483483+ __DRIextension base;
484484+};
485485+486486+/**
487487+ * The remaining extensions describe driver extensions, immediately
488488+ * available interfaces provided by the driver. To start using the
489489+ * driver, dlsym() for the __DRI_DRIVER_EXTENSIONS symbol and look for
490490+ * the extension you need in the array.
491491+ */
492492+#define __DRI_DRIVER_EXTENSIONS "__driDriverExtensions"
493493+494494+/**
495495+ * This symbol replaces the __DRI_DRIVER_EXTENSIONS symbol, and will be
496496+ * suffixed by "_drivername", allowing multiple drivers to be built into one
497497+ * library, and also giving the driver the chance to return a variable driver
498498+ * extensions struct depending on the driver name being loaded or any other
499499+ * system state.
500500+ *
501501+ * The function prototype is:
502502+ *
503503+ * const __DRIextension **__driDriverGetExtensions_drivername(void);
504504+ */
505505+#define __DRI_DRIVER_GET_EXTENSIONS "__driDriverGetExtensions"
506506+507507+/**
508508+ * Tokens for __DRIconfig attribs. A number of attributes defined by
509509+ * GLX or EGL standards are not in the table, as they must be provided
510510+ * by the loader. For example, FBConfig ID or visual ID, drawable type.
511511+ */
512512+513513+#define __DRI_ATTRIB_BUFFER_SIZE 1
514514+#define __DRI_ATTRIB_LEVEL 2
515515+#define __DRI_ATTRIB_RED_SIZE 3
516516+#define __DRI_ATTRIB_GREEN_SIZE 4
517517+#define __DRI_ATTRIB_BLUE_SIZE 5
518518+#define __DRI_ATTRIB_LUMINANCE_SIZE 6
519519+#define __DRI_ATTRIB_ALPHA_SIZE 7
520520+#define __DRI_ATTRIB_ALPHA_MASK_SIZE 8
521521+#define __DRI_ATTRIB_DEPTH_SIZE 9
522522+#define __DRI_ATTRIB_STENCIL_SIZE 10
523523+#define __DRI_ATTRIB_ACCUM_RED_SIZE 11
524524+#define __DRI_ATTRIB_ACCUM_GREEN_SIZE 12
525525+#define __DRI_ATTRIB_ACCUM_BLUE_SIZE 13
526526+#define __DRI_ATTRIB_ACCUM_ALPHA_SIZE 14
527527+#define __DRI_ATTRIB_SAMPLE_BUFFERS 15
528528+#define __DRI_ATTRIB_SAMPLES 16
529529+#define __DRI_ATTRIB_RENDER_TYPE 17
530530+#define __DRI_ATTRIB_CONFIG_CAVEAT 18
531531+#define __DRI_ATTRIB_CONFORMANT 19
532532+#define __DRI_ATTRIB_DOUBLE_BUFFER 20
533533+#define __DRI_ATTRIB_STEREO 21
534534+#define __DRI_ATTRIB_AUX_BUFFERS 22
535535+#define __DRI_ATTRIB_TRANSPARENT_TYPE 23
536536+#define __DRI_ATTRIB_TRANSPARENT_INDEX_VALUE 24
537537+#define __DRI_ATTRIB_TRANSPARENT_RED_VALUE 25
538538+#define __DRI_ATTRIB_TRANSPARENT_GREEN_VALUE 26
539539+#define __DRI_ATTRIB_TRANSPARENT_BLUE_VALUE 27
540540+#define __DRI_ATTRIB_TRANSPARENT_ALPHA_VALUE 28
541541+#define __DRI_ATTRIB_FLOAT_MODE 29
542542+#define __DRI_ATTRIB_RED_MASK 30
543543+#define __DRI_ATTRIB_GREEN_MASK 31
544544+#define __DRI_ATTRIB_BLUE_MASK 32
545545+#define __DRI_ATTRIB_ALPHA_MASK 33
546546+#define __DRI_ATTRIB_MAX_PBUFFER_WIDTH 34
547547+#define __DRI_ATTRIB_MAX_PBUFFER_HEIGHT 35
548548+#define __DRI_ATTRIB_MAX_PBUFFER_PIXELS 36
549549+#define __DRI_ATTRIB_OPTIMAL_PBUFFER_WIDTH 37
550550+#define __DRI_ATTRIB_OPTIMAL_PBUFFER_HEIGHT 38
551551+#define __DRI_ATTRIB_VISUAL_SELECT_GROUP 39
552552+#define __DRI_ATTRIB_SWAP_METHOD 40
553553+#define __DRI_ATTRIB_MAX_SWAP_INTERVAL 41
554554+#define __DRI_ATTRIB_MIN_SWAP_INTERVAL 42
555555+#define __DRI_ATTRIB_BIND_TO_TEXTURE_RGB 43
556556+#define __DRI_ATTRIB_BIND_TO_TEXTURE_RGBA 44
557557+#define __DRI_ATTRIB_BIND_TO_MIPMAP_TEXTURE 45
558558+#define __DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS 46
559559+#define __DRI_ATTRIB_YINVERTED 47
560560+#define __DRI_ATTRIB_FRAMEBUFFER_SRGB_CAPABLE 48
561561+562562+/* __DRI_ATTRIB_RENDER_TYPE */
563563+#define __DRI_ATTRIB_RGBA_BIT 0x01
564564+#define __DRI_ATTRIB_COLOR_INDEX_BIT 0x02
565565+#define __DRI_ATTRIB_LUMINANCE_BIT 0x04
566566+#define __DRI_ATTRIB_FLOAT_BIT 0x08
567567+#define __DRI_ATTRIB_UNSIGNED_FLOAT_BIT 0x10
568568+569569+/* __DRI_ATTRIB_CONFIG_CAVEAT */
570570+#define __DRI_ATTRIB_SLOW_BIT 0x01
571571+#define __DRI_ATTRIB_NON_CONFORMANT_CONFIG 0x02
572572+573573+/* __DRI_ATTRIB_TRANSPARENT_TYPE */
574574+#define __DRI_ATTRIB_TRANSPARENT_RGB 0x00
575575+#define __DRI_ATTRIB_TRANSPARENT_INDEX 0x01
576576+577577+/* __DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS */
578578+#define __DRI_ATTRIB_TEXTURE_1D_BIT 0x01
579579+#define __DRI_ATTRIB_TEXTURE_2D_BIT 0x02
580580+#define __DRI_ATTRIB_TEXTURE_RECTANGLE_BIT 0x04
581581+582582+/**
583583+ * This extension defines the core DRI functionality.
584584+ */
585585+#define __DRI_CORE "DRI_Core"
586586+#define __DRI_CORE_VERSION 1
587587+588588+struct __DRIcoreExtensionRec {
589589+ __DRIextension base;
590590+591591+ __DRIscreen *(*createNewScreen)(int screen, int fd,
592592+ unsigned int sarea_handle,
593593+ const __DRIextension **extensions,
594594+ const __DRIconfig ***driverConfigs,
595595+ void *loaderPrivate);
596596+597597+ void (*destroyScreen)(__DRIscreen *screen);
598598+599599+ const __DRIextension **(*getExtensions)(__DRIscreen *screen);
600600+601601+ int (*getConfigAttrib)(const __DRIconfig *config,
602602+ unsigned int attrib,
603603+ unsigned int *value);
604604+605605+ int (*indexConfigAttrib)(const __DRIconfig *config, int index,
606606+ unsigned int *attrib, unsigned int *value);
607607+608608+ __DRIdrawable *(*createNewDrawable)(__DRIscreen *screen,
609609+ const __DRIconfig *config,
610610+ unsigned int drawable_id,
611611+ unsigned int head,
612612+ void *loaderPrivate);
613613+614614+ void (*destroyDrawable)(__DRIdrawable *drawable);
615615+616616+ void (*swapBuffers)(__DRIdrawable *drawable);
617617+618618+ __DRIcontext *(*createNewContext)(__DRIscreen *screen,
619619+ const __DRIconfig *config,
620620+ __DRIcontext *shared,
621621+ void *loaderPrivate);
622622+623623+ int (*copyContext)(__DRIcontext *dest,
624624+ __DRIcontext *src,
625625+ unsigned long mask);
626626+627627+ void (*destroyContext)(__DRIcontext *context);
628628+629629+ int (*bindContext)(__DRIcontext *ctx,
630630+ __DRIdrawable *pdraw,
631631+ __DRIdrawable *pread);
632632+633633+ int (*unbindContext)(__DRIcontext *ctx);
634634+};
635635+636636+/**
637637+ * Stored version of some component (i.e., server-side DRI module, kernel-side
638638+ * DRM, etc.).
639639+ *
640640+ * \todo
641641+ * There are several data structures that explicitly store a major version,
642642+ * minor version, and patch level. These structures should be modified to
643643+ * have a \c __DRIversionRec instead.
644644+ */
645645+struct __DRIversionRec {
646646+ int major; /**< Major version number. */
647647+ int minor; /**< Minor version number. */
648648+ int patch; /**< Patch-level. */
649649+};
650650+651651+/**
652652+ * Framebuffer information record. Used by libGL to communicate information
653653+ * about the framebuffer to the driver's \c __driCreateNewScreen function.
654654+ *
655655+ * In XFree86, most of this information is derrived from data returned by
656656+ * calling \c XF86DRIGetDeviceInfo.
657657+ *
658658+ * \sa XF86DRIGetDeviceInfo __DRIdisplayRec::createNewScreen
659659+ * __driUtilCreateNewScreen CallCreateNewScreen
660660+ *
661661+ * \bug This structure could be better named.
662662+ */
663663+struct __DRIframebufferRec {
664664+ unsigned char *base; /**< Framebuffer base address in the CPU's
665665+ * address space. This value is calculated by
666666+ * calling \c drmMap on the framebuffer handle
667667+ * returned by \c XF86DRIGetDeviceInfo (or a
668668+ * similar function).
669669+ */
670670+ int size; /**< Framebuffer size, in bytes. */
671671+ int stride; /**< Number of bytes from one line to the next. */
672672+ int width; /**< Pixel width of the framebuffer. */
673673+ int height; /**< Pixel height of the framebuffer. */
674674+ int dev_priv_size; /**< Size of the driver's dev-priv structure. */
675675+ void *dev_priv; /**< Pointer to the driver's dev-priv structure. */
676676+};
677677+678678+679679+/**
680680+ * This extension provides alternative screen, drawable and context
681681+ * constructors for legacy DRI functionality. This is used in
682682+ * conjunction with the core extension.
683683+ */
684684+#define __DRI_LEGACY "DRI_Legacy"
685685+#define __DRI_LEGACY_VERSION 1
686686+687687+struct __DRIlegacyExtensionRec {
688688+ __DRIextension base;
689689+690690+ __DRIscreen *(*createNewScreen)(int screen,
691691+ const __DRIversion *ddx_version,
692692+ const __DRIversion *dri_version,
693693+ const __DRIversion *drm_version,
694694+ const __DRIframebuffer *frame_buffer,
695695+ void *pSAREA, int fd,
696696+ const __DRIextension **extensions,
697697+ const __DRIconfig ***driver_configs,
698698+ void *loaderPrivate);
699699+700700+ __DRIdrawable *(*createNewDrawable)(__DRIscreen *screen,
701701+ const __DRIconfig *config,
702702+ drm_drawable_t hwDrawable,
703703+ int renderType, const int *attrs,
704704+ void *loaderPrivate);
705705+706706+ __DRIcontext *(*createNewContext)(__DRIscreen *screen,
707707+ const __DRIconfig *config,
708708+ int render_type,
709709+ __DRIcontext *shared,
710710+ drm_context_t hwContext,
711711+ void *loaderPrivate);
712712+};
713713+714714+/**
715715+ * This extension provides alternative screen, drawable and context
716716+ * constructors for swrast DRI functionality. This is used in
717717+ * conjunction with the core extension.
718718+ */
719719+#define __DRI_SWRAST "DRI_SWRast"
720720+#define __DRI_SWRAST_VERSION 4
721721+722722+struct __DRIswrastExtensionRec {
723723+ __DRIextension base;
724724+725725+ __DRIscreen *(*createNewScreen)(int screen,
726726+ const __DRIextension **extensions,
727727+ const __DRIconfig ***driver_configs,
728728+ void *loaderPrivate);
729729+730730+ __DRIdrawable *(*createNewDrawable)(__DRIscreen *screen,
731731+ const __DRIconfig *config,
732732+ void *loaderPrivate);
733733+734734+ /* Since version 2 */
735735+ __DRIcontext *(*createNewContextForAPI)(__DRIscreen *screen,
736736+ int api,
737737+ const __DRIconfig *config,
738738+ __DRIcontext *shared,
739739+ void *data);
740740+741741+ /**
742742+ * Create a context for a particular API with a set of attributes
743743+ *
744744+ * \since version 3
745745+ *
746746+ * \sa __DRIdri2ExtensionRec::createContextAttribs
747747+ */
748748+ __DRIcontext *(*createContextAttribs)(__DRIscreen *screen,
749749+ int api,
750750+ const __DRIconfig *config,
751751+ __DRIcontext *shared,
752752+ unsigned num_attribs,
753753+ const uint32_t *attribs,
754754+ unsigned *error,
755755+ void *loaderPrivate);
756756+757757+ /**
758758+ * createNewScreen() with the driver extensions passed in.
759759+ *
760760+ * \since version 4
761761+ */
762762+ __DRIscreen *(*createNewScreen2)(int screen,
763763+ const __DRIextension **loader_extensions,
764764+ const __DRIextension **driver_extensions,
765765+ const __DRIconfig ***driver_configs,
766766+ void *loaderPrivate);
767767+768768+};
769769+770770+/** Common DRI function definitions, shared among DRI2 and Image extensions
771771+ */
772772+773773+typedef __DRIscreen *
774774+(*__DRIcreateNewScreen2Func)(int screen, int fd,
775775+ const __DRIextension **extensions,
776776+ const __DRIextension **driver_extensions,
777777+ const __DRIconfig ***driver_configs,
778778+ void *loaderPrivate);
779779+780780+typedef __DRIdrawable *
781781+(*__DRIcreateNewDrawableFunc)(__DRIscreen *screen,
782782+ const __DRIconfig *config,
783783+ void *loaderPrivate);
784784+785785+typedef __DRIcontext *
786786+(*__DRIcreateContextAttribsFunc)(__DRIscreen *screen,
787787+ int api,
788788+ const __DRIconfig *config,
789789+ __DRIcontext *shared,
790790+ unsigned num_attribs,
791791+ const uint32_t *attribs,
792792+ unsigned *error,
793793+ void *loaderPrivate);
794794+795795+typedef unsigned int
796796+(*__DRIgetAPIMaskFunc)(__DRIscreen *screen);
797797+798798+/**
799799+ * DRI2 Loader extension.
800800+ */
801801+#define __DRI_BUFFER_FRONT_LEFT 0
802802+#define __DRI_BUFFER_BACK_LEFT 1
803803+#define __DRI_BUFFER_FRONT_RIGHT 2
804804+#define __DRI_BUFFER_BACK_RIGHT 3
805805+#define __DRI_BUFFER_DEPTH 4
806806+#define __DRI_BUFFER_STENCIL 5
807807+#define __DRI_BUFFER_ACCUM 6
808808+#define __DRI_BUFFER_FAKE_FRONT_LEFT 7
809809+#define __DRI_BUFFER_FAKE_FRONT_RIGHT 8
810810+#define __DRI_BUFFER_DEPTH_STENCIL 9 /**< Only available with DRI2 1.1 */
811811+#define __DRI_BUFFER_HIZ 10
812812+813813+/* Inofficial and for internal use. Increase when adding a new buffer token. */
814814+#define __DRI_BUFFER_COUNT 11
815815+816816+struct __DRIbufferRec {
817817+ unsigned int attachment;
818818+ unsigned int name;
819819+ unsigned int pitch;
820820+ unsigned int cpp;
821821+ unsigned int flags;
822822+};
823823+824824+#define __DRI_DRI2_LOADER "DRI_DRI2Loader"
825825+#define __DRI_DRI2_LOADER_VERSION 3
826826+struct __DRIdri2LoaderExtensionRec {
827827+ __DRIextension base;
828828+829829+ __DRIbuffer *(*getBuffers)(__DRIdrawable *driDrawable,
830830+ int *width, int *height,
831831+ unsigned int *attachments, int count,
832832+ int *out_count, void *loaderPrivate);
833833+834834+ /**
835835+ * Flush pending front-buffer rendering
836836+ *
837837+ * Any rendering that has been performed to the
838838+ * \c __DRI_BUFFER_FAKE_FRONT_LEFT will be flushed to the
839839+ * \c __DRI_BUFFER_FRONT_LEFT.
840840+ *
841841+ * \param driDrawable Drawable whose front-buffer is to be flushed
842842+ * \param loaderPrivate Loader's private data that was previously passed
843843+ * into __DRIdri2ExtensionRec::createNewDrawable
844844+ */
845845+ void (*flushFrontBuffer)(__DRIdrawable *driDrawable, void *loaderPrivate);
846846+847847+848848+ /**
849849+ * Get list of buffers from the server
850850+ *
851851+ * Gets a list of buffer for the specified set of attachments. Unlike
852852+ * \c ::getBuffers, this function takes a list of attachments paired with
853853+ * opaque \c unsigned \c int value describing the format of the buffer.
854854+ * It is the responsibility of the caller to know what the service that
855855+ * allocates the buffers will expect to receive for the format.
856856+ *
857857+ * \param driDrawable Drawable whose buffers are being queried.
858858+ * \param width Output where the width of the buffers is stored.
859859+ * \param height Output where the height of the buffers is stored.
860860+ * \param attachments List of pairs of attachment ID and opaque format
861861+ * requested for the drawable.
862862+ * \param count Number of attachment / format pairs stored in
863863+ * \c attachments.
864864+ * \param loaderPrivate Loader's private data that was previously passed
865865+ * into __DRIdri2ExtensionRec::createNewDrawable.
866866+ */
867867+ __DRIbuffer *(*getBuffersWithFormat)(__DRIdrawable *driDrawable,
868868+ int *width, int *height,
869869+ unsigned int *attachments, int count,
870870+ int *out_count, void *loaderPrivate);
871871+};
872872+873873+/**
874874+ * This extension provides alternative screen, drawable and context
875875+ * constructors for DRI2.
876876+ */
877877+#define __DRI_DRI2 "DRI_DRI2"
878878+#define __DRI_DRI2_VERSION 4
879879+880880+#define __DRI_API_OPENGL 0 /**< OpenGL compatibility profile */
881881+#define __DRI_API_GLES 1 /**< OpenGL ES 1.x */
882882+#define __DRI_API_GLES2 2 /**< OpenGL ES 2.x */
883883+#define __DRI_API_OPENGL_CORE 3 /**< OpenGL 3.2+ core profile */
884884+#define __DRI_API_GLES3 4 /**< OpenGL ES 3.x */
885885+886886+#define __DRI_CTX_ATTRIB_MAJOR_VERSION 0
887887+#define __DRI_CTX_ATTRIB_MINOR_VERSION 1
888888+#define __DRI_CTX_ATTRIB_FLAGS 2
889889+890890+/**
891891+ * \requires __DRI2_ROBUSTNESS.
892892+ */
893893+#define __DRI_CTX_ATTRIB_RESET_STRATEGY 3
894894+895895+#define __DRI_CTX_FLAG_DEBUG 0x00000001
896896+#define __DRI_CTX_FLAG_FORWARD_COMPATIBLE 0x00000002
897897+898898+/**
899899+ * \requires __DRI2_ROBUSTNESS.
900900+ */
901901+#define __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS 0x00000004
902902+903903+/**
904904+ * \name Context reset strategies.
905905+ */
906906+/*@{*/
907907+#define __DRI_CTX_RESET_NO_NOTIFICATION 0
908908+#define __DRI_CTX_RESET_LOSE_CONTEXT 1
909909+/*@}*/
910910+911911+/**
912912+ * \name Reasons that __DRIdri2Extension::createContextAttribs might fail
913913+ */
914914+/*@{*/
915915+/** Success! */
916916+#define __DRI_CTX_ERROR_SUCCESS 0
917917+918918+/** Memory allocation failure */
919919+#define __DRI_CTX_ERROR_NO_MEMORY 1
920920+921921+/** Client requested an API (e.g., OpenGL ES 2.0) that the driver can't do. */
922922+#define __DRI_CTX_ERROR_BAD_API 2
923923+924924+/** Client requested an API version that the driver can't do. */
925925+#define __DRI_CTX_ERROR_BAD_VERSION 3
926926+927927+/** Client requested a flag or combination of flags the driver can't do. */
928928+#define __DRI_CTX_ERROR_BAD_FLAG 4
929929+930930+/** Client requested an attribute the driver doesn't understand. */
931931+#define __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE 5
932932+933933+/** Client requested a flag the driver doesn't understand. */
934934+#define __DRI_CTX_ERROR_UNKNOWN_FLAG 6
935935+/*@}*/
936936+937937+struct __DRIdri2ExtensionRec {
938938+ __DRIextension base;
939939+940940+ __DRIscreen *(*createNewScreen)(int screen, int fd,
941941+ const __DRIextension **extensions,
942942+ const __DRIconfig ***driver_configs,
943943+ void *loaderPrivate);
944944+945945+ __DRIcreateNewDrawableFunc createNewDrawable;
946946+ __DRIcontext *(*createNewContext)(__DRIscreen *screen,
947947+ const __DRIconfig *config,
948948+ __DRIcontext *shared,
949949+ void *loaderPrivate);
950950+951951+ /* Since version 2 */
952952+ __DRIgetAPIMaskFunc getAPIMask;
953953+954954+ __DRIcontext *(*createNewContextForAPI)(__DRIscreen *screen,
955955+ int api,
956956+ const __DRIconfig *config,
957957+ __DRIcontext *shared,
958958+ void *data);
959959+960960+ __DRIbuffer *(*allocateBuffer)(__DRIscreen *screen,
961961+ unsigned int attachment,
962962+ unsigned int format,
963963+ int width,
964964+ int height);
965965+ void (*releaseBuffer)(__DRIscreen *screen,
966966+ __DRIbuffer *buffer);
967967+968968+ /**
969969+ * Create a context for a particular API with a set of attributes
970970+ *
971971+ * \since version 3
972972+ *
973973+ * \sa __DRIswrastExtensionRec::createContextAttribs
974974+ */
975975+ __DRIcreateContextAttribsFunc createContextAttribs;
976976+977977+ /**
978978+ * createNewScreen with the driver's extension list passed in.
979979+ *
980980+ * \since version 4
981981+ */
982982+ __DRIcreateNewScreen2Func createNewScreen2;
983983+};
984984+985985+986986+/**
987987+ * This extension provides functionality to enable various EGLImage
988988+ * extensions.
989989+ */
990990+#define __DRI_IMAGE "DRI_IMAGE"
991991+#define __DRI_IMAGE_VERSION 8
992992+993993+/**
994994+ * These formats correspond to the similarly named MESA_FORMAT_*
995995+ * tokens, except in the native endian of the CPU. For example, on
996996+ * little endian __DRI_IMAGE_FORMAT_XRGB8888 corresponds to
997997+ * MESA_FORMAT_XRGB8888, but MESA_FORMAT_XRGB8888_REV on big endian.
998998+ *
999999+ * __DRI_IMAGE_FORMAT_NONE is for images that aren't directly usable
10001000+ * by the driver (YUV planar formats) but serve as a base image for
10011001+ * creating sub-images for the different planes within the image.
10021002+ *
10031003+ * R8, GR88 and NONE should not be used with createImageFormName or
10041004+ * createImage, and are returned by query from sub images created with
10051005+ * createImageFromNames (NONE, see above) and fromPlane (R8 & GR88).
10061006+ */
10071007+#define __DRI_IMAGE_FORMAT_RGB565 0x1001
10081008+#define __DRI_IMAGE_FORMAT_XRGB8888 0x1002
10091009+#define __DRI_IMAGE_FORMAT_ARGB8888 0x1003
10101010+#define __DRI_IMAGE_FORMAT_ABGR8888 0x1004
10111011+#define __DRI_IMAGE_FORMAT_XBGR8888 0x1005
10121012+#define __DRI_IMAGE_FORMAT_R8 0x1006 /* Since version 5 */
10131013+#define __DRI_IMAGE_FORMAT_GR88 0x1007
10141014+#define __DRI_IMAGE_FORMAT_NONE 0x1008
10151015+#define __DRI_IMAGE_FORMAT_XRGB2101010 0x1009
10161016+#define __DRI_IMAGE_FORMAT_ARGB2101010 0x100a
10171017+#define __DRI_IMAGE_FORMAT_SARGB8 0x100b
10181018+10191019+#define __DRI_IMAGE_USE_SHARE 0x0001
10201020+#define __DRI_IMAGE_USE_SCANOUT 0x0002
10211021+#define __DRI_IMAGE_USE_CURSOR 0x0004 /* Depricated */
10221022+#define __DRI_IMAGE_USE_LINEAR 0x0008
10231023+10241024+10251025+/**
10261026+ * Four CC formats that matches with WL_DRM_FORMAT_* from wayland_drm.h
10271027+ * and GBM_FORMAT_* from gbm.h, used with createImageFromNames.
10281028+ *
10291029+ * \since 5
10301030+ */
10311031+10321032+#define __DRI_IMAGE_FOURCC_RGB565 0x36314752
10331033+#define __DRI_IMAGE_FOURCC_ARGB8888 0x34325241
10341034+#define __DRI_IMAGE_FOURCC_XRGB8888 0x34325258
10351035+#define __DRI_IMAGE_FOURCC_ABGR8888 0x34324241
10361036+#define __DRI_IMAGE_FOURCC_XBGR8888 0x34324258
10371037+#define __DRI_IMAGE_FOURCC_YUV410 0x39565559
10381038+#define __DRI_IMAGE_FOURCC_YUV411 0x31315559
10391039+#define __DRI_IMAGE_FOURCC_YUV420 0x32315559
10401040+#define __DRI_IMAGE_FOURCC_YUV422 0x36315559
10411041+#define __DRI_IMAGE_FOURCC_YUV444 0x34325559
10421042+#define __DRI_IMAGE_FOURCC_NV12 0x3231564e
10431043+#define __DRI_IMAGE_FOURCC_NV16 0x3631564e
10441044+#define __DRI_IMAGE_FOURCC_YUYV 0x56595559
10451045+10461046+10471047+/**
10481048+ * Queryable on images created by createImageFromNames.
10491049+ *
10501050+ * RGB and RGBA are may be usable directly as images but its still
10511051+ * recommended to call fromPlanar with plane == 0.
10521052+ *
10531053+ * Y_U_V, Y_UV and Y_XUXV all requires call to fromPlanar to create
10541054+ * usable sub-images, sampling from images return raw YUV data and
10551055+ * color conversion needs to be done in the shader.
10561056+ *
10571057+ * \since 5
10581058+ */
10591059+10601060+#define __DRI_IMAGE_COMPONENTS_RGB 0x3001
10611061+#define __DRI_IMAGE_COMPONENTS_RGBA 0x3002
10621062+#define __DRI_IMAGE_COMPONENTS_Y_U_V 0x3003
10631063+#define __DRI_IMAGE_COMPONENTS_Y_UV 0x3004
10641064+#define __DRI_IMAGE_COMPONENTS_Y_XUXV 0x3005
10651065+10661066+10671067+/**
10681068+ * queryImage attributes
10691069+ */
10701070+10711071+#define __DRI_IMAGE_ATTRIB_STRIDE 0x2000
10721072+#define __DRI_IMAGE_ATTRIB_HANDLE 0x2001
10731073+#define __DRI_IMAGE_ATTRIB_NAME 0x2002
10741074+#define __DRI_IMAGE_ATTRIB_FORMAT 0x2003 /* available in versions 3+ */
10751075+#define __DRI_IMAGE_ATTRIB_WIDTH 0x2004 /* available in versions 4+ */
10761076+#define __DRI_IMAGE_ATTRIB_HEIGHT 0x2005
10771077+#define __DRI_IMAGE_ATTRIB_COMPONENTS 0x2006 /* available in versions 5+ */
10781078+#define __DRI_IMAGE_ATTRIB_FD 0x2007 /* available in versions
10791079+ * 7+. Each query will return a
10801080+ * new fd. */
10811081+10821082+enum __DRIYUVColorSpace {
10831083+ __DRI_YUV_COLOR_SPACE_UNDEFINED = 0,
10841084+ __DRI_YUV_COLOR_SPACE_ITU_REC601 = 0x327F,
10851085+ __DRI_YUV_COLOR_SPACE_ITU_REC709 = 0x3280,
10861086+ __DRI_YUV_COLOR_SPACE_ITU_REC2020 = 0x3281
10871087+};
10881088+10891089+enum __DRISampleRange {
10901090+ __DRI_YUV_RANGE_UNDEFINED = 0,
10911091+ __DRI_YUV_FULL_RANGE = 0x3282,
10921092+ __DRI_YUV_NARROW_RANGE = 0x3283
10931093+};
10941094+10951095+enum __DRIChromaSiting {
10961096+ __DRI_YUV_CHROMA_SITING_UNDEFINED = 0,
10971097+ __DRI_YUV_CHROMA_SITING_0 = 0x3284,
10981098+ __DRI_YUV_CHROMA_SITING_0_5 = 0x3285
10991099+};
11001100+11011101+/**
11021102+ * \name Reasons that __DRIimageExtensionRec::createImageFromTexture might fail
11031103+ */
11041104+/*@{*/
11051105+/** Success! */
11061106+#define __DRI_IMAGE_ERROR_SUCCESS 0
11071107+11081108+/** Memory allocation failure */
11091109+#define __DRI_IMAGE_ERROR_BAD_ALLOC 1
11101110+11111111+/** Client requested an invalid attribute for a texture object */
11121112+#define __DRI_IMAGE_ERROR_BAD_MATCH 2
11131113+11141114+/** Client requested an invalid texture object */
11151115+#define __DRI_IMAGE_ERROR_BAD_PARAMETER 3
11161116+/*@}*/
11171117+11181118+typedef struct __DRIimageRec __DRIimage;
11191119+typedef struct __DRIimageExtensionRec __DRIimageExtension;
11201120+struct __DRIimageExtensionRec {
11211121+ __DRIextension base;
11221122+11231123+ __DRIimage *(*createImageFromName)(__DRIscreen *screen,
11241124+ int width, int height, int format,
11251125+ int name, int pitch,
11261126+ void *loaderPrivate);
11271127+11281128+ __DRIimage *(*createImageFromRenderbuffer)(__DRIcontext *context,
11291129+ int renderbuffer,
11301130+ void *loaderPrivate);
11311131+11321132+ void (*destroyImage)(__DRIimage *image);
11331133+11341134+ __DRIimage *(*createImage)(__DRIscreen *screen,
11351135+ int width, int height, int format,
11361136+ unsigned int use,
11371137+ void *loaderPrivate);
11381138+11391139+ GLboolean (*queryImage)(__DRIimage *image, int attrib, int *value);
11401140+11411141+ /**
11421142+ * The new __DRIimage will share the content with the old one, see dup(2).
11431143+ */
11441144+ __DRIimage *(*dupImage)(__DRIimage *image, void *loaderPrivate);
11451145+11461146+ /**
11471147+ * Validate that a __DRIimage can be used a certain way.
11481148+ *
11491149+ * \since 2
11501150+ */
11511151+ GLboolean (*validateUsage)(__DRIimage *image, unsigned int use);
11521152+11531153+ /**
11541154+ * Unlike createImageFromName __DRI_IMAGE_FORMAT is not but instead
11551155+ * __DRI_IMAGE_FOURCC and strides are in bytes not pixels. Stride is
11561156+ * also per block and not per pixel (for non-RGB, see gallium blocks).
11571157+ *
11581158+ * \since 5
11591159+ */
11601160+ __DRIimage *(*createImageFromNames)(__DRIscreen *screen,
11611161+ int width, int height, int fourcc,
11621162+ int *names, int num_names,
11631163+ int *strides, int *offsets,
11641164+ void *loaderPrivate);
11651165+11661166+ /**
11671167+ * Create an image out of a sub-region of a parent image. This
11681168+ * entry point lets us create individual __DRIimages for different
11691169+ * planes in a planar buffer (typically yuv), for example. While a
11701170+ * sub-image shares the underlying buffer object with the parent
11711171+ * image and other sibling sub-images, the life times of parent and
11721172+ * sub-images are not dependent. Destroying the parent or a
11731173+ * sub-image doesn't affect other images. The underlying buffer
11741174+ * object is free when no __DRIimage remains that references it.
11751175+ *
11761176+ * Sub-images may overlap, but rendering to overlapping sub-images
11771177+ * is undefined.
11781178+ *
11791179+ * \since 5
11801180+ */
11811181+ __DRIimage *(*fromPlanar)(__DRIimage *image, int plane,
11821182+ void *loaderPrivate);
11831183+11841184+ /**
11851185+ * Create image from texture.
11861186+ *
11871187+ * \since 6
11881188+ */
11891189+ __DRIimage *(*createImageFromTexture)(__DRIcontext *context,
11901190+ int target,
11911191+ unsigned texture,
11921192+ int depth,
11931193+ int level,
11941194+ unsigned *error,
11951195+ void *loaderPrivate);
11961196+ /**
11971197+ * Like createImageFromNames, but takes a prime fd instead.
11981198+ *
11991199+ * \since 7
12001200+ */
12011201+ __DRIimage *(*createImageFromFds)(__DRIscreen *screen,
12021202+ int width, int height, int fourcc,
12031203+ int *fds, int num_fds,
12041204+ int *strides, int *offsets,
12051205+ void *loaderPrivate);
12061206+12071207+ /**
12081208+ * Like createImageFromFds, but takes additional attributes.
12091209+ *
12101210+ * For EGL_EXT_image_dma_buf_import.
12111211+ *
12121212+ * \since 8
12131213+ */
12141214+ __DRIimage *(*createImageFromDmaBufs)(__DRIscreen *screen,
12151215+ int width, int height, int fourcc,
12161216+ int *fds, int num_fds,
12171217+ int *strides, int *offsets,
12181218+ enum __DRIYUVColorSpace color_space,
12191219+ enum __DRISampleRange sample_range,
12201220+ enum __DRIChromaSiting horiz_siting,
12211221+ enum __DRIChromaSiting vert_siting,
12221222+ unsigned *error,
12231223+ void *loaderPrivate);
12241224+};
12251225+12261226+12271227+/**
12281228+ * This extension must be implemented by the loader and passed to the
12291229+ * driver at screen creation time. The EGLImage entry points in the
12301230+ * various client APIs take opaque EGLImage handles and use this
12311231+ * extension to map them to a __DRIimage. At version 1, this
12321232+ * extensions allows mapping EGLImage pointers to __DRIimage pointers,
12331233+ * but future versions could support other EGLImage-like, opaque types
12341234+ * with new lookup functions.
12351235+ */
12361236+#define __DRI_IMAGE_LOOKUP "DRI_IMAGE_LOOKUP"
12371237+#define __DRI_IMAGE_LOOKUP_VERSION 1
12381238+12391239+typedef struct __DRIimageLookupExtensionRec __DRIimageLookupExtension;
12401240+struct __DRIimageLookupExtensionRec {
12411241+ __DRIextension base;
12421242+12431243+ __DRIimage *(*lookupEGLImage)(__DRIscreen *screen, void *image,
12441244+ void *loaderPrivate);
12451245+};
12461246+12471247+/**
12481248+ * This extension allows for common DRI2 options
12491249+ */
12501250+#define __DRI2_CONFIG_QUERY "DRI_CONFIG_QUERY"
12511251+#define __DRI2_CONFIG_QUERY_VERSION 1
12521252+12531253+typedef struct __DRI2configQueryExtensionRec __DRI2configQueryExtension;
12541254+struct __DRI2configQueryExtensionRec {
12551255+ __DRIextension base;
12561256+12571257+ int (*configQueryb)(__DRIscreen *screen, const char *var, GLboolean *val);
12581258+ int (*configQueryi)(__DRIscreen *screen, const char *var, GLint *val);
12591259+ int (*configQueryf)(__DRIscreen *screen, const char *var, GLfloat *val);
12601260+};
12611261+12621262+/**
12631263+ * Robust context driver extension.
12641264+ *
12651265+ * Existence of this extension means the driver can accept the
12661266+ * \c __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS flag and the
12671267+ * \c __DRI_CTX_ATTRIB_RESET_STRATEGY attribute in
12681268+ * \c __DRIdri2ExtensionRec::createContextAttribs.
12691269+ */
12701270+#define __DRI2_ROBUSTNESS "DRI_Robustness"
12711271+#define __DRI2_ROBUSTNESS_VERSION 1
12721272+12731273+typedef struct __DRIrobustnessExtensionRec __DRIrobustnessExtension;
12741274+struct __DRIrobustnessExtensionRec {
12751275+ __DRIextension base;
12761276+};
12771277+12781278+/**
12791279+ * DRI config options extension.
12801280+ *
12811281+ * This extension provides the XML string containing driver options for use by
12821282+ * the loader in supporting the driconf application.
12831283+ */
12841284+#define __DRI_CONFIG_OPTIONS "DRI_ConfigOptions"
12851285+#define __DRI_CONFIG_OPTIONS_VERSION 1
12861286+12871287+typedef struct __DRIconfigOptionsExtensionRec {
12881288+ __DRIextension base;
12891289+ const char *xml;
12901290+} __DRIconfigOptionsExtension;
12911291+12921292+/**
12931293+ * This extension provides a driver vtable to a set of common driver helper
12941294+ * functions (driCoreExtension, driDRI2Extension) within the driver
12951295+ * implementation, as opposed to having to pass them through a global
12961296+ * variable.
12971297+ *
12981298+ * It is not intended to be public API to the actual loader, and the vtable
12991299+ * layout may change at any time.
13001300+ */
13011301+#define __DRI_DRIVER_VTABLE "DRI_DriverVtable"
13021302+#define __DRI_DRIVER_VTABLE_VERSION 1
13031303+13041304+typedef struct __DRIDriverVtableExtensionRec {
13051305+ __DRIextension base;
13061306+ const struct __DriverAPIRec *vtable;
13071307+} __DRIDriverVtableExtension;
13081308+13091309+/**
13101310+ * Query renderer driver extension
13111311+ *
13121312+ * This allows the window system layer (either EGL or GLX) to query aspects of
13131313+ * hardware and driver support without creating a context.
13141314+ */
13151315+#define __DRI2_RENDERER_QUERY "DRI_RENDERER_QUERY"
13161316+#define __DRI2_RENDERER_QUERY_VERSION 1
13171317+13181318+#define __DRI2_RENDERER_VENDOR_ID 0x0000
13191319+#define __DRI2_RENDERER_DEVICE_ID 0x0001
13201320+#define __DRI2_RENDERER_VERSION 0x0002
13211321+#define __DRI2_RENDERER_ACCELERATED 0x0003
13221322+#define __DRI2_RENDERER_VIDEO_MEMORY 0x0004
13231323+#define __DRI2_RENDERER_UNIFIED_MEMORY_ARCHITECTURE 0x0005
13241324+#define __DRI2_RENDERER_PREFERRED_PROFILE 0x0006
13251325+#define __DRI2_RENDERER_OPENGL_CORE_PROFILE_VERSION 0x0007
13261326+#define __DRI2_RENDERER_OPENGL_COMPATIBILITY_PROFILE_VERSION 0x0008
13271327+#define __DRI2_RENDERER_OPENGL_ES_PROFILE_VERSION 0x0009
13281328+#define __DRI2_RENDERER_OPENGL_ES2_PROFILE_VERSION 0x000a
13291329+13301330+typedef struct __DRI2rendererQueryExtensionRec __DRI2rendererQueryExtension;
13311331+struct __DRI2rendererQueryExtensionRec {
13321332+ __DRIextension base;
13331333+13341334+ int (*queryInteger)(__DRIscreen *screen, int attribute, unsigned int *val);
13351335+ int (*queryString)(__DRIscreen *screen, int attribute, const char **val);
13361336+};
13371337+13381338+/**
13391339+ * Image Loader extension. Drivers use this to allocate color buffers
13401340+ */
13411341+13421342+enum __DRIimageBufferMask {
13431343+ __DRI_IMAGE_BUFFER_BACK = (1 << 0),
13441344+ __DRI_IMAGE_BUFFER_FRONT = (1 << 1)
13451345+};
13461346+13471347+struct __DRIimageList {
13481348+ uint32_t image_mask;
13491349+ __DRIimage *back;
13501350+ __DRIimage *front;
13511351+};
13521352+13531353+#define __DRI_IMAGE_LOADER "DRI_IMAGE_LOADER"
13541354+#define __DRI_IMAGE_LOADER_VERSION 1
13551355+13561356+struct __DRIimageLoaderExtensionRec {
13571357+ __DRIextension base;
13581358+13591359+ /**
13601360+ * Allocate color buffers.
13611361+ *
13621362+ * \param driDrawable
13631363+ * \param width Width of allocated buffers
13641364+ * \param height Height of allocated buffers
13651365+ * \param format one of __DRI_IMAGE_FORMAT_*
13661366+ * \param stamp Address of variable to be updated when
13671367+ * getBuffers must be called again
13681368+ * \param loaderPrivate The loaderPrivate for driDrawable
13691369+ * \param buffer_mask Set of buffers to allocate
13701370+ * \param buffers Returned buffers
13711371+ */
13721372+ int (*getBuffers)(__DRIdrawable *driDrawable,
13731373+ unsigned int format,
13741374+ uint32_t *stamp,
13751375+ void *loaderPrivate,
13761376+ uint32_t buffer_mask,
13771377+ struct __DRIimageList *buffers);
13781378+13791379+ /**
13801380+ * Flush pending front-buffer rendering
13811381+ *
13821382+ * Any rendering that has been performed to the
13831383+ * fake front will be flushed to the front
13841384+ *
13851385+ * \param driDrawable Drawable whose front-buffer is to be flushed
13861386+ * \param loaderPrivate Loader's private data that was previously passed
13871387+ * into __DRIdri2ExtensionRec::createNewDrawable
13881388+ */
13891389+ void (*flushFrontBuffer)(__DRIdrawable *driDrawable, void *loaderPrivate);
13901390+};
13911391+13921392+/**
13931393+ * DRI extension.
13941394+ */
13951395+13961396+#define __DRI_IMAGE_DRIVER "DRI_IMAGE_DRIVER"
13971397+#define __DRI_IMAGE_DRIVER_VERSION 1
13981398+13991399+struct __DRIimageDriverExtensionRec {
14001400+ __DRIextension base;
14011401+14021402+ /* Common DRI functions, shared with DRI2 */
14031403+ __DRIcreateNewScreen2Func createNewScreen2;
14041404+ __DRIcreateNewDrawableFunc createNewDrawable;
14051405+ __DRIcreateContextAttribsFunc createContextAttribs;
14061406+ __DRIgetAPIMaskFunc getAPIMask;
14071407+};
14081408+14091409+#endif
···11+#!/bin/bash
22+33+export PATH=@PATH@:$PATH
44+55+export FONTCONFIG_FILE="@FONTCONFIG_FILE@"
66+ENCODINGSDIR="@ENCODINGSDIR@"
77+FC_LOCKFILE=""
88+99+# Are we caching system fonts or user fonts?
1010+system=0
1111+1212+# Are we including OSX font dirs ({/,~/,/System/}Library/Fonts)
1313+osxfonts=1
1414+1515+# Do we want to force a recache?
1616+force=0
1717+1818+# How noisy are we?
1919+verbose=0
2020+2121+# Check if the data in the given directory is newer than its cache
2222+check_dirty() {
2323+ local dir=$1
2424+ local fontfiles=""
2525+ local retval=1
2626+2727+ # If the dir does not exist, we just exit
2828+ if [[ ! -d "${dir}" ]]; then
2929+ return 1
3030+ fi
3131+3232+ # Create a list of all files in the dir
3333+ # Filter out config / cache files. Ugly... counting down the day until
3434+ # xfs finally goes away
3535+ fontfiles="$(find ${dir}/ -maxdepth 1 -type f | awk '$0 !~ /fonts\..*$|^.*\.dir$/ {print}')"
3636+3737+ # Fonts were deleted (or never there). Kill off the caches
3838+ if [[ -z "${fontfiles}" ]] ; then
3939+ local f
4040+ for f in "${dir}"/fonts.* "${dir}"/encodings.dir; do
4141+ if [[ -f ${f} ]] ; then
4242+ rm -f "${f}"
4343+ fi
4444+ done
4545+ return 1
4646+ fi
4747+4848+ # Force a recache
4949+ if [[ ${force} == 1 ]] ; then
5050+ retval=0
5151+ fi
5252+5353+ # If we don't have our caches, we are dirty
5454+ if [[ ! -f "${dir}/fonts.list" || ! -f "${dir}/fonts.dir" || ! -f "${dir}/encodings.dir" ]]; then
5555+ retval=0
5656+ fi
5757+5858+ # Check that no files were added or removed....
5959+ if [[ "${retval}" -ne 0 && "$(cat ${dir}/fonts.list)" != "${fontfiles}" ]] ; then
6060+ retval=0
6161+ fi
6262+6363+ # Check that no files were updated....
6464+ if [[ "${retval}" -ne 0 ]] ; then
6565+ local changed="$(find ${dir}/ -type f -cnewer ${dir}/fonts.dir | awk '$0 !~ /fonts\..*$|^.*\.dir$/ {print}')"
6666+6767+ if [[ -n "${changed}" ]] ; then
6868+ retval=0
6969+ fi
7070+ fi
7171+7272+ # Recreate fonts.list since something changed
7373+ if [[ "${retval}" == 0 ]] ; then
7474+ echo "${fontfiles}" > "${dir}"/fonts.list
7575+ fi
7676+7777+ return ${retval}
7878+}
7979+8080+get_fontdirs() {
8181+ local d
8282+ if [[ $system == 1 ]] ; then
8383+ if [[ $osxfonts == 1 ]] ; then
8484+ find {/System/,/}Library/Fonts -type d
8585+ fi
8686+ else
8787+ if [[ $osxfonts == 1 && -d "${HOME}/Library/Fonts" ]] ; then
8888+ find "${HOME}/Library/Fonts" -type d
8989+ fi
9090+9191+ if [[ -d "${HOME}/.fonts" ]] ; then
9292+ find "${HOME}/.fonts" -type d
9393+ fi
9494+ fi
9595+}
9696+9797+setup_fontdirs() {
9898+ local x=""
9999+ local fontdirs=""
100100+ local changed="no"
101101+102102+ umask 022
103103+104104+ if [[ $system == 1 ]] ; then
105105+ echo "font_cache: Scanning system font directories to generate X11 font caches"
106106+ else
107107+ echo "font_cache: Scanning user font directories to generate X11 font caches"
108108+ fi
109109+110110+ OIFS=$IFS
111111+ IFS='
112112+'
113113+ for x in $(get_fontdirs) ; do
114114+ if [[ -d "${x}" ]] && check_dirty "${x}" ; then
115115+ if [[ -z "${fontdirs}" ]] ; then
116116+ fontdirs="${x}"
117117+ else
118118+ fontdirs="${fontdirs}${IFS}${x}"
119119+ fi
120120+ fi
121121+ done
122122+123123+ if [[ -n "${fontdirs}" ]] ; then
124124+ echo "font_cache: Making fonts.dir for updated directories."
125125+ for x in ${fontdirs} ; do
126126+ if [[ $verbose == 1 ]] ; then
127127+ echo "font_cache: ${x}"
128128+ fi
129129+130130+ # First, generate fonts.scale for scaleable fonts that might be there
131131+ @MKFONTSCALE@ \
132132+ -a $ENCODINGSDIR/encodings.dir \
133133+ -a $ENCODINGSDIR/large/encodings.dir \
134134+ -- ${x}
135135+136136+ # Next, generate fonts.dir
137137+ if [[ $verbose == 1 ]] ; then
138138+ @MKFONTDIR@ \
139139+ -e $ENCODINGSDIR \
140140+ -e $ENCODINGSDIR/large \
141141+ -- ${x}
142142+ else
143143+ @MKFONTDIR@ \
144144+ -e $ENCODINGSDIR \
145145+ -e $ENCODINGSDIR/large \
146146+ -- ${x} > /dev/null
147147+ fi
148148+ done
149149+ fi
150150+ IFS=$OIFS
151151+152152+ # Finally, update fontconfig's cache
153153+ echo "font_cache: Updating FC cache"
154154+ if [[ $system == 1 ]] ; then
155155+ @FC_CACHE@ -s \
156156+ $([[ $force == 1 ]] && echo "-f -r") \
157157+ $([[ $verbose == 1 ]] && echo "-v")
158158+ else
159159+ @FC_CACHE@ \
160160+ $([[ $force == 1 ]] && echo "-f -r") \
161161+ $([[ $verbose == 1 ]] && echo "-v")
162162+ fi
163163+ echo "font_cache: Done"
164164+}
165165+166166+do_usage() {
167167+ echo "font_cache [options]"
168168+ echo " -f, --force : Force cache recreation"
169169+ echo " -n, --no-osxfonts : Just cache X11 font directories"
170170+ echo " (-n just pertains to XFont cache, not fontconfig)"
171171+ echo " -s, --system : Cache system font dirs instead of user dirs"
172172+ echo " -v, --verbose : Verbose Output"
173173+}
174174+175175+cleanup() {
176176+ [[ -r "${FC_LOCKFILE}" ]] && rm -f "${FC_LOCKFILE}"
177177+ exit 1
178178+}
179179+180180+while [[ $# -gt 0 ]] ; do
181181+ case $1 in
182182+ -s|--system) system=1 ;;
183183+ -f|--force) force=1 ;;
184184+ -v|--verbose) verbose=1 ;;
185185+ -n|--no-osxfonts) osxfonts=0 ;;
186186+ --help) do_usage ; exit 0 ;;
187187+ *) do_usage ; exit 1 ;;
188188+ esac
189189+ shift
190190+done
191191+192192+if [[ $system == 1 ]] ; then
193193+ FC_LOCKFILE="/tmp/font_cache.$UID.lock"
194194+elif [[ -w "${TMPDIR}" ]] ; then
195195+ FC_LOCKFILE="${TMPDIR}/font_cache.lock"
196196+elif [[ -w "/tmp" ]] ; then
197197+ FC_LOCKFILE="/tmp/font_cache.$UID.lock"
198198+else
199199+ FC_LOCKFILE="${HOME}/.font_cache.lock"
200200+fi
201201+202202+if [[ -x /usr/bin/lockfile ]] ; then
203203+ if /usr/bin/lockfile -r 0 -l 240 -s 4 -! "${FC_LOCKFILE}" ; then
204204+ echo "font_cache is already running." >&2
205205+ echo "If you believe this to be erroneous, please remove ${FC_LOCKFILE}." >&2
206206+ exit 1
207207+ fi
208208+else
209209+ if [[ -r "${FC_LOCKFILE}" ]] ; then
210210+ read OLD_PID < "${FC_LOCKFILE}"
211211+ if kill -0 ${OLD_PID} >& /dev/null ; then
212212+ echo "font_cache is already running with PID ${OLD_PID}." >&2
213213+ echo "If you believe this to be erroneous, please remove ${FC_LOCKFILE}." >&2
214214+ exit 1
215215+ fi
216216+217217+ echo "Removing stale ${FC_LOCKFILE}" >&2
218218+ rm -f "${FC_LOCKFILE}"
219219+ fi
220220+221221+ echo $$ > "${FC_LOCKFILE}"
222222+223223+ if [[ ! -r "${FC_LOCKFILE}" ]] ; then
224224+ echo "Unable to write to ${FC_LOCKFILE}." >&2
225225+ exit 1
226226+ fi
227227+228228+ # Now make sure we didn't collide mid-air
229229+ read OLD_PID < "${FC_LOCKFILE}"
230230+ if [[ $$ != ${OLD_PID} ]] ; then
231231+ echo "font_cache is already running with PID ${OLD_PID}." >&2
232232+ exit 1
233233+ fi
234234+fi
235235+236236+trap cleanup SIGINT SIGQUIT SIGABRT SIGTERM
237237+238238+setup_fontdirs
239239+240240+rm -f "${FC_LOCKFILE}"
···11+require 'rexml/document'
22+33+# This script is for setting environment variables in OSX applications.
44+#
55+# This script takes two arguments:
66+# 1) A Nix attrset serialized via `builtins.toXML'
77+# 2) The path to an OSX app's Info.plist file.
88+99+def main(serialized_attrs, plist_path)
1010+ env = attrs_to_hash(serialized_attrs)
1111+ doc = REXML::Document.new(File.open(plist_path, &:read))
1212+ topmost_dict = doc.root.elements.detect { |e| e.name == "dict" }
1313+ topmost_dict.add_element("key").tap do |key|
1414+ key.text = "LSEnvironment"
1515+ end
1616+ topmost_dict.add_element(env_to_dict(env))
1717+1818+ formatter = REXML::Formatters::Pretty.new(2)
1919+ formatter.compact = true
2020+ formatter.write(doc, File.open(plist_path, "w"))
2121+end
2222+2323+# Convert a `builtins.toXML' serialized attrs to a hash.
2424+# This assumes the values are strings.
2525+def attrs_to_hash(serialized_attrs)
2626+ hash = {}
2727+ env_vars = REXML::Document.new(serialized_attrs)
2828+ env_vars.root.elements[1].elements.each do |attr|
2929+ name = attr.attribute("name")
3030+ value = attr.elements.first.attribute("value")
3131+ hash[name] = value
3232+ end
3333+ hash
3434+end
3535+3636+def env_to_dict(env)
3737+ dict = REXML::Element.new("dict")
3838+ env.each do |k, v|
3939+ key = dict.add_element("key")
4040+ key.text = k
4141+ string = dict.add_element("string")
4242+ string.text = v
4343+ end
4444+ dict
4545+end
4646+4747+main(ARGV[0], ARGV[1])
+43
pkgs/servers/x11/xquartz/privileged
···11+#!/bin/sh
22+33+export PATH=@PATH@:$PATH
44+export FONTCONFIG_FILE="@FONTCONFIG_FILE@"
55+66+# Our usage of mktemp fails with GNU, so prefer /usr/bin to hopefully
77+# get BSD mktemp
88+if [ -x /usr/bin/mktemp ] ; then
99+ MKTEMP=/usr/bin/mktemp
1010+else
1111+ MKTEMP=mktemp
1212+fi
1313+1414+STAT=/usr/bin/stat
1515+1616+for dir in /tmp/.ICE-unix /tmp/.X11-unix /tmp/.font-unix ; do
1717+ success=0
1818+ for attempt in 1 2 3 4 5 ; do
1919+ check=`${STAT} -f '%#p %u %g' ${dir} 2> /dev/null`
2020+ if [ "${check}" = "041777 0 0" ] ; then
2121+ success=1
2222+ break
2323+ elif [ -n "${check}" ] ; then
2424+ saved=$(${MKTEMP} -d ${dir}-XXXXXXXX)
2525+ mv ${dir} ${saved}
2626+ echo "${dir} exists but is insecure. It has been moved into ${saved}" >&2
2727+ fi
2828+2929+ # if $dir exists and is a symlink (ie protect against a race)
3030+ if ${MKTEMP} -d ${dir} >& /dev/null ; then
3131+ chmod 1777 $dir
3232+ chown root:wheel $dir
3333+ success=1
3434+ break
3535+ fi
3636+ done
3737+3838+ if [ "${success}" -eq 0 ] ; then
3939+ echo "Could not successfully create ${dir}" >&2
4040+ fi
4141+done
4242+4343+@FONT_CACHE@ -s &
+232
pkgs/servers/x11/xquartz/startx
···11+#!/bin/sh
22+33+# vim :set ts=4 sw=4 sts=4 et :
44+55+#
66+# This is just a sample implementation of a slightly less primitive
77+# interface than xinit. It looks for user .xinitrc and .xserverrc
88+# files, then system xinitrc and xserverrc files, else lets xinit choose
99+# its default. The system xinitrc should probably do things like check
1010+# for .Xresources files and merge them in, start up a window manager,
1111+# and pop a clock and several xterms.
1212+#
1313+# Site administrators are STRONGLY urged to write nicer versions.
1414+#
1515+1616+unset DBUS_SESSION_BUS_ADDRESS
1717+unset SESSION_MANAGER
1818+1919+2020+# Bourne shell does not automatically export modified environment variables
2121+# so export the new PATH just in case the user changes the shell
2222+export PATH=@PATH@:$PATH
2323+2424+export FONTCONFIG_FILE="@FONTCONFIG_FILE@"
2525+2626+userclientrc=$HOME/.xinitrc
2727+sysclientrc=@XINITRC@
2828+2929+userserverrc=$HOME/.xserverrc
3030+sysserverrc=@XINITRC@
3131+defaultclient=@DEFAULT_CLIENT@ # xterm
3232+defaultserver=@DEFAULT_SERVER@
3333+defaultclientargs=""
3434+defaultserverargs=""
3535+defaultdisplay=":0"
3636+clientargs=""
3737+serverargs=""
3838+3939+export X11_PREFS_DOMAIN=org.nixos.xquartz".X11"
4040+4141+# Initialize defaults (this will cut down on "safe" error messages)
4242+if ! /usr/bin/defaults read $X11_PREFS_DOMAIN cache_fonts > /dev/null 2>&1 ; then
4343+ /usr/bin/defaults write $X11_PREFS_DOMAIN cache_fonts -bool true
4444+fi
4545+4646+if ! /usr/bin/defaults read $X11_PREFS_DOMAIN no_auth > /dev/null 2>&1 ; then
4747+ /usr/bin/defaults write $X11_PREFS_DOMAIN no_auth -bool false
4848+fi
4949+5050+if ! /usr/bin/defaults read $X11_PREFS_DOMAIN nolisten_tcp > /dev/null 2>&1 ; then
5151+ /usr/bin/defaults write $X11_PREFS_DOMAIN nolisten_tcp -bool true
5252+fi
5353+5454+# First, start caching fonts
5555+if [ x`/usr/bin/defaults read $X11_PREFS_DOMAIN cache_fonts` = x1 ] ; then
5656+ @FONT_CACHE@ &
5757+fi
5858+5959+# a race to create /tmp/.X11-unix
6060+@PRIVILEGED_STARTX@
6161+6262+if [ x`/usr/bin/defaults read $X11_PREFS_DOMAIN no_auth` = x0 ] ; then
6363+ enable_xauth=1
6464+else
6565+ enable_xauth=0
6666+fi
6767+6868+if [ x`defaults read $X11_PREFS_DOMAIN nolisten_tcp` = x1 ] ; then
6969+ defaultserverargs="$defaultserverargs -nolisten tcp"
7070+fi
7171+7272+# The second check is the real one. The first is to hopefully avoid
7373+# needless syslog spamming.
7474+if /usr/bin/defaults read $X11_PREFS_DOMAIN 2> /dev/null | grep -q 'dpi' && /usr/bin/defaults read $X11_PREFS_DOMAIN dpi > /dev/null 2>&1 ; then
7575+ defaultserverargs="$defaultserverargs -dpi `/usr/bin/defaults read $X11_PREFS_DOMAIN dpi`"
7676+fi
7777+7878+# Automatically determine an unused $DISPLAY
7979+d=0
8080+while true ; do
8181+ [ -e /tmp/.X$d-lock ] || break
8282+ d=$(($d + 1))
8383+done
8484+defaultdisplay=":$d"
8585+unset d
8686+8787+whoseargs="client"
8888+while [ x"$1" != x ]; do
8989+ case "$1" in
9090+ # '' required to prevent cpp from treating "/*" as a C comment.
9191+ /''*|\./''*)
9292+ if [ "$whoseargs" = "client" ]; then
9393+ if [ x"$client" = x ] && [ x"$clientargs" = x ]; then
9494+ client="$1"
9595+ else
9696+ clientargs="$clientargs $1"
9797+ fi
9898+ else
9999+ if [ x"$server" = x ] && [ x"$serverargs" = x ]; then
100100+ server="$1"
101101+ else
102102+ serverargs="$serverargs $1"
103103+ fi
104104+ fi
105105+ ;;
106106+ --)
107107+ whoseargs="server"
108108+ ;;
109109+ *)
110110+ if [ "$whoseargs" = "client" ]; then
111111+ clientargs="$clientargs $1"
112112+ else
113113+ # display must be the FIRST server argument
114114+ if [ x"$serverargs" = x ] && \
115115+ expr "$1" : ':[0-9][0-9]*$' > /dev/null 2>&1; then
116116+ display="$1"
117117+ else
118118+ serverargs="$serverargs $1"
119119+ fi
120120+ fi
121121+ ;;
122122+ esac
123123+ shift
124124+done
125125+126126+# process client arguments
127127+if [ x"$client" = x ]; then
128128+ client=$defaultclient
129129+130130+ # For compatibility reasons, only use startxrc if there were no client command line arguments
131131+ if [ x"$clientargs" = x ]; then
132132+ if [ -f "$userclientrc" ]; then
133133+ client=$userclientrc
134134+ elif [ -f "$sysclientrc" ]; then
135135+ client=$sysclientrc
136136+ fi
137137+ fi
138138+fi
139139+140140+# if no client arguments, use defaults
141141+if [ x"$clientargs" = x ]; then
142142+ clientargs=$defaultclientargs
143143+fi
144144+145145+# process server arguments
146146+if [ x"$server" = x ]; then
147147+ server=$defaultserver
148148+149149+ # For compatibility reasons, only use xserverrc if there were no server command line arguments
150150+ if [ x"$serverargs" = x -a x"$display" = x ]; then
151151+ if [ -f "$userserverrc" ]; then
152152+ server=$userserverrc
153153+ elif [ -f "$sysserverrc" ]; then
154154+ server=$sysserverrc
155155+ fi
156156+ fi
157157+fi
158158+159159+# if no server arguments, use defaults
160160+if [ x"$serverargs" = x ]; then
161161+ serverargs=$defaultserverargs
162162+fi
163163+164164+# if no display, use default
165165+if [ x"$display" = x ]; then
166166+ display=$defaultdisplay
167167+fi
168168+169169+if [ x"$enable_xauth" = x1 ] ; then
170170+ if [ x"$XAUTHORITY" = x ]; then
171171+ XAUTHORITY=$HOME/.Xauthority
172172+ export XAUTHORITY
173173+ fi
174174+175175+ removelist=
176176+177177+ # set up default Xauth info for this machine
178178+ hostname=`/bin/hostname`
179179+180180+ authdisplay=${display:-:0}
181181+182182+ mcookie=`/usr/bin/openssl rand -hex 16`
183183+184184+ if test x"$mcookie" = x; then
185185+ echo "Couldn't create cookie"
186186+ exit 1
187187+ fi
188188+ dummy=0
189189+190190+ # create a file with auth information for the server. ':0' is a dummy.
191191+ xserverauthfile=$HOME/.serverauth.$$
192192+ trap "rm -f '$xserverauthfile'" HUP INT QUIT ILL TRAP KILL BUS TERM
193193+ @XAUTH@ -q -f "$xserverauthfile" << EOF
194194+add :$dummy . $mcookie
195195+EOF
196196+197197+ xserverauthfilequoted=$(echo ${xserverauthfile} | sed "s/'/'\\\\''/g")
198198+ serverargs=${serverargs}" -auth '"${xserverauthfilequoted}"'"
199199+200200+ # now add the same credentials to the client authority file
201201+ # if '$displayname' already exists do not overwrite it as another
202202+ # server man need it. Add them to the '$xserverauthfile' instead.
203203+ for displayname in $authdisplay $hostname$authdisplay; do
204204+ authcookie=`@XAUTH@ list "$displayname" \
205205+ | sed -n "s/.*$displayname[[:space:]*].*[[:space:]*]//p"` 2>/dev/null;
206206+ if [ "z${authcookie}" = "z" ] ; then
207207+ @XAUTH@ -q << EOF
208208+add $displayname . $mcookie
209209+EOF
210210+ removelist="$displayname $removelist"
211211+ else
212212+ dummy=$(($dummy+1));
213213+ @XAUTH@ -q -f "$xserverauthfile" << EOF
214214+add :$dummy . $authcookie
215215+EOF
216216+ fi
217217+ done
218218+fi
219219+220220+eval @XINIT@ \"$client\" $clientargs -- \"$server\" $display $serverargs "-xkbdir" "@XKEYBOARD_CONFIG@"
221221+retval=$?
222222+223223+if [ x"$enable_xauth" = x1 ] ; then
224224+ if [ x"$removelist" != x ]; then
225225+ @XAUTH@ remove $removelist
226226+ fi
227227+ if [ x"$xserverauthfile" != x ]; then
228228+ rm -f "$xserverauthfile"
229229+ fi
230230+fi
231231+232232+exit $retval
+36
pkgs/servers/x11/xquartz/system-fonts.nix
···11+{ stdenv, xorg, fontDirs }:
22+33+stdenv.mkDerivation {
44+ name = "xquartz-system-fonts";
55+ buildInputs = [
66+ xorg.mkfontdir xorg.mkfontscale
77+ ];
88+ buildCommand = ''
99+ source $stdenv/setup
1010+1111+ for i in ${toString fontDirs} ; do
1212+ if [ -d $i/ ]; then
1313+ list="$list $i";
1414+ fi;
1515+ done
1616+ list=$(find $list -name fonts.dir -o -name '*.ttf' -o -name '*.otf');
1717+ fontDirs=''';
1818+ for i in $list ; do
1919+ fontDirs="$fontDirs $(dirname $i)";
2020+ done;
2121+ mkdir -p $out/share/X11-fonts/;
2222+ find $fontDirs -type f -o -type l | while read i; do
2323+ j="''${i##*/}"
2424+ if ! test -e "$out/share/X11-fonts/''${j}"; then
2525+ ln -s "$i" "$out/share/X11-fonts/''${j}";
2626+ fi;
2727+ done;
2828+ cd $out/share/X11-fonts/
2929+ rm fonts.dir
3030+ rm fonts.scale
3131+ rm fonts.alias
3232+ mkfontdir
3333+ mkfontscale
3434+ cat $( find ${xorg.fontalias}/ -name fonts.alias) >fonts.alias
3535+ '';
3636+}
+40
pkgs/servers/x11/xquartz/xinitrc
···11+#!/bin/sh
22+33+export PATH=@PATH@:$PATH
44+55+userresources=$HOME/.Xresources
66+usermodmap=$HOME/.Xmodmap
77+88+# Fix ridiculously slow key repeat.
99+@XSET@ r rate
1010+1111+# merge in defaults and keymaps
1212+1313+if [ -f "$userresources" ]; then
1414+ if [ -x /usr/bin/cpp ] ; then
1515+ @XRDB@ -merge "$userresources"
1616+ else
1717+ @XRDB@ -nocpp -merge "$userresources"
1818+ fi
1919+fi
2020+2121+if [ -f "$usermodmap" ]; then
2222+ @XMODMAP@ "$usermodmap"
2323+fi
2424+2525+fontpath="@SYSTEM_FONTS@"
2626+[ -e "$HOME"/.fonts/fonts.dir ] && fontpath="$fontpath,$HOME/.fonts"
2727+[ -e "$HOME"/Library/Fonts/fonts.dir ] && fontpath="$fontpath,$HOME/Library/Fonts"
2828+[ -e /Library/Fonts/fonts.dir ] && fontpath="$fontpath,/Library/Fonts"
2929+[ -e /System/Library/Fonts/fonts.dir ] && fontpath="$fontpath,/System/Library/Fonts"
3030+@XSET@ fp= "$fontpath"
3131+unset fontpath
3232+3333+if [ -d "${HOME}/.xinitrc.d" ] ; then
3434+ for f in "${HOME}"/.xinitrc.d/*.sh ; do
3535+ [ -x "$f" ] && . "$f"
3636+ done
3737+ unset f
3838+fi
3939+4040+exec @QUARTZ_WM@
+21-20
pkgs/top-level/all-packages.nix
···164164165165 ### Symbolic names.
166166167167- x11 = if stdenv.isDarwin then darwinX11AndOpenGL else xlibsWrapper;
167167+ x11 = xlibsWrapper;
168168169169 # `xlibs' is the set of X library components. This used to be the
170170 # old modular X llibraries project (called `xlibs') but now it's just
···4548454845494549 freealut = callPackage ../development/libraries/freealut { };
4550455045514551- freeglut = if stdenv.isDarwin then darwinX11AndOpenGL else
45524552- callPackage ../development/libraries/freeglut { };
45514551+ freeglut = callPackage ../development/libraries/freeglut { };
4553455245544553 freetype = callPackage ../development/libraries/freetype { };
45554554···5666566556675666 mesaSupported = lib.elem system lib.platforms.mesaPlatforms;
5668566756695669- mesa_original = callPackage ../development/libraries/mesa {
56685668+ mesaDarwinOr = alternative: if stdenv.isDarwin
56695669+ then callPackage ../development/libraries/mesa-darwin { }
56705670+ else alternative;
56715671+ mesa_noglu = mesaDarwinOr (callPackage ../development/libraries/mesa {
56705672 # makes it slower, but during runtime we link against just mesa_drivers
56715673 # through /run/opengl-driver*, which is overriden according to config.grsecurity
56725674 grsecEnabled = true;
56735673- };
56745674-56755675- mesa_noglu = if stdenv.isDarwin
56765676- then darwinX11AndOpenGL // { driverLink = mesa_noglu; }
56775677- else mesa_original;
56755675+ });
56765676+ mesa_glu = mesaDarwinOr (callPackage ../development/libraries/mesa-glu { });
56785677 mesa_drivers = let
56795679- mo = mesa_original.override { grsecEnabled = config.grsecurity or false; };
56785678+ mo = mesa_noglu.override { grsecEnabled = config.grsecurity or false; };
56805679 in mo.drivers;
56815681- mesa_glu = callPackage ../development/libraries/mesa-glu { };
56825682- mesa = if stdenv.isDarwin then darwinX11AndOpenGL
56835683- else buildEnv {
56845684- name = "mesa-${mesa_noglu.version}";
56855685- paths = [ mesa_glu mesa_noglu ];
56865686- };
56875687- darwinX11AndOpenGL = callPackage ../os-specific/darwin/native-x11-and-opengl { };
56805680+ mesa = mesaDarwinOr (buildEnv {
56815681+ name = "mesa-${mesa_noglu.version}";
56825682+ paths = [ mesa_noglu mesa_glu ];
56835683+ });
5688568456895685 metaEnvironment = recurseIntoAttrs (let callPackage = newScope pkgs.metaEnvironment; in rec {
56905686 sdfLibrary = callPackage ../development/libraries/sdf-library { aterm = aterm28; };
···7012700870137009 xinetd = callPackage ../servers/xinetd { };
7014701070117011+ xquartz = callPackage ../servers/x11/xquartz { };
70127012+ quartz-wm = callPackage ../servers/x11/quartz-wm { stdenv = clangStdenv; };
70137013+70157014 xorg = recurseIntoAttrs (import ../servers/x11/xorg/default.nix {
70167016- inherit fetchurl fetchgit fetchpatch stdenv pkgconfig intltool freetype fontconfig
70177017- libxslt expat libdrm libpng zlib perl mesa_drivers
70157015+ inherit clangStdenv fetchurl fetchgit fetchpatch stdenv pkgconfig intltool freetype fontconfig
70167016+ libxslt expat libpng zlib perl mesa_drivers
70187017 dbus libuuid openssl gperf m4
70197019- autoconf automake libtool xmlto asciidoc udev flex bison python mtdev pixman;
70187018+ autoconf automake libtool xmlto asciidoc flex bison python mtdev pixman;
70207019 mesa = mesa_noglu;
70207020+ udev = if stdenv.isLinux then udev else null;
70217021+ libdrm = if stdenv.isLinux then libdrm else null;
70217022 } // {
70227023 xf86videointel-testing = callPackage ../servers/x11/xorg/xf86-video-intel-testing.nix { };
70237024 });