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



Author: thorstenb
Date: Wed Jan  7 22:58:41 2009
New Revision: 15021
URL: http://svn.gnome.org/viewvc/ooo-build?rev=15021&view=rev

Log:
    * patches/test/opengl-canvas.diff: gradients & textures working
    now



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	Wed Jan  7 22:58:41 2009
@@ -16,16 +16,16 @@
  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_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          | 1055 ++++++++++++++++++++
- canvas/source/opengl/ogl_canvashelper.hxx          |  238 +++++
+ canvas/source/opengl/ogl_canvashelper.cxx          | 1101 ++++++++++++++++++++
+ canvas/source/opengl/ogl_canvashelper.hxx          |  238 ++++
  canvas/source/opengl/ogl_spritecanvas.cxx          |  202 ++++
  canvas/source/opengl/ogl_spritecanvas.hxx          |  126 ++
- canvas/source/opengl/ogl_spritedevicehelper.cxx    |  794 +++++++++++++++
+ canvas/source/opengl/ogl_spritedevicehelper.cxx    |  760 ++++++++++++++
  canvas/source/opengl/ogl_spritedevicehelper.hxx    |  146 +++
  canvas/source/opengl/ogl_textlayout.cxx            |  222 ++++
  canvas/source/opengl/ogl_textlayout.hxx            |   83 ++
@@ -50,7 +50,7 @@
  sdext/source/presenter/PresenterSlideShowView.cxx  |   48 +
  sdext/source/presenter/PresenterSlideShowView.hxx  |    7 
  slideshow/source/engine/waitsymbol.cxx             |   13 
- 45 files changed, 3873 insertions(+), 64 deletions(-)
+ 45 files changed, 3885 insertions(+), 64 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
@@ -1060,10 +1060,10 @@
 +#endif
 diff --git canvas/source/opengl/ogl_canvashelper.cxx canvas/source/opengl/ogl_canvashelper.cxx
 new file mode 100644
-index 0000000..d7e5e3e
+index 0000000..0e34ca4
 --- /dev/null
 +++ canvas/source/opengl/ogl_canvashelper.cxx
-@@ -0,0 +1,1055 @@
+@@ -0,0 +1,1101 @@
 +/*************************************************************************
 + *
 + *    OpenOffice.org - a multi-platform office productivity suite
@@ -1092,6 +1092,7 @@
 +#include <basegfx/tools/canvastools.hxx>
 +#include <basegfx/polygon/b2dpolypolygon.hxx>
 +#include <basegfx/polygon/b2dpolygontriangulator.hxx>
++#include <basegfx/polygon/b2dpolypolygontools.hxx>
 +
 +#include <com/sun/star/rendering/TexturingMode.hpp>
 +#include <com/sun/star/rendering/CompositeOperation.hpp>
@@ -1298,7 +1299,7 @@
 +            return true;
 +        }
 +
-+        bool lcl_fillPolyPolygon( const CanvasHelper&                    rHelper,
++        bool lcl_fillPolyPolygon( const CanvasHelper&                    /*rHelper*/,
 +                                  const ::basegfx::B2DHomMatrix&         rTransform,
 +                                  GLenum                                 eSrcBlend,
 +                                  GLenum                                 eDstBlend,
@@ -1336,25 +1337,38 @@
 +            const rendering::ARGBColor aEndColor(
 +                rHelper.getDevice()->getDeviceColorSpace()->convertToARGB(rValues.maColors[1])[0]);
 +
