chart2/source/view/main/DummyXShape.cxx  |   37 ++++++++++++++++++++++++---
 chart2/source/view/main/OpenGLRender.cxx |   42 +++++++++++++++++++++----------
 chart2/source/view/main/OpenGLRender.hxx |    6 ++--
 3 files changed, 66 insertions(+), 19 deletions(-)

New commits:
commit 8360a65fb813ab575338a1ce9cfc784f7d84f405
Author: Markus Mohrhard <[email protected]>
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 240bf78..ad28fc9 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 )
@@ -620,8 +624,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")
         {
@@ -671,7 +675,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(aTrans.Line1.Column1, aTrans.Line2.Column2));
+        setPosition(awt::Point(aTrans.Line1.Column3, aTrans.Line2.Column3));
+    }
+    else
+        setSize(awt::Size(20*bmpWidth, 20*bmpHeight));
 }
 
 void DummyText::render()
@@ -680,7 +691,25 @@ 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())
+    {
+        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 42fdaa2..dd9d5b1 100644
--- a/chart2/source/view/main/OpenGLRender.cxx
+++ b/chart2/source/view/main/OpenGLRender.cxx
@@ -1414,8 +1414,12 @@ int OpenGLRender::RenderRectangleShape()
 }
 
 
-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;
@@ -1458,17 +1462,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))
@@ -1532,7 +1548,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 45cef79..4271791 100644
--- a/chart2/source/view/main/OpenGLRender.hxx
+++ b/chart2/source/view/main/OpenGLRender.hxx
@@ -23,6 +23,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>
@@ -96,7 +97,7 @@ typedef struct TextInfo
     float y;
     float z;
     double rotation;
-    float vertex[8];
+    float vertex[12];
 }TextInfo;
 
 typedef std::vector<GLfloat> Area2DPointList;
@@ -167,7 +168,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);
_______________________________________________
Libreoffice-commits mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to