From ddfc3dcce42ad1dc805f29102f7d056a5809d489 Mon Sep 17 00:00:00 2001 From: Nicolas Pena Date: Thu, 20 Apr 2017 15:29:25 -0400 Subject: Let {Argb,Cmyk}Decode return tuples MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ic4e766d9417f9a9ece5f9e4269d0f96e1e91639b Reviewed-on: https://pdfium-review.googlesource.com/4392 Commit-Queue: Nicolás Peña Reviewed-by: Tom Sepez --- xfa/fxfa/cxfa_ffwidget.cpp | 7 +++---- xfa/fxfa/parser/cxfa_fill.cpp | 7 +++++-- xfa/fxfa/parser/cxfa_node.cpp | 11 +++++++---- xfa/fxfa/parser/cxfa_stroke.cpp | 2 +- xfa/fxgraphics/cfx_shading.cpp | 6 +++--- 5 files changed, 19 insertions(+), 14 deletions(-) (limited to 'xfa') diff --git a/xfa/fxfa/cxfa_ffwidget.cpp b/xfa/fxfa/cxfa_ffwidget.cpp index bdadba7c85..06de436e09 100644 --- a/xfa/fxfa/cxfa_ffwidget.cpp +++ b/xfa/fxfa/cxfa_ffwidget.cpp @@ -1660,12 +1660,11 @@ static void XFA_BOX_Fill(CXFA_Box box, FX_ARGB cr; if (eType == XFA_Element::Stipple) { int32_t iRate = fill.GetStipple(cr); - if (iRate == 0) { + if (iRate == 0) iRate = 100; - } - int32_t a = 0; + int32_t a; FX_COLORREF rgb; - ArgbDecode(cr, a, rgb); + std::tie(a, rgb) = ArgbToColorRef(cr); cr = ArgbEncode(iRate * a / 100, rgb); } else { cr = fill.GetColor(); diff --git a/xfa/fxfa/parser/cxfa_fill.cpp b/xfa/fxfa/parser/cxfa_fill.cpp index 8621c3c961..8a7969d5e4 100644 --- a/xfa/fxfa/parser/cxfa_fill.cpp +++ b/xfa/fxfa/parser/cxfa_fill.cpp @@ -19,8 +19,11 @@ int32_t CXFA_Fill::GetPresence() { void CXFA_Fill::SetColor(FX_ARGB color) { CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_Element::Color); CFX_WideString wsColor; - int a, r, g, b; - ArgbDecode(color, a, r, g, b); + int a; + int r; + int g; + int b; + std::tie(a, r, g, b) = ArgbDecode(color); wsColor.Format(L"%d,%d,%d", r, g, b); pNode->SetCData(XFA_ATTRIBUTE_Value, wsColor); } diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp index d6d2ece428..73fc88db8f 100644 --- a/xfa/fxfa/parser/cxfa_node.cpp +++ b/xfa/fxfa/parser/cxfa_node.cpp @@ -2054,8 +2054,11 @@ void CXFA_Node::Script_Som_BorderColor(CFXJSE_Value* pValue, } else { CXFA_Edge edge = border.GetEdge(0); FX_ARGB color = edge.GetColor(); - int32_t a, r, g, b; - ArgbDecode(color, a, r, g, b); + int32_t a; + int32_t r; + int32_t g; + int32_t b; + std::tie(a, r, g, b) = ArgbDecode(color); CFX_WideString strColor; strColor.Format(L"%d,%d,%d", r, g, b); pValue->SetString(strColor.UTF8Encode().AsStringC()); @@ -2113,7 +2116,7 @@ void CXFA_Node::Script_Som_FillColor(CFXJSE_Value* pValue, int32_t r; int32_t g; int32_t b; - ArgbDecode(color, a, r, g, b); + std::tie(a, r, g, b) = ArgbDecode(color); CFX_WideString wsColor; wsColor.Format(L"%d,%d,%d", r, g, b); pValue->SetString(wsColor.UTF8Encode().AsStringC()); @@ -2265,7 +2268,7 @@ void CXFA_Node::Script_Som_FontColor(CFXJSE_Value* pValue, int32_t r; int32_t g; int32_t b; - ArgbDecode(color, a, r, g, b); + std::tie(a, r, g, b) = ArgbDecode(color); CFX_WideString wsColor; wsColor.Format(L"%d,%d,%d", r, g, b); pValue->SetString(wsColor.UTF8Encode().AsStringC()); diff --git a/xfa/fxfa/parser/cxfa_stroke.cpp b/xfa/fxfa/parser/cxfa_stroke.cpp index df11cbee00..e81c0ce591 100644 --- a/xfa/fxfa/parser/cxfa_stroke.cpp +++ b/xfa/fxfa/parser/cxfa_stroke.cpp @@ -67,7 +67,7 @@ void CXFA_Stroke::SetColor(FX_ARGB argb) { int r; int g; int b; - ArgbDecode(argb, a, r, g, b); + std::tie(a, r, g, b) = ArgbDecode(argb); wsColor.Format(L"%d,%d,%d", r, g, b); pNode->SetCData(XFA_ATTRIBUTE_Value, wsColor); } diff --git a/xfa/fxgraphics/cfx_shading.cpp b/xfa/fxgraphics/cfx_shading.cpp index 7dc8ce3412..b099bb97b1 100644 --- a/xfa/fxgraphics/cfx_shading.cpp +++ b/xfa/fxgraphics/cfx_shading.cpp @@ -51,15 +51,15 @@ void CFX_Shading::InitArgbArray() { int32_t r1; int32_t g1; int32_t b1; - ArgbDecode(m_beginArgb, a1, r1, g1, b1); + std::tie(a1, r1, g1, b1) = ArgbDecode(m_beginArgb); int32_t a2; int32_t r2; int32_t g2; int32_t b2; - ArgbDecode(m_endArgb, a2, r2, g2, b2); + std::tie(a2, r2, g2, b2) = ArgbDecode(m_endArgb); - float f = (float)(FX_SHADING_Steps - 1); + float f = static_cast(FX_SHADING_Steps - 1); float aScale = 1.0 * (a2 - a1) / f; float rScale = 1.0 * (r2 - r1) / f; float gScale = 1.0 * (g2 - g1) / f; -- cgit v1.2.3