ooo-build r14411 - in trunk: . patches/test



Author: thorstenb
Date: Mon Oct 27 08:54:21 2008
New Revision: 14411
URL: http://svn.gnome.org/viewvc/ooo-build?rev=14411&view=rev

Log:
    * patches/test/opengl-canvas.diff: added initial support for
    gradient shaders



Modified:
   trunk/ChangeLog
   trunk/patches/test/opengl-canvas.diff

Modified: trunk/patches/test/opengl-canvas.diff
==============================================================================
--- trunk/patches/test/opengl-canvas.diff	(original)
+++ trunk/patches/test/opengl-canvas.diff	Mon Oct 27 08:54:21 2008
@@ -13,20 +13,20 @@
  canvas/source/opengl/exports.dxp                   |    3 
  canvas/source/opengl/exports.map                   |    8 
  canvas/source/opengl/makefile.mk                   |   65 ++
- canvas/source/opengl/ogl_bitmapcanvashelper.cxx    |  107 +++
- canvas/source/opengl/ogl_bitmapcanvashelper.hxx    |  106 +++
- canvas/source/opengl/ogl_canvasbitmap.cxx          |   62 +
- canvas/source/opengl/ogl_canvasbitmap.hxx          |   81 ++
- canvas/source/opengl/ogl_canvascustomsprite.cxx    |  152 ++++
- canvas/source/opengl/ogl_canvascustomsprite.hxx    |  100 ++
+ canvas/source/opengl/ogl_bitmapcanvashelper.cxx    |  108 +++
+ canvas/source/opengl/ogl_bitmapcanvashelper.hxx    |  107 ++
+ canvas/source/opengl/ogl_canvasbitmap.cxx          |   63 +
+ canvas/source/opengl/ogl_canvasbitmap.hxx          |   82 ++
+ canvas/source/opengl/ogl_canvascustomsprite.cxx    |  154 ++++
+ canvas/source/opengl/ogl_canvascustomsprite.hxx    |  101 ++
  canvas/source/opengl/ogl_canvasfont.cxx            |   88 ++
  canvas/source/opengl/ogl_canvasfont.hxx            |   72 ++
- canvas/source/opengl/ogl_canvashelper.cxx          |  829 ++++++++++++++++++++
- canvas/source/opengl/ogl_canvashelper.hxx          |  227 +++++
+ canvas/source/opengl/ogl_canvashelper.cxx          |  860 ++++++++++++++++++++
+ canvas/source/opengl/ogl_canvashelper.hxx          |  237 ++++++
  canvas/source/opengl/ogl_spritecanvas.cxx          |  202 +++++
  canvas/source/opengl/ogl_spritecanvas.hxx          |  126 +++
- canvas/source/opengl/ogl_spritedevicehelper.cxx    |  529 +++++++++++++
- canvas/source/opengl/ogl_spritedevicehelper.hxx    |  119 +++
+ canvas/source/opengl/ogl_spritedevicehelper.cxx    |  658 +++++++++++++++
+ canvas/source/opengl/ogl_spritedevicehelper.hxx    |  134 +++
  canvas/source/opengl/ogl_textlayout.cxx            |  222 +++++
  canvas/source/opengl/ogl_textlayout.hxx            |   83 ++
  canvas/source/opengl/ogl_tools.hxx                 |   35 +
@@ -46,7 +46,7 @@
  sdext/source/presenter/PresenterSlideShowView.cxx  |   48 +
  sdext/source/presenter/PresenterSlideShowView.hxx  |    7 
  slideshow/source/engine/waitsymbol.cxx             |   13 
- 41 files changed, 3334 insertions(+), 50 deletions(-)
+ 41 files changed, 3526 insertions(+), 50 deletions(-)
  create mode 100644 canvas/source/opengl/exports.dxp
  create mode 100644 canvas/source/opengl/exports.map
  create mode 100644 canvas/source/opengl/makefile.mk
@@ -233,10 +233,10 @@
 +.INCLUDE :	target.mk
 diff --git canvas/source/opengl/ogl_bitmapcanvashelper.cxx canvas/source/opengl/ogl_bitmapcanvashelper.cxx
 new file mode 100644
