Changeset 2d32081 in mainline
- Timestamp:
- 2008-12-22T21:33:22Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a728ed3
- Parents:
- 723060a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fb/fb.c
r723060a r2d32081 140 140 static bool client_connected = false; /**< Allow only 1 connection */ 141 141 142 static void draw_glyph(viewport_t *vport, bool cursor, unsigned int col, 143 unsigned int row); 144 145 142 146 #define RED(x, bits) ((x >> (8 + 8 + 8 - bits)) & ((1 << bits) - 1)) 143 147 #define GREEN(x, bits) ((x >> (8 + 8 - bits)) & ((1 << bits) - 1)) … … 220 224 } 221 225 222 223 /** Redraw viewport 226 /** Draw a filled rectangle. */ 227 static void draw_filled_rect(unsigned int x0, unsigned int y0, unsigned int x1, 228 unsigned int y1, uint32_t color) 229 { 230 unsigned int x, y; 231 uint8_t cbuf[4]; 232 233 screen.rgb_conv(cbuf, color); 234 235 for (y = y0; y < y1; y++) { 236 for (x = x0; x < x1; x++) { 237 memcpy(&screen.fb_addr[FB_POS(x, y)], cbuf, 238 screen.pixelbytes); 239 } 240 } 241 } 242 243 /** Redraw viewport. 224 244 * 225 245 * @param vport Viewport to redraw … … 228 248 static void vport_redraw(viewport_t *vport) 229 249 { 230 unsigned int row ;231 250 unsigned int row, col; 251 232 252 for (row = 0; row < vport->rows; row++) { 233 unsigned int y = vport->y + ROW2Y(row); 234 unsigned int yd; 235 236 for (yd = 0; yd < FONT_SCANLINES; yd++) { 237 unsigned int x; 238 unsigned int col; 239 240 for (col = 0, x = vport->x; col < vport->cols; col++, x += FONT_WIDTH) 241 memcpy(&screen.fb_addr[FB_POS(x, y + yd)], 242 &vport->glyphs[GLYPH_POS(vport->backbuf[BB_POS(vport, col, row)], yd, false)], 243 screen.glyphscanline); 244 } 245 } 246 253 for (col = 0; col < vport->cols; col++) { 254 draw_glyph(vport, false, col, row); 255 } 256 } 257 247 258 if (COL2X(vport->cols) < vport->width) { 248 unsigned int y; 249 250 for (y = 0; y < vport->height; y++) { 251 unsigned int x; 252 253 for (x = COL2X(vport->cols); x < vport->width; x++) 254 memcpy(&screen.fb_addr[FB_POS(x, y)], vport->bgpixel, screen.pixelbytes); 255 } 256 } 257 259 draw_filled_rect( 260 vport->x + COL2X(vport->cols), vport->y, 261 vport->x + vport->width, vport->y + vport->height, 262 vport->style.bg_color); 263 } 264 258 265 if (ROW2Y(vport->rows) < vport->height) { 259 unsigned int y; 260 261 for (y = ROW2Y(vport->rows); y < vport->height; y++) { 262 unsigned int x; 263 264 for (x = 0; x < vport->width; x++) 265 memcpy(&screen.fb_addr[FB_POS(x, y)], vport->bgpixel, screen.pixelbytes); 266 } 266 draw_filled_rect( 267 vport->x, vport->y + ROW2Y(vport->rows), 268 vport->x + vport->width, vport->y + vport->height, 269 vport->style.bg_color); 267 270 } 268 271 } … … 280 283 } 281 284 282 283 285 /** Scroll viewport by given number of lines 284 286 * … … 289 291 static void vport_scroll(viewport_t *vport, int lines) 290 292 { 291 unsigned int row; 292 293 unsigned int row, col; 294 295 if (lines > 0) { 296 memcpy(vport->backbuf, vport->backbuf + vport->cols * lines, 297 vport->cols * (vport->rows - lines)); 298 memset(&vport->backbuf[BB_POS(vport, 0, vport->rows - lines)], 299 0, vport->cols * lines); 300 } else { 301 memcpy(vport->backbuf - vport->cols * lines, vport->backbuf, 302 vport->cols * (vport->rows + lines)); 303 memset(vport->backbuf, 0, - vport->cols * lines); 304 } 305 293 306 for (row = 0; row < vport->rows; row++) { 294 unsigned int y = vport->y + ROW2Y(row); 295 unsigned int yd; 296 297 for (yd = 0; yd < FONT_SCANLINES; yd++) { 298 unsigned int x; 299 unsigned int col; 300 301 for (col = 0, x = vport->x; col < vport->cols; col++, x += FONT_WIDTH) { 302 uint8_t glyph; 303 304 if ((row + lines >= 0) && (row + lines < vport->rows)) { 305 if (vport->backbuf[BB_POS(vport, col, row)] == vport->backbuf[BB_POS(vport, col, row + lines)]) 306 continue; 307 308 glyph = vport->backbuf[BB_POS(vport, col, row + lines)]; 309 } else 310 glyph = 0; 311 312 memcpy(&screen.fb_addr[FB_POS(x, y + yd)], 313 &vport->glyphs[GLYPH_POS(glyph, yd, false)], screen.glyphscanline); 314 } 315 } 316 } 317 318 if (lines > 0) { 319 memcpy(vport->backbuf, vport->backbuf + vport->cols * lines, vport->cols * (vport->rows - lines)); 320 memset(&vport->backbuf[BB_POS(vport, 0, vport->rows - lines)], 0, vport->cols * lines); 321 } else { 322 memcpy(vport->backbuf - vport->cols * lines, vport->backbuf, vport->cols * (vport->rows + lines)); 323 memset(vport->backbuf, 0, - vport->cols * lines); 324 } 325 } 326 307 for (col = 0; col < vport->cols; col++) { 308 draw_glyph(vport, false, col, row); 309 } 310 } 311 } 327 312 328 313 /** Render glyphs … … 931 916 return; 932 917 933 /* Save image under the cursor*/918 /* Save image under the pointer. */ 934 919 if (pointer_vport == -1) { 935 920 pointer_vport = vport_create(pointer_x, pointer_y, pointer_width, pointer_height); … … 946 931 copy_vp_to_pixmap(&viewports[pointer_vport], &pixmaps[pointer_pixmap]); 947 932 948 /* Draw cursor*/933 /* Draw mouse pointer. */ 949 934 for (i = 0; i < pointer_height; i++) 950 935 for (j = 0; j < pointer_width; j++) { … … 967 952 static void mouse_hide(void) 968 953 { 969 /* Restore image under the cursor*/954 /* Restore image under the pointer. */ 970 955 if (pointer_shown) { 971 956 draw_pixmap(pointer_vport, pointer_pixmap);
Note:
See TracChangeset
for help on using the changeset viewer.