Sync-up with latest release source code.
authorSangjin Kim <sangjin3.kim@samsung.com>
Mon, 4 Mar 2013 02:46:24 +0000 (11:46 +0900)
committerSangjin Kim <sangjin3.kim@samsung.com>
Mon, 4 Mar 2013 02:46:24 +0000 (11:46 +0900)
Signed-off-by: Sangjin Kim <sangjin3.kim@samsung.com>
tizen/src/hw/gloffscreen_common.c
tizen/src/hw/gloffscreen_test.c
tizen/src/hw/gloffscreen_xcomposite.c
tizen/src/hw/opengl_exec.c

index e2fee96..433c78e 100644 (file)
@@ -304,6 +304,8 @@ int glo_flags_get_from_glx(const int *fbConfig, int assumeBooleans) {
             case GLX_ACCUM_BLUE_SIZE:
             case GLX_ACCUM_ALPHA_SIZE:
                 break;
+                       default:
+                               break;
         }
 
         // go to next
@@ -473,6 +475,8 @@ int glo_get_glx_from_flags(int formatFlags, int glxEnum) {
         case GLX_MAX_PBUFFER_HEIGHT:
         case GLX_MAX_PBUFFER_PIXELS:
             return 0;
+               default:
+                       return 0;
     }
     return 0;
 }
index 525447a..67ce8f2 100644 (file)
 #define TX (32)
 #define TY (32)
 
