summaryrefslogtreecommitdiff
path: root/fpdfsdk/pdfwindow/cpwl_utils.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-07-13 13:44:40 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-07-13 18:31:06 +0000
commit334e79e15c271aeccacd65376e0050725d79d79d (patch)
treee7a19aa140a8ec32b04268dee355944849d48f08 /fpdfsdk/pdfwindow/cpwl_utils.cpp
parent3628f8b06e4518c81971782455270d5db4ff91c9 (diff)
downloadpdfium-334e79e15c271aeccacd65376e0050725d79d79d.tar.xz
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 <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fpdfsdk/pdfwindow/cpwl_utils.cpp')
-rw-r--r--fpdfsdk/pdfwindow/cpwl_utils.cpp36
1 files changed, 16 insertions, 20 deletions
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);
}
}