Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
rect_conversions.h
Go to the documentation of this file.
1// Copyright (c) 2012 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef UI_GFX_GEOMETRY_RECT_CONVERSIONS_H_
6#define UI_GFX_GEOMETRY_RECT_CONVERSIONS_H_
7
8#include "rect.h"
9#include "rect_f.h"
10
11namespace gfx {
12
13// Returns the smallest Rect that encloses the given RectF.
14GFX_EXPORT Rect ToEnclosingRect(const RectF& rect);
15
16// Similar to ToEnclosingRect(), but for each edge, if the distance between the
17// edge and the nearest integer grid is smaller than |error|, the edge is
18// snapped to the integer grid. Unlike ToNearestRect() which only accepts
19// integer rect with or without floating point error, this function also accepts
20// non-integer rect.
21GFX_EXPORT Rect ToEnclosingRectIgnoringError(const RectF& rect, float error);
22
23// Returns the largest Rect that is enclosed by the given RectF.
24GFX_EXPORT Rect ToEnclosedRect(const RectF& rect);
25
26// Similar to ToEnclosedRect(), but for each edge, if the distance between the
27// edge and the nearest integer grid is smaller than |error|, the edge is
28// snapped to the integer grid. Unlike ToNearestRect() which only accepts
29// integer rect with or without floating point error, this function also accepts
30// non-integer rect.
31GFX_EXPORT Rect ToEnclosedRectIgnoringError(const RectF& rect, float error);
32
33// Returns the Rect after snapping the corners of the RectF to an integer grid.
34// This should only be used when the RectF you provide is expected to be an
35// integer rect with floating point error. If it is an arbitrary RectF, then
36// you should use a different method.
37GFX_EXPORT Rect ToNearestRect(const RectF& rect);
38
39// Returns true if the Rect produced after snapping the corners of the RectF
40// to an integer grid is within |distance|.
42 float distance);
43
44// Returns the Rect after rounding the corners of the RectF to an integer grid.
46
47// Returns a Rect obtained by flooring the values of the given RectF.
48// Please prefer the previous two functions in new code.
49GFX_EXPORT Rect ToFlooredRectDeprecated(const RectF& rect);
50
51} // namespace gfx
52
53#endif // UI_GFX_GEOMETRY_RECT_CONVERSIONS_H_
const uint8_t uint32_t uint32_t GError ** error
#define GFX_EXPORT
Definition gfx_export.h:26
Definition insets.cc:10
Rect ToEnclosingRectIgnoringError(const RectF &r, float error)
Rect ToEnclosingRect(const RectF &r)
gfx::Rect ToRoundedRect(const gfx::RectF &rect)
bool IsNearestRectWithinDistance(const gfx::RectF &rect, float distance)
Rect ToEnclosedRectIgnoringError(const RectF &r, float error)
Rect ToEnclosedRect(const RectF &rect)
Rect ToFlooredRectDeprecated(const RectF &rect)
Rect ToNearestRect(const RectF &rect)
TRect< Scalar > Rect
Definition rect.h:746