summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/fpdfapi/page/cpdf_textobject.cpp12
-rw-r--r--core/fpdfapi/parser/cpdf_object_unittest.cpp12
-rw-r--r--core/fpdfapi/render/cpdf_devicebuffer.cpp2
-rw-r--r--core/fpdfapi/render/cpdf_imagerenderer.cpp2
-rw-r--r--core/fpdfapi/render/cpdf_renderstatus.cpp8
-rw-r--r--core/fpdfapi/render/cpdf_scaledrenderbuffer.cpp2
-rw-r--r--core/fxcrt/fx_basic_coords.cpp244
-rw-r--r--core/fxcrt/fx_coordinates.h28
-rw-r--r--core/fxge/dib/fx_dib_transform.cpp2
-rw-r--r--core/fxge/ge/cfx_facecache.cpp8
-rw-r--r--core/fxge/ge/cfx_renderdevice.cpp2
-rw-r--r--core/fxge/win32/fx_win32_device.cpp7
-rw-r--r--core/fxge/win32/fx_win32_print.cpp12
13 files changed, 136 insertions, 205 deletions
diff --git a/core/fpdfapi/page/cpdf_textobject.cpp b/core/fpdfapi/page/cpdf_textobject.cpp
index 503ea78f9e..1534bc65d6 100644
--- a/core/fpdfapi/page/cpdf_textobject.cpp
+++ b/core/fpdfapi/page/cpdf_textobject.cpp
@@ -138,12 +138,12 @@ void CPDF_TextObject::Transform(const CFX_Matrix& matrix) {
text_matrix.Concat(matrix);
FX_FLOAT* pTextMatrix = m_TextState.GetMutableMatrix();
- pTextMatrix[0] = text_matrix.GetA();
- pTextMatrix[1] = text_matrix.GetC();
- pTextMatrix[2] = text_matrix.GetB();
- pTextMatrix[3] = text_matrix.GetD();
- m_PosX = text_matrix.GetE();
- m_PosY = text_matrix.GetF();
+ pTextMatrix[0] = text_matrix.a;
+ pTextMatrix[1] = text_matrix.c;
+ pTextMatrix[2] = text_matrix.b;
+ pTextMatrix[3] = text_matrix.d;
+ m_PosX = text_matrix.e;
+ m_PosY = text_matrix.f;
CalcPositionData(nullptr, nullptr, 0);
}
diff --git a/core/fpdfapi/parser/cpdf_object_unittest.cpp b/core/fpdfapi/parser/cpdf_object_unittest.cpp
index 4977c9931f..927b106474 100644
--- a/core/fpdfapi/parser/cpdf_object_unittest.cpp
+++ b/core/fpdfapi/parser/cpdf_object_unittest.cpp
@@ -397,12 +397,12 @@ TEST(PDFArrayTest, GetMatrix) {
for (size_t j = 0; j < 6; ++j)
arr->AddNew<CPDF_Number>(elems[i][j]);
CFX_Matrix arr_matrix = arr->GetMatrix();
- EXPECT_EQ(matrix.GetA(), arr_matrix.GetA());
- EXPECT_EQ(matrix.GetB(), arr_matrix.GetB());
- EXPECT_EQ(matrix.GetC(), arr_matrix.GetC());
- EXPECT_EQ(matrix.GetD(), arr_matrix.GetD());
- EXPECT_EQ(matrix.GetE(), arr_matrix.GetE());
- EXPECT_EQ(matrix.GetF(), arr_matrix.GetF());
+ EXPECT_EQ(matrix.a, arr_matrix.a);
+ EXPECT_EQ(matrix.b, arr_matrix.b);
+ EXPECT_EQ(matrix.c, arr_matrix.c);
+ EXPECT_EQ(matrix.d, arr_matrix.d);
+ EXPECT_EQ(matrix.e, arr_matrix.e);
+ EXPECT_EQ(matrix.f, arr_matrix.f);
}
}
diff --git a/core/fpdfapi/render/cpdf_devicebuffer.cpp b/core/fpdfapi/render/cpdf_devicebuffer.cpp
index a1ad5984b1..dec13433e4 100644
--- a/core/fpdfapi/render/cpdf_devicebuffer.cpp
+++ b/core/fpdfapi/render/cpdf_devicebuffer.cpp
@@ -28,7 +28,7 @@ bool CPDF_DeviceBuffer::Initialize(CPDF_RenderContext* pContext,
m_pContext = pContext;
m_Rect = *pRect;
m_pObject = pObj;
- m_Matrix.TranslateI(-pRect->left, -pRect->top);
+ m_Matrix.Translate(-pRect->left, -pRect->top);
#if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_
int horz_size = pDevice->GetDeviceCaps(FXDC_HORZ_SIZE);
int vert_size = pDevice->GetDeviceCaps(FXDC_VERT_SIZE);
diff --git a/core/fpdfapi/render/cpdf_imagerenderer.cpp b/core/fpdfapi/render/cpdf_imagerenderer.cpp
index ad713d0a5e..358d13edd0 100644
--- a/core/fpdfapi/render/cpdf_imagerenderer.cpp
+++ b/core/fpdfapi/render/cpdf_imagerenderer.cpp
@@ -239,7 +239,7 @@ FX_RECT CPDF_ImageRenderer::GetDrawRect() const {
CFX_Matrix CPDF_ImageRenderer::GetDrawMatrix(const FX_RECT& rect) const {
CFX_Matrix new_matrix = m_ImageMatrix;
- new_matrix.TranslateI(-rect.left, -rect.top);
+ new_matrix.Translate(-rect.left, -rect.top);
return new_matrix;
}
diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp
index 813ff3784c..b8fd7c743a 100644
--- a/core/fpdfapi/render/cpdf_renderstatus.cpp
+++ b/core/fpdfapi/render/cpdf_renderstatus.cpp
@@ -1531,7 +1531,7 @@ bool CPDF_RenderStatus::ProcessTransparency(CPDF_PageObject* pPageObj,
CFX_DIBitmap* bitmap = bitmap_device.GetBitmap();
bitmap->Clear(0);
CFX_Matrix new_matrix = *pObj2Device;
- new_matrix.TranslateI(-rect.left, -rect.top);
+ new_matrix.Translate(-rect.left, -rect.top);
new_matrix.Scale(scaleX, scaleY);
std::unique_ptr<CFX_DIBitmap> pTextMask;
if (bTextClip) {
@@ -1633,7 +1633,7 @@ std::unique_ptr<CFX_DIBitmap> CPDF_RenderStatus::GetBackdrop(
}
CFX_Matrix FinalMatrix = m_DeviceMatrix;
- FinalMatrix.TranslateI(-left, -top);
+ FinalMatrix.Translate(-left, -top);
FinalMatrix.Scale(scaleX, scaleY);
pBackdrop->Clear(pBackdrop->HasAlpha() ? 0 : 0xffffffff);
CFX_FxgeDevice device;
@@ -1877,7 +1877,7 @@ bool CPDF_RenderStatus::ProcessType3Text(CPDF_TextObject* textobj,
pFormResource, false, pType3Char, fill_argb);
status.m_Type3FontCache = m_Type3FontCache;
status.m_Type3FontCache.push_back(pType3Font);
- matrix.TranslateI(-rect.left, -rect.top);
+ matrix.Translate(-rect.left, -rect.top);
matrix.Scale(sa, sd);
status.RenderObjectList(pType3Char->m_pForm.get(), &matrix);
m_pDevice->SetDIBits(bitmap_device.GetBitmap(), rect.left, rect.top);
@@ -2524,7 +2524,7 @@ std::unique_ptr<CFX_DIBitmap> CPDF_RenderStatus::LoadSMask(
pFunc = CPDF_Function::Load(pFuncObj);
CFX_Matrix matrix = *pMatrix;
- matrix.TranslateI(-pClipRect->left, -pClipRect->top);
+ matrix.Translate(-pClipRect->left, -pClipRect->top);
CPDF_Form form(m_pContext->GetDocument(), m_pContext->GetPageResources(),
pGroup);
diff --git a/core/fpdfapi/render/cpdf_scaledrenderbuffer.cpp b/core/fpdfapi/render/cpdf_scaledrenderbuffer.cpp
index bcc03ba2dd..de60e732bb 100644
--- a/core/fpdfapi/render/cpdf_scaledrenderbuffer.cpp
+++ b/core/fpdfapi/render/cpdf_scaledrenderbuffer.cpp
@@ -31,7 +31,7 @@ bool CPDF_ScaledRenderBuffer::Initialize(CPDF_RenderContext* pContext,
m_pContext = pContext;
m_Rect = pRect;
m_pObject = pObj;
- m_Matrix.TranslateI(-pRect.left, -pRect.top);
+ m_Matrix.Translate(-pRect.left, -pRect.top);
int horz_size = pDevice->GetDeviceCaps(FXDC_HORZ_SIZE);
int vert_size = pDevice->GetDeviceCaps(FXDC_VERT_SIZE);
if (horz_size && vert_size && max_dpi) {
diff --git a/core/fxcrt/fx_basic_coords.cpp b/core/fxcrt/fx_basic_coords.cpp
index c76e6c9060..e8abace53d 100644
--- a/core/fxcrt/fx_basic_coords.cpp
+++ b/core/fxcrt/fx_basic_coords.cpp
@@ -11,6 +11,21 @@
#include "core/fxcrt/fx_coordinates.h"
#include "core/fxcrt/fx_ext.h"
+namespace {
+
+void MatchFloatRange(FX_FLOAT f1, FX_FLOAT f2, int* i1, int* i2) {
+ int length = static_cast<int>(FXSYS_ceil(f2 - f1));
+ int i1_1 = static_cast<int>(FXSYS_floor(f1));
+ int i1_2 = static_cast<int>(FXSYS_ceil(f1));
+ FX_FLOAT error1 = f1 - i1_1 + (FX_FLOAT)FXSYS_fabs(f2 - i1_1 - length);
+ FX_FLOAT error2 = i1_2 - f1 + (FX_FLOAT)FXSYS_fabs(f2 - i1_2 - length);
+
+ *i1 = (error1 > error2) ? i1_2 : i1_1;
+ *i2 = *i1 + length;
+}
+
+} // namespace
+
void FX_RECT::Normalize() {
if (left > right) {
int temp = left;
@@ -150,6 +165,7 @@ int CFX_FloatRect::Substract4(CFX_FloatRect& s, CFX_FloatRect* pRects) {
}
return nRects;
}
+
FX_RECT CFX_FloatRect::GetOuterRect() const {
CFX_FloatRect rect1 = *this;
FX_RECT rect;
@@ -160,6 +176,7 @@ FX_RECT CFX_FloatRect::GetOuterRect() const {
rect.Normalize();
return rect;
}
+
FX_RECT CFX_FloatRect::GetInnerRect() const {
CFX_FloatRect rect1 = *this;
FX_RECT rect;
@@ -170,20 +187,12 @@ FX_RECT CFX_FloatRect::GetInnerRect() const {
rect.Normalize();
return rect;
}
-static void _MatchFloatRange(FX_FLOAT f1, FX_FLOAT f2, int& i1, int& i2) {
- int length = (int)FXSYS_ceil(f2 - f1);
- int i1_1 = (int)FXSYS_floor(f1);
- int i1_2 = (int)FXSYS_ceil(f1);
- FX_FLOAT error1 = f1 - i1_1 + (FX_FLOAT)FXSYS_fabs(f2 - i1_1 - length);
- FX_FLOAT error2 = i1_2 - f1 + (FX_FLOAT)FXSYS_fabs(f2 - i1_2 - length);
- i1 = (error1 > error2) ? i1_2 : i1_1;
- i2 = i1 + length;
-}
+
FX_RECT CFX_FloatRect::GetClosestRect() const {
CFX_FloatRect rect1 = *this;
FX_RECT rect;
- _MatchFloatRange(rect1.left, rect1.right, rect.left, rect.right);
- _MatchFloatRange(rect1.bottom, rect1.top, rect.top, rect.bottom);
+ MatchFloatRange(rect1.left, rect1.right, &rect.left, &rect.right);
+ MatchFloatRange(rect1.bottom, rect1.top, &rect.top, &rect.bottom);
rect.Normalize();
return rect;
}
@@ -204,47 +213,34 @@ bool CFX_FloatRect::Contains(FX_FLOAT x, FX_FLOAT y) const {
}
void CFX_FloatRect::UpdateRect(FX_FLOAT x, FX_FLOAT y) {
- if (left > x) {
- left = x;
- }
- if (right < x) {
- right = x;
- }
- if (bottom > y) {
- bottom = y;
- }
- if (top < y) {
- top = y;
- }
+ left = std::min(left, x);
+ right = std::max(right, x);
+ bottom = std::min(bottom, y);
+ top = std::max(top, y);
}
+
CFX_FloatRect CFX_FloatRect::GetBBox(const CFX_PointF* pPoints, int nPoints) {
- if (nPoints == 0) {
+ if (nPoints == 0)
return CFX_FloatRect();
- }
- FX_FLOAT min_x = pPoints->x, max_x = pPoints->x, min_y = pPoints->y,
- max_y = pPoints->y;
+
+ FX_FLOAT min_x = pPoints->x;
+ FX_FLOAT max_x = pPoints->x;
+ FX_FLOAT min_y = pPoints->y;
+ FX_FLOAT max_y = pPoints->y;
for (int i = 1; i < nPoints; i++) {
- if (min_x > pPoints[i].x) {
- min_x = pPoints[i].x;
- }
- if (max_x < pPoints[i].x) {
- max_x = pPoints[i].x;
- }
- if (min_y > pPoints[i].y) {
- min_y = pPoints[i].y;
- }
- if (max_y < pPoints[i].y) {
- max_y = pPoints[i].y;
- }
+ min_x = std::min(min_x, pPoints[i].x);
+ max_x = std::max(max_x, pPoints[i].x);
+ min_y = std::min(min_y, pPoints[i].y);
+ max_y = std::max(max_y, pPoints[i].y);
}
return CFX_FloatRect(min_x, min_y, max_x, max_y);
}
void CFX_Matrix::SetReverse(const CFX_Matrix& m) {
FX_FLOAT i = m.a * m.d - m.b * m.c;
- if (FXSYS_fabs(i) == 0) {
+ if (FXSYS_fabs(i) == 0)
return;
- }
+
FX_FLOAT j = -i;
a = m.d / i;
b = m.b / j;
@@ -253,70 +249,57 @@ void CFX_Matrix::SetReverse(const CFX_Matrix& m) {
e = (m.c * m.f - m.d * m.e) / i;
f = (m.a * m.f - m.b * m.e) / j;
}
-static void FXCRT_Matrix_Concat(CFX_Matrix& m,
- const CFX_Matrix& m1,
- const CFX_Matrix& m2) {
- FX_FLOAT aa = m1.a * m2.a + m1.b * m2.c;
- FX_FLOAT bb = m1.a * m2.b + m1.b * m2.d;
- FX_FLOAT cc = m1.c * m2.a + m1.d * m2.c;
- FX_FLOAT dd = m1.c * m2.b + m1.d * m2.d;
- FX_FLOAT ee = m1.e * m2.a + m1.f * m2.c + m2.e;
- 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(const CFX_Matrix& m, bool bPrepended) {
- if (bPrepended) {
- FXCRT_Matrix_Concat(*this, m, *this);
- } else {
- FXCRT_Matrix_Concat(*this, *this, m);
- }
+ ConcatInternal(m, bPrepended);
}
+
void CFX_Matrix::ConcatInverse(const CFX_Matrix& src, bool bPrepended) {
CFX_Matrix m;
m.SetReverse(src);
Concat(m, bPrepended);
}
-bool CFX_Matrix::IsInvertible() const {
- return FXSYS_fabs(a * d - b * c) >= 0.0001f;
-}
+
bool CFX_Matrix::Is90Rotated() const {
return FXSYS_fabs(a * 1000) < FXSYS_fabs(b) &&
FXSYS_fabs(d * 1000) < FXSYS_fabs(c);
}
+
bool CFX_Matrix::IsScaled() const {
return FXSYS_fabs(b * 1000) < FXSYS_fabs(a) &&
FXSYS_fabs(c * 1000) < FXSYS_fabs(d);
}
+
void CFX_Matrix::Translate(FX_FLOAT x, FX_FLOAT y, bool bPrepended) {
if (bPrepended) {
e += x * a + y * c;
f += y * d + x * b;
- } else {
- e += x, f += y;
+ return;
}
+ e += x;
+ f += y;
}
+
void CFX_Matrix::Scale(FX_FLOAT sx, FX_FLOAT sy, bool bPrepended) {
- a *= sx, d *= sy;
+ a *= sx;
+ d *= sy;
if (bPrepended) {
b *= sx;
c *= sy;
- } else {
- b *= sy;
- c *= sx;
- e *= sx;
- f *= sy;
+ return;
}
+
+ b *= sy;
+ c *= sx;
+ e *= sx;
+ 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(cosValue, sinValue, -sinValue, cosValue, 0, 0);
- if (bPrepended)
- FXCRT_Matrix_Concat(*this, m, *this);
- else
- FXCRT_Matrix_Concat(*this, *this, m);
+ ConcatInternal(CFX_Matrix(cosValue, sinValue, -sinValue, cosValue, 0, 0),
+ bPrepended);
}
void CFX_Matrix::RotateAt(FX_FLOAT fRadian,
@@ -331,17 +314,16 @@ void CFX_Matrix::RotateAt(FX_FLOAT fRadian,
void CFX_Matrix::Shear(FX_FLOAT fAlphaRadian,
FX_FLOAT fBetaRadian,
bool bPrepended) {
- CFX_Matrix m(1, FXSYS_tan(fAlphaRadian), FXSYS_tan(fBetaRadian), 1, 0, 0);
- if (bPrepended)
- FXCRT_Matrix_Concat(*this, m, *this);
- else
- FXCRT_Matrix_Concat(*this, *this, m);
+ ConcatInternal(
+ CFX_Matrix(1, FXSYS_tan(fAlphaRadian), FXSYS_tan(fBetaRadian), 1, 0, 0),
+ bPrepended);
}
void CFX_Matrix::MatchRect(const CFX_FloatRect& dest,
const CFX_FloatRect& src) {
FX_FLOAT fDiff = src.left - src.right;
a = FXSYS_fabs(fDiff) < 0.001f ? 1 : (dest.left - dest.right) / fDiff;
+
fDiff = src.bottom - src.top;
d = FXSYS_fabs(fDiff) < 0.001f ? 1 : (dest.bottom - dest.top) / fDiff;
e = dest.left - src.left * a;
@@ -349,90 +331,50 @@ void CFX_Matrix::MatchRect(const CFX_FloatRect& dest,
b = 0;
c = 0;
}
+
FX_FLOAT CFX_Matrix::GetXUnit() const {
- if (b == 0) {
+ if (b == 0)
return (a > 0 ? a : -a);
- }
- if (a == 0) {
+ if (a == 0)
return (b > 0 ? b : -b);
- }
return FXSYS_sqrt(a * a + b * b);
}
+
FX_FLOAT CFX_Matrix::GetYUnit() const {
- if (c == 0) {
+ if (c == 0)
return (d > 0 ? d : -d);
- }
- if (d == 0) {
+ if (d == 0)
return (c > 0 ? c : -c);
- }
return FXSYS_sqrt(c * c + d * d);
}
-void CFX_Matrix::GetUnitRect(CFX_RectF& rect) const {
- rect.left = rect.top = 0;
- rect.width = rect.height = 1;
- TransformRect(rect);
-}
+
CFX_FloatRect CFX_Matrix::GetUnitRect() const {
CFX_FloatRect rect(0, 0, 1, 1);
TransformRect(rect);
return rect;
}
-FX_FLOAT CFX_Matrix::GetUnitArea() const {
- FX_FLOAT A = FXSYS_sqrt(a * a + b * b);
- FX_FLOAT B = FXSYS_sqrt(c * c + d * d);
- FX_FLOAT ac = a + c, bd = b + d;
- FX_FLOAT C = FXSYS_sqrt(ac * ac + bd * bd);
- FX_FLOAT P = (A + B + C) / 2;
- return FXSYS_sqrt(P * (P - A) * (P - B) * (P - C)) * 2;
-}
+
FX_FLOAT CFX_Matrix::TransformXDistance(FX_FLOAT dx) const {
- FX_FLOAT fx = a * dx, fy = b * dx;
+ FX_FLOAT fx = a * dx;
+ FX_FLOAT fy = b * dx;
return FXSYS_sqrt(fx * fx + fy * fy);
}
-int32_t CFX_Matrix::TransformXDistance(int32_t dx) const {
- FX_FLOAT fx = a * dx, fy = b * dx;
- return FXSYS_round(FXSYS_sqrt(fx * fx + fy * fy));
-}
-FX_FLOAT CFX_Matrix::TransformYDistance(FX_FLOAT dy) const {
- FX_FLOAT fx = c * dy, fy = d * dy;
- return FXSYS_sqrt(fx * fx + fy * fy);
-}
-int32_t CFX_Matrix::TransformYDistance(int32_t dy) const {
- FX_FLOAT fx = c * dy, fy = d * dy;
- return FXSYS_round(FXSYS_sqrt(fx * fx + fy * fy));
-}
+
FX_FLOAT CFX_Matrix::TransformDistance(FX_FLOAT dx, FX_FLOAT dy) const {
- FX_FLOAT fx = a * dx + c * dy, fy = b * dx + d * dy;
+ FX_FLOAT fx = a * dx + c * dy;
+ FX_FLOAT fy = b * dx + d * dy;
return FXSYS_sqrt(fx * fx + fy * fy);
}
-int32_t CFX_Matrix::TransformDistance(int32_t dx, int32_t dy) const {
- FX_FLOAT fx = a * dx + c * dy, fy = b * dx + d * dy;
- return FXSYS_round(FXSYS_sqrt(fx * fx + fy * fy));
-}
+
FX_FLOAT CFX_Matrix::TransformDistance(FX_FLOAT distance) const {
return distance * (GetXUnit() + GetYUnit()) / 2;
}
-void CFX_Matrix::TransformVector(CFX_VectorF& v) const {
- FX_FLOAT fx = a * v.x + c * v.y;
- FX_FLOAT fy = b * v.x + d * v.y;
- v.x = fx, v.y = fy;
-}
-void CFX_Matrix::TransformVector(CFX_Vector& v) const {
- FX_FLOAT fx = a * v.x + c * v.y;
- FX_FLOAT fy = b * v.x + d * v.y;
- v.x = FXSYS_round(fx);
- v.y = FXSYS_round(fy);
-}
+
void CFX_Matrix::TransformPoint(FX_FLOAT& x, FX_FLOAT& y) const {
FX_FLOAT fx = a * x + c * y + e;
FX_FLOAT fy = b * x + d * y + f;
- x = fx, y = fy;
-}
-void CFX_Matrix::TransformPoint(int32_t& x, int32_t& y) const {
- FX_FLOAT fx = a * x + c * y + e;
- FX_FLOAT fy = b * x + d * y + f;
- x = FXSYS_round(fx);
- y = FXSYS_round(fy);
+ x = fx;
+ y = fy;
}
void CFX_Matrix::TransformRect(CFX_RectF& rect) const {
@@ -442,19 +384,6 @@ void CFX_Matrix::TransformRect(CFX_RectF& rect) const {
rect.height = bottom - rect.top;
}
-void CFX_Matrix::TransformRect(CFX_Rect& rect) const {
- FX_FLOAT left = (FX_FLOAT)rect.left;
- FX_FLOAT top = (FX_FLOAT)rect.bottom();
- FX_FLOAT right = (FX_FLOAT)rect.right();
- FX_FLOAT bottom = (FX_FLOAT)rect.top;
-
- TransformRect(left, right, top, bottom);
- rect.left = FXSYS_round(left);
- rect.top = FXSYS_round(bottom);
- rect.width = FXSYS_round(right - left);
- rect.height = FXSYS_round(top - bottom);
-}
-
void CFX_Matrix::TransformRect(FX_FLOAT& left,
FX_FLOAT& right,
FX_FLOAT& top,
@@ -475,3 +404,22 @@ void CFX_Matrix::TransformRect(FX_FLOAT& left,
bottom = std::min(bottom, y[i]);
}
}
+
+void CFX_Matrix::ConcatInternal(const CFX_Matrix& other, bool prepend) {
+ CFX_Matrix left;
+ CFX_Matrix right;
+ if (prepend) {
+ left = other;
+ right = *this;
+ } else {
+ left = *this;
+ right = other;
+ }
+
+ a = left.a * right.a + left.b * right.c;
+ b = left.a * right.b + left.b * right.d;
+ c = left.c * right.a + left.d * right.c;
+ d = left.c * right.b + left.d * right.d;
+ e = left.e * right.a + left.f * right.c + right.e;
+ f = left.e * right.b + left.f * right.d + right.f;
+}
diff --git a/core/fxcrt/fx_coordinates.h b/core/fxcrt/fx_coordinates.h
index a1638fdbb5..c9e5433226 100644
--- a/core/fxcrt/fx_coordinates.h
+++ b/core/fxcrt/fx_coordinates.h
@@ -602,6 +602,7 @@ class CFX_Matrix {
d(other.d),
e(other.e),
f(other.f) {}
+
CFX_Matrix(FX_FLOAT a1,
FX_FLOAT b1,
FX_FLOAT c1,
@@ -637,13 +638,13 @@ class CFX_Matrix {
return a == 1 && b == 0 && c == 0 && d == 1 && e == 0 && f == 0;
}
- bool IsInvertible() const;
bool Is90Rotated() const;
bool IsScaled() const;
+ bool WillScale() const { return a != 1.0f || b != 0 || c != 0 || d != 1.0f; }
void Translate(FX_FLOAT x, FX_FLOAT y, bool bPrepended = false);
- void TranslateI(int32_t x, int32_t y, bool bPrepended = false) {
- Translate((FX_FLOAT)x, (FX_FLOAT)y, bPrepended);
+ void Translate(int32_t x, int32_t y, bool bPrepended = false) {
+ Translate(static_cast<FX_FLOAT>(x), static_cast<FX_FLOAT>(y), bPrepended);
}
void Scale(FX_FLOAT sx, FX_FLOAT sy, bool bPrepended = false);
@@ -658,27 +659,18 @@ class CFX_Matrix {
bool bPrepended = false);
void MatchRect(const CFX_FloatRect& dest, const CFX_FloatRect& src);
+
FX_FLOAT GetXUnit() const;
FX_FLOAT GetYUnit() const;
- void GetUnitRect(CFX_RectF& rect) const;
CFX_FloatRect GetUnitRect() const;
- FX_FLOAT GetUnitArea() const;
FX_FLOAT TransformXDistance(FX_FLOAT dx) const;
- int32_t TransformXDistance(int32_t dx) const;
- FX_FLOAT TransformYDistance(FX_FLOAT dy) const;
- int32_t TransformYDistance(int32_t dy) const;
FX_FLOAT TransformDistance(FX_FLOAT dx, FX_FLOAT dy) const;
- int32_t TransformDistance(int32_t dx, int32_t dy) const;
FX_FLOAT TransformDistance(FX_FLOAT distance) const;
void TransformPoint(FX_FLOAT& x, FX_FLOAT& y) const;
- void TransformPoint(int32_t& x, int32_t& y) const;
- void TransformVector(CFX_VectorF& v) const;
- void TransformVector(CFX_Vector& v) const;
void TransformRect(CFX_RectF& rect) const;
- void TransformRect(CFX_Rect& rect) const;
void TransformRect(FX_FLOAT& left,
FX_FLOAT& right,
FX_FLOAT& top,
@@ -687,19 +679,15 @@ class CFX_Matrix {
TransformRect(rect.left, rect.right, rect.top, rect.bottom);
}
- FX_FLOAT GetA() const { return a; }
- FX_FLOAT GetB() const { return b; }
- FX_FLOAT GetC() const { return c; }
- FX_FLOAT GetD() const { return d; }
- FX_FLOAT GetE() const { return e; }
- FX_FLOAT GetF() const { return f; }
-
FX_FLOAT a;
FX_FLOAT b;
FX_FLOAT c;
FX_FLOAT d;
FX_FLOAT e;
FX_FLOAT f;
+
+ private:
+ void ConcatInternal(const CFX_Matrix& other, bool prepend);
};
#endif // CORE_FXCRT_FX_COORDINATES_H_
diff --git a/core/fxge/dib/fx_dib_transform.cpp b/core/fxge/dib/fx_dib_transform.cpp
index 55e8b8fa20..bd88272941 100644
--- a/core/fxge/dib/fx_dib_transform.cpp
+++ b/core/fxge/dib/fx_dib_transform.cpp
@@ -456,7 +456,7 @@ bool CFX_ImageTransformer::Continue(IFX_Pause* pPause) {
CFX_Matrix result2stretch(1.0f, 0.0f, 0.0f, 1.0f, (FX_FLOAT)(m_result.left),
(FX_FLOAT)(m_result.top));
result2stretch.Concat(m_dest2stretch);
- result2stretch.TranslateI(-m_StretchClip.left, -m_StretchClip.top);
+ result2stretch.Translate(-m_StretchClip.left, -m_StretchClip.top);
if (!stretch_buf_mask && pTransformed->m_pAlphaMask) {
pTransformed->m_pAlphaMask->Clear(0xff000000);
} else if (pTransformed->m_pAlphaMask) {
diff --git a/core/fxge/ge/cfx_facecache.cpp b/core/fxge/ge/cfx_facecache.cpp
index cbaa07e449..314c95b8b2 100644
--- a/core/fxge/ge/cfx_facecache.cpp
+++ b/core/fxge/ge/cfx_facecache.cpp
@@ -101,10 +101,10 @@ CFX_GlyphBitmap* CFX_FaceCache::RenderGlyph(const CFX_Font* pFont,
return nullptr;
FXFT_Matrix ft_matrix;
- ft_matrix.xx = (signed long)(pMatrix->GetA() / 64 * 65536);
- ft_matrix.xy = (signed long)(pMatrix->GetC() / 64 * 65536);
- ft_matrix.yx = (signed long)(pMatrix->GetB() / 64 * 65536);
- ft_matrix.yy = (signed long)(pMatrix->GetD() / 64 * 65536);
+ ft_matrix.xx = (signed long)(pMatrix->a / 64 * 65536);
+ ft_matrix.xy = (signed long)(pMatrix->c / 64 * 65536);
+ ft_matrix.yx = (signed long)(pMatrix->b / 64 * 65536);
+ ft_matrix.yy = (signed long)(pMatrix->d / 64 * 65536);
bool bUseCJKSubFont = false;
const CFX_SubstFont* pSubstFont = pFont->GetSubstFont();
if (pSubstFont) {
diff --git a/core/fxge/ge/cfx_renderdevice.cpp b/core/fxge/ge/cfx_renderdevice.cpp
index 0c73c7a66a..12a3dd480d 100644
--- a/core/fxge/ge/cfx_renderdevice.cpp
+++ b/core/fxge/ge/cfx_renderdevice.cpp
@@ -610,7 +610,7 @@ bool CFX_RenderDevice::DrawFillStrokePath(const CFX_PathData* pPathData,
CFX_Matrix matrix;
if (pObject2Device)
matrix = *pObject2Device;
- matrix.TranslateI(-rect.left, -rect.top);
+ matrix.Translate(-rect.left, -rect.top);
matrix.Concat(CFX_Matrix(fScaleX, 0, 0, fScaleY, 0, 0));
if (!bitmap_device.GetDeviceDriver()->DrawPath(
pPathData, &matrix, pGraphState, fill_color, stroke_color, fill_mode,
diff --git a/core/fxge/win32/fx_win32_device.cpp b/core/fxge/win32/fx_win32_device.cpp
index 3df38f1965..add0f0e3d3 100644
--- a/core/fxge/win32/fx_win32_device.cpp
+++ b/core/fxge/win32/fx_win32_device.cpp
@@ -316,11 +316,6 @@ unsigned clip_liang_barsky(FX_FLOAT x1,
}
#endif // _SKIA_SUPPORT_
-bool MatrixNoScaled(const CFX_Matrix* pMatrix) {
- return pMatrix->GetA() == 1.0f && pMatrix->GetB() == 0 &&
- pMatrix->GetC() == 0 && pMatrix->GetD() == 1.0f;
-}
-
class CFX_Win32FallbackFontInfo final : public CFX_FolderFontInfo {
public:
CFX_Win32FallbackFontInfo() {}
@@ -1022,7 +1017,7 @@ bool CGdiDeviceDriver::DrawPath(const CFX_PathData* pPathData,
if (bDrawAlpha ||
((m_DeviceClass != FXDC_PRINTER && !(fill_mode & FXFILL_FULLCOVER)) ||
(pGraphState && pGraphState->m_DashCount))) {
- if (!((!pMatrix || MatrixNoScaled(pMatrix)) && pGraphState &&
+ if (!((!pMatrix || !pMatrix->WillScale()) && pGraphState &&
pGraphState->m_LineWidth == 1.f &&
(pPathData->GetPointCount() == 5 ||
pPathData->GetPointCount() == 4) &&
diff --git a/core/fxge/win32/fx_win32_print.cpp b/core/fxge/win32/fx_win32_print.cpp
index 94c415b721..a2ea82a94e 100644
--- a/core/fxge/win32/fx_win32_print.cpp
+++ b/core/fxge/win32/fx_win32_print.cpp
@@ -269,12 +269,12 @@ bool CGdiPrinterDriver::DrawDeviceText(int nChars,
// Transforms
SetGraphicsMode(m_hDC, GM_ADVANCED);
XFORM xform;
- xform.eM11 = pObject2Device->GetA() / kScaleFactor;
- xform.eM12 = pObject2Device->GetB() / kScaleFactor;
- xform.eM21 = -pObject2Device->GetC() / kScaleFactor;
- xform.eM22 = -pObject2Device->GetD() / kScaleFactor;
- xform.eDx = pObject2Device->GetE();
- xform.eDy = pObject2Device->GetF();
+ xform.eM11 = pObject2Device->a / kScaleFactor;
+ xform.eM12 = pObject2Device->b / kScaleFactor;
+ xform.eM21 = -pObject2Device->c / kScaleFactor;
+ xform.eM22 = -pObject2Device->d / kScaleFactor;
+ xform.eDx = pObject2Device->e;
+ xform.eDy = pObject2Device->f;
ModifyWorldTransform(m_hDC, &xform, MWT_LEFTMULTIPLY);
// Color