diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2014-02-05 11:54:50 +0100 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2014-02-06 16:15:05 +0100 |
commit | a12ce634d83625886ee6930d6db2999c6864262d (patch) | |
tree | 7191d863b9096e7c1d478a9da57733cd2b0de1e0 /chart2 | |
parent | d76b50a0883451c6c92618f06ecbd7d5232d79d7 (diff) |
improve color handling and alpha channel handling
Change-Id: Ic58c763318eab538ff84e408029aaabda635443e
Diffstat (limited to 'chart2')
-rw-r--r-- | chart2/source/view/main/DummyXShape.cxx | 76 | ||||
-rwxr-xr-x | chart2/source/view/main/OpenGLRender.cxx | 26 | ||||
-rwxr-xr-x | chart2/source/view/main/OpenGLRender.hxx | 10 |
3 files changed, 59 insertions, 53 deletions
diff --git a/chart2/source/view/main/DummyXShape.cxx b/chart2/source/view/main/DummyXShape.cxx index 4cb2c7ab8e4e..da83f7304b50 100644 --- a/chart2/source/view/main/DummyXShape.cxx +++ b/chart2/source/view/main/DummyXShape.cxx @@ -361,17 +361,18 @@ void DummyPieSegment2D::render() pChart->m_GLRender.GeneratePieSegment2D(mfUnitCircleInnerRadius, mfUnitCircleOuterRadius, mfUnitCircleStartAngleDegree, mfUnitCircleWidthAngleDegree); - std::map<OUString, uno::Any>::const_iterator itr = maProperties.find(UNO_NAME_FILLCOLOR); + sal_uInt8 nAlpha = 255; + std::map<OUString, uno::Any>::const_iterator itr = maProperties.find(UNO_NAME_FILL_TRANSPARENCE); if(itr != maProperties.end()) { - sal_Int32 nColor = itr->second.get<sal_Int32>(); - pChart->m_GLRender.SetColor(nColor); + nAlpha = 255 - itr->second.get<sal_Int32>(); } - itr = maProperties.find(UNO_NAME_FILL_TRANSPARENCE); + + itr = maProperties.find(UNO_NAME_FILLCOLOR); if(itr != maProperties.end()) { - sal_Int32 transparency = itr->second.get<sal_Int32>(); - pChart->m_GLRender.SetTransparency(255-(transparency&(0xFF))); + sal_Int32 nColor = itr->second.get<sal_Int32>(); + pChart->m_GLRender.SetColor(nColor, nAlpha); } float nSize = std::max<float>(maUnitCircleToScene.Line1.Column1, maUnitCircleToScene.Line2.Column2); @@ -424,7 +425,7 @@ void DummyArea2D::render() if(itr != maProperties.end()) { sal_Int32 nColor = itr->second.get<sal_Int32>(); - pChart->m_GLRender.SetColor(nColor); + pChart->m_GLRender.SetColor(nColor, 255); } pChart->m_GLRender.RenderArea2DShape(); @@ -445,7 +446,7 @@ void DummySymbol2D::render() { DummyChart* pChart = getRootShape(); - pChart->m_GLRender.SetColor(mnFillColor); + pChart->m_GLRender.SetColor(mnFillColor, 255); pChart->m_GLRender.RenderSymbol2DShape(maPosition.X, maPosition.Y, maSize.Width, maSize.Height, mnStandardSymbol); } @@ -465,10 +466,11 @@ void DummyCircle::render() if(itr != maProperties.end()) { sal_Int32 nColor = itr->second.get<sal_Int32>(); - pChart->m_GLRender.SetColor(nColor); + pChart->m_GLRender.SetColor(nColor, 255); } else SAL_WARN("chart2.opengl", "missing color"); + pChart->m_GLRender.Bubble2DShapePoint(maPosition.X, maPosition.Y, maSize.Width, maSize.Height); pChart->m_GLRender.RenderBubble2FBO(GL_TRUE); @@ -530,19 +532,41 @@ void DummyLine2D::render() SAL_WARN("chart2.opengl", "rendering line 2D"); debugProperties(maProperties); DummyChart* pChart = getRootShape(); - std::map< OUString, uno::Any >::const_iterator itr = maProperties.find(UNO_NAME_LINECOLOR); + + //add style and transparency + std::map< OUString, uno::Any >::const_iterator itr = maProperties.find(UNO_NAME_LINESTYLE); + if (itr != maProperties.end()) + { + uno::Any cow = itr->second; + drawing::LineStyle nStyle = cow.get<drawing::LineStyle>(); + if (drawing::LineStyle_NONE == nStyle) + { + // nothing to render + return; + } + } + + sal_uInt8 nAlpha = 255; + itr = maProperties.find("LineTransparence"); + if(itr != maProperties.end()) + { + uno::Any al = itr->second; + nAlpha = 255 - al.get<sal_Int32>(); + } + + itr = maProperties.find(UNO_NAME_LINECOLOR); if(itr != maProperties.end()) { //set line color uno::Any co = itr->second; sal_Int32 nColorValue = co.get<sal_Int32>(); - SAL_WARN("chart2.opengl", "*colorvalue = " << nColorValue); + SAL_INFO("chart2.opengl", "line colorvalue = " << nColorValue); sal_uInt8 R = (nColorValue & 0x00FF0000) >> 16; sal_uInt8 G = (nColorValue & 0x0000FF00) >> 8; sal_uInt8 B = (nColorValue & 0x000000FF); - pChart->m_GLRender.SetLine2DColor(R, G, B); + pChart->m_GLRender.SetLine2DColor(R, G, B, nAlpha); - SAL_WARN("chart2.opengl", "*colorvalue = " << nColorValue << ", R = " << (int)R << ", G = " << (int)G << ", B = " << (int)B); + SAL_INFO("chart2.opengl", "line colorvalue = " << nColorValue << ", R = " << (int)R << ", G = " << (int)G << ", B = " << (int)B); } else SAL_WARN("chart2.opengl", "no line color set"); @@ -560,22 +584,6 @@ void DummyLine2D::render() else SAL_WARN("chart2.opengl", "no line width set"); - //add style and transparency - itr = maProperties.find(UNO_NAME_LINESTYLE); - if (itr != maProperties.end()) - { - uno::Any cow = itr->second; - drawing::LineStyle nStyle = cow.get<drawing::LineStyle>(); - if (drawing::LineStyle_NONE == nStyle) - { - pChart->m_GLRender.SetTransparency(0); - } - else - { - pChart->m_GLRender.SetTransparency(255); - } - } - sal_Int32 pointsscount = maPoints.getLength(); for(sal_Int32 i = 0; i < pointsscount; i++) { @@ -636,7 +644,15 @@ void DummyRectangle::render() { uno::Any co = itr->second; sal_Int32 nColorValue = co.get<sal_Int32>(); - pChart->m_GLRender.SetBackGroundColor(nColorValue, nColorValue); + + itr = maProperties.find("FillTransparence"); + sal_uInt8 nAlpha = 255; + if(itr != maProperties.end()) + { + uno::Any al = itr->second; + nAlpha = al.get<sal_Int32>(); + } + pChart->m_GLRender.SetBackGroundColor(nColorValue, nColorValue, nAlpha); } bool bBorder = true; diff --git a/chart2/source/view/main/OpenGLRender.cxx b/chart2/source/view/main/OpenGLRender.cxx index 9097c7858397..9de0571cd5c4 100755 --- a/chart2/source/view/main/OpenGLRender.cxx +++ b/chart2/source/view/main/OpenGLRender.cxx @@ -835,9 +835,9 @@ int OpenGLRender::CreateBMPHeader(sal_uInt8 *bmpHeader, int xsize, int ysize) } #endif -void OpenGLRender::SetLine2DColor(sal_uInt8 r, sal_uInt8 g, sal_uInt8 b) +void OpenGLRender::SetLine2DColor(sal_uInt8 r, sal_uInt8 g, sal_uInt8 b, sal_uInt8 nAlpha) { - m_2DColor = glm::vec4((float)r / 255.0f, (float)g / 255.0f, (float)b / 255.0f, m_fAlpha); + m_2DColor = glm::vec4((float)r / 255.0f, (float)g / 255.0f, (float)b / 255.0f, nAlpha/255.f); } void OpenGLRender::SetLine2DWidth(int width) @@ -1046,12 +1046,12 @@ bool OpenGLRender::WGLisExtensionSupported(const char *extension) } #endif -void OpenGLRender::SetColor(sal_uInt32 color) +void OpenGLRender::SetColor(sal_uInt32 color, sal_uInt8 nAlpha) { sal_uInt8 r = (color & 0x00FF0000) >> 16; sal_uInt8 g = (color & 0x0000FF00) >> 8; sal_uInt8 b = (color & 0x000000FF); - m_2DColor = glm::vec4((float)r / 255.0f, (float)g / 255.0f, (float)b / 255.0f, m_fAlpha); + m_2DColor = glm::vec4((float)r / 255.0f, (float)g / 255.0f, (float)b / 255.0f, nAlpha/ 255.f); } int OpenGLRender::CreateMultiSampleFrameBufObj() @@ -1169,12 +1169,6 @@ int OpenGLRender::RenderBubble2FBO(int) return 0; } -void OpenGLRender::SetTransparency(sal_uInt32 transparency) -{ - m_fAlpha = (float)transparency / 255.0; - m_2DColor = glm::vec4(m_2DColor.r, m_2DColor.g, m_2DColor.b, m_fAlpha); -} - int OpenGLRender::RectangleShapePoint(float x, float y, float directionX, float directionY) { //check whether to create the circle data @@ -1269,7 +1263,7 @@ int OpenGLRender::RenderRectangleShape(bool bBorder, bool bFill) m_fZStep += Z_STEP; glUniformMatrix4fv(m_BackgroundMatrixID, 1, GL_FALSE, &m_MVP[0][0]); } - SetBackGroundColor(COL_BLACK, COL_BLACK); + SetBackGroundColor(COL_BLACK, COL_BLACK, 255); glBindBuffer(GL_ARRAY_BUFFER, m_ColorBuffer); glBufferData(GL_ARRAY_BUFFER, sizeof(m_BackgroundColor), m_BackgroundColor, GL_STATIC_DRAW); @@ -1571,7 +1565,7 @@ int OpenGLRender::RenderArea2DShape() return 0; } -void OpenGLRender::SetBackGroundColor(sal_uInt32 color1, sal_uInt32 color2) +void OpenGLRender::SetBackGroundColor(sal_uInt32 color1, sal_uInt32 color2, sal_uInt8 nAlpha) { sal_uInt8 r = (color1 & 0x00FF0000) >> 16; sal_uInt8 g = (color1 & 0x0000FF00) >> 8; @@ -1580,12 +1574,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] = m_fAlpha; + m_BackgroundColor[3] = nAlpha / 255.0f; m_BackgroundColor[4] = (float)r / 255.0f; m_BackgroundColor[5] = (float)g / 255.0f; m_BackgroundColor[6] = (float)b / 255.0f; - m_BackgroundColor[7] = m_fAlpha; + m_BackgroundColor[7] = nAlpha / 255.0f; r = (color2 & 0x00FF0000) >> 16; g = (color2 & 0x0000FF00) >> 8; @@ -1594,12 +1588,12 @@ void OpenGLRender::SetBackGroundColor(sal_uInt32 color1, sal_uInt32 color2) m_BackgroundColor[8] = (float)r / 255.0f; m_BackgroundColor[9] = (float)g / 255.0f; m_BackgroundColor[10] = (float)b / 255.0f; - m_BackgroundColor[11] = 1.0; + m_BackgroundColor[11] = nAlpha / 255.0f; m_BackgroundColor[12] = (float)r / 255.0f; m_BackgroundColor[13] = (float)g / 255.0f; m_BackgroundColor[14] = (float)b / 255.0f; - m_BackgroundColor[15] = 1.0; + m_BackgroundColor[15] = nAlpha / 255.0f; SAL_INFO("chart2.opengl", "color1 = " << color1 << ", color2 = " << color2); } diff --git a/chart2/source/view/main/OpenGLRender.hxx b/chart2/source/view/main/OpenGLRender.hxx index b5aeba302f36..8ba5c761a21d 100755 --- a/chart2/source/view/main/OpenGLRender.hxx +++ b/chart2/source/view/main/OpenGLRender.hxx @@ -141,7 +141,7 @@ public: #endif int RenderLine2FBO(int wholeFlag); int SetLine2DShapePoint(float x, float y, int listLength); - void SetLine2DColor(sal_uInt8 r, sal_uInt8 g, sal_uInt8 b); + void SetLine2DColor(sal_uInt8 r, sal_uInt8 g, sal_uInt8 b, sal_uInt8 nAlpha); void SetLine2DWidth(int width); BitmapEx GetAsBitmap(); #if defined( _WIN32 ) @@ -149,15 +149,13 @@ public: bool GetMSAASupport(); int GetMSAAFormat(); #endif - void SetColor(sal_uInt32 color); + void SetColor(sal_uInt32 color, sal_uInt8 nAlpha); int Bubble2DShapePoint(float x, float y, float directionX, float directionY); int RenderBubble2FBO(int wholeFlag); void prepareToRender(); void renderToBitmap(); - - void SetTransparency(sal_uInt32 transparency); int RenderRectangleShape(bool bBorder, bool bFill); int RectangleShapePoint(float x, float y, float directionX, float directionY); @@ -178,7 +176,7 @@ public: void renderDebug(); #endif - void SetBackGroundColor(sal_uInt32 color1, sal_uInt32 color2); + void SetBackGroundColor(sal_uInt32 color1, sal_uInt32 color2, sal_uInt8 nAlpha); private: GLint LoadShaders(const OUString& rVertexShaderName, const OUString& rFragmentShaderName); @@ -262,8 +260,6 @@ private: float m_fZStep; - float m_fAlpha; - std::list <RectanglePointList> m_RectangleShapePointList; // add for text std::list <TextInfo> m_TextInfoList; |