Rev 3715 | Rev 3724 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3715 | Rev 3723 | ||
---|---|---|---|
Line 137... | Line 137... | ||
137 | static pixmap_t pixmaps[MAX_PIXMAPS]; |
137 | static pixmap_t pixmaps[MAX_PIXMAPS]; |
138 | static viewport_t viewports[128]; |
138 | static viewport_t viewports[128]; |
139 | 139 | ||
140 | static bool client_connected = false; /**< Allow only 1 connection */ |
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 | #define RED(x, bits) ((x >> (8 + 8 + 8 - bits)) & ((1 << bits) - 1)) |
146 | #define RED(x, bits) ((x >> (8 + 8 + 8 - bits)) & ((1 << bits) - 1)) |
143 | #define GREEN(x, bits) ((x >> (8 + 8 - bits)) & ((1 << bits) - 1)) |
147 | #define GREEN(x, bits) ((x >> (8 + 8 - bits)) & ((1 << bits) - 1)) |
144 | #define BLUE(x, bits) ((x >> (8 - bits)) & ((1 << bits) - 1)) |
148 | #define BLUE(x, bits) ((x >> (8 - bits)) & ((1 << bits) - 1)) |
145 | 149 | ||
146 | #define COL2X(col) ((col) * FONT_WIDTH) |
150 | #define COL2X(col) ((col) * FONT_WIDTH) |
Line 217... | Line 221... | ||
217 | { |
221 | { |
218 | *((uint8_t *) dst) |
222 | *((uint8_t *) dst) |
219 | = ~((RED(rgb, 3) << 5) | (GREEN(rgb, 2) << 3) | BLUE(rgb, 3)); |
223 | = ~((RED(rgb, 3) << 5) | (GREEN(rgb, 2) << 3) | BLUE(rgb, 3)); |
220 | } |
224 | } |
221 | 225 | ||
- | 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 | } |
|
222 | 242 | ||
223 | /** Redraw viewport |
243 | /** Redraw viewport. |
224 | * |
244 | * |
225 | * @param vport Viewport to redraw |
245 | * @param vport Viewport to redraw |
226 | * |
246 | * |
227 | */ |
247 | */ |
228 | static void vport_redraw(viewport_t *vport) |
248 | static void vport_redraw(viewport_t *vport) |
229 | { |
249 | { |
230 | unsigned int row; |
250 | unsigned int row, col; |
231 | 251 | ||
232 | for (row = 0; row < vport->rows; row++) { |
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++) { |
253 | for (col = 0; col < vport->cols; col++) { |
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); |
254 | draw_glyph(vport, false, col, row); |
244 | } |
255 | } |
245 | } |
256 | } |
246 | 257 | ||
247 | if (COL2X(vport->cols) < vport->width) { |
258 | if (COL2X(vport->cols) < vport->width) { |
248 | unsigned int y; |
259 | draw_filled_rect( |
249 | - | ||
250 | for (y = 0; y < vport->height; y++) { |
260 | vport->x + COL2X(vport->cols), vport->y, |
251 | unsigned int x; |
- | |
252 | - | ||
253 | for (x = COL2X(vport->cols); x < vport->width; x++) |
261 | vport->x + vport->width, vport->y + vport->height, |
254 | memcpy(&screen.fb_addr[FB_POS(x, y)], vport->bgpixel, screen.pixelbytes); |
262 | vport->style.bg_color); |
255 | } |
- | |
256 | } |
263 | } |
257 | 264 | ||
258 | if (ROW2Y(vport->rows) < vport->height) { |
265 | if (ROW2Y(vport->rows) < vport->height) { |
259 | unsigned int y; |
266 | draw_filled_rect( |
260 | - | ||
261 | for (y = ROW2Y(vport->rows); y < vport->height; y++) { |
267 | vport->x, vport->y + ROW2Y(vport->rows), |
262 | unsigned int x; |
- | |
263 | - | ||
264 | for (x = 0; x < vport->width; x++) |
268 | vport->x + vport->width, vport->y + vport->height, |
265 | memcpy(&screen.fb_addr[FB_POS(x, y)], vport->bgpixel, screen.pixelbytes); |
269 | vport->style.bg_color); |
266 | } |
- | |
267 | } |
270 | } |
268 | } |
271 | } |
269 | 272 | ||
270 | 273 | ||
271 | /** Clear viewport |
274 | /** Clear viewport |
Line 277... | Line 280... | ||
277 | { |
280 | { |
278 | memset(vport->backbuf, 0, vport->bbsize); |
281 | memset(vport->backbuf, 0, vport->bbsize); |
279 | vport_redraw(vport); |
282 | vport_redraw(vport); |
280 | } |
283 | } |
281 | 284 | ||
282 | - | ||
283 | /** Scroll viewport by given number of lines |
285 | /** Scroll viewport by given number of lines |
284 | * |
286 | * |
285 | * @param vport Viewport to scroll |
287 | * @param vport Viewport to scroll |
286 | * @param lines Number of lines to scroll |
288 | * @param lines Number of lines to scroll |
287 | * |
289 | * |
288 | */ |
290 | */ |
289 | static void vport_scroll(viewport_t *vport, int lines) |
291 | static void vport_scroll(viewport_t *vport, int lines) |
290 | { |
292 | { |
291 | unsigned int row; |
293 | unsigned int row, col; |
292 | - | ||
293 | 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 | 294 | ||
318 | if (lines > 0) { |
295 | if (lines > 0) { |
319 | memcpy(vport->backbuf, vport->backbuf + vport->cols * lines, vport->cols * (vport->rows - lines)); |
296 | memcpy(vport->backbuf, vport->backbuf + vport->cols * lines, |
- | 297 | vport->cols * (vport->rows - lines)); |
|
320 | memset(&vport->backbuf[BB_POS(vport, 0, vport->rows - lines)], 0, vport->cols * lines); |
298 | memset(&vport->backbuf[BB_POS(vport, 0, vport->rows - lines)], |
- | 299 | 0, vport->cols * lines); |
|
321 | } else { |
300 | } else { |
322 | memcpy(vport->backbuf - vport->cols * lines, vport->backbuf, vport->cols * (vport->rows + lines)); |
301 | memcpy(vport->backbuf - vport->cols * lines, vport->backbuf, |
- | 302 | vport->cols * (vport->rows + lines)); |
|
323 | memset(vport->backbuf, 0, - vport->cols * lines); |
303 | memset(vport->backbuf, 0, - vport->cols * lines); |
324 | } |
304 | } |
325 | } |
- | |
326 | 305 | ||
- | 306 | for (row = 0; row < vport->rows; row++) { |
|
- | 307 | for (col = 0; col < vport->cols; col++) { |
|
- | 308 | draw_glyph(vport, false, col, row); |
|
- | 309 | } |
|
- | 310 | } |
|
- | 311 | } |
|
327 | 312 | ||
328 | /** Render glyphs |
313 | /** Render glyphs |
329 | * |
314 | * |
330 | * Convert glyphs from device independent font |
315 | * Convert glyphs from device independent font |
331 | * description to current visual representation. |
316 | * description to current visual representation. |
Line 928... | Line 913... | ||
928 | int bytepos; |
913 | int bytepos; |
929 | 914 | ||
930 | if ((pointer_shown) || (!pointer_enabled)) |
915 | if ((pointer_shown) || (!pointer_enabled)) |
931 | return; |
916 | return; |
932 | 917 | ||
933 | /* Save image under the cursor */ |
918 | /* Save image under the pointer. */ |
934 | if (pointer_vport == -1) { |
919 | if (pointer_vport == -1) { |
935 | pointer_vport = vport_create(pointer_x, pointer_y, pointer_width, pointer_height); |
920 | pointer_vport = vport_create(pointer_x, pointer_y, pointer_width, pointer_height); |
936 | if (pointer_vport < 0) |
921 | if (pointer_vport < 0) |
937 | return; |
922 | return; |
938 | } else { |
923 | } else { |
Line 943... | Line 928... | ||
943 | if (pointer_pixmap == -1) |
928 | if (pointer_pixmap == -1) |
944 | pointer_pixmap = save_vp_to_pixmap(&viewports[pointer_vport]); |
929 | pointer_pixmap = save_vp_to_pixmap(&viewports[pointer_vport]); |
945 | else |
930 | else |
946 | copy_vp_to_pixmap(&viewports[pointer_vport], &pixmaps[pointer_pixmap]); |
931 | copy_vp_to_pixmap(&viewports[pointer_vport], &pixmaps[pointer_pixmap]); |
947 | 932 | ||
948 | /* Draw cursor */ |
933 | /* Draw mouse pointer. */ |
949 | for (i = 0; i < pointer_height; i++) |
934 | for (i = 0; i < pointer_height; i++) |
950 | for (j = 0; j < pointer_width; j++) { |
935 | for (j = 0; j < pointer_width; j++) { |
951 | bytepos = i * ((pointer_width - 1) / 8 + 1) + j / 8; |
936 | bytepos = i * ((pointer_width - 1) / 8 + 1) + j / 8; |
952 | visibility = pointer_mask_bits[bytepos] & |
937 | visibility = pointer_mask_bits[bytepos] & |
953 | (1 << (j % 8)); |
938 | (1 << (j % 8)); |
Line 964... | Line 949... | ||
964 | } |
949 | } |
965 | 950 | ||
966 | 951 | ||
967 | static void mouse_hide(void) |
952 | static void mouse_hide(void) |
968 | { |
953 | { |
969 | /* Restore image under the cursor */ |
954 | /* Restore image under the pointer. */ |
970 | if (pointer_shown) { |
955 | if (pointer_shown) { |
971 | draw_pixmap(pointer_vport, pointer_pixmap); |
956 | draw_pixmap(pointer_vport, pointer_pixmap); |
972 | pointer_shown = 0; |
957 | pointer_shown = 0; |
973 | } |
958 | } |
974 | } |
959 | } |