summaryrefslogtreecommitdiff
path: root/vcl/win
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@collabora.com>2014-11-14 11:15:17 +0100
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2014-11-15 13:50:54 +0100
commit30c6b2f1ec9dd2a639c5bcabeb7fa1afc15a1c17 (patch)
tree31454223ffbedb4d0590b49138b6e839e22ebd77 /vcl/win
parent6fd7199230bfc81d6aadf53b3c115def8caba90c (diff)
windows opengl: Explain the concept of the text drawing + minor fixes.
Change-Id: I4651e7e9b8163844be548d4ed975a881d4f83fff
Diffstat (limited to 'vcl/win')
-rw-r--r--vcl/win/source/gdi/winlayout.cxx43
1 files changed, 39 insertions, 4 deletions
diff --git a/vcl/win/source/gdi/winlayout.cxx b/vcl/win/source/gdi/winlayout.cxx
index 30c62ef456de..480e1a00baf1 100644
--- a/vcl/win/source/gdi/winlayout.cxx
+++ b/vcl/win/source/gdi/winlayout.cxx
@@ -163,7 +163,34 @@ void WinLayout::DrawText(SalGraphics& rGraphics) const
}
else
{
- // we have to render the text to a hidden texture, and draw it
+ // We have to render the text to a hidden texture, and draw it.
+ //
+ // Note that Windows GDI does not really support the alpha correctly
+ // when drawing - ie. it draws nothing to the alpha channel when
+ // rendering the text, even the antialiasing is done as 'real' pixels,
+ // not alpha...
+ //
+ // Luckily, this does not really limit us:
+ //
+ // To blend properly, we draw the texture, but then use it as an alpha
+ // channel for solid color (that will define the text color). This
+ // destroys the subpixel antialiasing - turns it into 'classic'
+ // antialiasing - but that is the best we can do, because the subpixel
+ // antialiasing needs to know what is in the background: When the
+ // background is white, or white-ish, it does the subpixel, but when
+ // there is a color, it just darkens the color (and does this even
+ // when part of the character is on a colored background, and part on
+ // white). It has to work this way, the results would look strange
+ // otherwise.
+ //
+ // For the GL rendering to work even with the subpixel antialiasing,
+ // we would need to get the current texture from the screen, let GDI
+ // draw the text to it (so that it can decide well where to use the
+ // subpixel and where not), and draw the result - but in that case we
+ // don't need alpha anyway.
+ //
+ // 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
@@ -176,12 +203,15 @@ void WinLayout::DrawText(SalGraphics& rGraphics) const
sal_uInt8 *data;
HBITMAP hBitmap = WinSalVirtualDevice::ImplCreateVirDevBitmap(compatibleDC, width, height, bpp, reinterpret_cast<void **>(&data));
- // FIXME fill transparent instead of 128
+ // FIXME fill transparent instead of 128, this is for testing
memset(data, 128, width*height*4);
- // draw the text to the hidden DC
+ // draw the text to the hidden DC with black color and white
+ // background, we will use the result 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));
DrawTextImpl(compatibleDC);
SelectObject(compatibleDC, hBitmapOld);
@@ -203,7 +233,12 @@ void WinLayout::DrawText(SalGraphics& rGraphics) const
aRects.mnDestHeight = height;
pImpl->PreDraw();
- pImpl->DrawAlphaTexture(aTexture, aRects);
+ COLORREF color = GetTextColor(hDC);
+ SalColor salColor = MAKE_SALCOLOR(GetRValue(color), GetGValue(color), GetBValue(color));
+ // TODO when we have it:
+ // pImpl->DrawSolidColorWithMask(salColor, aTexture, aRects);
+ // and kill the following interim thing:
+ pImpl->DrawTexture(aTexture, aRects);
pImpl->PostDraw();
}