Pico Graphics: Double buffer scanline conversion
This commit is contained in:
parent
05ef0d7f03
commit
f341c15fa7
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue