From 4fbb9a5e9220097cce7d43cecaec8d645d5e5e84 Mon Sep 17 00:00:00 2001 From: "Carsten Haitzler (Rasterman)" Date: Sun, 9 Mar 2014 01:22:33 +0900 Subject: [PATCH] win - add accel preference option to elm windows @feature - this adds the ability to hint what engine acceleration to use that is specific per display system. --- src/lib/elm_config.c | 20 ++++++++++ src/lib/elm_config.h | 35 +++++++++++++++++ src/lib/elm_priv.h | 1 + src/lib/elm_win.c | 106 ++++++++++++++++++++++++++++++++++++++++++--------- 4 files changed, 143 insertions(+), 19 deletions(-) diff --git a/src/lib/elm_config.c b/src/lib/elm_config.c index 4e63d08..843ea38 100644 --- a/src/lib/elm_config.c +++ b/src/lib/elm_config.c @@ -22,6 +22,7 @@ static Eet_Data_Descriptor *_config_color_overlay_edd = NULL; static Eet_Data_Descriptor *_config_bindings_widget_edd = NULL; static Eet_Data_Descriptor *_config_binding_key_edd = NULL; const char *_elm_preferred_engine = NULL; +const char *_elm_accel_preference = NULL; Eina_List *_font_overlays_del = NULL; Eina_List *_color_overlays_del = NULL; @@ -3005,6 +3006,7 @@ _elm_config_init(void) _config_load(); _env_get(); ELM_SAFE_FREE(_elm_preferred_engine, eina_stringshare_del); + ELM_SAFE_FREE(_elm_accel_preference, eina_stringshare_del); _translation_init(); _config_apply(); _elm_config_font_overlay_apply(); @@ -3146,6 +3148,23 @@ elm_config_preferred_engine_set(const char *engine) } EAPI const char * +elm_config_accel_preference_get(void) +{ + return _elm_accel_preference; +} + +EAPI void +elm_config_accel_preference_set(const char *pref) +{ + if (pref) + eina_stringshare_replace(&(_elm_accel_preference), pref); + else + { + ELM_SAFE_FREE(_elm_accel_preference, eina_stringshare_del); + } +} + +EAPI const char * elm_config_indicator_service_get(int rotation) { switch (rotation) @@ -3207,6 +3226,7 @@ _elm_config_shutdown(void) } ELM_SAFE_FREE(_elm_config, _config_free); ELM_SAFE_FREE(_elm_preferred_engine, eina_stringshare_del); + ELM_SAFE_FREE(_elm_accel_preference, eina_stringshare_del); ELM_SAFE_FREE(_elm_profile, free); #ifdef HAVE_ELEMENTARY_X diff --git a/src/lib/elm_config.h b/src/lib/elm_config.h index c7c3cd8..ccbf787 100644 --- a/src/lib/elm_config.h +++ b/src/lib/elm_config.h @@ -806,6 +806,41 @@ EAPI const char *elm_config_preferred_engine_get(void); */ EAPI void elm_config_preferred_engine_set(const char *engine); +/** + * @brief Get Elementary's preferred engine to use. + * + * @return The acceleration preference hint string + * @note there's no need to free the returned string, here. + * + * See elm_config_accel_preference_set() for more information, but this simply + * returns what was set by this call, nothing more. + * + * @see elm_config_accel_preference_set() + */ +EAPI const char *elm_config_accel_preference_get(void); + +/** + * @brief Set Elementary's acceleration preferences for new windows. + * + * @param pref The preference desired as a normal C string + * + * Note that it will take effect only to Elementary windows created after + * this is called. The @p pref string is a freeform C string that indicates + * what kind of acceleration is preferred. This may or may not be honored, + * but a best attempt will be made. Known strings are as follows: + * + * "gl", "opengl" - try use opengl. + * "3d" - try and use a 3d acceleration unit. + * "hw", "hardware", "accel" - try any acceleration unit (best possible) + * + * This takes precedence over engine preferences set with + * elm_config_preferred_engine_set(). + * + * @see elm_win_add() + */ +EAPI void elm_config_accel_preference_set(const char *pref); + + typedef struct _Elm_Text_Class { const char *name; diff --git a/src/lib/elm_priv.h b/src/lib/elm_priv.h index e1081e3..12d2200 100644 --- a/src/lib/elm_priv.h +++ b/src/lib/elm_priv.h @@ -532,6 +532,7 @@ extern int _elm_log_dom; extern Eina_List *_elm_win_list; extern int _elm_win_deferred_free; extern const char *_elm_preferred_engine; +extern const char *_elm_accel_preference; extern const char SIG_WIDGET_FOCUSED[]; extern const char SIG_WIDGET_UNFOCUSED[]; extern const char SIG_WIDGET_LANG_CHANGED[]; diff --git a/src/lib/elm_win.c b/src/lib/elm_win.c index e53088e..343282d 100644 --- a/src/lib/elm_win.c +++ b/src/lib/elm_win.c @@ -2886,17 +2886,49 @@ _win_constructor(Eo *obj, void *_pd, va_list *list) disp = getenv("ELM_DISPLAY"); if ((disp) && (!strcmp(disp, "x11"))) { - enginelist[0] = ENGINE_GET(); - enginelist[1] = ELM_SOFTWARE_X11; - enginelist[2] = ELM_OPENGL_X11; - enginelist[3] = NULL; + if ((_elm_accel_preference) && + ((!strcasecmp(_elm_accel_preference, "gl")) || + (!strcasecmp(_elm_accel_preference, "opengl")) || + (!strcasecmp(_elm_accel_preference, "3d")) || + (!strcasecmp(_elm_accel_preference, "hw")) || + (!strcasecmp(_elm_accel_preference, "hardware")) || + (!strcasecmp(_elm_accel_preference, "accel")) + )) + { + enginelist[0] = ELM_OPENGL_X11; + enginelist[1] = ELM_SOFTWARE_X11; + enginelist[2] = NULL; + } + else + { + enginelist[0] = ENGINE_GET(); + enginelist[1] = ELM_SOFTWARE_X11; + enginelist[2] = ELM_OPENGL_X11; + enginelist[3] = NULL; + } } else if ((disp) && (!strcmp(disp, "wl"))) { - enginelist[0] = ENGINE_GET(); - enginelist[1] = ELM_WAYLAND_SHM; - enginelist[2] = ELM_WAYLAND_EGL; - enginelist[3] = NULL; + if ((_elm_accel_preference) && + ((!strcasecmp(_elm_accel_preference, "gl")) || + (!strcasecmp(_elm_accel_preference, "opengl")) || + (!strcasecmp(_elm_accel_preference, "3d")) || + (!strcasecmp(_elm_accel_preference, "hw")) || + (!strcasecmp(_elm_accel_preference, "hardware")) || + (!strcasecmp(_elm_accel_preference, "accel")) + )) + { + enginelist[0] = ELM_WAYLAND_EGL; + enginelist[1] = ELM_WAYLAND_SHM; + enginelist[2] = NULL; + } + else + { + enginelist[0] = ENGINE_GET(); + enginelist[1] = ELM_WAYLAND_SHM; + enginelist[2] = ELM_WAYLAND_EGL; + enginelist[3] = NULL; + } } else if ((disp) && (!strcmp(disp, "win"))) { @@ -2906,10 +2938,26 @@ _win_constructor(Eo *obj, void *_pd, va_list *list) } else if ((disp) && (!strcmp(disp, "sdl"))) { - enginelist[0] = ENGINE_GET(); - enginelist[1] = ELM_SOFTWARE_SDL; - enginelist[2] = ELM_OPENGL_SDL; - enginelist[3] = NULL; + if ((_elm_accel_preference) && + ((!strcasecmp(_elm_accel_preference, "gl")) || + (!strcasecmp(_elm_accel_preference, "opengl")) || + (!strcasecmp(_elm_accel_preference, "3d")) || + (!strcasecmp(_elm_accel_preference, "hw")) || + (!strcasecmp(_elm_accel_preference, "hardware")) || + (!strcasecmp(_elm_accel_preference, "accel")) + )) + { + enginelist[0] = ELM_OPENGL_SDL; + enginelist[1] = ELM_SOFTWARE_SDL; + enginelist[2] = NULL; + } + else + { + enginelist[0] = ENGINE_GET(); + enginelist[1] = ELM_SOFTWARE_SDL; + enginelist[2] = ELM_OPENGL_SDL; + enginelist[3] = NULL; + } } else if ((disp) && (!strcmp(disp, "mac"))) { @@ -2948,13 +2996,33 @@ _win_constructor(Eo *obj, void *_pd, va_list *list) } else { - enginelist[0] = ENGINE_GET(); - enginelist[1] = ELM_SOFTWARE_X11; - enginelist[2] = ELM_WAYLAND_SHM; - enginelist[3] = ELM_SOFTWARE_FB; - enginelist[4] = ELM_OPENGL_COCOA; - enginelist[5] = ELM_SOFTWARE_SDL; - enginelist[6] = NULL; + if ((_elm_accel_preference) && + ((!strcasecmp(_elm_accel_preference, "gl")) || + (!strcasecmp(_elm_accel_preference, "opengl")) || + (!strcasecmp(_elm_accel_preference, "3d")) || + (!strcasecmp(_elm_accel_preference, "hw")) || + (!strcasecmp(_elm_accel_preference, "hardware")) || + (!strcasecmp(_elm_accel_preference, "accel")) + )) + { + enginelist[0] = ENGINE_GET(); + enginelist[1] = ELM_OPENGL_X11; + enginelist[2] = ELM_WAYLAND_EGL; + enginelist[3] = ELM_SOFTWARE_FB; + enginelist[4] = ELM_OPENGL_COCOA; + enginelist[5] = ELM_OPENGL_SDL; + enginelist[6] = NULL; + } + else + { + enginelist[0] = ENGINE_GET(); + enginelist[1] = ELM_SOFTWARE_X11; + enginelist[2] = ELM_WAYLAND_SHM; + enginelist[3] = ELM_SOFTWARE_FB; + enginelist[4] = ELM_OPENGL_COCOA; + enginelist[5] = ELM_SOFTWARE_SDL; + enginelist[6] = NULL; + } } for (i = 0; i < 30; i++) { -- 2.7.4