LCOV - code coverage report
Current view: top level - drawinglayer/source/processor3d - defaultprocessor3d.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 171 228 75.0 %
Date: 2012-08-25 Functions: 8 11 72.7 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 202 506 39.9 %

           Branch data     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 <drawinglayer/processor3d/defaultprocessor3d.hxx>
      21                 :            : #include <drawinglayer/primitive3d/textureprimitive3d.hxx>
      22                 :            : #include <drawinglayer/texture/texture.hxx>
      23                 :            : #include <drawinglayer/texture/texture3d.hxx>
      24                 :            : #include <drawinglayer/primitive3d/hatchtextureprimitive3d.hxx>
      25                 :            : #include <drawinglayer/primitive3d/modifiedcolorprimitive3d.hxx>
      26                 :            : #include <drawinglayer/primitive3d/polygonprimitive3d.hxx>
      27                 :            : #include <basegfx/polygon/b3dpolygontools.hxx>
      28                 :            : #include <drawinglayer/attribute/materialattribute3d.hxx>
      29                 :            : #include <drawinglayer/primitive3d/polypolygonprimitive3d.hxx>
      30                 :            : #include <basegfx/polygon/b3dpolypolygontools.hxx>
      31                 :            : #include <com/sun/star/drawing/ShadeMode.hpp>
      32                 :            : #include <drawinglayer/primitive3d/transformprimitive3d.hxx>
      33                 :            : #include <drawinglayer/primitive3d/drawinglayer_primitivetypes3d.hxx>
      34                 :            : #include <vcl/bitmapex.hxx>
      35                 :            : #include <drawinglayer/attribute/sdrsceneattribute3d.hxx>
      36                 :            : #include <drawinglayer/attribute/sdrlightingattribute3d.hxx>
      37                 :            : 
      38                 :            : //////////////////////////////////////////////////////////////////////////////
      39                 :            : 
      40                 :            : using namespace com::sun::star;
      41                 :            : 
      42                 :            : //////////////////////////////////////////////////////////////////////////////
      43                 :            : 
      44                 :            : namespace drawinglayer
      45                 :            : {
      46                 :            :     namespace processor3d
      47                 :            :     {
      48                 :         16 :         void DefaultProcessor3D::impRenderGradientTexturePrimitive3D(const primitive3d::GradientTexturePrimitive3D& rPrimitive, bool bTransparence)
      49                 :            :         {
      50                 :         16 :             const primitive3d::Primitive3DSequence& rSubSequence = rPrimitive.getChildren();
      51                 :            : 
      52         [ +  - ]:         16 :             if(rSubSequence.hasElements())
      53                 :            :             {
      54                 :            :                 // rescue values
      55                 :         16 :                 const bool bOldModulate(getModulate()); mbModulate = rPrimitive.getModulate();
      56                 :         16 :                 const bool bOldFilter(getFilter()); mbFilter = rPrimitive.getFilter();
      57                 :         16 :                 const bool bOldSimpleTextureActive(getSimpleTextureActive());
      58 [ +  - ][ +  - ]:         16 :                 boost::shared_ptr< texture::GeoTexSvx > pOldTex = (bTransparence) ? mpTransparenceGeoTexSvx : mpGeoTexSvx;
      59                 :            : 
      60                 :            :                 // create texture
      61                 :         16 :                 const attribute::FillGradientAttribute& rFillGradient = rPrimitive.getGradient();
      62         [ +  - ]:         16 :                 const basegfx::B2DRange aOutlineRange(0.0, 0.0, rPrimitive.getTextureSize().getX(), rPrimitive.getTextureSize().getY());
      63         [ +  - ]:         16 :                 const attribute::GradientStyle aGradientStyle(rFillGradient.getStyle());
      64         [ +  - ]:         16 :                 sal_uInt32 nSteps(rFillGradient.getSteps());
      65         [ +  - ]:         16 :                 const basegfx::BColor aStart(rFillGradient.getStartColor());
      66         [ +  - ]:         16 :                 const basegfx::BColor aEnd(rFillGradient.getEndColor());
      67                 :         16 :                 const sal_uInt32 nMaxSteps(sal_uInt32((aStart.getMaximumDistance(aEnd) * 127.5) + 0.5));
      68         [ +  - ]:         16 :                 boost::shared_ptr< texture::GeoTexSvx > pNewTex;
      69                 :            : 
      70         [ +  - ]:         16 :                 if(nMaxSteps)
      71                 :            :                 {
      72                 :            :                     // there IS a color distance
      73         [ +  - ]:         16 :                     if(nSteps == 0L)
      74                 :            :                     {
      75                 :         16 :                         nSteps = nMaxSteps;
      76                 :            :                     }
      77                 :            : 
      78         [ -  + ]:         16 :                     if(nSteps < 2L)
      79                 :            :                     {
      80                 :          0 :                         nSteps = 2L;
      81                 :            :                     }
      82                 :            : 
      83         [ -  + ]:         16 :                     if(nSteps > nMaxSteps)
      84                 :            :                     {
      85                 :          0 :                         nSteps = nMaxSteps;
      86                 :            :                     }
      87                 :            : 
      88   [ +  +  -  -  :         16 :                     switch(aGradientStyle)
                -  -  - ]
      89                 :            :                     {
      90                 :            :                         case attribute::GRADIENTSTYLE_LINEAR:
      91                 :            :                         {
      92 [ +  - ][ +  - ]:          8 :                             pNewTex.reset(new texture::GeoTexSvxGradientLinear(aOutlineRange, aStart, aEnd, nSteps, rFillGradient.getBorder(), rFillGradient.getAngle()));
         [ +  - ][ +  - ]
                 [ +  - ]
      93                 :          8 :                             break;
      94                 :            :                         }
      95                 :            :                         case attribute::GRADIENTSTYLE_AXIAL:
      96                 :            :                         {
      97 [ +  - ][ +  - ]:          8 :                             pNewTex.reset(new texture::GeoTexSvxGradientAxial(aOutlineRange, aStart, aEnd, nSteps, rFillGradient.getBorder(), rFillGradient.getAngle()));
         [ +  - ][ +  - ]
                 [ +  - ]
      98                 :          8 :                             break;
      99                 :            :                         }
     100                 :            :                         case attribute::GRADIENTSTYLE_RADIAL:
     101                 :            :                         {
     102 [ #  # ][ #  # ]:          0 :                             pNewTex.reset(new texture::GeoTexSvxGradientRadial(aOutlineRange, aStart, aEnd, nSteps, rFillGradient.getBorder(), rFillGradient.getOffsetX(), rFillGradient.getOffsetY()));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     103                 :          0 :                             break;
     104                 :            :                         }
     105                 :            :                         case attribute::GRADIENTSTYLE_ELLIPTICAL:
     106                 :            :                         {
     107 [ #  # ][ #  # ]:          0 :                             pNewTex.reset(new texture::GeoTexSvxGradientElliptical(aOutlineRange, aStart, aEnd, nSteps, rFillGradient.getBorder(), rFillGradient.getOffsetX(), rFillGradient.getOffsetY(), rFillGradient.getAngle()));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     108                 :          0 :                             break;
     109                 :            :                         }
     110                 :            :                         case attribute::GRADIENTSTYLE_SQUARE:
     111                 :            :                         {
     112 [ #  # ][ #  # ]:          0 :                             pNewTex.reset(new texture::GeoTexSvxGradientSquare(aOutlineRange, aStart, aEnd, nSteps, rFillGradient.getBorder(), rFillGradient.getOffsetX(), rFillGradient.getOffsetY(), rFillGradient.getAngle()));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     113                 :          0 :                             break;
     114                 :            :                         }
     115                 :            :                         case attribute::GRADIENTSTYLE_RECT:
     116                 :            :                         {
     117 [ #  # ][ #  # ]:          0 :                             pNewTex.reset(new texture::GeoTexSvxGradientRect(aOutlineRange, aStart, aEnd, nSteps, rFillGradient.getBorder(), rFillGradient.getOffsetX(), rFillGradient.getOffsetY(), rFillGradient.getAngle()));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     118                 :          0 :                             break;
     119                 :            :                         }
     120                 :            :                     }
     121                 :            : 
     122                 :         16 :                     mbSimpleTextureActive = false;
     123                 :            :                 }
     124                 :            :                 else
     125                 :            :                 {
     126                 :            :                     // no color distance -> same color, use simple texture
     127 [ #  # ][ #  # ]:          0 :                     pNewTex.reset(new texture::GeoTexSvxMono(aStart, 1.0 - aStart.luminance()));
                 [ #  # ]
     128                 :          0 :                     mbSimpleTextureActive = true;
     129                 :            :                 }
     130                 :            : 
     131                 :            :                 // set created texture
     132         [ +  - ]:         16 :                 if(bTransparence)
     133                 :            :                 {
     134         [ +  - ]:         16 :                     mpTransparenceGeoTexSvx = pNewTex;
     135                 :            :                 }
     136                 :            :                 else
     137                 :            :                 {
     138         [ #  # ]:          0 :                     mpGeoTexSvx = pNewTex;
     139                 :            :                 }
     140                 :            : 
     141                 :            :                 // process sub-list
     142         [ +  - ]:         16 :                 process(rSubSequence);
     143                 :            : 
     144                 :            :                 // restore values
     145                 :         16 :                 mbModulate = bOldModulate;
     146                 :         16 :                 mbFilter = bOldFilter;
     147                 :         16 :                 mbSimpleTextureActive = bOldSimpleTextureActive;
     148                 :            : 
     149         [ +  - ]:         16 :                 if(bTransparence)
     150                 :            :                 {
     151         [ +  - ]:         16 :                     mpTransparenceGeoTexSvx = pOldTex;
     152                 :            :                 }
     153                 :            :                 else
     154                 :            :                 {
     155         [ #  # ]:          0 :                     mpGeoTexSvx = pOldTex;
     156 [ +  - ][ +  - ]:         16 :                 }
     157                 :         16 :             }
     158                 :         16 :         }
     159                 :            : 
     160                 :          8 :         void DefaultProcessor3D::impRenderHatchTexturePrimitive3D(const primitive3d::HatchTexturePrimitive3D& rPrimitive)
     161                 :            :         {
     162                 :          8 :             const primitive3d::Primitive3DSequence& rSubSequence = rPrimitive.getChildren();
     163                 :            : 
     164         [ +  - ]:          8 :             if(rSubSequence.hasElements())
     165                 :            :             {
     166                 :            :                 // rescue values
     167                 :          8 :                 const bool bOldModulate(getModulate()); mbModulate = rPrimitive.getModulate();
     168                 :          8 :                 const bool bOldFilter(getFilter()); mbFilter = rPrimitive.getFilter();
     169         [ +  - ]:          8 :                 boost::shared_ptr< texture::GeoTexSvx > pOldTex = mpGeoTexSvx;
     170                 :            : 
     171                 :            :                 // calculate logic pixel size in object coordinates. Create transformation view
     172                 :            :                 // to object by inverting ObjectToView
     173 [ +  - ][ +  - ]:          8 :                 basegfx::B3DHomMatrix aInvObjectToView(getViewInformation3D().getObjectToView());
     174         [ +  - ]:          8 :                 aInvObjectToView.invert();
     175                 :            : 
     176                 :            :                 // back-project discrete coordinates to object coordinates and extract
     177                 :            :                 // maximum distance
     178         [ +  - ]:          8 :                 const basegfx::B3DPoint aZero(aInvObjectToView * basegfx::B3DPoint(0.0, 0.0, 0.0));
     179         [ +  - ]:          8 :                 const basegfx::B3DPoint aOne(aInvObjectToView * basegfx::B3DPoint(1.0, 1.0, 1.0));
     180                 :          8 :                 const basegfx::B3DVector aLogicPixel(aOne - aZero);
     181 [ +  - ][ +  - ]:          8 :                 double fLogicPixelSizeWorld(::std::max(::std::max(fabs(aLogicPixel.getX()), fabs(aLogicPixel.getY())), fabs(aLogicPixel.getZ())));
     182                 :            : 
     183                 :            :                 // calculate logic pixel size in texture coordinates
     184                 :          8 :                 const double fLogicTexSizeX(fLogicPixelSizeWorld / rPrimitive.getTextureSize().getX());
     185                 :          8 :                 const double fLogicTexSizeY(fLogicPixelSizeWorld / rPrimitive.getTextureSize().getY());
     186         [ +  - ]:          8 :                 const double fLogicTexSize(fLogicTexSizeX > fLogicTexSizeY ? fLogicTexSizeX : fLogicTexSizeY);
     187                 :            : 
     188                 :            :                 // create texture and set
     189 [ +  - ][ +  - ]:          8 :                 mpGeoTexSvx.reset(new texture::GeoTexSvxMultiHatch(rPrimitive, fLogicTexSize));
                 [ +  - ]
     190                 :            : 
     191                 :            :                 // process sub-list
     192         [ +  - ]:          8 :                 process(rSubSequence);
     193                 :            : 
     194                 :            :                 // restore values
     195                 :          8 :                 mbModulate = bOldModulate;
     196                 :          8 :                 mbFilter = bOldFilter;
     197 [ +  - ][ +  - ]:          8 :                 mpGeoTexSvx = pOldTex;
                 [ +  - ]
     198                 :          8 :             }
     199                 :          8 :         }
     200                 :            : 
     201                 :          0 :         void DefaultProcessor3D::impRenderBitmapTexturePrimitive3D(const primitive3d::BitmapTexturePrimitive3D& rPrimitive)
     202                 :            :         {
     203                 :          0 :             const primitive3d::Primitive3DSequence& rSubSequence = rPrimitive.getChildren();
     204                 :            : 
     205         [ #  # ]:          0 :             if(rSubSequence.hasElements())
     206                 :            :             {
     207                 :            :                 // rescue values
     208                 :          0 :                 const bool bOldModulate(getModulate()); mbModulate = rPrimitive.getModulate();
     209                 :          0 :                 const bool bOldFilter(getFilter()); mbFilter = rPrimitive.getFilter();
     210         [ #  # ]:          0 :                 boost::shared_ptr< texture::GeoTexSvx > pOldTex = mpGeoTexSvx;
     211                 :            : 
     212                 :            :                 // create texture
     213                 :          0 :                 const attribute::FillBitmapAttribute& rFillBitmapAttribute = rPrimitive.getFillBitmapAttribute();
     214                 :            : 
     215 [ #  # ][ #  # ]:          0 :                 if(rFillBitmapAttribute.getTiling())
     216                 :            :                 {
     217                 :            :                     mpGeoTexSvx.reset(new texture::GeoTexSvxBitmapTiled(
     218         [ #  # ]:          0 :                         rFillBitmapAttribute.getBitmapEx().GetBitmap(),
     219         [ #  # ]:          0 :                         rFillBitmapAttribute.getTopLeft() * rPrimitive.getTextureSize(),
     220 [ #  # ][ #  # ]:          0 :                         rFillBitmapAttribute.getSize() * rPrimitive.getTextureSize()));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     221                 :            :                 }
     222                 :            :                 else
     223                 :            :                 {
     224                 :            :                     mpGeoTexSvx.reset(new texture::GeoTexSvxBitmap(
     225         [ #  # ]:          0 :                         rFillBitmapAttribute.getBitmapEx().GetBitmap(),
     226         [ #  # ]:          0 :                         rFillBitmapAttribute.getTopLeft() * rPrimitive.getTextureSize(),
     227 [ #  # ][ #  # ]:          0 :                         rFillBitmapAttribute.getSize() * rPrimitive.getTextureSize()));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     228                 :            :                 }
     229                 :            : 
     230                 :            :                 // process sub-list
     231         [ #  # ]:          0 :                 process(rSubSequence);
     232                 :            : 
     233                 :            :                 // restore values
     234                 :          0 :                 mbModulate = bOldModulate;
     235                 :          0 :                 mbFilter = bOldFilter;
     236 [ #  # ][ #  # ]:          0 :                 mpGeoTexSvx = pOldTex;
     237                 :          0 :             }
     238                 :          0 :         }
     239                 :            : 
     240                 :          0 :         void DefaultProcessor3D::impRenderModifiedColorPrimitive3D(const primitive3d::ModifiedColorPrimitive3D& rModifiedCandidate)
     241                 :            :         {
     242                 :          0 :             const primitive3d::Primitive3DSequence& rSubSequence = rModifiedCandidate.getChildren();
     243                 :            : 
     244         [ #  # ]:          0 :             if(rSubSequence.hasElements())
     245                 :            :             {
     246                 :            :                 // put modifier on stack
     247         [ #  # ]:          0 :                 maBColorModifierStack.push(rModifiedCandidate.getColorModifier());
     248                 :            : 
     249                 :            :                 // process sub-list
     250 [ #  # ][ #  # ]:          0 :                 process(rModifiedCandidate.getChildren());
                 [ #  # ]
     251                 :            : 
     252                 :            :                 // remove modifier from stack
     253         [ #  # ]:          0 :                 maBColorModifierStack.pop();
     254                 :          0 :             }
     255                 :          0 :         }
     256                 :            : 
     257                 :         30 :         void DefaultProcessor3D::impRenderPolygonHairlinePrimitive3D(const primitive3d::PolygonHairlinePrimitive3D& rPrimitive)
     258                 :            :         {
     259         [ +  - ]:         30 :             basegfx::B3DPolygon aHairline(rPrimitive.getB3DPolygon());
     260                 :            : 
     261 [ +  - ][ +  - ]:         30 :             if(aHairline.count())
     262                 :            :             {
     263                 :            :                 // hairlines need no extra data, clear it
     264         [ +  - ]:         30 :                 aHairline.clearTextureCoordinates();
     265         [ +  - ]:         30 :                 aHairline.clearNormals();
     266         [ +  - ]:         30 :                 aHairline.clearBColors();
     267                 :            : 
     268                 :            :                 // transform to device coordinates (-1.0 .. 1.0) and check for visibility
     269 [ +  - ][ +  - ]:         30 :                 aHairline.transform(getViewInformation3D().getObjectToView());
     270         [ +  - ]:         30 :                 const basegfx::B3DRange a3DRange(basegfx::tools::getRange(aHairline));
     271 [ +  - ][ +  - ]:         30 :                 const basegfx::B2DRange a2DRange(a3DRange.getMinX(), a3DRange.getMinY(), a3DRange.getMaxX(), a3DRange.getMaxY());
         [ +  - ][ +  - ]
                 [ +  - ]
     272                 :            : 
     273 [ +  - ][ +  - ]:         30 :                 if(a2DRange.overlaps(maRasterRange))
     274                 :            :                 {
     275 [ +  - ][ +  - ]:         30 :                     const attribute::MaterialAttribute3D aMaterial(maBColorModifierStack.getModifiedColor(rPrimitive.getBColor()));
     276                 :            : 
     277 [ +  - ][ +  - ]:         30 :                     rasterconvertB3DPolygon(aMaterial, aHairline);
     278                 :            :                 }
     279         [ +  - ]:         30 :             }
     280                 :         30 :         }
     281                 :            : 
     282                 :        631 :         void DefaultProcessor3D::impRenderPolyPolygonMaterialPrimitive3D(const primitive3d::PolyPolygonMaterialPrimitive3D& rPrimitive)
     283                 :            :         {
     284         [ +  - ]:        631 :             basegfx::B3DPolyPolygon aFill(rPrimitive.getB3DPolyPolygon());
     285         [ +  - ]:        631 :             basegfx::BColor aObjectColor(rPrimitive.getMaterial().getColor());
     286         [ +  - ]:        631 :             bool bPaintIt(aFill.count());
     287                 :            : 
     288                 :            :             // #i98295# get ShadeMode. Correct early when only flat is possible due to missing normals
     289                 :            :             const ::com::sun::star::drawing::ShadeMode aShadeMode(
     290         [ +  - ]:        631 :                 aFill.areNormalsUsed() ?
     291 [ +  + ][ +  - ]:        631 :                     getSdrSceneAttribute().getShadeMode() : ::com::sun::star::drawing::ShadeMode_FLAT);
     292                 :            : 
     293         [ +  - ]:        631 :             if(bPaintIt)
     294                 :            :             {
     295                 :            :                 // get rid of texture coordinates if there is no texture
     296 [ +  - ][ +  - ]:        631 :                 if(aFill.areTextureCoordinatesUsed() && !getGeoTexSvx().get() && !getTransparenceGeoTexSvx().get())
         [ +  + ][ +  + ]
                 [ +  + ]
     297                 :            :                 {
     298         [ +  - ]:        487 :                     aFill.clearTextureCoordinates();
     299                 :            :                 }
     300                 :            : 
     301                 :            :                 // #i98295# get rid of normals and color early when not needed
     302         [ +  + ]:        631 :                 if(::com::sun::star::drawing::ShadeMode_FLAT == aShadeMode)
     303                 :            :                 {
     304         [ +  - ]:        487 :                     aFill.clearNormals();
     305         [ +  - ]:        487 :                     aFill.clearBColors();
     306                 :            :                 }
     307                 :            : 
     308                 :            :                 // transform to device coordinates (-1.0 .. 1.0) and check for visibility
     309 [ +  - ][ +  - ]:        631 :                 aFill.transform(getViewInformation3D().getObjectToView());
     310         [ +  - ]:        631 :                 const basegfx::B3DRange a3DRange(basegfx::tools::getRange(aFill));
     311 [ +  - ][ +  - ]:        631 :                 const basegfx::B2DRange a2DRange(a3DRange.getMinX(), a3DRange.getMinY(), a3DRange.getMaxX(), a3DRange.getMaxY());
         [ +  - ][ +  - ]
                 [ +  - ]
     312                 :            : 
     313         [ +  - ]:        631 :                 bPaintIt = a2DRange.overlaps(maRasterRange);
     314                 :            :             }
     315                 :            : 
     316                 :            :             // check if it shall be painted regarding hiding of normals (backface culling)
     317 [ +  + ][ +  + ]:        631 :             if(bPaintIt && !rPrimitive.getDoubleSided())
                 [ +  + ]
     318                 :            :             {
     319                 :            :                 // get plane normal of polygon in view coordinates (with ZBuffer values),
     320                 :            :                 // left-handed coordinate system
     321 [ +  - ][ +  - ]:        127 :                 const basegfx::B3DVector aPlaneNormal(aFill.getB3DPolygon(0L).getNormal());
                 [ +  - ]
     322                 :            : 
     323         [ +  + ]:        127 :                 if(aPlaneNormal.getZ() > 0.0)
     324                 :            :                 {
     325                 :         44 :                     bPaintIt = false;
     326                 :        127 :                 }
     327                 :            :             }
     328                 :            : 
     329         [ +  + ]:        631 :             if(bPaintIt)
     330                 :            :             {
     331                 :            :                 // prepare ObjectToEye in NormalTransform
     332 [ +  - ][ +  - ]:        551 :                 basegfx::B3DHomMatrix aNormalTransform(getViewInformation3D().getOrientation() * getViewInformation3D().getObjectTransformation());
                 [ +  - ]
     333                 :            : 
     334 [ +  - ][ +  - ]:        551 :                 if(getSdrSceneAttribute().getTwoSidedLighting())
     335                 :            :                 {
     336                 :            :                     // get plane normal of polygon in view coordinates (with ZBuffer values),
     337                 :            :                     // left-handed coordinate system
     338 [ +  - ][ +  - ]:        551 :                     const basegfx::B3DVector aPlaneNormal(aFill.getB3DPolygon(0L).getNormal());
                 [ +  - ]
     339                 :            : 
     340         [ +  + ]:        551 :                     if(aPlaneNormal.getZ() > 0.0)
     341                 :            :                     {
     342                 :            :                         // mirror normals
     343         [ +  - ]:        226 :                         aNormalTransform.scale(-1.0, -1.0, -1.0);
     344                 :        551 :                     }
     345                 :            :                 }
     346                 :            : 
     347   [ -  +  +  - ]:        551 :                 switch(aShadeMode)
     348                 :            :                 {
     349                 :            :                     case ::com::sun::star::drawing::ShadeMode_PHONG:
     350                 :            :                     {
     351                 :            :                         // phong shading. Transform normals to eye coor
     352         [ #  # ]:          0 :                         aFill.transformNormals(aNormalTransform);
     353                 :          0 :                         break;
     354                 :            :                     }
     355                 :            :                     case ::com::sun::star::drawing::ShadeMode_SMOOTH:
     356                 :            :                     {
     357                 :            :                         // gouraud shading. Transform normals to eye coor
     358         [ +  - ]:         66 :                         aFill.transformNormals(aNormalTransform);
     359                 :            : 
     360                 :            :                         // prepare color model parameters, evtl. use blend color
     361 [ +  + ][ +  - ]:         66 :                         const basegfx::BColor aColor(getModulate() ? basegfx::BColor(1.0, 1.0, 1.0) : rPrimitive.getMaterial().getColor());
     362         [ +  - ]:         66 :                         const basegfx::BColor& rSpecular(rPrimitive.getMaterial().getSpecular());
     363         [ +  - ]:         66 :                         const basegfx::BColor& rEmission(rPrimitive.getMaterial().getEmission());
     364         [ +  - ]:         66 :                         const sal_uInt16 nSpecularIntensity(rPrimitive.getMaterial().getSpecularIntensity());
     365                 :            : 
     366                 :            :                         // solve color model for each normal vector, set colors at points. Clear normals.
     367 [ +  - ][ +  + ]:        132 :                         for(sal_uInt32 a(0L); a < aFill.count(); a++)
     368                 :            :                         {
     369         [ +  - ]:         66 :                             basegfx::B3DPolygon aPartFill(aFill.getB3DPolygon(a));
     370                 :            : 
     371 [ +  - ][ +  + ]:        330 :                             for(sal_uInt32 b(0L); b < aPartFill.count(); b++)
     372                 :            :                             {
     373                 :            :                                 // solve color model. Transform normal to eye coor
     374         [ +  - ]:        264 :                                 const basegfx::B3DVector aNormal(aPartFill.getNormal(b));
     375         [ +  - ]:        264 :                                 const basegfx::BColor aSolvedColor(getSdrLightingAttribute().solveColorModel(aNormal, aColor, rSpecular, rEmission, nSpecularIntensity));
     376         [ +  - ]:        264 :                                 aPartFill.setBColor(b, aSolvedColor);
     377                 :        264 :                             }
     378                 :            : 
     379                 :            :                             // clear normals on this part polygon and write it back
     380         [ +  - ]:         66 :                             aPartFill.clearNormals();
     381         [ +  - ]:         66 :                             aFill.setB3DPolygon(a, aPartFill);
     382         [ +  - ]:         66 :                         }
     383                 :         66 :                         break;
     384                 :            :                     }
     385                 :            :                     case ::com::sun::star::drawing::ShadeMode_FLAT:
     386                 :            :                     {
     387                 :            :                         // flat shading. Get plane vector in eye coordinates
     388 [ +  - ][ +  - ]:        485 :                         const basegfx::B3DVector aPlaneEyeNormal(aNormalTransform * rPrimitive.getB3DPolyPolygon().getB3DPolygon(0L).getNormal());
         [ +  - ][ +  - ]
     389                 :            : 
     390                 :            :                         // prepare color model parameters, evtl. use blend color
     391 [ -  + ][ +  - ]:        485 :                         const basegfx::BColor aColor(getModulate() ? basegfx::BColor(1.0, 1.0, 1.0) : rPrimitive.getMaterial().getColor());
     392         [ +  - ]:        485 :                         const basegfx::BColor& rSpecular(rPrimitive.getMaterial().getSpecular());
     393         [ +  - ]:        485 :                         const basegfx::BColor& rEmission(rPrimitive.getMaterial().getEmission());
     394         [ +  - ]:        485 :                         const sal_uInt16 nSpecularIntensity(rPrimitive.getMaterial().getSpecularIntensity());
     395                 :            : 
     396                 :            :                         // solve color model for plane vector and use that color for whole plane
     397 [ +  - ][ +  - ]:        485 :                         aObjectColor = getSdrLightingAttribute().solveColorModel(aPlaneEyeNormal, aColor, rSpecular, rEmission, nSpecularIntensity);
     398                 :        485 :                         break;
     399                 :            :                     }
     400                 :            :                     default: // case ::com::sun::star::drawing::ShadeMode_DRAFT:
     401                 :            :                     {
     402                 :            :                         // draft, just use object color which is already set. Delete all other infos
     403         [ #  # ]:          0 :                         aFill.clearNormals();
     404         [ #  # ]:          0 :                         aFill.clearBColors();
     405                 :          0 :                         break;
     406                 :            :                     }
     407                 :            :                 }
     408                 :            : 
     409                 :            :                 // draw it to ZBuffer
     410                 :            :                 const attribute::MaterialAttribute3D aMaterial(
     411                 :            :                     maBColorModifierStack.getModifiedColor(aObjectColor),
     412         [ +  - ]:        551 :                     rPrimitive.getMaterial().getSpecular(),
     413         [ +  - ]:        551 :                     rPrimitive.getMaterial().getEmission(),
     414 [ +  - ][ +  - ]:       1102 :                     rPrimitive.getMaterial().getSpecularIntensity());
                 [ +  - ]
     415                 :            : 
     416 [ +  - ][ +  - ]:        551 :                 rasterconvertB3DPolyPolygon(aMaterial, aFill);
                 [ +  - ]
     417         [ +  - ]:        631 :             }
     418                 :        631 :         }
     419                 :            : 
     420                 :        198 :         void DefaultProcessor3D::impRenderTransformPrimitive3D(const primitive3d::TransformPrimitive3D& rTransformCandidate)
     421                 :            :         {
     422                 :            :             // transform group. Remember current transformations
     423         [ +  - ]:        198 :             const geometry::ViewInformation3D aLastViewInformation3D(getViewInformation3D());
     424                 :            : 
     425                 :            :             // create new transformation; add new object transform from right side
     426                 :            :             const geometry::ViewInformation3D aNewViewInformation3D(
     427         [ +  - ]:        198 :                 aLastViewInformation3D.getObjectTransformation() * rTransformCandidate.getTransformation(),
     428         [ +  - ]:        198 :                 aLastViewInformation3D.getOrientation(),
     429         [ +  - ]:        198 :                 aLastViewInformation3D.getProjection(),
     430         [ +  - ]:        198 :                 aLastViewInformation3D.getDeviceToView(),
     431                 :            :                 aLastViewInformation3D.getViewTime(),
     432 [ +  - ][ +  - ]:        396 :                 aLastViewInformation3D.getExtendedInformationSequence());
         [ +  - ][ +  - ]
                 [ +  - ]
     433         [ +  - ]:        198 :             updateViewInformation(aNewViewInformation3D);
     434                 :            : 
     435                 :            :             // let break down recursively
     436 [ +  - ][ +  - ]:        198 :             process(rTransformCandidate.getChildren());
                 [ +  - ]
     437                 :            : 
     438                 :            :             // restore transformations
     439 [ +  - ][ +  - ]:        198 :             updateViewInformation(aLastViewInformation3D);
                 [ +  - ]
     440                 :        198 :         }
     441                 :            : 
     442                 :       1476 :         void DefaultProcessor3D::processBasePrimitive3D(const primitive3d::BasePrimitive3D& rBasePrimitive)
     443                 :            :         {
     444                 :            :             // it is a BasePrimitive3D implementation, use getPrimitive3DID() call for switch
     445   [ -  +  -  +  :       1476 :             switch(rBasePrimitive.getPrimitive3DID())
             -  +  +  +  
                      + ]
     446                 :            :             {
     447                 :            :                 case PRIMITIVE3D_ID_GRADIENTTEXTUREPRIMITIVE3D :
     448                 :            :                 {
     449                 :            :                     // GradientTexturePrimitive3D
     450                 :          0 :                     const primitive3d::GradientTexturePrimitive3D& rPrimitive = static_cast< const primitive3d::GradientTexturePrimitive3D& >(rBasePrimitive);
     451                 :          0 :                     impRenderGradientTexturePrimitive3D(rPrimitive, false);
     452                 :          0 :                     break;
     453                 :            :                 }
     454                 :            :                 case PRIMITIVE3D_ID_HATCHTEXTUREPRIMITIVE3D :
     455                 :            :                 {
     456                 :            :                     // HatchTexturePrimitive3D
     457                 :            :                     static bool bDoHatchDecomposition(false);
     458                 :            : 
     459         [ -  + ]:          8 :                     if(bDoHatchDecomposition)
     460                 :            :                     {
     461                 :            :                         // let break down
     462         [ #  # ]:          0 :                         process(rBasePrimitive.get3DDecomposition(getViewInformation3D()));
     463                 :            :                     }
     464                 :            :                     else
     465                 :            :                     {
     466                 :            :                         // hatchTexturePrimitive3D
     467                 :          8 :                         const primitive3d::HatchTexturePrimitive3D& rPrimitive = static_cast< const primitive3d::HatchTexturePrimitive3D& >(rBasePrimitive);
     468                 :          8 :                         impRenderHatchTexturePrimitive3D(rPrimitive);
     469                 :            :                     }
     470                 :          8 :                     break;
     471                 :            :                 }
     472                 :            :                 case PRIMITIVE3D_ID_BITMAPTEXTUREPRIMITIVE3D :
     473                 :            :                 {
     474                 :            :                     // BitmapTexturePrimitive3D
     475                 :          0 :                     const primitive3d::BitmapTexturePrimitive3D& rPrimitive = static_cast< const primitive3d::BitmapTexturePrimitive3D& >(rBasePrimitive);
     476                 :          0 :                     impRenderBitmapTexturePrimitive3D(rPrimitive);
     477                 :          0 :                     break;
     478                 :            :                 }
     479                 :            :                 case PRIMITIVE3D_ID_TRANSPARENCETEXTUREPRIMITIVE3D :
     480                 :            :                 {
     481                 :            :                     // TransparenceTexturePrimitive3D
     482                 :         16 :                     const primitive3d::TransparenceTexturePrimitive3D& rPrimitive = static_cast< const primitive3d::TransparenceTexturePrimitive3D& >(rBasePrimitive);
     483                 :         16 :                     mnTransparenceCounter++;
     484                 :         16 :                     impRenderGradientTexturePrimitive3D(rPrimitive, true);
     485                 :         16 :                     mnTransparenceCounter--;
     486                 :         16 :                     break;
     487                 :            :                 }
     488                 :            :                 case PRIMITIVE3D_ID_MODIFIEDCOLORPRIMITIVE3D :
     489                 :            :                 {
     490                 :            :                     // ModifiedColorPrimitive3D
     491                 :            :                     // Force output to unified color.
     492                 :          0 :                     const primitive3d::ModifiedColorPrimitive3D& rPrimitive = static_cast< const primitive3d::ModifiedColorPrimitive3D& >(rBasePrimitive);
     493                 :          0 :                     impRenderModifiedColorPrimitive3D(rPrimitive);
     494                 :          0 :                     break;
     495                 :            :                 }
     496                 :            :                 case PRIMITIVE3D_ID_POLYGONHAIRLINEPRIMITIVE3D :
     497                 :            :                 {
     498                 :            :                     // directdraw of PolygonHairlinePrimitive3D
     499                 :         30 :                     const primitive3d::PolygonHairlinePrimitive3D& rPrimitive = static_cast< const primitive3d::PolygonHairlinePrimitive3D& >(rBasePrimitive);
     500                 :         30 :                     impRenderPolygonHairlinePrimitive3D(rPrimitive);
     501                 :         30 :                     break;
     502                 :            :                 }
     503                 :            :                 case PRIMITIVE3D_ID_POLYPOLYGONMATERIALPRIMITIVE3D :
     504                 :            :                 {
     505                 :            :                     // directdraw of PolyPolygonMaterialPrimitive3D
     506                 :        631 :                     const primitive3d::PolyPolygonMaterialPrimitive3D& rPrimitive = static_cast< const primitive3d::PolyPolygonMaterialPrimitive3D& >(rBasePrimitive);
     507                 :        631 :                     impRenderPolyPolygonMaterialPrimitive3D(rPrimitive);
     508                 :        631 :                     break;
     509                 :            :                 }
     510                 :            :                 case PRIMITIVE3D_ID_TRANSFORMPRIMITIVE3D :
     511                 :            :                 {
     512                 :            :                     // transform group (TransformPrimitive3D)
     513                 :        198 :                     impRenderTransformPrimitive3D(static_cast< const primitive3d::TransformPrimitive3D& >(rBasePrimitive));
     514                 :        198 :                     break;
     515                 :            :                 }
     516                 :            :                 default:
     517                 :            :                 {
     518                 :            :                     // process recursively
     519         [ +  - ]:        593 :                     process(rBasePrimitive.get3DDecomposition(getViewInformation3D()));
     520                 :        593 :                     break;
     521                 :            :                 }
     522                 :            :             }
     523                 :       1476 :         }
     524                 :            : 
     525                 :         15 :         DefaultProcessor3D::DefaultProcessor3D(
     526                 :            :             const geometry::ViewInformation3D& rViewInformation,
     527                 :            :             const attribute::SdrSceneAttribute& rSdrSceneAttribute,
     528                 :            :             const attribute::SdrLightingAttribute& rSdrLightingAttribute)
     529                 :            :         :   BaseProcessor3D(rViewInformation),
     530                 :            :             mrSdrSceneAttribute(rSdrSceneAttribute),
     531                 :            :             mrSdrLightingAttribute(rSdrLightingAttribute),
     532                 :            :             maRasterRange(),
     533                 :            :             maBColorModifierStack(),
     534                 :            :             mpGeoTexSvx(),
     535                 :            :             mpTransparenceGeoTexSvx(),
     536                 :            :             maDrawinglayerOpt(),
     537                 :            :             mnTransparenceCounter(0),
     538                 :            :             mbModulate(false),
     539                 :            :             mbFilter(false),
     540 [ +  - ][ +  - ]:         15 :             mbSimpleTextureActive(false)
         [ +  - ][ +  - ]
                 [ +  - ]
     541                 :            :         {
     542                 :            :             // a derivation has to set maRasterRange which is used in the basic render methods.
     543                 :            :             // Setting to default here ([0.0 .. 1.0] in X,Y) to avoid problems
     544         [ +  - ]:         15 :             maRasterRange.expand(basegfx::B2DTuple(0.0, 0.0));
     545         [ +  - ]:         15 :             maRasterRange.expand(basegfx::B2DTuple(1.0, 1.0));
     546                 :         15 :         }
     547                 :            : 
     548 [ +  - ][ +  - ]:         15 :         DefaultProcessor3D::~DefaultProcessor3D()
                 [ +  - ]
     549                 :            :         {
     550         [ -  + ]:         15 :         }
     551                 :            :     } // end of namespace processor3d
     552                 :            : } // end of namespace drawinglayer
     553                 :            : 
     554                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10