diff options
author | Jan Holesovsky <kendy@collabora.com> | 2014-11-14 13:58:09 +0100 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2014-11-15 13:51:03 +0100 |
commit | 5b924866e70359b295a4ecdd39430fa2217b8a81 (patch) | |
tree | 2420e856f82c1588b19a8b4fa10541e80371da09 | |
parent | 30c6b2f1ec9dd2a639c5bcabeb7fa1afc15a1c17 (diff) |
windows opengl: Finally got the text working.
It still does not have a transparent background, but that is pending support in
OpenGLSalGraphicsImpl.
Change-Id: I477a483e6ac940f54f6ffd6816d753d87206bf23
-rw-r--r-- | vcl/win/source/gdi/winlayout.cxx | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/vcl/win/source/gdi/winlayout.cxx b/vcl/win/source/gdi/winlayout.cxx index 480e1a00baf1..7f6fdc9729e2 100644 --- a/vcl/win/source/gdi/winlayout.cxx +++ b/vcl/win/source/gdi/winlayout.cxx @@ -192,27 +192,38 @@ void WinLayout::DrawText(SalGraphics& rGraphics) const // TODO: check the performance of this 2nd approach at some stage and // switch to that if it performs well. - // FIXME so that we don't have to use enormous bitmap, move the text - // to 0,0, size the width / height accordingly, and move it back via - // SalTwoRects later - const int width = 1024; - const int height = 1024; + Rectangle aRect; + GetBoundRect(rGraphics, aRect); + + const int origin_x = aRect.Left(); + const int origin_y = aRect.Top(); + const int width = aRect.GetWidth(); + const int height = aRect.GetHeight(); const int bpp = 32; HDC compatibleDC = CreateCompatibleDC(hDC); + // move the origin so that we always paint at 0,0 - to keep the bitmap + // small + OffsetViewportOrgEx(compatibleDC, -origin_x, -origin_y, NULL); + sal_uInt8 *data; HBITMAP hBitmap = WinSalVirtualDevice::ImplCreateVirDevBitmap(compatibleDC, width, height, bpp, reinterpret_cast<void **>(&data)); - // FIXME fill transparent instead of 128, this is for testing - memset(data, 128, width*height*4); - // draw the text to the hidden DC with black color and white - // background, we will use the result later as a mask only + // setup the hidden DC with black color and white background, we will + // use the result of the text drawing later as a mask only HGDIOBJ hBitmapOld = SelectObject(compatibleDC, hBitmap); SelectFont(compatibleDC, mhFont); + SetTextColor(compatibleDC, RGB(0, 0, 0)); SetBkColor(compatibleDC, RGB(255, 255, 255)); + + UINT nTextAlign = GetTextAlign(hDC); + SetTextAlign(compatibleDC, nTextAlign); + + // the actual drawing DrawTextImpl(compatibleDC); + SelectObject(compatibleDC, hBitmapOld); // and turn it into a texture @@ -227,8 +238,8 @@ void WinLayout::DrawText(SalGraphics& rGraphics) const aRects.mnSrcY = 0; aRects.mnSrcWidth = width; aRects.mnSrcHeight = height; - aRects.mnDestX = 0; - aRects.mnDestY = 0; + aRects.mnDestX = origin_x; + aRects.mnDestY = origin_y; aRects.mnDestWidth = width; aRects.mnDestHeight = height; |