wind+libui: Ignore alpha bits in the window buffer

This commit is contained in:
apio 2024-03-31 13:38:39 +02:00
parent 5087b6db30
commit a863b17746
Signed by: apio
GPG Key ID: B8A7D06E42258954
3 changed files with 22 additions and 1 deletions

View File

@ -69,5 +69,13 @@ namespace ui
* @param stride The number of pixels to skip to go to the next line.
*/
void fill(u32* pixels, int stride);
/**
* @brief Fill the canvas with pixels, without doing any extra processing.
*
* @param pixels The array of pixels (must be at least width*height).
* @param stride The number of pixels to skip to go to the next line.
*/
void copy(u32* pixels, int stride);
};
};

View File

@ -7,6 +7,7 @@
*
*/
#include <luna/CString.h>
#include <ui/Canvas.h>
namespace ui
@ -59,4 +60,16 @@ namespace ui
p += stride * sizeof(Color);
}
}
void Canvas::copy(u32* pixels, int _stride)
{
u8* p = ptr;
for (int i = 0; i < height; i++)
{
u32* colorp = (u32*)p;
memcpy(colorp, pixels, width * sizeof(u32));
pixels += _stride;
p += stride * sizeof(Color);
}
}
}

View File

@ -12,7 +12,7 @@ void Window::draw(ui::Canvas& screen)
dirty = false;
auto window = screen.subcanvas(surface);
window.fill(pixels, surface.width);
window.copy(pixels, surface.width);
}
void Window::focus()