mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-11 06:05:21 -05:00
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
This commit is contained in:
parent
fc03c8e3c9
commit
48be8e6a8b
2 changed files with 40 additions and 44 deletions
|
|
@ -42,15 +42,14 @@
|
||||||
|
|
||||||
#if LCD_DEPTH == 2
|
#if LCD_DEPTH == 2
|
||||||
#define YBLOCK 4
|
#define YBLOCK 4
|
||||||
#define BITOFFS 1 /* take the MSB of each pixel */
|
|
||||||
#define ANDBIT 3 /* AND with this to get the color number */
|
#define ANDBIT 3 /* AND with this to get the color number */
|
||||||
#else
|
#else
|
||||||
#define YBLOCK 8
|
#define YBLOCK 8
|
||||||
#define BITOFFS 0
|
|
||||||
#define ANDBIT 1
|
#define ANDBIT 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern void screen_resized(int width, int height);
|
extern void screen_resized(int width, int height);
|
||||||
|
extern bool lcd_display_redraw;
|
||||||
|
|
||||||
#ifdef HAVE_LCD_BITMAP
|
#ifdef HAVE_LCD_BITMAP
|
||||||
extern unsigned char lcd_framebuffer[LCD_HEIGHT/YBLOCK][LCD_WIDTH];
|
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 ymax;
|
||||||
int colors[LCD_WIDTH * LCD_HEIGHT];
|
int colors[LCD_WIDTH * LCD_HEIGHT];
|
||||||
struct coordinate points[LCD_WIDTH * LCD_HEIGHT];
|
struct coordinate points[LCD_WIDTH * LCD_HEIGHT];
|
||||||
|
unsigned force_mask = lcd_display_redraw ? 0xFF : 0;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
fprintf(stderr, "%04d: lcd_update_rect(%d, %d, %d, %d)\n",
|
fprintf(stderr, "%04d: lcd_update_rect(%d, %d, %d, %d)\n",
|
||||||
|
|
@ -93,19 +93,18 @@ void lcd_update_rect(int x_start, int y_start,
|
||||||
for(; yline <= ymax; yline++) {
|
for(; yline <= ymax; yline++) {
|
||||||
y = yline * YBLOCK;
|
y = yline * YBLOCK;
|
||||||
for(x = x_start; x < xmax; x++) {
|
for(x = x_start; x < xmax; x++) {
|
||||||
if(lcd_framebuffer[yline][x] != lcd_framebuffer_copy[yline][x]) {
|
unsigned char diff = (lcd_framebuffer[yline][x]
|
||||||
|
^ lcd_framebuffer_copy[yline][x])
|
||||||
|
| force_mask;
|
||||||
|
if(diff) {
|
||||||
/* one or more bits/pixels are changed */
|
/* one or more bits/pixels are changed */
|
||||||
|
unsigned char mask = ANDBIT;
|
||||||
for(bit = 0; bit < YBLOCK; bit++) {
|
for(bit = 0; bit < YBLOCK; bit++) {
|
||||||
unsigned int col;
|
if(diff & mask) {
|
||||||
col = lcd_framebuffer[yline][x]&(ANDBIT<<(bit*LCD_DEPTH));
|
/* pixel has changed */
|
||||||
|
unsigned int col = lcd_framebuffer[yline][x] & mask;
|
||||||
#if LCD_DEPTH == 2
|
#if LCD_DEPTH == 2
|
||||||
/* shift down the value to the lower bits */
|
colors[p] = col >> (bit * LCD_DEPTH);
|
||||||
col >>= (bit * LCD_DEPTH);
|
|
||||||
|
|
||||||
/* set a dot */
|
|
||||||
colors[p] = col;
|
|
||||||
#else
|
#else
|
||||||
colors[p] = col ? 3 : 0;
|
colors[p] = col ? 3 : 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -113,6 +112,8 @@ void lcd_update_rect(int x_start, int y_start,
|
||||||
points[p].y = y + bit + MARGIN_Y;
|
points[p].y = y + bit + MARGIN_Y;
|
||||||
p++; /* increase the point counter */
|
p++; /* increase the point counter */
|
||||||
}
|
}
|
||||||
|
mask <<= LCD_DEPTH;
|
||||||
|
}
|
||||||
|
|
||||||
/* update the copy */
|
/* update the copy */
|
||||||
lcd_framebuffer_copy[yline][x] = lcd_framebuffer[yline][x];
|
lcd_framebuffer_copy[yline][x] = lcd_framebuffer[yline][x];
|
||||||
|
|
@ -125,6 +126,7 @@ void lcd_update_rect(int x_start, int y_start,
|
||||||
XtAppLock(app);
|
XtAppLock(app);
|
||||||
XSync(dpy,False);
|
XSync(dpy,False);
|
||||||
XtAppUnlock(app);
|
XtAppUnlock(app);
|
||||||
|
lcd_display_redraw=false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef LCD_REMOTE_HEIGHT
|
#ifdef LCD_REMOTE_HEIGHT
|
||||||
|
|
@ -148,8 +150,9 @@ void lcd_remote_update_rect(int x_start, int y_start,
|
||||||
int bit;
|
int bit;
|
||||||
int xmax;
|
int xmax;
|
||||||
int ymax;
|
int ymax;
|
||||||
struct coordinate points[LCD_WIDTH * LCD_HEIGHT];
|
struct coordinate points[LCD_REMOTE_WIDTH * LCD_REMOTE_HEIGHT];
|
||||||
int colors[LCD_WIDTH * LCD_HEIGHT];
|
int colors[LCD_REMOTE_WIDTH * LCD_REMOTE_HEIGHT];
|
||||||
|
unsigned force_mask = lcd_display_redraw ? 0xFF : 0;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
fprintf(stderr, "%04d: lcd_update_rect(%d, %d, %d, %d)\n",
|
fprintf(stderr, "%04d: lcd_update_rect(%d, %d, %d, %d)\n",
|
||||||
|
|
@ -169,28 +172,20 @@ void lcd_remote_update_rect(int x_start, int y_start,
|
||||||
for(; yline <= ymax; yline++) {
|
for(; yline <= ymax; yline++) {
|
||||||
y = yline * 8;
|
y = yline * 8;
|
||||||
for(x = x_start; x < xmax; x++) {
|
for(x = x_start; x < xmax; x++) {
|
||||||
if(lcd_remote_framebuffer[yline][x] ||
|
unsigned char diff = (lcd_remote_framebuffer[yline][x]
|
||||||
lcd_remote_framebuffer_copy[yline][x]) {
|
^ lcd_remote_framebuffer_copy[yline][x])
|
||||||
/* one or more bits/pixels are changed */
|
| force_mask;
|
||||||
unsigned char diff =
|
if(diff) {
|
||||||
lcd_remote_framebuffer[yline][x] ^
|
unsigned char mask = 1;
|
||||||
lcd_remote_framebuffer_copy[yline][x];
|
|
||||||
|
|
||||||
for(bit = 0; bit < 8; bit++) {
|
for(bit = 0; bit < 8; bit++) {
|
||||||
if(lcd_remote_framebuffer[yline][x]&(1<<bit)) {
|
if(diff & mask) {
|
||||||
/* set a dot */
|
unsigned int col = lcd_remote_framebuffer[yline][x] & mask;
|
||||||
colors[p]=3;
|
colors[p] = col ? 3 : 0;
|
||||||
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;
|
|
||||||
points[p].x = x + MARGIN_X;
|
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 */
|
p++; /* increase the point counter */
|
||||||
}
|
}
|
||||||
|
mask <<= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* update the copy */
|
/* update the copy */
|
||||||
|
|
@ -205,6 +200,7 @@ void lcd_remote_update_rect(int x_start, int y_start,
|
||||||
XtAppLock(app);
|
XtAppLock(app);
|
||||||
XSync(dpy,False);
|
XSync(dpy,False);
|
||||||
XtAppUnlock(app);
|
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 void lcd_print_char(int x, int y);
|
||||||
extern unsigned char lcd_buffer[2][11];
|
extern unsigned char lcd_buffer[2][11];
|
||||||
extern void drawrect(int color, int x1, int y1, int x2, int y2);
|
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];
|
extern unsigned char hardware_buffer_lcd[11][2];
|
||||||
static unsigned char lcd_buffer_copy[11][2];
|
static unsigned char lcd_buffer_copy[11][2];
|
||||||
|
|
|
||||||
|
|
@ -144,7 +144,6 @@ void screen_resized(int width, int height)
|
||||||
XFillRectangle(dpy, window, draw_gc, 0, 0, width*display_zoom,
|
XFillRectangle(dpy, window, draw_gc, 0, 0, width*display_zoom,
|
||||||
height*display_zoom);
|
height*display_zoom);
|
||||||
XtAppUnlock(app);
|
XtAppUnlock(app);
|
||||||
lcd_display_redraw=true;
|
|
||||||
screen_redraw();
|
screen_redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -259,6 +258,7 @@ void screen_redraw()
|
||||||
drawline(1, X2, Y1, X2, Y2);
|
drawline(1, X2, Y1, X2, Y2);
|
||||||
drawline(1, X1, Y2, X2, Y2);
|
drawline(1, X1, Y2, X2, Y2);
|
||||||
drawline(1, X1, Y1, X1, Y2);
|
drawline(1, X1, Y1, X1, Y2);
|
||||||
|
lcd_display_redraw = true;
|
||||||
lcd_update();
|
lcd_update();
|
||||||
#ifdef LCD_REMOTE_HEIGHT
|
#ifdef LCD_REMOTE_HEIGHT
|
||||||
/* draw a border around the remote LCD screen */
|
/* draw a border around the remote LCD screen */
|
||||||
|
|
@ -271,6 +271,7 @@ void screen_redraw()
|
||||||
drawline(1, RX2, RY1, RX2, RY2);
|
drawline(1, RX2, RY1, RX2, RY2);
|
||||||
drawline(1, RX1, RY2, RX2, RY2);
|
drawline(1, RX1, RY2, RX2, RY2);
|
||||||
drawline(1, RX1, RY1, RX1, RY2);
|
drawline(1, RX1, RY1, RX1, RY2);
|
||||||
|
lcd_display_redraw = true;
|
||||||
lcd_remote_update();
|
lcd_remote_update();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue