[Libreoffice-commits] core.git: chart2/source

Markus Mohrhard markus.mohrhard at collabora.co.uk
Fri Mar 7 02:41:03 PST 2014


 chart2/source/view/main/OpenGLRender.cxx |   27 +++++++++++----------------
 chart2/source/view/main/OpenGLRender.hxx |    4 ++--
 2 files changed, 13 insertions(+), 18 deletions(-)

New commits:
commit d102ae2ce8873b01d9408e37a843e16062c50531
Author: Markus Mohrhard <markus.mohrhard at collabora.co.uk>
Date:   Fri Mar 7 11:37:30 2014 +0100

    fix the rotation matrix for text shapes
    
    Change-Id: I78bf93da4b06f694621e92832773a1abd01256d7

diff --git a/chart2/source/view/main/OpenGLRender.cxx b/chart2/source/view/main/OpenGLRender.cxx
index 7c8932d..3b81db2 100755
--- a/chart2/source/view/main/OpenGLRender.cxx
+++ b/chart2/source/view/main/OpenGLRender.cxx
@@ -1299,24 +1299,23 @@ int OpenGLRender::CreateTextTexture(const BitmapEx& rBitmapEx, const awt::Point&
 
     TextInfo aTextInfo;
     aTextInfo.rotation = -(double)rotation / 360.0 * 2* GL_PI;
-    aTextInfo.vertex[0] = rTrans.Line1.Column3 / OPENGL_SCALE_VALUE;
-    aTextInfo.vertex[1] = rTrans.Line2.Column3 / OPENGL_SCALE_VALUE;
+    aTextInfo.vertex[0] = -aSize.Width / 2 / OPENGL_SCALE_VALUE;
+    aTextInfo.vertex[1] = -aSize.Height / 2 / OPENGL_SCALE_VALUE;
     aTextInfo.vertex[2] = m_fZStep;
 
-    aTextInfo.vertex[3] = (rTrans.Line1.Column3 + aSize.Width ) / OPENGL_SCALE_VALUE ;
-    aTextInfo.vertex[4] = rTrans.Line2.Column3 / OPENGL_SCALE_VALUE;
+    aTextInfo.vertex[3] = aSize.Width / 2 / OPENGL_SCALE_VALUE ;
+    aTextInfo.vertex[4] = -aSize.Height / 2 / OPENGL_SCALE_VALUE;
     aTextInfo.vertex[5] = m_fZStep;
 
-    aTextInfo.vertex[6] = (rTrans.Line1.Column3 + aSize.Width) / OPENGL_SCALE_VALUE;
-    aTextInfo.vertex[7] = (rTrans.Line2.Column3 + aSize.Height) / OPENGL_SCALE_VALUE;
+    aTextInfo.vertex[6] = aSize.Width / 2 / OPENGL_SCALE_VALUE;
+    aTextInfo.vertex[7] = aSize.Height / 2 / OPENGL_SCALE_VALUE;
     aTextInfo.vertex[8] = m_fZStep;
 
-    aTextInfo.vertex[9] = rTrans.Line1.Column3 / OPENGL_SCALE_VALUE;
-    aTextInfo.vertex[10] = (rTrans.Line2.Column3 + aSize.Height) / OPENGL_SCALE_VALUE;
+    aTextInfo.vertex[9] = -aSize.Width / 2 / OPENGL_SCALE_VALUE;
+    aTextInfo.vertex[10] = aSize.Height / 2 / OPENGL_SCALE_VALUE;
     aTextInfo.vertex[11] = m_fZStep;
-
-    aTextInfo.bmpWidth = bmpWidth;
-    aTextInfo.bmpHeight = bmpHeight;
+    aTextInfo.nDx = (rTrans.Line1.Column3 + aSize.Width / 2 ) / OPENGL_SCALE_VALUE - bmpWidth/2;
+    aTextInfo.nDy = (rTrans.Line2.Column3 + aSize.Height / 2 ) / OPENGL_SCALE_VALUE - bmpHeight/2;
 
     CHECK_GL_ERROR();
     glGenTextures(1, &aTextInfo.texture);
@@ -1346,11 +1345,7 @@ int OpenGLRender::RenderTextShape()
     for (size_t i = 0; i < listNum; i++)
     {
         TextInfo &textInfo = m_TextInfoList.front();
-        PosVecf3 trans = { (float)-textInfo.bmpWidth/2.0f, (float)-textInfo.bmpHeight/2.0f, 0};
-        if(0.0 != textInfo.rotation)
-        {
-            SAL_WARN("chart2.opengl", "rotation: " << textInfo.rotation);
-        }
+        PosVecf3 trans = { textInfo.nDx, textInfo.nDy, 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 ca999e2..8e5314d 100755
--- a/chart2/source/view/main/OpenGLRender.hxx
+++ b/chart2/source/view/main/OpenGLRender.hxx
@@ -81,8 +81,8 @@ struct TextInfo
     GLuint texture;
     double rotation;
     float vertex[12];
-    long bmpWidth;
-    long bmpHeight;
+    float nDx;
+    float nDy;
 };
 
 typedef std::vector<GLfloat> Area2DPointList;


More information about the Libreoffice-commits mailing list