svgtopt/nvgdecoder/inc/NVGCSIcon.h
changeset 46 88edb906c587
equal deleted inserted replaced
-1:000000000000 46:88edb906c587
       
     1 /*
       
     2 * Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  NVG Decoder header file
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef NVGCSICON_H_
       
    20 #define NVGCSICON_H_
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <openvg.h>
       
    24 
       
    25 #include "NVGIcon.h"
       
    26 
       
    27 class CNVGIconData;
       
    28 class CNvgEngine;
       
    29 class COpenVGHandleStore;
       
    30 
       
    31 class CNVGCSIcon : public CBase, public MNVGIcon
       
    32     {
       
    33 private:
       
    34     enum TNVGCSIconCommands
       
    35         {
       
    36         EPath,
       
    37         EPathData,
       
    38         EPaint,
       
    39         EColorRamp,
       
    40         ETransform,
       
    41         EStrokeWidth,
       
    42         EStrokeMiterLimit,
       
    43         EStrokeLineJoinCap,
       
    44         EStrokePaint,
       
    45         EStrokeColorRamp
       
    46         };
       
    47 
       
    48     CNVGCSIcon();
       
    49     void ConstructL(const TDesC8& aBuf);
       
    50     
       
    51 public:
       
    52     static CNVGCSIcon * NewL(const TDesC8& aBuf);
       
    53     static CNVGCSIcon * NewLC(const TDesC8& aBuf);
       
    54     virtual ~CNVGCSIcon();
       
    55     
       
    56     virtual TInt Draw(const TSize aSize, CNvgEngine * aNVGEngine);
       
    57     
       
    58     TInt SetViewBox(TReal32 x, TReal32 y, TReal32 w, TReal32 h) __SOFTFP;
       
    59 
       
    60     TInt SetPreserveAspectRatio(TInt aPreserveAspectSetting, 
       
    61             TInt aSmilFitSetting);
       
    62 
       
    63     TInt Rotate(TReal32 aAngle, TReal32 aX, TReal32 aY) __SOFTFP;
       
    64     
       
    65     /**
       
    66      * Adds new path drawing command. 
       
    67      * @param aPath vgPath to be appended
       
    68      */
       
    69     void AddDrawPathCommandL(VGPath aPath, VGbitfield aPaintMode);
       
    70     
       
    71     /**
       
    72      * Adds path data. This is required if vgCreatePath fails. 
       
    73      */        
       
    74     void AddPathDataL(VGint numSegments, const VGubyte * pathSegments, const void * pathData);
       
    75     
       
    76     /**
       
    77      * Adds linear gradient drawing command. Stores the gradient data and matrix
       
    78      * to be used with VG_MATRIX_FILL_PAINT_TO_USER mode.
       
    79      * 
       
    80      * @param aCount            Gradient data parameter count
       
    81      * @param aGradientData     Linear gradient data to be given to vgSetParameterfv
       
    82      * @param aGradientMatrix   Linear gradient matrix used for FILL_PAINT_TO_USER matrix mode
       
    83      */
       
    84     void AddLinearGradientCommandL(VGint aCount, VGfloat* aGradientData, VGfloat* aGradientMatrix, VGPaint aPaint);
       
    85 
       
    86     /**
       
    87      * Adds radial gradient drawing command. Stores the gradient data and matrix
       
    88      * to be used with VG_MATRIX_FILL_PAINT_TO_USER mode.
       
    89      * 
       
    90      * @param aCount            Gradient data parameter count
       
    91      * @param aGradientData     Linear gradient data to be given to vgSetParameterfv
       
    92      * @param aGradientMatrix   Linear gradient matrix used for FILL_PAINT_TO_USER matrix mode
       
    93      */
       
    94     void AddRadialGradientCommandL(VGint aCount, VGfloat* aGradientData, VGfloat* aGradientMatrix, VGPaint aPaint);
       
    95     
       
    96     /**
       
    97      * Adds a setColor command to be used with paints.
       
    98      * 
       
    99      * @param aRgba RGBA color in hex format to be set with vgSetColor
       
   100      */
       
   101     void AddSetColorCommandL(VGuint aRgba);
       
   102 
       
   103     /**
       
   104      * Adds color ramp to the icon data structure.
       
   105      * 
       
   106      * @param aStopCount    Count of the color ramps, has to be multiple of 5
       
   107      * @param aColorRamps   Color ramp data
       
   108      */
       
   109     void AddColorRampCommandL(VGPaint aPaint);
       
   110     
       
   111     /**
       
   112      * Adds a transformation command which is multiplied to the current matrix
       
   113      * 
       
   114      * @param aTransformMatrix  Transformation matrix used for multiplication
       
   115      * @param aFlag 1 multiplies  aTransformMatrix with current matrix, 0 loads original matrix
       
   116      */
       
   117     void AddSetTransformCommandL(const VGfloat* aTransformMatrix, TInt aFlag);
       
   118     
       
   119     /**
       
   120      * Adds set stroke-width command
       
   121      * 
       
   122      * @param aStrokeWidth stroke width
       
   123      */
       
   124     void AddSetStrokeWidthCommandL(VGfloat aStrokeWidth);
       
   125     
       
   126     /**
       
   127      * Adds set stroke-miterlimit command
       
   128      * 
       
   129      * @param aMiterLimit miter length     
       
   130      */
       
   131     void AddSetStrokeMiterLimitCommandL(VGfloat aMiterLimit);
       
   132     
       
   133     /**
       
   134      * Adds set line join cap command
       
   135      * 
       
   136      * @param aCapStyle   end cap style
       
   137      * @param aJoinStyle  line join style
       
   138      */
       
   139     void AddStrokeLineJoinCapCommandL(VGint aCapStyle, VGint aJoinStyle);
       
   140 
       
   141     /**
       
   142      * Adds linear gradient drawing command. Stores the gradient data and matrix
       
   143      * 
       
   144      * @param aCount            Gradient data parameter count
       
   145      * @param aGradientData     Linear gradient data to be given to vgSetParameterfv
       
   146      * @param aGradientMatrix   Linear gradient matrix used for STROKE_PAINT_TO_USER matrix mode
       
   147      */
       
   148     void AddStrokeLinearGradientCommandL(VGint aCount, VGfloat* aGradientData, VGfloat* aGradientMatrix, VGPaint aPaint);
       
   149 
       
   150     /**
       
   151      * Adds radial gradient drawing command. Stores the gradient data and matrix
       
   152      * to be used with VG_MATRIX_STROKE_PAINT_TO_USER mode.
       
   153      * 
       
   154      * @param aCount            Gradient data parameter count
       
   155      * @param aGradientData     Linear gradient data to be given to vgSetParameterfv
       
   156      * @param aGradientMatrix   Linear gradient matrix used for VG_MATRIX_STROKE_PAINT_TO_USER matrix mode
       
   157      */
       
   158     void AddStrokeRadialGradientCommandL(VGint aCount, VGfloat* aGradientData, VGfloat* aGradientMatrix, VGPaint aPaint);
       
   159     
       
   160     /**
       
   161      * Adds a setColor command to be used with stroke.
       
   162      * 
       
   163      * @param aRgba RGBA color in hex format
       
   164      */
       
   165     void AddStrokeSetColorCommandL(VGuint aRgba);
       
   166     
       
   167     /**
       
   168      * Adds color ramp to the icon data structure.
       
   169      * 
       
   170      * @param aStopCount    Count of the color ramps, has to be multiple of 5
       
   171      * @param aColorRamps   Color ramp data
       
   172      */
       
   173     void AddStrokeColorRampCommandL(VGPaint aPaint);
       
   174     
       
   175 private:
       
   176 
       
   177     TInt DoDrawL(const TSize aSize);
       
   178 
       
   179     void AddLinearGradientCommandDataL(VGPaint aPaint, VGint aCount, VGfloat* aGradientData, VGfloat* aGradientMatrix);
       
   180     void AddRadialGradientCommandDataL(VGPaint aPaint, VGint aCount, VGfloat* aGradientData, VGfloat* aGradientMatrix);
       
   181     void AddSetColorCommandDataL(VGuint aRgba);
       
   182 
       
   183     void DrawPaintL(VGPaint aPaint, VGMatrixMode aMatrixMode, TUint & aLastPaintType, TUint & aLastPaintColor, VGPaintMode aPaintMode);
       
   184     void DrawColorRampL(VGPaint aPaint);
       
   185     void SetViewBoxToViewTransformationL(const TSize aSize);
       
   186     void SetRotation();
       
   187 
       
   188     void UpdateClientMatrices();
       
   189     void RestoreClientMatrices();
       
   190     
       
   191 private:
       
   192     TReal32             iViewBoxX;
       
   193     TReal32             iViewBoxY;
       
   194     TReal32             iViewBoxW;
       
   195     TReal32             iViewBoxH;
       
   196     
       
   197     TReal32             iRotationAngle;
       
   198     TReal32             iRotationX;
       
   199     TReal32             iRotationY;
       
   200     
       
   201     TInt                iPreserveAspectSetting;
       
   202     TInt                iSmilFitSetting;
       
   203 
       
   204     CNVGIconData *      iNVGIconData;
       
   205 
       
   206     VGPath              iPath;          // when create path fails this handle will be used
       
   207     VGPaint             iFillPaint;     // currently just one object for fill paint
       
   208     VGPaint             iStrokePaint;   // currently just one object for stroke paint
       
   209 
       
   210     // caller's parameters
       
   211     VGPaint             iUserStrokePaint;
       
   212     VGPaint             iUserFillPaint;
       
   213 
       
   214     VGint               iMatrixMode;
       
   215     TReal32             iImageMatrix[9];
       
   216     TReal32             iPathMatrix[9];
       
   217     TReal32             iFillPaintMatrix[9];
       
   218     TReal32             iStrokePaintMatrix[9];
       
   219     CNvgEngine *        iNVGEngine;
       
   220     COpenVGHandleStore* iOpenVGHandles;
       
   221     
       
   222     TUint       iLastFillPaintType;
       
   223     TUint       iLastStrokePaintType;
       
   224     TUint       iLastFillPaintColor;
       
   225     TUint       iLastStrkePaintColor;
       
   226     
       
   227     TUint       iResetFillPaint;
       
   228     VGPaint     iResetStrokePaint;
       
   229     };
       
   230 
       
   231 #endif