summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSung Park <sungwoo@gmail.com>2012-08-02 01:15:38 +0000
committerSung Park <sungwoo@gmail.com>2012-08-02 01:15:38 +0000
commitd0b5d1e13eeb51a08eb47504a263020c6ee808c7 (patch)
tree6c9e0a28d18dd53b3e9e659a507a2c7b3916075f
parente40c9a05c803c4054380f1f8158f66d25ea5de2f (diff)
Fix evas_gl's internal resource surface bug. For optimzation evas_gl
was using evas' window surface to do its resource creation and it wans't properly updated when a window is destroyed and recreated. Also, deleted some whitespaces. SVN revision: 74771
Diffstat (limited to '')
-rw-r--r--legacy/evas/ChangeLog6
-rw-r--r--legacy/evas/NEWS1
-rw-r--r--legacy/evas/src/modules/engines/gl_x11/evas_engine.c141
3 files changed, 90 insertions, 58 deletions
diff --git a/legacy/evas/ChangeLog b/legacy/evas/ChangeLog
index ab2a3a2ae5..fd3133eb1f 100644
--- a/legacy/evas/ChangeLog
+++ b/legacy/evas/ChangeLog
@@ -943,3 +943,9 @@
943 * Provide share (Data) file for prefix finding and use 943 * Provide share (Data) file for prefix finding and use
944 eina_prefix for modules too so we work with debian multiarch 944 eina_prefix for modules too so we work with debian multiarch
945 945
946
9472012-08-02 Sung W. Park (sung_)
948
949 * Fix evas_gl's internal resource surface bug. For optimzation evas_gl
950 was using evas' window surface to do its resource creation and it
951 wans't properly updated when a window is destroyed and recreated.
diff --git a/legacy/evas/NEWS b/legacy/evas/NEWS
index ea0dede6bc..6426cd01e4 100644
--- a/legacy/evas/NEWS
+++ b/legacy/evas/NEWS
@@ -26,6 +26,7 @@ Fixes:
26 * Don't crash when calling evas_object_smart_type_check without type. 26 * Don't crash when calling evas_object_smart_type_check without type.
27 * Handle proxy with the right context. 27 * Handle proxy with the right context.
28 * Force proxied object to stay active to keep track of change in them. 28 * Force proxied object to stay active to keep track of change in them.
29 * Fix evas_gl's internal resource surface bug when evas' window is deleted/recreated.
29 30
30Removal: 31Removal:
31 * Remove EVAS_FRAME_QUEUING, EVAS_SLI, METRIC_CACHE and WORD_CACHE. 32 * Remove EVAS_FRAME_QUEUING, EVAS_SLI, METRIC_CACHE and WORD_CACHE.
diff --git a/legacy/evas/src/modules/engines/gl_x11/evas_engine.c b/legacy/evas/src/modules/engines/gl_x11/evas_engine.c
index 78cc98c190..7dc6c248f6 100644
--- a/legacy/evas/src/modules/engines/gl_x11/evas_engine.c
+++ b/legacy/evas/src/modules/engines/gl_x11/evas_engine.c
@@ -621,14 +621,14 @@ _gl_ext_init(Render_Engine *re)
621 glexts = (const char*)glGetString(GL_EXTENSIONS); 621 glexts = (const char*)glGetString(GL_EXTENSIONS);
622 622
623 ext_len = strlen(glexts); 623 ext_len = strlen(glexts);
624 if (!ext_len) 624 if (!ext_len)
625 { 625 {
626 DBG("GL Get Extension string NULL: No extensions supported"); 626 DBG("GL Get Extension string NULL: No extensions supported");
627 return; 627 return;
628 } 628 }
629 629
630 _gl_ext_string = calloc(1, sizeof(char) * ext_len * 2); 630 _gl_ext_string = calloc(1, sizeof(char) * ext_len * 2);
631 if (!_gl_ext_string) 631 if (!_gl_ext_string)
632 { 632 {
633 ERR("Error allocating _gl_ext_string."); 633 ERR("Error allocating _gl_ext_string.");
634 return; 634 return;
@@ -662,14 +662,14 @@ _gl_ext_init(Render_Engine *re)
662#endif 662#endif
663 ext_len = strlen(evasglexts); 663 ext_len = strlen(evasglexts);
664 664
665 if (!ext_len) 665 if (!ext_len)
666 { 666 {
667 DBG("GL Get Extension string NULL: No extensions supported"); 667 DBG("GL Get Extension string NULL: No extensions supported");
668 return; 668 return;
669 } 669 }
670 670
671 _evasgl_ext_string = calloc(1, sizeof(char) * ext_len * 2); 671 _evasgl_ext_string = calloc(1, sizeof(char) * ext_len * 2);
672 if (!_evasgl_ext_string) 672 if (!_evasgl_ext_string)
673 { 673 {
674 ERR("Error allocating _evasgl_ext_string."); 674 ERR("Error allocating _evasgl_ext_string.");
675 return; 675 return;
@@ -889,6 +889,15 @@ _destroy_internal_glue_resources(void *data)
889 Render_Engine_GL_Resource *rsc; 889 Render_Engine_GL_Resource *rsc;
890 890
891#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX) 891#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
892 // Create internal resource context if it hasn't been created already
893 if ((rsc = eina_tls_get(resource_key)) == NULL)
894 {
895 ERR("Error retrieving the TLS resources.");
896 return 0;
897 }
898
899 if (eina_main_loop_is()) rsc->surface = re->win->egl_surface[0];
900
892 // EGL 901 // EGL
893 // Delete the Resources 902 // Delete the Resources
894 LKL(resource_lock); 903 LKL(resource_lock);
@@ -900,7 +909,7 @@ _destroy_internal_glue_resources(void *data)
900 eglDestroyContext(re->win->egl_disp, rsc->context); 909 eglDestroyContext(re->win->egl_disp, rsc->context);
901 free(rsc); 910 free(rsc);
902 } 911 }
903#else 912 #else
904 // GLX 913 // GLX
905 // Delete the Resources 914 // Delete the Resources
906 LKL(resource_lock); 915 LKL(resource_lock);
@@ -937,6 +946,45 @@ _destroy_internal_glue_resources(void *data)
937} 946}
938 947
939 948
949static int
950_internal_resources_make_current(void *data)
951{
952 Render_Engine *re = (Render_Engine *)data;
953 Render_Engine_GL_Resource *rsc;
954 int ret = 0;
955
956 // Create internal resource context if it hasn't been created already
957 if ((rsc = eina_tls_get(resource_key)) == NULL)
958 {
959 if ((rsc = _create_internal_glue_resources(re)) == NULL)
960 {
961 ERR("Error creating internal resources.");
962 return 0;
963 }
964 }
965
966 // Use resource surface/context to create surface resrouces
967#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
968 // Update the evas' window surface
969 if (eina_main_loop_is()) rsc->surface = re->win->egl_surface[0];
970
971 ret = eglMakeCurrent(re->win->egl_disp, rsc->surface, rsc->surface, rsc->context);
972
973 if (!ret)
974 {
975 ERR("eglMakeCurrent() failed. Error Code: %#x", eglGetError());
976 return 0;
977 }
978#else
979 ret = glXMakeCurrent(re->info->info.display, re->win->win, rsc->context);
980 if (!ret)
981 {
982 ERR("glXMakeCurrent()!");
983 return 0;
984 }
985#endif
986 return 1;
987}
940 988
941static int 989static int
942eng_setup(Evas *e, void *in) 990eng_setup(Evas *e, void *in)
@@ -3023,7 +3071,7 @@ _print_gl_surface_info(Render_Engine_GL_Surface *sfc, int error)
3023 else \ 3071 else \
3024 DBG(__VA_ARGS__); 3072 DBG(__VA_ARGS__);
3025 3073
3026 PRINT_LOG("----------Surface Info------------"); 3074 PRINT_LOG("----------Surface Info------------");
3027 PRINT_LOG(" [Surface] %x", (unsigned int)sfc); 3075 PRINT_LOG(" [Surface] %x", (unsigned int)sfc);
3028 PRINT_LOG(" Width: %d", sfc->w); 3076 PRINT_LOG(" Width: %d", sfc->w);
3029 PRINT_LOG(" Height: %d", sfc->h); 3077 PRINT_LOG(" Height: %d", sfc->h);
@@ -3045,7 +3093,7 @@ _print_gl_surface_info(Render_Engine_GL_Surface *sfc, int error)
3045 PRINT_LOG(" RenderBuffer Stencil Format : %x", sfc->rb_stencil_fmt); 3093 PRINT_LOG(" RenderBuffer Stencil Format : %x", sfc->rb_stencil_fmt);
3046 PRINT_LOG(" RenderBuffer Depth Stencil : %x", sfc->rb_depth_stencil); 3094 PRINT_LOG(" RenderBuffer Depth Stencil : %x", sfc->rb_depth_stencil);
3047 PRINT_LOG(" RenderBuffer Depth Stencil Format: %x", sfc->rb_depth_stencil_fmt); 3095 PRINT_LOG(" RenderBuffer Depth Stencil Format: %x", sfc->rb_depth_stencil_fmt);
3048 PRINT_LOG("--------------------------------------"); 3096 PRINT_LOG("--------------------------------------");
3049 3097
3050#undef PRINT_LOG 3098#undef PRINT_LOG
3051} 3099}
@@ -3368,9 +3416,9 @@ _attach_fbo_surface(Render_Engine *data __UNUSED__,
3368 3416
3369 // Attach texture to FBO 3417 // Attach texture to FBO
3370 if (sfc->rt_msaa_samples) 3418 if (sfc->rt_msaa_samples)
3371 glsym_glFramebufferTexture2DMultisample(GL_FRAMEBUFFER, 3419 glsym_glFramebufferTexture2DMultisample(GL_FRAMEBUFFER,
3372 GL_COLOR_ATTACHMENT0, 3420 GL_COLOR_ATTACHMENT0,
3373 GL_TEXTURE_2D, sfc->rt_tex, 3421 GL_TEXTURE_2D, sfc->rt_tex,
3374 0, sfc->rt_msaa_samples); 3422 0, sfc->rt_msaa_samples);
3375 else 3423 else
3376 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, 3424 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
@@ -3391,17 +3439,17 @@ _attach_fbo_surface(Render_Engine *data __UNUSED__,
3391 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 3439 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
3392 glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_STENCIL_OES, sfc->w, sfc->h, 3440 glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_STENCIL_OES, sfc->w, sfc->h,
3393 0, GL_DEPTH_STENCIL_OES, GL_UNSIGNED_INT_24_8_OES, NULL); 3441 0, GL_DEPTH_STENCIL_OES, GL_UNSIGNED_INT_24_8_OES, NULL);
3394 if (sfc->rt_msaa_samples) 3442 if (sfc->rt_msaa_samples)
3395 { 3443 {
3396 glsym_glFramebufferTexture2DMultisample(GL_FRAMEBUFFER, 3444 glsym_glFramebufferTexture2DMultisample(GL_FRAMEBUFFER,
3397 GL_DEPTH_ATTACHMENT, 3445 GL_DEPTH_ATTACHMENT,
3398 GL_TEXTURE_2D, 3446 GL_TEXTURE_2D,
3399 sfc->rb_depth_stencil, 3447 sfc->rb_depth_stencil,
3400 0, sfc->rt_msaa_samples); 3448 0, sfc->rt_msaa_samples);
3401 glsym_glFramebufferTexture2DMultisample(GL_FRAMEBUFFER, 3449 glsym_glFramebufferTexture2DMultisample(GL_FRAMEBUFFER,
3402 GL_STENCIL_ATTACHMENT, 3450 GL_STENCIL_ATTACHMENT,
3403 GL_TEXTURE_2D, 3451 GL_TEXTURE_2D,
3404 sfc->rb_depth_stencil, 3452 sfc->rb_depth_stencil,
3405 0, sfc->rt_msaa_samples); 3453 0, sfc->rt_msaa_samples);
3406 } 3454 }
3407 else 3455 else
@@ -3535,7 +3583,7 @@ _create_rt_buffers(Render_Engine *data __UNUSED__,
3535 ERR("_attach_fbo_surface() failed."); 3583 ERR("_attach_fbo_surface() failed.");
3536 return 0; 3584 return 0;
3537 } 3585 }
3538 else 3586 else
3539 return 1; 3587 return 1;
3540} 3588}
3541 3589
@@ -3582,25 +3630,10 @@ eng_gl_surface_create(void *data, void *config, int w, int h)
3582#endif 3630#endif
3583 } 3631 }
3584 3632
3585 // Create internal resource context if it hasn't been created already 3633 // Use resource surface/context to do a make current
3586 if ((rsc = eina_tls_get(resource_key)) == NULL) 3634 if (!_internal_resources_make_current(re))
3587 {
3588 if ((rsc = _create_internal_glue_resources(re)) == NULL)
3589 {
3590 ERR("Error creating internal resources.");
3591 goto finish;
3592 }
3593 }
3594
3595 // Use resource surface/context to create surface resrouces
3596#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
3597 res = eglMakeCurrent(re->win->egl_disp, rsc->surface, rsc->surface, rsc->context);
3598#else
3599 res = glXMakeCurrent(re->info->info.display, re->win->win, rsc->context);
3600#endif
3601 if (!res)
3602 { 3635 {
3603 ERR("xxxMakeCurrent() finish!"); 3636 ERR("Error doing a make current with the internal resources.");
3604 goto finish; 3637 goto finish;
3605 } 3638 }
3606 3639
@@ -3662,16 +3695,10 @@ eng_gl_surface_destroy(void *data, void *surface)
3662 3695
3663 if (!sfc) return 0; 3696 if (!sfc) return 0;
3664 3697
3665 if ((rsc = eina_tls_get(resource_key)) == EINA_FALSE) return 0; 3698 // Use resource surface/context to create surface resrouces
3666 3699 if (!_internal_resources_make_current(re))
3667#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
3668 ret = eglMakeCurrent(re->win->egl_disp, rsc->surface, rsc->surface, rsc->context);
3669#else
3670 ret = glXMakeCurrent(re->info->info.display, re->win->win, rsc->context);
3671#endif
3672 if (!ret)
3673 { 3700 {
3674 ERR("xxxMakeCurrent() failed!"); 3701 ERR("Error doing a make current with the internal resources.");
3675 return 0; 3702 return 0;
3676 } 3703 }
3677 3704
@@ -3813,19 +3840,10 @@ eng_gl_context_destroy(void *data, void *context)
3813 3840
3814 if (!ctx) return 0; 3841 if (!ctx) return 0;
3815 3842
3816 if ((rsc = eina_tls_get(resource_key)) == EINA_FALSE) return 0; 3843 // Use resource surface/context to create surface resrouces
3817 3844 if (!_internal_resources_make_current(re))
3818 // Do a make current with the given context
3819#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
3820 ret = eglMakeCurrent(re->win->egl_disp, rsc->surface,
3821 rsc->surface, ctx->context);
3822#else
3823 ret = glXMakeCurrent(re->info->info.display, re->win->win,
3824 ctx->context);
3825#endif
3826 if (!ret)
3827 { 3845 {
3828 ERR("xxxMakeCurrent() failed!"); 3846 ERR("Error doing a make current with the internal resources.");
3829 return 0; 3847 return 0;
3830 } 3848 }
3831 3849
@@ -3904,7 +3922,14 @@ eng_gl_make_current(void *data __UNUSED__, void *surface, void *context)
3904 // rendering outside of pixel getter but it doesn't guarantee 3922 // rendering outside of pixel getter but it doesn't guarantee
3905 // correct rendering. 3923 // correct rendering.
3906 if ((sfc->direct_fb_opt) && (gl_direct_img_obj || gl_direct_override)) 3924 if ((sfc->direct_fb_opt) && (gl_direct_img_obj || gl_direct_override))
3907 gl_direct_enabled = 1; 3925 {
3926#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
3927 sfc->direct_sfc = re->win->egl_surface[0];
3928#else
3929 sfc->direct_sfc = re->win->win;
3930#endif
3931 gl_direct_enabled = 1;
3932 }
3908 else 3933 else
3909 gl_direct_enabled = 0; 3934 gl_direct_enabled = 0;
3910 3935