|
@@ -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 ) {
|
|
|
-
|
|
|
- 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
|
|
|
if (Device->ClearWindow) {
|
|
|
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 Width = Device->Width;
|
|
|
// try to do byte processing as much as possible
|
|
|
- int c;
|
|
|
- for (c = x1; c <= x2; c++) {
|
|
|
- int r = y1;
|
|
|
- while (r & 0x07 && r <= y2) GDS_DrawPixelFast( Device, c, r++, Color);
|
|
|
- //for (; (r >> 3) < (y2 >> 3); r++) Device->Framebuffer[(r >> 3) * Width + c] = _Color;
|
|
|
- memset(Device->Framebuffer + (r >> 3) * Width + c, _Color, (y2 - r) >> 3);
|
|
|
- while (r <= y2) GDS_DrawPixelFast( Device, c, r++, Color);
|
|
|
+ for (int r = y1; r <= y2;) {
|
|
|
+ int c = x1;
|
|
|
+ // for a row that is not on a boundary, no optimization possible
|
|
|
+ while (r & 0x07 && r <= y2) {
|
|
|
+ for (c = x1; c <= x2; c++) GDS_DrawPixelFast( Device, c, r, Color);
|
|
|
+ r++;
|
|
|
+ }
|
|
|
+ // 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) {
|
|
@@ -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 Width = Device->Width;
|
|
|
// try to do byte processing as much as possible
|
|
|
- int r;
|
|
|
- for (r = y1; r <= y2; r++) {
|
|
|
+ for (int r = y1; r <= y2; r++) {
|
|
|
int c = x1;
|
|
|
if (c & 0x01) GDS_DrawPixelFast( Device, c++, r, Color);
|
|
|
- //for (; (c >> 1) < (x2 >> 1); c++) Device->Framebuffer[(r * Width + c) >> 1] = _Color;
|
|
|
- memset(Device->Framebuffer + ((r * Width +c) >> 1), _Color, (x2 - c) >> 1);
|
|
|
- if (c < x2) GDS_DrawPixelFast( Device, c, r, Color);
|
|
|
+ int chunk = (x2 - c + 1) >> 1;
|
|
|
+ memset(Device->Framebuffer + ((r * Width + c) >> 1), _Color, chunk);
|
|
|
+ if (c + chunk <= x2) GDS_DrawPixelFast( Device, x2, r, Color);
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
} else {
|
|
|
- int y;
|
|
|
- for (y = y1; y <= y2; y++) {
|
|
|
- int x;
|
|
|
- for (x = x1; x <= x2; x++) {
|
|
|
+ for (int y = y1; y <= y2; y++) {
|
|
|
+ for (int x = x1; x <= x2; x++) {
|
|
|
GDS_DrawPixelFast( Device, x, y, Color);
|
|
|
}
|
|
|
}
|