Kaydet (Commit) 8d8a2f2b authored tarafından Markus Mohrhard's avatar Markus Mohrhard Kaydeden (comit) Markus Mohrhard

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
üst 1cc82471
......@@ -122,6 +122,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 )
......@@ -642,8 +646,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")
{
......@@ -693,7 +697,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()
......@@ -702,7 +713,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();
}
......
......@@ -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
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment