Pico Graphics: Double buffer scanline conversion

pull/422/head
Mike Bell 2022-07-02 11:49:16 +01:00 zatwierdzone przez Mike Bell
rodzic 05ef0d7f03
commit f341c15fa7
3 zmienionych plików z 18 dodań i 15 usunięć

Wyświetl plik

@ -135,8 +135,9 @@ namespace pimoroni {
// Treat our void* frame_buffer as uint8_t
uint8_t *src = (uint8_t *)frame_buffer;
// Allocate a per-row temporary buffer
uint16_t row_buf[bounds.w];
// Allocate two per-row temporary buffers, as the callback may transfer by DMA
// while we're preparing the next row
uint16_t row_buf[2][bounds.w];
for(auto y = 0; y < bounds.h; y++) {
/*if(scanline_interrupt != nullptr) {
scanline_interrupt(y);
@ -150,11 +151,11 @@ namespace pimoroni {
uint8_t c = src[(bounds.w * y / 2) + (x / 2)];
uint8_t o = (~x & 0b1) * 4; // bit offset within byte
uint8_t b = (c >> o) & 0xf; // bit value shifted to position
row_buf[x] = cache[b];
row_buf[y & 1][x] = cache[b];
}
// Callback to the driver with the row data
callback(row_buf, bounds.w * sizeof(RGB565));
callback(row_buf[y & 1], bounds.w * sizeof(RGB565));
}
}
}
}
}

Wyświetl plik

@ -109,15 +109,16 @@ namespace pimoroni {
// Treat our void* frame_buffer as uint8_t
uint8_t *src = (uint8_t *)frame_buffer;
// Allocate a per-row temporary buffer
uint16_t row_buf[bounds.w];
// Allocate two per-row temporary buffers, as the callback may transfer by DMA
// while we're preparing the next row
uint16_t row_buf[2][bounds.w];
for(auto y = 0; y < bounds.h; y++) {
for(auto x = 0; x < bounds.w; x++) {
row_buf[x] = cache[src[bounds.w * y + x]];
row_buf[y & 1][x] = cache[src[bounds.w * y + x]];
}
// Callback to the driver with the row data
callback(row_buf, bounds.w * sizeof(RGB565));
callback(row_buf[y & 1], bounds.w * sizeof(RGB565));
}
}
}
}
}

Wyświetl plik

@ -84,16 +84,17 @@ namespace pimoroni {
// Treat our void* frame_buffer as uint8_t
uint8_t *src = (uint8_t *)frame_buffer;
// Allocate a per-row temporary buffer
uint16_t row_buf[bounds.w];
// Allocate two per-row temporary buffers, as the callback may transfer by DMA
// while we're preparing the next row
uint16_t row_buf[2][bounds.w];
for(auto y = 0; y < bounds.h; y++) {
for(auto x = 0; x < bounds.w; x++) {
row_buf[x] = rgb332_to_rgb565_lut[*src];
row_buf[y & 1][x] = rgb332_to_rgb565_lut[*src];
src++;
}
// Callback to the driver with the row data
callback(row_buf, bounds.w * sizeof(RGB565));
callback(row_buf[y & 1], bounds.w * sizeof(RGB565));
}
}
}
@ -118,4 +119,4 @@ namespace pimoroni {
}
}
}
}
}