📄 video.h
字号:
* Draws the bitmap * * Default implementation: uses blit, stores a backbuffer */ void (*sprite_show)(struct sprite *spr); /* Optional * Undraws the bitmap * * Default implementation: blits the backbuffer back onto the screen */ void (*sprite_hide)(struct sprite *spr); /* Optional * Repositions a sprite after coordinate change * * Default implementation: redraws sprite stack as necessary, * uses sprite_show and sprite_hide */ void (*sprite_update)(struct sprite *spr); /* Optional * Shows/hides all sprites in preparation for modifications * * Default implementation: traverses list of sprites, calls show and hide */ void (*sprite_hideall)(void); void (*sprite_showall)(void); /* Optional * Removes any necessary sprites from a given area to protect it from * screen updates. If applicable, only hides sprites starting with * and above the specified sprite. * * Default implementation: Calls sprite_hide for sprites in the area */ void (*sprite_protectarea)(struct quad *in,struct sprite *from); /******************************************** Text/fonts */ /* Reccomended when using BDF fonts * Used for character data. Blits 1bpp data from * chardat to the screen, filling '1' bits with the * color 'col'. If lines > 0, every 'lines' lines * the image is left-shifted one pixel, to simulate * italics. * * Although in the future arbitrary rotation may be supported, currently * 'angle' must be a PG_DIR_* constant (measured in degrees) * * Default implementation: pixel(). Need I say more? */ void (*charblit)(hwrbitmap dest, u8 *chardat, s16 x, s16 y, s16 w, s16 h, s16 lines, s16 angle, hwrcolor c, struct quad *clip, s16 lgop, int char_pitch);#ifdef CONFIG_FONTENGINE_FREETYPE /* Reccomended when using antialiased fonts * Alpha blend the given color to the destination using * the supplied bytes as alpha mask. * Origin, rotation, and clipping are handled just like charblit above. * If gammatable is not NULL, use it for gamma correction. * * Default implementation: pixel */ void (*alpha_charblit)(hwrbitmap dest, u8 *chardat, s16 x, s16 y, s16 w, s16 h, int char_pitch, u8 *gammatable, s16 angle, hwrcolor c, struct quad *clip, s16 lgop);#endif};/* Currently in-use video driver */extern struct vidlib *vid;/* Optional wrapper around that driver that provides some transformation */extern struct vidlib *vidwrap;/* This macro is used to call a video function */#define VID(f) (*vidwrap->f)/* Trig (sin*256 from 0 to 90 degrees) */extern unsigned char trigtab[];/* Unloads previous driver, sets up a new driver and initializes it. This is for changing the driver, and optionally changing the mode. If you just want to change the mode use vid->setmode*/g_error load_vidlib(g_error (*regfunc)(struct vidlib *v), s16 xres,s16 yres,s16 bpp,u32 flags);/* List of installed video drivers */struct vidinfo { const u8 *name; g_error (*regfunc)(struct vidlib *v);};extern struct vidinfo videodrivers[];g_error (*find_videodriver(const u8 *name))(struct vidlib *v);/* Set the video mode using the current driver. This is the implementation * of the setmode client request */g_error video_setmode(u16 xres,u16 yres,u16 bpp,u16 flagmode,u32 flags);/* Sprite helper functions */g_error new_sprite(struct sprite **ps,struct divtree *dt,s16 w,s16 h);void free_sprite(struct sprite *s);/* All sprites onscreen, sorted from back to front. */extern struct sprite *spritelist;/* Update region union/realize for a divtree */void add_updarea(struct divtree *dt, s16 x,s16 y,s16 w,s16 h);void realize_updareas(struct divtree *dt);/* Iterator functions to convert between pgcolor arrays and hwrcolor arrays */g_error array_pgtohwr(u32 **array);g_error array_hwrtopg(u32 **array);/* Convert a array to a palette */g_error array_palettize(handle h, int owner);/* Generic functions from the default VBL. Drivers will usually choose to * only process the most commonly used options, to save code space. When * an unsupported LGOP or other parameter is used, the corresponding * defaultvbl function should be called */void emulate_dos(void);void def_update(hwrbitmap dest,s16 x, s16 y, s16 w, s16 h);g_error def_setmode(s16 xres,s16 yres,s16 bpp,u32 flags);hwrcolor def_color_pgtohwr(pgcolor c);pgcolor def_color_hwrtopg(hwrcolor c);void def_pixel(hwrbitmap dest, s16 x, s16 y, hwrcolor c, s16 lgop);hwrcolor def_getpixel(hwrbitmap src, s16 x, s16 y);void def_slab(hwrbitmap dest, s16 x, s16 y, s16 w, hwrcolor c, s16 lgop);void def_bar(hwrbitmap dest, s16 x,s16 y,s16 h,hwrcolor c, s16 lgop);void def_line(hwrbitmap dest, s16 x1,s16 y1,s16 x2,s16 y2, hwrcolor c, s16 lgop);void def_rect(hwrbitmap dest, s16 x,s16 y,s16 w,s16 h,hwrcolor c, s16 lgop);void def_gradient(hwrbitmap dest, s16 x,s16 y,s16 w,s16 h,s16 angle, pgcolor c1, pgcolor c2, s16 lgop);void def_blit(hwrbitmap dest, s16 x,s16 y,s16 w,s16 h, hwrbitmap src, s16 src_x, s16 src_y, s16 lgop);void def_multiblit(hwrbitmap dest, s16 x, s16 y, s16 w, s16 h, hwrbitmap src, s16 sx, s16 sy, s16 sw, s16 sh, s16 xo, s16 yo, s16 lgop);void def_charblit(hwrbitmap dest, u8 *chardat, s16 x, s16 y, s16 w, s16 h, s16 lines, s16 angle, hwrcolor c, struct quad *clip, s16 lgop, int char_pitch);void def_alpha_charblit(hwrbitmap dest, u8 *chardat, s16 x, s16 y, s16 w, s16 h, int char_pitch, u8 *gammatable, s16 angle, hwrcolor c, struct quad *clip, s16 lgop);void def_scrollblit(hwrbitmap dest, s16 x,s16 y,s16 w,s16 h, hwrbitmap src, s16 src_x, s16 src_y, s16 lgop);void def_rotateblit(hwrbitmap dest, s16 dest_x, s16 dest_y, hwrbitmap src, s16 src_x, s16 src_y, s16 src_w, s16 src_h, struct quad *clip, s16 angle, s16 lgop);void def_sprite_protectarea(struct quad *in,struct sprite *from);g_error def_bitmap_loadxbm(hwrbitmap *bmp,const u8 *data, s16 w, s16 h, hwrcolor fg, hwrcolor bg);struct fontglyph const *def_font_getglyph(struct fontdesc *fd, int ch);g_error def_bitmap_getsize(hwrbitmap bmp,s16 *w,s16 *h);g_error def_bitmap_getshm(hwrbitmap bmp, u32 uid, struct pgshmbitmap *shm);void def_coord_keyrotate(int *k);void rotate90_coord_keyrotate(int *k);void rotate180_coord_keyrotate(int *k);void rotate270_coord_keyrotate(int *k);void def_coord_physicalize(int *x, int *y);void rotate90_coord_physicalize(int *x, int *y);void rotate180_coord_physicalize(int *x, int *y);void rotate270_coord_physicalize(int *x, int *y);void def_coord_logicalize(int *x, int *y);void rotate90_coord_logicalize(int *x, int *y);void rotate180_coord_logicalize(int *x, int *y);void rotate270_coord_logicalize(int *x, int *y);void linear32_pixel(hwrbitmap dest, s16 x, s16 y, hwrcolor c, s16 lgop);hwrcolor linear32_getpixel(hwrbitmap src, s16 x, s16 y);void linear32_slab(hwrbitmap dest, s16 x, s16 y, s16 w, hwrcolor c, s16 lgop);void linear32_bar(hwrbitmap dest, s16 x,s16 y,s16 h,hwrcolor c, s16 lgop);void linear32_rect(hwrbitmap dest, s16 x,s16 y,s16 w,s16 h,hwrcolor c, s16 lgop);void linear32_blit(hwrbitmap dest, s16 x,s16 y,s16 w,s16 h, hwrbitmap src, s16 src_x, s16 src_y, s16 lgop);void def_ellipse(hwrbitmap dest, s16 x, s16 y, s16 w, s16 h, hwrcolor c, s16 lgop); void def_fellipse(hwrbitmap dest, s16 x, s16 y, s16 w, s16 h, hwrcolor c, s16 lgop); void def_fpolygon(hwrbitmap dest, s32* array, s16 xoff, s16 yoff , hwrcolor c, s16 lgop);g_error def_bitmap_load(hwrbitmap *bmp,const u8 *data,u32 datalen);g_error def_bitmap_new(hwrbitmap *bmp, s16 w,s16 h,u16 bpp);g_error def_bitmap_new_adv(hwrbitmap * b, s16 w, s16 h, u16 bpp, u32 * clut, u32 clutsize); /* Added by kdhong */void def_bitmap_free(hwrbitmap bmp);void def_sprite_show(struct sprite *spr);void def_sprite_hide(struct sprite *spr);void def_sprite_update(struct sprite *spr);void def_sprite_hideall(void);void def_sprite_showall(void);g_error def_bitmap_modeconvert(hwrbitmap *bmp);g_error def_bitmap_modeunconvert(hwrbitmap *bmp);g_error def_bitmap_get_groprender(hwrbitmap bmp, struct groprender **rend);void def_blur(hwrbitmap dest, s16 x, s16 y, s16 w, s16 h, s16 radius);#ifdef CONFIG_DITHERg_error def_dither_start(hwrdither *d, hwrbitmap dest, int vflip, int x, int y, int w, int h);void def_dither_store(hwrdither d, pgcolor pixel, s16 lgop);void def_dither_finish(hwrdither d);#endif/**************************************** Window flags */#define PG_WINDOW_UNMANAGED (1<<0) /* This window should not be decorated or managed by the host GUI */#define PG_WINDOW_GRAB (1<<1) /* This window grabs all user input while it exists */#define PG_WINDOW_BACKGROUND (1<<2) /* This window stays behind all others and takes the entire screen *//**************************************** Registration functions for video drivers */g_error sdlfb_regfunc(struct vidlib *v);g_error sdlgl_regfunc(struct vidlib *v);g_error svgagl_regfunc(struct vidlib *v);g_error svgafb_regfunc(struct vidlib *v);g_error chipslice_video_regfunc(struct vidlib *v);g_error ez328_regfunc(struct vidlib *v);g_error ez328vga_regfunc(struct vidlib *v);g_error ncurses_regfunc(struct vidlib *v);g_error null_regfunc(struct vidlib *v);g_error nullfb_regfunc(struct vidlib *v);g_error fbdev_regfunc(struct vidlib *v);g_error serial40x4_regfunc(struct vidlib *v);g_error scrshot_regfunc(struct vidlib *v);g_error s1d13806_regfunc(struct vidlib *v);g_error sed133x_regfunc(struct vidlib *v);g_error x11_regfunc(struct vidlib *v);g_error mgl2fb_regfunc(struct vidlib *v);/* Added by kdhong */g_error ibmstbdev_regfunc(struct vidlib *v);/***************************************** Registration functions for Video Base Libraries */void setvbl_default(struct vidlib *vid);void setvbl_linear1(struct vidlib *vid);void setvbl_linear2(struct vidlib *vid);void setvbl_linear4(struct vidlib *vid);void setvbl_linear8(struct vidlib *vid);void setvbl_linear16(struct vidlib *vid);void setvbl_linear24(struct vidlib *vid);void setvbl_linear32(struct vidlib *vid);void setvbl_slowvbl(struct vidlib *vid);/***************************************** Registration functions for video wrapper libraries */void vidwrap_rotate90(struct vidlib *vid);void vidwrap_rotate180(struct vidlib *vid);void vidwrap_rotate270(struct vidlib *vid);/***************************************** Bitmap format functions */extern struct bitformat bitmap_formats[];bool pnm_detect(const u8 *data, u32 datalen);g_error pnm_load(hwrbitmap *bmp, const u8 *data, u32 datalen);bool jpeg_detect(const u8 *data, u32 datalen);g_error jpeg_load(hwrbitmap *bmp, const u8 *data, u32 datalen);bool bmp_detect(const u8 *data, u32 datalen);g_error bmp_load(hwrbitmap *bmp, const u8 *data, u32 datalen);bool png_detect(const u8 *data, u32 datalen);g_error png_load(hwrbitmap *bmp, const u8 *data, u32 datalen);bool gif_detect(const u8 *data, u32 datalen);g_error gif_load(hwrbitmap *bmp, const u8 *data, u32 datalen);/* Rotate an existing bitmap by the given angle, reallocating it. * Only supports angles 0,90,180,270 */g_error bitmap_rotate(hwrbitmap *pbit, s16 angle);/* Run the given function on _all_ bitmaps */g_error bitmap_iterate(handle_iterator iterator, void *extra);/* Rotate _all_ loaded bitmaps by the given angle */g_error bitmap_rotate_all(s16 angle);/***************************************** Initialization */g_error video_init(void);void video_shutdown(void);/***************************************** Debugging */void videotest_run(s16 number);void videotest_help(void);void videotest_benchmark(void);/***************************************** Send a driver message (to all loaded drivers) */void drivermessage(u32 message, u32 param, u32 *ret);/***************************************** Palettes */#ifdef CONFIG_PAL8_CUSTOMextern pgcolor palette8_custom[256];g_error load_custom_palette(const char *name);#endif/* Default heuristics for reporting color information in SHM bitmaps */void def_shm_colorspace(int bpp, int alpha, struct pgshmbitmap *shm);#endif /* __H_VIDEO *//* The End */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -