animations
This commit is contained in:
parent
721ff8f42f
commit
e4dda0861c
8 changed files with 161 additions and 4 deletions
|
|
@ -163,8 +163,8 @@ void RenderElement(UiElementBufferBuffer* element, WindowWayland* window) {
|
|||
std::vector<Pixel_BU8_GU8_RU8_AU8> scaled(element->transform.scaled.width*element->transform.scaled.height);
|
||||
element->CopyNearestNeighbour(scaled.data(), element->transform.scaled.width, element->transform.scaled.height);
|
||||
|
||||
for (std::int32_t x = element->transform.scaled.x; x - element->transform.scaled.x < element->transform.scaled.width; x++) {
|
||||
for (std::int32_t y = element->transform.scaled.y; y - element->transform.scaled.y < element->transform.scaled.height; y++) {
|
||||
for (std::int_fast32_t x = element->transform.scaled.x; x - element->transform.scaled.x < element->transform.scaled.width; x++) {
|
||||
for (std::int_fast32_t y = element->transform.scaled.y; y - element->transform.scaled.y < element->transform.scaled.height; y++) {
|
||||
if (x >= 0 && x < window->width && y >= 0 && y < window->height) {
|
||||
Pixel_BU8_GU8_RU8_AU8& dst = window->framebuffer[y * window->width + x];
|
||||
const Pixel_BU8_GU8_RU8_AU8& src = scaled[(y - element->transform.scaled.y) * element->transform.scaled.width + (x - element->transform.scaled.x)];
|
||||
|
|
@ -191,6 +191,12 @@ void RenderElement(UiElementBufferBuffer* element, WindowWayland* window) {
|
|||
void WindowWayland::Render() {
|
||||
std::sort(elements.begin(), elements.end(), [](UiElementBufferBuffer* a, UiElementBufferBuffer* b){ return a->transform.z < b->transform.z; });
|
||||
|
||||
for (std::int_fast32_t x = 0; x < width; x++) {
|
||||
for (std::int_fast32_t y = 0; y - height; y++) {
|
||||
framebuffer[y * width + x] = {0,0,0,0};
|
||||
}
|
||||
}
|
||||
|
||||
for(UiElementBufferBuffer* element : elements) {
|
||||
RenderElement(element, this);
|
||||
}
|
||||
|
|
@ -251,12 +257,17 @@ void WindowWayland::wl_surface_frame_done(void* data, struct wl_callback *cb, ui
|
|||
wl_callback_destroy(cb);
|
||||
WindowWayland* window = reinterpret_cast<WindowWayland*>(data);
|
||||
|
||||
auto start = std::chrono::high_resolution_clock::now();
|
||||
|
||||
if(window->updating) {
|
||||
cb = wl_surface_frame(window->surface);
|
||||
wl_callback_add_listener(cb, &WindowWayland::wl_callback_listener, window);
|
||||
window->onUpdate.Invoke({start, start-window->lastFrameEnd});
|
||||
}
|
||||
|
||||
window->Render();
|
||||
|
||||
window->lastFrameEnd = start;
|
||||
}
|
||||
|
||||
void WindowWayland::pointer_handle_button(void* data, wl_pointer* pointer, std::uint32_t serial, std::uint32_t time, std::uint32_t button, std::uint32_t state) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue