static void resizor_draw(struct resizor *resizor) { cairo_surface_t *surface; cairo_t *cr; struct rectangle allocation; window_draw(resizor->window); window_get_child_allocation(resizor->window, &allocation); surface = window_get_surface(resizor->window); cr = cairo_create(surface); cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); cairo_rectangle(cr, allocation.x, allocation.y, allocation.width, allocation.height); cairo_set_source_rgba(cr, 0, 0, 0, 0.8); cairo_fill(cr); cairo_destroy(cr); cairo_surface_destroy(surface); window_flush(resizor->window); if (fabs(resizor->height.previous - resizor->height.target) > 0.1) { wl_display_frame_callback(display_get_display(resizor->display), frame_callback, resizor); } }
/** * * rct2: 0x006E7499 * left (ax) * top (bx) * right (dx) * bottom (bp) */ void gfx_redraw_screen_rect(short left, short top, short right, short bottom) { rct_window* w; rct_drawpixelinfo *screenDPI = RCT2_ADDRESS(RCT2_ADDRESS_SCREEN_DPI, rct_drawpixelinfo); rct_drawpixelinfo *windowDPI = RCT2_ADDRESS(RCT2_ADDRESS_WINDOW_DPI, rct_drawpixelinfo); // Unsure what this does RCT2_CALLPROC_X(0x00683326, left, top, right - 1, bottom - 1, 0, 0, 0); windowDPI->bits = screenDPI->bits + left + ((screenDPI->width + screenDPI->pitch) * top); windowDPI->x = left; windowDPI->y = top; windowDPI->width = right - left; windowDPI->height = bottom - top; windowDPI->pitch = screenDPI->width + screenDPI->pitch + left - right; for (w = RCT2_ADDRESS(RCT2_ADDRESS_WINDOW_LIST, rct_window); w < RCT2_GLOBAL(RCT2_ADDRESS_NEW_WINDOW_PTR, rct_window*); w++) { if (w->flags & WF_TRANSPARENT) continue; if (right <= w->x || bottom <= w->y) continue; if (left >= w->x + w->width || top >= w->y + w->height) continue; window_draw(w, left, top, right, bottom); } }
bool graphics_init(gfx_t* gfx) { memset(gfx, 0, sizeof *gfx); if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0) { return false; } if (!window_init(&gfx->window, "Spielbub", SCREEN_WIDTH, SCREEN_HEIGHT)) { return false; } gfx->background = create_surface(); gfx->sprites_bg = create_surface(); gfx->sprites_fg = create_surface(); if (!gfx->background || !gfx->sprites_bg || ! gfx->sprites_fg) { goto error; } gfx->layers[0] = gfx->background; gfx->layers[1] = gfx->sprites_bg; gfx->layers[2] = gfx->sprites_fg; gfx->state = OAM; window_clear(&gfx->window); window_draw(&gfx->window); return true; error: { graphics_destroy(gfx); return false; } }
/*EXTL_DOC * Set contents of the info window. */ EXTL_EXPORT_MEMBER void infowin_set_text(WInfoWin *p, const char *str, int maxw) { bool set=FALSE; if(str==NULL){ INFOWIN_BUFFER(p)[0]='\0'; }else{ if(maxw>0 && p->brush!=NULL){ char *tmp=grbrush_make_label(p->brush, str, maxw); if(tmp!=NULL){ infowin_do_set_text(p, tmp); free(tmp); set=TRUE; } } if(!set) infowin_do_set_text(p, str); } infowin_resize(p); /* sometimes unnecessary */ window_draw((WWindow*)p, TRUE); }
static void allocate_buffer(struct gears *gears) { EGLImageKHR image; struct rectangle allocation; window_draw(gears->window); gears->surface[gears->current] = window_get_surface(gears->window); #ifdef HAVE_CAIRO_EGL image = display_get_image_for_drm_surface(gears->display, gears->surface[gears->current]); #else /* XXX: hack to make Wayland compile, even if this example doesn't run */ die("gears cannot allocate buffer: it was compiled without cairo-gl\n"); return; #endif if (!eglMakeCurrent(gears->display, NULL, NULL, gears->context)) die("faile to make context current\n"); glBindRenderbuffer(GL_RENDERBUFFER_EXT, gears->color_rbo[gears->current]); glEGLImageTargetRenderbufferStorageOES(GL_RENDERBUFFER, image); glBindRenderbuffer(GL_RENDERBUFFER_EXT, gears->depth_rbo); window_get_child_allocation(gears->window, &allocation); glRenderbufferStorage(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, allocation.width + 20 + 32, allocation.height + 60 + 32); }
static void draw_gears(struct gears *gears) { GLfloat view_rotx = 20.0, view_roty = 30.0, view_rotz = 0.0; struct rectangle window_allocation; struct rectangle allocation; window_draw(gears->window); window_get_child_allocation(gears->window, &allocation); window_get_allocation(gears->window, &window_allocation); display_acquire_window_surface(gears->d, gears->window, gears->context); glViewport(allocation.x, window_allocation.height - allocation.height - allocation.x, allocation.width, allocation.height); glScissor(allocation.x, window_allocation.height - allocation.height - allocation.y, allocation.width, allocation.height); glEnable(GL_SCISSOR_TEST); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glPushMatrix(); glTranslatef(0.0, 0.0, -50); glRotatef(view_rotx, 1.0, 0.0, 0.0); glRotatef(view_roty, 0.0, 1.0, 0.0); glRotatef(view_rotz, 0.0, 0.0, 1.0); glPushMatrix(); glTranslatef(-3.0, -2.0, 0.0); glRotatef(gears->angle, 0.0, 0.0, 1.0); glCallList(gears->gear_list[0]); glPopMatrix(); glPushMatrix(); glTranslatef(3.1, -2.0, 0.0); glRotatef(-2.0 * gears->angle - 9.0, 0.0, 0.0, 1.0); glCallList(gears->gear_list[1]); glPopMatrix(); glPushMatrix(); glTranslatef(-3.1, 4.2, 0.0); glRotatef(-2.0 * gears->angle - 25.0, 0.0, 0.0, 1.0); glCallList(gears->gear_list[2]); glPopMatrix(); glPopMatrix(); glFlush(); display_release(gears->d); window_flush(gears->window); }
void window_list_draw(Picture surface) { window_t *window = window_list; while (window != NULL) { if (window->mapped == TRUE) { window_draw(window->id, surface); } window = window->next; } }
void menu_updategr(WMenu *menu) { if(!menu_init_gr(menu, region_rootwin_of((WRegion*)menu), MENU_WIN(menu))){ return; } menu_do_refit(menu, NULL, &(menu->last_fp)); region_updategr_default((WRegion*)menu); window_draw((WWindow*)menu, TRUE); }
////////////////////////////////////////////////////////////////////////////////////////// //测试 void win_test(u16 x, u16 y, u16 width, u16 height, u8 type, u16 cup, u16 cdown, u8 *caption) { _window_obj *twin; twin = window_creat(x, y, width, height, 0, type, 16); //创建窗口 if(twin == NULL) { return; //创建失败. } twin->caption = caption; { twin->windowbkc = cup; } window_draw(twin); window_delete(twin); }
static void image_draw(struct image *image) { struct rectangle allocation; GdkPixbuf *pb; cairo_t *cr; cairo_surface_t *surface; window_draw(image->window); window_get_child_allocation(image->window, &allocation); pb = gdk_pixbuf_new_from_file_at_size(image->filename, allocation.width, allocation.height, NULL); if (pb == NULL) return; surface = window_get_surface(image->window); cr = cairo_create(surface); window_get_child_allocation(image->window, &allocation); cairo_rectangle(cr, allocation.x, allocation.y, allocation.width, allocation.height); cairo_clip(cr); cairo_push_group(cr); cairo_translate(cr, allocation.x, allocation.y); cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); cairo_set_source_rgba(cr, 0, 0, 0, 1); cairo_paint(cr); set_source_pixbuf(cr, pb, 0, 0, allocation.width, allocation.height); cairo_set_operator(cr, CAIRO_OPERATOR_OVER); cairo_paint(cr); g_object_unref(pb); cairo_pop_group_to_source(cr); cairo_paint(cr); cairo_destroy(cr); window_flush(image->window); cairo_surface_destroy(surface); }
void infowin_updategr(WInfoWin *p) { GrBrush *nbrush; assert(p->style!=NULL); nbrush=gr_get_brush(p->wwin.win, region_rootwin_of((WRegion*)p), p->style); if(nbrush==NULL) return; if(p->brush!=NULL) grbrush_release(p->brush); p->brush=nbrush; window_draw(&(p->wwin), TRUE); }
void lodoovka_redraw() { draw_desktop(); window_sref sref = window_stack; if(window_stack) { do { window_draw(sref->wnd); } while((sref = sref->next)); } draw_plusbtn(); drawScreen(); }
int main(int argc, char *argv[]) { cairo_surface_t *s; struct flower flower; struct display *d; struct timeval tv; d = display_create(&argc, &argv, NULL, NULL); if (d == NULL) { fprintf(stderr, "failed to create display: %m\n"); return -1; } gettimeofday(&tv, NULL); srandom(tv.tv_usec); flower.width = 200; flower.height = 200; flower.display = d; flower.window = window_create(d, flower.width, flower.height); window_set_title(flower.window, "flower"); window_set_decoration(flower.window, 0); window_draw(flower.window); s = window_get_surface(flower.window); if (s == NULL || cairo_surface_status (s) != CAIRO_STATUS_SUCCESS) { fprintf(stderr, "failed to create cairo egl surface\n"); return -1; } draw_stuff(s, flower.width, flower.height); cairo_surface_flush(s); cairo_surface_destroy(s); window_flush(flower.window); window_set_motion_handler(flower.window, motion_handler); window_set_button_handler(flower.window, button_handler); window_set_user_data(flower.window, &flower); display_run(d); return 0; }
int main(int argc, char *argv[]) { struct window *window; window = window_create(0, 0, 640, 480); if (!window) { fprintf(stderr, "window_create() failed\n"); return 1; } window_show(window); while (true) { if (!window_event_loop(window)) break; window_draw(window); } window_close(window); return 0; }
static void moveres_draw_infowin(WMoveresMode *mode) { char *buf; if(mode->infowin==NULL) return; buf=INFOWIN_BUFFER(mode->infowin); if(buf==NULL) return; if(mode->mode==MOVERES_SIZE){ int w, h; w=mode->geom.w; h=mode->geom.h; if(mode->hints.base_set){ w=MAXOF(0, w-mode->hints.base_width); h=MAXOF(0, h-mode->hints.base_height); } if(mode->hints.inc_set){ w/=MAXOF(1, mode->hints.width_inc); h/=MAXOF(1, mode->hints.height_inc); } snprintf(buf, INFOWIN_BUFFER_LEN, "%dx%d", w, h); }else{ snprintf(buf, INFOWIN_BUFFER_LEN, "%+d %+d", mode->geom.x, mode->geom.y); } window_draw((WWindow*)mode->infowin, TRUE); }
//在制定位置显示一个msg box //x,y,width,height:坐标尺寸 //str:字符串 //caption:消息窗口名字 //font:字体大小 //color:颜色 //mode: //[7]:0,没有关闭按钮.1,有关闭按钮 //[6]:0,不读取背景色.1,读取背景色. //[5]:0,标题靠左.1,标题居中. //[4:2]:保留 //[1]:0,不显示取消按键;1,显示取消按键. //[0]:0,不显示OK按键;1,显示OK按键. //返回值: //0,没有任何按键按下/产生了错误. //1,确认按钮按下了. //2,取消按钮按下了. u8 window_msg_box(u16 x, u16 y, u16 width, u16 height, u8 *str, u8 *caption, u8 font, u16 color, u8 mode) { u8 rval = 0, res; u16 offx = 0, offy = 0; u16 temp, strheight = 0; _window_obj *twin = 0; //窗体 _btn_obj *okbtn = 0; //确定按钮 _btn_obj *cancelbtn = 0; //取消按钮 if(width < 150 || height < (WIN_CAPTION_HEIGHT + font + 5)) { return 0; //尺寸错误 } twin = window_creat(x, y, width, height, 0, 1 | ((7 << 5)&mode), 16); //创建窗口 if((mode & 0X03) == 0x03) { //有两个按钮 offy = MSG_BOX_BTN1_WIDTH; offx = (width - MSG_BOX_BTN1_WIDTH * 2) / 3; } else { //只有一个按钮 offy = MSG_BOX_BTN2_WIDTH; offx = (width - MSG_BOX_BTN2_WIDTH) / 2; } if(mode & (1 << 0)) { //需要显示OK按键 okbtn = btn_creat(x + offx, y + height - MSG_BOX_BTN_HEIGHT - 10, offy, MSG_BOX_BTN_HEIGHT, 0, 0x02); //创建OK按钮 if(okbtn == NULL) { rval = 1; } else { okbtn->caption = (u8 *)GUI_OK_CAPTION_TBL[gui_phy.language]; //确认 okbtn->bkctbl[0] = 0X8452; //边框颜色 okbtn->bkctbl[1] = 0XAD97; //第一行的颜色 okbtn->bkctbl[2] = 0XAD97; //上半部分颜色 okbtn->bkctbl[3] = 0X8452; //下半部分颜色 } } if(mode & (1 << 1)) { //需要显示取消按键 if(mode & (1 << 0)) { cancelbtn = btn_creat(x + offx * 2 + MSG_BOX_BTN1_WIDTH, y + height - MSG_BOX_BTN_HEIGHT - 10, offy, MSG_BOX_BTN_HEIGHT, 0, 0x02); //创建cancel按钮 } else { cancelbtn = btn_creat(x + offx, y + height - MSG_BOX_BTN_HEIGHT - 10, offy, MSG_BOX_BTN_HEIGHT, 0, 0x02); //创建cancel按钮 } if(cancelbtn == NULL) { rval = 1; } else { cancelbtn->caption = (u8 *)GUI_CANCEL_CAPTION_TBL[gui_phy.language]; //确认 cancelbtn->bkctbl[0] = 0X8452; //边框颜色 cancelbtn->bkctbl[1] = 0XAD97; //第一行的颜色 cancelbtn->bkctbl[2] = 0XAD97; //上半部分颜色 cancelbtn->bkctbl[3] = 0X8452; //下半部分颜色 } } if(twin == NULL) { rval = 1; } else { twin->caption = caption; window_draw(twin); //画出窗体 btn_draw(okbtn); //画按钮 btn_draw(cancelbtn); //画按钮 if((mode & 0X03) == 0) { rval = 1; //不需要进入while strheight = height - (WIN_CAPTION_HEIGHT + 5); } else { strheight = height - (WIN_CAPTION_HEIGHT + 50 + 5); } temp = strlen((const char *)str) * (font / 2); //得到字符串长度 if(temp >= (width - 10)) { offx = 5; //得到x的偏移 } else { offx = (width - temp) / 2; } temp = gui_get_stringline(str, width - offx * 2, font) * font; //得到字符串要占用的行数(像素) if(temp >= strheight) { offy = 5; //得到y的偏移 } else { offy = (strheight - temp) / 2; } gui_show_string(str, x + offx, y + WIN_CAPTION_HEIGHT + offy, width - offx * 2, strheight, font, color); //显示要显示的文字 } // system_task_return=0;//取消TPAD while(rval == 0) { tp_dev.scan(0); in_obj.get_key(&tp_dev, IN_TYPE_TOUCH); //得到按键键值 //在其他系统里面,用户可以自行去掉此句 // if(system_task_return)//TPAD返回 // { // rval=0XFE;//视为取消的情况,退出 // break; // } delay_ms(10); //延时10ms if(okbtn) { res = btn_check(okbtn, &in_obj); //确认按钮检测 if(res) { if((okbtn->sta & 0X80) == 0) { //有有效操作 rval = 0XFF; break;//退出 } } } if(cancelbtn) { res = btn_check(cancelbtn, &in_obj); //返回按钮检测 if(res) { if((cancelbtn->sta & 0X80) == 0) { //有有效操作 rval = 0XFE; break;//退出 } } } } btn_delete(cancelbtn); //删除按钮 btn_delete(okbtn); //删除按钮 window_delete(twin); //删除窗体 if(rval == 0XFF) { return 1; //确认 } if(rval == 0XFE) { return 2; //取消 } return 0; //错误或者无操作 }
static void menu_activated(WMenu *menu) { window_draw((WWindow*)menu, FALSE); }
/* ...redraw main application window */ static void objdet_redraw(display_data_t *display, void *data) { app_data_t *app = data; window_data_t *window = app->window; GstBuffer *buffer; /* ...retrieve pending buffer from rendering queue */ while ((buffer = objdet_pop_buffer(app)) != NULL) { vsink_meta_t *vmeta = gst_buffer_get_vsink_meta(buffer); objdet_meta_t *ometa = gst_buffer_get_objdet_meta(buffer); texture_data_t *texture = vmeta->priv; float fps = window_frame_rate_update(window); cairo_t *cr; /* ...add some performance monitors here - tbd */ TRACE(INFO, _b("redraw frame: %u"), app->frame_num++); /* ...clear buffer before drawing anything */ glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClearDepthf(1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); /* ...output buffer on screen */ texture_draw(texture, &app->view, NULL, 1.0); /* ...get cairo drawing context */ cr = window_get_cairo(window); /* ...set cairo transformation matrix for a given view-port - tbd */ cairo_save(cr); /* ...apply visualization matrix */ cairo_set_matrix(cr, &app->matrix); /* ...visualize detection data as required */ objdet_engine_ldw_draw(app->od, &ometa->scene, cr); /* ...restore transformation matrix */ cairo_restore(cr); /* ...output current vehicle status? - use unprocessed frame, maybe... */ if (app->flags & APP_FLAG_DEBUG) { /* ...output frame-rate in the upper-left corner */ cairo_set_source_rgba(cr, 1, 1, 1, 0.5); cairo_move_to(cr, 40, 80); draw_string(cr, "%.1f FPS", fps); } else { TRACE(DEBUG, _b("fps: %.2f"), fps); } /* ...output GUI graphics as needed */ gui_redraw(app->gui, cr); /* ...release cairo drawing context */ window_put_cairo(window, cr); /* ...submit window to composer */ window_draw(window); /* ...return buffer to the pool */ gst_buffer_unref(buffer); } TRACE(DEBUG, _b("frontal camera drawing complete..")); }
/* ...surround-view scene rendering */ static void sview_redraw(display_data_t *display, void *data) { app_data_t *app = data; window_data_t *window = app->window; int W = window_get_width(window); int H = window_get_height(window); GstBuffer *buffers[CAMERAS_NUMBER]; texture_data_t *texture[CAMERAS_NUMBER]; GLuint tex[CAMERAS_NUMBER]; void *planes[CAMERAS_NUMBER]; s64 ts; /* ...try to get buffers */ while(sview_pop_buffers(app, buffers, texture, tex, planes, &ts)) { float fps = window_frame_rate_update(window); cairo_t *cr; /* ...ready for rendering; clear surface content */ glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClearDepthf(1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); /* ...specify a GL-viewport for an image */ if (0) glViewport(0, 0, W, H); /* ...draw graphics on top of the scene */ cr = window_get_cairo(window); /* ...generate a single scene; acquire engine access lock */ pthread_mutex_lock(&app->access); sview_engine_process(app->sv, tex, planes, cr, ts); pthread_mutex_unlock(&app->access); /* ...output frame-rate in the upper-left corner */ if(app->flags & APP_FLAG_DEBUG) { cairo_set_source_rgba(cr, 1, 1, 1, 0.5); cairo_move_to(cr, 40, 80); draw_string(cr, "%.1f FPS", fps); } else { TRACE(DEBUG, _b("main-window fps: %.1f"), fps); } /* ...output GUI graphics as needed */ gui_redraw(app->gui, cr); /* ...release cairo interface */ window_put_cairo(window, cr); /* ...submit window to a compositor */ window_draw(window); /* ...release buffers collected */ sview_release_buffers(app, buffers); } TRACE(DEBUG, _b("surround-view drawing complete")); }