From 5a423ef8708e61d43f1556ab09c2e09f496d700d Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Tue, 14 Nov 2017 18:56:54 +0000 Subject: Rename the fxgraphics classes The build system doesn't like name clashes over directories in XFA. The Pattern and and Shading classes need to be renamed to not clash with future XFA node class names. Change-Id: I978da492d884626c0db2e11ac236a3399e9c7e58 Reviewed-on: https://pdfium-review.googlesource.com/18290 Commit-Queue: dsinclair Reviewed-by: Tom Sepez --- xfa/fwl/cfwl_caret.h | 2 +- xfa/fwl/cfwl_edit.cpp | 14 +-- xfa/fwl/cfwl_edit.h | 4 +- xfa/fwl/cfwl_themebackground.h | 4 +- xfa/fwl/theme/cfwl_carettp.cpp | 12 +-- xfa/fwl/theme/cfwl_carettp.h | 2 +- xfa/fwl/theme/cfwl_checkboxtp.cpp | 28 +++--- xfa/fwl/theme/cfwl_checkboxtp.h | 2 +- xfa/fwl/theme/cfwl_comboboxtp.cpp | 13 +-- xfa/fwl/theme/cfwl_edittp.cpp | 20 ++--- xfa/fwl/theme/cfwl_listboxtp.cpp | 8 +- xfa/fwl/theme/cfwl_monthcalendartp.cpp | 58 +++++++------ xfa/fwl/theme/cfwl_pushbuttontp.cpp | 12 +-- xfa/fwl/theme/cfwl_scrollbartp.cpp | 24 +++--- xfa/fwl/theme/cfwl_widgettp.cpp | 33 +++---- xfa/fwl/theme/cfwl_widgettp.h | 2 +- xfa/fxfa/cxfa_fffield.cpp | 12 +-- xfa/fxfa/cxfa_ffline.cpp | 8 +- xfa/fxfa/cxfa_ffpushbutton.cpp | 12 +-- xfa/fxfa/cxfa_ffwidget.cpp | 78 ++++++++--------- xfa/fxfa/cxfa_fwltheme.cpp | 2 +- xfa/fxgraphics/cxfa_color.cpp | 46 ---------- xfa/fxgraphics/cxfa_color.h | 50 ----------- xfa/fxgraphics/cxfa_gecolor.cpp | 47 ++++++++++ xfa/fxgraphics/cxfa_gecolor.h | 50 +++++++++++ xfa/fxgraphics/cxfa_gepath.cpp | 151 +++++++++++++++++++++++++++++++++ xfa/fxgraphics/cxfa_gepath.h | 55 ++++++++++++ xfa/fxgraphics/cxfa_gepattern.cpp | 20 +++++ xfa/fxgraphics/cxfa_gepattern.h | 36 ++++++++ xfa/fxgraphics/cxfa_geshading.cpp | 78 +++++++++++++++++ xfa/fxgraphics/cxfa_geshading.h | 56 ++++++++++++ xfa/fxgraphics/cxfa_graphics.cpp | 34 ++++---- xfa/fxgraphics/cxfa_graphics.h | 25 +++--- xfa/fxgraphics/cxfa_path.cpp | 148 -------------------------------- xfa/fxgraphics/cxfa_path.h | 55 ------------ xfa/fxgraphics/cxfa_pattern.cpp | 20 ----- xfa/fxgraphics/cxfa_pattern.h | 36 -------- xfa/fxgraphics/cxfa_shading.cpp | 78 ----------------- xfa/fxgraphics/cxfa_shading.h | 56 ------------ 39 files changed, 700 insertions(+), 691 deletions(-) delete mode 100644 xfa/fxgraphics/cxfa_color.cpp delete mode 100644 xfa/fxgraphics/cxfa_color.h create mode 100644 xfa/fxgraphics/cxfa_gecolor.cpp create mode 100644 xfa/fxgraphics/cxfa_gecolor.h create mode 100644 xfa/fxgraphics/cxfa_gepath.cpp create mode 100644 xfa/fxgraphics/cxfa_gepath.h create mode 100644 xfa/fxgraphics/cxfa_gepattern.cpp create mode 100644 xfa/fxgraphics/cxfa_gepattern.h create mode 100644 xfa/fxgraphics/cxfa_geshading.cpp create mode 100644 xfa/fxgraphics/cxfa_geshading.h delete mode 100644 xfa/fxgraphics/cxfa_path.cpp delete mode 100644 xfa/fxgraphics/cxfa_path.h delete mode 100644 xfa/fxgraphics/cxfa_pattern.cpp delete mode 100644 xfa/fxgraphics/cxfa_pattern.h delete mode 100644 xfa/fxgraphics/cxfa_shading.cpp delete mode 100644 xfa/fxgraphics/cxfa_shading.h (limited to 'xfa') diff --git a/xfa/fwl/cfwl_caret.h b/xfa/fwl/cfwl_caret.h index 638823699d..90d62d6e9b 100644 --- a/xfa/fwl/cfwl_caret.h +++ b/xfa/fwl/cfwl_caret.h @@ -11,7 +11,7 @@ #include "xfa/fwl/cfwl_timer.h" #include "xfa/fwl/cfwl_widget.h" -#include "xfa/fxgraphics/cxfa_color.h" +#include "xfa/fxgraphics/cxfa_gecolor.h" class CFWL_WidgetProperties; class CFWL_Widget; diff --git a/xfa/fwl/cfwl_edit.cpp b/xfa/fwl/cfwl_edit.cpp index 45e69ab843..cdbca2cf54 100644 --- a/xfa/fwl/cfwl_edit.cpp +++ b/xfa/fwl/cfwl_edit.cpp @@ -31,7 +31,7 @@ #include "xfa/fwl/theme/cfwl_utils.h" #include "xfa/fxfa/cxfa_ffdoc.h" #include "xfa/fxfa/cxfa_ffwidget.h" -#include "xfa/fxgraphics/cxfa_path.h" +#include "xfa/fxgraphics/cxfa_gepath.h" namespace { @@ -49,7 +49,7 @@ bool FxEditIsLatinWord(wchar_t c) { c == 0x0027; } -void AddSquigglyPath(CXFA_Path* pPathData, +void AddSquigglyPath(CXFA_GEPath* pPathData, float fStartX, float fEndX, float fY, @@ -163,7 +163,7 @@ FWL_WidgetHit CFWL_Edit::HitTest(const CFX_PointF& point) { return FWL_WidgetHit::Unknown; } -void CFWL_Edit::AddSpellCheckObj(CXFA_Path& PathData, +void CFWL_Edit::AddSpellCheckObj(CXFA_GEPath& PathData, int32_t nStart, int32_t nCount, float fOffSetX, @@ -190,7 +190,7 @@ void CFWL_Edit::DrawSpellCheck(CXFA_Graphics* pGraphics, CFWL_EventCheckWord checkWordEvent(this); ByteString sLatinWord; - CXFA_Path pathSpell; + CXFA_GEPath pathSpell; int32_t nStart = 0; float fOffSetX = m_rtEngine.left - m_fScrollOffsetX; float fOffSetY = m_rtEngine.top - m_fScrollOffsetY + m_fVAlignOffset; @@ -230,7 +230,7 @@ void CFWL_Edit::DrawSpellCheck(CXFA_Graphics* pGraphics, mt.Concat(*pMatrix); } pGraphics->SetClipRect(rtClip); - pGraphics->SetStrokeColor(CXFA_Color(0xFFFF0000)); + pGraphics->SetStrokeColor(CXFA_GEColor(0xFFFF0000)); pGraphics->SetLineWidth(0); pGraphics->StrokePath(&pathSpell, nullptr); } @@ -486,7 +486,7 @@ void CFWL_Edit::DrawContent(CXFA_Graphics* pGraphics, std::vector rects = m_EdtEngine.GetCharacterRectsInRange(sel_start, count); - CXFA_Path path; + CXFA_GEPath path; for (auto& rect : rects) { rect.left += fOffSetX; rect.top += fOffSetY; @@ -512,7 +512,7 @@ void CFWL_Edit::DrawContent(CXFA_Graphics* pGraphics, if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_CombText) { pGraphics->RestoreGraphState(); - CXFA_Path path; + CXFA_GEPath path; int32_t iLimit = m_nLimit > 0 ? m_nLimit : 1; float fStep = m_rtEngine.width / iLimit; float fLeft = m_rtEngine.left + 1; diff --git a/xfa/fwl/cfwl_edit.h b/xfa/fwl/cfwl_edit.h index b7c252668b..6aedca8dec 100644 --- a/xfa/fwl/cfwl_edit.h +++ b/xfa/fwl/cfwl_edit.h @@ -15,7 +15,7 @@ #include "xfa/fwl/cfwl_event.h" #include "xfa/fwl/cfwl_scrollbar.h" #include "xfa/fwl/cfwl_widget.h" -#include "xfa/fxgraphics/cxfa_path.h" +#include "xfa/fxgraphics/cxfa_gepath.h" #define FWL_STYLEEXT_EDT_ReadOnly (1L << 0) #define FWL_STYLEEXT_EDT_MultiLine (1L << 1) @@ -134,7 +134,7 @@ class CFWL_Edit : public CFWL_Widget, public CFDE_TextEditEngine::Delegate { bool ValidateNumberChar(wchar_t cNum); bool IsShowScrollBar(bool bVert); bool IsContentHeightOverflow(); - void AddSpellCheckObj(CXFA_Path& PathData, + void AddSpellCheckObj(CXFA_GEPath& PathData, int32_t nStart, int32_t nCount, float fOffSetX, diff --git a/xfa/fwl/cfwl_themebackground.h b/xfa/fwl/cfwl_themebackground.h index 65c29ebd7a..81fa0a2212 100644 --- a/xfa/fwl/cfwl_themebackground.h +++ b/xfa/fwl/cfwl_themebackground.h @@ -12,7 +12,7 @@ class CFX_DIBitmpa; class CXFA_Graphics; -class CXFA_Path; +class CXFA_GEPath; class CFWL_ThemeBackground : public CFWL_ThemePart { public: @@ -20,7 +20,7 @@ class CFWL_ThemeBackground : public CFWL_ThemePart { ~CFWL_ThemeBackground(); CXFA_Graphics* m_pGraphics; - CXFA_Path* m_pPath; + CXFA_GEPath* m_pPath; RetainPtr m_pImage; }; diff --git a/xfa/fwl/theme/cfwl_carettp.cpp b/xfa/fwl/theme/cfwl_carettp.cpp index 37dfad5146..973531958a 100644 --- a/xfa/fwl/theme/cfwl_carettp.cpp +++ b/xfa/fwl/theme/cfwl_carettp.cpp @@ -9,8 +9,8 @@ #include "xfa/fwl/cfwl_caret.h" #include "xfa/fwl/cfwl_themebackground.h" #include "xfa/fwl/cfwl_widget.h" -#include "xfa/fxgraphics/cxfa_color.h" -#include "xfa/fxgraphics/cxfa_path.h" +#include "xfa/fxgraphics/cxfa_gecolor.h" +#include "xfa/fxgraphics/cxfa_gepath.h" CFWL_CaretTP::CFWL_CaretTP() {} CFWL_CaretTP::~CFWL_CaretTP() {} @@ -25,7 +25,7 @@ void CFWL_CaretTP::DrawBackground(CFWL_ThemeBackground* pParams) { return; DrawCaretBK(pParams->m_pGraphics, pParams->m_dwStates, - &(pParams->m_rtPart), (CXFA_Color*)pParams->m_pData, + &(pParams->m_rtPart), (CXFA_GEColor*)pParams->m_pData, &(pParams->m_matrix)); break; } @@ -37,15 +37,15 @@ void CFWL_CaretTP::DrawBackground(CFWL_ThemeBackground* pParams) { void CFWL_CaretTP::DrawCaretBK(CXFA_Graphics* pGraphics, uint32_t dwStates, const CFX_RectF* pRect, - CXFA_Color* crFill, + CXFA_GEColor* crFill, CFX_Matrix* pMatrix) { - CXFA_Path path; + CXFA_GEPath path; CFX_RectF rect = *pRect; path.AddRectangle(rect.left, rect.top, rect.width, rect.height); if (crFill) { pGraphics->SetFillColor(*crFill); } else { - pGraphics->SetFillColor(CXFA_Color(ArgbEncode(255, 0, 0, 0))); + pGraphics->SetFillColor(CXFA_GEColor(ArgbEncode(255, 0, 0, 0))); } pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); } diff --git a/xfa/fwl/theme/cfwl_carettp.h b/xfa/fwl/theme/cfwl_carettp.h index fdf330b8bf..8b88feeda3 100644 --- a/xfa/fwl/theme/cfwl_carettp.h +++ b/xfa/fwl/theme/cfwl_carettp.h @@ -21,7 +21,7 @@ class CFWL_CaretTP : public CFWL_WidgetTP { void DrawCaretBK(CXFA_Graphics* pGraphics, uint32_t dwStates, const CFX_RectF* pRect, - CXFA_Color* crFill, + CXFA_GEColor* crFill, CFX_Matrix* pMatrix = nullptr); }; diff --git a/xfa/fwl/theme/cfwl_checkboxtp.cpp b/xfa/fwl/theme/cfwl_checkboxtp.cpp index 8d73738aab..82fdc1a18a 100644 --- a/xfa/fwl/theme/cfwl_checkboxtp.cpp +++ b/xfa/fwl/theme/cfwl_checkboxtp.cpp @@ -13,8 +13,8 @@ #include "xfa/fwl/cfwl_themebackground.h" #include "xfa/fwl/cfwl_themetext.h" #include "xfa/fwl/cfwl_widget.h" -#include "xfa/fxgraphics/cxfa_color.h" -#include "xfa/fxgraphics/cxfa_path.h" +#include "xfa/fxgraphics/cxfa_gecolor.h" +#include "xfa/fxgraphics/cxfa_gepath.h" namespace { @@ -74,7 +74,7 @@ void CFWL_CheckBoxTP::DrawSignCheck(CXFA_Graphics* pGraphics, mt.Translate(pRtSign->left, pRtSign->top); mt.Concat(*pMatrix); pGraphics->SaveGraphState(); - pGraphics->SetFillColor(CXFA_Color(argbFill)); + pGraphics->SetFillColor(CXFA_GEColor(argbFill)); pGraphics->FillPath(m_pCheckPath.get(), FXFILL_WINDING, &mt); pGraphics->RestoreGraphState(); } @@ -83,10 +83,10 @@ void CFWL_CheckBoxTP::DrawSignCircle(CXFA_Graphics* pGraphics, const CFX_RectF* pRtSign, FX_ARGB argbFill, CFX_Matrix* pMatrix) { - CXFA_Path path; + CXFA_GEPath path; path.AddEllipse(*pRtSign); pGraphics->SaveGraphState(); - pGraphics->SetFillColor(CXFA_Color(argbFill)); + pGraphics->SetFillColor(CXFA_GEColor(argbFill)); pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); pGraphics->RestoreGraphState(); } @@ -95,7 +95,7 @@ void CFWL_CheckBoxTP::DrawSignCross(CXFA_Graphics* pGraphics, const CFX_RectF* pRtSign, FX_ARGB argbFill, CFX_Matrix* pMatrix) { - CXFA_Path path; + CXFA_GEPath path; float fRight = pRtSign->right(); float fBottom = pRtSign->bottom(); path.AddLine(pRtSign->TopLeft(), CFX_PointF(fRight, fBottom)); @@ -103,7 +103,7 @@ void CFWL_CheckBoxTP::DrawSignCross(CXFA_Graphics* pGraphics, CFX_PointF(fRight, pRtSign->top)); pGraphics->SaveGraphState(); - pGraphics->SetStrokeColor(CXFA_Color(argbFill)); + pGraphics->SetStrokeColor(CXFA_GEColor(argbFill)); pGraphics->SetLineWidth(1.0f); pGraphics->StrokePath(&path, pMatrix); pGraphics->RestoreGraphState(); @@ -113,7 +113,7 @@ void CFWL_CheckBoxTP::DrawSignDiamond(CXFA_Graphics* pGraphics, const CFX_RectF* pRtSign, FX_ARGB argbFill, CFX_Matrix* pMatrix) { - CXFA_Path path; + CXFA_GEPath path; float fWidth = pRtSign->width; float fHeight = pRtSign->height; float fBottom = pRtSign->bottom(); @@ -124,7 +124,7 @@ void CFWL_CheckBoxTP::DrawSignDiamond(CXFA_Graphics* pGraphics, path.LineTo(CFX_PointF(pRtSign->left + fWidth / 2, pRtSign->top)); pGraphics->SaveGraphState(); - pGraphics->SetFillColor(CXFA_Color(argbFill)); + pGraphics->SetFillColor(CXFA_GEColor(argbFill)); pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); pGraphics->RestoreGraphState(); } @@ -133,11 +133,11 @@ void CFWL_CheckBoxTP::DrawSignSquare(CXFA_Graphics* pGraphics, const CFX_RectF* pRtSign, FX_ARGB argbFill, CFX_Matrix* pMatrix) { - CXFA_Path path; + CXFA_GEPath path; path.AddRectangle(pRtSign->left, pRtSign->top, pRtSign->width, pRtSign->height); pGraphics->SaveGraphState(); - pGraphics->SetFillColor(CXFA_Color(argbFill)); + pGraphics->SetFillColor(CXFA_GEColor(argbFill)); pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); pGraphics->RestoreGraphState(); } @@ -146,7 +146,7 @@ void CFWL_CheckBoxTP::DrawSignStar(CXFA_Graphics* pGraphics, const CFX_RectF* pRtSign, FX_ARGB argbFill, CFX_Matrix* pMatrix) { - CXFA_Path path; + CXFA_GEPath path; float fBottom = pRtSign->bottom(); float fRadius = (pRtSign->top - fBottom) / (1 + static_cast(cos(FX_PI / 5.0f))); @@ -172,7 +172,7 @@ void CFWL_CheckBoxTP::DrawSignStar(CXFA_Graphics* pGraphics, path.LineTo(points[nNext]); } pGraphics->SaveGraphState(); - pGraphics->SetFillColor(CXFA_Color(argbFill)); + pGraphics->SetFillColor(CXFA_GEColor(argbFill)); pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); pGraphics->RestoreGraphState(); } @@ -217,7 +217,7 @@ void CFWL_CheckBoxTP::SetThemeData() { void CFWL_CheckBoxTP::InitCheckPath(float fCheckLen) { if (!m_pCheckPath) { - m_pCheckPath = pdfium::MakeUnique(); + m_pCheckPath = pdfium::MakeUnique(); float fWidth = kSignPath; float fHeight = -kSignPath; diff --git a/xfa/fwl/theme/cfwl_checkboxtp.h b/xfa/fwl/theme/cfwl_checkboxtp.h index 97ef5cf20c..e373b382a8 100644 --- a/xfa/fwl/theme/cfwl_checkboxtp.h +++ b/xfa/fwl/theme/cfwl_checkboxtp.h @@ -68,7 +68,7 @@ class CFWL_CheckBoxTP : public CFWL_WidgetTP { void InitCheckPath(float fCheckLen); std::unique_ptr m_pThemeData; - std::unique_ptr m_pCheckPath; + std::unique_ptr m_pCheckPath; private: void SetThemeData(); diff --git a/xfa/fwl/theme/cfwl_comboboxtp.cpp b/xfa/fwl/theme/cfwl_comboboxtp.cpp index 86888c0487..76953423e6 100644 --- a/xfa/fwl/theme/cfwl_comboboxtp.cpp +++ b/xfa/fwl/theme/cfwl_comboboxtp.cpp @@ -10,8 +10,8 @@ #include "xfa/fwl/cfwl_themebackground.h" #include "xfa/fwl/cfwl_widget.h" #include "xfa/fwl/ifwl_themeprovider.h" -#include "xfa/fxgraphics/cxfa_color.h" -#include "xfa/fxgraphics/cxfa_path.h" +#include "xfa/fxgraphics/cxfa_gecolor.h" +#include "xfa/fxgraphics/cxfa_gepath.h" CFWL_ComboBoxTP::CFWL_ComboBoxTP() {} @@ -27,7 +27,7 @@ void CFWL_ComboBoxTP::DrawBackground(CFWL_ThemeBackground* pParams) { break; } case CFWL_Part::Background: { - CXFA_Path path; + CXFA_GEPath path; CFX_RectF& rect = pParams->m_rtPart; path.AddRectangle(rect.left, rect.top, rect.width, rect.height); FX_ARGB argb_color; @@ -42,7 +42,7 @@ void CFWL_ComboBoxTP::DrawBackground(CFWL_ThemeBackground* pParams) { argb_color = 0xFFFFFFFF; } pParams->m_pGraphics->SaveGraphState(); - pParams->m_pGraphics->SetFillColor(CXFA_Color(argb_color)); + pParams->m_pGraphics->SetFillColor(CXFA_GEColor(argb_color)); pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, &pParams->m_matrix); pParams->m_pGraphics->RestoreGraphState(); break; @@ -63,10 +63,11 @@ void CFWL_ComboBoxTP::DrawBackground(CFWL_ThemeBackground* pParams) { void CFWL_ComboBoxTP::DrawStrethHandler(CFWL_ThemeBackground* pParams, uint32_t dwStates, CFX_Matrix* pMatrix) { - CXFA_Path path; + CXFA_GEPath path; path.AddRectangle(pParams->m_rtPart.left, pParams->m_rtPart.top, pParams->m_rtPart.width - 1, pParams->m_rtPart.height); - pParams->m_pGraphics->SetFillColor(CXFA_Color(ArgbEncode(0xff, 0xff, 0, 0))); + pParams->m_pGraphics->SetFillColor( + CXFA_GEColor(ArgbEncode(0xff, 0xff, 0, 0))); pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, &pParams->m_matrix); } diff --git a/xfa/fwl/theme/cfwl_edittp.cpp b/xfa/fwl/theme/cfwl_edittp.cpp index 9b8497a41e..4f8c4d533e 100644 --- a/xfa/fwl/theme/cfwl_edittp.cpp +++ b/xfa/fwl/theme/cfwl_edittp.cpp @@ -11,8 +11,8 @@ #include "xfa/fwl/cfwl_widget.h" #include "xfa/fxfa/cxfa_ffwidget.h" #include "xfa/fxfa/cxfa_fwltheme.h" -#include "xfa/fxgraphics/cxfa_color.h" -#include "xfa/fxgraphics/cxfa_path.h" +#include "xfa/fxgraphics/cxfa_gecolor.h" +#include "xfa/fxgraphics/cxfa_gepath.h" CFWL_EditTP::CFWL_EditTP() {} @@ -31,7 +31,7 @@ void CFWL_EditTP::DrawBackground(CFWL_ThemeBackground* pParams) { fWidth = edgeData.GetThickness(); } } - pParams->m_pGraphics->SetStrokeColor(CXFA_Color(cr)); + pParams->m_pGraphics->SetStrokeColor(CXFA_GEColor(cr)); pParams->m_pGraphics->SetLineWidth(fWidth); pParams->m_pGraphics->StrokePath(pParams->m_pPath, &pParams->m_matrix); return; @@ -46,22 +46,22 @@ void CFWL_EditTP::DrawBackground(CFWL_ThemeBackground* pParams) { if (pParams->m_pPath) { CXFA_Graphics* pGraphics = pParams->m_pGraphics; pGraphics->SaveGraphState(); - pGraphics->SetFillColor(CXFA_Color(FWLTHEME_COLOR_BKSelected)); + pGraphics->SetFillColor(CXFA_GEColor(FWLTHEME_COLOR_BKSelected)); pGraphics->FillPath(pParams->m_pPath, FXFILL_WINDING, &pParams->m_matrix); pGraphics->RestoreGraphState(); } else { - CXFA_Path path; + CXFA_GEPath path; path.AddRectangle(pParams->m_rtPart.left, pParams->m_rtPart.top, pParams->m_rtPart.width, pParams->m_rtPart.height); - CXFA_Color cr(FWLTHEME_COLOR_Background); + CXFA_GEColor cr(FWLTHEME_COLOR_Background); if (!pParams->m_bStaticBackground) { if (pParams->m_dwStates & CFWL_PartState_Disabled) - cr = CXFA_Color(FWLTHEME_COLOR_EDGERB1); + cr = CXFA_GEColor(FWLTHEME_COLOR_EDGERB1); else if (pParams->m_dwStates & CFWL_PartState_ReadOnly) - cr = CXFA_Color(ArgbEncode(255, 236, 233, 216)); + cr = CXFA_GEColor(ArgbEncode(255, 236, 233, 216)); else - cr = CXFA_Color(0xFFFFFFFF); + cr = CXFA_GEColor(0xFFFFFFFF); } pParams->m_pGraphics->SaveGraphState(); pParams->m_pGraphics->SetFillColor(cr); @@ -72,7 +72,7 @@ void CFWL_EditTP::DrawBackground(CFWL_ThemeBackground* pParams) { break; } case CFWL_Part::CombTextLine: { - pParams->m_pGraphics->SetStrokeColor(CXFA_Color(0xFF000000)); + pParams->m_pGraphics->SetStrokeColor(CXFA_GEColor(0xFF000000)); pParams->m_pGraphics->SetLineWidth(1.0f); pParams->m_pGraphics->StrokePath(pParams->m_pPath, &pParams->m_matrix); break; diff --git a/xfa/fwl/theme/cfwl_listboxtp.cpp b/xfa/fwl/theme/cfwl_listboxtp.cpp index 432be21193..c977b21120 100644 --- a/xfa/fwl/theme/cfwl_listboxtp.cpp +++ b/xfa/fwl/theme/cfwl_listboxtp.cpp @@ -9,8 +9,8 @@ #include "xfa/fwl/cfwl_listbox.h" #include "xfa/fwl/cfwl_themebackground.h" #include "xfa/fwl/cfwl_widget.h" -#include "xfa/fxgraphics/cxfa_color.h" -#include "xfa/fxgraphics/cxfa_path.h" +#include "xfa/fxgraphics/cxfa_gecolor.h" +#include "xfa/fxgraphics/cxfa_gepath.h" CFWL_ListBoxTP::CFWL_ListBoxTP() {} @@ -66,9 +66,9 @@ void CFWL_ListBoxTP::DrawListBoxItem(CXFA_Graphics* pGraphics, CFX_Matrix* pMatrix) { if (dwStates & CFWL_PartState_Selected) { pGraphics->SaveGraphState(); - pGraphics->SetFillColor(CXFA_Color(FWLTHEME_COLOR_BKSelected)); + pGraphics->SetFillColor(CXFA_GEColor(FWLTHEME_COLOR_BKSelected)); CFX_RectF rt(*prtItem); - CXFA_Path path; + CXFA_GEPath path; #if (_FX_OS_ == _FX_OS_MACOSX_) path.AddRectangle(rt.left, rt.top, rt.width - 1, rt.height - 1); #else diff --git a/xfa/fwl/theme/cfwl_monthcalendartp.cpp b/xfa/fwl/theme/cfwl_monthcalendartp.cpp index 975ca013f7..6bb3f186b7 100644 --- a/xfa/fwl/theme/cfwl_monthcalendartp.cpp +++ b/xfa/fwl/theme/cfwl_monthcalendartp.cpp @@ -12,8 +12,8 @@ #include "xfa/fwl/cfwl_themetext.h" #include "xfa/fwl/cfwl_widget.h" #include "xfa/fwl/ifwl_themeprovider.h" -#include "xfa/fxgraphics/cxfa_color.h" -#include "xfa/fxgraphics/cxfa_path.h" +#include "xfa/fxgraphics/cxfa_gecolor.h" +#include "xfa/fxgraphics/cxfa_gepath.h" CFWL_MonthCalendarTP::CFWL_MonthCalendarTP() : m_pThemeData(new MCThemeData) { SetThemeData(); @@ -104,42 +104,42 @@ void CFWL_MonthCalendarTP::DrawText(CFWL_ThemeText* pParams) { void CFWL_MonthCalendarTP::DrawTotalBK(CFWL_ThemeBackground* pParams, CFX_Matrix* pMatrix) { - CXFA_Path path; + CXFA_GEPath path; CFX_RectF rtTotal(pParams->m_rtPart); path.AddRectangle(rtTotal.left, rtTotal.top, rtTotal.width, rtTotal.height); pParams->m_pGraphics->SaveGraphState(); - pParams->m_pGraphics->SetFillColor(CXFA_Color(m_pThemeData->clrBK)); + pParams->m_pGraphics->SetFillColor(CXFA_GEColor(m_pThemeData->clrBK)); pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); pParams->m_pGraphics->RestoreGraphState(); } void CFWL_MonthCalendarTP::DrawHeadBk(CFWL_ThemeBackground* pParams, CFX_Matrix* pMatrix) { - CXFA_Path path; + CXFA_GEPath path; CFX_RectF rtHead = pParams->m_rtPart; path.AddRectangle(rtHead.left, rtHead.top, rtHead.width, rtHead.height); pParams->m_pGraphics->SaveGraphState(); - pParams->m_pGraphics->SetFillColor(CXFA_Color(m_pThemeData->clrBK)); + pParams->m_pGraphics->SetFillColor(CXFA_GEColor(m_pThemeData->clrBK)); pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); pParams->m_pGraphics->RestoreGraphState(); } void CFWL_MonthCalendarTP::DrawLButton(CFWL_ThemeBackground* pParams, CFX_Matrix* pMatrix) { - CXFA_Path path; + CXFA_GEPath path; CFX_RectF rtLBtn = pParams->m_rtPart; path.AddRectangle(rtLBtn.left, rtLBtn.top, rtLBtn.width, rtLBtn.height); pParams->m_pGraphics->SaveGraphState(); pParams->m_pGraphics->SetStrokeColor( - CXFA_Color(ArgbEncode(0xff, 205, 219, 243))); + CXFA_GEColor(ArgbEncode(0xff, 205, 219, 243))); pParams->m_pGraphics->StrokePath(&path, pMatrix); if (pParams->m_dwStates & CFWL_PartState_Pressed) { pParams->m_pGraphics->SetFillColor( - CXFA_Color(ArgbEncode(0xff, 174, 198, 242))); + CXFA_GEColor(ArgbEncode(0xff, 174, 198, 242))); pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); } else { pParams->m_pGraphics->SetFillColor( - CXFA_Color(ArgbEncode(0xff, 227, 235, 249))); + CXFA_GEColor(ArgbEncode(0xff, 227, 235, 249))); pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); } @@ -152,27 +152,27 @@ void CFWL_MonthCalendarTP::DrawLButton(CFWL_ThemeBackground* pParams, rtLBtn.bottom() - rtLBtn.height / 4)); pParams->m_pGraphics->SetStrokeColor( - CXFA_Color(ArgbEncode(0xff, 50, 104, 205))); + CXFA_GEColor(ArgbEncode(0xff, 50, 104, 205))); pParams->m_pGraphics->StrokePath(&path, pMatrix); pParams->m_pGraphics->RestoreGraphState(); } void CFWL_MonthCalendarTP::DrawRButton(CFWL_ThemeBackground* pParams, CFX_Matrix* pMatrix) { - CXFA_Path path; + CXFA_GEPath path; CFX_RectF rtRBtn = pParams->m_rtPart; path.AddRectangle(rtRBtn.left, rtRBtn.top, rtRBtn.width, rtRBtn.height); pParams->m_pGraphics->SaveGraphState(); pParams->m_pGraphics->SetStrokeColor( - CXFA_Color(ArgbEncode(0xff, 205, 219, 243))); + CXFA_GEColor(ArgbEncode(0xff, 205, 219, 243))); pParams->m_pGraphics->StrokePath(&path, pMatrix); if (pParams->m_dwStates & CFWL_PartState_Pressed) { pParams->m_pGraphics->SetFillColor( - CXFA_Color(ArgbEncode(0xff, 174, 198, 242))); + CXFA_GEColor(ArgbEncode(0xff, 174, 198, 242))); pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); } else { pParams->m_pGraphics->SetFillColor( - CXFA_Color(ArgbEncode(0xff, 227, 235, 249))); + CXFA_GEColor(ArgbEncode(0xff, 227, 235, 249))); pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); } @@ -185,31 +185,33 @@ void CFWL_MonthCalendarTP::DrawRButton(CFWL_ThemeBackground* pParams, rtRBtn.bottom() - rtRBtn.height / 4)); pParams->m_pGraphics->SetStrokeColor( - CXFA_Color(ArgbEncode(0xff, 50, 104, 205))); + CXFA_GEColor(ArgbEncode(0xff, 50, 104, 205))); pParams->m_pGraphics->StrokePath(&path, pMatrix); pParams->m_pGraphics->RestoreGraphState(); } void CFWL_MonthCalendarTP::DrawHSeperator(CFWL_ThemeBackground* pParams, CFX_Matrix* pMatrix) { - CXFA_Path path; + CXFA_GEPath path; CFX_RectF rtHSep = pParams->m_rtPart; path.MoveTo(CFX_PointF(rtHSep.left, rtHSep.top + rtHSep.height / 2)); path.LineTo(CFX_PointF(rtHSep.right(), rtHSep.top + rtHSep.height / 2)); pParams->m_pGraphics->SaveGraphState(); - pParams->m_pGraphics->SetStrokeColor(CXFA_Color(m_pThemeData->clrSeperator)); + pParams->m_pGraphics->SetStrokeColor( + CXFA_GEColor(m_pThemeData->clrSeperator)); pParams->m_pGraphics->StrokePath(&path, pMatrix); pParams->m_pGraphics->RestoreGraphState(); } void CFWL_MonthCalendarTP::DrawWeekNumSep(CFWL_ThemeBackground* pParams, CFX_Matrix* pMatrix) { - CXFA_Path path; + CXFA_GEPath path; CFX_RectF rtWeekSep = pParams->m_rtPart; path.MoveTo(rtWeekSep.TopLeft()); path.LineTo(rtWeekSep.BottomLeft()); pParams->m_pGraphics->SaveGraphState(); - pParams->m_pGraphics->SetStrokeColor(CXFA_Color(m_pThemeData->clrSeperator)); + pParams->m_pGraphics->SetStrokeColor( + CXFA_GEColor(m_pThemeData->clrSeperator)); pParams->m_pGraphics->StrokePath(&path, pMatrix); pParams->m_pGraphics->RestoreGraphState(); } @@ -218,20 +220,20 @@ void CFWL_MonthCalendarTP::DrawDatesInBK(CFWL_ThemeBackground* pParams, CFX_Matrix* pMatrix) { pParams->m_pGraphics->SaveGraphState(); if (pParams->m_dwStates & CFWL_PartState_Selected) { - CXFA_Path path; + CXFA_GEPath path; CFX_RectF rtSelDay = pParams->m_rtPart; path.AddRectangle(rtSelDay.left, rtSelDay.top, rtSelDay.width, rtSelDay.height); pParams->m_pGraphics->SetFillColor( - CXFA_Color(m_pThemeData->clrDatesSelectedBK)); + CXFA_GEColor(m_pThemeData->clrDatesSelectedBK)); pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); } else if (pParams->m_dwStates & CFWL_PartState_Hovered) { - CXFA_Path path; + CXFA_GEPath path; CFX_RectF rtSelDay = pParams->m_rtPart; path.AddRectangle(rtSelDay.left, rtSelDay.top, rtSelDay.width, rtSelDay.height); pParams->m_pGraphics->SetFillColor( - CXFA_Color(m_pThemeData->clrDatesHoverBK)); + CXFA_GEColor(m_pThemeData->clrDatesHoverBK)); pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); } pParams->m_pGraphics->RestoreGraphState(); @@ -239,26 +241,26 @@ void CFWL_MonthCalendarTP::DrawDatesInBK(CFWL_ThemeBackground* pParams, void CFWL_MonthCalendarTP::DrawDatesInCircle(CFWL_ThemeBackground* pParams, CFX_Matrix* pMatrix) { - CXFA_Path path; + CXFA_GEPath path; CFX_RectF rtSelDay = pParams->m_rtPart; path.AddRectangle(rtSelDay.left, rtSelDay.top, rtSelDay.width, rtSelDay.height); pParams->m_pGraphics->SaveGraphState(); pParams->m_pGraphics->SetStrokeColor( - CXFA_Color(m_pThemeData->clrDatesCircle)); + CXFA_GEColor(m_pThemeData->clrDatesCircle)); pParams->m_pGraphics->StrokePath(&path, pMatrix); pParams->m_pGraphics->RestoreGraphState(); } void CFWL_MonthCalendarTP::DrawTodayCircle(CFWL_ThemeBackground* pParams, CFX_Matrix* pMatrix) { - CXFA_Path path; + CXFA_GEPath path; CFX_RectF rtTodayCircle = pParams->m_rtPart; path.AddRectangle(rtTodayCircle.left, rtTodayCircle.top, rtTodayCircle.width, rtTodayCircle.height); pParams->m_pGraphics->SaveGraphState(); pParams->m_pGraphics->SetStrokeColor( - CXFA_Color(m_pThemeData->clrDatesCircle)); + CXFA_GEColor(m_pThemeData->clrDatesCircle)); pParams->m_pGraphics->StrokePath(&path, pMatrix); pParams->m_pGraphics->RestoreGraphState(); } diff --git a/xfa/fwl/theme/cfwl_pushbuttontp.cpp b/xfa/fwl/theme/cfwl_pushbuttontp.cpp index c8152f8d9b..3d3b1aabf7 100644 --- a/xfa/fwl/theme/cfwl_pushbuttontp.cpp +++ b/xfa/fwl/theme/cfwl_pushbuttontp.cpp @@ -10,8 +10,8 @@ #include "xfa/fwl/cfwl_themebackground.h" #include "xfa/fwl/cfwl_widget.h" #include "xfa/fwl/ifwl_themeprovider.h" -#include "xfa/fxgraphics/cxfa_color.h" -#include "xfa/fxgraphics/cxfa_path.h" +#include "xfa/fxgraphics/cxfa_gecolor.h" +#include "xfa/fxgraphics/cxfa_gepath.h" #define PUSHBUTTON_SIZE_Corner 2 @@ -32,7 +32,7 @@ void CFWL_PushButtonTP::DrawBackground(CFWL_ThemeBackground* pParams) { float fRight = rect.right(); float fBottom = rect.bottom(); - CXFA_Path strokePath; + CXFA_GEPath strokePath; strokePath.MoveTo( CFX_PointF(rect.left + PUSHBUTTON_SIZE_Corner, rect.top)); strokePath.LineTo(CFX_PointF(fRight - PUSHBUTTON_SIZE_Corner, rect.top)); @@ -48,7 +48,7 @@ void CFWL_PushButtonTP::DrawBackground(CFWL_ThemeBackground* pParams) { strokePath.LineTo( CFX_PointF(rect.left + PUSHBUTTON_SIZE_Corner, rect.top)); - CXFA_Path fillPath; + CXFA_GEPath fillPath; fillPath.AddSubpath(&strokePath); CXFA_Graphics* pGraphics = pParams->m_pGraphics; @@ -67,14 +67,14 @@ void CFWL_PushButtonTP::DrawBackground(CFWL_ThemeBackground* pParams) { m_pThemeData->clrEnd[iColor], &fillPath, FXFILL_ALTERNATE, &pParams->m_matrix); - pGraphics->SetStrokeColor(CXFA_Color(m_pThemeData->clrBorder[iColor])); + pGraphics->SetStrokeColor(CXFA_GEColor(m_pThemeData->clrBorder[iColor])); pGraphics->StrokePath(&strokePath, &pParams->m_matrix); fillPath.Clear(); fillPath.AddRectangle(rtInner.left, rtInner.top, rtInner.width, rtInner.height); - pGraphics->SetFillColor(CXFA_Color(m_pThemeData->clrFill[iColor])); + pGraphics->SetFillColor(CXFA_GEColor(m_pThemeData->clrFill[iColor])); pGraphics->FillPath(&fillPath, FXFILL_WINDING, &pParams->m_matrix); if (pParams->m_dwStates & CFWL_PartState_Focused) { rtInner.Inflate(1, 1, 0, 0); diff --git a/xfa/fwl/theme/cfwl_scrollbartp.cpp b/xfa/fwl/theme/cfwl_scrollbartp.cpp index 6b998a9641..d94eed0ebf 100644 --- a/xfa/fwl/theme/cfwl_scrollbartp.cpp +++ b/xfa/fwl/theme/cfwl_scrollbartp.cpp @@ -10,8 +10,8 @@ #include "xfa/fwl/cfwl_themebackground.h" #include "xfa/fwl/cfwl_widget.h" #include "xfa/fwl/ifwl_themeprovider.h" -#include "xfa/fxgraphics/cxfa_color.h" -#include "xfa/fxgraphics/cxfa_path.h" +#include "xfa/fxgraphics/cxfa_gecolor.h" +#include "xfa/fxgraphics/cxfa_gepath.h" namespace { @@ -80,7 +80,7 @@ void CFWL_ScrollBarTP::DrawThumbBtn(CXFA_Graphics* pGraphics, if (eState < FWLTHEME_STATE_Normal || eState > FWLTHEME_STATE_Disable) return; - CXFA_Path path; + CXFA_GEPath path; CFX_RectF rect(*pRect); if (bVert) { rect.Deflate(1, 0); @@ -94,7 +94,7 @@ void CFWL_ScrollBarTP::DrawThumbBtn(CXFA_Graphics* pGraphics, FXFILL_WINDING, pMatrix); pGraphics->SaveGraphState(); pGraphics->SetStrokeColor( - CXFA_Color(m_pThemeData->clrBtnBorder[eState - 1])); + CXFA_GEColor(m_pThemeData->clrBtnBorder[eState - 1])); pGraphics->StrokePath(&path, pMatrix); pGraphics->RestoreGraphState(); } else { @@ -109,7 +109,7 @@ void CFWL_ScrollBarTP::DrawThumbBtn(CXFA_Graphics* pGraphics, FXFILL_WINDING, pMatrix); pGraphics->SaveGraphState(); pGraphics->SetStrokeColor( - CXFA_Color(m_pThemeData->clrBtnBorder[eState - 1])); + CXFA_GEColor(m_pThemeData->clrBtnBorder[eState - 1])); pGraphics->StrokePath(&path, pMatrix); pGraphics->RestoreGraphState(); } @@ -120,7 +120,7 @@ void CFWL_ScrollBarTP::DrawPaw(CXFA_Graphics* pGraphics, bool bVert, FWLTHEME_STATE eState, CFX_Matrix* pMatrix) { - CXFA_Path path; + CXFA_GEPath path; if (bVert) { float fPawLen = kPawLength; if (pRect->width / 2 <= fPawLen) { @@ -140,7 +140,7 @@ void CFWL_ScrollBarTP::DrawPaw(CXFA_Graphics* pGraphics, pGraphics->SetLineWidth(1); pGraphics->SetStrokeColor( - CXFA_Color(m_pThemeData->clrPawColorLight[eState - 1])); + CXFA_GEColor(m_pThemeData->clrPawColorLight[eState - 1])); pGraphics->StrokePath(&path, nullptr); fX++; @@ -156,7 +156,7 @@ void CFWL_ScrollBarTP::DrawPaw(CXFA_Graphics* pGraphics, pGraphics->SetLineWidth(1); pGraphics->SetStrokeColor( - CXFA_Color(m_pThemeData->clrPawColorDark[eState - 1])); + CXFA_GEColor(m_pThemeData->clrPawColorDark[eState - 1])); pGraphics->StrokePath(&path, pMatrix); } else { float fPawLen = kPawLength; @@ -177,7 +177,7 @@ void CFWL_ScrollBarTP::DrawPaw(CXFA_Graphics* pGraphics, pGraphics->SetLineWidth(1); pGraphics->SetStrokeColor( - CXFA_Color(m_pThemeData->clrPawColorLight[eState - 1])); + CXFA_GEColor(m_pThemeData->clrPawColorLight[eState - 1])); pGraphics->StrokePath(&path, pMatrix); fY++; @@ -193,7 +193,7 @@ void CFWL_ScrollBarTP::DrawPaw(CXFA_Graphics* pGraphics, pGraphics->SetLineWidth(1); pGraphics->SetStrokeColor( - CXFA_Color(m_pThemeData->clrPawColorDark[eState - 1])); + CXFA_GEColor(m_pThemeData->clrPawColorDark[eState - 1])); pGraphics->StrokePath(&path, pMatrix); } } @@ -208,7 +208,7 @@ void CFWL_ScrollBarTP::DrawTrack(CXFA_Graphics* pGraphics, return; pGraphics->SaveGraphState(); - CXFA_Path path; + CXFA_GEPath path; float fRight = pRect->right(); float fBottom = pRect->bottom(); if (bVert) { @@ -218,7 +218,7 @@ void CFWL_ScrollBarTP::DrawTrack(CXFA_Graphics* pGraphics, path.AddRectangle(pRect->left, pRect->top, pRect->width, 1); path.AddRectangle(pRect->left, fBottom - 1, pRect->width, 1); } - pGraphics->SetFillColor(CXFA_Color(ArgbEncode(255, 238, 237, 229))); + pGraphics->SetFillColor(CXFA_GEColor(ArgbEncode(255, 238, 237, 229))); pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); path.Clear(); path.AddRectangle(pRect->left + 1, pRect->top, pRect->width - 2, diff --git a/xfa/fwl/theme/cfwl_widgettp.cpp b/xfa/fwl/theme/cfwl_widgettp.cpp index b2c1c9aa74..8a2754b4ad 100644 --- a/xfa/fwl/theme/cfwl_widgettp.cpp +++ b/xfa/fwl/theme/cfwl_widgettp.cpp @@ -19,9 +19,9 @@ #include "xfa/fwl/cfwl_widget.h" #include "xfa/fwl/cfwl_widgetmgr.h" #include "xfa/fwl/ifwl_themeprovider.h" -#include "xfa/fxgraphics/cxfa_color.h" -#include "xfa/fxgraphics/cxfa_path.h" -#include "xfa/fxgraphics/cxfa_shading.h" +#include "xfa/fxgraphics/cxfa_gecolor.h" +#include "xfa/fxgraphics/cxfa_gepath.h" +#include "xfa/fxgraphics/cxfa_geshading.h" CFWL_WidgetTP::CFWL_WidgetTP() : m_dwRefCount(1), m_pFDEFont(nullptr), m_pColorData(nullptr) {} @@ -102,12 +102,12 @@ void CFWL_WidgetTP::DrawBorder(CXFA_Graphics* pGraphics, if (!pGraphics || !pRect) return; - CXFA_Path path; + CXFA_GEPath path; path.AddRectangle(pRect->left, pRect->top, pRect->width, pRect->height); path.AddRectangle(pRect->left + 1, pRect->top + 1, pRect->width - 2, pRect->height - 2); pGraphics->SaveGraphState(); - pGraphics->SetFillColor(CXFA_Color(ArgbEncode(255, 0, 0, 0))); + pGraphics->SetFillColor(CXFA_GEColor(ArgbEncode(255, 0, 0, 0))); pGraphics->FillPath(&path, FXFILL_ALTERNATE, pMatrix); pGraphics->RestoreGraphState(); } @@ -125,10 +125,10 @@ void CFWL_WidgetTP::FillSoildRect(CXFA_Graphics* pGraphics, if (!pGraphics || !pRect) return; - CXFA_Path path; + CXFA_GEPath path; path.AddRectangle(pRect->left, pRect->top, pRect->width, pRect->height); pGraphics->SaveGraphState(); - pGraphics->SetFillColor(CXFA_Color(fillColor)); + pGraphics->SetFillColor(CXFA_GEColor(fillColor)); pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); pGraphics->RestoreGraphState(); } @@ -140,7 +140,7 @@ void CFWL_WidgetTP::DrawAxialShading(CXFA_Graphics* pGraphics, float fy2, FX_ARGB beginColor, FX_ARGB endColor, - CXFA_Path* path, + CXFA_GEPath* path, int32_t fillMode, CFX_Matrix* pMatrix) { if (!pGraphics || !path) @@ -148,9 +148,10 @@ void CFWL_WidgetTP::DrawAxialShading(CXFA_Graphics* pGraphics, CFX_PointF begPoint(fx1, fy1); CFX_PointF endPoint(fx2, fy2); - CXFA_Shading shading(begPoint, endPoint, false, false, beginColor, endColor); + CXFA_GEShading shading(begPoint, endPoint, false, false, beginColor, + endColor); pGraphics->SaveGraphState(); - pGraphics->SetFillColor(CXFA_Color(&shading)); + pGraphics->SetFillColor(CXFA_GEColor(&shading)); pGraphics->FillPath(path, fillMode, pMatrix); pGraphics->RestoreGraphState(); } @@ -162,10 +163,10 @@ void CFWL_WidgetTP::DrawFocus(CXFA_Graphics* pGraphics, return; float DashPattern[2] = {1, 1}; - CXFA_Path path; + CXFA_GEPath path; path.AddRectangle(pRect->left, pRect->top, pRect->width, pRect->height); pGraphics->SaveGraphState(); - pGraphics->SetStrokeColor(CXFA_Color(0xFF000000)); + pGraphics->SetStrokeColor(CXFA_GEColor(0xFF000000)); pGraphics->SetLineDash(0.0f, DashPattern, 2); pGraphics->StrokePath(&path, pMatrix); pGraphics->RestoreGraphState(); @@ -182,7 +183,7 @@ void CFWL_WidgetTP::DrawArrow(CXFA_Graphics* pGraphics, (float)(((pRect->width - (bVert ? 9 : 6)) / 2 + pRect->left) + 0.5); float fTop = (float)(((pRect->height - (bVert ? 6 : 9)) / 2 + pRect->top) + 0.5); - CXFA_Path path; + CXFA_GEPath path; switch (eDict) { case FWLTHEME_DIRECTION_Down: { path.MoveTo(CFX_PointF(fLeft, fTop + 1)); @@ -221,7 +222,7 @@ void CFWL_WidgetTP::DrawArrow(CXFA_Graphics* pGraphics, break; } } - pGraphics->SetFillColor(CXFA_Color(argSign)); + pGraphics->SetFillColor(CXFA_GEColor(argSign)); pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); } @@ -231,7 +232,7 @@ void CFWL_WidgetTP::DrawBtn(CXFA_Graphics* pGraphics, CFX_Matrix* pMatrix) { InitializeArrowColorData(); - CXFA_Path path; + CXFA_GEPath path; float fRight = pRect->right(); float fBottom = pRect->bottom(); path.AddRectangle(pRect->left, pRect->top, pRect->width, pRect->height); @@ -240,7 +241,7 @@ void CFWL_WidgetTP::DrawBtn(CXFA_Graphics* pGraphics, m_pColorData->clrEnd[eState - 1], &path, FXFILL_WINDING, pMatrix); - pGraphics->SetStrokeColor(CXFA_Color(m_pColorData->clrBorder[eState - 1])); + pGraphics->SetStrokeColor(CXFA_GEColor(m_pColorData->clrBorder[eState - 1])); pGraphics->StrokePath(&path, pMatrix); } diff --git a/xfa/fwl/theme/cfwl_widgettp.h b/xfa/fwl/theme/cfwl_widgettp.h index a7a217f4a0..5f143fe7d9 100644 --- a/xfa/fwl/theme/cfwl_widgettp.h +++ b/xfa/fwl/theme/cfwl_widgettp.h @@ -72,7 +72,7 @@ class CFWL_WidgetTP { float fy2, FX_ARGB beginColor, FX_ARGB endColor, - CXFA_Path* path, + CXFA_GEPath* path, int32_t fillMode = FXFILL_WINDING, CFX_Matrix* pMatrix = nullptr); void DrawFocus(CXFA_Graphics* pGraphics, diff --git a/xfa/fxfa/cxfa_fffield.cpp b/xfa/fxfa/cxfa_fffield.cpp index 0ef6722d7f..9758eb76dc 100644 --- a/xfa/fxfa/cxfa_fffield.cpp +++ b/xfa/fxfa/cxfa_fffield.cpp @@ -23,8 +23,8 @@ #include "xfa/fxfa/cxfa_fwltheme.h" #include "xfa/fxfa/cxfa_textlayout.h" #include "xfa/fxfa/parser/cxfa_node.h" -#include "xfa/fxgraphics/cxfa_color.h" -#include "xfa/fxgraphics/cxfa_path.h" +#include "xfa/fxgraphics/cxfa_gecolor.h" +#include "xfa/fxgraphics/cxfa_gepath.h" namespace { @@ -89,8 +89,8 @@ void CXFA_FFField::DrawHighlight(CXFA_Graphics* pGS, CXFA_FFDoc* pDoc = GetDoc(); pGS->SetFillColor( - CXFA_Color(pDoc->GetDocEnvironment()->GetHighlightColor(pDoc))); - CXFA_Path path; + CXFA_GEColor(pDoc->GetDocEnvironment()->GetHighlightColor(pDoc))); + CXFA_GEPath path; if (bEllipse) path.AddEllipse(m_rtUI); else @@ -103,13 +103,13 @@ void CXFA_FFField::DrawFocus(CXFA_Graphics* pGS, CFX_Matrix* pMatrix) { if (!(m_dwStatus & XFA_WidgetStatus_Focused)) return; - pGS->SetStrokeColor(CXFA_Color(0xFF000000)); + pGS->SetStrokeColor(CXFA_GEColor(0xFF000000)); float DashPattern[2] = {1, 1}; pGS->SetLineDash(0.0f, DashPattern, 2); pGS->SetLineWidth(0); - CXFA_Path path; + CXFA_GEPath path; path.AddRectangle(m_rtUI.left, m_rtUI.top, m_rtUI.width, m_rtUI.height); pGS->StrokePath(&path, pMatrix); } diff --git a/xfa/fxfa/cxfa_ffline.cpp b/xfa/fxfa/cxfa_ffline.cpp index de37e50bf9..d24444c401 100644 --- a/xfa/fxfa/cxfa_ffline.cpp +++ b/xfa/fxfa/cxfa_ffline.cpp @@ -6,9 +6,9 @@ #include "xfa/fxfa/cxfa_ffline.h" -#include "xfa/fxgraphics/cxfa_color.h" +#include "xfa/fxgraphics/cxfa_gecolor.h" +#include "xfa/fxgraphics/cxfa_gepath.h" #include "xfa/fxgraphics/cxfa_graphics.h" -#include "xfa/fxgraphics/cxfa_path.h" CXFA_FFLine::CXFA_FFLine(CXFA_WidgetAcc* pDataAcc) : CXFA_FFDraw(pDataAcc) {} @@ -81,7 +81,7 @@ void CXFA_FFLine::RenderWidget(CXFA_Graphics* pGS, XFA_RectWidthoutMargin(rtLine, marginData); GetRectFromHand(rtLine, lineData.GetHand(), fLineWidth); - CXFA_Path linePath; + CXFA_GEPath linePath; if (lineData.GetSlope() && rtLine.right() > 0.0f && rtLine.bottom() > 0.0f) linePath.AddLine(rtLine.TopRight(), rtLine.BottomLeft()); else @@ -91,7 +91,7 @@ void CXFA_FFLine::RenderWidget(CXFA_Graphics* pGS, pGS->SetLineWidth(fLineWidth); pGS->EnableActOnDash(); XFA_StrokeTypeSetLineDash(pGS, iStrokeType, iCap); - pGS->SetStrokeColor(CXFA_Color(lineColor)); + pGS->SetStrokeColor(CXFA_GEColor(lineColor)); pGS->SetLineCap(XFA_LineCapToFXGE(iCap)); pGS->StrokePath(&linePath, &mtRotate); pGS->RestoreGraphState(); diff --git a/xfa/fxfa/cxfa_ffpushbutton.cpp b/xfa/fxfa/cxfa_ffpushbutton.cpp index c966cdacfd..1f5d9021ee 100644 --- a/xfa/fxfa/cxfa_ffpushbutton.cpp +++ b/xfa/fxfa/cxfa_ffpushbutton.cpp @@ -18,8 +18,8 @@ #include "xfa/fxfa/cxfa_ffwidget.h" #include "xfa/fxfa/cxfa_textlayout.h" #include "xfa/fxfa/cxfa_textprovider.h" -#include "xfa/fxgraphics/cxfa_color.h" -#include "xfa/fxgraphics/cxfa_path.h" +#include "xfa/fxgraphics/cxfa_gecolor.h" +#include "xfa/fxgraphics/cxfa_gepath.h" CXFA_FFPushButton::CXFA_FFPushButton(CXFA_WidgetAcc* pDataAcc) : CXFA_FFField(pDataAcc), m_pOldDelegate(nullptr) {} @@ -210,9 +210,9 @@ void CXFA_FFPushButton::OnDrawWidget(CXFA_Graphics* pGraphics, CFX_RectF rtFill(0, 0, m_pNormalWidget->GetWidgetRect().Size()); float fLineWith = GetLineWidth(); rtFill.Deflate(fLineWith, fLineWith); - CXFA_Path path; + CXFA_GEPath path; path.AddRectangle(rtFill.left, rtFill.top, rtFill.width, rtFill.height); - pGraphics->SetFillColor(CXFA_Color(FXARGB_MAKE(128, 128, 255, 255))); + pGraphics->SetFillColor(CXFA_GEColor(FXARGB_MAKE(128, 128, 255, 255))); pGraphics->FillPath(&path, FXFILL_WINDING, &matrix); } return; @@ -222,10 +222,10 @@ void CXFA_FFPushButton::OnDrawWidget(CXFA_Graphics* pGraphics, if ((m_pNormalWidget->GetStates() & FWL_STATE_PSB_Pressed) && (m_pNormalWidget->GetStates() & FWL_STATE_PSB_Hovered)) { float fLineWidth = GetLineWidth(); - pGraphics->SetStrokeColor(CXFA_Color(FXARGB_MAKE(255, 128, 255, 255))); + pGraphics->SetStrokeColor(CXFA_GEColor(FXARGB_MAKE(255, 128, 255, 255))); pGraphics->SetLineWidth(fLineWidth); - CXFA_Path path; + CXFA_GEPath path; CFX_RectF rect = m_pNormalWidget->GetWidgetRect(); path.AddRectangle(0, 0, rect.width, rect.height); pGraphics->StrokePath(&path, &matrix); diff --git a/xfa/fxfa/cxfa_ffwidget.cpp b/xfa/fxfa/cxfa_ffwidget.cpp index d3a6498c4e..6bcf524586 100644 --- a/xfa/fxfa/cxfa_ffwidget.cpp +++ b/xfa/fxfa/cxfa_ffwidget.cpp @@ -31,17 +31,17 @@ #include "xfa/fxfa/cxfa_widgetacc.h" #include "xfa/fxfa/parser/cxfa_cornerdata.h" #include "xfa/fxfa/parser/cxfa_node.h" -#include "xfa/fxgraphics/cxfa_color.h" +#include "xfa/fxgraphics/cxfa_gecolor.h" +#include "xfa/fxgraphics/cxfa_gepath.h" +#include "xfa/fxgraphics/cxfa_gepattern.h" +#include "xfa/fxgraphics/cxfa_geshading.h" #include "xfa/fxgraphics/cxfa_graphics.h" -#include "xfa/fxgraphics/cxfa_path.h" -#include "xfa/fxgraphics/cxfa_pattern.h" -#include "xfa/fxgraphics/cxfa_shading.h" namespace { void XFA_BOX_GetPath_Arc(const CXFA_BoxData& boxData, CFX_RectF rtDraw, - CXFA_Path& fillPath, + CXFA_GEPath& fillPath, uint32_t dwFlags) { float a, b; a = rtDraw.width / 2.0f; @@ -68,7 +68,7 @@ void XFA_BOX_GetPath_Arc(const CXFA_BoxData& boxData, void XFA_BOX_GetPath(const std::vector& strokes, CFX_RectF rtWidget, - CXFA_Path& path, + CXFA_GEPath& path, int32_t nIndex, bool bStart, bool bCorner) { @@ -237,7 +237,7 @@ void XFA_BOX_GetPath(const std::vector& strokes, void XFA_BOX_GetFillPath(const CXFA_BoxData& boxData, const std::vector& strokes, CFX_RectF rtWidget, - CXFA_Path& fillPath, + CXFA_GEPath& fillPath, uint16_t dwFlags) { if (boxData.IsArc() || (dwFlags & XFA_DRAWBOX_ForceRound) != 0) { float fThickness = std::fmax(0.0, boxData.GetEdgeData(0).GetThickness()); @@ -386,7 +386,7 @@ void XFA_BOX_GetFillPath(const CXFA_BoxData& boxData, void XFA_BOX_Fill_Radial(const CXFA_BoxData& boxData, CXFA_Graphics* pGS, - CXFA_Path& fillPath, + CXFA_GEPath& fillPath, CFX_RectF rtFill, const CFX_Matrix& matrix) { CXFA_FillData fillData = boxData.GetFillData(false); @@ -398,18 +398,18 @@ void XFA_BOX_Fill_Radial(const CXFA_BoxData& boxData, crEnd = crStart; crStart = temp; } - CXFA_Shading shading(rtFill.Center(), rtFill.Center(), 0, - sqrt(rtFill.Width() * rtFill.Width() + - rtFill.Height() * rtFill.Height()) / - 2, - true, true, crStart, crEnd); - pGS->SetFillColor(CXFA_Color(&shading)); + CXFA_GEShading shading(rtFill.Center(), rtFill.Center(), 0, + sqrt(rtFill.Width() * rtFill.Width() + + rtFill.Height() * rtFill.Height()) / + 2, + true, true, crStart, crEnd); + pGS->SetFillColor(CXFA_GEColor(&shading)); pGS->FillPath(&fillPath, FXFILL_WINDING, &matrix); } void XFA_BOX_Fill_Pattern(const CXFA_BoxData& boxData, CXFA_Graphics* pGS, - CXFA_Path& fillPath, + CXFA_GEPath& fillPath, CFX_RectF rtFill, const CFX_Matrix& matrix) { CXFA_FillData fillData = boxData.GetFillData(false); @@ -437,14 +437,14 @@ void XFA_BOX_Fill_Pattern(const CXFA_BoxData& boxData, break; } - CXFA_Pattern pattern(iHatch, crEnd, crStart); - pGS->SetFillColor(CXFA_Color(&pattern, 0x0)); + CXFA_GEPattern pattern(iHatch, crEnd, crStart); + pGS->SetFillColor(CXFA_GEColor(&pattern, 0x0)); pGS->FillPath(&fillPath, FXFILL_WINDING, &matrix); } void XFA_BOX_Fill_Linear(const CXFA_BoxData& boxData, CXFA_Graphics* pGS, - CXFA_Path& fillPath, + CXFA_GEPath& fillPath, CFX_RectF rtFill, const CFX_Matrix& matrix) { CXFA_FillData fillData = boxData.GetFillData(false); @@ -473,8 +473,8 @@ void XFA_BOX_Fill_Linear(const CXFA_BoxData& boxData, default: break; } - CXFA_Shading shading(ptStart, ptEnd, false, false, crStart, crEnd); - pGS->SetFillColor(CXFA_Color(&shading)); + CXFA_GEShading shading(ptStart, ptEnd, false, false, crStart, crEnd); + pGS->SetFillColor(CXFA_GEColor(&shading)); pGS->FillPath(&fillPath, FXFILL_WINDING, &matrix); } @@ -489,7 +489,7 @@ void XFA_BOX_Fill(const CXFA_BoxData& boxData, return; pGS->SaveGraphState(); - CXFA_Path fillPath; + CXFA_GEPath fillPath; XFA_BOX_GetFillPath(boxData, strokes, rtWidget, fillPath, (dwFlags & XFA_DRAWBOX_ForceRound) != 0); fillPath.Close(); @@ -517,7 +517,7 @@ void XFA_BOX_Fill(const CXFA_BoxData& boxData, } else { cr = fillData.GetColor(); } - pGS->SetFillColor(CXFA_Color(cr)); + pGS->SetFillColor(CXFA_GEColor(cr)); pGS->FillPath(&fillPath, FXFILL_WINDING, &matrix); } break; } @@ -525,7 +525,7 @@ void XFA_BOX_Fill(const CXFA_BoxData& boxData, } void XFA_BOX_StrokePath(const CXFA_StrokeData& strokeData, - CXFA_Path* pPath, + CXFA_GEPath* pPath, CXFA_Graphics* pGS, const CFX_Matrix& matrix) { if (!strokeData || !strokeData.IsVisible()) @@ -544,7 +544,7 @@ void XFA_BOX_StrokePath(const CXFA_StrokeData& strokeData, pGS->SetLineCap(CFX_GraphStateData::LineCapButt); XFA_StrokeTypeSetLineDash(pGS, strokeData.GetStrokeType(), XFA_ATTRIBUTEENUM_Butt); - pGS->SetStrokeColor(CXFA_Color(strokeData.GetColor())); + pGS->SetStrokeColor(CXFA_GEColor(strokeData.GetColor())); pGS->StrokePath(pPath, &matrix); pGS->RestoreGraphState(); } @@ -581,7 +581,7 @@ void XFA_BOX_StrokeArc(const CXFA_BoxData& boxData, if (fHalf < 0.001f) return; - CXFA_Path arcPath; + CXFA_GEPath arcPath; XFA_BOX_GetPath_Arc(boxData, rtWidget, arcPath, dwFlags); XFA_BOX_StrokePath(edgeData, &arcPath, pGS, matrix); return; @@ -607,30 +607,30 @@ void XFA_BOX_StrokeArc(const CXFA_BoxData& boxData, startAngle = startAngle * FX_PI / 180.0f; sweepAngle = -sweepAngle * FX_PI / 180.0f; - CXFA_Path arcPath; + CXFA_GEPath arcPath; arcPath.AddArc(rtWidget.TopLeft(), rtWidget.Size(), 3.0f * FX_PI / 4.0f, FX_PI); - pGS->SetStrokeColor(CXFA_Color(0xFF808080)); + pGS->SetStrokeColor(CXFA_GEColor(0xFF808080)); pGS->StrokePath(&arcPath, &matrix); arcPath.Clear(); arcPath.AddArc(rtWidget.TopLeft(), rtWidget.Size(), -1.0f * FX_PI / 4.0f, FX_PI); - pGS->SetStrokeColor(CXFA_Color(0xFFFFFFFF)); + pGS->SetStrokeColor(CXFA_GEColor(0xFFFFFFFF)); pGS->StrokePath(&arcPath, &matrix); rtWidget.Deflate(fHalf, fHalf); arcPath.Clear(); arcPath.AddArc(rtWidget.TopLeft(), rtWidget.Size(), 3.0f * FX_PI / 4.0f, FX_PI); - pGS->SetStrokeColor(CXFA_Color(0xFF404040)); + pGS->SetStrokeColor(CXFA_GEColor(0xFF404040)); pGS->StrokePath(&arcPath, &matrix); arcPath.Clear(); arcPath.AddArc(rtWidget.TopLeft(), rtWidget.Size(), -1.0f * FX_PI / 4.0f, FX_PI); - pGS->SetStrokeColor(CXFA_Color(0xFFC0C0C0)); + pGS->SetStrokeColor(CXFA_GEColor(0xFFC0C0C0)); pGS->StrokePath(&arcPath, &matrix); pGS->RestoreGraphState(); } @@ -643,7 +643,7 @@ void XFA_Draw3DRect(CXFA_Graphics* pGraphic, FX_ARGB argbBottomRight) { float fBottom = rt.bottom(); float fRight = rt.right(); - CXFA_Path pathLT; + CXFA_GEPath pathLT; pathLT.MoveTo(CFX_PointF(rt.left, fBottom)); pathLT.LineTo(CFX_PointF(rt.left, rt.top)); pathLT.LineTo(CFX_PointF(fRight, rt.top)); @@ -651,10 +651,10 @@ void XFA_Draw3DRect(CXFA_Graphics* pGraphic, pathLT.LineTo(CFX_PointF(rt.left + fLineWidth, rt.top + fLineWidth)); pathLT.LineTo(CFX_PointF(rt.left + fLineWidth, fBottom - fLineWidth)); pathLT.LineTo(CFX_PointF(rt.left, fBottom)); - pGraphic->SetFillColor(CXFA_Color(argbTopLeft)); + pGraphic->SetFillColor(CXFA_GEColor(argbTopLeft)); pGraphic->FillPath(&pathLT, FXFILL_WINDING, &matrix); - CXFA_Path pathRB; + CXFA_GEPath pathRB; pathRB.MoveTo(CFX_PointF(fRight, rt.top)); pathRB.LineTo(CFX_PointF(fRight, fBottom)); pathRB.LineTo(CFX_PointF(rt.left, fBottom)); @@ -662,7 +662,7 @@ void XFA_Draw3DRect(CXFA_Graphics* pGraphic, pathRB.LineTo(CFX_PointF(fRight - fLineWidth, fBottom - fLineWidth)); pathRB.LineTo(CFX_PointF(fRight - fLineWidth, rt.top + fLineWidth)); pathRB.LineTo(CFX_PointF(fRight, rt.top)); - pGraphic->SetFillColor(CXFA_Color(argbBottomRight)); + pGraphic->SetFillColor(CXFA_GEColor(argbBottomRight)); pGraphic->FillPath(&pathRB, FXFILL_WINDING, &matrix); } @@ -674,10 +674,10 @@ void XFA_BOX_Stroke_3DRect_Lowered(CXFA_Graphics* pGS, CFX_RectF rtInner(rt); rtInner.Deflate(fHalfWidth, fHalfWidth); - CXFA_Path path; + CXFA_GEPath path; path.AddRectangle(rt.left, rt.top, rt.width, rt.height); path.AddRectangle(rtInner.left, rtInner.top, rtInner.width, rtInner.height); - pGS->SetFillColor(CXFA_Color(0xFF000000)); + pGS->SetFillColor(CXFA_GEColor(0xFF000000)); pGS->FillPath(&path, FXFILL_ALTERNATE, &matrix); XFA_Draw3DRect(pGS, rtInner, fHalfWidth, matrix, 0xFF808080, 0xFFC0C0C0); } @@ -690,10 +690,10 @@ void XFA_BOX_Stroke_3DRect_Raised(CXFA_Graphics* pGS, CFX_RectF rtInner(rt); rtInner.Deflate(fHalfWidth, fHalfWidth); - CXFA_Path path; + CXFA_GEPath path; path.AddRectangle(rt.left, rt.top, rt.width, rt.height); path.AddRectangle(rtInner.left, rtInner.top, rtInner.width, rtInner.height); - pGS->SetFillColor(CXFA_Color(0xFF000000)); + pGS->SetFillColor(CXFA_GEColor(0xFF000000)); pGS->FillPath(&path, FXFILL_ALTERNATE, &matrix); XFA_Draw3DRect(pGS, rtInner, fHalfWidth, matrix, 0xFFFFFFFF, 0xFF808080); } @@ -781,7 +781,7 @@ void XFA_BOX_Stroke_Rect(CXFA_BoxData boxData, } } bool bStart = true; - CXFA_Path path; + CXFA_GEPath path; for (int32_t i = 0; i < 8; i++) { CXFA_StrokeData strokeData = strokes[i]; if ((i % 1) == 0 && strokeData.GetRadius() < 0) { diff --git a/xfa/fxfa/cxfa_fwltheme.cpp b/xfa/fxfa/cxfa_fwltheme.cpp index 61c4e25f1d..440c41dd5b 100644 --- a/xfa/fxfa/cxfa_fwltheme.cpp +++ b/xfa/fxfa/cxfa_fwltheme.cpp @@ -24,7 +24,7 @@ #include "xfa/fwl/cfwl_themetext.h" #include "xfa/fxfa/cxfa_ffapp.h" #include "xfa/fxfa/cxfa_ffwidget.h" -#include "xfa/fxgraphics/cxfa_color.h" +#include "xfa/fxgraphics/cxfa_gecolor.h" namespace { diff --git a/xfa/fxgraphics/cxfa_color.cpp b/xfa/fxgraphics/cxfa_color.cpp deleted file mode 100644 index 731d144c41..0000000000 --- a/xfa/fxgraphics/cxfa_color.cpp +++ /dev/null @@ -1,46 +0,0 @@ -// 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 "xfa/fxgraphics/cxfa_color.h" - -CXFA_Color::CXFA_Color() : m_type(Invalid) {} - -CXFA_Color::CXFA_Color(const FX_ARGB argb) : m_type(Solid), m_argb(argb) { - m_pointer.pattern = nullptr; -} - -CXFA_Color::CXFA_Color(CXFA_Pattern* pattern, const FX_ARGB argb) - : m_type(Pattern), m_argb(argb) { - m_pointer.pattern = pattern; -} - -CXFA_Color::CXFA_Color(CXFA_Shading* shading) : m_type(Shading), m_argb(0) { - m_pointer.shading = shading; -} - -CXFA_Color::~CXFA_Color() {} - -CXFA_Color& CXFA_Color::operator=(const CXFA_Color& that) { - if (this != &that) { - m_type = that.m_type; - switch (m_type) { - case Solid: - m_argb = that.m_argb; - m_pointer.pattern = nullptr; - break; - case Pattern: - m_argb = that.m_argb; - m_pointer.pattern = that.m_pointer.pattern; - break; - case Shading: - m_argb = 0; - m_pointer.shading = that.m_pointer.shading; - default: - break; - } - } - return *this; -} diff --git a/xfa/fxgraphics/cxfa_color.h b/xfa/fxgraphics/cxfa_color.h deleted file mode 100644 index 4ae790507b..0000000000 --- a/xfa/fxgraphics/cxfa_color.h +++ /dev/null @@ -1,50 +0,0 @@ -// 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 XFA_FXGRAPHICS_CXFA_COLOR_H_ -#define XFA_FXGRAPHICS_CXFA_COLOR_H_ - -#include "core/fxge/fx_dib.h" - -class CXFA_Pattern; -class CXFA_Shading; - -class CXFA_Color { - public: - enum Type { Invalid, Solid, Pattern, Shading }; - - CXFA_Color(); - explicit CXFA_Color(const FX_ARGB argb); - explicit CXFA_Color(CXFA_Shading* shading); - CXFA_Color(CXFA_Pattern* pattern, const FX_ARGB argb); - ~CXFA_Color(); - - Type GetType() const { return m_type; } - FX_ARGB GetArgb() const { - ASSERT(m_type == Solid || m_type == Pattern); - return m_argb; - } - CXFA_Pattern* GetPattern() const { - ASSERT(m_type == Pattern); - return m_pointer.pattern; - } - CXFA_Shading* GetShading() const { - ASSERT(m_type == Shading); - return m_pointer.shading; - } - - CXFA_Color& operator=(const CXFA_Color& that); - - private: - Type m_type; - FX_ARGB m_argb; - union { - CXFA_Pattern* pattern; - CXFA_Shading* shading; - } m_pointer; -}; - -#endif // XFA_FXGRAPHICS_CXFA_COLOR_H_ diff --git a/xfa/fxgraphics/cxfa_gecolor.cpp b/xfa/fxgraphics/cxfa_gecolor.cpp new file mode 100644 index 0000000000..3dca4a7df5 --- /dev/null +++ b/xfa/fxgraphics/cxfa_gecolor.cpp @@ -0,0 +1,47 @@ +// 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 "xfa/fxgraphics/cxfa_gecolor.h" + +CXFA_GEColor::CXFA_GEColor() : m_type(Invalid) {} + +CXFA_GEColor::CXFA_GEColor(const FX_ARGB argb) : m_type(Solid), m_argb(argb) { + m_pointer.pattern = nullptr; +} + +CXFA_GEColor::CXFA_GEColor(CXFA_GEPattern* pattern, const FX_ARGB argb) + : m_type(Pattern), m_argb(argb) { + m_pointer.pattern = pattern; +} + +CXFA_GEColor::CXFA_GEColor(CXFA_GEShading* shading) + : m_type(Shading), m_argb(0) { + m_pointer.shading = shading; +} + +CXFA_GEColor::~CXFA_GEColor() {} + +CXFA_GEColor& CXFA_GEColor::operator=(const CXFA_GEColor& that) { + if (this != &that) { + m_type = that.m_type; + switch (m_type) { + case Solid: + m_argb = that.m_argb; + m_pointer.pattern = nullptr; + break; + case Pattern: + m_argb = that.m_argb; + m_pointer.pattern = that.m_pointer.pattern; + break; + case Shading: + m_argb = 0; + m_pointer.shading = that.m_pointer.shading; + default: + break; + } + } + return *this; +} diff --git a/xfa/fxgraphics/cxfa_gecolor.h b/xfa/fxgraphics/cxfa_gecolor.h new file mode 100644 index 0000000000..b60585b7a4 --- /dev/null +++ b/xfa/fxgraphics/cxfa_gecolor.h @@ -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 + +#ifndef XFA_FXGRAPHICS_CXFA_GECOLOR_H_ +#define XFA_FXGRAPHICS_CXFA_GECOLOR_H_ + +#include "core/fxge/fx_dib.h" + +class CXFA_GEPattern; +class CXFA_GEShading; + +class CXFA_GEColor { + public: + enum Type { Invalid, Solid, Pattern, Shading }; + + CXFA_GEColor(); + explicit CXFA_GEColor(const FX_ARGB argb); + explicit CXFA_GEColor(CXFA_GEShading* shading); + CXFA_GEColor(CXFA_GEPattern* pattern, const FX_ARGB argb); + ~CXFA_GEColor(); + + Type GetType() const { return m_type; } + FX_ARGB GetArgb() const { + ASSERT(m_type == Solid || m_type == Pattern); + return m_argb; + } + CXFA_GEPattern* GetPattern() const { + ASSERT(m_type == Pattern); + return m_pointer.pattern; + } + CXFA_GEShading* GetShading() const { + ASSERT(m_type == Shading); + return m_pointer.shading; + } + + CXFA_GEColor& operator=(const CXFA_GEColor& that); + + private: + Type m_type; + FX_ARGB m_argb; + union { + CXFA_GEPattern* pattern; + CXFA_GEShading* shading; + } m_pointer; +}; + +#endif // XFA_FXGRAPHICS_CXFA_GECOLOR_H_ diff --git a/xfa/fxgraphics/cxfa_gepath.cpp b/xfa/fxgraphics/cxfa_gepath.cpp new file mode 100644 index 0000000000..88372f72ac --- /dev/null +++ b/xfa/fxgraphics/cxfa_gepath.cpp @@ -0,0 +1,151 @@ +// 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 "xfa/fxgraphics/cxfa_gepath.h" + +#include "core/fxge/cfx_pathdata.h" +#include "third_party/base/ptr_util.h" + +CXFA_GEPath::CXFA_GEPath() {} + +CXFA_GEPath::~CXFA_GEPath() {} + +void CXFA_GEPath::Clear() { + data_.Clear(); +} + +void CXFA_GEPath::Close() { + data_.ClosePath(); +} + +void CXFA_GEPath::MoveTo(const CFX_PointF& point) { + data_.AppendPoint(point, FXPT_TYPE::MoveTo, false); +} + +void CXFA_GEPath::LineTo(const CFX_PointF& point) { + data_.AppendPoint(point, FXPT_TYPE::LineTo, false); +} + +void CXFA_GEPath::BezierTo(const CFX_PointF& c1, + const CFX_PointF& c2, + const CFX_PointF& to) { + data_.AppendPoint(c1, FXPT_TYPE::BezierTo, false); + data_.AppendPoint(c2, FXPT_TYPE::BezierTo, false); + data_.AppendPoint(to, FXPT_TYPE::BezierTo, false); +} + +void CXFA_GEPath::ArcTo(const CFX_PointF& pos, + const CFX_SizeF& size, + float start_angle, + float sweep_angle) { + CFX_SizeF new_size = size / 2.0f; + ArcToInternal(CFX_PointF(pos.x + new_size.width, pos.y + new_size.height), + new_size, start_angle, sweep_angle); +} + +void CXFA_GEPath::ArcToInternal(const CFX_PointF& pos, + const CFX_SizeF& size, + float start_angle, + float sweep_angle) { + float x0 = cos(sweep_angle / 2); + float y0 = sin(sweep_angle / 2); + float tx = ((1.0f - x0) * 4) / (3 * 1.0f); + float ty = y0 - ((tx * x0) / y0); + + CFX_PointF points[] = {CFX_PointF(x0 + tx, -ty), CFX_PointF(x0 + tx, ty)}; + float sn = sin(start_angle + sweep_angle / 2); + float cs = cos(start_angle + sweep_angle / 2); + + CFX_PointF bezier; + bezier.x = pos.x + (size.width * ((points[0].x * cs) - (points[0].y * sn))); + bezier.y = pos.y + (size.height * ((points[0].x * sn) + (points[0].y * cs))); + data_.AppendPoint(bezier, FXPT_TYPE::BezierTo, false); + + bezier.x = pos.x + (size.width * ((points[1].x * cs) - (points[1].y * sn))); + bezier.y = pos.y + (size.height * ((points[1].x * sn) + (points[1].y * cs))); + data_.AppendPoint(bezier, FXPT_TYPE::BezierTo, false); + + bezier.x = pos.x + (size.width * cos(start_angle + sweep_angle)); + bezier.y = pos.y + (size.height * sin(start_angle + sweep_angle)); + data_.AppendPoint(bezier, FXPT_TYPE::BezierTo, false); +} + +void CXFA_GEPath::AddLine(const CFX_PointF& p1, const CFX_PointF& p2) { + data_.AppendPoint(p1, FXPT_TYPE::MoveTo, false); + data_.AppendPoint(p2, FXPT_TYPE::LineTo, false); +} + +void CXFA_GEPath::AddRectangle(float left, + float top, + float width, + float height) { + data_.AppendRect(left, top, left + width, top + height); +} + +void CXFA_GEPath::AddEllipse(const CFX_RectF& rect) { + AddArc(rect.TopLeft(), rect.Size(), 0, FX_PI * 2); +} + +void CXFA_GEPath::AddArc(const CFX_PointF& original_pos, + const CFX_SizeF& original_size, + float start_angle, + float sweep_angle) { + if (sweep_angle == 0) + return; + + const float bezier_arc_angle_epsilon = 0.01f; + while (start_angle > FX_PI * 2) + start_angle -= FX_PI * 2; + while (start_angle < 0) + start_angle += FX_PI * 2; + if (sweep_angle >= FX_PI * 2) + sweep_angle = FX_PI * 2; + if (sweep_angle <= -FX_PI * 2) + sweep_angle = -FX_PI * 2; + + CFX_SizeF size = original_size / 2; + CFX_PointF pos(original_pos.x + size.width, original_pos.y + size.height); + data_.AppendPoint(pos + CFX_PointF(size.width * cos(start_angle), + size.height * sin(start_angle)), + FXPT_TYPE::MoveTo, false); + + float total_sweep = 0; + float local_sweep = 0; + float prev_sweep = 0; + bool done = false; + do { + if (sweep_angle < 0) { + prev_sweep = total_sweep; + local_sweep = -FX_PI / 2; + total_sweep -= FX_PI / 2; + if (total_sweep <= sweep_angle + bezier_arc_angle_epsilon) { + local_sweep = sweep_angle - prev_sweep; + done = true; + } + } else { + prev_sweep = total_sweep; + local_sweep = FX_PI / 2; + total_sweep += FX_PI / 2; + if (total_sweep >= sweep_angle - bezier_arc_angle_epsilon) { + local_sweep = sweep_angle - prev_sweep; + done = true; + } + } + + ArcToInternal(pos, size, start_angle, local_sweep); + start_angle += local_sweep; + } while (!done); +} + +void CXFA_GEPath::AddSubpath(CXFA_GEPath* path) { + if (!path) + return; + data_.Append(&path->data_, nullptr); +} + +void CXFA_GEPath::TransformBy(const CFX_Matrix& mt) { + data_.Transform(&mt); +} diff --git a/xfa/fxgraphics/cxfa_gepath.h b/xfa/fxgraphics/cxfa_gepath.h new file mode 100644 index 0000000000..0c3afc4edf --- /dev/null +++ b/xfa/fxgraphics/cxfa_gepath.h @@ -0,0 +1,55 @@ +// 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 XFA_FXGRAPHICS_CXFA_GEPATH_H_ +#define XFA_FXGRAPHICS_CXFA_GEPATH_H_ + +#include "core/fxcrt/fx_system.h" +#include "core/fxge/cfx_pathdata.h" +#include "xfa/fxgraphics/cxfa_graphics.h" + +class CXFA_GEPath final { + public: + CXFA_GEPath(); + ~CXFA_GEPath(); + + const CFX_PathData* GetPathData() const { return &data_; } + + void Clear(); + bool IsEmpty() const { return data_.GetPoints().empty(); } + void TransformBy(const CFX_Matrix& mt); + + void Close(); + void MoveTo(const CFX_PointF& point); + void LineTo(const CFX_PointF& point); + void BezierTo(const CFX_PointF& c1, + const CFX_PointF& c2, + const CFX_PointF& to); + void ArcTo(const CFX_PointF& pos, + const CFX_SizeF& size, + float startAngle, + float sweepAngle); + + void AddLine(const CFX_PointF& p1, const CFX_PointF& p2); + void AddRectangle(float left, float top, float width, float height); + void AddEllipse(const CFX_RectF& rect); + void AddArc(const CFX_PointF& pos, + const CFX_SizeF& size, + float startAngle, + float sweepAngle); + + void AddSubpath(CXFA_GEPath* path); + + private: + void ArcToInternal(const CFX_PointF& pos, + const CFX_SizeF& size, + float start_angle, + float sweep_angle); + + CFX_PathData data_; +}; + +#endif // XFA_FXGRAPHICS_CXFA_GEPATH_H_ diff --git a/xfa/fxgraphics/cxfa_gepattern.cpp b/xfa/fxgraphics/cxfa_gepattern.cpp new file mode 100644 index 0000000000..2a6a0e4934 --- /dev/null +++ b/xfa/fxgraphics/cxfa_gepattern.cpp @@ -0,0 +1,20 @@ +// 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 "xfa/fxgraphics/cxfa_gepattern.h" + +CXFA_GEPattern::CXFA_GEPattern(FX_HatchStyle hatchStyle, + const FX_ARGB foreArgb, + const FX_ARGB backArgb, + CFX_Matrix* matrix) + : m_hatchStyle(hatchStyle), m_foreArgb(foreArgb), m_backArgb(backArgb) { + if (matrix) + m_matrix = *matrix; + else + m_matrix.SetIdentity(); +} + +CXFA_GEPattern::~CXFA_GEPattern() {} diff --git a/xfa/fxgraphics/cxfa_gepattern.h b/xfa/fxgraphics/cxfa_gepattern.h new file mode 100644 index 0000000000..0f4ced20ea --- /dev/null +++ b/xfa/fxgraphics/cxfa_gepattern.h @@ -0,0 +1,36 @@ +// 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 XFA_FXGRAPHICS_CXFA_GEPATTERN_H_ +#define XFA_FXGRAPHICS_CXFA_GEPATTERN_H_ + +#include "core/fxcrt/fx_coordinates.h" +#include "core/fxcrt/fx_system.h" +#include "xfa/fxgraphics/cxfa_graphics.h" + +class CFX_DIBitmap; +class CFX_Matrix; + +class CXFA_GEPattern { + public: + CXFA_GEPattern(FX_HatchStyle hatchStyle, + const FX_ARGB foreArgb, + const FX_ARGB backArgb, + CFX_Matrix* matrix = nullptr); + + virtual ~CXFA_GEPattern(); + + private: + friend class CXFA_Graphics; + + CFX_Matrix m_matrix; + + const FX_HatchStyle m_hatchStyle; + const FX_ARGB m_foreArgb; + const FX_ARGB m_backArgb; +}; + +#endif // XFA_FXGRAPHICS_CXFA_GEPATTERN_H_ diff --git a/xfa/fxgraphics/cxfa_geshading.cpp b/xfa/fxgraphics/cxfa_geshading.cpp new file mode 100644 index 0000000000..f6911696a1 --- /dev/null +++ b/xfa/fxgraphics/cxfa_geshading.cpp @@ -0,0 +1,78 @@ +// 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 "xfa/fxgraphics/cxfa_geshading.h" + +CXFA_GEShading::CXFA_GEShading(const CFX_PointF& beginPoint, + const CFX_PointF& endPoint, + bool isExtendedBegin, + bool isExtendedEnd, + const FX_ARGB beginArgb, + const FX_ARGB endArgb) + : m_type(FX_SHADING_Axial), + m_beginPoint(beginPoint), + m_endPoint(endPoint), + m_beginRadius(0), + m_endRadius(0), + m_isExtendedBegin(isExtendedBegin), + m_isExtendedEnd(isExtendedEnd), + m_beginArgb(beginArgb), + m_endArgb(endArgb) { + InitArgbArray(); +} + +CXFA_GEShading::CXFA_GEShading(const CFX_PointF& beginPoint, + const CFX_PointF& endPoint, + const float beginRadius, + const float endRadius, + bool isExtendedBegin, + bool isExtendedEnd, + const FX_ARGB beginArgb, + const FX_ARGB endArgb) + : m_type(FX_SHADING_Radial), + m_beginPoint(beginPoint), + m_endPoint(endPoint), + m_beginRadius(beginRadius), + m_endRadius(endRadius), + m_isExtendedBegin(isExtendedBegin), + m_isExtendedEnd(isExtendedEnd), + m_beginArgb(beginArgb), + m_endArgb(endArgb) { + InitArgbArray(); +} + +CXFA_GEShading::~CXFA_GEShading() {} + +void CXFA_GEShading::InitArgbArray() { + int32_t a1; + int32_t r1; + int32_t g1; + int32_t b1; + std::tie(a1, r1, g1, b1) = ArgbDecode(m_beginArgb); + + int32_t a2; + int32_t r2; + int32_t g2; + int32_t b2; + std::tie(a2, r2, g2, b2) = ArgbDecode(m_endArgb); + + float f = static_cast(FX_SHADING_Steps - 1); + float aScale = 1.0 * (a2 - a1) / f; + float rScale = 1.0 * (r2 - r1) / f; + float gScale = 1.0 * (g2 - g1) / f; + float bScale = 1.0 * (b2 - b1) / f; + + for (int32_t i = 0; i < FX_SHADING_Steps; i++) { + int32_t a3 = static_cast(i * aScale); + int32_t r3 = static_cast(i * rScale); + int32_t g3 = static_cast(i * gScale); + int32_t b3 = static_cast(i * bScale); + + // TODO(dsinclair): Add overloads for FX_ARGB. pdfium:437 + m_argbArray[i] = + FXARGB_TODIB(FXARGB_MAKE(a1 + a3, r1 + r3, g1 + g3, b1 + b3)); + } +} diff --git a/xfa/fxgraphics/cxfa_geshading.h b/xfa/fxgraphics/cxfa_geshading.h new file mode 100644 index 0000000000..fc7a13e619 --- /dev/null +++ b/xfa/fxgraphics/cxfa_geshading.h @@ -0,0 +1,56 @@ +// 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 XFA_FXGRAPHICS_CXFA_GESHADING_H_ +#define XFA_FXGRAPHICS_CXFA_GESHADING_H_ + +#include "core/fxcrt/fx_coordinates.h" +#include "core/fxcrt/fx_system.h" +#include "core/fxge/fx_dib.h" + +#define FX_SHADING_Steps 256 + +enum CXFA_GEShading_Type { FX_SHADING_Axial = 1, FX_SHADING_Radial }; + +class CXFA_GEShading { + public: + // Axial shading. + CXFA_GEShading(const CFX_PointF& beginPoint, + const CFX_PointF& endPoint, + bool isExtendedBegin, + bool isExtendedEnd, + const FX_ARGB beginArgb, + const FX_ARGB endArgb); + + // Radial shading. + CXFA_GEShading(const CFX_PointF& beginPoint, + const CFX_PointF& endPoint, + const float beginRadius, + const float endRadius, + bool isExtendedBegin, + bool isExtendedEnd, + const FX_ARGB beginArgb, + const FX_ARGB endArgb); + virtual ~CXFA_GEShading(); + + private: + friend class CXFA_Graphics; + + void InitArgbArray(); + + const CXFA_GEShading_Type m_type; + const CFX_PointF m_beginPoint; + const CFX_PointF m_endPoint; + const float m_beginRadius; + const float m_endRadius; + const bool m_isExtendedBegin; + const bool m_isExtendedEnd; + const FX_ARGB m_beginArgb; + const FX_ARGB m_endArgb; + FX_ARGB m_argbArray[FX_SHADING_Steps]; +}; + +#endif // XFA_FXGRAPHICS_CXFA_GESHADING_H_ diff --git a/xfa/fxgraphics/cxfa_graphics.cpp b/xfa/fxgraphics/cxfa_graphics.cpp index 7cb83e10aa..66a109ddaa 100644 --- a/xfa/fxgraphics/cxfa_graphics.cpp +++ b/xfa/fxgraphics/cxfa_graphics.cpp @@ -12,10 +12,10 @@ #include "core/fxge/cfx_renderdevice.h" #include "core/fxge/cfx_unicodeencoding.h" #include "third_party/base/ptr_util.h" -#include "xfa/fxgraphics/cxfa_color.h" -#include "xfa/fxgraphics/cxfa_path.h" -#include "xfa/fxgraphics/cxfa_pattern.h" -#include "xfa/fxgraphics/cxfa_shading.h" +#include "xfa/fxgraphics/cxfa_gecolor.h" +#include "xfa/fxgraphics/cxfa_gepath.h" +#include "xfa/fxgraphics/cxfa_gepattern.h" +#include "xfa/fxgraphics/cxfa_geshading.h" namespace { @@ -168,24 +168,24 @@ void CXFA_Graphics::EnableActOnDash() { m_info.isActOnDash = true; } -void CXFA_Graphics::SetStrokeColor(const CXFA_Color& color) { +void CXFA_Graphics::SetStrokeColor(const CXFA_GEColor& color) { if (m_type == FX_CONTEXT_Device && m_renderDevice) m_info.strokeColor = color; } -void CXFA_Graphics::SetFillColor(const CXFA_Color& color) { +void CXFA_Graphics::SetFillColor(const CXFA_GEColor& color) { if (m_type == FX_CONTEXT_Device && m_renderDevice) m_info.fillColor = color; } -void CXFA_Graphics::StrokePath(CXFA_Path* path, const CFX_Matrix* matrix) { +void CXFA_Graphics::StrokePath(CXFA_GEPath* path, const CFX_Matrix* matrix) { if (!path) return; if (m_type == FX_CONTEXT_Device && m_renderDevice) RenderDeviceStrokePath(path, matrix); } -void CXFA_Graphics::FillPath(CXFA_Path* path, +void CXFA_Graphics::FillPath(CXFA_GEPath* path, FX_FillMode fillMode, const CFX_Matrix* matrix) { if (!path) @@ -268,9 +268,9 @@ void CXFA_Graphics::RenderDeviceSetLineDash(FX_DashStyle dashStyle) { } } -void CXFA_Graphics::RenderDeviceStrokePath(const CXFA_Path* path, +void CXFA_Graphics::RenderDeviceStrokePath(const CXFA_GEPath* path, const CFX_Matrix* matrix) { - if (m_info.strokeColor.GetType() != CXFA_Color::Solid) + if (m_info.strokeColor.GetType() != CXFA_GEColor::Solid) return; CFX_Matrix m = m_info.CTM; @@ -281,7 +281,7 @@ void CXFA_Graphics::RenderDeviceStrokePath(const CXFA_Path* path, m_info.strokeColor.GetArgb(), 0); } -void CXFA_Graphics::RenderDeviceFillPath(const CXFA_Path* path, +void CXFA_Graphics::RenderDeviceFillPath(const CXFA_GEPath* path, FX_FillMode fillMode, const CFX_Matrix* matrix) { CFX_Matrix m = m_info.CTM; @@ -289,14 +289,14 @@ void CXFA_Graphics::RenderDeviceFillPath(const CXFA_Path* path, m.Concat(*matrix); switch (m_info.fillColor.GetType()) { - case CXFA_Color::Solid: + case CXFA_GEColor::Solid: m_renderDevice->DrawPath(path->GetPathData(), &m, &m_info.graphState, m_info.fillColor.GetArgb(), 0x0, fillMode); return; - case CXFA_Color::Pattern: + case CXFA_GEColor::Pattern: FillPathWithPattern(path, fillMode, m); return; - case CXFA_Color::Shading: + case CXFA_GEColor::Shading: FillPathWithShading(path, fillMode, m); return; default: @@ -329,10 +329,10 @@ void CXFA_Graphics::RenderDeviceStretchImage( FXSYS_round(r.left - left), FXSYS_round(r.top - top)); } -void CXFA_Graphics::FillPathWithPattern(const CXFA_Path* path, +void CXFA_Graphics::FillPathWithPattern(const CXFA_GEPath* path, FX_FillMode fillMode, const CFX_Matrix& matrix) { - CXFA_Pattern* pattern = m_info.fillColor.GetPattern(); + CXFA_GEPattern* pattern = m_info.fillColor.GetPattern(); RetainPtr bitmap = m_renderDevice->GetBitmap(); int32_t width = bitmap->GetWidth(); int32_t height = bitmap->GetHeight(); @@ -363,7 +363,7 @@ void CXFA_Graphics::FillPathWithPattern(const CXFA_Path* path, SetDIBitsWithMatrix(bmp, pattern->m_matrix); } -void CXFA_Graphics::FillPathWithShading(const CXFA_Path* path, +void CXFA_Graphics::FillPathWithShading(const CXFA_GEPath* path, FX_FillMode fillMode, const CFX_Matrix& matrix) { RetainPtr bitmap = m_renderDevice->GetBitmap(); diff --git a/xfa/fxgraphics/cxfa_graphics.h b/xfa/fxgraphics/cxfa_graphics.h index 6b9dcb9a86..16cd123fc7 100644 --- a/xfa/fxgraphics/cxfa_graphics.h +++ b/xfa/fxgraphics/cxfa_graphics.h @@ -16,9 +16,9 @@ #include "core/fxge/cfx_renderdevice.h" #include "core/fxge/fx_dib.h" #include "core/fxge/fx_font.h" -#include "xfa/fxgraphics/cxfa_color.h" +#include "xfa/fxgraphics/cxfa_gecolor.h" -class CXFA_Path; +class CXFA_GEPath; using FX_FillMode = int32_t; @@ -58,11 +58,11 @@ class CXFA_Graphics { void SetLineDash(FX_DashStyle dashStyle); void SetLineWidth(float lineWidth); void EnableActOnDash(); - void SetStrokeColor(const CXFA_Color& color); - void SetFillColor(const CXFA_Color& color); + void SetStrokeColor(const CXFA_GEColor& color); + void SetFillColor(const CXFA_GEColor& color); void SetClipRect(const CFX_RectF& rect); - void StrokePath(CXFA_Path* path, const CFX_Matrix* matrix); - void FillPath(CXFA_Path* path, + void StrokePath(CXFA_GEPath* path, const CFX_Matrix* matrix); + void FillPath(CXFA_GEPath* path, FX_FillMode fillMode, const CFX_Matrix* matrix); void StretchImage(const RetainPtr& source, @@ -82,23 +82,24 @@ class CXFA_Graphics { CFX_GraphStateData graphState; CFX_Matrix CTM; bool isActOnDash; - CXFA_Color strokeColor; - CXFA_Color fillColor; + CXFA_GEColor strokeColor; + CXFA_GEColor fillColor; } m_info; void RenderDeviceSetLineDash(FX_DashStyle dashStyle); - void RenderDeviceStrokePath(const CXFA_Path* path, const CFX_Matrix* matrix); - void RenderDeviceFillPath(const CXFA_Path* path, + void RenderDeviceStrokePath(const CXFA_GEPath* path, + const CFX_Matrix* matrix); + void RenderDeviceFillPath(const CXFA_GEPath* path, FX_FillMode fillMode, const CFX_Matrix* matrix); void RenderDeviceStretchImage(const RetainPtr& source, const CFX_RectF& rect, const CFX_Matrix& matrix); - void FillPathWithPattern(const CXFA_Path* path, + void FillPathWithPattern(const CXFA_GEPath* path, FX_FillMode fillMode, const CFX_Matrix& matrix); - void FillPathWithShading(const CXFA_Path* path, + void FillPathWithShading(const CXFA_GEPath* path, FX_FillMode fillMode, const CFX_Matrix& matrix); diff --git a/xfa/fxgraphics/cxfa_path.cpp b/xfa/fxgraphics/cxfa_path.cpp deleted file mode 100644 index 6d7ed0be58..0000000000 --- a/xfa/fxgraphics/cxfa_path.cpp +++ /dev/null @@ -1,148 +0,0 @@ -// 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 "xfa/fxgraphics/cxfa_path.h" - -#include "core/fxge/cfx_pathdata.h" -#include "third_party/base/ptr_util.h" - -CXFA_Path::CXFA_Path() {} - -CXFA_Path::~CXFA_Path() {} - -void CXFA_Path::Clear() { - data_.Clear(); -} - -void CXFA_Path::Close() { - data_.ClosePath(); -} - -void CXFA_Path::MoveTo(const CFX_PointF& point) { - data_.AppendPoint(point, FXPT_TYPE::MoveTo, false); -} - -void CXFA_Path::LineTo(const CFX_PointF& point) { - data_.AppendPoint(point, FXPT_TYPE::LineTo, false); -} - -void CXFA_Path::BezierTo(const CFX_PointF& c1, - const CFX_PointF& c2, - const CFX_PointF& to) { - data_.AppendPoint(c1, FXPT_TYPE::BezierTo, false); - data_.AppendPoint(c2, FXPT_TYPE::BezierTo, false); - data_.AppendPoint(to, FXPT_TYPE::BezierTo, false); -} - -void CXFA_Path::ArcTo(const CFX_PointF& pos, - const CFX_SizeF& size, - float start_angle, - float sweep_angle) { - CFX_SizeF new_size = size / 2.0f; - ArcToInternal(CFX_PointF(pos.x + new_size.width, pos.y + new_size.height), - new_size, start_angle, sweep_angle); -} - -void CXFA_Path::ArcToInternal(const CFX_PointF& pos, - const CFX_SizeF& size, - float start_angle, - float sweep_angle) { - float x0 = cos(sweep_angle / 2); - float y0 = sin(sweep_angle / 2); - float tx = ((1.0f - x0) * 4) / (3 * 1.0f); - float ty = y0 - ((tx * x0) / y0); - - CFX_PointF points[] = {CFX_PointF(x0 + tx, -ty), CFX_PointF(x0 + tx, ty)}; - float sn = sin(start_angle + sweep_angle / 2); - float cs = cos(start_angle + sweep_angle / 2); - - CFX_PointF bezier; - bezier.x = pos.x + (size.width * ((points[0].x * cs) - (points[0].y * sn))); - bezier.y = pos.y + (size.height * ((points[0].x * sn) + (points[0].y * cs))); - data_.AppendPoint(bezier, FXPT_TYPE::BezierTo, false); - - bezier.x = pos.x + (size.width * ((points[1].x * cs) - (points[1].y * sn))); - bezier.y = pos.y + (size.height * ((points[1].x * sn) + (points[1].y * cs))); - data_.AppendPoint(bezier, FXPT_TYPE::BezierTo, false); - - bezier.x = pos.x + (size.width * cos(start_angle + sweep_angle)); - bezier.y = pos.y + (size.height * sin(start_angle + sweep_angle)); - data_.AppendPoint(bezier, FXPT_TYPE::BezierTo, false); -} - -void CXFA_Path::AddLine(const CFX_PointF& p1, const CFX_PointF& p2) { - data_.AppendPoint(p1, FXPT_TYPE::MoveTo, false); - data_.AppendPoint(p2, FXPT_TYPE::LineTo, false); -} - -void CXFA_Path::AddRectangle(float left, float top, float width, float height) { - data_.AppendRect(left, top, left + width, top + height); -} - -void CXFA_Path::AddEllipse(const CFX_RectF& rect) { - AddArc(rect.TopLeft(), rect.Size(), 0, FX_PI * 2); -} - -void CXFA_Path::AddArc(const CFX_PointF& original_pos, - const CFX_SizeF& original_size, - float start_angle, - float sweep_angle) { - if (sweep_angle == 0) - return; - - const float bezier_arc_angle_epsilon = 0.01f; - while (start_angle > FX_PI * 2) - start_angle -= FX_PI * 2; - while (start_angle < 0) - start_angle += FX_PI * 2; - if (sweep_angle >= FX_PI * 2) - sweep_angle = FX_PI * 2; - if (sweep_angle <= -FX_PI * 2) - sweep_angle = -FX_PI * 2; - - CFX_SizeF size = original_size / 2; - CFX_PointF pos(original_pos.x + size.width, original_pos.y + size.height); - data_.AppendPoint(pos + CFX_PointF(size.width * cos(start_angle), - size.height * sin(start_angle)), - FXPT_TYPE::MoveTo, false); - - float total_sweep = 0; - float local_sweep = 0; - float prev_sweep = 0; - bool done = false; - do { - if (sweep_angle < 0) { - prev_sweep = total_sweep; - local_sweep = -FX_PI / 2; - total_sweep -= FX_PI / 2; - if (total_sweep <= sweep_angle + bezier_arc_angle_epsilon) { - local_sweep = sweep_angle - prev_sweep; - done = true; - } - } else { - prev_sweep = total_sweep; - local_sweep = FX_PI / 2; - total_sweep += FX_PI / 2; - if (total_sweep >= sweep_angle - bezier_arc_angle_epsilon) { - local_sweep = sweep_angle - prev_sweep; - done = true; - } - } - - ArcToInternal(pos, size, start_angle, local_sweep); - start_angle += local_sweep; - } while (!done); -} - -void CXFA_Path::AddSubpath(CXFA_Path* path) { - if (!path) - return; - data_.Append(&path->data_, nullptr); -} - -void CXFA_Path::TransformBy(const CFX_Matrix& mt) { - data_.Transform(&mt); -} diff --git a/xfa/fxgraphics/cxfa_path.h b/xfa/fxgraphics/cxfa_path.h deleted file mode 100644 index 9c71a4d5ff..0000000000 --- a/xfa/fxgraphics/cxfa_path.h +++ /dev/null @@ -1,55 +0,0 @@ -// 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 XFA_FXGRAPHICS_CXFA_PATH_H_ -#define XFA_FXGRAPHICS_CXFA_PATH_H_ - -#include "core/fxcrt/fx_system.h" -#include "core/fxge/cfx_pathdata.h" -#include "xfa/fxgraphics/cxfa_graphics.h" - -class CXFA_Path final { - public: - CXFA_Path(); - ~CXFA_Path(); - - const CFX_PathData* GetPathData() const { return &data_; } - - void Clear(); - bool IsEmpty() const { return data_.GetPoints().empty(); } - void TransformBy(const CFX_Matrix& mt); - - void Close(); - void MoveTo(const CFX_PointF& point); - void LineTo(const CFX_PointF& point); - void BezierTo(const CFX_PointF& c1, - const CFX_PointF& c2, - const CFX_PointF& to); - void ArcTo(const CFX_PointF& pos, - const CFX_SizeF& size, - float startAngle, - float sweepAngle); - - void AddLine(const CFX_PointF& p1, const CFX_PointF& p2); - void AddRectangle(float left, float top, float width, float height); - void AddEllipse(const CFX_RectF& rect); - void AddArc(const CFX_PointF& pos, - const CFX_SizeF& size, - float startAngle, - float sweepAngle); - - void AddSubpath(CXFA_Path* path); - - private: - void ArcToInternal(const CFX_PointF& pos, - const CFX_SizeF& size, - float start_angle, - float sweep_angle); - - CFX_PathData data_; -}; - -#endif // XFA_FXGRAPHICS_CXFA_PATH_H_ diff --git a/xfa/fxgraphics/cxfa_pattern.cpp b/xfa/fxgraphics/cxfa_pattern.cpp deleted file mode 100644 index ea6cea87a5..0000000000 --- a/xfa/fxgraphics/cxfa_pattern.cpp +++ /dev/null @@ -1,20 +0,0 @@ -// 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 "xfa/fxgraphics/cxfa_pattern.h" - -CXFA_Pattern::CXFA_Pattern(FX_HatchStyle hatchStyle, - const FX_ARGB foreArgb, - const FX_ARGB backArgb, - CFX_Matrix* matrix) - : m_hatchStyle(hatchStyle), m_foreArgb(foreArgb), m_backArgb(backArgb) { - if (matrix) - m_matrix = *matrix; - else - m_matrix.SetIdentity(); -} - -CXFA_Pattern::~CXFA_Pattern() {} diff --git a/xfa/fxgraphics/cxfa_pattern.h b/xfa/fxgraphics/cxfa_pattern.h deleted file mode 100644 index 838ec98b01..0000000000 --- a/xfa/fxgraphics/cxfa_pattern.h +++ /dev/null @@ -1,36 +0,0 @@ -// 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 XFA_FXGRAPHICS_CXFA_PATTERN_H_ -#define XFA_FXGRAPHICS_CXFA_PATTERN_H_ - -#include "core/fxcrt/fx_coordinates.h" -#include "core/fxcrt/fx_system.h" -#include "xfa/fxgraphics/cxfa_graphics.h" - -class CFX_DIBitmap; -class CFX_Matrix; - -class CXFA_Pattern { - public: - CXFA_Pattern(FX_HatchStyle hatchStyle, - const FX_ARGB foreArgb, - const FX_ARGB backArgb, - CFX_Matrix* matrix = nullptr); - - virtual ~CXFA_Pattern(); - - private: - friend class CXFA_Graphics; - - CFX_Matrix m_matrix; - - const FX_HatchStyle m_hatchStyle; - const FX_ARGB m_foreArgb; - const FX_ARGB m_backArgb; -}; - -#endif // XFA_FXGRAPHICS_CXFA_PATTERN_H_ diff --git a/xfa/fxgraphics/cxfa_shading.cpp b/xfa/fxgraphics/cxfa_shading.cpp deleted file mode 100644 index 599a3f9d42..0000000000 --- a/xfa/fxgraphics/cxfa_shading.cpp +++ /dev/null @@ -1,78 +0,0 @@ -// 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 "xfa/fxgraphics/cxfa_shading.h" - -CXFA_Shading::CXFA_Shading(const CFX_PointF& beginPoint, - const CFX_PointF& endPoint, - bool isExtendedBegin, - bool isExtendedEnd, - const FX_ARGB beginArgb, - const FX_ARGB endArgb) - : m_type(FX_SHADING_Axial), - m_beginPoint(beginPoint), - m_endPoint(endPoint), - m_beginRadius(0), - m_endRadius(0), - m_isExtendedBegin(isExtendedBegin), - m_isExtendedEnd(isExtendedEnd), - m_beginArgb(beginArgb), - m_endArgb(endArgb) { - InitArgbArray(); -} - -CXFA_Shading::CXFA_Shading(const CFX_PointF& beginPoint, - const CFX_PointF& endPoint, - const float beginRadius, - const float endRadius, - bool isExtendedBegin, - bool isExtendedEnd, - const FX_ARGB beginArgb, - const FX_ARGB endArgb) - : m_type(FX_SHADING_Radial), - m_beginPoint(beginPoint), - m_endPoint(endPoint), - m_beginRadius(beginRadius), - m_endRadius(endRadius), - m_isExtendedBegin(isExtendedBegin), - m_isExtendedEnd(isExtendedEnd), - m_beginArgb(beginArgb), - m_endArgb(endArgb) { - InitArgbArray(); -} - -CXFA_Shading::~CXFA_Shading() {} - -void CXFA_Shading::InitArgbArray() { - int32_t a1; - int32_t r1; - int32_t g1; - int32_t b1; - std::tie(a1, r1, g1, b1) = ArgbDecode(m_beginArgb); - - int32_t a2; - int32_t r2; - int32_t g2; - int32_t b2; - std::tie(a2, r2, g2, b2) = ArgbDecode(m_endArgb); - - float f = static_cast(FX_SHADING_Steps - 1); - float aScale = 1.0 * (a2 - a1) / f; - float rScale = 1.0 * (r2 - r1) / f; - float gScale = 1.0 * (g2 - g1) / f; - float bScale = 1.0 * (b2 - b1) / f; - - for (int32_t i = 0; i < FX_SHADING_Steps; i++) { - int32_t a3 = static_cast(i * aScale); - int32_t r3 = static_cast(i * rScale); - int32_t g3 = static_cast(i * gScale); - int32_t b3 = static_cast(i * bScale); - - // TODO(dsinclair): Add overloads for FX_ARGB. pdfium:437 - m_argbArray[i] = - FXARGB_TODIB(FXARGB_MAKE(a1 + a3, r1 + r3, g1 + g3, b1 + b3)); - } -} diff --git a/xfa/fxgraphics/cxfa_shading.h b/xfa/fxgraphics/cxfa_shading.h deleted file mode 100644 index 22ef941250..0000000000 --- a/xfa/fxgraphics/cxfa_shading.h +++ /dev/null @@ -1,56 +0,0 @@ -// 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 XFA_FXGRAPHICS_CXFA_SHADING_H_ -#define XFA_FXGRAPHICS_CXFA_SHADING_H_ - -#include "core/fxcrt/fx_coordinates.h" -#include "core/fxcrt/fx_system.h" -#include "core/fxge/fx_dib.h" - -#define FX_SHADING_Steps 256 - -enum CXFA_Shading_Type { FX_SHADING_Axial = 1, FX_SHADING_Radial }; - -class CXFA_Shading { - public: - // Axial shading. - CXFA_Shading(const CFX_PointF& beginPoint, - const CFX_PointF& endPoint, - bool isExtendedBegin, - bool isExtendedEnd, - const FX_ARGB beginArgb, - const FX_ARGB endArgb); - - // Radial shading. - CXFA_Shading(const CFX_PointF& beginPoint, - const CFX_PointF& endPoint, - const float beginRadius, - const float endRadius, - bool isExtendedBegin, - bool isExtendedEnd, - const FX_ARGB beginArgb, - const FX_ARGB endArgb); - virtual ~CXFA_Shading(); - - private: - friend class CXFA_Graphics; - - void InitArgbArray(); - - const CXFA_Shading_Type m_type; - const CFX_PointF m_beginPoint; - const CFX_PointF m_endPoint; - const float m_beginRadius; - const float m_endRadius; - const bool m_isExtendedBegin; - const bool m_isExtendedEnd; - const FX_ARGB m_beginArgb; - const FX_ARGB m_endArgb; - FX_ARGB m_argbArray[FX_SHADING_Steps]; -}; - -#endif // XFA_FXGRAPHICS_CXFA_SHADING_H_ -- cgit v1.2.3