Ret ftk_backend_init(int argc, char* argv[]) { ftk_set_display(ftk_display_fb_create(getenv("FTK_FB_NAME") ? getenv("FTK_FB_NAME") : FTK_FB_NAME)); if(ftk_default_display() == NULL) { size_t i = 0; for(i = 0; fb_dev[i] != NULL; i++) { ftk_set_display(ftk_display_fb_create(fb_dev[i])); if(ftk_default_display() != NULL) { break; } else { ftk_loge("open %s failed.\n", fb_dev[i]); } } } if(ftk_default_display() == NULL) { ftk_loge("open display failed %s.\n", FTK_FB_NAME); exit(0); } ftk_init_input(); return RET_OK; }
Ret ftk_backend_init(int argc, char* argv[]) { ftk_set_display(ftk_display_lcd_create("lcd")); ftk_default_display(); ftk_source_touch_init(); ftk_source_input_init(); return RET_OK; }
Ret ftk_backend_init(int argc, char* argv[]) { ftk_init_input(); ftk_set_display(ftk_display_ucosii_create()); if(ftk_default_display() == NULL) { ftk_loge("open display failed.\n"); exit(0); } return RET_OK; }
static int lua_ftk_set_display(lua_State* L) { tolua_Error err = {0}; FtkDisplay* display; int param_ok = tolua_isusertype(L, 1, "FtkDisplay", 0, &err); return_val_if_fail(param_ok, 0); display = tolua_tousertype(L, 1, 0); ftk_set_display(display); return 1; }
Ret ftk_init(int argc, char* argv[]) { FtkColor bg = {0}; FtkConfig* config = NULL; FtkDisplay* display = NULL; static int ftk_inited = 0; if(ftk_inited) { return RET_OK; } else { ftk_inited = 1; } ftk_clear_globals(); PROFILE_START(); #ifndef USE_STD_MALLOC ftk_set_allocator(FTK_ALLOC_PROFILE(ftk_allocator_default_create())); quit_if_fail(ftk_default_allocator(), "Init allocator failed.\n"); #endif ftk_platform_init(argc, argv); config = ftk_config_create(); ftk_set_config(config); ftk_config_init(config, argc, argv); quit_if_fail(ftk_default_config(), "Init config failed.\n"); PROFILE_END("config init"); ftk_set_text_layout(ftk_text_layout_create()); PROFILE_START(); ftk_set_sources_manager(ftk_sources_manager_create(64)); ftk_set_main_loop(ftk_main_loop_create(ftk_default_sources_manager())); ftk_set_wnd_manager(ftk_wnd_manager_default_create(ftk_default_main_loop())); quit_if_fail(ftk_default_wnd_manager(), "Init windows manager failed.\n"); PROFILE_END("source main loop wnd manager init"); ftk_init_bitmap_factory(); PROFILE_START(); ftk_init_theme(ftk_config_get_theme(config)); ftk_backend_init(argc, argv); PROFILE_END("theme and backend init"); display = ftk_display_rotate_create(ftk_default_display(), ftk_config_get_rotate(ftk_default_config())); ftk_set_display(display); quit_if_fail(ftk_default_display(), "Init display failed.\n"); PROFILE_START(); bg.a = 0xff; ftk_set_shared_canvas(ftk_canvas_create(ftk_display_width(display), ftk_display_height(display), &bg)); ftk_logd("canvas init: %d %d\n", ftk_display_width(display), ftk_display_height(display)); PROFILE_END("canvas init"); PROFILE_START(); ftk_set_input_method_manager(ftk_input_method_manager_create()); ftk_set_input_method_preeditor(ftk_input_method_preeditor_default_create()); quit_if_fail(ftk_default_input_method_manager(), "Init input method failed.\n"); PROFILE_END("input method init"); PROFILE_START(); if(ftk_config_get_enable_status_bar(config)) { ftk_init_panel(); } PROFILE_END("panel init"); if(ftk_config_get_enable_cursor(config)) { #ifndef USE_LINUX_DFB ftk_enable_curosr(); #endif } return RET_OK; }
void ftk_deinit(void) { if(ftk_default_input_method_preeditor() != NULL) { ftk_input_method_preeditor_destroy(ftk_default_input_method_preeditor()); ftk_set_input_method_preeditor(NULL); } if(ftk_default_wnd_manager() != NULL) { ftk_wnd_manager_destroy(ftk_default_wnd_manager()); ftk_set_wnd_manager(NULL); } if(ftk_default_main_loop() != NULL) { ftk_main_loop_destroy(ftk_default_main_loop()); ftk_set_main_loop(NULL); } if(ftk_default_sources_manager() != NULL) { ftk_sources_manager_destroy(ftk_default_sources_manager()); ftk_set_sources_manager(NULL); } if(ftk_default_bitmap_factory() != NULL) { ftk_bitmap_factory_destroy(ftk_default_bitmap_factory()); ftk_set_bitmap_factory(NULL); } if(ftk_default_text_layout() != NULL) { ftk_text_layout_destroy(ftk_default_text_layout()); ftk_set_text_layout(NULL); } if(ftk_default_font() != NULL) { ftk_font_destroy(ftk_default_font()); ftk_set_font(NULL); } if(ftk_default_display() != NULL) { ftk_display_destroy(ftk_default_display()); ftk_set_display(NULL); } if(ftk_default_theme() != NULL) { ftk_theme_destroy(ftk_default_theme()); ftk_set_theme(NULL); } if(ftk_shared_canvas() != NULL) { ftk_canvas_destroy(ftk_shared_canvas()); ftk_set_shared_canvas(NULL); } if(ftk_default_input_method_manager() != NULL) { ftk_input_method_manager_destroy(ftk_default_input_method_manager()); ftk_set_input_method_manager(NULL); } if(ftk_default_config() != NULL) { ftk_config_destroy(ftk_default_config()); ftk_set_config(NULL); } ftk_platform_deinit(); #ifndef USE_STD_MALLOC if(ftk_default_allocator() != NULL) { ftk_allocator_destroy(ftk_default_allocator()); ftk_set_allocator(NULL); } #endif ftk_logd("%s: ftk exit.\n", __func__); return; }