kopia lustrzana https://github.com/pimoroni/pimoroni-pico
Pico Graphics: Double buffer scanline conversion
rodzic
05ef0d7f03
commit
f341c15fa7
|
@ -135,8 +135,9 @@ namespace pimoroni {
|
||||||
// Treat our void* frame_buffer as uint8_t
|
// Treat our void* frame_buffer as uint8_t
|
||||||
uint8_t *src = (uint8_t *)frame_buffer;
|
uint8_t *src = (uint8_t *)frame_buffer;
|
||||||
|
|
||||||
// Allocate a per-row temporary buffer
|
// Allocate two per-row temporary buffers, as the callback may transfer by DMA
|
||||||
uint16_t row_buf[bounds.w];
|
// while we're preparing the next row
|
||||||
|
uint16_t row_buf[2][bounds.w];
|
||||||
for(auto y = 0; y < bounds.h; y++) {
|
for(auto y = 0; y < bounds.h; y++) {
|
||||||
/*if(scanline_interrupt != nullptr) {
|
/*if(scanline_interrupt != nullptr) {
|
||||||
scanline_interrupt(y);
|
scanline_interrupt(y);
|
||||||
|
@ -150,11 +151,11 @@ namespace pimoroni {
|
||||||
uint8_t c = src[(bounds.w * y / 2) + (x / 2)];
|
uint8_t c = src[(bounds.w * y / 2) + (x / 2)];
|
||||||
uint8_t o = (~x & 0b1) * 4; // bit offset within byte
|
uint8_t o = (~x & 0b1) * 4; // bit offset within byte
|
||||||
uint8_t b = (c >> o) & 0xf; // bit value shifted to position
|
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 to the driver with the row data
|
||||||
callback(row_buf, bounds.w * sizeof(RGB565));
|
callback(row_buf[y & 1], bounds.w * sizeof(RGB565));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,15 +109,16 @@ namespace pimoroni {
|
||||||
// Treat our void* frame_buffer as uint8_t
|
// Treat our void* frame_buffer as uint8_t
|
||||||
uint8_t *src = (uint8_t *)frame_buffer;
|
uint8_t *src = (uint8_t *)frame_buffer;
|
||||||
|
|
||||||
// Allocate a per-row temporary buffer
|
// Allocate two per-row temporary buffers, as the callback may transfer by DMA
|
||||||
uint16_t row_buf[bounds.w];
|
// while we're preparing the next row
|
||||||
|
uint16_t row_buf[2][bounds.w];
|
||||||
for(auto y = 0; y < bounds.h; y++) {
|
for(auto y = 0; y < bounds.h; y++) {
|
||||||
for(auto x = 0; x < bounds.w; x++) {
|
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 to the driver with the row data
|
||||||
callback(row_buf, bounds.w * sizeof(RGB565));
|
callback(row_buf[y & 1], bounds.w * sizeof(RGB565));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,16 +84,17 @@ namespace pimoroni {
|
||||||
// Treat our void* frame_buffer as uint8_t
|
// Treat our void* frame_buffer as uint8_t
|
||||||
uint8_t *src = (uint8_t *)frame_buffer;
|
uint8_t *src = (uint8_t *)frame_buffer;
|
||||||
|
|
||||||
// Allocate a per-row temporary buffer
|
// Allocate two per-row temporary buffers, as the callback may transfer by DMA
|
||||||
uint16_t row_buf[bounds.w];
|
// while we're preparing the next row
|
||||||
|
uint16_t row_buf[2][bounds.w];
|
||||||
for(auto y = 0; y < bounds.h; y++) {
|
for(auto y = 0; y < bounds.h; y++) {
|
||||||
for(auto x = 0; x < bounds.w; x++) {
|
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++;
|
src++;
|
||||||
}
|
}
|
||||||
// Callback to the driver with the row data
|
// 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 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue