| OLD | NEW |
| 1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #ifndef XFA_FXGRAPHICS_INCLUDE_CFX_GRAPHICS_H_ | 7 #ifndef XFA_FXGRAPHICS_INCLUDE_CFX_GRAPHICS_H_ |
| 8 #define XFA_FXGRAPHICS_INCLUDE_CFX_GRAPHICS_H_ | 8 #define XFA_FXGRAPHICS_INCLUDE_CFX_GRAPHICS_H_ |
| 9 | 9 |
| 10 #include "core/fxcrt/include/fx_system.h" | 10 #include "core/fxcrt/include/fx_system.h" |
| 11 #include "core/fxge/include/fx_dib.h" | 11 #include "core/fxge/include/fx_dib.h" |
| 12 #include "core/fxge/include/fx_ge.h" | 12 #include "core/fxge/include/fx_ge.h" |
| 13 #include "xfa/fwl/core/fwl_error.h" |
| 13 | 14 |
| 14 class CFX_Color; | 15 class CFX_Color; |
| 15 class CFX_Path; | 16 class CFX_Path; |
| 16 class CAGG_Graphics; | 17 class CAGG_Graphics; |
| 17 | 18 |
| 18 #define FX_ERR_Succeeded 0 | |
| 19 #define FX_ERR_Indefinite -1 | |
| 20 #define FX_ERR_Parameter_Invalid -100 | |
| 21 #define FX_ERR_Property_Invalid -200 | |
| 22 #define FX_ERR_Intermediate_Value_Invalid -300 | |
| 23 #define FX_ERR_Method_Not_Supported -400 | |
| 24 #define FX_ERR_Out_Of_Memory -500 | |
| 25 | |
| 26 using FX_ERR = int; | |
| 27 using FX_DeviceCap = int32_t; | 19 using FX_DeviceCap = int32_t; |
| 28 using FX_FillMode = int32_t; | 20 using FX_FillMode = int32_t; |
| 29 | 21 |
| 30 enum FX_DashStyle { | 22 enum FX_DashStyle { |
| 31 FX_DASHSTYLE_Solid = 0, | 23 FX_DASHSTYLE_Solid = 0, |
| 32 FX_DASHSTYLE_Dash = 1, | 24 FX_DASHSTYLE_Dash = 1, |
| 33 FX_DASHSTYLE_Dot = 2, | 25 FX_DASHSTYLE_Dot = 2, |
| 34 FX_DASHSTYLE_DashDot = 3, | 26 FX_DASHSTYLE_DashDot = 3, |
| 35 FX_DASHSTYLE_DashDotDot = 4 | 27 FX_DASHSTYLE_DashDotDot = 4 |
| 36 }; | 28 }; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 FX_HATCHSTYLE_SolidDiamond = 52 | 91 FX_HATCHSTYLE_SolidDiamond = 52 |
| 100 }; | 92 }; |
| 101 | 93 |
| 102 class CFX_RenderDevice; | 94 class CFX_RenderDevice; |
| 103 | 95 |
| 104 class CFX_Graphics { | 96 class CFX_Graphics { |
| 105 public: | 97 public: |
| 106 CFX_Graphics(); | 98 CFX_Graphics(); |
| 107 virtual ~CFX_Graphics(); | 99 virtual ~CFX_Graphics(); |
| 108 | 100 |
| 109 FX_ERR Create(CFX_RenderDevice* renderDevice, FX_BOOL isAntialiasing = TRUE); | 101 FWL_Error Create(CFX_RenderDevice* renderDevice, |
| 110 FX_ERR Create(int32_t width, | 102 FX_BOOL isAntialiasing = TRUE); |
| 111 int32_t height, | 103 FWL_Error Create(int32_t width, |
| 112 FXDIB_Format format, | 104 int32_t height, |
| 113 FX_BOOL isNative = TRUE, | 105 FXDIB_Format format, |
| 114 FX_BOOL isAntialiasing = TRUE); | 106 FX_BOOL isNative = TRUE, |
| 107 FX_BOOL isAntialiasing = TRUE); |
| 115 | 108 |
| 116 FX_ERR GetDeviceCap(const int32_t capID, FX_DeviceCap& capVal); | 109 FWL_Error GetDeviceCap(const int32_t capID, FX_DeviceCap& capVal); |
| 117 FX_ERR IsPrinterDevice(FX_BOOL& isPrinter); | 110 FWL_Error IsPrinterDevice(FX_BOOL& isPrinter); |
| 118 FX_ERR EnableAntialiasing(FX_BOOL isAntialiasing); | 111 FWL_Error EnableAntialiasing(FX_BOOL isAntialiasing); |
| 119 | 112 |
| 120 FX_ERR SaveGraphState(); | 113 FWL_Error SaveGraphState(); |
| 121 FX_ERR RestoreGraphState(); | 114 FWL_Error RestoreGraphState(); |
| 122 | 115 |
| 123 FX_ERR GetLineCap(CFX_GraphStateData::LineCap& lineCap) const; | 116 FWL_Error GetLineCap(CFX_GraphStateData::LineCap& lineCap) const; |
| 124 FX_ERR GetDashCount(int32_t& dashCount) const; | 117 FWL_Error GetDashCount(int32_t& dashCount) const; |
| 125 FX_ERR GetLineDash(FX_FLOAT& dashPhase, FX_FLOAT* dashArray) const; | 118 FWL_Error GetLineDash(FX_FLOAT& dashPhase, FX_FLOAT* dashArray) const; |
| 126 FX_ERR GetLineJoin(CFX_GraphStateData::LineJoin& lineJoin) const; | 119 FWL_Error GetLineJoin(CFX_GraphStateData::LineJoin& lineJoin) const; |
| 127 FX_ERR GetMiterLimit(FX_FLOAT& miterLimit) const; | 120 FWL_Error GetMiterLimit(FX_FLOAT& miterLimit) const; |
| 128 FX_ERR GetLineWidth(FX_FLOAT& lineWidth) const; | 121 FWL_Error GetLineWidth(FX_FLOAT& lineWidth) const; |
| 129 FX_ERR GetStrokeAlignment(FX_StrokeAlignment& strokeAlignment) const; | 122 FWL_Error GetStrokeAlignment(FX_StrokeAlignment& strokeAlignment) const; |
| 130 FX_ERR GetClipRect(CFX_RectF& rect) const; | 123 FWL_Error GetClipRect(CFX_RectF& rect) const; |
| 131 CFX_Matrix* GetMatrix(); | 124 CFX_Matrix* GetMatrix(); |
| 132 CFX_RenderDevice* GetRenderDevice(); | 125 CFX_RenderDevice* GetRenderDevice(); |
| 133 | 126 |
| 134 FX_ERR SetLineCap(CFX_GraphStateData::LineCap lineCap); | 127 FWL_Error SetLineCap(CFX_GraphStateData::LineCap lineCap); |
| 135 FX_ERR SetLineDash(FX_FLOAT dashPhase, | 128 FWL_Error SetLineDash(FX_FLOAT dashPhase, |
| 136 FX_FLOAT* dashArray, | 129 FX_FLOAT* dashArray, |
| 137 int32_t dashCount); | 130 int32_t dashCount); |
| 138 FX_ERR SetLineDash(FX_DashStyle dashStyle); | 131 FWL_Error SetLineDash(FX_DashStyle dashStyle); |
| 139 FX_ERR SetLineJoin(CFX_GraphStateData::LineJoin lineJoin); | 132 FWL_Error SetLineJoin(CFX_GraphStateData::LineJoin lineJoin); |
| 140 FX_ERR SetMiterLimit(FX_FLOAT miterLimit); | 133 FWL_Error SetMiterLimit(FX_FLOAT miterLimit); |
| 141 FX_ERR SetLineWidth(FX_FLOAT lineWidth, FX_BOOL isActOnDash = FALSE); | 134 FWL_Error SetLineWidth(FX_FLOAT lineWidth, FX_BOOL isActOnDash = FALSE); |
| 142 FX_ERR SetStrokeAlignment(FX_StrokeAlignment strokeAlignment); | 135 FWL_Error SetStrokeAlignment(FX_StrokeAlignment strokeAlignment); |
| 143 FX_ERR SetStrokeColor(CFX_Color* color); | 136 FWL_Error SetStrokeColor(CFX_Color* color); |
| 144 FX_ERR SetFillColor(CFX_Color* color); | 137 FWL_Error SetFillColor(CFX_Color* color); |
| 145 FX_ERR SetClipRect(const CFX_RectF& rect); | 138 FWL_Error SetClipRect(const CFX_RectF& rect); |
| 146 FX_ERR SetFont(CFX_Font* font); | 139 FWL_Error SetFont(CFX_Font* font); |
| 147 FX_ERR SetFontSize(const FX_FLOAT size); | 140 FWL_Error SetFontSize(const FX_FLOAT size); |
| 148 FX_ERR SetFontHScale(const FX_FLOAT scale); | 141 FWL_Error SetFontHScale(const FX_FLOAT scale); |
| 149 FX_ERR SetCharSpacing(const FX_FLOAT spacing); | 142 FWL_Error SetCharSpacing(const FX_FLOAT spacing); |
| 150 FX_ERR SetTextDrawingMode(const int32_t mode); | 143 FWL_Error SetTextDrawingMode(const int32_t mode); |
| 151 | 144 |
| 152 FX_ERR StrokePath(CFX_Path* path, CFX_Matrix* matrix = NULL); | 145 FWL_Error StrokePath(CFX_Path* path, CFX_Matrix* matrix = NULL); |
| 153 FX_ERR FillPath(CFX_Path* path, | 146 FWL_Error FillPath(CFX_Path* path, |
| 154 FX_FillMode fillMode = FXFILL_WINDING, | 147 FX_FillMode fillMode = FXFILL_WINDING, |
| 155 CFX_Matrix* matrix = NULL); | 148 CFX_Matrix* matrix = NULL); |
| 156 FX_ERR ClipPath(CFX_Path* path, | 149 FWL_Error ClipPath(CFX_Path* path, |
| 157 FX_FillMode fillMode = FXFILL_WINDING, | 150 FX_FillMode fillMode = FXFILL_WINDING, |
| 158 CFX_Matrix* matrix = NULL); | 151 CFX_Matrix* matrix = NULL); |
| 159 FX_ERR DrawImage(CFX_DIBSource* source, | 152 FWL_Error DrawImage(CFX_DIBSource* source, |
| 160 const CFX_PointF& point, | 153 const CFX_PointF& point, |
| 161 CFX_Matrix* matrix = NULL); | |
| 162 FX_ERR StretchImage(CFX_DIBSource* source, | |
| 163 const CFX_RectF& rect, | |
| 164 CFX_Matrix* matrix = NULL); | 154 CFX_Matrix* matrix = NULL); |
| 165 FX_ERR ConcatMatrix(const CFX_Matrix* matrix); | 155 FWL_Error StretchImage(CFX_DIBSource* source, |
| 166 FX_ERR ClearClip(); | 156 const CFX_RectF& rect, |
| 167 FX_ERR ShowText(const CFX_PointF& point, | 157 CFX_Matrix* matrix = NULL); |
| 168 const CFX_WideString& text, | 158 FWL_Error ConcatMatrix(const CFX_Matrix* matrix); |
| 169 CFX_Matrix* matrix = NULL); | 159 FWL_Error ClearClip(); |
| 170 FX_ERR CalcTextRect(CFX_RectF& rect, | 160 FWL_Error ShowText(const CFX_PointF& point, |
| 171 const CFX_WideString& text, | 161 const CFX_WideString& text, |
| 172 FX_BOOL isMultiline = FALSE, | 162 CFX_Matrix* matrix = NULL); |
| 173 CFX_Matrix* matrix = NULL); | 163 FWL_Error CalcTextRect(CFX_RectF& rect, |
| 174 FX_ERR Transfer(CFX_Graphics* graphics, const CFX_Matrix* matrix); | 164 const CFX_WideString& text, |
| 175 FX_ERR Transfer(CFX_Graphics* graphics, | 165 FX_BOOL isMultiline = FALSE, |
| 176 FX_FLOAT srcLeft, | 166 CFX_Matrix* matrix = NULL); |
| 177 FX_FLOAT srcTop, | 167 FWL_Error Transfer(CFX_Graphics* graphics, const CFX_Matrix* matrix); |
| 178 const CFX_RectF& dstRect, | 168 FWL_Error Transfer(CFX_Graphics* graphics, |
| 179 const CFX_Matrix* matrix); | 169 FX_FLOAT srcLeft, |
| 170 FX_FLOAT srcTop, |
| 171 const CFX_RectF& dstRect, |
| 172 const CFX_Matrix* matrix); |
| 180 | 173 |
| 181 FX_ERR InverseRect(const CFX_RectF& rect); | 174 FWL_Error InverseRect(const CFX_RectF& rect); |
| 182 FX_ERR XorDIBitmap(const CFX_DIBitmap* srcBitmap, const CFX_RectF& rect); | 175 FWL_Error XorDIBitmap(const CFX_DIBitmap* srcBitmap, const CFX_RectF& rect); |
| 183 FX_ERR EqvDIBitmap(const CFX_DIBitmap* srcBitmap, const CFX_RectF& rect); | 176 FWL_Error EqvDIBitmap(const CFX_DIBitmap* srcBitmap, const CFX_RectF& rect); |
| 184 | 177 |
| 185 protected: | 178 protected: |
| 186 int32_t m_type; | 179 int32_t m_type; |
| 187 | 180 |
| 188 private: | 181 private: |
| 189 struct TInfo { | 182 struct TInfo { |
| 190 TInfo() | 183 TInfo() |
| 191 : isAntialiasing(TRUE), | 184 : isAntialiasing(TRUE), |
| 192 strokeAlignment(FX_STROKEALIGNMENT_Center), | 185 strokeAlignment(FX_STROKEALIGNMENT_Center), |
| 193 isActOnDash(FALSE), | 186 isActOnDash(FALSE), |
| (...skipping 12 matching lines...) Expand all Loading... |
| 206 CFX_Matrix CTM; | 199 CFX_Matrix CTM; |
| 207 FX_BOOL isActOnDash; | 200 FX_BOOL isActOnDash; |
| 208 CFX_Color* strokeColor; | 201 CFX_Color* strokeColor; |
| 209 CFX_Color* fillColor; | 202 CFX_Color* fillColor; |
| 210 CFX_Font* font; | 203 CFX_Font* font; |
| 211 FX_FLOAT fontSize; | 204 FX_FLOAT fontSize; |
| 212 FX_FLOAT fontHScale; | 205 FX_FLOAT fontHScale; |
| 213 FX_FLOAT fontSpacing; | 206 FX_FLOAT fontSpacing; |
| 214 } m_info; | 207 } m_info; |
| 215 | 208 |
| 216 FX_ERR RenderDeviceSetLineDash(FX_DashStyle dashStyle); | 209 FWL_Error RenderDeviceSetLineDash(FX_DashStyle dashStyle); |
| 217 FX_ERR RenderDeviceStrokePath(CFX_Path* path, CFX_Matrix* matrix); | 210 FWL_Error RenderDeviceStrokePath(CFX_Path* path, CFX_Matrix* matrix); |
| 218 FX_ERR RenderDeviceFillPath(CFX_Path* path, | 211 FWL_Error RenderDeviceFillPath(CFX_Path* path, |
| 219 FX_FillMode fillMode, | 212 FX_FillMode fillMode, |
| 220 CFX_Matrix* matrix); | 213 CFX_Matrix* matrix); |
| 221 FX_ERR RenderDeviceDrawImage(CFX_DIBSource* source, | 214 FWL_Error RenderDeviceDrawImage(CFX_DIBSource* source, |
| 222 const CFX_PointF& point, | 215 const CFX_PointF& point, |
| 223 CFX_Matrix* matrix); | |
| 224 FX_ERR RenderDeviceStretchImage(CFX_DIBSource* source, | |
| 225 const CFX_RectF& rect, | |
| 226 CFX_Matrix* matrix); | 216 CFX_Matrix* matrix); |
| 227 FX_ERR RenderDeviceShowText(const CFX_PointF& point, | 217 FWL_Error RenderDeviceStretchImage(CFX_DIBSource* source, |
| 228 const CFX_WideString& text, | 218 const CFX_RectF& rect, |
| 229 CFX_Matrix* matrix); | 219 CFX_Matrix* matrix); |
| 220 FWL_Error RenderDeviceShowText(const CFX_PointF& point, |
| 221 const CFX_WideString& text, |
| 222 CFX_Matrix* matrix); |
| 230 | 223 |
| 231 FX_ERR StrokePathWithPattern(CFX_Path* path, CFX_Matrix* matrix); | 224 FWL_Error StrokePathWithPattern(CFX_Path* path, CFX_Matrix* matrix); |
| 232 FX_ERR StrokePathWithShading(CFX_Path* path, CFX_Matrix* matrix); | 225 FWL_Error StrokePathWithShading(CFX_Path* path, CFX_Matrix* matrix); |
| 233 | 226 |
| 234 FX_ERR FillPathWithPattern(CFX_Path* path, | 227 FWL_Error FillPathWithPattern(CFX_Path* path, |
| 235 FX_FillMode fillMode, | 228 FX_FillMode fillMode, |
| 236 CFX_Matrix* matrix); | 229 CFX_Matrix* matrix); |
| 237 FX_ERR FillPathWithShading(CFX_Path* path, | 230 FWL_Error FillPathWithShading(CFX_Path* path, |
| 238 FX_FillMode fillMode, | 231 FX_FillMode fillMode, |
| 239 CFX_Matrix* matrix); | 232 CFX_Matrix* matrix); |
| 240 | 233 |
| 241 FX_ERR SetDIBitsWithMatrix(CFX_DIBSource* source, CFX_Matrix* matrix); | 234 FWL_Error SetDIBitsWithMatrix(CFX_DIBSource* source, CFX_Matrix* matrix); |
| 242 FX_ERR CalcTextInfo(const CFX_WideString& text, | 235 FWL_Error CalcTextInfo(const CFX_WideString& text, |
| 243 uint32_t* charCodes, | 236 uint32_t* charCodes, |
| 244 FXTEXT_CHARPOS* charPos, | 237 FXTEXT_CHARPOS* charPos, |
| 245 CFX_RectF& rect); | 238 CFX_RectF& rect); |
| 246 | 239 |
| 247 CFX_RenderDevice* m_renderDevice; | 240 CFX_RenderDevice* m_renderDevice; |
| 248 CFX_ArrayTemplate<TInfo*> m_infoStack; | 241 CFX_ArrayTemplate<TInfo*> m_infoStack; |
| 249 CAGG_Graphics* m_aggGraphics; | 242 CAGG_Graphics* m_aggGraphics; |
| 250 friend class CAGG_Graphics; | 243 friend class CAGG_Graphics; |
| 251 }; | 244 }; |
| 252 | 245 |
| 253 #endif // XFA_FXGRAPHICS_INCLUDE_CFX_GRAPHICS_H_ | 246 #endif // XFA_FXGRAPHICS_INCLUDE_CFX_GRAPHICS_H_ |
| OLD | NEW |