[Libreoffice-commits] core.git: Branch 'feature/chart-opengl2' - 10 commits - chart2/source

Markus Mohrhard markus.mohrhard at collabora.co.uk
Tue Jan 21 14:46:05 PST 2014


 chart2/source/view/inc/DummyXShape.hxx   |    3 
 chart2/source/view/main/DummyXShape.cxx  |   83 ++++++++++++--
 chart2/source/view/main/OpenGLRender.cxx |  177 ++++++++++++-------------------
 chart2/source/view/main/OpenGLRender.hxx |   20 +--
 4 files changed, 154 insertions(+), 129 deletions(-)

New commits:
commit 13d9c441512a6245c5e93156d2fb059d02484ab2
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Tue Jan 21 23:43:52 2014 +0100

    fix some warnings
    
    Change-Id: I3bded252fb6af9166dc533e7e2756e7569a82112

diff --git a/chart2/source/view/main/DummyXShape.cxx b/chart2/source/view/main/DummyXShape.cxx
index 3fbae2b..77fcabd 100644
--- a/chart2/source/view/main/DummyXShape.cxx
+++ b/chart2/source/view/main/DummyXShape.cxx
@@ -721,7 +721,6 @@ void DummyText::render()
     DummyChart* pChart = getRootShape();
 
     drawing::HomogenMatrix3 aTransformation;
-    bool bHasTransformation = false;
     std::map<OUString, uno::Any>::const_iterator itr =
         maProperties.find("Transformation");
     if(itr != maProperties.end())
@@ -730,7 +729,6 @@ void DummyText::render()
         if(itr->second.hasValue())
         {
             aTransformation = itr->second.get<drawing::HomogenMatrix3>();
-            bHasTransformation = true;
         }
     }
     else if(maTrans.hasValue())
@@ -738,7 +736,7 @@ void DummyText::render()
         aTransformation = maTrans.get<drawing::HomogenMatrix3>();
     }
     pChart->m_GLRender.CreateTextTexture(maBitmap, maPosition, maSize, 0,
-            bHasTransformation, aTransformation);
+            aTransformation);
     pChart->m_GLRender.RenderTextShape();
 }
 
diff --git a/chart2/source/view/main/OpenGLRender.cxx b/chart2/source/view/main/OpenGLRender.cxx
index 98681d6..d96b219 100644
--- a/chart2/source/view/main/OpenGLRender.cxx
+++ b/chart2/source/view/main/OpenGLRender.cxx
@@ -43,7 +43,9 @@ using namespace com::sun::star;
 using namespace std;
 
 #define DEBUG_PNG 1
+#if RENDER_TO_FILE
 #define BMP_HEADER_LEN 54
+#endif
 
 #if DEBUG_PNG
 #include <vcl/pngwrite.hxx>
