Kaydet (Commit) 5b924866 authored tarafından Jan Holesovsky's avatar Jan Holesovsky Kaydeden (comit) Markus Mohrhard

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
üst 30c6b2f1
...@@ -192,27 +192,38 @@ void WinLayout::DrawText(SalGraphics& rGraphics) const ...@@ -192,27 +192,38 @@ void WinLayout::DrawText(SalGraphics& rGraphics) const
// TODO: check the performance of this 2nd approach at some stage and // TODO: check the performance of this 2nd approach at some stage and
// switch to that if it performs well. // switch to that if it performs well.
// FIXME so that we don't have to use enormous bitmap, move the text Rectangle aRect;
// to 0,0, size the width / height accordingly, and move it back via GetBoundRect(rGraphics, aRect);
// SalTwoRects later
const int width = 1024; const int origin_x = aRect.Left();
const int height = 1024; const int origin_y = aRect.Top();
const int width = aRect.GetWidth();
const int height = aRect.GetHeight();
const int bpp = 32; const int bpp = 32;
HDC compatibleDC = CreateCompatibleDC(hDC); 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; sal_uInt8 *data;
HBITMAP hBitmap = WinSalVirtualDevice::ImplCreateVirDevBitmap(compatibleDC, width, height, bpp, reinterpret_cast<void **>(&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 // setup the hidden DC with black color and white background, we will
// background, we will use the result later as a mask only // use the result of the text drawing later as a mask only
HGDIOBJ hBitmapOld = SelectObject(compatibleDC, hBitmap); HGDIOBJ hBitmapOld = SelectObject(compatibleDC, hBitmap);
SelectFont(compatibleDC, mhFont); SelectFont(compatibleDC, mhFont);
SetTextColor(compatibleDC, RGB(0, 0, 0)); SetTextColor(compatibleDC, RGB(0, 0, 0));
SetBkColor(compatibleDC, RGB(255, 255, 255)); SetBkColor(compatibleDC, RGB(255, 255, 255));
UINT nTextAlign = GetTextAlign(hDC);
SetTextAlign(compatibleDC, nTextAlign);
// the actual drawing
DrawTextImpl(compatibleDC); DrawTextImpl(compatibleDC);
SelectObject(compatibleDC, hBitmapOld); SelectObject(compatibleDC, hBitmapOld);
// and turn it into a texture // and turn it into a texture
...@@ -227,8 +238,8 @@ void WinLayout::DrawText(SalGraphics& rGraphics) const ...@@ -227,8 +238,8 @@ void WinLayout::DrawText(SalGraphics& rGraphics) const
aRects.mnSrcY = 0; aRects.mnSrcY = 0;
aRects.mnSrcWidth = width; aRects.mnSrcWidth = width;
aRects.mnSrcHeight = height; aRects.mnSrcHeight = height;
aRects.mnDestX = 0; aRects.mnDestX = origin_x;
aRects.mnDestY = 0; aRects.mnDestY = origin_y;
aRects.mnDestWidth = width; aRects.mnDestWidth = width;
aRects.mnDestHeight = height; aRects.mnDestHeight = height;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment