Skip to content

Commit

Permalink
rename pushImageARGB to pushAlphaImage
Browse files Browse the repository at this point in the history
  • Loading branch information
lovyan03 committed Aug 12, 2024
1 parent 42f0986 commit b255484
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 7 deletions.
21 changes: 21 additions & 0 deletions src/lgfx/v1/LGFXBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
15 changes: 8 additions & 7 deletions src/lgfx/v1/LGFXBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -568,9 +568,13 @@ namespace lgfx

// T == bgra8888_t or argb8888_t
template<typename T>
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<bgr888_t, T>;
Expand All @@ -584,14 +588,11 @@ namespace lgfx
pc.fp_copy = pixelcopy_t::blend_rgb_fast<rgb332_t, T>;
}
}
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
Expand Down
24 changes: 24 additions & 0 deletions src/lgfx/v1/panel/Panel_Device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
{
Expand Down

0 comments on commit b255484

Please sign in to comment.