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



Author: thorstenb
Date: Tue Oct 14 17:04:09 2008
New Revision: 14312
URL: http://svn.gnome.org/viewvc/ooo-build?rev=14312&view=rev

Log:
    * patches/test/opengl-canvas.diff: work-in-progress, retained mode
    rework finished



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	Tue Oct 14 17:04:09 2008
@@ -8,24 +8,28 @@
  canvas/prj/build.lst                            |    1 
  canvas/source/opengl/exports.dxp                |    3 
  canvas/source/opengl/exports.map                |    8 
- canvas/source/opengl/makefile.mk                |   63 +++
- canvas/source/opengl/ogl_canvascustomsprite.cxx |   77 +++
- canvas/source/opengl/ogl_canvascustomsprite.hxx |   83 ++++
- canvas/source/opengl/ogl_canvasfont.cxx         |  109 +++++
- canvas/source/opengl/ogl_canvasfont.hxx         |   79 +++
- canvas/source/opengl/ogl_canvashelper.cxx       |  539 +++++++++++++++++++++++
- canvas/source/opengl/ogl_canvashelper.hxx       |  204 +++++++++
- canvas/source/opengl/ogl_spritecanvas.cxx       |  190 ++++++++
- canvas/source/opengl/ogl_spritecanvas.hxx       |  117 +++++
- canvas/source/opengl/ogl_spritedevicehelper.cxx |  214 +++++++++
- canvas/source/opengl/ogl_spritedevicehelper.hxx |  102 ++++
- canvas/source/opengl/ogl_textlayout.cxx         |  244 ++++++++++
- canvas/source/opengl/ogl_textlayout.hxx         |   90 ++++
+ canvas/source/opengl/makefile.mk                |   63 ++
+ canvas/source/opengl/ogl_canvasbitmap.cxx       |   72 ++
+ canvas/source/opengl/ogl_canvasbitmap.hxx       |   87 +++
+ canvas/source/opengl/ogl_canvascustomsprite.cxx |   77 ++
+ canvas/source/opengl/ogl_canvascustomsprite.hxx |   83 ++
+ canvas/source/opengl/ogl_canvasfont.cxx         |  109 +++
+ canvas/source/opengl/ogl_canvasfont.hxx         |   79 ++
+ canvas/source/opengl/ogl_canvashelper.cxx       |  766 +++++++++++++++++++++++
+ canvas/source/opengl/ogl_canvashelper.hxx       |  208 ++++++
+ canvas/source/opengl/ogl_spritecanvas.cxx       |  190 ++++++
+ canvas/source/opengl/ogl_spritecanvas.hxx       |  117 ++++
+ canvas/source/opengl/ogl_spritedevicehelper.cxx |  220 +++++++
+ canvas/source/opengl/ogl_spritedevicehelper.hxx |  102 +++
+ canvas/source/opengl/ogl_textlayout.cxx         |  244 +++++++
+ canvas/source/opengl/ogl_textlayout.hxx         |   90 +++
  offapi/com/sun/star/rendering/XSpriteCanvas.idl |    8 
- 17 files changed, 2127 insertions(+), 4 deletions(-)
+ 19 files changed, 2523 insertions(+), 4 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
+ create mode 100644 canvas/source/opengl/ogl_canvasbitmap.cxx
+ create mode 100644 canvas/source/opengl/ogl_canvasbitmap.hxx
  create mode 100644 canvas/source/opengl/ogl_canvascustomsprite.cxx
  create mode 100644 canvas/source/opengl/ogl_canvascustomsprite.hxx
  create mode 100644 canvas/source/opengl/ogl_canvasfont.cxx
@@ -144,9 +148,180 @@
 +# ==========================================================================
 +
 +.INCLUDE :	target.mk
