summaryrefslogtreecommitdiff
path: root/core/fxcrt
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-02-07 16:36:39 -0500
committerChromium commit bot <commit-bot@chromium.org>2017-02-08 01:36:02 +0000
commitbba2a7cf30da9e84bcc14ef32dbb0bb944229219 (patch)
tree94a74de8d07b3e395bf6e08a62811a3a0d652d19 /core/fxcrt
parent55e026b7b6eec17b012c819c4a7d39e63094b5c4 (diff)
downloadpdfium-bba2a7cf30da9e84bcc14ef32dbb0bb944229219.tar.xz
Update to use CFX_Rect{F} and CFX_Matrix constructors.
This Cl updates the code to use the constructors instead of creating an empty object and calling Set(). It also removes the various memsets of the CFX_Rect{F} classes. Change-Id: I6e20cec00866a38372858dcba5a30d31103172e4 Reviewed-on: https://pdfium-review.googlesource.com/2550 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fxcrt')
-rw-r--r--core/fxcrt/fx_basic_coords.cpp48
-rw-r--r--core/fxcrt/fx_coordinates.h95
2 files changed, 53 insertions, 90 deletions
diff --git a/core/fxcrt/fx_basic_coords.cpp b/core/fxcrt/fx_basic_coords.cpp
index d2bcc2b3ed..62cc4f5890 100644
--- a/core/fxcrt/fx_basic_coords.cpp
+++ b/core/fxcrt/fx_basic_coords.cpp
@@ -239,27 +239,7 @@ CFX_FloatRect CFX_FloatRect::GetBBox(const CFX_PointF* pPoints, int nPoints) {
}
return CFX_FloatRect(min_x, min_y, max_x, max_y);
}
-void CFX_Matrix::Set(FX_FLOAT other_a,
- FX_FLOAT other_b,
- FX_FLOAT other_c,
- FX_FLOAT other_d,
- FX_FLOAT other_e,
- FX_FLOAT other_f) {
- a = other_a;
- b = other_b;
- c = other_c;
- d = other_d;
- e = other_e;
- f = other_f;
-}
-void CFX_Matrix::Set(const FX_FLOAT n[6]) {
- a = n[0];
- b = n[1];
- c = n[2];
- d = n[3];
- e = n[4];
- f = n[5];
-}
+
void CFX_Matrix::SetReverse(const CFX_Matrix& m) {
FX_FLOAT i = m.a * m.d - m.b * m.c;
if (FXSYS_fabs(i) == 0) {
@@ -284,6 +264,7 @@ static void FXCRT_Matrix_Concat(CFX_Matrix& m,
FX_FLOAT ff = m1.e * m2.b + m1.f * m2.d + m2.f;
m.a = aa, m.b = bb, m.c = cc, m.d = dd, m.e = ee, m.f = ff;
}
+
void CFX_Matrix::Concat(FX_FLOAT a_in,
FX_FLOAT b_in,
FX_FLOAT c_in,
@@ -291,10 +272,9 @@ void CFX_Matrix::Concat(FX_FLOAT a_in,
FX_FLOAT e_in,
FX_FLOAT f_in,
bool bPrepended) {
- CFX_Matrix m;
- m.Set(a_in, b_in, c_in, d_in, e_in, f_in);
- Concat(m, bPrepended);
+ Concat(CFX_Matrix(a_in, b_in, c_in, d_in, e_in, f_in), bPrepended);
}
+
void CFX_Matrix::Concat(const CFX_Matrix& m, bool bPrepended) {
if (bPrepended) {
FXCRT_Matrix_Concat(*this, m, *this);
@@ -338,17 +318,17 @@ void CFX_Matrix::Scale(FX_FLOAT sx, FX_FLOAT sy, bool bPrepended) {
f *= sy;
}
}
+
void CFX_Matrix::Rotate(FX_FLOAT fRadian, bool bPrepended) {
FX_FLOAT cosValue = FXSYS_cos(fRadian);
FX_FLOAT sinValue = FXSYS_sin(fRadian);
- CFX_Matrix m;
- m.Set(cosValue, sinValue, -sinValue, cosValue, 0, 0);
- if (bPrepended) {
+ CFX_Matrix m(cosValue, sinValue, -sinValue, cosValue, 0, 0);
+ if (bPrepended)
FXCRT_Matrix_Concat(*this, m, *this);
- } else {
+ else
FXCRT_Matrix_Concat(*this, *this, m);
- }
}
+
void CFX_Matrix::RotateAt(FX_FLOAT fRadian,
FX_FLOAT dx,
FX_FLOAT dy,
@@ -357,17 +337,17 @@ void CFX_Matrix::RotateAt(FX_FLOAT fRadian,
Rotate(fRadian, bPrepended);
Translate(-dx, -dy, bPrepended);
}
+
void CFX_Matrix::Shear(FX_FLOAT fAlphaRadian,
FX_FLOAT fBetaRadian,
bool bPrepended) {
- CFX_Matrix m;
- m.Set(1, FXSYS_tan(fAlphaRadian), FXSYS_tan(fBetaRadian), 1, 0, 0);
- if (bPrepended) {
+ CFX_Matrix m(1, FXSYS_tan(fAlphaRadian), FXSYS_tan(fBetaRadian), 1, 0, 0);
+ if (bPrepended)
FXCRT_Matrix_Concat(*this, m, *this);
- } else {
+ else
FXCRT_Matrix_Concat(*this, *this, m);
- }
}
+
void CFX_Matrix::MatchRect(const CFX_FloatRect& dest,
const CFX_FloatRect& src) {
FX_FLOAT fDiff = src.left - src.right;
diff --git a/core/fxcrt/fx_coordinates.h b/core/fxcrt/fx_coordinates.h
index f00675842d..359bf46884 100644
--- a/core/fxcrt/fx_coordinates.h
+++ b/core/fxcrt/fx_coordinates.h
@@ -270,48 +270,22 @@ class CFX_RTemplate {
: left(p.x), top(p.y), width(dst_width), height(dst_height) {}
CFX_RTemplate(const PointType& p1, const SizeType& s2)
: left(p1.x), top(p1.y), width(s2.x), height(s2.y) {}
-
- void Set(BaseType dst_left,
- BaseType dst_top,
- BaseType dst_width,
- BaseType dst_height) {
- left = dst_left;
- top = dst_top;
- width = dst_width;
- height = dst_height;
- }
- void Set(BaseType dst_left, BaseType dst_top, const SizeType& dst_size) {
- left = dst_left;
- top = dst_top;
- width = dst_size.x;
- height = dst_size.y;
- }
- void Set(const PointType& p, BaseType dst_width, BaseType dst_height) {
- left = p.x;
- top = p.y;
- width = dst_width;
- height = dst_height;
- }
- void Set(const PointType& p, const SizeType& s) {
- left = p.x;
- top = p.y;
- width = s.x;
- height = s.y;
- }
- void Set(const PointType& p1, const PointType& p2) {
- left = p1.x;
- top = p1.y;
- width = p2.x - p1.x;
- height = p2.y - p1.y;
+ CFX_RTemplate(const PointType& p1, const PointType& p2)
+ : left(p1.x), top(p1.y), width(p2.x - p1.x), height(p2.y - p1.y) {
Normalize();
}
- void Set(const PointType& p, const VectorType& v) {
- left = p.x;
- top = p.y;
- width = v.x;
- height = v.y;
+ CFX_RTemplate(const PointType& p, const VectorType& v)
+ : left(p.x), top(p.y), width(v.x), height(v.y) {
Normalize();
}
+
+ // NOLINTNEXTLINE(runtime/explicit)
+ CFX_RTemplate(const RectType& other)
+ : left(other.left),
+ top(other.top),
+ width(other.width),
+ height(other.height) {}
+
void Reset() {
left = 0;
top = 0;
@@ -595,31 +569,40 @@ class CFX_Matrix {
public:
CFX_Matrix() { SetIdentity(); }
+ explicit CFX_Matrix(const FX_FLOAT n[6])
+ : a(n[0]), b(n[1]), c(n[2]), d(n[3]), e(n[4]), f(n[5]) {}
+
+ CFX_Matrix(const CFX_Matrix& other)
+ : a(other.a),
+ b(other.b),
+ c(other.c),
+ d(other.d),
+ e(other.e),
+ f(other.f) {}
CFX_Matrix(FX_FLOAT a1,
FX_FLOAT b1,
FX_FLOAT c1,
FX_FLOAT d1,
FX_FLOAT e1,
- FX_FLOAT f1) {
- a = a1;
- b = b1;
- c = c1;
- d = d1;
- e = e1;
- f = f1;
- }
-
- void Set(FX_FLOAT a,
- FX_FLOAT b,
- FX_FLOAT c,
- FX_FLOAT d,
- FX_FLOAT e,
- FX_FLOAT f);
- void Set(const FX_FLOAT n[6]);
+ FX_FLOAT f1)
+ : a(a1), b(b1), c(c1), d(d1), e(e1), f(f1) {}
+
+ void operator=(const CFX_Matrix& other) {
+ a = other.a;
+ b = other.b;
+ c = other.c;
+ d = other.d;
+ e = other.e;
+ f = other.f;
+ }
void SetIdentity() {
- a = d = 1;
- b = c = e = f = 0;
+ a = 1;
+ b = 0;
+ c = 0;
+ d = 1;
+ e = 0;
+ f = 0;
}
void SetReverse(const CFX_Matrix& m);