diff options
Diffstat (limited to 'src/glx')
-rw-r--r-- | src/glx/x11/glxclient.h | 17 | ||||
-rw-r--r-- | src/glx/x11/glxcmds.c | 128 | ||||
-rw-r--r-- | src/glx/x11/glxext.c | 2 | ||||
-rw-r--r-- | src/glx/x11/xfont.c | 4 |
4 files changed, 83 insertions, 68 deletions
diff --git a/src/glx/x11/glxclient.h b/src/glx/x11/glxclient.h index b5951bd62a..05354073c4 100644 --- a/src/glx/x11/glxclient.h +++ b/src/glx/x11/glxclient.h @@ -342,16 +342,16 @@ struct __GLXcontextRec { */ GLint majorOpcode; -#ifdef GLX_DIRECT_RENDERING /** - * Per context direct rendering interface functions and data. + * Pointer to the mode used to create this context. */ - __DRIcontext driContext; + const __GLcontextModes * mode; +#ifdef GLX_DIRECT_RENDERING /** - * Pointer to the mode used to create this context. + * Per context direct rendering interface functions and data. */ - const __GLcontextModes * mode; + __DRIcontext driContext; /** * XID for the server side drm_context_t @@ -719,7 +719,12 @@ extern int __glXGetInternalVersion(void); /* Get the unadjusted system time */ extern int __glXGetUST( int64_t * ust ); -extern GLboolean __glXGetMscRateOML(__DRIdrawable *draw, +extern GLboolean __glXGetMscRateOML(Display * dpy, GLXDrawable drawable, int32_t * numerator, int32_t * denominator); +#ifdef GLX_DIRECT_RENDERING +GLboolean +__driGetMscRateOML(__DRIdrawable *draw, int32_t *numerator, int32_t *denominator); +#endif + #endif /* !__GLX_client_h__ */ diff --git a/src/glx/x11/glxcmds.c b/src/glx/x11/glxcmds.c index 848ba3bba1..2d217517af 100644 --- a/src/glx/x11/glxcmds.c +++ b/src/glx/x11/glxcmds.c @@ -2169,6 +2169,68 @@ static Bool __glXGetSyncValuesOML(Display *dpy, GLXDrawable drawable, return False; } +#ifdef GLX_DIRECT_RENDERING +GLboolean +__driGetMscRateOML(__DRIdrawable *draw, int32_t *numerator, int32_t *denominator) +{ +#ifdef XF86VIDMODE + __GLXscreenConfigs *psc; + XF86VidModeModeLine mode_line; + int dot_clock; + int i; + __GLXdrawable *glxDraw; + + glxDraw = containerOf(draw, __GLXdrawable, driDrawable); + psc = glxDraw->psc; + if (XF86VidModeQueryVersion(psc->dpy, &i, &i) && + XF86VidModeGetModeLine(psc->dpy, psc->scr, &dot_clock, &mode_line) ) { + unsigned n = dot_clock * 1000; + unsigned d = mode_line.vtotal * mode_line.htotal; + +# define V_INTERLACE 0x010 +# define V_DBLSCAN 0x020 + + if (mode_line.flags & V_INTERLACE) + n *= 2; + else if (mode_line.flags & V_DBLSCAN) + d *= 2; + + /* The OML_sync_control spec requires that if the refresh rate is a + * whole number, that the returned numerator be equal to the refresh + * rate and the denominator be 1. + */ + + if (n % d == 0) { + n /= d; + d = 1; + } + else { + static const unsigned f[] = { 13, 11, 7, 5, 3, 2, 0 }; + + /* This is a poor man's way to reduce a fraction. It's far from + * perfect, but it will work well enough for this situation. + */ + + for (i = 0; f[i] != 0; i++) { + while (n % f[i] == 0 && d % f[i] == 0) { + d /= f[i]; + n /= f[i]; + } + } + } + + *numerator = n; + *denominator = d; + + return True; + } + else + return False; +#else + return False; +#endif +} +#endif /** * Determine the refresh rate of the specified drawable and display. @@ -2186,71 +2248,19 @@ static Bool __glXGetSyncValuesOML(Display *dpy, GLXDrawable drawable, * when GLX_OML_sync_control appears in the client extension string. */ -GLboolean __glXGetMscRateOML(__DRIdrawable *draw, +GLboolean __glXGetMscRateOML(Display * dpy, GLXDrawable drawable, int32_t * numerator, int32_t * denominator) { #if defined( GLX_DIRECT_RENDERING ) && defined( XF86VIDMODE ) - __GLXdrawable *glxDraw = - containerOf(draw, __GLXdrawable, driDrawable); - __GLXscreenConfigs *psc = glxDraw->psc; - Display *dpy = psc->dpy; - __GLXdisplayPrivate * const priv = __glXInitialize(dpy); - - - if ( priv != NULL ) { - XF86VidModeModeLine mode_line; - int dot_clock; - int i; - - - if (XF86VidModeQueryVersion( dpy, & i, & i ) && - XF86VidModeGetModeLine(dpy, psc->scr, &dot_clock, &mode_line) ) { - unsigned n = dot_clock * 1000; - unsigned d = mode_line.vtotal * mode_line.htotal; - -# define V_INTERLACE 0x010 -# define V_DBLSCAN 0x020 + __DRIdrawable *driDraw = GetDRIDrawable(dpy, drawable, NULL); - if ( (mode_line.flags & V_INTERLACE) ) { - n *= 2; - } - else if ( (mode_line.flags & V_DBLSCAN) ) { - d *= 2; - } - - /* The OML_sync_control spec requires that if the refresh rate is a - * whole number, that the returned numerator be equal to the refresh - * rate and the denominator be 1. - */ - - if ( (n % d) == 0 ) { - n /= d; - d = 1; - } - else { - static const unsigned f[] = { 13, 11, 7, 5, 3, 2, 0 }; - - - /* This is a poor man's way to reduce a fraction. It's far from - * perfect, but it will work well enough for this situation. - */ - - for ( i = 0 ; f[i] != 0 ; i++ ) { - while ( ((n % f[i]) == 0) && ((d % f[i]) == 0) ) { - d /= f[i]; - n /= f[i]; - } - } - } - - *numerator = n; - *denominator = d; + if (driDraw == NULL) + return False; - return True; - } - } + return __driGetMscRateOML(driDraw, numerator, denominator); #else - (void) draw; + (void) dpy; + (void) drawable; (void) numerator; (void) denominator; #endif diff --git a/src/glx/x11/glxext.c b/src/glx/x11/glxext.c index e65b7f2043..b98d48d22d 100644 --- a/src/glx/x11/glxext.c +++ b/src/glx/x11/glxext.c @@ -788,7 +788,7 @@ static const __DRIinterfaceMethods interface_methods = { __glXDRIGetDrawableInfo, __glXGetUST, - __glXGetMscRateOML, + __driGetMscRateOML, __glXReportDamage, }; diff --git a/src/glx/x11/xfont.c b/src/glx/x11/xfont.c index 5f23a79622..843a2298b2 100644 --- a/src/glx/x11/xfont.c +++ b/src/glx/x11/xfont.c @@ -34,6 +34,7 @@ called by that routine when direct rendering is enabled. */ +#ifdef GLX_DIRECT_RENDERING #include "glxclient.h" @@ -209,7 +210,6 @@ static XCharStruct *isvalid(XFontStruct *fs, int which) return(NULL); } - void DRI_glXUseXFont( Font font, int first, int count, int listbase ) { GLXContext CC; @@ -374,4 +374,4 @@ bm_height); glPixelStorei(GL_UNPACK_ALIGNMENT, alignment); } -/* The End. */ +#endif |