You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by al...@apache.org on 2013/05/08 19:00:01 UTC

svn commit: r1480354 - in /openoffice/branches/alg/sysdepgs/main: basegfx/inc/basegfx/tools/ basegfx/source/tools/ drawinglayer/inc/drawinglayer/processor2d/ drawinglayer/source/processor2d/ vcl/inc/win/ vcl/win/source/gdi/

Author: alg
Date: Wed May  8 17:00:00 2013
New Revision: 1480354

URL: http://svn.apache.org/r1480354
Log:
Securing older changes in CWS (just seen as not safed)

Modified:
    openoffice/branches/alg/sysdepgs/main/basegfx/inc/basegfx/tools/cacheable.hxx
    openoffice/branches/alg/sysdepgs/main/basegfx/inc/basegfx/tools/cmanager.hxx
    openoffice/branches/alg/sysdepgs/main/basegfx/source/tools/cmanager.cxx
    openoffice/branches/alg/sysdepgs/main/drawinglayer/inc/drawinglayer/processor2d/vclprocessor2d.hxx
    openoffice/branches/alg/sysdepgs/main/drawinglayer/inc/drawinglayer/processor2d/win_pixelprocessor2d.hxx
    openoffice/branches/alg/sysdepgs/main/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
    openoffice/branches/alg/sysdepgs/main/drawinglayer/source/processor2d/win_pixelprocessor2d.cxx
    openoffice/branches/alg/sysdepgs/main/vcl/inc/win/gdiplusobjectbuffer.hxx
    openoffice/branches/alg/sysdepgs/main/vcl/win/source/gdi/salgdi_gdiplus.cxx

