diff options
author | Lei Zhang <thestig@chromium.org> | 2018-03-15 19:27:17 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-03-15 19:27:17 +0000 |
commit | 7d75650672a848428aaadb603b2814d33dfb479f (patch) | |
tree | 508d0c992231aa1a5faad16d7ebe1bf1c44c4d78 /core | |
parent | 35841fa4e3dbf8f9146f78def048c4a287894a8a (diff) | |
download | pdfium-7d75650672a848428aaadb603b2814d33dfb479f.tar.xz |
Add a CFX_PathData::AppendRect() variant.chromium/3372
One that takes a CFX_FloatRect instead of LBRT floats. Use it where
appropriate.
Change-Id: I8ba19e86c61c91d8b4ef685b5cb65c8fb717f013
Reviewed-on: https://pdfium-review.googlesource.com/28581
Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'core')
-rw-r--r-- | core/fpdfdoc/cpdf_annot.cpp | 7 | ||||
-rw-r--r-- | core/fxge/cfx_pathdata.cpp | 4 | ||||
-rw-r--r-- | core/fxge/cfx_pathdata.h | 1 | ||||
-rw-r--r-- | core/fxge/cfx_renderdevice.cpp | 9 |
4 files changed, 12 insertions, 9 deletions
diff --git a/core/fpdfdoc/cpdf_annot.cpp b/core/fpdfdoc/cpdf_annot.cpp index c74965c3e7..cc70a3087c 100644 --- a/core/fpdfdoc/cpdf_annot.cpp +++ b/core/fpdfdoc/cpdf_annot.cpp @@ -485,11 +485,12 @@ void CPDF_Annot::DrawBorder(CFX_RenderDevice* pDevice, graph_state.m_DashArray[0] = graph_state.m_DashArray[1] = 3 * 1.0f; } } + CFX_FloatRect rect = GetRect(); + rect.Deflate(width / 2, width / 2); CFX_PathData path; - width /= 2; - path.AppendRect(rect.left + width, rect.bottom + width, rect.right - width, - rect.top - width); + path.AppendRect(rect); + int fill_type = 0; if (pOptions && (pOptions->HasFlag(RENDER_NOPATHSMOOTH))) fill_type |= FXFILL_NOPATHSMOOTH; diff --git a/core/fxge/cfx_pathdata.cpp b/core/fxge/cfx_pathdata.cpp index 4ac5cf6a7a..ac1ff42629 100644 --- a/core/fxge/cfx_pathdata.cpp +++ b/core/fxge/cfx_pathdata.cpp @@ -210,6 +210,10 @@ void CFX_PathData::AppendLine(const CFX_PointF& pt1, const CFX_PointF& pt2) { AppendPoint(pt2, FXPT_TYPE::LineTo, false); } +void CFX_PathData::AppendRect(const CFX_FloatRect& rect) { + return AppendRect(rect.left, rect.bottom, rect.right, rect.top); +} + void CFX_PathData::AppendRect(float left, float bottom, float right, diff --git a/core/fxge/cfx_pathdata.h b/core/fxge/cfx_pathdata.h index d346ba0666..5c2be627bf 100644 --- a/core/fxge/cfx_pathdata.h +++ b/core/fxge/cfx_pathdata.h @@ -59,6 +59,7 @@ class CFX_PathData : public Retainable { bool IsRect(const CFX_Matrix* pMatrix, CFX_FloatRect* rect) const; void Append(const CFX_PathData* pSrc, const CFX_Matrix* pMatrix); + void AppendRect(const CFX_FloatRect& rect); void AppendRect(float left, float bottom, float right, float top); void AppendLine(const CFX_PointF& pt1, const CFX_PointF& pt2); void AppendPoint(const CFX_PointF& pos, FXPT_TYPE type, bool closeFigure); diff --git a/core/fxge/cfx_renderdevice.cpp b/core/fxge/cfx_renderdevice.cpp index 6c7e896b01..2e279d636f 100644 --- a/core/fxge/cfx_renderdevice.cpp +++ b/core/fxge/cfx_renderdevice.cpp @@ -1134,8 +1134,7 @@ void CFX_RenderDevice::DrawFillRect(const CFX_Matrix* pUser2Device, const CFX_FloatRect& rect, const FX_COLORREF& color) { CFX_PathData path; - CFX_FloatRect rcTemp(rect); - path.AppendRect(rcTemp.left, rcTemp.bottom, rcTemp.right, rcTemp.top); + path.AppendRect(rect); DrawPath(&path, pUser2Device, nullptr, color, 0, FXFILL_WINDING); } @@ -1155,13 +1154,11 @@ void CFX_RenderDevice::DrawStrokeRect(const CFX_Matrix* pUser2Device, const CFX_FloatRect& rect, const FX_COLORREF& color, float fWidth) { - CFX_PathData path; - CFX_FloatRect rcTemp(rect); - path.AppendRect(rcTemp.left, rcTemp.bottom, rcTemp.right, rcTemp.top); - CFX_GraphStateData gsd; gsd.m_LineWidth = fWidth; + CFX_PathData path; + path.AppendRect(rect); DrawPath(&path, pUser2Device, &gsd, 0, color, FXFILL_ALTERNATE); } |