LCOV - code coverage report
Current view: top level - drawinglayer/source/processor2d - vclpixelprocessor2d.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 416 491 84.7 %
Date: 2014-11-03 Functions: 13 13 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "vclpixelprocessor2d.hxx"
      21             : #include <vcl/outdev.hxx>
      22             : #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
      23             : #include <drawinglayer/primitive2d/textprimitive2d.hxx>
      24             : #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
      25             : #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
      26             : #include <drawinglayer/primitive2d/bitmapprimitive2d.hxx>
      27             : #include <drawinglayer/primitive2d/fillgraphicprimitive2d.hxx>
      28             : #include <drawinglayer/primitive2d/metafileprimitive2d.hxx>
      29             : #include <drawinglayer/primitive2d/maskprimitive2d.hxx>
      30             : #include <drawinglayer/primitive2d/modifiedcolorprimitive2d.hxx>
      31             : #include <drawinglayer/primitive2d/transparenceprimitive2d.hxx>
      32             : #include <drawinglayer/primitive2d/transformprimitive2d.hxx>
      33             : #include <drawinglayer/primitive2d/markerarrayprimitive2d.hxx>
      34             : #include <drawinglayer/primitive2d/pointarrayprimitive2d.hxx>
      35             : #include <drawinglayer/primitive2d/wrongspellprimitive2d.hxx>
      36             : #include <drawinglayer/primitive2d/controlprimitive2d.hxx>
      37             : #include <drawinglayer/primitive2d/borderlineprimitive2d.hxx>
      38             : #include <com/sun/star/awt/XWindow2.hpp>
      39             : #include <drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx>
      40             : #include <drawinglayer/primitive2d/pagepreviewprimitive2d.hxx>
      41             : #include <helperwrongspellrenderer.hxx>
      42             : #include <drawinglayer/primitive2d/fillhatchprimitive2d.hxx>
      43             : #include <basegfx/polygon/b2dpolygontools.hxx>
      44             : #include <vcl/hatch.hxx>
      45             : #include <tools/diagnose_ex.h>
      46             : #include <com/sun/star/awt/PosSize.hpp>
      47             : #include <drawinglayer/primitive2d/invertprimitive2d.hxx>
      48             : #include <cstdio>
      49             : #include <drawinglayer/primitive2d/backgroundcolorprimitive2d.hxx>
      50             : #include <basegfx/matrix/b2dhommatrixtools.hxx>
      51             : #include <drawinglayer/primitive2d/epsprimitive2d.hxx>
      52             : #include <drawinglayer/primitive2d/svggradientprimitive2d.hxx>
      53             : #include <toolkit/helper/vclunohelper.hxx>
      54             : #include <vcl/window.hxx>
      55             : #include <svtools/borderhelper.hxx>
      56             : 
      57             : #include <com/sun/star/table/BorderLineStyle.hpp>
      58             : 
      59             : 
      60             : 
      61             : using namespace com::sun::star;
      62             : 
      63             : namespace {
      64             : 
      65       31271 : basegfx::B2DPolygon makeRectPolygon( double fX, double fY, double fW, double fH )
      66             : {
      67       31271 :     basegfx::B2DPolygon aPoly;
      68       31271 :     aPoly.append(basegfx::B2DPoint(fX, fY));
      69       31271 :     aPoly.append(basegfx::B2DPoint(fX+fW, fY));
      70       31271 :     aPoly.append(basegfx::B2DPoint(fX+fW, fY+fH));
      71       31271 :     aPoly.append(basegfx::B2DPoint(fX, fY+fH));
      72       31271 :     aPoly.setClosed(true);
      73       31271 :     return aPoly;
      74             : }
      75             : 
      76       16761 : void drawHairLine(
      77             :     OutputDevice* pOutDev, double fX1, double fY1, double fX2, double fY2,
      78             :     const basegfx::BColor& rColor )
      79             : {
      80       16761 :     basegfx::B2DPolygon aTarget;
      81       16761 :     aTarget.append(basegfx::B2DPoint(fX1, fY1));
      82       16761 :     aTarget.append(basegfx::B2DPoint(fX2, fY2));
      83             : 
      84       16761 :     pOutDev->SetFillColor();
      85       16761 :     pOutDev->SetLineColor(Color(rColor));
      86       16761 :     pOutDev->DrawPolyLine(aTarget);
      87       16761 : }
      88             : 
      89             : }
      90             : 
      91             : namespace drawinglayer
      92             : {
      93             :     namespace processor2d
      94             :     {
      95             :         struct VclPixelProcessor2D::Impl
      96             :         {
      97             :             sal_uInt16 m_nOrigAntiAliasing;
      98             : 
      99       48166 :             explicit Impl(OutputDevice const& rOutDev)
     100       48166 :                 : m_nOrigAntiAliasing(rOutDev.GetAntialiasing())
     101       48166 :             { }
     102             :         };
     103             : 
     104       48166 :         VclPixelProcessor2D::VclPixelProcessor2D(const geometry::ViewInformation2D& rViewInformation, OutputDevice& rOutDev)
     105             :             :   VclProcessor2D(rViewInformation, rOutDev)
     106       48166 :             ,   m_pImpl(new Impl(rOutDev))
     107             :         {
     108             :             // prepare maCurrentTransformation matrix with viewTransformation to target directly to pixels
     109       48166 :             maCurrentTransformation = rViewInformation.getObjectToViewTransformation();
     110             : 
     111             :             // prepare output directly to pixels
     112       48166 :                mpOutputDevice->Push(PushFlags::MAPMODE);
     113       48166 :             mpOutputDevice->SetMapMode();
     114             : 
     115             :             // react on AntiAliasing settings
     116       48166 :             if(getOptionsDrawinglayer().IsAntiAliasing())
     117             :             {
     118             :                 mpOutputDevice->SetAntialiasing(
     119           0 :                    m_pImpl->m_nOrigAntiAliasing | ANTIALIASING_ENABLE_B2DDRAW);
     120             :             }
     121             :             else
     122             :             {
     123             :                 mpOutputDevice->SetAntialiasing(
     124       48166 :                    m_pImpl->m_nOrigAntiAliasing & ~ANTIALIASING_ENABLE_B2DDRAW);
     125             :             }
     126       48166 :         }
     127             : 
     128      144498 :         VclPixelProcessor2D::~VclPixelProcessor2D()
     129             :         {
     130             :             // restore MapMode
     131       48166 :                mpOutputDevice->Pop();
     132             : 
     133             :             // restore AntiAliasing
     134       48166 :             mpOutputDevice->SetAntialiasing(m_pImpl->m_nOrigAntiAliasing);
     135       96332 :         }
     136             : 
     137      138212 :         bool VclPixelProcessor2D::tryDrawPolyPolygonColorPrimitive2DDirect(const drawinglayer::primitive2d::PolyPolygonColorPrimitive2D& rSource, double fTransparency)
     138             :         {
     139      138212 :             basegfx::B2DPolyPolygon aLocalPolyPolygon(rSource.getB2DPolyPolygon());
     140             : 
     141      138212 :             if(!aLocalPolyPolygon.count())
     142             :             {
     143             :                 // no geometry, done
     144           0 :                 return true;
     145             :             }
     146             : 
     147      276424 :             const basegfx::BColor aPolygonColor(maBColorModifierStack.getModifiedColor(rSource.getBColor()));
     148             : 
     149      138212 :             mpOutputDevice->SetFillColor(Color(aPolygonColor));
     150      138212 :             mpOutputDevice->SetLineColor();
     151      138212 :             aLocalPolyPolygon.transform(maCurrentTransformation);
     152             :             mpOutputDevice->DrawTransparent(
     153             :                 aLocalPolyPolygon,
     154      138212 :                 fTransparency);
     155             : 
     156      276424 :             return true;
     157             :         }
     158             : 
     159       91035 :         bool VclPixelProcessor2D::tryDrawPolygonHairlinePrimitive2DDirect(const drawinglayer::primitive2d::PolygonHairlinePrimitive2D& rSource, double fTransparency)
     160             :         {
     161       91035 :             basegfx::B2DPolygon aLocalPolygon(rSource.getB2DPolygon());
     162             : 
     163       91035 :             if(!aLocalPolygon.count())
     164             :             {
     165             :                 // no geometry, done
     166           0 :                 return true;
     167             :             }
     168             : 
     169      182070 :             const basegfx::BColor aLineColor(maBColorModifierStack.getModifiedColor(rSource.getBColor()));
     170             : 
     171       91035 :             mpOutputDevice->SetFillColor();
     172       91035 :             mpOutputDevice->SetLineColor(Color(aLineColor));
     173       91035 :             aLocalPolygon.transform(maCurrentTransformation);
     174             : 
     175             :             // try drawing; if it did not work, use standard fallback
     176       91035 :             if(mpOutputDevice->DrawPolyLineDirect( aLocalPolygon, 0.0, fTransparency))
     177             :             {
     178           0 :                 return true;
     179             :             }
     180             : 
     181      182070 :             return false;
     182             :         }
     183             : 
     184       14965 :         bool VclPixelProcessor2D::tryDrawPolygonStrokePrimitive2DDirect(const drawinglayer::primitive2d::PolygonStrokePrimitive2D& rSource, double fTransparency)
     185             :         {
     186       14965 :             basegfx::B2DPolygon aLocalPolygon(rSource.getB2DPolygon());
     187             : 
     188       14965 :             if(!aLocalPolygon.count())
     189             :             {
     190             :                 // no geometry, done
     191           0 :                 return true;
     192             :             }
     193             : 
     194       14965 :             aLocalPolygon = basegfx::tools::simplifyCurveSegments(aLocalPolygon);
     195       29930 :             basegfx::B2DPolyPolygon aHairLinePolyPolygon;
     196             : 
     197       14965 :             if(rSource.getStrokeAttribute().isDefault() || 0.0 == rSource.getStrokeAttribute().getFullDotDashLen())
     198             :             {
     199             :                 // no line dashing, just copy
     200       13430 :                 aHairLinePolyPolygon.append(aLocalPolygon);
     201             :             }
     202             :             else
     203             :             {
     204             :                 // apply LineStyle
     205             :                 basegfx::tools::applyLineDashing(
     206             :                     aLocalPolygon,
     207        1535 :                     rSource.getStrokeAttribute().getDotDashArray(),
     208             :                     &aHairLinePolyPolygon,
     209             :                     0,
     210        3070 :                     rSource.getStrokeAttribute().getFullDotDashLen());
     211             :             }
     212             : 
     213       14965 :             if(!aHairLinePolyPolygon.count())
     214             :             {
     215             :                 // no geometry, done
     216          24 :                 return true;
     217             :             }
     218             : 
     219             :             const basegfx::BColor aLineColor(
     220             :                 maBColorModifierStack.getModifiedColor(
     221       29882 :                     rSource.getLineAttribute().getColor()));
     222             : 
     223       14941 :             mpOutputDevice->SetFillColor();
     224       14941 :             mpOutputDevice->SetLineColor(Color(aLineColor));
     225       14941 :             aHairLinePolyPolygon.transform(maCurrentTransformation);
     226             : 
     227       14941 :             double fLineWidth(rSource.getLineAttribute().getWidth());
     228             : 
     229       14941 :             if(basegfx::fTools::more(fLineWidth, 0.0))
     230             :             {
     231        4496 :                 basegfx::B2DVector aLineWidth(fLineWidth, 0.0);
     232             : 
     233        4496 :                 aLineWidth = maCurrentTransformation * aLineWidth;
     234        4496 :                 fLineWidth = aLineWidth.getLength();
     235             :             }
     236             : 
     237             :             // draw simple hairline for small line widths
     238             :             // see also RenderPolygonStrokePrimitive2D which is used if this try fails
     239       14941 :             bool bIsAntiAliasing = getOptionsDrawinglayer().IsAntiAliasing();
     240       70562 :             if (   (basegfx::fTools::lessOrEqual(fLineWidth, 1.0) && bIsAntiAliasing)
     241       74705 :                 || (basegfx::fTools::lessOrEqual(fLineWidth, 1.5) && !bIsAntiAliasing))
     242             :             {
     243             :                 // draw simple hairline
     244       11256 :                 fLineWidth = 0.0;
     245             :             }
     246             : 
     247       14941 :             bool bHasPoints(false);
     248       14941 :             bool bTryWorked(false);
     249             : 
     250       93875 :             for(sal_uInt32 a(0); a < aHairLinePolyPolygon.count(); a++)
     251             :             {
     252       78934 :                 const basegfx::B2DPolygon aSingle(aHairLinePolyPolygon.getB2DPolygon(a));
     253             : 
     254       78934 :                 if(aSingle.count())
     255             :                 {
     256       78934 :                     bHasPoints = true;
     257             : 
     258       78934 :                     if(mpOutputDevice->DrawPolyLineDirect(
     259             :                         aSingle,
     260             :                         fLineWidth,
     261             :                         fTransparency,
     262       78934 :                         rSource.getLineAttribute().getLineJoin(),
     263      157868 :                         rSource.getLineAttribute().getLineCap()))
     264             :                     {
     265           0 :                         bTryWorked = true;
     266             :                     }
     267             :                 }
     268       78934 :             }
     269             : 
     270       14941 :             if(!bTryWorked && !bHasPoints)
     271             :             {
     272             :                 // no geometry despite try
     273           0 :                 bTryWorked = true;
     274             :             }
     275             : 
     276       29906 :             return bTryWorked;
     277             :         }
     278             : 
     279       17843 :         bool VclPixelProcessor2D::tryDrawBorderLinePrimitive2DDirect(
     280             :             const drawinglayer::primitive2d::BorderLinePrimitive2D& rSource)
     281             :         {
     282       17843 :             const basegfx::B2DPoint& rS = rSource.getStart();
     283       17843 :             const basegfx::B2DPoint& rE = rSource.getEnd();
     284             : 
     285       17843 :             double fX1 = rS.getX();
     286       17843 :             double fY1 = rS.getY();
     287       17843 :             double fX2 = rE.getX();
     288       17843 :             double fY2 = rE.getY();
     289             : 
     290       17843 :             bool bHorizontal = false;
     291       17843 :             if (fX1 == fX2)
     292             :             {
     293             :                 // Vertical line.
     294             :             }
     295        9453 :             else if (fY1 == fY2)
     296             :             {
     297             :                 // Horizontal line.
     298        9453 :                 bHorizontal = true;
     299             :             }
     300             :             else
     301             :                 // Neither.  Bail out.
     302           0 :                 return false;
     303             : 
     304       17843 :             switch (rSource.getStyle())
     305             :             {
     306             :                 case table::BorderLineStyle::SOLID:
     307             :                 case table::BorderLineStyle::DOUBLE_THIN:
     308             :                 {
     309             :                     const basegfx::BColor aLineColor =
     310       17589 :                         maBColorModifierStack.getModifiedColor(rSource.getRGBColorLeft());
     311       17589 :                     double nThick = rtl::math::round(rSource.getLeftWidth());
     312             : 
     313       17589 :                     bool bDouble = rSource.getStyle() == table::BorderLineStyle::DOUBLE_THIN;
     314             : 
     315       35178 :                     basegfx::B2DPolygon aTarget;
     316             : 
     317       17589 :                     if (bHorizontal)
     318             :                     {
     319             :                         // Horizontal line.  Draw it as a rectangle.
     320             : 
     321        9293 :                         aTarget = makeRectPolygon(fX1, fY1, fX2-fX1, nThick);
     322        9293 :                         aTarget.transform(maCurrentTransformation);
     323             : 
     324        9293 :                         basegfx::B2DRange aRange = aTarget.getB2DRange();
     325        9293 :                         double fH = aRange.getHeight();
     326             : 
     327        9293 :                         if (bDouble)
     328             :                         {
     329             :                             // Double line
     330             :                             drawHairLine(
     331          80 :                                 mpOutputDevice, aRange.getMinX(), aRange.getMinY()-1.0, aRange.getMaxX(), aRange.getMinY()-1.0,
     332          80 :                                 aLineColor);
     333             : 
     334             :                             drawHairLine(
     335          80 :                                 mpOutputDevice, aRange.getMinX(), aRange.getMinY()+1.0, aRange.getMaxX(), aRange.getMinY()+1.0,
     336          80 :                                 aLineColor);
     337             : 
     338        8901 :                             return true;
     339             :                         }
     340             : 
     341        9253 :                         if (fH <= 1.0)
     342             :                         {
     343             :                             // Draw it as a line.
     344             :                             drawHairLine(
     345             :                                 mpOutputDevice, aRange.getMinX(), aRange.getMinY(), aRange.getMaxX(), aRange.getMinY(),
     346        8821 :                                 aLineColor);
     347             : 
     348        8821 :                             return true;
     349             :                         }
     350             : 
     351         432 :                         double fOffset = rtl::math::round(fH/2.0, 0, rtl_math_RoundingMode_Down);
     352         432 :                         if (fOffset != 0.0)
     353             :                         {
     354             :                             // Move it up a bit to align it vertically centered.
     355         276 :                             basegfx::B2DHomMatrix aMat;
     356         276 :                             aMat.set(1, 2, -fOffset);
     357         276 :                             aTarget.transform(aMat);
     358             :                         }
     359             :                     }
     360             :                     else
     361             :                     {
     362             :                         // Vertical line.  Draw it as a rectangle.
     363             : 
     364        8296 :                         aTarget = makeRectPolygon(fX1, fY1, nThick, fY2-fY1);
     365        8296 :                         aTarget.transform(maCurrentTransformation);
     366             : 
     367        8296 :                         basegfx::B2DRange aRange = aTarget.getB2DRange();
     368        8296 :                         double fW = aRange.getWidth();
     369             : 
     370        8296 :                         if (bDouble)
     371             :                         {
     372             :                             // Draw it as a line.
     373             :                             drawHairLine(
     374          80 :                                 mpOutputDevice, aRange.getMinX()-1.0, aRange.getMinY(), aRange.getMinX()-1.0, aRange.getMaxY(),
     375         120 :                                 aLineColor);
     376             : 
     377             :                             drawHairLine(
     378          80 :                                 mpOutputDevice, aRange.getMinX()+1.0, aRange.getMinY(), aRange.getMinX()+1.0, aRange.getMaxY(),
     379         120 :                                 aLineColor);
     380             : 
     381        7860 :                             return true;
     382             :                         }
     383             : 
     384        8256 :                         if (fW <= 1.0)
     385             :                         {
     386             :                             // Draw it as a line.
     387             :                             drawHairLine(
     388             :                                 mpOutputDevice, aRange.getMinX(), aRange.getMinY(), aRange.getMinX(), aRange.getMaxY(),
     389        7780 :                                 aLineColor);
     390             : 
     391        7780 :                             return true;
     392             :                         }
     393             : 
     394         476 :                         double fOffset = rtl::math::round(fW/2.0, 0, rtl_math_RoundingMode_Down);
     395         476 :                         if (fOffset != 0.0)
     396             :                         {
     397             :                             // Move it to the left a bit to center it horizontally.
     398         304 :                             basegfx::B2DHomMatrix aMat;
     399         304 :                             aMat.set(0, 2, -fOffset);
     400         304 :                             aTarget.transform(aMat);
     401             :                         }
     402             :                     }
     403             : 
     404         908 :                     mpOutputDevice->SetFillColor(Color(aLineColor));
     405         908 :                     mpOutputDevice->SetLineColor();
     406         908 :                     mpOutputDevice->DrawPolygon(aTarget);
     407       18497 :                     return true;
     408             :                 }
     409             :                 break;
     410             :                 case table::BorderLineStyle::DOTTED:
     411             :                 case table::BorderLineStyle::DASHED:
     412             :                 case table::BorderLineStyle::DASH_DOT:
     413             :                 case table::BorderLineStyle::DASH_DOT_DOT:
     414             :                 case table::BorderLineStyle::FINE_DASHED:
     415             :                 {
     416             :                     std::vector<double> aPattern =
     417         158 :                         svtools::GetLineDashing(rSource.getStyle(), rSource.getPatternScale()*10.0);
     418             : 
     419         158 :                     if (aPattern.empty())
     420             :                         // Failed to get pattern values.
     421           0 :                         return false;
     422             : 
     423         158 :                     double nThick = rtl::math::round(rSource.getLeftWidth());
     424             : 
     425             :                     const basegfx::BColor aLineColor =
     426         316 :                         maBColorModifierStack.getModifiedColor(rSource.getRGBColorLeft());
     427             : 
     428             :                     // Transform the current line range before using it for rendering.
     429         158 :                     basegfx::B2DRange aRange(fX1, fY1, fX2, fY2);
     430         158 :                     aRange.transform(maCurrentTransformation);
     431         158 :                     fX1 = aRange.getMinX();
     432         158 :                     fX2 = aRange.getMaxX();
     433         158 :                     fY1 = aRange.getMinY();
     434         158 :                     fY2 = aRange.getMaxY();
     435             : 
     436         316 :                     basegfx::B2DPolyPolygon aTarget;
     437             : 
     438         158 :                     if (bHorizontal)
     439             :                     {
     440             :                         // Horizontal line.
     441             : 
     442         108 :                         if (basegfx::fTools::equalZero(nThick))
     443             :                         {
     444             :                             // Dash line segment too small to draw.  Substitute it with a solid line.
     445           0 :                             drawHairLine(mpOutputDevice, fX1, fY1, fX2, fY1, aLineColor);
     446           0 :                             return true;
     447             :                         }
     448             : 
     449             :                         // Create a dash unit polygon set.
     450         108 :                         basegfx::B2DPolyPolygon aDashes;
     451         108 :                         std::vector<double>::const_iterator it = aPattern.begin(), itEnd = aPattern.end();
     452         324 :                         for (; it != itEnd; ++it)
     453         216 :                             aDashes.append(makeRectPolygon(0, 0, *it, nThick));
     454             : 
     455         108 :                         aDashes.transform(maCurrentTransformation);
     456         108 :                         rtl::math::setNan(&nThick);
     457             : 
     458             :                         // Pixelize the dash unit.  We use the same height for
     459             :                         // all dash polygons.
     460         216 :                         basegfx::B2DPolyPolygon aDashesPix;
     461             : 
     462         324 :                         for (sal_uInt32 i = 0, n = aDashes.count(); i < n; ++i)
     463             :                         {
     464         216 :                             basegfx::B2DPolygon aPoly = aDashes.getB2DPolygon(i);
     465         216 :                             aRange = aPoly.getB2DRange();
     466         216 :                             double fW = rtl::math::round(aRange.getWidth());
     467         216 :                             if (basegfx::fTools::equalZero(fW))
     468             :                             {
     469             :                                 // Dash line segment too small to draw.  Substitute it with a solid line.
     470           0 :                                 drawHairLine(mpOutputDevice, fX1, fY1, fX2, fY1, aLineColor);
     471           0 :                                 return true;
     472             :                             }
     473             : 
     474         216 :                             if (rtl::math::isNan(nThick))
     475         108 :                                 nThick = rtl::math::round(aRange.getHeight());
     476             : 
     477         216 :                             aDashesPix.append(makeRectPolygon(0, 0, fW, nThick));
     478         216 :                         }
     479             : 
     480             :                         // Make all dash polygons and render them.
     481         108 :                         double fX = fX1;
     482         108 :                         bool bLine = true;
     483         108 :                         sal_uInt32 i = 0, n = aDashesPix.count();
     484       25118 :                         while (fX <= fX2)
     485             :                         {
     486       24902 :                             basegfx::B2DPolygon aPoly = aDashesPix.getB2DPolygon(i);
     487       24902 :                             aRange = aPoly.getB2DRange();
     488       24902 :                             if (bLine)
     489             :                             {
     490       12494 :                                 double fBlockW = aRange.getWidth();
     491       12494 :                                 if (fX + fBlockW > fX2)
     492             :                                     // Clip the right end in case it spills over the range.
     493          86 :                                     fBlockW = fX2 - fX + 1;
     494             : 
     495       12494 :                                 double fH = aRange.getHeight();
     496       12494 :                                 if (basegfx::fTools::equalZero(fH))
     497         128 :                                     fH = 1.0;
     498             : 
     499       12494 :                                 aTarget.append(makeRectPolygon(fX, fY1, fBlockW, fH));
     500             :                             }
     501             : 
     502       24902 :                             bLine = !bLine; // line and blank alternate.
     503       24902 :                             fX += aRange.getWidth();
     504             : 
     505       24902 :                             ++i;
     506       24902 :                             if (i >= n)
     507       12408 :                                 i = 0;
     508       24902 :                         }
     509             : 
     510         108 :                         double fOffset = rtl::math::round(nThick/2.0, 0, rtl_math_RoundingMode_Down);
     511         108 :                         if (fOffset != 0.0)
     512             :                         {
     513             :                             // Move it up a bit to align it vertically centered.
     514          82 :                             basegfx::B2DHomMatrix aMat;
     515          82 :                             aMat.set(1, 2, -fOffset);
     516          82 :                             aTarget.transform(aMat);
     517         108 :                         }
     518             :                     }
     519             :                     else
     520             :                     {
     521             :                         // Vertical line.
     522             : 
     523          50 :                         if (basegfx::fTools::equalZero(nThick))
     524             :                         {
     525             :                             // Dash line segment too small to draw.  Substitute it with a solid line.
     526           0 :                             drawHairLine(mpOutputDevice, fX1, fY1, fX1, fY2, aLineColor);
     527           0 :                             return true;
     528             :                         }
     529             : 
     530             :                         // Create a dash unit polygon set.
     531          50 :                         basegfx::B2DPolyPolygon aDashes;
     532          50 :                         std::vector<double>::const_iterator it = aPattern.begin(), itEnd = aPattern.end();
     533         150 :                         for (; it != itEnd; ++it)
     534         100 :                             aDashes.append(makeRectPolygon(0, 0, nThick, *it));
     535             : 
     536          50 :                         aDashes.transform(maCurrentTransformation);
     537          50 :                         rtl::math::setNan(&nThick);
     538             : 
     539             :                         // Pixelize the dash unit.  We use the same width for
     540             :                         // all dash polygons.
     541         100 :                         basegfx::B2DPolyPolygon aDashesPix;
     542             : 
     543         150 :                         for (sal_uInt32 i = 0, n = aDashes.count(); i < n; ++i)
     544             :                         {
     545         100 :                             basegfx::B2DPolygon aPoly = aDashes.getB2DPolygon(i);
     546         100 :                             aRange = aPoly.getB2DRange();
     547         100 :                             double fH = rtl::math::round(aRange.getHeight());
     548         100 :                             if (basegfx::fTools::equalZero(fH))
     549             :                             {
     550             :                                 // Dash line segment too small to draw.  Substitute it with a solid line.
     551           0 :                                 drawHairLine(mpOutputDevice, fX1, fY1, fX1, fY2, aLineColor);
     552           0 :                                 return true;
     553             :                             }
     554             : 
     555         100 :                             if (rtl::math::isNan(nThick))
     556          50 :                                 nThick = rtl::math::round(aRange.getWidth());
     557             : 
     558         100 :                             aDashesPix.append(makeRectPolygon(0, 0, nThick, fH));
     559         100 :                         }
     560             : 
     561             :                         // Make all dash polygons and render them.
     562          50 :                         double fY = fY1;
     563          50 :                         bool bLine = true;
     564          50 :                         sal_uInt32 i = 0, n = aDashesPix.count();
     565        1188 :                         while (fY <= fY2)
     566             :                         {
     567        1088 :                             basegfx::B2DPolygon aPoly = aDashesPix.getB2DPolygon(i);
     568        1088 :                             aRange = aPoly.getB2DRange();
     569        1088 :                             if (bLine)
     570             :                             {
     571         556 :                                 double fBlockH = aRange.getHeight();
     572         556 :                                 if (fY + fBlockH > fY2)
     573             :                                     // Clip the bottom end in case it spills over the range.
     574          24 :                                     fBlockH = fY2 - fY + 1;
     575             : 
     576         556 :                                 double fW = aRange.getWidth();
     577         556 :                                 if (basegfx::fTools::equalZero(fW))
     578           0 :                                     fW = 1.0;
     579             : 
     580         556 :                                 aTarget.append(makeRectPolygon(fX1, fY, fW, fBlockH));
     581             :                             }
     582             : 
     583        1088 :                             bLine = !bLine; // line and blank alternate.
     584        1088 :                             fY += aRange.getHeight();
     585             : 
     586        1088 :                             ++i;
     587        1088 :                             if (i >= n)
     588         532 :                                 i = 0;
     589        1088 :                         }
     590             : 
     591          50 :                         double fOffset = rtl::math::round(nThick/2.0, 0, rtl_math_RoundingMode_Down);
     592          50 :                         if (fOffset != 0.0)
     593             :                         {
     594             :                             // Move it to the left a bit to center it horizontally.
     595          40 :                             basegfx::B2DHomMatrix aMat;
     596          40 :                             aMat.set(0, 2, -fOffset);
     597          40 :                             aTarget.transform(aMat);
     598          50 :                         }
     599             :                     }
     600             : 
     601         158 :                     mpOutputDevice->SetFillColor(Color(aLineColor));
     602         158 :                     mpOutputDevice->SetLineColor();
     603         158 :                     mpOutputDevice->DrawPolyPolygon(aTarget);
     604             : 
     605         316 :                     return true;
     606             :                 }
     607             :                 break;
     608             :                 default:
     609             :                     ;
     610             :             }
     611          96 :             return false;
     612             :         }
     613             : 
     614      391779 :         void VclPixelProcessor2D::processBasePrimitive2D(const primitive2d::BasePrimitive2D& rCandidate)
     615             :         {
     616      391779 :             switch(rCandidate.getPrimitive2DID())
     617             :             {
     618             :                 case PRIMITIVE2D_ID_WRONGSPELLPRIMITIVE2D :
     619             :                 {
     620             :                     // directdraw of wrong spell primitive; added test possibility to check wrong spell decompose
     621             :                     static bool bHandleWrongSpellDirectly(true);
     622             : 
     623           0 :                     if(bHandleWrongSpellDirectly)
     624             :                     {
     625           0 :                         const primitive2d::WrongSpellPrimitive2D& rWrongSpellPrimitive = static_cast< const primitive2d::WrongSpellPrimitive2D& >(rCandidate);
     626             : 
     627           0 :                         if(!renderWrongSpellPrimitive2D(
     628             :                             rWrongSpellPrimitive,
     629             :                             *mpOutputDevice,
     630             :                             maCurrentTransformation,
     631           0 :                             maBColorModifierStack))
     632             :                         {
     633             :                             // fallback to decomposition (MetaFile)
     634           0 :                             process(rWrongSpellPrimitive.get2DDecomposition(getViewInformation2D()));
     635             :                         }
     636             :                     }
     637             :                     else
     638             :                     {
     639           0 :                         process(rCandidate.get2DDecomposition(getViewInformation2D()));
     640             :                     }
     641           0 :                     break;
     642             :                 }
     643             :                 case PRIMITIVE2D_ID_TEXTSIMPLEPORTIONPRIMITIVE2D :
     644             :                 {
     645             :                     // directdraw of text simple portion; added test possibility to check text decompose
     646             :                     static bool bForceSimpleTextDecomposition(false);
     647             : 
     648             :                     // Adapt evtl. used special DrawMode
     649        7756 :                     const sal_uInt32 nOriginalDrawMode(mpOutputDevice->GetDrawMode());
     650        7756 :                     adaptTextToFillDrawMode();
     651             : 
     652        7756 :                     if(!bForceSimpleTextDecomposition && getOptionsDrawinglayer().IsRenderSimpleTextDirect())
     653             :                     {
     654        7756 :                         RenderTextSimpleOrDecoratedPortionPrimitive2D(static_cast< const primitive2d::TextSimplePortionPrimitive2D& >(rCandidate));
     655             :                     }
     656             :                     else
     657             :                     {
     658           0 :                         process(rCandidate.get2DDecomposition(getViewInformation2D()));
     659             :                     }
     660             : 
     661             :                     // restore DrawMode
     662        7756 :                     mpOutputDevice->SetDrawMode(nOriginalDrawMode);
     663             : 
     664        7756 :                     break;
     665             :                 }
     666             :                 case PRIMITIVE2D_ID_TEXTDECORATEDPORTIONPRIMITIVE2D :
     667             :                 {
     668             :                     // directdraw of decorated text portion; added test possibility to check text decompose
     669             :                     static bool bForceComplexTextDecomposition(false);
     670             : 
     671             :                     // Adapt evtl. used special DrawMode
     672        1061 :                     const sal_uInt32 nOriginalDrawMode(mpOutputDevice->GetDrawMode());
     673        1061 :                     adaptTextToFillDrawMode();
     674             : 
     675        1061 :                     if(!bForceComplexTextDecomposition && getOptionsDrawinglayer().IsRenderDecoratedTextDirect())
     676             :                     {
     677        1061 :                         RenderTextSimpleOrDecoratedPortionPrimitive2D(static_cast< const primitive2d::TextSimplePortionPrimitive2D& >(rCandidate));
     678             :                     }
     679             :                     else
     680             :                     {
     681           0 :                         process(rCandidate.get2DDecomposition(getViewInformation2D()));
     682             :                     }
     683             : 
     684             :                     // restore DrawMode
     685        1061 :                     mpOutputDevice->SetDrawMode(nOriginalDrawMode);
     686             : 
     687        1061 :                     break;
     688             :                 }
     689             :                 case PRIMITIVE2D_ID_POLYGONHAIRLINEPRIMITIVE2D :
     690             :                 {
     691             :                     // try to use directly
     692       91035 :                     const primitive2d::PolygonHairlinePrimitive2D& rPolygonHairlinePrimitive2D = static_cast< const primitive2d::PolygonHairlinePrimitive2D& >(rCandidate);
     693             :                     static bool bAllowed(true);
     694             : 
     695       91035 :                     if(bAllowed && tryDrawPolygonHairlinePrimitive2DDirect(rPolygonHairlinePrimitive2D, 0.0))
     696             :                     {
     697           0 :                         break;
     698             :                     }
     699             : 
     700             :                     // direct draw of hairline
     701       91035 :                     RenderPolygonHairlinePrimitive2D(rPolygonHairlinePrimitive2D, true);
     702       91035 :                     break;
     703             :                 }
     704             :                 case PRIMITIVE2D_ID_BITMAPPRIMITIVE2D :
     705             :                 {
     706             :                     // direct draw of transformed BitmapEx primitive
     707        4752 :                     const primitive2d::BitmapPrimitive2D& rBitmapCandidate = static_cast< const primitive2d::BitmapPrimitive2D& >(rCandidate);
     708             : 
     709             :                     // check if graphic content is inside discrete local ViewPort
     710        4752 :                     const basegfx::B2DRange& rDiscreteViewPort(getViewInformation2D().getDiscreteViewport());
     711        4752 :                     const basegfx::B2DHomMatrix aLocalTransform(maCurrentTransformation * rBitmapCandidate.getTransform());
     712             : 
     713        4752 :                     if(!rDiscreteViewPort.isEmpty())
     714             :                     {
     715        4358 :                         basegfx::B2DRange aUnitRange(0.0, 0.0, 1.0, 1.0);
     716             : 
     717        4358 :                         aUnitRange.transform(aLocalTransform);
     718             : 
     719        4358 :                         if(!aUnitRange.overlaps(rDiscreteViewPort))
     720             :                         {
     721             :                             // content is outside discrete local ViewPort
     722        1454 :                             break;
     723             :                         }
     724             :                     }
     725             : 
     726        3298 :                     RenderBitmapPrimitive2D(static_cast< const primitive2d::BitmapPrimitive2D& >(rCandidate));
     727        3298 :                     break;
     728             :                 }
     729             :                 case PRIMITIVE2D_ID_FILLGRAPHICPRIMITIVE2D :
     730             :                 {
     731             :                     // direct draw of fillBitmapPrimitive
     732          86 :                     RenderFillGraphicPrimitive2D(static_cast< const primitive2d::FillGraphicPrimitive2D& >(rCandidate));
     733          86 :                     break;
     734             :                 }
     735             :                 case PRIMITIVE2D_ID_POLYPOLYGONGRADIENTPRIMITIVE2D :
     736             :                 {
     737             :                     // direct draw of gradient
     738          54 :                     const primitive2d::PolyPolygonGradientPrimitive2D& rPolygonCandidate = static_cast< const primitive2d::PolyPolygonGradientPrimitive2D& >(rCandidate);
     739          54 :                     const attribute::FillGradientAttribute& rGradient(rPolygonCandidate.getFillGradient());
     740          54 :                     basegfx::BColor aStartColor(maBColorModifierStack.getModifiedColor(rGradient.getStartColor()));
     741         108 :                     basegfx::BColor aEndColor(maBColorModifierStack.getModifiedColor(rGradient.getEndColor()));
     742         108 :                     basegfx::B2DPolyPolygon aLocalPolyPolygon(rPolygonCandidate.getB2DPolyPolygon());
     743             : 
     744          54 :                     if(aLocalPolyPolygon.count())
     745             :                     {
     746          54 :                         aLocalPolyPolygon.transform(maCurrentTransformation);
     747             : 
     748          54 :                         if(aStartColor == aEndColor)
     749             :                         {
     750             :                             // no gradient at all, draw as polygon in AA and non-AA case
     751           0 :                             mpOutputDevice->SetLineColor();
     752           0 :                             mpOutputDevice->SetFillColor(Color(aStartColor));
     753           0 :                             mpOutputDevice->DrawPolyPolygon(aLocalPolyPolygon);
     754             :                         }
     755             :                         else
     756             :                         {
     757             :                             // use the primitive decomposition of the metafile
     758          54 :                             process(rPolygonCandidate.get2DDecomposition(getViewInformation2D()));
     759             :                         }
     760             :                     }
     761         108 :                     break;
     762             :                 }
     763             :                 case PRIMITIVE2D_ID_POLYPOLYGONGRAPHICPRIMITIVE2D :
     764             :                 {
     765             :                     // direct draw of bitmap
     766          86 :                     RenderPolyPolygonGraphicPrimitive2D(static_cast< const primitive2d::PolyPolygonGraphicPrimitive2D& >(rCandidate));
     767          86 :                     break;
     768             :                 }
     769             :                 case PRIMITIVE2D_ID_POLYPOLYGONCOLORPRIMITIVE2D :
     770             :                 {
     771             :                     // try to use directly
     772      137452 :                     const primitive2d::PolyPolygonColorPrimitive2D& rPolyPolygonColorPrimitive2D = static_cast< const primitive2d::PolyPolygonColorPrimitive2D& >(rCandidate);
     773      137452 :                     basegfx::B2DPolyPolygon aLocalPolyPolygon;
     774             :                     static bool bAllowed(true);
     775             : 
     776      137452 :                     if(bAllowed && tryDrawPolyPolygonColorPrimitive2DDirect(rPolyPolygonColorPrimitive2D, 0.0))
     777             :                     {
     778             :                         // okay, done. In this case no gaps should have to be repaired, too
     779             :                     }
     780             :                     else
     781             :                     {
     782             :                         // direct draw of tools::PolyPolygon with color
     783           0 :                         const basegfx::BColor aPolygonColor(maBColorModifierStack.getModifiedColor(rPolyPolygonColorPrimitive2D.getBColor()));
     784             : 
     785           0 :                         mpOutputDevice->SetFillColor(Color(aPolygonColor));
     786           0 :                         mpOutputDevice->SetLineColor();
     787           0 :                         aLocalPolyPolygon = rPolyPolygonColorPrimitive2D.getB2DPolyPolygon();
     788           0 :                         aLocalPolyPolygon.transform(maCurrentTransformation);
     789           0 :                         mpOutputDevice->DrawPolyPolygon(aLocalPolyPolygon);
     790             :                     }
     791             : 
     792             :                     // when AA is on and this filled polygons are the result of stroked line geometry,
     793             :                     // draw the geometry once extra as lines to avoid AA 'gaps' between partial polygons
     794             :                     // Caution: This is needed in both cases (!)
     795      137452 :                     if(mnPolygonStrokePrimitive2D
     796       53386 :                         && getOptionsDrawinglayer().IsAntiAliasing()
     797      137452 :                         && (mpOutputDevice->GetAntialiasing() & ANTIALIASING_ENABLE_B2DDRAW))
     798             :                     {
     799           0 :                         const basegfx::BColor aPolygonColor(maBColorModifierStack.getModifiedColor(rPolyPolygonColorPrimitive2D.getBColor()));
     800           0 :                         sal_uInt32 nCount(aLocalPolyPolygon.count());
     801             : 
     802           0 :                         if(!nCount)
     803             :                         {
     804           0 :                             aLocalPolyPolygon = rPolyPolygonColorPrimitive2D.getB2DPolyPolygon();
     805           0 :                             aLocalPolyPolygon.transform(maCurrentTransformation);
     806           0 :                             nCount = aLocalPolyPolygon.count();
     807             :                         }
     808             : 
     809           0 :                         mpOutputDevice->SetFillColor();
     810           0 :                         mpOutputDevice->SetLineColor(Color(aPolygonColor));
     811             : 
     812           0 :                         for(sal_uInt32 a(0); a < nCount; a++)
     813             :                         {
     814           0 :                             mpOutputDevice->DrawPolyLine(aLocalPolyPolygon.getB2DPolygon(a), 0.0);
     815           0 :                         }
     816             :                     }
     817             : 
     818      137452 :                     break;
     819             :                 }
     820             :                 case PRIMITIVE2D_ID_METAFILEPRIMITIVE2D :
     821             :                 {
     822             :                     // #i98289#
     823          76 :                     const bool bForceLineSnap(getOptionsDrawinglayer().IsAntiAliasing() && getOptionsDrawinglayer().IsSnapHorVerLinesToDiscrete());
     824          76 :                     const sal_uInt16 nOldAntiAliase(mpOutputDevice->GetAntialiasing());
     825             : 
     826          76 :                     if(bForceLineSnap)
     827             :                     {
     828           0 :                         mpOutputDevice->SetAntialiasing(nOldAntiAliase | ANTIALIASING_PIXELSNAPHAIRLINE);
     829             :                     }
     830             : 
     831          76 :                     const primitive2d::MetafilePrimitive2D& rMetafilePrimitive( static_cast< const primitive2d::MetafilePrimitive2D& >(rCandidate) );
     832             : 
     833             :                     static bool bTestMetaFilePrimitiveDecomposition( true );
     834          76 :                     if( bTestMetaFilePrimitiveDecomposition && !rMetafilePrimitive.getMetaFile().GetUseCanvas() )
     835             :                     {
     836             :                         // use new Metafile decomposition
     837             :                         // TODO EMF+ stuffed into METACOMMENT support required
     838          74 :                         process(rCandidate.get2DDecomposition(getViewInformation2D()));
     839             :                     }
     840             :                     else
     841             :                     {
     842             :                         // direct draw of MetaFile
     843           2 :                         RenderMetafilePrimitive2D( rMetafilePrimitive );
     844             :                     }
     845             : 
     846          76 :                     if(bForceLineSnap)
     847             :                     {
     848           0 :                         mpOutputDevice->SetAntialiasing(nOldAntiAliase);
     849             :                     }
     850             : 
     851          76 :                     break;
     852             :                 }
     853             :                 case PRIMITIVE2D_ID_MASKPRIMITIVE2D :
     854             :                 {
     855             :                     // mask group.
     856        3793 :                     RenderMaskPrimitive2DPixel(static_cast< const primitive2d::MaskPrimitive2D& >(rCandidate));
     857        3793 :                     break;
     858             :                 }
     859             :                 case PRIMITIVE2D_ID_MODIFIEDCOLORPRIMITIVE2D :
     860             :                 {
     861             :                     // modified color group. Force output to unified color.
     862         798 :                     RenderModifiedColorPrimitive2D(static_cast< const primitive2d::ModifiedColorPrimitive2D& >(rCandidate));
     863         798 :                     break;
     864             :                 }
     865             :                 case PRIMITIVE2D_ID_UNIFIEDTRANSPARENCEPRIMITIVE2D :
     866             :                 {
     867             :                     // Detect if a single PolyPolygonColorPrimitive2D is contained; in that case,
     868             :                     // use the faster OutputDevice::DrawTransparent method
     869        1445 :                     const primitive2d::UnifiedTransparencePrimitive2D& rUniTransparenceCandidate = static_cast< const primitive2d::UnifiedTransparencePrimitive2D& >(rCandidate);
     870        1445 :                     const primitive2d::Primitive2DSequence rContent = rUniTransparenceCandidate.getChildren();
     871             : 
     872        1445 :                     if(rContent.hasElements())
     873             :                     {
     874        1445 :                         if(0.0 == rUniTransparenceCandidate.getTransparence())
     875             :                         {
     876             :                             // not transparent at all, use content
     877           0 :                             process(rUniTransparenceCandidate.getChildren());
     878             :                         }
     879        1445 :                         else if(rUniTransparenceCandidate.getTransparence() > 0.0 && rUniTransparenceCandidate.getTransparence() < 1.0)
     880             :                         {
     881        1445 :                             bool bDrawTransparentUsed(false);
     882             : 
     883             :                             // since DEV300 m33 DrawTransparent is supported in VCL (for some targets
     884             :                             // natively), so i am now enabling this shortcut
     885             :                             static bool bAllowUsingDrawTransparent(true);
     886             : 
     887        1445 :                             if(bAllowUsingDrawTransparent && 1 == rContent.getLength())
     888             :                             {
     889        1379 :                                 const primitive2d::Primitive2DReference xReference(rContent[0]);
     890        1379 :                                 const primitive2d::BasePrimitive2D* pBasePrimitive = dynamic_cast< const primitive2d::BasePrimitive2D* >(xReference.get());
     891             : 
     892        1379 :                                 if(pBasePrimitive)
     893             :                                 {
     894        1379 :                                     switch(pBasePrimitive->getPrimitive2DID())
     895             :                                     {
     896             :                                         case PRIMITIVE2D_ID_POLYPOLYGONCOLORPRIMITIVE2D:
     897             :                                         {
     898             :                                             // single transparent tools::PolyPolygon identified, use directly
     899         760 :                                             const primitive2d::PolyPolygonColorPrimitive2D* pPoPoColor = static_cast< const primitive2d::PolyPolygonColorPrimitive2D* >(pBasePrimitive);
     900             :                                             OSL_ENSURE(pPoPoColor, "OOps, PrimitiveID and PrimitiveType do not match (!)");
     901         760 :                                             bDrawTransparentUsed = tryDrawPolyPolygonColorPrimitive2DDirect(*pPoPoColor, rUniTransparenceCandidate.getTransparence());
     902         760 :                                             break;
     903             :                                         }
     904             :                                         case PRIMITIVE2D_ID_POLYGONHAIRLINEPRIMITIVE2D:
     905             :                                         {
     906             :                                             // single transparent PolygonHairlinePrimitive2D identified, use directly
     907           0 :                                             const primitive2d::PolygonHairlinePrimitive2D* pPoHair = static_cast< const primitive2d::PolygonHairlinePrimitive2D* >(pBasePrimitive);
     908             :                                             OSL_ENSURE(pPoHair, "OOps, PrimitiveID and PrimitiveType do not match (!)");
     909             : 
     910             :                                             // do no tallow by default - problem is that self-overlapping parts of this geometry will
     911             :                                             // not be in a all-same transparency but will already alpha-cover themselves with blending.
     912             :                                             // This is not what the UnifiedTransparencePrimitive2D defines: It requires all its
     913             :                                             // content to be uniformely transparent.
     914             :                                             // For hairline the effect is pretty minimal, but still not correct.
     915             :                                             static bool bAllowed(false);
     916             : 
     917           0 :                                             bDrawTransparentUsed = bAllowed && tryDrawPolygonHairlinePrimitive2DDirect(*pPoHair, rUniTransparenceCandidate.getTransparence());
     918           0 :                                             break;
     919             :                                         }
     920             :                                         case PRIMITIVE2D_ID_POLYGONSTROKEPRIMITIVE2D:
     921             :                                         {
     922             :                                             // single transparent PolygonStrokePrimitive2D identified, use directly
     923          41 :                                             const primitive2d::PolygonStrokePrimitive2D* pPoStroke = static_cast< const primitive2d::PolygonStrokePrimitive2D* >(pBasePrimitive);
     924             :                                             OSL_ENSURE(pPoStroke, "OOps, PrimitiveID and PrimitiveType do not match (!)");
     925             : 
     926             :                                             // do no tallow by default - problem is that self-overlapping parts of this geometry will
     927             :                                             // not be in a all-same transparency but will already alpha-cover themselves with blending.
     928             :                                             // This is not what the UnifiedTransparencePrimitive2D defines: It requires all its
     929             :                                             // content to be uniformely transparent.
     930             :                                             // To check, acitvate and draw a wide transparent self-crossing line/curve
     931             :                                             static bool bAllowed(false);
     932             : 
     933          41 :                                             bDrawTransparentUsed = bAllowed && tryDrawPolygonStrokePrimitive2DDirect(*pPoStroke, rUniTransparenceCandidate.getTransparence());
     934          41 :                                             break;
     935             :                                         }
     936             :                                     default:
     937             :                                         SAL_INFO("drawinglayer", "default case for " << drawinglayer::primitive2d::idToString(rCandidate.getPrimitive2DID()));
     938         578 :                                         break;
     939             :                                     }
     940        1379 :                                 }
     941             :                             }
     942             : 
     943        1445 :                             if(!bDrawTransparentUsed)
     944             :                             {
     945             :                                 // unified sub-transparence. Draw to VDev first.
     946         685 :                                 RenderUnifiedTransparencePrimitive2D(rUniTransparenceCandidate);
     947             :                             }
     948             :                         }
     949             :                     }
     950             : 
     951        1445 :                     break;
     952             :                 }
     953             :                 case PRIMITIVE2D_ID_TRANSPARENCEPRIMITIVE2D :
     954             :                 {
     955             :                     // sub-transparence group. Draw to VDev first.
     956         748 :                     RenderTransparencePrimitive2D(static_cast< const primitive2d::TransparencePrimitive2D& >(rCandidate));
     957         748 :                     break;
     958             :                 }
     959             :                 case PRIMITIVE2D_ID_TRANSFORMPRIMITIVE2D :
     960             :                 {
     961             :                     // transform group.
     962        6736 :                     RenderTransformPrimitive2D(static_cast< const primitive2d::TransformPrimitive2D& >(rCandidate));
     963        6736 :                     break;
     964             :                 }
     965             :                 case PRIMITIVE2D_ID_PAGEPREVIEWPRIMITIVE2D :
     966             :                 {
     967             :                     // new XDrawPage for ViewInformation2D
     968           0 :                     RenderPagePreviewPrimitive2D(static_cast< const primitive2d::PagePreviewPrimitive2D& >(rCandidate));
     969           0 :                     break;
     970             :                 }
     971             :                 case PRIMITIVE2D_ID_MARKERARRAYPRIMITIVE2D :
     972             :                 {
     973             :                     // marker array
     974           0 :                     RenderMarkerArrayPrimitive2D(static_cast< const primitive2d::MarkerArrayPrimitive2D& >(rCandidate));
     975           0 :                     break;
     976             :                 }
     977             :                 case PRIMITIVE2D_ID_POINTARRAYPRIMITIVE2D :
     978             :                 {
     979             :                     // point array
     980           0 :                     RenderPointArrayPrimitive2D(static_cast< const primitive2d::PointArrayPrimitive2D& >(rCandidate));
     981           0 :                     break;
     982             :                 }
     983             :                 case PRIMITIVE2D_ID_CONTROLPRIMITIVE2D :
     984             :                 {
     985             :                     // control primitive
     986        4504 :                     const primitive2d::ControlPrimitive2D& rControlPrimitive = static_cast< const primitive2d::ControlPrimitive2D& >(rCandidate);
     987        4504 :                     const uno::Reference< awt::XControl >& rXControl(rControlPrimitive.getXControl());
     988             : 
     989             :                     try
     990             :                     {
     991             :                         // remember old graphics and create new
     992        4504 :                         uno::Reference< awt::XView > xControlView(rXControl, uno::UNO_QUERY_THROW);
     993        5888 :                         const uno::Reference< awt::XGraphics > xOriginalGraphics(xControlView->getGraphics());
     994        5888 :                         const uno::Reference< awt::XGraphics > xNewGraphics(mpOutputDevice->CreateUnoGraphics());
     995             : 
     996        2944 :                         if(xNewGraphics.is())
     997             :                         {
     998             :                             // link graphics and view
     999        2944 :                             xControlView->setGraphics(xNewGraphics);
    1000             : 
    1001             :                             // get position
    1002        2944 :                             const basegfx::B2DHomMatrix aObjectToPixel(maCurrentTransformation * rControlPrimitive.getTransform());
    1003        5888 :                             const basegfx::B2DPoint aTopLeftPixel(aObjectToPixel * basegfx::B2DPoint(0.0, 0.0));
    1004             : 
    1005             :                             // find out if the control is already visualized as a VCL-ChildWindow. If yes,
    1006             :                             // it does not need to be painted at all.
    1007        5888 :                             uno::Reference< awt::XWindow2 > xControlWindow(rXControl, uno::UNO_QUERY_THROW);
    1008        2944 :                             const bool bControlIsVisibleAsChildWindow(rXControl->getPeer().is() && xControlWindow->isVisible());
    1009             : 
    1010        2944 :                             if(!bControlIsVisibleAsChildWindow)
    1011             :                             {
    1012             :                                 // draw it. Do not forget to use the evtl. offsetted origin of the target device,
    1013             :                                 // e.g. when used with mask/transparence buffer device
    1014        2589 :                                 const Point aOrigin(mpOutputDevice->GetMapMode().GetOrigin());
    1015        2589 :                                 xControlView->draw(
    1016        5178 :                                     aOrigin.X() + basegfx::fround(aTopLeftPixel.getX()),
    1017        7767 :                                     aOrigin.Y() + basegfx::fround(aTopLeftPixel.getY()));
    1018             :                             }
    1019             : 
    1020             :                             // restore original graphics
    1021        5888 :                             xControlView->setGraphics(xOriginalGraphics);
    1022        2944 :                         }
    1023             :                     }
    1024        1560 :                     catch(const uno::Exception&)
    1025             :                     {
    1026             :                         // #i116763# removing since there is a good alternative when the xControlView
    1027             :                         // is not found and it is allowed to happen
    1028             :                         // DBG_UNHANDLED_EXCEPTION();
    1029             : 
    1030             :                         // process recursively and use the decomposition as Bitmap
    1031        1560 :                         process(rCandidate.get2DDecomposition(getViewInformation2D()));
    1032             :                     }
    1033             : 
    1034        4504 :                     break;
    1035             :                 }
    1036             :                 case PRIMITIVE2D_ID_POLYGONSTROKEPRIMITIVE2D:
    1037             :                 {
    1038             :                     // try to use directly
    1039       14965 :                     const primitive2d::PolygonStrokePrimitive2D& rPolygonStrokePrimitive2D = static_cast< const primitive2d::PolygonStrokePrimitive2D& >(rCandidate);
    1040             : 
    1041       14965 :                     if(tryDrawPolygonStrokePrimitive2DDirect(rPolygonStrokePrimitive2D, 0.0))
    1042             :                     {
    1043          24 :                         break;
    1044             :                     }
    1045             : 
    1046             :                     // the stroke primitive may be decomposed to filled polygons. To keep
    1047             :                     // evtl. set DrawModes aka DRAWMODE_BLACKLINE, DRAWMODE_GRAYLINE,
    1048             :                     // DRAWMODE_GHOSTEDLINE, DRAWMODE_WHITELINE or DRAWMODE_SETTINGSLINE
    1049             :                     // working, these need to be copied to the corresponding fill modes
    1050       14941 :                     const sal_uInt32 nOriginalDrawMode(mpOutputDevice->GetDrawMode());
    1051       14941 :                     adaptLineToFillDrawMode();
    1052             : 
    1053             :                     // polygon stroke primitive
    1054             :                     static bool bSuppressFatToHairlineCorrection(false);
    1055             : 
    1056       14941 :                     if(bSuppressFatToHairlineCorrection)
    1057             :                     {
    1058             :                         // remember that we enter a PolygonStrokePrimitive2D decomposition,
    1059             :                         // used for AA thick line drawing
    1060           0 :                         mnPolygonStrokePrimitive2D++;
    1061             : 
    1062             :                         // with AA there is no need to handle thin lines special
    1063           0 :                         process(rCandidate.get2DDecomposition(getViewInformation2D()));
    1064             : 
    1065             :                         // leave PolygonStrokePrimitive2D
    1066           0 :                         mnPolygonStrokePrimitive2D--;
    1067             :                     }
    1068             :                     else
    1069             :                     {
    1070             :                         // Lines with 1 and 2 pixel width without AA need special treatment since their vsiualisation
    1071             :                         // as filled polygons is geometrically corret but looks wrong since polygon filling avoids
    1072             :                         // the right and bottom pixels. The used method evaluates that and takes the correct action,
    1073             :                         // including calling recursively with decomposition if line is wide enough
    1074       14941 :                         RenderPolygonStrokePrimitive2D(rPolygonStrokePrimitive2D);
    1075             :                     }
    1076             : 
    1077             :                     // restore DrawMode
    1078       14941 :                     mpOutputDevice->SetDrawMode(nOriginalDrawMode);
    1079             : 
    1080       14941 :                     break;
    1081             :                 }
    1082             :                 case PRIMITIVE2D_ID_FILLHATCHPRIMITIVE2D :
    1083             :                 {
    1084             :                     static bool bForceIgnoreHatchSmoothing(false);
    1085             : 
    1086         164 :                     if(bForceIgnoreHatchSmoothing || getOptionsDrawinglayer().IsAntiAliasing())
    1087             :                     {
    1088             :                         // if AA is used (or ignore smoothing is on), there is no need to smooth
    1089             :                         // hatch painting, use decomposition
    1090           0 :                         process(rCandidate.get2DDecomposition(getViewInformation2D()));
    1091             :                     }
    1092             :                     else
    1093             :                     {
    1094             :                         // without AA, use VCL to draw the hatch. It snaps hatch distances to the next pixel
    1095             :                         // and forces hatch distance to be >= 3 pixels to make the hatch display look smoother.
    1096             :                         // This is wrong in principle, but looks nicer. This could also be done here directly
    1097             :                         // without VCL usage if needed
    1098         164 :                         const primitive2d::FillHatchPrimitive2D& rFillHatchPrimitive = static_cast< const primitive2d::FillHatchPrimitive2D& >(rCandidate);
    1099         164 :                         const attribute::FillHatchAttribute& rFillHatchAttributes = rFillHatchPrimitive.getFillHatch();
    1100             : 
    1101             :                         // create hatch polygon in range size and discrete coordinates
    1102         164 :                         basegfx::B2DRange aHatchRange(rFillHatchPrimitive.getOutputRange());
    1103         164 :                         aHatchRange.transform(maCurrentTransformation);
    1104         164 :                         const basegfx::B2DPolygon aHatchPolygon(basegfx::tools::createPolygonFromRect(aHatchRange));
    1105             : 
    1106         164 :                         if(rFillHatchAttributes.isFillBackground())
    1107             :                         {
    1108             :                             // #i111846# background fill is active; draw fill polygon
    1109           0 :                             const basegfx::BColor aPolygonColor(maBColorModifierStack.getModifiedColor(rFillHatchPrimitive.getBColor()));
    1110             : 
    1111           0 :                             mpOutputDevice->SetFillColor(Color(aPolygonColor));
    1112           0 :                             mpOutputDevice->SetLineColor();
    1113           0 :                             mpOutputDevice->DrawPolygon(aHatchPolygon);
    1114             :                         }
    1115             : 
    1116             :                         // set hatch line color
    1117         328 :                         const basegfx::BColor aHatchColor(maBColorModifierStack.getModifiedColor(rFillHatchPrimitive.getBColor()));
    1118         164 :                         mpOutputDevice->SetFillColor();
    1119         164 :                         mpOutputDevice->SetLineColor(Color(aHatchColor));
    1120             : 
    1121             :                         // get hatch style
    1122         164 :                         HatchStyle eHatchStyle(HATCH_SINGLE);
    1123             : 
    1124         164 :                         switch(rFillHatchAttributes.getStyle())
    1125             :                         {
    1126             :                             default : // HATCHSTYLE_SINGLE
    1127             :                             {
    1128         164 :                                 break;
    1129             :                             }
    1130             :                             case attribute::HATCHSTYLE_DOUBLE :
    1131             :                             {
    1132           0 :                                 eHatchStyle = HATCH_DOUBLE;
    1133           0 :                                 break;
    1134             :                             }
    1135             :                             case attribute::HATCHSTYLE_TRIPLE :
    1136             :                             {
    1137           0 :                                 eHatchStyle = HATCH_TRIPLE;
    1138           0 :                                 break;
    1139             :                             }
    1140             :                         }
    1141             : 
    1142             :                         // create hatch
    1143         164 :                         const basegfx::B2DVector aDiscreteDistance(maCurrentTransformation * basegfx::B2DVector(rFillHatchAttributes.getDistance(), 0.0));
    1144         164 :                         const sal_uInt32 nDistance(basegfx::fround(aDiscreteDistance.getLength()));
    1145         164 :                         const sal_uInt16 nAngle10((sal_uInt16)basegfx::fround(rFillHatchAttributes.getAngle() / F_PI1800));
    1146         328 :                         ::Hatch aVCLHatch(eHatchStyle, Color(rFillHatchAttributes.getColor()), nDistance, nAngle10);
    1147             : 
    1148             :                         // draw hatch using VCL
    1149         492 :                         mpOutputDevice->DrawHatch(tools::PolyPolygon(Polygon(aHatchPolygon)), aVCLHatch);
    1150             :                     }
    1151         164 :                     break;
    1152             :                 }
    1153             :                 case PRIMITIVE2D_ID_BACKGROUNDCOLORPRIMITIVE2D :
    1154             :                 {
    1155             :                     // #i98404# Handle directly, especially when AA is active
    1156         716 :                     const primitive2d::BackgroundColorPrimitive2D& rPrimitive = static_cast< const primitive2d::BackgroundColorPrimitive2D& >(rCandidate);
    1157         716 :                     const sal_uInt16 nOriginalAA(mpOutputDevice->GetAntialiasing());
    1158             : 
    1159             :                     // switch AA off in all cases
    1160         716 :                     mpOutputDevice->SetAntialiasing(mpOutputDevice->GetAntialiasing() & ~ANTIALIASING_ENABLE_B2DDRAW);
    1161             : 
    1162             :                     // create color for fill
    1163         716 :                     const basegfx::BColor aPolygonColor(maBColorModifierStack.getModifiedColor(rPrimitive.getBColor()));
    1164         716 :                     mpOutputDevice->SetFillColor(Color(aPolygonColor));
    1165         716 :                     mpOutputDevice->SetLineColor();
    1166             : 
    1167             :                     // create rectangle for fill
    1168         716 :                     const basegfx::B2DRange& aViewport(getViewInformation2D().getDiscreteViewport());
    1169             :                     const Rectangle aRectangle(
    1170        1432 :                         (sal_Int32)floor(aViewport.getMinX()), (sal_Int32)floor(aViewport.getMinY()),
    1171        2148 :                         (sal_Int32)ceil(aViewport.getMaxX()), (sal_Int32)ceil(aViewport.getMaxY()));
    1172         716 :                     mpOutputDevice->DrawRect(aRectangle);
    1173             : 
    1174             :                     // restore AA setting
    1175         716 :                     mpOutputDevice->SetAntialiasing(nOriginalAA);
    1176         716 :                     break;
    1177             :                 }
    1178             :                 case PRIMITIVE2D_ID_TEXTHIERARCHYEDITPRIMITIVE2D :
    1179             :                 {
    1180             :                     // #i97628#
    1181             :                     // This primitive means that the content is derived from an active text edit,
    1182             :                     // not from model data itself. Some renderers need to suppress this content, e.g.
    1183             :                     // the pixel renderer used for displaying the edit view (like this one). It's
    1184             :                     // not to be suppressed by the MetaFile renderers, so that the edited text is
    1185             :                     // part of the MetaFile, e.g. needed for presentation previews.
    1186             :                     // Action: Ignore here, do nothing.
    1187           0 :                     break;
    1188             :                 }
    1189             :                 case PRIMITIVE2D_ID_INVERTPRIMITIVE2D :
    1190             :                 {
    1191             :                     // invert primitive (currently only used for HighContrast fallback for selection in SW and SC).
    1192             :                     // Set OutDev to XOR and switch AA off (XOR does not work with AA)
    1193        4196 :                     mpOutputDevice->Push();
    1194        4196 :                     mpOutputDevice->SetRasterOp( ROP_XOR );
    1195        4196 :                     const sal_uInt16 nAntiAliasing(mpOutputDevice->GetAntialiasing());
    1196        4196 :                     mpOutputDevice->SetAntialiasing(nAntiAliasing & ~ANTIALIASING_ENABLE_B2DDRAW);
    1197             : 
    1198             :                     // process content recursively
    1199        4196 :                     process(rCandidate.get2DDecomposition(getViewInformation2D()));
    1200             : 
    1201             :                     // restore OutDev
    1202        4196 :                     mpOutputDevice->Pop();
    1203        4196 :                     mpOutputDevice->SetAntialiasing(nAntiAliasing);
    1204        4196 :                     break;
    1205             :                 }
    1206             :                 case PRIMITIVE2D_ID_EPSPRIMITIVE2D :
    1207             :                 {
    1208           0 :                     RenderEpsPrimitive2D(static_cast< const primitive2d::EpsPrimitive2D& >(rCandidate));
    1209           0 :                     break;
    1210             :                 }
    1211             :                 case PRIMITIVE2D_ID_SVGLINEARATOMPRIMITIVE2D:
    1212             :                 {
    1213        6144 :                     RenderSvgLinearAtomPrimitive2D(static_cast< const primitive2d::SvgLinearAtomPrimitive2D& >(rCandidate));
    1214        6144 :                     break;
    1215             :                 }
    1216             :                 case PRIMITIVE2D_ID_SVGRADIALATOMPRIMITIVE2D:
    1217             :                 {
    1218         462 :                     RenderSvgRadialAtomPrimitive2D(static_cast< const primitive2d::SvgRadialAtomPrimitive2D& >(rCandidate));
    1219         462 :                     break;
    1220             :                 }
    1221             :                 case PRIMITIVE2D_ID_BORDERLINEPRIMITIVE2D:
    1222             :                 {
    1223             :                     // process recursively, but turn off anti-aliasing. Border
    1224             :                     // lines are always rectangular, and look horrible when
    1225             :                     // the anti-aliasing is enabled.
    1226       17843 :                     sal_uInt16 nAntiAliasing = mpOutputDevice->GetAntialiasing();
    1227       17843 :                     mpOutputDevice->SetAntialiasing(nAntiAliasing & ~ANTIALIASING_ENABLE_B2DDRAW);
    1228             : 
    1229             :                     const drawinglayer::primitive2d::BorderLinePrimitive2D& rBorder =
    1230       17843 :                         static_cast<const drawinglayer::primitive2d::BorderLinePrimitive2D&>(rCandidate);
    1231             : 
    1232       17843 :                     if (!tryDrawBorderLinePrimitive2DDirect(rBorder))
    1233          96 :                         process(rCandidate.get2DDecomposition(getViewInformation2D()));
    1234             : 
    1235       17843 :                     mpOutputDevice->SetAntialiasing(nAntiAliasing);
    1236       17843 :                     break;
    1237             :                 }
    1238             :                 default :
    1239             :                 {
    1240             :                     SAL_INFO("drawinglayer", "default case for " << drawinglayer::primitive2d::idToString(rCandidate.getPrimitive2DID()));
    1241             :                     // process recursively
    1242       86907 :                     process(rCandidate.get2DDecomposition(getViewInformation2D()));
    1243       86907 :                     break;
    1244             :                 }
    1245             :             }
    1246      391779 :         }
    1247             :     } // end of namespace processor2d
    1248        1143 : } // end of namespace drawinglayer
    1249             : 
    1250             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10