[Title] Host gl capability check bug, return variable null pointer bug fix.
authorsangjin3.kim <sangjin3.kim@samsung.com>
Thu, 22 Mar 2012 08:24:46 +0000 (17:24 +0900)
committersangjin3.kim <sangjin3.kim@samsung.com>
Thu, 22 Mar 2012 08:24:46 +0000 (17:24 +0900)
[Type] bug fix
[Module] opengl-es
[Priority]
[CQ#]
[Redmine#]
[Problem]
[Cause]
[Solution]
[TestCase]

tizen/src/hw/gloffscreen_glx.c
tizen/src/hw/gloffscreen_test.c
tizen/src/hw/gloffscreen_wgl.c
tizen/src/hw/gloffscreen_xcomposite.c
tizen/src/hw/helper_opengl.c

index 8f95121..67af15a 100755 (executable)
@@ -78,6 +78,7 @@ int glo_initialised(void) {
 
 /* Initialise gloffscreen */
 void glo_init(void) {
+       fprintf(stdout, "[rla1957]glo_init() in gloffscreen_glx.c\n");
     if (glo_inited) {
         printf( "gloffscreen already inited\n" );
         exit( EXIT_FAILURE );
@@ -147,7 +148,8 @@ GloContext *glo_context_create(int formatFlags, GloContext *shareLists) {
                                  bufferAttributes, &numReturned );
   if (numReturned==0) {
       printf( "No matching configs found.\n" );
-      exit( EXIT_FAILURE );
+      //exit( EXIT_FAILURE );
+         return NULL;
   }
   context = (GloContext*)qemu_malloc(sizeof(GloContext));
   memset(context, 0, sizeof(GloContext));
@@ -162,7 +164,8 @@ GloContext *glo_context_create(int formatFlags, GloContext *shareLists) {
 
   if (!context->context) {
     printf( "glXCreateNewContext failed\n" );
-    exit( EXIT_FAILURE );
+    //exit( EXIT_FAILURE );
+       return NULL;
   }
 
   return context;
@@ -209,7 +212,8 @@ static void glo_surface_try_alloc_xshm_image(GloSurface *surface) {
 GloSurface *glo_surface_create(int width, int height, GloContext *context) {
     GloSurface           *surface;
 
-    if (!context) return 0;
+    if (!context) 
+               return NULL;
 
     surface = (GloSurface*)qemu_malloc(sizeof(GloSurface));
     memset(surface, 0, sizeof(GloSurface));
@@ -222,7 +226,8 @@ GloSurface *glo_surface_create(int width, int height, GloContext *context) {
 
     if (!surface->xPixmap) {
       printf( "XCreatePixmap failed\n" );
-      exit( EXIT_FAILURE );
+      //exit( EXIT_FAILURE );
+         return NULL;
     }
 
     /* Create a GLX window to associate the frame buffer configuration
@@ -230,7 +235,8 @@ GloSurface *glo_surface_create(int width, int height, GloContext *context) {
     surface->glxPixmap = glXCreatePixmap( glo.dpy, context->fbConfig, surface->xPixmap, NULL );
     if (!surface->glxPixmap) {
       printf( "glXCreatePixmap failed\n" );
-      exit( EXIT_FAILURE );
+      //exit( EXIT_FAILURE );
+         return NULL;
     }
 
     // If we're using XImages to pull the data from the graphics card...
index 887c32b..0e262b5 100755 (executable)
@@ -89,8 +89,9 @@ int gl_acceleration_capability_check (void) {
     int glFormat, glType;
 
     if (glo_sanity_test () != 0) {
-        // test failed.
-        return 1;
+        printf ("glo_sanity_test() failed.\n");
+        test_failure = 1;
+        goto TEST_END;
     }
 
     memset(datain_flip, 0, TX*TY*4);
@@ -108,11 +109,33 @@ int gl_acceleration_capability_check (void) {
       memcpy(&datain_flip[((TY-1)-y)*bpp*TX], &datain[y*bpp*TX], bpp*TX);
     }
 
-    glo_init();
+    if (glo_init() != 0) {
+        printf ("glo_init() failed.\n");
+        test_failure = 1;
+        goto TEST_END;
+    }
+
     // new surface
     context = glo_context_create(bufferFlags, 0);
+       if (context == NULL) {
+        printf ("glo_context_create() failed.\n");
+        test_failure = 1;
+        goto TEST_END;
+    }
+
     surface = glo_surface_create(TX, TY, context);
-    glo_surface_makecurrent(surface);
+       if (surface == NULL) {
+        printf ("glo_surface_create() failed.\n");
+        test_failure = 1;
+        goto TEST_END;
+    }
+
+    if (!glo_surface_makecurrent(surface)) {
+        printf ("glo_surface_makecurrent() failed.\n");
+        test_failure = 1;
+        goto TEST_END;
+    }
+
     printf("GL VENDOR %s\n", glGetString(GL_VENDOR));
     printf("GL RENDERER %s\n", glGetString(GL_RENDERER));
     printf("GL VERSION %s\n", glGetString(GL_VERSION));
index 127d651..f1c1b2f 100755 (executable)
@@ -697,7 +697,8 @@ GloContext *glo_context_create(int formatFlags, GloContext *shareLists) {
     wglChoosePixelFormatARB( glo.hDC, pf_attri, pf_attrf, 1, &context->wglPixelFormat, &numReturned);
     if( numReturned == 0 ) {
         printf( "No matching configs found.\n" );
-        exit( EXIT_FAILURE );
+        //exit( EXIT_FAILURE );
+               return NULL;
     }
 
     // We create a tiny pbuffer - just so we can make a context of the right pixel format
@@ -705,18 +706,21 @@ GloContext *glo_context_create(int formatFlags, GloContext *shareLists) {
                                              16, 16, pb_attr );
     if( !context->hPBuffer ) {
         printf( "Couldn't create the PBuffer\n" );
-        exit( EXIT_FAILURE );
+        //exit( EXIT_FAILURE );
+               return NULL;
     }
     context->hDC      = wglGetPbufferDCARB( context->hPBuffer );
     if( !context->hDC ) {
         printf( "Couldn't create the DC\n" );
-        exit( EXIT_FAILURE );
+        //exit( EXIT_FAILURE );
+               return NULL;
     }
 
     context->hContext = wglCreateContext(context->hDC);
     if (context->hContext == NULL) {
         printf( "Unable to create GL context\n" );
-        exit( EXIT_FAILURE );
+        //exit( EXIT_FAILURE );
+               return NULL;
     }
 
     if (shareLists) {
@@ -764,12 +768,14 @@ GloSurface *glo_surface_create(int width, int height, GloContext *context) {
                                              surface->width, surface->height, pb_attr );
     if( !surface->hPBuffer ) {
         printf( "Couldn't create the PBuffer\n" );
-        exit( EXIT_FAILURE );
+        //exit( EXIT_FAILURE );
+               return NULL;
     }
     surface->hDC      = wglGetPbufferDCARB( surface->hPBuffer );
     if( !surface->hDC ) {
         printf( "Couldn't create the DC\n" );
-        exit( EXIT_FAILURE );
+        //exit( EXIT_FAILURE );
+               return NULL;
     }
 
     return surface;
index 2e0234c..ad892b9 100755 (executable)
@@ -104,6 +104,7 @@ int glo_sanity_test (void) {
 
 /* Initialise gloffscreen */
 void glo_init(void) {
+       fprintf(stdout, "[rla1957]glo_init() in gloffscreen_xcomposite.c\n");
     if (glo_inited) {
         printf( "gloffscreen already inited\n" );
         exit( EXIT_FAILURE );
@@ -179,7 +180,8 @@ GloContext *glo_context_create(int formatFlags, GloContext *shareLists) {
                                    bufferAttributes, &numReturned );
     if (numReturned==0) {
         printf( "No matching configs found.\n" );
-        exit( EXIT_FAILURE );
+        //exit( EXIT_FAILURE );
+               return NULL;
     }
     context = (GloContext*)g_malloc(sizeof(GloContext));
     memset(context, 0, sizeof(GloContext));
@@ -194,7 +196,8 @@ GloContext *glo_context_create(int formatFlags, GloContext *shareLists) {
 
     if (!context->context) {
         printf( "glXCreateNewContext failed\n" );
-        exit( EXIT_FAILURE );
+        //exit( EXIT_FAILURE );
+               return NULL;
     }
 
     return context;
@@ -248,7 +251,7 @@ GloSurface *glo_surface_create(int width, int height, GloContext *context) {
     XVisualInfo *vis;
 
     if (!context)
-      return 0;
+      return NULL;
 
     surface = (GloSurface*)g_malloc(sizeof(GloSurface));
     memset(surface, 0, sizeof(GloSurface));
@@ -257,6 +260,8 @@ GloSurface *glo_surface_create(int width, int height, GloContext *context) {
     surface->context = context;
 
     vis = glXGetVisualFromFBConfig(glo.dpy, ((struct _GloContext*)context)->fbConfig);
+       if (vis == NULL)
+               return NULL;
 
     attr.background_pixel = 0xff000000;
     attr.border_pixel = 0;
@@ -273,7 +278,8 @@ GloSurface *glo_surface_create(int width, int height, GloContext *context) {
 
     if (!surface->window) {
         printf( "XCreateWindow failed\n" );
-        exit( EXIT_FAILURE );
+        //exit( EXIT_FAILURE );
+               return NULL;
     }
 
     XMapWindow(glo.dpy, surface->window);
@@ -289,7 +295,8 @@ GloSurface *glo_surface_create(int width, int height, GloContext *context) {
 
     if(surface->pixmap == 0) {
         fprintf(stderr, "Failed to allocate pixmap!\n");
-        exit(EXIT_FAILURE);
+        //exit(EXIT_FAILURE);
+               return NULL;
     }
 
     XSync(glo.dpy, 0);
index 181ce88..c5cd4fa 100755 (executable)
@@ -132,11 +132,13 @@ static inline int do_decode_call_int(ProcessStruct *process, void *args_in, int
 
                 CASE_OUT_POINTERS:
                 {
-                    /* It seems that we never experience NULL out pointers!!! */
-                    if (args_size == 0 && func_number != 4) // FIXMEIM - hack for now
-                        return 0;
-
-                    if(*(int*)argptr) {
+                                       /* NULL pointer is used as output pointer
+                                          since the argument size is zero. */
+                                       if (args_size == 0) {
+                                               *(int*)r_buffer = 0;
+                                               r_buffer += 4;
+                                               args[i] = NULL;
+                                       } else if(*(int*)argptr) {
                         *(int*)r_buffer = args_size;
                         r_buffer+=4;
                         args[i] = (host_ptr)r_buffer;