-index 0000000..3033de3
+index 0000000..e3f516e
 --- /dev/null
 +++ canvas/source/opengl/ogl_bitmapcanvashelper.cxx
-@@ -0,0 +1,107 @@
+@@ -0,0 +1,108 @@
 +/*************************************************************************
 + *
 + *    OpenOffice.org - a multi-platform office productivity suite
@@ -275,10 +275,11 @@
 +    }
 +
 +    void BitmapCanvasHelper::init( rendering::XGraphicDevice&     rDevice,
++                                   SpriteDeviceHelper&            rDeviceHelper,
 +                                   const geometry::IntegerSize2D& rSize )
 +    {
 +        maSize = rSize;
-+        CanvasHelper::init(rDevice);
++        CanvasHelper::init(rDevice,rDeviceHelper);
 +    }
 +
 +    void BitmapCanvasHelper::copyRect( const rendering::XCanvas*                            /*pCanvas*/, 
@@ -346,10 +347,10 @@
 +}
 diff --git canvas/source/opengl/ogl_bitmapcanvashelper.hxx canvas/source/opengl/ogl_bitmapcanvashelper.hxx
 new file mode 100644
-index 0000000..35c1f94
+index 0000000..2d2faeb
 --- /dev/null
 +++ canvas/source/opengl/ogl_bitmapcanvashelper.hxx
-@@ -0,0 +1,106 @@
+@@ -0,0 +1,107 @@
 +/*************************************************************************
 + *
 + *    OpenOffice.org - a multi-platform office productivity suite
@@ -407,6 +408,7 @@
 +
 +         */
 +        void init( ::com::sun::star::rendering::XGraphicDevice&     rDevice,
++                   SpriteDeviceHelper&                              rDeviceHelper,
 +                   const ::com::sun::star::geometry::IntegerSize2D& rSize );
 +
 +        // BitmapCanvasHelper functionality
@@ -458,10 +460,10 @@
 +#endif
 diff --git canvas/source/opengl/ogl_canvasbitmap.cxx canvas/source/opengl/ogl_canvasbitmap.cxx
 new file mode 100644
-index 0000000..51b58e5
+index 0000000..9853461
 --- /dev/null
 +++ canvas/source/opengl/ogl_canvasbitmap.cxx
