📄 video.h
字号:
* In a rootless driver, set the window flags (PG_WINDOW_* constants) */ void (*window_set_flags)(hwrbitmap window, int flags); /* Optional * Routines to get/set position and size for the window * * Default implementation: set does nothing, get returns logical video mode */ void (*window_set_position)(hwrbitmap window, s16 x, s16 y); void (*window_set_size)(hwrbitmap window, s16 w, s16 h); void (*window_get_position)(hwrbitmap window, s16 *x, s16 *y); void (*window_get_size)(hwrbitmap window, s16 *w, s16 *h); /* Optional * Return nonzero if the driver is rootless. This indicates to the * rendering engine that it needs to update all divtrees, not just the topmost one. * * Default implementation: return 0 */ int (*is_rootless)(void); /******************************************** Hooks */ /* These hooks let picogui video drivers take over functionality * normally handled by other parts of picogui. */ /* Optional * Called at the beginning of grop_render, before anything has been set up. * Abort setup if this returns nonzero */ int (*grop_render_presetup_hook)(struct divnode **div, struct gropnode ***listp, struct groprender *rend); /* Optional * Called at the beginning of grop_render, but after setup * Abort grop_render if this returns nonzero */ int (*grop_render_postsetup_hook)(struct divnode **div, struct gropnode ***listp, struct groprender *rend); /* Optional * Called at the end of grop_render */ void (*grop_render_end_hook)(struct divnode **div, struct gropnode ***listp, struct groprender *rend); /* Optional * Called before gropnode transformation but after flag testing. * Return nonzero to skip the normal gropnode transformation and clipping. */ int (*grop_render_node_hook)(struct divnode **div, struct gropnode ***listp, struct groprender *rend, struct gropnode *node); /* Optional * Called for any picogui update(). Return nonzero to abort the update */ int (*update_hook)(void); /* Optional * This lets the video driver add its own gropnodes. It's called whenever * gropnode_draw finds an unknown grop type. */ void (*grop_handler)(struct groprender *r, struct gropnode *n); /******************************************** Colors */ /* Optional * Convert a color to/from the driver's native format * * Default implementation: * < 8bpp: Assumes grayscale * 8bpp: 2-3-3 color * 16bpp: 5-6-5 color * >= 24bpp: No change */ hwrcolor (*color_pgtohwr)(pgcolor c); pgcolor (*color_hwrtopg)(hwrcolor c); /******************************************** Primitives */ /* Required * Draw a pixel to the screen, in the hardware's color format */ void (*pixel)(hwrbitmap dest, s16 x, s16 y, hwrcolor c, s16 lgop); /* Required * Get a pixel, in hwrcolor format */ hwrcolor (*getpixel)(hwrbitmap src, s16 x, s16 y); /* Very Recommended * draws a continuous horizontal run of pixels * * Default implementation: draws a 1 pixel high rectangle */ void (*slab)(hwrbitmap dest, s16 x, s16 y, s16 w, hwrcolor c, s16 lgop); /* Optional * draws a vertical bar of pixels (a sideways slab) * * Default implementation: draws a 1 pixel wide rectangle */ void (*bar)(hwrbitmap dest, s16 x,s16 y,s16 h,hwrcolor c, s16 lgop); /* Optional * draws an arbitrary line between 2 points * * Default implementation: bresenham algrorithm and * many calls to pixel() */ void (*line)(hwrbitmap dest, s16 x1,s16 y1,s16 x2,s16 y2, hwrcolor c, s16 lgop); /* Optional * fills a rectangular area with a color * * Default implementation: Looped calls to slab() */ void (*rect)(hwrbitmap dest, s16 x,s16 y,s16 w,s16 h,hwrcolor c, s16 lgop); /* Optional * fills a rectangular area with a linear gradient * of an arbitrary angle (in degrees), between two colors. * If angle==0, c1 is at the left and c2 is at the * right. The gradient rotates clockwise as angle * increases. * * Default implementation: interpolation algorithm, pixel() */ void (*gradient)(hwrbitmap dest, s16 x,s16 y,s16 w,s16 h,s16 angle, pgcolor c1, pgcolor c2, s16 lgop); /* Very Reccomended * Blits a bitmap to screen, optionally using lgop. * If the source and destination rectangles overlap, the result is undefined. * This does _not_ tile or stretch bitmaps, * so don't go past the edge of the source bitmap. * * Default implementation: pixel! */ void (*blit)(hwrbitmap dest, s16 x,s16 y,s16 w,s16 h, hwrbitmap src, s16 src_x, s16 src_y, s16 lgop); /* Reccomended * A version of blit() with the restriction on overlapping source * and destination rectangles removed * Also note that this does _not_ need to support tiling, and * it is almost always called with PG_LGOP_NONE * * Default implementation: Multiple calls to blit() * (can be very slow in some directions) */ void (*scrollblit)(hwrbitmap dest, s16 x,s16 y,s16 w,s16 h, hwrbitmap src, s16 src_x, s16 src_y, s16 lgop); /* Reccomended * Blits a bitmap or a section of a bitmap, wrapping around the edges of the * source bitmap if necessary to cover the destination area. * If the source and destination rectangles overlap, the result is undefined. * x,y,w,h is the destination rectangle, sx,sy,sw,sh is the source rectangle, * xo,yo is the amount of the first tile to skip in each axis. This function * replaces the old tiling functionality of blit() and tileblit() * * Default implementation: Many calls to blit()! */ void (*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); /* Reccomended on platforms that are usually rotated * Copy a source rectangle (in the source bitmap's coordinates) * rotated to a new angle. The source x,y is always anchored at * the destination x,y and rotation is performed anticlockwise about * this point. This function is also responsible for clipping the rotated * bitmap into that rectangle. On most platforms this will only support * rotating by multiples of 90 degrees, but it may support arbitrary * rotation as well. Note that this function is _not_ responsible * for clipping the source rectangle, but since it is in normal * bitmap coordinates it shouldn't be hard for the caller to do that * if necessary. * * Default implementation: pixel() */ void (*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 (*ellipse) (hwrbitmap dest, s16 x, s16 y, s16 w, s16 h, hwrcolor c, s16 lgop); void (*fellipse) (hwrbitmap dest, s16 x, s16 y, s16 w, s16 h, hwrcolor c, s16 lgop); void (*fpolygon) (hwrbitmap dest, s32* array, s16 xoff, s16 yoff , hwrcolor c, s16 lgop); /* Optional * Yep, it's a blur... */ void (*blur) (hwrbitmap dest, s16 x, s16 y, s16 w, s16 h, s16 radius); /******************************************** Bitmaps */ /* These functions all use the stdbitmap structure. If your driver needs a different bitmap format, implement all these functions. (also implement set/get pixel above) If not, you should be ok leaving these with the defaults. */ /* Optional * Allocates a new bitmap, and loads the * formatted bitmap data into it * * Default implementation: transcribes pixels with vid->pixel() */#ifdef CONFIG_FORMAT_XBM /* XBM 1-bit data (used internally) */ g_error (*bitmap_loadxbm)(hwrbitmap *bmp,const u8 *data, s16 w, s16 h, hwrcolor fg,hwrcolor bg);#endif /* Load a bitmap, detecting the appropriate format */ g_error (*bitmap_load)(hwrbitmap *bmp,const u8 *data,u32 datalen); /* Optional * Allocates an empty bitmap * * Default implementation: g_malloc, of course! */ g_error (*bitmap_new)(hwrbitmap *bmp, s16 w,s16 h,u16 bpp); /* Optional * Added by kdhong - For Making Device Incompatible Bitmap.... * Allocates an empty bitmap * * Default implementation: g_malloc, of course! */ g_error (*bitmap_new_adv)(hwrbitmap *bmp, s16 w,s16 h,u16 bpp, u32* clut, u32 clutsize); g_error (*bitmap_setclut)(hwrbitmap *bmp, u32* clut, u32 clutsize); /* Optional * Frees bitmap memory * * Default implementation: g_free... */ void (*bitmap_free)(hwrbitmap bmp); /* Optional * Gets size of a bitmap * * Default implementation: stdbitmap */ g_error (*bitmap_getsize)(hwrbitmap bmp,s16 *w,s16 *h); /* Optional * This is called for every bitmap when entering a new bpp or loading * a new driver. Converts a bitmap from a linear array of 32-bit * pgcolor values to the hwrcolors for this mode * * Default implementation: stdbitmap */ g_error (*bitmap_modeconvert)(hwrbitmap *bmp); /* Optional * The reverse of bitmap_modeconvert, this converts the bitmap from * the hardware-specific format to a pgcolor array * * Default implementation: stdbitmap */ g_error (*bitmap_modeunconvert)(hwrbitmap *bmp); /* Optional * Return the groprender structure associated with the bitmap, * and if one does not yet exist, create it. * * Default implementation: stdbitmap */ g_error (*bitmap_get_groprender)(hwrbitmap bmp, struct groprender **rend); /* Optional * Map the bitmap into shared memory, and fill out a struct pgshmbitmap * structure with information about the bitmap. The 'shm' structure enters * already zeroed, and should be returned with all applicable fields filled * out in network byte order. 'uid' is the UID of the client that owns this * bitmap. * * Default implementation: stdbitmap */ g_error (*bitmap_getshm)(hwrbitmap bmp, u32 uid, struct pgshmbitmap *shm);#ifdef CONFIG_DITHER /* Optional * Start writing dithered data into a bitmap. Returns a dithering structure * that's used to keep track of the position in the image. It's assumed that * image data will be fed in top-down unless vflip is 1, in which case it's * assumed bottom-up. */ g_error (*dither_start)(hwrdither *d, hwrbitmap dest, int vflip, int x, int y, int w, int h); /* Optional * Dither this pixel and store it in the bitmap */ void (*dither_store)(hwrdither d, pgcolor pixel, s16 lgop); /* Optional * Free the dithering structure */ void (*dither_finish)(hwrdither d);#endif /* CONFIG_DITHER */ /******************************************** Sprites */ /* Optional
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -