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_radial.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'xfa/fxfa/parser/cxfa_radial.cpp') diff --git a/xfa/fxfa/parser/cxfa_radial.cpp b/xfa/fxfa/parser/cxfa_radial.cpp index 80753b3803..3d024e744d 100644 --- a/xfa/fxfa/parser/cxfa_radial.cpp +++ b/xfa/fxfa/parser/cxfa_radial.cpp @@ -6,9 +6,12 @@ #include "xfa/fxfa/parser/cxfa_radial.h" +#include + #include "fxjs/xfa/cjx_radial.h" #include "third_party/base/ptr_util.h" #include "xfa/fxfa/parser/cxfa_color.h" +#include "xfa/fxgraphics/cxfa_geshading.h" namespace { @@ -49,3 +52,25 @@ bool CXFA_Radial::IsToEdge() { CXFA_Color* CXFA_Radial::GetColorIfExists() { return GetChild(0, XFA_Element::Color, false); } + +void CXFA_Radial::Draw(CXFA_Graphics* pGS, + CXFA_GEPath* fillPath, + FX_ARGB crStart, + const CFX_RectF& rtFill, + const CFX_Matrix& matrix) { + CXFA_Color* pColor = GetColorIfExists(); + FX_ARGB crEnd = pColor ? pColor->GetValue() : CXFA_Color::kBlackColor; + if (!IsToEdge()) + std::swap(crStart, crEnd); + + float endRadius = sqrt(rtFill.Width() * rtFill.Width() + + rtFill.Height() * rtFill.Height()) / + 2; + CXFA_GEShading shading(rtFill.Center(), rtFill.Center(), 0, endRadius, true, + true, crStart, crEnd); + + pGS->SaveGraphState(); + pGS->SetFillColor(CXFA_GEColor(&shading)); + pGS->FillPath(fillPath, FXFILL_WINDING, &matrix); + pGS->RestoreGraphState(); +} -- cgit v1.2.3