mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-09 21:17:18 +03:00
Fixed ClearWindow & few scroller tweaks
systematic verification of ClearWindow done ...
This commit is contained in:
@@ -60,14 +60,6 @@ void GDS_Clear( struct GDS_Device* Device, int Color ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GDS_ClearWindow( struct GDS_Device* Device, int x1, int y1, int x2, int y2, int Color ) {
|
void GDS_ClearWindow( struct GDS_Device* Device, int x1, int y1, int x2, int y2, int Color ) {
|
||||||
|
|
||||||
for (int y = y1; y <= y2; y++) {
|
|
||||||
for (int x = x1; x <= x2; x++) {
|
|
||||||
GDS_DrawPixelFast( Device, x, y, Color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
|
|
||||||
// driver can provide own optimized clear window
|
// driver can provide own optimized clear window
|
||||||
if (Device->ClearWindow) {
|
if (Device->ClearWindow) {
|
||||||
Device->ClearWindow( Device, x1, y1, x2, y2, Color );
|
Device->ClearWindow( Device, x1, y1, x2, y2, Color );
|
||||||
@@ -79,13 +71,21 @@ void GDS_ClearWindow( struct GDS_Device* Device, int x1, int y1, int x2, int y2,
|
|||||||
uint8_t _Color = Color == GDS_COLOR_BLACK ? 0: 0xff;
|
uint8_t _Color = Color == GDS_COLOR_BLACK ? 0: 0xff;
|
||||||
uint8_t Width = Device->Width;
|
uint8_t Width = Device->Width;
|
||||||
// try to do byte processing as much as possible
|
// try to do byte processing as much as possible
|
||||||
int c;
|
for (int r = y1; r <= y2;) {
|
||||||
for (c = x1; c <= x2; c++) {
|
int c = x1;
|
||||||
int r = y1;
|
// for a row that is not on a boundary, no optimization possible
|
||||||
while (r & 0x07 && r <= y2) GDS_DrawPixelFast( Device, c, r++, Color);
|
while (r & 0x07 && r <= y2) {
|
||||||
//for (; (r >> 3) < (y2 >> 3); r++) Device->Framebuffer[(r >> 3) * Width + c] = _Color;
|
for (c = x1; c <= x2; c++) GDS_DrawPixelFast( Device, c, r, Color);
|
||||||
memset(Device->Framebuffer + (r >> 3) * Width + c, _Color, (y2 - r) >> 3);
|
r++;
|
||||||
while (r <= y2) GDS_DrawPixelFast( Device, c, r++, Color);
|
}
|
||||||
|
// go fast if we have more than 8 lines to write
|
||||||
|
if (r + 8 < y2) {
|
||||||
|
memset(Device->Framebuffer + Width * r / 8 + x1, _Color, x2 - x1 + 1);
|
||||||
|
r += 8;
|
||||||
|
} else while (r <= y2) {
|
||||||
|
for (c = x1; c <= x2; c++) GDS_DrawPixelFast( Device, c, r, Color);
|
||||||
|
r++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} if (Device->Depth == 4) {
|
} if (Device->Depth == 4) {
|
||||||
@@ -96,20 +96,17 @@ void GDS_ClearWindow( struct GDS_Device* Device, int x1, int y1, int x2, int y2,
|
|||||||
uint8_t _Color = Color | (Color << 4);
|
uint8_t _Color = Color | (Color << 4);
|
||||||
uint8_t Width = Device->Width;
|
uint8_t Width = Device->Width;
|
||||||
// try to do byte processing as much as possible
|
// try to do byte processing as much as possible
|
||||||
int r;
|
for (int r = y1; r <= y2; r++) {
|
||||||
for (r = y1; r <= y2; r++) {
|
|
||||||
int c = x1;
|
int c = x1;
|
||||||
if (c & 0x01) GDS_DrawPixelFast( Device, c++, r, Color);
|
if (c & 0x01) GDS_DrawPixelFast( Device, c++, r, Color);
|
||||||
//for (; (c >> 1) < (x2 >> 1); c++) Device->Framebuffer[(r * Width + c) >> 1] = _Color;
|
int chunk = (x2 - c + 1) >> 1;
|
||||||
memset(Device->Framebuffer + ((r * Width +c) >> 1), _Color, (x2 - c) >> 1);
|
memset(Device->Framebuffer + ((r * Width + c) >> 1), _Color, chunk);
|
||||||
if (c < x2) GDS_DrawPixelFast( Device, c, r, Color);
|
if (c + chunk <= x2) GDS_DrawPixelFast( Device, x2, r, Color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int y;
|
for (int y = y1; y <= y2; y++) {
|
||||||
for (y = y1; y <= y2; y++) {
|
for (int x = x1; x <= x2; x++) {
|
||||||
int x;
|
|
||||||
for (x = x1; x <= x2; x++) {
|
|
||||||
GDS_DrawPixelFast( Device, x, y, Color);
|
GDS_DrawPixelFast( Device, x, y, Color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -500,8 +500,9 @@ static void grfe_handler( u8_t *data, int len) {
|
|||||||
displayer.dirty = false;
|
displayer.dirty = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw new frame
|
// draw new frame, it might be less than full screen (small visu)
|
||||||
GDS_DrawBitmapCBR(display, data + sizeof(struct grfe_packet), displayer.width, displayer.height, GDS_COLOR_WHITE);
|
int width = ((len - sizeof(struct grfe_packet)) * 8) / displayer.height;
|
||||||
|
GDS_DrawBitmapCBR(display, data + sizeof(struct grfe_packet), width, displayer.height, GDS_COLOR_WHITE);
|
||||||
GDS_Update(display);
|
GDS_Update(display);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -561,7 +562,7 @@ static void grfs_handler(u8_t *data, int len) {
|
|||||||
|
|
||||||
// background excludes space taken by visu (if any)
|
// background excludes space taken by visu (if any)
|
||||||
scroller.back.width = displayer.width - ((visu.mode && visu.row < SB_HEIGHT) ? visu.width : 0);
|
scroller.back.width = displayer.width - ((visu.mode && visu.row < SB_HEIGHT) ? visu.width : 0);
|
||||||
|
|
||||||
// set scroller steps & beginning
|
// set scroller steps & beginning
|
||||||
if (pkt->direction == 1) {
|
if (pkt->direction == 1) {
|
||||||
scroller.scrolled = 0;
|
scroller.scrolled = 0;
|
||||||
@@ -779,6 +780,9 @@ static void visu_handler( u8_t *data, int len) {
|
|||||||
visu.border = htonl(pkt->border);
|
visu.border = htonl(pkt->border);
|
||||||
bars = htonl(pkt->bars);
|
bars = htonl(pkt->bars);
|
||||||
visu.spectrum_scale = htonl(pkt->spectrum_scale) / 100.;
|
visu.spectrum_scale = htonl(pkt->spectrum_scale) / 100.;
|
||||||
|
|
||||||
|
// might have a race condition with scroller message, so update width in case
|
||||||
|
if (scroller.active) scroller.back.width = displayer.width - visu.width;
|
||||||
} else {
|
} else {
|
||||||
// full screen visu, try to use bottom screen if available
|
// full screen visu, try to use bottom screen if available
|
||||||
visu.width = displayer.width;
|
visu.width = displayer.width;
|
||||||
|
|||||||
Reference in New Issue
Block a user