summaryrefslogtreecommitdiff
path: root/core/fxcrt/fx_coordinates.h
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2017-12-04 21:24:15 +0000
committerChromium commit bot <commit-bot@chromium.org>2017-12-04 21:24:15 +0000
commit12ec6760afd92b63d185854008a55762fe39f866 (patch)
tree77c68ccfba27109dd6de1dcb01848693272a3790 /core/fxcrt/fx_coordinates.h
parentcfc8b87d5242f1493a54ba4f1125f2b8ef1791bd (diff)
downloadpdfium-12ec6760afd92b63d185854008a55762fe39f866.tar.xz
Simplify some CFX_FloatRect methods.chromium/3285
Also add a comment about the various CFX_FloatRect to FX_RECT conversion methods. Change-Id: Ia9984797dc513cdc487fe9972b32c216c9f99ec1 Reviewed-on: https://pdfium-review.googlesource.com/20217 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Diffstat (limited to 'core/fxcrt/fx_coordinates.h')
-rw-r--r--core/fxcrt/fx_coordinates.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/core/fxcrt/fx_coordinates.h b/core/fxcrt/fx_coordinates.h
index 1767e33f0c..55d28cd66f 100644
--- a/core/fxcrt/fx_coordinates.h
+++ b/core/fxcrt/fx_coordinates.h
@@ -247,9 +247,20 @@ class CFX_FloatRect {
void Intersect(const CFX_FloatRect& other_rect);
void Union(const CFX_FloatRect& other_rect);
+ // These may be better at rounding than ToFxRect() and friends.
+ //
+ // Returned rect has bounds rounded up/down such that it is contained in the
+ // original.
FX_RECT GetInnerRect() const;
+
+ // Returned rect has bounds rounded up/down such that the original is
+ // contained in it.
FX_RECT GetOuterRect() const;
+
+ // Returned rect has bounds rounded up/down such that the dimensions are
+ // rounded up and the sum of the error in the bounds is minimized.
FX_RECT GetClosestRect() const;
+
CFX_FloatRect GetCenterSquare() const;
void InitRect(const CFX_PointF& point) {
@@ -329,7 +340,15 @@ class CFX_FloatRect {
void Scale(float fScale);
void ScaleFromCenterPoint(float fScale);
+ // GetInnerRect() and friends may be better at rounding than these methods.
+ // Unlike the methods above, these two blindly floor / round the LBRT values.
+ // Doing so may introduce rounding errors that are visible to users as
+ // off-by-one pixels/lines.
+ //
+ // Floors LBRT values.
FX_RECT ToFxRect() const;
+
+ // Rounds LBRT values.
FX_RECT ToRoundedFxRect() const;
float left;