summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2005-10-23 23:49:46 +0000
committerJens Arnold <amiconn@rockbox.org>2005-10-23 23:49:46 +0000
commit48be8e6a8b45fa16380af97829ba944430a78f17 (patch)
tree4844e52532e3ce4981333deddcf8aefe9cdc8d77
parentfc03c8e3c9a4067beccda3303236044d970d336b (diff)
downloadrockbox-48be8e6a8b45fa16380af97829ba944430a78f17.tar.gz
rockbox-48be8e6a8b45fa16380af97829ba944430a78f17.tar.bz2
rockbox-48be8e6a8b45fa16380af97829ba944430a78f17.zip
X11 simulator: * Correctly redraw the window when it was destroyed by overlaying (X11 'Expose' event). * Simplified, corrected and unified redraw algorithm for main & remote bitmap display.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7655 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--uisimulator/x11/lcd-x11.c81
-rw-r--r--uisimulator/x11/uibasic.c3
2 files changed, 40 insertions, 44 deletions
diff --git a/uisimulator/x11/lcd-x11.c b/uisimulator/x11/lcd-x11.c
index 4a7dbc6bf3..75e29f3554 100644
--- a/uisimulator/x11/lcd-x11.c
+++ b/uisimulator/x11/lcd-x11.c
@@ -42,15 +42,14 @@
#if LCD_DEPTH == 2
#define YBLOCK 4
-#define BITOFFS 1 /* take the MSB of each pixel */
#define ANDBIT 3 /* AND with this to get the color number */
#else
#define YBLOCK 8
-#define BITOFFS 0
#define ANDBIT 1
#endif
extern void screen_resized(int width, int height);
+extern bool lcd_display_redraw;
#ifdef HAVE_LCD_BITMAP
extern unsigned char lcd_framebuffer[LCD_HEIGHT/YBLOCK][LCD_WIDTH];
@@ -74,6 +73,7 @@ void lcd_update_rect(int x_start, int y_start,
int ymax;
int colors[LCD_WIDTH * LCD_HEIGHT];
struct coordinate points[LCD_WIDTH * LCD_HEIGHT];
+ unsigned force_mask = lcd_display_redraw ? 0xFF : 0;
#if 0
fprintf(stderr, "%04d: lcd_update_rect(%d, %d, %d, %d)\n",
@@ -90,28 +90,29 @@ void lcd_update_rect(int x_start, int y_start,
if(ymax >= LCD_HEIGHT/YBLOCK)
ymax = LCD_HEIGHT/YBLOCK-1;
- for(; yline<=ymax; yline++) {
+ for(; yline <= ymax; yline++) {
y = yline * YBLOCK;
- for(x=x_start; x<xmax; x++) {
- if(lcd_framebuffer[yline][x] != lcd_framebuffer_copy[yline][x]) {
+ for(x = x_start; x < xmax; x++) {
+ unsigned char diff = (lcd_framebuffer[yline][x]
+ ^ lcd_framebuffer_copy[yline][x])
+ | force_mask;
+ if(diff) {
/* one or more bits/pixels are changed */
-
- for(bit=0; bit<YBLOCK; bit++) {
- unsigned int col;
- col = lcd_framebuffer[yline][x]&(ANDBIT<<(bit*LCD_DEPTH));
-
+ unsigned char mask = ANDBIT;
+ for(bit = 0; bit < YBLOCK; bit++) {
+ if(diff & mask) {
+ /* pixel has changed */
+ unsigned int col = lcd_framebuffer[yline][x] & mask;
#if LCD_DEPTH == 2
- /* shift down the value to the lower bits */
- col >>= (bit * LCD_DEPTH);
-
- /* set a dot */
- colors[p] = col;
+ colors[p] = col >> (bit * LCD_DEPTH);
#else
- colors[p] = col?3:0;
+ colors[p] = col ? 3 : 0;
#endif
- points[p].x = x + MARGIN_X;
- points[p].y = y+bit + MARGIN_Y;
- p++; /* increase the point counter */
+ points[p].x = x + MARGIN_X;
+ points[p].y = y + bit + MARGIN_Y;
+ p++; /* increase the point counter */
+ }
+ mask <<= LCD_DEPTH;
}
/* update the copy */
@@ -125,6 +126,7 @@ void lcd_update_rect(int x_start, int y_start,
XtAppLock(app);
XSync(dpy,False);
XtAppUnlock(app);
+ lcd_display_redraw=false;
}
#ifdef LCD_REMOTE_HEIGHT
@@ -148,8 +150,9 @@ void lcd_remote_update_rect(int x_start, int y_start,
int bit;
int xmax;
int ymax;
- struct coordinate points[LCD_WIDTH * LCD_HEIGHT];
- int colors[LCD_WIDTH * LCD_HEIGHT];
+ struct coordinate points[LCD_REMOTE_WIDTH * LCD_REMOTE_HEIGHT];
+ int colors[LCD_REMOTE_WIDTH * LCD_REMOTE_HEIGHT];
+ unsigned force_mask = lcd_display_redraw ? 0xFF : 0;
#if 0
fprintf(stderr, "%04d: lcd_update_rect(%d, %d, %d, %d)\n",
@@ -166,31 +169,23 @@ void lcd_remote_update_rect(int x_start, int y_start,
if(ymax >= LCD_REMOTE_HEIGHT/8)
ymax = LCD_REMOTE_HEIGHT/8-1;
- for(; yline<=ymax; yline++) {
+ for(; yline <= ymax; yline++) {
y = yline * 8;
- for(x=x_start; x<xmax; x++) {
- if(lcd_remote_framebuffer[yline][x] ||
- lcd_remote_framebuffer_copy[yline][x]) {
- /* one or more bits/pixels are changed */
- unsigned char diff =
- lcd_remote_framebuffer[yline][x] ^
- lcd_remote_framebuffer_copy[yline][x];
-
- for(bit=0; bit<8; bit++) {
- if(lcd_remote_framebuffer[yline][x]&(1<<bit)) {
- /* set a dot */
- colors[p]=3;
- points[p].x = x + MARGIN_X;
- points[p].y = y+bit + (REMOTE_START_Y + MARGIN_Y);
- p++; /* increase the point counter */
- }
- else if(diff &(1<<bit)) {
- /* clear a dot */
- colors[p]=0;
+ for(x = x_start; x < xmax; x++) {
+ unsigned char diff = (lcd_remote_framebuffer[yline][x]
+ ^ lcd_remote_framebuffer_copy[yline][x])
+ | force_mask;
+ if(diff) {
+ unsigned char mask = 1;
+ for(bit = 0; bit < 8; bit++) {
+ if(diff & mask) {
+ unsigned int col = lcd_remote_framebuffer[yline][x] & mask;
+ colors[p] = col ? 3 : 0;
points[p].x = x + MARGIN_X;
- points[p].y = y+bit + (REMOTE_START_Y + MARGIN_Y);
+ points[p].y = y + bit + (REMOTE_START_Y + MARGIN_Y);
p++; /* increase the point counter */
}
+ mask <<= 1;
}
/* update the copy */
@@ -205,6 +200,7 @@ void lcd_remote_update_rect(int x_start, int y_start,
XtAppLock(app);
XSync(dpy,False);
XtAppUnlock(app);
+ lcd_display_redraw=false;
}
@@ -217,7 +213,6 @@ void lcd_remote_update_rect(int x_start, int y_start,
extern void lcd_print_char(int x, int y);
extern unsigned char lcd_buffer[2][11];
extern void drawrect(int color, int x1, int y1, int x2, int y2);
-extern bool lcd_display_redraw;
extern unsigned char hardware_buffer_lcd[11][2];
static unsigned char lcd_buffer_copy[11][2];
diff --git a/uisimulator/x11/uibasic.c b/uisimulator/x11/uibasic.c
index 40389e946e..57870c39d3 100644
--- a/uisimulator/x11/uibasic.c
+++ b/uisimulator/x11/uibasic.c
@@ -144,7 +144,6 @@ void screen_resized(int width, int height)
XFillRectangle(dpy, window, draw_gc, 0, 0, width*display_zoom,
height*display_zoom);
XtAppUnlock(app);
- lcd_display_redraw=true;
screen_redraw();
}
@@ -259,6 +258,7 @@ void screen_redraw()
drawline(1, X2, Y1, X2, Y2);
drawline(1, X1, Y2, X2, Y2);
drawline(1, X1, Y1, X1, Y2);
+ lcd_display_redraw = true;
lcd_update();
#ifdef LCD_REMOTE_HEIGHT
/* draw a border around the remote LCD screen */
@@ -271,6 +271,7 @@ void screen_redraw()
drawline(1, RX2, RY1, RX2, RY2);
drawline(1, RX1, RY2, RX2, RY2);
drawline(1, RX1, RY1, RX1, RY2);
+ lcd_display_redraw = true;
lcd_remote_update();
#endif
}