@@ -1457,7 +1459,7 @@ int OpenGLRender::RenderRectangleShape(bool bBorder, bool bFill)
 
 
 int OpenGLRender::CreateTextTexture(const BitmapEx& rBitmapEx, awt::Point aPos, awt::Size aSize, long rotation,
-        bool bRotation, const drawing::HomogenMatrix3& rTrans)
+        const drawing::HomogenMatrix3& rTrans)
 {
     glm::mat3 aTrans(rTrans.Line1.Column1, rTrans.Line1.Column2, rTrans.Line1.Column3,
                     rTrans.Line2.Column1, rTrans.Line2.Column2, rTrans.Line2.Column3,
@@ -1504,26 +1506,18 @@ int OpenGLRender::CreateTextTexture(const BitmapEx& rBitmapEx, awt::Point aPos,
     aTextInfo.y = (float)(aPos.Y + aSize.Height / 2);
     aTextInfo.z = m_fZStep;
     aTextInfo.rotation = -(double)rotation * GL_PI / 18000.0f;
-    glm::vec3 aPos1( 0, 0, 1 );
-    glm::vec3 aPos1Trans = aTrans * aPos1;
     aTextInfo.vertex[0] = rTrans.Line1.Column3 / OPENGL_SCALE_VALUE;
     aTextInfo.vertex[1] = rTrans.Line2.Column3 / OPENGL_SCALE_VALUE;
     aTextInfo.vertex[2] = m_fZStep;
 
-    glm::vec3 aPos2( 1, 0, 1 );
-    glm::vec3 aPos2Trans = aTrans * aPos2;
     aTextInfo.vertex[3] = (rTrans.Line1.Column3 + aSize.Width ) / OPENGL_SCALE_VALUE ;
     aTextInfo.vertex[4] = rTrans.Line2.Column3 / OPENGL_SCALE_VALUE;
     aTextInfo.vertex[5] = m_fZStep;
 
-    glm::vec3 aPos3( 1, 1, 1 );
-    glm::vec3 aPos3Trans = aTrans * aPos3;
     aTextInfo.vertex[6] = (rTrans.Line1.Column3 + aSize.Width) / OPENGL_SCALE_VALUE;
     aTextInfo.vertex[7] = (rTrans.Line2.Column3 + aSize.Height) / OPENGL_SCALE_VALUE;
     aTextInfo.vertex[8] = m_fZStep;
 
-    glm::vec3 aPos4( 0, 1, 1 );
-    glm::vec3 aPos4Trans = aTrans * aPos4;
     aTextInfo.vertex[9] = rTrans.Line1.Column3 / OPENGL_SCALE_VALUE;
     aTextInfo.vertex[10] = (rTrans.Line2.Column3 + aSize.Height) / OPENGL_SCALE_VALUE;
     aTextInfo.vertex[11] = m_fZStep;
diff --git a/chart2/source/view/main/OpenGLRender.hxx b/chart2/source/view/main/OpenGLRender.hxx
index ebd3b2a..435e76d 100644
--- a/chart2/source/view/main/OpenGLRender.hxx
+++ b/chart2/source/view/main/OpenGLRender.hxx
@@ -168,7 +168,7 @@ public:
 
     int CreateTextTexture(const BitmapEx& rBitmapEx,
             com::sun::star::awt::Point aPos, com::sun::star::awt::Size aSize, long rotation,
-            bool bTransformation, const com::sun::star::drawing::HomogenMatrix3& rTrans);
+            const com::sun::star::drawing::HomogenMatrix3& rTrans);
     int RenderTextShape();
 
     int SetArea2DShapePoint(float x, float y, int listLength);
commit caf99532d8eee99b9d9cca2b5c54b260fa1853a0
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Tue Jan 21 00:17:55 2014 +0100

    more work in the direction of correct text rendering
    
    It still does not render text correctly (or visible) but at least
    according to my debugging skills we are making progress.
    
    Change-Id: I2bff955b7395126770295ba1546e8cb3f70557c7

diff --git a/chart2/source/view/main/DummyXShape.cxx b/chart2/source/view/main/DummyXShape.cxx
index 23a9c81..3fbae2b 100644
--- a/chart2/source/view/main/DummyXShape.cxx
+++ b/chart2/source/view/main/DummyXShape.cxx
@@ -121,6 +121,10 @@ void DummyXShape::setPropertyValue( const OUString& rName, const uno::Any& rValu
 {
     SAL_WARN("chart2", "DummyXShape::setProperty: " << rName << " " << "Any");
     maProperties[rName] = rValue;
+    if(rName == "Transformation")
+    {
+        SAL_WARN("chart2.opengl", "Transformation");
+    }
 }
 
 uno::Any DummyXShape::getPropertyValue( const OUString& rName )
@@ -648,8 +652,8 @@ struct FontAttribSetter
         }
         else if(rPropName == "CharHeight")
         {
-            //float fHeight = rProp.second.get<float>();
-            mrFont.SetSize(Size(0,100)); //taken from the MCW implementation
+            float fHeight = rProp.second.get<float>();
+            mrFont.SetSize(Size(0,(fHeight*127+36)/72)); //taken from the MCW implementation
         }
         else if(rPropName == "CharUnderline")
         {
@@ -699,7 +703,14 @@ DummyText::DummyText(const OUString& rText, const tNameSequence& rNames,
     int bmpHeight = (aRect.Bottom() - aRect.Top() + 3) & ~3;
     maBitmap = BitmapEx(aDevice.GetBitmapEx(aRect.TopLeft(), Size(bmpWidth, bmpHeight)));
 
-    setSize(awt::Size(bmpWidth, bmpHeight));
+    if(rTrans.hasValue())
+    {
+        drawing::HomogenMatrix3 aTrans = rTrans.get<drawing::HomogenMatrix3>();
+        setSize(awt::Size(20*bmpWidth, 20*bmpHeight));
+        setPosition(awt::Point(aTrans.Line1.Column3, aTrans.Line2.Column3));
+    }
+    else
+        setSize(awt::Size(20*bmpWidth, 20*bmpHeight));
 }
 
 void DummyText::render()
@@ -708,7 +719,26 @@ void DummyText::render()
     debugProperties(maProperties);
 
     DummyChart* pChart = getRootShape();
-    pChart->m_GLRender.CreateTextTexture(maBitmap, maPosition, maSize, 0);
+
+    drawing::HomogenMatrix3 aTransformation;
+    bool bHasTransformation = false;
+    std::map<OUString, uno::Any>::const_iterator itr =
+        maProperties.find("Transformation");
+    if(itr != maProperties.end())
+    {
+        SAL_WARN("chart2.opengl", "found a transformation");
+        if(itr->second.hasValue())
+        {
+            aTransformation = itr->second.get<drawing::HomogenMatrix3>();
+            bHasTransformation = true;
+        }
+    }
+    else if(maTrans.hasValue())
+    {
+        aTransformation = maTrans.get<drawing::HomogenMatrix3>();
+    }
+    pChart->m_GLRender.CreateTextTexture(maBitmap, maPosition, maSize, 0,
+            bHasTransformation, aTransformation);
     pChart->m_GLRender.RenderTextShape();
 }
 
diff --git a/chart2/source/view/main/OpenGLRender.cxx b/chart2/source/view/main/OpenGLRender.cxx
index f407d11..98681d6 100644
--- a/chart2/source/view/main/OpenGLRender.cxx
+++ b/chart2/source/view/main/OpenGLRender.cxx
@@ -1456,8 +1456,12 @@ int OpenGLRender::RenderRectangleShape(bool bBorder, bool bFill)
 }
 
 
-int OpenGLRender::CreateTextTexture(const BitmapEx& rBitmapEx, awt::Point aPos, awt::Size aSize, long rotation)
+int OpenGLRender::CreateTextTexture(const BitmapEx& rBitmapEx, awt::Point aPos, awt::Size aSize, long rotation,
+        bool bRotation, const drawing::HomogenMatrix3& rTrans)
 {
+    glm::mat3 aTrans(rTrans.Line1.Column1, rTrans.Line1.Column2, rTrans.Line1.Column3,
+                    rTrans.Line2.Column1, rTrans.Line2.Column2, rTrans.Line2.Column3,
+                    rTrans.Line3.Column1, rTrans.Line3.Column3, rTrans.Line3.Column3);
 
 #if DEBUG_PNG // debug PNG writing
     static int nIdx = 0;
@@ -1500,17 +1504,29 @@ int OpenGLRender::CreateTextTexture(const BitmapEx& rBitmapEx, awt::Point aPos,
     aTextInfo.y = (float)(aPos.Y + aSize.Height / 2);
     aTextInfo.z = m_fZStep;
     aTextInfo.rotation = -(double)rotation * GL_PI / 18000.0f;
-    aTextInfo.vertex[0] = (float)(aPos.X);
-    aTextInfo.vertex[1] = (float)(aPos.Y);
-
-    aTextInfo.vertex[2] = (float)(aPos.X + aSize.Width);
-    aTextInfo.vertex[3] = (float)(aPos.Y);
-
-    aTextInfo.vertex[4] = (float)(aPos.X + aSize.Width);
-    aTextInfo.vertex[5] = (float)(aPos.Y + aSize.Height);
-
-    aTextInfo.vertex[6] = (float)(aPos.X);
-    aTextInfo.vertex[7] = (float)(aPos.Y + aSize.Height);
+    glm::vec3 aPos1( 0, 0, 1 );
+    glm::vec3 aPos1Trans = aTrans * aPos1;
+    aTextInfo.vertex[0] = rTrans.Line1.Column3 / OPENGL_SCALE_VALUE;
+    aTextInfo.vertex[1] = rTrans.Line2.Column3 / OPENGL_SCALE_VALUE;
+    aTextInfo.vertex[2] = m_fZStep;
+
+    glm::vec3 aPos2( 1, 0, 1 );
+    glm::vec3 aPos2Trans = aTrans * aPos2;
+    aTextInfo.vertex[3] = (rTrans.Line1.Column3 + aSize.Width ) / OPENGL_SCALE_VALUE ;
+    aTextInfo.vertex[4] = rTrans.Line2.Column3 / OPENGL_SCALE_VALUE;
+    aTextInfo.vertex[5] = m_fZStep;
+
+    glm::vec3 aPos3( 1, 1, 1 );
+    glm::vec3 aPos3Trans = aTrans * aPos3;
+    aTextInfo.vertex[6] = (rTrans.Line1.Column3 + aSize.Width) / OPENGL_SCALE_VALUE;
+    aTextInfo.vertex[7] = (rTrans.Line2.Column3 + aSize.Height) / OPENGL_SCALE_VALUE;
+    aTextInfo.vertex[8] = m_fZStep;
+
+    glm::vec3 aPos4( 0, 1, 1 );
+    glm::vec3 aPos4Trans = aTrans * aPos4;
+    aTextInfo.vertex[9] = rTrans.Line1.Column3 / OPENGL_SCALE_VALUE;
+    aTextInfo.vertex[10] = (rTrans.Line2.Column3 + aSize.Height) / OPENGL_SCALE_VALUE;
+    aTextInfo.vertex[11] = m_fZStep;
 
     //if has ratotion, we must re caculate the central pos
     if (!rtl::math::approxEqual(0, rotation))
@@ -1574,7 +1590,7 @@ int OpenGLRender::RenderTextShape()
         glBindBuffer(GL_ARRAY_BUFFER, m_VertexBuffer);
         glVertexAttribPointer(
             m_TextVertexID,                  // attribute. No particular reason for 0, but must match the layout in the shader.
-            2,                  // size
+            3,                  // size
             GL_FLOAT,           // type
             GL_FALSE,           // normalized?
             0,                  // stride
diff --git a/chart2/source/view/main/OpenGLRender.hxx b/chart2/source/view/main/OpenGLRender.hxx
index 4871943..ebd3b2a 100644
--- a/chart2/source/view/main/OpenGLRender.hxx
+++ b/chart2/source/view/main/OpenGLRender.hxx
@@ -29,6 +29,7 @@
 #include <vcl/syschild.hxx>
 #include <vcl/sysdata.hxx>
 #include <vcl/bitmapex.hxx>
+#include <com/sun/star/drawing/HomogenMatrix3.hpp>
 
 #if defined( _WIN32 )
 #include <GL/glu.h>
@@ -95,7 +96,7 @@ typedef struct TextInfo
     float y;
     float z;
     double rotation;
-    float vertex[8];
+    float vertex[12];
 }TextInfo;
 
 typedef std::vector<GLfloat> Area2DPointList;
@@ -166,7 +167,8 @@ public:
     int RectangleShapePoint(float x, float y, float directionX, float directionY);
 
     int CreateTextTexture(const BitmapEx& rBitmapEx,
-            com::sun::star::awt::Point aPos, com::sun::star::awt::Size aSize, long rotation);
+            com::sun::star::awt::Point aPos, com::sun::star::awt::Size aSize, long rotation,
+            bool bTransformation, const com::sun::star::drawing::HomogenMatrix3& rTrans);
     int RenderTextShape();
 
     int SetArea2DShapePoint(float x, float y, int listLength);
commit bdb80f32e28ba73c387b4d7f434d94ad6a53756d
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Sun Jan 19 04:32:36 2014 +0100

    remove unused struct
    
    Change-Id: I446b2f5739f95634ebff9447d0af108b1dedf6a2

diff --git a/chart2/source/view/main/OpenGLRender.hxx b/chart2/source/view/main/OpenGLRender.hxx
index 2879045..4871943 100644
--- a/chart2/source/view/main/OpenGLRender.hxx
+++ b/chart2/source/view/main/OpenGLRender.hxx
@@ -60,12 +60,6 @@
 #define DEBUG_POSITIONING 0
 #define RENDER_TO_FILE 0
 
-typedef struct PosVeci3
-{
-    int x;
-    int y;
-    int z;
-}PosVeci3;
 typedef struct PosVecf3
 {
     float x;
commit 32271522326ebe656603b105b8b9e2df2b8320de
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Tue Jan 14 23:24:45 2014 +0100

    more work for text rendering
    
    Change-Id: I4c94757de59722b7dfec9e2d0db83fc5734ba942

diff --git a/chart2/source/view/inc/DummyXShape.hxx b/chart2/source/view/inc/DummyXShape.hxx
index f915650..7112ac7 100644
--- a/chart2/source/view/inc/DummyXShape.hxx
+++ b/chart2/source/view/inc/DummyXShape.hxx
@@ -374,9 +374,12 @@ public:
 
     virtual void render() SAL_OVERRIDE;
 
+    virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+
 private:
     OUString maText;
     uno::Any maTrans;
+    BitmapEx maBitmap;
 };
 
 class DummyFormattedText : public DummyXShape
diff --git a/chart2/source/view/main/DummyXShape.cxx b/chart2/source/view/main/DummyXShape.cxx
index 3c7c551..23a9c81 100644
--- a/chart2/source/view/main/DummyXShape.cxx
+++ b/chart2/source/view/main/DummyXShape.cxx
@@ -21,6 +21,8 @@
 #include <rtl/ustring.hxx>
 
 #include <vcl/window.hxx>
+#include <vcl/virdev.hxx>
+#include <vcl/svapp.hxx>
 #include <tools/gen.hxx>
 #include <editeng/unoprnms.hxx>
 #include <toolkit/helper/vclunohelper.hxx>
@@ -624,14 +626,6 @@ void DummyRectangle::render()
     pChart->m_GLRender.RenderRectangleShape(bBorder, bFill);
 }
 
-DummyText::DummyText(const OUString& rText, const tNameSequence& rNames,
-        const tAnySequence& rValues, const uno::Any& rTrans ):
-    maText(rText),
-    maTrans(rTrans)
-{
-    setProperties(rNames, rValues, maProperties);
-}
-
 namespace {
 
 struct FontAttribSetter
@@ -681,19 +675,52 @@ private:
 
 }
 
-void DummyText::render()
+DummyText::DummyText(const OUString& rText, const tNameSequence& rNames,
+        const tAnySequence& rValues, const uno::Any& rTrans ):
+    maText(rText),
+    maTrans(rTrans)
 {
-    SAL_WARN("chart2.opengl", "render DummyText");
-    debugProperties(maProperties);
+    setProperties(rNames, rValues, maProperties);
 
     Font aFont;
     std::for_each(maProperties.begin(), maProperties.end(), FontAttribSetter(aFont));
 
+    VirtualDevice aDevice(*Application::GetDefaultDevice(), 0, 0);
+    aDevice.Erase();
+    Rectangle aRect;
+    aDevice.SetFont(aFont);
+    aDevice.GetTextBoundRect(aRect, rText);
+    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), rText);
+    int bmpWidth = (aRect.Right() - aRect.Left() + 3) & ~3;
+    int bmpHeight = (aRect.Bottom() - aRect.Top() + 3) & ~3;
+    maBitmap = BitmapEx(aDevice.GetBitmapEx(aRect.TopLeft(), Size(bmpWidth, bmpHeight)));
+
+    setSize(awt::Size(bmpWidth, bmpHeight));
+}
+
+void DummyText::render()
+{
+    SAL_WARN("chart2.opengl", "render DummyText");
+    debugProperties(maProperties);
+
     DummyChart* pChart = getRootShape();
-    pChart->m_GLRender.CreateTextTexture(maText, 0, aFont, maPosition, maSize, 0);
+    pChart->m_GLRender.CreateTextTexture(maBitmap, maPosition, maSize, 0);
     pChart->m_GLRender.RenderTextShape();
 }
 
+void DummyText::setPropertyValue( const OUString& rName, const uno::Any& rValue)
+    throw(beans::UnknownPropertyException, beans::PropertyVetoException,
+            lang::IllegalArgumentException, lang::WrappedTargetException,
+            uno::RuntimeException)
+{
+    SAL_WARN("chart2.opengl", "property value set after image has been created");
+    DummyXShape::setPropertyValue(rName, rValue);
+}
+
 DummyFormattedText::DummyFormattedText(uno::Sequence< uno::Reference<
         chart2::XFormattedString > >& rFormattedString,
         uno::Reference< beans::XPropertySet > , double fRotation):
diff --git a/chart2/source/view/main/OpenGLRender.cxx b/chart2/source/view/main/OpenGLRender.cxx
index 7673d8a..f407d11 100644
--- a/chart2/source/view/main/OpenGLRender.cxx
+++ b/chart2/source/view/main/OpenGLRender.cxx
@@ -10,7 +10,6 @@
 #include <GL/glew.h>
 #include <vector>
 #include "OpenGLRender.hxx"
-#include <vcl/bitmapex.hxx>
 #include <vcl/bmpacc.hxx>
 #include <vcl/graph.hxx>
 #include <com/sun/star/awt/XBitmap.hpp>
@@ -36,8 +35,6 @@
 #include <editeng/unoprnms.hxx>
 #include <vcl/virdev.hxx>
 #include <vcl/dibtools.hxx>
