summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser/cxfa_fill.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2018-01-17 16:29:15 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-01-17 16:29:15 +0000
commitf855489794ffd575d073eb575b04ac1ca1f286c2 (patch)
tree692d54fa51fa882873a9fbb296f0f031c92046ea /xfa/fxfa/parser/cxfa_fill.cpp
parent181ffee7dd19906f9eee175627a9e6d0abb2e881 (diff)
downloadpdfium-f855489794ffd575d073eb575b04ac1ca1f286c2.tar.xz
Move fill draw code to fill classes
This CL moves the code related to drawing fills and the various types of fill to the specific fill classes. Change-Id: Ie151089b00ca96c5fa88d22ab5f697d9425297cd Reviewed-on: https://pdfium-review.googlesource.com/23071 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fxfa/parser/cxfa_fill.cpp')
-rw-r--r--xfa/fxfa/parser/cxfa_fill.cpp138
1 files changed, 66 insertions, 72 deletions
diff --git a/xfa/fxfa/parser/cxfa_fill.cpp b/xfa/fxfa/parser/cxfa_fill.cpp
index e1e077b5bb..4cbd8f812c 100644
--- a/xfa/fxfa/parser/cxfa_fill.cpp
+++ b/xfa/fxfa/parser/cxfa_fill.cpp
@@ -75,7 +75,7 @@ FX_ARGB CXFA_Fill::GetColor(bool bText) {
return pColor->GetValueOrDefault(bText ? 0xFF000000 : 0xFFFFFFFF);
}
-XFA_Element CXFA_Fill::GetFillType() const {
+XFA_Element CXFA_Fill::GetType() const {
CXFA_Node* pChild = GetFirstChild();
while (pChild) {
XFA_Element eType = pChild->GetElementType();
@@ -87,76 +87,70 @@ XFA_Element CXFA_Fill::GetFillType() const {
return XFA_Element::Solid;
}
-XFA_AttributeEnum CXFA_Fill::GetPatternType() {
- CXFA_Pattern* pattern = GetPatternIfExists();
- return pattern ? pattern->GetType() : CXFA_Pattern::kDefaultType;
-}
-
-FX_ARGB CXFA_Fill::GetPatternColor() {
- CXFA_Pattern* pattern = GetPatternIfExists();
- if (!pattern)
- return CXFA_Color::kBlackColor;
-
- CXFA_Color* pColor = pattern->GetColorIfExists();
- return pColor ? pColor->GetValue() : CXFA_Color::kBlackColor;
-}
-
-int32_t CXFA_Fill::GetStippleRate() {
- CXFA_Stipple* stipple = GetStippleIfExists();
- if (!stipple)
- return CXFA_Stipple::GetDefaultRate();
- return stipple->GetRate();
-}
-
-FX_ARGB CXFA_Fill::GetStippleColor() {
- CXFA_Stipple* stipple = GetStippleIfExists();
- if (!stipple)
- return CXFA_Color::kBlackColor;
-
- CXFA_Color* pColor = stipple->GetColorIfExists();
- return pColor ? pColor->GetValue() : CXFA_Color::kBlackColor;
-}
-
-XFA_AttributeEnum CXFA_Fill::GetLinearType() {
- CXFA_Linear* linear = GetLinearIfExists();
- return linear ? linear->GetType() : CXFA_Linear::kDefaultType;
-}
-
-FX_ARGB CXFA_Fill::GetLinearColor() {
- CXFA_Linear* linear = GetLinearIfExists();
- if (!linear)
- return CXFA_Color::kBlackColor;
-
- CXFA_Color* pColor = linear->GetColorIfExists();
- return pColor ? pColor->GetValue() : CXFA_Color::kBlackColor;
-}
-
-bool CXFA_Fill::IsRadialToEdge() {
- CXFA_Radial* radial = GetRadialIfExists();
- return radial ? radial->IsToEdge() : false;
-}
-
-FX_ARGB CXFA_Fill::GetRadialColor() {
- CXFA_Radial* radial = GetRadialIfExists();
- if (!radial)
- return CXFA_Color::kBlackColor;
-
- CXFA_Color* pColor = radial->GetColorIfExists();
- return pColor ? pColor->GetValue() : CXFA_Color::kBlackColor;
-}
-
-CXFA_Stipple* CXFA_Fill::GetStippleIfExists() {
- return JSObject()->GetOrCreateProperty<CXFA_Stipple>(0, XFA_Element::Stipple);
-}
-
-CXFA_Radial* CXFA_Fill::GetRadialIfExists() {
- return JSObject()->GetOrCreateProperty<CXFA_Radial>(0, XFA_Element::Radial);
-}
-
-CXFA_Linear* CXFA_Fill::GetLinearIfExists() {
- return JSObject()->GetOrCreateProperty<CXFA_Linear>(0, XFA_Element::Linear);
-}
+void CXFA_Fill::Draw(CXFA_Graphics* pGS,
+ CXFA_GEPath* fillPath,
+ const CFX_RectF& rtWidget,
+ const CFX_Matrix& matrix) {
+ pGS->SaveGraphState();
+
+ switch (GetType()) {
+ case XFA_Element::Radial:
+ DrawRadial(pGS, fillPath, rtWidget, matrix);
+ break;
+ case XFA_Element::Pattern:
+ DrawPattern(pGS, fillPath, rtWidget, matrix);
+ break;
+ case XFA_Element::Linear:
+ DrawLinear(pGS, fillPath, rtWidget, matrix);
+ break;
+ case XFA_Element::Stipple:
+ DrawStipple(pGS, fillPath, rtWidget, matrix);
+ break;
+ default:
+ pGS->SetFillColor(CXFA_GEColor(GetColor(false)));
+ pGS->FillPath(fillPath, FXFILL_WINDING, &matrix);
+ break;
+ }
-CXFA_Pattern* CXFA_Fill::GetPatternIfExists() {
- return JSObject()->GetOrCreateProperty<CXFA_Pattern>(0, XFA_Element::Pattern);
+ pGS->RestoreGraphState();
+}
+
+void CXFA_Fill::DrawStipple(CXFA_Graphics* pGS,
+ CXFA_GEPath* fillPath,
+ const CFX_RectF& rtWidget,
+ const CFX_Matrix& matrix) {
+ CXFA_Stipple* stipple =
+ JSObject()->GetOrCreateProperty<CXFA_Stipple>(0, XFA_Element::Stipple);
+ if (stipple)
+ stipple->Draw(pGS, fillPath, rtWidget, matrix);
+}
+
+void CXFA_Fill::DrawRadial(CXFA_Graphics* pGS,
+ CXFA_GEPath* fillPath,
+ const CFX_RectF& rtWidget,
+ const CFX_Matrix& matrix) {
+ CXFA_Radial* radial =
+ JSObject()->GetOrCreateProperty<CXFA_Radial>(0, XFA_Element::Radial);
+ if (radial)
+ radial->Draw(pGS, fillPath, GetColor(false), rtWidget, matrix);
+}
+
+void CXFA_Fill::DrawLinear(CXFA_Graphics* pGS,
+ CXFA_GEPath* fillPath,
+ const CFX_RectF& rtWidget,
+ const CFX_Matrix& matrix) {
+ CXFA_Linear* linear =
+ JSObject()->GetOrCreateProperty<CXFA_Linear>(0, XFA_Element::Linear);
+ if (linear)
+ linear->Draw(pGS, fillPath, GetColor(false), rtWidget, matrix);
+}
+
+void CXFA_Fill::DrawPattern(CXFA_Graphics* pGS,
+ CXFA_GEPath* fillPath,
+ const CFX_RectF& rtWidget,
+ const CFX_Matrix& matrix) {
+ CXFA_Pattern* pattern =
+ JSObject()->GetOrCreateProperty<CXFA_Pattern>(0, XFA_Element::Pattern);
+ if (pattern)
+ pattern->Draw(pGS, fillPath, GetColor(false), rtWidget, matrix);
}