Kaydet (Commit) 5302d5a3 authored tarafından Louis-Francis Ratté-Boulianne's avatar Louis-Francis Ratté-Boulianne Kaydeden (comit) Markus Mohrhard

vcl: Add support for transparent polygon drawing with OpenGL

Change-Id: Iaa7cdcf4742d8148507c69c222bff417b9f9426c
üst ab63fe78
......@@ -61,6 +61,7 @@ protected:
bool CreateMaskProgram( void );
void BeginSolid( SalColor nColor, sal_uInt8 nTransparency );
void BeginSolid( SalColor nColor, double fTransparency );
void BeginSolid( SalColor nColor );
void EndSolid( void );
void BeginInvert( void );
......
......@@ -40,6 +40,13 @@
((float) SALCOLOR_BLUE( nColor )) / 255, \
(100 - nTransparency) * (1.0 / 100) )
#define glUniformColorf(nUniform, nColor, fTransparency) \
glUniform4f( nUniform, \
((float) SALCOLOR_RED( nColor )) / 255, \
((float) SALCOLOR_GREEN( nColor )) / 255, \
((float) SALCOLOR_BLUE( nColor )) / 255, \
(1.0f - fTransparency) )
OpenGLSalGraphicsImpl::~OpenGLSalGraphicsImpl()
{
}
......@@ -202,18 +209,41 @@ void OpenGLSalGraphicsImpl::BeginSolid( SalColor nColor, sal_uInt8 nTransparency
return;
}
if( nTransparency > 0 )
{
glEnable( GL_BLEND );
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
}
glUseProgram( mnSolidProgram );
glUniformColor( mnColorUniform, nColor, nTransparency );
}
void OpenGLSalGraphicsImpl::BeginSolid( SalColor nColor, double fTransparency )
{
if( mnSolidProgram == 0 )
{
if( !CreateSolidProgram() )
return;
}
if( fTransparency > 0.0f )
{
glEnable( GL_BLEND );
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
}
glUseProgram( mnSolidProgram );
glUniformColorf( mnColorUniform, nColor, fTransparency );
}
void OpenGLSalGraphicsImpl::BeginSolid( SalColor nColor )
{
BeginSolid( nColor, 0 );
BeginSolid( nColor, 0.0f );
}
void OpenGLSalGraphicsImpl::EndSolid( void )
{
glUseProgram( 0 );
glDisable( GL_BLEND );
}
void OpenGLSalGraphicsImpl::BeginInvert( void )
......@@ -592,9 +622,27 @@ void OpenGLSalGraphicsImpl::drawPolyPolygon( sal_uInt32 nPoly, const sal_uInt32*
}
}
bool OpenGLSalGraphicsImpl::drawPolyPolygon( const ::basegfx::B2DPolyPolygon&, double /*fTransparency*/ )
bool OpenGLSalGraphicsImpl::drawPolyPolygon( const ::basegfx::B2DPolyPolygon& rPolyPolygon, double fTransparency )
{
return false;
SAL_INFO( "vcl.opengl", "::drawPolyPolygon trans " << fTransparency );
if( rPolyPolygon.count() <= 0 )
return true;
maContext.makeCurrent();
glViewport( 0, 0, GetWidth(), GetHeight() );
if( mnFillColor != SALCOLOR_NONE )
{
BeginSolid( mnFillColor, fTransparency );
for( sal_uInt32 i = 0; i < rPolyPolygon.count(); i++ )
{
const ::basegfx::B2DPolyPolygon aOnePoly( rPolyPolygon.getB2DPolygon( i ) );
DrawPolyPolygon( aOnePoly );
}
EndSolid();
}
return true;
}
bool OpenGLSalGraphicsImpl::drawPolyLine(
......@@ -843,6 +891,7 @@ bool OpenGLSalGraphicsImpl::drawAlphaRect(
long nWidth, long nHeight,
sal_uInt8 nTransparency )
{
SAL_INFO( "vcl.opengl", "::drawAlphaRect" );
if( mnFillColor != SALCOLOR_NONE && nTransparency < 100 )
{
BeginSolid( mnFillColor, nTransparency );
......
......@@ -11,7 +11,7 @@
uniform vec4 color;
void main() {
gl_FragColor = color;
gl_FragColor = color;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -231,7 +231,7 @@ void OutputDevice::DrawPolygon( const Polygon& rPoly )
// Caution: This method is nearly the same as
// OutputDevice::DrawTransparent( const basegfx::B2DPolyPolygon& rB2DPolyPoly, double fTransparency),
// so when changes are made here do not forget to make change sthere, too
// so when changes are made here do not forget to make changes there, too
void OutputDevice::DrawPolyPolygon( const basegfx::B2DPolyPolygon& rB2DPolyPoly )
{
......
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