diff --git a/src/lgfx/v1/LGFXBase.cpp b/src/lgfx/v1/LGFXBase.cpp index 2f132e07..ac616615 100644 --- a/src/lgfx/v1/LGFXBase.cpp +++ b/src/lgfx/v1/LGFXBase.cpp @@ -1441,6 +1441,27 @@ namespace lgfx endWrite(); } + void LGFXBase::pushAlphaImage(int32_t x, int32_t y, int32_t w, int32_t h, pixelcopy_t *param) + { + uint32_t x_mask = 7 >> (param->src_bits >> 1); + param->src_bitwidth = (w + x_mask) & (~x_mask); + + int32_t dx=0, dw=w; + if (0 < _clip_l - x) { dx = _clip_l - x; dw -= dx; x = _clip_l; } + + if (_adjust_width(x, dx, dw, _clip_l, _clip_r - _clip_l + 1)) return; + param->src_x32 = param->src_x32_add * dx; + + int32_t dy=0, dh=h; + if (0 < _clip_t - y) { dy = _clip_t - y; dh -= dy; y = _clip_t; } + if (_adjust_width(y, dy, dh, _clip_t, _clip_b - _clip_t + 1)) return; + param->src_y = dy; + + startWrite(); + _panel->writeImageARGB(x, y, dw, dh, param); + endWrite(); + } + void LGFXBase::make_rotation_matrix(float* result, float dst_x, float dst_y, float src_x, float src_y, float angle, float zoom_x, float zoom_y) { float rad = fmodf(angle, 360) * deg_to_rad; diff --git a/src/lgfx/v1/LGFXBase.hpp b/src/lgfx/v1/LGFXBase.hpp index ec96117e..a20369e0 100644 --- a/src/lgfx/v1/LGFXBase.hpp +++ b/src/lgfx/v1/LGFXBase.hpp @@ -568,9 +568,13 @@ namespace lgfx // T == bgra8888_t or argb8888_t template - void pushImageARGB(int32_t x, int32_t y, int32_t w, int32_t h, const T* data) + void pushAlphaImage(int32_t x, int32_t y, int32_t w, int32_t h, const T* data) { auto pc = create_pc(data); + + // not support 1, 2, 4, and palette mode. + if (pc.dst_bits < 8 || this->hasPalette()) { return; } + if (pc.dst_bits > 16) { if (pc.dst_depth == rgb888_3Byte) { pc.fp_copy = pixelcopy_t::blend_rgb_fast; @@ -584,14 +588,11 @@ namespace lgfx pc.fp_copy = pixelcopy_t::blend_rgb_fast; } } - pc.src_bitwidth = w; - pc.src_width = w; - pc.src_height = h; - startWrite(); - _panel->writeImageARGB(x, y, w, h, &pc); - endWrite(); + pushAlphaImage(x, y, w, h, &pc); } + void pushAlphaImage(int32_t x, int32_t y, int32_t w, int32_t h, pixelcopy_t *param); + //---------------------------------------------------------------------------- /// read RGB565 16bit color diff --git a/src/lgfx/v1/panel/Panel_Device.cpp b/src/lgfx/v1/panel/Panel_Device.cpp index f8c7c6b9..f876716d 100644 --- a/src/lgfx/v1/panel/Panel_Device.cpp +++ b/src/lgfx/v1/panel/Panel_Device.cpp @@ -178,7 +178,30 @@ namespace lgfx } //---------------------------------------------------------------------------- + void Panel_Device::writeImageARGB(uint_fast16_t x, uint_fast16_t y, uint_fast16_t w, uint_fast16_t h, pixelcopy_t* param) + { + auto src_x = param->src_x; + auto bytes = param->dst_bits >> 3; + pixelcopy_t pc_read(nullptr, _write_depth, _read_depth); + pixelcopy_t pc_write(nullptr, _write_depth, _write_depth); + for (;;) + { + uint8_t* dmabuf = _bus->getDMABuffer((w+1) * bytes); + pc_write.src_data = dmabuf; + readRect(x, y, w, 1, dmabuf, &pc_read); + { + param->fp_copy(dmabuf, 0, w, param); + pc_write.src_x = 0; + writeImage(x, y, w, 1, &pc_write, true); + } + if (!--h) return; + param->src_x = src_x; + param->src_y++; + ++y; + } + } +#if 0 void Panel_Device::writeImageARGB(uint_fast16_t x, uint_fast16_t y, uint_fast16_t w, uint_fast16_t h, pixelcopy_t* param) { auto src_x = param->src_x; @@ -237,6 +260,7 @@ namespace lgfx ++y; } } +#endif void Panel_Device::copyRect(uint_fast16_t dst_x, uint_fast16_t dst_y, uint_fast16_t w, uint_fast16_t h, uint_fast16_t src_x, uint_fast16_t src_y) {