void screen_draw() { int x, y; int i; unsigned long top; int halfwin = WIN_W*T_SIZE/2; if (gPlayers == 1) { blit((BITMAP *)gData[BACK_1PLAYER].dat, gBuff, 0, 0, 0, 0, gBuff->w, gBuff->h); // information textprintf(gBuff, (FONT *)gData[FONT_TINY].dat, 180, 77, 15, "LEVEL: %d", gDifficulty + 1); textprintf(gBuff, (FONT *)gData[FONT_TINY].dat, 180, 109, 15, "LINES: %d", p[0].total_lines); textprintf(gBuff, (FONT *)gData[FONT_TINY].dat, 180, 141, 15, "SCORE: %ld", p[0].total_score); if (p[0].total_score > gTable[0].score) top = p[0].total_score; else top = gTable[0].score; textprintf(gBuff, (FONT *)gData[FONT_TINY].dat, 180, 173, 15, "TOP : %ld", top); } else blit((BITMAP *)gData[BACK_2PLAYER].dat, gBuff, 0, 0, 0, 0, gBuff->w, gBuff->h); for (i = 0; i != gPlayers; ++i) { // draw game area // grid for (y = 0; y != WIN_H; ++y) { hline(gBuff, p[i].win_x, p[i].win_y + y*T_SIZE, p[i].win_x + WIN_W*T_SIZE, 4); for (x = 0; x != WIN_W; ++x) vline(gBuff, p[i].win_x + x*T_SIZE, p[i].win_y, p[i].win_y + WIN_H*T_SIZE, 4); } // next piece box next_draw(); // the stack player_stack_draw(i); // the deleting line effect if (p[i].process == DELETING_LINES) { for (y = 0; y != 4; ++y) { if (p[i].full_lines[y] != -1) rectfill(gBuff, p[i].win_x + halfwin - halfwin * gDeleteCounter[i]/cDeleteTime, p[i].win_y + p[i].full_lines[y]*T_SIZE, p[i].win_x + halfwin + halfwin * gDeleteCounter[i]/cDeleteTime, p[i].win_y + p[i].full_lines[y]*T_SIZE + T_SIZE - 1, 0); } } // the current piece set_clip(gBuff, p[i].win_x, p[i].win_y, p[i].win_x + WIN_W*T_SIZE, p[i].win_y + WIN_H*T_SIZE); piece_draw(p[i].win_x + p[i].piece_x*T_SIZE, p[i].win_y + p[i].piece_y*T_SIZE, p[i].piece_r, p[i].current); set_clip(gBuff, 0, 0, gBuff->w, gBuff->h); //textprintf(gBuff, font, SCREEN_W/2*i, 0, 15, "(%d, %d, %d)", p[i].piece_x, p[i].piece_y, p[i].piece_r); } }
int d_aphoton_window_proc(int msg, DIALOG *d, int c) { int rtm, cl, ct, cr, cb; (void)c; if (msg == MSG_DRAW) { rect(screen, d->x, d->y, d->x+d->w-1, d->y+d->h-1, black); rect(screen, d->x+1, d->y+1, d->x+d->w-2, d->y+d->h-2, window_black); /* gray frame */ vline(screen, d->x+2, d->y+2, d->y+d->h-3, white); hline(screen, d->x+2, d->y+d->h-3, d->x+d->w-3, window_gray); vline(screen, d->x+d->w-3, d->y+2, d->y+d->h-3, window_gray); vline(screen, d->x+3, d->y+3, d->y+d->h-4, menu_gray_to); hline(screen, d->x+3, d->y+d->h-4, d->x+d->w-4, menu_gray_to); vline(screen, d->x+d->w-4, d->y+3, d->y+d->h-4, menu_gray_to); vline(screen, d->x+4, d->y+4, d->y+d->h-5, window_gray); hline(screen, d->x+4, d->y+d->h-5, d->x+d->w-5, white); vline(screen, d->x+d->w-5, d->y+4, d->y+d->h-5, white); /* blue frame */ hline(screen, d->x+2, d->y+2, d->x+d->w-3, window_blue1); hline(screen, d->x+2, d->y+3, d->x+d->w-3, window_blue2); hline(screen, d->x+2, d->y+4, d->x+d->w-3, window_blue3); hline(screen, d->x+2, d->y+5, d->x+d->w-3, window_blue2); rectgouraud(screen, d->x+2, d->y+6, d->x+d->w-3, d->y+19, &window_blue_range, FALSE); hline(screen, d->x+2, d->y+20, d->x+d->w-3, window_blue3); vline(screen, d->x+2, d->y+6, d->y+20, window_blue1); vline(screen, d->x+d->w-3, d->y+6, d->y+20, window_blue3); /* background */ rectfill(screen, d->x+5, d->y+21, d->x+d->w-6, d->y+d->h-6, normal); if (d->dp) { rtm = text_mode(-1); cl = screen->cl; ct = screen->ct; cr = screen->cr; cb = screen->cb; set_clip(screen, d->x, d->y, d->x+d->w-1, d->y+d->h-1); textout_centre(screen, font, (char *)d->dp, d->x+d->w/2, d->y+8, black); set_clip(screen, cl, ct, cr, cb); text_mode(rtm); } } return D_O_K; }
static void draw_crosshair (render_priv *priv) { GdkWindow *window = gtk_widget_get_window (gport->drawing_area); GtkStyle *style = gtk_widget_get_style (gport->drawing_area); gint x, y; static GdkGC *xor_gc; static GdkColor cross_color; if (gport->crosshair_x < 0 || ghidgui->creating || !gport->has_entered) return; if (!xor_gc) { xor_gc = gdk_gc_new (window); gdk_gc_copy (xor_gc, style->white_gc); gdk_gc_set_function (xor_gc, GDK_XOR); gdk_gc_set_clip_origin (xor_gc, 0, 0); set_clip (priv, xor_gc); /* FIXME: when CrossColor changed from config */ ghid_map_color_string (Settings.CrossColor, &cross_color); } gdk_gc_set_foreground (xor_gc, &cross_color); x = DRAW_X (gport->crosshair_x); y = DRAW_Y (gport->crosshair_y); draw_right_cross (xor_gc, x, y); if (Crosshair.shape == Union_Jack_Crosshair_Shape) draw_slanted_cross (xor_gc, x, y); if (Crosshair.shape == Dozen_Crosshair_Shape) draw_dozen_cross (xor_gc, x, y); }
static int use_gc (hidGC gc) { render_priv *priv = gport->render_priv; GdkWindow *window = gtk_widget_get_window (gport->top_window); if (gc->me_pointer != &ghid_hid) { fprintf (stderr, "Fatal: GC from another HID passed to GTK HID\n"); abort (); } if (!gport->pixmap) return 0; if (!gc->gc) { gc->gc = gdk_gc_new (window); ghid_set_color (gc, gc->colorname); ghid_set_line_width (gc, gc->width); ghid_set_line_cap (gc, (EndCapStyle)gc->cap); ghid_set_draw_xor (gc, gc->xor_mask); gdk_gc_set_clip_origin (gc->gc, 0, 0); } if (gc->mask_seq != mask_seq) { if (mask_seq) gdk_gc_set_clip_mask (gc->gc, gport->mask); else set_clip (priv, gc->gc); gc->mask_seq = mask_seq; } priv->u_gc = WHICH_GC (gc); return 1; }
void CharacterCamera::_set(const String& p_name, const Variant& p_value) { if (p_name=="type") set_camera_type((CameraType)((int)(p_value))); else if (p_name=="orbit") set_orbit(p_value); else if (p_name=="height") set_height(p_value); else if (p_name=="inclination") set_inclination(p_value); else if (p_name=="max_orbit_x") set_max_orbit_x(p_value); else if (p_name=="min_orbit_x") set_min_orbit_x(p_value); else if (p_name=="max_distance") set_max_distance(p_value); else if (p_name=="min_distance") set_min_distance(p_value); else if (p_name=="distance") set_distance(p_value); else if (p_name=="clip") set_clip(p_value); else if (p_name=="autoturn") set_autoturn(p_value); else if (p_name=="autoturn_tolerance") set_autoturn_tolerance(p_value); else if (p_name=="autoturn_speed") set_autoturn_speed(p_value); }
Door::Door(int x, int y):Sprite(x, y){ box.w = 40; box.h = 120; attr = ROBOT_ACTIVE; frame = CLOSE; set_clip(); }
bool AllegroGraphics::pushClipArea(Rectangle area) { bool result = Graphics::pushClipArea(area); const ClipRectangle& cr = mClipStack.top(); // Allegro won't let you set clip areas // that have zero width or height // so we have to check for that. if (cr.width == 0 || cr.height == 0) { mClipNull = true; } else { mClipNull = false; #if ALLEGRO_VERSION == 4 && ALLEGRO_SUB_VERSION == 0 set_clip(mTarget, cr.x, cr.y, cr.x + cr.width - 1, cr.y + cr.height - 1); #else set_clip_rect(mTarget, cr.x, cr.y, cr.x + cr.width - 1, cr.y + cr.height - 1); #endif } return result; }
static void clipboard_changed(GntWM *wm, gchar *string) { if (child) { kill(child, SIGTERM); } if ((child = fork() == 0)) { set_clip(string); _exit(0); } }
static int resize( GEM_PLOTTER self, int w, int h ) { if( w == VIEW(self).w && h == VIEW(self).h ) return( 1 ); struct rect newclip = { 0, 0, w-1, h-1 }; VIEW(self).w = w; VIEW(self).h = h; update_visible_rect( self ); set_clip( self, &newclip); LOG(("%s: %s\n", (char*)__FILE__, (char*)__FUNCTION__)); return( 1 ); }
void ghid_use_mask (int use_it) { static int mask_seq_id = 0; GdkColor color; render_priv *priv = gport->render_priv; if (!gport->pixmap) return; if (use_it == cur_mask) return; switch (use_it) { case HID_MASK_OFF: gport->drawable = gport->pixmap; mask_seq = 0; break; case HID_MASK_BEFORE: /* The HID asks not to receive this mask type, so warn if we get it */ g_return_if_reached (); case HID_MASK_CLEAR: if (!gport->mask) gport->mask = gdk_pixmap_new (0, gport->width, gport->height, 1); gport->drawable = gport->mask; mask_seq = 0; if (!priv->mask_gc) { priv->mask_gc = gdk_gc_new (gport->drawable); gdk_gc_set_clip_origin (priv->mask_gc, 0, 0); set_clip (priv, priv->mask_gc); } color.pixel = 1; gdk_gc_set_foreground (priv->mask_gc, &color); gdk_draw_rectangle (gport->drawable, priv->mask_gc, TRUE, 0, 0, gport->width, gport->height); color.pixel = 0; gdk_gc_set_foreground (priv->mask_gc, &color); break; case HID_MASK_AFTER: mask_seq_id++; if (!mask_seq_id) mask_seq_id = 1; mask_seq = mask_seq_id; gport->drawable = gport->pixmap; break; } cur_mask = use_it; }
int d_aase_window_proc(int msg, DIALOG *d, int c) { (void)c; if (msg == MSG_DRAW) { ase_rectbox(screen, d->x, d->y, d->x+d->w-1, d->y+d->h-1, d->flags); if (d->dp) { int rtm = text_mode(-1); int cl = screen->cl, ct = screen->ct, cr = screen->cr, cb = screen->cb; set_clip(screen, d->x, d->y, d->x+d->w-1, d->y+d->h-1); textout_centre(screen, font, (char *)d->dp, d->x+d->w/2, d->y+4, makecol(0, 0, 0)); set_clip(screen, cl, ct, cr, cb); text_mode(rtm); } } return D_O_K; }
static void draw_lead_user (render_priv *priv) { GdkWindow *window = gtk_widget_get_window (gport->drawing_area); GtkStyle *style = gtk_widget_get_style (gport->drawing_area); int i; Coord radius = priv->lead_user_radius; Coord width = MM_TO_COORD (LEAD_USER_WIDTH); Coord separation = MM_TO_COORD (LEAD_USER_ARC_SEPARATION); static GdkGC *lead_gc = NULL; GdkColor lead_color; if (!priv->lead_user) return; if (lead_gc == NULL) { lead_gc = gdk_gc_new (window); gdk_gc_copy (lead_gc, style->white_gc); gdk_gc_set_function (lead_gc, GDK_XOR); gdk_gc_set_clip_origin (lead_gc, 0, 0); lead_color.pixel = 0; lead_color.red = (int)(65535. * LEAD_USER_COLOR_R); lead_color.green = (int)(65535. * LEAD_USER_COLOR_G); lead_color.blue = (int)(65535. * LEAD_USER_COLOR_B); gdk_color_alloc (gport->colormap, &lead_color); gdk_gc_set_foreground (lead_gc, &lead_color); } set_clip (priv, lead_gc); gdk_gc_set_line_attributes (lead_gc, Vz (width), GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER); /* arcs at the approrpriate radii */ for (i = 0; i < LEAD_USER_ARC_COUNT; i++, radius -= separation) { if (radius < width) radius += MM_TO_COORD (LEAD_USER_INITIAL_RADIUS); /* Draw an arc at radius */ gdk_draw_arc (gport->drawable, lead_gc, FALSE, Vx (priv->lead_user_x - radius), Vy (priv->lead_user_y - radius), Vz (2. * radius), Vz (2. * radius), 0, 360 * 64); } }
/** * Compute absolute clip * * \param style Style to process * \param ex_size Ex size in ems * \return CSS_OK on success */ css_error compute_absolute_clip(css_computed_style *style, const css_hint_length *ex_size) { css_computed_clip_rect rect = { 0, 0, 0, 0, CSS_UNIT_PX, CSS_UNIT_PX, CSS_UNIT_PX, CSS_UNIT_PX, false, false, false, false }; css_error error; if (get_clip(style, &rect) == CSS_CLIP_RECT) { if (rect.top_auto == false) { if (rect.tunit == CSS_UNIT_EX) { rect.top = FMUL(rect.top, ex_size->value); rect.tunit = ex_size->unit; } } if (rect.right_auto == false) { if (rect.runit == CSS_UNIT_EX) { rect.right = FMUL(rect.right, ex_size->value); rect.runit = ex_size->unit; } } if (rect.bottom_auto == false) { if (rect.bunit == CSS_UNIT_EX) { rect.bottom = FMUL(rect.bottom, ex_size->value); rect.bunit = ex_size->unit; } } if (rect.left_auto == false) { if (rect.lunit == CSS_UNIT_EX) { rect.left = FMUL(rect.left, ex_size->value); rect.lunit = ex_size->unit; } } error = set_clip(style, CSS_CLIP_RECT, &rect); if (error != CSS_OK) return error; } return CSS_OK; }
Level::Level(std::string file_name, int row, int column){ this->file_name = file_name; this->row = row; this->column = column; total_tile = row * column; tiles = NULL; total_sprites = 2; sprite_list = new Sprite*[total_sprites]; sprite_list[0] = new Exit(10 * TILE_WIDTH, 2 * TILE_HEIGHT); sprite_list[1] = new GlassDoor(5 * TILE_WIDTH+ 10, 3 * TILE_HEIGHT); //sprite_list[2] = new Book(4 * TILE_WIDTH, 5 * TILE_HEIGHT); int pos1[2] = {80,120}; stick_master = new StickMaster(this,1,pos1); int pos2[2] = {280,160}; robot_master = new RobotMaster(this,1,pos2); state = PLAYING; set_clip(); set_tile(); }
static void show_crosshair (gboolean paint_new_location) { render_priv *priv = gport->render_priv; GdkWindow *window = gtk_widget_get_window (gport->drawing_area); GtkStyle *style = gtk_widget_get_style (gport->drawing_area); gint x, y; static gint x_prev = -1, y_prev = -1; static GdkGC *xor_gc; static GdkColor cross_color; if (gport->crosshair_x < 0 || ghidgui->creating || !gport->has_entered) return; if (!xor_gc) { xor_gc = gdk_gc_new (window); gdk_gc_copy (xor_gc, style->white_gc); gdk_gc_set_function (xor_gc, GDK_XOR); gdk_gc_set_clip_origin (xor_gc, 0, 0); set_clip (priv, xor_gc); /* FIXME: when CrossColor changed from config */ ghid_map_color_string (Settings.CrossColor, &cross_color); } x = DRAW_X (gport->crosshair_x); y = DRAW_Y (gport->crosshair_y); gdk_gc_set_foreground (xor_gc, &cross_color); if (x_prev >= 0 && !paint_new_location) draw_crosshair (xor_gc, x_prev, y_prev); if (x >= 0 && paint_new_location) { draw_crosshair (xor_gc, x, y); x_prev = x; y_prev = y; } else x_prev = y_prev = -1; }
void TrackerDialog::set_model(int val) { dialog_settings.active_model_panel = val; switch (val) { case TrackerDialogSettings::MODEL_CLIP: set_clip(); break; case TrackerDialogSettings::MODEL_CAP: set_cap(); break; case TrackerDialogSettings::MODEL_CUSTOM: set_custom(); break; default: break; } }
void AllegroGraphics::popClipArea() { Graphics::popClipArea(); if (mClipStack.empty()) { return; } const ClipRectangle& cr = mClipStack.top(); // Allegro won't let you set clip areas //that have zero width or height // so we have to check for that. if (cr.width == 0 || cr.height == 0) { mClipNull = true; } else { mClipNull = false; #if ALLEGRO_VERSION == 4 && ALLEGRO_SUB_VERSION == 0 set_clip(mTarget, cr.x, cr.y, cr.x + cr.width - 1, cr.y + cr.height - 1); #else set_clip_rect(mTarget, cr.x, cr.y, cr.x + cr.width - 1, cr.y + cr.height - 1); #endif } }
void Rectangle::rectToClip(BITMAP *dest) { set_clip(dest, x, y, x + w - 1, y + h - 1); }
Font::Font():Sprite(){ set_clip(); }
static void redraw_region (GdkRectangle *rect) { int eleft, eright, etop, ebottom; BoxType region; render_priv *priv = gport->render_priv; if (!gport->pixmap) return; if (rect != NULL) { priv->clip_rect = *rect; priv->clip = true; } else { priv->clip_rect.x = 0; priv->clip_rect.y = 0; priv->clip_rect.width = gport->width; priv->clip_rect.height = gport->height; priv->clip = false; } set_clip (priv, priv->bg_gc); set_clip (priv, priv->offlimits_gc); set_clip (priv, priv->mask_gc); set_clip (priv, priv->grid_gc); region.X1 = MIN(Px(priv->clip_rect.x), Px(priv->clip_rect.x + priv->clip_rect.width + 1)); region.Y1 = MIN(Py(priv->clip_rect.y), Py(priv->clip_rect.y + priv->clip_rect.height + 1)); region.X2 = MAX(Px(priv->clip_rect.x), Px(priv->clip_rect.x + priv->clip_rect.width + 1)); region.Y2 = MAX(Py(priv->clip_rect.y), Py(priv->clip_rect.y + priv->clip_rect.height + 1)); region.X1 = MAX (0, MIN (PCB->MaxWidth, region.X1)); region.X2 = MAX (0, MIN (PCB->MaxWidth, region.X2)); region.Y1 = MAX (0, MIN (PCB->MaxHeight, region.Y1)); region.Y2 = MAX (0, MIN (PCB->MaxHeight, region.Y2)); eleft = Vx (0); eright = Vx (PCB->MaxWidth); etop = Vy (0); ebottom = Vy (PCB->MaxHeight); if (eleft > eright) { int tmp = eleft; eleft = eright; eright = tmp; } if (etop > ebottom) { int tmp = etop; etop = ebottom; ebottom = tmp; } if (eleft > 0) gdk_draw_rectangle (gport->drawable, priv->offlimits_gc, 1, 0, 0, eleft, gport->height); else eleft = 0; if (eright < gport->width) gdk_draw_rectangle (gport->drawable, priv->offlimits_gc, 1, eright, 0, gport->width - eright, gport->height); else eright = gport->width; if (etop > 0) gdk_draw_rectangle (gport->drawable, priv->offlimits_gc, 1, eleft, 0, eright - eleft + 1, etop); else etop = 0; if (ebottom < gport->height) gdk_draw_rectangle (gport->drawable, priv->offlimits_gc, 1, eleft, ebottom, eright - eleft + 1, gport->height - ebottom); else ebottom = gport->height; gdk_draw_rectangle (gport->drawable, priv->bg_gc, 1, eleft, etop, eright - eleft + 1, ebottom - etop + 1); ghid_draw_bg_image(); hid_expose_callback (&ghid_hid, ®ion, 0); ghid_draw_grid (); /* In some cases we are called with the crosshair still off */ if (priv->attached_invalidate_depth == 0) DrawAttached (); /* In some cases we are called with the mark still off */ if (priv->mark_invalidate_depth == 0) DrawMark (); draw_lead_user (priv); priv->clip = false; /* Rest the clip for bg_gc, as it is used outside this function */ gdk_gc_set_clip_mask (priv->bg_gc, NULL); }
Level::Level(std::string file_name){ this->file_name = file_name; set_clip(); tiles = NULL; stick_master = NULL; robot_master = NULL; std::ifstream map( file_name.c_str() ); //cin row and column row = get_int_from_file(map); column = get_int_from_file(map); if (row < 0 || column < 0) { load_file_fail(map, "r & c fail"); return ; } total_tile = row * column; //set_tile(); tiles = new Level::Tile[total_tile]; for (int i = 0; i < row; i++) { for (int j = 0; j < column; j ++) { int tileType = get_int_from_file(map); if (tileType < 0) { load_file_fail(map, "tile fail"); return ; } //If the number is a valid tile number, else close if( ( tileType >= 0 ) && ( tileType < TOTAL_CLIP ) ){ tiles[i * column + j].set_tile(j * TILE_HEIGHT, i * TILE_WIDTH, TILE_WIDTH, TILE_HEIGHT, tileType); }else{ break; } } } //1, 80 120, int stick_count = get_int_from_file(map); if (stick_count > 0) { int * pos = new int[2 * stick_count]; for (int i = 0; i < stick_count; i++) { int x = get_int_from_file(map); int y = get_int_from_file(map); if (x >= 0 && y >= 0) { pos[2 * i] = x; pos[2 * i + 1] = y; }else{ load_file_fail(map, "stick fail"); delete [] pos; return ; } } stick_master = new StickMaster(this,stick_count,pos); delete [] pos; } int robot_count = get_int_from_file(map); if (robot_count > 0) { int * pos = new int[2 * robot_count]; for (int i = 0; i < robot_count; i++) { int x = get_int_from_file(map); int y = get_int_from_file(map); if (x >= 0 && y >= 0) { pos[2 * i] = x; pos[2 * i + 1] = y; }else{ load_file_fail(map, "robot fail"); delete [] pos; return ; } } robot_master = new RobotMaster(this,stick_count,pos); delete [] pos; } state = PLAYING; //now load sprite list total_sprites = get_int_from_file(map); sprite_list = new Sprite*[total_sprites]; for (int i = 0; i < total_sprites; i++) { std::string type; map>>type; int x = get_int_from_file(map); int y = get_int_from_file(map); if (x >= 0 && y >= 0) { if (type == "EXIT") { sprite_list[i] = new Exit(x,y); } }else{ load_file_fail(map, "sprite fail"); return ; } } //sprite_list[1] = new GlassDoor(5 * TILE_WIDTH+ 10, 3 * TILE_HEIGHT); //sprite_list[2] = new Book(4 * TILE_WIDTH, 5 * TILE_HEIGHT); std::string s[2] = {"Robot","likes you"}; backText = new BackGroundText(200,120,s,2); //Close the file map.close(); }
static void ghid_draw_grid (void) { static GdkPoint *points = 0; static int npoints = 0; Coord x1, y1, x2, y2, x, y; int n, i; render_priv *priv = gport->render_priv; if (!Settings.DrawGrid) return; if (Vz (PCB->Grid) < MIN_GRID_DISTANCE) return; if (!priv->grid_gc) { if (gdk_color_parse (Settings.GridColor, &gport->grid_color)) { gport->grid_color.red ^= gport->bg_color.red; gport->grid_color.green ^= gport->bg_color.green; gport->grid_color.blue ^= gport->bg_color.blue; gdk_color_alloc (gport->colormap, &gport->grid_color); } priv->grid_gc = gdk_gc_new (gport->drawable); gdk_gc_set_function (priv->grid_gc, GDK_XOR); gdk_gc_set_foreground (priv->grid_gc, &gport->grid_color); gdk_gc_set_clip_origin (priv->grid_gc, 0, 0); set_clip (priv, priv->grid_gc); } x1 = GridFit (SIDE_X (gport->view.x0), PCB->Grid, PCB->GridOffsetX); y1 = GridFit (SIDE_Y (gport->view.y0), PCB->Grid, PCB->GridOffsetY); x2 = GridFit (SIDE_X (gport->view.x0 + gport->view.width - 1), PCB->Grid, PCB->GridOffsetX); y2 = GridFit (SIDE_Y (gport->view.y0 + gport->view.height - 1), PCB->Grid, PCB->GridOffsetY); if (x1 > x2) { Coord tmp = x1; x1 = x2; x2 = tmp; } if (y1 > y2) { Coord tmp = y1; y1 = y2; y2 = tmp; } if (Vx (x1) < 0) x1 += PCB->Grid; if (Vy (y1) < 0) y1 += PCB->Grid; if (Vx (x2) >= gport->width) x2 -= PCB->Grid; if (Vy (y2) >= gport->height) y2 -= PCB->Grid; n = (x2 - x1) / PCB->Grid + 1; if (n > npoints) { npoints = n + 10; points = (GdkPoint *)realloc (points, npoints * sizeof (GdkPoint)); } n = 0; for (x = x1; x <= x2; x += PCB->Grid) { points[n].x = Vx (x); n++; } if (n == 0) return; for (y = y1; y <= y2; y += PCB->Grid) { for (i = 0; i < n; i++) points[i].y = Vy (y); gdk_draw_points (gport->drawable, priv->grid_gc, points, n); } }
int main(int argc, char **argv) { ULONG ulType = 0; ULONG ulAttr = 0; APIRET rc; int i; int iMode = MODE_NONE; rc = DosQueryHType(0, &ulType, &ulAttr); //STDIN if(!rc) { ulType &= 0xFF; if(ulType == 0 || ulType == 2) //file or pipe iMode |= MODE_IN; } rc = DosQueryHType(1, &ulType, &ulAttr); //STDOUT if(!rc) { ulType &= 0xFF; if(ulType == 0 || ulType == 2) //file or pipe iMode |= MODE_OUT; } for(i = 1; i < argc; i++) { if(argv[i][0] == '-' || argv[i][0] == '/') { switch(argv[i][1]) { case 'I': case 'i': if(argv[i][2] == '-') iMode &= ~MODE_IN; else iMode |= MODE_IN; break; case 'o': case 'O': if(argv[i][2] == '-') iMode &= ~MODE_OUT; else iMode |= MODE_OUT; break; case 'h': case 'H': case '?': usage(); return 0; } } } if(!iMode) { usage(); return 0; } rc = init_pm(); if(rc) return -1; if(iMode & MODE_IN) { char *str = ReadPipe(0); if(str) set_clip(str); delete str; } if(iMode & MODE_OUT) { char *str = get_clip(); if(str) { ULONG ulWrote = 0; rc = DosWrite(1, str, strlen(str), &ulWrote); } } done_pm(); return rc; }
int shveu_setup( SHVEU *veu, const struct ren_vid_surface *src_surface, const struct ren_vid_surface *dst_surface, shveu_rotation_t filter_control) { float scale_x, scale_y; uint32_t temp; uint32_t Y, C; const struct veu_format_info *src_info; const struct veu_format_info *dst_info; struct ren_vid_surface local_src; struct ren_vid_surface local_dst; struct ren_vid_surface *src = &local_src; struct ren_vid_surface *dst = &local_dst; void *base_addr; if (!veu || !src_surface || !dst_surface) { debug_info("ERR: Invalid input - need src and dest"); return -1; } src_info = fmt_info(src_surface->format); dst_info = fmt_info(dst_surface->format); dbg(__func__, __LINE__, "src_user", src_surface); dbg(__func__, __LINE__, "dst_user", dst_surface); /* scale factors */ scale_x = (float)dst_surface->w / src_surface->w; scale_y = (float)dst_surface->h / src_surface->h; if (!format_supported(src_surface->format) || !format_supported(dst_surface->format)) { debug_info("ERR: Invalid surface format!"); return -1; } /* Scaling limits */ if (veu_is_veu2h(veu)) { if ((scale_x > 8.0) || (scale_y > 8.0)) { debug_info("ERR: Outside scaling limits!"); return -1; } } else { if ((scale_x > 16.0) || (scale_y > 16.0)) { debug_info("ERR: Outside scaling limits!"); return -1; } } if ((scale_x < 1.0/16.0) || (scale_y < 1.0/16.0)) { debug_info("ERR: Outside scaling limits!"); return -1; } /* source - use a buffer the hardware can access */ if (get_hw_surface(veu->uiomux, veu->uiores, src, src_surface) < 0) { debug_info("ERR: src is not accessible by hardware"); return -1; } copy_surface(src, src_surface); /* destination - use a buffer the hardware can access */ if (get_hw_surface(veu->uiomux, veu->uiores, dst, dst_surface) < 0) { debug_info("ERR: dest is not accessible by hardware"); return -1; } uiomux_lock (veu->uiomux, veu->uiores); base_addr = veu->uio_mmio.iomem; /* Keep track of the requested surfaces */ veu->src_user = *src_surface; veu->dst_user = *dst_surface; /* Keep track of the actual surfaces used */ veu->src_hw = local_src; veu->dst_hw = local_dst; /* Software reset */ if (read_reg(base_addr, VESTR) & 0x1) write_reg(base_addr, 0, VESTR); while (read_reg(base_addr, VESTR) & 1) ; /* Clear VEU end interrupt flag */ write_reg(base_addr, 0, VEVTR); /* VEU Module reset */ write_reg(base_addr, 0x100, VBSRR); /* default to not using bundle mode */ write_reg(base_addr, 0, VBSSR); /* source */ Y = uiomux_all_virt_to_phys(src->py); C = uiomux_all_virt_to_phys(src->pc); write_reg(base_addr, Y, VSAYR); write_reg(base_addr, C, VSACR); write_reg(base_addr, (src->h << 16) | src->w, VESSR); write_reg(base_addr, size_y(src->format, src->pitch), VESWR); /* destination */ Y = uiomux_all_virt_to_phys(dst->py); C = uiomux_all_virt_to_phys(dst->pc); if (filter_control & 0xFF) { if ((filter_control & 0xFF) == 0x10) { /* Horizontal Mirror (A) */ Y += size_y(dst->format, src->w); C += size_y(dst->format, src->w); } else if ((filter_control & 0xFF) == 0x20) { /* Vertical Mirror (B) */ Y += size_y(dst->format, (src->h-1) * dst->pitch); C += size_c(dst->format, (src->h-2) * dst->pitch); } else if ((filter_control & 0xFF) == 0x30) { /* Rotate 180 (C) */ Y += size_y(dst->format, src->w); C += size_y(dst->format, src->w); Y += size_y(dst->format, src->h * dst->pitch); C += size_c(dst->format, src->h * dst->pitch); } else if ((filter_control & 0xFF) == 1) { /* Rotate 90 (D) */ Y += size_y(dst->format, src->h-16); C += size_y(dst->format, src->h-16); } else if ((filter_control & 0xFF) == 2) { /* Rotate 270 (E) */ Y += size_y(dst->format, (src->w-16) * dst->pitch); C += size_c(dst->format, (src->w-16) * dst->pitch); } else if ((filter_control & 0xFF) == 0x11) { /* Rotate 90 & Mirror Horizontal (F) */ /* Nothing to do */ } else if ((filter_control & 0xFF) == 0x21) { /* Rotate 90 & Mirror Vertical (G) */ Y += size_y(dst->format, src->h-16); C += size_y(dst->format, src->h-16); Y += size_y(dst->format, (src->w-16) * dst->pitch); C += size_c(dst->format, (src->w-16) * dst->pitch); } } write_reg(base_addr, Y, VDAYR); write_reg(base_addr, C, VDACR); write_reg(base_addr, size_y(dst->format, dst->pitch), VEDWR); /* byte/word swapping */ temp = 0; #ifdef __LITTLE_ENDIAN__ temp |= src_info->vswpr; temp |= dst_info->vswpr << 4; #endif write_reg(base_addr, temp, VSWPR); /* transform control */ temp = src_info->vtrcr_src; temp |= dst_info->vtrcr_dst; if (is_rgb(src_surface->format)) temp |= VTRCR_RY_SRC_RGB; if (different_colorspace(src_surface->format, dst_surface->format)) temp |= VTRCR_TE_BIT_SET; if (veu->bt709) temp |= VTRCR_BT709; if (veu->full_range) temp |= VTRCR_FULL_COLOR_CONV; write_reg(base_addr, temp, VTRCR); if (veu_is_veu2h(veu)) { /* color conversion matrix */ write_reg(base_addr, 0x0cc5, VMCR00); write_reg(base_addr, 0x0950, VMCR01); write_reg(base_addr, 0x0000, VMCR02); write_reg(base_addr, 0x397f, VMCR10); write_reg(base_addr, 0x0950, VMCR11); write_reg(base_addr, 0x3cdd, VMCR12); write_reg(base_addr, 0x0000, VMCR20); write_reg(base_addr, 0x0950, VMCR21); write_reg(base_addr, 0x1023, VMCR22); write_reg(base_addr, 0x00800010, VCOFFR); } /* Clipping */ write_reg(base_addr, 0, VRFSR); set_clip(base_addr, 0, dst->w); set_clip(base_addr, 1, dst->h); /* Scaling */ write_reg(base_addr, 0, VRFCR); if (!(filter_control & 0x3)) { /* Not a rotate operation */ set_scale(veu, base_addr, 0, src->w, dst->w, 0); set_scale(veu, base_addr, 1, src->h, dst->h, 0); } /* Filter control - directly pass user arg to register */ write_reg(base_addr, filter_control, VFMCR); return 0; fail: uiomux_unlock(veu->uiomux, veu->uiores); return -1; }
// draws everything (output) void cSteam::draw() { if (game.state == GAME_MENU) { // Menu Menu window is always drawn... WindowDraw(bmp_screen, 16,360,120,100, "Main Menu"); // Main Menu / main if (iMainState == STATE_MAIN_MENU) { // Draw menu items and react upon them DrawMenuItems(36, 390, 0, true); } if (iMainState == STATE_MAIN_OPTIONS) { // Draw main options buttons, but do not use them DrawMenuItems(36, 390, 0, false); // draw options window WindowDraw(bmp_screen, 150, 60, 400,400, "Options"); DrawMenuItems(170, 90, 1, true); // devide bar (vertically) line(bmp_screen, 240, 90, 240, 420, makecol(40,46,34)); line(bmp_screen, 241, 90, 241, 420, makecol(136,145,128)); } // Start a new game if (iMainState == STATE_MAIN_NEWGAME) { iMainState = STATE_NONE; iSubState = STATE_NONE; game.state = GAME_GAME; } // Start editor if (iMainState == STATE_MAIN_EDITOR) { iMainState = STATE_EDITOR; iSubState = STATE_NONE; game.state = GAME_EDITOR; } // get out the game here if (iMainState == STATE_MAIN_EXIT) game.playing = false; } // In the game if (game.state == GAME_GAME) { if (iMainState == STATE_INGAME_OPTIONS) { WindowDraw(bmp_screen, 160,120,320,240, "In-game options"); DrawMenuItems(180, 150, 2, true); } if (iMainState == STATE_MAIN_MENU) game.state = GAME_MENU; } // In the editor if (game.state == GAME_EDITOR) { if (iMainState == STATE_MAIN_MENU) game.state = GAME_MENU; // Editor with options WindowDraw(bmp_screen, 0, 300, 160, 180, "Editor"); // Minimap window WindowDraw(bmp_screen, 0, 0, 160, 140, "Minimap"); if (iMainState == STATE_EDITOR) { DrawMenuItems(20, 330, 3, true); // depending on sub-state: if (iSubState == STATE_EDITOR_SUB_TEXTURES) { WindowDraw(bmp_screen, 0, 141, 160, 158, "Textures"); bool bBlock; // draw a window of the current texture + 2 buttons (next/prev) bool bNext = ButtonDraw(bmp_screen, 126, 274, 19, 16, ">>"); bool bPrev = ButtonDraw(bmp_screen, 16, 274, 19, 16, "<<"); bool bUp = ButtonDraw(bmp_screen, 140, 187, 12, 20, "+"); bool bDown = ButtonDraw(bmp_screen, 140, 227, 12, 40, "-"); // Blocked or not? if (game.bBlockTextures) bBlock = ButtonDraw(bmp_screen, 140, 167, 12, 20, "U"); else bBlock = ButtonDraw(bmp_screen, 140, 167, 12, 20, "B"); if (bBlock) { if (game.bBlockTextures) game.bBlockTextures=false; else game.bBlockTextures=true; } // ---- // BUTTON: Switch from GROUP to SINGLE and back bool bGroupPressed = false; if (game.bShowGroupTextures == false) bGroupPressed = ButtonDraw(bmp_screen, 46, 274, 68, 16, "< GROUP >"); else bGroupPressed = ButtonDraw(bmp_screen, 46, 274, 68, 16, "< SINGLE >"); if (bGroupPressed) { if (game.bShowGroupTextures) game.bShowGroupTextures = false; else game.bShowGroupTextures = true; } // ---- // next if (bNext) { if (game.bShowGroupTextures) game.iGroupNumber++; else game.iSingleNumber++; } // go back if (bPrev) { if (game.bShowGroupTextures) game.iGroupNumber--; else game.iSingleNumber--; if (game.iGroupNumber < 0) game.iGroupNumber = 0; if (game.iSingleNumber < 0) game.iSingleNumber = 0; } // Upper and lower the brightness if (bUp) { game.iBrightness+=10; if (game.iBrightness > 255) game.iBrightness = 255; } if (bDown) { game.iBrightness -=10; if (game.iBrightness < 10) game.iBrightness = 10; } // draw something black in the window rectfill(bmp_screen, 10, 165, 130, 260, makecol(0,0,0)); set_clip(bmp_screen, 10, 165, 130, 260); set_trans_blender(255, 255, 255, game.iBrightness); // clip the entire texture group / or single texture! if (game.bShowGroupTextures) { // draw the entire thingy int dx=0; int dy=0; for (int i=0; i < 64; i++) { if (game.GROUP_Textures[game.iGroupNumber].iTextures[i] > -1) { // now create tile at the correct spot at the map: draw_trans_sprite(bmp_screen, game.DATA_Textures[game.GROUP_Textures[game.iGroupNumber].iTextures[i]].bmp, 11+(dx*32), 166+(dy*32)); dx++; if (dx >= game.GROUP_Textures[game.iGroupNumber].iWidth) { dx=0; dy++; } } } } else { // its a 32x32 square if (game.DATA_Textures[game.iSingleNumber].bmp != NULL) draw_trans_sprite(bmp_screen, game.DATA_Textures[game.iSingleNumber].bmp, 60, 180); } set_clip(bmp_screen, 0, 0, game.screen_x, game.screen_y); // When the mouse is on the editing field, and a mouse button is pressed // add the tiles (group or single) if (mouse_x > 160) { if (game.MOUSE_PRESSED_LEFT()) { // calculate x and y int x=(mouse_x-160)/32; int y=mouse_y/32; x+=(map.lScrollX/32); y+=(map.lScrollY/32); if (game.bShowGroupTextures) map.create_tile_group(x,y,game.iGroupNumber, game.iBrightness, game.bBlockTextures); else map.create_tile(x,y,game.iSingleNumber, game.iBrightness, game.bBlockTextures); } else { int ddx, ddy; ddx=mouse_x/32; ddy=mouse_y/32; ddx*=32; ddy*=32; // Increase (because editor = 160 (=5x32) + 5 pixels = 165) ddx+=5; // Make sure scrolling is taken into account to! ddx-= (map.lScrollX)-((int)(map.lScrollX/32)*32); ddy-= (map.lScrollY)-((int)(map.lScrollY/32)*32); /* ddx+= (map.lScrollX-(map.lScrollX/32)); ddy+= (map.lScrollY-(map.lScrollY/32));*/ if (game.bShowGroupTextures) { int dx=0; int dy=0; if (game.GROUP_Textures[game.iGroupNumber].iWidth > -1) { rectfill(bmp_screen, ddx+2, ddy+2, ddx+2+game.GROUP_Textures[game.iGroupNumber].iWidth*32, ddy+2+game.GROUP_Textures[game.iGroupNumber].iHeight*32, makecol(0,0,0)); } for (int i=0; i < 64; i++) { if (game.GROUP_Textures[game.iGroupNumber].iTextures[i] > -1) { // now create tile at the correct spot at the map: draw_trans_sprite(bmp_screen, game.DATA_Textures[game.GROUP_Textures[game.iGroupNumber].iTextures[i]].bmp, ddx+(dx*32), ddy+(dy*32)); dx++; if (dx >= game.GROUP_Textures[game.iGroupNumber].iWidth) { dx=0; dy++; } } } } else { if (game.DATA_Textures[game.iSingleNumber].bmp != NULL) { rectfill(bmp_screen, ddx+2, ddy+2, ddx+34, ddy+34, makecol(0,0,0)); draw_trans_sprite(bmp_screen, game.DATA_Textures[game.iSingleNumber].bmp, ddx, ddy); } } } } } // substate if (iSubState == STATE_EDITOR_SUB_LIGHT) { WindowDraw(bmp_screen, 0, 141, 160, 158, "Light/Shadows"); // draw a window of the current texture + 2 buttons (next/prev) bool bNext = ButtonDraw(bmp_screen, 126, 274, 19, 16, ">>"); bool bPrev = ButtonDraw(bmp_screen, 16, 274, 19, 16, "<<"); bool bUp = ButtonDraw(bmp_screen, 140, 167, 12, 40, "+"); bool bDown = ButtonDraw(bmp_screen, 140, 227, 12, 40, "-"); // next if (bNext) if (shadows[game.iShadowNumber].type != DAT_END) game.iShadowNumber++; // go back if (bPrev || shadows[game.iShadowNumber].type != DAT_BITMAP) game.iShadowNumber--; if (game.iShadowNumber < 0) game.iShadowNumber = 0; // Upper and lower the brightness if (bUp) { game.iBrightness+=10; if (game.iBrightness > 255) game.iBrightness = 255; } if (bDown) { game.iBrightness -=10; if (game.iBrightness < 10) game.iBrightness = 10; } // draw something black in the window rectfill(bmp_screen, 10, 165, 130, 260, makecol(192,192,192)); set_clip(bmp_screen, 10, 165, 130, 260); // fill in set_trans_blender(255, 255, 255, game.iBrightness); draw_trans_sprite(bmp_screen, (BITMAP *)shadows[game.iShadowNumber].dat, 60, 180); // set clip back set_clip(bmp_screen, 0, 0 , game.screen_x, game.screen_y); if (mouse_x > 160) { if (game.MOUSE_PRESSED_LEFT()) { // calculate x and y int x=(mouse_x-160)/32; int y=mouse_y/32; x+=(map.lScrollX/32); y+=(map.lScrollY/32); map.shadow_map[x][y] = game.iShadowNumber; } else { int ddx, ddy; ddx=mouse_x/32; ddy=mouse_y/32; ddx*=32; ddy*=32; // Increase (because editor = 160 (=5x32) + 5 pixels = 165) ddx+=5; // Make sure scrolling is taken into account to! ddx-= (map.lScrollX)-((int)(map.lScrollX/32)*32); ddy-= (map.lScrollY)-((int)(map.lScrollY/32)*32); rectfill(bmp_screen, ddx+2, ddy+2, ddx+34, ddy+34, makecol(0,0,0)); draw_trans_sprite(bmp_screen, (BITMAP *)shadows[game.iShadowNumber].dat, ddx, ddy); } } } } } }
VideoStream::VideoStream(RedClient& client, Canvas& canvas, DisplayChannel& channel, uint32_t codec_type, bool top_down, uint32_t stream_width, uint32_t stream_height, uint32_t src_width, uint32_t src_height, SpiceRect* dest, int clip_type, uint32_t num_clip_rects, SpiceRect* clip_rects) : _client (client) , _canvas (canvas) , _channel (channel) , _mjpeg_decoder (NULL) , _stream_width (stream_width) , _stream_height (stream_height) , _stride (stream_width * sizeof(uint32_t)) , _top_down (top_down) , _dest (*dest) , _clip (NULL) , _frames_head (0) , _frames_tail (0) , _kill_mark (0) , _uncompressed_data (NULL) , _update_mark (0) , _update_time (0) , next (NULL) { memset(_frames, 0, sizeof(_frames)); region_init(&_clip_region); if (codec_type != SPICE_VIDEO_CODEC_TYPE_MJPEG) { THROW("invalid video codec type %u", codec_type); } try { #ifdef WIN32 if (!create_bitmap(&_dc, &_prev_bitmap, &_uncompressed_data, &_stride, stream_width, stream_height)) { THROW("create_bitmap failed"); } #else _uncompressed_data = new uint8_t[_stride * stream_height]; #endif _pixmap.width = src_width; _pixmap.height = src_height; _mjpeg_decoder = new MJpegDecoder(stream_width, stream_height, _stride, _uncompressed_data, channel.get_peer_major() == 1); #ifdef WIN32 SetViewportOrgEx(_dc, 0, stream_height - src_height, NULL); #endif if (_top_down) { _pixmap.data = _uncompressed_data; _pixmap.stride = _stride; } else { _pixmap.data = _uncompressed_data + _stride * (src_height - 1); _pixmap.stride = -_stride; } set_clip(clip_type, num_clip_rects, clip_rects); } catch (...) { if (_mjpeg_decoder) { delete _mjpeg_decoder; _mjpeg_decoder = NULL; } release_all_bufs(); throw; } }
void Graphics::SetClip(const Rect &rc) { set_clip(_alBitmap, rc.Left, rc.Top, rc.Right, rc.Bottom); }