-@@ -0,0 +1,62 @@
+@@ -0,0 +1,63 @@
 +/*************************************************************************
 + *
 + *    OpenOffice.org - a multi-platform office productivity suite
@@ -494,6 +496,7 @@
 +{
 +    CanvasBitmap::CanvasBitmap( const geometry::IntegerSize2D& rSize,
 +                                const SpriteCanvasRef&         rDevice,
++                                SpriteDeviceHelper&            rDeviceHelper,
 +                                bool                           bHasAlpha ) :
 +        mpDevice( rDevice ),
 +        mbHasAlpha( bHasAlpha )
@@ -501,7 +504,7 @@
 +        ENSURE_OR_THROW( mpDevice.is(),
 +                         "CanvasBitmap::CanvasBitmap(): Invalid surface or device" );
 +
-+        maCanvasHelper.init( *mpDevice.get(), rSize );
++        maCanvasHelper.init( *mpDevice.get(), rDeviceHelper, rSize );
 +    }
 +
 +    CanvasBitmap::CanvasBitmap( const CanvasBitmap& rSrc ) :
@@ -526,10 +529,10 @@
 +}
 diff --git canvas/source/opengl/ogl_canvasbitmap.hxx canvas/source/opengl/ogl_canvasbitmap.hxx
 new file mode 100644
-index 0000000..efb92bb
+index 0000000..aa0d242
 --- /dev/null
 +++ canvas/source/opengl/ogl_canvasbitmap.hxx
-@@ -0,0 +1,81 @@
+@@ -0,0 +1,82 @@
 +/*************************************************************************
 + *
 + *    OpenOffice.org - a multi-platform office productivity suite
@@ -588,6 +591,7 @@
 +         */
 +        CanvasBitmap( const ::com::sun::star::geometry::IntegerSize2D& rSize,
 +                      const SpriteCanvasRef&                           rDevice,
++                      SpriteDeviceHelper&                              rDeviceHelper,
 +                      bool                                             bHasAlpha );
 +
 +        /** Create verbatim copy (including all recorded actions)
@@ -613,10 +617,10 @@
 +#endif
 diff --git canvas/source/opengl/ogl_canvascustomsprite.cxx canvas/source/opengl/ogl_canvascustomsprite.cxx
 new file mode 100644
-index 0000000..4606018
+index 0000000..2d88417
 --- /dev/null
 +++ canvas/source/opengl/ogl_canvascustomsprite.cxx
-@@ -0,0 +1,152 @@
+@@ -0,0 +1,154 @@
 +/*************************************************************************
 + *
 + *    OpenOffice.org - a multi-platform office productivity suite
@@ -659,7 +663,8 @@
 +namespace oglcanvas
 +{
 +    CanvasCustomSprite::CanvasCustomSprite( const ::com::sun::star::geometry::RealSize2D& rSpriteSize,
-+                                            const SpriteCanvasRef&                        rRefDevice ) :
++                                            const SpriteCanvasRef&                        rRefDevice,
++                                            SpriteDeviceHelper&                           rDeviceHelper ) :
 +        mpSpriteCanvas( rRefDevice ),
 +        maSize(rSpriteSize),
 +        maTransformation(),
@@ -670,7 +675,8 @@
 +        ENSURE_OR_THROW( rRefDevice.get(),
 +                         "CanvasCustomSprite::CanvasCustomSprite(): Invalid sprite canvas" );
 +
-+        maCanvasHelper.init( *rRefDevice.get() );
++        maCanvasHelper.init( *rRefDevice.get(),
++                             rDeviceHelper );
 +    }
 +    
 +    void SAL_CALL CanvasCustomSprite::disposing()
@@ -771,10 +777,10 @@
 +}
 diff --git canvas/source/opengl/ogl_canvascustomsprite.hxx canvas/source/opengl/ogl_canvascustomsprite.hxx
 new file mode 100644
-index 0000000..7d71803
+index 0000000..7d0b4bf
 --- /dev/null
 +++ canvas/source/opengl/ogl_canvascustomsprite.hxx
-@@ -0,0 +1,100 @@
+@@ -0,0 +1,101 @@
 +/*************************************************************************
 + *
 + *    OpenOffice.org - a multi-platform office productivity suite
@@ -839,7 +845,8 @@
 +            Target DX device
 +         */
 +        CanvasCustomSprite( const ::com::sun::star::geometry::RealSize2D&   rSpriteSize,
-+                            const SpriteCanvasRef&                          rRefDevice );
++                            const SpriteCanvasRef&                          rRefDevice,
++                            SpriteDeviceHelper&                             rDeviceHelper );
 +
 +        virtual void SAL_CALL disposing();
 +
@@ -1049,10 +1056,10 @@
 +#endif
 diff --git canvas/source/opengl/ogl_canvashelper.cxx canvas/source/opengl/ogl_canvashelper.cxx
 new file mode 100644
-index 0000000..2ab8711
+index 0000000..b827c8e
 --- /dev/null
 +++ canvas/source/opengl/ogl_canvashelper.cxx
