LCOV - code coverage report
Current view: top level - include/drawinglayer/texture - texture.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 1 100.0 %
Date: 2015-06-13 12:38:46 Functions: 3 3 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             : #ifndef INCLUDED_DRAWINGLAYER_TEXTURE_TEXTURE_HXX
      21             : #define INCLUDED_DRAWINGLAYER_TEXTURE_TEXTURE_HXX
      22             : 
      23             : #include <drawinglayer/drawinglayerdllapi.h>
      24             : 
      25             : #include <basegfx/matrix/b2dhommatrix.hxx>
      26             : #include <basegfx/range/b2drange.hxx>
      27             : #include <basegfx/color/bcolor.hxx>
      28             : #include <basegfx/tools/gradienttools.hxx>
      29             : #include <vector>
      30             : 
      31             : 
      32             : namespace drawinglayer
      33             : {
      34             :     namespace texture
      35             :     {
      36             :         class DRAWINGLAYER_DLLPUBLIC GeoTexSvx
      37             :         {
      38             :         public:
      39             :             GeoTexSvx();
      40             :             virtual ~GeoTexSvx();
      41             : 
      42             :             // compare operator
      43             :             virtual bool operator==(const GeoTexSvx& rGeoTexSvx) const;
      44             :             bool operator!=(const GeoTexSvx& rGeoTexSvx) const { return !operator==(rGeoTexSvx); }
      45             : 
      46             :             // virtual base methods
      47             :             virtual void modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const;
      48             :             virtual void modifyOpacity(const basegfx::B2DPoint& rUV, double& rfOpacity) const;
      49             :         };
      50             :     } // end of namespace texture
      51             : } // end of namespace drawinglayer
      52             : 
      53             : 
      54             : 
      55             : namespace drawinglayer
      56             : {
      57             :     namespace texture
      58             :     {
      59             :         /// helper class for processing equal number of matrices and colors
      60             :         /// for texture processing
      61      879370 :         struct B2DHomMatrixAndBColor
      62             :         {
      63             :             basegfx::B2DHomMatrix   maB2DHomMatrix;
      64             :             basegfx::BColor         maBColor;
      65             :         };
      66             :     } // end of namespace texture
      67             : } // end of namespace drawinglayer
      68             : 
      69             : 
      70             : 
      71             : namespace drawinglayer
      72             : {
      73             :     namespace texture
      74             :     {
      75             :         class DRAWINGLAYER_DLLPUBLIC GeoTexSvxGradient : public GeoTexSvx
      76             :         {
      77             :         protected:
      78             :             basegfx::ODFGradientInfo            maGradientInfo;
      79             :             basegfx::B2DRange                   maDefinitionRange;
      80             :             basegfx::BColor                     maStart;
      81             :             basegfx::BColor                     maEnd;
      82             :             double                              mfBorder;
      83             : 
      84             :         public:
      85             :             GeoTexSvxGradient(
      86             :                 const basegfx::B2DRange& rDefinitionRange,
      87             :                 const basegfx::BColor& rStart,
      88             :                 const basegfx::BColor& rEnd,
      89             :                 sal_uInt32 nSteps,
      90             :                 double fBorder);
      91             :             virtual ~GeoTexSvxGradient();
      92             : 
      93             :             // compare operator
      94             :             virtual bool operator==(const GeoTexSvx& rGeoTexSvx) const SAL_OVERRIDE;
      95             : 
      96             :             // virtual base methods
      97             :             virtual void appendTransformationsAndColors(
      98             :                 std::vector< B2DHomMatrixAndBColor >& rEntries,
      99             :                 basegfx::BColor& rOuterColor) = 0;
     100             : 
     101             :             // data access
     102             :             const basegfx::BColor& getStart() const { return maStart; }
     103             :             const basegfx::BColor& getEnd() const { return maEnd; }
     104             :         };
     105             :     } // end of namespace texture
     106             : } // end of namespace drawinglayer
     107             : 
     108             : 
     109             : 
     110             : namespace drawinglayer
     111             : {
     112             :     namespace texture
     113             :     {
     114             :         class DRAWINGLAYER_DLLPUBLIC GeoTexSvxGradientLinear : public GeoTexSvxGradient
     115             :         {
     116             :         protected:
     117             :             double                  mfUnitMinX;
     118             :             double                  mfUnitWidth;
     119             :             double                  mfUnitMaxY;
     120             : 
     121             :         public:
     122             :             GeoTexSvxGradientLinear(
     123             :                 const basegfx::B2DRange& rDefinitionRange,
     124             :                 const basegfx::B2DRange& rOutputRange,
     125             :                 const basegfx::BColor& rStart,
     126             :                 const basegfx::BColor& rEnd,
     127             :                 sal_uInt32 nSteps,
     128             :                 double fBorder,
     129             :                 double fAngle);
     130             :             virtual ~GeoTexSvxGradientLinear();
     131             : 
     132             :             virtual void appendTransformationsAndColors(
     133             :                 std::vector< B2DHomMatrixAndBColor >& rEntries,
     134             :                 basegfx::BColor& rOuterColor) SAL_OVERRIDE;
     135             :             virtual void modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const SAL_OVERRIDE;
     136             :         };
     137             :     } // end of namespace texture
     138             : } // end of namespace drawinglayer
     139             : 
     140             : 
     141             : 
     142             : namespace drawinglayer
     143             : {
     144             :     namespace texture
     145             :     {
     146             :         class DRAWINGLAYER_DLLPUBLIC GeoTexSvxGradientAxial : public GeoTexSvxGradient
     147             :         {
     148             :         protected:
     149             :             double                  mfUnitMinX;
     150             :             double                  mfUnitWidth;
     151             : 
     152             :         public:
     153             :             GeoTexSvxGradientAxial(
     154             :                 const basegfx::B2DRange& rDefinitionRange,
     155             :                 const basegfx::B2DRange& rOutputRange,
     156             :                 const basegfx::BColor& rStart,
     157             :                 const basegfx::BColor& rEnd,
     158             :                 sal_uInt32 nSteps,
     159             :                 double fBorder,
     160             :                 double fAngle);
     161             :             virtual ~GeoTexSvxGradientAxial();
     162             : 
     163             :             virtual void appendTransformationsAndColors(
     164             :                 std::vector< B2DHomMatrixAndBColor >& rEntries,
     165             :                 basegfx::BColor& rOuterColor) SAL_OVERRIDE;
     166             :             virtual void modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const SAL_OVERRIDE;
     167             :         };
     168             :     } // end of namespace texture
     169             : } // end of namespace drawinglayer
     170             : 
     171             : 
     172             : 
     173             : namespace drawinglayer
     174             : {
     175             :     namespace texture
     176             :     {
     177             :         class DRAWINGLAYER_DLLPUBLIC GeoTexSvxGradientRadial : public GeoTexSvxGradient
     178             :         {
     179             :         public:
     180             :             GeoTexSvxGradientRadial(
     181             :                 const basegfx::B2DRange& rDefinitionRange,
     182             :                 const basegfx::BColor& rStart,
     183             :                 const basegfx::BColor& rEnd,
     184             :                 sal_uInt32 nSteps,
     185             :                 double fBorder,
     186             :                 double fOffsetX,
     187             :                 double fOffsetY);
     188             :             virtual ~GeoTexSvxGradientRadial();
     189             : 
     190             :             virtual void appendTransformationsAndColors(
     191             :                 std::vector< B2DHomMatrixAndBColor >& rEntries,
     192             :                 basegfx::BColor& rOuterColor) SAL_OVERRIDE;
     193             :             virtual void modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const SAL_OVERRIDE;
     194             :         };
     195             :     } // end of namespace texture
     196             : } // end of namespace drawinglayer
     197             : 
     198             : 
     199             : 
     200             : namespace drawinglayer
     201             : {
     202             :     namespace texture
     203             :     {
     204             :         class DRAWINGLAYER_DLLPUBLIC GeoTexSvxGradientElliptical : public GeoTexSvxGradient
     205             :         {
     206             :         public:
     207             :             GeoTexSvxGradientElliptical(
     208             :                 const basegfx::B2DRange& rDefinitionRange,
     209             :                 const basegfx::BColor& rStart,
     210             :                 const basegfx::BColor& rEnd,
     211             :                 sal_uInt32 nSteps,
     212             :                 double fBorder,
     213             :                 double fOffsetX,
     214             :                 double fOffsetY,
     215             :                 double fAngle);
     216             :             virtual ~GeoTexSvxGradientElliptical();
     217             : 
     218             :             virtual void appendTransformationsAndColors(
     219             :                 std::vector< B2DHomMatrixAndBColor >& rEntries,
     220             :                 basegfx::BColor& rOuterColor) SAL_OVERRIDE;
     221             :             virtual void modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const SAL_OVERRIDE;
     222             :         };
     223             :     } // end of namespace texture
     224             : } // end of namespace drawinglayer
     225             : 
     226             : 
     227             : 
     228             : namespace drawinglayer
     229             : {
     230             :     namespace texture
     231             :     {
     232             :         class DRAWINGLAYER_DLLPUBLIC GeoTexSvxGradientSquare : public GeoTexSvxGradient
     233             :         {
     234             :         public:
     235             :             GeoTexSvxGradientSquare(
     236             :                 const basegfx::B2DRange& rDefinitionRange,
     237             :                 const basegfx::BColor& rStart,
     238             :                 const basegfx::BColor& rEnd,
     239             :                 sal_uInt32 nSteps,
     240             :                 double fBorder,
     241             :                 double fOffsetX,
     242             :                 double fOffsetY,
     243             :                 double fAngle);
     244             :             virtual ~GeoTexSvxGradientSquare();
     245             : 
     246             :             virtual void appendTransformationsAndColors(
     247             :                 std::vector< B2DHomMatrixAndBColor >& rEntries,
     248             :                 basegfx::BColor& rOuterColor) SAL_OVERRIDE;
     249             :             virtual void modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const SAL_OVERRIDE;
     250             :         };
     251             :     } // end of namespace texture
     252             : } // end of namespace drawinglayer
     253             : 
     254             : 
     255             : 
     256             : namespace drawinglayer
     257             : {
     258             :     namespace texture
     259             :     {
     260             :         class DRAWINGLAYER_DLLPUBLIC GeoTexSvxGradientRect : public GeoTexSvxGradient
     261             :         {
     262             :         public:
     263             :             GeoTexSvxGradientRect(
     264             :                 const basegfx::B2DRange& rDefinitionRange,
     265             :                 const basegfx::BColor& rStart,
     266             :                 const basegfx::BColor& rEnd,
     267             :                 sal_uInt32 nSteps,
     268             :                 double fBorder,
     269             :                 double fOffsetX,
     270             :                 double fOffsetY,
     271             :                 double fAngle);
     272             :             virtual ~GeoTexSvxGradientRect();
     273             : 
     274             :             virtual void appendTransformationsAndColors(
     275             :                 std::vector< B2DHomMatrixAndBColor >& rEntries,
     276             :                 basegfx::BColor& rOuterColor) SAL_OVERRIDE;
     277             :             virtual void modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const SAL_OVERRIDE;
     278             :         };
     279             :     } // end of namespace texture
     280             : } // end of namespace drawinglayer
     281             : 
     282             : 
     283             : 
     284             : namespace drawinglayer
     285             : {
     286             :     namespace texture
     287             :     {
     288             :         class DRAWINGLAYER_DLLPUBLIC GeoTexSvxHatch : public GeoTexSvx
     289             :         {
     290             :         protected:
     291             :             basegfx::B2DRange                   maOutputRange;
     292             :             basegfx::B2DHomMatrix               maTextureTransform;
     293             :             basegfx::B2DHomMatrix               maBackTextureTransform;
     294             :             double                              mfDistance;
     295             :             double                              mfAngle;
     296             :             sal_uInt32                          mnSteps;
     297             : 
     298             :             /// bitfield
     299             :             bool                                mbDefinitionRangeEqualsOutputRange : 1;
     300             : 
     301             :         public:
     302             :             GeoTexSvxHatch(
     303             :                 const basegfx::B2DRange& rDefinitionRange,
     304             :                 const basegfx::B2DRange& rOutputRange,
     305             :                 double fDistance,
     306             :                 double fAngle);
     307             :             virtual ~GeoTexSvxHatch();
     308             : 
     309             :             // compare operator
     310             :             virtual bool operator==(const GeoTexSvx& rGeoTexSvx) const SAL_OVERRIDE;
     311             : 
     312             :             void appendTransformations(::std::vector< basegfx::B2DHomMatrix >& rMatrices);
     313             :             double getDistanceToHatch(const basegfx::B2DPoint& rUV) const;
     314             :             const basegfx::B2DHomMatrix& getBackTextureTransform() const;
     315             :         };
     316             :     } // end of namespace texture
     317             : } // end of namespace drawinglayer
     318             : 
     319             : 
     320             : 
     321             : namespace drawinglayer
     322             : {
     323             :     namespace texture
     324             :     {
     325             :         // This class applies a tiling to the unit range. The given range
     326             :         // will be repeated inside the unit range in X and Y and for each
     327             :         // tile a matrix will be created (by appendTransformations) that
     328             :         // represents the needed transformation to map a filling in unit
     329             :         // coordinates to that tile.
     330             :         // When offsetX is given, every 2nd line will be ofsetted by the
     331             :         // given percentage value (offsetX has to be 0.0 <= offsetX <= 1.0).
     332             :         // Accordingly to offsetY. If both are given, offsetX is preferred
     333             :         // and offsetY is ignored.
     334             :         class DRAWINGLAYER_DLLPUBLIC GeoTexSvxTiled : public GeoTexSvx
     335             :         {
     336             :         protected:
     337             :             basegfx::B2DRange               maRange;
     338             :             double                          mfOffsetX;
     339             :             double                          mfOffsetY;
     340             : 
     341             :         public:
     342             :             GeoTexSvxTiled(
     343             :                 const basegfx::B2DRange& rRange,
     344             :                 double fOffsetX = 0.0,
     345             :                 double fOffsetY = 0.0);
     346             :             virtual ~GeoTexSvxTiled();
     347             : 
     348             :             // compare operator
     349             :             virtual bool operator==(const GeoTexSvx& rGeoTexSvx) const SAL_OVERRIDE;
     350             : 
     351             :             void appendTransformations(::std::vector< basegfx::B2DHomMatrix >& rMatrices);
     352             :         };
     353             :     } // end of namespace texture
     354             : } // end of namespace drawinglayer
     355             : 
     356             : 
     357             : 
     358             : #endif //_DRAWINGLAYER_TEXTURE_TEXTURE_HXX
     359             : 
     360             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11