Merge CPDF_FixedMatrix into CFX_BilinearMatrix subclass.
Since there now is (never was) a possibility of a bicubic matrix,
collapse the superclass into the subclass.
-- CFX_PointF is a better point that pair<float, float>.
Change-Id: I3413c3d021c075bb0cb0522e75cdd92578414fc2
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/75654
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fxge/dib/cfx_imagetransformer.cpp b/core/fxge/dib/cfx_imagetransformer.cpp
index a1bc817..d751ada 100644
--- a/core/fxge/dib/cfx_imagetransformer.cpp
+++ b/core/fxge/dib/cfx_imagetransformer.cpp
@@ -48,9 +48,9 @@
return (r_pos_0 * (255 - res_y) + r_pos_1 * res_y) >> 8;
}
-class CPDF_FixedMatrix {
+class CFX_BilinearMatrix {
public:
- explicit CPDF_FixedMatrix(const CFX_Matrix& src)
+ explicit CFX_BilinearMatrix(const CFX_Matrix& src)
: a(FXSYS_roundf(src.a * kBase)),
b(FXSYS_roundf(src.b * kBase)),
c(FXSYS_roundf(src.c * kBase)),
@@ -58,16 +58,22 @@
e(FXSYS_roundf(src.e * kBase)),
f(FXSYS_roundf(src.f * kBase)) {}
- void Transform(int x, int y, int* x1, int* y1) const {
- std::pair<float, float> val = TransformInternal(x, y);
- *x1 = pdfium::base::saturated_cast<int>(val.first / kBase);
- *y1 = pdfium::base::saturated_cast<int>(val.second / kBase);
+ void Transform(int x, int y, int* x1, int* y1, int* res_x, int* res_y) const {
+ CFX_PointF val = TransformInternal(CFX_PointF(x, y));
+ *x1 = pdfium::base::saturated_cast<int>(val.x / kBase);
+ *y1 = pdfium::base::saturated_cast<int>(val.y / kBase);
+ *res_x = static_cast<int>(val.x) % kBase;
+ *res_y = static_cast<int>(val.y) % kBase;
+ if (*res_x < 0 && *res_x > -kBase)
+ *res_x = kBase + *res_x;
+ if (*res_y < 0 && *res_y > -kBase)
+ *res_y = kBase + *res_y;
}
- protected:
- std::pair<float, float> TransformInternal(float x, float y) const {
- return std::make_pair(a * x + c * y + e + kBase / 2,
- b * x + d * y + f + kBase / 2);
+ private:
+ CFX_PointF TransformInternal(CFX_PointF pt) const {
+ return CFX_PointF(a * pt.x + c * pt.y + e + kBase / 2,
+ b * pt.x + d * pt.y + f + kBase / 2);
}
const int a;
@@ -78,24 +84,6 @@
const int f;
};
-class CFX_BilinearMatrix final : public CPDF_FixedMatrix {
- public:
- explicit CFX_BilinearMatrix(const CFX_Matrix& src) : CPDF_FixedMatrix(src) {}
-
- void Transform(int x, int y, int* x1, int* y1, int* res_x, int* res_y) const {
- std::pair<float, float> val = TransformInternal(x, y);
- *x1 = pdfium::base::saturated_cast<int>(val.first / kBase);
- *y1 = pdfium::base::saturated_cast<int>(val.second / kBase);
-
- *res_x = static_cast<int>(val.first) % kBase;
- *res_y = static_cast<int>(val.second) % kBase;
- if (*res_x < 0 && *res_x > -kBase)
- *res_x = kBase + *res_x;
- if (*res_y < 0 && *res_y > -kBase)
- *res_y = kBase + *res_y;
- }
-};
-
bool InStretchBounds(const FX_RECT& clip_rect, int col, int row) {
return col >= 0 && col <= clip_rect.Width() && row >= 0 &&
row <= clip_rect.Height();