-@@ -0,0 +1,829 @@
+@@ -0,0 +1,860 @@
 +/*************************************************************************
 + *
 + *    OpenOffice.org - a multi-platform office productivity suite
@@ -1078,6 +1085,7 @@
 +#include <tools/diagnose_ex.h>
 +#include <basegfx/tools/canvastools.hxx>
 +#include <basegfx/polygon/b2dpolypolygon.hxx>
++#include <basegfx/polygon/b2dpolygontriangulator.hxx>
 +
 +#include <com/sun/star/rendering/TexturingMode.hpp>
 +#include <com/sun/star/rendering/CompositeOperation.hpp>
@@ -1151,6 +1159,31 @@
 +
 +    namespace
 +    {
++        /// triangulates polygon before
++        void renderComplexPolyPolygon( const ::basegfx::B2DPolyPolygon& rPolyPoly )
++        {
++            ::basegfx::B2DPolyPolygon aPolyPoly(rPolyPoly);
++            if( aPolyPoly.areControlPointsUsed() )
++                aPolyPoly = rPolyPoly.getDefaultAdaptiveSubdivision();
++            const ::basegfx::B2DRange& rBounds(aPolyPoly.getB2DRange());
++            const double nWidth=rBounds.getWidth();
++            const double nHeight=rBounds.getHeight();
++            const ::basegfx::B2DPolygon& rTriangulatedPolygon(
++                ::basegfx::triangulator::triangulate(aPolyPoly));
++
++            for( sal_uInt32 i=0; i<rTriangulatedPolygon.count(); i++ ) 
++            {
++                const ::basegfx::B2DPoint& rPt( rTriangulatedPolygon.getB2DPoint(i) );
++				const double s(rPt.getX()/nWidth);
++                const double t(rPt.getY()/nHeight);
++                glTexCoord2f(s,t); glVertex2d(rPt.getX(), rPt.getY());
++            }
++        }
++
++        /** only use this for line polygons. 
++
++            better not leave triangulation to OpenGL. also, ignores texturing
++          */
 +        void renderPolyPolygon( const ::basegfx::B2DPolyPolygon& rPolyPoly )
 +        {
 +            ::basegfx::B2DPolyPolygon aPolyPoly(rPolyPoly);
@@ -1170,7 +1203,6 @@
 +                }
 +            }
 +        }
-+
 +        
 +        void setupState( const ::basegfx::B2DHomMatrix&   rTransform,
 +                         GLenum                           eSrcBlend,
@@ -1260,7 +1292,7 @@
 +            return true;
 +        }
 +
-+        bool lcl_fillPolyPolygon( const CanvasHelper&                    /*rHelper*/,
++        bool lcl_fillPolyPolygon( const CanvasHelper&                    rHelper,
 +                                  const ::basegfx::B2DHomMatrix&         rTransform,
 +                                  GLenum                                 eSrcBlend,
 +                                  GLenum                                 eDstBlend,
@@ -1270,12 +1302,15 @@
 +            TransformationPreserver aPreserver;
 +            setupState(rTransform, eSrcBlend, eDstBlend, rColor);
 +
++            rHelper.getDeviceHelper()->useLinearGradientShader(rColor,
++                                                               rendering::ARGBColor(1.0,0.0,1.0,0.0));
++            
 +            ::basegfx::B2DPolyPolygonVector::const_iterator aCurr=rPolyPolygons.begin();
 +            const ::basegfx::B2DPolyPolygonVector::const_iterator aEnd=rPolyPolygons.end();
 +            while( aCurr != aEnd )
 +            {
-+                glBegin(GL_POLYGON);
-+                renderPolyPolygon(*aCurr++);
++                glBegin(GL_TRIANGLES);
++                renderComplexPolyPolygon(*aCurr++);
 +                glEnd();
 +            }
 +
@@ -1366,11 +1401,14 @@
 +        RecordVectorT aThrowaway;
 +        mpRecordedActions.swap( aThrowaway );
 +        mpDevice = NULL;
++        mpDeviceHelper = NULL;
 +    }
 +
-+    void CanvasHelper::init( rendering::XGraphicDevice& rDevice )
++    void CanvasHelper::init( rendering::XGraphicDevice& rDevice,
++                             SpriteDeviceHelper& rDeviceHelper )
 +    {
 +        mpDevice = &rDevice;
++        mpDeviceHelper = &rDeviceHelper;
 +    }
 +
 +    void CanvasHelper::clear()
@@ -1884,10 +1922,10 @@
 +}
 diff --git canvas/source/opengl/ogl_canvashelper.hxx canvas/source/opengl/ogl_canvashelper.hxx
 new file mode 100644
-index 0000000..74efbc5
+index 0000000..88ab9d9
 --- /dev/null
 +++ canvas/source/opengl/ogl_canvashelper.hxx