-#include <vcl/bmpacc.hxx>
-#include <vcl/svapp.hxx>
 
 #include <boost/scoped_array.hpp>
 
@@ -45,7 +42,7 @@ using namespace com::sun::star;
 
 using namespace std;
 
-#define DEBUG_PNG 0
+#define DEBUG_PNG 1
 #define BMP_HEADER_LEN 54
 
 #if DEBUG_PNG
@@ -1459,27 +1456,14 @@ int OpenGLRender::RenderRectangleShape(bool bBorder, bool bFill)
 }
 
 
-int OpenGLRender::CreateTextTexture(::rtl::OUString textValue, sal_uInt32 color, const Font& rFont, awt::Point aPos, awt::Size aSize, long rotation)
+int OpenGLRender::CreateTextTexture(const BitmapEx& rBitmapEx, awt::Point aPos, awt::Size aSize, long rotation)
 {
-    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.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 );
+        vcl::PNGWriter aWriter( rBitmapEx );
         SvFileStream sOutput( aName, STREAM_WRITE );
         aWriter.Write( sOutput );
         sOutput.Close();
@@ -1488,8 +1472,11 @@ int OpenGLRender::CreateTextTexture(::rtl::OUString textValue, sal_uInt32 color,
     }
 #endif
 
-    Bitmap aBitmap (aBitmapEx.GetBitmap());
-    AlphaMask aAlpha (aBitmapEx.GetAlpha());
+    long bmpWidth = rBitmapEx.GetSizePixel().Width();
+    long bmpHeight = rBitmapEx.GetSizePixel().Height();
+
+    Bitmap aBitmap (rBitmapEx.GetBitmap());
+    AlphaMask aAlpha (rBitmapEx.GetAlpha());
     boost::scoped_array<sal_uInt8> bitmapBuf(new sal_uInt8[4* bmpWidth * bmpHeight ]);
     Bitmap::ScopedReadAccess pReadAccces( aBitmap );
     AlphaMask::ScopedReadAccess pAlphaReadAccess( aAlpha );
