diff options
Diffstat (limited to 'core/src')
28 files changed, 850 insertions, 687 deletions
diff --git a/core/src/fpdfapi/fpdf_font/ttgsubtable.h b/core/src/fpdfapi/fpdf_font/ttgsubtable.h index b717c7af8b..78de3f0a28 100644 --- a/core/src/fpdfapi/fpdf_font/ttgsubtable.h +++ b/core/src/fpdfapi/fpdf_font/ttgsubtable.h @@ -166,7 +166,7 @@ class CFX_CTTGSUBTable { TT_uint16_t GlyphCount; TT_uint16_t* GlyphArray; TCoverageFormat1() : GlyphCount(0), GlyphArray(NULL) { CoverageFormat = 1; } - ~TCoverageFormat1() { + ~TCoverageFormat1() override { if (GlyphArray) { delete[] GlyphArray; } @@ -194,7 +194,7 @@ class CFX_CTTGSUBTable { TCoverageFormat2() : RangeCount(0), RangeRecord(NULL) { CoverageFormat = 2; } - ~TCoverageFormat2() { + ~TCoverageFormat2() override { if (RangeRecord) { delete[] RangeRecord; } @@ -220,7 +220,7 @@ class CFX_CTTGSUBTable { TClassDefFormat1() : StartGlyph(0), GlyphCount(0), ClassValueArray(NULL) { ClassFormat = 1; } - ~TClassDefFormat1() { + ~TClassDefFormat1() override { if (ClassValueArray) { delete[] ClassValueArray; } @@ -246,7 +246,7 @@ class CFX_CTTGSUBTable { TClassDefFormat2() : ClassRangeCount(0), ClassRangeRecord(NULL) { ClassFormat = 2; } - ~TClassDefFormat2() { + ~TClassDefFormat2() override { if (ClassRangeRecord) { delete[] ClassRangeRecord; } @@ -279,7 +279,7 @@ class CFX_CTTGSUBTable { TCoverageFormatBase* Coverage; TT_int16_t DeltaGlyphID; TSingleSubstFormat1() : Coverage(NULL), DeltaGlyphID(0) { SubstFormat = 1; } - ~TSingleSubstFormat1() { delete Coverage; } + ~TSingleSubstFormat1() override { delete Coverage; } private: TSingleSubstFormat1(const TSingleSubstFormat1&); diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_func.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_func.cpp index 87ff0a3b63..1ee062ee7c 100644 --- a/core/src/fpdfapi/fpdf_page/fpdf_page_func.cpp +++ b/core/src/fpdfapi/fpdf_page/fpdf_page_func.cpp @@ -463,18 +463,23 @@ typedef struct { int sizes; } SampleEncodeInfo; typedef struct { FX_FLOAT decode_max, decode_min; } SampleDecodeInfo; + class CPDF_SampledFunc : public CPDF_Function { public: CPDF_SampledFunc(); - virtual ~CPDF_SampledFunc(); - virtual FX_BOOL v_Init(CPDF_Object* pObj); - virtual FX_BOOL v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const; + ~CPDF_SampledFunc() override; + + // CPDF_Function + FX_BOOL v_Init(CPDF_Object* pObj) override; + FX_BOOL v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const override; + SampleEncodeInfo* m_pEncodeInfo; SampleDecodeInfo* m_pDecodeInfo; FX_DWORD m_nBitsPerSample; FX_DWORD m_SampleMax; CPDF_StreamAcc* m_pSampleStream; }; + CPDF_SampledFunc::CPDF_SampledFunc() { m_pSampleStream = NULL; m_pEncodeInfo = NULL; @@ -620,12 +625,16 @@ FX_BOOL CPDF_SampledFunc::v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const { } return TRUE; } + class CPDF_PSFunc : public CPDF_Function { public: - virtual FX_BOOL v_Init(CPDF_Object* pObj); - virtual FX_BOOL v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const; + // CPDF_Function + FX_BOOL v_Init(CPDF_Object* pObj) override; + FX_BOOL v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const override; + CPDF_PSEngine m_PS; }; + FX_BOOL CPDF_PSFunc::v_Init(CPDF_Object* pObj) { CPDF_Stream* pStream = (CPDF_Stream*)pObj; CPDF_StreamAcc acc; @@ -648,17 +657,22 @@ FX_BOOL CPDF_PSFunc::v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const { } return TRUE; } + class CPDF_ExpIntFunc : public CPDF_Function { public: CPDF_ExpIntFunc(); - virtual ~CPDF_ExpIntFunc(); - virtual FX_BOOL v_Init(CPDF_Object* pObj); - virtual FX_BOOL v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const; + ~CPDF_ExpIntFunc() override; + + // CPDF_Function + FX_BOOL v_Init(CPDF_Object* pObj) override; + FX_BOOL v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const override; + FX_FLOAT m_Exponent; FX_FLOAT* m_pBeginValues; FX_FLOAT* m_pEndValues; int m_nOrigOutputs; }; + CPDF_ExpIntFunc::CPDF_ExpIntFunc() { m_pBeginValues = NULL; m_pEndValues = NULL; @@ -708,17 +722,22 @@ FX_BOOL CPDF_ExpIntFunc::v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const { } return TRUE; } + class CPDF_StitchFunc : public CPDF_Function { public: CPDF_StitchFunc(); - virtual ~CPDF_StitchFunc(); - virtual FX_BOOL v_Init(CPDF_Object* pObj); - virtual FX_BOOL v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const; + ~CPDF_StitchFunc() override; + + // CPDF_Function + FX_BOOL v_Init(CPDF_Object* pObj) override; + FX_BOOL v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const override; + int m_nSubs; CPDF_Function** m_pSubFunctions; FX_FLOAT* m_pBounds; FX_FLOAT* m_pEncode; }; + CPDF_StitchFunc::CPDF_StitchFunc() { m_nSubs = 0; m_pSubFunctions = NULL; diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp index 21b2fbae8a..74eabe1396 100644 --- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp +++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp @@ -2815,7 +2815,7 @@ void CPDF_SyntaxParser::GetBinary(uint8_t* buffer, FX_DWORD size) { class CPDF_DataAvail final : public IPDF_DataAvail { public: CPDF_DataAvail(IFX_FileAvail* pFileAvail, IFX_FileRead* pFileRead); - ~CPDF_DataAvail(); + ~CPDF_DataAvail() override; virtual FX_BOOL IsDocAvail(IFX_DownloadHints* pHints) override; diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp index 987ffd88d4..222f58c088 100644 --- a/core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp +++ b/core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp @@ -139,6 +139,10 @@ CFX_DIBSource* CPDF_TransferFunc::TranslateImage(const CFX_DIBSource* pSrc, pDest->LoadSrc(pSrc, bAutoDropSrc); return pDest; } + +CPDF_DIBTransferFunc::~CPDF_DIBTransferFunc() { +} + FXDIB_Format CPDF_DIBTransferFunc::GetDestFormat() { if (m_pSrc->IsAlphaMask()) { return FXDIB_8bppMask; diff --git a/core/src/fpdfapi/fpdf_render/render_int.h b/core/src/fpdfapi/fpdf_render/render_int.h index d6b314d853..733e24cbcf 100644 --- a/core/src/fpdfapi/fpdf_render/render_int.h +++ b/core/src/fpdfapi/fpdf_render/render_int.h @@ -87,7 +87,9 @@ struct _PDF_RenderItem { CPDF_PageObjects* m_pObjectList; CFX_AffineMatrix m_Matrix; }; + typedef CFX_ArrayTemplate<_PDF_RenderItem> CPDF_RenderLayer; + class IPDF_ObjectRenderer { public: static IPDF_ObjectRenderer* Create(int type); @@ -100,6 +102,7 @@ class IPDF_ObjectRenderer { virtual FX_BOOL Continue(IFX_Pause* pPause) = 0; FX_BOOL m_Result; }; + class CPDF_RenderStatus { public: CPDF_RenderStatus(); @@ -319,15 +322,20 @@ class CPDF_ProgressiveImageLoaderHandle { int32_t m_nDownsampleHeight; }; class CFX_ImageTransformer; + class CPDF_ImageRenderer : public IPDF_ObjectRenderer { public: CPDF_ImageRenderer(); - ~CPDF_ImageRenderer(); + ~CPDF_ImageRenderer() override; + + // IPDF_ObjectRenderer FX_BOOL Start(CPDF_RenderStatus* pStatus, const CPDF_PageObject* pObj, const CFX_AffineMatrix* pObj2Device, FX_BOOL bStdCS, - int blendType = FXDIB_BLEND_NORMAL); + int blendType = FXDIB_BLEND_NORMAL) override; + FX_BOOL Continue(IFX_Pause* pPause) override; + FX_BOOL Start(CPDF_RenderStatus* pStatus, const CFX_DIBSource* pDIBSource, FX_ARGB bitmap_argb, @@ -336,7 +344,6 @@ class CPDF_ImageRenderer : public IPDF_ObjectRenderer { FX_DWORD flags, FX_BOOL bStdCS, int blendType = FXDIB_BLEND_NORMAL); - FX_BOOL Continue(IFX_Pause* pPause); protected: CPDF_RenderStatus* m_pRenderStatus; @@ -365,6 +372,7 @@ class CPDF_ImageRenderer : public IPDF_ObjectRenderer { FX_BOOL DrawMaskedImage(); FX_BOOL DrawPatternImage(const CFX_Matrix* pObj2Device); }; + class CPDF_ScaledRenderBuffer { public: CPDF_ScaledRenderBuffer(); @@ -483,10 +491,12 @@ typedef struct { int m_ColorKeyMin; int m_ColorKeyMax; } DIB_COMP_DATA; + class CPDF_DIBSource : public CFX_DIBSource { public: CPDF_DIBSource(); - virtual ~CPDF_DIBSource(); + ~CPDF_DIBSource() override; + FX_BOOL Load(CPDF_Document* pDoc, const CPDF_Stream* pStream, CPDF_DIBSource** ppMask, @@ -496,17 +506,20 @@ class CPDF_DIBSource : public CFX_DIBSource { FX_BOOL bStdCS = FALSE, FX_DWORD GroupFamily = 0, FX_BOOL bLoadMask = FALSE); - virtual FX_BOOL SkipToScanline(int line, IFX_Pause* pPause) const; - virtual uint8_t* GetBuffer() const; - virtual const uint8_t* GetScanline(int line) const; - virtual void DownSampleScanline(int line, - uint8_t* dest_scan, - int dest_bpp, - int dest_width, - FX_BOOL bFlipX, - int clip_left, - int clip_width) const; - virtual void SetDownSampleSize(int dest_width, int dest_height) const; + + // CFX_DIBSource + FX_BOOL SkipToScanline(int line, IFX_Pause* pPause) const override; + uint8_t* GetBuffer() const override; + const uint8_t* GetScanline(int line) const override; + void DownSampleScanline(int line, + uint8_t* dest_scan, + int dest_bpp, + int dest_width, + FX_BOOL bFlipX, + int clip_left, + int clip_width) const override; + void SetDownSampleSize(int dest_width, int dest_height) const override; + CFX_DIBitmap* GetBitmap() const; void ReleaseBitmap(CFX_DIBitmap*) const; void ClearImageData(); @@ -569,22 +582,28 @@ class CPDF_DIBSource : public CFX_DIBSource { nonstd::unique_ptr<CFX_DIBitmap> m_pCachedBitmap; ICodec_ScanlineDecoder* m_pDecoder; }; + #define FPDF_HUGE_IMAGE_SIZE 60000000 class CPDF_DIBTransferFunc : public CFX_FilteredDIB { public: CPDF_DIBTransferFunc(const CPDF_TransferFunc* pTransferFunc); - virtual FXDIB_Format GetDestFormat(); - virtual FX_ARGB* GetDestPalette() { return NULL; } - virtual void TranslateScanline(uint8_t* dest_buf, - const uint8_t* src_buf) const; - virtual void TranslateDownSamples(uint8_t* dest_buf, - const uint8_t* src_buf, - int pixels, - int Bpp) const; + ~CPDF_DIBTransferFunc() override; + + // CFX_FilteredDIB + FXDIB_Format GetDestFormat() override; + FX_ARGB* GetDestPalette() override { return NULL; } + void TranslateScanline(uint8_t* dest_buf, + const uint8_t* src_buf) const override; + void TranslateDownSamples(uint8_t* dest_buf, + const uint8_t* src_buf, + int pixels, + int Bpp) const override; + const uint8_t* m_RampR; const uint8_t* m_RampG; const uint8_t* m_RampB; }; + struct _CPDF_UniqueKeyGen { void Generate(int count, ...); FX_CHAR m_Key[128]; diff --git a/core/src/fpdfdoc/doc_ap.cpp b/core/src/fpdfdoc/doc_ap.cpp index feedb32989..cffaad9900 100644 --- a/core/src/fpdfdoc/doc_ap.cpp +++ b/core/src/fpdfdoc/doc_ap.cpp @@ -38,15 +38,19 @@ FX_BOOL FPDF_GenerateAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict) { } return FALSE; } + class CPVT_FontMap : public IPVT_FontMap { public: CPVT_FontMap(CPDF_Document* pDoc, CPDF_Dictionary* pResDict, CPDF_Font* pDefFont, const CFX_ByteString& sDefFontAlias); - virtual ~CPVT_FontMap(); - CPDF_Font* GetPDFFont(int32_t nFontIndex); - CFX_ByteString GetPDFFontAlias(int32_t nFontIndex); + ~CPVT_FontMap() override; + + // IPVT_FontMap + CPDF_Font* GetPDFFont(int32_t nFontIndex) override; + CFX_ByteString GetPDFFontAlias(int32_t nFontIndex) override; + static void GetAnnotSysPDFFont(CPDF_Document* pDoc, CPDF_Dictionary* pResDict, CPDF_Font*& pSysFont, @@ -60,6 +64,7 @@ class CPVT_FontMap : public IPVT_FontMap { CPDF_Font* m_pSysFont; CFX_ByteString m_sSysFontAlias; }; + CPVT_FontMap::CPVT_FontMap(CPDF_Document* pDoc, CPDF_Dictionary* pResDict, CPDF_Font* pDefFont, diff --git a/core/src/fpdfdoc/doc_vt.cpp b/core/src/fpdfdoc/doc_vt.cpp index b7c8ed80f6..396a7d6b71 100644 --- a/core/src/fpdfdoc/doc_vt.cpp +++ b/core/src/fpdfdoc/doc_vt.cpp @@ -960,10 +960,10 @@ CPVT_WordPlace CPDF_VariableText::DeleteWords( return PlaceRange.BeginPos; } CPVT_WordPlace CPDF_VariableText::DeleteWord(const CPVT_WordPlace& place) { - return ClearRightWord(AjustLineHeader(place, TRUE)); + return ClearRightWord(AdjustLineHeader(place, TRUE)); } CPVT_WordPlace CPDF_VariableText::BackSpaceWord(const CPVT_WordPlace& place) { - return ClearLeftWord(AjustLineHeader(place, TRUE)); + return ClearLeftWord(AdjustLineHeader(place, TRUE)); } void CPDF_VariableText::SetText(const FX_WCHAR* text, int32_t charset, @@ -1032,7 +1032,7 @@ void CPDF_VariableText::UpdateWordPlace(CPVT_WordPlace& place) const { if (place.nSecIndex >= m_SectionArray.GetSize()) { place = GetEndWordPlace(); } - place = AjustLineHeader(place, TRUE); + place = AdjustLineHeader(place, TRUE); if (CSection* pSection = m_SectionArray.GetAt(place.nSecIndex)) { pSection->UpdateWordPlace(place); } @@ -1429,7 +1429,7 @@ int32_t CPDF_VariableText::GetHorzScale(const CPVT_WordInfo& WordInfo) { : m_nHorzScale; } void CPDF_VariableText::ClearSectionRightWords(const CPVT_WordPlace& place) { - CPVT_WordPlace wordplace = AjustLineHeader(place, TRUE); + CPVT_WordPlace wordplace = AdjustLineHeader(place, TRUE); if (CSection* pSection = m_SectionArray.GetAt(place.nSecIndex)) { for (int32_t w = pSection->m_WordArray.GetSize() - 1; w > wordplace.nWordIndex; w--) { @@ -1438,8 +1438,8 @@ void CPDF_VariableText::ClearSectionRightWords(const CPVT_WordPlace& place) { } } } -CPVT_WordPlace CPDF_VariableText::AjustLineHeader(const CPVT_WordPlace& place, - FX_BOOL bPrevOrNext) const { +CPVT_WordPlace CPDF_VariableText::AdjustLineHeader(const CPVT_WordPlace& place, + FX_BOOL bPrevOrNext) const { if (place.nWordIndex < 0 && place.nLineIndex > 0) { return bPrevOrNext ? GetPrevWordPlace(place) : GetNextWordPlace(place); } @@ -1467,7 +1467,7 @@ void CPDF_VariableText::ClearEmptySections(const CPVT_WordRange& PlaceRange) { } } void CPDF_VariableText::LinkLatterSection(const CPVT_WordPlace& place) { - CPVT_WordPlace oldplace = AjustLineHeader(place, TRUE); + CPVT_WordPlace oldplace = AdjustLineHeader(place, TRUE); if (CSection* pNextSection = m_SectionArray.GetAt(place.nSecIndex + 1)) { if (CSection* pSection = m_SectionArray.GetAt(oldplace.nSecIndex)) { for (int32_t w = 0, sz = pNextSection->m_WordArray.GetSize(); w < sz; @@ -1484,8 +1484,8 @@ void CPDF_VariableText::LinkLatterSection(const CPVT_WordPlace& place) { } void CPDF_VariableText::ClearWords(const CPVT_WordRange& PlaceRange) { CPVT_WordRange NewRange; - NewRange.BeginPos = AjustLineHeader(PlaceRange.BeginPos, TRUE); - NewRange.EndPos = AjustLineHeader(PlaceRange.EndPos, TRUE); + NewRange.BeginPos = AdjustLineHeader(PlaceRange.BeginPos, TRUE); + NewRange.EndPos = AdjustLineHeader(PlaceRange.EndPos, TRUE); for (int32_t s = NewRange.EndPos.nSecIndex; s >= NewRange.BeginPos.nSecIndex; s--) { if (CSection* pSection = m_SectionArray.GetAt(s)) { @@ -1513,7 +1513,8 @@ CPVT_WordPlace CPDF_VariableText::ClearLeftWord(const CPVT_WordPlace& place) { } CPVT_WordPlace CPDF_VariableText::ClearRightWord(const CPVT_WordPlace& place) { if (CSection* pSection = m_SectionArray.GetAt(place.nSecIndex)) { - CPVT_WordPlace rightplace = AjustLineHeader(GetNextWordPlace(place), FALSE); + CPVT_WordPlace rightplace = + AdjustLineHeader(GetNextWordPlace(place), FALSE); if (rightplace != place) { if (rightplace.nSecIndex != place.nSecIndex) { LinkLatterSection(place); diff --git a/core/src/fpdfdoc/pdf_vt.h b/core/src/fpdfdoc/pdf_vt.h index d3010da73b..207daab98d 100644 --- a/core/src/fpdfdoc/pdf_vt.h +++ b/core/src/fpdfdoc/pdf_vt.h @@ -343,6 +343,7 @@ class CPDF_EditContainer { CPDF_Rect m_rcPlate; CPVT_FloatRect m_rcContent; }; + class CPDF_VariableText : public IPDF_VariableText, private CPDF_EditContainer { friend class CTypeset; friend class CSection; @@ -350,80 +351,102 @@ class CPDF_VariableText : public IPDF_VariableText, private CPDF_EditContainer { public: CPDF_VariableText(); - virtual ~CPDF_VariableText(); + ~CPDF_VariableText() override; + + // IPDF_VariableText IPDF_VariableText_Provider* SetProvider( - IPDF_VariableText_Provider* pProvider); - IPDF_VariableText_Iterator* GetIterator(); - void SetPlateRect(const CPDF_Rect& rect) { + IPDF_VariableText_Provider* pProvider) override; + IPDF_VariableText_Iterator* GetIterator() override; + void SetPlateRect(const CPDF_Rect& rect) override { CPDF_EditContainer::SetPlateRect(rect); } - void SetAlignment(int32_t nFormat = 0) { m_nAlignment = nFormat; } - void SetPasswordChar(FX_WORD wSubWord = '*') { m_wSubWord = wSubWord; } - void SetLimitChar(int32_t nLimitChar = 0) { m_nLimitChar = nLimitChar; } - void SetCharSpace(FX_FLOAT fCharSpace = 0.0f) { m_fCharSpace = fCharSpace; } - void SetHorzScale(int32_t nHorzScale = 100) { m_nHorzScale = nHorzScale; } - void SetMultiLine(FX_BOOL bMultiLine = TRUE) { m_bMultiLine = bMultiLine; } - void SetAutoReturn(FX_BOOL bAuto = TRUE) { m_bLimitWidth = bAuto; } - void SetFontSize(FX_FLOAT fFontSize) { m_fFontSize = fFontSize; } - void SetCharArray(int32_t nCharArray = 0) { m_nCharArray = nCharArray; } - void SetAutoFontSize(FX_BOOL bAuto = TRUE) { m_bAutoFontSize = bAuto; } - void SetRichText(FX_BOOL bRichText) { m_bRichText = bRichText; } - void SetLineLeading(FX_FLOAT fLineLeading) { m_fLineLeading = fLineLeading; } - void Initialize(); - FX_BOOL IsValid() const { return m_bInitial; } - FX_BOOL IsRichText() const { return m_bRichText; } - void RearrangeAll(); - void RearrangePart(const CPVT_WordRange& PlaceRange); - void ResetAll(); + void SetAlignment(int32_t nFormat = 0) override { m_nAlignment = nFormat; } + void SetPasswordChar(FX_WORD wSubWord = '*') override { + m_wSubWord = wSubWord; + } + void SetLimitChar(int32_t nLimitChar = 0) override { + m_nLimitChar = nLimitChar; + } + void SetCharSpace(FX_FLOAT fCharSpace = 0.0f) override { + m_fCharSpace = fCharSpace; + } + void SetHorzScale(int32_t nHorzScale = 100) override { + m_nHorzScale = nHorzScale; + } + void SetMultiLine(FX_BOOL bMultiLine = TRUE) override { + m_bMultiLine = bMultiLine; + } + void SetAutoReturn(FX_BOOL bAuto = TRUE) override { m_bLimitWidth = bAuto; } + void SetFontSize(FX_FLOAT fFontSize) override { m_fFontSize = fFontSize; } + void SetCharArray(int32_t nCharArray = 0) override { + m_nCharArray = nCharArray; + } + void SetAutoFontSize(FX_BOOL bAuto = TRUE) override { + m_bAutoFontSize = bAuto; + } + void SetRichText(FX_BOOL bRichText) override { m_bRichText = bRichText; } + void SetLineLeading(FX_FLOAT fLineLeading) override { + m_fLineLeading = fLineLeading; + } + void Initialize() override; + FX_BOOL IsValid() const override { return m_bInitial; } + FX_BOOL IsRichText() const override { return m_bRichText; } + void RearrangeAll() override; + void RearrangePart(const CPVT_WordRange& PlaceRange) override; + void ResetAll() override; void SetText(const FX_WCHAR* text, int32_t charset = 1, const CPVT_SecProps* pSecProps = NULL, - const CPVT_WordProps* pWordProps = NULL); + const CPVT_WordProps* pWordProps = NULL) override; CPVT_WordPlace InsertWord(const CPVT_WordPlace& place, FX_WORD word, int32_t charset = 1, - const CPVT_WordProps* pWordProps = NULL); - CPVT_WordPlace InsertSection(const CPVT_WordPlace& place, - const CPVT_SecProps* pSecProps = NULL, - const CPVT_WordProps* pWordProps = NULL); + const CPVT_WordProps* pWordProps = NULL) override; + CPVT_WordPlace InsertSection( + const CPVT_WordPlace& place, + const CPVT_SecProps* pSecProps = NULL, + const CPVT_WordProps* pWordProps = NULL) override; CPVT_WordPlace InsertText(const CPVT_WordPlace& place, const FX_WCHAR* text, int32_t charset = 1, const CPVT_SecProps* pSecProps = NULL, - const CPVT_WordProps* pWordProps = NULL); - CPVT_WordPlace DeleteWords(const CPVT_WordRange& PlaceRange); - CPVT_WordPlace DeleteWord(const CPVT_WordPlace& place); - CPVT_WordPlace BackSpaceWord(const CPVT_WordPlace& place); - const CPDF_Rect& GetPlateRect() const { + const CPVT_WordProps* pWordProps = NULL) override; + CPVT_WordPlace DeleteWords(const CPVT_WordRange& PlaceRange) override; + CPVT_WordPlace DeleteWord(const CPVT_WordPlace& place) override; + CPVT_WordPlace BackSpaceWord(const CPVT_WordPlace& place) override; + const CPDF_Rect& GetPlateRect() const override { return CPDF_EditContainer::GetPlateRect(); } - CPDF_Rect GetContentRect() const; - int32_t GetTotalWords() const; - FX_FLOAT GetFontSize() const { return m_fFontSize; } - int32_t GetAlignment() const { return m_nAlignment; } - int32_t GetCharArray() const { return m_nCharArray; } - int32_t GetLimitChar() const { return m_nLimitChar; } - FX_BOOL IsMultiLine() const { return m_bMultiLine; } - int32_t GetHorzScale() const { return m_nHorzScale; } - FX_FLOAT GetCharSpace() const { return m_fCharSpace; } - - CPVT_WordPlace GetBeginWordPlace() const; - CPVT_WordPlace GetEndWordPlace() const; - CPVT_WordPlace GetPrevWordPlace(const CPVT_WordPlace& place) const; - CPVT_WordPlace GetNextWordPlace(const CPVT_WordPlace& place) const; - CPVT_WordPlace SearchWordPlace(const CPDF_Point& point) const; + CPDF_Rect GetContentRect() const override; + int32_t GetTotalWords() const override; + FX_FLOAT GetFontSize() const override { return m_fFontSize; } + int32_t GetAlignment() const override { return m_nAlignment; } + FX_WORD GetPasswordChar() const override { return GetSubWord(); } + int32_t GetCharArray() const override { return m_nCharArray; } + int32_t GetLimitChar() const override { return m_nLimitChar; } + FX_BOOL IsMultiLine() const override { return m_bMultiLine; } + int32_t GetHorzScale() const override { return m_nHorzScale; } + FX_FLOAT GetCharSpace() const override { return m_fCharSpace; } + CPVT_WordPlace GetBeginWordPlace() const override; + CPVT_WordPlace GetEndWordPlace() const override; + CPVT_WordPlace GetPrevWordPlace(const CPVT_WordPlace& place) const override; + CPVT_WordPlace GetNextWordPlace(const CPVT_WordPlace& place) const override; + CPVT_WordPlace SearchWordPlace(const CPDF_Point& point) const override; CPVT_WordPlace GetUpWordPlace(const CPVT_WordPlace& place, - const CPDF_Point& point) const; + const CPDF_Point& point) const override; CPVT_WordPlace GetDownWordPlace(const CPVT_WordPlace& place, - const CPDF_Point& point) const; - CPVT_WordPlace GetLineBeginPlace(const CPVT_WordPlace& place) const; - CPVT_WordPlace GetLineEndPlace(const CPVT_WordPlace& place) const; - CPVT_WordPlace GetSectionBeginPlace(const CPVT_WordPlace& place) const; - CPVT_WordPlace GetSectionEndPlace(const CPVT_WordPlace& place) const; - void UpdateWordPlace(CPVT_WordPlace& place) const; - int32_t WordPlaceToWordIndex(const CPVT_WordPlace& place) const; - CPVT_WordPlace WordIndexToWordPlace(int32_t index) const; - FX_WORD GetPasswordChar() const { return GetSubWord(); } + const CPDF_Point& point) const override; + CPVT_WordPlace GetLineBeginPlace(const CPVT_WordPlace& place) const override; + CPVT_WordPlace GetLineEndPlace(const CPVT_WordPlace& place) const override; + CPVT_WordPlace GetSectionBeginPlace( + const CPVT_WordPlace& place) const override; + CPVT_WordPlace GetSectionEndPlace(const CPVT_WordPlace& place) const override; + void UpdateWordPlace(CPVT_WordPlace& place) const override; + CPVT_WordPlace AdjustLineHeader(const CPVT_WordPlace& place, + FX_BOOL bPrevOrNext) const override; + int32_t WordPlaceToWordIndex(const CPVT_WordPlace& place) const override; + CPVT_WordPlace WordIndexToWordPlace(int32_t index) const override; + FX_WORD GetSubWord() const { return m_wSubWord; } private: @@ -437,7 +460,6 @@ class CPDF_VariableText : public IPDF_VariableText, private CPDF_EditContainer { int32_t GetDefaultFontIndex(); FX_BOOL IsLatinWord(FX_WORD word); - private: CPVT_WordPlace AddSection(const CPVT_WordPlace& place, const CPVT_SectionInfo& secinfo); CPVT_WordPlace AddLine(const CPVT_WordPlace& place, @@ -479,8 +501,7 @@ class CPDF_VariableText : public IPDF_VariableText, private CPDF_EditContainer { int32_t GetAlignment(const CPVT_SectionInfo& SecInfo); void ClearSectionRightWords(const CPVT_WordPlace& place); - CPVT_WordPlace AjustLineHeader(const CPVT_WordPlace& place, - FX_BOOL bPrevOrNext) const; + FX_BOOL ClearEmptySection(const CPVT_WordPlace& place); void ClearEmptySections(const CPVT_WordRange& PlaceRange); void LinkLatterSection(const CPVT_WordPlace& place); @@ -494,10 +515,8 @@ class CPDF_VariableText : public IPDF_VariableText, private CPDF_EditContainer { FX_BOOL IsBigger(FX_FLOAT fFontSize); CPVT_FloatRect RearrangeSections(const CPVT_WordRange& PlaceRange); - private: void ResetSectionArray(); - private: CPVT_ArrayTemplate<CSection*> m_SectionArray; int32_t m_nLimitChar; int32_t m_nCharArray; @@ -517,24 +536,27 @@ class CPDF_VariableText : public IPDF_VariableText, private CPDF_EditContainer { IPDF_VariableText_Provider* m_pVTProvider; CPDF_VariableText_Iterator* m_pVTIterator; }; + class CPDF_VariableText_Iterator : public IPDF_VariableText_Iterator { public: CPDF_VariableText_Iterator(CPDF_VariableText* pVT); - virtual ~CPDF_VariableText_Iterator(); - FX_BOOL NextWord(); - FX_BOOL PrevWord(); - FX_BOOL NextLine(); - FX_BOOL PrevLine(); - FX_BOOL NextSection(); - FX_BOOL PrevSection(); - FX_BOOL SetWord(const CPVT_Word& word); - FX_BOOL GetWord(CPVT_Word& word) const; - FX_BOOL GetLine(CPVT_Line& line) const; - FX_BOOL GetSection(CPVT_Section& section) const; - FX_BOOL SetSection(const CPVT_Section& section); - void SetAt(int32_t nWordIndex); - void SetAt(const CPVT_WordPlace& place); - const CPVT_WordPlace& GetAt() const { return m_CurPos; }; + ~CPDF_VariableText_Iterator() override; + + // IPDF_VariableText_Iterator + FX_BOOL NextWord() override; + FX_BOOL PrevWord() override; + FX_BOOL NextLine() override; + FX_BOOL PrevLine() override; + FX_BOOL NextSection() override; + FX_BOOL PrevSection() override; + FX_BOOL SetWord(const CPVT_Word& word) override; + FX_BOOL GetWord(CPVT_Word& word) const override; + FX_BOOL GetLine(CPVT_Line& line) const override; + FX_BOOL GetSection(CPVT_Section& section) const override; + FX_BOOL SetSection(const CPVT_Section& section) override; + void SetAt(int32_t nWordIndex) override; + void SetAt(const CPVT_WordPlace& place) override; + const CPVT_WordPlace& GetAt() const override { return m_CurPos; }; private: CPVT_WordPlace m_CurPos; diff --git a/core/src/fpdfdoc/tagged_int.h b/core/src/fpdfdoc/tagged_int.h index 7cf368083c..de6854ea0b 100644 --- a/core/src/fpdfdoc/tagged_int.h +++ b/core/src/fpdfdoc/tagged_int.h @@ -10,14 +10,18 @@ #include "../../include/fpdfdoc/fpdf_tagged.h" class CPDF_StructElementImpl; + class CPDF_StructTreeImpl : public CPDF_StructTree { public: - CPDF_StructTreeImpl(const CPDF_Document* pDoc); - ~CPDF_StructTreeImpl(); - int CountTopElements() const { return m_Kids.GetSize(); } - CPDF_StructElement* GetTopElement(int i) const { + explicit CPDF_StructTreeImpl(const CPDF_Document* pDoc); + ~CPDF_StructTreeImpl() override; + + // CPDF_StructTree + int CountTopElements() const override { return m_Kids.GetSize(); } + CPDF_StructElement* GetTopElement(int i) const override { return (CPDF_StructElement*)m_Kids.GetAt(i); } + void LoadDocTree(); void LoadPageTree(const CPDF_Dictionary* pPageDict); CPDF_StructElementImpl* AddPageNode(CPDF_Dictionary* pElement, @@ -33,46 +37,48 @@ class CPDF_StructTreeImpl : public CPDF_StructTree { CFX_ArrayTemplate<CPDF_StructElementImpl*> m_Kids; friend class CPDF_StructElementImpl; }; + class CPDF_StructElementImpl final : public CPDF_StructElement { public: CPDF_StructElementImpl(CPDF_StructTreeImpl* pTree, CPDF_StructElementImpl* pParent, CPDF_Dictionary* pDict); - CPDF_StructTree* GetTree() const { return m_pTree; } - const CFX_ByteString& GetType() const { return m_Type; } - CPDF_StructElement* GetParent() const { return m_pParent; } - CPDF_Dictionary* GetDict() const { return m_pDict; } - int CountKids() const { return m_Kids.GetSize(); } - const CPDF_StructKid& GetKid(int index) const { + + // CPDF_StructTreeImpl + CPDF_StructTree* GetTree() const override { return m_pTree; } + const CFX_ByteString& GetType() const override { return m_Type; } + CPDF_StructElement* GetParent() const override { return m_pParent; } + CPDF_Dictionary* GetDict() const override { return m_pDict; } + int CountKids() const override { return m_Kids.GetSize(); } + const CPDF_StructKid& GetKid(int index) const override { return m_Kids.GetData()[index]; } - CFX_PtrArray* GetObjectArray() { return &m_ObjectArray; } - + CFX_PtrArray* GetObjectArray() override { return &m_ObjectArray; } CPDF_Object* GetAttr(const CFX_ByteStringC& owner, const CFX_ByteStringC& name, FX_BOOL bInheritable = FALSE, - FX_FLOAT fLevel = 0.0F); - + FX_FLOAT fLevel = 0.0F) override; CFX_ByteString GetName(const CFX_ByteStringC& owner, const CFX_ByteStringC& name, const CFX_ByteStringC& default_value, FX_BOOL bInheritable = FALSE, - int subindex = -1); + int subindex = -1) override; FX_ARGB GetColor(const CFX_ByteStringC& owner, const CFX_ByteStringC& name, FX_ARGB default_value, FX_BOOL bInheritable = FALSE, - int subindex = -1); + int subindex = -1) override; FX_FLOAT GetNumber(const CFX_ByteStringC& owner, const CFX_ByteStringC& name, FX_FLOAT default_value, FX_BOOL bInheritable = FALSE, - int subindex = -1); + int subindex = -1) override; int GetInteger(const CFX_ByteStringC& owner, const CFX_ByteStringC& name, int default_value, FX_BOOL bInheritable = FALSE, - int subindex = -1); + int subindex = -1) override; + CFX_PtrArray m_ObjectArray; void LoadKids(CPDF_Dictionary* pDict); void LoadKid(FX_DWORD PageObjNum, CPDF_Object* pObj, CPDF_StructKid* pKid); @@ -84,7 +90,7 @@ class CPDF_StructElementImpl final : public CPDF_StructElement { void Release(); protected: - ~CPDF_StructElementImpl(); + ~CPDF_StructElementImpl() override; CPDF_StructTreeImpl* m_pTree; CFX_ByteString m_Type; diff --git a/core/src/fpdftext/text_int.h b/core/src/fpdftext/text_int.h index 9e7073d24e..b0c79cd9bc 100644 --- a/core/src/fpdftext/text_int.h +++ b/core/src/fpdftext/text_int.h @@ -7,7 +7,6 @@ #ifndef CORE_SRC_FPDFTEXT_TEXT_INT_H_ #define CORE_SRC_FPDFTEXT_TEXT_INT_H_ -class CPDF_TextPage; class CPDF_LinkExtract; class CPDF_TextPageFind; class CPDF_DocProgressiveSearch; @@ -42,53 +41,52 @@ typedef struct { CFX_AffineMatrix m_formMatrix; } PDFTEXT_Obj; typedef CFX_ArrayTemplate<PDFTEXT_Obj> LINEOBJ; + class CPDF_TextPage : public IPDF_TextPage { public: CPDF_TextPage(const CPDF_Page* pPage, int flags = 0); CPDF_TextPage(const CPDF_PageObjects* pPage, int flags = 0); CPDF_TextPage(const CPDF_Page* pPage, CPDFText_ParseOptions ParserOptions); - virtual FX_BOOL ParseTextPage(); - virtual void NormalizeObjects(FX_BOOL bNormalize); - virtual FX_BOOL IsParsered() const { return m_IsParsered; } - virtual ~CPDF_TextPage(){}; - - public: - virtual int CharIndexFromTextIndex(int TextIndex) const; - virtual int TextIndexFromCharIndex(int CharIndex) const; - virtual int CountChars() const; - virtual void GetCharInfo(int index, FPDF_CHAR_INFO& info) const; - virtual void GetRectArray(int start, - int nCount, - CFX_RectArray& rectArray) const; - virtual int GetIndexAtPos(CPDF_Point point, - FX_FLOAT xTolerance, - FX_FLOAT yTolerance) const; - virtual int GetIndexAtPos(FX_FLOAT x, - FX_FLOAT y, - FX_FLOAT xTolerance, - FX_FLOAT yTolerance) const; - virtual CFX_WideString GetTextByRect(const CFX_FloatRect& rect) const; - virtual void GetRectsArrayByRect(const CFX_FloatRect& rect, - CFX_RectArray& resRectArray) const; - virtual CFX_WideString GetPageText(int start = 0, int nCount = -1) const; - - virtual int CountRects(int start, int nCount); - virtual void GetRect(int rectIndex, - FX_FLOAT& left, - FX_FLOAT& top, - FX_FLOAT& right, - FX_FLOAT& bottom) const; - virtual FX_BOOL GetBaselineRotate(int rectIndex, int& Rotate); - virtual FX_BOOL GetBaselineRotate(const CFX_FloatRect& rect, int& Rotate); - virtual int CountBoundedSegments(FX_FLOAT left, - FX_FLOAT top, - FX_FLOAT right, - FX_FLOAT bottom, - FX_BOOL bContains = FALSE); - virtual void GetBoundedSegment(int index, int& start, int& count) const; - virtual int GetWordBreak(int index, int direction) const; + ~CPDF_TextPage() override{}; + + // IPDF_TextPage + FX_BOOL ParseTextPage() override; + void NormalizeObjects(FX_BOOL bNormalize) override; + FX_BOOL IsParsered() const override { return m_IsParsered; } + int CharIndexFromTextIndex(int TextIndex) const override; + int TextIndexFromCharIndex(int CharIndex) const override; + int CountChars() const override; + void GetCharInfo(int index, FPDF_CHAR_INFO& info) const override; + void GetRectArray(int start, + int nCount, + CFX_RectArray& rectArray) const override; + int GetIndexAtPos(CPDF_Point point, + FX_FLOAT xTolerance, + FX_FLOAT yTolerance) const override; + int GetIndexAtPos(FX_FLOAT x, + FX_FLOAT y, + FX_FLOAT xTolerance, + FX_FLOAT yTolerance) const override; + CFX_WideString GetTextByRect(const CFX_FloatRect& rect) const override; + void GetRectsArrayByRect(const CFX_FloatRect& rect, + CFX_RectArray& resRectArray) const override; + CFX_WideString GetPageText(int start = 0, int nCount = -1) const override; + int CountRects(int start, int nCount) override; + void GetRect(int rectIndex, + FX_FLOAT& left, + FX_FLOAT& top, + FX_FLOAT& right, + FX_FLOAT& bottom) const override; + FX_BOOL GetBaselineRotate(int rectIndex, int& Rotate) override; + FX_BOOL GetBaselineRotate(const CFX_FloatRect& rect, int& Rotate) override; + int CountBoundedSegments(FX_FLOAT left, + FX_FLOAT top, + FX_FLOAT right, + FX_FLOAT bottom, + FX_BOOL bContains = FALSE) override; + void GetBoundedSegment(int index, int& start, int& count) const override; + int GetWordBreak(int index, int direction) const override; - public: const PAGECHAR_InfoArray* GetCharList() const { return &m_charList; } static FX_BOOL IsRectIntersect(const CFX_FloatRect& rect1, const CFX_FloatRect& rect2); @@ -147,21 +145,21 @@ class CPDF_TextPage : public IPDF_TextPage { int32_t m_TextlineDir; CFX_FloatRect m_CurlineRect; }; + class CPDF_TextPageFind : public IPDF_TextPageFind { public: CPDF_TextPageFind(const IPDF_TextPage* pTextPage); - virtual ~CPDF_TextPageFind(){}; - - public: - virtual FX_BOOL FindFirst(const CFX_WideString& findwhat, - int flags, - int startPos = 0); - virtual FX_BOOL FindNext(); - virtual FX_BOOL FindPrev(); - - virtual void GetRectArray(CFX_RectArray& rects) const; - virtual int GetCurOrder() const; - virtual int GetMatchedCount() const; + ~CPDF_TextPageFind() override{}; + + // IPDF_TextPageFind + FX_BOOL FindFirst(const CFX_WideString& findwhat, + int flags, + int startPos = 0) override; + FX_BOOL FindNext() override; + FX_BOOL FindPrev() override; + void GetRectArray(CFX_RectArray& rects) const override; + int GetCurOrder() const override; + int GetMatchedCount() const override; protected: void ExtractFindWhat(const CFX_WideString& findwhat); @@ -203,19 +201,22 @@ class CPDF_LinkExt { CFX_WideString m_strUrl; virtual ~CPDF_LinkExt(){}; }; + typedef CFX_ArrayTemplate<CPDF_LinkExt*> LINK_InfoArray; + class CPDF_LinkExtract : public IPDF_LinkExtract { public: CPDF_LinkExtract(); - virtual ~CPDF_LinkExtract(); - virtual FX_BOOL ExtractLinks(const IPDF_TextPage* pTextPage); - virtual FX_BOOL IsExtract() const { return m_IsParserd; } + ~CPDF_LinkExtract() override; - public: - virtual int CountLinks() const; - virtual CFX_WideString GetURL(int index) const; - virtual void GetBoundedSegment(int index, int& start, int& count) const; - virtual void GetRects(int index, CFX_RectArray& rects) const; + // IPDF_LinkExtract + FX_BOOL ExtractLinks(const IPDF_TextPage* pTextPage) override; + int CountLinks() const override; + CFX_WideString GetURL(int index) const override; + void GetBoundedSegment(int index, int& start, int& count) const override; + void GetRects(int index, CFX_RectArray& rects) const override; + + FX_BOOL IsExtract() const { return m_IsParserd; } protected: void parserLink(); @@ -230,6 +231,7 @@ class CPDF_LinkExtract : public IPDF_LinkExtract { CFX_WideString m_strPageText; FX_BOOL m_IsParserd; }; + FX_STRSIZE FX_Unicode_GetNormalization(FX_WCHAR wch, FX_WCHAR* pDst); void NormalizeString(CFX_WideString& str); void NormalizeCompositeChar(FX_WCHAR wChar, CFX_WideString& sDest); diff --git a/core/src/fxcodec/codec/codec_int.h b/core/src/fxcodec/codec/codec_int.h index e9449693dd..9fe77a44f7 100644 --- a/core/src/fxcodec/codec/codec_int.h +++ b/core/src/fxcodec/codec/codec_int.h @@ -31,36 +31,29 @@ class CCodec_BasicModule : public ICodec_BasicModule { int nComps, int bpc); }; + struct CCodec_ImageDataCache { int m_Width, m_Height; int m_nCachedLines; uint8_t m_Data; }; + class CCodec_ScanlineDecoder : public ICodec_ScanlineDecoder { public: CCodec_ScanlineDecoder(); - - virtual ~CCodec_ScanlineDecoder(); - - virtual FX_DWORD GetSrcOffset() { return -1; } - - virtual void DownScale(int dest_width, int dest_height); - - uint8_t* GetScanline(int line); - - FX_BOOL SkipToScanline(int line, IFX_Pause* pPause); - - int GetWidth() { return m_OutputWidth; } - - int GetHeight() { return m_OutputHeight; } - - int CountComps() { return m_nComps; } - - int GetBPC() { return m_bpc; } - - FX_BOOL IsColorTransformed() { return m_bColorTransformed; } - - void ClearImageData() { + ~CCodec_ScanlineDecoder() override; + + // ICodec_ScanlineDecoder + FX_DWORD GetSrcOffset() override { return -1; } + void DownScale(int dest_width, int dest_height) override; + uint8_t* GetScanline(int line) override; + FX_BOOL SkipToScanline(int line, IFX_Pause* pPause) override; + int GetWidth() override { return m_OutputWidth; } + int GetHeight() override { return m_OutputHeight; } + int CountComps() override { return m_nComps; } + int GetBPC() override { return m_bpc; } + FX_BOOL IsColorTransformed() override { return m_bColorTransformed; } + void ClearImageData() override { if (m_pDataCache) { FX_Free(m_pDataCache); } @@ -100,6 +93,7 @@ class CCodec_ScanlineDecoder : public ICodec_ScanlineDecoder { CCodec_ImageDataCache* m_pDataCache; }; + class CCodec_FaxModule : public ICodec_FaxModule { public: virtual ICodec_ScanlineDecoder* CreateDecoder(const uint8_t* src_buf, @@ -119,6 +113,7 @@ class CCodec_FaxModule : public ICodec_FaxModule { uint8_t*& dest_buf, FX_DWORD& dest_size); }; + class CCodec_FlateModule : public ICodec_FlateModule { public: virtual ICodec_ScanlineDecoder* CreateDecoder(const uint8_t* src_buf, @@ -155,6 +150,7 @@ class CCodec_FlateModule : public ICodec_FlateModule { uint8_t*& dest_buf, FX_DWORD& dest_size); }; + class CCodec_JpegModule : public ICodec_JpegModule { public: CCodec_JpegModule() : m_pExtProvider(NULL) {} @@ -244,6 +240,7 @@ class CCodec_IccModule : public ICodec_IccModule { Icc_CLASS ic, CFX_BinaryBuf* pTransformKey); }; + class CCodec_JpxModule : public ICodec_JpxModule { public: CCodec_JpxModule(); @@ -262,6 +259,7 @@ class CCodec_JpxModule : public ICodec_JpxModule { uint8_t* offsets); void DestroyDecoder(void* ctx); }; + class CPDF_Jbig2Interface : public CJBig2_Module { public: virtual void* JBig2_Malloc(FX_DWORD dwSize) { @@ -288,6 +286,7 @@ class CPDF_Jbig2Interface : public CJBig2_Module { } virtual void JBig2_Free(void* pMem) { FX_Free(pMem); } }; + class CCodec_Jbig2Context { public: CCodec_Jbig2Context(); @@ -309,7 +308,9 @@ class CCodec_Jbig2Context { class CCodec_Jbig2Module : public ICodec_Jbig2Module { public: CCodec_Jbig2Module(){}; - ~CCodec_Jbig2Module(); + ~CCodec_Jbig2Module() override; + + // ICodec_Jbig2Module FX_BOOL Decode(FX_DWORD width, FX_DWORD height, const uint8_t* src_buf, @@ -317,13 +318,13 @@ class CCodec_Jbig2Module : public ICodec_Jbig2Module { const uint8_t* global_data, FX_DWORD global_size, uint8_t* dest_buf, - FX_DWORD dest_pitch); + FX_DWORD dest_pitch) override; FX_BOOL Decode(IFX_FileRead* file_ptr, FX_DWORD& width, FX_DWORD& height, FX_DWORD& pitch, - uint8_t*& dest_buf); - void* CreateJbig2Context(); + uint8_t*& dest_buf) override; + void* CreateJbig2Context() override; FXCODEC_STATUS StartDecode(void* pJbig2Context, FX_DWORD width, FX_DWORD height, @@ -333,21 +334,21 @@ class CCodec_Jbig2Module : public ICodec_Jbig2Module { FX_DWORD global_size, uint8_t* dest_buf, FX_DWORD dest_pitch, - IFX_Pause* pPause); - + IFX_Pause* pPause) override; FXCODEC_STATUS StartDecode(void* pJbig2Context, IFX_FileRead* file_ptr, FX_DWORD& width, FX_DWORD& height, FX_DWORD& pitch, uint8_t*& dest_buf, - IFX_Pause* pPause); - FXCODEC_STATUS ContinueDecode(void* pJbig2Context, IFX_Pause* pPause); - void DestroyJbig2Context(void* pJbig2Context); - CPDF_Jbig2Interface m_Module; - std::list<CJBig2_CachePair> m_SymbolDictCache; + IFX_Pause* pPause) override; + FXCODEC_STATUS ContinueDecode(void* pJbig2Context, + IFX_Pause* pPause) override; + void DestroyJbig2Context(void* pJbig2Context) override; private: + CPDF_Jbig2Interface m_Module; + std::list<CJBig2_CachePair> m_SymbolDictCache; }; struct DecodeData { diff --git a/core/src/fxcodec/codec/fx_codec.cpp b/core/src/fxcodec/codec/fx_codec.cpp index 806cac1bc3..4ed02dc2c0 100644 --- a/core/src/fxcodec/codec/fx_codec.cpp +++ b/core/src/fxcodec/codec/fx_codec.cpp @@ -217,17 +217,20 @@ FX_BOOL CCodec_BasicModule::A85Encode(const uint8_t* src_buf, class CCodec_RLScanlineDecoder : public CCodec_ScanlineDecoder { public: CCodec_RLScanlineDecoder(); - virtual ~CCodec_RLScanlineDecoder(); + ~CCodec_RLScanlineDecoder() override; + FX_BOOL Create(const uint8_t* src_buf, FX_DWORD src_size, int width, int height, int nComps, int bpc); - virtual void v_DownScale(int dest_width, int dest_height) {} - virtual FX_BOOL v_Rewind(); - virtual uint8_t* v_GetNextLine(); - virtual FX_DWORD GetSrcOffset() { return m_SrcOffset; } + + // CCodec_ScanlineDecoder + void v_DownScale(int dest_width, int dest_height) override {} + FX_BOOL v_Rewind() override; + uint8_t* v_GetNextLine() override; + FX_DWORD GetSrcOffset() override { return m_SrcOffset; } protected: FX_BOOL CheckDestSize(); diff --git a/core/src/fxcodec/codec/fx_codec_fax.cpp b/core/src/fxcodec/codec/fx_codec_fax.cpp index 4260309380..34c07ac484 100644 --- a/core/src/fxcodec/codec/fx_codec_fax.cpp +++ b/core/src/fxcodec/codec/fx_codec_fax.cpp @@ -455,10 +455,12 @@ FX_BOOL _FaxGet1DLine(const uint8_t* src_buf, } return TRUE; } + class CCodec_FaxDecoder : public CCodec_ScanlineDecoder { public: CCodec_FaxDecoder(); - virtual ~CCodec_FaxDecoder(); + ~CCodec_FaxDecoder() override; + FX_BOOL Create(const uint8_t* src_buf, FX_DWORD src_size, int width, @@ -469,10 +471,13 @@ class CCodec_FaxDecoder : public CCodec_ScanlineDecoder { FX_BOOL BlackIs1, int Columns, int Rows); - virtual void v_DownScale(int dest_width, int dest_height) {} - virtual FX_BOOL v_Rewind(); - virtual uint8_t* v_GetNextLine(); - virtual FX_DWORD GetSrcOffset(); + + // CCodec_ScanlineDecoder + void v_DownScale(int dest_width, int dest_height) override {} + FX_BOOL v_Rewind() override; + uint8_t* v_GetNextLine() override; + FX_DWORD GetSrcOffset() override; + int m_Encoding, m_bEndOfLine, m_bByteAlign, m_bBlack; int bitpos; const uint8_t* m_pSrcBuf; @@ -480,6 +485,7 @@ class CCodec_FaxDecoder : public CCodec_ScanlineDecoder { uint8_t* m_pScanlineBuf; uint8_t* m_pRefBuf; }; + CCodec_FaxDecoder::CCodec_FaxDecoder() { m_pScanlineBuf = NULL; m_pRefBuf = NULL; diff --git a/core/src/fxcodec/codec/fx_codec_flate.cpp b/core/src/fxcodec/codec/fx_codec_flate.cpp index 91d28b0553..a4b37c1ca3 100644 --- a/core/src/fxcodec/codec/fx_codec_flate.cpp +++ b/core/src/fxcodec/codec/fx_codec_flate.cpp @@ -603,10 +603,12 @@ static FX_BOOL TIFF_Predictor(uint8_t*& data_buf, } return TRUE; } + class CCodec_FlateScanlineDecoder : public CCodec_ScanlineDecoder { public: CCodec_FlateScanlineDecoder(); - ~CCodec_FlateScanlineDecoder(); + ~CCodec_FlateScanlineDecoder() override; + void Create(const uint8_t* src_buf, FX_DWORD src_size, int width, @@ -617,11 +619,14 @@ class CCodec_FlateScanlineDecoder : public CCodec_ScanlineDecoder { int Colors, int BitsPerComponent, int Columns); - virtual void Destroy() { delete this; } - virtual void v_DownScale(int dest_width, int dest_height) {} - virtual FX_BOOL v_Rewind(); - virtual uint8_t* v_GetNextLine(); - virtual FX_DWORD GetSrcOffset(); + void Destroy() { delete this; } + + // CCodec_ScanlineDecoder + void v_DownScale(int dest_width, int dest_height) override {} + FX_BOOL v_Rewind() override; + uint8_t* v_GetNextLine() override; + FX_DWORD GetSrcOffset() override; + void* m_pFlate; const uint8_t* m_SrcBuf; FX_DWORD m_SrcSize; @@ -632,6 +637,7 @@ class CCodec_FlateScanlineDecoder : public CCodec_ScanlineDecoder { int m_Predictor; int m_Colors, m_BitsPerComponent, m_Columns, m_PredictPitch, m_LeftOver; }; + CCodec_FlateScanlineDecoder::CCodec_FlateScanlineDecoder() { m_pFlate = NULL; m_pScanline = NULL; diff --git a/core/src/fxcodec/codec/fx_codec_jpeg.cpp b/core/src/fxcodec/codec/fx_codec_jpeg.cpp index 681678c264..779e7f6b37 100644 --- a/core/src/fxcodec/codec/fx_codec_jpeg.cpp +++ b/core/src/fxcodec/codec/fx_codec_jpeg.cpp @@ -287,10 +287,12 @@ static FX_BOOL _JpegLoadInfo(const uint8_t* src_buf, jpeg_destroy_decompress(&cinfo); return TRUE; } + class CCodec_JpegDecoder : public CCodec_ScanlineDecoder { public: CCodec_JpegDecoder(); - ~CCodec_JpegDecoder(); + ~CCodec_JpegDecoder() override; + FX_BOOL Create(const uint8_t* src_buf, FX_DWORD src_size, int width, @@ -298,11 +300,16 @@ class CCodec_JpegDecoder : public CCodec_ScanlineDecoder { int nComps, FX_BOOL ColorTransform, IFX_JpegProvider* pJP); - virtual void Destroy() { delete this; } - virtual void v_DownScale(int dest_width, int dest_height); - virtual FX_BOOL v_Rewind(); - virtual uint8_t* v_GetNextLine(); - virtual FX_DWORD GetSrcOffset(); + void Destroy() { delete this; } + + // CCodec_ScanlineDecoder + void v_DownScale(int dest_width, int dest_height) override; + FX_BOOL v_Rewind() override; + uint8_t* v_GetNextLine() override; + FX_DWORD GetSrcOffset() override; + + FX_BOOL InitDecode(); + jmp_buf m_JmpBuf; struct jpeg_decompress_struct cinfo; struct jpeg_error_mgr jerr; @@ -310,14 +317,17 @@ class CCodec_JpegDecoder : public CCodec_ScanlineDecoder { const uint8_t* m_SrcBuf; FX_DWORD m_SrcSize; uint8_t* m_pScanlineBuf; - FX_BOOL InitDecode(); - FX_BOOL m_bInited, m_bStarted, m_bJpegTransform; + + FX_BOOL m_bInited; + FX_BOOL m_bStarted; + FX_BOOL m_bJpegTransform; protected: IFX_JpegProvider* m_pExtProvider; void* m_pExtContext; FX_DWORD m_nDefaultScaleDenom; }; + CCodec_JpegDecoder::CCodec_JpegDecoder() { m_pScanlineBuf = NULL; m_DownScale = 1; diff --git a/core/src/fxcrt/extension.h b/core/src/fxcrt/extension.h index 7d14cb0b9a..a712fa3770 100644 --- a/core/src/fxcrt/extension.h +++ b/core/src/fxcrt/extension.h @@ -30,10 +30,11 @@ class IFXCRT_FileAccess { virtual FX_BOOL Truncate(FX_FILESIZE szFile) = 0; }; IFXCRT_FileAccess* FXCRT_FileAccess_Create(); + class CFX_CRTFileStream final : public IFX_FileStream { public: CFX_CRTFileStream(IFXCRT_FileAccess* pFA) : m_pFile(pFA), m_dwCount(1) {} - ~CFX_CRTFileStream() { + ~CFX_CRTFileStream() override { if (m_pFile) { m_pFile->Release(); } @@ -70,6 +71,7 @@ class CFX_CRTFileStream final : public IFX_FileStream { IFXCRT_FileAccess* m_pFile; FX_DWORD m_dwCount; }; + #define FX_MEMSTREAM_BlockSize (64 * 1024) #define FX_MEMSTREAM_Consecutive 0x01 #define FX_MEMSTREAM_TakeOver 0x02 @@ -94,7 +96,7 @@ class CFX_MemoryStream final : public IFX_MemoryStream { m_dwFlags = FX_MEMSTREAM_Consecutive | (bTakeOver ? FX_MEMSTREAM_TakeOver : 0); } - ~CFX_MemoryStream() { + ~CFX_MemoryStream() override { if (m_dwFlags & FX_MEMSTREAM_TakeOver) { for (int32_t i = 0; i < m_Blocks.GetSize(); i++) { FX_Free((uint8_t*)m_Blocks[i]); @@ -287,6 +289,7 @@ class CFX_MemoryStream final : public IFX_MemoryStream { return TRUE; } }; + #ifdef __cplusplus extern "C" { #endif diff --git a/core/src/fxcrt/fxcrt_platforms.h b/core/src/fxcrt/fxcrt_platforms.h index 5870c76469..393df694eb 100644 --- a/core/src/fxcrt/fxcrt_platforms.h +++ b/core/src/fxcrt/fxcrt_platforms.h @@ -15,22 +15,24 @@ void FXCRT_GetFileModeString(FX_DWORD dwModes, CFX_WideString& wsMode); class CFXCRT_FileAccess_CRT : public IFXCRT_FileAccess { public: CFXCRT_FileAccess_CRT(); - virtual ~CFXCRT_FileAccess_CRT(); - virtual FX_BOOL Open(const CFX_ByteStringC& fileName, FX_DWORD dwMode); - virtual FX_BOOL Open(const CFX_WideStringC& fileName, FX_DWORD dwMode); - virtual void Close(); - virtual void Release(); - virtual FX_FILESIZE GetSize() const; - virtual FX_FILESIZE GetPosition() const; - virtual FX_FILESIZE SetPosition(FX_FILESIZE pos); - virtual size_t Read(void* pBuffer, size_t szBuffer); - virtual size_t Write(const void* pBuffer, size_t szBuffer); - virtual size_t ReadPos(void* pBuffer, size_t szBuffer, FX_FILESIZE pos); - virtual size_t WritePos(const void* pBuffer, - size_t szBuffer, - FX_FILESIZE pos); - virtual FX_BOOL Flush(); - virtual FX_BOOL Truncate(FX_FILESIZE szFile); + ~CFXCRT_FileAccess_CRT() override; + + // IFXCRT_FileAccess + FX_BOOL Open(const CFX_ByteStringC& fileName, FX_DWORD dwMode) override; + FX_BOOL Open(const CFX_WideStringC& fileName, FX_DWORD dwMode) override; + void Close() override; + void Release() override; + FX_FILESIZE GetSize() const override; + FX_FILESIZE GetPosition() const override; + FX_FILESIZE SetPosition(FX_FILESIZE pos) override; + size_t Read(void* pBuffer, size_t szBuffer) override; + size_t Write(const void* pBuffer, size_t szBuffer) override; + size_t ReadPos(void* pBuffer, size_t szBuffer, FX_FILESIZE pos) override; + size_t WritePos(const void* pBuffer, + size_t szBuffer, + FX_FILESIZE pos) override; + FX_BOOL Flush() override; + FX_BOOL Truncate(FX_FILESIZE szFile) override; protected: FXSYS_FILE* m_hFile; diff --git a/core/src/fxcrt/fxcrt_posix.h b/core/src/fxcrt/fxcrt_posix.h index 19e11da4a8..b24721dddd 100644 --- a/core/src/fxcrt/fxcrt_posix.h +++ b/core/src/fxcrt/fxcrt_posix.h @@ -15,22 +15,24 @@ class CFXCRT_FileAccess_Posix : public IFXCRT_FileAccess { public: CFXCRT_FileAccess_Posix(); - virtual ~CFXCRT_FileAccess_Posix(); - virtual FX_BOOL Open(const CFX_ByteStringC& fileName, FX_DWORD dwMode); - virtual FX_BOOL Open(const CFX_WideStringC& fileName, FX_DWORD dwMode); - virtual void Close(); - virtual void Release(); - virtual FX_FILESIZE GetSize() const; - virtual FX_FILESIZE GetPosition() const; - virtual FX_FILESIZE SetPosition(FX_FILESIZE pos); - virtual size_t Read(void* pBuffer, size_t szBuffer); - virtual size_t Write(const void* pBuffer, size_t szBuffer); - virtual size_t ReadPos(void* pBuffer, size_t szBuffer, FX_FILESIZE pos); - virtual size_t WritePos(const void* pBuffer, - size_t szBuffer, - FX_FILESIZE pos); - virtual FX_BOOL Flush(); - virtual FX_BOOL Truncate(FX_FILESIZE szFile); + ~CFXCRT_FileAccess_Posix() override; + + // IFXCRT_FileAccess + FX_BOOL Open(const CFX_ByteStringC& fileName, FX_DWORD dwMode) override; + FX_BOOL Open(const CFX_WideStringC& fileName, FX_DWORD dwMode) override; + void Close() override; + void Release() override; + FX_FILESIZE GetSize() const override; + FX_FILESIZE GetPosition() const override; + FX_FILESIZE SetPosition(FX_FILESIZE pos) override; + size_t Read(void* pBuffer, size_t szBuffer) override; + size_t Write(const void* pBuffer, size_t szBuffer) override; + size_t ReadPos(void* pBuffer, size_t szBuffer, FX_FILESIZE pos) override; + size_t WritePos(const void* pBuffer, + size_t szBuffer, + FX_FILESIZE pos) override; + FX_BOOL Flush() override; + FX_BOOL Truncate(FX_FILESIZE szFile) override; protected: int32_t m_nFD; diff --git a/core/src/fxcrt/fxcrt_windows.h b/core/src/fxcrt/fxcrt_windows.h index bb00410e19..b3a20a91e5 100644 --- a/core/src/fxcrt/fxcrt_windows.h +++ b/core/src/fxcrt/fxcrt_windows.h @@ -13,22 +13,24 @@ class CFXCRT_FileAccess_Win64 : public IFXCRT_FileAccess { public: CFXCRT_FileAccess_Win64(); - virtual ~CFXCRT_FileAccess_Win64(); - virtual FX_BOOL Open(const CFX_ByteStringC& fileName, FX_DWORD dwMode); - virtual FX_BOOL Open(const CFX_WideStringC& fileName, FX_DWORD dwMode); - virtual void Close(); - virtual void Release(); - virtual FX_FILESIZE GetSize() const; - virtual FX_FILESIZE GetPosition() const; - virtual FX_FILESIZE SetPosition(FX_FILESIZE pos); - virtual size_t Read(void* pBuffer, size_t szBuffer); - virtual size_t Write(const void* pBuffer, size_t szBuffer); - virtual size_t ReadPos(void* pBuffer, size_t szBuffer, FX_FILESIZE pos); - virtual size_t WritePos(const void* pBuffer, - size_t szBuffer, - FX_FILESIZE pos); - virtual FX_BOOL Flush(); - virtual FX_BOOL Truncate(FX_FILESIZE szFile); + ~CFXCRT_FileAccess_Win64() override; + + // IFXCRT_FileAccess + FX_BOOL Open(const CFX_ByteStringC& fileName, FX_DWORD dwMode) override; + FX_BOOL Open(const CFX_WideStringC& fileName, FX_DWORD dwMode) override; + void Close() override; + void Release() override; + FX_FILESIZE GetSize() const override; + FX_FILESIZE GetPosition() const override; + FX_FILESIZE SetPosition(FX_FILESIZE pos) override; + size_t Read(void* pBuffer, size_t szBuffer) override; + size_t Write(const void* pBuffer, size_t szBuffer) override; + size_t ReadPos(void* pBuffer, size_t szBuffer, FX_FILESIZE pos) override; + size_t WritePos(const void* pBuffer, + size_t szBuffer, + FX_FILESIZE pos) override; + FX_BOOL Flush() override; + FX_BOOL Truncate(FX_FILESIZE szFile) override; protected: void* m_hFile; diff --git a/core/src/fxcrt/xml_int.h b/core/src/fxcrt/xml_int.h index 1008436c84..6020f45819 100644 --- a/core/src/fxcrt/xml_int.h +++ b/core/src/fxcrt/xml_int.h @@ -13,12 +13,14 @@ class CXML_DataBufAcc : public IFX_BufferRead { public: CXML_DataBufAcc(const uint8_t* pBuffer, size_t size) : m_pBuffer(pBuffer), m_dwSize(size), m_dwCurPos(0) {} - virtual ~CXML_DataBufAcc() {} - virtual void Release() { delete this; } - virtual FX_BOOL IsEOF() { return m_dwCurPos >= m_dwSize; } - virtual FX_FILESIZE GetPosition() { return (FX_FILESIZE)m_dwCurPos; } - virtual size_t ReadBlock(void* buffer, size_t size) { return 0; } - virtual FX_BOOL ReadNextBlock(FX_BOOL bRestart = FALSE) { + ~CXML_DataBufAcc() override {} + + // IFX_BufferRead + void Release() override { delete this; } + FX_BOOL IsEOF() override { return m_dwCurPos >= m_dwSize; } + FX_FILESIZE GetPosition() override { return (FX_FILESIZE)m_dwCurPos; } + size_t ReadBlock(void* buffer, size_t size) override { return 0; } + FX_BOOL ReadNextBlock(FX_BOOL bRestart = FALSE) override { if (bRestart) { m_dwCurPos = 0; } @@ -28,15 +30,16 @@ class CXML_DataBufAcc : public IFX_BufferRead { } return FALSE; } - virtual const uint8_t* GetBlockBuffer() { return m_pBuffer; } - virtual size_t GetBlockSize() { return m_dwSize; } - virtual FX_FILESIZE GetBlockOffset() { return 0; } + const uint8_t* GetBlockBuffer() override { return m_pBuffer; } + size_t GetBlockSize() override { return m_dwSize; } + FX_FILESIZE GetBlockOffset() override { return 0; } protected: const uint8_t* m_pBuffer; size_t m_dwSize; size_t m_dwCurPos; }; + #define FX_XMLDATASTREAM_BufferSize (32 * 1024) class CXML_DataStmAcc : public IFX_BufferRead { public: @@ -44,18 +47,21 @@ class CXML_DataStmAcc : public IFX_BufferRead { : m_pFileRead(pFileRead), m_pBuffer(NULL), m_nStart(0), m_dwSize(0) { FXSYS_assert(m_pFileRead != NULL); } - virtual ~CXML_DataStmAcc() { + ~CXML_DataStmAcc() override { if (m_pBuffer) { FX_Free(m_pBuffer); } } - virtual void Release() { delete this; } - virtual FX_BOOL IsEOF() { + + void Release() override { delete this; } + FX_BOOL IsEOF() override { return m_nStart + (FX_FILESIZE)m_dwSize >= m_pFileRead->GetSize(); } - virtual FX_FILESIZE GetPosition() { return m_nStart + (FX_FILESIZE)m_dwSize; } - virtual size_t ReadBlock(void* buffer, size_t size) { return 0; } - virtual FX_BOOL ReadNextBlock(FX_BOOL bRestart = FALSE) { + FX_FILESIZE GetPosition() override { + return m_nStart + (FX_FILESIZE)m_dwSize; + } + size_t ReadBlock(void* buffer, size_t size) override { return 0; } + FX_BOOL ReadNextBlock(FX_BOOL bRestart = FALSE) override { if (bRestart) { m_nStart = 0; } @@ -70,9 +76,9 @@ class CXML_DataStmAcc : public IFX_BufferRead { } return m_pFileRead->ReadBlock(m_pBuffer, m_nStart, m_dwSize); } - virtual const uint8_t* GetBlockBuffer() { return (const uint8_t*)m_pBuffer; } - virtual size_t GetBlockSize() { return m_dwSize; } - virtual FX_FILESIZE GetBlockOffset() { return m_nStart; } + const uint8_t* GetBlockBuffer() override { return (const uint8_t*)m_pBuffer; } + size_t GetBlockSize() override { return m_dwSize; } + FX_FILESIZE GetBlockOffset() override { return m_nStart; } protected: IFX_FileRead* m_pFileRead; @@ -80,6 +86,7 @@ class CXML_DataStmAcc : public IFX_BufferRead { FX_FILESIZE m_nStart; size_t m_dwSize; }; + class CXML_Parser { public: ~CXML_Parser(); @@ -113,6 +120,7 @@ class CXML_Parser { CXML_Element* pElement); void InsertCDATASegment(CFX_UTF8Decoder& decoder, CXML_Element* pElement); }; + void FX_XML_SplitQualifiedName(const CFX_ByteStringC& bsFullName, CFX_ByteStringC& bsSpace, CFX_ByteStringC& bsName); diff --git a/core/src/fxge/agg/include/fx_agg_driver.h b/core/src/fxge/agg/include/fx_agg_driver.h index 2954526cd5..c3de76d369 100644 --- a/core/src/fxge/agg/include/fx_agg_driver.h +++ b/core/src/fxge/agg/include/fx_agg_driver.h @@ -26,119 +26,110 @@ class CFX_AggDeviceDriver : public IFX_RenderDeviceDriver { FX_BOOL bRgbByteOrder, CFX_DIBitmap* pOriDevice, FX_BOOL bGroupKnockout); - virtual ~CFX_AggDeviceDriver(); + ~CFX_AggDeviceDriver() override; + void InitPlatform(); void DestroyPlatform(); - virtual int GetDeviceCaps(int caps_id); - - virtual void SaveState(); - virtual void RestoreState(FX_BOOL bKeepSaved); - - virtual FX_BOOL SetClip_PathFill(const CFX_PathData* pPathData, - const CFX_AffineMatrix* pObject2Device, - int fill_mode); - - virtual FX_BOOL SetClip_PathStroke(const CFX_PathData* pPathData, - const CFX_AffineMatrix* pObject2Device, - const CFX_GraphStateData* pGraphState); - - virtual FX_BOOL DrawPath(const CFX_PathData* pPathData, + // IFX_RenderDeviceDriver + int GetDeviceCaps(int caps_id) override; + void SaveState() override; + void RestoreState(FX_BOOL bKeepSaved) override; + FX_BOOL SetClip_PathFill(const CFX_PathData* pPathData, const CFX_AffineMatrix* pObject2Device, - const CFX_GraphStateData* pGraphState, - FX_DWORD fill_color, - FX_DWORD stroke_color, - int fill_mode, - int alpha_flag, - void* pIccTransform, - int blend_type); - - virtual FX_BOOL SetPixel(int x, - int y, + int fill_mode) override; + FX_BOOL SetClip_PathStroke(const CFX_PathData* pPathData, + const CFX_AffineMatrix* pObject2Device, + const CFX_GraphStateData* pGraphState) override; + FX_BOOL DrawPath(const CFX_PathData* pPathData, + const CFX_AffineMatrix* pObject2Device, + const CFX_GraphStateData* pGraphState, + FX_DWORD fill_color, + FX_DWORD stroke_color, + int fill_mode, + int alpha_flag, + void* pIccTransform, + int blend_type) override; + FX_BOOL SetPixel(int x, + int y, + FX_DWORD color, + int alpha_flag, + void* pIccTransform) override; + FX_BOOL FillRect(const FX_RECT* pRect, + FX_DWORD fill_color, + int alpha_flag, + void* pIccTransform, + int blend_type) override; + FX_BOOL DrawCosmeticLine(FX_FLOAT x1, + FX_FLOAT y1, + FX_FLOAT x2, + FX_FLOAT y2, FX_DWORD color, int alpha_flag, - void* pIccTransform); - - virtual FX_BOOL FillRect(const FX_RECT* pRect, - FX_DWORD fill_color, - int alpha_flag, void* pIccTransform, - int blend_type); - - virtual FX_BOOL DrawCosmeticLine(FX_FLOAT x1, - FX_FLOAT y1, - FX_FLOAT x2, - FX_FLOAT y2, - FX_DWORD color, - int alpha_flag, - void* pIccTransform, - int blend_type) { + int blend_type) override { return FALSE; } - - virtual FX_BOOL GetClipBox(FX_RECT* pRect); - - virtual FX_BOOL GetDIBits(CFX_DIBitmap* pBitmap, - int left, - int top, - void* pIccTransform = NULL, - FX_BOOL bDEdge = FALSE); - virtual CFX_DIBitmap* GetBackDrop() { return m_pOriDevice; } - - virtual FX_BOOL SetDIBits(const CFX_DIBSource* pBitmap, - FX_DWORD color, - const FX_RECT* pSrcRect, - int left, - int top, - int blend_type, - int alpha_flag, - void* pIccTransform); - virtual FX_BOOL StretchDIBits(const CFX_DIBSource* pBitmap, - FX_DWORD color, - int dest_left, - int dest_top, - int dest_width, - int dest_height, - const FX_RECT* pClipRect, - FX_DWORD flags, - int alpha_flag, - void* pIccTransform, - int blend_type); - - virtual FX_BOOL StartDIBits(const CFX_DIBSource* pBitmap, - int bitmap_alpha, - FX_DWORD color, - const CFX_AffineMatrix* pMatrix, - FX_DWORD flags, - void*& handle, - int alpha_flag, - void* pIccTransform, - int blend_type); - virtual FX_BOOL ContinueDIBits(void* handle, IFX_Pause* pPause); - virtual void CancelDIBits(void* handle); - - virtual FX_BOOL DrawDeviceText(int nChars, - const FXTEXT_CHARPOS* pCharPos, - CFX_Font* pFont, - CFX_FontCache* pCache, - const CFX_AffineMatrix* pObject2Device, - FX_FLOAT font_size, - FX_DWORD color, - int alpha_flag, - void* pIccTransform); - virtual FX_BOOL RenderRasterizer( - FX_NAMESPACE_DECLARE(agg, rasterizer_scanline_aa) & rasterizer, - FX_DWORD color, - FX_BOOL bFullCover, - FX_BOOL bGroupKnockout, - int alpha_flag, - void* pIccTransform); + FX_BOOL GetClipBox(FX_RECT* pRect) override; + FX_BOOL GetDIBits(CFX_DIBitmap* pBitmap, + int left, + int top, + void* pIccTransform = NULL, + FX_BOOL bDEdge = FALSE) override; + CFX_DIBitmap* GetBackDrop() override { return m_pOriDevice; } + FX_BOOL SetDIBits(const CFX_DIBSource* pBitmap, + FX_DWORD color, + const FX_RECT* pSrcRect, + int left, + int top, + int blend_type, + int alpha_flag, + void* pIccTransform) override; + FX_BOOL StretchDIBits(const CFX_DIBSource* pBitmap, + FX_DWORD color, + int dest_left, + int dest_top, + int dest_width, + int dest_height, + const FX_RECT* pClipRect, + FX_DWORD flags, + int alpha_flag, + void* pIccTransform, + int blend_type) override; + FX_BOOL StartDIBits(const CFX_DIBSource* pBitmap, + int bitmap_alpha, + FX_DWORD color, + const CFX_AffineMatrix* pMatrix, + FX_DWORD flags, + void*& handle, + int alpha_flag, + void* pIccTransform, + int blend_type) override; + FX_BOOL ContinueDIBits(void* handle, IFX_Pause* pPause) override; + void CancelDIBits(void* handle) override; + FX_BOOL DrawDeviceText(int nChars, + const FXTEXT_CHARPOS* pCharPos, + CFX_Font* pFont, + CFX_FontCache* pCache, + const CFX_AffineMatrix* pObject2Device, + FX_FLOAT font_size, + FX_DWORD color, + int alpha_flag, + void* pIccTransform) override; + int GetDriverType() override { return 1; } + + FX_BOOL RenderRasterizer(FX_NAMESPACE_DECLARE(agg, rasterizer_scanline_aa) & + rasterizer, + FX_DWORD color, + FX_BOOL bFullCover, + FX_BOOL bGroupKnockout, + int alpha_flag, + void* pIccTransform); void SetClipMask(FX_NAMESPACE_DECLARE(agg, rasterizer_scanline_aa) & rasterizer); virtual uint8_t* GetBuffer() const { return m_pBitmap->GetBuffer(); } - virtual int GetDriverType() { return 1; } CFX_DIBitmap* m_pBitmap; CFX_ClipRgn* m_pClipRgn; diff --git a/core/src/fxge/android/fpf_skiafont.h b/core/src/fxge/android/fpf_skiafont.h index 4a841940df..6ee2f258e4 100644 --- a/core/src/fxge/android/fpf_skiafont.h +++ b/core/src/fxge/android/fpf_skiafont.h @@ -8,38 +8,37 @@ #define CORE_SRC_FXGE_ANDROID_FPF_SKIAFONT_H_ #if _FX_OS_ == _FX_ANDROID_ + +#include "../../../include/fxge/fpf.h" + class CFPF_SkiaFontDescriptor; class CFPF_SkiaFontMgr; class SkTypeface; class CFPF_SkiaFont : public IFPF_Font { public: CFPF_SkiaFont(); - virtual ~CFPF_SkiaFont(); - virtual void Release(); - virtual IFPF_Font* Retain(); - - virtual FPF_HFONT GetHandle(); - - virtual CFX_ByteString GetFamilyName(); - virtual CFX_WideString GetPsName(); - - virtual FX_DWORD GetFontStyle() const { return m_dwStyle; } - virtual uint8_t GetCharset() const { return m_uCharset; } - - virtual int32_t GetGlyphIndex(FX_WCHAR wUnicode); - virtual int32_t GetGlyphWidth(int32_t iGlyphIndex); - - virtual int32_t GetAscent() const; - virtual int32_t GetDescent() const; - - virtual FX_BOOL GetGlyphBBox(int32_t iGlyphIndex, FX_RECT& rtBBox); - virtual FX_BOOL GetBBox(FX_RECT& rtBBox); + ~CFPF_SkiaFont() override; + + // IFPF_Font + void Release() override; + IFPF_Font* Retain() override; + FPF_HFONT GetHandle() override; + CFX_ByteString GetFamilyName() override; + CFX_WideString GetPsName() override; + FX_DWORD GetFontStyle() const override { return m_dwStyle; } + uint8_t GetCharset() const override { return m_uCharset; } + int32_t GetGlyphIndex(FX_WCHAR wUnicode) override; + int32_t GetGlyphWidth(int32_t iGlyphIndex) override; + int32_t GetAscent() const override; + int32_t GetDescent() const override; + FX_BOOL GetGlyphBBox(int32_t iGlyphIndex, FX_RECT& rtBBox) override; + FX_BOOL GetBBox(FX_RECT& rtBBox) override; + int32_t GetHeight() const override; + int32_t GetItalicAngle() const override; + FX_DWORD GetFontData(FX_DWORD dwTable, + uint8_t* pBuffer, + FX_DWORD dwSize) override; - virtual int32_t GetHeight() const; - virtual int32_t GetItalicAngle() const; - virtual FX_DWORD GetFontData(FX_DWORD dwTable, - uint8_t* pBuffer, - FX_DWORD dwSize); FX_BOOL InitFont(CFPF_SkiaFontMgr* pFontMgr, CFPF_SkiaFontDescriptor* pFontDes, const CFX_ByteStringC& bsFamily, diff --git a/core/src/fxge/android/fpf_skiafontmgr.h b/core/src/fxge/android/fpf_skiafontmgr.h index c5dd8fd1b2..17bcb48ca1 100644 --- a/core/src/fxge/android/fpf_skiafontmgr.h +++ b/core/src/fxge/android/fpf_skiafontmgr.h @@ -8,10 +8,14 @@ #define CORE_SRC_FXGE_ANDROID_FPF_SKIAFONTMGR_H_ #if _FX_OS_ == _FX_ANDROID_ + +#include "../../../include/fxge/fpf.h" + #define FPF_SKIAFONTTYPE_Unknown 0 #define FPF_SKIAFONTTYPE_Path 1 #define FPF_SKIAFONTTYPE_File 2 #define FPF_SKIAFONTTYPE_Buffer 3 + class CFPF_SkiaFontDescriptor { public: CFPF_SkiaFontDescriptor() @@ -25,7 +29,9 @@ class CFPF_SkiaFontDescriptor { FX_Free(m_pFamily); } } + virtual int32_t GetType() const { return FPF_SKIAFONTTYPE_Unknown; } + void SetFamily(const FX_CHAR* pFamily) { if (m_pFamily) { FX_Free(m_pFamily); @@ -41,15 +47,19 @@ class CFPF_SkiaFontDescriptor { FX_DWORD m_dwCharsets; int32_t m_iGlyphNum; }; + class CFPF_SkiaPathFont : public CFPF_SkiaFontDescriptor { public: CFPF_SkiaPathFont() : m_pPath(NULL) {} - virtual ~CFPF_SkiaPathFont() { + ~CFPF_SkiaPathFont() override { if (m_pPath) { FX_Free(m_pPath); } } - virtual int32_t GetType() const { return FPF_SKIAFONTTYPE_Path; } + + // CFPF_SkiaFontDescriptor + int32_t GetType() const override { return FPF_SKIAFONTTYPE_Path; } + void SetPath(const FX_CHAR* pPath) { if (m_pPath) { FX_Free(m_pPath); @@ -61,33 +71,43 @@ class CFPF_SkiaPathFont : public CFPF_SkiaFontDescriptor { } FX_CHAR* m_pPath; }; + class CFPF_SkiaFileFont : public CFPF_SkiaFontDescriptor { public: CFPF_SkiaFileFont() : m_pFile(NULL) {} - virtual int32_t GetType() const { return FPF_SKIAFONTTYPE_File; } + + // CFPF_SkiaFontDescriptor + int32_t GetType() const override { return FPF_SKIAFONTTYPE_File; } IFX_FileRead* m_pFile; }; + class CFPF_SkiaBufferFont : public CFPF_SkiaFontDescriptor { public: CFPF_SkiaBufferFont() : m_pBuffer(NULL), m_szBuffer(0) {} - virtual int32_t GetType() const { return FPF_SKIAFONTTYPE_Buffer; } + + // CFPF_SkiaFontDescriptor + int32_t GetType() const override { return FPF_SKIAFONTTYPE_Buffer; } + void* m_pBuffer; size_t m_szBuffer; }; + class CFPF_SkiaFontMgr : public IFPF_FontMgr { public: CFPF_SkiaFontMgr(); - virtual ~CFPF_SkiaFontMgr(); + ~CFPF_SkiaFontMgr() override; + + // IFPF_FontMgr + void LoadSystemFonts() override; + void LoadPrivateFont(IFX_FileRead* pFontFile) override; + void LoadPrivateFont(const CFX_ByteStringC& bsFileName) override; + void LoadPrivateFont(void* pBuffer, size_t szBuffer) override; + IFPF_Font* CreateFont(const CFX_ByteStringC& bsFamilyname, + uint8_t uCharset, + FX_DWORD dwStyle, + FX_DWORD dwMatch = 0) override; + FX_BOOL InitFTLibrary(); - virtual void LoadSystemFonts(); - virtual void LoadPrivateFont(IFX_FileRead* pFontFile); - virtual void LoadPrivateFont(const CFX_ByteStringC& bsFileName); - virtual void LoadPrivateFont(void* pBuffer, size_t szBuffer); - - virtual IFPF_Font* CreateFont(const CFX_ByteStringC& bsFamilyname, - uint8_t uCharset, - FX_DWORD dwStyle, - FX_DWORD dwMatch = 0); FXFT_Face GetFontFace(IFX_FileRead* pFileRead, int32_t iFaceIndex = 0); FXFT_Face GetFontFace(const CFX_ByteStringC& bsFile, int32_t iFaceIndex = 0); FXFT_Face GetFontFace(const uint8_t* pBuffer, @@ -104,6 +124,7 @@ class CFPF_SkiaFontMgr : public IFPF_FontMgr { FXFT_Library m_FTLibrary; CFX_MapPtrToPtr m_FamilyFonts; }; + #endif #endif // CORE_SRC_FXGE_ANDROID_FPF_SKIAFONTMGR_H_ diff --git a/core/src/fxge/android/fpf_skiamodule.h b/core/src/fxge/android/fpf_skiamodule.h index 4f1c1193d8..5d1da7be32 100644 --- a/core/src/fxge/android/fpf_skiamodule.h +++ b/core/src/fxge/android/fpf_skiamodule.h @@ -8,13 +8,19 @@ #define CORE_SRC_FXGE_ANDROID_FPF_SKIAMODULE_H_ #if _FX_OS_ == _FX_ANDROID_ + +#include "../../../include/fxge/fpf.h" + class CFPF_SkiaFontMgr; + class CFPF_SkiaDeviceModule : public IFPF_DeviceModule { public: - CFPF_SkiaDeviceModule() : m_pFontMgr(NULL) {} - virtual ~CFPF_SkiaDeviceModule(); - virtual void Destroy(); - virtual IFPF_FontMgr* GetFontMgr(); + CFPF_SkiaDeviceModule() : m_pFontMgr(nullptr) {} + ~CFPF_SkiaDeviceModule() override; + + // IFPF_DeviceModule + void Destroy() override; + IFPF_FontMgr* GetFontMgr() override; protected: CFPF_SkiaFontMgr* m_pFontMgr; diff --git a/core/src/fxge/apple/apple_int.h b/core/src/fxge/apple/apple_int.h index ba3d0a83e8..9bff4ebcbc 100644 --- a/core/src/fxge/apple/apple_int.h +++ b/core/src/fxge/apple/apple_int.h @@ -8,9 +8,13 @@ #define CORE_SRC_FXGE_APPLE_APPLE_INT_H_ #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ + +#include "../../../include/fxge/fx_ge.h" + #if _FX_OS_ == _FX_MACOSX_ #include <Carbon/Carbon.h> #endif + typedef enum eFXIOSFONTCHARSET { eFXFontCharsetDEFAULT = 0, eFXFontCharsetANSI = 1, @@ -68,105 +72,107 @@ class CApplePlatform { CQuartz2D _quartz2d; }; + class CFX_QuartzDeviceDriver : public IFX_RenderDeviceDriver { public: CFX_QuartzDeviceDriver(CGContextRef context, int32_t deviceClass); - virtual ~CFX_QuartzDeviceDriver(); + ~CFX_QuartzDeviceDriver() override; - virtual int GetDeviceCaps(int caps_id); - virtual CFX_Matrix GetCTM() const; - virtual CFX_DIBitmap* GetBackDrop() { return NULL; } - virtual void* GetPlatformSurface() { return NULL; } - virtual FX_BOOL IsPSPrintDriver() { return FALSE; } - virtual FX_BOOL StartRendering() { return TRUE; } - virtual void EndRendering() {} - virtual void SaveState(); - virtual void RestoreState(FX_BOOL bKeepSaved); - virtual FX_BOOL SetClip_PathFill(const CFX_PathData* pPathData, - const CFX_AffineMatrix* pObject2Device, - int fill_mode); - virtual FX_BOOL SetClip_PathStroke(const CFX_PathData* pPathData, - const CFX_AffineMatrix* pObject2Device, - const CFX_GraphStateData* pGraphState); - virtual FX_BOOL DrawPath(const CFX_PathData* pPathData, + // IFX_RenderDeviceDriver + int GetDeviceCaps(int caps_id) override; + CFX_Matrix GetCTM() const override; + FX_BOOL IsPSPrintDriver() override { return FALSE; } + FX_BOOL StartRendering() override { return TRUE; } + void EndRendering() override {} + void SaveState() override; + void RestoreState(FX_BOOL bKeepSaved) override; + FX_BOOL SetClip_PathFill(const CFX_PathData* pPathData, const CFX_AffineMatrix* pObject2Device, - const CFX_GraphStateData* pGraphState, - FX_DWORD fill_color, - FX_DWORD stroke_color, - int fill_mode, - int alpha_flag = 0, - void* pIccTransform = NULL, - int blend_type = FXDIB_BLEND_NORMAL); - virtual FX_BOOL SetPixel(int x, - int y, - FX_DWORD color, - int alpha_flag = 0, - void* pIccTransform = NULL) { + int fill_mode) override; + FX_BOOL SetClip_PathStroke(const CFX_PathData* pPathData, + const CFX_AffineMatrix* pObject2Device, + const CFX_GraphStateData* pGraphState) override; + FX_BOOL DrawPath(const CFX_PathData* pPathData, + const CFX_AffineMatrix* pObject2Device, + const CFX_GraphStateData* pGraphState, + FX_DWORD fill_color, + FX_DWORD stroke_color, + int fill_mode, + int alpha_flag = 0, + void* pIccTransform = NULL, + int blend_type = FXDIB_BLEND_NORMAL) override; + FX_BOOL SetPixel(int x, + int y, + FX_DWORD color, + int alpha_flag = 0, + void* pIccTransform = NULL) override { return FALSE; } - virtual FX_BOOL FillRect(const FX_RECT* pRect, - FX_DWORD fill_color, + FX_BOOL FillRect(const FX_RECT* pRect, + FX_DWORD fill_color, + int alpha_flag = 0, + void* pIccTransform = NULL, + int blend_type = FXDIB_BLEND_NORMAL) override; + FX_BOOL DrawCosmeticLine(FX_FLOAT x1, + FX_FLOAT y1, + FX_FLOAT x2, + FX_FLOAT y2, + FX_DWORD color, int alpha_flag = 0, void* pIccTransform = NULL, - int blend_type = FXDIB_BLEND_NORMAL); - virtual FX_BOOL DrawCosmeticLine(FX_FLOAT x1, - FX_FLOAT y1, - FX_FLOAT x2, - FX_FLOAT y2, - FX_DWORD color, - int alpha_flag = 0, - void* pIccTransform = NULL, - int blend_type = FXDIB_BLEND_NORMAL); - virtual FX_BOOL GetClipBox(FX_RECT* pRect); - virtual FX_BOOL GetDIBits(CFX_DIBitmap* pBitmap, - int left, - int top, - void* pIccTransform = NULL, - FX_BOOL bDEdge = FALSE); - virtual FX_BOOL SetDIBits(const CFX_DIBSource* pBitmap, - FX_DWORD color, - const FX_RECT* pSrcRect, - int dest_left, - int dest_top, - int blend_type, - int alpha_flag = 0, - void* pIccTransform = NULL); - virtual FX_BOOL StretchDIBits(const CFX_DIBSource* pBitmap, - FX_DWORD color, - int dest_left, - int dest_top, - int dest_width, - int dest_height, - const FX_RECT* pClipRect, - FX_DWORD flags, - int alpha_flag = 0, - void* pIccTransform = NULL, - int blend_type = FXDIB_BLEND_NORMAL); - virtual FX_BOOL StartDIBits(const CFX_DIBSource* pBitmap, - int bitmap_alpha, - FX_DWORD color, - const CFX_AffineMatrix* pMatrix, - FX_DWORD flags, - void*& handle, - int alpha_flag = 0, - void* pIccTransform = NULL, - int blend_type = FXDIB_BLEND_NORMAL) { + int blend_type = FXDIB_BLEND_NORMAL) override; + FX_BOOL GetClipBox(FX_RECT* pRect) override; + FX_BOOL GetDIBits(CFX_DIBitmap* pBitmap, + int left, + int top, + void* pIccTransform = NULL, + FX_BOOL bDEdge = FALSE) override; + CFX_DIBitmap* GetBackDrop() override { return NULL; } + FX_BOOL SetDIBits(const CFX_DIBSource* pBitmap, + FX_DWORD color, + const FX_RECT* pSrcRect, + int dest_left, + int dest_top, + int blend_type, + int alpha_flag = 0, + void* pIccTransform = NULL) override; + FX_BOOL StretchDIBits(const CFX_DIBSource* pBitmap, + FX_DWORD color, + int dest_left, + int dest_top, + int dest_width, + int dest_height, + const FX_RECT* pClipRect, + FX_DWORD flags, + int alpha_flag = 0, + void* pIccTransform = NULL, + int blend_type = FXDIB_BLEND_NORMAL) override; + FX_BOOL StartDIBits(const CFX_DIBSource* pBitmap, + int bitmap_alpha, + FX_DWORD color, + const CFX_AffineMatrix* pMatrix, + FX_DWORD flags, + void*& handle, + int alpha_flag = 0, + void* pIccTransform = NULL, + int blend_type = FXDIB_BLEND_NORMAL) override { return FALSE; } - virtual FX_BOOL ContinueDIBits(void* handle, IFX_Pause* pPause) { + FX_BOOL ContinueDIBits(void* handle, IFX_Pause* pPause) override { return FALSE; } - virtual void CancelDIBits(void* handle) {} - virtual FX_BOOL DrawDeviceText(int nChars, - const FXTEXT_CHARPOS* pCharPos, - CFX_Font* pFont, - CFX_FontCache* pCache, - const CFX_AffineMatrix* pObject2Device, - FX_FLOAT font_size, - FX_DWORD color, - int alpha_flag = 0, - void* pIccTransform = NULL); - virtual void ClearDriver(); + void CancelDIBits(void* handle) override {} + FX_BOOL DrawDeviceText(int nChars, + const FXTEXT_CHARPOS* pCharPos, + CFX_Font* pFont, + CFX_FontCache* pCache, + const CFX_AffineMatrix* pObject2Device, + FX_FLOAT font_size, + FX_DWORD color, + int alpha_flag = 0, + void* pIccTransform = NULL) override; + void* GetPlatformSurface() override { return NULL; } + void ClearDriver() override; protected: void setStrokeInfo(const CFX_GraphStateData* graphState, @@ -206,21 +212,20 @@ class CFX_QuartzDeviceDriver : public IFX_RenderDeviceDriver { int32_t _horzSize; int32_t _vertSize; }; + class CFX_FontProvider final : public IFX_FileRead { public: - virtual void Release() override { delete this; } - virtual FX_FILESIZE GetSize() override { return (FX_FILESIZE)_totalSize; } - virtual FX_BOOL ReadBlock(void* buffer, - FX_FILESIZE offset, - size_t size) override; - - virtual FX_BOOL IsEOF() override { return _offSet == _totalSize; } - virtual FX_FILESIZE GetPosition() override { return (FX_FILESIZE)_offSet; } - virtual size_t ReadBlock(void* buffer, size_t size) override; + // IFX_FileRead + void Release() override { delete this; } + FX_FILESIZE GetSize() override { return (FX_FILESIZE)_totalSize; } + FX_BOOL IsEOF() override { return _offSet == _totalSize; } + FX_FILESIZE GetPosition() override { return (FX_FILESIZE)_offSet; } + FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override; + size_t ReadBlock(void* buffer, size_t size) override; public: CFX_FontProvider(CGFontRef cgFont); - ~CFX_FontProvider(); + ~CFX_FontProvider() override; void InitTableOffset(); unsigned long Read(unsigned long offset, unsigned char* buffer, @@ -254,6 +259,7 @@ class CFX_FontProvider final : public IFX_FileRead { int _tableCount; int _totalSize; }; + uint32_t FX_GetHashCode(const FX_CHAR* pStr); FX_DWORD FX_IOSGetMatchFamilyNameHashcode(const FX_CHAR* pFontName); uint32_t FX_IOSGetFamilyNamesCount(); diff --git a/core/src/fxge/skia/fx_skia_device.h b/core/src/fxge/skia/fx_skia_device.h index 1de829b783..a2cfc355b3 100644 --- a/core/src/fxge/skia/fx_skia_device.h +++ b/core/src/fxge/skia/fx_skia_device.h @@ -13,7 +13,7 @@ class CFX_SkiaDeviceDriver : public IFX_RenderDeviceDriver { FX_BOOL bRgbByteOrder, CFX_DIBitmap* pOriDevice, FX_BOOL bGroupKnockout); - virtual ~CFX_SkiaDeviceDriver(); + ~CFX_SkiaDeviceDriver() override; /** Options */ virtual int GetDeviceCaps(int caps_id); diff --git a/core/src/fxge/win32/fx_win32_device.cpp b/core/src/fxge/win32/fx_win32_device.cpp index c3325ba738..9dbad11492 100644 --- a/core/src/fxge/win32/fx_win32_device.cpp +++ b/core/src/fxge/win32/fx_win32_device.cpp @@ -21,23 +21,26 @@ class CFX_Win32FontInfo final : public IFX_SystemFontInfo { public: CFX_Win32FontInfo(); - ~CFX_Win32FontInfo(); - virtual void Release(); - virtual FX_BOOL EnumFontList(CFX_FontMapper* pMapper); - virtual void* MapFont(int weight, - FX_BOOL bItalic, - int charset, - int pitch_family, - const FX_CHAR* face, - int& iExact); - virtual void* GetFont(const FX_CHAR* face) { return NULL; } - virtual FX_DWORD GetFontData(void* hFont, - FX_DWORD table, - uint8_t* buffer, - FX_DWORD size); - virtual void DeleteFont(void* hFont); - virtual FX_BOOL GetFaceName(void* hFont, CFX_ByteString& name); - virtual FX_BOOL GetFontCharset(void* hFont, int& charset); + ~CFX_Win32FontInfo() override; + + // IFX_SystemFontInfo + void Release() override; + FX_BOOL EnumFontList(CFX_FontMapper* pMapper) override; + void* MapFont(int weight, + FX_BOOL bItalic, + int charset, + int pitch_family, + const FX_CHAR* face, + int& iExact) override; + void* GetFont(const FX_CHAR* face) override { return NULL; } + FX_DWORD GetFontData(void* hFont, + FX_DWORD table, + uint8_t* buffer, + FX_DWORD size) override; + FX_BOOL GetFaceName(void* hFont, CFX_ByteString& name) override; + FX_BOOL GetFontCharset(void* hFont, int& charset) override; + void DeleteFont(void* hFont) override; + FX_BOOL IsOpenTypeFromDiv(const LOGFONTA* plf); FX_BOOL IsSupportFontFormDiv(const LOGFONTA* plf); void AddInstalledFont(const LOGFONTA* plf, FX_DWORD FontType); @@ -51,6 +54,7 @@ class CFX_Win32FontInfo final : public IFX_SystemFontInfo { CFX_ByteString m_LastFamily; CFX_ByteString m_KaiTi, m_FangSong; }; + CFX_Win32FontInfo::CFX_Win32FontInfo() { m_hDC = CreateCompatibleDC(NULL); } diff --git a/core/src/fxge/win32/win32_int.h b/core/src/fxge/win32/win32_int.h index cb3b017ad8..7f73fdbb1a 100644 --- a/core/src/fxge/win32/win32_int.h +++ b/core/src/fxge/win32/win32_int.h @@ -6,6 +6,8 @@ #ifndef CORE_SRC_FXGE_WIN32_WIN32_INT_H_ #define CORE_SRC_FXGE_WIN32_WIN32_INT_H_ +#include "../../../include/fxge/fx_ge.h" + struct WINDIB_Open_Args_; class CGdiplusExt { public: @@ -101,50 +103,54 @@ class CWin32Platform { CGdiplusExt m_GdiplusExt; CDWriteExt m_DWriteExt; }; + class CGdiDeviceDriver : public IFX_RenderDeviceDriver { protected: - virtual int GetDeviceCaps(int caps_id); - virtual void SaveState() { SaveDC(m_hDC); } - virtual void RestoreState(FX_BOOL bKeepSaved = FALSE) { + // IFX_RenderDeviceDriver + int GetDeviceCaps(int caps_id) override; + void SaveState() override { SaveDC(m_hDC); } + void RestoreState(FX_BOOL bKeepSaved = FALSE) override { RestoreDC(m_hDC, -1); if (bKeepSaved) { SaveDC(m_hDC); } } - virtual FX_BOOL SetClip_PathFill(const CFX_PathData* pPathData, - const CFX_AffineMatrix* pObject2Device, - int fill_mode); - virtual FX_BOOL SetClip_PathStroke(const CFX_PathData* pPathData, - const CFX_AffineMatrix* pObject2Device, - const CFX_GraphStateData* pGraphState); - virtual FX_BOOL DrawPath(const CFX_PathData* pPathData, + FX_BOOL SetClip_PathFill(const CFX_PathData* pPathData, const CFX_AffineMatrix* pObject2Device, - const CFX_GraphStateData* pGraphState, - FX_DWORD fill_color, - FX_DWORD stroke_color, - int fill_mode, - int alpha_flag, - void* pIccTransform, - int blend_type); - virtual FX_BOOL FillRect(const FX_RECT* pRect, - FX_DWORD fill_color, + int fill_mode) override; + FX_BOOL SetClip_PathStroke(const CFX_PathData* pPathData, + const CFX_AffineMatrix* pObject2Device, + const CFX_GraphStateData* pGraphState) override; + FX_BOOL DrawPath(const CFX_PathData* pPathData, + const CFX_AffineMatrix* pObject2Device, + const CFX_GraphStateData* pGraphState, + FX_DWORD fill_color, + FX_DWORD stroke_color, + int fill_mode, + int alpha_flag, + void* pIccTransform, + int blend_type) override; + FX_BOOL FillRect(const FX_RECT* pRect, + FX_DWORD fill_color, + int alpha_flag, + void* pIccTransform, + int blend_type) override; + FX_BOOL DrawCosmeticLine(FX_FLOAT x1, + FX_FLOAT y1, + FX_FLOAT x2, + FX_FLOAT y2, + FX_DWORD color, int alpha_flag, void* pIccTransform, - int blend_type); - virtual FX_BOOL DrawCosmeticLine(FX_FLOAT x1, - FX_FLOAT y1, - FX_FLOAT x2, - FX_FLOAT y2, - FX_DWORD color, - int alpha_flag, - void* pIccTransform, - int blend_type); + int blend_type) override; + FX_BOOL GetClipBox(FX_RECT* pRect) override; + void* GetPlatformSurface() override { return (void*)m_hDC; } + virtual void* GetClipRgn(); virtual FX_BOOL SetClipRgn(void* pRgn); - virtual FX_BOOL GetClipBox(FX_RECT* pRect); virtual FX_BOOL DeleteDeviceRgn(void* pRgn); virtual void DrawLine(FX_FLOAT x1, FX_FLOAT y1, FX_FLOAT x2, FX_FLOAT y2); - virtual void* GetPlatformSurface() { return (void*)m_hDC; } + FX_BOOL GDI_SetDIBits(const CFX_DIBitmap* pBitmap, const FX_RECT* pSrcRect, int left, @@ -170,8 +176,9 @@ class CGdiDeviceDriver : public IFX_RenderDeviceDriver { int m_Width, m_Height, m_nBitsPerPixel; int m_DeviceClass, m_RenderCaps; CGdiDeviceDriver(HDC hDC, int device_class); - ~CGdiDeviceDriver() {} + ~CGdiDeviceDriver() override {} }; + class CGdiDisplayDriver : public CGdiDeviceDriver { public: CGdiDisplayDriver(HDC hDC); @@ -261,83 +268,91 @@ class CGdiPrinterDriver : public CGdiDeviceDriver { int m_HorzSize, m_VertSize; FX_BOOL m_bSupportROP; }; + class CPSOutput : public IFX_PSOutput { public: - CPSOutput(HDC hDC); - virtual ~CPSOutput(); - virtual void Release() { delete this; } + explicit CPSOutput(HDC hDC); + ~CPSOutput() override; + + // IFX_PSOutput + void Release() override { delete this; } + void OutputPS(const FX_CHAR* string, int len) override; + void Init(); - virtual void OutputPS(const FX_CHAR* string, int len); + HDC m_hDC; FX_CHAR* m_pBuf; }; + class CPSPrinterDriver : public IFX_RenderDeviceDriver { public: CPSPrinterDriver(); FX_BOOL Init(HDC hDC, int ps_level, FX_BOOL bCmykOutput); - ~CPSPrinterDriver(); + ~CPSPrinterDriver() override; protected: - virtual FX_BOOL IsPSPrintDriver() { return TRUE; } - virtual int GetDeviceCaps(int caps_id); - virtual FX_BOOL StartRendering(); - virtual void EndRendering(); - virtual void SaveState(); - virtual void RestoreState(FX_BOOL bKeepSaved = FALSE); - virtual FX_BOOL SetClip_PathFill(const CFX_PathData* pPathData, - const CFX_AffineMatrix* pObject2Device, - int fill_mode); - virtual FX_BOOL SetClip_PathStroke(const CFX_PathData* pPathData, - const CFX_AffineMatrix* pObject2Device, - const CFX_GraphStateData* pGraphState); - virtual FX_BOOL DrawPath(const CFX_PathData* pPathData, + // IFX_RenderDeviceDriver + int GetDeviceCaps(int caps_id); + FX_BOOL IsPSPrintDriver() override { return TRUE; } + FX_BOOL StartRendering() override; + void EndRendering() override; + void SaveState() override; + void RestoreState(FX_BOOL bKeepSaved = FALSE) override; + FX_BOOL SetClip_PathFill(const CFX_PathData* pPathData, const CFX_AffineMatrix* pObject2Device, - const CFX_GraphStateData* pGraphState, - FX_DWORD fill_color, - FX_DWORD stroke_color, - int fill_mode, - int alpha_flag, - void* pIccTransform, - int blend_type); - virtual FX_BOOL GetClipBox(FX_RECT* pRect); - virtual FX_BOOL SetDIBits(const CFX_DIBSource* pBitmap, - FX_DWORD color, - const FX_RECT* pSrcRect, - int left, - int top, - int blend_type, - int alpha_flag, - void* pIccTransform); - virtual FX_BOOL StretchDIBits(const CFX_DIBSource* pBitmap, - FX_DWORD color, - int dest_left, - int dest_top, - int dest_width, - int dest_height, - const FX_RECT* pClipRect, - FX_DWORD flags, - int alpha_flag, - void* pIccTransform, - int blend_type); - virtual FX_BOOL StartDIBits(const CFX_DIBSource* pBitmap, - int bitmap_alpha, - FX_DWORD color, - const CFX_AffineMatrix* pMatrix, - FX_DWORD render_flags, - void*& handle, - int alpha_flag, - void* pIccTransform, - int blend_type); - virtual FX_BOOL DrawDeviceText(int nChars, - const FXTEXT_CHARPOS* pCharPos, - CFX_Font* pFont, - CFX_FontCache* pCache, - const CFX_AffineMatrix* pObject2Device, - FX_FLOAT font_size, - FX_DWORD color, - int alpha_flag, - void* pIccTransform); - virtual void* GetPlatformSurface() { return (void*)m_hDC; } + int fill_mode) override; + FX_BOOL SetClip_PathStroke(const CFX_PathData* pPathData, + const CFX_AffineMatrix* pObject2Device, + const CFX_GraphStateData* pGraphState) override; + FX_BOOL DrawPath(const CFX_PathData* pPathData, + const CFX_AffineMatrix* pObject2Device, + const CFX_GraphStateData* pGraphState, + FX_DWORD fill_color, + FX_DWORD stroke_color, + int fill_mode, + int alpha_flag, + void* pIccTransform, + int blend_type) override; + FX_BOOL GetClipBox(FX_RECT* pRect) override; + FX_BOOL SetDIBits(const CFX_DIBSource* pBitmap, + FX_DWORD color, + const FX_RECT* pSrcRect, + int left, + int top, + int blend_type, + int alpha_flag, + void* pIccTransform) override; + FX_BOOL StretchDIBits(const CFX_DIBSource* pBitmap, + FX_DWORD color, + int dest_left, + int dest_top, + int dest_width, + int dest_height, + const FX_RECT* pClipRect, + FX_DWORD flags, + int alpha_flag, + void* pIccTransform, + int blend_type) override; + FX_BOOL StartDIBits(const CFX_DIBSource* pBitmap, + int bitmap_alpha, + FX_DWORD color, + const CFX_AffineMatrix* pMatrix, + FX_DWORD render_flags, + void*& handle, + int alpha_flag, + void* pIccTransform, + int blend_type) override; + FX_BOOL DrawDeviceText(int nChars, + const FXTEXT_CHARPOS* pCharPos, + CFX_Font* pFont, + CFX_FontCache* pCache, + const CFX_AffineMatrix* pObject2Device, + FX_FLOAT font_size, + FX_DWORD color, + int alpha_flag, + void* pIccTransform) override; + void* GetPlatformSurface() override { return (void*)m_hDC; } + HDC m_hDC; FX_BOOL m_bCmykOutput; int m_Width, m_Height, m_nBitsPerPixel; |