diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/fpdfapi/render/cpdf_devicebuffer.cpp | 6 | ||||
-rw-r--r-- | core/fpdfapi/render/cpdf_renderstatus.cpp | 4 | ||||
-rw-r--r-- | core/fpdfdoc/cpdf_variabletext.cpp | 8 | ||||
-rw-r--r-- | core/fxcrt/fx_basic_coords.cpp | 10 | ||||
-rw-r--r-- | core/fxcrt/fx_coordinates.h | 81 | ||||
-rw-r--r-- | core/fxge/dib/fx_dib_transform.cpp | 7 | ||||
-rw-r--r-- | core/fxge/ge/cfx_renderdevice.cpp | 12 | ||||
-rw-r--r-- | core/fxge/win32/cfx_psrenderer.cpp | 2 |
8 files changed, 70 insertions, 60 deletions
diff --git a/core/fpdfapi/render/cpdf_devicebuffer.cpp b/core/fpdfapi/render/cpdf_devicebuffer.cpp index edc91802fb..a1ad5984b1 100644 --- a/core/fpdfapi/render/cpdf_devicebuffer.cpp +++ b/core/fpdfapi/render/cpdf_devicebuffer.cpp @@ -44,11 +44,11 @@ bool CPDF_DeviceBuffer::Initialize(CPDF_RenderContext* pContext, } #endif CFX_Matrix ctm = m_pDevice->GetCTM(); - FX_FLOAT fScaleX = FXSYS_fabs(ctm.a); - FX_FLOAT fScaleY = FXSYS_fabs(ctm.d); - m_Matrix.Concat(fScaleX, 0, 0, fScaleY, 0, 0); + m_Matrix.Concat(CFX_Matrix(FXSYS_fabs(ctm.a), 0, 0, FXSYS_fabs(ctm.d), 0, 0)); + CFX_FloatRect rect(*pRect); m_Matrix.TransformRect(rect); + FX_RECT bitmap_rect = rect.GetOuterRect(); m_pBitmap = pdfium::MakeUnique<CFX_DIBitmap>(); m_pBitmap->Create(bitmap_rect.Width(), bitmap_rect.Height(), FXDIB_Argb); diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp index 861aec4eea..86b9670cd1 100644 --- a/core/fpdfapi/render/cpdf_renderstatus.cpp +++ b/core/fpdfapi/render/cpdf_renderstatus.cpp @@ -2003,8 +2003,8 @@ void CPDF_RenderStatus::DrawTextPathWithPattern(const CPDF_TextObject* textobj, charpos.m_AdjustMatrix[2], charpos.m_AdjustMatrix[3], 0, 0); } - matrix.Concat(font_size, 0, 0, font_size, charpos.m_OriginX, - charpos.m_OriginY); + matrix.Concat(CFX_Matrix(font_size, 0, 0, font_size, charpos.m_OriginX, + charpos.m_OriginY)); path.m_Path.Append(pPath, &matrix); path.m_Matrix = *pTextMatrix; path.m_bStroke = bStroke; diff --git a/core/fpdfdoc/cpdf_variabletext.cpp b/core/fpdfdoc/cpdf_variabletext.cpp index 1313516f22..546bd9f740 100644 --- a/core/fpdfdoc/cpdf_variabletext.cpp +++ b/core/fpdfdoc/cpdf_variabletext.cpp @@ -1010,10 +1010,10 @@ bool CPDF_VariableText::IsBigger(FX_FLOAT fFontSize) const { for (int32_t s = 0, sz = m_SectionArray.GetSize(); s < sz; s++) { if (CSection* pSection = m_SectionArray.GetAt(s)) { CFX_SizeF size = pSection->GetSectionSize(fFontSize); - szTotal.x = std::max(size.x, szTotal.x); - szTotal.y += size.y; - if (IsFloatBigger(szTotal.x, GetPlateWidth()) || - IsFloatBigger(szTotal.y, GetPlateHeight())) { + szTotal.width = std::max(size.width, szTotal.width); + szTotal.height += size.height; + if (IsFloatBigger(szTotal.width, GetPlateWidth()) || + IsFloatBigger(szTotal.height, GetPlateHeight())) { return true; } } diff --git a/core/fxcrt/fx_basic_coords.cpp b/core/fxcrt/fx_basic_coords.cpp index 62cc4f5890..dc207901f6 100644 --- a/core/fxcrt/fx_basic_coords.cpp +++ b/core/fxcrt/fx_basic_coords.cpp @@ -265,16 +265,6 @@ static void FXCRT_Matrix_Concat(CFX_Matrix& m, 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, - FX_FLOAT d_in, - FX_FLOAT e_in, - FX_FLOAT f_in, - bool 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); diff --git a/core/fxcrt/fx_coordinates.h b/core/fxcrt/fx_coordinates.h index 359bf46884..01436c7250 100644 --- a/core/fxcrt/fx_coordinates.h +++ b/core/fxcrt/fx_coordinates.h @@ -76,61 +76,72 @@ using CFX_PointF = CFX_PTemplate<FX_FLOAT>; template <class BaseType> class CFX_STemplate { public: - CFX_STemplate() : x(0), y(0) {} - CFX_STemplate(BaseType new_x, BaseType new_y) : x(new_x), y(new_y) {} - CFX_STemplate(const CFX_STemplate& other) : x(other.x), y(other.y) {} + CFX_STemplate() : width(0), height(0) {} + + CFX_STemplate(BaseType new_width, BaseType new_height) + : width(new_width), height(new_height) {} + + CFX_STemplate(const CFX_STemplate& other) + : width(other.width), height(other.height) {} + + template <typename OtherType> + CFX_STemplate<OtherType> As() const { + return CFX_STemplate<OtherType>(static_cast<OtherType>(width), + static_cast<OtherType>(height)); + } + void clear() { - x = 0; - y = 0; + width = 0; + height = 0; } CFX_STemplate operator=(const CFX_STemplate& other) { if (this != &other) { - x = other.x; - y = other.y; + width = other.width; + height = other.height; } return *this; } bool operator==(const CFX_STemplate& other) const { - return x == other.x && y == other.y; + return width == other.width && height == other.height; } bool operator!=(const CFX_STemplate& other) const { return !(*this == other); } CFX_STemplate& operator+=(const CFX_STemplate<BaseType>& obj) { - x += obj.x; - y += obj.y; + width += obj.width; + height += obj.height; return *this; } CFX_STemplate& operator-=(const CFX_STemplate<BaseType>& obj) { - x -= obj.x; - y -= obj.y; + width -= obj.width; + height -= obj.height; return *this; } CFX_STemplate& operator*=(BaseType factor) { - x *= factor; - y *= factor; + width *= factor; + height *= factor; return *this; } CFX_STemplate& operator/=(BaseType divisor) { - x /= divisor; - y /= divisor; + width /= divisor; + height /= divisor; return *this; } CFX_STemplate operator+(const CFX_STemplate& other) { - return CFX_STemplate(x + other.x, y + other.y); + return CFX_STemplate(width + other.width, height + other.height); } CFX_STemplate operator-(const CFX_STemplate& other) { - return CFX_STemplate(x - other.x, y - other.y); + return CFX_STemplate(width - other.width, height - other.height); } CFX_STemplate operator*(BaseType factor) { - return CFX_STemplate(x * factor, y * factor); + return CFX_STemplate(width * factor, height * factor); } CFX_STemplate operator/(BaseType divisor) { - return CFX_STemplate(x / divisor, y / divisor); + return CFX_STemplate(width / divisor, height / divisor); } - BaseType x; - BaseType y; + BaseType width; + BaseType height; }; using CFX_Size = CFX_STemplate<int32_t>; using CFX_SizeF = CFX_STemplate<FX_FLOAT>; @@ -265,13 +276,19 @@ class CFX_RTemplate { BaseType dst_height) : left(dst_left), top(dst_top), width(dst_width), height(dst_height) {} CFX_RTemplate(BaseType dst_left, BaseType dst_top, const SizeType& dst_size) - : left(dst_left), top(dst_top), width(dst_size.x), height(dst_size.y) {} + : left(dst_left), + top(dst_top), + width(dst_size.width), + height(dst_size.height) {} CFX_RTemplate(const PointType& p, BaseType dst_width, BaseType dst_height) : 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) {} + : left(p1.x), top(p1.y), width(s2.width), height(s2.height) {} CFX_RTemplate(const PointType& p1, const PointType& p2) - : left(p1.x), top(p1.y), width(p2.x - p1.x), height(p2.y - p1.y) { + : left(p1.x), + top(p1.y), + width(p2.width - p1.width), + height(p2.height - p1.height) { Normalize(); } CFX_RTemplate(const PointType& p, const VectorType& v) @@ -286,6 +303,13 @@ class CFX_RTemplate { width(other.width), height(other.height) {} + template <typename OtherType> + CFX_RTemplate<OtherType> As() const { + return CFX_RTemplate<OtherType>( + static_cast<OtherType>(left), static_cast<OtherType>(top), + static_cast<OtherType>(width), static_cast<OtherType>(height)); + } + void Reset() { left = 0; top = 0; @@ -607,13 +631,6 @@ class CFX_Matrix { void SetReverse(const CFX_Matrix& m); - void Concat(FX_FLOAT a, - FX_FLOAT b, - FX_FLOAT c, - FX_FLOAT d, - FX_FLOAT e, - FX_FLOAT f, - bool bPrepended = false); void Concat(const CFX_Matrix& m, bool bPrepended = false); void ConcatInverse(const CFX_Matrix& m, bool bPrepended = false); diff --git a/core/fxge/dib/fx_dib_transform.cpp b/core/fxge/dib/fx_dib_transform.cpp index 1c29ada68f..8932a633fa 100644 --- a/core/fxge/dib/fx_dib_transform.cpp +++ b/core/fxge/dib/fx_dib_transform.cpp @@ -396,10 +396,11 @@ bool CFX_ImageTransformer::Start() { CFX_Matrix stretch2dest(1.0f, 0.0f, 0.0f, -1.0f, 0.0f, (FX_FLOAT)(stretch_height)); stretch2dest.Concat( - m_pMatrix->a / stretch_width, m_pMatrix->b / stretch_width, - m_pMatrix->c / stretch_height, m_pMatrix->d / stretch_height, - m_pMatrix->e, m_pMatrix->f); + CFX_Matrix(m_pMatrix->a / stretch_width, m_pMatrix->b / stretch_width, + m_pMatrix->c / stretch_height, m_pMatrix->d / stretch_height, + m_pMatrix->e, m_pMatrix->f)); m_dest2stretch.SetReverse(stretch2dest); + CFX_FloatRect clip_rect_f(result_clip); clip_rect_f.Transform(&m_dest2stretch); m_StretchClip = clip_rect_f.GetOuterRect(); diff --git a/core/fxge/ge/cfx_renderdevice.cpp b/core/fxge/ge/cfx_renderdevice.cpp index 2f3d1bb60e..ba99c87469 100644 --- a/core/fxge/ge/cfx_renderdevice.cpp +++ b/core/fxge/ge/cfx_renderdevice.cpp @@ -613,7 +613,7 @@ bool CFX_RenderDevice::DrawFillStrokePath(const CFX_PathData* pPathData, if (pObject2Device) matrix = *pObject2Device; matrix.TranslateI(-rect.left, -rect.top); - matrix.Concat(fScaleX, 0, 0, fScaleY, 0, 0); + matrix.Concat(CFX_Matrix(fScaleX, 0, 0, fScaleY, 0, 0)); if (!bitmap_device.GetDeviceDriver()->DrawPath( pPathData, &matrix, pGraphState, fill_color, stroke_color, fill_mode, blend_type)) { @@ -902,8 +902,10 @@ bool CFX_RenderDevice::DrawNormalText(int nChars, FX_FLOAT scale_x = FXSYS_fabs(matrixCTM.a); FX_FLOAT scale_y = FXSYS_fabs(matrixCTM.d); CFX_Matrix deviceCtm = char2device; - deviceCtm.Concat(scale_x, 0, 0, scale_y, 0, 0); - text2Device.Concat(scale_x, 0, 0, scale_y, 0, 0); + CFX_Matrix m(scale_x, 0, 0, scale_y, 0, 0); + deviceCtm.Concat(m); + text2Device.Concat(m); + for (size_t i = 0; i < glyphs.size(); ++i) { FXTEXT_GLYPHPOS& glyph = glyphs[i]; const FXTEXT_CHARPOS& charpos = pCharPos[i]; @@ -1064,8 +1066,8 @@ bool CFX_RenderDevice::DrawTextPath(int nChars, charpos.m_AdjustMatrix[2], charpos.m_AdjustMatrix[3], 0, 0); } - matrix.Concat(font_size, 0, 0, font_size, charpos.m_OriginX, - charpos.m_OriginY); + matrix.Concat(CFX_Matrix(font_size, 0, 0, font_size, charpos.m_OriginX, + charpos.m_OriginY)); const CFX_PathData* pPath = pFont->LoadGlyphPath(charpos.m_GlyphIndex, charpos.m_FontCharWidth); if (!pPath) diff --git a/core/fxge/win32/cfx_psrenderer.cpp b/core/fxge/win32/cfx_psrenderer.cpp index 9970e21254..71e62a75f2 100644 --- a/core/fxge/win32/cfx_psrenderer.cpp +++ b/core/fxge/win32/cfx_psrenderer.cpp @@ -588,7 +588,7 @@ void CFX_PSRenderer::FindPSFontGlyph(CFX_FaceCache* pFaceCache, CFX_Matrix(charpos.m_AdjustMatrix[0], charpos.m_AdjustMatrix[1], charpos.m_AdjustMatrix[2], charpos.m_AdjustMatrix[3], 0, 0); } - matrix.Concat(1.0f, 0, 0, 1.0f, 0, 0); + matrix.Concat(CFX_Matrix(1.0f, 0, 0, 1.0f, 0, 0)); const CFX_PathData* pPathData = pFaceCache->LoadGlyphPath( pFont, charpos.m_GlyphIndex, charpos.m_FontCharWidth); if (!pPathData) { |