@@ -1504,26 +1491,26 @@ int OpenGLRender::CreateTextTexture(::rtl::OUString textValue, sal_uInt32 color,
             bitmapBuf[i++] = aCol.GetRed();
             bitmapBuf[i++] = aCol.GetGreen();
             bitmapBuf[i++] = aCol.GetBlue();
-            bitmapBuf[i++] = *pAScan++;
+            bitmapBuf[i++] = 255 - *pAScan++;
         }
     }
 
     TextInfo aTextInfo;
-    aTextInfo.x = (float)(aPos.X + aSize.Width / 2) / OPENGL_SCALE_VALUE;
-    aTextInfo.y = (float)(aPos.Y + aSize.Height / 2) / OPENGL_SCALE_VALUE;
+    aTextInfo.x = (float)(aPos.X + aSize.Width / 2);
+    aTextInfo.y = (float)(aPos.Y + aSize.Height / 2);
     aTextInfo.z = m_fZStep;
     aTextInfo.rotation = -(double)rotation * GL_PI / 18000.0f;
-    aTextInfo.vertex[0] = (float)(-aSize.Width / 2) / OPENGL_SCALE_VALUE;
-    aTextInfo.vertex[1] = (float)(-aSize.Height / 2) / OPENGL_SCALE_VALUE;
+    aTextInfo.vertex[0] = (float)(aPos.X);
+    aTextInfo.vertex[1] = (float)(aPos.Y);
 
-    aTextInfo.vertex[2] = (float)(aSize.Width / 2) / OPENGL_SCALE_VALUE;
-    aTextInfo.vertex[3] = (float)(-aSize.Height / 2) / OPENGL_SCALE_VALUE;
+    aTextInfo.vertex[2] = (float)(aPos.X + aSize.Width);
+    aTextInfo.vertex[3] = (float)(aPos.Y);
 
-    aTextInfo.vertex[4] = (float)(aSize.Width / 2) / OPENGL_SCALE_VALUE;
-    aTextInfo.vertex[5] = (float)(aSize.Height / 2) / OPENGL_SCALE_VALUE;
+    aTextInfo.vertex[4] = (float)(aPos.X + aSize.Width);
+    aTextInfo.vertex[5] = (float)(aPos.Y + aSize.Height);
 
-    aTextInfo.vertex[6] = (float)(-aSize.Width / 2) / OPENGL_SCALE_VALUE;
-    aTextInfo.vertex[7] = (float)(aSize.Height / 2) / OPENGL_SCALE_VALUE;
+    aTextInfo.vertex[6] = (float)(aPos.X);
+    aTextInfo.vertex[7] = (float)(aPos.Y + aSize.Height);
 
     //if has ratotion, we must re caculate the central pos
     if (!rtl::math::approxEqual(0, rotation))
@@ -1561,7 +1548,6 @@ int OpenGLRender::CreateTextTexture(::rtl::OUString textValue, sal_uInt32 color,
     glBindTexture(GL_TEXTURE_2D, 0);
     CHECK_GL_ERROR();
     m_TextInfoList.push_back(aTextInfo);
-    aDevice.Erase();
     return 0;
 }
 