-@@ -0,0 +1,227 @@
+@@ -0,0 +1,237 @@
 +/*************************************************************************
 + *
 + *    OpenOffice.org - a multi-platform office productivity suite
@@ -1916,6 +1954,8 @@
 +
 +namespace oglcanvas
 +{
++    class SpriteDeviceHelper;
++
 +    /** Helper class for basic canvas functionality. */
 +    class CanvasHelper
 +    {
@@ -1943,7 +1983,8 @@
 +            Reference device this canvas is associated with
 +
 +         */
-+        void init( com::sun::star::rendering::XGraphicDevice& rDevice );
++        void init( com::sun::star::rendering::XGraphicDevice& rDevice,
++                   SpriteDeviceHelper& rDeviceHelper );
 +
 +        // CanvasHelper functionality
 +        // ==========================
@@ -2086,6 +2127,8 @@
 +         */
 +        bool renderRecordedActions() const;
 +
++        SpriteDeviceHelper* getDeviceHelper() const { return mpDeviceHelper; }
++
 +    private:
 +        // declared, but not defined
 +        CanvasHelper( const CanvasHelper& );
@@ -2105,6 +2148,11 @@
 +         */
 +        ::com::sun::star::rendering::XGraphicDevice* mpDevice;
 +
++        /** Internal helper - used for a few global GL objects,
++            e.g. shader programs
++         */
++        SpriteDeviceHelper*                          mpDeviceHelper;
++
 +        /** Ptr to array of recorded render calls
 +
 +            Gets shared copy-on-write, when this CanvasHelper is
@@ -2117,7 +2165,7 @@
 +#endif
 diff --git canvas/source/opengl/ogl_spritecanvas.cxx canvas/source/opengl/ogl_spritecanvas.cxx
 new file mode 100644
-index 0000000..5624d60
+index 0000000..275adbc
 --- /dev/null
 +++ canvas/source/opengl/ogl_spritecanvas.cxx
 @@ -0,0 +1,202 @@
@@ -2213,7 +2261,7 @@
 +        maDeviceHelper.init( *pParentWindow,
 +                             *this,
 +                             aRect );
-+        maCanvasHelper.init( *this );
++        maCanvasHelper.init( *this, maDeviceHelper );
 +        maArguments.realloc(0);
 +    }
 +
@@ -2268,7 +2316,7 @@
 +                                                        uno::RuntimeException)
 +    {
 +        return uno::Reference< rendering::XCustomSprite >( 
-+            new CanvasCustomSprite(spriteSize, this) );
++            new CanvasCustomSprite(spriteSize, this, maDeviceHelper) );
 +    }
 +
 +    uno::Reference< rendering::XSprite > SAL_CALL SpriteCanvas::createClonedSprite( 
@@ -2457,16 +2505,17 @@
 +#endif
 diff --git canvas/source/opengl/ogl_spritedevicehelper.cxx canvas/source/opengl/ogl_spritedevicehelper.cxx
 new file mode 100644
-index 0000000..f5209de
+index 0000000..8e8fb5d
 --- /dev/null
 +++ canvas/source/opengl/ogl_spritedevicehelper.cxx
-@@ -0,0 +1,529 @@
+@@ -0,0 +1,658 @@
 +/*************************************************************************
 + *
 + *    OpenOffice.org - a multi-platform office productivity suite
 + *
 + *    Author:
 + *      Thorsten Behrens <tbehrens novell com>      
++ *      Radek Doulik <rodo novell com>      
 + *
 + *      Copyright (C) 2008, Novell Inc.
 + *      Parts copyright 2005 by Sun Microsystems, Inc.
@@ -2500,6 +2549,7 @@
 +#include <vcl/canvastools.hxx>
 +#include <toolkit/helper/vclunohelper.hxx>
 +
++#define GL_GLEXT_PROTOTYPES
 +#include <GL/gl.h>
 +#include <GL/glu.h>
 +#include <GL/glext.h>
@@ -2522,15 +2572,101 @@
 +    return 0;
 +}
 +
++/** Dummy vertex processing. Simply uses default pipeline for vertex
++   transformation, and forwards texture coodinates to fragment shader
++ */
++static const char dummyVertexShader[] = 
++{
++    "varying vec2 v_textureCoords2d;                                            "
++    "void main(void)                                                            "
++    "{                                                                          "
++	"    gl_Position = ftransform();                                            "
++	"    v_textureCoords2d = gl_MultiTexCoord0.st;                              "
++    "}                                                                          "
++};
++
++/** Two-color linear gradient
++ */
++static const char linearGradientFragmentShader[] = 
++{
++    "uniform vec4 v_startColor4d;                                               "
++    "uniform vec4 v_endColor4d;                                                 "
++    "varying vec2 v_textureCoords2d;                                            "
++    "void main(void)                                                            "
++    "{                                                                          "
++	"    gl_FragColor = mix(v_startColor4d,                                     "
++    "                       v_endColor4d,                                       "
++    "                       v_textureCoords2d.s);                               "
++    "}                                                                          "
++};
++
 +namespace oglcanvas
 +{
++    /** Compile shader program
++
++        Code courtesy rodo
++     */
++    void SpriteDeviceHelper::compileShader(unsigned int& o_rShaderHandle,
++                                           unsigned int  eShaderType, 
++                                           const char*   pShaderSourceCode)
++    {
++        GLint nCompileStatus;
++        char log[1024];
++
++        o_rShaderHandle = glCreateShader( eShaderType );
++        glShaderSource( o_rShaderHandle, 1, &pShaderSourceCode, NULL );
++        glCompileShader( o_rShaderHandle );
++        glGetShaderInfoLog( o_rShaderHandle, sizeof(log), NULL, log );
++        OSL_TRACE("shader compile log: %s", log);
++
++        glGetShaderiv( o_rShaderHandle, GL_COMPILE_STATUS, &nCompileStatus );
++        if( !nCompileStatus )
++        {
++            glDeleteShader(o_rShaderHandle);
++            o_rShaderHandle=0;
++        }
++    }
++
++    /** Link vertex & fragment shaders
++
++        Code courtesy rodo
++     */
++    void SpriteDeviceHelper::linkShaders(unsigned int& o_rProgramHandle,
++                                         unsigned int  nVertexProgramId, 
++                                         unsigned int  nFragmentProgramId)
++    {
++        if( !nVertexProgramId || !nFragmentProgramId )
++            return;
++
++        o_rProgramHandle = glCreateProgram();
++        glAttachShader( o_rProgramHandle, nVertexProgramId );
++        glAttachShader( o_rProgramHandle, nFragmentProgramId );
++
++        char log[1024];
++        GLint nProgramLinked;
++
++        glLinkProgram( o_rProgramHandle );
++        glGetProgramInfoLog( o_rProgramHandle, sizeof(log), NULL, log );
++        OSL_TRACE("shader program link log: %s", log);
++        glGetProgramiv( o_rProgramHandle, GL_LINK_STATUS, &nProgramLinked );
++
++        if( !nProgramLinked )
++        {
++            glDeleteProgram(o_rProgramHandle);
++            o_rProgramHandle=0;
++        }
++    }
++
 +    SpriteDeviceHelper::SpriteDeviceHelper() :
 +        mpDevice(NULL),
 +        mpSpriteCanvas(NULL),
 +        maActiveSprites(),
 +        mpChildWindow(),
 +        mpDisplay(NULL),
-+        mpGLContext(NULL)
++        mpGLContext(NULL),
++        mnDummyVertexProgram(0),
++        mnLinearGradientFragmentProgram(0),
++        mnLinearGradientProgram(0)
 +    {}
 +
 +    void SpriteDeviceHelper::init( Window&               rWindow,
@@ -2711,6 +2847,17 @@
 +            glHint(GL_POLYGON_SMOOTH_HINT,GL_NICEST);
 +            glShadeModel(GL_FLAT);
 +
++            // compile & link shaders - code courtesy rodo
++            compileShader(mnDummyVertexProgram, 
++                          GL_VERTEX_SHADER, 
++                          dummyVertexShader);
++            compileShader(mnLinearGradientFragmentProgram, 
++                          GL_FRAGMENT_SHADER, 
++                          linearGradientFragmentShader);
++            linkShaders(mnLinearGradientProgram,
++                        mnDummyVertexProgram,
++                        mnLinearGradientFragmentProgram);
++
 +            glXMakeCurrent(pDisplay, None, NULL);
 +        }
 +
@@ -2731,8 +2878,14 @@
 +        mpDevice = NULL;
 +
 +        if( mpGLContext )
++        {
++            glDeleteProgram( mnLinearGradientProgram );
++            glDeleteShader( mnLinearGradientFragmentProgram );
++            glDeleteShader( mnDummyVertexProgram );
++
 +            glXDestroyContext(reinterpret_cast<unx::Display*>(mpDisplay), 
 +                              reinterpret_cast<unx::GLXContext>(mpGLContext));
++        }
 +
 +        mpDisplay = NULL;
 +        mpGLContext = NULL;
@@ -2804,6 +2957,7 @@
 +        return uno::Reference< rendering::XBitmap >(
 +            new CanvasBitmap( size,
 +                              mpSpriteCanvas,
++                              *this,
 +                              false ) );
 +    }
 +
@@ -2825,6 +2979,7 @@
 +        return uno::Reference< rendering::XBitmap >(
 +            new CanvasBitmap( size,
 +                              mpSpriteCanvas,
++                              *this,
 +                              true ) );
 +    }
 +
@@ -2989,13 +3144,35 @@
 +    {
 +        maActiveSprites.erase(xSprite);
 +    }
++
++    void SpriteDeviceHelper::useLinearGradientShader( const rendering::ARGBColor& rStartColor,
++                                                      const rendering::ARGBColor& rEndColor )
++    {
++        glUseProgram(mnLinearGradientProgram);
++
++        const GLint nStartColorLocation = glGetUniformLocation(mnLinearGradientProgram,
++                                                               "v_startColor4d" );
++        glUniform4f(nStartColorLocation, 
++                    rStartColor.Alpha,
++                    rStartColor.Red,
++                    rStartColor.Green,
++                    rStartColor.Blue);
++
++        const GLint nEndColorLocation = glGetUniformLocation(mnLinearGradientProgram,
++                                                             "v_endColor4d" );
++        glUniform4f(nEndColorLocation, 
++                    rEndColor.Alpha,
++                    rEndColor.Red,
++                    rEndColor.Green,
++                    rEndColor.Blue);
++    }
 +}
 diff --git canvas/source/opengl/ogl_spritedevicehelper.hxx canvas/source/opengl/ogl_spritedevicehelper.hxx
 new file mode 100644
-index 0000000..9d9febf
+index 0000000..0318c6d
 --- /dev/null
 +++ canvas/source/opengl/ogl_spritedevicehelper.hxx
