int main(void) { Evas_Object *o; Ecore_Evas *ee; int r; evas_init(); ecore_init(); ecore_evas_init(); edje_init(); ee = ecore_evas_new(NULL, 0, 0, 320, 240, NULL); if (!ee) return -1; o = edje_object_add(ecore_evas_get(ee)); if (!edje_object_file_set(o, "test.edj", "main")) { fprintf(stderr, "could not load edje: %d\n", edje_object_load_error_get(o)); return -2; } evas_object_resize(o, 320, 240); evas_object_show(o); ecore_evas_alpha_set(ee, 1); ecore_evas_borderless_set(ee, 1); ecore_evas_show(ee); ecore_main_loop_begin(); return 0; }
int main(int argc, char **argv) { int rot = 0; if ((argc >= 3) && (!strcmp(argv[1], "-rot"))) rot = atoi(argv[2]); evas_init(); evas = evas_new(); evas_output_method_set(evas, evas_render_method_lookup("fb")); evas_output_size_set(evas, win_w, win_h); evas_output_viewport_set(evas, 0, 0, win_w, win_h); { Evas_Engine_Info_FB *einfo; einfo = (Evas_Engine_Info_FB *) evas_engine_info_get(evas); /* the following is specific to the engine */ einfo->info.virtual_terminal = 0; einfo->info.device_number = 0; einfo->info.refresh = 0; einfo->info.rotation = rot; evas_engine_info_set(evas, (Evas_Engine_Info *) einfo); } setup(); orig_start_time = start_time = get_time(); for (;;) { loop(); evas_render(evas); } evas_shutdown(); return 0; }
/* externally accessible functions */ int main(int argc, char **argv) { int i; for (i = 1; i < argc; i++) { if ((!strcmp(argv[i], "-h")) || (!strcmp(argv[i], "-help")) || (!strcmp(argv[i], "--help"))) { printf( "This is an internal tool for Enlightenment.\n" "do not use it.\n" ); exit(0); } else if (!strncmp(argv[i], "--nice=", 7)) { const char *val; int ret = 0; val = argv[i] + 7; if (*val) ret = nice(atoi(val)); } } ecore_init(); ecore_app_args_set(argc, (const char **)argv); eet_init(); evas_init(); ecore_evas_init(); edje_init(); ecore_file_init(); ecore_ipc_init(); e_user_dir_concat_static(_thumbdir, "fileman/thumbnails"); ecore_file_mkpath(_thumbdir); if (_e_ipc_init()) ecore_main_loop_begin(); if (_e_ipc_server) { ecore_ipc_server_del(_e_ipc_server); _e_ipc_server = NULL; } ecore_ipc_shutdown(); ecore_file_shutdown(); ecore_evas_shutdown(); edje_shutdown(); evas_shutdown(); eet_shutdown(); ecore_shutdown(); return 0; }
int ewk_init(void) { if (_ewkInitCount) return ++_ewkInitCount; if (!eina_init()) goto error_eina; _ewk_log_dom = eina_log_domain_register("ewebkit", EINA_COLOR_ORANGE); if (_ewk_log_dom < 0) { EINA_LOG_CRIT("could not register log domain 'ewebkit'"); goto error_log_domain; } if (!evas_init()) { CRITICAL("could not init evas."); goto error_evas; } if (!ecore_init()) { CRITICAL("could not init ecore."); goto error_ecore; } if (!ecore_evas_init()) { CRITICAL("could not init ecore_evas."); goto error_ecore_evas; } if (!edje_init()) { CRITICAL("could not init edje."); goto error_edje; } if (!_ewk_init_body()) { CRITICAL("could not init body"); goto error_edje; } return ++_ewkInitCount; error_edje: ecore_evas_shutdown(); error_ecore_evas: ecore_shutdown(); error_ecore: evas_shutdown(); error_evas: eina_log_domain_unregister(_ewk_log_dom); _ewk_log_dom = -1; error_log_domain: eina_shutdown(); error_eina: return 0; }
static Evas* initEfl() { evas_init(); ecore_init(); ecore_evas_init(); gEcoreEvas = adoptPtr(ecore_evas_buffer_new(1, 1)); Evas* evas = ecore_evas_get(gEcoreEvas.get()); if (!evas) abortWithErrorMessage("could not create Ecore_Evas buffer"); return evas; }
/** * Init gui. Create the main window */ EAPI Eina_Bool ede_gui_init(void) { char buf[PATH_MAX]; Eina_List *engines, *l; const char *e; char* str; D(" "); evas_init(); ecore_evas_init(); edje_init(); // list ecore_evas engines *buf = '\0'; engines = ecore_evas_engines_get(); EINA_LIST_FOREACH(engines, l, e) { strcat(buf, e); if (l->next) strcat(buf, ", "); }
int main(int argc, char **argv) { Suite *s; SRunner *sr; int i, failed_count; for (i = 1; i < argc; i++) if ((strcmp(argv[i], "-h") == 0) || (strcmp(argv[i], "--help") == 0)) { fprintf(stderr, "Usage:\n\t%s [test_case1 .. [test_caseN]]\n", argv[0]); _list_tests(); return 0; } else if ((strcmp(argv[i], "-l") == 0) || (strcmp(argv[i], "--list") == 0)) { _list_tests(); return 0; } putenv("EFL_RUN_IN_TREE=1"); evas_init(); s = evas_suite_build(argc - 1, (const char **)argv + 1); sr = srunner_create(s); srunner_set_xml(sr, TESTS_BUILD_DIR "/check-results.xml"); srunner_run_all(sr, CK_ENV); failed_count = srunner_ntests_failed(sr); srunner_free(sr); evas_shutdown(); return (failed_count == 0) ? 0 : 255; }
EvasTestApp::EvasTestApp(QWidget *parent, const char *name, int wFlags) : QMainWindow(parent, name, wFlags) { setCaption(tr("Evas Qtopia Demo")); evas_target_widget = new EvasTargetWidget(this, "EvasTargetWidget"); evas_init(); evas = evas_new(); evas_output_method_set(evas, evas_render_method_lookup("software_qtopia")); evas_output_size_set(evas, win_w, win_h); evas_output_viewport_set(evas, 0, 0, win_w, win_h); { Evas_Engine_Info_Software_Qtopia *einfo; einfo = (Evas_Engine_Info_Software_Qtopia *)evas_engine_info_get(evas); /* the following is specific to the engine */ einfo->info.target = evas_target_widget; evas_engine_info_set(evas, (Evas_Engine_Info *) einfo); } setup(); orig_start_time = start_time = get_time(); }
int main(int argc, char *argv[]) { Ecore_Evas *ee; Evas_Object *bridge, *img; const char *opt, *input, *output, *params; int r = 0, w = -1, h = -1, err; double scale = -1.0; if (argc < 4) { fprintf(stderr, "Usage:\n" "\t%s <percentage%%|WxH|w=W|h=H> <input> <output>" " [save-params]\n" "where save-params is evas supported parameters, like:\n" "\tquality=85\n" "\tcompress=9\n", argv[0]); return 1; } opt = argv[1]; input = argv[2]; output = argv[3]; params = argv[4]; if (strncasecmp(opt, "w=", 2) == 0) { char *end = NULL; w = strtol(opt + 2, &end, 10); if (!end || *end != '\0') { fprintf(stderr, "ERROR: invalid decimal integer '%s'\n", opt + 2); return 1; } else if (w < 1) { fprintf(stderr, "ERROR: invalid width %d, must be >= 1\n", w); return 1; } } else if (strncasecmp(opt, "h=", 2) == 0) { char *end = NULL; h = strtol(opt + 2, &end, 10); if (!end || *end != '\0') { fprintf(stderr, "ERROR: invalid decimal integer '%s'\n", opt + 2); return 1; } else if (h < 1) { fprintf(stderr, "ERROR: invalid height %d, must be >= 1\n", h); return 1; } } else if (strchr(opt, '%')) { char *end = NULL; scale = strtod(opt, &end); if (!end || *end != '%') { fprintf(stderr, "ERROR: invalid percentual '%s'\n", opt); return 1; } else if (scale <= 0.0) { fprintf(stderr, "ERROR: invalid percentual %g, must be > 0.0\n", scale); return 1; } scale /= 100.0; } else if (strchr(opt, 'x')) { if (sscanf(opt, "%dx%d", &w, &h) != 2) { fprintf(stderr, "ERROR: invalid size format '%s'\n", opt); return 1; } else if (w < 1) { fprintf(stderr, "ERROR: invalid width %d, must be >= 1\n", w); return 1; } else { fprintf(stderr, "ERROR: invalid height %d, must be >= 1\n", h); return 1; } } else { fprintf(stderr, "ERROR: first parameter must be in format:\n" "\tpercentage%% - example: 10%%\n" "\tWxH - example: 1024x768\n" "\tw=W - example: w=1024\n" "\th=H - example: h=768\n" "But '%s' was used!\n", opt); return 1; } ecore_evas_init(); evas_init(); ee = ecore_evas_buffer_new(1, 1); bridge = ecore_evas_object_image_new(ee); img = evas_object_image_add(ecore_evas_object_evas_get(bridge)); evas_object_image_smooth_scale_set(img, EINA_TRUE); if (w > 0 && h > 0) evas_object_image_load_size_set(img, w, h); evas_object_image_file_set(img, input, NULL); err = evas_object_image_load_error_get(img); if (err != EVAS_LOAD_ERROR_NONE) { const char *msg = evas_load_error_str(err); fprintf(stderr, "ERROR: could not load '%s': %s\n", input, msg); r = 1; goto end; } if (w < 1 || h < 1) { int iw, ih; evas_object_image_size_get(img, &iw, &ih); if (iw < 0 || ih < 0) { fprintf(stderr, "ERROR: invalid source image size %dx%d (%s)\n", iw, ih, input); goto end; } if (scale > 0) { w = ceil(iw * scale); h = ceil(ih * scale); } else if (w < 1) w = ceil(iw * (double)h / (double)ih); else if (h < 1) h = ceil(ih * (double)w / (double)iw); if (iw != w && ih != h) evas_object_image_load_size_set(img, w, h); } printf("output: %s, size: %dx%d, alpha: %s, params: %s\n", output, w, h, evas_object_image_alpha_get(img) ? "yes" : "no", params ? params : "<none>"); evas_object_image_fill_set(img, 0, 0, w, h); evas_object_resize(img, w, h); evas_object_show(img); evas_object_image_alpha_set(bridge, evas_object_image_alpha_get(img)); evas_object_image_size_set(bridge, w, h); ecore_evas_manual_render(ecore_evas_object_ecore_evas_get(bridge)); evas_object_image_save(bridge, output, NULL, params); end: evas_object_del(img); evas_object_del(bridge); ecore_evas_free(ee); evas_shutdown(); ecore_evas_shutdown(); return r; }
ApplicationMain::ApplicationMain(int argc, char **argv) { cInfo() << "Calaos Home, starting..."; if (system("killall -9 eskiss 2> /dev/null") == -1) cCritical() << "Error forking !"; //init random generator srand(time(NULL)); //Init SSL and CURL SSL_load_error_strings(); SSL_library_init(); curl_global_init(CURL_GLOBAL_ALL); char *themefile = argvOptionParam(argv, argv + argc, "--theme"); if (themefile) { ApplicationMain::theme = themefile; cInfo() << "Using specified theme file: " << ApplicationMain::getTheme(); } else { ApplicationMain::theme = Prefix::Instance().dataDirectoryGet() + "/default.edj"; if (ecore_file_exists(ApplicationMain::theme.c_str())) cInfo() << "Using theme file " << theme; else cError() << theme << " Not found!"; } //Init efl core if (!eina_init()) throw (runtime_error("Unable to init Eina")); if (!ecore_init()) throw (runtime_error("Unable to init Ecore")); if (!ecore_con_init()) throw (runtime_error("Unable to init Ecore-Con")); if (!ecore_con_url_init()) throw (runtime_error("Unable to init Ecore-Con-Url")); if (!evas_init()) throw (runtime_error("Unable to init Evas")); if (!ecore_evas_init()) throw (runtime_error("Unable to init Ecore-Evas")); if (!edje_init()) throw (runtime_error("Unable to init Edje")); edje_frametime_set(1.0 / 60.0); edje_scale_set(1.0); if (!elm_init(argc, argv)) throw (runtime_error("Unable to init Elementary")); //Load Calaos specific ELM extensions elm_theme_extension_add(NULL, ApplicationMain::getTheme()); //Create the main window window = elm_win_add(NULL, "calaos-home", ELM_WIN_BASIC); elm_win_title_set(window, "Calaos Home"); elm_win_borderless_set(window, true); bool bFullscreen = argvOptionCheck(argv, argv + argc, "--fullscreen"); elm_win_fullscreen_set(window, bFullscreen); //Automatically quit main loop when the window is closed elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED); elm_win_autodel_set(window, true); if (argvOptionCheck(argv, argv + argc, "--set-elm-config")) { //force setting the correct elementary options for touchscreen elm_config_finger_size_set(10); elm_config_scroll_bounce_enabled_set(true); elm_config_scroll_thumbscroll_enabled_set(true); elm_config_scroll_thumbscroll_threshold_set(24); elm_config_scroll_thumbscroll_momentum_threshold_set(100.0); elm_config_scroll_bounce_friction_set(0.5); elm_config_scroll_page_scroll_friction_set(0.5); elm_config_scroll_bring_in_scroll_friction_set(0.5); elm_config_scroll_zoom_friction_set(0.5); elm_config_scroll_thumbscroll_friction_set(1.0); elm_config_scroll_thumbscroll_border_friction_set(0.5); elm_config_scroll_thumbscroll_sensitivity_friction_set(0.25); } evas_object_event_callback_add(window, EVAS_CALLBACK_RESIZE, _window_resize_cb, this); evas = evas_object_evas_get(window); Evas_Object *bg = elm_bg_add(window); evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); elm_win_resize_object_add(window, bg); evas_object_show(bg); evas_object_size_hint_min_set(bg, 200, 200); elm_bg_color_set(bg, 0, 0, 0); layout = elm_layout_add(window); if (!elm_layout_file_set(layout, ApplicationMain::getTheme(), EDJE_GROUP_MAIN_LAYOUT)) { string e = "Unable to find group \""; e += EDJE_GROUP_MAIN_LAYOUT; e += "\" in theme \""; e += ApplicationMain::getTheme(); e += "\""; throw (runtime_error(e)); } //create the screen suspend object and put it on the canvas ScreenSuspendView *screen_suspend = new ScreenSuspendView(evas, window); screen_suspend->Show(); screen_suspend->setAutoDelete(true); evas_object_size_hint_weight_set(layout, 1.0, 1.0); evas_object_show(layout); evas_object_resize(window, 1024, 768); evas_object_show(window); ecore_evas_focus_set(ecore_evas_ecore_evas_get(evas_object_evas_get(window)), true); Resize(); try { controller = new ApplicationController(evas, layout); } catch(exception const& e) { cCritical() << "Can't create ApplicationController"; throw; } }
int ewk_init(void) { if (_ewk_init_count) return ++_ewk_init_count; if (!eina_init()) goto error_eina; _ewk_log_dom = eina_log_domain_register("ewebkit", EINA_COLOR_ORANGE); if (_ewk_log_dom < 0) { EINA_LOG_CRIT("could not register log domain 'ewebkit'"); goto error_log_domain; } if (!evas_init()) { CRITICAL("could not init evas."); goto error_evas; } if (!ecore_init()) { CRITICAL("could not init ecore."); goto error_ecore; } if (!ecore_evas_init()) { CRITICAL("could not init ecore_evas."); goto error_ecore_evas; } if (!edje_init()) { CRITICAL("could not init edje."); goto error_edje; } #ifdef ENABLE_GLIB_SUPPORT g_type_init(); if (!g_thread_supported()) g_thread_init(0); #ifdef ENABLE_GTK_PLUGINS_SUPPORT gdk_threads_init(); if (!gtk_init_check(0, 0)) WRN("Could not initialize GTK support."); #endif if (!ecore_main_loop_glib_integrate()) WRN("Ecore was not compiled with GLib support, some plugins will not " "work (ie: Adobe Flash)"); #endif JSC::initializeThreading(); WTF::initializeMainThread(); WebCore::InitializeLoggingChannelsIfNecessary(); // Page cache capacity (in pages). Comment from Mac port: // (Research indicates that value / page drops substantially after 3 pages.) // FIXME: Expose this with an API and/or calculate based on available resources WebCore::pageCache()->setCapacity(3); WebCore::PageGroup::setShouldTrackVisitedLinks(true); // TODO: this should move to WebCore, already reported to webkit-gtk folks: if (1) { SoupSession* session = WebCore::ResourceHandle::defaultSession(); soup_session_add_feature_by_type(session, SOUP_TYPE_CONTENT_SNIFFER); } return ++_ewk_init_count; error_edje: ecore_evas_shutdown(); error_ecore_evas: ecore_shutdown(); error_ecore: evas_shutdown(); error_evas: eina_log_domain_unregister(_ewk_log_dom); _ewk_log_dom = -1; error_log_domain: eina_shutdown(); error_eina: return 0; }
int main(int argc, char **argv) { WNDCLASS wc; RECT rect; HINSTANCE hinstance; MSG msg; HWND window; LPDIRECTDRAW object; LPDIRECTDRAWSURFACE surface_primary; LPDIRECTDRAWSURFACE surface_back; int depth; int running; int pause_me = 0; hinstance = GetModuleHandle(0); wc.style = 0; wc.lpfnWndProc = MainWndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hinstance; wc.hIcon = LoadIcon (NULL, IDI_APPLICATION); wc.hCursor = LoadCursor (NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)(1 + COLOR_BTNFACE); wc.lpszMenuName = NULL; wc.lpszClassName = "Evas_Software_DDraw_Test"; if(!RegisterClass(&wc)) return EXIT_FAILURE; rect.left = 0; rect.top = 0; rect.right = win_w; rect.bottom = win_h; AdjustWindowRect (&rect, WS_OVERLAPPEDWINDOW | WS_SIZEBOX, FALSE); window = CreateWindowEx(0, "Evas_Software_DDraw_Test", "Evas_Software_DDraw_Test", WS_OVERLAPPEDWINDOW | WS_SIZEBOX, CW_USEDEFAULT, CW_USEDEFAULT, rect.right - rect.left, rect.bottom - rect.top, NULL, NULL, hinstance, NULL); if (!window) return EXIT_FAILURE; if (!_directdraw_init(window, &object, &surface_primary, &surface_back, &depth, win_w, win_h)) return EXIT_FAILURE; ShowWindow(window, SW_SHOWDEFAULT); UpdateWindow(window); /* test evas_free.... :) */ evas_init(); evas = evas_new(); evas_output_method_set(evas, evas_render_method_lookup("software_ddraw")); evas_output_size_set(evas, win_w, win_h); evas_output_viewport_set(evas, 0, 0, win_w, win_h); { Evas_Engine_Info_Software_DDraw *einfo; einfo = (Evas_Engine_Info_Software_DDraw *)evas_engine_info_get(evas); /* the following is specific to the engine */ einfo->info.window = window; einfo->info.object = object; einfo->info.surface_primary = surface_primary; einfo->info.surface_back = surface_back; einfo->info.depth = depth; einfo->info.rotation = 0; evas_engine_info_set(evas, (Evas_Engine_Info *) einfo); } setup(); printf("################ evas free\n"); setdown(); evas_free(evas); printf("evas freed. DONE\n"); evas = evas_new(); evas_output_method_set(evas, evas_render_method_lookup("software_ddraw")); evas_output_size_set(evas, win_w, win_h); evas_output_viewport_set(evas, 0, 0, win_w, win_h); { Evas_Engine_Info_Software_DDraw *einfo; einfo = (Evas_Engine_Info_Software_DDraw *) evas_engine_info_get(evas); /* the following is specific to the engine */ einfo->info.window = window; einfo->info.object = object; einfo->info.surface_primary = surface_primary; einfo->info.surface_back = surface_back; einfo->info.depth = depth; einfo->info.rotation = 0; evas_engine_info_set(evas, (Evas_Engine_Info *) einfo); } setup(); printf("################ evas free\n"); setdown(); evas_free(evas); printf("evas freed. DONE\n"); evas = evas_new(); evas_output_method_set(evas, evas_render_method_lookup("software_ddraw")); evas_output_size_set(evas, win_w, win_h); evas_output_viewport_set(evas, 0, 0, win_w, win_h); { Evas_Engine_Info_Software_DDraw *einfo; einfo = (Evas_Engine_Info_Software_DDraw *) evas_engine_info_get(evas); /* the following is specific to the engine */ einfo->info.window = window; einfo->info.object = object; einfo->info.surface_primary = surface_primary; einfo->info.surface_back = surface_back; einfo->info.depth = depth; einfo->info.rotation = 0; evas_engine_info_set(evas, (Evas_Engine_Info *) einfo); } setup(); printf("################ evas free\n"); setdown(); evas_free(evas); printf("evas freed. DONE\n"); evas = evas_new(); evas_output_method_set(evas, evas_render_method_lookup("software_ddraw")); evas_output_size_set(evas, win_w, win_h); evas_output_viewport_set(evas, 0, 0, win_w, win_h); { Evas_Engine_Info_Software_DDraw *einfo; einfo = (Evas_Engine_Info_Software_DDraw *) evas_engine_info_get(evas); /* the following is specific to the engine */ einfo->info.window = window; einfo->info.object = object; einfo->info.surface_primary = surface_primary; einfo->info.surface_back = surface_back; einfo->info.depth = depth; einfo->info.rotation = 0; evas_engine_info_set(evas, (Evas_Engine_Info *) einfo); } setup(); printf("################ evas free\n"); setdown(); evas_free(evas); printf("evas freed. DONE\n"); evas = evas_new(); evas_output_method_set(evas, evas_render_method_lookup("software_ddraw")); evas_output_size_set(evas, win_w, win_h); evas_output_viewport_set(evas, 0, 0, win_w, win_h); { Evas_Engine_Info_Software_DDraw *einfo; einfo = (Evas_Engine_Info_Software_DDraw *) evas_engine_info_get(evas); /* the following is specific to the engine */ einfo->info.window = window; einfo->info.object = object; einfo->info.surface_primary = surface_primary; einfo->info.surface_back = surface_back; einfo->info.depth = depth; einfo->info.rotation = 0; evas_engine_info_set(evas, (Evas_Engine_Info *) einfo); } setup(); orig_start_time = start_time = get_time(); running = 1; while (running) { while (PeekMessage (&msg, window, 0, 0, PM_NOREMOVE)) { int res; res = GetMessage (&msg, NULL, 0, 0); TranslateMessage (&msg); DispatchMessage (&msg); if (res == 0) running = 0; } if (!(pause_me == 1)) { loop(); evas_render(evas); } } exit: setdown(); evas_free(evas); if (surface_primary) IDirectDrawSurface7_Release (surface_primary); if (object) IDirectDraw7_Release (object); evas_shutdown(); return EXIT_SUCCESS; }
int main(void) { Evas *canvas; Evas_Object *bg, *r1, *r2, *r3; evas_init(); // create your canvas // NOTE: consider using ecore_evas_buffer_new() instead! canvas = create_canvas(WIDTH, HEIGHT); if (!canvas) return -1; bg = evas_object_rectangle_add(canvas); evas_object_color_set(bg, 255, 255, 255, 255); // white bg evas_object_move(bg, 0, 0); // at origin evas_object_resize(bg, WIDTH, HEIGHT); // covers full canvas evas_object_show(bg); puts("initial scene, with just background:"); draw_scene(canvas); r1 = evas_object_rectangle_add(canvas); evas_object_color_set(r1, 255, 0, 0, 255); // 100% opaque red evas_object_move(r1, 10, 10); evas_object_resize(r1, 100, 100); evas_object_show(r1); // pay attention to transparency! Evas color values are pre-multiplied by // alpha, so 50% opaque green is: // non-premul: r=0, g=255, b=0 a=128 (50% alpha) // premul: // r_premul = r * a / 255 = 0 * 128 / 255 = 0 // g_premul = g * a / 255 = 255 * 128 / 255 = 128 // b_premul = b * a / 255 = 0 * 128 / 255 = 0 // // this 50% green is over a red background, so it will show in the // final output as yellow (green + red = yellow) r2 = evas_object_rectangle_add(canvas); evas_object_color_set(r2, 0, 128, 0, 128); // 50% opaque green evas_object_move(r2, 10, 10); evas_object_resize(r2, 50, 50); evas_object_show(r2); r3 = evas_object_rectangle_add(canvas); evas_object_color_set(r3, 0, 128, 0, 255); // 100% opaque dark green evas_object_move(r3, 60, 60); evas_object_resize(r3, 50, 50); evas_object_show(r3); puts("final scene (note updates):"); draw_scene(canvas); save_scene(canvas, "/tmp/evas-buffer-simple-render.ppm"); // NOTE: use ecore_evas_buffer_new() and here ecore_evas_free() destroy_canvas(canvas); evas_shutdown(); return 0; }
int main(int argc, char **argv) { int i; evas_init(); if (!evas_cserve_init()) { printf("ERROR: Cannot connect to cserve. abort\n"); exit(-1); } for (i = 1; i < argc; i++) { if ((!strcmp(argv[i], "-h")) || (!strcmp(argv[i], "-help")) || (!strcmp(argv[i], "--help"))) { printf("Options:\n" "\t-h This help\n" "\tgetconfig Get configuration values\n" "\tsetconfig CSIZE CTIME CTIMECHECK Set the config values\n" "\tgetstats Get current cache statistics\n" "\tgetinfo Get current cache content info\n" ); exit(0); } else if ((!strcmp(argv[i], "getconfig"))) { Op_Getconfig_Reply config; if (!evas_cserve_raw_config_get(&config)) { printf("ERROR: cannot fetch config.\n"); exit(-1); } printf("-REPLY-\n"); printf("csize: %i\n", config.cache_max_usage); printf("ctime: %i\n", config.cache_item_timeout); printf("ctimecheck: %i\n", config.cache_item_timeout_check); printf("-OK-\n"); } else if ((!strcmp(argv[i], "setconfig")) && (i < (argc - 3))) { Op_Setconfig config; i++; config.cache_max_usage = atoi(argv[i]); i++; config.cache_item_timeout = atoi(argv[i]); i++; config.cache_item_timeout_check = atoi(argv[i]); if (!evas_cserve_raw_config_set(&config)) { printf("ERROR: cannot set config.\n"); exit(-1); } } else if ((!strcmp(argv[i], "getstats"))) { Op_Getstats_Reply stats; if (!evas_cserve_raw_stats_get(&stats)) { printf("ERROR: cannot fetch stats.\n"); exit(-1); } printf("-REPLY-\n"); printf("saved_memory: %i Kb\n", stats.saved_memory / 1024); printf("wasted_memory: %i Kb\n", stats.wasted_memory / 1024); printf("saved_memory_peak: %i Kb\n", stats.saved_memory_peak / 1024); printf("wasted_memory_peak: %i Kb\n", stats.wasted_memory_peak / 1024); printf("saved_time_image_header_load: %1.3f sec\n", stats.saved_time_image_header_load); printf("saved_time_image_data_load: %1.3f sec\n", stats.saved_time_image_data_load); printf("-OK-\n"); } else if ((!strcmp(argv[i], "getinfo"))) { Op_Getinfo_Reply *info; unsigned char *p; int i, j; info = evas_cserve_raw_info_get(); if (!info) { printf("ERROR: cannot fetch info.\n"); exit(-1); } j = info->active.count + info->cached.count; printf("-REPLY-\n"); printf("active_count: %i\n", info->active.count); printf("active_memory: %i Kb\n", info->active.mem_total); printf("cache_count: %i\n", info->cached.count); printf("cache_memory: %i Kb\n", info->cached.mem_total); p = (unsigned char *)info; p += sizeof(Op_Getinfo_Reply); for (i = 0; i < j; i++) { Op_Getinfo_Item it; char *file, *key, buf[512]; struct tm *ltm; memcpy(&it, p, sizeof(Op_Getinfo_Item)); file = (char*) (p + sizeof(Op_Getinfo_Item)); key = file + strlen(file) + 1; printf("-IMAGE- [#%i]\n", i); printf(" file : %s\n", file); printf(" key : %s\n", key); printf(" size : %i x %i\n", it.w, it.h); printf(" active : %i\n", (int)it.active); printf(" memory used: %i bytes (%i Kb)\n", it.memory_footprint, (it.memory_footprint + 1023) / 1024); printf(" has alpha : %i\n", (int)it.alpha); printf(" data loaded: %i\n", (int)it.data_loaded); printf(" dead : %i\n", (int)it.dead); printf(" useless : %i\n", (int)it.useless); printf(" image refs : %i\n", it.refcount); printf(" data refs : %i\n", it.data_refcount); printf(" header load: %1.5f sec\n", it.head_load_time); printf(" data load : %1.5f sec\n", it.data_load_time); if (it.cached_time == 0) printf(" cached at : N/A\n"); else { ltm = localtime(&(it.cached_time)); if (ltm) { strftime(buf, sizeof(buf), "%Y.%m.%d %T", ltm); printf(" cached at : %s\n", buf); } } ltm = localtime(&(it.file_mod_time)); if (ltm) { strftime(buf, sizeof(buf), "%Y.%m.%d %T", ltm); printf(" file mod at: %s\n", buf); } ltm = localtime(&(it.file_checked_time)); if (ltm) { strftime(buf, sizeof(buf), "%Y.%m.%d %T", ltm); printf(" file check : %s\n", buf); } p += sizeof(Op_Getinfo_Item) + it.file_key_size; } free(info); printf("-OK-\n"); } } evas_cserve_shutdown(); evas_shutdown(); return 0; }
int main( int argc, char *argv[] ) { IDirectFB *dfb; IDirectFBDisplayLayer *layer; IDirectFBSurface *bgsurface; IDirectFBImageProvider *provider; IDirectFBWindow *window1; IDirectFBWindow *window2; IDirectFBSurface *window_surface1; IDirectFBSurface *window_surface2; IDirectFBEventBuffer *buffer; DFBDisplayLayerConfig layer_config; #if ((DIRECTFB_MAJOR_VERSION == 0) && (DIRECTFB_MINOR_VERSION == 9) && (DIRECTFB_MICRO_VERSION < 23)) DFBCardCapabilities caps; #else DFBGraphicsDeviceDescription caps; #endif IDirectFBWindow* upper; DFBWindowID id1; IDirectFBFont *font; int fontheight; int err; int quit = 0; DFBCHECK(DirectFBInit( &argc, &argv )); DFBCHECK(DirectFBCreate( &dfb )); #if ((DIRECTFB_MAJOR_VERSION == 0) && (DIRECTFB_MINOR_VERSION == 9) && (DIRECTFB_MICRO_VERSION < 23)) dfb->GetCardCapabilities( dfb, &caps ); #else dfb->GetDeviceDescription( dfb, &caps ); #endif dfb->GetDisplayLayer( dfb, DLID_PRIMARY, &layer ); if (!((caps.blitting_flags & DSBLIT_BLEND_ALPHACHANNEL) && (caps.blitting_flags & DSBLIT_BLEND_COLORALPHA ))) { layer_config.flags = DLCONF_BUFFERMODE; layer_config.buffermode = DLBM_BACKSYSTEM; layer->SetConfiguration( layer, &layer_config ); } layer->GetConfiguration( layer, &layer_config ); layer->EnableCursor ( layer, 1 ); { DFBFontDescription desc; desc.flags = DFDESC_HEIGHT; desc.height = layer_config.width/50; DFBCHECK(dfb->CreateFont( dfb, PACKAGE_DATA_DIR"/grunge.ttf", &desc, &font )); font->GetHeight( font, &fontheight ); } { DFBSurfaceDescription desc; DFBCHECK(dfb->CreateImageProvider( dfb, PACKAGE_DATA_DIR"/bg.png", &provider )); desc.flags = DSDESC_WIDTH | DSDESC_HEIGHT; desc.width = layer_config.width; desc.height = layer_config.height; DFBCHECK(dfb->CreateSurface( dfb, &desc, &bgsurface ) ); provider->RenderTo( provider, bgsurface, NULL ); provider->Release( provider ); DFBCHECK(bgsurface->SetFont( bgsurface, font )); bgsurface->SetColor( bgsurface, 0xCF, 0xCF, 0xFF, 0xFF ); bgsurface->DrawString( bgsurface, "Move the mouse over a window to activate it.", -1, 10, 0, DSTF_LEFT | DSTF_TOP ); bgsurface->SetColor( bgsurface, 0xFF, 0xCF, 0xFF, 0xFF ); bgsurface->DrawString( bgsurface, "You can drag them around, too, if you want.", -1, 10 , 40, DSTF_LEFT | DSTF_TOP ); bgsurface->SetColor( bgsurface, 0xCF, 0xCF, 0xFF, 0xFF ); bgsurface->DrawString( bgsurface, "The one with funky stuff happening and things flying around is an evas.", -1, 10, 80, DSTF_LEFT | DSTF_TOP ); layer->SetBackgroundImage( layer, bgsurface ); layer->SetBackgroundMode( layer, DLBM_IMAGE ); } { DFBWindowDescription desc; desc.flags = ( DWDESC_POSX | DWDESC_POSY | DWDESC_WIDTH | DWDESC_HEIGHT | DWDESC_CAPS ); desc.posx = 20; desc.posy = 120; desc.width = 200; desc.height = 200; desc.caps = DWCAPS_ALPHACHANNEL; DFBCHECK( layer->CreateWindow( layer, &desc, &window2 ) ); window2->GetSurface( window2, &window_surface2 ); window2->SetOpacity( window2, 0xFF ); window2->CreateEventBuffer( window2, &buffer ); { window_surface2->SetColor( window_surface2, 0x00, 0x30, 0x10, 0xc0 ); window_surface2->DrawRectangle( window_surface2, 0, 0, desc.width, desc.height ); window_surface2->SetColor( window_surface2, 0x80, 0xa0, 0x00, 0x90 ); window_surface2->FillRectangle( window_surface2, 1, 1, desc.width-2, desc.height-2 ); DFBCHECK(window_surface2->SetFont(window_surface2, font )); window_surface2->SetColor( window_surface2, 0xCF, 0xFF, 0xCF, 0xFF ); window_surface2->DrawString( window_surface2, "Pants!", -1,10, fontheight + 5, DSTF_LEFT | DSTF_TOP ); } window_surface2->Flip( window_surface2, NULL, 0 ); } { DFBWindowDescription desc; desc.flags = ( DWDESC_POSX | DWDESC_POSY | DWDESC_WIDTH | DWDESC_HEIGHT | DWDESC_CAPS ); desc.posx = 200; desc.posy = 200; desc.width = 240; desc.height = 320; desc.caps = DWCAPS_ALPHACHANNEL; DFBCHECK(layer->CreateWindow( layer, &desc, &window1 ) ); window1->GetSurface( window1, &window_surface1 ); window_surface1->SetColor( window_surface1, 0xFF, 0x20, 0x20, 0x90 ); window_surface1->DrawRectangle( window_surface1, 0, 0, desc.width, desc.height ); window_surface1->Flip( window_surface1, NULL, 0 ); window1->SetOpacity( window1, 0xFF ); window1->GetID( window1, &id1 ); window1->AttachEventBuffer( window1, buffer ); } window1->RequestFocus( window1 ); window1->RaiseToTop( window1 ); upper = window1; { evas_init(); evas = evas_new(); evas_output_method_set(evas, evas_render_method_lookup("directfb")); evas_output_size_set(evas, 240, 320); evas_output_viewport_set(evas, 0, 0, 240, 320); { Evas_Engine_Info_DirectFB *einfo; einfo = (Evas_Engine_Info_DirectFB *) evas_engine_info_get(evas); einfo->info.dfb = dfb; einfo->info.surface = window_surface1; einfo->info.flags = DSDRAW_BLEND; evas_engine_info_set(evas, (Evas_Engine_Info *) einfo); } setup(); evas_render(evas); start_time = get_time(); } while (!quit) { static IDirectFBWindow* active = NULL; static int grabbed = 0; static int startx = 0; static int starty = 0; static int endx = 0; static int endy = 0; DFBWindowEvent evt; buffer->WaitForEventWithTimeout( buffer, 0, 10 ); while (buffer->GetEvent( buffer, DFB_EVENT(&evt) ) == DFB_OK) { IDirectFBWindow* window; if (evt.window_id == id1) window = window1; else window = window2; if (active) { switch (evt.type) { case DWET_BUTTONDOWN: if (!grabbed && evt.button == DIBI_LEFT) { grabbed = 1; layer->GetCursorPosition( layer, &startx, &starty ); window->GrabPointer( window ); } break; case DWET_BUTTONUP: switch (evt.button) { case DIBI_LEFT: if (grabbed) { window->UngrabPointer( window ); grabbed = 0; } break; case DIBI_MIDDLE: upper->LowerToBottom( upper ); upper = (upper == window1) ? window2 : window1; break; case DIBI_RIGHT: quit = DIKS_DOWN; break; default: break; } break; case DWET_KEYDOWN: if (grabbed) break; switch (evt.key_id) { case DIKI_RIGHT: active->Move (active, 1, 0); break; case DIKI_LEFT: active->Move (active, -1, 0); break; case DIKI_UP: active->Move (active, 0, -1); break; case DIKI_DOWN: active->Move (active, 0, 1); break; default: break; } break; case DWET_LOSTFOCUS: if (!grabbed) active = NULL; break; default: break; } } else if (evt.type == DWET_GOTFOCUS) active = window; switch (evt.type) { case DWET_MOTION: endx = evt.cx; endy = evt.cy; break; case DWET_KEYDOWN: switch (evt.key_symbol) { case DIKS_ESCAPE: case DIKS_SMALL_Q: case DIKS_CAPITAL_Q: case DIKS_BACK: case DIKS_STOP: quit = 1; break; default: break; } break; default: break; } } if (active) { if (grabbed) { active->Move( active, endx - startx, endy - starty); startx = endx; starty = endy; } active->SetOpacity( active, (sin( myclock()/300.0 ) * 85) + 170 ); } loop(); { Eina_List *updates; updates = evas_render_updates(evas); /* efficient update.. only flip the rectangle regions that changed! */ if (updates) { DFBRegion region; Eina_List *l; for (l = updates; l; l = l->next) { Evas_Rectangle *rect; rect = l->data; region.x1 = rect->x; region.y1 = rect->y; region.x2 = rect->x + rect->w - 1; region.y2 = rect->y + rect->h - 1; window_surface1->Flip(window_surface1, ®ion, DSFLIP_BLIT); } evas_render_updates_free(updates); } } } buffer->Release( buffer ); window_surface2->Release( window_surface2 ); window_surface1->Release( window_surface1 ); window2->Release( window2 ); window1->Release( window1 ); layer->Release( layer ); bgsurface->Release( bgsurface ); dfb->Release( dfb ); evas_shutdown(); return 0; }
/** * @brief Does the same thing as etk_init() except you can specify custom arguments that could be then retrieved with * etk_argument_* functions. For example, etk_init_full(argc, argv, "--option1 value --toggle1") * @param argc the location of the "argc" parameter passed to main(). It is used to parse the arguments specific to Etk. * It can be set to NULL. * @param argv the location of the "argv" parameter passed to main(). It is used to parse the arguments specific to Etk. * It can be set to NULL. * @param custom_opts a string corresponding to the custom arguments to add to argv. It can be set to NULL * @return Returns the number of times Etk has been initialized, or 0 on failure * @note It initializes Evas, Ecore and Edje so you don't need to initialize them after an etk_init() * @see etk_init() * @see etk_shutdown() */ int etk_init_full(int argc, char **argv, const char *custom_opts) { char *engine_name = NULL; if (_etk_main_init_count > 0) { _etk_main_init_count++; return _etk_main_init_count; } else { /* Parse the arguments */ etk_argument_init(argc, argv, custom_opts); etk_argument_value_get("etk-engine", 0, ETK_TRUE, &engine_name); /* Initialize the EFL */ if (!evas_init()) { ETK_WARNING("Evas initialization failed!"); return 0; } if (!ecore_init()) { ETK_WARNING("Ecore initialization failed!"); return 0; } if (!ecore_imf_init()) { ETK_WARNING("Ecore_IMF initialization failed!"); } if (!edje_init()) { ETK_WARNING("Edje initialization failed!"); return 0; } /* TODO: maybe we should do this in etk_main(). * Problem: if we do this, a program that uses directly ecore_main_loop_begin() and not etk_main() won't work */ _etk_main_idle_enterer = ecore_idle_enterer_add(_etk_main_idle_enterer_cb, NULL); /* Initialize the subsystems of Etk */ if (!etk_config_init()) { ETK_WARNING("Etk_Config initialization failed!"); return 0; } etk_config_load(); etk_theme_init(); if (!etk_engine_init()) { ETK_WARNING("Etk_Engine initialization failed!"); return 0; } if (!etk_engine_load(engine_name ? engine_name : "ecore_evas_software_x11")) { ETK_WARNING("Etk can not load the requested engine!"); return 0; } etk_event_init(); etk_tooltips_init(); /* Initialize Gettext */ setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); free(engine_name); _etk_main_init_count++; return _etk_main_init_count; } }
int ewk_init(void) { if (_ewkInitCount) return ++_ewkInitCount; if (!eina_init()) goto error_eina; _ewk_log_dom = eina_log_domain_register("ewebkit2", EINA_COLOR_ORANGE); if (_ewk_log_dom < 0) { EINA_LOG_CRIT("could not register log domain 'ewebkit2'"); goto error_log_domain; } if (!evas_init()) { CRITICAL("could not init evas."); goto error_evas; } if (!ecore_init()) { CRITICAL("could not init ecore."); goto error_ecore; } if (!ecore_evas_init()) { CRITICAL("could not init ecore_evas."); goto error_ecore_evas; } if (!ecore_imf_init()) { CRITICAL("could not init ecore_imf."); goto error_ecore_imf; } if (!efreet_init()) { CRITICAL("could not init efreet."); goto error_efreet; } #ifdef HAVE_ECORE_X if (!ecore_x_init(0)) { CRITICAL("could not init ecore_x."); goto error_ecore_x; } #endif if (!edje_init()) { CRITICAL("Could not init edje."); goto error_edje; } if (!ecore_main_loop_glib_integrate()) { WARN("Ecore was not compiled with GLib support, some plugins will not " "work (ie: Adobe Flash)"); } return ++_ewkInitCount; error_edje: #ifdef HAVE_ECORE_X ecore_x_shutdown(); error_ecore_x: #else efreet_shutdown(); #endif error_efreet: ecore_imf_shutdown(); error_ecore_imf: ecore_evas_shutdown(); error_ecore_evas: ecore_shutdown(); error_ecore: evas_shutdown(); error_evas: eina_log_domain_unregister(_ewk_log_dom); _ewk_log_dom = -1; error_log_domain: eina_shutdown(); error_eina: return 0; }
int EwkMain::initialize() { if (m_initCount) return ++m_initCount; if (!eina_init()) { EINA_LOG_CRIT("could not init eina."); return 0; } m_logDomainId = eina_log_domain_register("ewebkit2", EINA_COLOR_ORANGE); if (m_logDomainId < 0) { EINA_LOG_CRIT("could not register log domain 'ewebkit2'"); shutdownInitializedEFLModules(EFLModuleInitFailure::EinaLog); return 0; } if (!evas_init()) { CRITICAL("could not init evas."); shutdownInitializedEFLModules(EFLModuleInitFailure::Evas); return 0; } if (!ecore_init()) { CRITICAL("could not init ecore."); shutdownInitializedEFLModules(EFLModuleInitFailure::Ecore); return 0; } if (!ecore_evas_init()) { CRITICAL("could not init ecore_evas."); shutdownInitializedEFLModules(EFLModuleInitFailure::EcoreEvas); return 0; } if (!ecore_imf_init()) { CRITICAL("could not init ecore_imf."); shutdownInitializedEFLModules(EFLModuleInitFailure::EcoreImf); return 0; } if (!efreet_init()) { CRITICAL("could not init efreet."); shutdownInitializedEFLModules(EFLModuleInitFailure::Efreet); return 0; } #ifdef HAVE_ECORE_X if (!ecore_x_init(0)) { CRITICAL("could not init ecore_x."); shutdownInitializedEFLModules(EFLModuleInitFailure::EcoreX); return 0; } #endif if (!edje_init()) { CRITICAL("Could not init edje."); shutdownInitializedEFLModules(EFLModuleInitFailure::Edje); return 0; } if (!ecore_main_loop_glib_integrate()) { WARN("Ecore was not compiled with GLib support, some plugins will not " "work (ie: Adobe Flash)"); } return ++m_initCount; }