From 334e79e15c271aeccacd65376e0050725d79d79d Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Thu, 13 Jul 2017 13:44:40 -0400 Subject: Move CPWL_Utils::ScaleRect to CFX_FloatRect This CL moves the ScaleRect method to Scale on CFX_FloatRect and changes it to operate directly on the rect. Change-Id: Ie0f91c9319be08c9e2cc81cba2519ebb5f2c35eb Reviewed-on: https://pdfium-review.googlesource.com/7714 Reviewed-by: Tom Sepez Commit-Queue: dsinclair --- fpdfsdk/pdfwindow/cpwl_utils.cpp | 36 ++++++++++++++++-------------------- fpdfsdk/pdfwindow/cpwl_utils.h | 2 -- 2 files changed, 16 insertions(+), 22 deletions(-) (limited to 'fpdfsdk/pdfwindow') diff --git a/fpdfsdk/pdfwindow/cpwl_utils.cpp b/fpdfsdk/pdfwindow/cpwl_utils.cpp index 998c95c875..238abe7488 100644 --- a/fpdfsdk/pdfwindow/cpwl_utils.cpp +++ b/fpdfsdk/pdfwindow/cpwl_utils.cpp @@ -218,18 +218,6 @@ CFX_ByteString CPWL_Utils::GetAP_HalfCircle(const CFX_FloatRect& crBBox, return CFX_ByteString(csAP); } -CFX_FloatRect CPWL_Utils::ScaleRect(const CFX_FloatRect& rcRect, float fScale) { - float fHalfWidth = (rcRect.right - rcRect.left) / 2.0f; - float fHalfHeight = (rcRect.top - rcRect.bottom) / 2.0f; - - CFX_PointF ptCenter = CFX_PointF((rcRect.left + rcRect.right) / 2, - (rcRect.top + rcRect.bottom) / 2); - - return CFX_FloatRect( - ptCenter.x - fHalfWidth * fScale, ptCenter.y - fHalfHeight * fScale, - ptCenter.x + fHalfWidth * fScale, ptCenter.y + fHalfHeight * fScale); -} - CFX_ByteString CPWL_Utils::GetRectFillAppStream(const CFX_FloatRect& rect, const CPWL_Color& color) { std::ostringstream sAppStream; @@ -784,15 +772,19 @@ CFX_ByteString CPWL_Utils::GetCheckBoxAppStream(const CFX_FloatRect& rcBBox, case PCS_CHECK: return GetAppStream_Check(rcCenter, crText); case PCS_CIRCLE: - return GetAppStream_Circle(ScaleRect(rcCenter, 2.0f / 3.0f), crText); + rcCenter.Scale(2.0f / 3.0f); + return GetAppStream_Circle(rcCenter, crText); case PCS_CROSS: return GetAppStream_Cross(rcCenter, crText); case PCS_DIAMOND: - return GetAppStream_Diamond(ScaleRect(rcCenter, 2.0f / 3.0f), crText); + rcCenter.Scale(2.0f / 3.0f); + return GetAppStream_Diamond(rcCenter, crText); case PCS_SQUARE: - return GetAppStream_Square(ScaleRect(rcCenter, 2.0f / 3.0f), crText); + rcCenter.Scale(2.0f / 3.0f); + return GetAppStream_Square(rcCenter, crText); case PCS_STAR: - return GetAppStream_Star(ScaleRect(rcCenter, 2.0f / 3.0f), crText); + rcCenter.Scale(2.0f / 3.0f); + return GetAppStream_Star(rcCenter, crText); } } @@ -805,15 +797,19 @@ CFX_ByteString CPWL_Utils::GetRadioButtonAppStream(const CFX_FloatRect& rcBBox, case PCS_CHECK: return GetAppStream_Check(rcCenter, crText); case PCS_CIRCLE: - return GetAppStream_Circle(ScaleRect(rcCenter, 1.0f / 2.0f), crText); + rcCenter.Scale(1.0f / 2.0f); + return GetAppStream_Circle(rcCenter, crText); case PCS_CROSS: return GetAppStream_Cross(rcCenter, crText); case PCS_DIAMOND: - return GetAppStream_Diamond(ScaleRect(rcCenter, 2.0f / 3.0f), crText); + rcCenter.Scale(2.0f / 3.0f); + return GetAppStream_Diamond(rcCenter, crText); case PCS_SQUARE: - return GetAppStream_Square(ScaleRect(rcCenter, 2.0f / 3.0f), crText); + rcCenter.Scale(2.0f / 3.0f); + return GetAppStream_Square(rcCenter, crText); case PCS_STAR: - return GetAppStream_Star(ScaleRect(rcCenter, 2.0f / 3.0f), crText); + rcCenter.Scale(2.0f / 3.0f); + return GetAppStream_Star(rcCenter, crText); } } diff --git a/fpdfsdk/pdfwindow/cpwl_utils.h b/fpdfsdk/pdfwindow/cpwl_utils.h index ec6188e2b9..8d2a47a34e 100644 --- a/fpdfsdk/pdfwindow/cpwl_utils.h +++ b/fpdfsdk/pdfwindow/cpwl_utils.h @@ -122,8 +122,6 @@ class CPWL_Utils { int32_t nEndGray); private: - static CFX_FloatRect ScaleRect(const CFX_FloatRect& rcRect, float fScale); - static CFX_ByteString GetAppStream_Check(const CFX_FloatRect& rcBBox, const CPWL_Color& crText); static CFX_ByteString GetAppStream_Circle(const CFX_FloatRect& rcBBox, -- cgit v1.2.3