@@ -1573,7 +1559,7 @@ int OpenGLRender::RenderTextShape()
     for (size_t i = 0; i < listNum; i++)
     {
         TextInfo &textInfo = m_TextInfoList.front();
-        PosVecf3 trans = {textInfo.x, textInfo.y, textInfo.z};
+        PosVecf3 trans = {0, 0, 0};
         PosVecf3 angle = {0.0f, 0.0f, float(textInfo.rotation)};
         PosVecf3 scale = {1.0, 1.0, 1.0f};
         MoveModelf(trans, angle, scale);
diff --git a/chart2/source/view/main/OpenGLRender.hxx b/chart2/source/view/main/OpenGLRender.hxx
index 7010edc..2879045 100644
--- a/chart2/source/view/main/OpenGLRender.hxx
+++ b/chart2/source/view/main/OpenGLRender.hxx
@@ -28,6 +28,7 @@
 #include <vcl/window.hxx>
 #include <vcl/syschild.hxx>
 #include <vcl/sysdata.hxx>
+#include <vcl/bitmapex.hxx>
 
 #if defined( _WIN32 )
 #include <GL/glu.h>
@@ -170,7 +171,7 @@ public:
     int RenderRectangleShape(bool bBorder, bool bFill);
     int RectangleShapePoint(float x, float y, float directionX, float directionY);
 
-    int CreateTextTexture(::rtl::OUString textValue, sal_uInt32 color, const Font& rFont,
+    int CreateTextTexture(const BitmapEx& rBitmapEx,
             com::sun::star::awt::Point aPos, com::sun::star::awt::Size aSize, long rotation);
     int RenderTextShape();
 
commit bec6bb9946279835d37cf65941f6e809d8dc4aa6
Author: Markus Mohrhard <markus.mohrhard at 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 a906fda..7673d8a 100644
--- a/chart2/source/view/main/OpenGLRender.cxx
+++ b/chart2/source/view/main/OpenGLRender.cxx
@@ -1475,6 +1475,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 82d71d9363ce77c836bcc61fa0d6295784d337d9
Author: Markus Mohrhard <markus.mohrhard at 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 5a72f1a..a906fda 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>
 
@@ -1460,49 +1461,40 @@ int OpenGLRender::RenderRectangleShape(bool bBorder, bool bFill)
 
 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;
@@ -1551,11 +1543,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;
 }
 
@@ -1692,12 +1685,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;
commit cfc875e025ee316e96f170c7f40a4efcf3b60cd2
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Tue Jan 14 16:15:41 2014 +0100

    we only need one of the BMP header functions
    
    Additionally we don't need them when we don't write to a file.
    
    Change-Id: Ib38f68f8f88490f6dfff9fffe7924a707438a040

diff --git a/chart2/source/view/main/OpenGLRender.cxx b/chart2/source/view/main/OpenGLRender.cxx
index 50764f4..5a72f1a 100644
--- a/chart2/source/view/main/OpenGLRender.cxx
+++ b/chart2/source/view/main/OpenGLRender.cxx
@@ -44,8 +44,7 @@ using namespace com::sun::star;
 
 using namespace std;
 
-#define RENDER_TO_FILE 0
-#define DEBUG_PNG 1
+#define DEBUG_PNG 0
 #define BMP_HEADER_LEN 54
 
 #if DEBUG_PNG
@@ -961,6 +960,7 @@ void OpenGLRender::SetHeight(int height)
     m_Projection = glm::ortho(0.f, float(m_iWidth), 0.f, float(m_iHeight), -4.f, 3.f);
 }
 