+diff --git canvas/source/opengl/ogl_canvasbitmap.cxx canvas/source/opengl/ogl_canvasbitmap.cxx
+new file mode 100644
+index 0000000..ebeba24
+--- /dev/null
++++ canvas/source/opengl/ogl_canvasbitmap.cxx
+@@ -0,0 +1,72 @@
++/*************************************************************************
++ *
++ *    OpenOffice.org - a multi-platform office productivity suite
++ *
++ *    Author:
++ *      Thorsten Behrens <tbehrens novell com>      
++ *
++ *      Copyright (C) 2008, Novell Inc.
++ *      Parts copyright 2005 by Sun Microsystems, Inc.
++ *      Parts copyright 2004 David Reveman, Peter Nilsson
++ *
++ *   The Contents of this file are made available subject to
++ *   the terms of GNU Lesser General Public License Version 2.1.
++ *
++ ************************************************************************/
++
++// MARKER(update_precomp.py): autogen include statement, do not remove
++#include "precompiled_canvas.hxx"
++
++#include "ogl_canvasbitmap.hxx"
++
++#include <canvas/debug.hxx>
++#include <canvas/canvastools.hxx>
++
++
++using namespace ::com::sun::star;
++
++namespace nullcanvas
++{
++    CanvasBitmap::CanvasBitmap( const ::basegfx::B2ISize& rSize,
++                                const DeviceRef&          rDevice,
++                                bool                      bHasAlpha ) :
++        mpDevice( rDevice )
++    {
++        ENSURE_AND_THROW( mpDevice.is(),
++                          "CanvasBitmap::CanvasBitmap(): Invalid surface or device" );
++
++        maCanvasHelper.init( rSize,
++                             *mpDevice.get(),
++                             bHasAlpha );
++    }
++
++    void SAL_CALL CanvasBitmap::disposing()
++    {
++        mpDevice.clear();
++
++        // forward to parent
++        CanvasBitmap_Base::disposing();
++    }
++
++#define IMPLEMENTATION_NAME "NullCanvas.CanvasBitmap"
++#define SERVICE_NAME "com.sun.star.rendering.CanvasBitmap"
++
++    ::rtl::OUString SAL_CALL CanvasBitmap::getImplementationName(  ) throw (uno::RuntimeException)
++    {
++        return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( IMPLEMENTATION_NAME ) );
++    }
++
++    sal_Bool SAL_CALL CanvasBitmap::supportsService( const ::rtl::OUString& ServiceName ) throw (uno::RuntimeException)
++    {
++        return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SERVICE_NAME ) );
++    }
++
++    uno::Sequence< ::rtl::OUString > SAL_CALL CanvasBitmap::getSupportedServiceNames(  ) throw (uno::RuntimeException)
++    {
++        uno::Sequence< ::rtl::OUString > aRet(1);
++        aRet[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME ) );
++        
++        return aRet;
++    }
++
++}
+diff --git canvas/source/opengl/ogl_canvasbitmap.hxx canvas/source/opengl/ogl_canvasbitmap.hxx
+new file mode 100644
+index 0000000..6596952
+--- /dev/null
++++ canvas/source/opengl/ogl_canvasbitmap.hxx
+@@ -0,0 +1,87 @@
++/*************************************************************************
++ *
++ *    OpenOffice.org - a multi-platform office productivity suite
++ *
++ *    Author:
++ *      Thorsten Behrens <tbehrens novell com>      
++ *
++ *      Copyright (C) 2008, Novell Inc.
++ *      Parts copyright 2005 by Sun Microsystems, Inc.
++ *      Parts copyright 2004 David Reveman, Peter Nilsson
++ *
++ *   The Contents of this file are made available subject to
++ *   the terms of GNU Lesser General Public License Version 2.1.
++ *
++ ************************************************************************/
++
++#ifndef OGL_CANVASBITMAP_HXX
++#define OGL_CANVASBITMAP_HXX
++
++#include <cppuhelper/compbase3.hxx>
++
++#include <com/sun/star/lang/XServiceInfo.hpp>
++#include <com/sun/star/rendering/XBitmapCanvas.hpp>
++#include <com/sun/star/rendering/XIntegerBitmap.hpp>
++
++#include <canvas/base/integerbitmapbase.hxx>
++#include <canvas/base/basemutexhelper.hxx>
++#include <basegfx/vector/b2isize.hxx>
++
++#include <boost/shared_ptr.hpp>
++
++#include "ogl_canvashelper.hxx"
++#include "ogl_spritecanvas.hxx"
++
++
++/* Definition of CanvasBitmap class */
++
++namespace oglcanvas
++{
++    typedef ::cppu::WeakComponentImplHelper3< ::com::sun::star::rendering::XBitmapCanvas,
++                                              ::com::sun::star::rendering::XIntegerBitmap,
++                                              ::com::sun::star::lang::XServiceInfo >    CanvasBitmapBase_Base;
++    typedef ::canvas::IntegerBitmapBase< ::canvas::BaseMutexHelper< CanvasBitmapBase_Base >, 
++                                         CanvasHelper, 
++                                         ::osl::MutexGuard,
++                                         ::cppu::OWeakObject >                          CanvasBitmapBaseT;
++
++    class CanvasBitmap : public CanvasBitmapBaseT
++    {
++    public:
++        /** Create a canvas bitmap for the given surface
++
++            @param rSize
++            Size of the bitmap
++        
++            @param rDevice
++            Reference device, with which bitmap should be compatible
++         */
++        CanvasBitmap( const ::basegfx::B2ISize& rSize,
++                      const SpriteCanvasRef&    rDevice,
++                      bool                      bHasAlpha );
++
++        /** Create verbatim copy (including all recorded actions)
++         */
++        CanvasBitmap( const CanvasBitmap& rSrc );
++
++        /// Dispose all internal references
++        virtual void SAL_CALL disposing();
++
++        // XServiceInfo
++        virtual ::rtl::OUString SAL_CALL getImplementationName(  ) throw (::com::sun::star::uno::RuntimeException);
++        virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException);
++        virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  ) throw (::com::sun::star::uno::RuntimeException);
++
++        /** Write out recorded actions
++         */
++        bool renderRecordedActions() const;
++
++    private:
++        /** MUST hold here, too, since CanvasHelper only contains a
++            raw pointer (without refcounting) 
++        */
++        SpriteCanvasRef mpDevice;
++    };
++}
++
++#endif
 diff --git canvas/source/opengl/ogl_canvascustomsprite.cxx canvas/source/opengl/ogl_canvascustomsprite.cxx
 new file mode 100644
-index 0000000..9cad500
+index 0000000..f3ff780
 --- /dev/null
 +++ canvas/source/opengl/ogl_canvascustomsprite.cxx
 @@ -0,0 +1,77 @@
