static void win_resize_cb(void *data, Evas *e , Evas_Object *obj , void *event_info) { appdata_s *ad = data; if(ad->evas_gl_surface) { cairo_surface_destroy(ad->surface); cairo_destroy(ad->cairo); cairo_device_destroy(ad->cairo_device); evas_gl_surface_destroy(ad->evas_gl, ad->evas_gl_surface); ad->evas_gl_surface = NULL; } evas_object_geometry_get(obj, NULL, NULL, &ad->width, &ad->height); evas_object_image_size_set(ad->img, ad->width, ad->height); evas_object_resize(ad->img, ad->width, ad->height); evas_object_show(ad->img); if(!ad->evas_gl_surface) { Evas_Native_Surface ns; ad->evas_gl_surface = evas_gl_surface_create(ad->evas_gl, ad->evas_gl_config, ad->width, ad->height); 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_dirty_set (ad->img, EINA_TRUE); 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); } }
/* local subsystem functions */ static void _win_unredirect(E_Comp_Win *cw) { E_CHECK(cw); E_CHECK(cw->visible); E_CHECK(!(cw->input_only)); E_CHECK(!(cw->invalid)); if (cw->obj) { evas_object_hide(cw->obj); evas_object_del(cw->obj); cw->obj = NULL; } if (cw->update_timeout) { ecore_timer_del(cw->update_timeout); cw->update_timeout = NULL; } if (cw->native) { evas_object_image_native_surface_set(cw->obj, NULL); cw->native = 0; } if (cw->pixmap) { ecore_x_pixmap_free(cw->pixmap); cw->pixmap = 0; cw->pw = 0; cw->ph = 0; } if (cw->xim) { evas_object_image_size_set(cw->obj, 1, 1); evas_object_image_data_set(cw->obj, NULL); ecore_x_image_free(cw->xim); cw->xim = NULL; } if (cw->redirected) { ecore_x_composite_unredirect_window (cw->win, ECORE_X_COMPOSITE_UPDATE_MANUAL); cw->redirected = 0; } if (cw->damage) { e_mod_comp_win_del_damage(cw, cw->damage); ecore_x_damage_subtract(cw->damage, 0, 0); ecore_x_damage_free(cw->damage); cw->damage = 0; } }
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); }