Modified: openoffice/branches/alg/sysdepgs/main/basegfx/inc/basegfx/tools/cacheable.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/alg/sysdepgs/main/basegfx/inc/basegfx/tools/cacheable.hxx?rev=1480354&r1=1480353&r2=1480354&view=diff
==============================================================================
--- openoffice/branches/alg/sysdepgs/main/basegfx/inc/basegfx/tools/cacheable.hxx (original)
+++ openoffice/branches/alg/sysdepgs/main/basegfx/inc/basegfx/tools/cacheable.hxx Wed May  8 17:00:00 2013
@@ -31,17 +31,24 @@ namespace basegfx
 {
     namespace cache
     {
-        // helper class to allow caching of a c++ object with tooling. To
+        // Helper class to allow caching of a c++ object with tooling. To
         // be able to use this, the object you want to cache needs to be derived 
         // from this tooling class. It just adds a pointer for managing purposes,
         // but needs no virtuality and only this include file. For more info on how 
-        // to cache these objects, see the coc::cmanager and node
-        // clases in the same namespace (normally in the file coc_manager.hxx in 
-        // the same dir as this file)
+        // to cache these objects, see the coc::cmanager and node clases in the same 
+        // namespace.
+        // To use cached instances of this class, ask your manager class derived from
+        // the 'manager' class of this namespace for an entry, it will then either have
+        // an instance or construct one and add it to the manager.
+        // You may still incarnate instances yourself without a manager, these will just
+        // not get cached (and there is currently no way to add them to caching after
+        // incarnation).
+        // The default constructor/destructor will do the needed handling, so an instance
+        // can just be deleted, independent of being cached or not.
         class cacheable
         {
         private:
-            friend class cmanager;
+            friend class manager;
             friend class node;
 
             // the managing data node
@@ -52,8 +59,8 @@ namespace basegfx
             const node* getNode() const { return mpNode; }
 
         protected:
-            // call this always when the original data changes, will remove
-            // all evtl. cached instances
+            // this needs always to be called when the original data changes, it will remove
+            // all evtl. cached instances from the manager
             void onChange() { if(mpNode) delete mpNode; mpNode = 0; }
 
         public:

Modified: openoffice/branches/alg/sysdepgs/main/basegfx/inc/basegfx/tools/cmanager.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/alg/sysdepgs/main/basegfx/inc/basegfx/tools/cmanager.hxx?rev=1480354&r1=1480353&r2=1480354&view=diff
==============================================================================
--- openoffice/branches/alg/sysdepgs/main/basegfx/inc/basegfx/tools/cmanager.hxx (original)
+++ openoffice/branches/alg/sysdepgs/main/basegfx/inc/basegfx/tools/cmanager.hxx Wed May  8 17:00:00 2013
@@ -34,27 +34,36 @@ namespace basegfx
         class node;
         class cacheable;
 
-        // the manager part to allow caching of any c++ object derived from the helper class
-        // cacheable, see this calss in the same namespace. normally in file 
-        // cacheable.hxx in the same dir as this file.
-        // An object derived from cacheable can be cached with this manager class. It
-        // will allow you to access cached entries using getEntry() which also resets the
-        // lifetime counter if found. If not found the cached object should be incarnated and
-        // added to the cache.
-        // This mechanism uses the helper class node where the management is done. It 
-        // implements basic mechanisms for organizing this.
-        // to use this, you need to derive own classes from cmanager and from node.
+        // This caching mechanism for any C++ objects is based on three classes
+        // in this namespace, which are: manager, node, cacheable. The roles of these
+        // and how to use will be explained below.
+
+        // This is the manager part of the caching mechanism. Any c++ object derived from the 
+        // helper class cacheable (see this class in the same namespace) can be cached.
+        //
+        // An object derived from cacheable can be cached with a manager derived from this manager 
+        // class. It will allow you to access cached entries using getEntry() which also resets the
+        // lifetime counter if found. If not found the cached object will be incarnated and
+        // added to the cache. To do this, the constructor/destructor of the class derived from
+        // cacheable is used, where the basic constructor implementation inserts the instance to 
+        // the manager and the destructor removes it.
+        //
+        // This mechanism uses the helper class node where the cache data management is done. It 
+        // implements basic mechanisms for organizing the caching mechanism.
+        // To use this, you need to derive your own classes from manager and from node
+        // respectively.
         //
-        // On the cmanager derivation:
+        // On the manager derivation:
         // - react on the cache being empty by overloading (onEmpty())
         // - react on getting the first element by overloading (onFilled())
         // - test if there are cached instances using empty()
         // - try to get a cached entry using getEntry()
         // - trigger the lifetime counter using trigger() which will remove
-        //   cached objects with zero count (probably timer based)
+        //   cached objects with zero count (probably timer based in real usages,
+        //   but this is not a must).
         // - implement a access method to your cached data type using getEntry().
         //   When you get one, it's the cached instance. If not, construct your
-        //   instance of node (it will be added automatically) and return it
+        //   instance of node (it will be added automatically) and return it.
         //
         // On the node derivation:
         // - Add a data entry to hold the cached data
@@ -62,21 +71,38 @@ namespace basegfx
         //   constructor
         // - destroy it in the destuctor
         //
+        // On the cacheable derivation:
+        // - nothing to do, all managed from the namager/node combination
+        //
         // To access your cached instance, you can use getEntry() at the manager instance
         // which may return the cached entry or a newly created one. On that instance,
-        // access your cached data.
-        // The insertion to manager, access to the instance and the removal at lifetime
-        // end are all linear operations.
-        // Usage examples would e.g. derive from cmanager and the Timer calss in sal,
+        // access your cached data. If it was created or cached is transparent.
+        // The insertion at the manager, the access to the instance and the removal at 
+        // end of lifetime are all linear operations.
+        // Note that multiple derivations of cacheable can be cached by a single derivation 
+        // (and instance) of a manager; e.g. a manager might cache specialized forms of bitmap 
+        // data and polygon data at the same time (or even more classes).
+        // Usage examples would e.g. derive from manager and the Timer class in sal,
         // call trigger in the overloaded timer callback and switch the timer on/off
         // in overlods of onEmpty()/onFilled(). I will use it to e.g. cache Widows-specific
-        // data creatatble from system-independent bitmap data.
-        class cmanager : protected comphelper::OBaseMutex
+        // data creatable from system-independent bitmap data and/or polygon data.
+        class manager : protected comphelper::OBaseMutex
         {
         private:
             friend class node;
 
+            // lifetime counter used as start value for existing touched or
+            // newly created cache entries
             sal_uInt32              mnLifetime;
+
+            // the cache entries managed by this manager. This pointer is the anchor
+            // to a double linked list. That double linked list uses pointers directly
+            // in the node (mpNext, mpPrev), insertion and removal is done safely in
+            // the private helpers removeNode/insertNode below. This is done self here
+            // by purpose; any usage of an stl class would introduce some search access
+            // to find the correct node in the removeNode case; this is *not* needed
+            // when doing the list self since the node *is* already the entry to work
+            // on and thus allows linear time operations.
             node*                   mpNodes;
 
             void removeNode(node& rNode);
@@ -84,15 +110,15 @@ namespace basegfx
 
         protected:
         public:
-            // constructor allows to give lifetime count for newly
+            // constructor allows to give a default lifetime count for newly
             // added cached objects
-            cmanager(sal_uInt32 nLifetime = 60);
-            virtual ~cmanager();
+            manager(sal_uInt32 nLifetime = 60);
+            virtual ~manager();
 
-            // react on last cached object removed
+            // allow to react on last cached object removed (e.g. stop timer)
             virtual void onEmpty();
 
-            // react on first cached object added
+            // allow to react on first cached object added (e.g. start timer)
             virtual void onFilled();
 
             // ask if objects are cached
@@ -105,7 +131,7 @@ namespace basegfx
             const node* getEntry(const cacheable& rCacheable);
 
             // decrease lifetime, delete cached objects which
-            // rech zero
+            // reached end of life
             void trigger();
 
             // return default lifetime
@@ -120,23 +146,36 @@ namespace basegfx
 {
     namespace cache
     {
+        // The node part of the mechanism; it is the data needed to manage
+        // the cached data. It builds a double linked list of cached entries 
+        // using mpNext/mpPrev to allow linear insertion/removal. It holds
+        // contact to the manager (cannot exxist without one, lifetime is bound
+        // to manager lifetime). It holds data to te cached data, it only
+        // exists if cached data exists for it.
         class node
         {
         private:
-            friend class cmanager;
+            friend class manager;
             friend class cacheable;
 
+            // entries for the double linked list of cached nodes
             node*               mpNext;
             node*               mpPrev;
 
-            cmanager&           mrManager;
+            // the manager who created this node and to whom it belongs
+            manager&            mrManager;
+
+            // the data cached by this node
             const cacheable&    mrCacheable;
 
+            // the remaining lifetime of this node. Zero means still alife,
+            // but will be deleted/removed in the next call to trigger() at
+            // the manager
             sal_uInt32  mnLifetime;
 
         protected:
         public:
-            node(cmanager& rManager, const cacheable& rCacheable);
+            node(manager& rManager, const cacheable& rCacheable);
             virtual ~node();
 
             void touch();

Modified: openoffice/branches/alg/sysdepgs/main/basegfx/source/tools/cmanager.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/alg/sysdepgs/main/basegfx/source/tools/cmanager.cxx?rev=1480354&r1=1480353&r2=1480354&view=diff
==============================================================================
--- openoffice/branches/alg/sysdepgs/main/basegfx/source/tools/cmanager.cxx (original)
+++ openoffice/branches/alg/sysdepgs/main/basegfx/source/tools/cmanager.cxx Wed May  8 17:00:00 2013
@@ -32,7 +32,7 @@ namespace basegfx
 {
     namespace cache
     {
-        void cmanager::removeNode(node& rNode)
+        void manager::removeNode(node& rNode)
         {
             ::osl::MutexGuard aGuard(m_aMutex);
 
@@ -59,7 +59,7 @@ namespace basegfx
             }
         }
 
-        void cmanager::insertNode(node& rNode)
+        void manager::insertNode(node& rNode)
         {
             ::osl::MutexGuard aGuard(m_aMutex);
             rNode.mpNext = rNode.mpPrev = 0;
@@ -87,13 +87,13 @@ namespace basegfx
             }
         }
 
-        cmanager::cmanager(sal_uInt32 nLifetime)
+        manager::manager(sal_uInt32 nLifetime)
         :   mnLifetime(nLifetime),
             mpNodes(0)
         {
         }
 
-        cmanager::~cmanager()
+        manager::~manager()
         {
             ::osl::MutexGuard aGuard(m_aMutex);
 
@@ -103,20 +103,20 @@ namespace basegfx
             }
         }
 
-        void cmanager::onEmpty()
+        void manager::onEmpty()
         {
         }
 
-        void cmanager::onFilled()
+        void manager::onFilled()
         {
         }
 
-        const node* cmanager::getEntry(const cacheable& rCacheable)
+        const node* manager::getEntry(const cacheable& rCacheable)
         {
             return rCacheable.getNode();
         }
 
-        void cmanager::trigger()
+        void manager::trigger()
         {
             ::osl::MutexGuard aGuard(m_aMutex);
             node* pCurr = mpNodes;
@@ -137,7 +137,7 @@ namespace basegfx
             }
         }
         
-        void cmanager::flush()
+        void manager::flush()
         {
             ::osl::MutexGuard aGuard(m_aMutex);
 
@@ -155,7 +155,7 @@ namespace basegfx
 {
     namespace cache
     {
-        node::node(cmanager& rManager, const cacheable& rCacheable) 
+        node::node(manager& rManager, const cacheable& rCacheable) 
         :   mpNext(0),
             mpPrev(0),
             mrManager(rManager), 

Modified: openoffice/branches/alg/sysdepgs/main/drawinglayer/inc/drawinglayer/processor2d/vclprocessor2d.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/alg/sysdepgs/main/drawinglayer/inc/drawinglayer/processor2d/vclprocessor2d.hxx?rev=1480354&r1=1480353&r2=1480354&view=diff
==============================================================================
--- openoffice/branches/alg/sysdepgs/main/drawinglayer/inc/drawinglayer/processor2d/vclprocessor2d.hxx (original)
+++ openoffice/branches/alg/sysdepgs/main/drawinglayer/inc/drawinglayer/processor2d/vclprocessor2d.hxx Wed May  8 17:00:00 2013
@@ -97,6 +97,7 @@ namespace drawinglayer
             // tooling
             void pushOutputDevice(OutputDevice& rNew);
             void popOutputDevice();
+            OutputDevice* getInitialOutputDevice() const { if(mnOutputDevices.empty()) return 0; return mnOutputDevices[0]; }
             OutputDevice& getOutputDevice() const { OSL_ENSURE(0 != mpOutputDevice, "0 == mpOutputDevice (!)"); return *mpOutputDevice; }
 
             // access to transformation stack

Modified: openoffice/branches/alg/sysdepgs/main/drawinglayer/inc/drawinglayer/processor2d/win_pixelprocessor2d.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/alg/sysdepgs/main/drawinglayer/inc/drawinglayer/processor2d/win_pixelprocessor2d.hxx?rev=1480354&r1=1480353&r2=1480354&view=diff
==============================================================================
--- openoffice/branches/alg/sysdepgs/main/drawinglayer/inc/drawinglayer/processor2d/win_pixelprocessor2d.hxx (original)
+++ openoffice/branches/alg/sysdepgs/main/drawinglayer/inc/drawinglayer/processor2d/win_pixelprocessor2d.hxx Wed May  8 17:00:00 2013
@@ -28,7 +28,6 @@
 #include <basegfx/color/bcolormodifier.hxx>
 #include <svtools/optionsdrawinglayer.hxx>
 #include <tools/svwin.h>
-#include <vector>
 
 #ifndef min
 #define min(a,b)	(((a) < (b)) ? (a) : (b))
@@ -62,7 +61,6 @@ namespace drawinglayer
 
             // the current Gdiplus::Graphics and the stack
             Gdiplus::Graphics*                      mpGraphics;
-            std::vector< Gdiplus::Graphics* >       maGraphics;
 
             // the modifiedColorPrimitive stack
             basegfx::BColorModifierStack            maBColorModifierStack;
@@ -78,122 +76,6 @@ namespace drawinglayer
         protected:
             //////////////////////////////////////////////////////////////////////////////
             // tooling
-            void pushGraphics(Gdiplus::Graphics& rNew);
-            void popGraphics();
-            Gdiplus::Graphics& getGraphics() const { OSL_ENSURE(0 != mpGraphics, "0 == mpGraphics (!)"); return *mpGraphics; }
-
-            // access to transformation stack
-            const basegfx::B2DHomMatrix& getCurrentTransformation() const { return maCurrentTransformation; }
-            void setCurrentTransformation(const basegfx::B2DHomMatrix& rNew) { maCurrentTransformation = rNew; }
-
-            // access to color modifyer stack
-            basegfx::BColorModifierStack& getBColorModifierStack() { return maBColorModifierStack; }
-
-            // access to Drawinglayer configuration options
-            const SvtOptionsDrawinglayer& getOptionsDrawinglayer() const { return maDrawinglayerOpt; }
-
-            //////////////////////////////////////////////////////////////////////////////
-            // the local processor for BasePrinitive2D-Implementation based primitives,
-            // called from the common process()-implementation
-            virtual void processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate);
-
-        public:
-            /// constructor/destructor
-            Win_PixelProcessor2D(
-                const geometry::ViewInformation2D& rViewInformation, 
-                OutputDevice& rOutDev);
-            virtual ~Win_PixelProcessor2D();
-        };
-    } // end of namespace processor2d
-} // end of namespace drawinglayer
-
-//////////////////////////////////////////////////////////////////////////////
-
-#endif // INCLUDED_DRAWINGLAYER_PROCESSOR2D_WIN_PIXELPROCESSOR2D_HXX
-
-// eof
-/**************************************************************
- * 
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *   http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * 
- *************************************************************/
-
-#ifndef INCLUDED_DRAWINGLAYER_PROCESSOR2D_WIN_PIXELPROCESSOR2D_HXX
-#define INCLUDED_DRAWINGLAYER_PROCESSOR2D_WIN_PIXELPROCESSOR2D_HXX
-
-#include <drawinglayer/drawinglayerdllapi.h>
-#include <drawinglayer/processor2d/baseprocessor2d.hxx>
-#include <basegfx/matrix/b2dhommatrix.hxx>
-#include <basegfx/color/bcolormodifier.hxx>
-#include <svtools/optionsdrawinglayer.hxx>
-#include <tools/svwin.h>
-#include <vector>
-
-#ifndef min
-#define min(a,b)	(((a) < (b)) ? (a) : (b))
-#endif
-#ifndef max
-#define max(a,b)	(((a) > (b)) ? (a) : (b))
-#endif
-
-#include <GdiPlus.h>
-
-//////////////////////////////////////////////////////////////////////////////
-// predefines
-class OutputDevice;
-
-//////////////////////////////////////////////////////////////////////////////
-
-namespace drawinglayer
-{
-    namespace processor2d
-    {
-        /** Win_PixelProcessor2D class
-
-            This processor derived from BaseProcessor2D is the base class for rendering
-            system-dependent on Win, using GDI+ for now
-         */
-        class Win_PixelProcessor2D : public BaseProcessor2D
-        {
-        private:
-            // the OutputDevice started with
-            OutputDevice&                           mrOutDev;
-
-            // the current Gdiplus::Graphics and the stack
-            Gdiplus::Graphics*                      mpGraphics;
-            std::vector< Gdiplus::Graphics* >       maGraphics;
-
-            // the modifiedColorPrimitive stack
-            basegfx::BColorModifierStack            maBColorModifierStack;
-
-            // the current transformation. Since VCL pixel renderer transforms to pixels
-            // and VCL MetaFile renderer to World (logic) coordinates, the local
-            // ViewInformation2D cannot directly be used, but needs to be kept up to date
-            basegfx::B2DHomMatrix                   maCurrentTransformation;
-
-            // SvtOptionsDrawinglayer incarnation to react on diverse settings
-            const SvtOptionsDrawinglayer            maDrawinglayerOpt;
-
-        protected:
-            //////////////////////////////////////////////////////////////////////////////
-            // tooling
-            void pushGraphics(Gdiplus::Graphics& rNew);
-            void popGraphics();
             Gdiplus::Graphics& getGraphics() const { OSL_ENSURE(0 != mpGraphics, "0 == mpGraphics (!)"); return *mpGraphics; }
 
             // access to transformation stack

Modified: openoffice/branches/alg/sysdepgs/main/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/alg/sysdepgs/main/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx?rev=1480354&r1=1480353&r2=1480354&view=diff
==============================================================================
--- openoffice/branches/alg/sysdepgs/main/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx (original)
+++ openoffice/branches/alg/sysdepgs/main/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx Wed May  8 17:00:00 2013
@@ -93,10 +93,19 @@ namespace drawinglayer
 		VclPixelProcessor2D::~VclPixelProcessor2D()
 		{
             // restore MapMode
-   			getOutputDevice().Pop();
+            OutputDevice* pOriginalDevice = getInitialOutputDevice();
 
-            // restore AntiAliasing
-            getOutputDevice().SetAntialiasing(getOutputDevice().GetAntialiasing() & ~ANTIALIASING_ENABLE_B2DDRAW);
+            if(pOriginalDevice)
+            {
+                pOriginalDevice->Pop();
+
+                // restore AntiAliasing
+                pOriginalDevice->SetAntialiasing(getOutputDevice().GetAntialiasing() & ~ANTIALIASING_ENABLE_B2DDRAW);
+            }
+            else
+            {
+                OSL_ENSURE(false, "OOps, no initial OutputDevice (!)");
+            }
 		}
 
 		void VclPixelProcessor2D::processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate)

Modified: openoffice/branches/alg/sysdepgs/main/drawinglayer/source/processor2d/win_pixelprocessor2d.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/alg/sysdepgs/main/drawinglayer/source/processor2d/win_pixelprocessor2d.cxx?rev=1480354&r1=1480353&r2=1480354&view=diff
==============================================================================
--- openoffice/branches/alg/sysdepgs/main/drawinglayer/source/processor2d/win_pixelprocessor2d.cxx (original)
+++ openoffice/branches/alg/sysdepgs/main/drawinglayer/source/processor2d/win_pixelprocessor2d.cxx Wed May  8 17:00:00 2013
@@ -68,6 +68,20 @@ namespace
 
         rGraphics.SetTransform(&aMatrix);
     }
+
+    bool isVisible(Gdiplus::Graphics& rGraphics, const basegfx::B2DRange& rRange)
+    {
+        if(rRange.isEmpty())
+        {
+            return false;
+        }
+
+        return rGraphics.IsVisible(
+            Gdiplus::REAL(rRange.getMinX()),
+            Gdiplus::REAL(rRange.getMinY()),
+            Gdiplus::REAL(rRange.getWidth()),
+            Gdiplus::REAL(rRange.getHeight()));
+    }
 } // end of anonymous namespace
 
 //////////////////////////////////////////////////////////////////////////////
@@ -82,7 +96,6 @@ namespace drawinglayer
         :   BaseProcessor2D(rViewInformation),
             mrOutDev(rOutDev),
             mpGraphics(0),
-            maGraphics(),
             maBColorModifierStack(),
             maCurrentTransformation(),
             maDrawinglayerOpt()
@@ -126,17 +139,14 @@ namespace drawinglayer
 
             // create Gdiplus::Graphics entry for new OutputDevice
             SystemGraphicsData aSystemGraphicsData(mrOutDev.GetSystemGfxData());
-            Gdiplus::Graphics* pGraphics = new Gdiplus::Graphics(aSystemGraphicsData.hDC);
-
-            pushGraphics(*pGraphics);
+            mpGraphics = new Gdiplus::Graphics(aSystemGraphicsData.hDC);
             setAntialiasing(getGraphics(), getOptionsDrawinglayer().IsAntiAliasing());
             setMatrix(getGraphics(), getCurrentTransformation());
         }
 
         Win_PixelProcessor2D::~Win_PixelProcessor2D()
         {
-            popGraphics();
-            OSL_ENSURE(maGraphics.empty(), "Mismatch in push/popGraphics (!)");
+            delete mpGraphics;
 
             // restore MapMode
             mrOutDev.Pop();
@@ -145,26 +155,6 @@ namespace drawinglayer
             mrOutDev.SetAntialiasing(mrOutDev.GetAntialiasing() & ~ANTIALIASING_ENABLE_B2DDRAW);
         }
 
-        void Win_PixelProcessor2D::pushGraphics(Gdiplus::Graphics& rNew)
-        {
-            maGraphics.push_back(&rNew);
-            mpGraphics = &rNew;
-        }
-
-        void Win_PixelProcessor2D::popGraphics()
-        {
-            if(maGraphics.empty())
-            {
-                OSL_ENSURE(false, "OOps, push/popGraphics mismatch (!)");
-            }
-            else
-            {
-                delete mpGraphics;
-                mpGraphics = maGraphics.back();
-                maGraphics.pop_back();
-            }
-        }
-
         void Win_PixelProcessor2D::processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate)
         {
             switch(rCandidate.getPrimitive2DID())
@@ -177,35 +167,40 @@ namespace drawinglayer
 
                     if(!rBitmapEx.IsEmpty())
                     {
-                        const boost::shared_ptr< Gdiplus::Bitmap > aBitmap(getBufferedGdiPlusBitmapFromBitmapEx(rBitmapEx));
+                        const basegfx::B2DRange aRange(rBitmapPrimitive2D.getB2DRange(getViewInformation2D()));
 
-                        if(aBitmap.get())
+                        if(isVisible(getGraphics(), aRange))
                         {
-                            const basegfx::B2DHomMatrix aCurrent(getCurrentTransformation() * rBitmapPrimitive2D.getTransform());
-                            Gdiplus::PointF aDestPoints[3];
-                            Gdiplus::ImageAttributes aAttributes;
-
-                            setMatrix(getGraphics(), aCurrent);
-                            aDestPoints[0].X = Gdiplus::REAL(0.0);
-                            aDestPoints[0].Y = Gdiplus::REAL(0.0);
-                            aDestPoints[1].X = Gdiplus::REAL(1.0);
-                            aDestPoints[1].Y = Gdiplus::REAL(0.0);
-                            aDestPoints[2].X = Gdiplus::REAL(0.0);
-                            aDestPoints[2].Y = Gdiplus::REAL(1.0);
-                            aAttributes.SetWrapMode(Gdiplus::WrapModeTileFlipXY);
-                            getGraphics().DrawImage(
-                                aBitmap.get(), 
-                                aDestPoints, 
-                                3,
-                                Gdiplus::REAL(0.0),
-                                Gdiplus::REAL(0.0),
-                                Gdiplus::REAL(aBitmap->GetWidth()),
-                                Gdiplus::REAL(aBitmap->GetHeight()),
-                                Gdiplus::UnitPixel,
-                                &aAttributes,
-                                0,
-                                0);
-                            setMatrix(getGraphics(), getCurrentTransformation());
+                            const boost::shared_ptr< Gdiplus::Bitmap > aBitmap(getBufferedGdiPlusBitmapFromBitmapEx(rBitmapEx));
+
+                            if(aBitmap.get())
+                            {
+                                const basegfx::B2DHomMatrix aCurrent(getCurrentTransformation() * rBitmapPrimitive2D.getTransform());
+                                Gdiplus::PointF aDestPoints[3];
+                                Gdiplus::ImageAttributes aAttributes;
+
+                                setMatrix(getGraphics(), aCurrent);
+                                aDestPoints[0].X = Gdiplus::REAL(0.0);
+                                aDestPoints[0].Y = Gdiplus::REAL(0.0);
+                                aDestPoints[1].X = Gdiplus::REAL(1.0);
+                                aDestPoints[1].Y = Gdiplus::REAL(0.0);
+                                aDestPoints[2].X = Gdiplus::REAL(0.0);
+                                aDestPoints[2].Y = Gdiplus::REAL(1.0);
+                                aAttributes.SetWrapMode(Gdiplus::WrapModeTileFlipXY);
+                                getGraphics().DrawImage(
+                                    aBitmap.get(), 
+                                    aDestPoints, 
+                                    3,
+                                    Gdiplus::REAL(0.0),
+                                    Gdiplus::REAL(0.0),
+                                    Gdiplus::REAL(aBitmap->GetWidth()),
+                                    Gdiplus::REAL(aBitmap->GetHeight()),
+                                    Gdiplus::UnitPixel,
+                                    &aAttributes,
+                                    0,
+                                    0);
+                                setMatrix(getGraphics(), getCurrentTransformation());
+                            }
                         }
                     }
 
@@ -214,6 +209,12 @@ namespace drawinglayer
                 case PRIMITIVE2D_ID_POINTARRAYPRIMITIVE2D:
                 {
                     const primitive2d::PointArrayPrimitive2D& rPointArrayPrimitive2D = static_cast< const primitive2d::PointArrayPrimitive2D& >(rCandidate);
+                    const basegfx::B2DRange aRange(rPointArrayPrimitive2D.getB2DRange(getViewInformation2D()));
+
+                    if(isVisible(getGraphics(), aRange))
+                    {
+                    }
+
                     break;
                 }
                 case PRIMITIVE2D_ID_POLYGONHAIRLINEPRIMITIVE2D:
@@ -223,15 +224,20 @@ namespace drawinglayer
 
                     if(rPolygon.count())
                     {
-                        const boost::shared_ptr< Gdiplus::GraphicsPath > aPath(getBufferedGdiPlusGraphicsPathFromB2DPolygon(rPolygon));
+                        const basegfx::B2DRange aRange(rPolygonHairlinePrimitive2D.getB2DRange(getViewInformation2D()));
 
-                        if(aPath.get())
+                        if(isVisible(getGraphics(), aRange))
                         {
-                            const basegfx::BColor aBColor(getBColorModifierStack().getModifiedColor(rPolygonHairlinePrimitive2D.getBColor()));
-                            const Gdiplus::Color aColor(BYTE(aBColor.getRed() * 255.0), BYTE(aBColor.getGreen() * 255.0), BYTE(aBColor.getBlue() * 255.0));
-                            const Gdiplus::Pen aPen(aColor, 1.0);
+                            const boost::shared_ptr< Gdiplus::GraphicsPath > aPath(getBufferedGdiPlusGraphicsPathFromB2DPolygon(rPolygon));
 
-                            getGraphics().DrawPath(&aPen, aPath.get());
+                            if(aPath.get())
+                            {
+                                const basegfx::BColor aBColor(getBColorModifierStack().getModifiedColor(rPolygonHairlinePrimitive2D.getBColor()));
+                                const Gdiplus::Color aColor(BYTE(aBColor.getRed() * 255.0), BYTE(aBColor.getGreen() * 255.0), BYTE(aBColor.getBlue() * 255.0));
+                                const Gdiplus::Pen aPen(aColor, 1.0);
+
+                                getGraphics().DrawPath(&aPen, aPath.get());
+                            }
                         }
                     }
 
@@ -244,15 +250,20 @@ namespace drawinglayer
 
                     if(rPolyPolygon.count())
                     {
-                        const boost::shared_ptr< Gdiplus::GraphicsPath > aPath(getBufferedGdiPlusGraphicsPathFromB2DPolyPolygon(rPolyPolygon));
+                        const basegfx::B2DRange aRange(rPolyPolygonColorPrimitive2D.getB2DRange(getViewInformation2D()));
 
-                        if(aPath.get())
+                        if(isVisible(getGraphics(), aRange))
                         {
-                            const basegfx::BColor aBColor(getBColorModifierStack().getModifiedColor(rPolyPolygonColorPrimitive2D.getBColor()));
-                            const Gdiplus::Color aColor(BYTE(aBColor.getRed() * 255.0), BYTE(aBColor.getGreen() * 255.0), BYTE(aBColor.getBlue() * 255.0));
-                            const Gdiplus::SolidBrush aBrush(aColor);
+                            const boost::shared_ptr< Gdiplus::GraphicsPath > aPath(getBufferedGdiPlusGraphicsPathFromB2DPolyPolygon(rPolyPolygon));
+
+                            if(aPath.get())
+                            {
+                                const basegfx::BColor aBColor(getBColorModifierStack().getModifiedColor(rPolyPolygonColorPrimitive2D.getBColor()));
+                                const Gdiplus::Color aColor(BYTE(aBColor.getRed() * 255.0), BYTE(aBColor.getGreen() * 255.0), BYTE(aBColor.getBlue() * 255.0));
+                                const Gdiplus::SolidBrush aBrush(aColor);
 
-                            getGraphics().FillPath(&aBrush, aPath.get());
+                                getGraphics().FillPath(&aBrush, aPath.get());
+                            }
                         }
                     }
                     break;
@@ -262,16 +273,218 @@ namespace drawinglayer
                 case PRIMITIVE2D_ID_TRANSPARENCEPRIMITIVE2D:
                 {
                     const primitive2d::TransparencePrimitive2D& rTransparencePrimitive2D = static_cast< const primitive2d::TransparencePrimitive2D& >(rCandidate);
+
+                    if(rTransparencePrimitive2D.getTransparence().hasElements())
+                    {
+                        basegfx::B2DRange aRange(rTransparencePrimitive2D.getB2DRange(getViewInformation2D()));
+
+                        if(isVisible(getGraphics(), aRange))
+                        {
+                            const sal_uInt32 nFullWidth(mrOutDev.GetOutputSizePixel().Width());
+                            const sal_uInt32 nFullHeight(mrOutDev.GetOutputSizePixel().Height());
+
+                            aRange.transform(getCurrentTransformation());
+                            aRange.intersect(basegfx::B2DRange(0.0, 0.0, nFullWidth, nFullHeight));
+
+                            if(!aRange.isEmpty())
+                            {
+                                // prepare bitmap and graphics for child content
+                                const sal_uInt32 nLeft(floor(aRange.getMinX()));
+                                const sal_uInt32 nTop(floor(aRange.getMinY()));
+                                const sal_uInt32 nRight(ceil(aRange.getMaxX()));
+                                const sal_uInt32 nBottom(ceil(aRange.getMaxY()));
+                                const sal_uInt32 nWidth(nRight - nLeft);
+                                const sal_uInt32 nHeight(nBottom - nTop);
+                                Gdiplus::Bitmap aBitmap(nWidth, nHeight, PixelFormat32bppRGB);
+                                Gdiplus::Graphics aBitmapGraphics(&aBitmap);
+
+                                // create new transformation
+                                const basegfx::B2DHomMatrix aLastCurrentTransformation(getCurrentTransformation());
+                                basegfx::B2DHomMatrix aNewTransformation(aLastCurrentTransformation);
+                                aNewTransformation.translate(nLeft * -1.0, nTop * -1.0);
+                                setCurrentTransformation(aNewTransformation);
+
+                                // set clipping, AntiAliasing and transformation
+                                aBitmapGraphics.SetClip(&getGraphics(), Gdiplus::CombineModeReplace);
+                                setAntialiasing(aBitmapGraphics, getOptionsDrawinglayer().IsAntiAliasing());
+                                setMatrix(aBitmapGraphics, getCurrentTransformation());
+
+                                // make the Bitmap the graphics target
+                                Gdiplus::Graphics* pOriginal = mpGraphics;
+                                mpGraphics = &aBitmapGraphics;
+
+                                // do process children
+                                process(rTransparencePrimitive2D.getChildren());
+
+                                // restore last target
+                                mpGraphics = pOriginal;
+
+                                // create bitmap and graphics for alpha
+                                Gdiplus::Bitmap aAlphaBitmap(nWidth, nHeight, PixelFormat32bppRGB);
+                                Gdiplus::Graphics aAlphaBitmapGraphics(&aAlphaBitmap);
+
+                                // set clipping, AntiAliasing and transformation
+                                aAlphaBitmapGraphics.SetClip(&getGraphics(), Gdiplus::CombineModeReplace);
+                                setAntialiasing(aAlphaBitmapGraphics, getOptionsDrawinglayer().IsAntiAliasing());
+                                setMatrix(aAlphaBitmapGraphics, getCurrentTransformation());
+                                
+                                // make the Bitmap the graphics target
+                                mpGraphics = &aAlphaBitmapGraphics;
+
+                                // activate gray mode
+                                //const basegfx::BColorModifier aGrayModifier(
+                                //    basegfx::BColor(), 
+                                //    0.5, 
+                                //    basegfx::BCOLORMODIFYMODE_GRAY);
+                                //getBColorModifierStack().push(aGrayModifier);
+
+                                // do process children
+                                process(rTransparencePrimitive2D.getTransparence());
+
+                                // deactivate gray mode
+                                //getBColorModifierStack().pop();
+
+                                // restore last target
+                                mpGraphics = pOriginal;
+
+                                // restore transformations
+                                setCurrentTransformation(aLastCurrentTransformation);
+
+                                if(false)
+                                {
+                                    // flush to ensure results
+                                    aBitmapGraphics.Flush(Gdiplus::FlushIntentionSync);
+                                    aAlphaBitmapGraphics.Flush(Gdiplus::FlushIntentionSync);
+
+                                    // copy aAlphaBitmap content as alpha to aBitmapGraphics
+                                    Gdiplus::ImageAttributes aImageAttributes;
+                                    const Gdiplus::REAL aWeight(1.0f / 3.0f);
+                                    const Gdiplus::ColorMatrix colorMatrix = {
+                                       0.0f, 0.0f, 0.0f, aWeight, 0.0f,
+                                       0.0f, 0.0f, 0.0f, aWeight, 0.0f,
+                                       0.0f, 0.0f, 0.0f, aWeight, 0.0f,
+                                       0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
+                                       0.0f, 0.0f, 0.0f, 0.0f, 1.0f};
+
+                                    aImageAttributes.SetColorMatrix(
+                                        &colorMatrix,
+                                        Gdiplus::ColorMatrixFlagsDefault,
+                                        Gdiplus::ColorAdjustTypeDefault);
+                                    setMatrix(aBitmapGraphics, basegfx::B2DHomMatrix());
+                                    aBitmapGraphics.SetCompositingMode(Gdiplus::CompositingModeSourceCopy);
+                                    aBitmapGraphics.DrawImage(
+                                        &aAlphaBitmap,
+                                        Gdiplus::Rect(0, 0, nWidth, nHeight),
+                                        0, 0, nWidth, nHeight,
+                                        Gdiplus::UnitPixel,
+                                        &aImageAttributes);
+                                }
+                                else
+                                {
+                                    // mix aAlphaBitmap's colors as alpha channel to aBitmap
+                                    Gdiplus::Color aColor;
+                                    Gdiplus::Color aAlphaColor;
+                                    static bool bDoCopy(true);
+                                    
+                                    if(bDoCopy)
+                                    {
+                                        for(INT y(0); y < nHeight; y++)
+                                        {
+                                            for(INT x(0); x < nWidth; x++)
+                                            {
+                                                aBitmap.GetPixel(x, y, &aColor);
+                                                //const sal_uInt16 aAlphaA(aColor.GetAlpha());
+                                                //
+                                                //if(aAlphaA)
+                                                //{
+                                                    aAlphaBitmap.GetPixel(x, y, &aAlphaColor);
+                                                    sal_uInt16 aAlpha((
+                                                        (aAlphaColor.GetRed() * 77) + 
+                                                        (aAlphaColor.GetGreen() * 151) + 
+                                                        (aAlphaColor.GetBlue() * 28)) >> 8);
+
+                                                //    if(0xff != aAlphaA)
+                                                //    {
+                                                //        aAlpha = 256 - (((256 - aAlpha) * (256 - aAlphaA)) >> 8);
+                                                //    }
+
+                                                    aBitmap.SetPixel(
+                                                        x, 
+                                                        y, 
+                                                        Gdiplus::Color(
+                                                            aAlpha, 
+                                                            aColor.GetRed(), 
+                                                            aColor.GetGreen(), 
+                                                            aColor.GetBlue()));
+                                                //}
+                                            }
+                                        }
+                                    }
+                                }
+
+                                // copy content
+                                setMatrix(getGraphics(), basegfx::B2DHomMatrix());
+                                getGraphics().DrawImage(
+                                    &aBitmap, 
+                                    INT(nLeft), 
+                                    INT(nTop), 
+                                    INT(aBitmap.GetWidth()), 
+                                    INT(aBitmap.GetHeight()));
+                                setMatrix(getGraphics(), getCurrentTransformation());
+                            }
+                        }
+                    }
+
                     break;
                 }
                 case PRIMITIVE2D_ID_INVERTPRIMITIVE2D:
                 {
                     const primitive2d::InvertPrimitive2D& rInvertPrimitive2D = static_cast< const primitive2d::InvertPrimitive2D& >(rCandidate);
+                    basegfx::B2DRange aRange(rInvertPrimitive2D.getB2DRange(getViewInformation2D()));
+
+                    if(isVisible(getGraphics(), aRange))
+                    {
+                        aRange.transform(getCurrentTransformation());
+                    }
+
                     break;
                 }
                 case PRIMITIVE2D_ID_MASKPRIMITIVE2D:
                 {
                     const primitive2d::MaskPrimitive2D& rMaskPrimitive2D = static_cast< const primitive2d::MaskPrimitive2D& >(rCandidate);
+
+                    if(rMaskPrimitive2D.getChildren().hasElements())
+                    {
+                        const basegfx::B2DPolyPolygon& rMask = rMaskPrimitive2D.getMask();
+
+                        if(rMask.count())
+                        {
+                            const basegfx::B2DRange aRange(rMaskPrimitive2D.getB2DRange(getViewInformation2D()));
+
+                            if(isVisible(getGraphics(), aRange))
+                            {
+                                const boost::shared_ptr< Gdiplus::GraphicsPath > aMaskPath(getBufferedGdiPlusGraphicsPathFromB2DPolyPolygon(rMask));
+
+                                if(aMaskPath.get())
+                                {
+                                    // save current clip region
+                                    const Gdiplus::GraphicsState aState = getGraphics().Save();
+
+                                    // add clip to current
+                                    getGraphics().SetClip(
+                                        aMaskPath.get(),
+                                        Gdiplus::CombineModeIntersect);
+
+                                    // do process children
+                                    process(rMaskPrimitive2D.getChildren());
+
+                                    // restore clip region
+                                    getGraphics().Restore(aState);
+                                }
+                            }
+                        }
+                    }
+
                     break;
                 }
                 case PRIMITIVE2D_ID_MODIFIEDCOLORPRIMITIVE2D:

Modified: openoffice/branches/alg/sysdepgs/main/vcl/inc/win/gdiplusobjectbuffer.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/alg/sysdepgs/main/vcl/inc/win/gdiplusobjectbuffer.hxx?rev=1480354&r1=1480353&r2=1480354&view=diff
==============================================================================
--- openoffice/branches/alg/sysdepgs/main/vcl/inc/win/gdiplusobjectbuffer.hxx (original)
+++ openoffice/branches/alg/sysdepgs/main/vcl/inc/win/gdiplusobjectbuffer.hxx Wed May  8 17:00:00 2013
@@ -44,9 +44,11 @@ namespace basegfx
 class WinSalBitmap;
 
 //////////////////////////////////////////////////////////////////////////////
-// Helper class to manage Gdiplus::Bitmap instances created from WinSalBitmap
+// Helper class to manage Gdiplus::Bitmap instances created from WinSalBitmap,
+// and Gdiplus::GraphicsPath instances created from basegfx::B2DPolygon or
+// basegfx::B2DPolyPolygon
 
-class GdiPlusObjectBuffer : public basegfx::cache::cmanager, public Timer
+class GdiPlusObjectBuffer : public basegfx::cache::manager, public Timer
 {
 private:
 protected:

Modified: openoffice/branches/alg/sysdepgs/main/vcl/win/source/gdi/salgdi_gdiplus.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/alg/sysdepgs/main/vcl/win/source/gdi/salgdi_gdiplus.cxx?rev=1480354&r1=1480353&r2=1480354&view=diff
==============================================================================
--- openoffice/branches/alg/sysdepgs/main/vcl/win/source/gdi/salgdi_gdiplus.cxx (original)
+++ openoffice/branches/alg/sysdepgs/main/vcl/win/source/gdi/salgdi_gdiplus.cxx Wed May  8 17:00:00 2013
@@ -59,13 +59,15 @@
 #include <impbmp.hxx>
 
 //////////////////////////////////////////////////////////////////////////////
-
+// cached entry for a Gdiplus::Bitmap which may be constructed from a single
+// WinSalBitmap or two (when transparence is used). This class should only
+// be used by GdiPlusObjectBuffer
 class GdiPlusBitmapBufferNode : public basegfx::cache::node
 {
 private:
     boost::shared_ptr< Gdiplus::Bitmap >       maGdiPlusBitmapPtr;
 
-protected:
+    // conversion helpers
     Gdiplus::Bitmap* createGdiPlusBitmap(const WinSalBitmap& rBitmapSource);
     Gdiplus::Bitmap* createGdiPlusBitmap(const WinSalBitmap& rBitmapSource, const WinSalBitmap& rAlphaSource);
 
@@ -80,13 +82,15 @@ public:
 };
 
 //////////////////////////////////////////////////////////////////////////////
-
+// cached entry for Gdiplus::GraphicsPath which may be constructed from a
+// basegfx::B2DPolyPolygon or basegfx::B2DPolygon. This class should only
+// be used by GdiPlusObjectBuffer
 class GdiPlusGraphicsPathBufferNode : public basegfx::cache::node
 {
 private:
     boost::shared_ptr< Gdiplus::GraphicsPath >       maGdiPlusGraphicsPathPtr;
 
-protected:
+    // conversion helpers
     Gdiplus::GraphicsPath* createGdiPlusGraphicsPath(const basegfx::B2DPolygon& rSource);
     Gdiplus::GraphicsPath* createGdiPlusGraphicsPath(const basegfx::B2DPolyPolygon& rSource);
 
@@ -105,7 +109,7 @@ public:
 //////////////////////////////////////////////////////////////////////////////
 
 GdiPlusObjectBuffer::GdiPlusObjectBuffer()
-:   basegfx::cache::cmanager(30), // keep for 30 seconds
+:   basegfx::cache::manager(30), // keep for 30 lifetime rounds
     Timer()
 {
     SetTimeout(1000); // one second
@@ -198,7 +202,10 @@ void GdiPlusObjectBuffer::onFilled()
 
 void GdiPlusObjectBuffer::Timeout()
 {
-    trigger();
+    if(!empty())
+    {
+        trigger();
+    }
 
     if(!empty())
     {