void EDFBFont::GetHeight(e_font_height *height, float size, float shear, bool bold) const { if(fEngine == NULL || height == NULL) return; bzero(height, sizeof(e_font_height)); EAutolock <EDFBGraphicsEngine> autolock(fEngine); if(autolock.IsLocked() == false || fEngine->InitCheck() != E_OK) return; int dfbHeight = 0; fDFBFont->GetHeight(fDFBFont, &dfbHeight); if(size != (float)dfbHeight) return; int ascent = 0, descent = 0; fDFBFont->GetAscender(fDFBFont, &ascent); fDFBFont->GetDescender(fDFBFont, &descent); height->ascent = (float)(dfbHeight - ascent + descent) / 2.f + (float)ascent; height->descent = (float)dfbHeight - height->ascent; height->leading = 0; return; }
float EDFBFont::StringWidth(const char *string, float size, float spacing, float shear, bool bold, eint32 length) const { if(fEngine == NULL) return 0; if((int)size <= 0 || string == NULL || *string == 0 || length == 0 || !IsAttached()) return 0; EAutolock <EDFBGraphicsEngine> autolock(fEngine); if(autolock.IsLocked() == false || fEngine->InitCheck() != E_OK) return 0; int height = 0; fDFBFont->GetHeight(fDFBFont, &height); if(size != (float)height) return 0; float width = 0; if(length < 0 || (size_t)length > strlen(string)) length = (eint32)strlen(string); float delta = (float)ceil((double)(spacing * size)); euint8 bytes = 0; const char *str = e_utf8_at(string, 0, &bytes); const char *tmp = str; while(!(tmp == NULL || bytes == 0 || (size_t)(tmp - string) > (size_t)length - (size_t)bytes)) { EString aStr(tmp, (eint32)bytes); int bWidth = -1; fDFBFont->GetStringWidth(fDFBFont, aStr.String(), aStr.Length(), &bWidth); width += (float)(bWidth > 0 ? bWidth : height) + (tmp == str ? 0.f : delta); tmp = e_utf8_next(tmp, &bytes); } return width; }
void EDFBFont::ForceFontAliasing(bool enable) { if(fEngine == NULL) return; EAutolock <EDFBGraphicsEngine> autolock(fEngine); if(autolock.IsLocked() == false || fEngine->InitCheck() != E_OK) return; if(fForceFontAliasing != enable) { fForceFontAliasing = enable; DFBFontDescription fontdesc; fontdesc.flags = (DFBFontDescriptionFlags)(DFDESC_ATTRIBUTES | DFDESC_HEIGHT); fontdesc.attributes = (fForceFontAliasing ? DFFA_MONOCHROME : DFFA_NONE); fontdesc.height = ETK_DIRECTFONT_DEFAULT_SIZE; IDirectFBFont *newFont = NULL; fEngine->dfbDisplay->CreateFont(fEngine->dfbDisplay, fFilename, &fontdesc, &newFont); if(newFont) { fDFBFont->Release(fDFBFont); fDFBFont = newFont; int height = 0; fDFBFont->GetHeight(fDFBFont, &height); float sizes = (float)height; SetFixedSize(&sizes, 1); } } }
ERect EDFBFont::RenderString(EHandler *_view, const char *string, float size, float spacing, float shear, bool bold, eint32 length) { if(fEngine == NULL || (int)size <= 0 || string == NULL || *string == 0 || length == 0) return ERect(); EView *view = e_cast_as(_view, EView); if(view == NULL || view->Window() == NULL || view->IsPrinting()) return ERect(); ERegion viewClipping; view->GetClippingRegion(&viewClipping); if(viewClipping.CountRects() <= 0) return ERect(); EAutolock <EDFBGraphicsEngine> autolock(fEngine); if(autolock.IsLocked() == false || fEngine->InitCheck() != E_OK) return ERect(); EDFBGraphicsDrawable *pix = e_cast_as(EGraphicsEngine::GetPixmap(view->Window()), EDFBGraphicsDrawable); EGraphicsContext *dc = EGraphicsEngine::GetContext(view); if(pix == NULL || pix->dfbSurface == NULL || dc == NULL) return ERect(); if(!IsAttached()) return ERect(); int height = 0, ascent = 0, descent = 0; fDFBFont->GetHeight(fDFBFont, &height); fDFBFont->GetAscender(fDFBFont, &ascent); fDFBFont->GetDescender(fDFBFont, &descent); if(size != (float)height) return ERect(); float width = 0; if(length < 0 || (size_t)length > strlen(string)) length = (eint32)strlen(string); float delta = (float)ceil((double)(spacing * size)); EPoint pt = view->ConvertToWindow(view->PenLocation()); pt.y -= (float)(ascent + 1); e_rgb_color c = dc->HighColor(); pix->dfbSurface->SetColor(pix->dfbSurface, c.red, c.green, c.blue, 255); pix->dfbSurface->SetDrawingFlags(pix->dfbSurface, DSDRAW_NOFX); pix->dfbSurface->SetFont(pix->dfbSurface, fDFBFont); euint8 bytes = 0; const char *str = e_utf8_at(string, 0, &bytes); const char *tmp = str; while(!(tmp == NULL || bytes == 0 || (size_t)(tmp - string) > (size_t)length - (size_t)bytes)) { EString aStr(tmp, (eint32)bytes); int bWidth = -1; fDFBFont->GetStringWidth(fDFBFont, aStr.String(), aStr.Length(), &bWidth); for(eint32 i = 0; i < dc->Clipping()->CountRects(); i++) { ERect rect = dc->Clipping()->RectAt(i).FloorCopy(); DFBRegion clipping; clipping.x1 = (int)rect.left; clipping.y1 = (int)rect.top; clipping.x2 = (int)rect.right; clipping.y2 = (int)rect.bottom; pix->dfbSurface->SetClip(pix->dfbSurface, &clipping); if(bWidth > 0) pix->dfbSurface->DrawString(pix->dfbSurface, aStr.String(), aStr.Length(), (int)pt.x, (int)pt.y, (DFBSurfaceTextFlags)(DSTF_LEFT | DSTF_TOP)); // else // pix->dfbSurface->FillRectangle(pix->dfbSurface, (int)pt.x + 3, (int)pt.y + 3, height - 6, height - 6); } pt.x += (float)(bWidth > 0 ? bWidth : height) + delta; width += (float)(bWidth > 0 ? bWidth : height) + (tmp == str ? 0.f : delta); tmp = e_utf8_next(tmp, &bytes); } pix->dfbSurface->SetFont(pix->dfbSurface, NULL); ERect updateRect; updateRect.left = pt.x; updateRect.right = pt.x + width; updateRect.top = pt.y; updateRect.bottom = updateRect.top + (float)height; view->ConvertFromWindow(&updateRect); updateRect &= viewClipping.Frame(); return updateRect; }
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; }
int main(int argc, char *argv[]) { IDirectFBDisplayLayer *layer; DFBWindowDescription dwsc; DFBSurfaceDescription dsc; DFBDisplayLayerConfig config; IDirectFBWindow *window_mic, *window_camera, *window_case, *window_tp; IDirectFBSurface *surface_case, *surface_tp, *surface_camera; IDirectFBSurface *surface_mic, *primary, *surface_button; IDirectFBFont *font; DFBRectangle rect; DFBFontDescription font_desc; DirectThread *thread_camera, *thread_music, *thread_mic, *thread_tp, *thread_flashlight, *thread_case[case_num]; DirectThread *thread_button; // int font_size = 24; // int camera_frame = 0; int i; char font_file[50] = "/misc/font/wqy-zenhei.ttc"; char conf_file[50] = "/misc/pcba.conf"; bool overflow = false; case_t *case_x; case_x = malloc((case_num + 3) * sizeof(case_t)); //20 case,11 auto case,gps is the last autocase init_case(case_x, case_num + 3, gps + 1); if(parser_config_file(conf_file, case_x)) { printf("config file open error, use default\n"); } parse_global_config(case_x); printf("camera_frame = %d\n", camera_frame); printf("font_size = %d\n", font_size); printf("camera pixel [%d*%d]\n", camera_pixel_width, camera_pixel_height); #ifndef __GS900A__ ion_open_alc(); #endif //define window size int screen_width, screen_height; int mic_width, camera_window_width, camera_window_height; int case_width, case_name_align, case_result_align; int font_height; //change env char event_path[100]; char env_gsensor[256]; //enable gsensor i = get_input_event_name(case_x[gsensor].dev_name, event_path); if(i != -1) { sprintf(env_gsensor, "echo 1 > /sys/class/input/input%d/enable", i); system(env_gsensor); } else { printf("----error! gsensor not found\n"); } //vibrate test for 3 second test_vibrate(3); //dfb init DFBCHECK(DirectFBInit(&argc, &argv)); DFBCHECK(DirectFBCreate(&dfb)); font_desc.flags = DFDESC_HEIGHT; font_desc.height = font_size; DFBCHECK(dfb->CreateFont( dfb, font_file, &font_desc, &font)); DFBCHECK(font->GetHeight(font, &font_height)); DFBCHECK(dfb->GetDisplayLayer(dfb, DLID_PRIMARY, &layer)); DFBCHECK(layer->GetConfiguration( layer, &config )); // DFBCHECK(layer->SetRotation( layer, 180 )); //set window size screen_width = config.width; screen_height = config.height; mic_width = screen_width / 20; camera_window_width = (screen_width - mic_width) / 2; camera_window_height = screen_height / 2; case_width = screen_width - mic_width - camera_window_width; case_name_align = font_size; case_result_align = 7 * font_size; //create tp window dwsc.flags = DWDESC_POSX | DWDESC_POSY | DWDESC_WIDTH | DWDESC_HEIGHT | DWDESC_CAPS; dwsc.posx = 0; dwsc.posy = 0; dwsc.width = screen_width; dwsc.height = screen_height; dwsc.caps = DWCAPS_ALPHACHANNEL; DFBCHECK(layer->CreateWindow(layer, &dwsc, &window_tp)); DFBCHECK(window_tp->GetSurface(window_tp, &surface_tp)); DFBCHECK(window_tp->SetOptions(window_tp, DWOP_ALPHACHANNEL)); DFBCHECK(window_tp->SetStackingClass(window_tp, DWSC_UPPER)); DFBCHECK(window_tp->RaiseToTop(window_tp)); DFBCHECK(surface_tp->Clear(surface_tp, 0, 0, 0, 0)); DFBCHECK(surface_tp->SetColor(surface_tp, 0, 0xff, 0, 0xff)); DFBCHECK(window_tp->SetOpacity(window_tp, 0xff)); //config camera window dwsc.flags = DWDESC_POSX | DWDESC_POSY | DWDESC_WIDTH | DWDESC_HEIGHT; dwsc.posx = case_width + mic_width; dwsc.posy = 0; dwsc.width = camera_window_width; dwsc.height = screen_height; DFBCHECK(layer->CreateWindow( layer, &dwsc, &window_camera )); DFBCHECK(window_camera->GetSurface(window_camera, &windowsurface)); DFBCHECK(windowsurface->SetColor(windowsurface, 0, 0, 0, 0xff)); DFBCHECK(windowsurface->FillRectangle(windowsurface, 0, 0, camera_window_width , screen_height)); DFBCHECK(windowsurface->Flip(windowsurface, NULL, 0)); DFBCHECK(window_camera->SetOpacity( window_camera, 0xff )); drawRGB(windowsurface, 0, screen_height / 2, camera_window_width, screen_height /2); rect.x = 0; rect.y = 0; rect.w = camera_window_width; rect.h = camera_window_height; DFBCHECK(windowsurface->GetSubSurface(windowsurface, &rect, &surface_camera)); rect.x = 0; rect.y = screen_height / 4 * 3; rect.w = camera_window_width; rect.h = screen_height - rect.y; DFBCHECK(windowsurface->GetSubSurface(windowsurface, &rect, &surface_button)); //create camera surface dsc.flags = DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT; dsc.pixelformat = DSPF_NV12; dsc.width = camera_pixel_width; dsc.height = camera_pixel_height; DFBCHECK(dfb->CreateSurface(dfb, &dsc, &camera_source)); //config mic window dwsc.flags = DWDESC_POSX | DWDESC_POSY | DWDESC_WIDTH | DWDESC_HEIGHT; dwsc.posx = case_width; dwsc.posy = 0; dwsc.width = mic_width; dwsc.height = screen_height; DFBCHECK(layer->CreateWindow(layer, &dwsc, &window_mic)); DFBCHECK(window_mic->GetSurface(window_mic, &surface_mic)); DFBCHECK(surface_mic->SetColor(surface_mic, 0, 0, 0, 0xff)); DFBCHECK(surface_mic->FillRectangle(surface_mic, 0, 0, mic_width , screen_height)); DFBCHECK(surface_mic->Flip(surface_mic, NULL, 0)); DFBCHECK(window_mic->SetOpacity( window_mic, 0xff)); //config case window dwsc.posx = 0; dwsc.posy = 0; dwsc.width = case_width; dwsc.height = screen_height; DFBCHECK(layer->CreateWindow(layer, &dwsc, &window_case)); DFBCHECK(window_case->GetSurface(window_case, &surface_case)); DFBCHECK(surface_case->SetColor(surface_case, 0xff, 0xff, 0xff, 0xff)); DFBCHECK(surface_case->SetFont(surface_case, font)); DFBCHECK(surface_case->FillRectangle(surface_case, 0, 0, case_width, screen_height)); //draw headline DFBCHECK(surface_case->SetColor(surface_case, 0xff, 0xff, 0, 0xff)); DFBCHECK(surface_case->FillRectangle(surface_case, 0, 0, case_width, font_size + 2)); DFBCHECK(surface_case->FillRectangle(surface_case, 0, screen_height / 2, case_width, font_size + 2)); DFBCHECK(surface_case->SetColor(surface_case, 0, 0, 0, 0xff)); DFBCHECK(surface_case->DrawString(surface_case, "自动测试选项", -1, case_width / 2, 0, DSTF_TOPCENTER)); DFBCHECK(surface_case->DrawString(surface_case, "手动测试选项", -1, case_width / 2, screen_height / 2, DSTF_TOPCENTER)); int auto_skip = 0; int manu_skip = 0; int skip_height = 0; bool double_line = false; //draw string for(i = 0; i < case_num; i++) { double_line = false; if(overflow) { case_x[i].enable = 0; continue; } if(!case_x[i].enable) { if(case_x[i].type) manu_skip++; else auto_skip++; //case_x[i].position = -1; continue; } if(case_x[i].doubleline == 1) { double_line = true; } if(case_x[i].type) skip_height = manu_skip * (font_height); else skip_height = auto_skip * (font_height); case_x[i].position = case_x[i].type * screen_height / 2 + (case_x[i].index + 1) * (font_height); case_x[i].position -= skip_height; // printf("name_h = %d\n", case_x[i].position); DFBCHECK(surface_case->SetColor(surface_case, 0, 0, 0, 0xff)); DFBCHECK(surface_case->DrawString(surface_case, case_x[i].name, -1, case_name_align, case_x[i].position, DSTF_TOPLEFT)); DFBCHECK(surface_case->SetColor(surface_case, 0xc0, 0xc0, 0xc0, 0xff)); DFBCHECK(surface_case->DrawString(surface_case, case_x[i].init_string, -1, case_result_align, case_x[i].position, DSTF_TOPLEFT)); rect.x = case_result_align; rect.y = case_x[i].position; rect.w = case_width - case_result_align; rect.h = font_height; if((rect.y + rect.h) > screen_height) { overflow = true; case_x[i].enable = 0; printf("case %d overflow, disable all case after it\n", i); continue; } if(double_line) { // case_x[i].position = -2; rect.h *= 2; if(case_x[i].type) manu_skip--; else auto_skip--; } DFBCHECK(surface_case->GetSubSurface(surface_case, &rect, &case_x[i].surface)); DFBCHECK(case_x[i].surface->SetFont(case_x[i].surface, font)); } DFBCHECK(window_case->SetOpacity(window_case, 0xff )); #ifdef __GS900A__ system("echo 1 > /sys/devices/e0250000.hdmi/enable"); #endif //start case thread for(i = 0; i < case_num; i++) { char thread_name[10]; sprintf(thread_name,"thread_%d", i); if(case_x[i].enable) { thread_case[i] = direct_thread_create(DTT_DEFAULT, case_thread, &case_x[i], thread_name); } } case_x[tp].surface = surface_tp; //start thread #ifdef __GS702C__ thread_music = direct_thread_create(DTT_DEFAULT, music_thread, NULL, "music"); thread_mic = direct_thread_create(DTT_DEFAULT, mic_thread, surface_mic, "mic"); #else thread_music = direct_thread_create(DTT_DEFAULT, tinyalsa_music_thread, NULL, "tinyalsa_music"); thread_mic = direct_thread_create(DTT_DEFAULT, tinyalsa_mic_thread, surface_mic, "tinyalsa_mic"); #endif thread_tp = direct_thread_create(DTT_DEFAULT, tp_thread, &case_x[tp], "tp"); thread_flashlight = direct_thread_create(DTT_DEFAULT, flashlight_thread, &case_x[flashlight], "flashlight"); thread_camera = direct_thread_create(DTT_DEFAULT, camera_thread, &camera_frame, "camera" ); //thread_mic = direct_thread_create(DTT_DEFAULT, mic_thread, surface_mic, "mic"); thread_button = direct_thread_create(DTT_DEFAULT, handle_record_button, surface_button, "button"); sleep(1); DFBCHECK(surface_case->Flip(surface_case, NULL, 0)); if(iio_read(info, case_x[gsensor].enable, case_x[gyro].enable, case_x[comp].enable) == -1) printf("get iio device error\n"); //block in iio_read //useless statement for(i = 0; i < case_num; i++) { if(case_x[i].enable) { direct_thread_join(thread_case[i]); case_x[i].surface->Release(case_x[i].surface); direct_thread_destroy(thread_case[i]); printf("thread %d destroyed\n", i); } } direct_thread_join(thread_camera); direct_thread_destroy(thread_camera); direct_thread_join(thread_music); direct_thread_destroy(thread_music); direct_thread_join(thread_mic); direct_thread_destroy(thread_mic); surface_button->Release(surface_button); surface_camera->Release(surface_camera); camera_source->Release(camera_source); windowsurface->Release(windowsurface); window_camera->Release(window_camera); surface_case->Release(surface_case); window_case->Release(window_case); layer->Release(layer); font->Release(font); dfb->Release(dfb); #ifndef __GS900A__ ion_close_alc(); #endif }