summaryrefslogtreecommitdiff
path: root/src/modules/evas/engines/wayland_egl/evas_engine.c
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2016-12-02 15:30:02 -0800
committerCedric BAIL <cedric@osg.samsung.com>2016-12-07 15:47:56 -0800
commit73b308fb66f871b93ef8e324997872e3bf175906 (patch)
treed9884312412aa72a9f636d334e2634b808960af3 /src/modules/evas/engines/wayland_egl/evas_engine.c
parentda5f41723aa3714a3a3faef59270066bdab2f11b (diff)
evas: refactor setup stage and reduce complexity for engine.
Diffstat (limited to 'src/modules/evas/engines/wayland_egl/evas_engine.c')
-rw-r--r--src/modules/evas/engines/wayland_egl/evas_engine.c286
1 files changed, 152 insertions, 134 deletions
diff --git a/src/modules/evas/engines/wayland_egl/evas_engine.c b/src/modules/evas/engines/wayland_egl/evas_engine.c
index 4d47f6f..a4687d4 100644
--- a/src/modules/evas/engines/wayland_egl/evas_engine.c
+++ b/src/modules/evas/engines/wayland_egl/evas_engine.c
@@ -524,19 +524,12 @@ eng_info_free(Evas *evas EINA_UNUSED, void *info)
524 free(inf); 524 free(inf);
525} 525}
526 526
527static int 527static Render_Engine_Swap_Mode
528eng_setup(Evas *evas, void *info) 528_eng_swap_mode_get(void)
529{ 529{
530 Render_Engine_Swap_Mode swap_mode = MODE_FULL; 530 Render_Engine_Swap_Mode swap_mode = MODE_FULL;
531 Evas_Engine_Info_Wayland *inf;
532 Evas_Public_Data *epd;
533 Render_Engine *re;
534 Outbuf *ob;
535 const char *s; 531 const char *s;
536 532
537 inf = (Evas_Engine_Info_Wayland *)info;
538 epd = efl_data_scope_get(evas, EVAS_CANVAS_CLASS);
539
540 if ((s = getenv("EVAS_GL_SWAP_MODE"))) 533 if ((s = getenv("EVAS_GL_SWAP_MODE")))
541 { 534 {
542 if ((!strcasecmp(s, "full")) || 535 if ((!strcasecmp(s, "full")) ||
@@ -558,149 +551,180 @@ eng_setup(Evas *evas, void *info)
558 (!strcasecmp(s, "4"))) 551 (!strcasecmp(s, "4")))
559 swap_mode = MODE_QUADRUPLE; 552 swap_mode = MODE_QUADRUPLE;
560 } 553 }
561 else swap_mode = MODE_AUTO; 554 else
555 {
556 swap_mode = MODE_AUTO;
557 }
558
559 return swap_mode;
560}
561
562static Render_Engine_Merge_Mode
563_eng_merge_mode_get(void)
564{
565 Render_Engine_Merge_Mode merge = MERGE_SMART;
566 const char *s;
562 567
563 if (!(re = epd->engine.data.output)) 568 if ((s = getenv("EVAS_GL_PARTIAL_MERGE")))
564 { 569 {
565 Render_Engine_Merge_Mode merge = MERGE_SMART; 570 if ((!strcmp(s, "bounding")) || (!strcmp(s, "b")))
566 571 merge = MERGE_BOUNDING;
567 /* FIXME: Remove this line as soon as eglGetDisplay() autodetection 572 else if ((!strcmp(s, "full")) || (!strcmp(s, "f")))
568 * gets fixed. Currently it is incorrectly detecting wl_display and 573 merge = MERGE_FULL;
569 * returning _EGL_PLATFORM_X11 instead of _EGL_PLATFORM_WAYLAND. 574 else if ((!strcmp(s, "smart")) || (!strcmp(s, "s")))
570 * 575 merge = MERGE_SMART;
571 * See ticket #1972 for more info. 576 }
572 */
573 setenv("EGL_PLATFORM", "wayland", 1);
574
575 /* try to allocate space for a new render engine */
576 if (!(re = calloc(1, sizeof(Render_Engine))))
577 return 0;
578
579 /* if we have not initialize gl & evas, do it */
580 if (!initted)
581 {
582 glsym_evas_gl_preload_init();
583 }
584 577
585 ob = eng_window_new(evas, inf, epd->output.w, epd->output.h, swap_mode); 578 return merge;
586 if (!ob) goto ob_err; 579}
587 580
588 if (!evas_render_engine_gl_generic_init(&re->generic, ob, 581static void *
589 eng_outbuf_swap_mode_get, 582eng_setup(void *info, unsigned int w, unsigned int h)
590 eng_outbuf_rotation_get, 583{
591 eng_outbuf_reconfigure, 584 Evas_Engine_Info_Wayland *inf = info;
592 eng_outbuf_region_first_rect, 585 Render_Engine *re;
593 eng_outbuf_damage_region_set, 586 Outbuf *ob;
594 eng_outbuf_update_region_new, 587 Render_Engine_Swap_Mode swap_mode;
595 eng_outbuf_update_region_push, 588 Render_Engine_Merge_Mode merge;
596 eng_outbuf_update_region_free,
597 NULL,
598 eng_outbuf_flush,
599 NULL,
600 eng_window_free,
601 eng_window_use,
602 eng_outbuf_gl_context_get,
603 eng_outbuf_egl_display_get,
604 eng_gl_context_new,
605 eng_gl_context_use,
606 &evgl_funcs,
607 epd->output.w, epd->output.h))
608 {
609 eng_window_free(ob);
610 goto ob_err;
611 }
612 589
613 epd->engine.data.output = re; 590 swap_mode = _eng_swap_mode_get();
614 gl_wins++; 591 merge = _eng_merge_mode_get();
615 592
616 if ((s = getenv("EVAS_GL_PARTIAL_MERGE"))) 593 /* FIXME: Remove this line as soon as eglGetDisplay() autodetection
617 { 594 * gets fixed. Currently it is incorrectly detecting wl_display and
618 if ((!strcmp(s, "bounding")) || (!strcmp(s, "b"))) 595 * returning _EGL_PLATFORM_X11 instead of _EGL_PLATFORM_WAYLAND.
619 merge = MERGE_BOUNDING; 596 *
620 else if ((!strcmp(s, "full")) || (!strcmp(s, "f"))) 597 * See ticket #1972 for more info.
621 merge = MERGE_FULL; 598 */
622 else if ((!strcmp(s, "smart")) || (!strcmp(s, "s"))) 599 setenv("EGL_PLATFORM", "wayland", 1);
623 merge = MERGE_SMART;
624 }
625 600
626 evas_render_engine_software_generic_merge_mode_set(&re->generic.software, merge); 601 /* try to allocate space for a new render engine */
602 if (!(re = calloc(1, sizeof(Render_Engine))))
603 return NULL;
627 604
628 if (!initted) 605 /* if we have not initialize gl & evas, do it */
629 { 606 if (!initted)
630 gl_extn_veto(re); 607 {
631 initted = EINA_TRUE; 608 glsym_evas_gl_preload_init();
632 }
633 } 609 }
634 else 610
611 ob = eng_window_new(evas, inf, w, h, swap_mode);
612 if (!ob) goto ob_err;
613
614 if (!evas_render_engine_gl_generic_init(&re->generic, ob,
615 eng_outbuf_swap_mode_get,
616 eng_outbuf_rotation_get,
617 eng_outbuf_reconfigure,
618 eng_outbuf_region_first_rect,
619 eng_outbuf_damage_region_set,
620 eng_outbuf_update_region_new,
621 eng_outbuf_update_region_push,
622 eng_outbuf_update_region_free,
623 NULL,
624 eng_outbuf_flush,
625 NULL,
626 eng_window_free,
627 eng_window_use,
628 eng_outbuf_gl_context_get,
629 eng_outbuf_egl_display_get,
630 eng_gl_context_new,
631 eng_gl_context_use,
632 &evgl_funcs,
633 w, h))
635 { 634 {
636 re = epd->engine.data.output; 635 eng_window_free(ob);
637 ob = eng_get_ob(re); 636 free(re);
637 return NULL;
638 }
638 639
639 if (!inf->info.wl_surface && (ob->egl_surface[0] != EGL_NO_SURFACE)) 640 gl_wins++;
640 {
641 eglDestroySurface(ob->egl_disp, ob->egl_surface[0]);
642 eglMakeCurrent(ob->egl_disp, EGL_NO_SURFACE, EGL_NO_SURFACE,
643 EGL_NO_CONTEXT);
644 ob->egl_surface[0] = EGL_NO_SURFACE;
645 return 1;
646 }
647 641
648 if ((ob) && (_re_wincheck(ob))) 642 evas_render_engine_software_generic_merge_mode_set(&re->generic.software, merge);
649 {
650 ob->info = inf;
651 if ((ob->info->info.wl_display != ob->disp) ||
652 (ob->info->info.wl_surface != ob->surface) ||
653 /* FIXME: comment out below line.
654 * since there is no place set the info->info.win for now,
655 * it causes renew the window unnecessarily.
656 */
657 /* (ob->info->info.win != ob->win) || */
658 (ob->info->info.depth != ob->depth) ||
659 (ob->info->info.destination_alpha != ob->alpha))
660 {
661 gl_wins--;
662 if (!ob->info->info.wl_display)
663 {
664 eng_window_free(re->generic.software.ob);
665 re->generic.software.ob = NULL;
666 epd->engine.data.output = NULL;
667 goto ob_err;
668 }
669 643
670 ob = eng_window_new(evas, inf, epd->output.w, epd->output.h, swap_mode); 644 if (!initted)
671 if (!ob) goto ob_err; 645 {
646 gl_extn_veto(re);
647 initted = EINA_TRUE;
648 }
672 649
673 eng_window_use(ob); 650 if (re->generic.software.tb)
651 evas_common_tilebuf_free(re->generic.software.tb);
652 re->generic.software.tb = evas_common_tilebuf_new(w, h);
674 653
675 evas_render_engine_software_generic_update(&re->generic.software, ob, 654 if (re->generic.software.tb)
676 epd->output.w, epd->output.h); 655 {
677 gl_wins++; 656 evas_common_tilebuf_set_tile_size(re->generic.software.tb,
678 } 657 TILESIZE, TILESIZE);
679 else if ((ob->w != epd->output.w) || (ob->h != epd->output.h) || 658 evas_render_engine_software_generic_tile_strict_set
680 (ob->info->info.rotation != ob->rot)) 659 (&re->generic.software, EINA_TRUE);
681 {
682 eng_outbuf_reconfigure(ob, epd->output.w, epd->output.h,
683 ob->info->info.rotation, 0);
684 }
685 }
686 } 660 }
687 661
688 if (!eng_get_ob(re)) goto ob_err; 662 eng_window_use(eng_get_ob(re));
663
664 return re;
665}
689 666
690 if (!epd->engine.data.output) 667static int
668eng_update(void *data, void *info, unsigned int w, unsigned int h)
669{
670 Evas_Engine_Info_Wayland *inf = info;
671 Render_Engine *re = data;
672 Outbuf *ob;
673
674 ob = eng_get_ob(re);
675
676 if (!inf->info.wl_surface && (ob->egl_surface[0] != EGL_NO_SURFACE))
691 { 677 {
692 if (eng_get_ob(re)) 678 eglDestroySurface(ob->egl_disp, ob->egl_surface[0]);
679 eglMakeCurrent(ob->egl_disp, EGL_NO_SURFACE, EGL_NO_SURFACE,
680 EGL_NO_CONTEXT);
681 ob->egl_surface[0] = EGL_NO_SURFACE;
682 return 1;
683 }
684
685 if ((ob) && (_re_wincheck(ob)))
686 {
687 ob->info = inf;
688 if ((ob->info->info.wl_display != ob->disp) ||
689 (ob->info->info.wl_surface != ob->surface) ||
690 /* FIXME: comment out below line.
691 * since there is no place set the info->info.win for now,
692 * it causes renew the window unnecessarily.
693 */
694 /* (ob->info->info.win != ob->win) || */
695 (ob->info->info.depth != ob->depth) ||
696 (ob->info->info.destination_alpha != ob->alpha))
693 { 697 {
694 eng_window_free(eng_get_ob(re));
695 gl_wins--; 698 gl_wins--;
699 if (!ob->info->info.wl_display)
700 {
701 eng_window_free(ob);
702 re->generic.software.ob = NULL;
703 goto ob_err;
704 }
705
706 ob = eng_window_new(evas, inf, w, h, swap_mode);
707 if (!ob) goto ob_err;
708
709 eng_window_use(ob);
710
711 evas_render_engine_software_generic_update(&re->generic.software, ob,
712 w, h);
713 gl_wins++;
714 }
715 else if ((ob->w != w) || (ob->h != h) ||
716 (ob->info->info.rotation != ob->rot))
717 {
718 eng_outbuf_reconfigure(ob, w, h,
719 ob->info->info.rotation, 0);
696 } 720 }
697 goto ob_err;
698 } 721 }
699 722
723 if (!eng_get_ob(re)) goto ob_err;
724
700 if (re->generic.software.tb) 725 if (re->generic.software.tb)
701 evas_common_tilebuf_free(re->generic.software.tb); 726 evas_common_tilebuf_free(re->generic.software.tb);
702 re->generic.software.tb = 727 re->generic.software.tb = evas_common_tilebuf_new(w, h);
703 evas_common_tilebuf_new(epd->output.w, epd->output.h);
704 728
705 if (re->generic.software.tb) 729 if (re->generic.software.tb)
706 { 730 {
@@ -710,18 +734,11 @@ eng_setup(Evas *evas, void *info)
710 (&re->generic.software, EINA_TRUE); 734 (&re->generic.software, EINA_TRUE);
711 } 735 }
712 736
713 if (!epd->engine.data.context)
714 {
715 epd->engine.data.context =
716 epd->engine.func->context_new(epd->engine.data.output);
717 }
718
719 eng_window_use(eng_get_ob(re)); 737 eng_window_use(eng_get_ob(re));
720 738
721 return 1; 739 return 1;
722 740
723ob_err: 741ob_err:
724 free(re);
725 return 0; 742 return 0;
726} 743}
727 744
@@ -1407,6 +1424,7 @@ module_open(Evas_Module *em)
1407 ORD(info); 1424 ORD(info);
1408 ORD(info_free); 1425 ORD(info_free);
1409 ORD(setup); 1426 ORD(setup);
1427 ORD(update);
1410 ORD(canvas_alpha_get); 1428 ORD(canvas_alpha_get);
1411 1429
1412 ORD(output_free); 1430 ORD(output_free);