make gdi rendering a little bit faster

This commit is contained in:
NishiOwO
2025-12-07 07:10:20 +09:00
parent c2e960fe59
commit 71cb96b06e
3 changed files with 17 additions and 9 deletions

View File

@@ -20,6 +20,7 @@ struct _MwLLGDI {
HICON icon; HICON icon;
int grabbed; int grabbed;
int force_render;
}; };
struct _MwLLGDIColor { struct _MwLLGDIColor {

View File

@@ -19,6 +19,8 @@ static LRESULT CALLBACK wndproc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) {
HBITMAP hbmp; HBITMAP hbmp;
HDC dc, hbdc; HDC dc, hbdc;
u->ll->gdi.force_render = 0;
if(u->ll->common.copy_buffer) { if(u->ll->common.copy_buffer) {
GetClientRect(hWnd, &rc); GetClientRect(hWnd, &rc);
@@ -235,6 +237,7 @@ static MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) {
r->common.copy_buffer = 1; r->common.copy_buffer = 1;
r->common.type = MwLLBackendGDI; r->common.type = MwLLBackendGDI;
r->gdi.force_render = 0;
r->gdi.grabbed = 0; r->gdi.grabbed = 0;
r->gdi.hWnd = CreateWindow("milsko", "Milsko", parent == NULL ? (WS_OVERLAPPEDWINDOW) : (WS_CHILD | WS_VISIBLE), x == MwDEFAULT ? CW_USEDEFAULT : x, y == MwDEFAULT ? CW_USEDEFAULT : y, width, height, parent == NULL ? NULL : parent->gdi.hWnd, 0, wc.hInstance, NULL); r->gdi.hWnd = CreateWindow("milsko", "Milsko", parent == NULL ? (WS_OVERLAPPEDWINDOW) : (WS_CHILD | WS_VISIBLE), x == MwDEFAULT ? CW_USEDEFAULT : x, y == MwDEFAULT ? CW_USEDEFAULT : y, width, height, parent == NULL ? NULL : parent->gdi.hWnd, 0, wc.hInstance, NULL);
r->gdi.hInstance = wc.hInstance; r->gdi.hInstance = wc.hInstance;
@@ -515,7 +518,11 @@ static void MwLLSetIconImpl(MwLL handle, MwLLPixmap pixmap) {
} }
static void MwLLForceRenderImpl(MwLL handle) { static void MwLLForceRenderImpl(MwLL handle) {
if(!handle->gdi.force_render) {
PostMessage(handle->gdi.hWnd, WM_USER, 0, 0); PostMessage(handle->gdi.hWnd, WM_USER, 0, 0);
handle->gdi.force_render = 1;
}
} }
static void MwLLSetCursorImpl(MwLL handle, MwCursor* image, MwCursor* mask) { static void MwLLSetCursorImpl(MwLL handle, MwCursor* image, MwCursor* mask) {

View File

@@ -773,10 +773,10 @@ static void MwLLSetIconImpl(MwLL handle, MwLLPixmap pixmap) {
} }
static void MwLLForceRenderImpl(MwLL handle) { static void MwLLForceRenderImpl(MwLL handle) {
if(!handle->x11.force_render) {
XEvent ev; XEvent ev;
memset(&ev, 0, sizeof(ev)); memset(&ev, 0, sizeof(ev));
if(!handle->x11.force_render) {
ev.type = Expose; ev.type = Expose;
ev.xexpose.window = handle->x11.window; ev.xexpose.window = handle->x11.window;
XSendEvent(handle->x11.display, handle->x11.window, False, ExposureMask, &ev); XSendEvent(handle->x11.display, handle->x11.window, False, ExposureMask, &ev);