summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorweili <weili@chromium.org>2016-06-14 17:21:14 -0700
committerCommit bot <commit-bot@chromium.org>2016-06-14 17:21:14 -0700
commitf4bb580add3824196dc49cd7de2f7d051019ede8 (patch)
tree15c1db6fb7000330d48c105c66acf1d468ba56bd /core
parentee2abec93f22bd10522181dc0362f24d389fc66b (diff)
downloadpdfium-f4bb580add3824196dc49cd7de2f7d051019ede8.tar.xz
Make code compile with clang_use_chrome_plugin (part II)
This change contains files in core directory which were not covered in part I. This is part of the efforts to make PDFium code compilable by Clang chromium style plugins. The changes are mainly the following: -- move inline constructor/destructor of complex class/struct out-of-line; -- add constructor/destructor of complex class/struct if not explicitly defined; -- add explicit out-of-line copy constructor when needed; -- move inline virtual functions out-of-line; -- Properly mark virtual functions with 'override'; -- some minor cleanups; BUG=pdfium:469 Review-Url: https://codereview.chromium.org/2060913003
Diffstat (limited to 'core')
-rw-r--r--core/fpdfdoc/clines.cpp50
-rw-r--r--core/fpdfdoc/clines.h30
-rw-r--r--core/fpdfdoc/cpdf_variabletext.cpp8
-rw-r--r--core/fpdfdoc/csection.h1
-rw-r--r--core/fpdfdoc/doc_basic.cpp40
-rw-r--r--core/fpdfdoc/doc_formcontrol.cpp4
-rw-r--r--core/fpdfdoc/doc_tagged.cpp24
-rw-r--r--core/fpdfdoc/doc_vt.cpp25
-rw-r--r--core/fpdfdoc/include/cpdf_variabletext.h10
-rw-r--r--core/fpdfdoc/include/cpvt_word.h20
-rw-r--r--core/fpdfdoc/include/fpdf_doc.h32
-rw-r--r--core/fpdfdoc/pdf_vt.h60
-rw-r--r--core/fpdfdoc/tagged_int.h16
-rw-r--r--core/fpdftext/fpdf_text_int.cpp7
-rw-r--r--core/fpdftext/include/cpdf_textpage.h8
-rw-r--r--core/fpdftext/include/cpdf_textpagefind.h6
-rw-r--r--core/fxcodec/codec/ccodec_iccmodule.h1
-rw-r--r--core/fxcodec/codec/fx_codec.cpp2
-rw-r--r--core/fxcodec/codec/fx_codec_icc.cpp3
-rw-r--r--core/fxcodec/include/fx_codec.h1
-rw-r--r--core/fxcodec/lgif/fx_gif.cpp19
-rw-r--r--core/fxcodec/lgif/fx_gif.h15
-rw-r--r--core/fxcrt/extension.h243
-rw-r--r--core/fxcrt/fx_basic_bstring.cpp12
-rw-r--r--core/fxcrt/fx_basic_util.cpp6
-rw-r--r--core/fxcrt/fx_basic_wstring.cpp12
-rw-r--r--core/fxcrt/fx_bidi.cpp2
-rw-r--r--core/fxcrt/fx_bidi.h2
-rw-r--r--core/fxcrt/fx_extension.cpp260
-rw-r--r--core/fxcrt/fx_xml_parser.cpp114
-rw-r--r--core/fxcrt/include/fx_string.h18
-rw-r--r--core/fxcrt/include/fx_ucd.h31
-rw-r--r--core/fxcrt/include/fx_xml.h8
-rw-r--r--core/fxcrt/xml_int.h95
-rw-r--r--core/fxge/agg/fx_agg_driver.cpp94
-rw-r--r--core/fxge/agg/fx_agg_driver.h6
-rw-r--r--core/fxge/ge/fx_ge_device.cpp33
-rw-r--r--core/fxge/ge/fx_ge_fontmap.cpp17
-rw-r--r--core/fxge/ge/fx_ge_path.cpp67
-rw-r--r--core/fxge/ge/fx_ge_text.cpp4
-rw-r--r--core/fxge/ge/fx_text_int.h60
-rw-r--r--core/fxge/include/fx_font.h52
-rw-r--r--core/fxge/include/fx_ge.h85
-rw-r--r--core/fxge/include/fx_ge_win32.h25
-rw-r--r--core/fxge/win32/fx_win32_device.cpp14
-rw-r--r--core/fxge/win32/fx_win32_dib.cpp15
-rw-r--r--core/fxge/win32/fx_win32_dwrite.cpp81
-rw-r--r--core/fxge/win32/fx_win32_gdipext.cpp82
-rw-r--r--core/fxge/win32/win32_int.h6
49 files changed, 1182 insertions, 644 deletions
diff --git a/core/fpdfdoc/clines.cpp b/core/fpdfdoc/clines.cpp
new file mode 100644
index 0000000000..b11731042d
--- /dev/null
+++ b/core/fpdfdoc/clines.cpp
@@ -0,0 +1,50 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "core/fpdfdoc/clines.h"
+
+CLines::CLines() : m_nTotal(0) {}
+
+CLines::~CLines() {
+ RemoveAll();
+}
+
+int32_t CLines::GetSize() const {
+ return m_Lines.GetSize();
+}
+
+CLine* CLines::GetAt(int32_t nIndex) const {
+ return m_Lines.GetAt(nIndex);
+}
+
+void CLines::Empty() {
+ m_nTotal = 0;
+}
+
+void CLines::RemoveAll() {
+ for (int32_t i = 0, sz = GetSize(); i < sz; i++)
+ delete GetAt(i);
+ m_Lines.RemoveAll();
+ m_nTotal = 0;
+}
+
+int32_t CLines::Add(const CPVT_LineInfo& lineinfo) {
+ if (m_nTotal >= GetSize()) {
+ CLine* pLine = new CLine;
+ pLine->m_LineInfo = lineinfo;
+ m_Lines.Add(pLine);
+ } else if (CLine* pLine = GetAt(m_nTotal)) {
+ pLine->m_LineInfo = lineinfo;
+ }
+ return m_nTotal++;
+}
+
+void CLines::Clear() {
+ for (int32_t i = GetSize() - 1; i >= m_nTotal; i--) {
+ delete GetAt(i);
+ m_Lines.RemoveAt(i);
+ }
+}
diff --git a/core/fpdfdoc/clines.h b/core/fpdfdoc/clines.h
new file mode 100644
index 0000000000..9d71d3f048
--- /dev/null
+++ b/core/fpdfdoc/clines.h
@@ -0,0 +1,30 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef CORE_FPDFDOC_CLINES_H_
+#define CORE_FPDFDOC_CLINES_H_
+
+#include "core/fpdfdoc/pdf_vt.h"
+
+class CLines final {
+ public:
+ CLines();
+ ~CLines();
+
+ int32_t GetSize() const;
+ CLine* GetAt(int32_t nIndex) const;
+
+ void Empty();
+ void RemoveAll();
+ int32_t Add(const CPVT_LineInfo& lineinfo);
+ void Clear();
+
+ private:
+ CPVT_ArrayTemplate<CLine*> m_Lines;
+ int32_t m_nTotal;
+};
+
+#endif // CORE_FPDFDOC_CLINES_H_
diff --git a/core/fpdfdoc/cpdf_variabletext.cpp b/core/fpdfdoc/cpdf_variabletext.cpp
index 1d5fde289d..010d426cf2 100644
--- a/core/fpdfdoc/cpdf_variabletext.cpp
+++ b/core/fpdfdoc/cpdf_variabletext.cpp
@@ -787,10 +787,18 @@ FX_BOOL CPDF_VariableText::GetSectionInfo(const CPVT_WordPlace& place,
return FALSE;
}
+void CPDF_VariableText::SetPlateRect(const CFX_FloatRect& rect) {
+ CPDF_EditContainer::SetPlateRect(rect);
+}
+
CFX_FloatRect CPDF_VariableText::GetContentRect() const {
return InToOut(CPVT_FloatRect(CPDF_EditContainer::GetContentRect()));
}
+const CFX_FloatRect& CPDF_VariableText::GetPlateRect() const {
+ return CPDF_EditContainer::GetPlateRect();
+}
+
FX_FLOAT CPDF_VariableText::GetWordFontSize(const CPVT_WordInfo& WordInfo,
FX_BOOL bFactFontSize) {
return m_bRichText && WordInfo.pWordProps
diff --git a/core/fpdfdoc/csection.h b/core/fpdfdoc/csection.h
index 4ac345c8df..8629be71a7 100644
--- a/core/fpdfdoc/csection.h
+++ b/core/fpdfdoc/csection.h
@@ -7,6 +7,7 @@
#ifndef CORE_FPDFDOC_CSECTION_H_
#define CORE_FPDFDOC_CSECTION_H_
+#include "core/fpdfdoc/clines.h"
#include "core/fpdfdoc/cpvt_sectioninfo.h"
#include "core/fpdfdoc/ctypeset.h"
#include "core/fxcrt/include/fx_coordinates.h"
diff --git a/core/fpdfdoc/doc_basic.cpp b/core/fpdfdoc/doc_basic.cpp
index 72f2985cef..3fe182ae78 100644
--- a/core/fpdfdoc/doc_basic.cpp
+++ b/core/fpdfdoc/doc_basic.cpp
@@ -31,6 +31,7 @@ int CPDF_Dest::GetPageIndex(CPDF_Document* pDoc) {
return 0;
return pDoc->GetPageIndex(pPage->GetObjNum());
}
+
uint32_t CPDF_Dest::GetPageObjNum() {
CPDF_Array* pArray = ToArray(m_pObj);
if (!pArray)
@@ -68,6 +69,7 @@ FX_FLOAT CPDF_Dest::GetParam(int index) {
CPDF_Array* pArray = ToArray(m_pObj);
return pArray ? pArray->GetNumberAt(2 + index) : 0;
}
+
CFX_ByteString CPDF_Dest::GetRemoteName() {
return m_pObj ? m_pObj->GetString() : CFX_ByteString();
}
@@ -224,6 +226,7 @@ int CPDF_NameTree::GetIndex(const CFX_ByteString& csName) const {
}
return nIndex;
}
+
CPDF_Object* CPDF_NameTree::LookupValue(int nIndex,
CFX_ByteString& csName) const {
if (!m_pRoot) {
@@ -232,6 +235,7 @@ CPDF_Object* CPDF_NameTree::LookupValue(int nIndex,
size_t nCurIndex = 0;
return SearchNameNode(m_pRoot, nIndex, nCurIndex, csName, nullptr);
}
+
CPDF_Object* CPDF_NameTree::LookupValue(const CFX_ByteString& csName) const {
if (!m_pRoot) {
return nullptr;
@@ -239,6 +243,7 @@ CPDF_Object* CPDF_NameTree::LookupValue(const CFX_ByteString& csName) const {
size_t nIndex = 0;
return SearchNameNode(m_pRoot, csName, nIndex, nullptr);
}
+
CPDF_Array* CPDF_NameTree::LookupNamedDest(CPDF_Document* pDoc,
const CFX_ByteString& sName) {
CPDF_Object* pValue = LookupValue(sName);
@@ -442,6 +447,7 @@ static CFX_WideString _MakeLetters(int num) {
}
return wsLetters;
}
+
static CFX_WideString _GetLabelNumPortion(int num,
const CFX_ByteString& bsStyle) {
CFX_WideString wsNumPortion;
@@ -463,6 +469,40 @@ static CFX_WideString _GetLabelNumPortion(int num,
}
return wsNumPortion;
}
+
+IPDF_FormNotify::~IPDF_FormNotify() {}
+
+int IPDF_FormNotify::BeforeValueChange(CPDF_FormField* pField,
+ const CFX_WideString& csValue) {
+ return 0;
+}
+
+void IPDF_FormNotify::AfterValueChange(CPDF_FormField* pField) {}
+
+int IPDF_FormNotify::BeforeSelectionChange(CPDF_FormField* pField,
+ const CFX_WideString& csValue) {
+ return 0;
+}
+
+void IPDF_FormNotify::AfterSelectionChange(CPDF_FormField* pField) {}
+
+void IPDF_FormNotify::AfterCheckedStatusChange(CPDF_FormField* pField) {}
+
+int IPDF_FormNotify::BeforeFormReset(CPDF_InterForm* pForm) {
+ return 0;
+}
+
+void IPDF_FormNotify::AfterFormReset(CPDF_InterForm* pForm) {}
+
+int IPDF_FormNotify::BeforeFormImportData(CPDF_InterForm* pForm) {
+ return 0;
+}
+
+void IPDF_FormNotify::AfterFormImportData(CPDF_InterForm* pForm) {}
+
+CPDF_PageLabel::CPDF_PageLabel(CPDF_Document* pDocument)
+ : m_pDocument(pDocument) {}
+
CFX_WideString CPDF_PageLabel::GetLabel(int nPage) const {
CFX_WideString wsLabel;
if (!m_pDocument) {
diff --git a/core/fpdfdoc/doc_formcontrol.cpp b/core/fpdfdoc/doc_formcontrol.cpp
index 9b3cf1e5de..7e058ae310 100644
--- a/core/fpdfdoc/doc_formcontrol.cpp
+++ b/core/fpdfdoc/doc_formcontrol.cpp
@@ -27,10 +27,6 @@ CPDF_FormControl::CPDF_FormControl(CPDF_FormField* pField,
m_pWidgetDict(pWidgetDict),
m_pForm(m_pField->m_pForm) {}
-CFX_FloatRect CPDF_FormControl::GetRect() const {
- return m_pWidgetDict->GetRectBy("Rect");
-}
-
CFX_ByteString CPDF_FormControl::GetOnStateName() const {
ASSERT(GetType() == CPDF_FormField::CheckBox ||
GetType() == CPDF_FormField::RadioButton);
diff --git a/core/fpdfdoc/doc_tagged.cpp b/core/fpdfdoc/doc_tagged.cpp
index 05109bb747..2bd4347e18 100644
--- a/core/fpdfdoc/doc_tagged.cpp
+++ b/core/fpdfdoc/doc_tagged.cpp
@@ -208,6 +208,30 @@ CPDF_StructElementImpl::CPDF_StructElementImpl(CPDF_StructTreeImpl* pTree,
LoadKids(pDict);
}
+IPDF_StructTree* CPDF_StructElementImpl::GetTree() const {
+ return m_pTree;
+}
+
+const CFX_ByteString& CPDF_StructElementImpl::GetType() const {
+ return m_Type;
+}
+
+IPDF_StructElement* CPDF_StructElementImpl::GetParent() const {
+ return m_pParent;
+}
+
+CPDF_Dictionary* CPDF_StructElementImpl::GetDict() const {
+ return m_pDict;
+}
+
+int CPDF_StructElementImpl::CountKids() const {
+ return pdfium::CollectionSize<int>(m_Kids);
+}
+
+const CPDF_StructKid& CPDF_StructElementImpl::GetKid(int index) const {
+ return m_Kids[index];
+}
+
CPDF_StructElementImpl::~CPDF_StructElementImpl() {
for (CPDF_StructKid& kid : m_Kids) {
if (kid.m_Type == CPDF_StructKid::Element && kid.m_Element.m_pElement)
diff --git a/core/fpdfdoc/doc_vt.cpp b/core/fpdfdoc/doc_vt.cpp
index 7b902f81a7..84d6a1ac07 100644
--- a/core/fpdfdoc/doc_vt.cpp
+++ b/core/fpdfdoc/doc_vt.cpp
@@ -7,14 +7,18 @@
#include "core/fpdfdoc/pdf_vt.h"
CLine::CLine() {}
+
CLine::~CLine() {}
+
CPVT_WordPlace CLine::GetBeginWordPlace() const {
return CPVT_WordPlace(LinePlace.nSecIndex, LinePlace.nLineIndex, -1);
}
+
CPVT_WordPlace CLine::GetEndWordPlace() const {
return CPVT_WordPlace(LinePlace.nSecIndex, LinePlace.nLineIndex,
m_LineInfo.nEndWordIndex);
}
+
CPVT_WordPlace CLine::GetPrevWordPlace(const CPVT_WordPlace& place) const {
if (place.nWordIndex > m_LineInfo.nEndWordIndex) {
return CPVT_WordPlace(place.nSecIndex, place.nLineIndex,
@@ -23,6 +27,7 @@ CPVT_WordPlace CLine::GetPrevWordPlace(const CPVT_WordPlace& place) const {
return CPVT_WordPlace(place.nSecIndex, place.nLineIndex,
place.nWordIndex - 1);
}
+
CPVT_WordPlace CLine::GetNextWordPlace(const CPVT_WordPlace& place) const {
if (place.nWordIndex < m_LineInfo.nBeginWordIndex) {
return CPVT_WordPlace(place.nSecIndex, place.nLineIndex,
@@ -31,3 +36,23 @@ CPVT_WordPlace CLine::GetNextWordPlace(const CPVT_WordPlace& place) const {
return CPVT_WordPlace(place.nSecIndex, place.nLineIndex,
place.nWordIndex + 1);
}
+
+CPDF_EditContainer::CPDF_EditContainer() {}
+
+CPDF_EditContainer::~CPDF_EditContainer() {}
+
+void CPDF_EditContainer::SetPlateRect(const CFX_FloatRect& rect) {
+ m_rcPlate = rect;
+}
+
+const CFX_FloatRect& CPDF_EditContainer::GetPlateRect() const {
+ return m_rcPlate;
+}
+
+void CPDF_EditContainer::SetContentRect(const CPVT_FloatRect& rect) {
+ m_rcContent = rect;
+}
+
+CFX_FloatRect CPDF_EditContainer::GetContentRect() const {
+ return m_rcContent;
+}
diff --git a/core/fpdfdoc/include/cpdf_variabletext.h b/core/fpdfdoc/include/cpdf_variabletext.h
index 06b41f186c..5e64ab29a9 100644
--- a/core/fpdfdoc/include/cpdf_variabletext.h
+++ b/core/fpdfdoc/include/cpdf_variabletext.h
@@ -87,13 +87,9 @@ class CPDF_VariableText : private CPDF_EditContainer {
CPDF_VariableText::Iterator* GetIterator();
// CPDF_EditContainer.
- void SetPlateRect(const CFX_FloatRect& rect) override {
- CPDF_EditContainer::SetPlateRect(rect);
- }
+ void SetPlateRect(const CFX_FloatRect& rect) override;
CFX_FloatRect GetContentRect() const override;
- const CFX_FloatRect& GetPlateRect() const override {
- return CPDF_EditContainer::GetPlateRect();
- }
+ const CFX_FloatRect& GetPlateRect() const override;
void SetAlignment(int32_t nFormat = 0) { m_nAlignment = nFormat; }
void SetPasswordChar(uint16_t wSubWord = '*') { m_wSubWord = wSubWord; }
@@ -108,8 +104,10 @@ class CPDF_VariableText : private CPDF_EditContainer {
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();
diff --git a/core/fpdfdoc/include/cpvt_word.h b/core/fpdfdoc/include/cpvt_word.h
index 7d022dda5d..f7b7b23dac 100644
--- a/core/fpdfdoc/include/cpvt_word.h
+++ b/core/fpdfdoc/include/cpvt_word.h
@@ -12,15 +12,7 @@
#include "core/fxcrt/include/fx_system.h"
struct CPVT_Word {
- CPVT_Word()
- : Word(0),
- nCharset(0),
- ptWord(0, 0),
- fAscent(0.0f),
- fDescent(0.0f),
- fWidth(0.0f),
- fFontSize(0),
- WordProps() {}
+ CPVT_Word();
uint16_t Word;
int32_t nCharset;
@@ -34,4 +26,14 @@ struct CPVT_Word {
CPVT_WordProps WordProps;
};
+inline CPVT_Word::CPVT_Word()
+ : Word(0),
+ nCharset(0),
+ ptWord(0.0f, 0.0f),
+ fAscent(0.0f),
+ fDescent(0.0f),
+ fWidth(0.0f),
+ nFontIndex(-1),
+ fFontSize(0.0f) {}
+
#endif // CORE_FPDFDOC_INCLUDE_CPVT_WORD_H_
diff --git a/core/fpdfdoc/include/fpdf_doc.h b/core/fpdfdoc/include/fpdf_doc.h
index 2722003743..afa5a30b18 100644
--- a/core/fpdfdoc/include/fpdf_doc.h
+++ b/core/fpdfdoc/include/fpdf_doc.h
@@ -738,7 +738,7 @@ class CPDF_FormControl {
CPDF_InterForm* GetInterForm() const { return m_pForm; }
CPDF_FormField* GetField() const { return m_pField; }
CPDF_Dictionary* GetWidget() const { return m_pWidgetDict; }
- CFX_FloatRect GetRect() const;
+ CFX_FloatRect GetRect() const { return m_pWidgetDict->GetRectBy("Rect"); }
void DrawControl(CFX_RenderDevice* pDevice,
CFX_Matrix* pMatrix,
@@ -756,9 +756,7 @@ class CPDF_FormControl {
bool HasMKEntry(const CFX_ByteString& csEntry) const;
int GetRotation();
- inline FX_ARGB GetBorderColor(int& iColorType) {
- return GetColor(iColorType, "BC");
- }
+ FX_ARGB GetBorderColor(int& iColorType) { return GetColor(iColorType, "BC"); }
FX_FLOAT GetOriginalBorderColor(int index) {
return GetOriginalColor(index, "BC");
@@ -823,28 +821,24 @@ class CPDF_FormControl {
class IPDF_FormNotify {
public:
- virtual ~IPDF_FormNotify() {}
+ virtual ~IPDF_FormNotify();
virtual int BeforeValueChange(CPDF_FormField* pField,
- const CFX_WideString& csValue) {
- return 0;
- }
- virtual void AfterValueChange(CPDF_FormField* pField) {}
+ const CFX_WideString& csValue);
+ virtual void AfterValueChange(CPDF_FormField* pField);
virtual int BeforeSelectionChange(CPDF_FormField* pField,
- const CFX_WideString& csValue) {
- return 0;
- }
- virtual void AfterSelectionChange(CPDF_FormField* pField) {}
- virtual void AfterCheckedStatusChange(CPDF_FormField* pField) {}
- virtual int BeforeFormReset(CPDF_InterForm* pForm) { return 0; }
- virtual void AfterFormReset(CPDF_InterForm* pForm) {}
- virtual int BeforeFormImportData(CPDF_InterForm* pForm) { return 0; }
- virtual void AfterFormImportData(CPDF_InterForm* pForm) {}
+ const CFX_WideString& csValue);
+ virtual void AfterSelectionChange(CPDF_FormField* pField);
+ virtual void AfterCheckedStatusChange(CPDF_FormField* pField);
+ virtual int BeforeFormReset(CPDF_InterForm* pForm);
+ virtual void AfterFormReset(CPDF_InterForm* pForm);
+ virtual int BeforeFormImportData(CPDF_InterForm* pForm);
+ virtual void AfterFormImportData(CPDF_InterForm* pForm);
};
class CPDF_PageLabel {
public:
- explicit CPDF_PageLabel(CPDF_Document* pDocument) : m_pDocument(pDocument) {}
+ explicit CPDF_PageLabel(CPDF_Document* pDocument);
CFX_WideString GetLabel(int nPage) const;
int32_t GetPageByLabel(const CFX_ByteStringC& bsLabel) const;
diff --git a/core/fpdfdoc/pdf_vt.h b/core/fpdfdoc/pdf_vt.h
index 3f06f7d6d6..71e28daad9 100644
--- a/core/fpdfdoc/pdf_vt.h
+++ b/core/fpdfdoc/pdf_vt.h
@@ -49,54 +49,16 @@ class CLine final {
CPVT_LineInfo m_LineInfo;
};
-class CLines final {
- public:
- CLines() : m_nTotal(0) {}
- ~CLines() { RemoveAll(); }
-
- int32_t GetSize() const { return m_Lines.GetSize(); }
- CLine* GetAt(int32_t nIndex) const { return m_Lines.GetAt(nIndex); }
- void Empty() { m_nTotal = 0; }
- void RemoveAll() {
- for (int32_t i = 0, sz = GetSize(); i < sz; i++) {
- delete GetAt(i);
- }
- m_Lines.RemoveAll();
- m_nTotal = 0;
- }
- int32_t Add(const CPVT_LineInfo& lineinfo) {
- if (m_nTotal >= GetSize()) {
- CLine* pLine = new CLine;
- pLine->m_LineInfo = lineinfo;
- m_Lines.Add(pLine);
- } else if (CLine* pLine = GetAt(m_nTotal)) {
- pLine->m_LineInfo = lineinfo;
- }
- return m_nTotal++;
- }
- void Clear() {
- for (int32_t i = GetSize() - 1; i >= m_nTotal; i--) {
- delete GetAt(i);
- m_Lines.RemoveAt(i);
- }
- }
-
- private:
- CPVT_ArrayTemplate<CLine*> m_Lines;
- int32_t m_nTotal;
-};
-
class CPDF_EditContainer {
public:
- CPDF_EditContainer() : m_rcPlate(0, 0, 0, 0), m_rcContent(0, 0, 0, 0) {}
- virtual ~CPDF_EditContainer() {}
+ CPDF_EditContainer();
+ virtual ~CPDF_EditContainer();
+
+ virtual void SetPlateRect(const CFX_FloatRect& rect);
+ virtual const CFX_FloatRect& GetPlateRect() const;
+ virtual void SetContentRect(const CPVT_FloatRect& rect);
+ virtual CFX_FloatRect GetContentRect() const;
- virtual void SetPlateRect(const CFX_FloatRect& rect) { m_rcPlate = rect; }
- virtual const CFX_FloatRect& GetPlateRect() const { return m_rcPlate; }
- virtual void SetContentRect(const CPVT_FloatRect& rect) {
- m_rcContent = rect;
- }
- virtual CFX_FloatRect GetContentRect() const { return m_rcContent; }
FX_FLOAT GetPlateWidth() const { return m_rcPlate.right - m_rcPlate.left; }
FX_FLOAT GetPlateHeight() const { return m_rcPlate.top - m_rcPlate.bottom; }
CFX_SizeF GetPlateSize() const {
@@ -108,20 +70,20 @@ class CPDF_EditContainer {
CFX_FloatPoint GetETPoint() const {
return CFX_FloatPoint(m_rcPlate.right, m_rcPlate.bottom);
}
- inline CFX_FloatPoint InToOut(const CFX_FloatPoint& point) const {
+ CFX_FloatPoint InToOut(const CFX_FloatPoint& point) const {
return CFX_FloatPoint(point.x + GetBTPoint().x, GetBTPoint().y - point.y);
}
- inline CFX_FloatPoint OutToIn(const CFX_FloatPoint& point) const {
+ CFX_FloatPoint OutToIn(const CFX_FloatPoint& point) const {
return CFX_FloatPoint(point.x - GetBTPoint().x, GetBTPoint().y - point.y);
}
- inline CFX_FloatRect InToOut(const CPVT_FloatRect& rect) const {
+ CFX_FloatRect InToOut(const CPVT_FloatRect& rect) const {
CFX_FloatPoint ptLeftTop = InToOut(CFX_FloatPoint(rect.left, rect.top));
CFX_FloatPoint ptRightBottom =
InToOut(CFX_FloatPoint(rect.right, rect.bottom));
return CFX_FloatRect(ptLeftTop.x, ptRightBottom.y, ptRightBottom.x,
ptLeftTop.y);
}
- inline CPVT_FloatRect OutToIn(const CFX_FloatRect& rect) const {
+ CPVT_FloatRect OutToIn(const CFX_FloatRect& rect) const {
CFX_FloatPoint ptLeftTop = OutToIn(CFX_FloatPoint(rect.left, rect.top));
CFX_FloatPoint ptRightBottom =
OutToIn(CFX_FloatPoint(rect.right, rect.bottom));
diff --git a/core/fpdfdoc/tagged_int.h b/core/fpdfdoc/tagged_int.h
index d508211441..354a93cb76 100644
--- a/core/fpdfdoc/tagged_int.h
+++ b/core/fpdfdoc/tagged_int.h
@@ -50,15 +50,13 @@ class CPDF_StructElementImpl final : public IPDF_StructElement {
CPDF_StructElementImpl* pParent,
CPDF_Dictionary* pDict);
- // IPDF_StructElement:
- IPDF_StructTree* GetTree() const override { return m_pTree; }
- const CFX_ByteString& GetType() const override { return m_Type; }
- IPDF_StructElement* GetParent() const override { return m_pParent; }
- CPDF_Dictionary* GetDict() const override { return m_pDict; }
- int CountKids() const override { return pdfium::CollectionSize<int>(m_Kids); }
- const CPDF_StructKid& GetKid(int index) const override {
- return m_Kids[index];
- }
+ // IPDF_StructElement
+ IPDF_StructTree* GetTree() const override;
+ const CFX_ByteString& GetType() const override;
+ IPDF_StructElement* GetParent() const override;
+ CPDF_Dictionary* GetDict() const override;
+ int CountKids() const override;
+ const CPDF_StructKid& GetKid(int index) const override;
CPDF_Object* GetAttr(const CFX_ByteStringC& owner,
const CFX_ByteStringC& name,
FX_BOOL bInheritable = FALSE,
diff --git a/core/fpdftext/fpdf_text_int.cpp b/core/fpdftext/fpdf_text_int.cpp
index 5be47143fd..565f078600 100644
--- a/core/fpdftext/fpdf_text_int.cpp
+++ b/core/fpdftext/fpdf_text_int.cpp
@@ -150,13 +150,14 @@ CPDF_TextPage::CPDF_TextPage(const CPDF_Page* pPage, FPDFText_Direction flags)
m_parserflag(flags),
m_pPreTextObj(nullptr),
m_bIsParsed(false),
- m_TextlineDir(TextOrientation::Unknown),
- m_CurlineRect(0, 0, 0, 0) {
+ m_TextlineDir(TextOrientation::Unknown) {
m_TextBuf.EstimateSize(0, 10240);
pPage->GetDisplayMatrix(m_DisplayMatrix, 0, 0, (int)pPage->GetPageWidth(),
(int)pPage->GetPageHeight(), 0);
}
+CPDF_TextPage::~CPDF_TextPage() {}
+
bool CPDF_TextPage::IsControlChar(const PAGECHAR_INFO& charInfo) {
switch (charInfo.m_Unicode) {
case 0x2:
@@ -1829,6 +1830,8 @@ CPDF_TextPageFind::CPDF_TextPageFind(const CPDF_TextPage* pTextPage)
}
}
+CPDF_TextPageFind::~CPDF_TextPageFind() {}
+
int CPDF_TextPageFind::GetCharIndex(int index) const {
return m_pTextPage->CharIndexFromTextIndex(index);
}
diff --git a/core/fpdftext/include/cpdf_textpage.h b/core/fpdftext/include/cpdf_textpage.h
index 0c1efdf34a..d414cbc829 100644
--- a/core/fpdftext/include/cpdf_textpage.h
+++ b/core/fpdftext/include/cpdf_textpage.h
@@ -61,11 +61,8 @@ struct PDFTEXT_Obj {
class CPDF_TextPage {
public:
- static FX_BOOL IsRectIntersect(const CFX_FloatRect& rect1,
- const CFX_FloatRect& rect2);
-
CPDF_TextPage(const CPDF_Page* pPage, FPDFText_Direction flags);
- ~CPDF_TextPage() {}
+ ~CPDF_TextPage();
// IPDF_TextPage:
void ParseTextPage();
@@ -98,6 +95,9 @@ class CPDF_TextPage {
FX_FLOAT bottom,
FX_BOOL bContains = FALSE);
+ static FX_BOOL IsRectIntersect(const CFX_FloatRect& rect1,
+ const CFX_FloatRect& rect2);
+
private:
enum class TextOrientation {
Unknown,
diff --git a/core/fpdftext/include/cpdf_textpagefind.h b/core/fpdftext/include/cpdf_textpagefind.h
index d9937772d1..4950bd1113 100644
--- a/core/fpdftext/include/cpdf_textpagefind.h
+++ b/core/fpdftext/include/cpdf_textpagefind.h
@@ -18,7 +18,7 @@ class CPDF_TextPage;
class CPDF_TextPageFind {
public:
explicit CPDF_TextPageFind(const CPDF_TextPage* pTextPage);
- ~CPDF_TextPageFind() {}
+ ~CPDF_TextPageFind();
FX_BOOL FindFirst(const CFX_WideString& findwhat,
int flags,
@@ -38,10 +38,6 @@ class CPDF_TextPageFind {
int iSubString,
FX_WCHAR chSep);
CFX_WideString MakeReverse(const CFX_WideString& str);
- int ReverseFind(const CFX_WideString& csPageText,
- const CFX_WideString& csWord,
- int nStartPos,
- int& WordLength);
int GetCharIndex(int index) const;
private:
diff --git a/core/fxcodec/codec/ccodec_iccmodule.h b/core/fxcodec/codec/ccodec_iccmodule.h
index 822b202e3f..fd2f456654 100644
--- a/core/fxcodec/codec/ccodec_iccmodule.h
+++ b/core/fxcodec/codec/ccodec_iccmodule.h
@@ -43,6 +43,7 @@ class CCodec_IccModule {
double Gamma;
};
+ CCodec_IccModule();
~CCodec_IccModule();
IccCS GetProfileCS(const uint8_t* pProfileData, unsigned int dwProfileSize);
diff --git a/core/fxcodec/codec/fx_codec.cpp b/core/fxcodec/codec/fx_codec.cpp
index 55cb6ee7fb..1995784dcd 100644
--- a/core/fxcodec/codec/fx_codec.cpp
+++ b/core/fxcodec/codec/fx_codec.cpp
@@ -31,6 +31,8 @@ CCodec_ModuleMgr::CCodec_ModuleMgr()
m_pFlateModule(new CCodec_FlateModule) {
}
+CCodec_ModuleMgr::~CCodec_ModuleMgr() {}
+
CCodec_ScanlineDecoder::CCodec_ScanlineDecoder()
: m_NextLine(-1), m_pLastScanline(nullptr) {}
diff --git a/core/fxcodec/codec/fx_codec_icc.cpp b/core/fxcodec/codec/fx_codec_icc.cpp
index 4903c24715..29cfe0e9f4 100644
--- a/core/fxcodec/codec/fx_codec_icc.cpp
+++ b/core/fxcodec/codec/fx_codec_icc.cpp
@@ -526,6 +526,9 @@ void* CCodec_IccModule::CreateTransform(
}
return pTransformCache->m_pCmm;
}
+
+CCodec_IccModule::CCodec_IccModule() : m_nComponents(0) {}
+
CCodec_IccModule::~CCodec_IccModule() {
for (const auto& pair : m_MapProfile) {
delete pair.second;
diff --git a/core/fxcodec/include/fx_codec.h b/core/fxcodec/include/fx_codec.h
index 4853e26a6a..8621db2b2c 100644
--- a/core/fxcodec/include/fx_codec.h
+++ b/core/fxcodec/include/fx_codec.h
@@ -59,6 +59,7 @@ class CFX_DIBAttribute {
class CCodec_ModuleMgr {
public:
CCodec_ModuleMgr();
+ ~CCodec_ModuleMgr();
CCodec_BasicModule* GetBasicModule() const { return m_pBasicModule.get(); }
CCodec_FaxModule* GetFaxModule() const { return m_pFaxModule.get(); }
diff --git a/core/fxcodec/lgif/fx_gif.cpp b/core/fxcodec/lgif/fx_gif.cpp
index b9ea090853..d6db28b427 100644
--- a/core/fxcodec/lgif/fx_gif.cpp
+++ b/core/fxcodec/lgif/fx_gif.cpp
@@ -12,9 +12,28 @@ void CGifLZWDecoder::Input(uint8_t* src_buf, uint32_t src_size) {
next_in = src_buf;
avail_in = src_size;
}
+
uint32_t CGifLZWDecoder::GetAvailInput() {
return avail_in;
}
+
+CGifLZWDecoder::CGifLZWDecoder(FX_CHAR* error_ptr)
+ : code_size(0),
+ code_size_cur(0),
+ code_clear(0),
+ code_end(0),
+ code_next(0),
+ code_first(0),
+ stack_size(0),
+ code_old(0),
+ next_in(nullptr),
+ avail_in(0),
+ bits_left(0),
+ code_store(0),
+ err_msg_ptr(error_ptr) {}
+
+CGifLZWDecoder::~CGifLZWDecoder() {}
+
void CGifLZWDecoder::InitTable(uint8_t code_len) {
code_size = code_len;
code_clear = 1 << code_size;
diff --git a/core/fxcodec/lgif/fx_gif.h b/core/fxcodec/lgif/fx_gif.h
index 7d325fb3fe..b7157df429 100644
--- a/core/fxcodec/lgif/fx_gif.h
+++ b/core/fxcodec/lgif/fx_gif.h
@@ -107,22 +107,25 @@ typedef struct tagGifImage {
uint8_t* image_row_buf;
int32_t image_row_num;
} GifImage;
+
typedef struct tagGifPlainText {
GifGCE* gce_ptr;
GifPTE* pte_ptr;
CFX_ByteString* string_ptr;
} GifPlainText;
+
class CGifLZWDecoder {
public:
struct tag_Table {
uint16_t prefix;
uint8_t suffix;
};
- CGifLZWDecoder(FX_CHAR* error_ptr = nullptr) { err_msg_ptr = error_ptr; }
- void InitTable(uint8_t code_len);
- int32_t Decode(uint8_t* des_buf, uint32_t& des_size);
+ explicit CGifLZWDecoder(FX_CHAR* error_ptr);
+ ~CGifLZWDecoder();
+ void InitTable(uint8_t code_len);
+ int32_t Decode(uint8_t* des_buf, uint32_t& des_size);
void Input(uint8_t* src_buf, uint32_t src_size);
uint32_t GetAvailInput();
@@ -130,6 +133,7 @@ class CGifLZWDecoder {
void ClearTable();
void AddCode(uint16_t prefix_code, uint8_t append_char);
void DecodeString(uint16_t code);
+
uint8_t code_size;
uint8_t code_size_cur;
uint16_t code_clear;
@@ -149,14 +153,17 @@ class CGifLZWDecoder {
FX_CHAR* err_msg_ptr;
};
+
class CGifLZWEncoder {
public:
struct tag_Table {
uint16_t prefix;
uint8_t suffix;
};
+
CGifLZWEncoder();
~CGifLZWEncoder();
+
void Start(uint8_t code_len,
const uint8_t* src_buf,
uint8_t*& dst_buf,
@@ -178,6 +185,7 @@ class CGifLZWEncoder {
uint32_t& dst_len,
uint32_t& offset);
void WriteBlock(uint8_t*& dst_buf, uint32_t& dst_len, uint32_t& offset);
+
jmp_buf jmp;
uint32_t src_offset;
uint8_t src_bit_offset;
@@ -194,6 +202,7 @@ class CGifLZWEncoder {
tag_Table code_table[GIF_MAX_LZW_CODE];
uint16_t table_cur;
};
+
typedef struct tag_gif_decompress_struct gif_decompress_struct;
typedef gif_decompress_struct* gif_decompress_struct_p;
typedef gif_decompress_struct_p* gif_decompress_struct_pp;
diff --git a/core/fxcrt/extension.h b/core/fxcrt/extension.h
index 877f1ca144..d4fd0931f4 100644
--- a/core/fxcrt/extension.h
+++ b/core/fxcrt/extension.h
@@ -37,30 +37,16 @@ class IFXCRT_FileAccess {
#ifdef PDF_ENABLE_XFA
class CFX_CRTFileAccess : public IFX_FileAccess {
public:
- CFX_CRTFileAccess() : m_RefCount(0) {}
+ CFX_CRTFileAccess();
+ ~CFX_CRTFileAccess() override;
// IFX_FileAccess
- void Release() override {
- if (--m_RefCount == 0)
- delete this;
- }
-
- IFX_FileAccess* Retain() override {
- m_RefCount++;
- return this;
- }
-
- void GetPath(CFX_WideString& wsPath) override { wsPath = m_path; }
-
- IFX_FileStream* CreateFileStream(uint32_t dwModes) override {
- return FX_CreateFileStream(m_path.c_str(), dwModes);
- }
+ void Release() override;
+ IFX_FileAccess* Retain() override;
+ void GetPath(CFX_WideString& wsPath) override;
+ IFX_FileStream* CreateFileStream(uint32_t dwModes) override;
- FX_BOOL Init(const CFX_WideStringC& wsPath) {
- m_path = wsPath;
- m_RefCount = 1;
- return TRUE;
- }
+ FX_BOOL Init(const CFX_WideStringC& wsPath);
protected:
CFX_WideString m_path;
@@ -96,190 +82,29 @@ class CFX_CRTFileStream final : public IFX_FileStream {
#define FX_MEMSTREAM_TakeOver 0x02
class CFX_MemoryStream final : public IFX_MemoryStream {
public:
- explicit CFX_MemoryStream(FX_BOOL bConsecutive)
- : m_dwCount(1),
- m_nTotalSize(0),
- m_nCurSize(0),
- m_nCurPos(0),
- m_nGrowSize(FX_MEMSTREAM_BlockSize) {
- m_dwFlags =
- FX_MEMSTREAM_TakeOver | (bConsecutive ? FX_MEMSTREAM_Consecutive : 0);
- }
- CFX_MemoryStream(uint8_t* pBuffer, size_t nSize, FX_BOOL bTakeOver)
- : m_dwCount(1),
- m_nTotalSize(nSize),
- m_nCurSize(nSize),
- m_nCurPos(0),
- m_nGrowSize(FX_MEMSTREAM_BlockSize) {
- m_Blocks.Add(pBuffer);
- m_dwFlags =
- FX_MEMSTREAM_Consecutive | (bTakeOver ? FX_MEMSTREAM_TakeOver : 0);
- }
- ~CFX_MemoryStream() override {
- if (m_dwFlags & FX_MEMSTREAM_TakeOver) {
- for (int32_t i = 0; i < m_Blocks.GetSize(); i++) {
- FX_Free(m_Blocks[i]);
- }
- }
- m_Blocks.RemoveAll();
- }
-
- // IFX_MemoryStream:
- IFX_FileStream* Retain() override {
- m_dwCount++;
- return this;
- }
- void Release() override {
- uint32_t nCount = --m_dwCount;
- if (nCount) {
- return;
- }
- delete this;
- }
- FX_FILESIZE GetSize() override { return (FX_FILESIZE)m_nCurSize; }
- FX_BOOL IsEOF() override { return m_nCurPos >= (size_t)GetSize(); }
- FX_FILESIZE GetPosition() override { return (FX_FILESIZE)m_nCurPos; }
- FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override {
- if (!buffer || !size) {
- return FALSE;
- }
+ explicit CFX_MemoryStream(FX_BOOL bConsecutive);
+ CFX_MemoryStream(uint8_t* pBuffer, size_t nSize, FX_BOOL bTakeOver);
+ ~CFX_MemoryStream() override;
- FX_SAFE_SIZE_T newPos = size;
- newPos += offset;
- if (!newPos.IsValid() || newPos.ValueOrDefault(0) == 0 ||
- newPos.ValueOrDie() > m_nCurSize) {
- return FALSE;
- }
-
- m_nCurPos = newPos.ValueOrDie();
- if (m_dwFlags & FX_MEMSTREAM_Consecutive) {
- FXSYS_memcpy(buffer, m_Blocks[0] + (size_t)offset, size);
- return TRUE;
- }
- size_t nStartBlock = (size_t)offset / m_nGrowSize;
- offset -= (FX_FILESIZE)(nStartBlock * m_nGrowSize);
- while (size) {
- size_t nRead = m_nGrowSize - (size_t)offset;
- if (nRead > size) {
- nRead = size;
- }
- FXSYS_memcpy(buffer, m_Blocks[(int)nStartBlock] + (size_t)offset, nRead);
- buffer = ((uint8_t*)buffer) + nRead;
- size -= nRead;
- nStartBlock++;
- offset = 0;
- }
- return TRUE;
- }
- size_t ReadBlock(void* buffer, size_t size) override {
- if (m_nCurPos >= m_nCurSize) {
- return 0;
- }
- size_t nRead = std::min(size, m_nCurSize - m_nCurPos);
- if (!ReadBlock(buffer, (int32_t)m_nCurPos, nRead)) {
- return 0;
- }
- return nRead;
- }
+ // IFX_MemoryStream
+ IFX_FileStream* Retain() override;
+ void Release() override;
+ FX_FILESIZE GetSize() override;
+ FX_BOOL IsEOF() override;
+ FX_FILESIZE GetPosition() override;
+ FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override;
+ size_t ReadBlock(void* buffer, size_t size) override;
FX_BOOL WriteBlock(const void* buffer,
FX_FILESIZE offset,
- size_t size) override {
- if (!buffer || !size) {
- return FALSE;
- }
- if (m_dwFlags & FX_MEMSTREAM_Consecutive) {
- FX_SAFE_SIZE_T newPos = size;
- newPos += offset;
- if (!newPos.IsValid())
- return FALSE;
-
- m_nCurPos = newPos.ValueOrDie();
- if (m_nCurPos > m_nTotalSize) {
- m_nTotalSize =
- (m_nCurPos + m_nGrowSize - 1) / m_nGrowSize * m_nGrowSize;
- if (m_Blocks.GetSize() < 1) {
- uint8_t* block = FX_Alloc(uint8_t, m_nTotalSize);
- m_Blocks.Add(block);
- } else {
- m_Blocks[0] = FX_Realloc(uint8_t, m_Blocks[0], m_nTotalSize);
- }
- if (!m_Blocks[0]) {
- m_Blocks.RemoveAll();
- return FALSE;
- }
- }
- FXSYS_memcpy(m_Blocks[0] + (size_t)offset, buffer, size);
- if (m_nCurSize < m_nCurPos) {
- m_nCurSize = m_nCurPos;
- }
- return TRUE;
- }
-
- FX_SAFE_SIZE_T newPos = size;
- newPos += offset;
- if (!newPos.IsValid()) {
- return FALSE;
- }
-
- if (!ExpandBlocks(newPos.ValueOrDie())) {
- return FALSE;
- }
- m_nCurPos = newPos.ValueOrDie();
- size_t nStartBlock = (size_t)offset / m_nGrowSize;
- offset -= (FX_FILESIZE)(nStartBlock * m_nGrowSize);
- while (size) {
- size_t nWrite = m_nGrowSize - (size_t)offset;
- if (nWrite > size) {
- nWrite = size;
- }
- FXSYS_memcpy(m_Blocks[(int)nStartBlock] + (size_t)offset, buffer, nWrite);
- buffer = ((uint8_t*)buffer) + nWrite;
- size -= nWrite;
- nStartBlock++;
- offset = 0;
- }
- return TRUE;
- }
- FX_BOOL Flush() override { return TRUE; }
- FX_BOOL IsConsecutive() const override {
- return !!(m_dwFlags & FX_MEMSTREAM_Consecutive);
- }
- void EstimateSize(size_t nInitSize, size_t nGrowSize) override {
- if (m_dwFlags & FX_MEMSTREAM_Consecutive) {
- if (m_Blocks.GetSize() < 1) {
- uint8_t* pBlock =
- FX_Alloc(uint8_t, std::max(nInitSize, static_cast<size_t>(4096)));
- m_Blocks.Add(pBlock);
- }
- m_nGrowSize = std::max(nGrowSize, static_cast<size_t>(4096));
- } else if (m_Blocks.GetSize() < 1) {
- m_nGrowSize = std::max(nGrowSize, static_cast<size_t>(4096));
- }
- }
- uint8_t* GetBuffer() const override {
- return m_Blocks.GetSize() ? m_Blocks[0] : nullptr;
- }
+ size_t size) override;
+ FX_BOOL Flush() override;
+ FX_BOOL IsConsecutive() const override;
+ void EstimateSize(size_t nInitSize, size_t nGrowSize) override;
+ uint8_t* GetBuffer() const override;
void AttachBuffer(uint8_t* pBuffer,
size_t nSize,
- FX_BOOL bTakeOver = FALSE) override {
- if (!(m_dwFlags & FX_MEMSTREAM_Consecutive)) {
- return;
- }
- m_Blocks.RemoveAll();
- m_Blocks.Add(pBuffer);
- m_nTotalSize = m_nCurSize = nSize;
- m_nCurPos = 0;
- m_dwFlags =
- FX_MEMSTREAM_Consecutive | (bTakeOver ? FX_MEMSTREAM_TakeOver : 0);
- }
- void DetachBuffer() override {
- if (!(m_dwFlags & FX_MEMSTREAM_Consecutive)) {
- return;
- }
- m_Blocks.RemoveAll();
- m_nTotalSize = m_nCurSize = m_nCurPos = 0;
- m_dwFlags = FX_MEMSTREAM_TakeOver;
- }
+ FX_BOOL bTakeOver = FALSE) override;
+ void DetachBuffer() override;
protected:
CFX_ArrayTemplate<uint8_t*> m_Blocks;
@@ -289,23 +114,7 @@ class CFX_MemoryStream final : public IFX_MemoryStream {
size_t m_nCurPos;
size_t m_nGrowSize;
uint32_t m_dwFlags;
- FX_BOOL ExpandBlocks(size_t size) {
- if (m_nCurSize < size) {
- m_nCurSize = size;
- }
- if (size <= m_nTotalSize) {
- return TRUE;
- }
- int32_t iCount = m_Blocks.GetSize();
- size = (size - m_nTotalSize + m_nGrowSize - 1) / m_nGrowSize;
- m_Blocks.SetSize(m_Blocks.GetSize() + (int32_t)size);
- while (size--) {
- uint8_t* pBlock = FX_Alloc(uint8_t, m_nGrowSize);
- m_Blocks.SetAt(iCount++, pBlock);
- m_nTotalSize += m_nGrowSize;
- }
- return TRUE;
- }
+ FX_BOOL ExpandBlocks(size_t size);
};
#ifdef __cplusplus
diff --git a/core/fxcrt/fx_basic_bstring.cpp b/core/fxcrt/fx_basic_bstring.cpp
index 379f1ee882..d0ba1af5ba 100644
--- a/core/fxcrt/fx_basic_bstring.cpp
+++ b/core/fxcrt/fx_basic_bstring.cpp
@@ -94,11 +94,23 @@ CFX_ByteString::CFX_ByteString(const uint8_t* pStr, FX_STRSIZE nLen) {
}
}
+CFX_ByteString::CFX_ByteString() {}
+
+CFX_ByteString::CFX_ByteString(const CFX_ByteString& other)
+ : m_pData(other.m_pData) {}
+
+CFX_ByteString::CFX_ByteString(CFX_ByteString&& other) {
+ m_pData.Swap(other.m_pData);
+}
+
CFX_ByteString::CFX_ByteString(char ch) {
m_pData.Reset(StringData::Create(1));
m_pData->m_String[0] = ch;
}
+CFX_ByteString::CFX_ByteString(const FX_CHAR* ptr)
+ : CFX_ByteString(ptr, ptr ? FXSYS_strlen(ptr) : 0) {}
+
CFX_ByteString::CFX_ByteString(const CFX_ByteStringC& stringSrc) {
if (!stringSrc.IsEmpty())
m_pData.Reset(StringData::Create(stringSrc.c_str(), stringSrc.GetLength()));
diff --git a/core/fxcrt/fx_basic_util.cpp b/core/fxcrt/fx_basic_util.cpp
index 8eba2cce0e..b9cf470d08 100644
--- a/core/fxcrt/fx_basic_util.cpp
+++ b/core/fxcrt/fx_basic_util.cpp
@@ -117,14 +117,16 @@ class CFindFileData {
HANDLE m_Handle;
FX_BOOL m_bEnd;
};
+
class CFindFileDataA : public CFindFileData {
public:
- virtual ~CFindFileDataA() {}
+ ~CFindFileDataA() override {}
WIN32_FIND_DATAA m_FindData;
};
+
class CFindFileDataW : public CFindFileData {
public:
- virtual ~CFindFileDataW() {}
+ ~CFindFileDataW() override {}
WIN32_FIND_DATAW m_FindData;
};
#endif
diff --git a/core/fxcrt/fx_basic_wstring.cpp b/core/fxcrt/fx_basic_wstring.cpp
index ba86823fe2..8837c6bb3b 100644
--- a/core/fxcrt/fx_basic_wstring.cpp
+++ b/core/fxcrt/fx_basic_wstring.cpp
@@ -63,6 +63,15 @@ const FX_WCHAR* FX_wcsstr(const FX_WCHAR* haystack,
static_assert(sizeof(CFX_WideString) <= sizeof(FX_WCHAR*),
"Strings must not require more space than pointers");
+CFX_WideString::CFX_WideString() {}
+
+CFX_WideString::CFX_WideString(const CFX_WideString& other)
+ : m_pData(other.m_pData) {}
+
+CFX_WideString::CFX_WideString(CFX_WideString&& other) {
+ m_pData.Swap(other.m_pData);
+}
+
CFX_WideString::CFX_WideString(const FX_WCHAR* pStr, FX_STRSIZE nLen) {
if (nLen < 0)
nLen = pStr ? FXSYS_wcslen(pStr) : 0;
@@ -76,6 +85,9 @@ CFX_WideString::CFX_WideString(FX_WCHAR ch) {
m_pData->m_String[0] = ch;
}
+CFX_WideString::CFX_WideString(const FX_WCHAR* ptr)
+ : CFX_WideString(ptr, ptr ? FXSYS_wcslen(ptr) : 0) {}
+
CFX_WideString::CFX_WideString(const CFX_WideStringC& stringSrc) {
if (!stringSrc.IsEmpty()) {
m_pData.Reset(StringData::Create(stringSrc.c_str(), stringSrc.GetLength()));
diff --git a/core/fxcrt/fx_bidi.cpp b/core/fxcrt/fx_bidi.cpp
index d8a8f88a64..f1d162dee9 100644
--- a/core/fxcrt/fx_bidi.cpp
+++ b/core/fxcrt/fx_bidi.cpp
@@ -73,6 +73,8 @@ CFX_BidiString::CFX_BidiString(const CFX_WideString& str)
SetOverallDirectionRight();
}
+CFX_BidiString::~CFX_BidiString() {}
+
void CFX_BidiString::SetOverallDirectionRight() {
if (m_eOverallDirection != CFX_BidiChar::RIGHT) {
std::reverse(m_Order.begin(), m_Order.end());
diff --git a/core/fxcrt/fx_bidi.h b/core/fxcrt/fx_bidi.h
index 309c6f518d..ad5fb27054 100644
--- a/core/fxcrt/fx_bidi.h
+++ b/core/fxcrt/fx_bidi.h
@@ -49,7 +49,9 @@ class CFX_BidiChar {
class CFX_BidiString {
public:
using const_iterator = std::vector<CFX_BidiChar::Segment>::const_iterator;
+
explicit CFX_BidiString(const CFX_WideString& str);
+ ~CFX_BidiString();
// Overall direction is always LEFT or RIGHT, never NEUTRAL.
CFX_BidiChar::Direction OverallDirection() const {
diff --git a/core/fxcrt/fx_extension.cpp b/core/fxcrt/fx_extension.cpp
index 1a95e8c318..4c77244b3d 100644
--- a/core/fxcrt/fx_extension.cpp
+++ b/core/fxcrt/fx_extension.cpp
@@ -16,11 +16,271 @@
#include <ctime>
#endif
+#ifdef PDF_ENABLE_XFA
+
+CFX_CRTFileAccess::CFX_CRTFileAccess() : m_RefCount(0) {}
+
+CFX_CRTFileAccess::~CFX_CRTFileAccess() {}
+
+void CFX_CRTFileAccess::Release() {
+ if (--m_RefCount == 0)
+ delete this;
+}
+
+IFX_FileAccess* CFX_CRTFileAccess::Retain() {
+ m_RefCount++;
+ return (IFX_FileAccess*)this;
+}
+
+void CFX_CRTFileAccess::GetPath(CFX_WideString& wsPath) {
+ wsPath = m_path;
+}
+
+IFX_FileStream* CFX_CRTFileAccess::CreateFileStream(uint32_t dwModes) {
+ return FX_CreateFileStream(m_path.c_str(), dwModes);
+}
+
+FX_BOOL CFX_CRTFileAccess::Init(const CFX_WideStringC& wsPath) {
+ m_path = wsPath;
+ m_RefCount = 1;
+ return TRUE;
+}
+
+#endif // PDF_ENABLE_XFA
+
CFX_CRTFileStream::CFX_CRTFileStream(std::unique_ptr<IFXCRT_FileAccess> pFA)
: m_pFile(std::move(pFA)), m_dwCount(1) {}
CFX_CRTFileStream::~CFX_CRTFileStream() {}
+CFX_MemoryStream::CFX_MemoryStream(FX_BOOL bConsecutive)
+ : m_dwCount(1),
+ m_nTotalSize(0),
+ m_nCurSize(0),
+ m_nCurPos(0),
+ m_nGrowSize(FX_MEMSTREAM_BlockSize) {
+ m_dwFlags =
+ FX_MEMSTREAM_TakeOver | (bConsecutive ? FX_MEMSTREAM_Consecutive : 0);
+}
+
+CFX_MemoryStream::CFX_MemoryStream(uint8_t* pBuffer,
+ size_t nSize,
+ FX_BOOL bTakeOver)
+ : m_dwCount(1),
+ m_nTotalSize(nSize),
+ m_nCurSize(nSize),
+ m_nCurPos(0),
+ m_nGrowSize(FX_MEMSTREAM_BlockSize) {
+ m_Blocks.Add(pBuffer);
+ m_dwFlags =
+ FX_MEMSTREAM_Consecutive | (bTakeOver ? FX_MEMSTREAM_TakeOver : 0);
+}
+
+CFX_MemoryStream::~CFX_MemoryStream() {
+ if (m_dwFlags & FX_MEMSTREAM_TakeOver) {
+ for (int32_t i = 0; i < m_Blocks.GetSize(); i++) {
+ FX_Free(m_Blocks[i]);
+ }
+ }
+ m_Blocks.RemoveAll();
+}
+
+IFX_FileStream* CFX_MemoryStream::Retain() {
+ m_dwCount++;
+ return this;
+}
+
+void CFX_MemoryStream::Release() {
+ uint32_t nCount = --m_dwCount;
+ if (nCount) {
+ return;
+ }
+ delete this;
+}
+
+FX_FILESIZE CFX_MemoryStream::GetSize() {
+ return (FX_FILESIZE)m_nCurSize;
+}
+
+FX_BOOL CFX_MemoryStream::IsEOF() {
+ return m_nCurPos >= (size_t)GetSize();
+}
+
+FX_FILESIZE CFX_MemoryStream::GetPosition() {
+ return (FX_FILESIZE)m_nCurPos;
+}
+
+FX_BOOL CFX_MemoryStream::ReadBlock(void* buffer,
+ FX_FILESIZE offset,
+ size_t size) {
+ if (!buffer || !size) {
+ return FALSE;
+ }
+
+ FX_SAFE_SIZE_T newPos = size;
+ newPos += offset;
+ if (!newPos.IsValid() || newPos.ValueOrDefault(0) == 0 ||
+ newPos.ValueOrDie() > m_nCurSize) {
+ return FALSE;
+ }
+
+ m_nCurPos = newPos.ValueOrDie();
+ if (m_dwFlags & FX_MEMSTREAM_Consecutive) {
+ FXSYS_memcpy(buffer, m_Blocks[0] + (size_t)offset, size);
+ return TRUE;
+ }
+ size_t nStartBlock = (size_t)offset / m_nGrowSize;
+ offset -= (FX_FILESIZE)(nStartBlock * m_nGrowSize);
+ while (size) {
+ size_t nRead = m_nGrowSize - (size_t)offset;
+ if (nRead > size) {
+ nRead = size;
+ }
+ FXSYS_memcpy(buffer, m_Blocks[(int)nStartBlock] + (size_t)offset, nRead);
+ buffer = ((uint8_t*)buffer) + nRead;
+ size -= nRead;
+ nStartBlock++;
+ offset = 0;
+ }
+ return TRUE;
+}
+
+size_t CFX_MemoryStream::ReadBlock(void* buffer, size_t size) {
+ if (m_nCurPos >= m_nCurSize) {
+ return 0;
+ }
+ size_t nRead = std::min(size, m_nCurSize - m_nCurPos);
+ if (!ReadBlock(buffer, (int32_t)m_nCurPos, nRead)) {
+ return 0;
+ }
+ return nRead;
+}
+
+FX_BOOL CFX_MemoryStream::WriteBlock(const void* buffer,
+ FX_FILESIZE offset,
+ size_t size) {
+ if (!buffer || !size) {
+ return FALSE;
+ }
+ if (m_dwFlags & FX_MEMSTREAM_Consecutive) {
+ FX_SAFE_SIZE_T newPos = size;
+ newPos += offset;
+ if (!newPos.IsValid())
+ return FALSE;
+
+ m_nCurPos = newPos.ValueOrDie();
+ if (m_nCurPos > m_nTotalSize) {
+ m_nTotalSize = (m_nCurPos + m_nGrowSize - 1) / m_nGrowSize * m_nGrowSize;
+ if (m_Blocks.GetSize() < 1) {
+ uint8_t* block = FX_Alloc(uint8_t, m_nTotalSize);
+ m_Blocks.Add(block);
+ } else {
+ m_Blocks[0] = FX_Realloc(uint8_t, m_Blocks[0], m_nTotalSize);
+ }
+ if (!m_Blocks[0]) {
+ m_Blocks.RemoveAll();
+ return FALSE;
+ }
+ }
+ FXSYS_memcpy(m_Blocks[0] + (size_t)offset, buffer, size);
+ if (m_nCurSize < m_nCurPos) {
+ m_nCurSize = m_nCurPos;
+ }
+ return TRUE;
+ }
+
+ FX_SAFE_SIZE_T newPos = size;
+ newPos += offset;
+ if (!newPos.IsValid()) {
+ return FALSE;
+ }
+
+ if (!ExpandBlocks(newPos.ValueOrDie())) {
+ return FALSE;
+ }
+ m_nCurPos = newPos.ValueOrDie();
+ size_t nStartBlock = (size_t)offset / m_nGrowSize;
+ offset -= (FX_FILESIZE)(nStartBlock * m_nGrowSize);
+ while (size) {
+ size_t nWrite = m_nGrowSize - (size_t)offset;
+ if (nWrite > size) {
+ nWrite = size;
+ }
+ FXSYS_memcpy(m_Blocks[(int)nStartBlock] + (size_t)offset, buffer, nWrite);
+ buffer = ((uint8_t*)buffer) + nWrite;
+ size -= nWrite;
+ nStartBlock++;
+ offset = 0;
+ }
+ return TRUE;
+}
+
+FX_BOOL CFX_MemoryStream::Flush() {
+ return TRUE;
+}
+
+FX_BOOL CFX_MemoryStream::IsConsecutive() const {
+ return !!(m_dwFlags & FX_MEMSTREAM_Consecutive);
+}
+
+void CFX_MemoryStream::EstimateSize(size_t nInitSize, size_t nGrowSize) {
+ if (m_dwFlags & FX_MEMSTREAM_Consecutive) {
+ if (m_Blocks.GetSize() < 1) {
+ uint8_t* pBlock =
+ FX_Alloc(uint8_t, std::max(nInitSize, static_cast<size_t>(4096)));
+ m_Blocks.Add(pBlock);
+ }
+ m_nGrowSize = std::max(nGrowSize, static_cast<size_t>(4096));
+ } else if (m_Blocks.GetSize() < 1) {
+ m_nGrowSize = std::max(nGrowSize, static_cast<size_t>(4096));
+ }
+}
+
+uint8_t* CFX_MemoryStream::GetBuffer() const {
+ return m_Blocks.GetSize() ? m_Blocks[0] : nullptr;
+}
+
+void CFX_MemoryStream::AttachBuffer(uint8_t* pBuffer,
+ size_t nSize,
+ FX_BOOL bTakeOver) {
+ if (!(m_dwFlags & FX_MEMSTREAM_Consecutive)) {
+ return;
+ }
+ m_Blocks.RemoveAll();
+ m_Blocks.Add(pBuffer);
+ m_nTotalSize = m_nCurSize = nSize;
+ m_nCurPos = 0;
+ m_dwFlags =
+ FX_MEMSTREAM_Consecutive | (bTakeOver ? FX_MEMSTREAM_TakeOver : 0);
+}
+
+void CFX_MemoryStream::DetachBuffer() {
+ if (!(m_dwFlags & FX_MEMSTREAM_Consecutive)) {
+ return;
+ }
+ m_Blocks.RemoveAll();
+ m_nTotalSize = m_nCurSize = m_nCurPos = 0;
+ m_dwFlags = FX_MEMSTREAM_TakeOver;
+}
+
+FX_BOOL CFX_MemoryStream::ExpandBlocks(size_t size) {
+ if (m_nCurSize < size) {
+ m_nCurSize = size;
+ }
+ if (size <= m_nTotalSize) {
+ return TRUE;
+ }
+ int32_t iCount = m_Blocks.GetSize();
+ size = (size - m_nTotalSize + m_nGrowSize - 1) / m_nGrowSize;
+ m_Blocks.SetSize(m_Blocks.GetSize() + (int32_t)size);
+ while (size--) {
+ uint8_t* pBlock = FX_Alloc(uint8_t, m_nGrowSize);
+ m_Blocks.SetAt(iCount++, pBlock);
+ m_nTotalSize += m_nGrowSize;
+ }
+ return TRUE;
+}
+
IFX_FileStream* CFX_CRTFileStream::Retain() {
m_dwCount++;
return this;
diff --git a/core/fxcrt/fx_xml_parser.cpp b/core/fxcrt/fx_xml_parser.cpp
index 6017bd8fda..9412cdde04 100644
--- a/core/fxcrt/fx_xml_parser.cpp
+++ b/core/fxcrt/fx_xml_parser.cpp
@@ -12,11 +12,121 @@
#include "core/fxcrt/include/fx_xml.h"
#include "third_party/base/stl_util.h"
+CXML_DataBufAcc::CXML_DataBufAcc(const uint8_t* pBuffer, size_t size)
+ : m_pBuffer(pBuffer), m_dwSize(size), m_dwCurPos(0) {}
+
+CXML_DataBufAcc::~CXML_DataBufAcc() {}
+
+void CXML_DataBufAcc::Release() {
+ delete this;
+}
+
+FX_BOOL CXML_DataBufAcc::IsEOF() {
+ return m_dwCurPos >= m_dwSize;
+}
+
+FX_FILESIZE CXML_DataBufAcc::GetPosition() {
+ return (FX_FILESIZE)m_dwCurPos;
+}
+
+size_t CXML_DataBufAcc::ReadBlock(void* buffer, size_t size) {
+ return 0;
+}
+
+FX_BOOL CXML_DataBufAcc::ReadNextBlock(FX_BOOL bRestart) {
+ if (bRestart) {
+ m_dwCurPos = 0;
+ }
+ if (m_dwCurPos < m_dwSize) {
+ m_dwCurPos = m_dwSize;
+ return TRUE;
+ }
+ return FALSE;
+}
+
+const uint8_t* CXML_DataBufAcc::GetBlockBuffer() {
+ return m_pBuffer;
+}
+
+size_t CXML_DataBufAcc::GetBlockSize() {
+ return m_dwSize;
+}
+
+FX_FILESIZE CXML_DataBufAcc::GetBlockOffset() {
+ return 0;
+}
+
+CXML_DataStmAcc::CXML_DataStmAcc(IFX_FileRead* pFileRead)
+ : m_pFileRead(pFileRead), m_pBuffer(nullptr), m_nStart(0), m_dwSize(0) {
+ ASSERT(m_pFileRead);
+}
+
+CXML_DataStmAcc::~CXML_DataStmAcc() {
+ FX_Free(m_pBuffer);
+}
+
+void CXML_DataStmAcc::Release() {
+ delete this;
+}
+
+FX_BOOL CXML_DataStmAcc::IsEOF() {
+ return m_nStart + (FX_FILESIZE)m_dwSize >= m_pFileRead->GetSize();
+}
+
+FX_FILESIZE CXML_DataStmAcc::GetPosition() {
+ return m_nStart + (FX_FILESIZE)m_dwSize;
+}
+
+size_t CXML_DataStmAcc::ReadBlock(void* buffer, size_t size) {
+ return 0;
+}
+
+FX_BOOL CXML_DataStmAcc::ReadNextBlock(FX_BOOL bRestart) {
+ if (bRestart) {
+ m_nStart = 0;
+ }
+ FX_FILESIZE nLength = m_pFileRead->GetSize();
+ m_nStart += (FX_FILESIZE)m_dwSize;
+ if (m_nStart >= nLength) {
+ return FALSE;
+ }
+ static const FX_FILESIZE FX_XMLDATASTREAM_BufferSize = 32 * 1024;
+ m_dwSize = static_cast<size_t>(
+ std::min(FX_XMLDATASTREAM_BufferSize, nLength - m_nStart));
+ if (!m_pBuffer) {
+ m_pBuffer = FX_Alloc(uint8_t, m_dwSize);
+ }
+ return m_pFileRead->ReadBlock(m_pBuffer, m_nStart, m_dwSize);
+}
+
+const uint8_t* CXML_DataStmAcc::GetBlockBuffer() {
+ return (const uint8_t*)m_pBuffer;
+}
+
+size_t CXML_DataStmAcc::GetBlockSize() {
+ return m_dwSize;
+}
+
+FX_FILESIZE CXML_DataStmAcc::GetBlockOffset() {
+ return m_nStart;
+}
+
+CXML_Parser::CXML_Parser()
+ : m_pDataAcc(nullptr),
+ m_bOwnedStream(FALSE),
+ m_nOffset(0),
+ m_bSaveSpaceChars(FALSE),
+ m_pBuffer(nullptr),
+ m_dwBufferSize(0),
+ m_nBufferOffset(0),
+ m_dwIndex(0) {}
+
CXML_Parser::~CXML_Parser() {
if (m_bOwnedStream) {
m_pDataAcc->Release();
}
}
+
FX_BOOL CXML_Parser::Init(uint8_t* pBuffer, size_t size) {
m_pDataAcc = new CXML_DataBufAcc(pBuffer, size);
return Init(TRUE);
@@ -764,6 +874,10 @@ bool CXML_AttrItem::Matches(const CFX_ByteString& space,
return (space.IsEmpty() || m_QSpaceName == space) && m_AttrName == name;
}
+CXML_AttrMap::CXML_AttrMap() {}
+
+CXML_AttrMap::~CXML_AttrMap() {}
+
const CFX_WideString* CXML_AttrMap::Lookup(const CFX_ByteString& space,
const CFX_ByteString& name) const {
if (!m_pMap)
diff --git a/core/fxcrt/include/fx_string.h b/core/fxcrt/include/fx_string.h
index 142f9372d0..b0a89fd06c 100644
--- a/core/fxcrt/include/fx_string.h
+++ b/core/fxcrt/include/fx_string.h
@@ -34,14 +34,13 @@ class CFX_ByteString {
public:
using CharType = FX_CHAR;
- CFX_ByteString() {}
- CFX_ByteString(const CFX_ByteString& other) : m_pData(other.m_pData) {}
- CFX_ByteString(CFX_ByteString&& other) { m_pData.Swap(other.m_pData); }
+ CFX_ByteString();
+ CFX_ByteString(const CFX_ByteString& other);
+ CFX_ByteString(CFX_ByteString&& other);
// Deliberately implicit to avoid calling on every string literal.
CFX_ByteString(char ch);
- CFX_ByteString(const FX_CHAR* ptr)
- : CFX_ByteString(ptr, ptr ? FXSYS_strlen(ptr) : 0) {}
+ CFX_ByteString(const FX_CHAR* ptr);
CFX_ByteString(const FX_CHAR* ptr, FX_STRSIZE len);
CFX_ByteString(const uint8_t* ptr, FX_STRSIZE len);
@@ -238,14 +237,13 @@ class CFX_WideString {
public:
using CharType = FX_WCHAR;
- CFX_WideString() {}
- CFX_WideString(const CFX_WideString& other) : m_pData(other.m_pData) {}
- CFX_WideString(CFX_WideString&& other) { m_pData.Swap(other.m_pData); }
+ CFX_WideString();
+ CFX_WideString(const CFX_WideString& other);
+ CFX_WideString(CFX_WideString&& other);
// Deliberately implicit to avoid calling on every string literal.
CFX_WideString(FX_WCHAR ch);
- CFX_WideString(const FX_WCHAR* ptr)
- : CFX_WideString(ptr, ptr ? FXSYS_wcslen(ptr) : 0) {}
+ CFX_WideString(const FX_WCHAR* ptr);
CFX_WideString(const FX_WCHAR* ptr, FX_STRSIZE len);
diff --git a/core/fxcrt/include/fx_ucd.h b/core/fxcrt/include/fx_ucd.h
index c2c4688628..eeecd39cbf 100644
--- a/core/fxcrt/include/fx_ucd.h
+++ b/core/fxcrt/include/fx_ucd.h
@@ -152,8 +152,7 @@ typedef CFX_ArrayTemplate<CFX_Char> CFX_CharArray;
class CFX_TxtChar : public CFX_Char {
public:
CFX_TxtChar()
- : CFX_Char(),
- m_dwStatus(0),
+ : m_dwStatus(0),
m_iBidiClass(0),
m_iBidiLevel(0),
m_iBidiPos(0),
@@ -169,17 +168,9 @@ class CFX_TxtChar : public CFX_Char {
typedef CFX_ArrayTemplate<CFX_TxtChar> CFX_TxtCharArray;
class CFX_RTFChar : public CFX_Char {
public:
- CFX_RTFChar()
- : CFX_Char(),
- m_dwStatus(0),
- m_iFontSize(0),
- m_iFontHeight(0),
- m_iBidiClass(0),
- m_iBidiLevel(0),
- m_iBidiPos(0),
- m_dwLayoutStyles(0),
- m_dwIdentity(0),
- m_pUserData(nullptr) {}
+ CFX_RTFChar();
+ CFX_RTFChar(const CFX_RTFChar& other);
+
uint32_t m_dwStatus;
int32_t m_iFontSize;
int32_t m_iFontHeight;
@@ -191,6 +182,20 @@ class CFX_RTFChar : public CFX_Char {
uint32_t m_dwIdentity;
IFX_Retainable* m_pUserData;
};
+
+inline CFX_RTFChar::CFX_RTFChar()
+ : m_dwStatus(0),
+ m_iFontSize(0),
+ m_iFontHeight(0),
+ m_iBidiClass(0),
+ m_iBidiLevel(0),
+ m_iBidiPos(0),
+ m_dwLayoutStyles(0),
+ m_dwIdentity(0),
+ m_pUserData(nullptr) {}
+
+inline CFX_RTFChar::CFX_RTFChar(const CFX_RTFChar& other) = default;
+
typedef CFX_ArrayTemplate<CFX_RTFChar> CFX_RTFCharArray;
#endif // PDF_ENABLE_XFA
diff --git a/core/fxcrt/include/fx_xml.h b/core/fxcrt/include/fx_xml.h
index 0e8c82b103..4db4998c32 100644
--- a/core/fxcrt/include/fx_xml.h
+++ b/core/fxcrt/include/fx_xml.h
@@ -23,13 +23,17 @@ class CXML_AttrItem {
class CXML_AttrMap {
public:
+ CXML_AttrMap();
+ ~CXML_AttrMap();
+
const CFX_WideString* Lookup(const CFX_ByteString& space,
const CFX_ByteString& name) const;
+ int GetSize() const;
+ CXML_AttrItem& GetAt(int index) const;
+
void SetAt(const CFX_ByteString& space,
const CFX_ByteString& name,
const CFX_WideString& value);
- int GetSize() const;
- CXML_AttrItem& GetAt(int index) const;
std::unique_ptr<std::vector<CXML_AttrItem>> m_pMap;
};
diff --git a/core/fxcrt/xml_int.h b/core/fxcrt/xml_int.h
index 6d3db4f525..121441b0c4 100644
--- a/core/fxcrt/xml_int.h
+++ b/core/fxcrt/xml_int.h
@@ -16,28 +16,18 @@ class CXML_Element;
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) {}
- ~CXML_DataBufAcc() override {}
+ CXML_DataBufAcc(const uint8_t* pBuffer, size_t size);
+ ~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;
- }
- if (m_dwCurPos < m_dwSize) {
- m_dwCurPos = m_dwSize;
- return TRUE;
- }
- return FALSE;
- }
- const uint8_t* GetBlockBuffer() override { return m_pBuffer; }
- size_t GetBlockSize() override { return m_dwSize; }
- FX_FILESIZE GetBlockOffset() override { return 0; }
+ void Release() override;
+ FX_BOOL IsEOF() override;
+ FX_FILESIZE GetPosition() override;
+ size_t ReadBlock(void* buffer, size_t size) override;
+ FX_BOOL ReadNextBlock(FX_BOOL bRestart = FALSE) override;
+ const uint8_t* GetBlockBuffer() override;
+ size_t GetBlockSize() override;
+ FX_FILESIZE GetBlockOffset() override;
protected:
const uint8_t* m_pBuffer;
@@ -47,40 +37,18 @@ class CXML_DataBufAcc : public IFX_BufferRead {
class CXML_DataStmAcc : public IFX_BufferRead {
public:
- explicit CXML_DataStmAcc(IFX_FileRead* pFileRead)
- : m_pFileRead(pFileRead), m_pBuffer(nullptr), m_nStart(0), m_dwSize(0) {
- ASSERT(m_pFileRead);
- }
- ~CXML_DataStmAcc() override { FX_Free(m_pBuffer); }
-
- void Release() override { delete this; }
- FX_BOOL IsEOF() override {
- return m_nStart + (FX_FILESIZE)m_dwSize >= m_pFileRead->GetSize();
- }
- 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;
- }
- FX_FILESIZE nLength = m_pFileRead->GetSize();
- m_nStart += (FX_FILESIZE)m_dwSize;
- if (m_nStart >= nLength) {
- return FALSE;
- }
- static const FX_FILESIZE FX_XMLDATASTREAM_BufferSize = 32 * 1024;
- m_dwSize = static_cast<size_t>(
- std::min(FX_XMLDATASTREAM_BufferSize, nLength - m_nStart));
- if (!m_pBuffer) {
- m_pBuffer = FX_Alloc(uint8_t, m_dwSize);
- }
- return m_pFileRead->ReadBlock(m_pBuffer, m_nStart, m_dwSize);
- }
- 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; }
+ explicit CXML_DataStmAcc(IFX_FileRead* pFileRead);
+ ~CXML_DataStmAcc() override;
+
+ // IFX_BufferRead
+ void Release() override;
+ FX_BOOL IsEOF() override;
+ FX_FILESIZE GetPosition() override;
+ size_t ReadBlock(void* buffer, size_t size) override;
+ FX_BOOL ReadNextBlock(FX_BOOL bRestart = FALSE) override;
+ const uint8_t* GetBlockBuffer() override;
+ size_t GetBlockSize() override;
+ FX_FILESIZE GetBlockOffset() override;
protected:
IFX_FileRead* m_pFileRead;
@@ -91,15 +59,9 @@ class CXML_DataStmAcc : public IFX_BufferRead {
class CXML_Parser {
public:
+ CXML_Parser();
~CXML_Parser();
- IFX_BufferRead* m_pDataAcc;
- FX_BOOL m_bOwnedStream;
- FX_FILESIZE m_nOffset;
- FX_BOOL m_bSaveSpaceChars;
- const uint8_t* m_pBuffer;
- size_t m_dwBufferSize;
- FX_FILESIZE m_nBufferOffset;
- size_t m_dwIndex;
+
FX_BOOL Init(uint8_t* pBuffer, size_t size);
FX_BOOL Init(IFX_FileRead* pFileRead);
FX_BOOL Init(IFX_BufferRead* pBuffer);
@@ -121,6 +83,15 @@ class CXML_Parser {
const CFX_WideStringC& content,
CXML_Element* pElement);
void InsertCDATASegment(CFX_UTF8Decoder& decoder, CXML_Element* pElement);
+
+ IFX_BufferRead* m_pDataAcc;
+ FX_BOOL m_bOwnedStream;
+ FX_FILESIZE m_nOffset;
+ FX_BOOL m_bSaveSpaceChars;
+ const uint8_t* m_pBuffer;
+ size_t m_dwBufferSize;
+ FX_FILESIZE m_nBufferOffset;
+ size_t m_dwIndex;
};
void FX_XML_SplitQualifiedName(const CFX_ByteStringC& bsFullName,
diff --git a/core/fxge/agg/fx_agg_driver.cpp b/core/fxge/agg/fx_agg_driver.cpp
index 554c79f349..f5d7cbbf4c 100644
--- a/core/fxge/agg/fx_agg_driver.cpp
+++ b/core/fxge/agg/fx_agg_driver.cpp
@@ -425,6 +425,88 @@ IFX_RenderDeviceDriver* IFX_RenderDeviceDriver::CreateFxgeDriver(
bGroupKnockout);
}
+IFX_RenderDeviceDriver::~IFX_RenderDeviceDriver() {}
+
+CFX_Matrix IFX_RenderDeviceDriver::GetCTM() const {
+ return CFX_Matrix();
+}
+
+FX_BOOL IFX_RenderDeviceDriver::StartRendering() {
+ return TRUE;
+}
+
+void IFX_RenderDeviceDriver::EndRendering() {}
+
+FX_BOOL IFX_RenderDeviceDriver::SetClip_PathStroke(
+ const CFX_PathData* pPathData,
+ const CFX_Matrix* pObject2Device,
+ const CFX_GraphStateData* pGraphState) {
+ return FALSE;
+}
+
+FX_BOOL IFX_RenderDeviceDriver::SetPixel(int x, int y, uint32_t color) {
+ return FALSE;
+}
+
+FX_BOOL IFX_RenderDeviceDriver::FillRectWithBlend(const FX_RECT* pRect,
+ uint32_t fill_color,
+ int blend_type) {
+ return FALSE;
+}
+
+FX_BOOL IFX_RenderDeviceDriver::DrawCosmeticLine(FX_FLOAT x1,
+ FX_FLOAT y1,
+ FX_FLOAT x2,
+ FX_FLOAT y2,
+ uint32_t color,
+ int blend_type) {
+ return FALSE;
+}
+
+FX_BOOL IFX_RenderDeviceDriver::GetDIBits(CFX_DIBitmap* pBitmap,
+ int left,
+ int top) {
+ return FALSE;
+}
+CFX_DIBitmap* IFX_RenderDeviceDriver::GetBackDrop() {
+ return nullptr;
+}
+
+FX_BOOL IFX_RenderDeviceDriver::ContinueDIBits(void* handle,
+ IFX_Pause* pPause) {
+ return FALSE;
+}
+
+void IFX_RenderDeviceDriver::CancelDIBits(void* handle) {}
+
+FX_BOOL IFX_RenderDeviceDriver::DrawDeviceText(int nChars,
+ const FXTEXT_CHARPOS* pCharPos,
+ CFX_Font* pFont,
+ CFX_FontCache* pCache,
+ const CFX_Matrix* pObject2Device,
+ FX_FLOAT font_size,
+ uint32_t color) {
+ return FALSE;
+}
+
+void* IFX_RenderDeviceDriver::GetPlatformSurface() const {
+ return nullptr;
+}
+
+int IFX_RenderDeviceDriver::GetDriverType() const {
+ return 0;
+}
+
+void IFX_RenderDeviceDriver::ClearDriver() {}
+
+FX_BOOL IFX_RenderDeviceDriver::DrawShading(const CPDF_ShadingPattern* pPattern,
+ const CFX_Matrix* pMatrix,
+ const FX_RECT& clip_rect,
+ int alpha,
+ FX_BOOL bAlphaMode) {
+ return false;
+}
+
CFX_AggDeviceDriver::CFX_AggDeviceDriver(CFX_DIBitmap* pBitmap,
FX_BOOL bRgbByteOrder,
CFX_DIBitmap* pOriDevice,
@@ -452,6 +534,10 @@ uint8_t* CFX_AggDeviceDriver::GetBuffer() const {
return m_pBitmap->GetBuffer();
}
+const CFX_DIBitmap* CFX_AggDeviceDriver::GetBitmap() const {
+ return m_pBitmap;
+}
+
#if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_
void CFX_AggDeviceDriver::InitPlatform() {}
@@ -1435,6 +1521,10 @@ class CFX_Renderer {
}
};
+int CFX_AggDeviceDriver::GetDriverType() const {
+ return 1;
+}
+
FX_BOOL CFX_AggDeviceDriver::RenderRasterizer(
agg::rasterizer_scanline_aa& rasterizer,
uint32_t color,
@@ -1645,6 +1735,10 @@ FX_BOOL CFX_AggDeviceDriver::GetDIBits(CFX_DIBitmap* pBitmap,
return bRet;
}
+CFX_DIBitmap* CFX_AggDeviceDriver::GetBackDrop() {
+ return m_pOriDevice;
+}
+
FX_BOOL CFX_AggDeviceDriver::SetDIBits(const CFX_DIBSource* pBitmap,
uint32_t argb,
const FX_RECT* pSrcRect,
diff --git a/core/fxge/agg/fx_agg_driver.h b/core/fxge/agg/fx_agg_driver.h
index 48d6fae87f..7c2e98047f 100644
--- a/core/fxge/agg/fx_agg_driver.h
+++ b/core/fxge/agg/fx_agg_driver.h
@@ -59,7 +59,7 @@ class CFX_AggDeviceDriver : public IFX_RenderDeviceDriver {
int blend_type) override;
FX_BOOL GetClipBox(FX_RECT* pRect) override;
FX_BOOL GetDIBits(CFX_DIBitmap* pBitmap, int left, int top) override;
- CFX_DIBitmap* GetBackDrop() override { return m_pOriDevice; }
+ CFX_DIBitmap* GetBackDrop() override;
FX_BOOL SetDIBits(const CFX_DIBSource* pBitmap,
uint32_t color,
const FX_RECT* pSrcRect,
@@ -91,7 +91,7 @@ class CFX_AggDeviceDriver : public IFX_RenderDeviceDriver {
const CFX_Matrix* pObject2Device,
FX_FLOAT font_size,
uint32_t color) override;
- int GetDriverType() const override { return 1; }
+ int GetDriverType() const override;
FX_BOOL RenderRasterizer(agg::rasterizer_scanline_aa& rasterizer,
uint32_t color,
@@ -103,7 +103,7 @@ class CFX_AggDeviceDriver : public IFX_RenderDeviceDriver {
void SetClipMask(agg::rasterizer_scanline_aa& rasterizer);
virtual uint8_t* GetBuffer() const;
- const CFX_DIBitmap* GetBitmap() const { return m_pBitmap; }
+ const CFX_DIBitmap* GetBitmap() const;
private:
CFX_DIBitmap* m_pBitmap;
diff --git a/core/fxge/ge/fx_ge_device.cpp b/core/fxge/ge/fx_ge_device.cpp
index f1f7dc021d..adf68a8749 100644
--- a/core/fxge/ge/fx_ge_device.cpp
+++ b/core/fxge/ge/fx_ge_device.cpp
@@ -6,18 +6,25 @@
#include "core/fxge/include/fx_ge.h"
-CFX_RenderDevice::CFX_RenderDevice() {
- m_pDeviceDriver = nullptr;
- m_pBitmap = nullptr;
-}
+CFX_RenderDevice::CFX_RenderDevice()
+ : m_pBitmap(nullptr),
+ m_Width(0),
+ m_Height(0),
+ m_bpp(0),
+ m_RenderCaps(0),
+ m_DeviceClass(0),
+ m_pDeviceDriver(nullptr) {}
+
CFX_RenderDevice::~CFX_RenderDevice() {
delete m_pDeviceDriver;
}
+
void CFX_RenderDevice::SetDeviceDriver(IFX_RenderDeviceDriver* pDriver) {
delete m_pDeviceDriver;
m_pDeviceDriver = pDriver;
InitDeviceInfo();
}
+
void CFX_RenderDevice::InitDeviceInfo() {
m_Width = m_pDeviceDriver->GetDeviceCaps(FXDC_PIXEL_WIDTH);
m_Height = m_pDeviceDriver->GetDeviceCaps(FXDC_PIXEL_HEIGHT);
@@ -31,12 +38,15 @@ void CFX_RenderDevice::InitDeviceInfo() {
m_ClipBox.bottom = m_Height;
}
}
+
FX_BOOL CFX_RenderDevice::StartRendering() {
return m_pDeviceDriver->StartRendering();
}
+
void CFX_RenderDevice::EndRendering() {
m_pDeviceDriver->EndRendering();
}
+
void CFX_RenderDevice::SaveState() {
m_pDeviceDriver->SaveState();
}
@@ -52,6 +62,7 @@ int CFX_RenderDevice::GetDeviceCaps(int caps_id) const {
CFX_Matrix CFX_RenderDevice::GetCTM() const {
return m_pDeviceDriver->GetCTM();
}
+
FX_BOOL CFX_RenderDevice::CreateCompatibleBitmap(CFX_DIBitmap* pDIB,
int width,
int height) const {
@@ -72,6 +83,7 @@ FX_BOOL CFX_RenderDevice::CreateCompatibleBitmap(CFX_DIBitmap* pDIB,
width, height, m_RenderCaps & FXRC_ALPHA_OUTPUT ? FXDIB_Argb : FXDIB_Rgb);
#endif
}
+
FX_BOOL CFX_RenderDevice::SetClip_PathFill(const CFX_PathData* pPathData,
const CFX_Matrix* pObject2Device,
int fill_mode) {
@@ -82,6 +94,7 @@ FX_BOOL CFX_RenderDevice::SetClip_PathFill(const CFX_PathData* pPathData,
UpdateClipBox();
return TRUE;
}
+
FX_BOOL CFX_RenderDevice::SetClip_PathStroke(
const CFX_PathData* pPathData,
const CFX_Matrix* pObject2Device,
@@ -93,6 +106,7 @@ FX_BOOL CFX_RenderDevice::SetClip_PathStroke(
UpdateClipBox();
return TRUE;
}
+
FX_BOOL CFX_RenderDevice::SetClip_Rect(const FX_RECT& rect) {
CFX_PathData path;
path.AppendRect(rect.left, rect.bottom, rect.right, rect.top);
@@ -102,6 +116,7 @@ FX_BOOL CFX_RenderDevice::SetClip_Rect(const FX_RECT& rect) {
UpdateClipBox();
return TRUE;
}
+
void CFX_RenderDevice::UpdateClipBox() {
if (m_pDeviceDriver->GetClipBox(&m_ClipBox)) {
return;
@@ -421,6 +436,16 @@ FX_BOOL CFX_RenderDevice::SetBitMask(const CFX_DIBSource* pBitmap,
FXDIB_BLEND_NORMAL);
}
+FX_BOOL CFX_RenderDevice::StretchBitMask(const CFX_DIBSource* pBitmap,
+ int left,
+ int top,
+ int dest_width,
+ int dest_height,
+ uint32_t color) {
+ return StretchBitMaskWithFlags(pBitmap, left, top, dest_width, dest_height,
+ color, 0);
+}
+
FX_BOOL CFX_RenderDevice::StretchBitMaskWithFlags(const CFX_DIBSource* pBitmap,
int left,
int top,
diff --git a/core/fxge/ge/fx_ge_fontmap.cpp b/core/fxge/ge/fx_ge_fontmap.cpp
index fa53898ecc..81e3137913 100644
--- a/core/fxge/ge/fx_ge_fontmap.cpp
+++ b/core/fxge/ge/fx_ge_fontmap.cpp
@@ -9,8 +9,9 @@
#include <utility>
#include <vector>
+#include "core/fxge/include/fx_font.h"
+
#include "core/fxge/fontdata/chromefontdata/chromefontdata.h"
-#include "core/fxge/ge/fx_text_int.h"
#include "core/fxge/include/fx_freetype.h"
#include "core/fxge/include/fx_ge.h"
#include "third_party/base/stl_util.h"
@@ -1358,7 +1359,21 @@ std::unique_ptr<IFX_SystemFontInfo> IFX_SystemFontInfo::CreateDefault(
}
#endif
+CFX_FontFaceInfo::CFX_FontFaceInfo(CFX_ByteString filePath,
+ CFX_ByteString faceName,
+ CFX_ByteString fontTables,
+ uint32_t fontOffset,
+ uint32_t fileSize)
+ : m_FilePath(filePath),
+ m_FaceName(faceName),
+ m_FontTables(fontTables),
+ m_FontOffset(fontOffset),
+ m_FileSize(fileSize),
+ m_Styles(0),
+ m_Charsets(0) {}
+
CFX_FolderFontInfo::CFX_FolderFontInfo() {}
+
CFX_FolderFontInfo::~CFX_FolderFontInfo() {
for (const auto& pair : m_FontList) {
delete pair.second;
diff --git a/core/fxge/ge/fx_ge_path.cpp b/core/fxge/ge/fx_ge_path.cpp
index 6eb41d3094..468d80eeec 100644
--- a/core/fxge/ge/fx_ge_path.cpp
+++ b/core/fxge/ge/fx_ge_path.cpp
@@ -8,27 +8,25 @@
#include "core/fxge/include/fx_ge.h"
#include "third_party/base/numerics/safe_math.h"
-CFX_ClipRgn::CFX_ClipRgn(int width, int height) {
- m_Type = RectI;
- m_Box.left = m_Box.top = 0;
- m_Box.right = width;
- m_Box.bottom = height;
-}
-CFX_ClipRgn::CFX_ClipRgn(const FX_RECT& rect) {
- m_Type = RectI;
- m_Box = rect;
-}
+CFX_ClipRgn::CFX_ClipRgn(int width, int height)
+ : m_Type(RectI), m_Box(0, 0, width, height) {}
+
+CFX_ClipRgn::CFX_ClipRgn(const FX_RECT& rect) : m_Type(RectI), m_Box(rect) {}
+
CFX_ClipRgn::CFX_ClipRgn(const CFX_ClipRgn& src) {
m_Type = src.m_Type;
m_Box = src.m_Box;
m_Mask = src.m_Mask;
}
+
CFX_ClipRgn::~CFX_ClipRgn() {}
+
void CFX_ClipRgn::Reset(const FX_RECT& rect) {
m_Type = RectI;
m_Box = rect;
m_Mask.SetNull();
}
+
void CFX_ClipRgn::IntersectRect(const FX_RECT& rect) {
if (m_Type == RectI) {
m_Box.Intersect(rect);
@@ -39,6 +37,7 @@ void CFX_ClipRgn::IntersectRect(const FX_RECT& rect) {
return;
}
}
+
void CFX_ClipRgn::IntersectMaskRect(FX_RECT rect,
FX_RECT mask_rect,
CFX_DIBitmapRef Mask) {
@@ -69,6 +68,7 @@ void CFX_ClipRgn::IntersectMaskRect(FX_RECT rect,
}
}
}
+
void CFX_ClipRgn::IntersectMaskF(int left, int top, CFX_DIBitmapRef Mask) {
const CFX_DIBitmap* mask_dib = Mask.GetObject();
ASSERT(mask_dib->GetFormat() == FXDIB_8bppMask);
@@ -112,13 +112,14 @@ void CFX_ClipRgn::IntersectMaskF(int left, int top, CFX_DIBitmapRef Mask) {
}
ASSERT(FALSE);
}
-CFX_PathData::CFX_PathData() {
- m_PointCount = m_AllocCount = 0;
- m_pPoints = nullptr;
-}
+
+CFX_PathData::CFX_PathData()
+ : m_PointCount(0), m_pPoints(nullptr), m_AllocCount(0) {}
+
CFX_PathData::~CFX_PathData() {
FX_Free(m_pPoints);
}
+
void CFX_PathData::SetPointCount(int nPoints) {
m_PointCount = nPoints;
if (m_AllocCount < nPoints) {
@@ -127,6 +128,7 @@ void CFX_PathData::SetPointCount(int nPoints) {
m_AllocCount = nPoints;
}
}
+
void CFX_PathData::AllocPointCount(int nPoints) {
if (m_AllocCount < nPoints) {
FX_PATHPOINT* pNewBuf = FX_Alloc(FX_PATHPOINT, nPoints);
@@ -138,17 +140,20 @@ void CFX_PathData::AllocPointCount(int nPoints) {
m_AllocCount = nPoints;
}
}
+
CFX_PathData::CFX_PathData(const CFX_PathData& src) {
m_PointCount = m_AllocCount = src.m_PointCount;
m_pPoints = FX_Alloc(FX_PATHPOINT, src.m_PointCount);
FXSYS_memcpy(m_pPoints, src.m_pPoints, sizeof(FX_PATHPOINT) * m_PointCount);
}
+
void CFX_PathData::TrimPoints(int nPoints) {
if (m_PointCount <= nPoints) {
return;
}
SetPointCount(nPoints);
}
+
void CFX_PathData::AddPointCount(int addPoints) {
pdfium::base::CheckedNumeric<int> safe_new_count = m_PointCount;
safe_new_count += addPoints;
@@ -156,6 +161,7 @@ void CFX_PathData::AddPointCount(int addPoints) {
AllocPointCount(new_count);
m_PointCount = new_count;
}
+
void CFX_PathData::Append(const CFX_PathData* pSrc, const CFX_Matrix* pMatrix) {
int old_count = m_PointCount;
AddPointCount(pSrc->m_PointCount);
@@ -168,12 +174,14 @@ void CFX_PathData::Append(const CFX_PathData* pSrc, const CFX_Matrix* pMatrix) {
}
}
}
+
void CFX_PathData::SetPoint(int index, FX_FLOAT x, FX_FLOAT y, int flag) {
ASSERT(index < m_PointCount);
m_pPoints[index].m_PointX = x;
m_pPoints[index].m_PointY = y;
m_pPoints[index].m_Flag = flag;
}
+
void CFX_PathData::AppendRect(FX_FLOAT left,
FX_FLOAT bottom,
FX_FLOAT right,
@@ -189,6 +197,7 @@ void CFX_PathData::AppendRect(FX_FLOAT left,
pPoints[1].m_Flag = pPoints[2].m_Flag = pPoints[3].m_Flag = FXPT_LINETO;
pPoints[4].m_Flag = FXPT_LINETO | FXPT_CLOSEFIGURE;
}
+
CFX_FloatRect CFX_PathData::GetBoundingBox() const {
CFX_FloatRect rect;
if (m_PointCount) {
@@ -199,6 +208,7 @@ CFX_FloatRect CFX_PathData::GetBoundingBox() const {
}
return rect;
}
+
static void _UpdateLineEndPoints(CFX_FloatRect& rect,
FX_FLOAT start_x,
FX_FLOAT start_y,
@@ -242,6 +252,7 @@ static void _UpdateLineEndPoints(CFX_FloatRect& rect,
rect.UpdateRect(mx - dx1, my + dy1);
rect.UpdateRect(mx + dx1, my - dy1);
}
+
static void _UpdateLineJoinPoints(CFX_FloatRect& rect,
FX_FLOAT start_x,
FX_FLOAT start_y,
@@ -334,6 +345,7 @@ static void _UpdateLineJoinPoints(CFX_FloatRect& rect,
FX_FLOAT join_y = (start_k * join_x) + start_outside_c;
rect.UpdateRect(join_x, join_y);
}
+
CFX_FloatRect CFX_PathData::GetBoundingBox(FX_FLOAT line_width,
FX_FLOAT miter_limit) const {
CFX_FloatRect rect(100000 * 1.0f, 100000 * 1.0f, -100000 * 1.0f,
@@ -384,6 +396,7 @@ CFX_FloatRect CFX_PathData::GetBoundingBox(FX_FLOAT line_width,
}
return rect;
}
+
void CFX_PathData::Transform(const CFX_Matrix* pMatrix) {
if (!pMatrix) {
return;
@@ -392,6 +405,7 @@ void CFX_PathData::Transform(const CFX_Matrix* pMatrix) {
pMatrix->Transform(m_pPoints[i].m_PointX, m_pPoints[i].m_PointY);
}
}
+
FX_BOOL CFX_PathData::GetZeroAreaPath(CFX_PathData& NewPath,
CFX_Matrix* pMatrix,
FX_BOOL& bThin,
@@ -536,6 +550,7 @@ FX_BOOL CFX_PathData::GetZeroAreaPath(CFX_PathData& NewPath,
}
return TRUE;
}
+
FX_BOOL CFX_PathData::IsRect() const {
if (m_PointCount != 5 && m_PointCount != 4) {
return FALSE;
@@ -563,6 +578,7 @@ FX_BOOL CFX_PathData::IsRect() const {
}
return m_PointCount == 5 || (m_pPoints[3].m_Flag & FXPT_CLOSEFIGURE);
}
+
FX_BOOL CFX_PathData::IsRect(const CFX_Matrix* pMatrix,
CFX_FloatRect* pRect) const {
if (!pMatrix) {
@@ -613,23 +629,26 @@ FX_BOOL CFX_PathData::IsRect(const CFX_Matrix* pMatrix,
}
return TRUE;
}
+
void CFX_PathData::Copy(const CFX_PathData& src) {
SetPointCount(src.m_PointCount);
FXSYS_memcpy(m_pPoints, src.m_pPoints, sizeof(FX_PATHPOINT) * m_PointCount);
}
-CFX_GraphStateData::CFX_GraphStateData() {
- m_LineCap = LineCapButt;
- m_DashCount = 0;
- m_DashArray = nullptr;
- m_DashPhase = 0;
- m_LineJoin = LineJoinMiter;
- m_MiterLimit = 10 * 1.0f;
- m_LineWidth = 1.0f;
-}
+
+CFX_GraphStateData::CFX_GraphStateData()
+ : m_LineCap(LineCapButt),
+ m_DashCount(0),
+ m_DashArray(nullptr),
+ m_DashPhase(0),
+ m_LineJoin(LineJoinMiter),
+ m_MiterLimit(10 * 1.0f),
+ m_LineWidth(1.0f) {}
+
CFX_GraphStateData::CFX_GraphStateData(const CFX_GraphStateData& src) {
m_DashArray = nullptr;
Copy(src);
}
+
void CFX_GraphStateData::Copy(const CFX_GraphStateData& src) {
m_LineCap = src.m_LineCap;
m_DashCount = src.m_DashCount;
@@ -644,9 +663,11 @@ void CFX_GraphStateData::Copy(const CFX_GraphStateData& src) {
FXSYS_memcpy(m_DashArray, src.m_DashArray, m_DashCount * sizeof(FX_FLOAT));
}
}
+
CFX_GraphStateData::~CFX_GraphStateData() {
FX_Free(m_DashArray);
}
+
void CFX_GraphStateData::SetDashCount(int count) {
FX_Free(m_DashArray);
m_DashArray = nullptr;
diff --git a/core/fxge/ge/fx_ge_text.cpp b/core/fxge/ge/fx_ge_text.cpp
index 6b456c2eaa..cf349eb9c0 100644
--- a/core/fxge/ge/fx_ge_text.cpp
+++ b/core/fxge/ge/fx_ge_text.cpp
@@ -933,12 +933,16 @@ const CFX_GlyphBitmap* CFX_FaceCache::LoadGlyphBitmap(CFX_Font* pFont,
bFontStyle, dest_width, anti_alias);
#endif
}
+
+CFX_SizeGlyphCache::CFX_SizeGlyphCache() {}
+
CFX_SizeGlyphCache::~CFX_SizeGlyphCache() {
for (const auto& pair : m_GlyphMap) {
delete pair.second;
}
m_GlyphMap.clear();
}
+
#define CONTRAST_RAMP_STEP 1
void CFX_Font::AdjustMMParams(int glyph_index, int dest_width, int weight) {
FXFT_MM_Var pMasters = nullptr;
diff --git a/core/fxge/ge/fx_text_int.h b/core/fxge/ge/fx_text_int.h
index 2ca23217c7..87a9b3eced 100644
--- a/core/fxge/ge/fx_text_int.h
+++ b/core/fxge/ge/fx_text_int.h
@@ -17,68 +17,12 @@ struct _CFX_UniqueKeyGen {
FX_CHAR m_Key[128];
int m_KeyLen;
};
+
class CFX_SizeGlyphCache {
public:
- CFX_SizeGlyphCache() {}
+ CFX_SizeGlyphCache();
~CFX_SizeGlyphCache();
std::map<uint32_t, CFX_GlyphBitmap*> m_GlyphMap;
};
-class CTTFontDesc {
- public:
- CTTFontDesc() {
- m_Type = 0;
- m_pFontData = nullptr;
- m_RefCount = 0;
- }
- ~CTTFontDesc();
- // ret < 0, releaseface not appropriate for this object.
- // ret == 0, object released
- // ret > 0, object still alive, other referrers.
- int ReleaseFace(FXFT_Face face);
- int m_Type;
- union {
- struct {
- FX_BOOL m_bItalic;
- FX_BOOL m_bBold;
- FXFT_Face m_pFace;
- } m_SingleFace;
- struct {
- FXFT_Face m_pFaces[16];
- } m_TTCFace;
- };
- uint8_t* m_pFontData;
- int m_RefCount;
-};
-
-#define CHARSET_FLAG_ANSI 1
-#define CHARSET_FLAG_SYMBOL 2
-#define CHARSET_FLAG_SHIFTJIS 4
-#define CHARSET_FLAG_BIG5 8
-#define CHARSET_FLAG_GB 16
-#define CHARSET_FLAG_KOREAN 32
-
-class CFX_FontFaceInfo {
- public:
- CFX_FontFaceInfo(CFX_ByteString filePath,
- CFX_ByteString faceName,
- CFX_ByteString fontTables,
- uint32_t fontOffset,
- uint32_t fileSize)
- : m_FilePath(filePath),
- m_FaceName(faceName),
- m_FontTables(fontTables),
- m_FontOffset(fontOffset),
- m_FileSize(fileSize),
- m_Styles(0),
- m_Charsets(0) {}
-
- const CFX_ByteString m_FilePath;
- const CFX_ByteString m_FaceName;
- const CFX_ByteString m_FontTables;
- const uint32_t m_FontOffset;
- const uint32_t m_FileSize;
- uint32_t m_Styles;
- uint32_t m_Charsets;
-};
#endif // CORE_FXGE_GE_FX_TEXT_INT_H_
diff --git a/core/fxge/include/fx_font.h b/core/fxge/include/fx_font.h
index b38ecaed33..17adc7ac9c 100644
--- a/core/fxge/include/fx_font.h
+++ b/core/fxge/include/fx_font.h
@@ -19,7 +19,6 @@ typedef struct FT_FaceRec_* FXFT_Face;
typedef void* FXFT_Library;
class CFX_FaceCache;
-class CFX_FontFaceInfo;
class CFX_FontMapper;
class CFX_PathData;
class CFX_SizeGlyphCache;
@@ -65,6 +64,13 @@ using CFX_TypeFace = SkTypeface;
#define FXFONT_FW_NORMAL 400
#define FXFONT_FW_BOLD 700
+#define CHARSET_FLAG_ANSI 1
+#define CHARSET_FLAG_SYMBOL 2
+#define CHARSET_FLAG_SHIFTJIS 4
+#define CHARSET_FLAG_BIG5 8
+#define CHARSET_FLAG_GB 16
+#define CHARSET_FLAG_KOREAN 32
+
class CFX_Font {
public:
CFX_Font();
@@ -379,6 +385,50 @@ class IFX_SystemFontInfo {
virtual void* RetainFont(void* hFont);
};
+class CTTFontDesc {
+ public:
+ CTTFontDesc() {
+ m_Type = 0;
+ m_pFontData = nullptr;
+ m_RefCount = 0;
+ }
+ ~CTTFontDesc();
+ // ret < 0, releaseface not appropriate for this object.
+ // ret == 0, object released
+ // ret > 0, object still alive, other referrers.
+ int ReleaseFace(FXFT_Face face);
+ int m_Type;
+ union {
+ struct {
+ FX_BOOL m_bItalic;
+ FX_BOOL m_bBold;
+ FXFT_Face m_pFace;
+ } m_SingleFace;
+ struct {
+ FXFT_Face m_pFaces[16];
+ } m_TTCFace;
+ };
+ uint8_t* m_pFontData;
+ int m_RefCount;
+};
+
+class CFX_FontFaceInfo {
+ public:
+ CFX_FontFaceInfo(CFX_ByteString filePath,
+ CFX_ByteString faceName,
+ CFX_ByteString fontTables,
+ uint32_t fontOffset,
+ uint32_t fileSize);
+
+ const CFX_ByteString m_FilePath;
+ const CFX_ByteString m_FaceName;
+ const CFX_ByteString m_FontTables;
+ const uint32_t m_FontOffset;
+ const uint32_t m_FileSize;
+ uint32_t m_Styles;
+ uint32_t m_Charsets;
+};
+
class CFX_FolderFontInfo : public IFX_SystemFontInfo {
public:
CFX_FolderFontInfo();
diff --git a/core/fxge/include/fx_ge.h b/core/fxge/include/fx_ge.h
index b2e2b455e4..9114b47008 100644
--- a/core/fxge/include/fx_ge.h
+++ b/core/fxge/include/fx_ge.h
@@ -36,9 +36,10 @@ class CFX_GEModule {
m_pCodecModule = pCodecModule;
}
CCodec_ModuleMgr* GetCodecModule() { return m_pCodecModule; }
- FXFT_Library m_FTLibrary;
void* GetPlatformData() { return m_pPlatformData; }
+ FXFT_Library m_FTLibrary;
+
protected:
explicit CFX_GEModule(const char** pUserFontPaths);
~CFX_GEModule();
@@ -71,16 +72,18 @@ struct FX_PATHPOINT {
class CFX_ClipRgn {
public:
+ enum ClipType { RectI, MaskF };
+
CFX_ClipRgn(int device_width, int device_height);
explicit CFX_ClipRgn(const FX_RECT& rect);
CFX_ClipRgn(const CFX_ClipRgn& src);
~CFX_ClipRgn();
- enum ClipType { RectI, MaskF };
- void Reset(const FX_RECT& rect);
ClipType GetType() const { return m_Type; }
const FX_RECT& GetBox() const { return m_Box; }
CFX_DIBitmapRef GetMask() const { return m_Mask; }
+
+ void Reset(const FX_RECT& rect);
void IntersectRect(const FX_RECT& rect);
void IntersectMaskF(int left, int top, CFX_DIBitmapRef Mask);
@@ -103,6 +106,7 @@ class CFX_PathData {
FX_FLOAT GetPointX(int index) const { return m_pPoints[index].m_PointX; }
FX_FLOAT GetPointY(int index) const { return m_pPoints[index].m_PointY; }
FX_PATHPOINT* GetPoints() const { return m_pPoints; }
+
void SetPointCount(int nPoints);
void AllocPointCount(int nPoints);
void AddPointCount(int addPoints);
@@ -131,6 +135,8 @@ class CFX_PathData {
class CFX_GraphStateData {
public:
+ enum LineCap { LineCapButt = 0, LineCapRound = 1, LineCapSquare = 2 };
+
CFX_GraphStateData();
CFX_GraphStateData(const CFX_GraphStateData& src);
~CFX_GraphStateData();
@@ -138,7 +144,6 @@ class CFX_GraphStateData {
void Copy(const CFX_GraphStateData& src);
void SetDashCount(int count);
- enum LineCap { LineCapButt = 0, LineCapRound = 1, LineCapSquare = 2 };
LineCap m_LineCap;
int m_DashCount;
FX_FLOAT* m_DashArray;
@@ -216,6 +221,7 @@ class CFX_RenderDevice {
void EndRendering();
void SaveState();
void RestoreState(bool bKeepSaved);
+
int GetWidth() const { return m_Width; }
int GetHeight() const { return m_Height; }
int GetDeviceClass() const { return m_DeviceClass; }
@@ -308,10 +314,7 @@ class CFX_RenderDevice {
int top,
int dest_width,
int dest_height,
- uint32_t color) {
- return StretchBitMaskWithFlags(pBitmap, left, top, dest_width, dest_height,
- color, 0);
- }
+ uint32_t color);
FX_BOOL StretchBitMaskWithFlags(const CFX_DIBSource* pBitmap,
int left,
int top,
@@ -421,35 +424,29 @@ class CFX_FxgeDevice : public CFX_RenderDevice {
class IFX_RenderDeviceDriver {
public:
+ virtual ~IFX_RenderDeviceDriver();
+
static IFX_RenderDeviceDriver* CreateFxgeDriver(CFX_DIBitmap* pBitmap,
FX_BOOL bRgbByteOrder,
CFX_DIBitmap* pOriDevice,
FX_BOOL bGroupKnockout);
- virtual ~IFX_RenderDeviceDriver() {}
virtual int GetDeviceCaps(int caps_id) = 0;
- virtual CFX_Matrix GetCTM() const { return CFX_Matrix(); }
-
- virtual FX_BOOL StartRendering() { return TRUE; }
-
- virtual void EndRendering() {}
+ virtual CFX_Matrix GetCTM() const;
+ virtual FX_BOOL StartRendering();
+ virtual void EndRendering();
virtual void SaveState() = 0;
-
virtual void RestoreState(bool bKeepSaved) = 0;
virtual FX_BOOL SetClip_PathFill(const CFX_PathData* pPathData,
const CFX_Matrix* pObject2Device,
int fill_mode) = 0;
-
virtual FX_BOOL SetClip_PathStroke(const CFX_PathData* pPathData,
const CFX_Matrix* pObject2Device,
- const CFX_GraphStateData* pGraphState) {
- return FALSE;
- }
-
+ const CFX_GraphStateData* pGraphState);
virtual FX_BOOL DrawPath(const CFX_PathData* pPathData,
const CFX_Matrix* pObject2Device,
const CFX_GraphStateData* pGraphState,
@@ -457,38 +454,26 @@ class IFX_RenderDeviceDriver {
uint32_t stroke_color,
int fill_mode,
int blend_type) = 0;
-
- virtual FX_BOOL SetPixel(int x, int y, uint32_t color) { return FALSE; }
-
+ virtual FX_BOOL SetPixel(int x, int y, uint32_t color);
virtual FX_BOOL FillRectWithBlend(const FX_RECT* pRect,
uint32_t fill_color,
- int blend_type) {
- return FALSE;
- }
-
+ int blend_type);
virtual FX_BOOL DrawCosmeticLine(FX_FLOAT x1,
FX_FLOAT y1,
FX_FLOAT x2,
FX_FLOAT y2,
uint32_t color,
- int blend_type) {
- return FALSE;
- }
+ int blend_type);
virtual FX_BOOL GetClipBox(FX_RECT* pRect) = 0;
-
- virtual FX_BOOL GetDIBits(CFX_DIBitmap* pBitmap, int left, int top) {
- return FALSE;
- }
- virtual CFX_DIBitmap* GetBackDrop() { return nullptr; }
-
+ virtual FX_BOOL GetDIBits(CFX_DIBitmap* pBitmap, int left, int top);
+ virtual CFX_DIBitmap* GetBackDrop();
virtual FX_BOOL SetDIBits(const CFX_DIBSource* pBitmap,
uint32_t color,
const FX_RECT* pSrcRect,
int dest_left,
int dest_top,
int blend_type) = 0;
-
virtual FX_BOOL StretchDIBits(const CFX_DIBSource* pBitmap,
uint32_t color,
int dest_left,
@@ -498,7 +483,6 @@ class IFX_RenderDeviceDriver {
const FX_RECT* pClipRect,
uint32_t flags,
int blend_type) = 0;
-
virtual FX_BOOL StartDIBits(const CFX_DIBSource* pBitmap,
int bitmap_alpha,
uint32_t color,
@@ -506,34 +490,23 @@ class IFX_RenderDeviceDriver {
uint32_t flags,
void*& handle,
int blend_type) = 0;
-
- virtual FX_BOOL ContinueDIBits(void* handle, IFX_Pause* pPause) {
- return FALSE;
- }
-
- virtual void CancelDIBits(void* handle) {}
-
+ 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_Matrix* pObject2Device,
FX_FLOAT font_size,
- uint32_t color) {
- return FALSE;
- }
-
- virtual void* GetPlatformSurface() const { return nullptr; }
- virtual int GetDriverType() const { return 0; }
- virtual void ClearDriver() {}
-
+ uint32_t color);
+ virtual void* GetPlatformSurface() const;
+ virtual int GetDriverType() const;
+ virtual void ClearDriver();
virtual FX_BOOL DrawShading(const CPDF_ShadingPattern* pPattern,
const CFX_Matrix* pMatrix,
const FX_RECT& clip_rect,
int alpha,
- FX_BOOL bAlphaMode) {
- return false;
- }
+ FX_BOOL bAlphaMode);
};
#endif // CORE_FXGE_INCLUDE_FX_GE_H_
diff --git a/core/fxge/include/fx_ge_win32.h b/core/fxge/include/fx_ge_win32.h
index e7207a5f70..703093d92f 100644
--- a/core/fxge/include/fx_ge_win32.h
+++ b/core/fxge/include/fx_ge_win32.h
@@ -25,42 +25,29 @@ typedef struct WINDIB_Open_Args_ {
class CFX_WindowsDIB : public CFX_DIBitmap {
public:
- static CFX_ByteString GetBitmapInfo(const CFX_DIBitmap* pBitmap);
+ CFX_WindowsDIB(HDC hDC, int width, int height);
+ ~CFX_WindowsDIB() override;
+ static CFX_ByteString GetBitmapInfo(const CFX_DIBitmap* pBitmap);
static CFX_DIBitmap* LoadFromBuf(BITMAPINFO* pbmi, void* pData);
-
static HBITMAP GetDDBitmap(const CFX_DIBitmap* pBitmap, HDC hDC);
-
static CFX_DIBitmap* LoadFromDDB(HDC hDC,
HBITMAP hBitmap,
uint32_t* pPalette = nullptr,
uint32_t size = 256);
-
static CFX_DIBitmap* LoadFromFile(const FX_WCHAR* filename);
-
- static CFX_DIBitmap* LoadFromFile(const FX_CHAR* filename) {
- return LoadFromFile(CFX_WideString::FromLocal(filename).c_str());
- }
-
+ static CFX_DIBitmap* LoadFromFile(const FX_CHAR* filename);
static CFX_DIBitmap* LoadDIBitmap(WINDIB_Open_Args_ args);
- CFX_WindowsDIB(HDC hDC, int width, int height);
-
- ~CFX_WindowsDIB();
-
HDC GetDC() const { return m_hMemDC; }
-
HBITMAP GetWindowsBitmap() const { return m_hBitmap; }
void LoadFromDevice(HDC hDC, int left, int top);
-
void SetToDevice(HDC hDC, int left, int top);
protected:
HDC m_hMemDC;
-
HBITMAP m_hBitmap;
-
HBITMAP m_hOldBitmap;
};
@@ -69,7 +56,7 @@ class CFX_WindowsDevice : public CFX_RenderDevice {
static IFX_RenderDeviceDriver* CreateDriver(HDC hDC);
explicit CFX_WindowsDevice(HDC hDC);
- ~CFX_WindowsDevice();
+ ~CFX_WindowsDevice() override;
HDC GetDC() const;
};
@@ -77,7 +64,7 @@ class CFX_WindowsDevice : public CFX_RenderDevice {
class CFX_WinBitmapDevice : public CFX_RenderDevice {
public:
CFX_WinBitmapDevice(int width, int height, FXDIB_Format format);
- ~CFX_WinBitmapDevice();
+ ~CFX_WinBitmapDevice() override;
HDC GetDC() { return m_hDC; }
diff --git a/core/fxge/win32/fx_win32_device.cpp b/core/fxge/win32/fx_win32_device.cpp
index c2084f2877..2df5c1c4ce 100644
--- a/core/fxge/win32/fx_win32_device.cpp
+++ b/core/fxge/win32/fx_win32_device.cpp
@@ -939,6 +939,10 @@ FX_BOOL CGdiDeviceDriver::GetClipBox(FX_RECT* pRect) {
return ::GetClipBox(m_hDC, (RECT*)pRect);
}
+void* CGdiDeviceDriver::GetPlatformSurface() const {
+ return (void*)m_hDC;
+}
+
void CGdiDeviceDriver::DrawLine(FX_FLOAT x1,
FX_FLOAT y1,
FX_FLOAT x2,
@@ -1363,6 +1367,16 @@ FX_BOOL CGdiDisplayDriver::StretchDIBits(const CFX_DIBSource* pSource,
dest_height, flags, nullptr);
}
+FX_BOOL CGdiDisplayDriver::StartDIBits(const CFX_DIBSource* pBitmap,
+ int bitmap_alpha,
+ uint32_t color,
+ const CFX_Matrix* pMatrix,
+ uint32_t render_flags,
+ void*& handle,
+ int blend_type) {
+ return FALSE;
+}
+
CFX_WindowsDevice::CFX_WindowsDevice(HDC hDC) {
SetDeviceDriver(CreateDriver(hDC));
}
diff --git a/core/fxge/win32/fx_win32_dib.cpp b/core/fxge/win32/fx_win32_dib.cpp
index 7221d10536..0e79399357 100644
--- a/core/fxge/win32/fx_win32_dib.cpp
+++ b/core/fxge/win32/fx_win32_dib.cpp
@@ -51,6 +51,7 @@ CFX_ByteString CFX_WindowsDIB::GetBitmapInfo(const CFX_DIBitmap* pBitmap) {
result.ReleaseBuffer(len);
return result;
}
+
CFX_DIBitmap* _FX_WindowsDIB_LoadFromBuf(BITMAPINFO* pbmi,
LPVOID pData,
FX_BOOL bAlpha) {
@@ -97,21 +98,25 @@ CFX_DIBitmap* _FX_WindowsDIB_LoadFromBuf(BITMAPINFO* pbmi,
}
return pBitmap;
}
+
CFX_DIBitmap* CFX_WindowsDIB::LoadFromBuf(BITMAPINFO* pbmi, LPVOID pData) {
return _FX_WindowsDIB_LoadFromBuf(pbmi, pData, FALSE);
}
+
HBITMAP CFX_WindowsDIB::GetDDBitmap(const CFX_DIBitmap* pBitmap, HDC hDC) {
CFX_ByteString info = GetBitmapInfo(pBitmap);
return CreateDIBitmap(hDC, (BITMAPINFOHEADER*)info.c_str(), CBM_INIT,
pBitmap->GetBuffer(), (BITMAPINFO*)info.c_str(),
DIB_RGB_COLORS);
}
+
void GetBitmapSize(HBITMAP hBitmap, int& w, int& h) {
BITMAP bmp;
GetObject(hBitmap, sizeof bmp, &bmp);
w = bmp.bmWidth;
h = bmp.bmHeight;
}
+
CFX_DIBitmap* CFX_WindowsDIB::LoadFromFile(const FX_WCHAR* filename) {
CWin32Platform* pPlatform =
(CWin32Platform*)CFX_GEModule::Get()->GetPlatformData();
@@ -145,6 +150,11 @@ CFX_DIBitmap* CFX_WindowsDIB::LoadFromFile(const FX_WCHAR* filename) {
DeleteDC(hDC);
return pDIBitmap;
}
+
+CFX_DIBitmap* CFX_WindowsDIB::LoadFromFile(const FX_CHAR* filename) {
+ return LoadFromFile(CFX_WideString::FromLocal(filename).c_str());
+}
+
CFX_DIBitmap* CFX_WindowsDIB::LoadDIBitmap(WINDIB_Open_Args_ args) {
CWin32Platform* pPlatform =
(CWin32Platform*)CFX_GEModule::Get()->GetPlatformData();
@@ -178,6 +188,7 @@ CFX_DIBitmap* CFX_WindowsDIB::LoadDIBitmap(WINDIB_Open_Args_ args) {
DeleteDC(hDC);
return pDIBitmap;
}
+
CFX_DIBitmap* CFX_WindowsDIB::LoadFromDDB(HDC hDC,
HBITMAP hBitmap,
uint32_t* pPalette,
@@ -259,6 +270,7 @@ CFX_DIBitmap* CFX_WindowsDIB::LoadFromDDB(HDC hDC,
}
return pDIBitmap;
}
+
CFX_WindowsDIB::CFX_WindowsDIB(HDC hDC, int width, int height) {
Create(width, height, FXDIB_Rgb, (uint8_t*)1);
BITMAPINFOHEADER bmih;
@@ -273,14 +285,17 @@ CFX_WindowsDIB::CFX_WindowsDIB(HDC hDC, int width, int height) {
m_hMemDC = CreateCompatibleDC(hDC);
m_hOldBitmap = (HBITMAP)SelectObject(m_hMemDC, m_hBitmap);
}
+
CFX_WindowsDIB::~CFX_WindowsDIB() {
SelectObject(m_hMemDC, m_hOldBitmap);
DeleteDC(m_hMemDC);
DeleteObject(m_hBitmap);
}
+
void CFX_WindowsDIB::LoadFromDevice(HDC hDC, int left, int top) {
::BitBlt(m_hMemDC, 0, 0, m_Width, m_Height, hDC, left, top, SRCCOPY);
}
+
void CFX_WindowsDIB::SetToDevice(HDC hDC, int left, int top) {
::BitBlt(hDC, left, top, m_Width, m_Height, m_hMemDC, 0, 0, SRCCOPY);
}
diff --git a/core/fxge/win32/fx_win32_dwrite.cpp b/core/fxge/win32/fx_win32_dwrite.cpp
index 5f620cba4c..b3ba28cfc7 100644
--- a/core/fxge/win32/fx_win32_dwrite.cpp
+++ b/core/fxge/win32/fx_win32_dwrite.cpp
@@ -30,22 +30,29 @@ inline InterfaceType* SafeAcquire(InterfaceType* newObject) {
}
return newObject;
}
+
class CDwFontFileStream final : public IDWriteFontFileStream {
public:
explicit CDwFontFileStream(void const* fontFileReferenceKey,
UINT32 fontFileReferenceKeySize);
- virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid,
- void** ppvObject);
- virtual ULONG STDMETHODCALLTYPE AddRef();
- virtual ULONG STDMETHODCALLTYPE Release();
- virtual HRESULT STDMETHODCALLTYPE
+
+ // IUnknown.
+ HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid,
+ void** ppvObject) override;
+ ULONG STDMETHODCALLTYPE AddRef() override;
+ ULONG STDMETHODCALLTYPE Release() override;
+
+ // IDWriteFontFileStream.
+ HRESULT STDMETHODCALLTYPE
ReadFileFragment(void const** fragmentStart,
UINT64 fileOffset,
UINT64 fragmentSize,
- OUT void** fragmentContext);
- virtual void STDMETHODCALLTYPE ReleaseFileFragment(void* fragmentContext);
- virtual HRESULT STDMETHODCALLTYPE GetFileSize(OUT UINT64* fileSize);
- virtual HRESULT STDMETHODCALLTYPE GetLastWriteTime(OUT UINT64* lastWriteTime);
+ OUT void** fragmentContext) override;
+ void STDMETHODCALLTYPE ReleaseFileFragment(void* fragmentContext) override;
+ HRESULT STDMETHODCALLTYPE GetFileSize(OUT UINT64* fileSize) override;
+ HRESULT STDMETHODCALLTYPE
+ GetLastWriteTime(OUT UINT64* lastWriteTime) override;
+
bool IsInitialized() { return !!resourcePtr_; }
private:
@@ -53,16 +60,20 @@ class CDwFontFileStream final : public IDWriteFontFileStream {
void const* resourcePtr_;
DWORD resourceSize_;
};
+
class CDwFontFileLoader final : public IDWriteFontFileLoader {
public:
- virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid,
- void** ppvObject);
- virtual ULONG STDMETHODCALLTYPE AddRef();
- virtual ULONG STDMETHODCALLTYPE Release();
- virtual HRESULT STDMETHODCALLTYPE
+ // IUnknown.
+ HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid,
+ void** ppvObject) override;
+ ULONG STDMETHODCALLTYPE AddRef() override;
+ ULONG STDMETHODCALLTYPE Release() override;
+
+ // IDWriteFontFileLoader.
+ HRESULT STDMETHODCALLTYPE
CreateStreamFromKey(void const* fontFileReferenceKey,
UINT32 fontFileReferenceKeySize,
- OUT IDWriteFontFileStream** fontFileStream);
+ OUT IDWriteFontFileStream** fontFileStream) override;
static IDWriteFontFileLoader* GetLoader() {
if (!instance_) {
@@ -77,10 +88,12 @@ class CDwFontFileLoader final : public IDWriteFontFileLoader {
ULONG refCount_;
static IDWriteFontFileLoader* instance_;
};
+
class CDwFontContext {
public:
CDwFontContext(IDWriteFactory* dwriteFactory);
~CDwFontContext();
+
HRESULT Initialize();
private:
@@ -89,12 +102,14 @@ class CDwFontContext {
HRESULT hr_;
IDWriteFactory* dwriteFactory_;
};
+
class CDwGdiTextRenderer {
public:
CDwGdiTextRenderer(CFX_DIBitmap* pBitmap,
IDWriteBitmapRenderTarget* bitmapRenderTarget,
IDWriteRenderingParams* renderingParams);
~CDwGdiTextRenderer();
+
HRESULT STDMETHODCALLTYPE DrawGlyphRun(const FX_RECT& text_bbox,
__in_opt CFX_ClipRgn* pClipRgn,
__in_opt DWRITE_MATRIX const* pMatrix,
@@ -109,13 +124,15 @@ class CDwGdiTextRenderer {
IDWriteBitmapRenderTarget* pRenderTarget_;
IDWriteRenderingParams* pRenderingParams_;
};
-CDWriteExt::CDWriteExt() {
- m_hModule = nullptr;
- m_pDWriteFactory = nullptr;
- m_pDwFontContext = nullptr;
- m_pDwTextRenderer = nullptr;
-}
+
+CDWriteExt::CDWriteExt()
+ : m_hModule(nullptr),
+ m_pDWriteFactory(nullptr),
+ m_pDwFontContext(nullptr),
+ m_pDwTextRenderer(nullptr) {}
+
void CDWriteExt::Load() {}
+
void CDWriteExt::Unload() {
if (m_pDwFontContext) {
delete (CDwFontContext*)m_pDwFontContext;
@@ -123,9 +140,11 @@ void CDWriteExt::Unload() {
}
SafeRelease((IDWriteFactory**)&m_pDWriteFactory);
}
+
CDWriteExt::~CDWriteExt() {
Unload();
}
+
LPVOID CDWriteExt::DwCreateFontFaceFromStream(uint8_t* pData,
uint32_t size,
int simulation_style) {
@@ -162,6 +181,7 @@ failed:
SafeRelease(&pDwFontFile);
return nullptr;
}
+
FX_BOOL CDWriteExt::DwCreateRenderingTarget(CFX_DIBitmap* pBitmap,
void** renderTarget) {
if (pBitmap->GetFormat() > FXDIB_Argb) {
@@ -203,6 +223,7 @@ failed:
SafeRelease(&pRenderingParams);
return FALSE;
}
+
FX_BOOL CDWriteExt::DwRendingString(void* renderTarget,
CFX_ClipRgn* pClipRgn,
FX_RECT& stringRect,
@@ -245,20 +266,24 @@ FX_BOOL CDWriteExt::DwRendingString(void* renderTarget,
RGB(FXARGB_R(text_color), FXARGB_G(text_color), FXARGB_B(text_color)));
return SUCCEEDED(hr);
}
+
void CDWriteExt::DwDeleteRenderingTarget(void* renderTarget) {
delete (CDwGdiTextRenderer*)renderTarget;
}
+
void CDWriteExt::DwDeleteFont(void* pFont) {
if (pFont) {
SafeRelease((IDWriteFontFace**)&pFont);
}
}
+
CDwFontFileStream::CDwFontFileStream(void const* fontFileReferenceKey,
UINT32 fontFileReferenceKeySize) {
refCount_ = 0;
resourcePtr_ = fontFileReferenceKey;
resourceSize_ = fontFileReferenceKeySize;
}
+
HRESULT STDMETHODCALLTYPE CDwFontFileStream::QueryInterface(REFIID iid,
void** ppvObject) {
if (iid == IID_IUnknown || iid == __uuidof(IDWriteFontFileStream)) {
@@ -269,9 +294,11 @@ HRESULT STDMETHODCALLTYPE CDwFontFileStream::QueryInterface(REFIID iid,
*ppvObject = nullptr;
return E_NOINTERFACE;
}
+
ULONG STDMETHODCALLTYPE CDwFontFileStream::AddRef() {
return InterlockedIncrement((long*)(&refCount_));
}
+
ULONG STDMETHODCALLTYPE CDwFontFileStream::Release() {
ULONG newCount = InterlockedDecrement((long*)(&refCount_));
if (newCount == 0) {
@@ -279,6 +306,7 @@ ULONG STDMETHODCALLTYPE CDwFontFileStream::Release() {
}
return newCount;
}
+
HRESULT STDMETHODCALLTYPE
CDwFontFileStream::ReadFileFragment(void const** fragmentStart,
UINT64 fileOffset,
@@ -295,17 +323,20 @@ CDwFontFileStream::ReadFileFragment(void const** fragmentStart,
*fragmentContext = nullptr;
return E_FAIL;
}
+
void STDMETHODCALLTYPE
CDwFontFileStream::ReleaseFileFragment(void* fragmentContext) {}
HRESULT STDMETHODCALLTYPE CDwFontFileStream::GetFileSize(OUT UINT64* fileSize) {
*fileSize = resourceSize_;
return S_OK;
}
+
HRESULT STDMETHODCALLTYPE
CDwFontFileStream::GetLastWriteTime(OUT UINT64* lastWriteTime) {
*lastWriteTime = 0;
return E_NOTIMPL;
}
+
IDWriteFontFileLoader* CDwFontFileLoader::instance_ = nullptr;
CDwFontFileLoader::CDwFontFileLoader() : refCount_(0) {}
HRESULT STDMETHODCALLTYPE CDwFontFileLoader::QueryInterface(REFIID iid,
@@ -318,9 +349,11 @@ HRESULT STDMETHODCALLTYPE CDwFontFileLoader::QueryInterface(REFIID iid,
*ppvObject = nullptr;
return E_NOINTERFACE;
}
+
ULONG STDMETHODCALLTYPE CDwFontFileLoader::AddRef() {
return InterlockedIncrement((long*)(&refCount_));
}
+
ULONG STDMETHODCALLTYPE CDwFontFileLoader::Release() {
ULONG newCount = InterlockedDecrement((long*)(&refCount_));
if (newCount == 0) {
@@ -329,6 +362,7 @@ ULONG STDMETHODCALLTYPE CDwFontFileLoader::Release() {
}
return newCount;
}
+
HRESULT STDMETHODCALLTYPE CDwFontFileLoader::CreateStreamFromKey(
void const* fontFileReferenceKey,
UINT32 fontFileReferenceKeySize,
@@ -343,14 +377,17 @@ HRESULT STDMETHODCALLTYPE CDwFontFileLoader::CreateStreamFromKey(
*fontFileStream = SafeAcquire(stream);
return S_OK;
}
+
CDwFontContext::CDwFontContext(IDWriteFactory* dwriteFactory)
: hr_(S_FALSE), dwriteFactory_(SafeAcquire(dwriteFactory)) {}
+
CDwFontContext::~CDwFontContext() {
if (dwriteFactory_ && hr_ == S_OK) {
dwriteFactory_->UnregisterFontFileLoader(CDwFontFileLoader::GetLoader());
}
SafeRelease(&dwriteFactory_);
}
+
HRESULT CDwFontContext::Initialize() {
if (hr_ == S_FALSE) {
return hr_ = dwriteFactory_->RegisterFontFileLoader(
@@ -358,6 +395,7 @@ HRESULT CDwFontContext::Initialize() {
}
return hr_;
}
+
CDwGdiTextRenderer::CDwGdiTextRenderer(
CFX_DIBitmap* pBitmap,
IDWriteBitmapRenderTarget* bitmapRenderTarget,
@@ -369,6 +407,7 @@ CDwGdiTextRenderer::~CDwGdiTextRenderer() {
SafeRelease(&pRenderTarget_);
SafeRelease(&pRenderingParams_);
}
+
STDMETHODIMP CDwGdiTextRenderer::DrawGlyphRun(
const FX_RECT& text_bbox,
__in_opt CFX_ClipRgn* pClipRgn,
diff --git a/core/fxge/win32/fx_win32_gdipext.cpp b/core/fxge/win32/fx_win32_gdipext.cpp
index 68b9aaa80e..3de1b5a8d5 100644
--- a/core/fxge/win32/fx_win32_gdipext.cpp
+++ b/core/fxge/win32/fx_win32_gdipext.cpp
@@ -1258,18 +1258,14 @@ FX_BOOL CGdiplusExt::DrawPath(HDC hDC,
CallFunc(GdipDeleteGraphics)(pGraphics);
return TRUE;
}
-class GpStream final : public IStream {
- LONG m_RefCount;
- int m_ReadPos;
- CFX_ByteTextBuf m_InterStream;
+class GpStream final : public IStream {
public:
- GpStream() {
- m_RefCount = 1;
- m_ReadPos = 0;
- }
- virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid,
- void** ppvObject) {
+ GpStream() : m_RefCount(1), m_ReadPos(0) {}
+
+ // IUnknown
+ HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid,
+ void** ppvObject) override {
if (iid == __uuidof(IUnknown) || iid == __uuidof(IStream) ||
iid == __uuidof(ISequentialStream)) {
*ppvObject = static_cast<IStream*>(this);
@@ -1278,10 +1274,10 @@ class GpStream final : public IStream {
}
return E_NOINTERFACE;
}
- virtual ULONG STDMETHODCALLTYPE AddRef(void) {
+ ULONG STDMETHODCALLTYPE AddRef(void) override {
return (ULONG)InterlockedIncrement(&m_RefCount);
}
- virtual ULONG STDMETHODCALLTYPE Release(void) {
+ ULONG STDMETHODCALLTYPE Release(void) override {
ULONG res = (ULONG)InterlockedDecrement(&m_RefCount);
if (res == 0) {
delete this;
@@ -1289,10 +1285,10 @@ class GpStream final : public IStream {
return res;
}
- public:
- virtual HRESULT STDMETHODCALLTYPE Read(void* Output,
- ULONG cb,
- ULONG* pcbRead) {
+ // ISequentialStream
+ HRESULT STDMETHODCALLTYPE Read(void* Output,
+ ULONG cb,
+ ULONG* pcbRead) override {
size_t bytes_left;
size_t bytes_out;
if (pcbRead) {
@@ -1310,9 +1306,9 @@ class GpStream final : public IStream {
}
return S_OK;
}
- virtual HRESULT STDMETHODCALLTYPE Write(void const* Input,
- ULONG cb,
- ULONG* pcbWritten) {
+ HRESULT STDMETHODCALLTYPE Write(void const* Input,
+ ULONG cb,
+ ULONG* pcbWritten) override {
if (cb <= 0) {
if (pcbWritten) {
*pcbWritten = 0;
@@ -1326,34 +1322,34 @@ class GpStream final : public IStream {
return S_OK;
}
- public:
- virtual HRESULT STDMETHODCALLTYPE SetSize(ULARGE_INTEGER) {
+ // IStream
+ HRESULT STDMETHODCALLTYPE SetSize(ULARGE_INTEGER) override {
return E_NOTIMPL;
}
- virtual HRESULT STDMETHODCALLTYPE CopyTo(IStream*,
- ULARGE_INTEGER,
- ULARGE_INTEGER*,
- ULARGE_INTEGER*) {
+ HRESULT STDMETHODCALLTYPE CopyTo(IStream*,
+ ULARGE_INTEGER,
+ ULARGE_INTEGER*,
+ ULARGE_INTEGER*) override {
return E_NOTIMPL;
}
- virtual HRESULT STDMETHODCALLTYPE Commit(DWORD) { return E_NOTIMPL; }
- virtual HRESULT STDMETHODCALLTYPE Revert(void) { return E_NOTIMPL; }
- virtual HRESULT STDMETHODCALLTYPE LockRegion(ULARGE_INTEGER,
- ULARGE_INTEGER,
- DWORD) {
+ HRESULT STDMETHODCALLTYPE Commit(DWORD) override { return E_NOTIMPL; }
+ HRESULT STDMETHODCALLTYPE Revert(void) override { return E_NOTIMPL; }
+ HRESULT STDMETHODCALLTYPE LockRegion(ULARGE_INTEGER,
+ ULARGE_INTEGER,
+ DWORD) override {
return E_NOTIMPL;
}
- virtual HRESULT STDMETHODCALLTYPE UnlockRegion(ULARGE_INTEGER,
- ULARGE_INTEGER,
- DWORD) {
+ HRESULT STDMETHODCALLTYPE UnlockRegion(ULARGE_INTEGER,
+ ULARGE_INTEGER,
+ DWORD) override {
return E_NOTIMPL;
}
- virtual HRESULT STDMETHODCALLTYPE Clone(IStream** stream) {
+ HRESULT STDMETHODCALLTYPE Clone(IStream** stream) override {
return E_NOTIMPL;
}
- virtual HRESULT STDMETHODCALLTYPE Seek(LARGE_INTEGER liDistanceToMove,
- DWORD dwOrigin,
- ULARGE_INTEGER* lpNewFilePointer) {
+ HRESULT STDMETHODCALLTYPE Seek(LARGE_INTEGER liDistanceToMove,
+ DWORD dwOrigin,
+ ULARGE_INTEGER* lpNewFilePointer) override {
long start = 0;
long new_read_position;
switch (dwOrigin) {
@@ -1381,7 +1377,8 @@ class GpStream final : public IStream {
}
return S_OK;
}
- virtual HRESULT STDMETHODCALLTYPE Stat(STATSTG* pStatstg, DWORD grfStatFlag) {
+ HRESULT STDMETHODCALLTYPE Stat(STATSTG* pStatstg,
+ DWORD grfStatFlag) override {
if (!pStatstg) {
return STG_E_INVALIDFUNCTION;
}
@@ -1389,7 +1386,13 @@ class GpStream final : public IStream {
pStatstg->cbSize.QuadPart = m_InterStream.GetLength();
return S_OK;
}
+
+ private:
+ LONG m_RefCount;
+ int m_ReadPos;
+ CFX_ByteTextBuf m_InterStream;
};
+
typedef struct {
BITMAPINFO* pbmi;
int Stride;
@@ -1398,6 +1401,7 @@ typedef struct {
BitmapData* pBitmapData;
GpStream* pStream;
} PREVIEW3_DIBITMAP;
+
static PREVIEW3_DIBITMAP* LoadDIBitmap(WINDIB_Open_Args_ args) {
GpBitmap* pBitmap;
GpStream* pStream = nullptr;
@@ -1477,6 +1481,7 @@ static PREVIEW3_DIBITMAP* LoadDIBitmap(WINDIB_Open_Args_ args) {
pInfo->pStream = pStream;
return pInfo;
}
+
static void FreeDIBitmap(PREVIEW3_DIBITMAP* pInfo) {
CGdiplusExt& GdiplusExt =
((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt;
@@ -1489,6 +1494,7 @@ static void FreeDIBitmap(PREVIEW3_DIBITMAP* pInfo) {
}
FX_Free(pInfo);
}
+
CFX_DIBitmap* _FX_WindowsDIB_LoadFromBuf(BITMAPINFO* pbmi,
LPVOID pData,
FX_BOOL bAlpha);
diff --git a/core/fxge/win32/win32_int.h b/core/fxge/win32/win32_int.h
index e0952706fa..b09c4ebbd5 100644
--- a/core/fxge/win32/win32_int.h
+++ b/core/fxge/win32/win32_int.h
@@ -137,7 +137,7 @@ class CGdiDeviceDriver : public IFX_RenderDeviceDriver {
uint32_t color,
int blend_type) override;
FX_BOOL GetClipBox(FX_RECT* pRect) override;
- void* GetPlatformSurface() const override { return (void*)m_hDC; }
+ void* GetPlatformSurface() const override;
void DrawLine(FX_FLOAT x1,
FX_FLOAT y1,
@@ -203,9 +203,7 @@ class CGdiDisplayDriver : public CGdiDeviceDriver {
const CFX_Matrix* pMatrix,
uint32_t render_flags,
void*& handle,
- int blend_type) override {
- return FALSE;
- }
+ int blend_type) override;
FX_BOOL UseFoxitStretchEngine(const CFX_DIBSource* pSource,
uint32_t color,
int dest_left,