@@ -184,7 +359,7 @@
 +
 +namespace oglcanvas
 +{
-+    CanvasCustomSprite::CanvasCustomSprite( const ::com::sun::star::geometry::RealSize2D&   rSpriteSize,
++    CanvasCustomSprite::CanvasCustomSprite( const ::com::sun::star::geometry::RealSize2D&   /*rSpriteSize*/,
 +                                            const SpriteCanvasRef&                          rRefDevice ) :
 +        CanvasCustomSpriteBaseT( m_aMutex ),
 +        mpSpriteCanvas( rRefDevice )
@@ -518,10 +693,10 @@
 +#endif
 diff --git canvas/source/opengl/ogl_canvashelper.cxx canvas/source/opengl/ogl_canvashelper.cxx
 new file mode 100644
-index 0000000..078e0ab
+index 0000000..1ab72de
 --- /dev/null
 +++ canvas/source/opengl/ogl_canvashelper.cxx
-@@ -0,0 +1,539 @@
+@@ -0,0 +1,766 @@
 +/*************************************************************************
 + *
 + *    OpenOffice.org - a multi-platform office productivity suite
@@ -555,9 +730,11 @@
 +#include <com/sun/star/rendering/PathJoinType.hpp>
 +
 +#include "ogl_canvasfont.hxx"
++#include "ogl_canvasbitmap.hxx"
 +#include "ogl_spritecanvas.hxx"
 +
 +#include <GL/gl.h>
++#include <GL/glu.h>
 +#include <GL/glext.h>
 +
 +
@@ -565,6 +742,48 @@
 +
 +namespace oglcanvas
 +{
++    /* Concepts:
++       =========
++
++       This OpenGL canvas implementation tries to keep all render
++       output as high-level as possible, i.e. geometry data and
++       externally-provided bitmaps. Therefore, calls at the
++       XCanvas-interfaces are not immediately transformed into colored
++       pixel inside some GL buffer, but are retained simply with their
++       call parameters. Only after XSpriteCanvas::updateScreen() has
++       been called, this all gets transferred to the OpenGL subsystem
++       and converted to a visible scene. The big advantage is, this
++       makes sprite modifications practically zero-overhead, and saves
++       a lot on texture memory (compared to the directx canvas, which
++       immediately dumps every render call into a texture).
++
++       The drawback, of course, is that complex images churn a lot of
++       GPU cycles on every re-rendering.
++
++       For the while, I'll be using immediate mode, i.e. transfer data
++       over and over again to the OpenGL subsystem. Alternatively,
++       there are display lists, which at least keep the data on the
++       server, or even better, vertex buffers, which copy geometry
++       data over en bloc.
++     */
++
++    struct CanvasHelper::Action
++    {
++        ::basegfx::B2DHomMatrix   maTransform;
++        GLenum                    meSrcBlendMode;
++        GLenum                    meDstBlendMode;
++        rendering::ARGBColor      maARGBColor;
++        ::basegfx::B2DPolyPolygon maPolyPoly;
++
++        ::boost::function6< bool,
++                            const CanvasHelper&,
++                            const ::basegfx::B2DHomMatrix&,
++                            GLenum,
++                            GLenum,
++                            const rendering::ARGBColor&,
++                            const ::basegfx::B2DPolyPolygon& > maFunction;
++    };
++
 +    namespace
 +    {
 +        struct TransformationPreserver
@@ -576,10 +795,8 @@
 +            { glPopAttrib(); }
 +        };
 +
-+        void renderPolyPolygon( const uno::Reference< rendering::XPolyPolygon2D >& xPolyPolygon )
++        void renderPolyPolygon( const ::basegfx::B2DPolyPolygon& rPolyPoly )
 +        {
-+            const ::basegfx::B2DPolyPolygon& rPolyPoly( 
-+                ::basegfx::unotools::b2DPolyPolygonFromXPolyPolygon2D(xPolyPolygon));
 +            for( sal_uInt32 i=0; i<rPolyPoly.count(); i++ ) 
 +            {
 +                const ::basegfx::B2DPolygon& rPolygon( rPolyPoly.getB2DPolygon(i) );
@@ -593,14 +810,166 @@
 +                }
 +            }
 +        }
++
++        
++        void setupState( const ::basegfx::B2DHomMatrix&   rTransform,
++                         GLenum                           eSrcBlend,
++                         GLenum                           eDstBlend,
++                         const rendering::ARGBColor&      rColor )
++        {
++            double aGLTransform[] = 
++                {
++                    rTransform.get(0,0), rTransform.get(1,0), 0, 0,
++                    rTransform.get(0,1), rTransform.get(1,1), 0, 0,
++                    rTransform.get(0,2), rTransform.get(1,2), 0, 0,
++                    0,                   0,                   0, 1
++                };
++            glMultMatrixd(aGLTransform);
++
++            glEnable(GL_BLEND);
++            glBlendFunc(eSrcBlend, eDstBlend);
++
++            glColor4d(rColor.Red,
++                      rColor.Green,
++                      rColor.Blue,
++                      rColor.Alpha);
++
++            // GL 1.2:
++            // glBlendEquation( GLenum mode );
++            // glBlendColor( GLclampf red, GLclampf green,GLclampf blue, GLclampf alpha );
++            // glConvolutionFilter1D
++            // glConvolutionFilter2D
++            // glSeparableFilter2D
++        }
++
++        bool lcl_drawPoint( const CanvasHelper&              /*rHelper*/,
++                            const ::basegfx::B2DHomMatrix&   rTransform,
++                            GLenum                           eSrcBlend,
++                            GLenum                           eDstBlend,
++                            const rendering::ARGBColor&      rColor,
++                            const geometry::RealPoint2D&     rPoint )
++        {
++            TransformationPreserver aPreserver;
++            setupState(rTransform, eSrcBlend, eDstBlend, rColor);
++
++            glBegin(GL_POINTS);
++            glVertex2d(rPoint.X, rPoint.Y);
++            glEnd();
++
++            return true;
++        }
++
++        bool lcl_drawLine( const CanvasHelper&              /*rHelper*/,
++                           const ::basegfx::B2DHomMatrix&   rTransform,
++                           GLenum                           eSrcBlend,
++                           GLenum                           eDstBlend,
++                           const rendering::ARGBColor&      rColor,
++                           const geometry::RealPoint2D&     rStartPoint,
++                           const geometry::RealPoint2D&     rEndPoint )
++        {
++            TransformationPreserver aPreserver;
++            setupState(rTransform, eSrcBlend, eDstBlend, rColor);
++
++            glBegin(GL_LINES);
++            glVertex2d(rStartPoint.X, rStartPoint.Y);
++            glVertex2d(rEndPoint.X, rEndPoint.Y);
++            glEnd();
++
++            return true;
++        }
++
++        bool lcl_drawPolyPolygon( const CanvasHelper&              /*rHelper*/,
++                                  const ::basegfx::B2DHomMatrix&   rTransform,
++                                  GLenum                           eSrcBlend,
++                                  GLenum                           eDstBlend,
++                                  const rendering::ARGBColor&      rColor,
++                                  const ::basegfx::B2DPolyPolygon& rPolyPolygon )
++        {
++            TransformationPreserver aPreserver;
++            setupState(rTransform, eSrcBlend, eDstBlend, rColor);
++
++            glBegin(GL_LINES);
++            renderPolyPolygon(rPolyPolygon);
++            glEnd();
++
++            return true;
++        }
++
++        bool lcl_fillPolyPolygon( const CanvasHelper&              /*rHelper*/,
++                                  const ::basegfx::B2DHomMatrix&   rTransform,
++                                  GLenum                           eSrcBlend,
++                                  GLenum                           eDstBlend,
++                                  const rendering::ARGBColor&      rColor,
++                                  const ::basegfx::B2DPolyPolygon& rPolyPolygon )
++        {
++            TransformationPreserver aPreserver;
++            setupState(rTransform, eSrcBlend, eDstBlend, rColor);
++
++            glBegin(GL_POLYGON);
++            renderPolyPolygon(rPolyPolygon);
++            glEnd();
++
++            return true;
++        }
++
++        bool lcl_drawOwnBitmap( const CanvasHelper&              /*rHelper*/,
++                                const ::basegfx::B2DHomMatrix&   rTransform,
++                                GLenum                           eSrcBlend,
++                                GLenum                           eDstBlend,
++                                const rendering::ARGBColor&      rColor,
++                                const CanvasBitmap&              rBitmap )
++        {
++            TransformationPreserver aPreserver;
++            setupState(rTransform, eSrcBlend, eDstBlend, rColor);
++
++            return rBitmap.renderRecordedActions();
++        }
++
++        bool lcl_drawGenericBitmap( const CanvasHelper&              /*rHelper*/,
++                                    const ::basegfx::B2DHomMatrix&   rTransform,
++                                    GLenum                           eSrcBlend,
++                                    GLenum                           eDstBlend,
++                                    const rendering::ARGBColor&      rColor,
++                                    const geometry::IntegerSize2D&   rPixelSize,
++                                    const uno::Sequence<sal_Int8>&   rPixelData )
++        {
++            TransformationPreserver aPreserver;
++            setupState(rTransform, eSrcBlend, eDstBlend, rColor);
++
++            // TODO(P3): reuse the texture next time
++            unsigned int nTexture;
++            glGenTextures(1, &nTexture);
++            glBindTexture(GL_TEXTURE_2D, nTexture);
++
++            gluBuild2DMipmaps(GL_TEXTURE_2D, 
++                              4, 
++                              rPixelSize.Width, 
++                              rPixelSize.Height, 
++                              GL_RGBA, 
++                              GL_UNSIGNED_BYTE,
++                              &rPixelData[0]);
++            glEnable(GL_TEXTURE_2D);
++            glBegin(GL_QUADS);
++            glTexCoord2f(0,0); glVertex2d(0,0);
++            glTexCoord2f(1,0); glVertex2d(rPixelSize.Width, 0);
++            glTexCoord2f(1,1); glVertex2d(rPixelSize.Width, rPixelSize.Height);
++            glTexCoord2f(0,1); glVertex2d(0, rPixelSize.Height);
++            glEnd();
++
++            glDeleteTextures(1, &nTexture);
++
++            return true;
++        }
 +    }
 +
 +    CanvasHelper::CanvasHelper() :
