From bba2a7cf30da9e84bcc14ef32dbb0bb944229219 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Tue, 7 Feb 2017 16:36:39 -0500 Subject: Update to use CFX_Rect{F} and CFX_Matrix constructors. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This Cl updates the code to use the constructors instead of creating an empty object and calling Set(). It also removes the various memsets of the CFX_Rect{F} classes. Change-Id: I6e20cec00866a38372858dcba5a30d31103172e4 Reviewed-on: https://pdfium-review.googlesource.com/2550 Commit-Queue: dsinclair Reviewed-by: Nicolás Peña Reviewed-by: Tom Sepez --- xfa/fde/tto/fde_textout.cpp | 54 ++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 28 deletions(-) (limited to 'xfa/fde/tto/fde_textout.cpp') diff --git a/xfa/fde/tto/fde_textout.cpp b/xfa/fde/tto/fde_textout.cpp index ca5aa566e1..b126d4e583 100644 --- a/xfa/fde/tto/fde_textout.cpp +++ b/xfa/fde/tto/fde_textout.cpp @@ -138,8 +138,10 @@ void CFDE_TextOut::SetRenderDevice(CFX_RenderDevice* pDevice) { } void CFDE_TextOut::SetClipRect(const CFX_Rect& rtClip) { - m_rtClip.Set((FX_FLOAT)rtClip.left, (FX_FLOAT)rtClip.top, - (FX_FLOAT)rtClip.Width(), (FX_FLOAT)rtClip.Height()); + m_rtClip = CFX_RectF(static_cast(rtClip.left), + static_cast(rtClip.top), + static_cast(rtClip.Width()), + static_cast(rtClip.Height())); } void CFDE_TextOut::SetClipRect(const CFX_RectF& rtClip) { @@ -166,8 +168,8 @@ int32_t CFDE_TextOut::GetTotalLines() { void CFDE_TextOut::CalcSize(const FX_WCHAR* pwsStr, int32_t iLength, CFX_Size& size) { - CFX_RectF rtText; - rtText.Set(0.0f, 0.0f, (FX_FLOAT)size.x, (FX_FLOAT)size.y); + CFX_RectF rtText(0.0f, 0.0f, static_cast(size.x), + static_cast(size.y)); CalcSize(pwsStr, iLength, rtText); size.x = (int32_t)rtText.Width(); size.y = (int32_t)rtText.Height(); @@ -176,8 +178,7 @@ void CFDE_TextOut::CalcSize(const FX_WCHAR* pwsStr, void CFDE_TextOut::CalcSize(const FX_WCHAR* pwsStr, int32_t iLength, CFX_SizeF& size) { - CFX_RectF rtText; - rtText.Set(0.0f, 0.0f, size.x, size.y); + CFX_RectF rtText(0.0f, 0.0f, size.x, size.y); CalcSize(pwsStr, iLength, rtText); size.x = rtText.Width(); size.y = rtText.Height(); @@ -186,12 +187,15 @@ void CFDE_TextOut::CalcSize(const FX_WCHAR* pwsStr, void CFDE_TextOut::CalcSize(const FX_WCHAR* pwsStr, int32_t iLength, CFX_Rect& rect) { - CFX_RectF rtText; - rtText.Set((FX_FLOAT)rect.left, (FX_FLOAT)rect.top, (FX_FLOAT)rect.Width(), - (FX_FLOAT)rect.Height()); + CFX_RectF rtText(static_cast(rect.left), + static_cast(rect.top), + static_cast(rect.Width()), + static_cast(rect.Height())); CalcSize(pwsStr, iLength, rtText); - rect.Set((int32_t)rtText.left, (int32_t)rtText.top, (int32_t)rtText.Width(), - (int32_t)rtText.Height()); + rect = CFX_Rect(static_cast(rtText.left), + static_cast(rtText.top), + static_cast(rtText.Width()), + static_cast(rtText.Height())); } void CFDE_TextOut::CalcSize(const FX_WCHAR* pwsStr, @@ -212,8 +216,7 @@ void CFDE_TextOut::CalcSize(const FX_WCHAR* pwsStr, void CFDE_TextOut::CalcLogicSize(const FX_WCHAR* pwsStr, int32_t iLength, CFX_SizeF& size) { - CFX_RectF rtText; - rtText.Set(0.0f, 0.0f, size.x, size.y); + CFX_RectF rtText(0.0f, 0.0f, size.x, size.y); CalcLogicSize(pwsStr, iLength, rtText); size.x = rtText.Width(); size.y = rtText.Height(); @@ -346,9 +349,8 @@ void CFDE_TextOut::DrawText(const FX_WCHAR* pwsStr, int32_t iLength, int32_t x, int32_t y) { - CFX_RectF rtText; - rtText.Set((FX_FLOAT)x, (FX_FLOAT)y, m_fFontSize * 1000.0f, - m_fFontSize * 1000.0f); + CFX_RectF rtText(static_cast(x), static_cast(y), + m_fFontSize * 1000.0f, m_fFontSize * 1000.0f); DrawText(pwsStr, iLength, rtText); } @@ -356,25 +358,23 @@ void CFDE_TextOut::DrawText(const FX_WCHAR* pwsStr, int32_t iLength, FX_FLOAT x, FX_FLOAT y) { - CFX_RectF rtText; - rtText.Set(x, y, m_fFontSize * 1000.0f, m_fFontSize * 1000.0f); + CFX_RectF rtText(x, y, m_fFontSize * 1000.0f, m_fFontSize * 1000.0f); DrawText(pwsStr, iLength, rtText); } void CFDE_TextOut::DrawText(const FX_WCHAR* pwsStr, int32_t iLength, const CFX_Rect& rect) { - CFX_RectF rtText; - rtText.Set((FX_FLOAT)rect.left, (FX_FLOAT)rect.top, (FX_FLOAT)rect.width, - (FX_FLOAT)rect.height); + CFX_RectF rtText( + static_cast(rect.left), static_cast(rect.top), + static_cast(rect.width), static_cast(rect.height)); DrawText(pwsStr, iLength, rtText); } void CFDE_TextOut::DrawText(const FX_WCHAR* pwsStr, int32_t iLength, const CFX_RectF& rect) { - CFX_RectF rtText; - rtText.Set(rect.left, rect.top, rect.width, rect.height); + CFX_RectF rtText(rect.left, rect.top, rect.width, rect.height); CFX_Matrix rm; rm.SetReverse(m_Matrix); rm.TransformRect(rtText); @@ -385,17 +385,15 @@ void CFDE_TextOut::DrawLogicText(const FX_WCHAR* pwsStr, int32_t iLength, FX_FLOAT x, FX_FLOAT y) { - CFX_RectF rtText; - rtText.Set(x, y, m_fFontSize * 1000.0f, m_fFontSize * 1000.0f); + CFX_RectF rtText(x, y, m_fFontSize * 1000.0f, m_fFontSize * 1000.0f); DrawLogicText(pwsStr, iLength, rtText); } void CFDE_TextOut::DrawLogicText(const FX_WCHAR* pwsStr, int32_t iLength, const CFX_RectF& rect) { - CFX_RectF rtClip; - rtClip.Set(m_rtLogicClip.left, m_rtLogicClip.top, m_rtLogicClip.width, - m_rtLogicClip.height); + CFX_RectF rtClip(m_rtLogicClip.left, m_rtLogicClip.top, m_rtLogicClip.width, + m_rtLogicClip.height); m_Matrix.TransformRect(rtClip); DrawText(pwsStr, iLength, rect, rtClip); } -- cgit v1.2.3