+#if RENDER_TO_FILE
 int OpenGLRender::CreateBMPHeader(sal_uInt8 *bmpHeader, int xsize, int ysize)
 {
     unsigned char header[BMP_HEADER_LEN] = {
@@ -989,8 +989,8 @@ int OpenGLRender::CreateBMPHeader(sal_uInt8 *bmpHeader, int xsize, int ysize)
     header[25] = (height >> 24) &0x000000ff;
     memcpy(bmpHeader, header, BMP_HEADER_LEN);
     return 0;
-
 }
+#endif
 
 void OpenGLRender::SetLine2DColor(sal_uInt8 r, sal_uInt8 g, sal_uInt8 b)
 {
@@ -1615,37 +1615,6 @@ int OpenGLRender::RenderTextShape()
     return 0;
 }
 
-int OpenGLRender::CreateBMPHeaderRGBA(sal_uInt8 *bmpHeader, int xsize, int ysize)
-{
-    unsigned char header[BMP_HEADER_LEN] = {
-        0x42, 0x4d, 0, 0, 0, 0, 0, 0, 0, 0,
-        54, 0, 0, 0, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 32, 0,
-        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0
-    };
-
-    long file_size = (long)xsize * (long)ysize * 4 + 54;
-    header[2] = (unsigned char)(file_size &0x000000ff);
-    header[3] = (file_size >> 8) & 0x000000ff;
-    header[4] = (file_size >> 16) & 0x000000ff;
-    header[5] = (file_size >> 24) & 0x000000ff;
-
-    long width = xsize;
-    header[18] = width & 0x000000ff;
-    header[19] = (width >> 8) &0x000000ff;
-    header[20] = (width >> 16) &0x000000ff;
-    header[21] = (width >> 24) &0x000000ff;
-
-    long height = -ysize;
-    header[22] = height &0x000000ff;
-    header[23] = (height >> 8) &0x000000ff;
-    header[24] = (height >> 16) &0x000000ff;
-    header[25] = (height >> 24) &0x000000ff;
-    memcpy(bmpHeader, header, BMP_HEADER_LEN);
-    return 0;
-
-}
-
 int OpenGLRender::SetArea2DShapePoint(float x, float y, int listLength)
 {
     if (m_Area2DPointList.empty())
diff --git a/chart2/source/view/main/OpenGLRender.hxx b/chart2/source/view/main/OpenGLRender.hxx
index 30b49af..7010edc 100644
--- a/chart2/source/view/main/OpenGLRender.hxx
+++ b/chart2/source/view/main/OpenGLRender.hxx
@@ -57,6 +57,7 @@
 
 #define OPENGL_SCALE_VALUE 20
 #define DEBUG_POSITIONING 0
+#define RENDER_TO_FILE 0
 
 typedef struct PosVeci3
 {
@@ -144,8 +145,9 @@ public:
     void SetWidth(int width);
     void SetHeight(int height);
     void Release();
+#if RENDER_TO_FILE
     int CreateBMPHeader(sal_uInt8 *bmpHeader, int xsize, int ysize);
-    int CreateBMPHeaderRGBA(sal_uInt8 *bmpHeader, int xsize, int ysize);
+#endif
     int RenderLine2FBO(int wholeFlag);
     int SetLine2DShapePoint(float x, float y, int listLength);
     void SetLine2DColor(sal_uInt8 r, sal_uInt8 g, sal_uInt8 b);
commit 6616122b5cbe60dd460a712e441362d82df6b84a
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Mon Jan 13 22:51:38 2014 +0100

    no need for a member variable if only used in one method
    
    Change-Id: If82cb7ff43932c6d37d4b3100c2bd5228f6109ce

diff --git a/chart2/source/view/main/OpenGLRender.cxx b/chart2/source/view/main/OpenGLRender.cxx
index 8d713c6..50764f4 100644
--- a/chart2/source/view/main/OpenGLRender.cxx
+++ b/chart2/source/view/main/OpenGLRender.cxx
@@ -932,7 +932,6 @@ OpenGLRender::OpenGLRender(uno::Reference< drawing::XShape > xTarget):
 {
     //TODO: moggi: use STL
     memset(&m_Bubble2DCircle, 0, sizeof(m_Bubble2DCircle));
-    memset(&m_TextInfo, 0, sizeof(TextInfo));
 
     m_iArbMultisampleFormat = 0;
 
@@ -1504,44 +1503,45 @@ int OpenGLRender::CreateTextTexture(::rtl::OUString textValue, sal_uInt32 color,
         }
     }
     aBitmap.ReleaseAccess(pRAcc);
-    m_TextInfo.x = (float)(aPos.X + aSize.Width / 2) / OPENGL_SCALE_VALUE;
-    m_TextInfo.y = (float)(aPos.Y + aSize.Height / 2) / OPENGL_SCALE_VALUE;
-    m_TextInfo.z = m_fZStep;
-    m_TextInfo.rotation = -(double)rotation * GL_PI / 18000.0f;
-    m_TextInfo.vertex[0] = (float)(-aSize.Width / 2) / OPENGL_SCALE_VALUE;
-    m_TextInfo.vertex[1] = (float)(-aSize.Height / 2) / OPENGL_SCALE_VALUE;
+    TextInfo aTextInfo;
+    aTextInfo.x = (float)(aPos.X + aSize.Width / 2) / OPENGL_SCALE_VALUE;
+    aTextInfo.y = (float)(aPos.Y + aSize.Height / 2) / OPENGL_SCALE_VALUE;
+    aTextInfo.z = m_fZStep;
+    aTextInfo.rotation = -(double)rotation * GL_PI / 18000.0f;
+    aTextInfo.vertex[0] = (float)(-aSize.Width / 2) / OPENGL_SCALE_VALUE;
+    aTextInfo.vertex[1] = (float)(-aSize.Height / 2) / OPENGL_SCALE_VALUE;
 
-    m_TextInfo.vertex[2] = (float)(aSize.Width / 2) / OPENGL_SCALE_VALUE;
-    m_TextInfo.vertex[3] = (float)(-aSize.Height / 2) / OPENGL_SCALE_VALUE;
+    aTextInfo.vertex[2] = (float)(aSize.Width / 2) / OPENGL_SCALE_VALUE;
+    aTextInfo.vertex[3] = (float)(-aSize.Height / 2) / OPENGL_SCALE_VALUE;
 
-    m_TextInfo.vertex[4] = (float)(aSize.Width / 2) / OPENGL_SCALE_VALUE;
-    m_TextInfo.vertex[5] = (float)(aSize.Height / 2) / OPENGL_SCALE_VALUE;
+    aTextInfo.vertex[4] = (float)(aSize.Width / 2) / OPENGL_SCALE_VALUE;
+    aTextInfo.vertex[5] = (float)(aSize.Height / 2) / OPENGL_SCALE_VALUE;
 
-    m_TextInfo.vertex[6] = (float)(-aSize.Width / 2) / OPENGL_SCALE_VALUE;
-    m_TextInfo.vertex[7] = (float)(aSize.Height / 2) / OPENGL_SCALE_VALUE;
+    aTextInfo.vertex[6] = (float)(-aSize.Width / 2) / OPENGL_SCALE_VALUE;
+    aTextInfo.vertex[7] = (float)(aSize.Height / 2) / OPENGL_SCALE_VALUE;
 
     //if has ratotion, we must re caculate the central pos
     if (!rtl::math::approxEqual(0, rotation))
     {
         //use left top
         double r = sqrt((double)(aSize.Width * aSize.Width + aSize.Height * aSize.Height)) / 2;
-        double sinOrgAngle =  m_TextInfo.vertex[1] / r / 2;
-        double cosOrgAngle = m_TextInfo.vertex[0] / r / 2;
-        double sinDiataAngle = sin(m_TextInfo.rotation);
-        double cosDiataAngle = cos(m_TextInfo.rotation);
+        double sinOrgAngle =  aTextInfo.vertex[1] / r / 2;
+        double cosOrgAngle = aTextInfo.vertex[0] / r / 2;
+        double sinDiataAngle = sin(aTextInfo.rotation);
+        double cosDiataAngle = cos(aTextInfo.rotation);
         double x = r * (cosOrgAngle * cosDiataAngle - sinOrgAngle * sinDiataAngle);
         double y = r * (sinOrgAngle * cosDiataAngle + cosOrgAngle * sinDiataAngle);
-        double diataX = x - m_TextInfo.vertex[0];
-        double diataY = y - m_TextInfo.vertex[1];
-        m_TextInfo.x = m_TextInfo.x - diataX;
-        m_TextInfo.y = m_TextInfo.y - diataY;
+        double diataX = x - aTextInfo.vertex[0];
+        double diataY = y - aTextInfo.vertex[1];
+        aTextInfo.x = aTextInfo.x - diataX;
+        aTextInfo.y = aTextInfo.y - diataY;
 
     }
 
     CHECK_GL_ERROR();
-    glGenTextures(1, &m_TextInfo.texture);
+    glGenTextures(1, &aTextInfo.texture);
     CHECK_GL_ERROR();
-    glBindTexture(GL_TEXTURE_2D, m_TextInfo.texture);
+    glBindTexture(GL_TEXTURE_2D, aTextInfo.texture);
     CHECK_GL_ERROR();
     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
     CHECK_GL_ERROR();
@@ -1555,7 +1555,7 @@ int OpenGLRender::CreateTextTexture(::rtl::OUString textValue, sal_uInt32 color,
     CHECK_GL_ERROR();
     glBindTexture(GL_TEXTURE_2D, 0);
     CHECK_GL_ERROR();
-    m_TextInfoList.push_back(m_TextInfo);
+    m_TextInfoList.push_back(aTextInfo);
     return 0;
 }
 
diff --git a/chart2/source/view/main/OpenGLRender.hxx b/chart2/source/view/main/OpenGLRender.hxx
index e082be7..30b49af 100644
--- a/chart2/source/view/main/OpenGLRender.hxx
+++ b/chart2/source/view/main/OpenGLRender.hxx
@@ -277,7 +277,6 @@ private:
 
     std::list <RectanglePointList> m_RectangleShapePointList;
     // add for text
-    TextInfo m_TextInfo;
     std::list <TextInfo> m_TextInfoList;
     GLint m_TextProID;
     GLint m_TextMatrixID;
commit 7eb818019a14e83b2fa9e9f79731c8528c7d5a16
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Mon Jan 13 22:49:54 2014 +0100

    let us be a bit more conservative and deal with floating point correctly
    
    Change-Id: I22e21c1550982458f1a2c464a8b82e1d71e0525d

diff --git a/chart2/source/view/main/OpenGLRender.cxx b/chart2/source/view/main/OpenGLRender.cxx
index 0fef5c5..8d713c6 100644
--- a/chart2/source/view/main/OpenGLRender.cxx
+++ b/chart2/source/view/main/OpenGLRender.cxx
@@ -1521,7 +1521,7 @@ int OpenGLRender::CreateTextTexture(::rtl::OUString textValue, sal_uInt32 color,
     m_TextInfo.vertex[7] = (float)(aSize.Height / 2) / OPENGL_SCALE_VALUE;
 
     //if has ratotion, we must re caculate the central pos
-    if (rotation)
+    if (!rtl::math::approxEqual(0, rotation))
     {
         //use left top
         double r = sqrt((double)(aSize.Width * aSize.Width + aSize.Height * aSize.Height)) / 2;
commit 55df03acb588fec5b6a726a9cb335d11340461e6
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Mon Jan 13 22:47:23 2014 +0100

    no need for the bitmap header, we ignore it anyway in the next stage
    
    Change-Id: I007434264bd5649c55d195d30c5447704f930fe0

diff --git a/chart2/source/view/main/OpenGLRender.cxx b/chart2/source/view/main/OpenGLRender.cxx
index 41728713..0fef5c5 100644
--- a/chart2/source/view/main/OpenGLRender.cxx
+++ b/chart2/source/view/main/OpenGLRender.cxx
@@ -1474,9 +1474,7 @@ int OpenGLRender::CreateTextTexture(::rtl::OUString textValue, sal_uInt32 color,
     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 + BMP_HEADER_LEN]);
-    //TODO:moggi: why do we need the BMP header?
-    CreateBMPHeaderRGBA(bitmapBuf.get(), bmpWidth, bmpHeight);
+    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;
@@ -1488,7 +1486,7 @@ int OpenGLRender::CreateTextTexture(::rtl::OUString textValue, sal_uInt32 color,
         for(long nx = 0; nx < bmpWidth; nx++)
         {
            sal_uInt8 *pm = pRAcc->GetScanline(ny) + nx * 3;
-           sal_uInt8 *mk = bitmapBuf.get() +  BMP_HEADER_LEN + ny * bmpWidth * 4 + nx * 4;
+           sal_uInt8 *mk = bitmapBuf.get() + ny * bmpWidth * 4 + nx * 4;
            if ((*pm == 0xFF) && (*(pm + 1) == 0xFF) && (*(pm + 2) == 0xFF))
            {
                *mk = *pm;
@@ -1553,7 +1551,7 @@ 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() + BMP_HEADER_LEN);
+    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, bmpWidth, bmpHeight, 0, GL_BGRA, GL_UNSIGNED_BYTE, bitmapBuf.get());
     CHECK_GL_ERROR();
     glBindTexture(GL_TEXTURE_2D, 0);
     CHECK_GL_ERROR();


More information about the Libreoffice-commits mailing list