Port 2V0-f window input and UI render command bridge

This commit is contained in:
shen
2026-09-22 20:34:45 -07:00
parent 9c30f06083
commit 5590714b16
22 changed files with 693 additions and 182 deletions
@@ -0,0 +1,36 @@
#include "UIRenderCommands.h"
namespace {
std::vector<UIRenderCommand> commands;
int canvas_width = 0;
int canvas_height = 0;
float clip_x1 = 0, clip_y1 = 0, clip_x2 = 0, clip_y2 = 0;
float saved_x1 = 0, saved_y1 = 0, saved_x2 = 0, saved_y2 = 0;
}
void UIRenderSetSize(int width, int height) { canvas_width = width; canvas_height = height; }
void UIRenderGetSize(unsigned* width, unsigned* height) {
if (width) *width = canvas_width;
if (height) *height = canvas_height;
}
void UIRenderBeginFrame() {
commands.clear();
clip_x1 = clip_y1 = 0;
clip_x2 = canvas_width;
clip_y2 = canvas_height;
}
void UIRenderAdd(UIRenderCommand command) {
command.clip_x1 = clip_x1; command.clip_y1 = clip_y1;
command.clip_x2 = clip_x2; command.clip_y2 = clip_y2;
commands.push_back(command);
}
const std::vector<UIRenderCommand>& UIRenderCommands() { return commands; }
void UIRenderSetClip(float x, float y, float width, float height) {
saved_x1 = clip_x1; saved_y1 = clip_y1; saved_x2 = clip_x2; saved_y2 = clip_y2;
clip_x1 = x; clip_y1 = y;
clip_x2 = x + width; clip_y2 = y + height;
}
void UIRenderRestoreClip() {
clip_x1 = saved_x1; clip_y1 = saved_y1;
clip_x2 = saved_x2; clip_y2 = saved_y2;
}