| OLD | NEW |
| (Empty) |
| 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 CORE_INCLUDE_FXGE_FX_GE_H_ | |
| 8 #define CORE_INCLUDE_FXGE_FX_GE_H_ | |
| 9 | |
| 10 #include "core/include/fxge/fx_dib.h" | |
| 11 #include "core/include/fxge/fx_font.h" | |
| 12 | |
| 13 class CFX_Font; | |
| 14 class CFX_FontMgr; | |
| 15 class CFX_FontCache; | |
| 16 class CFX_FaceCache; | |
| 17 class CPDF_ShadingPattern; | |
| 18 class IFX_RenderDeviceDriver; | |
| 19 class CCodec_ModuleMgr; | |
| 20 class SkPictureRecorder; | |
| 21 | |
| 22 class CFX_GEModule { | |
| 23 public: | |
| 24 static void Create(const char** pUserFontPaths); | |
| 25 | |
| 26 static void Use(CFX_GEModule* pMgr); | |
| 27 | |
| 28 static CFX_GEModule* Get(); | |
| 29 | |
| 30 static void Destroy(); | |
| 31 | |
| 32 public: | |
| 33 CFX_FontCache* GetFontCache(); | |
| 34 CFX_FontMgr* GetFontMgr() { return m_pFontMgr; } | |
| 35 void SetTextGamma(FX_FLOAT gammaValue); | |
| 36 const uint8_t* GetTextGammaTable(); | |
| 37 | |
| 38 void SetCodecModule(CCodec_ModuleMgr* pCodecModule) { | |
| 39 m_pCodecModule = pCodecModule; | |
| 40 } | |
| 41 CCodec_ModuleMgr* GetCodecModule() { return m_pCodecModule; } | |
| 42 FXFT_Library m_FTLibrary; | |
| 43 void* GetPlatformData() { return m_pPlatformData; } | |
| 44 | |
| 45 protected: | |
| 46 explicit CFX_GEModule(const char** pUserFontPaths); | |
| 47 | |
| 48 ~CFX_GEModule(); | |
| 49 void InitPlatform(); | |
| 50 void DestroyPlatform(); | |
| 51 | |
| 52 private: | |
| 53 uint8_t m_GammaValue[256]; | |
| 54 CFX_FontCache* m_pFontCache; | |
| 55 CFX_FontMgr* m_pFontMgr; | |
| 56 CCodec_ModuleMgr* m_pCodecModule; | |
| 57 void* m_pPlatformData; | |
| 58 const char** m_pUserFontPaths; | |
| 59 }; | |
| 60 typedef struct { | |
| 61 FX_FLOAT m_PointX; | |
| 62 | |
| 63 FX_FLOAT m_PointY; | |
| 64 | |
| 65 int m_Flag; | |
| 66 } FX_PATHPOINT; | |
| 67 #define FXPT_CLOSEFIGURE 0x01 | |
| 68 #define FXPT_LINETO 0x02 | |
| 69 #define FXPT_BEZIERTO 0x04 | |
| 70 #define FXPT_MOVETO 0x06 | |
| 71 #define FXPT_TYPE 0x06 | |
| 72 #define FXFILL_ALTERNATE 1 | |
| 73 #define FXFILL_WINDING 2 | |
| 74 class CFX_ClipRgn { | |
| 75 public: | |
| 76 CFX_ClipRgn(int device_width, int device_height); | |
| 77 | |
| 78 CFX_ClipRgn(const FX_RECT& rect); | |
| 79 | |
| 80 CFX_ClipRgn(const CFX_ClipRgn& src); | |
| 81 | |
| 82 ~CFX_ClipRgn(); | |
| 83 | |
| 84 typedef enum { RectI, MaskF } ClipType; | |
| 85 | |
| 86 void Reset(const FX_RECT& rect); | |
| 87 | |
| 88 ClipType GetType() const { return m_Type; } | |
| 89 | |
| 90 const FX_RECT& GetBox() const { return m_Box; } | |
| 91 | |
| 92 CFX_DIBitmapRef GetMask() const { return m_Mask; } | |
| 93 | |
| 94 void IntersectRect(const FX_RECT& rect); | |
| 95 | |
| 96 void IntersectMaskF(int left, int top, CFX_DIBitmapRef Mask); | |
| 97 | |
| 98 protected: | |
| 99 ClipType m_Type; | |
| 100 | |
| 101 FX_RECT m_Box; | |
| 102 | |
| 103 CFX_DIBitmapRef m_Mask; | |
| 104 | |
| 105 void IntersectMaskRect(FX_RECT rect, FX_RECT mask_box, CFX_DIBitmapRef Mask); | |
| 106 }; | |
| 107 #define FX_GAMMA(value) (value) | |
| 108 #define FX_GAMMA_INVERSE(value) (value) | |
| 109 inline FX_ARGB ArgbGamma(FX_ARGB argb) { | |
| 110 return argb; | |
| 111 } | |
| 112 inline FX_ARGB ArgbGammaInverse(FX_ARGB argb) { | |
| 113 return argb; | |
| 114 } | |
| 115 class CFX_PathData { | |
| 116 public: | |
| 117 CFX_PathData(); | |
| 118 | |
| 119 CFX_PathData(const CFX_PathData& src); | |
| 120 | |
| 121 ~CFX_PathData(); | |
| 122 | |
| 123 int GetPointCount() const { return m_PointCount; } | |
| 124 | |
| 125 int GetFlag(int index) const { return m_pPoints[index].m_Flag; } | |
| 126 | |
| 127 FX_FLOAT GetPointX(int index) const { return m_pPoints[index].m_PointX; } | |
| 128 | |
| 129 FX_FLOAT GetPointY(int index) const { return m_pPoints[index].m_PointY; } | |
| 130 | |
| 131 FX_PATHPOINT* GetPoints() const { return m_pPoints; } | |
| 132 | |
| 133 void SetPointCount(int nPoints); | |
| 134 void AllocPointCount(int nPoints); | |
| 135 void AddPointCount(int addPoints); | |
| 136 | |
| 137 CFX_FloatRect GetBoundingBox() const; | |
| 138 | |
| 139 CFX_FloatRect GetBoundingBox(FX_FLOAT line_width, FX_FLOAT miter_limit) const; | |
| 140 | |
| 141 void Transform(const CFX_Matrix* pMatrix); | |
| 142 | |
| 143 FX_BOOL IsRect() const; | |
| 144 | |
| 145 FX_BOOL GetZeroAreaPath(CFX_PathData& NewPath, | |
| 146 CFX_Matrix* pMatrix, | |
| 147 FX_BOOL& bThin, | |
| 148 FX_BOOL bAdjust) const; | |
| 149 | |
| 150 FX_BOOL IsRect(const CFX_Matrix* pMatrix, CFX_FloatRect* rect) const; | |
| 151 | |
| 152 void Append(const CFX_PathData* pSrc, const CFX_Matrix* pMatrix); | |
| 153 void AppendRect(FX_FLOAT left, FX_FLOAT bottom, FX_FLOAT right, FX_FLOAT top); | |
| 154 | |
| 155 void SetPoint(int index, FX_FLOAT x, FX_FLOAT y, int flag); | |
| 156 | |
| 157 void TrimPoints(int nPoints); | |
| 158 | |
| 159 void Copy(const CFX_PathData& src); | |
| 160 | |
| 161 protected: | |
| 162 friend class CPDF_Path; | |
| 163 | |
| 164 int m_PointCount; | |
| 165 | |
| 166 FX_PATHPOINT* m_pPoints; | |
| 167 | |
| 168 int m_AllocCount; | |
| 169 }; | |
| 170 class CFX_GraphStateData { | |
| 171 public: | |
| 172 CFX_GraphStateData(); | |
| 173 | |
| 174 CFX_GraphStateData(const CFX_GraphStateData& src); | |
| 175 | |
| 176 ~CFX_GraphStateData(); | |
| 177 | |
| 178 void Copy(const CFX_GraphStateData& src); | |
| 179 | |
| 180 void SetDashCount(int count); | |
| 181 | |
| 182 typedef enum { LineCapButt = 0, LineCapRound = 1, LineCapSquare = 2 } LineCap; | |
| 183 LineCap m_LineCap; | |
| 184 int m_DashCount; | |
| 185 FX_FLOAT* m_DashArray; | |
| 186 FX_FLOAT m_DashPhase; | |
| 187 | |
| 188 typedef enum { | |
| 189 LineJoinMiter = 0, | |
| 190 LineJoinRound = 1, | |
| 191 LineJoinBevel = 2, | |
| 192 } LineJoin; | |
| 193 LineJoin m_LineJoin; | |
| 194 FX_FLOAT m_MiterLimit; | |
| 195 FX_FLOAT m_LineWidth; | |
| 196 }; | |
| 197 #define FXDC_DEVICE_CLASS 1 | |
| 198 #define FXDC_PIXEL_WIDTH 2 | |
| 199 #define FXDC_PIXEL_HEIGHT 3 | |
| 200 #define FXDC_BITS_PIXEL 4 | |
| 201 #define FXDC_HORZ_SIZE 5 | |
| 202 #define FXDC_VERT_SIZE 6 | |
| 203 #define FXDC_RENDER_CAPS 7 | |
| 204 #define FXDC_DITHER_BITS 8 | |
| 205 #define FXDC_DISPLAY 1 | |
| 206 #define FXDC_PRINTER 2 | |
| 207 #define FXRC_GET_BITS 0x01 | |
| 208 #define FXRC_BIT_MASK 0x02 | |
| 209 #define FXRC_ALPHA_MASK 0x04 | |
| 210 #define FXRC_ALPHA_PATH 0x10 | |
| 211 #define FXRC_ALPHA_IMAGE 0x20 | |
| 212 #define FXRC_ALPHA_OUTPUT 0x40 | |
| 213 #define FXRC_BLEND_MODE 0x80 | |
| 214 #define FXRC_SOFT_CLIP 0x100 | |
| 215 #define FXRC_CMYK_OUTPUT 0x200 | |
| 216 #define FXRC_BITMASK_OUTPUT 0x400 | |
| 217 #define FXRC_BYTEMASK_OUTPUT 0x800 | |
| 218 #define FXRENDER_IMAGE_LOSSY 0x1000 | |
| 219 #define FXRC_FILLSTROKE_PATH 0x2000 | |
| 220 #define FXRC_SHADING 0x4000 | |
| 221 #define FXFILL_ALTERNATE 1 | |
| 222 #define FXFILL_WINDING 2 | |
| 223 #define FXFILL_FULLCOVER 4 | |
| 224 #define FXFILL_RECT_AA 8 | |
| 225 #define FX_FILL_STROKE 16 | |
| 226 #define FX_STROKE_ADJUST 32 | |
| 227 #define FX_STROKE_TEXT_MODE 64 | |
| 228 #define FX_FILL_TEXT_MODE 128 | |
| 229 #define FX_ZEROAREA_FILL 256 | |
| 230 #define FXFILL_NOPATHSMOOTH 512 | |
| 231 #define FXTEXT_CLEARTYPE 0x01 | |
| 232 #define FXTEXT_BGR_STRIPE 0x02 | |
| 233 #define FXTEXT_PRINTGRAPHICTEXT 0x04 | |
| 234 #define FXTEXT_NO_NATIVETEXT 0x08 | |
| 235 #define FXTEXT_PRINTIMAGETEXT 0x10 | |
| 236 #define FXTEXT_NOSMOOTH 0x20 | |
| 237 typedef struct { | |
| 238 uint32_t m_GlyphIndex; | |
| 239 FX_FLOAT m_OriginX, m_OriginY; | |
| 240 int m_FontCharWidth; | |
| 241 FX_BOOL m_bGlyphAdjust; | |
| 242 FX_FLOAT m_AdjustMatrix[4]; | |
| 243 uint32_t m_ExtGID; | |
| 244 FX_BOOL m_bFontStyle; | |
| 245 } FXTEXT_CHARPOS; | |
| 246 | |
| 247 class CFX_RenderDevice { | |
| 248 public: | |
| 249 CFX_RenderDevice(); | |
| 250 virtual ~CFX_RenderDevice(); | |
| 251 | |
| 252 void SetDeviceDriver(IFX_RenderDeviceDriver* pDriver); | |
| 253 IFX_RenderDeviceDriver* GetDeviceDriver() const { return m_pDeviceDriver; } | |
| 254 | |
| 255 FX_BOOL StartRendering(); | |
| 256 void EndRendering(); | |
| 257 void SaveState(); | |
| 258 void RestoreState(FX_BOOL bKeepSaved = FALSE); | |
| 259 | |
| 260 int GetWidth() const { return m_Width; } | |
| 261 int GetHeight() const { return m_Height; } | |
| 262 int GetDeviceClass() const { return m_DeviceClass; } | |
| 263 int GetBPP() const { return m_bpp; } | |
| 264 int GetRenderCaps() const { return m_RenderCaps; } | |
| 265 int GetDeviceCaps(int id) const; | |
| 266 CFX_Matrix GetCTM() const; | |
| 267 | |
| 268 CFX_DIBitmap* GetBitmap() const { return m_pBitmap; } | |
| 269 void SetBitmap(CFX_DIBitmap* pBitmap) { m_pBitmap = pBitmap; } | |
| 270 | |
| 271 FX_BOOL CreateCompatibleBitmap(CFX_DIBitmap* pDIB, | |
| 272 int width, | |
| 273 int height) const; | |
| 274 | |
| 275 const FX_RECT& GetClipBox() const { return m_ClipBox; } | |
| 276 | |
| 277 FX_BOOL SetClip_PathFill(const CFX_PathData* pPathData, | |
| 278 const CFX_Matrix* pObject2Device, | |
| 279 int fill_mode); | |
| 280 | |
| 281 FX_BOOL SetClip_Rect(const FX_RECT& pRect); | |
| 282 FX_BOOL SetClip_PathStroke(const CFX_PathData* pPathData, | |
| 283 const CFX_Matrix* pObject2Device, | |
| 284 const CFX_GraphStateData* pGraphState); | |
| 285 | |
| 286 FX_BOOL DrawPath(const CFX_PathData* pPathData, | |
| 287 const CFX_Matrix* pObject2Device, | |
| 288 const CFX_GraphStateData* pGraphState, | |
| 289 uint32_t fill_color, | |
| 290 uint32_t stroke_color, | |
| 291 int fill_mode, | |
| 292 int alpha_flag = 0, | |
| 293 void* pIccTransform = NULL, | |
| 294 int blend_type = FXDIB_BLEND_NORMAL); | |
| 295 | |
| 296 FX_BOOL SetPixel(int x, | |
| 297 int y, | |
| 298 uint32_t color, | |
| 299 int alpha_flag = 0, | |
| 300 void* pIccTransform = NULL); | |
| 301 | |
| 302 FX_BOOL FillRect(const FX_RECT* pRect, | |
| 303 uint32_t color, | |
| 304 int alpha_flag = 0, | |
| 305 void* pIccTransform = NULL, | |
| 306 int blend_type = FXDIB_BLEND_NORMAL); | |
| 307 | |
| 308 FX_BOOL DrawCosmeticLine(FX_FLOAT x1, | |
| 309 FX_FLOAT y1, | |
| 310 FX_FLOAT x2, | |
| 311 FX_FLOAT y2, | |
| 312 uint32_t color, | |
| 313 int fill_mode = 0, | |
| 314 int alpha_flag = 0, | |
| 315 void* pIccTransform = NULL, | |
| 316 int blend_type = FXDIB_BLEND_NORMAL); | |
| 317 | |
| 318 FX_BOOL GetDIBits(CFX_DIBitmap* pBitmap, | |
| 319 int left, | |
| 320 int top, | |
| 321 void* pIccTransform = NULL); | |
| 322 | |
| 323 CFX_DIBitmap* GetBackDrop(); | |
| 324 | |
| 325 FX_BOOL SetDIBits(const CFX_DIBSource* pBitmap, | |
| 326 int left, | |
| 327 int top, | |
| 328 int blend_type = FXDIB_BLEND_NORMAL, | |
| 329 void* pIccTransform = NULL); | |
| 330 | |
| 331 FX_BOOL StretchDIBits(const CFX_DIBSource* pBitmap, | |
| 332 int left, | |
| 333 int top, | |
| 334 int dest_width, | |
| 335 int dest_height, | |
| 336 uint32_t flags = 0, | |
| 337 void* pIccTransform = NULL, | |
| 338 int blend_type = FXDIB_BLEND_NORMAL); | |
| 339 | |
| 340 FX_BOOL SetBitMask(const CFX_DIBSource* pBitmap, | |
| 341 int left, | |
| 342 int top, | |
| 343 uint32_t color, | |
| 344 int alpha_flag = 0, | |
| 345 void* pIccTransform = NULL); | |
| 346 | |
| 347 FX_BOOL StretchBitMask(const CFX_DIBSource* pBitmap, | |
| 348 int left, | |
| 349 int top, | |
| 350 int dest_width, | |
| 351 int dest_height, | |
| 352 uint32_t color, | |
| 353 uint32_t flags = 0, | |
| 354 int alpha_flag = 0, | |
| 355 void* pIccTransform = NULL); | |
| 356 | |
| 357 FX_BOOL StartDIBits(const CFX_DIBSource* pBitmap, | |
| 358 int bitmap_alpha, | |
| 359 uint32_t color, | |
| 360 const CFX_Matrix* pMatrix, | |
| 361 uint32_t flags, | |
| 362 void*& handle, | |
| 363 int alpha_flag = 0, | |
| 364 void* pIccTransform = NULL, | |
| 365 int blend_type = FXDIB_BLEND_NORMAL); | |
| 366 | |
| 367 FX_BOOL ContinueDIBits(void* handle, IFX_Pause* pPause); | |
| 368 | |
| 369 void CancelDIBits(void* handle); | |
| 370 | |
| 371 FX_BOOL DrawNormalText(int nChars, | |
| 372 const FXTEXT_CHARPOS* pCharPos, | |
| 373 CFX_Font* pFont, | |
| 374 CFX_FontCache* pCache, | |
| 375 FX_FLOAT font_size, | |
| 376 const CFX_Matrix* pText2Device, | |
| 377 uint32_t fill_color, | |
| 378 uint32_t text_flags, | |
| 379 int alpha_flag = 0, | |
| 380 void* pIccTransform = NULL); | |
| 381 | |
| 382 FX_BOOL DrawTextPath(int nChars, | |
| 383 const FXTEXT_CHARPOS* pCharPos, | |
| 384 CFX_Font* pFont, | |
| 385 CFX_FontCache* pCache, | |
| 386 FX_FLOAT font_size, | |
| 387 const CFX_Matrix* pText2User, | |
| 388 const CFX_Matrix* pUser2Device, | |
| 389 const CFX_GraphStateData* pGraphState, | |
| 390 uint32_t fill_color, | |
| 391 uint32_t stroke_color, | |
| 392 CFX_PathData* pClippingPath, | |
| 393 int nFlag = 0, | |
| 394 int alpha_flag = 0, | |
| 395 void* pIccTransform = NULL, | |
| 396 int blend_type = FXDIB_BLEND_NORMAL); | |
| 397 virtual void Begin() {} | |
| 398 virtual void End() {} | |
| 399 | |
| 400 private: | |
| 401 void InitDeviceInfo(); | |
| 402 void UpdateClipBox(); | |
| 403 FX_BOOL DrawFillStrokePath(const CFX_PathData* pPathData, | |
| 404 const CFX_Matrix* pObject2Device, | |
| 405 const CFX_GraphStateData* pGraphState, | |
| 406 uint32_t fill_color, | |
| 407 uint32_t stroke_color, | |
| 408 int fill_mode, | |
| 409 int alpha_flag, | |
| 410 void* pIccTransform, | |
| 411 int blend_type); | |
| 412 | |
| 413 CFX_DIBitmap* m_pBitmap; | |
| 414 int m_Width; | |
| 415 int m_Height; | |
| 416 int m_bpp; | |
| 417 int m_RenderCaps; | |
| 418 int m_DeviceClass; | |
| 419 FX_RECT m_ClipBox; | |
| 420 IFX_RenderDeviceDriver* m_pDeviceDriver; | |
| 421 }; | |
| 422 | |
| 423 class CFX_FxgeDevice : public CFX_RenderDevice { | |
| 424 public: | |
| 425 CFX_FxgeDevice(); | |
| 426 ~CFX_FxgeDevice() override; | |
| 427 | |
| 428 bool Attach(CFX_DIBitmap* pBitmap, | |
| 429 int dither_bits = 0, | |
| 430 bool bRgbByteOrder = false, | |
| 431 CFX_DIBitmap* pOriDevice = NULL, | |
| 432 bool bGroupKnockout = false); | |
| 433 | |
| 434 bool Create(int width, | |
| 435 int height, | |
| 436 FXDIB_Format format, | |
| 437 int dither_bits = 0, | |
| 438 CFX_DIBitmap* pOriDevice = NULL); | |
| 439 | |
| 440 protected: | |
| 441 bool m_bOwnedBitmap; | |
| 442 }; | |
| 443 | |
| 444 class CFX_SkiaDevice : public CFX_RenderDevice { | |
| 445 public: | |
| 446 CFX_SkiaDevice(); | |
| 447 ~CFX_SkiaDevice() override; | |
| 448 | |
| 449 FX_BOOL Attach(CFX_DIBitmap* pBitmap, | |
| 450 int dither_bits = 0, | |
| 451 FX_BOOL bRgbByteOrder = FALSE, | |
| 452 CFX_DIBitmap* pOriDevice = NULL, | |
| 453 FX_BOOL bGroupKnockout = FALSE); | |
| 454 | |
| 455 FX_BOOL AttachRecorder(SkPictureRecorder* recorder); | |
| 456 | |
| 457 FX_BOOL Create(int width, | |
| 458 int height, | |
| 459 FXDIB_Format format, | |
| 460 int dither_bits = 0, | |
| 461 CFX_DIBitmap* pOriDevice = NULL); | |
| 462 | |
| 463 SkPictureRecorder* CreateRecorder(int size_x, int size_y); | |
| 464 | |
| 465 protected: | |
| 466 FX_BOOL m_bOwnedBitmap; | |
| 467 }; | |
| 468 | |
| 469 class IFX_RenderDeviceDriver { | |
| 470 public: | |
| 471 static IFX_RenderDeviceDriver* CreateFxgeDriver( | |
| 472 CFX_DIBitmap* pBitmap, | |
| 473 FX_BOOL bRgbByteOrder = FALSE, | |
| 474 CFX_DIBitmap* pOriDevice = NULL, | |
| 475 FX_BOOL bGroupKnockout = FALSE); | |
| 476 | |
| 477 virtual ~IFX_RenderDeviceDriver() {} | |
| 478 virtual void Begin() {} | |
| 479 virtual void End() {} | |
| 480 | |
| 481 virtual int GetDeviceCaps(int caps_id) = 0; | |
| 482 | |
| 483 virtual CFX_Matrix GetCTM() const { return CFX_Matrix(); } | |
| 484 | |
| 485 virtual FX_BOOL IsPSPrintDriver() { return FALSE; } | |
| 486 | |
| 487 virtual FX_BOOL StartRendering() { return TRUE; } | |
| 488 | |
| 489 virtual void EndRendering() {} | |
| 490 | |
| 491 virtual void SaveState() = 0; | |
| 492 | |
| 493 virtual void RestoreState(FX_BOOL bKeepSaved = FALSE) = 0; | |
| 494 | |
| 495 virtual FX_BOOL SetClip_PathFill(const CFX_PathData* pPathData, | |
| 496 const CFX_Matrix* pObject2Device, | |
| 497 int fill_mode) = 0; | |
| 498 | |
| 499 virtual FX_BOOL SetClip_PathStroke(const CFX_PathData* pPathData, | |
| 500 const CFX_Matrix* pObject2Device, | |
| 501 const CFX_GraphStateData* pGraphState) { | |
| 502 return FALSE; | |
| 503 } | |
| 504 | |
| 505 virtual FX_BOOL DrawPath(const CFX_PathData* pPathData, | |
| 506 const CFX_Matrix* pObject2Device, | |
| 507 const CFX_GraphStateData* pGraphState, | |
| 508 uint32_t fill_color, | |
| 509 uint32_t stroke_color, | |
| 510 int fill_mode, | |
| 511 int alpha_flag = 0, | |
| 512 void* pIccTransform = NULL, | |
| 513 int blend_type = FXDIB_BLEND_NORMAL) = 0; | |
| 514 | |
| 515 virtual FX_BOOL SetPixel(int x, | |
| 516 int y, | |
| 517 uint32_t color, | |
| 518 int alpha_flag = 0, | |
| 519 void* pIccTransform = NULL) { | |
| 520 return FALSE; | |
| 521 } | |
| 522 | |
| 523 virtual FX_BOOL FillRect(const FX_RECT* pRect, | |
| 524 uint32_t fill_color, | |
| 525 int alpha_flag = 0, | |
| 526 void* pIccTransform = NULL, | |
| 527 int blend_type = FXDIB_BLEND_NORMAL) { | |
| 528 return FALSE; | |
| 529 } | |
| 530 | |
| 531 virtual FX_BOOL DrawCosmeticLine(FX_FLOAT x1, | |
| 532 FX_FLOAT y1, | |
| 533 FX_FLOAT x2, | |
| 534 FX_FLOAT y2, | |
| 535 uint32_t color, | |
| 536 int alpha_flag = 0, | |
| 537 void* pIccTransform = NULL, | |
| 538 int blend_type = FXDIB_BLEND_NORMAL) { | |
| 539 return FALSE; | |
| 540 } | |
| 541 | |
| 542 virtual FX_BOOL GetClipBox(FX_RECT* pRect) = 0; | |
| 543 | |
| 544 virtual FX_BOOL GetDIBits(CFX_DIBitmap* pBitmap, | |
| 545 int left, | |
| 546 int top, | |
| 547 void* pIccTransform = NULL, | |
| 548 FX_BOOL bDEdge = FALSE) { | |
| 549 return FALSE; | |
| 550 } | |
| 551 virtual CFX_DIBitmap* GetBackDrop() { return NULL; } | |
| 552 | |
| 553 virtual FX_BOOL SetDIBits(const CFX_DIBSource* pBitmap, | |
| 554 uint32_t color, | |
| 555 const FX_RECT* pSrcRect, | |
| 556 int dest_left, | |
| 557 int dest_top, | |
| 558 int blend_type, | |
| 559 int alpha_flag = 0, | |
| 560 void* pIccTransform = NULL) = 0; | |
| 561 | |
| 562 virtual FX_BOOL StretchDIBits(const CFX_DIBSource* pBitmap, | |
| 563 uint32_t color, | |
| 564 int dest_left, | |
| 565 int dest_top, | |
| 566 int dest_width, | |
| 567 int dest_height, | |
| 568 const FX_RECT* pClipRect, | |
| 569 uint32_t flags, | |
| 570 int alpha_flag = 0, | |
| 571 void* pIccTransform = NULL, | |
| 572 int blend_type = FXDIB_BLEND_NORMAL) = 0; | |
| 573 | |
| 574 virtual FX_BOOL StartDIBits(const CFX_DIBSource* pBitmap, | |
| 575 int bitmap_alpha, | |
| 576 uint32_t color, | |
| 577 const CFX_Matrix* pMatrix, | |
| 578 uint32_t flags, | |
| 579 void*& handle, | |
| 580 int alpha_flag = 0, | |
| 581 void* pIccTransform = NULL, | |
| 582 int blend_type = FXDIB_BLEND_NORMAL) = 0; | |
| 583 | |
| 584 virtual FX_BOOL ContinueDIBits(void* handle, IFX_Pause* pPause) { | |
| 585 return FALSE; | |
| 586 } | |
| 587 | |
| 588 virtual void CancelDIBits(void* handle) {} | |
| 589 | |
| 590 virtual FX_BOOL DrawDeviceText(int nChars, | |
| 591 const FXTEXT_CHARPOS* pCharPos, | |
| 592 CFX_Font* pFont, | |
| 593 CFX_FontCache* pCache, | |
| 594 const CFX_Matrix* pObject2Device, | |
| 595 FX_FLOAT font_size, | |
| 596 uint32_t color, | |
| 597 int alpha_flag = 0, | |
| 598 void* pIccTransform = NULL) { | |
| 599 return FALSE; | |
| 600 } | |
| 601 | |
| 602 virtual void* GetPlatformSurface() const { return NULL; } | |
| 603 virtual int GetDriverType() const { return 0; } | |
| 604 virtual void ClearDriver() {} | |
| 605 | |
| 606 virtual FX_BOOL DrawShading(CPDF_ShadingPattern* pPattern, | |
| 607 CFX_Matrix* pMatrix, | |
| 608 int alpha, | |
| 609 FX_BOOL bAlphaMode) { | |
| 610 return false; | |
| 611 } | |
| 612 }; | |
| 613 | |
| 614 class IFX_PSOutput { | |
| 615 public: | |
| 616 virtual void Release() = 0; | |
| 617 virtual void OutputPS(const FX_CHAR* str, int len) = 0; | |
| 618 | |
| 619 protected: | |
| 620 virtual ~IFX_PSOutput() {} | |
| 621 }; | |
| 622 | |
| 623 class CPSFont; | |
| 624 class CFX_PSRenderer { | |
| 625 public: | |
| 626 CFX_PSRenderer(); | |
| 627 | |
| 628 ~CFX_PSRenderer(); | |
| 629 | |
| 630 void Init(IFX_PSOutput* pOutput, | |
| 631 int ps_level, | |
| 632 int width, | |
| 633 int height, | |
| 634 FX_BOOL bCmykOutput); | |
| 635 FX_BOOL StartRendering(); | |
| 636 void EndRendering(); | |
| 637 | |
| 638 void SaveState(); | |
| 639 | |
| 640 void RestoreState(FX_BOOL bKeepSaved = FALSE); | |
| 641 | |
| 642 void SetClip_PathFill(const CFX_PathData* pPathData, | |
| 643 const CFX_Matrix* pObject2Device, | |
| 644 int fill_mode); | |
| 645 | |
| 646 void SetClip_PathStroke(const CFX_PathData* pPathData, | |
| 647 const CFX_Matrix* pObject2Device, | |
| 648 const CFX_GraphStateData* pGraphState); | |
| 649 | |
| 650 FX_RECT GetClipBox() { return m_ClipBox; } | |
| 651 | |
| 652 FX_BOOL DrawPath(const CFX_PathData* pPathData, | |
| 653 const CFX_Matrix* pObject2Device, | |
| 654 const CFX_GraphStateData* pGraphState, | |
| 655 uint32_t fill_color, | |
| 656 uint32_t stroke_color, | |
| 657 int fill_mode, | |
| 658 int alpha_flag = 0, | |
| 659 void* pIccTransform = NULL); | |
| 660 | |
| 661 FX_BOOL SetDIBits(const CFX_DIBSource* pBitmap, | |
| 662 uint32_t color, | |
| 663 int dest_left, | |
| 664 int dest_top, | |
| 665 int alpha_flag = 0, | |
| 666 void* pIccTransform = NULL); | |
| 667 | |
| 668 FX_BOOL StretchDIBits(const CFX_DIBSource* pBitmap, | |
| 669 uint32_t color, | |
| 670 int dest_left, | |
| 671 int dest_top, | |
| 672 int dest_width, | |
| 673 int dest_height, | |
| 674 uint32_t flags, | |
| 675 int alpha_flag = 0, | |
| 676 void* pIccTransform = NULL); | |
| 677 | |
| 678 FX_BOOL DrawDIBits(const CFX_DIBSource* pBitmap, | |
| 679 uint32_t color, | |
| 680 const CFX_Matrix* pMatrix, | |
| 681 uint32_t flags, | |
| 682 int alpha_flag = 0, | |
| 683 void* pIccTransform = NULL); | |
| 684 | |
| 685 FX_BOOL DrawText(int nChars, | |
| 686 const FXTEXT_CHARPOS* pCharPos, | |
| 687 CFX_Font* pFont, | |
| 688 CFX_FontCache* pCache, | |
| 689 const CFX_Matrix* pObject2Device, | |
| 690 FX_FLOAT font_size, | |
| 691 uint32_t color, | |
| 692 int alpha_flag = 0, | |
| 693 void* pIccTransform = NULL); | |
| 694 | |
| 695 private: | |
| 696 IFX_PSOutput* m_pOutput; | |
| 697 | |
| 698 int m_PSLevel; | |
| 699 | |
| 700 CFX_GraphStateData m_CurGraphState; | |
| 701 | |
| 702 FX_BOOL m_bGraphStateSet; | |
| 703 | |
| 704 FX_BOOL m_bCmykOutput; | |
| 705 | |
| 706 FX_BOOL m_bColorSet; | |
| 707 | |
| 708 uint32_t m_LastColor; | |
| 709 | |
| 710 FX_RECT m_ClipBox; | |
| 711 | |
| 712 CFX_ArrayTemplate<CPSFont*> m_PSFontList; | |
| 713 | |
| 714 CFX_ArrayTemplate<FX_RECT> m_ClipBoxStack; | |
| 715 FX_BOOL m_bInited; | |
| 716 | |
| 717 void OutputPath(const CFX_PathData* pPathData, | |
| 718 const CFX_Matrix* pObject2Device); | |
| 719 | |
| 720 void SetGraphState(const CFX_GraphStateData* pGraphState); | |
| 721 | |
| 722 void SetColor(uint32_t color, int alpha_flag, void* pIccTransform); | |
| 723 | |
| 724 void FindPSFontGlyph(CFX_FaceCache* pFaceCache, | |
| 725 CFX_Font* pFont, | |
| 726 const FXTEXT_CHARPOS& charpos, | |
| 727 int& ps_fontnum, | |
| 728 int& ps_glyphindex); | |
| 729 | |
| 730 void WritePSBinary(const uint8_t* data, int len); | |
| 731 }; | |
| 732 | |
| 733 #endif // CORE_INCLUDE_FXGE_FX_GE_H_ | |
| OLD | NEW |