summaryrefslogtreecommitdiff
path: root/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c
diff options
context:
space:
mode:
authorDerek Foreman <derekf@osg.samsung.com>2016-09-02 11:07:17 -0500
committerDerek Foreman <derekf@osg.samsung.com>2016-09-08 13:55:23 -0500
commit316ca09b0d705bf38c5cc0dda066351116807cd7 (patch)
treef57bf22812ccc393b0411370186ec4bcf4abbf18 /src/modules/ecore_evas/engines/drm/ecore_evas_drm.c
parent31de16d40840381cf9d425441cd55c3b1d57301c (diff)
ecore_evas_drm: Refactor common code
ecore_evas_gl_drm_new_internal and ecore_Evas_drm_new_internal are huge functions differing in very few lines. Combined them.
Diffstat (limited to 'src/modules/ecore_evas/engines/drm/ecore_evas_drm.c')
-rw-r--r--src/modules/ecore_evas/engines/drm/ecore_evas_drm.c163
1 files changed, 39 insertions, 124 deletions
diff --git a/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c b/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c
index eef1bdaf62..8289a76332 100644
--- a/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c
+++ b/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c
@@ -668,16 +668,18 @@ static Ecore_Evas_Engine_Func _ecore_evas_drm_engine_func =
668 NULL // evas_changed 668 NULL // evas_changed
669}; 669};
670 670
671EAPI Ecore_Evas * 671static Ecore_Evas *
672ecore_evas_drm_new_internal(const char *device, unsigned int parent EINA_UNUSED, int x, int y, int w, int h) 672_ecore_evas_new_internal(const char *device, int x, int y, int w, int h, Eina_Bool gl)
673{ 673{
674 Ecore_Evas *ee; 674 Ecore_Evas *ee;
675 Evas_Engine_Info_Drm *einfo;
676 Ecore_Evas_Interface_Drm *iface; 675 Ecore_Evas_Interface_Drm *iface;
677 Ecore_Evas_Engine_Drm_Data *edata; 676 Ecore_Evas_Engine_Drm_Data *edata;
678 int method, mw, mh; 677 int method, mw, mh;
678 void *tinfo;
679
680 if (gl) method = evas_render_method_lookup("gl_drm");
681 else method = evas_render_method_lookup("drm");
679 682
680 method = evas_render_method_lookup("drm");
681 if (!method) return NULL; 683 if (!method) return NULL;
682 684
683 ee = calloc(1, sizeof(Ecore_Evas)); 685 ee = calloc(1, sizeof(Ecore_Evas));
@@ -707,7 +709,9 @@ ecore_evas_drm_new_internal(const char *device, unsigned int parent EINA_UNUSED,
707 709
708 ECORE_MAGIC_SET(ee, ECORE_MAGIC_EVAS); 710 ECORE_MAGIC_SET(ee, ECORE_MAGIC_EVAS);
709 711
710 ee->driver = "drm"; 712 if (gl) ee->driver = "gl_drm";
713 else ee->driver = "drm";
714
711 ee->engine.func = (Ecore_Evas_Engine_Func *)&_ecore_evas_drm_engine_func; 715 ee->engine.func = (Ecore_Evas_Engine_Func *)&_ecore_evas_drm_engine_func;
712 ee->engine.data = edata; 716 ee->engine.data = edata;
713 717
@@ -730,7 +734,7 @@ ecore_evas_drm_new_internal(const char *device, unsigned int parent EINA_UNUSED,
730 ee->prop.withdrawn = EINA_TRUE; 734 ee->prop.withdrawn = EINA_TRUE;
731 ee->alpha = EINA_FALSE; 735 ee->alpha = EINA_FALSE;
732 736
733 ee->can_async_render = 1; 737 ee->can_async_render = !gl;
734 if (getenv("ECORE_EVAS_FORCE_SYNC_RENDER")) 738 if (getenv("ECORE_EVAS_FORCE_SYNC_RENDER"))
735 ee->can_async_render = 0; 739 ee->can_async_render = 0;
736 740
@@ -744,9 +748,18 @@ ecore_evas_drm_new_internal(const char *device, unsigned int parent EINA_UNUSED,
744 evas_event_callback_add(ee->evas, EVAS_CALLBACK_RENDER_POST, 748 evas_event_callback_add(ee->evas, EVAS_CALLBACK_RENDER_POST,
745 _drm_render_updates, ee); 749 _drm_render_updates, ee);
746 750
747 einfo = (Evas_Engine_Info_Drm *)evas_engine_info_get(ee->evas); 751 tinfo = evas_engine_info_get(ee->evas);
748 if (einfo) 752 if (tinfo && gl)
749 { 753 {
754 char *num;
755 Evas_Engine_Info_GL_Drm *einfo = tinfo;
756
757 einfo->info.vsync = EINA_TRUE;
758
759 num = getenv("EVAS_DRM_VSYNC");
760 if ((num) && (!atoi(num)))
761 einfo->info.vsync = EINA_FALSE;
762
750 einfo->info.fd = edata->fd; 763 einfo->info.fd = edata->fd;
751 einfo->info.bpp = edata->bpp; 764 einfo->info.bpp = edata->bpp;
752 einfo->info.depth = edata->depth; 765 einfo->info.depth = edata->depth;
@@ -759,123 +772,9 @@ ecore_evas_drm_new_internal(const char *device, unsigned int parent EINA_UNUSED,
759 goto eng_err; 772 goto eng_err;
760 } 773 }
761 } 774 }
762 775 else if (tinfo)
763 ee->prop.window = ecore_drm2_output_crtc_get(edata->output);
764 ecore_drm2_device_window_set(edata->dev, ee->prop.window);
765
766 ecore_evas_data_set(ee, "device", edata->dev);
767
768 _ecore_evas_register(ee);
769 ecore_event_window_register(ee->prop.window, ee, ee->evas,
770 (Ecore_Event_Mouse_Move_Cb)_ecore_evas_mouse_move_process,
771 (Ecore_Event_Multi_Move_Cb)_ecore_evas_mouse_multi_move_process,
772 (Ecore_Event_Multi_Down_Cb)_ecore_evas_mouse_multi_down_process,
773 (Ecore_Event_Multi_Up_Cb)_ecore_evas_mouse_multi_up_process);
774 _ecore_event_window_direct_cb_set(ee->prop.window, _ecore_evas_input_direct_cb);
775
776 ecore_drm2_output_crtc_size_get(edata->output, &mw, &mh);
777
778 ecore_drm2_device_calibrate(edata->dev, mw, mh);
779 ecore_drm2_device_pointer_max_set(edata->dev, mw, mh);
780 ecore_drm2_device_pointer_warp(edata->dev, mw / 2, mh / 2);
781
782 return ee;
783
784eng_err:
785 ecore_evas_free(ee);
786 return NULL;
787}
788
789#ifdef BUILD_ECORE_EVAS_GL_DRM
790EAPI Ecore_Evas *
791ecore_evas_gl_drm_new_internal(const char *device, unsigned int parent EINA_UNUSED, int x, int y, int w, int h)
792{
793 Ecore_Evas *ee;
794 Evas_Engine_Info_GL_Drm *einfo;
795 Ecore_Evas_Interface_Drm *iface;
796 Ecore_Evas_Engine_Drm_Data *edata;
797 int method, mw, mh;
798
799 dlopen("libglapi.so.0", RTLD_LAZY | RTLD_GLOBAL);
800 if (dlerror()) return NULL;
801
802 method = evas_render_method_lookup("gl_drm");
803 if (!method) return NULL;
804
805 ee = calloc(1, sizeof(Ecore_Evas));
806 if (!ee) return NULL;
807
808 edata = calloc(1, sizeof(Ecore_Evas_Engine_Drm_Data));
809 if (!edata)
810 {
811 free(ee);
812 return NULL;
813 }
814
815 edata->x = x;
816 edata->y = y;
817 edata->w = w;
818 edata->h = h;
819 edata->depth = 24; // FIXME: Remove hardcode
820 edata->bpp = 32; // FIXME: Remove hardcode
821 edata->format = DRM_FORMAT_XRGB8888;
822
823 if (_ecore_evas_drm_init(edata, device) < 1)
824 {
825 free(edata);
826 free(ee);
827 return NULL;
828 }
829
830 ECORE_MAGIC_SET(ee, ECORE_MAGIC_EVAS);
831
832 ee->driver = "gl_drm";
833 ee->engine.func = (Ecore_Evas_Engine_Func *)&_ecore_evas_drm_engine_func;
834 ee->engine.data = edata;
835
836 /* FIXME */
837 /* if (edata->device) ee->name = strdup(edata->device); */
838
839 iface = _ecore_evas_drm_interface_new();
840 ee->engine.ifaces = eina_list_append(ee->engine.ifaces, iface);
841
842 ee->x = ee->req.x = x;
843 ee->y = ee->req.y = y;
844 ee->w = ee->req.w = w;
845 ee->h = ee->req.h = h;
846
847 ee->prop.max.w = 32767;
848 ee->prop.max.h = 32767;
849 ee->prop.layer = 4;
850 ee->prop.request_pos = 0;
851 ee->prop.sticky = 0;
852 ee->prop.withdrawn = EINA_TRUE;
853 ee->alpha = EINA_FALSE;
854
855 ee->can_async_render = 0; // FIXME ??
856 if (getenv("ECORE_EVAS_FORCE_SYNC_RENDER"))
857 ee->can_async_render = 0;
858
859 ee->evas = evas_new();
860 evas_data_attach_set(ee->evas, ee);
861 evas_output_method_set(ee->evas, method);
862 evas_output_size_set(ee->evas, w, h);
863 evas_output_viewport_set(ee->evas, 0, 0, w, h);
864
865 if (ee->can_async_render)
866 evas_event_callback_add(ee->evas, EVAS_CALLBACK_RENDER_POST,
867 _drm_render_updates, ee);
868
869 einfo = (Evas_Engine_Info_GL_Drm *)evas_engine_info_get(ee->evas);
870 if (einfo)
871 { 776 {
872 char *num; 777 Evas_Engine_Info_Drm *einfo = tinfo;
873
874 einfo->info.vsync = EINA_TRUE;
875
876 num = getenv("EVAS_DRM_VSYNC");
877 if ((num) && (!atoi(num)))
878 einfo->info.vsync = EINA_FALSE;
879 778
880 einfo->info.fd = edata->fd; 779 einfo->info.fd = edata->fd;
881 einfo->info.bpp = edata->bpp; 780 einfo->info.bpp = edata->bpp;
@@ -915,4 +814,20 @@ eng_err:
915 ecore_evas_free(ee); 814 ecore_evas_free(ee);
916 return NULL; 815 return NULL;
917} 816}
817
818EAPI Ecore_Evas *
819ecore_evas_drm_new_internal(const char *device, unsigned int parent EINA_UNUSED, int x, int y, int w, int h)
820{
821 return _ecore_evas_new_internal(device, x, y, w, h, EINA_FALSE);
822}
823
824#ifdef BUILD_ECORE_EVAS_GL_DRM
825EAPI Ecore_Evas *
826ecore_evas_gl_drm_new_internal(const char *device, unsigned int parent EINA_UNUSED, int x, int y, int w, int h)
827{
828 dlopen("libglapi.so.0", RTLD_LAZY | RTLD_GLOBAL);
829 if (dlerror()) return NULL;
830
831 return _ecore_evas_new_internal(device, x, y, w, h, EINA_TRUE);
832}
918#endif 833#endif