static bool app_create(void *data) { /* Hook to take necessary actions before main event loop starts Initialize UI resources and application's data If this function returns true, the main loop of application starts If this function returns false, the application is terminated */ appdata_s *ad = data; /* Force OpenGL engine */ elm_config_accel_preference_set("opengl"); create_base_gui(ad); return true; }
static Evas_Object* add_win(const char *name) { Evas_Object *win; elm_config_accel_preference_set("opengl"); win = elm_win_util_standard_add(name, "OpenGL example: Cube"); if (!win) return NULL; if (elm_win_wm_rotation_supported_get(win)) { int rots[4] = { 0, 90, 180, 270 }; elm_win_wm_rotation_available_rotations_set(win, rots, 4); } evas_object_show(win); return win; }
static void cairo_evasgl_drawing(appdata_s *ad) { /* Window */ elm_config_accel_preference_set("opengl"); ad->win = elm_win_util_standard_add(PACKAGE, PACKAGE); elm_win_autodel_set(ad->win, EINA_TRUE); if (elm_win_wm_rotation_supported_get(ad->win)) { int rots[4] = { 0, 90, 180, 270 }; elm_win_wm_rotation_available_rotations_set(ad->win, (const int *)(&rots), 4); } evas_object_smart_callback_add(ad->win, "delete,request", win_delete_request_cb, NULL); eext_object_event_callback_add(ad->win, EEXT_CALLBACK_BACK, win_back_cb, ad); evas_object_event_callback_add(ad->win, EVAS_CALLBACK_RESIZE, win_resize_cb, ad); evas_object_show(ad->win); /* Image */ ad->img = evas_object_image_filled_add(evas_object_evas_get(ad->win)); evas_object_show(ad->img); evas_object_geometry_get(ad->win, NULL, NULL, &ad->width, &ad->height); /* Init EVASGL */ Evas_Native_Surface ns; ad->evas_gl = evas_gl_new(evas_object_evas_get(ad->img)); ad->evas_gl_config = evas_gl_config_new(); ad->evas_gl_config->color_format = EVAS_GL_RGBA_8888; ad->evas_gl_surface = evas_gl_surface_create(ad->evas_gl, ad->evas_gl_config, ad->width, ad->height); ad->evas_gl_context = evas_gl_context_create(ad->evas_gl, NULL); evas_gl_native_surface_get(ad->evas_gl, ad->evas_gl_surface, &ns); evas_object_image_native_surface_set(ad->img, &ns); evas_object_image_pixels_get_callback_set(ad->img, cairo_drawing_rt, ad); /* cairo & cairo device create with evasgl */ setenv("CAIRO_GL_COMPOSITOR", "msaa", 1); ad->cairo_device = (cairo_device_t *)cairo_evas_gl_device_create (ad->evas_gl, ad->evas_gl_context); cairo_gl_device_set_thread_aware(ad->cairo_device, 0); ad->surface = (cairo_surface_t *)cairo_gl_surface_create_for_evas_gl(ad->cairo_device, ad->evas_gl_surface, ad->evas_gl_config, ad->width, ad->height); ad->cairo = cairo_create (ad->surface); }
static bool app_create(void *data) { /* Hook to take necessary actions before main event loop starts * Initialize UI resources and application's data * If this function returns true, the main loop of application starts * If this function returns false, the application is terminated. */ Evas_Object *gl; Application *ad = (Application *)data; if (!data) return false; /* Create and initialize GLView */ elm_config_accel_preference_set("opengl"); /* Create the window */ ad->_win = add_win("cocos2d-x"); if (!ad->_win) return false; int rots[2]; rots[0] = ad->_orientation; rots[1] = rots[0] + 180 % 360; elm_win_wm_rotation_available_rotations_set(ad->_win, rots, 2); ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, _key_down_cb, ad); ecore_event_handler_add(ECORE_EVENT_KEY_UP, _key_up_cb, ad); gl = elm_glview_add(ad->_win); elm_win_resize_object_add(ad->_win, gl); ELEMENTARY_GLVIEW_GLOBAL_USE(gl); evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL); evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); /* Create and initialize GLView */ ad->initGLContextAttrs(); auto attrs = GLView::getGLContextAttrs(); auto mode = get_glview_mode(attrs); elm_glview_mode_set(gl, mode); /* The resize policy tells GLView what to do with the surface when it * resizes. ELM_GLVIEW_RESIZE_POLICY_RECREATE will tell it to * destroy the current surface and recreate it to the new size. */ //elm_glview_resize_policy_set(gl, ELM_GLVIEW_RESIZE_POLICY_RECREATE); /* The render policy sets how GLView should render GL code. * ELM_GLVIEW_RENDER_POLICY_ON_DEMAND will have the GL callback * called only when the object is visible. * ELM_GLVIEW_RENDER_POLICY_ALWAYS would cause the callback to be * called even if the object were hidden. */ elm_glview_render_policy_set(gl, ELM_GLVIEW_RENDER_POLICY_ON_DEMAND); /* The initialize callback function gets registered here */ elm_glview_init_func_set(gl, init_gl); /* The delete callback function gets registered here */ elm_glview_del_func_set(gl, del_gl); /* The resize callback function gets registered here */ // Cocos2d-x doesn't support to change orientation from portrait to landscape. // So comment next line. // elm_glview_resize_func_set(gl, resize_gl); /* The render callback function gets registered here */ elm_glview_render_func_set(gl, draw_gl); /* Add the GLView to the box and show it */ evas_object_show(gl); elm_object_focus_set(gl, EINA_TRUE); /* This adds an animator so that the app will regularly * trigger updates of the GLView using elm_glview_changed_set(). * * NOTE: If you delete GL, this animator will keep running trying to access * GL so this animator needs to be deleted with ecore_animator_del(). */ ecore_animator_source_set(ECORE_ANIMATOR_SOURCE_TIMER); ad->_ani = ecore_animator_add(anim, gl); evas_object_data_set(gl, "ani", ad->_ani); evas_object_event_callback_add(gl, EVAS_CALLBACK_DEL, del_anim, gl); /* Add Mouse Event Callbacks */ evas_object_event_callback_add(gl, EVAS_CALLBACK_MOUSE_DOWN, touch_down_cb, ad); evas_object_event_callback_add(gl, EVAS_CALLBACK_MOUSE_MOVE, touch_move_cb, ad); evas_object_event_callback_add(gl, EVAS_CALLBACK_MOUSE_UP, touch_up_cb, ad); evas_object_event_callback_add(gl, EVAS_CALLBACK_MULTI_DOWN, touches_down_cb, ad); evas_object_event_callback_add(gl, EVAS_CALLBACK_MULTI_MOVE, touches_move_cb, ad); evas_object_event_callback_add(gl, EVAS_CALLBACK_MULTI_UP, touches_up_cb, ad); create_indicator(ad); return true; }
interface * intf_create(application *app) { interface *intf = calloc(1, sizeof(*intf)); intf->p_app = app; intf->current_view = -1; #ifdef __arm__ /* no opengl for emulator */ elm_config_accel_preference_set("opengl"); #endif /* Add and set the main Window */ intf->win = elm_win_util_standard_add(PACKAGE, PACKAGE); elm_win_autodel_set(intf->win, EINA_TRUE); /* Change colors */ // 2.3.1 EDJE_COLOR_CLASS_SET_VLC_ORANGE("B011"); // Base class EDJE_COLOR_CLASS_SET_VLC_ORANGE("B0511"); // Naviframe base EDJE_COLOR_CLASS_SET_VLC_ORANGE("B0514"); // Naviframe tab bar EDJE_COLOR_CLASS_SET_VLC_ORANGE("B0514S"); // Naviframe tab bar EDJE_COLOR_CLASS_SET_VLC_ORANGE("B0514P"); // Naviframe tab bar EDJE_COLOR_CLASS_SET_VLC_ORANGE("B0517"); // Naviframe second EDJE_COLOR_CLASS_SET_VLC_COLOR("F043P", VLC_GREY_400_TRANSPARENT); // Naviframe selection // 2.4 EDJE_COLOR_CLASS_SET_VLC_ORANGE("B001"); // Base class EDJE_COLOR_CLASS_SET_VLC_ORANGE("B071"); // Scrollbars EDJE_COLOR_CLASS_SET_VLC_COLOR("B018", VLC_ORANGE_500_TRANSPARENT_100); // End of list effect /* Progress Bar Colors */ EDJE_COLOR_CLASS_SET_VLC_COLOR("W062L1", VLC_GREY_400_TRANSPARENT); // slider background EDJE_COLOR_CLASS_SET_VLC_COLOR("W062L2", VLC_ORANGE_500_TRANSPARENT); // slider foreground EDJE_COLOR_CLASS_SET_VLC_COLOR("W0641P", VLC_ORANGE_500_TRANSPARENT); // slider thumb pressed EDJE_COLOR_CLASS_SET_VLC_COLOR("W0641D", VLC_ORANGE_500_TRANSPARENT); // slider thumb disabled EDJE_COLOR_CLASS_SET_VLC_ORANGE("W0641"); // slider thumb // Extend theme elm_theme_extension_add(NULL, THEME_EDJ); /* Handle rotations */ if (elm_win_wm_rotation_supported_get(intf->win)) { int rots[4] = { 0, 90, 180, 270 }; elm_win_wm_rotation_available_rotations_set(intf->win, (const int *)(&rots), 4); } /* Handle back buttons and delete callbacks */ evas_object_smart_callback_add(intf->win, "delete,request", win_delete_request_cb, NULL); eext_object_event_callback_add(intf->win, EEXT_CALLBACK_BACK, win_back_key_cb, intf); eext_object_event_callback_add(intf->win, EEXT_CALLBACK_MORE, right_panel_button_clicked_cb, intf); /* Add and set a conformant in the main Window */ Evas_Object *conform = elm_conformant_add(intf->win); elm_win_conformant_set(intf->win, EINA_TRUE); evas_object_size_hint_weight_set(conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); /* */ elm_win_indicator_mode_set(intf->win, ELM_WIN_INDICATOR_SHOW); elm_win_indicator_opacity_set(intf->win, ELM_WIN_INDICATOR_OPAQUE); elm_win_resize_object_add(intf->win, conform); evas_object_show(conform); /* Add and set a bg in the conformant */ Evas_Object *bg = elm_bg_add(conform); elm_bg_color_set(bg, 255, 136, 0); /* Add the bg in the conformant */ elm_object_part_content_set(conform, "elm.swallow.indicator_bg", bg); evas_object_show(bg); view_e view_type = preferences_get_index(PREF_CURRENT_VIEW, VIEW_VIDEO); /* Create the main view in the conformant */ create_main_layout(intf, conform, view_type); /* Create the default view in the content naviframe */ intf_show_view(intf, view_type); ps_register_on_emotion_restart_cb(application_get_playback_service(intf->p_app), intf_on_emotion_restart_cb, intf); media_library* p_ml = (media_library*)application_get_media_library(intf->p_app); media_library_register_progress_cb( p_ml, &intf_scan_progress_set_cb, intf ); /* */ evas_object_show(intf->win); return intf; }