-+        mpDevice( NULL )
++        mpDevice( NULL ),
++        mpRecordedActions( new std::vector<Action>() )
 +    {}
 +
 +    void CanvasHelper::disposing()
 +    {
++        mpRecordedActions.reset( new std::vector<Action>() );
 +        mpDevice = NULL;
 +    }
 +
@@ -611,11 +980,7 @@
 +
 +    void CanvasHelper::clear()
 +    {        
-+        if( mpDevice )
-+        {
-+            glClearColor(0,0,0,0);
-+            glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-+        }
++        mpRecordedActions->clear();
 +    }
 +
 +    void CanvasHelper::drawPoint( const rendering::XCanvas*     /*pCanvas*/,
@@ -625,12 +990,13 @@
 +    {
 +        if( mpDevice )
 +        {
-+            TransformationPreserver aPreserver;
-+            setupGraphicsState( viewState, renderState );
++            mpRecordedActions->push_back( Action() );
++            Action& rAct=mpRecordedActions->back();
 +
-+            glBegin(GL_POINTS);
-+            glVertex2d(aPoint.X, aPoint.Y);
-+            glEnd();
++            setupGraphicsState( rAct, viewState, renderState );
++            rAct.maFunction = ::boost::bind(&lcl_drawPoint,
++                                            _1,_2,_3,_4,_5,
++                                            aPoint);
 +        }
 +    }
 +
@@ -642,13 +1008,13 @@
 +    {
 +        if( mpDevice )
 +        {
-+            TransformationPreserver aPreserver;
-+            setupGraphicsState( viewState, renderState );
++            mpRecordedActions->push_back( Action() );
++            Action& rAct=mpRecordedActions->back();
 +
-+            glBegin(GL_LINES);
-+            glVertex2d(aStartPoint.X, aStartPoint.Y);
-+            glVertex2d(aEndPoint.X, aEndPoint.Y);
-+            glEnd();
++            setupGraphicsState( rAct, viewState, renderState );
++            rAct.maFunction = ::boost::bind(&lcl_drawLine,
++                                            _1,_2,_3,_4,_5,
++                                            aStartPoint,aEndPoint);
 +        }
 +    }
 +
@@ -660,14 +1026,18 @@
 +    {
 +        if( mpDevice )
 +        {
-+            TransformationPreserver aPreserver;
-+            setupGraphicsState( viewState, renderState );
++            mpRecordedActions->push_back( Action() );
++            Action& rAct=mpRecordedActions->back();
++
++            setupGraphicsState( rAct, viewState, renderState );
 +
 +            // TODO(F2): subdivide&render whole curve
-+            glBegin(GL_LINES);
-+            glVertex2d(aBezierSegment.Px, aBezierSegment.Py);
-+            glVertex2d(aEndPoint.X, aEndPoint.Y);
-+            glEnd();
++            rAct.maFunction = ::boost::bind(&lcl_drawLine,
++                                            _1,_2,_3,_4,_5,
++                                            geometry::RealPoint2D(
++                                                aBezierSegment.Px,
++                                                aBezierSegment.Py),
++                                            aEndPoint);
 +        }
 +    }
 +
@@ -681,12 +1051,15 @@
 +
 +        if( mpDevice )
 +        {
-+            TransformationPreserver aPreserver;
-+            setupGraphicsState( viewState, renderState );
++            mpRecordedActions->push_back( Action() );
++            Action& rAct=mpRecordedActions->back();
 +
-+            glBegin(GL_LINES);
-+            renderPolyPolygon(xPolyPolygon);
-+            glEnd();
++            setupGraphicsState( rAct, viewState, renderState );
++            rAct.maPolyPoly = 
++                ::basegfx::unotools::b2DPolyPolygonFromXPolyPolygon2D(xPolyPolygon);
++            rAct.maPolyPoly.makeUnique(); // own copy, for thread safety
++
++            rAct.maFunction = &lcl_drawPolyPolygon;
 +        }
 +
 +        // TODO(P1): Provide caching here.
@@ -697,9 +1070,24 @@
 +                                                                                   const uno::Reference< rendering::XPolyPolygon2D >&   xPolyPolygon, 
 +                                                                                   const rendering::ViewState&                          viewState, 
 +                                                                                   const rendering::RenderState&                        renderState, 
-+                                                                                   const rendering::StrokeAttributes&                   strokeAttributes )
++                                                                                   const rendering::StrokeAttributes&                   /*strokeAttributes*/ )
 +    {
-+        // TODO(F3)
++        ENSURE_OR_THROW( xPolyPolygon.is(), 
++                          "CanvasHelper::strokePolyPolygon: polygon is NULL");
++
++        if( mpDevice )
++        {
++            mpRecordedActions->push_back( Action() );
++            Action& rAct=mpRecordedActions->back();
++
++            setupGraphicsState( rAct, viewState, renderState );
++            rAct.maPolyPoly = 
++                ::basegfx::unotools::b2DPolyPolygonFromXPolyPolygon2D(xPolyPolygon);
++            rAct.maPolyPoly.makeUnique(); // own copy, for thread safety
++
++            // TODO(F3): fallback to drawPolyPolygon currently
++            rAct.maFunction = &lcl_drawPolyPolygon;
++        }
 +
 +        // TODO(P1): Provide caching here.
 +        return uno::Reference< rendering::XCachedPrimitive >(NULL);
@@ -748,13 +1136,15 @@
 +
 +        if( mpDevice )
 +        {
-+            TransformationPreserver aPreserver;
-+            setupGraphicsState( viewState, renderState );
++            mpRecordedActions->push_back( Action() );
++            Action& rAct=mpRecordedActions->back();
 +
-+            // TODO(F3): complex polygons
-+            glBegin(GL_POLYGON);
-+            renderPolyPolygon(xPolyPolygon);
-+            glEnd();
++            setupGraphicsState( rAct, viewState, renderState );
++            rAct.maPolyPoly = 
++                ::basegfx::unotools::b2DPolyPolygonFromXPolyPolygon2D(xPolyPolygon);
++            rAct.maPolyPoly.makeUnique(); // own copy, for thread safety
++
++            rAct.maFunction = &lcl_fillPolyPolygon;
 +        }
 +
 +        // TODO(P1): Provide caching here.
@@ -788,10 +1178,8 @@
 +                                                                       const geometry::Matrix2D&                    fontMatrix )
 +    {
 +        if( mpDevice )
-+        {
 +            return uno::Reference< rendering::XCanvasFont >( 
 +                    new CanvasFont(fontRequest, extraFontProperties, fontMatrix ) );
-+        }
 +
 +        return uno::Reference< rendering::XCanvasFont >();
 +    }
