diff options
author | Jens Arnold <amiconn@rockbox.org> | 2005-10-23 23:49:46 +0000 |
---|---|---|
committer | Jens Arnold <amiconn@rockbox.org> | 2005-10-23 23:49:46 +0000 |
commit | 48be8e6a8b45fa16380af97829ba944430a78f17 (patch) | |
tree | 4844e52532e3ce4981333deddcf8aefe9cdc8d77 | |
parent | fc03c8e3c9a4067beccda3303236044d970d336b (diff) | |
download | rockbox-48be8e6a8b45fa16380af97829ba944430a78f17.tar.gz 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.c | 81 | ||||
-rw-r--r-- | uisimulator/x11/uibasic.c | 3 |
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 @@ | |||
42 | 42 | ||
43 | #if LCD_DEPTH == 2 | 43 | #if LCD_DEPTH == 2 |
44 | #define YBLOCK 4 | 44 | #define YBLOCK 4 |
45 | #define BITOFFS 1 /* take the MSB of each pixel */ | ||
46 | #define ANDBIT 3 /* AND with this to get the color number */ | 45 | #define ANDBIT 3 /* AND with this to get the color number */ |
47 | #else | 46 | #else |
48 | #define YBLOCK 8 | 47 | #define YBLOCK 8 |
49 | #define BITOFFS 0 | ||
50 | #define ANDBIT 1 | 48 | #define ANDBIT 1 |
51 | #endif | 49 | #endif |
52 | 50 | ||
53 | extern void screen_resized(int width, int height); | 51 | extern void screen_resized(int width, int height); |
52 | extern bool lcd_display_redraw; | ||
54 | 53 | ||
55 | #ifdef HAVE_LCD_BITMAP | 54 | #ifdef HAVE_LCD_BITMAP |
56 | extern unsigned char lcd_framebuffer[LCD_HEIGHT/YBLOCK][LCD_WIDTH]; | 55 | extern unsigned char lcd_framebuffer[LCD_HEIGHT/YBLOCK][LCD_WIDTH]; |
@@ -74,6 +73,7 @@ void lcd_update_rect(int x_start, int y_start, | |||
74 | int ymax; | 73 | int ymax; |
75 | int colors[LCD_WIDTH * LCD_HEIGHT]; | 74 | int colors[LCD_WIDTH * LCD_HEIGHT]; |
76 | struct coordinate points[LCD_WIDTH * LCD_HEIGHT]; | 75 | struct coordinate points[LCD_WIDTH * LCD_HEIGHT]; |
76 | unsigned force_mask = lcd_display_redraw ? 0xFF : 0; | ||
77 | 77 | ||
78 | #if 0 | 78 | #if 0 |
79 | fprintf(stderr, "%04d: lcd_update_rect(%d, %d, %d, %d)\n", | 79 | 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, | |||
90 | if(ymax >= LCD_HEIGHT/YBLOCK) | 90 | if(ymax >= LCD_HEIGHT/YBLOCK) |
91 | ymax = LCD_HEIGHT/YBLOCK-1; | 91 | ymax = LCD_HEIGHT/YBLOCK-1; |
92 | 92 | ||
93 | for(; yline<=ymax; yline++) { | 93 | for(; yline <= ymax; yline++) { |
94 | y = yline * YBLOCK; | 94 | y = yline * YBLOCK; |
95 | for(x=x_start; x<xmax; x++) { | 95 | for(x = x_start; x < xmax; x++) { |
96 | if(lcd_framebuffer[yline][x] != lcd_framebuffer_copy[yline][x]) { | 96 | unsigned char diff = (lcd_framebuffer[yline][x] |
97 | ^ lcd_framebuffer_copy[yline][x]) | ||
98 | | force_mask; | ||
99 | if(diff) { | ||
97 | /* one or more bits/pixels are changed */ | 100 | /* one or more bits/pixels are changed */ |
98 | 101 | unsigned char mask = ANDBIT; | |
99 | for(bit=0; bit<YBLOCK; bit++) { | 102 | for(bit = 0; bit < YBLOCK; bit++) { |
100 | unsigned int col; | 103 | if(diff & mask) { |
101 | col = lcd_framebuffer[yline][x]&(ANDBIT<<(bit*LCD_DEPTH)); | 104 | /* pixel has changed */ |
102 | 105 | unsigned int col = lcd_framebuffer[yline][x] & mask; | |
103 | #if LCD_DEPTH == 2 | 106 | #if LCD_DEPTH == 2 |
104 | /* shift down the value to the lower bits */ | 107 | colors[p] = col >> (bit * LCD_DEPTH); |
105 | col >>= (bit * LCD_DEPTH); | ||
106 | |||
107 | /* set a dot */ | ||
108 | colors[p] = col; | ||
109 | #else | 108 | #else |
110 | colors[p] = col?3:0; | 109 | colors[p] = col ? 3 : 0; |
111 | #endif | 110 | #endif |
112 | points[p].x = x + MARGIN_X; | 111 | points[p].x = x + MARGIN_X; |
113 | points[p].y = y+bit + MARGIN_Y; | 112 | points[p].y = y + bit + MARGIN_Y; |
114 | p++; /* increase the point counter */ | 113 | p++; /* increase the point counter */ |
114 | } | ||
115 | mask <<= LCD_DEPTH; | ||
115 | } | 116 | } |
116 | 117 | ||
117 | /* update the copy */ | 118 | /* update the copy */ |
@@ -125,6 +126,7 @@ void lcd_update_rect(int x_start, int y_start, | |||
125 | XtAppLock(app); | 126 | XtAppLock(app); |
126 | XSync(dpy,False); | 127 | XSync(dpy,False); |
127 | XtAppUnlock(app); | 128 | XtAppUnlock(app); |
129 | lcd_display_redraw=false; | ||
128 | } | 130 | } |
129 | 131 | ||
130 | #ifdef LCD_REMOTE_HEIGHT | 132 | #ifdef LCD_REMOTE_HEIGHT |
@@ -148,8 +150,9 @@ void lcd_remote_update_rect(int x_start, int y_start, | |||
148 | int bit; | 150 | int bit; |
149 | int xmax; | 151 | int xmax; |
150 | int ymax; | 152 | int ymax; |
151 | struct coordinate points[LCD_WIDTH * LCD_HEIGHT]; | 153 | struct coordinate points[LCD_REMOTE_WIDTH * LCD_REMOTE_HEIGHT]; |
152 | int colors[LCD_WIDTH * LCD_HEIGHT]; | 154 | int colors[LCD_REMOTE_WIDTH * LCD_REMOTE_HEIGHT]; |
155 | unsigned force_mask = lcd_display_redraw ? 0xFF : 0; | ||
153 | 156 | ||
154 | #if 0 | 157 | #if 0 |
155 | fprintf(stderr, "%04d: lcd_update_rect(%d, %d, %d, %d)\n", | 158 | 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, | |||
166 | if(ymax >= LCD_REMOTE_HEIGHT/8) | 169 | if(ymax >= LCD_REMOTE_HEIGHT/8) |
167 | ymax = LCD_REMOTE_HEIGHT/8-1; | 170 | ymax = LCD_REMOTE_HEIGHT/8-1; |
168 | 171 | ||
169 | for(; yline<=ymax; yline++) { | 172 | for(; yline <= ymax; yline++) { |
170 | y = yline * 8; | 173 | y = yline * 8; |
171 | for(x=x_start; x<xmax; x++) { | 174 | for(x = x_start; x < xmax; x++) { |
172 | if(lcd_remote_framebuffer[yline][x] || | 175 | unsigned char diff = (lcd_remote_framebuffer[yline][x] |
173 | lcd_remote_framebuffer_copy[yline][x]) { | 176 | ^ lcd_remote_framebuffer_copy[yline][x]) |
174 | /* one or more bits/pixels are changed */ | 177 | | force_mask; |
175 | unsigned char diff = | 178 | if(diff) { |
176 | lcd_remote_framebuffer[yline][x] ^ | 179 | unsigned char mask = 1; |
177 | lcd_remote_framebuffer_copy[yline][x]; | 180 | for(bit = 0; bit < 8; bit++) { |
178 | 181 | if(diff & mask) { | |
179 | for(bit=0; bit<8; bit++) { | 182 | unsigned int col = lcd_remote_framebuffer[yline][x] & mask; |
180 | if(lcd_remote_framebuffer[yline][x]&(1<<bit)) { | 183 | colors[p] = col ? 3 : 0; |
181 | /* set a dot */ | ||
182 | colors[p]=3; | ||
183 | points[p].x = x + MARGIN_X; | ||
184 | points[p].y = y+bit + (REMOTE_START_Y + MARGIN_Y); | ||
185 | p++; /* increase the point counter */ | ||
186 | } | ||
187 | else if(diff &(1<<bit)) { | ||
188 | /* clear a dot */ | ||
189 | colors[p]=0; | ||
190 | points[p].x = x + MARGIN_X; | 184 | points[p].x = x + MARGIN_X; |
191 | points[p].y = y+bit + (REMOTE_START_Y + MARGIN_Y); | 185 | points[p].y = y + bit + (REMOTE_START_Y + MARGIN_Y); |
192 | p++; /* increase the point counter */ | 186 | p++; /* increase the point counter */ |
193 | } | 187 | } |
188 | mask <<= 1; | ||
194 | } | 189 | } |
195 | 190 | ||
196 | /* update the copy */ | 191 | /* update the copy */ |
@@ -205,6 +200,7 @@ void lcd_remote_update_rect(int x_start, int y_start, | |||
205 | XtAppLock(app); | 200 | XtAppLock(app); |
206 | XSync(dpy,False); | 201 | XSync(dpy,False); |
207 | XtAppUnlock(app); | 202 | XtAppUnlock(app); |
203 | lcd_display_redraw=false; | ||
208 | } | 204 | } |
209 | 205 | ||
210 | 206 | ||
@@ -217,7 +213,6 @@ void lcd_remote_update_rect(int x_start, int y_start, | |||
217 | extern void lcd_print_char(int x, int y); | 213 | extern void lcd_print_char(int x, int y); |
218 | extern unsigned char lcd_buffer[2][11]; | 214 | extern unsigned char lcd_buffer[2][11]; |
219 | extern void drawrect(int color, int x1, int y1, int x2, int y2); | 215 | extern void drawrect(int color, int x1, int y1, int x2, int y2); |
220 | extern bool lcd_display_redraw; | ||
221 | 216 | ||
222 | extern unsigned char hardware_buffer_lcd[11][2]; | 217 | extern unsigned char hardware_buffer_lcd[11][2]; |
223 | static unsigned char lcd_buffer_copy[11][2]; | 218 | 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) | |||
144 | XFillRectangle(dpy, window, draw_gc, 0, 0, width*display_zoom, | 144 | XFillRectangle(dpy, window, draw_gc, 0, 0, width*display_zoom, |
145 | height*display_zoom); | 145 | height*display_zoom); |
146 | XtAppUnlock(app); | 146 | XtAppUnlock(app); |
147 | lcd_display_redraw=true; | ||
148 | screen_redraw(); | 147 | screen_redraw(); |
149 | } | 148 | } |
150 | 149 | ||
@@ -259,6 +258,7 @@ void screen_redraw() | |||
259 | drawline(1, X2, Y1, X2, Y2); | 258 | drawline(1, X2, Y1, X2, Y2); |
260 | drawline(1, X1, Y2, X2, Y2); | 259 | drawline(1, X1, Y2, X2, Y2); |
261 | drawline(1, X1, Y1, X1, Y2); | 260 | drawline(1, X1, Y1, X1, Y2); |
261 | lcd_display_redraw = true; | ||
262 | lcd_update(); | 262 | lcd_update(); |
263 | #ifdef LCD_REMOTE_HEIGHT | 263 | #ifdef LCD_REMOTE_HEIGHT |
264 | /* draw a border around the remote LCD screen */ | 264 | /* draw a border around the remote LCD screen */ |
@@ -271,6 +271,7 @@ void screen_redraw() | |||
271 | drawline(1, RX2, RY1, RX2, RY2); | 271 | drawline(1, RX2, RY1, RX2, RY2); |
272 | drawline(1, RX1, RY2, RX2, RY2); | 272 | drawline(1, RX1, RY2, RX2, RY2); |
273 | drawline(1, RX1, RY1, RX1, RY2); | 273 | drawline(1, RX1, RY1, RX1, RY2); |
274 | lcd_display_redraw = true; | ||
274 | lcd_remote_update(); | 275 | lcd_remote_update(); |
275 | #endif | 276 | #endif |
276 | } | 277 | } |