From c37fa7d9c5c60ac407b46bfc2e7745afa0b2df85 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Wed, 17 Jan 2018 19:29:46 +0000 Subject: Move code related to stroke line dash to CXFA_Stroke This CL moves XFA_StrokeTypeSetLineDash into the CXFA_Stroke class and cleans up the unused CXFA_Graphics code for setting line dash values. Change-Id: If6db6c315571dbcea630bc32e0d05dae6c0f10be Reviewed-on: https://pdfium-review.googlesource.com/23114 Reviewed-by: Henrique Nakashima Commit-Queue: dsinclair --- xfa/fxfa/cxfa_ffwidget.cpp | 46 ----------------------------------------- xfa/fxfa/cxfa_ffwidget.h | 3 --- xfa/fxfa/parser/cxfa_stroke.cpp | 45 ++++++++++++++++++++++++++++++++++++++++ xfa/fxfa/parser/cxfa_stroke.h | 4 ++++ 4 files changed, 49 insertions(+), 49 deletions(-) (limited to 'xfa/fxfa') diff --git a/xfa/fxfa/cxfa_ffwidget.cpp b/xfa/fxfa/cxfa_ffwidget.cpp index 4836e04811..8df7ff7782 100644 --- a/xfa/fxfa/cxfa_ffwidget.cpp +++ b/xfa/fxfa/cxfa_ffwidget.cpp @@ -70,52 +70,6 @@ bool IsFXCodecErrorStatus(FXCODEC_STATUS status) { } // namespace -int32_t XFA_StrokeTypeSetLineDash(CXFA_Graphics* pGraphics, - XFA_AttributeEnum iStrokeType, - XFA_AttributeEnum iCapType) { - switch (iStrokeType) { - case XFA_AttributeEnum::DashDot: { - float dashArray[] = {4, 1, 2, 1}; - if (iCapType != XFA_AttributeEnum::Butt) { - dashArray[1] = 2; - dashArray[3] = 2; - } - pGraphics->SetLineDash(0, dashArray, 4); - return FX_DASHSTYLE_DashDot; - } - case XFA_AttributeEnum::DashDotDot: { - float dashArray[] = {4, 1, 2, 1, 2, 1}; - if (iCapType != XFA_AttributeEnum::Butt) { - dashArray[1] = 2; - dashArray[3] = 2; - dashArray[5] = 2; - } - pGraphics->SetLineDash(0, dashArray, 6); - return FX_DASHSTYLE_DashDotDot; - } - case XFA_AttributeEnum::Dashed: { - float dashArray[] = {5, 1}; - if (iCapType != XFA_AttributeEnum::Butt) - dashArray[1] = 2; - - pGraphics->SetLineDash(0, dashArray, 2); - return FX_DASHSTYLE_Dash; - } - case XFA_AttributeEnum::Dotted: { - float dashArray[] = {2, 1}; - if (iCapType != XFA_AttributeEnum::Butt) - dashArray[1] = 2; - - pGraphics->SetLineDash(0, dashArray, 2); - return FX_DASHSTYLE_Dot; - } - default: - break; - } - pGraphics->SetLineDash(FX_DASHSTYLE_Solid); - return FX_DASHSTYLE_Solid; -} - void XFA_DrawImage(CXFA_Graphics* pGS, const CFX_RectF& rtImage, const CFX_Matrix& matrix, diff --git a/xfa/fxfa/cxfa_ffwidget.h b/xfa/fxfa/cxfa_ffwidget.h index 192f559fd4..aa913cca99 100644 --- a/xfa/fxfa/cxfa_ffwidget.h +++ b/xfa/fxfa/cxfa_ffwidget.h @@ -31,9 +31,6 @@ inline float XFA_UnitPx2Pt(float fPx, float fDpi) { #define XFA_FLOAT_PERCISION 0.001f -int32_t XFA_StrokeTypeSetLineDash(CXFA_Graphics* pGraphics, - XFA_AttributeEnum iStrokeType, - XFA_AttributeEnum iCapType); void XFA_DrawImage(CXFA_Graphics* pGS, const CFX_RectF& rtImage, const CFX_Matrix& matrix, diff --git a/xfa/fxfa/parser/cxfa_stroke.cpp b/xfa/fxfa/parser/cxfa_stroke.cpp index 45634b26e3..c581a96303 100644 --- a/xfa/fxfa/parser/cxfa_stroke.cpp +++ b/xfa/fxfa/parser/cxfa_stroke.cpp @@ -15,6 +15,51 @@ #include "xfa/fxfa/parser/xfa_utils.h" #include "xfa/fxgraphics/cxfa_graphics.h" +void XFA_StrokeTypeSetLineDash(CXFA_Graphics* pGraphics, + XFA_AttributeEnum iStrokeType, + XFA_AttributeEnum iCapType) { + switch (iStrokeType) { + case XFA_AttributeEnum::DashDot: { + float dashArray[] = {4, 1, 2, 1}; + if (iCapType != XFA_AttributeEnum::Butt) { + dashArray[1] = 2; + dashArray[3] = 2; + } + pGraphics->SetLineDash(0, dashArray, 4); + break; + } + case XFA_AttributeEnum::DashDotDot: { + float dashArray[] = {4, 1, 2, 1, 2, 1}; + if (iCapType != XFA_AttributeEnum::Butt) { + dashArray[1] = 2; + dashArray[3] = 2; + dashArray[5] = 2; + } + pGraphics->SetLineDash(0, dashArray, 6); + break; + } + case XFA_AttributeEnum::Dashed: { + float dashArray[] = {5, 1}; + if (iCapType != XFA_AttributeEnum::Butt) + dashArray[1] = 2; + + pGraphics->SetLineDash(0, dashArray, 2); + break; + } + case XFA_AttributeEnum::Dotted: { + float dashArray[] = {2, 1}; + if (iCapType != XFA_AttributeEnum::Butt) + dashArray[1] = 2; + + pGraphics->SetLineDash(0, dashArray, 2); + break; + } + default: + pGraphics->SetSolidLineDash(); + break; + } +} + CXFA_Stroke::CXFA_Stroke(CXFA_Document* pDoc, XFA_PacketType ePacket, uint32_t validPackets, diff --git a/xfa/fxfa/parser/cxfa_stroke.h b/xfa/fxfa/parser/cxfa_stroke.h index d3eeff1ed2..ed41997073 100644 --- a/xfa/fxfa/parser/cxfa_stroke.h +++ b/xfa/fxfa/parser/cxfa_stroke.h @@ -22,6 +22,10 @@ class CXFA_GEPath; class CXFA_Graphics; class CXFA_Node; +void XFA_StrokeTypeSetLineDash(CXFA_Graphics* pGraphics, + XFA_AttributeEnum iStrokeType, + XFA_AttributeEnum iCapType); + class CXFA_Stroke : public CXFA_Node { public: ~CXFA_Stroke() override; -- cgit v1.2.3