清单 1 MiniGUI 中的图形引擎结构(src/include/gal.h)
55 typedef struct tagGFX 56 { 57 char* id; 58 59 // Initialization and termination 60 BOOL (*initgfx) (struct tagGFX* gfx); 61 void (*termgfx) (struct tagGFX* gfx); 62 63 // Phisical graphics context 64 GAL_GC phygc; 65 int bytes_per_phypixel; 66 int bits_per_phypixel; 67 int width_phygc; 68 int height_phygc; 69 int colors_phygc; 70 BOOL grayscale_screen; 71 72 // GC properties 73 int (*bytesperpixel) (GAL_GC gc); 74 int (*bitsperpixel) (GAL_GC gc); 75 int (*width) (GAL_GC gc); 76 int (*height) (GAL_GC gc); 77 int (*colors) (GAL_GC gc); 78 79 // Allocation and release of graphics context 80 int (*allocategc) (GAL_GC gc, int width, int height, int depth, 81 GAL_GC* newgc); 82 void (*freegc) (GAL_GC gc); 83 void (*setgc) (GAL_GC gc); 84 85 // Clipping of graphics context 86 void (*enableclipping) (GAL_GC gc); 87 void (*disableclipping) (GAL_GC gc); 88 int (*setclipping) (GAL_GC gc, int x1, int y1, int x2, int y2); 89 int (*getclipping) (GAL_GC gc, int* x1, int* y1, int* x2, int* y2); 90 91 // Background and foreground colors 92 int (*getbgcolor) (GAL_GC gc, gal_pixel* color); 93 int (*setbgcolor) (GAL_GC gc, gal_pixel color); 94 int (*getfgcolor) (GAL_GC gc, gal_pixel* color); 95 int (*setfgcolor) (GAL_GC gc, gal_pixel color); 96 97 // Convertion between gal_color and gal_pixel 98 gal_pixel (*mapcolor) (GAL_GC gc, gal_color *color); 99 int (*unmappixel) (GAL_GC gc, gal_pixel pixel, gal_color* color); 100 int (*packcolors) (GAL_GC gc, void* buf, gal_color* colors, int len); 101 int (*unpackpixels) (GAL_GC gc, void* buf, gal_color* colors, int len); 102 103 // Palette operations 104 int (*getpalette) (GAL_GC gc, int s, int len, gal_color* cmap); 105 int (*setpalette) (GAL_GC gc, int s, int len, gal_color* cmap); 106 int (*setcolorfulpalette) (GAL_GC gc); 107 108 // Box operations 109 size_t (*boxsize) (GAL_GC gc, int w, int h); 110 int (*fillbox) (GAL_GC gc, int x, int y, int w, int h, 111 gal_pixel pixel); 112 int (*putbox) (GAL_GC gc, int x, int y, int w, int h, void* buf); 113 int (*getbox) (GAL_GC gc, int x, int y, int w, int h, void* buf); 114 int (*putboxmask) (GAL_GC gc, int x, int y, int w, int h, void* buf, gal_pixel cxx); 115 int (*putboxpart) (GAL_GC gc, int x, int y, int w, int h, int bw, 116 int bh, void* buf, int xo, int yo); 117 int (*putboxwithop) (GAL_GC gc, int x, int y, int w, int h, 118 void* buf, int raster_op); 119 int (*scalebox) (GAL_GC gc, int sw, int sh, void* srcbuf, 120 int dw, int dh, void* dstbuf); 121 122 int (*copybox) (GAL_GC gc, int x, int y, int w, int h, int nx, int ny); 123 int (*crossblit) (GAL_GC src, int sx, int sy, int sw, int sh, 124 GAL_GC dst, int dx, int dy); 125 126 // Horizontal line operaions 127 int (*drawhline) (GAL_GC gc, int x, int y, int w, gal_pixel pixel); 128 int (*puthline) (GAL_GC gc, int x, int y, int w, void* buf); 129 int (*gethline) (GAL_GC gc, int x, int y, int w, void* buf); 130 131 // Vertical line operations 132 int (*drawvline) (GAL_GC gc, int x, int y, int h, gal_pixel pixel); 133 int (*putvline) (GAL_GC gc, int x, int y, int h, void* buf); 134 int (*getvline) (GAL_GC gc, int x, int y, int h, void* buf); 135 136 // Pixel operations 137 int (*drawpixel) (GAL_GC gc, int x, int y, gal_pixel pixel); 138 int (*putpixel) (GAL_GC gc, int x, int y, gal_pixel color); 139 int (*getpixel) (GAL_GC gc, int x, int y, gal_pixel* color); 140 141 // Other drawing 142 int (*circle) (GAL_GC gc, int x, int y, int r, gal_pixel pixel); 143 int (*line) (GAL_GC gc, int x1, int y1, int x2, int y2, 144 gal_pixel pixel); 145 int (*rectangle) (GAL_GC gc, int l, int t, int r, int b, 146 gal_pixel pixel); 147 148 // Simple Character output 149 int (*putchar) (GAL_GC gc, int x, int y, char c); 150 int (*putstr) (GAL_GC gc, int x, int y, const char* str); 151 int (*getcharsize) (GAL_GC gc, int* width, int* height); 152 int (*setputcharmode) (GAL_GC gc, int bkmode); 153 int (*setfontcolors) (GAL_GC gc, 154 gal_pixel fg, gal_pixel bg); 155 156 // Asynchronous mode support 157 void (*flush) (GAL_GC gc); 158 void (*flushregion) (GAL_GC gc, int x, int y, int w, int h); 159 160 // Panic 161 void (*panic) (int exitcode); 162 163 } GFX; 164 165 extern GFX* cur_gfx;
|