assorted updates (bug #1025977)
authorBrian Paul <brian.paul@tungstengraphics.com>
Fri, 10 Sep 2004 19:19:24 +0000 (19:19 +0000)
committerBrian Paul <brian.paul@tungstengraphics.com>
Fri, 10 Sep 2004 19:19:24 +0000 (19:19 +0000)
src/mesa/drivers/ggi/default/linear.c
src/mesa/drivers/ggi/display/fbdev_mode.c
src/mesa/drivers/ggi/display/fbdev_visual.c
src/mesa/drivers/ggi/ggimesa.c
src/mesa/drivers/ggi/include/ggi/mesa/ggimesa.h
src/mesa/drivers/ggi/include/ggi/mesa/ggimesa_int.h

index ffd0acc3d3b80106e6806deb886ec3f19b296460..9d29761ad5b45336b16ac529ba009950f083acd3 100644 (file)
@@ -39,7 +39,7 @@
                      ((color[GCOMP]>>GS) << B)     |  \
                      ((color[BCOMP]>>BS)))
 
-#define FLIP(coord) (LIBGGI_MODE(ggi_ctx->ggi_visual)->visible.y-(coord) - 1)
+#define FLIP(coord) (LIBGGI_VIRTY(ggi_ctx->ggi_visual) - (coord) - 1)
 
 
 /**********************************************************************/
index 6fb952d55c68dd53310b2851847e5a1f5e658839..eee80eb4b771e07d33d4ee2502f723e21fe54d87 100644 (file)
 
 int GGIMesa_fbdev_getapi(ggi_visual *vis, int num, char *apiname, char *arguments)
 {
-       struct fbdev_priv_mesa *priv = GGIMESA_PRIVATE(vis);
+       struct fbdev_priv_mesa *priv = GGIMESA_PRIV(vis);
        
-       strcpy(arguments, "");
+       arguments = '\0';
 
-       switch(num) 
-       {
-               case 0:
-               if (priv->oldpriv->have_accel) 
-               {
+       switch(num) {
+       case 0:
+               if (priv->oldpriv->have_accel) {
                        strcpy(apiname, priv->oldpriv->accel);
                        return 0;
                }
@@ -70,17 +68,16 @@ int GGIMesa_fbdev_getapi(ggi_visual *vis, int num, char *apiname, char *argument
 
 static int do_setmode(ggi_visual *vis)
 {
-       struct fbdev_priv_mesa *priv = GGIMESA_PRIVATE(vis);
+       struct fbdev_priv_mesa *priv = GGIMESA_PRIV(vis);
        int err, id;
-       char libname[256], libargs[256];
+       char libname[GGI_API_MAXLEN], libargs[GGI_API_MAXLEN];
        ggi_graphtype gt;
 
        _ggiZapMode(vis, ~GGI_DL_OPDISPLAY);
        priv->have_accel = 0;
        for (id = 1; GGIMesa_fbdev_getapi(vis, id, libname, libargs) == 0; id++) 
        {
-               if (_ggiOpenDL(vis, libname, libargs, NULL) == 0) 
-               {
+               if (_ggiOpenDL(vis, libname, libargs, NULL) == 0) {
                        fprintf(stderr, "display-fbdev-mesa: Error opening the "
                                "%s (%s) library.\n", libname, libargs);
                        return GGI_EFATAL;
@@ -92,9 +89,7 @@ static int do_setmode(ggi_visual *vis)
        if (priv->oldpriv->accel &&
            _ggiOpenDL(vis, priv->accel, NULL, NULL) != 0) {
                priv->have_accel = 1;
-       } 
-       else 
-       {
+       } else {
                priv->have_accel = 0;
        }
        vis->accelactive = 0;
index 0176614ffba8942a304ea1b1ed8b3ffebece2113..79c16ec79634af993c9ccd68fce6bd96adcf743c 100644 (file)
@@ -76,51 +76,47 @@ char *conffile = confstub;
 
 static int changed(ggi_visual_t vis, int whatchanged)
 {
-       switch (whatchanged)
-       {
-               case GGI_CHG_APILIST:
-               {
-                       char api[256];
-                       char args[256];
-                       int i;
-                       const char *fname;
-                       ggi_dlhandle *lib;
+       switch (whatchanged) {
+       case GGI_CHG_APILIST: {
+               char api[GGI_API_MAXLEN], args[GGI_API_MAXLEN];
+               int i;
+               const char *fname;
+               ggi_dlhandle *lib;
                        
-                       for (i = 0; ggiGetAPI(vis, i, api, args) == 0; i++)
-                       {
-                               strcat(api, "-mesa");
-                               fname = ggMatchConfig(_configHandle, api, NULL);
-                               if (fname == NULL)
-                               {
-                                       /* No special implementation for this sublib */
-                                       continue;
-                               }
-                               
-                               lib = ggiExtensionLoadDL(vis, fname, args, NULL, GGI_SYMNAME_PREFIX);
+               for (i = 0; ggiGetAPI(vis, i, api, args) == 0; i++) {
+                       strcat(api, "-mesa");
+                       fname = ggMatchConfig(_configHandle, api, NULL);
+                       if (fname == NULL) {
+                               /* No special implementation for this sublib */
+                               continue;
                        }
+                               
+                       lib = ggiExtensionLoadDL(vis, fname, args, NULL, GGI_SYMNAME_PREFIX);
                }
-               break;
+       }
+       break;
        }
        return 0;
 }
 
-int GGIdlinit(ggi_visual *vis, const char *args, void *argptr)
+
+static int GGIopen(ggi_visual *vis, struct ggi_dlhandle *dlh,
+                   const char *args, void *argptr, uint32 *dlret)
 {
        struct fbdev_priv_mesa *priv;
        int err;
        ggifunc_getapi *oldgetapi;
 
-       GGIMESA_PRIVATE(vis) = priv = malloc(sizeof(struct fbdev_priv_mesa));
+       GGIMESA_PRIV(vis) = priv = malloc(sizeof(struct fbdev_priv_mesa));
        if (priv == NULL) {
                fprintf(stderr, "Failed to allocate fbdev private data\n");
-               return GGI_DL_ERROR;
+               return GGI_ENOMEM;
        }
        
        priv->oldpriv = LIBGGI_PRIVATE(vis);  /* Hook back */
        
        err = ggLoadConfig(conffile, &_configHandle);
-       if (err != GGI_OK)
-       {
+       if (err != GGI_OK) {
                GGIMESADPRINT_CORE("display-fbdev: Couldn't open %s\n", conffile);
                return err;
        }
@@ -139,12 +135,35 @@ int GGIdlinit(ggi_visual *vis, const char *args, void *argptr)
                vis->opdisplay->getapi = oldgetapi;
        }
 
+       *dlret = GGI_DL_EXTENSION;
        return 0;
 }
 
-int GGIdlcleanup(ggi_visual *vis)
+
+static int GGIclose(ggi_visual *vis, struct ggi_dlhandle *dlh)
 {
        return 0;
 }
 
+
+int MesaGGIdl_fbdev_mesa(int func, void **funcptr)
+{
+       switch (func) {
+       case GGIFUNC_open:
+               *funcptr = GGIopen;
+               return 0;
+       case GGIFUNC_exit:
+               *funcptr = NULL;
+               return 0;
+       case GGIFUNC_close:
+               *funcptr = GGIclose;
+               return 0;
+       default:
+               *funcptr = NULL;
+       }
+        
+       return GGI_ENOTFOUND;
+}
+
+
 #include <ggi/internal/ggidlinit.h>
index 8a2f44a558c71887d95539bc43e6fc8e7b797064..6f5189456af686c270c888f1ddd79ac8b0f21810 100644 (file)
@@ -73,8 +73,8 @@ static void gl_ggiGetSize(GLframebuffer *fb, GLuint *width, GLuint *height)
        
        GGIMESADPRINT_CORE("gl_ggiGetSize() called\n");
        
-       *width = LIBGGI_MODE(ggi_ctx->ggi_visual)->visible.x; 
-       *height = LIBGGI_MODE(ggi_ctx->ggi_visual)->visible.y;
+       *width = LIBGGI_VIRTX(ggi_ctx->ggi_visual);
+       *height = LIBGGI_VIRTY(ggi_ctx->ggi_visual);
        printf("returning %d, %d\n", *width, *height);
 }
 
@@ -91,9 +91,9 @@ static void gl_ggiSetIndex(GLcontext *ctx, GLuint ci)
 static void gl_ggiSetClearIndex(GLcontext *ctx, GLuint ci)
 {      
        ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx;
-       
+
        GGIMESADPRINT_CORE("gl_ggiSetClearIndex() called\n");
-       
+
        ggiSetGCForeground(ggi_ctx->ggi_visual, ci);
        ggi_ctx->clearcolor = (ggi_pixel)ci;
 }
@@ -126,19 +126,15 @@ static void gl_ggiClear(GLcontext *ctx, GLbitfield mask, GLboolean all,
        
        GGIMESADPRINT_CORE("gl_ggiClear() called\n");
 
-       if (mask & (DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT)) 
-       {
+       if (mask & (DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT)) {
                ggiSetGCForeground(ggi_ctx->ggi_visual, ggi_ctx->clearcolor);
 
-               if (all)
-               {
+               if (all) {
                        int w, h;
-                       w = LIBGGI_MODE(ggi_ctx->ggi_visual)->visible.x;
-                       h = LIBGGI_MODE(ggi_ctx->ggi_visual)->visible.y;
+                       w = LIBGGI_VIRTX(ggi_ctx->ggi_visual);
+                       h = LIBGGI_VIRTX(ggi_ctx->ggi_visual);
                        ggiDrawBox(ggi_ctx->ggi_visual, 0, 0, w, h);
-               }
-               else
-               {
+               } else {
                        ggiDrawBox(ggi_ctx->ggi_visual, x, y, //FLIP(y),
                                   width, height);
                }
@@ -156,7 +152,7 @@ static void gl_ggiClear(GLcontext *ctx, GLbitfield mask, GLboolean all,
 static GLboolean gl_ggiSetBuffer(GLcontext *ctx, GLframebuffer *buffer, GLuint bufferBit)
 {
        ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx;
-       
+
        printf("set read %d\n", bufferBit);
        GGIMESADPRINT_CORE("gl_ggiSetBuffer() called\n");
 
@@ -184,11 +180,12 @@ static GLboolean gl_ggiSetBuffer(GLcontext *ctx, GLframebuffer *buffer, GLuint b
 static const GLubyte * gl_ggiGetString(GLcontext *ctx, GLenum name)
 {
        GGIMESADPRINT_CORE("gl_ggiGetString() called\n");
-       
-       if (name == GL_RENDERER)
-               return (GLubyte *) "Mesa GGI";
-       else
+
+       if (name == GL_RENDERER) {
+               return (GLubyte *) "Mesa GGI";
+       } else {
                return NULL;
+       }
 }
 
 static void gl_ggiFlush(GLcontext *ctx)
@@ -219,7 +216,7 @@ static void gl_ggiEnable(GLcontext *ctx, GLenum pname, GLboolean state)
 static void gl_ggiSetupPointers(GLcontext *ctx)
 {
        TNLcontext *tnl;
-  
+
        GGIMESADPRINT_CORE("gl_ggiSetupPointers() called\n");
 
        /* General information */
@@ -293,13 +290,13 @@ static void get_mode_info(ggi_visual_t vis, int *r, int *g, int *b,
        *g = 0;
        *b = 0;
 
-       for(i = 0; i < sizeof(ggi_pixel)*8; ++i){
+       for(i = 0; i < sizeof(ggi_pixel)*8; ++i) {
                int mask = 1 << i;
-               if(LIBGGI_PIXFMT(vis)->red_mask & mask)
+               if (LIBGGI_PIXFMT(vis)->red_mask & mask)
                        ++(*r);
-               if(LIBGGI_PIXFMT(vis)->green_mask & mask)
+               if (LIBGGI_PIXFMT(vis)->green_mask & mask)
                        ++(*g);
-               if(LIBGGI_PIXFMT(vis)->blue_mask & mask)
+               if (LIBGGI_PIXFMT(vis)->blue_mask & mask)
                        ++(*b);
        }
 
@@ -317,15 +314,17 @@ int ggiMesaInit()
        
        GGIMESADPRINT_CORE("ggiMesaInit() called\n");
        
-        str = getenv("GGIMESA_DEBUG");
+       str = getenv("GGIMESA_DEBUGSYNC");
        if (str != NULL) {
-               _ggimesaDebugState = atoi(str);
-               GGIMESADPRINT_CORE("Debugging=%d\n", _ggimesaDebugState);
+               _ggimesaDebugSync = 1;
        }
        
-       str = getenv("GGIMESA_DEBUGSYNC");
+       str = getenv("GGIMESA_DEBUG");
        if (str != NULL) {
-               _ggimesaDebugSync = 1;
+               _ggimesaDebugState = atoi(str);
+               GGIMESADPRINT_CORE("%s Debugging=%d\n",
+                       _ggimesaDebugSync ? "sync" : "async",
+                       _ggimesaDebugState);
        }
        
        GGIMESADPRINT_CORE("ggiMesaInit()\n");
@@ -360,12 +359,12 @@ int ggiMesaInit()
 int ggiMesaExit(void)
 {
        int rc;
-       
+
        GGIMESADPRINT_CORE("ggiMesaExit() called\n");
-       
+
        if (!_ggimesaLibIsUp)
                return -1;
-       
+
        if (_ggimesaLibIsUp > 1)
        {
                /* Exit only at last call */
@@ -375,18 +374,18 @@ int ggiMesaExit(void)
        
        rc = ggiExtensionUnregister(ggiMesaID);
        ggFreeConfig(_ggimesaConfigHandle);
-       
+
        _ggimesaLibIsUp = 0;
-       
+
        return rc;
 }
 
 int ggiMesaAttach(ggi_visual_t vis)
 {
        int rc;
-       
+
        GGIMESADPRINT_CORE("ggiMesaAttach() called\n");
-       
+
        rc = ggiExtensionAttach(vis, ggiMesaID);
        if (rc == 0)
        {
@@ -531,10 +530,10 @@ void ggiMesaMakeCurrent(ggi_mesa_context_t ctx, ggi_visual_t vis)
        if (ctx->gl_ctx->Viewport.Width == 0)
        {
                _mesa_Viewport(0, 0,
-                              LIBGGI_MODE(vis)->visible.x,
-                              LIBGGI_MODE(vis)->visible.y);
-               ctx->gl_ctx->Scissor.Width = LIBGGI_MODE(vis)->visible.x;
-               ctx->gl_ctx->Scissor.Height = LIBGGI_MODE(vis)->visible.y;
+                              LIBGGI_VIRTX(vis),
+                              LIBGGI_VIRTY(vis));
+               ctx->gl_ctx->Scissor.Width = LIBGGI_VIRTX(vis);
+               ctx->gl_ctx->Scissor.Height = LIBGGI_VIRTY(vis);
        }
 }
 
@@ -579,6 +578,7 @@ static void gl_ggiUpdateState(GLcontext *ctx, GLuint new_state)
        _swsetup_InvalidateState(ctx, new_state);
        _tnl_InvalidateState(ctx, new_state);
        
+       /* XXX: Better use an assertion that bails out here on failure */
        if (!LIBGGI_MESAEXT(ggi_ctx->ggi_visual)->update_state) {
                GGIMESADPRINT_CORE("update_state == NULL!\n");
                GGIMESADPRINT_CORE("Please check your config files!\n");
@@ -595,12 +595,11 @@ static int changed(ggi_visual_t vis, int whatchanged)
 
        GGIMESADPRINT_CORE("changed() called\n");
                
-       switch (whatchanged)
-       {
+       switch (whatchanged) {
        case GGI_CHG_APILIST:
        {
-               char api[256];
-               char args[256];
+               char api[GGI_API_MAXLEN];
+               char args[GGI_API_MAXLEN];
                int i;
                const char *fname;
                ggi_dlhandle *lib;
index 22e863117be7409b1061d758a6ba57bba626cb31..ecdbe414f8ac8b21c58259edf61a5407b8343bf8 100644 (file)
@@ -75,7 +75,7 @@ struct ggi_mesa_context
        ggi_pixel color;                /* Current color or index*/
        ggi_pixel clearcolor;
        
-       void *private;
+       void *priv;
 };
 
 #define SHIFT (GGI_COLOR_PRECISION - 8)
index da8b10f2ff90854785e19f0f4120fbcc71c2a138..edd23ea7986f954be2db12099561fc0a7d2678ea 100644 (file)
@@ -40,6 +40,6 @@ typedef struct ggi_mesa_ext
 } ggi_mesa_ext_t;
 
 #define LIBGGI_MESAEXT(vis) ((ggi_mesa_ext_t *)LIBGGI_EXT(vis,ggiMesaID))
-#define GGIMESA_PRIVATE(vis) ((LIBGGI_MESAEXT(vis)->private))
+#define GGIMESA_PRIV(vis) ((LIBGGI_MESAEXT(vis)->priv))
 
 #endif /* _GGI_MISC_INT_H */