7#include "core/fxcrt/fx_coordinates.h"
16#include "build/build_config.h"
17#include "core/fxcrt/fx_extension.h"
18#include "core/fxcrt/fx_safe_types.h"
19#include "core/fxcrt/fx_system.h"
23void MatchFloatRange(
float f1,
float f2,
int* i1,
int* i2) {
24 float length = ceilf(f2 - f1);
25 float f1_floor = floorf(f1);
26 float f1_ceil = ceilf(f1);
27 float error1 = f1 - f1_floor + fabsf(f2 - f1_floor - length);
28 float error2 = f1_ceil - f1 + fabsf(f2 - f1_ceil - length);
29 float start = error1 > error2 ? f1_ceil : f1_floor;
32 if (safe1.IsValid() && safe2.IsValid()) {
33 *i1 = safe1.ValueOrDie();
34 *i2 = safe2.ValueOrDie();
42static_assert(
sizeof(FX_RECT) ==
sizeof(RECT),
"FX_RECT vs. RECT mismatch");
43static_assert(offsetof(FX_RECT, left) == offsetof(RECT, left),
44 "FX_RECT vs. RECT mismatch");
45static_assert(offsetof(FX_RECT, top) == offsetof(RECT, top),
46 "FX_RECT vs. RECT mismatch");
47static_assert(offsetof(FX_RECT, right) == offsetof(RECT, right),
48 "FX_RECT vs. RECT mismatch");
49static_assert(offsetof(FX_RECT, bottom) == offsetof(RECT, bottom),
50 "FX_RECT vs. RECT mismatch");
51static_assert(
sizeof(FX_RECT::left) ==
sizeof(RECT::left),
52 "FX_RECT vs. RECT mismatch");
53static_assert(
sizeof(FX_RECT::top) ==
sizeof(RECT::top),
54 "FX_RECT vs. RECT mismatch");
55static_assert(
sizeof(FX_RECT::right) ==
sizeof(RECT::right),
56 "FX_RECT vs. RECT mismatch");
57static_assert(
sizeof(FX_RECT::bottom) ==
sizeof(RECT::bottom),
58 "FX_RECT vs. RECT mismatch");
64float CFX_VTemplate<
float>::Length()
const {
69void CFX_VTemplate<
float>::Normalize() {
70 float fLen = Length();
83 return w.IsValid() && h.IsValid();
141 float min_x = pPoints.front().x;
142 float max_x = pPoints.front().x;
143 float min_y = pPoints.front().y;
144 float max_y = pPoints.front().y;
145 for (
const auto& point : pPoints.subspan(1)) {
146 min_x = std::min(min_x, point.x);
147 max_x = std::max(max_x, point.x);
148 min_y = std::min(min_y, point.y);
149 max_y = std::max(max_y, point.y);
214 float fHalfWidth = (fWidth > fHeight) ? fHeight / 2 : fWidth / 2;
219 fCenterX + fHalfWidth
, fCenterY + fHalfWidth
);
225 return point.x <= n1
.right && point.x >= n1
.left && point.y <= n1
.top &&
256 right += other_right;
272 Inflate(-other_left
, -other_bottom
, -other_right
, -other_top
);
304 float fHalfWidth = (
right -
left) / 2.0f;
305 float fHalfHeight = (
top -
bottom) / 2.0f;
310 left = center_x - fHalfWidth * fScale;
311 bottom = center_y - fHalfHeight * fScale;
312 right = center_x + fHalfWidth * fScale;
313 top = center_y + fHalfHeight * fScale;
367 static_cast<int32_t>(floor(
top))
,
368 static_cast<int32_t>(ceil(
right()))
,
374 float i =
a *
d -
b *
c;
383 inverse
.e = (
c *
f -
d *
e) / i;
384 inverse
.f = (
a *
f -
b *
e) / j;
389 return fabs(
a * 1000) < fabs(
b) && fabs(
d * 1000) < fabs(
c);
393 return fabs(
b * 1000) < fabs(
a) && fabs(
c * 1000) < fabs(
d);
416 float cosValue = cos(fRadian);
417 float sinValue = sin(fRadian);
424 a = fabs(fDiff) < 0.001f ? 1 : (dest
.left - dest
.right) / fDiff;
427 d = fabs(fDiff) < 0.001f ? 1 : (dest
.bottom - dest
.top) / fDiff;
436 return (
a > 0 ?
a : -
a);
438 return (
b > 0 ?
b : -
b);
444 return (
d > 0 ?
d : -
d);
446 return (
c > 0 ?
c : -
c);
457 return hypotf(fx, fy);
466 b * point.x +
d * point.y +
f);
477 {rect.left, rect.bottom},
478 {rect.right, rect.top},
479 {rect.right, rect.bottom}}};
480 for (CFX_PointF& point : points) {
481 point = Transform(point);
483 float new_right = points[0].x;
484 float new_left = points[0].x;
485 float new_top = points[0].y;
486 float new_bottom = points[0].y;
487 for (size_t i = 1; i < points.size(); i++) {
488 new_right =
std::max(new_right, points[i].x);
489 new_left =
std::min(new_left, points[i].x);
490 new_top =
std::max(new_top, points[i].y);
491 new_bottom =
std::min(new_bottom, points[i].y);
void Deflate(const CFX_FloatRect &rt)
void Deflate(float other_left, float other_bottom, float other_right, float other_top)
FX_RECT ToRoundedFxRect() const
bool Contains(const CFX_PointF &point) const
CFX_FloatRect(const CFX_FloatRect &that)=default
CFX_FloatRect GetCenterSquare() const
constexpr CFX_FloatRect(float l, float b, float r, float t)
constexpr CFX_FloatRect()=default
FX_RECT GetClosestRect() const
CFX_FloatRect(const FX_RECT &rect)
void UpdateRect(const CFX_PointF &point)
void Intersect(const CFX_FloatRect &other_rect)
void ScaleFromCenterPoint(float fScale)
void Inflate(float x, float y)
FX_RECT GetInnerRect() const
CFX_FloatRect & operator=(const CFX_FloatRect &that)=default
void Deflate(float x, float y)
bool Contains(const CFX_FloatRect &other_rect) const
FX_RECT GetOuterRect() const
void Inflate(const CFX_FloatRect &rt)
void Translate(float e, float f)
CFX_FloatRect GetDeflated(float x, float y) const
void Inflate(float other_left, float other_bottom, float other_right, float other_top)
void Union(const CFX_FloatRect &other_rect)
CFX_FloatRect(const CFX_PointF &point)
CFX_FloatRect TransformRect(const CFX_FloatRect &rect) const
float TransformDistance(float distance) const
CFX_RectF TransformRect(const CFX_RectF &rect) const
void MatchRect(const CFX_FloatRect &dest, const CFX_FloatRect &src)
CFX_PointF Transform(const CFX_PointF &point) const
CFX_FloatRect GetUnitRect() const
CFX_Matrix GetInverse() const
void TranslatePrepend(float x, float y)
void Rotate(float fRadian)
constexpr CFX_Matrix(float a1, float b1, float c1, float d1, float e1, float f1)
void Scale(float sx, float sy)
void Translate(float x, float y)
void Concat(const CFX_Matrix &right)
float TransformXDistance(float dx) const
CFX_FloatRect ToFloatRect() const
void Intersect(const CFX_RectF &rt)
FX_RECT GetOuterRect() const
void Union(float x, float y)
constexpr CFX_RectF(float dst_left, float dst_top, float dst_width, float dst_height)
void Union(const CFX_RectF &rt)
CFX_PTemplate< float > CFX_PointF
pdfium::CheckedNumeric< int32_t > FX_SAFE_INT32
int FXSYS_roundf(float f)
FX_RECT SwappedClipBox(int width, int height, bool bFlipX, bool bFlipY) const
void Intersect(const FX_RECT &src)
constexpr FX_RECT(int l, int t, int r, int b)