@@ -805,20 +1193,20 @@
 +    }
 +
 +    uno::Reference< rendering::XCachedPrimitive > CanvasHelper::drawText( const rendering::XCanvas*                         /*pCanvas*/, 
-+                                                                          const rendering::StringContext&                   text, 
-+                                                                          const uno::Reference< rendering::XCanvasFont >&   xFont, 
-+                                                                          const rendering::ViewState&                       viewState, 
-+                                                                          const rendering::RenderState&                     renderState, 
++                                                                          const rendering::StringContext&                   /*text*/, 
++                                                                          const uno::Reference< rendering::XCanvasFont >&   /*xFont*/, 
++                                                                          const rendering::ViewState&                       /*viewState*/, 
++                                                                          const rendering::RenderState&                     /*renderState*/, 
 +                                                                          sal_Int8                                          /*textDirection*/ )
 +    {
-+        // TODO
++        // TODO - but not used from slideshow
 +        return uno::Reference< rendering::XCachedPrimitive >(NULL);
 +    }
 +
 +    uno::Reference< rendering::XCachedPrimitive > CanvasHelper::drawTextLayout( const rendering::XCanvas*                       /*pCanvas*/, 
-+                                                                                const uno::Reference< rendering::XTextLayout >& xLayoutetText, 
-+                                                                                const rendering::ViewState&                     viewState, 
-+                                                                                const rendering::RenderState&                   renderState )
++                                                                                const uno::Reference< rendering::XTextLayout >& /*xLayoutetText*/, 
++                                                                                const rendering::ViewState&                     /*viewState*/, 
++                                                                                const rendering::RenderState&                   /*renderState*/ )
 +    {
 +        // TODO
 +        return uno::Reference< rendering::XCachedPrimitive >(NULL);
@@ -832,6 +1220,55 @@
 +        ENSURE_OR_THROW( xBitmap.is(), 
 +                          "CanvasHelper::drawBitmap: bitmap is NULL");
 +
++        if( mpDevice )
++        {
++            // own bitmap?
++            CanvasBitmap* pOwnBitmap=dynamic_cast<CanvasBitmap*>(xBitmap.get());
++            if( pOwnBitmap )
++            {
++                // insert as transformed copy of bitmap action vector -
++                // during rendering, this gets rendered into a temporary
++                // buffer, and then composited to the front
++                mpRecordedActions->push_back( Action() );
++                Action& rAct=mpRecordedActions->back();
++                
++                setupGraphicsState( rAct, viewState, renderState );
++                rAct.maFunction = ::boost::bind(&lcl_drawOwnBitmap,
++                                                _1,_2,_3,_4,_5,
++                                                *pOwnBitmap);
++            }
++            else
++            {
++                // TODO(P3): Highly inefficient - simply copies pixel data
++
++                uno::Reference< rendering::XIntegerReadOnlyBitmap > xIntegerBitmap(
++                    xBitmap, uno::UNO_QUERY);
++                if( xIntegerBitmap.is() )
++                {
++                    const geometry::IntegerSize2D aSize=xBitmap->getSize();
++                    rendering::IntegerBitmapLayout aLayout;
++                    uno::Sequence<sal_Int8> aPixelData=
++                        xIntegerBitmap->getData(
++                            aLayout,
++                            geometry::IntegerRectangle2D(0,0,aSize.Width,aSize.Height));
++
++                    // force-convert color to ARGB8888 int color space  
++                    uno::Sequence<sal_Int8> aARGBBytes(
++                        aLayout.ColorSpace->convertToIntegerColorSpace(
++                            aPixelData,
++                            canvas::tools::getStdColorSpace()));
++
++                    mpRecordedActions->push_back( Action() );
++                    Action& rAct=mpRecordedActions->back();
++                
++                    setupGraphicsState( rAct, viewState, renderState );
++                    rAct.maFunction = ::boost::bind(&lcl_drawGenericBitmap,
++                                                    _1,_2,_3,_4,_5,
++                                                    aSize, aARGBBytes);
++                }
++                // TODO(F1): handle non-integer case
++            }
++        }
 +#if 0
 +        if( mpDevice )
 +        {
@@ -929,13 +1366,8 @@
 +                                                                                     const rendering::ViewState&                    viewState, 
 +                                                                                     const rendering::RenderState&                  renderState )
 +    {
-+        ENSURE_OR_THROW( xBitmap.is(), 
-+                          "CanvasHelper::drawBitmap: bitmap is NULL");
-+
-+        // TODO
-+
-+        // TODO(P1): Provide caching here.
-+        return uno::Reference< rendering::XCachedPrimitive >(NULL);
++        // TODO(F3): remove this wart altogether
++        return drawBitmap(pCanvas, xBitmap, viewState, renderState);
 +    }
 +
 +    uno::Reference< rendering::XGraphicDevice > CanvasHelper::getDevice()
@@ -943,7 +1375,8 @@
 +        return uno::Reference< rendering::XGraphicDevice >(mpDevice);
 +    }
 +
