From f855489794ffd575d073eb575b04ac1ca1f286c2 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Wed, 17 Jan 2018 16:29:15 +0000 Subject: 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 Commit-Queue: dsinclair --- xfa/fxfa/parser/cxfa_stipple.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'xfa/fxfa/parser/cxfa_stipple.cpp') 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(); +} -- cgit v1.2.3