chart2/source/view/main/OpenGLRender.cxx | 68 ++++++++++++++++--------------- 1 file changed, 37 insertions(+), 31 deletions(-)
New commits: commit 103880ce92b09656d1f408e96ad137940de71c2b Author: Markus Mohrhard <markus.mohrh...@collabora.co.uk> Date: Tue Jan 14 19:14:49 2014 +0100 add more debugging for text rendering Change-Id: I1cb43c8a02313acf2a48ba91e88534c17f5f86c8 diff --git a/chart2/source/view/main/OpenGLRender.cxx b/chart2/source/view/main/OpenGLRender.cxx index 57cd0a2..bd83199 100644 --- a/chart2/source/view/main/OpenGLRender.cxx +++ b/chart2/source/view/main/OpenGLRender.cxx @@ -1433,6 +1433,19 @@ int OpenGLRender::CreateTextTexture(::rtl::OUString textValue, sal_uInt32 color, int bmpHeight = (aRect.Bottom() - aRect.Top() + 3) & ~3; BitmapEx aBitmapEx(aDevice.GetBitmapEx(aRect.TopLeft(), Size(bmpWidth, bmpHeight))); +#if DEBUG_PNG // debug PNG writing + static int nIdx = 0; + OUString aName = OUString( "file:///home/moggi/Documents/work/text" ) + OUString::number( nIdx++ ) + ".png"; + try { + vcl::PNGWriter aWriter( aBitmapEx ); + SvFileStream sOutput( aName, STREAM_WRITE ); + aWriter.Write( sOutput ); + sOutput.Close(); + } catch (...) { + SAL_WARN("slideshow.opengl", "Error writing png to " << aName); + } +#endif + Bitmap aBitmap (aBitmapEx.GetBitmap()); AlphaMask aAlpha (aBitmapEx.GetAlpha()); boost::scoped_array<sal_uInt8> bitmapBuf(new sal_uInt8[4* bmpWidth * bmpHeight ]); commit d9a75f9df3d614cbcd1451168c0d4db8e714c293 Author: Markus Mohrhard <markus.mohrh...@collabora.co.uk> Date: Mon Jan 13 23:32:37 2014 +0100 try to use alpha background in text rendering Change-Id: I9750117a72d05c7325580a1f93e5db3b9e0fdeb6 diff --git a/chart2/source/view/main/OpenGLRender.cxx b/chart2/source/view/main/OpenGLRender.cxx index 451b169..57cd0a2 100644 --- a/chart2/source/view/main/OpenGLRender.cxx +++ b/chart2/source/view/main/OpenGLRender.cxx @@ -37,6 +37,7 @@ #include <vcl/virdev.hxx> #include <vcl/dibtools.hxx> #include <vcl/bmpacc.hxx> +#include <vcl/svapp.hxx> #include <boost/scoped_array.hpp> @@ -1418,49 +1419,40 @@ int OpenGLRender::RenderRectangleShape() int OpenGLRender::CreateTextTexture(::rtl::OUString textValue, sal_uInt32 color, const Font& rFont, awt::Point aPos, awt::Size aSize, long rotation) { - VirtualDevice aDevice; - aDevice.SetFont(rFont); + VirtualDevice aDevice(*Application::GetDefaultDevice(), 0, 0); + aDevice.Erase(); Rectangle aRect; + aDevice.SetFont(rFont); aDevice.GetTextBoundRect(aRect, textValue); int screenWidth = (aRect.BottomRight().X() + 3) & ~3; int screenHeight = (aRect.BottomRight().Y() + 3) & ~3; aDevice.SetOutputSizePixel(Size(screenWidth * 3, screenHeight)); + aDevice.SetBackground(Wallpaper(COL_TRANSPARENT)); aDevice.DrawText(Point(0, 0), textValue); int bmpWidth = (aRect.Right() - aRect.Left() + 3) & ~3; int bmpHeight = (aRect.Bottom() - aRect.Top() + 3) & ~3; - BitmapEx aBitmapEx(aDevice.GetBitmap(aRect.TopLeft(), Size(bmpWidth, bmpHeight))); - Bitmap aBitmap( aBitmapEx.GetBitmap()); - int bitmapsize = aBitmap.GetSizeBytes(); - boost::scoped_array<sal_uInt8> bitmapBuf(new sal_uInt8[bitmapsize * 4 / 3 ]); - BitmapReadAccess* pRAcc = aBitmap.AcquireReadAccess(); - sal_uInt8 red = (color & 0x00FF0000) >> 16; - sal_uInt8 g = (color & 0x0000FF00) >> 8; - sal_uInt8 b = (color & 0x000000FF); + BitmapEx aBitmapEx(aDevice.GetBitmapEx(aRect.TopLeft(), Size(bmpWidth, bmpHeight))); + + Bitmap aBitmap (aBitmapEx.GetBitmap()); + AlphaMask aAlpha (aBitmapEx.GetAlpha()); + boost::scoped_array<sal_uInt8> bitmapBuf(new sal_uInt8[4* bmpWidth * bmpHeight ]); + Bitmap::ScopedReadAccess pReadAccces( aBitmap ); + AlphaMask::ScopedReadAccess pAlphaReadAccess( aAlpha ); - SAL_WARN("chart2.opengl", "r = " << (int)red << ", g = " << (int)g << ", b = " << (int)b ); + size_t i = 0; for (long ny = 0; ny < bmpHeight; ny++) { + Scanline pAScan = pAlphaReadAccess->GetScanline(ny); for(long nx = 0; nx < bmpWidth; nx++) { - sal_uInt8 *pm = pRAcc->GetScanline(ny) + nx * 3; - sal_uInt8 *mk = bitmapBuf.get() + ny * bmpWidth * 4 + nx * 4; - if ((*pm == 0xFF) && (*(pm + 1) == 0xFF) && (*(pm + 2) == 0xFF)) - { - *mk = *pm; - *(mk + 1) = *(pm + 1); - *(mk + 2) = *(pm + 2); - *(mk + 3) = 0; - } - else - { - *mk = b; - *(mk + 1) = g; - *(mk + 2) = red; - *(mk + 3) = ((0xFF - *pm) + (0xFF - *(pm + 1)) + (0xFF - *(pm + 2))) / 3; - } + BitmapColor aCol = pReadAccces->GetColor( ny, nx ); + bitmapBuf[i++] = aCol.GetRed(); + bitmapBuf[i++] = aCol.GetGreen(); + bitmapBuf[i++] = aCol.GetBlue(); + bitmapBuf[i++] = *pAScan++; } } - aBitmap.ReleaseAccess(pRAcc); + TextInfo aTextInfo; aTextInfo.x = (float)(aPos.X + aSize.Width / 2) / OPENGL_SCALE_VALUE; aTextInfo.y = (float)(aPos.Y + aSize.Height / 2) / OPENGL_SCALE_VALUE; @@ -1509,11 +1501,12 @@ int OpenGLRender::CreateTextTexture(::rtl::OUString textValue, sal_uInt32 color, CHECK_GL_ERROR(); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); CHECK_GL_ERROR(); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, bmpWidth, bmpHeight, 0, GL_BGRA, GL_UNSIGNED_BYTE, bitmapBuf.get()); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, bmpWidth, bmpHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, bitmapBuf.get()); CHECK_GL_ERROR(); glBindTexture(GL_TEXTURE_2D, 0); CHECK_GL_ERROR(); m_TextInfoList.push_back(aTextInfo); + aDevice.Erase(); return 0; } @@ -1650,12 +1643,12 @@ void OpenGLRender::SetBackGroundColor(sal_uInt32 color1, sal_uInt32 color2) m_BackgroundColor[0] = (float)r / 255.0f; m_BackgroundColor[1] = (float)g / 255.0f; m_BackgroundColor[2] = (float)b / 255.0f; - m_BackgroundColor[3] = 1.0; + m_BackgroundColor[3] = m_fAlpha; m_BackgroundColor[4] = (float)r / 255.0f; m_BackgroundColor[5] = (float)g / 255.0f; m_BackgroundColor[6] = (float)b / 255.0f; - m_BackgroundColor[7] = 1.0; + m_BackgroundColor[7] = m_fAlpha; r = (color2 & 0x00FF0000) >> 16; g = (color2 & 0x0000FF00) >> 8; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits