DMA used for ARGB4444 bitmaps
This commit is contained in:
@@ -162,14 +162,7 @@ class BitmapBuffer: public BitmapBufferBase<uint16_t>
|
||||
if (y + h > height) {
|
||||
h = height - y;
|
||||
}
|
||||
if (srcw == w) {
|
||||
DMACopyBitmap(data, width, x, y, &bmp->data[srcw*srcy], srcw, h);
|
||||
}
|
||||
else {
|
||||
for (int i=0; i<h; i++) {
|
||||
DMACopyBitmap(data, width, x, y+i, &bmp->data[srcw*(srcy+i)+srcx], w, 1);
|
||||
}
|
||||
}
|
||||
DMACopyBitmap(data, width, x, y, bmp->data, srcw, srcx, srcy, w, h);
|
||||
}
|
||||
else {
|
||||
int scaledw = w * scale;
|
||||
@@ -218,14 +211,7 @@ class BitmapBuffer: public BitmapBufferBase<uint16_t>
|
||||
return;
|
||||
}
|
||||
|
||||
for (coord_t line=0; line<height; line++) {
|
||||
display_t * p = getPixelPtr(x, y+line);
|
||||
const uint8_t * q = ((uint8_t *)bmp->data) + line*width*2;
|
||||
for (coord_t col=0; col<width; col++) {
|
||||
drawAlphaPixel(p, q[1] >> 4, ((q[1] & 0x0f) << 12) + ((q[0] & 0xf0) << 3) + ((q[0] & 0x0f) << 1));
|
||||
p++; q+=2;
|
||||
}
|
||||
}
|
||||
DMACopyAlphaBitmap(data, this->width, x, y, bmp->data, width, height);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -671,10 +671,26 @@ void DMAFillRect(uint16_t * dest, uint16_t destw, uint16_t x, uint16_t y, uint16
|
||||
}
|
||||
}
|
||||
|
||||
void DMACopyBitmap(uint16_t * dest, uint16_t destw, uint16_t x, uint16_t y, const uint16_t * src, uint16_t srcw, uint16_t h)
|
||||
void DMACopyBitmap(uint16_t * dest, uint16_t destw, uint16_t x, uint16_t y, const uint16_t * src, uint16_t srcw, uint16_t srcx, uint16_t srcy, uint16_t w, uint16_t h)
|
||||
{
|
||||
for (int i=0; i<h; i++) {
|
||||
memcpy(dest+(y+i)*destw+x, src+i*srcw, 2*srcw);
|
||||
memcpy(dest+(y+i)*destw+x, src+(srcy+i)*srcw+srcx, 2*w);
|
||||
}
|
||||
}
|
||||
|
||||
void DMACopyAlphaBitmap(uint16_t * dest, uint16_t destw, uint16_t x, uint16_t y, const uint16_t * src, uint16_t srcw, uint16_t h)
|
||||
{
|
||||
for (coord_t line=0; line<h; line++) {
|
||||
uint16_t * p = dest + (y+line)*destw + x;
|
||||
const uint16_t * q = src + line*srcw;
|
||||
for (coord_t col=0; col<srcw; col++) {
|
||||
uint8_t alpha = *q >> 12;
|
||||
uint8_t red = ((((*q >> 8) & 0x0f) << 1) * alpha + (*p >> 11) * (0x0f-alpha)) / 0x0f;
|
||||
uint8_t green = ((((*q >> 4) & 0x0f) << 2) * alpha + ((*p >> 5) & 0x3f) * (0x0f-alpha)) / 0x0f;
|
||||
uint8_t blue = ((((*q >> 0) & 0x0f) << 1) * alpha + ((*p >> 0) & 0x1f) * (0x0f-alpha)) / 0x0f;
|
||||
*p = (red << 11) + (green << 5) + (blue << 0);
|
||||
p++; q++;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user