++            // convert to weird canvas textur coordinate system (not
++            // [0,1]^2, but path coordinate system)
++            ::basegfx::B2DHomMatrix aTextureTransform;
++            ::basegfx::unotools::homMatrixFromAffineMatrix( aTextureTransform,
++                                                            rTexture.AffineTransform );
++            ::basegfx::B2DRange aBounds;
++            ::basegfx::B2DPolyPolygonVector::const_iterator aCurr=rPolyPolygons.begin();
++            const ::basegfx::B2DPolyPolygonVector::const_iterator aEnd=rPolyPolygons.end();
++            while( aCurr != aEnd )
++                aBounds.expand(::basegfx::tools::getRange(*aCurr++));
++            aTextureTransform.translate(-aBounds.getMinX(), -aBounds.getMinY());
++            aTextureTransform.scale(1/aBounds.getWidth(), 1/aBounds.getHeight());
++
 +            switch( rValues.meType )
 +            {
 +                case ::canvas::ParametricPolyPolygon::GRADIENT_AXIAL:
 +                case ::canvas::ParametricPolyPolygon::GRADIENT_LINEAR:
 +                    rHelper.getDeviceHelper()->useLinearGradientShader(aStartColor, 
 +                                                                       aEndColor,
-+                                                                       rTexture.AffineTransform);
++                                                                       aTextureTransform);
 +                    break;
 +
 +                case ::canvas::ParametricPolyPolygon::GRADIENT_ELLIPTICAL:
 +                    rHelper.getDeviceHelper()->useRadialGradientShader(aStartColor, 
 +                                                                       aEndColor,
-+                                                                       rTexture.AffineTransform);
++                                                                       aTextureTransform);
 +                    break;
 +
 +                case ::canvas::ParametricPolyPolygon::GRADIENT_RECTANGULAR:
 +                    rHelper.getDeviceHelper()->useRectangularGradientShader(aStartColor, 
 +                                                                            aEndColor,
-+                                                                            rTexture.AffineTransform);
++                                                                            aTextureTransform);
 +                    break;
 +
 +                default:
@@ -1363,8 +1377,7 @@
 +            }
 +
 +
-+            ::basegfx::B2DPolyPolygonVector::const_iterator aCurr=rPolyPolygons.begin();
-+            const ::basegfx::B2DPolyPolygonVector::const_iterator aEnd=rPolyPolygons.end();
++            aCurr=rPolyPolygons.begin();
 +            while( aCurr != aEnd )
 +            {
 +                glBegin(GL_TRIANGLES);
@@ -1427,8 +1440,12 @@
 +            glTexParameteri(GL_TEXTURE_2D,
 +                            GL_TEXTURE_MAG_FILTER,
 +                            GL_NEAREST);
-+            glDisable(GL_BLEND);
-+            glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
++            glEnable(GL_BLEND);
++            glBlendFunc(GL_SRC_ALPHA, 
++                        GL_ONE_MINUS_SRC_ALPHA);
++
++            // blend against fixed vertex color; texture alpha is multiplied in
++            glColor4f(1,1,1,1); 
 +
 +            glBegin(GL_TRIANGLE_STRIP);
 +            glTexCoord2f(0,0); glVertex2d(0,0);
@@ -1478,12 +1495,39 @@
 +            glTexParameteri(GL_TEXTURE_2D,
 +                            GL_TEXTURE_MAG_FILTER,
 +                            GL_NEAREST);
-+            glDisable(GL_BLEND);
-+            glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
++            glEnable(GL_BLEND);
++            glBlendFunc(GL_SRC_ALPHA, 
++                        GL_ONE_MINUS_SRC_ALPHA);
 +
++            // convert to weird canvas textur coordinate system (not
++            // [0,1]^2, but path coordinate system)
++            ::basegfx::B2DHomMatrix aTextureTransform;
++            ::basegfx::unotools::homMatrixFromAffineMatrix( aTextureTransform,
++                                                            rTexture.AffineTransform );
++            ::basegfx::B2DRange aBounds;
 +            ::basegfx::B2DPolyPolygonVector::const_iterator aCurr=rPolyPolygons.begin();
 +            const ::basegfx::B2DPolyPolygonVector::const_iterator aEnd=rPolyPolygons.end();
 +            while( aCurr != aEnd )
++                aBounds.expand(::basegfx::tools::getRange(*aCurr++));
++            aTextureTransform.translate(-aBounds.getMinX(), -aBounds.getMinY());
++            aTextureTransform.scale(1/aBounds.getWidth(), 1/aBounds.getHeight());
++            aTextureTransform.invert();
++
++            glMatrixMode(GL_TEXTURE);
++            double aTexTransform[] = 
++                {
++                    aTextureTransform.get(0,0), aTextureTransform.get(1,0), 0, 0,
++                    aTextureTransform.get(0,1), aTextureTransform.get(1,1), 0, 0,
++                    0,                          0,                          1, 0,
++                    aTextureTransform.get(0,2), aTextureTransform.get(1,2), 0, 1
++                };
++            glLoadMatrixd(aTexTransform);
++
++            // blend against fixed vertex color; texture alpha is multiplied in
++            glColor4f(1,1,1,1); 
++
++            aCurr=rPolyPolygons.begin();
++            while( aCurr != aEnd )
 +            {
 +                glBegin(GL_TRIANGLES);
 +                renderComplexPolyPolygon(*aCurr++);
@@ -1491,6 +1535,8 @@
 +            }
 +
 +            glDeleteTextures(1, &nTexture);
++            glLoadIdentity();
++            glMatrixMode(GL_MODELVIEW);
 +
 +            return true;
 +        }
