faster gdi text rendering
All checks were successful
pyrite-dev/milsko/pipeline/head This commit looks good
All checks were successful
pyrite-dev/milsko/pipeline/head This commit looks good
This commit is contained in:
parent
6bc00c6dca
commit
bc5fc10816
4 changed files with 50 additions and 35 deletions
|
|
@ -34,6 +34,7 @@ struct _MwLLGDI {
|
||||||
struct _MwLLGDIColor {
|
struct _MwLLGDIColor {
|
||||||
struct _MwLLCommonColor common;
|
struct _MwLLCommonColor common;
|
||||||
|
|
||||||
|
COLORREF color;
|
||||||
HBRUSH brush;
|
HBRUSH brush;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -502,7 +502,8 @@ static void MwLLColorUpdateImpl(MwLL handle, MwLLColor c, int r, int g, int b) {
|
||||||
if(b < 0) b = 0;
|
if(b < 0) b = 0;
|
||||||
|
|
||||||
if(c->gdi.brush != NULL) DeleteObject(c->gdi.brush);
|
if(c->gdi.brush != NULL) DeleteObject(c->gdi.brush);
|
||||||
c->gdi.brush = CreateSolidBrush(GetNearestColor(dc, RGB(r, g, b)));
|
c->gdi.color = GetNearestColor(dc, RGB(r, g, b));
|
||||||
|
c->gdi.brush = CreateSolidBrush(c->gdi.color);
|
||||||
c->common.red = r;
|
c->common.red = r;
|
||||||
c->common.green = g;
|
c->common.green = g;
|
||||||
c->common.blue = b;
|
c->common.blue = b;
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,20 @@ static int GDI_MwDrawText(MwWidget handle, MwFLFont ttf, MwPoint* point, const c
|
||||||
tw = MwTextWidth(handle, ttf, text);
|
tw = MwTextWidth(handle, ttf, text);
|
||||||
th = MwTextHeight(handle, ttf, text);
|
th = MwTextHeight(handle, ttf, text);
|
||||||
|
|
||||||
|
if(handle->lowlevel->common.type == MwLLBackendGDI) {
|
||||||
|
HFONT old_font = SelectObject(handle->lowlevel->gdi.hDC, ttf->font);
|
||||||
|
int old_bkmode = SetBkMode(handle->lowlevel->gdi.hDC, TRANSPARENT);
|
||||||
|
COLORREF old_color = SetTextColor(handle->lowlevel->gdi.hDC, color->gdi.color);
|
||||||
|
|
||||||
|
TextOut(handle->lowlevel->gdi.hDC, point->x, point->y - th / 2, t, strlen(t));
|
||||||
|
|
||||||
|
SetTextColor(handle->lowlevel->gdi.hDC, old_color);
|
||||||
|
SetBkMode(handle->lowlevel->gdi.hDC, old_bkmode);
|
||||||
|
SelectObject(handle->lowlevel->gdi.hDC, old_font);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
px = malloc(tw * th * 4);
|
px = malloc(tw * th * 4);
|
||||||
|
|
||||||
bmih.biSize = sizeof(bmih);
|
bmih.biSize = sizeof(bmih);
|
||||||
|
|
@ -69,7 +83,6 @@ static int GDI_MwDrawText(MwWidget handle, MwFLFont ttf, MwPoint* point, const c
|
||||||
free(px);
|
free(px);
|
||||||
|
|
||||||
DeleteObject(hbm);
|
DeleteObject(hbm);
|
||||||
|
|
||||||
free(t);
|
free(t);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue