summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser/cxfa_stipple.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_stipple.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_stipple.cpp')
-rw-r--r--xfa/fxfa/parser/cxfa_stipple.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/xfa/fxfa/parser/cxfa_stipple.cpp b/xfa/fxfa/parser/cxfa_stipple.cpp
index 24715171b8..f8c059e328 100644
--- a/xfa/fxfa/parser/cxfa_stipple.cpp
+++ b/xfa/fxfa/parser/cxfa_stipple.cpp
@@ -48,3 +48,25 @@ int32_t CXFA_Stipple::GetRate() {
->TryInteger(XFA_Attribute::Rate, true)
.value_or(GetDefaultRate());
}
+
+void CXFA_Stipple::Draw(CXFA_Graphics* pGS,
+ CXFA_GEPath* fillPath,
+ const CFX_RectF& rtFill,
+ const CFX_Matrix& matrix) {
+ int32_t iRate = GetRate();
+ if (iRate == 0)
+ iRate = 100;
+
+ CXFA_Color* pColor = GetColorIfExists();
+ FX_ARGB crColor = pColor ? pColor->GetValue() : CXFA_Color::kBlackColor;
+
+ int32_t a;
+ FX_COLORREF rgb;
+ std::tie(a, rgb) = ArgbToColorRef(crColor);
+ FX_ARGB cr = ArgbEncode(iRate * a / 100, rgb);
+
+ pGS->SaveGraphState();
+ pGS->SetFillColor(CXFA_GEColor(cr));
+ pGS->FillPath(fillPath, FXFILL_WINDING, &matrix);
+ pGS->RestoreGraphState();
+}