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/pwl/cpwl_wnd.cpp | 15 +++++---------- fpdfsdk/pwl/cpwl_wnd.h | 2 +- 2 files changed, 6 insertions(+), 11 deletions(-) (limited to 'fpdfsdk/pwl') diff --git a/fpdfsdk/pwl/cpwl_wnd.cpp b/fpdfsdk/pwl/cpwl_wnd.cpp index 0198c63d6a..53c692dada 100644 --- a/fpdfsdk/pwl/cpwl_wnd.cpp +++ b/fpdfsdk/pwl/cpwl_wnd.cpp @@ -18,7 +18,6 @@ namespace { constexpr float kDefaultFontSize = 9.0f; -constexpr int kInvalidationInflate = 2; } // namespace @@ -302,11 +301,9 @@ void CPWL_Wnd::InvalidateRect(CFX_FloatRect* pRect) { } } - FX_RECT rcWin = PWLtoWnd(rcRefresh); - rcWin.left -= kInvalidationInflate; - rcWin.top -= kInvalidationInflate; - rcWin.right += kInvalidationInflate; - rcWin.bottom += kInvalidationInflate; + CFX_FloatRect rcWin = PWLtoWnd(rcRefresh); + rcWin.Inflate(1, 1); + rcWin.Normalize(); if (CFX_SystemHandler* pSH = GetSystemHandler()) { if (CPDFSDK_Widget* widget = static_cast( @@ -737,11 +734,9 @@ CFX_Matrix CPWL_Wnd::GetWindowMatrix() const { return mt; } -FX_RECT CPWL_Wnd::PWLtoWnd(const CFX_FloatRect& rect) const { +CFX_FloatRect CPWL_Wnd::PWLtoWnd(const CFX_FloatRect& rect) const { CFX_Matrix mt = GetWindowMatrix(); - CFX_FloatRect rcTemp = mt.TransformRect(rect); - return FX_RECT((int32_t)(rcTemp.left + 0.5), (int32_t)(rcTemp.bottom + 0.5), - (int32_t)(rcTemp.right + 0.5), (int32_t)(rcTemp.top + 0.5)); + return mt.TransformRect(rect); } CFX_PointF CPWL_Wnd::ParentToChild(const CFX_PointF& point) const { diff --git a/fpdfsdk/pwl/cpwl_wnd.h b/fpdfsdk/pwl/cpwl_wnd.h index 3c6c2824e2..9c913f1c23 100644 --- a/fpdfsdk/pwl/cpwl_wnd.h +++ b/fpdfsdk/pwl/cpwl_wnd.h @@ -318,7 +318,7 @@ class CPWL_Wnd : public CPWL_TimerHandler, public CFX_Observable { void DrawChildAppearance(CFX_RenderDevice* pDevice, const CFX_Matrix& mtUser2Device); - FX_RECT PWLtoWnd(const CFX_FloatRect& rect) const; + CFX_FloatRect PWLtoWnd(const CFX_FloatRect& rect) const; void AddChild(CPWL_Wnd* pWnd); void RemoveChild(CPWL_Wnd* pWnd); -- cgit v1.2.3