@@ -2705,10 +2751,10 @@
 +#endif
 diff --git canvas/source/opengl/ogl_spritedevicehelper.cxx canvas/source/opengl/ogl_spritedevicehelper.cxx
 new file mode 100644
-index 0000000..cfd4fc8
+index 0000000..24e38f5
 --- /dev/null
 +++ canvas/source/opengl/ogl_spritedevicehelper.cxx
-@@ -0,0 +1,794 @@
+@@ -0,0 +1,760 @@
 +/*************************************************************************
 + *
 + *    OpenOffice.org - a multi-platform office productivity suite
@@ -2789,35 +2835,36 @@
 + */
 +static const char linearGradientFragmentShader[] = 
 +{
-+    "#version 120                                                               "
-+    "uniform vec4   v_startColor4d;                                             "
-+    "uniform vec4   v_endColor4d;                                               "
-+    "uniform mat3x2 m_transform;                                                "
-+    "varying vec2   v_textureCoords2d;                                          "
-+    "void main(void)                                                            "
-+    "{                                                                          "
-+	"    gl_FragColor = mix(v_startColor4d,                                     "
-+    "                       v_endColor4d,                                       "
-+    "                       (m_transform*vec3(v_textureCoords2d,1)).s);         "
-+    "}                                                                          "
++    "#version 120                                                            \n"
++    "uniform vec4   v_startColor4d;                                            "
++    "uniform vec4   v_endColor4d;                                              "
++    "uniform mat3x2 m_transform;                                               "
++    "varying vec2   v_textureCoords2d;                                         "
++    "void main(void)                                                           "
++    "{                                                                         "
++    "    gl_FragColor = mix(v_startColor4d,                                    "
++    "                       v_endColor4d,                                      "
++    "                       (m_transform * vec3(v_textureCoords2d,1)).s);      "
++    "}                                                                         "
 +};
 +
 +/** Two-color radial gradient
 + */
 +static const char radialGradientFragmentShader[] = 
 +{
-+    "#version 120                                                               "
-+    "uniform vec4 v_startColor4d;                                               "
-+    "uniform vec4 v_endColor4d;                                                 "
-+    "const vec2 v_center2d = vec2(0,0);                                         "
-+    "varying vec2 v_textureCoords2d;                                            "
++    "#version 120                                                             \n"
++    "uniform vec4   v_startColor4d;                                             "
++    "uniform vec4   v_endColor4d;                                               "
++    "uniform mat3x2 m_transform;                                                "
++    "varying vec2   v_textureCoords2d;                                          "
++    "const vec2     v_center2d = vec2(0,0);                                     "
 +    "void main(void)                                                            "
 +    "{                                                                          "
 +	"    gl_FragColor = mix(v_startColor4d,                                     "
 +    "                       v_endColor4d,                                       "
 +    "                       distance(                                           "
 +    "                          vec2(                                            "
-+    "                             m_transform*vec3(v_textureCoords2d,1)),       "
++    "                             m_transform * vec3(v_textureCoords2d,1)),     "
 +    "                          v_center2d));                                    "
 +    "}                                                                          "
 +};
@@ -2826,18 +2873,19 @@
 + */
 +static const char rectangularGradientFragmentShader[] = 
 +{
-+    "#version 120                                                               "
-+    "uniform vec4 v_startColor4d;                                               "
-+    "uniform vec4 v_endColor4d;                                                 "
-+    "const vec2 v_center2d = vec2(0,0);                                         "
-+    "varying vec2 v_textureCoords2d;                                            "
++    "#version 120                                                             \n"
++    "uniform vec4   v_startColor4d;                                             "
++    "uniform vec4   v_endColor4d;                                               "
++    "uniform mat3x2 m_transform;                                                "
++    "varying vec2   v_textureCoords2d;                                          "
++    "const vec2     v_center2d = vec2(0,0);                                     "
 +    "void main(void)                                                            "
 +    "{                                                                          "
 +	"    gl_FragColor = mix(v_startColor4d,                                     "
 +    "                       v_endColor4d,                                       "
 +    "                       distance(                                           "
 +    "                          vec2(                                            "
-+    "                             m_transform*vec3(v_textureCoords2d,1)),       "
++    "                             m_transform * vec3(v_textureCoords2d,1)),     "
 +    "                          v_center2d));                                    "
 +    "}                                                                          "
 +};
