From 77f9bff2c229df771a43448a9d5087e042235936 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Tue, 29 Aug 2017 11:34:12 -0700 Subject: Reduce rounding errors when Invalidating rects. Instead of using CFX_FloatRect::ToFxRect(), which always rounds down, use GetOuterRect() which correctly rounds up / down depending on the side of the rectangle. Change-Id: I7abd3a65e8c0467ed4303292f26a72737a5d553b Reviewed-on: https://pdfium-review.googlesource.com/12312 Commit-Queue: dsinclair Reviewed-by: dsinclair --- fpdfsdk/cfx_systemhandler.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'fpdfsdk/cfx_systemhandler.cpp') diff --git a/fpdfsdk/cfx_systemhandler.cpp b/fpdfsdk/cfx_systemhandler.cpp index 6281b1be91..c8b1ef4b04 100644 --- a/fpdfsdk/cfx_systemhandler.cpp +++ b/fpdfsdk/cfx_systemhandler.cpp @@ -40,7 +40,8 @@ CFX_SystemHandler::CFX_SystemHandler(CPDFSDK_FormFillEnvironment* pFormFillEnv) CFX_SystemHandler::~CFX_SystemHandler() {} -void CFX_SystemHandler::InvalidateRect(CPDFSDK_Widget* widget, FX_RECT rect) { +void CFX_SystemHandler::InvalidateRect(CPDFSDK_Widget* widget, + const CFX_FloatRect& rect) { CPDFSDK_PageView* pPageView = widget->GetPageView(); UnderlyingPageType* pPage = widget->GetUnderlyingPage(); if (!pPage || !pPageView) @@ -51,14 +52,13 @@ void CFX_SystemHandler::InvalidateRect(CPDFSDK_Widget* widget, FX_RECT rect) { CFX_Matrix device2page = page2device.GetInverse(); - CFX_PointF left_top = device2page.Transform( - CFX_PointF(static_cast(rect.left), static_cast(rect.top))); - CFX_PointF right_bottom = device2page.Transform(CFX_PointF( - static_cast(rect.right), static_cast(rect.bottom))); + CFX_PointF left_top = device2page.Transform(CFX_PointF(rect.left, rect.top)); + CFX_PointF right_bottom = + device2page.Transform(CFX_PointF(rect.right, rect.bottom)); CFX_FloatRect rcPDF(left_top.x, right_bottom.y, right_bottom.x, left_top.y); rcPDF.Normalize(); - m_pFormFillEnv->Invalidate(pPage, rcPDF.ToFxRect()); + m_pFormFillEnv->Invalidate(pPage, rcPDF.GetOuterRect()); } void CFX_SystemHandler::OutputSelectedRect(CFFL_FormFiller* pFormFiller, -- cgit v1.2.3