-+    void CanvasHelper::setupGraphicsState( const rendering::ViewState&   viewState, 
++    void CanvasHelper::setupGraphicsState( Action&                       o_action,
++                                           const rendering::ViewState&   viewState, 
 +                                           const rendering::RenderState& renderState )
 +    {
 +        ENSURE_OR_THROW( mpDevice,
@@ -955,106 +1388,75 @@
 +        // setup overall transform only now. View clip above was
 +        // relative to view transform
 +        ::basegfx::B2DHomMatrix aTransform;
-+        ::canvas::tools::mergeViewAndRenderTransform(aTransform,
++        ::canvas::tools::mergeViewAndRenderTransform(o_action.maTransform,
 +                                                     viewState,
 +                                                     renderState);
-+        double aGLTransform[] = 
-+            {
-+                aTransform.get(0,0), aTransform.get(1,0), 0, 0,
-+                aTransform.get(0,1), aTransform.get(1,1), 0, 0,
-+                aTransform.get(0,2), aTransform.get(1,2), 0, 0,
-+                0,                   0,                   0, 1
-+            };
-+        glLoadMatrixd(aGLTransform);
-+
-+        // TODO(Q3): this needs thorough review, and the
-+        // rendering::CompositeOperation as well.
-+        
 +        // setup compositing - mapping courtesy David Reveman
 +        // (glitz_operator.c)
-+        bool bEnableBlend=true;
-+        GLenum eSrcBlendMode=GL_ONE; 
-+        GLenum eDstBlendMode=GL_ONE_MINUS_SRC_ALPHA; 
 +        switch( renderState.CompositeOperation )
 +        {
 +            case rendering::CompositeOperation::OVER:
-+                eSrcBlendMode=GL_ONE; 
-+                eDstBlendMode=GL_ONE_MINUS_SRC_ALPHA; 
++                o_action.meSrcBlendMode=GL_ONE; 
++                o_action.meDstBlendMode=GL_ONE_MINUS_SRC_ALPHA; 
 +                break;
 +            case rendering::CompositeOperation::CLEAR:
-+                eSrcBlendMode=GL_ZERO; 
-+                eDstBlendMode=GL_ZERO; 
++                o_action.meSrcBlendMode=GL_ZERO; 
++                o_action.meDstBlendMode=GL_ZERO; 
 +                break;
 +            case rendering::CompositeOperation::SOURCE:
-+                bEnableBlend=false;
++                o_action.meSrcBlendMode=GL_ONE; 
++                o_action.meDstBlendMode=GL_ZERO; 
 +                break;
 +            case rendering::CompositeOperation::UNDER:
 +                // FALLTHROUGH intended - but correct?!
 +            case rendering::CompositeOperation::DESTINATION:
-+                eSrcBlendMode=GL_ZERO; 
-+                eDstBlendMode=GL_ONE; 
++                o_action.meSrcBlendMode=GL_ZERO; 
++                o_action.meDstBlendMode=GL_ONE; 
 +                break;
 +            case rendering::CompositeOperation::INSIDE:
-+                eSrcBlendMode=GL_DST_ALPHA; 
-+                eDstBlendMode=GL_ZERO; 
++                o_action.meSrcBlendMode=GL_DST_ALPHA; 
++                o_action.meDstBlendMode=GL_ZERO; 
 +                break;
 +            case rendering::CompositeOperation::INSIDE_REVERSE:
-+                eSrcBlendMode=GL_ONE_MINUS_DST_ALPHA; 
-+                eDstBlendMode=GL_ZERO; 
++                o_action.meSrcBlendMode=GL_ONE_MINUS_DST_ALPHA; 
++                o_action.meDstBlendMode=GL_ZERO; 
 +                break;
 +            case rendering::CompositeOperation::OUTSIDE:
-+                eSrcBlendMode=GL_ONE_MINUS_DST_ALPHA; 
-+                eDstBlendMode=GL_ONE; 
++                o_action.meSrcBlendMode=GL_ONE_MINUS_DST_ALPHA; 
++                o_action.meDstBlendMode=GL_ONE; 
 +                break;
 +            case rendering::CompositeOperation::OUTSIDE_REVERSE:
-+                eSrcBlendMode=GL_ZERO; 
-+                eDstBlendMode=GL_ONE_MINUS_SRC_ALPHA; 
++                o_action.meSrcBlendMode=GL_ZERO; 
++                o_action.meDstBlendMode=GL_ONE_MINUS_SRC_ALPHA; 
 +                break;
 +            case rendering::CompositeOperation::ATOP:
-+                eSrcBlendMode=GL_DST_ALPHA; 
-+                eDstBlendMode=GL_ONE_MINUS_SRC_ALPHA; 
++                o_action.meSrcBlendMode=GL_DST_ALPHA; 
++                o_action.meDstBlendMode=GL_ONE_MINUS_SRC_ALPHA; 
 +                break;
 +            case rendering::CompositeOperation::ATOP_REVERSE:
-+                eSrcBlendMode=GL_ONE_MINUS_DST_ALPHA; 
-+                eDstBlendMode=GL_SRC_ALPHA; 
++                o_action.meSrcBlendMode=GL_ONE_MINUS_DST_ALPHA; 
++                o_action.meDstBlendMode=GL_SRC_ALPHA; 
 +                break;
 +            case rendering::CompositeOperation::XOR:
-+                eSrcBlendMode=GL_ONE_MINUS_DST_ALPHA; 
-+                eDstBlendMode=GL_ONE_MINUS_SRC_ALPHA; 
++                o_action.meSrcBlendMode=GL_ONE_MINUS_DST_ALPHA; 
++                o_action.meDstBlendMode=GL_ONE_MINUS_SRC_ALPHA; 
 +                break;
 +            case rendering::CompositeOperation::ADD:
-+                eSrcBlendMode=GL_ONE;
-+                eDstBlendMode=GL_ONE;
++                o_action.meSrcBlendMode=GL_ONE;
++                o_action.meDstBlendMode=GL_ONE;
 +                break;
 +            case rendering::CompositeOperation::SATURATE:
-+                eSrcBlendMode=GL_SRC_ALPHA_SATURATE;
-+                eDstBlendMode=GL_SRC_ALPHA_SATURATE;
++                o_action.meSrcBlendMode=GL_SRC_ALPHA_SATURATE;
++                o_action.meDstBlendMode=GL_SRC_ALPHA_SATURATE;
 +                break;
 +                
 +            default:
 +                ENSURE_OR_THROW( false, "CanvasHelper::setupGraphicsState: unexpected mode" );
 +                break;
 +        }
-+        if( bEnableBlend )
-+            glEnable(GL_BLEND);
-+        else
-+            glDisable(GL_BLEND);
-+        glBlendFunc(eSrcBlendMode, eDstBlendMode);
 +
-+        const rendering::ARGBColor& rARGBColor(
-+            mpDevice->getDeviceColorSpace()->convertToARGB(renderState.DeviceColor)[0]);
-+
-+        glColor4d(rARGBColor.Red,
-+                  rARGBColor.Green,
-+                  rARGBColor.Blue,
-+                  rARGBColor.Alpha);
-+
-+        // GL 1.2:
-+        // glBlendEquation( GLenum mode );
-+        // glBlendColor( GLclampf red, GLclampf green,GLclampf blue, GLclampf alpha );
-+        // glConvolutionFilter1D
-+        // glConvolutionFilter2D
-+        // glSeparableFilter2D
++        o_action.maARGBColor = 
++            mpDevice->getDeviceColorSpace()->convertToARGB(renderState.DeviceColor)[0];
 +    }
 +
 +    void CanvasHelper::flush() const
@@ -1063,10 +1465,10 @@
 +}
 diff --git canvas/source/opengl/ogl_canvashelper.hxx canvas/source/opengl/ogl_canvashelper.hxx
 new file mode 100644
-index 0000000..bfb2c4a
+index 0000000..f66e7fe
 --- /dev/null
 +++ canvas/source/opengl/ogl_canvashelper.hxx
-@@ -0,0 +1,204 @@
+@@ -0,0 +1,208 @@
 +/*************************************************************************
 + *
 + *    OpenOffice.org - a multi-platform office productivity suite
@@ -1091,7 +1493,8 @@
 +#include <basegfx/vector/b2dsize.hxx>
 +
 +#include <boost/utility.hpp>
-+
++#include <boost/shared_ptr.hpp>
++#include <vector>
 +
 +namespace oglcanvas
 +{
@@ -1258,7 +1661,9 @@
 +        void modifying() {}
 +
 +    private:
-+        void setupGraphicsState( const ::com::sun::star::rendering::ViewState&   viewState, 
++        struct Action;
++        void setupGraphicsState( Action&                                         o_action,
++                                 const ::com::sun::star::rendering::ViewState&   viewState, 
 +                                 const ::com::sun::star::rendering::RenderState& renderState );
 +
 +        /** Phyical output device
@@ -1267,6 +1672,7 @@
 +            potential circular references for spritecanvas.
 +         */
 +        ::com::sun::star::rendering::XGraphicDevice* mpDevice;
++        ::boost::shared_ptr< std::vector<Action> >   mpRecordedActions; 
 +    };
 +}
 +