-@@ -0,0 +1,119 @@
+@@ -0,0 +1,134 @@
 +/*************************************************************************
 + *
 + *    OpenOffice.org - a multi-platform office productivity suite
@@ -3092,9 +3269,19 @@
 +        void show( const ::rtl::Reference< CanvasCustomSprite >& );
 +        void hide( const ::rtl::Reference< CanvasCustomSprite >& );
 +
++        void useLinearGradientShader( const ::com::sun::star::rendering::ARGBColor& rStartColor,
++                                      const ::com::sun::star::rendering::ARGBColor& rEndColor );
++
 +    private:
 +        void resize( const ::basegfx::B2IVector& rNewSize );
 +
++        void compileShader(unsigned int& o_rShaderHandle,
++                           unsigned int  eShaderType, 
++                           const char*   pShaderSourceCode);
++        void linkShaders(unsigned int& o_rProgramHandle,
++                         unsigned int  nVertexProgramId, 
++                         unsigned int  nFragmentProgramId);
++
 +        /** Phyical output device
 +
 +            Deliberately not a refcounted reference, because of
@@ -3111,6 +3298,11 @@
 +        boost::shared_ptr<SystemChildWindow>               mpChildWindow;
 +        void*                                              mpDisplay;
 +        void*                                              mpGLContext;
++
++        unsigned int                                       mnDummyVertexProgram;
++
++        unsigned int                                       mnLinearGradientFragmentProgram;
++        unsigned int                                       mnLinearGradientProgram;
 +    };
 +}
 +



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]