1 // Copyright 2014 PDFium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 6 7 #ifndef _FDE_BRUSH 8 #define _FDE_BRUSH 9 class IFDE_Image; 10 class IFDE_Path; 11 class IFDE_Brush; 12 class IFDE_SolidBrush; 13 class IFDE_HatchBrush; 14 class IFDE_TextureBrush; 15 class IFDE_LinearGradientBrush; 16 #define FDE_BRUSHTYPE_Unknown -1 17 #define FDE_BRUSHTYPE_Solid 0 18 #define FDE_BRUSHTYPE_Hatch 1 19 #define FDE_BRUSHTYPE_Texture 2 20 #define FDE_BRUSHTYPE_LinearGradient 3 21 #define FDE_BRUSHTYPE_MAX 3 22 #define FDE_WRAPMODE_Tile 0 23 #define FDE_WRAPMODE_TileFlipX 1 24 #define FDE_WRAPMODE_TileFlipY 2 25 #define FDE_WRAPMODE_TileFlipXY 3 26 #define FDE_WRAPMODE_Clamp 4 27 typedef struct _FDE_GRADIENTCOLOR { 28 FX_FLOAT pos; 29 FX_ARGB color; 30 } FDE_GRADIENTCOLOR, *FDE_LPGRADIENTCOLOR; 31 typedef FDE_GRADIENTCOLOR const* FDE_LPCGRADIENTCOLOR; 32 typedef CFX_ArrayTemplate<FDE_GRADIENTCOLOR> CFDE_GradientColors; 33 class IFDE_Brush { 34 public: 35 static IFDE_Brush* Create(int32_t iType); 36 virtual ~IFDE_Brush() {} 37 virtual void Release() = 0; 38 virtual int32_t GetType() const = 0; 39 }; 40 class IFDE_SolidBrush : public IFDE_Brush { 41 public: 42 virtual FX_ARGB GetColor() const = 0; 43 virtual void SetColor(FX_ARGB color) = 0; 44 virtual const CFX_Matrix& GetMatrix() const = 0; 45 virtual void ResetMatrix() = 0; 46 virtual void TranslateMatrix(FX_FLOAT dx, FX_FLOAT dy) = 0; 47 virtual void RotateMatrix(FX_FLOAT fRadian) = 0; 48 virtual void ScaleMatrix(FX_FLOAT sx, FX_FLOAT sy) = 0; 49 virtual void ConcatMatrix(const CFX_Matrix& matrix) = 0; 50 virtual void SetMatrix(const CFX_Matrix& matrix) = 0; 51 }; 52 #define FDE_HATCHSTYLE_Horizontal 0 53 #define FDE_HATCHSTYLE_Vertical 1 54 #define FDE_HATCHSTYLE_ForwardDiagonal 2 55 #define FDE_HATCHSTYLE_BackwardDiagonal 3 56 #define FDE_HATCHSTYLE_Cross 4 57 #define FDE_HATCHSTYLE_DiagonalCross 5 58 #define FDE_HATCHSTYLE_05Percent 6 59 #define FDE_HATCHSTYLE_10Percent 7 60 #define FDE_HATCHSTYLE_20Percent 8 61 #define FDE_HATCHSTYLE_25Percent 9 62 #define FDE_HATCHSTYLE_30Percent 10 63 #define FDE_HATCHSTYLE_40Percent 11 64 #define FDE_HATCHSTYLE_50Percent 12 65 #define FDE_HATCHSTYLE_60Percent 13 66 #define FDE_HATCHSTYLE_70Percent 14 67 #define FDE_HATCHSTYLE_75Percent 15 68 #define FDE_HATCHSTYLE_80Percent 16 69 #define FDE_HATCHSTYLE_90Percent 17 70 #define FDE_HATCHSTYLE_LightDownwardDiagonal 18 71 #define FDE_HATCHSTYLE_LightUpwardDiagonal 19 72 #define FDE_HATCHSTYLE_DarkDownwardDiagonal 20 73 #define FDE_HATCHSTYLE_DarkUpwardDiagonal 21 74 #define FDE_HATCHSTYLE_WideDownwardDiagonal 22 75 #define FDE_HATCHSTYLE_WideUpwardDiagonal 23 76 #define FDE_HATCHSTYLE_LightVertical 24 77 #define FDE_HATCHSTYLE_LightHorizontal 25 78 #define FDE_HATCHSTYLE_NarrowVertical 26 79 #define FDE_HATCHSTYLE_NarrowHorizontal 27 80 #define FDE_HATCHSTYLE_DarkVertical 28 81 #define FDE_HATCHSTYLE_DarkHorizontal 29 82 #define FDE_HATCHSTYLE_DashedDownwardDiagonal 30 83 #define FDE_HATCHSTYLE_DashedUpwardDiagonal 31 84 #define FDE_HATCHSTYLE_DashedHorizontal 32 85 #define FDE_HATCHSTYLE_DashedVertical 33 86 #define FDE_HATCHSTYLE_SmallConfetti 34 87 #define FDE_HATCHSTYLE_LargeConfetti 35 88 #define FDE_HATCHSTYLE_ZigZag 36 89 #define FDE_HATCHSTYLE_Wave 37 90 #define FDE_HATCHSTYLE_DiagonalBrick 38 91 #define FDE_HATCHSTYLE_HorizontalBrick 39 92 #define FDE_HATCHSTYLE_Weave 40 93 #define FDE_HATCHSTYLE_Plaid 41 94 #define FDE_HATCHSTYLE_Divot 42 95 #define FDE_HATCHSTYLE_DottedGrid 43 96 #define FDE_HATCHSTYLE_DottedDiamond 44 97 #define FDE_HATCHSTYLE_Shingle 45 98 #define FDE_HATCHSTYLE_Trellis 46 99 #define FDE_HATCHSTYLE_Sphere 47 100 #define FDE_HATCHSTYLE_SmallGrid 48 101 #define FDE_HATCHSTYLE_SmallCheckerBoard 49 102 #define FDE_HATCHSTYLE_LargeCheckerBoard 50 103 #define FDE_HATCHSTYLE_OutlinedDiamond 51 104 #define FDE_HATCHSTYLE_SolidDiamond 52 105 #define FDE_HATCHSTYLE_Total 53 106 #define FDE_HATCHSTYLE_LargeGrid FDE_HATCHSTYLE_Cross 107 #define FDE_HATCHSTYLE_Min FDE_HATCHSTYLE_Horizontal 108 #define FDE_HATCHSTYLE_Max (FDE_HATCHSTYLE_Total - 1) 109 class IFDE_HatchBrush : public IFDE_Brush { 110 public: 111 virtual FX_ARGB GetColor(FX_BOOL bForegroundColor) const = 0; 112 virtual void SetColor(FX_ARGB color, FX_BOOL bForegroundColor) = 0; 113 virtual int32_t GetHatchStyle() const = 0; 114 virtual FX_BOOL SetHatchStyle(int32_t iHatchStyle) = 0; 115 }; 116 class IFDE_TextureBrush : public IFDE_Brush { 117 public: 118 virtual IFDE_Image* GetImage() const = 0; 119 virtual void SetImage(IFDE_Image* pImage, FX_BOOL bAutoRelease) = 0; 120 virtual int32_t GetWrapMode() const = 0; 121 virtual void SetWrapMode(int32_t iWrapMode) = 0; 122 }; 123 #define FDE_LINEARGRADIENTMODE_Horizontal 0 124 #define FDE_LINEARGRADIENTMODE_Vertical 1 125 #define FDE_LINEARGRADIENTMODE_ForwardDiagonal 2 126 #define FDE_LINEARGRADIENTMODE_BackwardDiagonal 3 127 class IFDE_LinearGradientBrush : public IFDE_Brush { 128 public: 129 virtual void GetLinearPoints(CFX_PointF& startingPoint, 130 CFX_PointF& endingPoint) const = 0; 131 virtual void SetLinearPoints(const CFX_PointF& startingPoint, 132 const CFX_PointF& endingPoint) = 0; 133 virtual void GetLinearColors(FX_ARGB& startingColor, 134 FX_ARGB& endingColor) const = 0; 135 virtual void SetLinearColors(const FX_ARGB& startingColor, 136 const FX_ARGB& endingColor) = 0; 137 virtual int32_t CountGradientColors() const = 0; 138 virtual FX_BOOL GetGradientColors(CFDE_GradientColors& colors) const = 0; 139 virtual FX_BOOL SetGradientColors(const CFDE_GradientColors& colors) = 0; 140 virtual int32_t GetWrapMode() const = 0; 141 virtual void SetWrapMode(int32_t iWrapMode) = 0; 142 }; 143 #endif 144