@@ -1592,10 +1998,10 @@
 +#endif
 diff --git canvas/source/opengl/ogl_spritedevicehelper.cxx canvas/source/opengl/ogl_spritedevicehelper.cxx
 new file mode 100644
-index 0000000..f6be1fa
+index 0000000..c10adfc
 --- /dev/null
 +++ canvas/source/opengl/ogl_spritedevicehelper.cxx
-@@ -0,0 +1,214 @@
+@@ -0,0 +1,220 @@
 +/*************************************************************************
 + *
 + *    OpenOffice.org - a multi-platform office productivity suite
@@ -1640,7 +2046,7 @@
 +        mpSpriteCanvas(NULL)
 +    {}
 +
-+    void SpriteDeviceHelper::init( Window&       rWindow,
++    void SpriteDeviceHelper::init( Window&       /*rWindow*/,
 +                                   SpriteCanvas& rSpriteCanvas )
 +    {
 +        mpSpriteCanvas = &rSpriteCanvas;
@@ -1653,6 +2059,12 @@
 +        glHint(GL_LINE_SMOOTH_HINT,GL_NICEST);
 +        glHint(GL_POLYGON_SMOOTH_HINT,GL_NICEST);
 +        glShadeModel(GL_FLAT);
++
++        if( mpDevice )
++        {
++            glClearColor(0,0,0,0);
++            glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
++        }
 +    }
 +
 +    void SpriteDeviceHelper::disposing()
@@ -1700,7 +2112,7 @@
 +
 +    uno::Reference< rendering::XBitmap > SpriteDeviceHelper::createCompatibleBitmap( 
 +        const uno::Reference< rendering::XGraphicDevice >& 	/*rDevice*/,
-+        const geometry::IntegerSize2D& 						size )
++        const geometry::IntegerSize2D& 						/*size*/ )
 +    {
 +        // disposed?
 +        if( !mpSpriteCanvas )
@@ -1719,7 +2131,7 @@
 +
 +    uno::Reference< rendering::XBitmap > SpriteDeviceHelper::createCompatibleAlphaBitmap( 
 +        const uno::Reference< rendering::XGraphicDevice >& 	/*rDevice*/,
-+        const geometry::IntegerSize2D& 						size )
++        const geometry::IntegerSize2D& 						/*size*/ )
 +    {
 +        // disposed?
 +        if( !mpSpriteCanvas )



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