From f8db78deb32adc9340f8bcc53598f33eba9369e9 Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Fri, 21 Mar 2003 11:23:06 +0000 Subject: Optimising by not drawing space characters in transparent mode. --- win32/PlatWin.cxx | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx index 1636e6c94..2d51b4023 100644 --- a/win32/PlatWin.cxx +++ b/win32/PlatWin.cxx @@ -557,22 +557,28 @@ void SurfaceImpl::DrawTextClipped(PRectangle rc, Font &font_, int ybase, const c void SurfaceImpl::DrawTextTransparent(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore) { - SetFont(font_); - ::SetTextColor(hdc, fore.AsLong()); - ::SetBkMode(hdc, TRANSPARENT); - RECT rcw = RectFromPRectangle(rc); - if (unicodeMode) { - wchar_t tbuf[MAX_US_LEN]; - int tlen = UCS2FromUTF8(s, len, tbuf, sizeof(tbuf)/sizeof(wchar_t)-1); - tbuf[tlen] = L'\0'; - ::ExtTextOutW(hdc, rc.left, ybase, 0, &rcw, tbuf, tlen, NULL); - } else { - // There appears to be a 16 bit string length limit in GDI - if (len > 65535) - len = 65535; - ::ExtTextOut(hdc, rc.left, ybase, 0, &rcw, s, len, NULL); + // Avoid drawing spaces in transparent mode + for (int i=0;i 65535) + len = 65535; + ::ExtTextOut(hdc, rc.left, ybase, 0, &rcw, s, len, NULL); + } + ::SetBkMode(hdc, OPAQUE); + return; + } } - ::SetBkMode(hdc, OPAQUE); } int SurfaceImpl::WidthText(Font &font_, const char *s, int len) { -- cgit v1.2.3