Evas GL: Fix direct_mem_opt and direct_override
authorDongyeon Kim <dy5.kim@samsung.com>
Thu, 16 Apr 2015 07:21:33 +0000 (16:21 +0900)
committerJean-Philippe Andre <jp.andre@samsung.com>
Wed, 3 Jun 2015 02:30:21 +0000 (11:30 +0900)
Summary:
Remove surface buffer create/allocate in pbuffer_surface_create.
In evgl_make_current, we should use direct_mem_opt, direct_override values
set in EVGL_Surface struct, not the global value set by env variables.
@fix

src/modules/evas/engines/gl_common/evas_gl_core.c

index 1b836b7..f53ee1a 100644 (file)
@@ -1854,13 +1854,6 @@ evgl_pbuffer_surface_create(void *eng_data, Evas_GL_Config *cfg,
    sfc->pbuffer.color_fmt = cfg->color_format;
    sfc->pbuffer.is_pbuffer = EINA_TRUE;
 
-   // Set the context current with resource context/surface
-   if (!_internal_resource_make_current(eng_data, NULL))
-     {
-        ERR("Error doing an internal resource make current");
-        goto error;
-     }
-
    // If the surface is defined as RGB or RGBA, then create an FBO
    if (sfc->pbuffer.color_fmt != EVAS_GL_NO_FBO)
      {
@@ -1871,30 +1864,8 @@ evgl_pbuffer_surface_create(void *eng_data, Evas_GL_Config *cfg,
              evas_gl_common_error_set(eng_data, EVAS_GL_BAD_CONFIG);
              goto error;
           }
-
-        // Create internal buffers
-        if (!_surface_buffers_create(sfc))
-          {
-             ERR("Unable Create Specificed Surfaces.");
-             evas_gl_common_error_set(eng_data, EVAS_GL_BAD_ALLOC);
-             goto error;
-          };
-
-        // Allocate resources for fallback unless the flag is on
-        // Note: we don't care about sfc->direct_mem_opt, as DR makes no sense with PBuffer.
-        if (!evgl_engine->direct_mem_opt)
-          {
-             if (!_surface_buffers_allocate(eng_data, sfc, sfc->w, sfc->h, 0))
-               {
-                  ERR("Unable Create Allocate Memory for Surface.");
-                  evas_gl_common_error_set(eng_data, EVAS_GL_BAD_ALLOC);
-                  goto error;
-               }
-          }
      }
 
-   // Not calling make_current
-
    pbuffer = evgl_engine->funcs->pbuffer_surface_create
      (eng_data, sfc, attrib_list);
 
@@ -1906,13 +1877,6 @@ evgl_pbuffer_surface_create(void *eng_data, Evas_GL_Config *cfg,
 
    sfc->pbuffer.native_surface = pbuffer;
 
-   if (dbg) DBG("Calling make_current(NULL, NULL)");
-   if (!evgl_engine->funcs->make_current(eng_data, NULL, NULL, 0))
-     {
-        ERR("Error doing make_current(NULL, NULL).");
-        goto error;
-     }
-
    // Keep track of all the created surfaces
    LKL(evgl_engine->resource_lock);
    evgl_engine->surfaces = eina_list_prepend(evgl_engine->surfaces, sfc);
@@ -2301,7 +2265,7 @@ evgl_make_current(void *eng_data, EVGL_Surface *sfc, EVGL_Context *ctx)
 
    // Allocate or free resources depending on what mode (direct of fbo) it's
    // running only if the env var EVAS_GL_DIRECT_MEM_OPT is set.
-   if (evgl_engine->direct_mem_opt)
+   if (sfc->direct_mem_opt)
      {
         if (_evgl_direct_renderable(rsc, sfc))
           {
@@ -2321,7 +2285,7 @@ evgl_make_current(void *eng_data, EVGL_Surface *sfc, EVGL_Context *ctx)
           }
         else
           {
-             if (evgl_engine->direct_override)
+             if (sfc->direct_override)
                {
                   DBG("Not creating fallback surfaces even though it should. Use at OWN discretion!");
                }
@@ -2336,7 +2300,7 @@ evgl_make_current(void *eng_data, EVGL_Surface *sfc, EVGL_Context *ctx)
                             ERR("Unable Create Specificed Surfaces.  Unsupported format!");
                             evas_gl_common_error_set(eng_data, EVAS_GL_BAD_ALLOC);
                             return 0;
-                         };
+                         }
                        sfc->buffers_allocated = 1;
                     }
                }
@@ -2393,7 +2357,7 @@ evgl_make_current(void *eng_data, EVGL_Surface *sfc, EVGL_Context *ctx)
                   glViewport(ctx->viewport_coord[0], ctx->viewport_coord[1], ctx->viewport_coord[2], ctx->viewport_coord[3]);
                   if ((ctx->direct_scissor) && (!ctx->scissor_enabled))
                     glDisable(GL_SCISSOR_TEST);
-             }
+               }
 
              ctx->current_fbo = 0;
              rsc->direct.rendered = 0;
@@ -2478,7 +2442,7 @@ evgl_make_current(void *eng_data, EVGL_Surface *sfc, EVGL_Context *ctx)
              if ((rsc->current_ctx != ctx) || (ctx->current_sfc != sfc) || (rsc->direct.rendered))
                {
                   sfc->current_ctx = ctx;
-                  if ((evgl_engine->direct_mem_opt) && (evgl_engine->direct_override))
+                  if ((sfc->direct_mem_opt) && (sfc->direct_override))
                     {
                        DBG("Not creating fallback surfaces even though it should. Use at OWN discretion!");
                     }