2014-10-23 23:23:26 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "openglgdiimpl.hxx"
|
|
|
|
|
2014-10-29 17:25:55 +01:00
|
|
|
#include <vcl/gradient.hxx>
|
2014-11-03 11:08:24 -05:00
|
|
|
#include <salframe.hxx>
|
2014-11-08 19:23:16 +01:00
|
|
|
#include "salvd.hxx"
|
2014-10-29 13:05:02 -04:00
|
|
|
#include <basegfx/polygon/b2dpolygontools.hxx>
|
|
|
|
#include <basegfx/polygon/b2dpolygontriangulator.hxx>
|
|
|
|
|
2014-10-29 22:30:55 +01:00
|
|
|
#include <vcl/opengl/OpenGLHelper.hxx>
|
2014-10-30 22:00:37 -04:00
|
|
|
#include "opengl/salbmp.hxx"
|
2014-10-29 22:30:55 +01:00
|
|
|
|
2014-11-06 03:37:47 +01:00
|
|
|
#include <vector>
|
|
|
|
|
2014-10-29 13:05:02 -04:00
|
|
|
#define GL_ATTRIB_POS 0
|
|
|
|
#define GL_ATTRIB_TEX 1
|
|
|
|
|
|
|
|
#define glUniformColor(nUniform, nColor, nTransparency) \
|
|
|
|
glUniform4f( nUniform, \
|
|
|
|
((float) SALCOLOR_RED( nColor )) / 255, \
|
|
|
|
((float) SALCOLOR_GREEN( nColor )) / 255, \
|
|
|
|
((float) SALCOLOR_BLUE( nColor )) / 255, \
|
|
|
|
(100 - nTransparency) * (1.0 / 100) )
|
2014-10-29 17:25:55 +01:00
|
|
|
|
2014-11-08 22:55:06 -05:00
|
|
|
#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) )
|
|
|
|
|
2014-10-23 23:23:26 +02:00
|
|
|
OpenGLSalGraphicsImpl::~OpenGLSalGraphicsImpl()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void OpenGLSalGraphicsImpl::freeResources()
|
|
|
|
{
|
2014-10-29 13:05:02 -04:00
|
|
|
// Delete shaders, programs and textures if not shared
|
2014-10-23 23:23:26 +02:00
|
|
|
}
|
|
|
|
|
2014-10-29 13:05:02 -04:00
|
|
|
bool OpenGLSalGraphicsImpl::setClipRegion( const vcl::Region& rClip )
|
2014-10-23 23:23:26 +02:00
|
|
|
{
|
2014-10-29 13:05:02 -04:00
|
|
|
const basegfx::B2DPolyPolygon aClip( rClip.GetAsB2DPolyPolygon() );
|
|
|
|
|
2014-11-06 14:22:15 -05:00
|
|
|
/*glEnable(GL_STENCIL_TEST);
|
2014-10-29 13:05:02 -04:00
|
|
|
|
|
|
|
glColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE );
|
|
|
|
glDepthMask( GL_FALSE );
|
|
|
|
glStencilMask( 0xFF );
|
|
|
|
glStencilFunc( GL_NEVER, 1, 0xFF );
|
|
|
|
glStencilOp( GL_REPLACE, GL_KEEP, GL_KEEP );
|
|
|
|
|
|
|
|
glClear( GL_STENCIL_BUFFER_BIT );
|
|
|
|
DrawPolyPolygon( aClip );
|
|
|
|
|
|
|
|
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
|
|
|
glDepthMask( GL_TRUE );
|
|
|
|
glStencilMask( 0x00 );
|
2014-11-06 14:22:15 -05:00
|
|
|
glStencilFunc(GL_EQUAL, 1, 0xFF);*/
|
2014-10-29 13:05:02 -04:00
|
|
|
|
|
|
|
return true;
|
2014-10-23 23:23:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// get the depth of the device
|
|
|
|
sal_uInt16 OpenGLSalGraphicsImpl::GetBitCount() const
|
|
|
|
{
|
|
|
|
return 32;
|
|
|
|
}
|
|
|
|
|
|
|
|
// get the width of the device
|
|
|
|
long OpenGLSalGraphicsImpl::GetGraphicsWidth() const
|
|
|
|
{
|
2014-11-03 11:08:24 -05:00
|
|
|
return GetWidth();
|
2014-10-30 21:54:22 -04:00
|
|
|
}
|
|
|
|
|
2014-10-23 23:23:26 +02:00
|
|
|
// set the clip region to empty
|
|
|
|
void OpenGLSalGraphicsImpl::ResetClipRegion()
|
|
|
|
{
|
2014-10-29 13:05:02 -04:00
|
|
|
glDisable(GL_STENCIL_TEST);
|
2014-10-23 23:23:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// set the line color to transparent (= don't draw lines)
|
|
|
|
void OpenGLSalGraphicsImpl::SetLineColor()
|
|
|
|
{
|
2014-10-29 13:05:02 -04:00
|
|
|
if( mnLineColor != SALCOLOR_NONE )
|
|
|
|
{
|
|
|
|
mnLineColor = SALCOLOR_NONE;
|
|
|
|
}
|
2014-10-23 23:23:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// set the line color to a specific color
|
2014-10-29 13:05:02 -04:00
|
|
|
void OpenGLSalGraphicsImpl::SetLineColor( SalColor nSalColor )
|
2014-10-23 23:23:26 +02:00
|
|
|
{
|
2014-10-29 13:05:02 -04:00
|
|
|
if( mnLineColor != nSalColor )
|
|
|
|
{
|
|
|
|
mnLineColor = nSalColor;
|
|
|
|
}
|
2014-10-23 23:23:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// set the fill color to transparent (= don't fill)
|
|
|
|
void OpenGLSalGraphicsImpl::SetFillColor()
|
|
|
|
{
|
2014-10-29 13:05:02 -04:00
|
|
|
if( mnFillColor != SALCOLOR_NONE )
|
|
|
|
{
|
|
|
|
mnFillColor = SALCOLOR_NONE;
|
|
|
|
}
|
2014-10-23 23:23:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// set the fill color to a specific color, shapes will be
|
|
|
|
// filled accordingly
|
2014-10-29 13:05:02 -04:00
|
|
|
void OpenGLSalGraphicsImpl::SetFillColor( SalColor nSalColor )
|
2014-10-23 23:23:26 +02:00
|
|
|
{
|
2014-10-29 13:05:02 -04:00
|
|
|
if( mnFillColor != nSalColor )
|
|
|
|
{
|
|
|
|
mnFillColor = nSalColor;
|
|
|
|
}
|
2014-10-23 23:23:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// enable/disable XOR drawing
|
|
|
|
void OpenGLSalGraphicsImpl::SetXORMode( bool /*bSet*/, bool /*bInvertOnly*/ )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// set line color for raster operations
|
|
|
|
void OpenGLSalGraphicsImpl::SetROPLineColor( SalROPColor /*nROPColor*/ )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// set fill color for raster operations
|
|
|
|
void OpenGLSalGraphicsImpl::SetROPFillColor( SalROPColor /*nROPColor*/ )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-10-29 13:05:02 -04:00
|
|
|
bool OpenGLSalGraphicsImpl::CreateSolidProgram( void )
|
|
|
|
{
|
2014-10-29 22:30:55 +01:00
|
|
|
mnSolidProgram = OpenGLHelper::LoadShaders( "solidVertexShader", "solidFragmentShader" );
|
2014-10-29 13:05:02 -04:00
|
|
|
if( mnSolidProgram == 0 )
|
|
|
|
return false;
|
|
|
|
|
2014-11-06 14:22:15 -05:00
|
|
|
SAL_INFO( "vcl.opengl", "Solid Program Created" );
|
2014-10-29 13:05:02 -04:00
|
|
|
glBindAttribLocation( mnSolidProgram, GL_ATTRIB_POS, "position" );
|
|
|
|
mnColorUniform = glGetUniformLocation( mnSolidProgram, "color" );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool OpenGLSalGraphicsImpl::CreateTextureProgram( void )
|
|
|
|
{
|
2014-10-30 21:51:39 -04:00
|
|
|
mnTextureProgram = OpenGLHelper::LoadShaders( "textureVertexShader", "textureFragmentShader" );
|
2014-10-29 13:05:02 -04:00
|
|
|
if( mnTextureProgram == 0 )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
glBindAttribLocation( mnTextureProgram, GL_ATTRIB_POS, "position" );
|
|
|
|
glBindAttribLocation( mnTextureProgram, GL_ATTRIB_TEX, "tex_coord_in" );
|
|
|
|
mnSamplerUniform = glGetUniformLocation( mnTextureProgram, "sampler" );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool OpenGLSalGraphicsImpl::CreateMaskedTextureProgram( void )
|
|
|
|
{
|
2014-10-29 22:30:55 +01:00
|
|
|
mnMaskedTextureProgram = OpenGLHelper::LoadShaders( "maskedTextureVertexShader", "maskedTextureFragmentShader" );
|
2014-10-29 13:05:02 -04:00
|
|
|
if( mnMaskedTextureProgram == 0 )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
glBindAttribLocation( mnTextureProgram, GL_ATTRIB_POS, "position" );
|
|
|
|
glBindAttribLocation( mnTextureProgram, GL_ATTRIB_TEX, "tex_coord_in" );
|
|
|
|
mnMaskedSamplerUniform = glGetUniformLocation( mnMaskedTextureProgram, "sampler" );
|
|
|
|
mnMaskSamplerUniform = glGetUniformLocation( mnMaskedTextureProgram, "mask" );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool OpenGLSalGraphicsImpl::CreateMaskProgram( void )
|
|
|
|
{
|
2014-10-29 22:30:55 +01:00
|
|
|
mnMaskedTextureProgram = OpenGLHelper::LoadShaders( "maskVertexShader", "maskFragmentShader" );
|
2014-10-29 13:05:02 -04:00
|
|
|
if( mnMaskedTextureProgram == 0 )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
glBindAttribLocation( mnTextureProgram, GL_ATTRIB_POS, "position" );
|
|
|
|
glBindAttribLocation( mnTextureProgram, GL_ATTRIB_TEX, "tex_coord_in" );
|
|
|
|
mnMaskUniform = glGetUniformLocation( mnMaskProgram, "sampler" );
|
|
|
|
mnMaskColorUniform = glGetUniformLocation( mnMaskProgram, "mask" );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OpenGLSalGraphicsImpl::BeginSolid( SalColor nColor, sal_uInt8 nTransparency )
|
|
|
|
{
|
|
|
|
if( mnSolidProgram == 0 )
|
|
|
|
{
|
2014-11-06 14:22:15 -05:00
|
|
|
glClearColor( 1, 1, 1, 1 );
|
|
|
|
glClear( GL_COLOR_BUFFER_BIT );
|
2014-10-29 13:05:02 -04:00
|
|
|
if( !CreateSolidProgram() )
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-11-08 22:55:06 -05:00
|
|
|
if( nTransparency > 0 )
|
|
|
|
{
|
|
|
|
glEnable( GL_BLEND );
|
|
|
|
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
|
|
|
|
}
|
2014-10-29 13:05:02 -04:00
|
|
|
glUseProgram( mnSolidProgram );
|
|
|
|
glUniformColor( mnColorUniform, nColor, nTransparency );
|
|
|
|
}
|
|
|
|
|
2014-11-08 22:55:06 -05:00
|
|
|
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 );
|
|
|
|
}
|
|
|
|
|
2014-10-29 13:05:02 -04:00
|
|
|
void OpenGLSalGraphicsImpl::BeginSolid( SalColor nColor )
|
|
|
|
{
|
2014-11-08 22:55:06 -05:00
|
|
|
BeginSolid( nColor, 0.0f );
|
2014-10-29 13:05:02 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void OpenGLSalGraphicsImpl::EndSolid( void )
|
|
|
|
{
|
|
|
|
glUseProgram( 0 );
|
2014-11-08 22:55:06 -05:00
|
|
|
glDisable( GL_BLEND );
|
2014-10-29 13:05:02 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void OpenGLSalGraphicsImpl::BeginInvert( void )
|
|
|
|
{
|
|
|
|
glEnable( GL_BLEND );
|
|
|
|
glBlendFunc( GL_ONE_MINUS_DST_COLOR, GL_ZERO );
|
|
|
|
BeginSolid( MAKE_SALCOLOR( 255, 255, 255 ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
void OpenGLSalGraphicsImpl::EndInvert( void )
|
|
|
|
{
|
|
|
|
EndSolid();
|
|
|
|
glDisable( GL_BLEND );
|
|
|
|
}
|
|
|
|
|
|
|
|
void OpenGLSalGraphicsImpl::DrawPoint( long nX, long nY )
|
|
|
|
{
|
|
|
|
GLushort pPoint[2];
|
|
|
|
|
|
|
|
pPoint[0] = nX;
|
2014-11-07 14:33:48 +00:00
|
|
|
pPoint[1] = GetHeight() - nY;
|
2014-10-29 13:05:02 -04:00
|
|
|
|
|
|
|
glEnableVertexAttribArray( GL_ATTRIB_POS );
|
|
|
|
glVertexAttribPointer( GL_ATTRIB_POS, 2, GL_UNSIGNED_SHORT, GL_FALSE, 0, pPoint );
|
|
|
|
glDrawArrays( GL_POINTS, 0, 1 );
|
|
|
|
glDisableVertexAttribArray( GL_ATTRIB_POS );
|
|
|
|
}
|
|
|
|
|
|
|
|
void OpenGLSalGraphicsImpl::DrawLine( long nX1, long nY1, long nX2, long nY2 )
|
|
|
|
{
|
2014-11-03 11:10:14 -05:00
|
|
|
GLfloat pPoints[4];
|
2014-10-29 13:05:02 -04:00
|
|
|
|
2014-11-03 11:10:14 -05:00
|
|
|
pPoints[0] = (2 * nX1) / GetWidth() - 1.0;
|
2014-11-07 14:33:48 +00:00
|
|
|
pPoints[1] = (2 * (GetHeight() - nY1)) / GetHeight() - 1.0;
|
2014-11-03 11:10:14 -05:00
|
|
|
pPoints[2] = (2 * nX2) / GetWidth() - 1.0;;
|
2014-11-07 14:33:48 +00:00
|
|
|
pPoints[3] = (2 * (GetHeight() - nY2)) / GetHeight() - 1.0;
|
2014-10-29 13:05:02 -04:00
|
|
|
|
|
|
|
glEnableVertexAttribArray( GL_ATTRIB_POS );
|
2014-11-03 11:10:14 -05:00
|
|
|
glVertexAttribPointer( GL_ATTRIB_POS, 2, GL_FLOAT, GL_FALSE, 0, pPoints );
|
2014-10-29 13:05:02 -04:00
|
|
|
glDrawArrays( GL_LINES, 0, 2 );
|
|
|
|
glDisableVertexAttribArray( GL_ATTRIB_POS );
|
|
|
|
}
|
|
|
|
|
|
|
|
void OpenGLSalGraphicsImpl::DrawLines( sal_uInt32 nPoints, const SalPoint* pPtAry, bool bClose )
|
|
|
|
{
|
2014-11-06 03:37:47 +01:00
|
|
|
std::vector<GLfloat> aPoints(nPoints * 2);
|
2014-10-29 13:05:02 -04:00
|
|
|
sal_uInt32 i, j;
|
|
|
|
|
2014-11-03 11:10:14 -05:00
|
|
|
for( i = 0, j = 0; i < nPoints; i++ )
|
2014-10-29 13:05:02 -04:00
|
|
|
{
|
2014-11-08 20:17:29 +01:00
|
|
|
aPoints[j++] = (2 * pPtAry[i].mnX) / GetWidth() - 1.0f;
|
|
|
|
aPoints[j++] = 1.0f - (2 * pPtAry[i].mnY) / GetHeight();
|
2014-10-29 13:05:02 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
glEnableVertexAttribArray( GL_ATTRIB_POS );
|
2014-11-08 18:22:41 +01:00
|
|
|
glVertexAttribPointer( GL_ATTRIB_POS, 2, GL_FLOAT, GL_FALSE, 0, &aPoints[0] );
|
2014-10-29 13:05:02 -04:00
|
|
|
if( bClose )
|
|
|
|
glDrawArrays( GL_LINE_LOOP, 0, nPoints );
|
|
|
|
else
|
|
|
|
glDrawArrays( GL_LINE_STRIP, 0, nPoints );
|
|
|
|
glDisableVertexAttribArray( GL_ATTRIB_POS );
|
|
|
|
}
|
|
|
|
|
|
|
|
void OpenGLSalGraphicsImpl::DrawConvexPolygon( sal_uInt32 nPoints, const SalPoint* pPtAry )
|
2014-10-23 23:23:26 +02:00
|
|
|
{
|
2014-11-06 03:37:47 +01:00
|
|
|
std::vector<GLfloat> aVertices(nPoints * 2);
|
2014-10-29 13:05:02 -04:00
|
|
|
sal_uInt32 i, j;
|
|
|
|
|
|
|
|
for( i = 0, j = 0; i < nPoints; i++, j += 2 )
|
|
|
|
{
|
2014-11-06 03:37:47 +01:00
|
|
|
aVertices[j] = (2 * pPtAry[i].mnX) / GetWidth() - 1.0;
|
|
|
|
aVertices[j+1] = (2 * pPtAry[i].mnY) / GetHeight() - 1.0;
|
2014-10-29 13:05:02 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
glEnableVertexAttribArray( GL_ATTRIB_POS );
|
2014-11-08 18:22:41 +01:00
|
|
|
glVertexAttribPointer( GL_ATTRIB_POS, 2, GL_FLOAT, GL_FALSE, 0, &aVertices[0] );
|
2014-10-29 13:05:02 -04:00
|
|
|
glDrawArrays( GL_TRIANGLE_FAN, 0, nPoints );
|
|
|
|
glDisableVertexAttribArray( GL_ATTRIB_POS );
|
2014-10-23 23:23:26 +02:00
|
|
|
}
|
|
|
|
|
2014-10-29 13:05:02 -04:00
|
|
|
void OpenGLSalGraphicsImpl::DrawRect( long nX, long nY, long nWidth, long nHeight )
|
2014-10-23 23:23:26 +02:00
|
|
|
{
|
2014-10-29 13:05:02 -04:00
|
|
|
long nX1( nX );
|
2014-11-05 16:36:22 -05:00
|
|
|
long nY1( GetHeight() - nY );
|
2014-11-03 11:10:14 -05:00
|
|
|
long nX2( nX + nWidth );
|
2014-11-05 16:36:22 -05:00
|
|
|
long nY2( GetHeight() - nY - nHeight );
|
2014-10-29 13:05:02 -04:00
|
|
|
const SalPoint aPoints[] = { { nX1, nY2 }, { nX1, nY1 },
|
|
|
|
{ nX2, nY1 }, { nX2, nY2 }};
|
|
|
|
|
|
|
|
DrawConvexPolygon( 4, aPoints );
|
2014-10-23 23:23:26 +02:00
|
|
|
}
|
|
|
|
|
2014-10-29 13:05:02 -04:00
|
|
|
void OpenGLSalGraphicsImpl::DrawPolygon( sal_uInt32 nPoints, const SalPoint* pPtAry )
|
2014-10-23 23:23:26 +02:00
|
|
|
{
|
2014-10-29 13:05:02 -04:00
|
|
|
::basegfx::B2DPolygon aPolygon;
|
|
|
|
|
|
|
|
for( sal_uInt32 i = 0; i < nPoints; i++ )
|
|
|
|
aPolygon.append( ::basegfx::B2DPoint( pPtAry[i].mnX, pPtAry[i].mnY ) );
|
|
|
|
aPolygon.setClosed( true );
|
|
|
|
|
|
|
|
if( ::basegfx::tools::isConvex( aPolygon ) )
|
|
|
|
{
|
|
|
|
if( nPoints > 2L )
|
|
|
|
{
|
|
|
|
DrawConvexPolygon( nPoints, pPtAry );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const ::basegfx::B2DPolygon& aResult(
|
|
|
|
::basegfx::triangulator::triangulate( aPolygon ) );
|
2014-11-08 20:12:34 +01:00
|
|
|
std::vector<GLfloat> aVertices(aResult.count() * 2);
|
2014-10-29 13:05:02 -04:00
|
|
|
sal_uInt32 j( 0 );
|
|
|
|
|
2014-11-08 20:12:34 +01:00
|
|
|
float nHeight = GetHeight();
|
|
|
|
float nWidth = GetWidth();
|
2014-10-29 13:05:02 -04:00
|
|
|
for( sal_uInt32 i = 0; i < aResult.count(); i++ )
|
|
|
|
{
|
|
|
|
const ::basegfx::B2DPoint& rPt( aResult.getB2DPoint(i) );
|
2014-11-08 20:12:34 +01:00
|
|
|
aVertices[j++] = 2 * rPt.getX() / nWidth - 1.0f;
|
2014-11-08 20:15:33 +01:00
|
|
|
aVertices[j++] = 1.0f - 2 * rPt.getY() / nHeight;
|
2014-10-29 13:05:02 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
glEnableVertexAttribArray( GL_ATTRIB_POS );
|
2014-11-08 20:12:34 +01:00
|
|
|
glVertexAttribPointer( GL_ATTRIB_POS, 2, GL_FLOAT, GL_FALSE, 0, &aVertices[0] );
|
2014-10-29 13:05:02 -04:00
|
|
|
glDrawArrays( GL_TRIANGLES, 0, aResult.count() );
|
|
|
|
glDisableVertexAttribArray( GL_ATTRIB_POS );
|
|
|
|
}
|
2014-10-23 23:23:26 +02:00
|
|
|
}
|
|
|
|
|
2014-10-29 13:05:02 -04:00
|
|
|
void OpenGLSalGraphicsImpl::DrawPolyPolygon( const basegfx::B2DPolyPolygon& pPolyPolygon )
|
2014-10-23 23:23:26 +02:00
|
|
|
{
|
2014-10-29 13:05:02 -04:00
|
|
|
sal_uInt32 i, j;
|
|
|
|
::std::vector< GLushort > pVertices;
|
|
|
|
|
|
|
|
for( i = 0; i < pPolyPolygon.count(); i++ )
|
|
|
|
{
|
|
|
|
const basegfx::B2DPolygon& pPolygon( pPolyPolygon.getB2DPolygon( i ) );
|
|
|
|
const ::basegfx::B2DPolygon& aResult(
|
|
|
|
::basegfx::triangulator::triangulate( pPolygon ) );
|
|
|
|
|
2014-11-03 11:10:14 -05:00
|
|
|
for( j = 0; j < aResult.count(); j++ )
|
2014-10-29 13:05:02 -04:00
|
|
|
{
|
2014-11-03 11:10:14 -05:00
|
|
|
const ::basegfx::B2DPoint& rPt( aResult.getB2DPoint( j ) );
|
2014-10-29 13:05:02 -04:00
|
|
|
pVertices.push_back( rPt.getX() );
|
|
|
|
pVertices.push_back( rPt.getY() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
glEnableVertexAttribArray( GL_ATTRIB_POS );
|
2014-11-03 11:10:14 -05:00
|
|
|
glVertexAttribPointer( GL_ATTRIB_POS, 2, GL_UNSIGNED_SHORT, GL_FALSE, 0, pVertices.data() );
|
2014-10-29 13:05:02 -04:00
|
|
|
glDrawArrays( GL_TRIANGLES, 0, pVertices.size() / 2 );
|
|
|
|
glDisableVertexAttribArray( GL_ATTRIB_POS );
|
2014-10-23 23:23:26 +02:00
|
|
|
}
|
|
|
|
|
2014-11-03 22:51:15 -05:00
|
|
|
void OpenGLSalGraphicsImpl::DrawTextureRect( const Size& rSize, const SalTwoRect& rPosAry )
|
2014-10-23 23:23:26 +02:00
|
|
|
{
|
2014-11-03 22:51:15 -05:00
|
|
|
GLfloat aTexCoord[8];
|
|
|
|
|
|
|
|
aTexCoord[0] = aTexCoord[2] = rPosAry.mnSrcX / (double) rSize.Width();
|
|
|
|
aTexCoord[4] = aTexCoord[6] = (rPosAry.mnSrcX + rPosAry.mnSrcWidth) / (double) rSize.Width();
|
2014-11-05 16:36:22 -05:00
|
|
|
aTexCoord[3] = aTexCoord[5] = (rSize.Height() - rPosAry.mnSrcY) / (double) rSize.Height();
|
|
|
|
aTexCoord[1] = aTexCoord[7] = (rSize.Height() - rPosAry.mnSrcY - rPosAry.mnSrcHeight) / (double) rSize.Height();
|
2014-10-29 13:05:02 -04:00
|
|
|
|
|
|
|
glEnableVertexAttribArray( GL_ATTRIB_TEX );
|
2014-11-03 22:51:15 -05:00
|
|
|
glVertexAttribPointer( GL_ATTRIB_TEX, 2, GL_FLOAT, GL_FALSE, 0, aTexCoord );
|
2014-10-29 13:05:02 -04:00
|
|
|
|
2014-11-03 22:51:15 -05:00
|
|
|
DrawRect( rPosAry.mnDestX, rPosAry.mnDestY, rPosAry.mnDestWidth, rPosAry.mnDestHeight );
|
2014-10-29 13:05:02 -04:00
|
|
|
|
|
|
|
glDisableVertexAttribArray( GL_ATTRIB_TEX );
|
2014-10-23 23:23:26 +02:00
|
|
|
}
|
|
|
|
|
2014-11-03 22:51:15 -05:00
|
|
|
void OpenGLSalGraphicsImpl::DrawTexture( GLuint nTexture, const Size& rSize, const SalTwoRect& pPosAry )
|
2014-10-23 23:23:26 +02:00
|
|
|
{
|
2014-10-29 13:05:02 -04:00
|
|
|
if( mnTextureProgram == 0 )
|
|
|
|
{
|
|
|
|
if( !CreateTextureProgram() )
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
glUseProgram( mnTextureProgram );
|
|
|
|
glUniform1i( mnSamplerUniform, 0 );
|
|
|
|
glActiveTexture( GL_TEXTURE0 );
|
2014-11-06 14:22:15 -05:00
|
|
|
CHECK_GL_ERROR();
|
2014-10-29 13:05:02 -04:00
|
|
|
glBindTexture( GL_TEXTURE_2D, nTexture );
|
|
|
|
|
2014-11-03 22:51:15 -05:00
|
|
|
DrawTextureRect( rSize, pPosAry );
|
2014-11-06 14:22:15 -05:00
|
|
|
CHECK_GL_ERROR();
|
2014-10-29 13:05:02 -04:00
|
|
|
|
|
|
|
glBindTexture( GL_TEXTURE_2D, 0 );
|
|
|
|
glUseProgram( 0 );
|
|
|
|
}
|
|
|
|
|
2014-11-04 05:01:07 +01:00
|
|
|
void OpenGLSalGraphicsImpl::DrawTextureWithMask( GLuint nTexture, GLuint nMask, const SalTwoRect& /*pPosAry*/ )
|
2014-10-29 13:05:02 -04:00
|
|
|
{
|
|
|
|
if( mnMaskedTextureProgram == 0 )
|
|
|
|
{
|
|
|
|
if( !CreateMaskedTextureProgram() )
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
glUseProgram( mnMaskedTextureProgram );
|
|
|
|
glUniform1i( mnMaskedSamplerUniform, 0 );
|
|
|
|
glUniform1i( mnMaskSamplerUniform, 1 );
|
|
|
|
glActiveTexture( GL_TEXTURE0 );
|
|
|
|
glBindTexture( GL_TEXTURE_2D, nTexture );
|
|
|
|
glActiveTexture( GL_TEXTURE1 );
|
|
|
|
glBindTexture( GL_TEXTURE_2D, nMask );
|
|
|
|
|
2014-11-03 22:51:15 -05:00
|
|
|
//DrawTextureRect( pPosAry );
|
2014-10-29 13:05:02 -04:00
|
|
|
|
|
|
|
glActiveTexture( GL_TEXTURE1 );
|
|
|
|
glBindTexture( GL_TEXTURE_2D, 0 );
|
|
|
|
glActiveTexture( GL_TEXTURE0 );
|
|
|
|
glBindTexture( GL_TEXTURE_2D, 0 );
|
|
|
|
glUseProgram( 0 );
|
2014-10-23 23:23:26 +02:00
|
|
|
}
|
|
|
|
|
2014-11-04 05:01:07 +01:00
|
|
|
void OpenGLSalGraphicsImpl::DrawMask( GLuint nMask, SalColor nMaskColor, const SalTwoRect& /*pPosAry*/ )
|
2014-10-23 23:23:26 +02:00
|
|
|
{
|
2014-10-29 13:05:02 -04:00
|
|
|
if( mnMaskProgram == 0 )
|
|
|
|
{
|
|
|
|
if( !CreateMaskProgram() )
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
glUseProgram( mnMaskProgram );
|
|
|
|
glUniformColor( mnMaskColorUniform, nMaskColor, 0 );
|
|
|
|
glUniform1i( mnMaskUniform, 0 );
|
|
|
|
glActiveTexture( GL_TEXTURE0 );
|
|
|
|
glBindTexture( GL_TEXTURE_2D, nMask );
|
|
|
|
|
2014-11-03 22:51:15 -05:00
|
|
|
//DrawTextureRect( pPosAry );
|
2014-10-29 13:05:02 -04:00
|
|
|
|
|
|
|
glActiveTexture( GL_TEXTURE0 );
|
|
|
|
glBindTexture( GL_TEXTURE_2D, 0 );
|
|
|
|
glUseProgram( 0 );
|
2014-10-23 23:23:26 +02:00
|
|
|
}
|
2014-10-29 13:05:02 -04:00
|
|
|
|
|
|
|
|
|
|
|
// draw --> LineColor and FillColor and RasterOp and ClipRegion
|
|
|
|
void OpenGLSalGraphicsImpl::drawPixel( long nX, long nY )
|
|
|
|
{
|
2014-11-06 14:22:15 -05:00
|
|
|
SAL_INFO( "vcl.opengl", "::drawPixel" );
|
2014-10-29 13:05:02 -04:00
|
|
|
if( mnLineColor != SALCOLOR_NONE )
|
|
|
|
{
|
2014-10-30 21:57:22 -04:00
|
|
|
maContext.makeCurrent();
|
2014-10-29 13:05:02 -04:00
|
|
|
BeginSolid( mnLineColor );
|
|
|
|
DrawPoint( nX, nY );
|
|
|
|
EndSolid();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void OpenGLSalGraphicsImpl::drawPixel( long nX, long nY, SalColor nSalColor )
|
|
|
|
{
|
2014-11-06 14:22:15 -05:00
|
|
|
SAL_INFO( "vcl.opengl", "::drawPixel" );
|
2014-10-29 13:05:02 -04:00
|
|
|
if( nSalColor != SALCOLOR_NONE )
|
|
|
|
{
|
2014-10-30 21:57:22 -04:00
|
|
|
maContext.makeCurrent();
|
2014-10-29 13:05:02 -04:00
|
|
|
BeginSolid( nSalColor );
|
|
|
|
DrawPoint( nX, nY );
|
|
|
|
EndSolid();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void OpenGLSalGraphicsImpl::drawLine( long nX1, long nY1, long nX2, long nY2 )
|
|
|
|
{
|
2014-11-06 14:22:15 -05:00
|
|
|
SAL_INFO( "vcl.opengl", "::drawLine" );
|
2014-10-29 13:05:02 -04:00
|
|
|
if( mnLineColor != SALCOLOR_NONE )
|
|
|
|
{
|
2014-10-30 21:57:22 -04:00
|
|
|
maContext.makeCurrent();
|
2014-10-29 13:05:02 -04:00
|
|
|
BeginSolid( mnLineColor );
|
|
|
|
DrawLine( nX1, nY1, nX2, nY2 );
|
|
|
|
EndSolid();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void OpenGLSalGraphicsImpl::drawRect( long nX, long nY, long nWidth, long nHeight )
|
|
|
|
{
|
2014-11-06 14:22:15 -05:00
|
|
|
SAL_INFO( "vcl.opengl", "::drawRect" );
|
2014-10-30 21:57:22 -04:00
|
|
|
maContext.makeCurrent();
|
2014-11-06 14:17:24 -05:00
|
|
|
glViewport( 0, 0, GetWidth(), GetHeight() );
|
2014-10-30 21:57:22 -04:00
|
|
|
|
2014-10-29 13:05:02 -04:00
|
|
|
if( mnFillColor != SALCOLOR_NONE )
|
|
|
|
{
|
|
|
|
BeginSolid( mnFillColor );
|
|
|
|
DrawRect( nX, nY, nWidth, nHeight );
|
|
|
|
EndSolid();
|
|
|
|
}
|
|
|
|
|
|
|
|
if( mnLineColor != SALCOLOR_NONE )
|
|
|
|
{
|
|
|
|
const long nX1( nX );
|
|
|
|
const long nY1( nY );
|
|
|
|
const long nX2( nX + nWidth - 1 );
|
|
|
|
const long nY2( nY + nHeight - 1 );
|
|
|
|
const SalPoint aPoints[] = { { nX1, nY1 }, { nX2, nY1 },
|
|
|
|
{ nX2, nY2 }, { nX1, nY2 } };
|
|
|
|
|
|
|
|
BeginSolid( mnLineColor );
|
|
|
|
DrawLines( 4, aPoints, true );
|
|
|
|
EndSolid();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void OpenGLSalGraphicsImpl::drawPolyLine( sal_uInt32 nPoints, const SalPoint* pPtAry )
|
|
|
|
{
|
2014-11-06 14:22:15 -05:00
|
|
|
SAL_INFO( "vcl.opengl", "::drawPolyLine" );
|
2014-10-30 21:57:22 -04:00
|
|
|
maContext.makeCurrent();
|
|
|
|
|
2014-10-29 13:05:02 -04:00
|
|
|
if( mnLineColor != SALCOLOR_NONE && nPoints > 1 )
|
|
|
|
{
|
|
|
|
BeginSolid( mnLineColor );
|
|
|
|
DrawLines( nPoints, pPtAry, false );
|
|
|
|
EndSolid();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void OpenGLSalGraphicsImpl::drawPolygon( sal_uInt32 nPoints, const SalPoint* pPtAry )
|
|
|
|
{
|
2014-11-06 14:22:15 -05:00
|
|
|
SAL_INFO( "vcl.opengl", "::drawPolygon" );
|
2014-10-29 13:05:02 -04:00
|
|
|
if( nPoints == 0 )
|
|
|
|
return;
|
|
|
|
if( nPoints == 1 )
|
|
|
|
{
|
|
|
|
drawPixel( pPtAry[0].mnX, pPtAry[0].mnY );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if( nPoints == 2 )
|
|
|
|
{
|
|
|
|
drawLine( pPtAry[0].mnX, pPtAry[0].mnY,
|
|
|
|
pPtAry[1].mnX, pPtAry[1].mnY );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-10-30 21:57:22 -04:00
|
|
|
maContext.makeCurrent();
|
|
|
|
|
2014-10-29 13:05:02 -04:00
|
|
|
if( mnFillColor != SALCOLOR_NONE )
|
|
|
|
{
|
|
|
|
BeginSolid( mnFillColor );
|
|
|
|
DrawPolygon( nPoints, pPtAry );
|
|
|
|
EndSolid();
|
|
|
|
}
|
|
|
|
|
|
|
|
if( mnLineColor != SALCOLOR_NONE )
|
|
|
|
{
|
|
|
|
BeginSolid( mnLineColor );
|
|
|
|
DrawLines( nPoints, pPtAry, true );
|
|
|
|
EndSolid();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void OpenGLSalGraphicsImpl::drawPolyPolygon( sal_uInt32 nPoly, const sal_uInt32* pPoints, PCONSTSALPOINT* pPtAry )
|
|
|
|
{
|
2014-11-06 14:22:15 -05:00
|
|
|
SAL_INFO( "vcl.opengl", "::drawPolyPolygon" );
|
2014-10-29 13:05:02 -04:00
|
|
|
if( nPoly <= 0 )
|
|
|
|
return;
|
|
|
|
|
2014-10-30 21:57:22 -04:00
|
|
|
maContext.makeCurrent();
|
|
|
|
|
2014-10-29 13:05:02 -04:00
|
|
|
if( mnFillColor != SALCOLOR_NONE )
|
|
|
|
{
|
|
|
|
BeginSolid( mnFillColor );
|
|
|
|
for( sal_uInt32 i = 0; i < nPoly; i++ )
|
|
|
|
DrawPolygon( pPoints[i], pPtAry[i] );
|
|
|
|
EndSolid();
|
|
|
|
}
|
|
|
|
|
|
|
|
if( mnLineColor != SALCOLOR_NONE )
|
|
|
|
{
|
|
|
|
// TODO Use glMultiDrawElements or primitive restart
|
|
|
|
BeginSolid( mnLineColor );
|
|
|
|
for( sal_uInt32 i = 0; i < nPoly; i++ )
|
|
|
|
DrawLines( pPoints[i], pPtAry[i], true );
|
|
|
|
EndSolid();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-08 22:55:06 -05:00
|
|
|
bool OpenGLSalGraphicsImpl::drawPolyPolygon( const ::basegfx::B2DPolyPolygon& rPolyPolygon, double fTransparency )
|
2014-10-23 23:23:26 +02:00
|
|
|
{
|
2014-11-08 22:55:06 -05:00
|
|
|
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;
|
2014-10-23 23:23:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool OpenGLSalGraphicsImpl::drawPolyLine(
|
|
|
|
const ::basegfx::B2DPolygon&,
|
|
|
|
double /*fTransparency*/,
|
|
|
|
const ::basegfx::B2DVector& /*rLineWidths*/,
|
|
|
|
basegfx::B2DLineJoin,
|
|
|
|
com::sun::star::drawing::LineCap)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool OpenGLSalGraphicsImpl::drawPolyLineBezier(
|
|
|
|
sal_uInt32 /*nPoints*/,
|
|
|
|
const SalPoint* /*pPtAry*/,
|
|
|
|
const sal_uInt8* /*pFlgAry*/ )
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool OpenGLSalGraphicsImpl::drawPolygonBezier(
|
|
|
|
sal_uInt32 /*nPoints*/,
|
|
|
|
const SalPoint* /*pPtAry*/,
|
|
|
|
const sal_uInt8* /*pFlgAry*/ )
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool OpenGLSalGraphicsImpl::drawPolyPolygonBezier(
|
|
|
|
sal_uInt32 /*nPoly*/,
|
|
|
|
const sal_uInt32* /*pPoints*/,
|
|
|
|
const SalPoint* const* /*pPtAry*/,
|
|
|
|
const sal_uInt8* const* /*pFlgAry*/ )
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// CopyArea --> No RasterOp, but ClipRegion
|
|
|
|
void OpenGLSalGraphicsImpl::copyArea(
|
|
|
|
long /*nDestX*/, long /*nDestY*/,
|
|
|
|
long /*nSrcX*/, long /*nSrcY*/,
|
|
|
|
long /*nSrcWidth*/, long /*nSrcHeight*/,
|
|
|
|
sal_uInt16 /*nFlags*/ )
|
|
|
|
{
|
2014-11-06 14:22:15 -05:00
|
|
|
SAL_INFO( "vcl.opengl", "::copyArea" );
|
2014-10-23 23:23:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// CopyBits and DrawBitmap --> RasterOp and ClipRegion
|
|
|
|
// CopyBits() --> pSrcGraphics == NULL, then CopyBits on same Graphics
|
2014-10-30 21:51:39 -04:00
|
|
|
void OpenGLSalGraphicsImpl::copyBits( const SalTwoRect& rPosAry, SalGraphics* /*pSrcGraphics*/ )
|
2014-10-23 23:23:26 +02:00
|
|
|
{
|
2014-10-29 13:05:02 -04:00
|
|
|
// TODO Check if SalGraphicsImpl is the same
|
|
|
|
const bool bSameGraphics( false );
|
|
|
|
|
2014-11-06 14:22:15 -05:00
|
|
|
SAL_INFO( "vcl.opengl", "::copyBits" );
|
2014-10-29 13:05:02 -04:00
|
|
|
if( bSameGraphics &&
|
|
|
|
(rPosAry.mnSrcWidth == rPosAry.mnDestWidth) &&
|
|
|
|
(rPosAry.mnSrcHeight == rPosAry.mnDestHeight))
|
|
|
|
{
|
|
|
|
// short circuit if there is nothing to do
|
|
|
|
if( (rPosAry.mnSrcX == rPosAry.mnDestX) &&
|
|
|
|
(rPosAry.mnSrcY == rPosAry.mnDestY))
|
|
|
|
return;
|
|
|
|
// use copyArea() if source and destination context are identical
|
|
|
|
copyArea( rPosAry.mnDestX, rPosAry.mnDestY, rPosAry.mnSrcX, rPosAry.mnSrcY,
|
|
|
|
rPosAry.mnSrcWidth, rPosAry.mnSrcHeight, 0 );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO Copy from one FBO to the other (glBlitFramebuffer)
|
2014-10-23 23:23:26 +02:00
|
|
|
}
|
|
|
|
|
2014-10-29 13:05:02 -04:00
|
|
|
void OpenGLSalGraphicsImpl::drawBitmap( const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap )
|
2014-10-23 23:23:26 +02:00
|
|
|
{
|
2014-10-29 13:05:02 -04:00
|
|
|
const OpenGLSalBitmap& rBitmap = static_cast<const OpenGLSalBitmap&>(rSalBitmap);
|
2014-10-30 22:00:37 -04:00
|
|
|
GLuint nTexture = rBitmap.GetTexture( maContext );
|
2014-11-03 22:51:15 -05:00
|
|
|
const Size aSize = rSalBitmap.GetSize();
|
2014-10-29 13:05:02 -04:00
|
|
|
|
2014-10-30 22:00:37 -04:00
|
|
|
SAL_INFO( "vcl.opengl", "::drawBitmap" );
|
2014-10-30 21:57:22 -04:00
|
|
|
maContext.makeCurrent();
|
2014-11-06 14:17:24 -05:00
|
|
|
glViewport( 0, 0, GetWidth(), GetHeight() );
|
2014-11-03 22:51:15 -05:00
|
|
|
DrawTexture( nTexture, aSize, rPosAry );
|
2014-10-23 23:23:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void OpenGLSalGraphicsImpl::drawBitmap(
|
|
|
|
const SalTwoRect& /*rPosAry*/,
|
|
|
|
const SalBitmap& /*rSalBitmap*/,
|
|
|
|
SalColor /*nTransparentColor*/ )
|
|
|
|
{
|
2014-10-29 13:05:02 -04:00
|
|
|
OSL_FAIL( "::DrawBitmap with transparent color not supported" );
|
2014-10-23 23:23:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void OpenGLSalGraphicsImpl::drawBitmap(
|
2014-10-29 13:05:02 -04:00
|
|
|
const SalTwoRect& rPosAry,
|
|
|
|
const SalBitmap& rSalBitmap,
|
|
|
|
const SalBitmap& rMaskBitmap )
|
2014-10-23 23:23:26 +02:00
|
|
|
{
|
2014-10-29 13:05:02 -04:00
|
|
|
const OpenGLSalBitmap& rBitmap = static_cast<const OpenGLSalBitmap&>(rSalBitmap);
|
|
|
|
const OpenGLSalBitmap& rMask = static_cast<const OpenGLSalBitmap&>(rMaskBitmap);
|
2014-10-30 22:00:37 -04:00
|
|
|
const GLuint nTexture( rBitmap.GetTexture( maContext ) );
|
|
|
|
const GLuint nMask( rMask.GetTexture( maContext ) );
|
2014-10-29 13:05:02 -04:00
|
|
|
|
2014-10-30 22:00:37 -04:00
|
|
|
SAL_INFO( "vcl.opengl", "::drawBitmap" );
|
2014-10-30 21:57:22 -04:00
|
|
|
maContext.makeCurrent();
|
2014-10-29 13:05:02 -04:00
|
|
|
DrawTextureWithMask( nTexture, nMask, rPosAry );
|
2014-10-23 23:23:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void OpenGLSalGraphicsImpl::drawMask(
|
2014-10-29 13:05:02 -04:00
|
|
|
const SalTwoRect& rPosAry,
|
|
|
|
const SalBitmap& rSalBitmap,
|
|
|
|
SalColor nMaskColor )
|
2014-10-23 23:23:26 +02:00
|
|
|
{
|
2014-10-29 13:05:02 -04:00
|
|
|
const OpenGLSalBitmap& rBitmap = static_cast<const OpenGLSalBitmap&>(rSalBitmap);
|
2014-10-30 22:00:37 -04:00
|
|
|
const GLuint nTexture( rBitmap.GetTexture( maContext ) );
|
2014-10-29 13:05:02 -04:00
|
|
|
|
2014-11-06 14:22:15 -05:00
|
|
|
SAL_INFO( "vcl.opengl", "::drawMask" );
|
2014-10-30 22:00:37 -04:00
|
|
|
maContext.makeCurrent();
|
2014-10-29 13:05:02 -04:00
|
|
|
DrawMask( nTexture, nMaskColor, rPosAry );
|
2014-10-23 23:23:26 +02:00
|
|
|
}
|
|
|
|
|
2014-10-29 13:05:02 -04:00
|
|
|
SalBitmap* OpenGLSalGraphicsImpl::getBitmap( long nX, long nY, long nWidth, long nHeight )
|
2014-10-23 23:23:26 +02:00
|
|
|
{
|
2014-10-29 13:05:02 -04:00
|
|
|
OpenGLSalBitmap* pBitmap = new OpenGLSalBitmap;
|
2014-11-07 12:33:15 +00:00
|
|
|
SAL_INFO( "vcl.opengl", "::getBitmap " << nX << "," << nY <<
|
|
|
|
" " << nWidth << "x" << nHeight );
|
2014-10-30 22:00:37 -04:00
|
|
|
if( !pBitmap->Create( maContext, nX, nY, nWidth, nHeight ) )
|
2014-10-29 13:05:02 -04:00
|
|
|
{
|
|
|
|
delete pBitmap;
|
|
|
|
pBitmap = NULL;
|
|
|
|
}
|
|
|
|
return pBitmap;
|
2014-10-23 23:23:26 +02:00
|
|
|
}
|
|
|
|
|
2014-10-29 13:05:02 -04:00
|
|
|
SalColor OpenGLSalGraphicsImpl::getPixel( long nX, long nY )
|
2014-10-23 23:23:26 +02:00
|
|
|
{
|
2014-10-29 13:05:02 -04:00
|
|
|
char pixel[3];
|
|
|
|
|
2014-10-30 21:57:22 -04:00
|
|
|
maContext.makeCurrent();
|
2014-10-29 13:05:02 -04:00
|
|
|
glReadPixels( nX, nY, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, pixel);
|
|
|
|
return MAKE_SALCOLOR( pixel[0], pixel[1], pixel[2] );
|
2014-10-23 23:23:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// invert --> ClipRegion (only Windows or VirDevs)
|
|
|
|
void OpenGLSalGraphicsImpl::invert(
|
2014-10-29 13:05:02 -04:00
|
|
|
long nX, long nY,
|
|
|
|
long nWidth, long nHeight,
|
|
|
|
SalInvert nFlags)
|
2014-10-23 23:23:26 +02:00
|
|
|
{
|
2014-10-29 13:05:02 -04:00
|
|
|
// TODO Figure out what are those:
|
|
|
|
// * SAL_INVERT_50 (50/50 pattern?)
|
|
|
|
// * SAL_INVERT_TRACKFRAME (dash-line rectangle?)
|
|
|
|
|
2014-10-30 21:57:22 -04:00
|
|
|
maContext.makeCurrent();
|
|
|
|
|
2014-10-29 13:05:02 -04:00
|
|
|
if( nFlags & SAL_INVERT_TRACKFRAME )
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
else if( nFlags & SAL_INVERT_50 )
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
else // just invert
|
|
|
|
{
|
|
|
|
BeginInvert();
|
2014-10-30 21:51:39 -04:00
|
|
|
DrawRect( nX, nY, nWidth, nHeight );
|
2014-10-29 13:05:02 -04:00
|
|
|
EndInvert();
|
|
|
|
}
|
2014-10-23 23:23:26 +02:00
|
|
|
}
|
|
|
|
|
2014-10-29 13:05:02 -04:00
|
|
|
void OpenGLSalGraphicsImpl::invert( sal_uInt32 nPoints, const SalPoint* pPtAry, SalInvert nFlags )
|
2014-10-23 23:23:26 +02:00
|
|
|
{
|
2014-10-30 21:57:22 -04:00
|
|
|
maContext.makeCurrent();
|
|
|
|
|
2014-10-29 13:05:02 -04:00
|
|
|
if( nFlags & SAL_INVERT_TRACKFRAME )
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
else if( nFlags & SAL_INVERT_50 )
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
else // just invert
|
|
|
|
{
|
|
|
|
BeginInvert();
|
|
|
|
DrawPolygon( nPoints, pPtAry );
|
|
|
|
EndInvert();
|
|
|
|
}
|
2014-10-23 23:23:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool OpenGLSalGraphicsImpl::drawEPS(
|
|
|
|
long /*nX*/, long /*nY*/,
|
|
|
|
long /*nWidth*/, long /*nHeight*/,
|
|
|
|
void* /*pPtr*/,
|
|
|
|
sal_uLong /*nSize*/ )
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Render bitmap with alpha channel
|
|
|
|
|
|
|
|
@param rSourceBitmap
|
|
|
|
Source bitmap to blit
|
|
|
|
|
|
|
|
@param rAlphaBitmap
|
|
|
|
Alpha channel to use for blitting
|
|
|
|
|
|
|
|
@return true, if the operation succeeded, and false
|
|
|
|
otherwise. In this case, clients should try to emulate alpha
|
|
|
|
compositing themselves
|
|
|
|
*/
|
|
|
|
bool OpenGLSalGraphicsImpl::drawAlphaBitmap(
|
2014-10-29 13:05:02 -04:00
|
|
|
const SalTwoRect& rPosAry,
|
|
|
|
const SalBitmap& rSalBitmap,
|
|
|
|
const SalBitmap& rAlphaBitmap )
|
2014-10-23 23:23:26 +02:00
|
|
|
{
|
2014-10-29 13:05:02 -04:00
|
|
|
const OpenGLSalBitmap& rBitmap = static_cast<const OpenGLSalBitmap&>(rSalBitmap);
|
|
|
|
const OpenGLSalBitmap& rAlpha = static_cast<const OpenGLSalBitmap&>(rAlphaBitmap);
|
2014-10-30 22:00:37 -04:00
|
|
|
const GLuint nTexture( rBitmap.GetTexture( maContext ) );
|
|
|
|
const GLuint nAlpha( rAlpha.GetTexture( maContext ) );
|
2014-10-29 13:05:02 -04:00
|
|
|
|
2014-10-30 21:57:22 -04:00
|
|
|
maContext.makeCurrent();
|
2014-10-29 13:05:02 -04:00
|
|
|
DrawTextureWithMask( nTexture, nAlpha, rPosAry );
|
|
|
|
return true;
|
2014-10-23 23:23:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/** draw transformed bitmap (maybe with alpha) where Null, X, Y define the coordinate system */
|
|
|
|
bool OpenGLSalGraphicsImpl::drawTransformedBitmap(
|
|
|
|
const basegfx::B2DPoint& /*rNull*/,
|
|
|
|
const basegfx::B2DPoint& /*rX*/,
|
|
|
|
const basegfx::B2DPoint& /*rY*/,
|
|
|
|
const SalBitmap& /*rSourceBitmap*/,
|
|
|
|
const SalBitmap* /*pAlphaBitmap*/)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Render solid rectangle with given transparency
|
|
|
|
|
|
|
|
@param nTransparency
|
|
|
|
Transparency value (0-255) to use. 0 blits and opaque, 255 a
|
|
|
|
fully transparent rectangle
|
|
|
|
*/
|
|
|
|
bool OpenGLSalGraphicsImpl::drawAlphaRect(
|
2014-10-29 13:05:02 -04:00
|
|
|
long nX, long nY,
|
|
|
|
long nWidth, long nHeight,
|
|
|
|
sal_uInt8 nTransparency )
|
|
|
|
{
|
2014-11-08 22:55:06 -05:00
|
|
|
SAL_INFO( "vcl.opengl", "::drawAlphaRect" );
|
2014-10-29 13:05:02 -04:00
|
|
|
if( mnFillColor != SALCOLOR_NONE && nTransparency < 100 )
|
|
|
|
{
|
|
|
|
BeginSolid( mnFillColor, nTransparency );
|
|
|
|
DrawRect( nX, nY, nWidth, nHeight );
|
|
|
|
EndSolid();
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
2014-10-23 23:23:26 +02:00
|
|
|
}
|
|
|
|
|
2014-10-29 17:25:55 +01:00
|
|
|
bool OpenGLSalGraphicsImpl::drawGradient(const tools::PolyPolygon& /*rPolygon*/,
|
|
|
|
const Gradient& /*rGradient*/)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-11-04 17:29:49 -05:00
|
|
|
bool OpenGLSalGraphicsImpl::swapBuffers()
|
|
|
|
{
|
|
|
|
maContext.swapBuffers();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-10-23 23:23:26 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|