@@ -3407,13 +3455,12 @@
 +        maActiveSprites.erase(xSprite);
 +    }
 +
-+    void SpriteDeviceHelper::useLinearGradientShader( const rendering::ARGBColor&     rStartColor,
-+                                                      const rendering::ARGBColor&     rEndColor,
-+                                                      const geometry::AffineMatrix2D& rTexTransform )
++    static void setupUniforms( unsigned int                    nProgramId,
++                               const rendering::ARGBColor&     rStartColor,
++                               const rendering::ARGBColor&     rEndColor,
++                               const ::basegfx::B2DHomMatrix&  rTexTransform )
 +    {
-+        glUseProgram(mnLinearGradientProgram);
-+
-+        const GLint nStartColorLocation = glGetUniformLocation(mnLinearGradientProgram,
++        const GLint nStartColorLocation = glGetUniformLocation(nProgramId,
 +                                                               "v_startColor4d" );
 +        glUniform4f(nStartColorLocation, 
 +                    rStartColor.Red,
@@ -3421,7 +3468,7 @@
 +                    rStartColor.Blue,
 +                    rStartColor.Alpha);
 +
-+        const GLint nEndColorLocation = glGetUniformLocation(mnLinearGradientProgram,
++        const GLint nEndColorLocation = glGetUniformLocation(nProgramId,
 +                                                             "v_endColor4d" );
 +        glUniform4f(nEndColorLocation, 
 +                    rEndColor.Red,
@@ -3429,83 +3476,48 @@
 +                    rEndColor.Blue,
 +                    rEndColor.Alpha);
 +
-+        const GLint nTransformLocation = glGetUniformLocation(mnLinearGradientProgram,
++        const GLint nTransformLocation = glGetUniformLocation(nProgramId,
 +                                                             "m_transform" );
++        // OGL is column-major
 +        float aTexTransform[] = 
 +            {
-+                rTexTransform.m00, rTexTransform.m01, rTexTransform.m02,
-+                rTexTransform.m10, rTexTransform.m11, rTexTransform.m12
++                rTexTransform.get(0,0), rTexTransform.get(1,0), 
++                rTexTransform.get(0,1), rTexTransform.get(1,1),
++                rTexTransform.get(0,2), rTexTransform.get(1,2)
 +            };
-+        glUniformMatrix3x2fv(nTransformLocation,6,false,aTexTransform);
++        glUniformMatrix3x2fv(nTransformLocation,1,false,aTexTransform);
++    }
++ 
++    void SpriteDeviceHelper::useLinearGradientShader( const rendering::ARGBColor&     rStartColor,
++                                                      const rendering::ARGBColor&     rEndColor,
++                                                      const ::basegfx::B2DHomMatrix&  rTexTransform )
++    {
++        glUseProgram(mnLinearGradientProgram);
++
++        setupUniforms(mnLinearGradientProgram, rStartColor, rEndColor, rTexTransform);
 +    }
 +
 +    void SpriteDeviceHelper::useRadialGradientShader( const rendering::ARGBColor&     rStartColor,
 +                                                      const rendering::ARGBColor&     rEndColor,
-+                                                      const geometry::AffineMatrix2D& rTexTransform )
++                                                      const ::basegfx::B2DHomMatrix&  rTexTransform )
 +    {
 +        glUseProgram(mnRadialGradientProgram);
 +
-+        const GLint nStartColorLocation = glGetUniformLocation(mnRadialGradientProgram,
-+                                                               "v_startColor4d" );
-+        glUniform4f(nStartColorLocation, 
-+                    rStartColor.Red,
-+                    rStartColor.Green,
-+                    rStartColor.Blue,
-+                    rStartColor.Alpha);
-+
-+        const GLint nEndColorLocation = glGetUniformLocation(mnRadialGradientProgram,
-+                                                             "v_endColor4d" );
-+        glUniform4f(nEndColorLocation, 
-+                    rEndColor.Red,
-+                    rEndColor.Green,
-+                    rEndColor.Blue,
-+                    rEndColor.Alpha);
-+
-+        const GLint nTransformLocation = glGetUniformLocation(mnLinearGradientProgram,
-+                                                             "m_transform" );
-+        float aTexTransform[] = 
-+            {
-+                rTexTransform.m00, rTexTransform.m01, rTexTransform.m02,
-+                rTexTransform.m10, rTexTransform.m11, rTexTransform.m12
-+            };
-+        glUniformMatrix3x2fv(nTransformLocation,6,false,aTexTransform);
++        setupUniforms(mnLinearGradientProgram, rStartColor, rEndColor, rTexTransform);
 +    }
 +
 +    void SpriteDeviceHelper::useRectangularGradientShader( const rendering::ARGBColor&     rStartColor,
 +                                                           const rendering::ARGBColor&     rEndColor,
-+                                                           const geometry::AffineMatrix2D& rTexTransform )
++                                                           const ::basegfx::B2DHomMatrix&  rTexTransform )
 +    {
 +        glUseProgram(mnRectangularGradientProgram);
 +
-+        const GLint nStartColorLocation = glGetUniformLocation(mnRectangularGradientProgram,
-+                                                               "v_startColor4d" );
-+        glUniform4f(nStartColorLocation, 
-+                    rStartColor.Red,
-+                    rStartColor.Green,
-+                    rStartColor.Blue,
-+                    rStartColor.Alpha);
-+
-+        const GLint nEndColorLocation = glGetUniformLocation(mnRectangularGradientProgram,
-+                                                             "v_endColor4d" );
-+        glUniform4f(nEndColorLocation, 
-+                    rEndColor.Red,
-+                    rEndColor.Green,
-+                    rEndColor.Blue,
-+                    rEndColor.Alpha);
-+
-+        const GLint nTransformLocation = glGetUniformLocation(mnLinearGradientProgram,
-+                                                             "m_transform" );
-+        float aTexTransform[] = 
-+            {
-+                rTexTransform.m00, rTexTransform.m01, rTexTransform.m02,
-+                rTexTransform.m10, rTexTransform.m11, rTexTransform.m12
-+            };
-+        glUniformMatrix3x2fv(nTransformLocation,6,false,aTexTransform);
++        setupUniforms(mnLinearGradientProgram, rStartColor, rEndColor, rTexTransform);
 +    }
 +}
 diff --git canvas/source/opengl/ogl_spritedevicehelper.hxx canvas/source/opengl/ogl_spritedevicehelper.hxx
 new file mode 100644
