LCOV - code coverage report
Current view: top level - canvas/source/opengl - ogl_canvastools.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 0 58 0.0 %
Date: 2014-04-11 Functions: 0 4 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  */
       9             : 
      10             : #define GL_GLEXT_PROTOTYPES
      11             : 
      12             : #include "ogl_canvastools.hxx"
      13             : 
      14             : #include <canvas/debug.hxx>
      15             : #include <tools/diagnose_ex.h>
      16             : #include <basegfx/tools/canvastools.hxx>
      17             : #include <basegfx/matrix/b2dhommatrix.hxx>
      18             : #include <basegfx/tools/tools.hxx>
      19             : #include <basegfx/polygon/b2dpolypolygon.hxx>
      20             : #include <basegfx/polygon/b2dpolygontriangulator.hxx>
      21             : #include <basegfx/polygon/b2dpolypolygontools.hxx>
      22             : 
      23             : #include <com/sun/star/rendering/ARGBColor.hpp>
      24             : 
      25             : #include <GL/gl.h>
      26             : #include <GL/glu.h>
      27             : #include <GL/glext.h>
      28             : 
      29             : 
      30             : using namespace ::com::sun::star;
      31             : 
      32             : namespace oglcanvas
      33             : {
      34             :     /// triangulates polygon before
      35           0 :     void renderComplexPolyPolygon( const ::basegfx::B2DPolyPolygon& rPolyPoly )
      36             :     {
      37           0 :         ::basegfx::B2DPolyPolygon aPolyPoly(rPolyPoly);
      38           0 :         if( aPolyPoly.areControlPointsUsed() )
      39           0 :             aPolyPoly = rPolyPoly.getDefaultAdaptiveSubdivision();
      40           0 :         const ::basegfx::B2DRange& rBounds(aPolyPoly.getB2DRange());
      41           0 :         const double nWidth=rBounds.getWidth();
      42           0 :         const double nHeight=rBounds.getHeight();
      43             :         const ::basegfx::B2DPolygon& rTriangulatedPolygon(
      44           0 :             ::basegfx::triangulator::triangulate(aPolyPoly));
      45             : 
      46           0 :         for( sal_uInt32 i=0; i<rTriangulatedPolygon.count(); i++ )
      47             :         {
      48           0 :             const ::basegfx::B2DPoint& rPt( rTriangulatedPolygon.getB2DPoint(i) );
      49           0 :             const double s(rPt.getX()/nWidth);
      50           0 :             const double t(rPt.getY()/nHeight);
      51           0 :             glTexCoord2f(s,t); glVertex2d(rPt.getX(), rPt.getY());
      52           0 :         }
      53           0 :     }
      54             : 
      55             :     /** only use this for line polygons.
      56             : 
      57             :         better not leave triangulation to OpenGL. also, ignores texturing
      58             :     */
      59           0 :     void renderPolyPolygon( const ::basegfx::B2DPolyPolygon& rPolyPoly )
      60             :     {
      61           0 :         ::basegfx::B2DPolyPolygon aPolyPoly(rPolyPoly);
      62           0 :         if( aPolyPoly.areControlPointsUsed() )
      63           0 :             aPolyPoly = rPolyPoly.getDefaultAdaptiveSubdivision();
      64             : 
      65           0 :         for( sal_uInt32 i=0; i<aPolyPoly.count(); i++ )
      66             :         {
      67           0 :             glBegin(GL_LINE_STRIP);
      68             : 
      69           0 :             const ::basegfx::B2DPolygon& rPolygon( aPolyPoly.getB2DPolygon(i) );
      70             : 
      71           0 :             const sal_uInt32 nPts=rPolygon.count();
      72           0 :             const sal_uInt32 nExtPts=nPts + int(rPolygon.isClosed());
      73           0 :             for( sal_uInt32 j=0; j<nExtPts; j++ )
      74             :             {
      75           0 :                 const ::basegfx::B2DPoint& rPt( rPolygon.getB2DPoint( j % nPts ) );
      76           0 :                 glVertex2d(rPt.getX(), rPt.getY());
      77           0 :             }
      78             : 
      79           0 :             glEnd();
      80           0 :         }
      81           0 :     }
      82             : 
      83           0 :     void setupState( const ::basegfx::B2DHomMatrix&   rTransform,
      84             :                      GLenum                           eSrcBlend,
      85             :                      GLenum                           eDstBlend,
      86             :                      const rendering::ARGBColor&      rColor )
      87             :     {
      88             :         double aGLTransform[] =
      89             :             {
      90           0 :                 rTransform.get(0,0), rTransform.get(1,0), 0, 0,
      91           0 :                 rTransform.get(0,1), rTransform.get(1,1), 0, 0,
      92             :                 0,                   0,                   1, 0,
      93           0 :                 rTransform.get(0,2), rTransform.get(1,2), 0, 1
      94           0 :             };
      95           0 :         glMultMatrixd(aGLTransform);
      96             : 
      97           0 :         glEnable(GL_BLEND);
      98           0 :         glBlendFunc(eSrcBlend, eDstBlend);
      99             : 
     100             :         glColor4d(rColor.Red,
     101             :                   rColor.Green,
     102             :                   rColor.Blue,
     103           0 :                   rColor.Alpha);
     104             : 
     105             :         // GL 1.2:
     106             :         // glBlendEquation( GLenum mode );
     107             :         // glBlendColor( GLclampf red, GLclampf green,GLclampf blue, GLclampf alpha );
     108             :         // glConvolutionFilter1D
     109             :         // glConvolutionFilter2D
     110             :         // glSeparableFilter2D
     111           0 :     }
     112             : 
     113           0 :     void renderOSD( const std::vector<double>& rNumbers, double scale )
     114             :     {
     115           0 :         double y=4.0;
     116           0 :         basegfx::B2DHomMatrix aTmp;
     117           0 :         basegfx::B2DHomMatrix aScaleShear;
     118           0 :         aScaleShear.shearX(-0.1);
     119           0 :         aScaleShear.scale(scale,scale);
     120             : 
     121           0 :         for( size_t i=0; i<rNumbers.size(); ++i )
     122             :         {
     123           0 :             aTmp.identity();
     124           0 :             aTmp.translate(0,y);
     125           0 :             y += 1.2*scale;
     126             : 
     127             :             basegfx::B2DPolyPolygon aPoly=
     128           0 :                 basegfx::tools::number2PolyPolygon(rNumbers[i],10,3);
     129             : 
     130           0 :             aTmp=aTmp*aScaleShear;
     131           0 :             aPoly.transform(aTmp);
     132             : 
     133           0 :             glColor4f(0,1,0,1);
     134           0 :             renderPolyPolygon(aPoly);
     135           0 :         }
     136           0 :     }
     137             : }
     138             : 
     139             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10