+#define CHECK_SUCCESS  0
+#define CHECK_FAIL             1
 int gl_acceleration_capability_check (void) {
-    int test_failure = 0;
+    //int test_failure = 0;
     GloContext *context;
     GloSurface *surface;
-    unsigned char *datain = (unsigned char *)malloc(4*TX*TY);
-    unsigned char *datain_flip = (unsigned char *)malloc(4*TX*TY); // flipped input data (for GL)
-    unsigned char *dataout = (unsigned char *)malloc(4*TX*TY);
+    unsigned char *datain;
+    unsigned char *datain_flip;
+    unsigned char *dataout;
     unsigned char *p;
     int x,y;
     const int bufferAttributes[] = {
@@ -96,9 +98,13 @@ int gl_acceleration_capability_check (void) {
         // test failed.
         return 1;
     }
-*/
-    memset(datain_flip, 0, TX*TY*4);
+*/ 
+       datain = (unsigned char *)malloc(4*TX*TY);
+       datain_flip = (unsigned char *)malloc(4*TX*TY);
+
     memset(datain, 0, TX*TY*4);
+    memset(datain_flip, 0, TX*TY*4);
+
     p = datain;
     for (y=0;y<TY;y++) {
       for (x=0;x<TX;x++) {
@@ -114,23 +120,26 @@ int gl_acceleration_capability_check (void) {
 
     if (glo_init() != 0) {
         printf ("Host does not have GL hardware acceleration!(glo_init() failed)\n");
-        test_failure = 1;
-        goto TEST_END;
+               free (datain);
+               free (datain_flip);
+               return CHECK_FAIL;
     }
 
     // new surface
     context = glo_context_create(bufferFlags, 0);
        if (context == NULL) {
         printf ("Host does not have GL hardware acceleration!(context_create() failed)\n");
-        test_failure = 1;
-        goto TEST_END;
+               free (datain);
+               free (datain_flip);
+               return CHECK_FAIL;
     }
 
     surface = glo_surface_create(TX, TY, context);
        if (surface == NULL) {
         printf ("Host does not have GL hardware acceleration!(surface_create() failed)\n");
-        test_failure = 1;
-        goto TEST_END;
+               free (datain);
+               free (datain_flip);
+               return CHECK_FAIL;
     }
 
     glo_surface_makecurrent(surface);
@@ -140,9 +149,10 @@ int gl_acceleration_capability_check (void) {
     //printf("GLSL VERSION %s\n", glGetString(GL_SHADING_LANGUAGE_VERSION));
 
     if (strstr((const char*)glGetString(GL_RENDERER), "Software")) {
-        printf ("Host does not have GL hardware acceleration!\n");
-        test_failure = 1;
-        goto TEST_END;
+        printf ("Host does not have GL hardware acceleration!(No host gl driver)\n");
+               free (datain);
+               free (datain_flip);
+               return CHECK_FAIL;
     }
 
     // fill with stuff (in correctly ordered way)
@@ -157,7 +167,8 @@ int gl_acceleration_capability_check (void) {
     printf("glFormat: 0x%08X glType: 0x%08X\n", glFormat, glType);
     glDrawPixels(TX,TY,glFormat, glType, datain_flip);
     glFlush();
-
+       
+       dataout = (unsigned char *)malloc(4*TX*TY);
     memset(dataout, 0, bpp*TX*TY);
 
     glo_surface_getcontents(surface, TX*bpp, bpp*8, dataout);
@@ -167,13 +178,18 @@ int gl_acceleration_capability_check (void) {
     glo_context_destroy(context);
     // compare
     if (memcmp(datain, dataout, bpp*TX*TY)!=0) {
-      test_failure = 1;
+        printf ("Host does not have GL hardware acceleration!(datain != dataout)\n");
+               free (datain);
+               free (datain_flip);
+               free (dataout);
+               return CHECK_FAIL;
     }
-TEST_END:
+
     //glo_kill();
     //printf ("Testing %s\n", (test_failure ? "FAILED" : "PASSED"));
     free (datain);
     free (datain_flip);
     free (dataout);
-    return test_failure;
+
+       return CHECK_SUCCESS;
 }
index af37dce..4389749 100644 (file)
@@ -122,7 +122,7 @@ int glo_init(void) {
     glo_inited = 1; // safe because we are single threaded. Otherwise we cause
                     // recursion on the next call.
     // set the X error handler.
-    XErrorHandler old_handler = XSetErrorHandler (x_errhandler);
+    XSetErrorHandler (x_errhandler);
     glo_test_readback_methods();
        return 0;
 }
@@ -277,9 +277,6 @@ GloSurface *glo_surface_create(int width, int height, GloContext *context) {
     XSetWindowAttributes attr = { 0 };
     unsigned long mask;
     XVisualInfo *vis;
-    int pixmapAttribs[] = { GLX_TEXTURE_TARGET_EXT, GLX_TEXTURE_2D_EXT,
-                        GLX_TEXTURE_FORMAT_EXT, GLX_TEXTURE_FORMAT_RGB_EXT,
-                                        None };
 
     if (!context)
       return 0;
@@ -391,7 +388,6 @@ int glo_surface_makecurrent(GloSurface *surface) {
 }
 
 void glo_surface_updatecontents(GloSurface *surface) {
-    XImage *img;
     if (!surface)
         return;
 
@@ -402,7 +398,7 @@ void glo_surface_updatecontents(GloSurface *surface) {
             XShmGetImage (glo.dpy, surface->pixmap, surface->image, 0, 0, AllPlanes);
         }
         else {
-            img = XGetImage(glo.dpy, surface->pixmap, 0, 0, surface->width, surface->height, AllPlanes, ZPixmap);
+            XGetImage(glo.dpy, surface->pixmap, 0, 0, surface->width, surface->height, AllPlanes, ZPixmap);
         }
     }
 
@@ -526,7 +522,7 @@ static int glo_can_readback(void) {
 
     unsigned char *datain = (unsigned char *)g_malloc(4*TX*TY);
     unsigned char *datain_flip = (unsigned char *)g_malloc(4*TX*TY); // flipped input data (for GL)
-    unsigned char *dataout = (unsigned char *)g_malloc(4*TX*TY);
+    unsigned char *dataout;
     unsigned char *p;
     int x,y;
 
@@ -560,11 +556,17 @@ static int glo_can_readback(void) {
     }
 
     context = glo_context_create(bufferFlags, 0);
-       if (context == NULL)
+       if (context == NULL) {
+               g_free(datain);
+               g_free(datain_flip);
                return 1;
+       }
     surface = glo_surface_create(TX, TY, context);
-       if (surface == NULL)
+       if (surface == NULL) {
+               g_free(datain);
+               g_free(datain_flip);
                return 1;
+       }
 
     glo_surface_makecurrent(surface);
 
@@ -579,6 +581,7 @@ static int glo_can_readback(void) {
     glDrawPixels(TX,TY,glFormat, glType, datain_flip);
     glFlush();
 
+       dataout = (unsigned char *)g_malloc(4*TX*TY);
     memset(dataout, 0, bpp*TX*TY);
 
     glo_surface_getcontents(surface, TX*4, bpp*8, dataout);
@@ -586,8 +589,16 @@ static int glo_can_readback(void) {
     glo_surface_destroy(surface);
     glo_context_destroy(context);
 
-    if (memcmp(datain, dataout, bpp*TX*TY)==0)
+    if (memcmp(datain, dataout, bpp*TX*TY)==0) {
+               g_free(datain);
+               g_free(datain_flip);
+               g_free(dataout);
         return 1;
+       }
+
+       g_free(datain);
+       g_free(datain_flip);
+       g_free(dataout);
 
     return 0;
 }
index 5b28351..43c1f35 100644 (file)
@@ -609,7 +609,8 @@ static void bind_qsurface(GLState *state,
 {
     qsurface->glstate = state;
 
-    QTAILQ_INSERT_HEAD(&state->qsurfaces, qsurface, next);
+       if ( qsurface->type == SURFACE_WINDOW )
+               QTAILQ_INSERT_HEAD(&state->qsurfaces, qsurface, next);
 
     state->current_qsurface = qsurface;
 }
@@ -620,7 +621,8 @@ static void unbind_qsurface(GLState *state,
 {
     qsurface->glstate = NULL;
 
-    QTAILQ_REMOVE(&state->qsurfaces, qsurface, next);
+       if ( qsurface->type == SURFACE_WINDOW )
+               QTAILQ_REMOVE(&state->qsurfaces, qsurface, next);
 
        if ( state->current_qsurface == qsurface )
                state->current_qsurface = NULL;
@@ -962,13 +964,6 @@ static void destroy_gl_state(GLState *state)
 {
     int i;
 
-    /* XXX:Current limitation is that each surface is binded to one
-     * context, thus not support sharing surface between contexts. If guest
-     * does this, deleting surface in one context make trouble to other
-     * context. Leave the work until the uninitialization. Need clean the code
-     * and decouple the context and surface in future.
-     */
-#if 0
     QGloSurface *qsurface, *tmp;
 
     QTAILQ_FOREACH_SAFE(qsurface, &state->qsurfaces, next, tmp) {
@@ -976,7 +971,6 @@ static void destroy_gl_state(GLState *state)
         QTAILQ_REMOVE(&state->qsurfaces, qsurface, next);
         g_free(qsurface);
     }
-#endif
         
     if (state->context)
       glo_context_destroy(state->context);
@@ -1125,9 +1119,11 @@ GLState *_create_context(ProcessState *process, int fake_ctxt, int fake_shareLis
 GLState *get_glstate_for_fake_ctxt(ProcessState *process, int fake_ctxt)
 {
     int i;
-    for (i = 0; i < process->nb_states; i++)
+    for (i = 0; i < process->nb_states; i++) {
         if (process->glstates[i]->fake_ctxt == fake_ctxt)
             return process->glstates[i];
+       }
+
     return 0;
 }
 
@@ -1144,9 +1140,12 @@ void gl_disconnect(ProcessState *process)
     if (process->cmdbuf)
         g_free(process->cmdbuf);
 
-    for (i = 0; &processes[i] != process; i ++);
-        memmove(&processes[i], &processes[i + 1],
-                (MAX_HANDLED_PROCESS - 1 - i) * sizeof(ProcessState));
+    for (i = 0; &processes[i] != process; i ++) {
+               ; // do nothing
+       }
+
+       memmove(&processes[i], &processes[i + 1],
+                       (MAX_HANDLED_PROCESS - 1 - i) * sizeof(ProcessState));
 }
 
 static const int beginend_allowed[GL_N_CALLS] = {
@@ -1171,7 +1170,7 @@ ProcessStruct *vmgl_get_process(pid_t pid)
      * process->current_state contains info on which of the guests contexts is
      * current.
      */
-    for (i = 0; i < MAX_HANDLED_PROCESS; i ++)
+    for (i = 0; i < MAX_HANDLED_PROCESS; i ++) {
         if (processes[i].p.process_id == pid) {
             process = &processes[i];
             break;
@@ -1183,6 +1182,7 @@ ProcessStruct *vmgl_get_process(pid_t pid)
             process->current_state = &process->default_state;
             break;
         }
+       }
 
     if (process == NULL) {
         DEBUGF( "Too many processes !\n");
@@ -1244,7 +1244,10 @@ static const char *opengl_strtok(const char *s, int *n, char **saveptr, char *pr
     }
 
        start = s;
-    for (; *n && *s && !strchr(delim, *s); s++, (*n)--);
+    for (; *n && *s && !strchr(delim, *s); s++, (*n)--) {
+               ; // do nothing
+       }
+
        if (*n > 0) 
                s++, (*n)--;
 
@@ -1303,7 +1306,10 @@ static char *do_eglShaderPatch(const char *source, int length, int *patched_len)
         if (!strncmp(p, "lowp", 4) || !strncmp(p, "mediump", 7) || !strncmp(p, "highp", 5)) {
             continue;
         } else if (!strncmp(p, "precision", 9)) {
-            while ((p = opengl_strtok(0, &length, &saveptr, p)) && !strchr(p, ';'));
+            while ((p = opengl_strtok(0, &length, &saveptr, p)) && !strchr(p, ';')) {
+                               // do nothing
+                               ;
+                       }
         } else {
             if (!strncmp(p, "gl_MaxVertexUniformVectors", 26)) {
                 p = "(gl_MaxVertexUniformComponents / 4)";
@@ -1330,15 +1336,23 @@ static char *do_eglShaderPatch(const char *source, int length, int *patched_len)
     patched[*patched_len] = 0;
     /* check that we don't leave dummy preprocessor lines */
     for (sp = patched; *sp;) {
-        for (; *sp == ' ' || *sp == '\t'; sp++);
+        for (; *sp == ' ' || *sp == '\t'; sp++) {
+                       ; // do nothing
+               }
         if (!strncmp(sp, "#define", 7)) {
-            for (p = sp + 7; *p == ' ' || *p == '\t'; p++);
+            for (p = sp + 7; *p == ' ' || *p == '\t'; p++) {
+                               ; // do nothing
+                       }
             if (*p == '\n' || *p == '\r' || *p == '/') {
                 memset(sp, 0x20, 7);
             }
         }
-        for (; *sp && *sp != '\n' && *sp != '\r'; sp++);
-        for (; *sp == '\n' || *sp == '\r'; sp++);
+        for (; *sp && *sp != '\n' && *sp != '\r'; sp++) {
+                       ; // do nothing
+               }
+        for (; *sp == '\n' || *sp == '\r'; sp++) {
+                       ; // do nothing
+               }
     }
     return patched;
 }
@@ -1360,8 +1374,9 @@ shadersrc_gles_to_gl(GLsizei count, const char** string, char **s, const GLint*
                if(string[i]) {
                        s[i] = do_eglShaderPatch(string[i], len, &l[i]);
                        if(!s[i]) {
-                               while(i)
+                               while(i) {
                                        free(s[--i]);
+                               }
 
                                free(l);
                                free(s);
@@ -1709,6 +1724,8 @@ int do_function_call(ProcessState *process, int func_number, unsigned long *args
                                                               glstate->context);
                        qsurface->client_drawable = client_drawable;
                        qsurface->ref = 1;
+                                          qsurface->type = SURFACE_WINDOW;
+                                          qsurface->status = SURFACE_ACTIVE;
 
                        bind_qsurface(glstate, qsurface);
 //                       DEBUGF( " --Client drawable not found, create new surface: %16x %16lx\n", (unsigned int)qsurface, (unsigned long int)client_drawable);
@@ -2478,8 +2495,10 @@ int do_function_call(ProcessState *process, int func_number, unsigned long *args
 
                        ptr_func_glShaderSource(args[0], args[1], tab_prog_new, tab_length_new);
 
-                       for (i = 0; i < args[1]; i++)
+                       for (i = 0; i < args[1]; i++) {
                                free(tab_prog_new[i]);
+                       }
+
                        free(tab_prog_new);
                        free(tab_length_new);