-index 0000000..0a9c19e
+index 0000000..578d71e
 --- /dev/null
 +++ canvas/source/opengl/ogl_spritedevicehelper.hxx
 @@ -0,0 +1,146 @@
@@ -3537,7 +3549,7 @@
 +
 +class Window;
 +class SystemChildWindow;
-+namespace basegfx{ class B2IVector; }
++namespace basegfx{ class B2IVector; class B2DHomMatrix; }
 +namespace com { namespace sun { namespace star { 
 +    namespace awt { struct Rectangle; }
 +    namespace geometry { struct AffineMatrix2D; }
@@ -3606,15 +3618,15 @@
 +        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,
-+                                      const ::com::sun::star::geometry::AffineMatrix2D& rTexTransform );
-+        void useRadialGradientShader( const ::com::sun::star::rendering::ARGBColor&     rStartColor,
-+                                      const ::com::sun::star::rendering::ARGBColor&     rEndColor,
-+                                      const ::com::sun::star::geometry::AffineMatrix2D& rTexTransform );
-+        void useRectangularGradientShader( const ::com::sun::star::rendering::ARGBColor&     rStartColor,
-+                                           const ::com::sun::star::rendering::ARGBColor&     rEndColor,
-+                                           const ::com::sun::star::geometry::AffineMatrix2D& rTexTransform );
++        void useLinearGradientShader( const ::com::sun::star::rendering::ARGBColor& rStartColor,
++                                      const ::com::sun::star::rendering::ARGBColor& rEndColor,
++                                      const ::basegfx::B2DHomMatrix&                rTexTransform );
++        void useRadialGradientShader( const ::com::sun::star::rendering::ARGBColor& rStartColor,
++                                      const ::com::sun::star::rendering::ARGBColor& rEndColor,
++                                      const ::basegfx::B2DHomMatrix&                rTexTransform );
++        void useRectangularGradientShader( const ::com::sun::star::rendering::ARGBColor& rStartColor,
++                                           const ::com::sun::star::rendering::ARGBColor& rEndColor,
++                                           const ::basegfx::B2DHomMatrix&                rTexTransform );
 +
 +    private:
 +        void resize( const ::basegfx::B2IVector& rNewSize );



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