diff options
author | dan sinclair <dsinclair@chromium.org> | 2017-07-12 21:56:27 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-07-13 17:11:16 +0000 |
commit | adf922f278d23e7f955b89f48cc64b5de7925977 (patch) | |
tree | 1cae79929399b712938d88480d90ebc2c7ea59ff /fpdfsdk/pdfwindow/cpwl_utils.cpp | |
parent | a860a3d596f3daeadfdca0cc2093bfca722fa3a3 (diff) | |
download | pdfium-adf922f278d23e7f955b89f48cc64b5de7925977.tar.xz |
Remove CPWL_Utils::{In,De}flateRect
This CL removes the custom InflateRect and Deflate rect code in CPWL_Utils in
favour of calling the CFX_FloatRect version. This required inlining some extra
code at each callsite to check the rect size and normalize.
Change-Id: I7f60e5de03fc1db0c1d8e51eaa1d0e0700ebf157
Reviewed-on: https://pdfium-review.googlesource.com/7710
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.cpp | 66 |
1 files changed, 22 insertions, 44 deletions
diff --git a/fpdfsdk/pdfwindow/cpwl_utils.cpp b/fpdfsdk/pdfwindow/cpwl_utils.cpp index 4dd897d7d2..c31e092cd6 100644 --- a/fpdfsdk/pdfwindow/cpwl_utils.cpp +++ b/fpdfsdk/pdfwindow/cpwl_utils.cpp @@ -236,28 +236,6 @@ CFX_ByteString CPWL_Utils::GetAP_HalfCircle(const CFX_FloatRect& crBBox, return CFX_ByteString(csAP); } -CFX_FloatRect CPWL_Utils::InflateRect(const CFX_FloatRect& rcRect, - float fSize) { - if (rcRect.IsEmpty()) - return rcRect; - - CFX_FloatRect rcNew(rcRect.left - fSize, rcRect.bottom - fSize, - rcRect.right + fSize, rcRect.top + fSize); - rcNew.Normalize(); - return rcNew; -} - -CFX_FloatRect CPWL_Utils::DeflateRect(const CFX_FloatRect& rcRect, - float fSize) { - if (rcRect.IsEmpty()) - return rcRect; - - CFX_FloatRect rcNew(rcRect.left + fSize, rcRect.bottom + fSize, - rcRect.right - fSize, rcRect.top - fSize); - rcNew.Normalize(); - return rcNew; -} - 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; @@ -675,6 +653,20 @@ CFX_ByteString CPWL_Utils::GetCircleBorderAppStream( if (fWidth > 0.0f) { sAppStream << "q\n"; + float fHalfWidth = fWidth / 2.0f; + + CFX_FloatRect rect_by_2 = rect; + CFX_FloatRect rect_by_75 = rect; + if (!rect.IsEmpty()) { + float div = fWidth / 2.0f; + rect_by_2.Deflate(div, div); + rect_by_2.Normalize(); + + div = fHalfWidth * 0.75f; + rect_by_75.Deflate(div, div); + rect_by_75.Normalize(); + } + switch (nStyle) { default: case BorderStyle::SOLID: @@ -683,9 +675,7 @@ CFX_ByteString CPWL_Utils::GetCircleBorderAppStream( if (sColor.GetLength() > 0) { sAppStream << "q\n" << fWidth << " w\n" - << sColor - << CPWL_Utils::GetAP_Circle( - CPWL_Utils::DeflateRect(rect, fWidth / 2.0f)) + << sColor << CPWL_Utils::GetAP_Circle(rect_by_2) << " S\nQ\n"; } } break; @@ -696,15 +686,11 @@ CFX_ByteString CPWL_Utils::GetCircleBorderAppStream( << fWidth << " w\n" << "[" << dash.nDash << " " << dash.nGap << "] " << dash.nPhase << " d\n" - << sColor - << CPWL_Utils::GetAP_Circle( - CPWL_Utils::DeflateRect(rect, fWidth / 2.0f)) + << sColor << CPWL_Utils::GetAP_Circle(rect_by_2) << " S\nQ\n"; } } break; case BorderStyle::BEVELED: { - float fHalfWidth = fWidth / 2.0f; - sColor = CPWL_Utils::GetColorAppStream(color, false); if (sColor.GetLength() > 0) { sAppStream << "q\n" @@ -717,9 +703,7 @@ CFX_ByteString CPWL_Utils::GetCircleBorderAppStream( sAppStream << "q\n" << fHalfWidth << " w\n" << sColor - << CPWL_Utils::GetAP_HalfCircle( - CPWL_Utils::DeflateRect(rect, fHalfWidth * 0.75f), - FX_PI / 4.0f) + << CPWL_Utils::GetAP_HalfCircle(rect_by_75, FX_PI / 4.0f) << " S\nQ\n"; } @@ -728,15 +712,12 @@ CFX_ByteString CPWL_Utils::GetCircleBorderAppStream( sAppStream << "q\n" << fHalfWidth << " w\n" << sColor - << CPWL_Utils::GetAP_HalfCircle( - CPWL_Utils::DeflateRect(rect, fHalfWidth * 0.75f), - FX_PI * 5 / 4.0f) + << CPWL_Utils::GetAP_HalfCircle(rect_by_75, + FX_PI * 5 / 4.0f) << " S\nQ\n"; } } break; case BorderStyle::INSET: { - float fHalfWidth = fWidth / 2.0f; - sColor = CPWL_Utils::GetColorAppStream(color, false); if (sColor.GetLength() > 0) { sAppStream << "q\n" @@ -749,9 +730,7 @@ CFX_ByteString CPWL_Utils::GetCircleBorderAppStream( sAppStream << "q\n" << fHalfWidth << " w\n" << sColor - << CPWL_Utils::GetAP_HalfCircle( - CPWL_Utils::DeflateRect(rect, fHalfWidth * 0.75f), - FX_PI / 4.0f) + << CPWL_Utils::GetAP_HalfCircle(rect_by_75, FX_PI / 4.0f) << " S\nQ\n"; } @@ -760,9 +739,8 @@ CFX_ByteString CPWL_Utils::GetCircleBorderAppStream( sAppStream << "q\n" << fHalfWidth << " w\n" << sColor - << CPWL_Utils::GetAP_HalfCircle( - CPWL_Utils::DeflateRect(rect, fHalfWidth * 0.75f), - FX_PI * 5 / 4.0f) + << CPWL_Utils::GetAP_HalfCircle(rect_by_75, + FX_PI * 5 / 4.0f) << " S\nQ\n"; } } break; |