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

Generated by: LCOV version 1.10