diff options
Diffstat (limited to 'core')
151 files changed, 1570 insertions, 1740 deletions
diff --git a/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp b/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp index 35595b3e1f..20af9b7c2e 100644 --- a/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp +++ b/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp @@ -33,7 +33,7 @@ CFX_ByteTextBuf& operator<<(CFX_ByteTextBuf& ar, const CFX_Matrix& matrix) { return ar; } -bool GetColor(const CPDF_Color* pColor, FX_FLOAT* rgb) { +bool GetColor(const CPDF_Color* pColor, float* rgb) { int intRGB[3]; if (!pColor || pColor->GetColorSpace() != CPDF_ColorSpace::GetStockCS(PDFCS_DEVICERGB) || @@ -201,17 +201,17 @@ void CPDF_PageContentGenerator::ProcessPath(CFX_ByteTextBuf* buf, void CPDF_PageContentGenerator::ProcessGraphics(CFX_ByteTextBuf* buf, CPDF_PageObject* pPageObj) { *buf << "q "; - FX_FLOAT fillColor[3]; + float fillColor[3]; if (GetColor(pPageObj->m_ColorState.GetFillColor(), fillColor)) { *buf << fillColor[0] << " " << fillColor[1] << " " << fillColor[2] << " rg "; } - FX_FLOAT strokeColor[3]; + float strokeColor[3]; if (GetColor(pPageObj->m_ColorState.GetStrokeColor(), strokeColor)) { *buf << strokeColor[0] << " " << strokeColor[1] << " " << strokeColor[2] << " RG "; } - FX_FLOAT lineWidth = pPageObj->m_GraphState.GetLineWidth(); + float lineWidth = pPageObj->m_GraphState.GetLineWidth(); if (lineWidth != 1.0f) *buf << lineWidth << " w "; diff --git a/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp b/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp index d8813ba30f..b9510b7803 100644 --- a/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp +++ b/core/fpdfapi/edit/cpdf_pagecontentgenerator_unittest.cpp @@ -107,11 +107,11 @@ TEST_F(CPDF_PageContentGeneratorTest, ProcessGraphics) { pPathObj->m_FillType = FXFILL_WINDING; pPathObj->m_bStroke = true; - FX_FLOAT rgb[3] = {0.5f, 0.7f, 0.35f}; + float rgb[3] = {0.5f, 0.7f, 0.35f}; CPDF_ColorSpace* pCS = CPDF_ColorSpace::GetStockCS(PDFCS_DEVICERGB); pPathObj->m_ColorState.SetFillColor(pCS, rgb, 3); - FX_FLOAT rgb2[3] = {1, 0.9f, 0}; + float rgb2[3] = {1, 0.9f, 0}; pPathObj->m_ColorState.SetStrokeColor(pCS, rgb2, 3); pPathObj->m_GeneralState.SetFillAlpha(0.5f); pPathObj->m_GeneralState.SetStrokeAlpha(0.8f); diff --git a/core/fpdfapi/font/cpdf_cidfont.cpp b/core/fpdfapi/font/cpdf_cidfont.cpp index 6e050c4bc7..7d14a9ea0a 100644 --- a/core/fpdfapi/font/cpdf_cidfont.cpp +++ b/core/fpdfapi/font/cpdf_cidfont.cpp @@ -823,7 +823,7 @@ void CPDF_CIDFont::LoadMetricsArray(CPDF_Array* pArray, } // static -FX_FLOAT CPDF_CIDFont::CIDTransformToFloat(uint8_t ch) { +float CPDF_CIDFont::CIDTransformToFloat(uint8_t ch) { return (ch < 128 ? ch : ch - 255) * (1.0f / 127); } diff --git a/core/fpdfapi/font/cpdf_cidfont.h b/core/fpdfapi/font/cpdf_cidfont.h index e256be1af5..ec7da6a9bf 100644 --- a/core/fpdfapi/font/cpdf_cidfont.h +++ b/core/fpdfapi/font/cpdf_cidfont.h @@ -36,7 +36,7 @@ class CPDF_CIDFont : public CPDF_Font { CPDF_CIDFont(); ~CPDF_CIDFont() override; - static FX_FLOAT CIDTransformToFloat(uint8_t ch); + static float CIDTransformToFloat(uint8_t ch); // CPDF_Font: bool IsCIDFont() const override; diff --git a/core/fpdfapi/font/cpdf_type3font.cpp b/core/fpdfapi/font/cpdf_type3font.cpp index b7ff8c9cf0..10a116ab46 100644 --- a/core/fpdfapi/font/cpdf_type3font.cpp +++ b/core/fpdfapi/font/cpdf_type3font.cpp @@ -44,7 +44,7 @@ CPDF_Type3Font* CPDF_Type3Font::AsType3Font() { bool CPDF_Type3Font::Load() { m_pFontResources = m_pFontDict->GetDictFor("Resources"); CPDF_Array* pMatrix = m_pFontDict->GetArrayFor("FontMatrix"); - FX_FLOAT xscale = 1.0f, yscale = 1.0f; + float xscale = 1.0f, yscale = 1.0f; if (pMatrix) { m_FontMatrix = pMatrix->GetMatrix(); xscale = m_FontMatrix.a; @@ -112,12 +112,12 @@ CPDF_Type3Char* CPDF_Type3Font::LoadChar(uint32_t charcode) { if (it != m_CacheMap.end()) return it->second.get(); - FX_FLOAT scale = m_FontMatrix.GetXUnit(); + float scale = m_FontMatrix.GetXUnit(); pNewChar->m_Width = (int32_t)(pNewChar->m_Width * scale + 0.5f); FX_RECT& rcBBox = pNewChar->m_BBox; CFX_FloatRect char_rect( - (FX_FLOAT)rcBBox.left / 1000.0f, (FX_FLOAT)rcBBox.bottom / 1000.0f, - (FX_FLOAT)rcBBox.right / 1000.0f, (FX_FLOAT)rcBBox.top / 1000.0f); + (float)rcBBox.left / 1000.0f, (float)rcBBox.bottom / 1000.0f, + (float)rcBBox.right / 1000.0f, (float)rcBBox.top / 1000.0f); if (rcBBox.right <= rcBBox.left || rcBBox.bottom >= rcBBox.top) char_rect = pNewChar->m_pForm->CalcBoundingBox(); diff --git a/core/fpdfapi/page/cpdf_allstates.cpp b/core/fpdfapi/page/cpdf_allstates.cpp index 282a47fe29..a30696e8b7 100644 --- a/core/fpdfapi/page/cpdf_allstates.cpp +++ b/core/fpdfapi/page/cpdf_allstates.cpp @@ -17,7 +17,7 @@ namespace { -FX_FLOAT ClipFloat(FX_FLOAT f) { +float ClipFloat(float f) { return std::max(0.0f, std::min(1.0f, f)); } @@ -40,9 +40,7 @@ void CPDF_AllStates::Copy(const CPDF_AllStates& src) { m_TextHorzScale = src.m_TextHorzScale; } -void CPDF_AllStates::SetLineDash(CPDF_Array* pArray, - FX_FLOAT phase, - FX_FLOAT scale) { +void CPDF_AllStates::SetLineDash(CPDF_Array* pArray, float phase, float scale) { m_GraphState.SetLineDash(pArray, phase, scale); } diff --git a/core/fpdfapi/page/cpdf_allstates.h b/core/fpdfapi/page/cpdf_allstates.h index dad1b8502b..730003a96a 100644 --- a/core/fpdfapi/page/cpdf_allstates.h +++ b/core/fpdfapi/page/cpdf_allstates.h @@ -22,16 +22,16 @@ class CPDF_AllStates : public CPDF_GraphicStates { void Copy(const CPDF_AllStates& src); void ProcessExtGS(CPDF_Dictionary* pGS, CPDF_StreamContentParser* pParser); - void SetLineDash(CPDF_Array*, FX_FLOAT, FX_FLOAT scale); + void SetLineDash(CPDF_Array*, float, float scale); CFX_Matrix m_TextMatrix; CFX_Matrix m_CTM; CFX_Matrix m_ParentMatrix; CFX_PointF m_TextPos; CFX_PointF m_TextLinePos; - FX_FLOAT m_TextLeading; - FX_FLOAT m_TextRise; - FX_FLOAT m_TextHorzScale; + float m_TextLeading; + float m_TextRise; + float m_TextHorzScale; }; #endif // CORE_FPDFAPI_PAGE_CPDF_ALLSTATES_H_ diff --git a/core/fpdfapi/page/cpdf_color.cpp b/core/fpdfapi/page/cpdf_color.cpp index 4ba28ce314..b191b24808 100644 --- a/core/fpdfapi/page/cpdf_color.cpp +++ b/core/fpdfapi/page/cpdf_color.cpp @@ -67,14 +67,14 @@ void CPDF_Color::SetColorSpace(CPDF_ColorSpace* pCS) { } } -void CPDF_Color::SetValue(FX_FLOAT* comps) { +void CPDF_Color::SetValue(float* comps) { if (!m_pBuffer) return; if (m_pCS->GetFamily() != PDFCS_PATTERN) - FXSYS_memcpy(m_pBuffer, comps, m_pCS->CountComponents() * sizeof(FX_FLOAT)); + FXSYS_memcpy(m_pBuffer, comps, m_pCS->CountComponents() * sizeof(float)); } -void CPDF_Color::SetValue(CPDF_Pattern* pPattern, FX_FLOAT* comps, int ncomps) { +void CPDF_Color::SetValue(CPDF_Pattern* pPattern, float* comps, int ncomps) { if (ncomps > MAX_PATTERN_COLORCOMPS) return; @@ -94,7 +94,7 @@ void CPDF_Color::SetValue(CPDF_Pattern* pPattern, FX_FLOAT* comps, int ncomps) { pvalue->m_nComps = ncomps; pvalue->m_pPattern = pPattern; if (ncomps) - FXSYS_memcpy(pvalue->m_Comps, comps, ncomps * sizeof(FX_FLOAT)); + FXSYS_memcpy(pvalue->m_Comps, comps, ncomps * sizeof(float)); pvalue->m_pCountedPattern = nullptr; if (pPattern && pPattern->document()) { @@ -136,7 +136,7 @@ bool CPDF_Color::GetRGB(int& R, int& G, int& B) const { if (!m_pCS || !m_pBuffer) return false; - FX_FLOAT r = 0.0f, g = 0.0f, b = 0.0f; + float r = 0.0f, g = 0.0f, b = 0.0f; if (!m_pCS->GetRGB(m_pBuffer, r, g, b)) return false; diff --git a/core/fpdfapi/page/cpdf_color.h b/core/fpdfapi/page/cpdf_color.h index e81b531055..9b6eff85a3 100644 --- a/core/fpdfapi/page/cpdf_color.h +++ b/core/fpdfapi/page/cpdf_color.h @@ -23,8 +23,8 @@ class CPDF_Color { void Copy(const CPDF_Color* pSrc); void SetColorSpace(CPDF_ColorSpace* pCS); - void SetValue(FX_FLOAT* comp); - void SetValue(CPDF_Pattern* pPattern, FX_FLOAT* comp, int ncomps); + void SetValue(float* comp); + void SetValue(CPDF_Pattern* pPattern, float* comp, int ncomps); bool GetRGB(int& R, int& G, int& B) const; CPDF_Pattern* GetPattern() const; @@ -35,7 +35,7 @@ class CPDF_Color { void ReleaseColorSpace(); CPDF_ColorSpace* m_pCS; - FX_FLOAT* m_pBuffer; + float* m_pBuffer; }; #endif // CORE_FPDFAPI_PAGE_CPDF_COLOR_H_ diff --git a/core/fpdfapi/page/cpdf_colorspace.cpp b/core/fpdfapi/page/cpdf_colorspace.cpp index 6cd0075e8e..a88edb1828 100644 --- a/core/fpdfapi/page/cpdf_colorspace.cpp +++ b/core/fpdfapi/page/cpdf_colorspace.cpp @@ -65,14 +65,8 @@ class CPDF_CalGray : public CPDF_ColorSpace { bool v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) override; - bool GetRGB(FX_FLOAT* pBuf, - FX_FLOAT& R, - FX_FLOAT& G, - FX_FLOAT& B) const override; - bool SetRGB(FX_FLOAT* pBuf, - FX_FLOAT R, - FX_FLOAT G, - FX_FLOAT B) const override; + bool GetRGB(float* pBuf, float& R, float& G, float& B) const override; + bool SetRGB(float* pBuf, float R, float G, float B) const override; void TranslateImageLine(uint8_t* pDestBuf, const uint8_t* pSrcBuf, @@ -82,9 +76,9 @@ class CPDF_CalGray : public CPDF_ColorSpace { bool bTransMask = false) const override; private: - FX_FLOAT m_WhitePoint[3]; - FX_FLOAT m_BlackPoint[3]; - FX_FLOAT m_Gamma; + float m_WhitePoint[3]; + float m_BlackPoint[3]; + float m_Gamma; }; class CPDF_CalRGB : public CPDF_ColorSpace { @@ -93,14 +87,8 @@ class CPDF_CalRGB : public CPDF_ColorSpace { bool v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) override; - bool GetRGB(FX_FLOAT* pBuf, - FX_FLOAT& R, - FX_FLOAT& G, - FX_FLOAT& B) const override; - bool SetRGB(FX_FLOAT* pBuf, - FX_FLOAT R, - FX_FLOAT G, - FX_FLOAT B) const override; + bool GetRGB(float* pBuf, float& R, float& G, float& B) const override; + bool SetRGB(float* pBuf, float R, float G, float B) const override; void TranslateImageLine(uint8_t* pDestBuf, const uint8_t* pSrcBuf, @@ -109,10 +97,10 @@ class CPDF_CalRGB : public CPDF_ColorSpace { int image_height, bool bTransMask = false) const override; - FX_FLOAT m_WhitePoint[3]; - FX_FLOAT m_BlackPoint[3]; - FX_FLOAT m_Gamma[3]; - FX_FLOAT m_Matrix[9]; + float m_WhitePoint[3]; + float m_BlackPoint[3]; + float m_Gamma[3]; + float m_Matrix[9]; bool m_bGamma; bool m_bMatrix; }; @@ -124,17 +112,11 @@ class CPDF_LabCS : public CPDF_ColorSpace { bool v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) override; void GetDefaultValue(int iComponent, - FX_FLOAT& value, - FX_FLOAT& min, - FX_FLOAT& max) const override; - bool GetRGB(FX_FLOAT* pBuf, - FX_FLOAT& R, - FX_FLOAT& G, - FX_FLOAT& B) const override; - bool SetRGB(FX_FLOAT* pBuf, - FX_FLOAT R, - FX_FLOAT G, - FX_FLOAT B) const override; + float& value, + float& min, + float& max) const override; + bool GetRGB(float* pBuf, float& R, float& G, float& B) const override; + bool SetRGB(float* pBuf, float R, float G, float B) const override; void TranslateImageLine(uint8_t* pDestBuf, const uint8_t* pSrcBuf, @@ -143,9 +125,9 @@ class CPDF_LabCS : public CPDF_ColorSpace { int image_height, bool bTransMask = false) const override; - FX_FLOAT m_WhitePoint[3]; - FX_FLOAT m_BlackPoint[3]; - FX_FLOAT m_Ranges[4]; + float m_WhitePoint[3]; + float m_BlackPoint[3]; + float m_Ranges[4]; }; class CPDF_ICCBasedCS : public CPDF_ColorSpace { @@ -155,20 +137,14 @@ class CPDF_ICCBasedCS : public CPDF_ColorSpace { bool v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) override; - bool GetRGB(FX_FLOAT* pBuf, - FX_FLOAT& R, - FX_FLOAT& G, - FX_FLOAT& B) const override; - bool SetRGB(FX_FLOAT* pBuf, - FX_FLOAT R, - FX_FLOAT G, - FX_FLOAT B) const override; - - bool v_GetCMYK(FX_FLOAT* pBuf, - FX_FLOAT& c, - FX_FLOAT& m, - FX_FLOAT& y, - FX_FLOAT& k) const override; + bool GetRGB(float* pBuf, float& R, float& G, float& B) const override; + bool SetRGB(float* pBuf, float R, float G, float B) const override; + + bool v_GetCMYK(float* pBuf, + float& c, + float& m, + float& y, + float& k) const override; void EnableStdConversion(bool bEnabled) override; void TranslateImageLine(uint8_t* pDestBuf, @@ -181,7 +157,7 @@ class CPDF_ICCBasedCS : public CPDF_ColorSpace { CFX_MaybeOwned<CPDF_ColorSpace> m_pAlterCS; CPDF_IccProfile* m_pProfile; uint8_t* m_pCache; - FX_FLOAT* m_pRanges; + float* m_pRanges; }; class CPDF_IndexedCS : public CPDF_ColorSpace { @@ -191,10 +167,7 @@ class CPDF_IndexedCS : public CPDF_ColorSpace { bool v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) override; - bool GetRGB(FX_FLOAT* pBuf, - FX_FLOAT& R, - FX_FLOAT& G, - FX_FLOAT& B) const override; + bool GetRGB(float* pBuf, float& R, float& G, float& B) const override; CPDF_ColorSpace* GetBaseCS() const override; void EnableStdConversion(bool bEnabled) override; @@ -204,7 +177,7 @@ class CPDF_IndexedCS : public CPDF_ColorSpace { int m_nBaseComponents; int m_MaxIndex; CFX_ByteString m_Table; - FX_FLOAT* m_pCompMinMax; + float* m_pCompMinMax; }; class CPDF_SeparationCS : public CPDF_ColorSpace { @@ -214,14 +187,11 @@ class CPDF_SeparationCS : public CPDF_ColorSpace { // CPDF_ColorSpace: void GetDefaultValue(int iComponent, - FX_FLOAT& value, - FX_FLOAT& min, - FX_FLOAT& max) const override; + float& value, + float& min, + float& max) const override; bool v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) override; - bool GetRGB(FX_FLOAT* pBuf, - FX_FLOAT& R, - FX_FLOAT& G, - FX_FLOAT& B) const override; + bool GetRGB(float* pBuf, float& R, float& G, float& B) const override; void EnableStdConversion(bool bEnabled) override; std::unique_ptr<CPDF_ColorSpace> m_pAltCS; @@ -236,21 +206,18 @@ class CPDF_DeviceNCS : public CPDF_ColorSpace { // CPDF_ColorSpace: void GetDefaultValue(int iComponent, - FX_FLOAT& value, - FX_FLOAT& min, - FX_FLOAT& max) const override; + float& value, + float& min, + float& max) const override; bool v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) override; - bool GetRGB(FX_FLOAT* pBuf, - FX_FLOAT& R, - FX_FLOAT& G, - FX_FLOAT& B) const override; + bool GetRGB(float* pBuf, float& R, float& G, float& B) const override; void EnableStdConversion(bool bEnabled) override; std::unique_ptr<CPDF_ColorSpace> m_pAltCS; std::unique_ptr<CPDF_Function> m_pFunc; }; -FX_FLOAT RGB_Conversion(FX_FLOAT colorComponent) { +float RGB_Conversion(float colorComponent) { if (colorComponent > 1) colorComponent = 1; if (colorComponent < 0) @@ -266,36 +233,31 @@ FX_FLOAT RGB_Conversion(FX_FLOAT colorComponent) { return colorComponent; } -void XYZ_to_sRGB(FX_FLOAT X, - FX_FLOAT Y, - FX_FLOAT Z, - FX_FLOAT& R, - FX_FLOAT& G, - FX_FLOAT& B) { - FX_FLOAT R1 = 3.2410f * X - 1.5374f * Y - 0.4986f * Z; - FX_FLOAT G1 = -0.9692f * X + 1.8760f * Y + 0.0416f * Z; - FX_FLOAT B1 = 0.0556f * X - 0.2040f * Y + 1.0570f * Z; +void XYZ_to_sRGB(float X, float Y, float Z, float& R, float& G, float& B) { + float R1 = 3.2410f * X - 1.5374f * Y - 0.4986f * Z; + float G1 = -0.9692f * X + 1.8760f * Y + 0.0416f * Z; + float B1 = 0.0556f * X - 0.2040f * Y + 1.0570f * Z; R = RGB_Conversion(R1); G = RGB_Conversion(G1); B = RGB_Conversion(B1); } -void XYZ_to_sRGB_WhitePoint(FX_FLOAT X, - FX_FLOAT Y, - FX_FLOAT Z, - FX_FLOAT& R, - FX_FLOAT& G, - FX_FLOAT& B, - FX_FLOAT Xw, - FX_FLOAT Yw, - FX_FLOAT Zw) { +void XYZ_to_sRGB_WhitePoint(float X, + float Y, + float Z, + float& R, + float& G, + float& B, + float Xw, + float Yw, + float Zw) { // The following RGB_xyz is based on // sRGB value {Rx,Ry}={0.64, 0.33}, {Gx,Gy}={0.30, 0.60}, {Bx,By}={0.15, 0.06} - FX_FLOAT Rx = 0.64f, Ry = 0.33f; - FX_FLOAT Gx = 0.30f, Gy = 0.60f; - FX_FLOAT Bx = 0.15f, By = 0.06f; + float Rx = 0.64f, Ry = 0.33f; + float Gx = 0.30f, Gy = 0.60f; + float Bx = 0.15f, By = 0.06f; CFX_Matrix_3by3 RGB_xyz(Rx, Gx, Bx, Ry, Gy, By, 1 - Rx - Ry, 1 - Gx - Gy, 1 - Bx - By); CFX_Vector_3by1 whitePoint(Xw, Yw, Zw); @@ -411,13 +373,13 @@ int CPDF_ColorSpace::GetBufSize() const { if (m_Family == PDFCS_PATTERN) { return sizeof(PatternValue); } - return m_nComponents * sizeof(FX_FLOAT); + return m_nComponents * sizeof(float); } -FX_FLOAT* CPDF_ColorSpace::CreateBuf() { +float* CPDF_ColorSpace::CreateBuf() { int size = GetBufSize(); uint8_t* pBuf = FX_Alloc(uint8_t, size); - return (FX_FLOAT*)pBuf; + return (float*)pBuf; } bool CPDF_ColorSpace::sRGB() const { @@ -431,22 +393,19 @@ bool CPDF_ColorSpace::sRGB() const { return pCS->m_pProfile->m_bsRGB; } -bool CPDF_ColorSpace::SetRGB(FX_FLOAT* pBuf, - FX_FLOAT R, - FX_FLOAT G, - FX_FLOAT B) const { +bool CPDF_ColorSpace::SetRGB(float* pBuf, float R, float G, float B) const { return false; } -bool CPDF_ColorSpace::GetCMYK(FX_FLOAT* pBuf, - FX_FLOAT& c, - FX_FLOAT& m, - FX_FLOAT& y, - FX_FLOAT& k) const { +bool CPDF_ColorSpace::GetCMYK(float* pBuf, + float& c, + float& m, + float& y, + float& k) const { if (v_GetCMYK(pBuf, c, m, y, k)) { return true; } - FX_FLOAT R, G, B; + float R, G, B; if (!GetRGB(pBuf, R, G, B)) { return false; } @@ -454,24 +413,24 @@ bool CPDF_ColorSpace::GetCMYK(FX_FLOAT* pBuf, return true; } -bool CPDF_ColorSpace::SetCMYK(FX_FLOAT* pBuf, - FX_FLOAT c, - FX_FLOAT m, - FX_FLOAT y, - FX_FLOAT k) const { +bool CPDF_ColorSpace::SetCMYK(float* pBuf, + float c, + float m, + float y, + float k) const { if (v_SetCMYK(pBuf, c, m, y, k)) { return true; } - FX_FLOAT R, G, B; + float R, G, B; AdobeCMYK_to_sRGB(c, m, y, k, R, G, B); return SetRGB(pBuf, R, G, B); } -void CPDF_ColorSpace::GetDefaultColor(FX_FLOAT* buf) const { +void CPDF_ColorSpace::GetDefaultColor(float* buf) const { if (!buf || m_Family == PDFCS_PATTERN) { return; } - FX_FLOAT min, max; + float min, max; for (uint32_t i = 0; i < m_nComponents; i++) { GetDefaultValue(i, buf[i], min, max); } @@ -482,9 +441,9 @@ uint32_t CPDF_ColorSpace::CountComponents() const { } void CPDF_ColorSpace::GetDefaultValue(int iComponent, - FX_FLOAT& value, - FX_FLOAT& min, - FX_FLOAT& max) const { + float& value, + float& min, + float& max) const { value = 0; min = 0; max = 1.0f; @@ -496,15 +455,15 @@ void CPDF_ColorSpace::TranslateImageLine(uint8_t* dest_buf, int image_width, int image_height, bool bTransMask) const { - CFX_FixedBufGrow<FX_FLOAT, 16> srcbuf(m_nComponents); - FX_FLOAT* src = srcbuf; - FX_FLOAT R, G, B; + CFX_FixedBufGrow<float, 16> srcbuf(m_nComponents); + float* src = srcbuf; + float R, G, B; for (int i = 0; i < pixels; i++) { for (uint32_t j = 0; j < m_nComponents; j++) if (m_Family == PDFCS_INDEXED) { - src[j] = (FX_FLOAT)(*src_buf++); + src[j] = (float)(*src_buf++); } else { - src[j] = (FX_FLOAT)(*src_buf++) / 255; + src[j] = (float)(*src_buf++) / 255; } GetRGB(src, R, G, B); *dest_buf++ = (int32_t)(B * 255); @@ -539,19 +498,19 @@ bool CPDF_ColorSpace::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) { return true; } -bool CPDF_ColorSpace::v_GetCMYK(FX_FLOAT* pBuf, - FX_FLOAT& c, - FX_FLOAT& m, - FX_FLOAT& y, - FX_FLOAT& k) const { +bool CPDF_ColorSpace::v_GetCMYK(float* pBuf, + float& c, + float& m, + float& y, + float& k) const { return false; } -bool CPDF_ColorSpace::v_SetCMYK(FX_FLOAT* pBuf, - FX_FLOAT c, - FX_FLOAT m, - FX_FLOAT y, - FX_FLOAT k) const { +bool CPDF_ColorSpace::v_SetCMYK(float* pBuf, + float c, + float m, + float y, + float k) const { return false; } @@ -578,18 +537,12 @@ bool CPDF_CalGray::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) { return true; } -bool CPDF_CalGray::GetRGB(FX_FLOAT* pBuf, - FX_FLOAT& R, - FX_FLOAT& G, - FX_FLOAT& B) const { +bool CPDF_CalGray::GetRGB(float* pBuf, float& R, float& G, float& B) const { R = G = B = *pBuf; return true; } -bool CPDF_CalGray::SetRGB(FX_FLOAT* pBuf, - FX_FLOAT R, - FX_FLOAT G, - FX_FLOAT B) const { +bool CPDF_CalGray::SetRGB(float* pBuf, float R, float G, float B) const { if (R == G && R == B) { *pBuf = R; return true; @@ -647,22 +600,19 @@ bool CPDF_CalRGB::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) { return true; } -bool CPDF_CalRGB::GetRGB(FX_FLOAT* pBuf, - FX_FLOAT& R, - FX_FLOAT& G, - FX_FLOAT& B) const { - FX_FLOAT A_ = pBuf[0]; - FX_FLOAT B_ = pBuf[1]; - FX_FLOAT C_ = pBuf[2]; +bool CPDF_CalRGB::GetRGB(float* pBuf, float& R, float& G, float& B) const { + float A_ = pBuf[0]; + float B_ = pBuf[1]; + float C_ = pBuf[2]; if (m_bGamma) { - A_ = (FX_FLOAT)FXSYS_pow(A_, m_Gamma[0]); - B_ = (FX_FLOAT)FXSYS_pow(B_, m_Gamma[1]); - C_ = (FX_FLOAT)FXSYS_pow(C_, m_Gamma[2]); + A_ = (float)FXSYS_pow(A_, m_Gamma[0]); + B_ = (float)FXSYS_pow(B_, m_Gamma[1]); + C_ = (float)FXSYS_pow(C_, m_Gamma[2]); } - FX_FLOAT X; - FX_FLOAT Y; - FX_FLOAT Z; + float X; + float Y; + float Z; if (m_bMatrix) { X = m_Matrix[0] * A_ + m_Matrix[3] * B_ + m_Matrix[6] * C_; Y = m_Matrix[1] * A_ + m_Matrix[4] * B_ + m_Matrix[7] * C_; @@ -677,10 +627,7 @@ bool CPDF_CalRGB::GetRGB(FX_FLOAT* pBuf, return true; } -bool CPDF_CalRGB::SetRGB(FX_FLOAT* pBuf, - FX_FLOAT R, - FX_FLOAT G, - FX_FLOAT B) const { +bool CPDF_CalRGB::SetRGB(float* pBuf, float R, float G, float B) const { pBuf[0] = R; pBuf[1] = G; pBuf[2] = B; @@ -694,14 +641,14 @@ void CPDF_CalRGB::TranslateImageLine(uint8_t* pDestBuf, int image_height, bool bTransMask) const { if (bTransMask) { - FX_FLOAT Cal[3]; - FX_FLOAT R; - FX_FLOAT G; - FX_FLOAT B; + float Cal[3]; + float R; + float G; + float B; for (int i = 0; i < pixels; i++) { - Cal[0] = ((FX_FLOAT)pSrcBuf[2]) / 255; - Cal[1] = ((FX_FLOAT)pSrcBuf[1]) / 255; - Cal[2] = ((FX_FLOAT)pSrcBuf[0]) / 255; + Cal[0] = ((float)pSrcBuf[2]) / 255; + Cal[1] = ((float)pSrcBuf[1]) / 255; + Cal[2] = ((float)pSrcBuf[0]) / 255; GetRGB(Cal, R, G, B); pDestBuf[0] = FXSYS_round(B * 255); pDestBuf[1] = FXSYS_round(G * 255); @@ -717,9 +664,9 @@ CPDF_LabCS::CPDF_LabCS(CPDF_Document* pDoc) : CPDF_ColorSpace(pDoc, PDFCS_LAB, 3) {} void CPDF_LabCS::GetDefaultValue(int iComponent, - FX_FLOAT& value, - FX_FLOAT& min, - FX_FLOAT& max) const { + float& value, + float& min, + float& max) const { ASSERT(iComponent < 3); value = 0; if (iComponent == 0) { @@ -750,24 +697,21 @@ bool CPDF_LabCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) { m_BlackPoint[i] = pParam ? pParam->GetNumberAt(i) : 0; pParam = pDict->GetArrayFor("Range"); - const FX_FLOAT def_ranges[4] = {-100 * 1.0f, 100 * 1.0f, -100 * 1.0f, - 100 * 1.0f}; + const float def_ranges[4] = {-100 * 1.0f, 100 * 1.0f, -100 * 1.0f, + 100 * 1.0f}; for (i = 0; i < 4; i++) m_Ranges[i] = pParam ? pParam->GetNumberAt(i) : def_ranges[i]; return true; } -bool CPDF_LabCS::GetRGB(FX_FLOAT* pBuf, - FX_FLOAT& R, - FX_FLOAT& G, - FX_FLOAT& B) const { - FX_FLOAT Lstar = pBuf[0]; - FX_FLOAT astar = pBuf[1]; - FX_FLOAT bstar = pBuf[2]; - FX_FLOAT M = (Lstar + 16.0f) / 116.0f; - FX_FLOAT L = M + astar / 500.0f; - FX_FLOAT N = M - bstar / 200.0f; - FX_FLOAT X, Y, Z; +bool CPDF_LabCS::GetRGB(float* pBuf, float& R, float& G, float& B) const { + float Lstar = pBuf[0]; + float astar = pBuf[1]; + float bstar = pBuf[2]; + float M = (Lstar + 16.0f) / 116.0f; + float L = M + astar / 500.0f; + float N = M - bstar / 200.0f; + float X, Y, Z; if (L < 0.2069f) X = 0.957f * 0.12842f * (L - 0.1379f); else @@ -787,10 +731,7 @@ bool CPDF_LabCS::GetRGB(FX_FLOAT* pBuf, return true; } -bool CPDF_LabCS::SetRGB(FX_FLOAT* pBuf, - FX_FLOAT R, - FX_FLOAT G, - FX_FLOAT B) const { +bool CPDF_LabCS::SetRGB(float* pBuf, float R, float G, float B) const { return false; } @@ -801,11 +742,11 @@ void CPDF_LabCS::TranslateImageLine(uint8_t* pDestBuf, int image_height, bool bTransMask) const { for (int i = 0; i < pixels; i++) { - FX_FLOAT lab[3]; - FX_FLOAT R, G, B; + float lab[3]; + float R, G, B; lab[0] = (pSrcBuf[0] * 100 / 255.0f); - lab[1] = (FX_FLOAT)(pSrcBuf[1] - 128); - lab[2] = (FX_FLOAT)(pSrcBuf[2] - 128); + lab[1] = (float)(pSrcBuf[1] - 128); + lab[2] = (float)(pSrcBuf[2] - 128); GetRGB(lab, R, G, B); pDestBuf[0] = (int32_t)(B * 255); pDestBuf[1] = (int32_t)(G * 255); @@ -875,7 +816,7 @@ bool CPDF_ICCBasedCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) { } } CPDF_Array* pRanges = pDict->GetArrayFor("Range"); - m_pRanges = FX_Alloc2D(FX_FLOAT, m_nComponents, 2); + m_pRanges = FX_Alloc2D(float, m_nComponents, 2); for (uint32_t i = 0; i < m_nComponents * 2; i++) { if (pRanges) m_pRanges[i] = pRanges->GetNumberAt(i); @@ -887,10 +828,7 @@ bool CPDF_ICCBasedCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) { return true; } -bool CPDF_ICCBasedCS::GetRGB(FX_FLOAT* pBuf, - FX_FLOAT& R, - FX_FLOAT& G, - FX_FLOAT& B) const { +bool CPDF_ICCBasedCS::GetRGB(float* pBuf, float& R, float& G, float& B) const { if (m_pProfile && m_pProfile->m_bsRGB) { R = pBuf[0]; G = pBuf[1]; @@ -907,7 +845,7 @@ bool CPDF_ICCBasedCS::GetRGB(FX_FLOAT* pBuf, B = 0.0f; return true; } - FX_FLOAT rgb[3]; + float rgb[3]; pIccModule->SetComponents(m_nComponents); pIccModule->Translate(m_pProfile->m_pTransform, pBuf, rgb); R = rgb[0]; @@ -916,18 +854,15 @@ bool CPDF_ICCBasedCS::GetRGB(FX_FLOAT* pBuf, return true; } -bool CPDF_ICCBasedCS::SetRGB(FX_FLOAT* pBuf, - FX_FLOAT R, - FX_FLOAT G, - FX_FLOAT B) const { +bool CPDF_ICCBasedCS::SetRGB(float* pBuf, float R, float G, float B) const { return false; } -bool CPDF_ICCBasedCS::v_GetCMYK(FX_FLOAT* pBuf, - FX_FLOAT& c, - FX_FLOAT& m, - FX_FLOAT& y, - FX_FLOAT& k) const { +bool CPDF_ICCBasedCS::v_GetCMYK(float* pBuf, + float& c, + float& m, + float& y, + float& k) const { if (m_nComponents != 4) return false; @@ -1025,8 +960,8 @@ bool CPDF_IndexedCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) { } m_pCountedBaseCS = pDocPageData->FindColorSpacePtr(m_pBaseCS->GetArray()); m_nBaseComponents = m_pBaseCS->CountComponents(); - m_pCompMinMax = FX_Alloc2D(FX_FLOAT, m_nBaseComponents, 2); - FX_FLOAT defvalue; + m_pCompMinMax = FX_Alloc2D(float, m_nBaseComponents, 2); + float defvalue; for (int i = 0; i < m_nBaseComponents; i++) { m_pBaseCS->GetDefaultValue(i, defvalue, m_pCompMinMax[i * 2], m_pCompMinMax[i * 2 + 1]); @@ -1048,10 +983,7 @@ bool CPDF_IndexedCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) { return true; } -bool CPDF_IndexedCS::GetRGB(FX_FLOAT* pBuf, - FX_FLOAT& R, - FX_FLOAT& G, - FX_FLOAT& B) const { +bool CPDF_IndexedCS::GetRGB(float* pBuf, float& R, float& G, float& B) const { int index = (int32_t)(*pBuf); if (index < 0 || index > m_MaxIndex) { return false; @@ -1063,8 +995,8 @@ bool CPDF_IndexedCS::GetRGB(FX_FLOAT* pBuf, return false; } } - CFX_FixedBufGrow<FX_FLOAT, 16> Comps(m_nBaseComponents); - FX_FLOAT* comps = Comps; + CFX_FixedBufGrow<float, 16> Comps(m_nBaseComponents); + float* comps = Comps; const uint8_t* pTable = m_Table.raw_str(); for (int i = 0; i < m_nBaseComponents; i++) { comps[i] = @@ -1119,10 +1051,7 @@ bool CPDF_PatternCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) { return true; } -bool CPDF_PatternCS::GetRGB(FX_FLOAT* pBuf, - FX_FLOAT& R, - FX_FLOAT& G, - FX_FLOAT& B) const { +bool CPDF_PatternCS::GetRGB(float* pBuf, float& R, float& G, float& B) const { if (m_pBaseCS) { ASSERT(m_pBaseCS->GetFamily() != PDFCS_PATTERN); PatternValue* pvalue = (PatternValue*)pBuf; @@ -1144,9 +1073,9 @@ CPDF_SeparationCS::CPDF_SeparationCS(CPDF_Document* pDoc) CPDF_SeparationCS::~CPDF_SeparationCS() {} void CPDF_SeparationCS::GetDefaultValue(int iComponent, - FX_FLOAT& value, - FX_FLOAT& min, - FX_FLOAT& max) const { + float& value, + float& min, + float& max) const { value = 1.0f; min = 0; max = 1.0f; @@ -1177,10 +1106,10 @@ bool CPDF_SeparationCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) { return true; } -bool CPDF_SeparationCS::GetRGB(FX_FLOAT* pBuf, - FX_FLOAT& R, - FX_FLOAT& G, - FX_FLOAT& B) const { +bool CPDF_SeparationCS::GetRGB(float* pBuf, + float& R, + float& G, + float& B) const { if (m_Type == None) return false; @@ -1189,13 +1118,13 @@ bool CPDF_SeparationCS::GetRGB(FX_FLOAT* pBuf, return false; int nComps = m_pAltCS->CountComponents(); - CFX_FixedBufGrow<FX_FLOAT, 16> results(nComps); + CFX_FixedBufGrow<float, 16> results(nComps); for (int i = 0; i < nComps; i++) results[i] = *pBuf; return m_pAltCS->GetRGB(results, R, G, B); } - CFX_FixedBufGrow<FX_FLOAT, 16> results(m_pFunc->CountOutputs()); + CFX_FixedBufGrow<float, 16> results(m_pFunc->CountOutputs()); int nresults = 0; m_pFunc->Call(pBuf, 1, results, nresults); if (nresults == 0) @@ -1222,9 +1151,9 @@ CPDF_DeviceNCS::CPDF_DeviceNCS(CPDF_Document* pDoc) CPDF_DeviceNCS::~CPDF_DeviceNCS() {} void CPDF_DeviceNCS::GetDefaultValue(int iComponent, - FX_FLOAT& value, - FX_FLOAT& min, - FX_FLOAT& max) const { + float& value, + float& min, + float& max) const { value = 1.0f; min = 0; max = 1.0f; @@ -1248,14 +1177,11 @@ bool CPDF_DeviceNCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) { return m_pFunc->CountOutputs() >= m_pAltCS->CountComponents(); } -bool CPDF_DeviceNCS::GetRGB(FX_FLOAT* pBuf, - FX_FLOAT& R, - FX_FLOAT& G, - FX_FLOAT& B) const { +bool CPDF_DeviceNCS::GetRGB(float* pBuf, float& R, float& G, float& B) const { if (!m_pFunc) return false; - CFX_FixedBufGrow<FX_FLOAT, 16> results(m_pFunc->CountOutputs()); + CFX_FixedBufGrow<float, 16> results(m_pFunc->CountOutputs()); int nresults = 0; m_pFunc->Call(pBuf, m_nComponents, results, nresults); if (nresults == 0) diff --git a/core/fpdfapi/page/cpdf_colorspace.h b/core/fpdfapi/page/cpdf_colorspace.h index c4d62ed849..e3c369e5ce 100644 --- a/core/fpdfapi/page/cpdf_colorspace.h +++ b/core/fpdfapi/page/cpdf_colorspace.h @@ -38,32 +38,21 @@ class CPDF_ColorSpace { void Release(); int GetBufSize() const; - FX_FLOAT* CreateBuf(); - void GetDefaultColor(FX_FLOAT* buf) const; + float* CreateBuf(); + void GetDefaultColor(float* buf) const; uint32_t CountComponents() const; int GetFamily() const { return m_Family; } virtual void GetDefaultValue(int iComponent, - FX_FLOAT& value, - FX_FLOAT& min, - FX_FLOAT& max) const; + float& value, + float& min, + float& max) const; bool sRGB() const; - virtual bool GetRGB(FX_FLOAT* pBuf, - FX_FLOAT& R, - FX_FLOAT& G, - FX_FLOAT& B) const = 0; - virtual bool SetRGB(FX_FLOAT* pBuf, FX_FLOAT R, FX_FLOAT G, FX_FLOAT B) const; - - bool GetCMYK(FX_FLOAT* pBuf, - FX_FLOAT& c, - FX_FLOAT& m, - FX_FLOAT& y, - FX_FLOAT& k) const; - bool SetCMYK(FX_FLOAT* pBuf, - FX_FLOAT c, - FX_FLOAT m, - FX_FLOAT y, - FX_FLOAT k) const; + virtual bool GetRGB(float* pBuf, float& R, float& G, float& B) const = 0; + virtual bool SetRGB(float* pBuf, float R, float G, float B) const; + + bool GetCMYK(float* pBuf, float& c, float& m, float& y, float& k) const; + bool SetCMYK(float* pBuf, float c, float m, float y, float k) const; virtual void TranslateImageLine(uint8_t* dest_buf, const uint8_t* src_buf, @@ -84,16 +73,12 @@ class CPDF_ColorSpace { virtual ~CPDF_ColorSpace(); virtual bool v_Load(CPDF_Document* pDoc, CPDF_Array* pArray); - virtual bool v_GetCMYK(FX_FLOAT* pBuf, - FX_FLOAT& c, - FX_FLOAT& m, - FX_FLOAT& y, - FX_FLOAT& k) const; - virtual bool v_SetCMYK(FX_FLOAT* pBuf, - FX_FLOAT c, - FX_FLOAT m, - FX_FLOAT y, - FX_FLOAT k) const; + virtual bool v_GetCMYK(float* pBuf, + float& c, + float& m, + float& y, + float& k) const; + virtual bool v_SetCMYK(float* pBuf, float c, float m, float y, float k) const; int m_Family; uint32_t m_nComponents; diff --git a/core/fpdfapi/page/cpdf_colorstate.cpp b/core/fpdfapi/page/cpdf_colorstate.cpp index c43a331c64..8ab182acc6 100644 --- a/core/fpdfapi/page/cpdf_colorstate.cpp +++ b/core/fpdfapi/page/cpdf_colorstate.cpp @@ -70,21 +70,21 @@ bool CPDF_ColorState::HasStrokeColor() const { } void CPDF_ColorState::SetFillColor(CPDF_ColorSpace* pCS, - FX_FLOAT* pValue, + float* pValue, uint32_t nValues) { ColorData* pData = m_Ref.GetPrivateCopy(); SetColor(pData->m_FillColor, pData->m_FillRGB, pCS, pValue, nValues); } void CPDF_ColorState::SetStrokeColor(CPDF_ColorSpace* pCS, - FX_FLOAT* pValue, + float* pValue, uint32_t nValues) { ColorData* pData = m_Ref.GetPrivateCopy(); SetColor(pData->m_StrokeColor, pData->m_StrokeRGB, pCS, pValue, nValues); } void CPDF_ColorState::SetFillPattern(CPDF_Pattern* pPattern, - FX_FLOAT* pValue, + float* pValue, uint32_t nValues) { ColorData* pData = m_Ref.GetPrivateCopy(); pData->m_FillColor.SetValue(pPattern, pValue, nValues); @@ -100,7 +100,7 @@ void CPDF_ColorState::SetFillPattern(CPDF_Pattern* pPattern, } void CPDF_ColorState::SetStrokePattern(CPDF_Pattern* pPattern, - FX_FLOAT* pValue, + float* pValue, uint32_t nValues) { ColorData* pData = m_Ref.GetPrivateCopy(); pData->m_StrokeColor.SetValue(pPattern, pValue, nValues); @@ -119,7 +119,7 @@ void CPDF_ColorState::SetStrokePattern(CPDF_Pattern* pPattern, void CPDF_ColorState::SetColor(CPDF_Color& color, uint32_t& rgb, CPDF_ColorSpace* pCS, - FX_FLOAT* pValue, + float* pValue, uint32_t nValues) { if (pCS) color.SetColorSpace(pCS); diff --git a/core/fpdfapi/page/cpdf_colorstate.h b/core/fpdfapi/page/cpdf_colorstate.h index 49c71b66f9..f66eac3d81 100644 --- a/core/fpdfapi/page/cpdf_colorstate.h +++ b/core/fpdfapi/page/cpdf_colorstate.h @@ -39,14 +39,10 @@ class CPDF_ColorState { CPDF_Color* GetMutableStrokeColor(); bool HasStrokeColor() const; - void SetFillColor(CPDF_ColorSpace* pCS, FX_FLOAT* pValue, uint32_t nValues); - void SetStrokeColor(CPDF_ColorSpace* pCS, FX_FLOAT* pValue, uint32_t nValues); - void SetFillPattern(CPDF_Pattern* pattern, - FX_FLOAT* pValue, - uint32_t nValues); - void SetStrokePattern(CPDF_Pattern* pattern, - FX_FLOAT* pValue, - uint32_t nValues); + void SetFillColor(CPDF_ColorSpace* pCS, float* pValue, uint32_t nValues); + void SetStrokeColor(CPDF_ColorSpace* pCS, float* pValue, uint32_t nValues); + void SetFillPattern(CPDF_Pattern* pattern, float* pValue, uint32_t nValues); + void SetStrokePattern(CPDF_Pattern* pattern, float* pValue, uint32_t nValues); explicit operator bool() const { return !!m_Ref; } @@ -68,7 +64,7 @@ class CPDF_ColorState { void SetColor(CPDF_Color& color, uint32_t& rgb, CPDF_ColorSpace* pCS, - FX_FLOAT* pValue, + float* pValue, uint32_t nValues); CFX_SharedCopyOnWrite<ColorData> m_Ref; diff --git a/core/fpdfapi/page/cpdf_devicecs_unittest.cpp b/core/fpdfapi/page/cpdf_devicecs_unittest.cpp index 287fc02fc4..b1b30094aa 100644 --- a/core/fpdfapi/page/cpdf_devicecs_unittest.cpp +++ b/core/fpdfapi/page/cpdf_devicecs_unittest.cpp @@ -8,13 +8,13 @@ #include "testing/gtest/include/gtest/gtest.h" TEST(CPDF_DeviceCSTest, GetRGBFromGray) { - FX_FLOAT R; - FX_FLOAT G; - FX_FLOAT B; + float R; + float G; + float B; CPDF_DeviceCS deviceGray(nullptr, PDFCS_DEVICEGRAY); // Test normal values. For gray, only first value from buf should be used. - FX_FLOAT buf[3] = {0.43f, 0.11f, 0.34f}; + float buf[3] = {0.43f, 0.11f, 0.34f}; ASSERT_TRUE(deviceGray.GetRGB(buf, R, G, B)); EXPECT_EQ(0.43f, R); EXPECT_EQ(0.43f, G); @@ -51,13 +51,13 @@ TEST(CPDF_DeviceCSTest, GetRGBFromGray) { } TEST(CPDF_DeviceCSTest, GetRGBFromRGB) { - FX_FLOAT R; - FX_FLOAT G; - FX_FLOAT B; + float R; + float G; + float B; CPDF_DeviceCS deviceRGB(nullptr, PDFCS_DEVICERGB); // Test normal values - FX_FLOAT buf[3] = {0.13f, 1.0f, 0.652f}; + float buf[3] = {0.13f, 1.0f, 0.652f}; ASSERT_TRUE(deviceRGB.GetRGB(buf, R, G, B)); EXPECT_EQ(0.13f, R); EXPECT_EQ(1.0f, G); @@ -80,14 +80,14 @@ TEST(CPDF_DeviceCSTest, GetRGBFromRGB) { } TEST(CPDF_DeviceCSTest, GetRGBFromCMYK) { - FX_FLOAT R; - FX_FLOAT G; - FX_FLOAT B; + float R; + float G; + float B; CPDF_DeviceCS deviceCMYK(nullptr, PDFCS_DEVICECMYK); // Use an error threshold because of the calculations used here. - FX_FLOAT eps = 1e-6f; + float eps = 1e-6f; // Test normal values - FX_FLOAT buf[4] = {0.6f, 0.5f, 0.3f, 0.9f}; + float buf[4] = {0.6f, 0.5f, 0.3f, 0.9f}; ASSERT_TRUE(deviceCMYK.GetRGB(buf, R, G, B)); EXPECT_TRUE(std::abs(0.0627451f - R) < eps); EXPECT_TRUE(std::abs(0.0627451f - G) < eps); diff --git a/core/fpdfapi/page/cpdf_generalstate.cpp b/core/fpdfapi/page/cpdf_generalstate.cpp index 4edd9b2a3c..dd5c5af878 100644 --- a/core/fpdfapi/page/cpdf_generalstate.cpp +++ b/core/fpdfapi/page/cpdf_generalstate.cpp @@ -88,21 +88,21 @@ void CPDF_GeneralState::SetBlendType(int type) { m_Ref.GetPrivateCopy()->m_BlendType = type; } -FX_FLOAT CPDF_GeneralState::GetFillAlpha() const { +float CPDF_GeneralState::GetFillAlpha() const { const StateData* pData = m_Ref.GetObject(); return pData ? pData->m_FillAlpha : 1.0f; } -void CPDF_GeneralState::SetFillAlpha(FX_FLOAT alpha) { +void CPDF_GeneralState::SetFillAlpha(float alpha) { m_Ref.GetPrivateCopy()->m_FillAlpha = alpha; } -FX_FLOAT CPDF_GeneralState::GetStrokeAlpha() const { +float CPDF_GeneralState::GetStrokeAlpha() const { const StateData* pData = m_Ref.GetObject(); return pData ? pData->m_StrokeAlpha : 1.0f; } -void CPDF_GeneralState::SetStrokeAlpha(FX_FLOAT alpha) { +void CPDF_GeneralState::SetStrokeAlpha(float alpha) { m_Ref.GetPrivateCopy()->m_StrokeAlpha = alpha; } @@ -186,11 +186,11 @@ void CPDF_GeneralState::SetHT(CPDF_Object* pObject) { m_Ref.GetPrivateCopy()->m_pHT = pObject; } -void CPDF_GeneralState::SetFlatness(FX_FLOAT flatness) { +void CPDF_GeneralState::SetFlatness(float flatness) { m_Ref.GetPrivateCopy()->m_Flatness = flatness; } -void CPDF_GeneralState::SetSmoothness(FX_FLOAT smoothness) { +void CPDF_GeneralState::SetSmoothness(float smoothness) { m_Ref.GetPrivateCopy()->m_Smoothness = smoothness; } diff --git a/core/fpdfapi/page/cpdf_generalstate.h b/core/fpdfapi/page/cpdf_generalstate.h index 5211c52e5b..ddc33ac800 100644 --- a/core/fpdfapi/page/cpdf_generalstate.h +++ b/core/fpdfapi/page/cpdf_generalstate.h @@ -28,11 +28,11 @@ class CPDF_GeneralState { int GetBlendType() const; void SetBlendType(int type); - FX_FLOAT GetFillAlpha() const; - void SetFillAlpha(FX_FLOAT alpha); + float GetFillAlpha() const; + void SetFillAlpha(float alpha); - FX_FLOAT GetStrokeAlpha() const; - void SetStrokeAlpha(FX_FLOAT alpha); + float GetStrokeAlpha() const; + void SetStrokeAlpha(float alpha); CPDF_Object* GetSoftMask() const; void SetSoftMask(CPDF_Object* pObject); @@ -61,8 +61,8 @@ class CPDF_GeneralState { void SetUCR(CPDF_Object* pObject); void SetHT(CPDF_Object* pObject); - void SetFlatness(FX_FLOAT flatness); - void SetSmoothness(FX_FLOAT smoothness); + void SetFlatness(float flatness); + void SetSmoothness(float smoothness); bool GetStrokeAdjust() const; void SetStrokeAdjust(bool adjust); @@ -84,8 +84,8 @@ class CPDF_GeneralState { int m_BlendType; CPDF_Object* m_pSoftMask; CFX_Matrix m_SMaskMatrix; - FX_FLOAT m_StrokeAlpha; - FX_FLOAT m_FillAlpha; + float m_StrokeAlpha; + float m_FillAlpha; CPDF_Object* m_pTR; CPDF_TransferFunc* m_pTransferFunc; CFX_Matrix m_Matrix; @@ -99,8 +99,8 @@ class CPDF_GeneralState { CPDF_Object* m_pBG; CPDF_Object* m_pUCR; CPDF_Object* m_pHT; - FX_FLOAT m_Flatness; - FX_FLOAT m_Smoothness; + float m_Flatness; + float m_Smoothness; }; CFX_SharedCopyOnWrite<StateData> m_Ref; diff --git a/core/fpdfapi/page/cpdf_image.cpp b/core/fpdfapi/page/cpdf_image.cpp index fea03c70e1..3de0511771 100644 --- a/core/fpdfapi/page/cpdf_image.cpp +++ b/core/fpdfapi/page/cpdf_image.cpp @@ -298,7 +298,7 @@ void CPDF_Image::SetImage(const CFX_DIBitmap* pBitmap) { for (int32_t row = 0; row < BitmapHeight; row++) { src_offset = row * src_pitch; for (int32_t column = 0; column < BitmapWidth; column++) { - FX_FLOAT alpha = 1; + float alpha = 1; pDest[dest_offset] = (uint8_t)(src_buf[src_offset + 2] * alpha); pDest[dest_offset + 1] = (uint8_t)(src_buf[src_offset + 1] * alpha); pDest[dest_offset + 2] = (uint8_t)(src_buf[src_offset] * alpha); diff --git a/core/fpdfapi/page/cpdf_meshstream.cpp b/core/fpdfapi/page/cpdf_meshstream.cpp index 24ef9b271e..6450d14904 100644 --- a/core/fpdfapi/page/cpdf_meshstream.cpp +++ b/core/fpdfapi/page/cpdf_meshstream.cpp @@ -191,25 +191,25 @@ CFX_PointF CPDF_MeshStream::ReadCoords() { return pos; } -std::tuple<FX_FLOAT, FX_FLOAT, FX_FLOAT> CPDF_MeshStream::ReadColor() { +std::tuple<float, float, float> CPDF_MeshStream::ReadColor() { ASSERT(ShouldCheckBPC(m_type)); - FX_FLOAT color_value[kMaxComponents]; + float color_value[kMaxComponents]; for (uint32_t i = 0; i < m_nComponents; ++i) { color_value[i] = m_ColorMin[i] + m_BitStream.GetBits(m_nComponentBits) * (m_ColorMax[i] - m_ColorMin[i]) / m_ComponentMax; } - FX_FLOAT r; - FX_FLOAT g; - FX_FLOAT b; + float r; + float g; + float b; if (m_funcs.empty()) { m_pCS->GetRGB(color_value, r, g, b); - return std::tuple<FX_FLOAT, FX_FLOAT, FX_FLOAT>(r, g, b); + return std::tuple<float, float, float>(r, g, b); } - FX_FLOAT result[kMaxComponents]; + float result[kMaxComponents]; FXSYS_memset(result, 0, sizeof(result)); int nResults; for (const auto& func : m_funcs) { @@ -218,7 +218,7 @@ std::tuple<FX_FLOAT, FX_FLOAT, FX_FLOAT> CPDF_MeshStream::ReadColor() { } m_pCS->GetRGB(result, r, g, b); - return std::tuple<FX_FLOAT, FX_FLOAT, FX_FLOAT>(r, g, b); + return std::tuple<float, float, float>(r, g, b); } bool CPDF_MeshStream::ReadVertex(const CFX_Matrix& pObject2Bitmap, diff --git a/core/fpdfapi/page/cpdf_meshstream.h b/core/fpdfapi/page/cpdf_meshstream.h index d40de4a013..e58e354b35 100644 --- a/core/fpdfapi/page/cpdf_meshstream.h +++ b/core/fpdfapi/page/cpdf_meshstream.h @@ -23,9 +23,9 @@ class CPDF_MeshVertex { ~CPDF_MeshVertex(); CFX_PointF position; - FX_FLOAT r; - FX_FLOAT g; - FX_FLOAT b; + float r; + float g; + float b; }; class CFX_Matrix; @@ -48,7 +48,7 @@ class CPDF_MeshStream { uint32_t ReadFlag(); CFX_PointF ReadCoords(); - std::tuple<FX_FLOAT, FX_FLOAT, FX_FLOAT> ReadColor(); + std::tuple<float, float, float> ReadColor(); bool ReadVertex(const CFX_Matrix& pObject2Bitmap, CPDF_MeshVertex* vertex, @@ -74,12 +74,12 @@ class CPDF_MeshStream { uint32_t m_nComponents; uint32_t m_CoordMax; uint32_t m_ComponentMax; - FX_FLOAT m_xmin; - FX_FLOAT m_xmax; - FX_FLOAT m_ymin; - FX_FLOAT m_ymax; - FX_FLOAT m_ColorMin[kMaxComponents]; - FX_FLOAT m_ColorMax[kMaxComponents]; + float m_xmin; + float m_xmax; + float m_ymin; + float m_ymax; + float m_ColorMin[kMaxComponents]; + float m_ColorMax[kMaxComponents]; CPDF_StreamAcc m_Stream; CFX_BitStream m_BitStream; }; diff --git a/core/fpdfapi/page/cpdf_page.h b/core/fpdfapi/page/cpdf_page.h index 9e303562c6..76587d8c32 100644 --- a/core/fpdfapi/page/cpdf_page.h +++ b/core/fpdfapi/page/cpdf_page.h @@ -24,8 +24,8 @@ class CPDF_PageRenderContext; // These structs are used to keep track of resources that have already been // generated in the page. struct GraphicsData { - FX_FLOAT fillAlpha; - FX_FLOAT strokeAlpha; + float fillAlpha; + float strokeAlpha; bool operator<(const GraphicsData& other) const; }; @@ -51,8 +51,8 @@ class CPDF_Page : public CPDF_PageObjectHolder { int ySize, int iRotate) const; - FX_FLOAT GetPageWidth() const { return m_PageWidth; } - FX_FLOAT GetPageHeight() const { return m_PageHeight; } + float GetPageWidth() const { return m_PageWidth; } + float GetPageHeight() const { return m_PageHeight; } CFX_FloatRect GetPageBBox() const { return m_BBox; } const CFX_Matrix& GetPageMatrix() const { return m_PageMatrix; } CPDF_Object* GetPageAttr(const CFX_ByteString& name) const; @@ -72,8 +72,8 @@ class CPDF_Page : public CPDF_PageObjectHolder { protected: void StartParse(); - FX_FLOAT m_PageWidth; - FX_FLOAT m_PageHeight; + float m_PageWidth; + float m_PageHeight; CFX_Matrix m_PageMatrix; View* m_pView; std::unique_ptr<CPDF_PageRenderCache> m_pPageRender; diff --git a/core/fpdfapi/page/cpdf_pageobject.h b/core/fpdfapi/page/cpdf_pageobject.h index d2b84a5d40..668621ff51 100644 --- a/core/fpdfapi/page/cpdf_pageobject.h +++ b/core/fpdfapi/page/cpdf_pageobject.h @@ -57,10 +57,10 @@ class CPDF_PageObject : public CPDF_GraphicStates { } FX_RECT GetBBox(const CFX_Matrix* pMatrix) const; - FX_FLOAT m_Left; - FX_FLOAT m_Right; - FX_FLOAT m_Top; - FX_FLOAT m_Bottom; + float m_Left; + float m_Right; + float m_Top; + float m_Bottom; CPDF_ContentMark m_ContentMark; protected: diff --git a/core/fpdfapi/page/cpdf_pageobjectholder.cpp b/core/fpdfapi/page/cpdf_pageobjectholder.cpp index 3304d4eec4..974baa65a0 100644 --- a/core/fpdfapi/page/cpdf_pageobjectholder.cpp +++ b/core/fpdfapi/page/cpdf_pageobjectholder.cpp @@ -46,10 +46,10 @@ CFX_FloatRect CPDF_PageObjectHolder::CalcBoundingBox() const { if (m_PageObjectList.empty()) return CFX_FloatRect(0, 0, 0, 0); - FX_FLOAT left = 1000000.0f; - FX_FLOAT right = -1000000.0f; - FX_FLOAT bottom = 1000000.0f; - FX_FLOAT top = -1000000.0f; + float left = 1000000.0f; + float right = -1000000.0f; + float bottom = 1000000.0f; + float top = -1000000.0f; for (const auto& pObj : m_PageObjectList) { left = std::min(left, pObj->m_Left); right = std::max(right, pObj->m_Right); diff --git a/core/fpdfapi/page/cpdf_path.cpp b/core/fpdfapi/page/cpdf_path.cpp index ddc6bbd1d6..b56249cd62 100644 --- a/core/fpdfapi/page/cpdf_path.cpp +++ b/core/fpdfapi/page/cpdf_path.cpp @@ -28,8 +28,8 @@ CFX_FloatRect CPDF_Path::GetBoundingBox() const { return m_Ref.GetObject()->GetBoundingBox(); } -CFX_FloatRect CPDF_Path::GetBoundingBox(FX_FLOAT line_width, - FX_FLOAT miter_limit) const { +CFX_FloatRect CPDF_Path::GetBoundingBox(float line_width, + float miter_limit) const { return m_Ref.GetObject()->GetBoundingBox(line_width, miter_limit); } @@ -49,10 +49,7 @@ void CPDF_Path::Append(const CFX_PathData* pData, const CFX_Matrix* pMatrix) { m_Ref.GetPrivateCopy()->Append(pData, pMatrix); } -void CPDF_Path::AppendRect(FX_FLOAT left, - FX_FLOAT bottom, - FX_FLOAT right, - FX_FLOAT top) { +void CPDF_Path::AppendRect(float left, float bottom, float right, float top) { m_Ref.GetPrivateCopy()->AppendRect(left, bottom, right, top); } diff --git a/core/fpdfapi/page/cpdf_path.h b/core/fpdfapi/page/cpdf_path.h index b0c5a68a44..84b844e798 100644 --- a/core/fpdfapi/page/cpdf_path.h +++ b/core/fpdfapi/page/cpdf_path.h @@ -29,14 +29,14 @@ class CPDF_Path { CFX_PointF GetPoint(int index) const; CFX_FloatRect GetBoundingBox() const; - CFX_FloatRect GetBoundingBox(FX_FLOAT line_width, FX_FLOAT miter_limit) const; + CFX_FloatRect GetBoundingBox(float line_width, float miter_limit) const; bool IsRect() const; void Transform(const CFX_Matrix* pMatrix); void Append(const CPDF_Path& other, const CFX_Matrix* pMatrix); void Append(const CFX_PathData* pData, const CFX_Matrix* pMatrix); - void AppendRect(FX_FLOAT left, FX_FLOAT bottom, FX_FLOAT right, FX_FLOAT top); + void AppendRect(float left, float bottom, float right, float top); void AppendPoint(const CFX_PointF& point, FXPT_TYPE type, bool close); // TODO(tsepez): Remove when all access thru this class. diff --git a/core/fpdfapi/page/cpdf_pathobject.cpp b/core/fpdfapi/page/cpdf_pathobject.cpp index b5bb89390c..1dd0a88f78 100644 --- a/core/fpdfapi/page/cpdf_pathobject.cpp +++ b/core/fpdfapi/page/cpdf_pathobject.cpp @@ -35,7 +35,7 @@ void CPDF_PathObject::CalcBoundingBox() { if (!m_Path) return; CFX_FloatRect rect; - FX_FLOAT width = m_GraphState.GetLineWidth(); + float width = m_GraphState.GetLineWidth(); if (m_bStroke && width != 0) { rect = m_Path.GetBoundingBox(width, m_GraphState.GetMiterLimit()); } else { diff --git a/core/fpdfapi/page/cpdf_psengine.h b/core/fpdfapi/page/cpdf_psengine.h index eba3e9bbf2..607d81065d 100644 --- a/core/fpdfapi/page/cpdf_psengine.h +++ b/core/fpdfapi/page/cpdf_psengine.h @@ -87,12 +87,12 @@ class CPDF_PSEngine { bool Execute(); bool DoOperator(PDF_PSOP op); void Reset() { m_StackCount = 0; } - void Push(FX_FLOAT value); - FX_FLOAT Pop(); + void Push(float value); + float Pop(); uint32_t GetStackSize() const { return m_StackCount; } private: - FX_FLOAT m_Stack[PSENGINE_STACKSIZE]; + float m_Stack[PSENGINE_STACKSIZE]; uint32_t m_StackCount; CPDF_PSProc m_MainProc; }; diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp index fe277f2839..798b9d4f4e 100644 --- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp +++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp @@ -415,7 +415,7 @@ CFX_ByteString CPDF_StreamContentParser::GetString(uint32_t index) { return CFX_ByteString(); } -FX_FLOAT CPDF_StreamContentParser::GetNumber(uint32_t index) { +float CPDF_StreamContentParser::GetNumber(uint32_t index) { if (index >= m_ParamCount) { return 0; } @@ -425,7 +425,7 @@ FX_FLOAT CPDF_StreamContentParser::GetNumber(uint32_t index) { } ContentParam& param = m_ParamBuf[real_index]; if (param.m_Type == ContentParam::NUMBER) { - return param.m_Number.m_bInteger ? (FX_FLOAT)param.m_Number.m_Integer + return param.m_Number.m_bInteger ? (float)param.m_Number.m_Integer : param.m_Number.m_Float; } if (param.m_Type == 0 && param.m_pObject) { @@ -864,13 +864,13 @@ void CPDF_StreamContentParser::Handle_EOFillPath() { } void CPDF_StreamContentParser::Handle_SetGray_Fill() { - FX_FLOAT value = GetNumber(0); + float value = GetNumber(0); CPDF_ColorSpace* pCS = CPDF_ColorSpace::GetStockCS(PDFCS_DEVICEGRAY); m_pCurStates->m_ColorState.SetFillColor(pCS, &value, 1); } void CPDF_StreamContentParser::Handle_SetGray_Stroke() { - FX_FLOAT value = GetNumber(0); + float value = GetNumber(0); CPDF_ColorSpace* pCS = CPDF_ColorSpace::GetStockCS(PDFCS_DEVICEGRAY); m_pCurStates->m_ColorState.SetStrokeColor(pCS, &value, 1); } @@ -916,7 +916,7 @@ void CPDF_StreamContentParser::Handle_SetCMYKColor_Fill() { if (m_ParamCount != 4) return; - FX_FLOAT values[4]; + float values[4]; for (int i = 0; i < 4; i++) { values[i] = GetNumber(3 - i); } @@ -928,7 +928,7 @@ void CPDF_StreamContentParser::Handle_SetCMYKColor_Stroke() { if (m_ParamCount != 4) return; - FX_FLOAT values[4]; + float values[4]; for (int i = 0; i < 4; i++) { values[i] = GetNumber(3 - i); } @@ -976,15 +976,12 @@ void CPDF_StreamContentParser::Handle_RestoreGraphState() { } void CPDF_StreamContentParser::Handle_Rectangle() { - FX_FLOAT x = GetNumber(3), y = GetNumber(2); - FX_FLOAT w = GetNumber(1), h = GetNumber(0); + float x = GetNumber(3), y = GetNumber(2); + float w = GetNumber(1), h = GetNumber(0); AddPathRect(x, y, w, h); } -void CPDF_StreamContentParser::AddPathRect(FX_FLOAT x, - FX_FLOAT y, - FX_FLOAT w, - FX_FLOAT h) { +void CPDF_StreamContentParser::AddPathRect(float x, float y, float w, float h) { AddPathPoint(x, y, FXPT_TYPE::MoveTo, false); AddPathPoint(x + w, y, FXPT_TYPE::LineTo, false); AddPathPoint(x + w, y + h, FXPT_TYPE::LineTo, false); @@ -996,7 +993,7 @@ void CPDF_StreamContentParser::Handle_SetRGBColor_Fill() { if (m_ParamCount != 3) return; - FX_FLOAT values[3]; + float values[3]; for (int i = 0; i < 3; i++) { values[i] = GetNumber(2 - i); } @@ -1008,7 +1005,7 @@ void CPDF_StreamContentParser::Handle_SetRGBColor_Stroke() { if (m_ParamCount != 3) return; - FX_FLOAT values[3]; + float values[3]; for (int i = 0; i < 3; i++) { values[i] = GetNumber(2 - i); } @@ -1028,7 +1025,7 @@ void CPDF_StreamContentParser::Handle_StrokePath() { } void CPDF_StreamContentParser::Handle_SetColor_Fill() { - FX_FLOAT values[4]; + float values[4]; int nargs = m_ParamCount; if (nargs > 4) { nargs = 4; @@ -1040,7 +1037,7 @@ void CPDF_StreamContentParser::Handle_SetColor_Fill() { } void CPDF_StreamContentParser::Handle_SetColor_Stroke() { - FX_FLOAT values[4]; + float values[4]; int nargs = m_ParamCount; if (nargs > 4) { nargs = 4; @@ -1060,9 +1057,9 @@ void CPDF_StreamContentParser::Handle_SetColorPS_Fill() { uint32_t nvalues = nargs; if (pLastParam->IsName()) nvalues--; - FX_FLOAT* values = nullptr; + float* values = nullptr; if (nvalues) { - values = FX_Alloc(FX_FLOAT, nvalues); + values = FX_Alloc(float, nvalues); for (uint32_t i = 0; i < nvalues; i++) { values[i] = GetNumber(nargs - i - 1); } @@ -1088,9 +1085,9 @@ void CPDF_StreamContentParser::Handle_SetColorPS_Stroke() { if (pLastParam->IsName()) nvalues--; - FX_FLOAT* values = nullptr; + float* values = nullptr; if (nvalues) { - values = FX_Alloc(FX_FLOAT, nvalues); + values = FX_Alloc(float, nvalues); for (int i = 0; i < nvalues; i++) { values[i] = GetNumber(nargs - i - 1); } @@ -1149,7 +1146,7 @@ void CPDF_StreamContentParser::Handle_MoveTextPoint_SetLeading() { } void CPDF_StreamContentParser::Handle_SetFont() { - FX_FLOAT fs = GetNumber(0); + float fs = GetNumber(0); if (fs == 0) { fs = m_DefFontSize; } @@ -1231,8 +1228,8 @@ CPDF_Pattern* CPDF_StreamContentParser::FindPattern(const CFX_ByteString& name, } void CPDF_StreamContentParser::AddTextObject(CFX_ByteString* pStrs, - FX_FLOAT fInitKerning, - FX_FLOAT* pKerning, + float fInitKerning, + float* pKerning, int nsegs) { CPDF_Font* pFont = m_pCurStates->m_TextState.GetFont(); if (!pFont) { @@ -1260,7 +1257,7 @@ void CPDF_StreamContentParser::AddTextObject(CFX_ByteString* pStrs, m_pLastTextObject = pText.get(); SetGraphicStates(m_pLastTextObject, true, true, true); if (TextRenderingModeIsStrokeMode(text_mode)) { - FX_FLOAT* pCTM = pText->m_TextState.GetMutableCTM(); + float* pCTM = pText->m_TextState.GetMutableCTM(); pCTM[0] = m_pCurStates->m_CTM.a; pCTM[1] = m_pCurStates->m_CTM.c; pCTM[2] = m_pCurStates->m_CTM.b; @@ -1323,9 +1320,9 @@ void CPDF_StreamContentParser::Handle_ShowText_Positioning() { return; } CFX_ByteString* pStrs = new CFX_ByteString[nsegs]; - FX_FLOAT* pKerning = FX_Alloc(FX_FLOAT, nsegs); + float* pKerning = FX_Alloc(float, nsegs); size_t iSegment = 0; - FX_FLOAT fInitKerning = 0; + float fInitKerning = 0; for (size_t i = 0; i < n; i++) { CPDF_Object* pObj = pArray->GetDirectObjectAt(i); if (pObj->IsString()) { @@ -1336,7 +1333,7 @@ void CPDF_StreamContentParser::Handle_ShowText_Positioning() { pStrs[iSegment] = str; pKerning[iSegment++] = 0; } else { - FX_FLOAT num = pObj ? pObj->GetNumber() : 0; + float num = pObj ? pObj->GetNumber() : 0; if (iSegment == 0) { fInitKerning += num; } else { @@ -1368,7 +1365,7 @@ void CPDF_StreamContentParser::OnChangeTextMatrix() { text_matrix.Concat(m_pCurStates->m_TextMatrix); text_matrix.Concat(m_pCurStates->m_CTM); text_matrix.Concat(m_mtContentToUser); - FX_FLOAT* pTextMatrix = m_pCurStates->m_TextState.GetMutableMatrix(); + float* pTextMatrix = m_pCurStates->m_TextState.GetMutableMatrix(); pTextMatrix[0] = text_matrix.a; pTextMatrix[1] = text_matrix.c; pTextMatrix[2] = text_matrix.b; @@ -1439,8 +1436,8 @@ void CPDF_StreamContentParser::Handle_NextLineShowText_Space() { void CPDF_StreamContentParser::Handle_Invalid() {} -void CPDF_StreamContentParser::AddPathPoint(FX_FLOAT x, - FX_FLOAT y, +void CPDF_StreamContentParser::AddPathPoint(float x, + float y, FXPT_TYPE type, bool close) { m_PathCurrentX = x; @@ -1553,7 +1550,7 @@ uint32_t CPDF_StreamContentParser::Parse(const uint8_t* pData, } void CPDF_StreamContentParser::ParsePathObject() { - FX_FLOAT params[6] = {}; + float params[6] = {}; int nParams = 0; int last_pos = m_pSyntax->GetPos(); while (1) { @@ -1624,7 +1621,7 @@ void CPDF_StreamContentParser::ParsePathObject() { int value; bool bInteger = FX_atonum(m_pSyntax->GetWord(), &value); - params[nParams++] = bInteger ? (FX_FLOAT)value : *(FX_FLOAT*)&value; + params[nParams++] = bInteger ? (float)value : *(float*)&value; break; } default: diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.h b/core/fpdfapi/page/cpdf_streamcontentparser.h index cd41990b0a..6cfc2731a9 100644 --- a/core/fpdfapi/page/cpdf_streamcontentparser.h +++ b/core/fpdfapi/page/cpdf_streamcontentparser.h @@ -46,7 +46,7 @@ class CPDF_StreamContentParser { CPDF_PageObjectHolder* GetPageObjectHolder() const { return m_pObjectHolder; } CPDF_AllStates* GetCurStates() const { return m_pCurStates.get(); } bool IsColored() const { return m_bColored; } - const FX_FLOAT* GetType3Data() const { return m_Type3Data; } + const float* GetType3Data() const { return m_Type3Data; } CPDF_Font* FindFont(const CFX_ByteString& name); private: @@ -62,7 +62,7 @@ class CPDF_StreamContentParser { bool m_bInteger; union { int m_Integer; - FX_FLOAT m_Float; + float m_Float; }; } m_Number; struct { @@ -84,18 +84,18 @@ class CPDF_StreamContentParser { void ClearAllParams(); CPDF_Object* GetObject(uint32_t index); CFX_ByteString GetString(uint32_t index); - FX_FLOAT GetNumber(uint32_t index); + float GetNumber(uint32_t index); int GetInteger(uint32_t index) { return (int32_t)(GetNumber(index)); } void OnOperator(const CFX_ByteStringC& op); void AddTextObject(CFX_ByteString* pText, - FX_FLOAT fInitKerning, - FX_FLOAT* pKerning, + float fInitKerning, + float* pKerning, int count); void OnChangeTextMatrix(); void ParsePathObject(); - void AddPathPoint(FX_FLOAT x, FX_FLOAT y, FXPT_TYPE type, bool close); - void AddPathRect(FX_FLOAT x, FX_FLOAT y, FX_FLOAT w, FX_FLOAT h); + void AddPathPoint(float x, float y, FXPT_TYPE type, bool close); + void AddPathRect(float x, float y, float w, float h); void AddPathObject(int FillType, bool bStroke); CPDF_ImageObject* AddImage(std::unique_ptr<CPDF_Stream> pStream); CPDF_ImageObject* AddImage(uint32_t streamObjNum); @@ -203,19 +203,19 @@ class CPDF_StreamContentParser { CPDF_ContentMark m_CurContentMark; std::vector<std::unique_ptr<CPDF_TextObject>> m_ClipTextList; CPDF_TextObject* m_pLastTextObject; - FX_FLOAT m_DefFontSize; + float m_DefFontSize; FX_PATHPOINT* m_pPathPoints; int m_PathPointCount; int m_PathAllocSize; - FX_FLOAT m_PathStartX; - FX_FLOAT m_PathStartY; - FX_FLOAT m_PathCurrentX; - FX_FLOAT m_PathCurrentY; + float m_PathStartX; + float m_PathStartY; + float m_PathCurrentX; + float m_PathCurrentY; uint8_t m_PathClipType; CFX_ByteString m_LastImageName; CPDF_Image* m_pLastImage; bool m_bColored; - FX_FLOAT m_Type3Data[6]; + float m_Type3Data[6]; bool m_bResourceMissing; std::vector<std::unique_ptr<CPDF_AllStates>> m_StateStack; }; diff --git a/core/fpdfapi/page/cpdf_textobject.cpp b/core/fpdfapi/page/cpdf_textobject.cpp index 1c940bc057..b8f3f61073 100644 --- a/core/fpdfapi/page/cpdf_textobject.cpp +++ b/core/fpdfapi/page/cpdf_textobject.cpp @@ -44,7 +44,7 @@ void CPDF_TextObject::GetItemInfo(int index, CPDF_TextObjectItem* pInfo) const { short vy; pFont->AsCIDFont()->GetVertOrigin(CID, vx, vy); - FX_FLOAT fontsize = m_TextState.GetFontSize(); + float fontsize = m_TextState.GetFontSize(); pInfo->m_Origin.x -= fontsize * vx / 1000; pInfo->m_Origin.y -= fontsize * vy / 1000; } @@ -60,7 +60,7 @@ int CPDF_TextObject::CountChars() const { void CPDF_TextObject::GetCharInfo(int index, uint32_t* charcode, - FX_FLOAT* kerning) const { + float* kerning) const { int count = 0; for (size_t i = 0; i < m_CharCodes.size(); ++i) { if (m_CharCodes[i] == CPDF_Font::kInvalidCharCode) @@ -108,7 +108,7 @@ void CPDF_TextObject::Transform(const CFX_Matrix& matrix) { CFX_Matrix text_matrix = GetTextMatrix(); text_matrix.Concat(matrix); - FX_FLOAT* pTextMatrix = m_TextState.GetMutableMatrix(); + float* pTextMatrix = m_TextState.GetMutableMatrix(); pTextMatrix[0] = text_matrix.a; pTextMatrix[1] = text_matrix.c; pTextMatrix[2] = text_matrix.b; @@ -130,13 +130,13 @@ const CPDF_TextObject* CPDF_TextObject::AsText() const { } CFX_Matrix CPDF_TextObject::GetTextMatrix() const { - const FX_FLOAT* pTextMatrix = m_TextState.GetMatrix(); + const float* pTextMatrix = m_TextState.GetMatrix(); return CFX_Matrix(pTextMatrix[0], pTextMatrix[2], pTextMatrix[1], pTextMatrix[3], m_Pos.x, m_Pos.y); } void CPDF_TextObject::SetSegments(const CFX_ByteString* pStrs, - const FX_FLOAT* pKerning, + const float* pKerning, int nsegs) { m_CharCodes.clear(); m_CharPos.clear(); @@ -166,8 +166,8 @@ void CPDF_TextObject::SetText(const CFX_ByteString& str) { RecalcPositionData(); } -FX_FLOAT CPDF_TextObject::GetCharWidth(uint32_t charcode) const { - FX_FLOAT fontsize = m_TextState.GetFontSize() / 1000; +float CPDF_TextObject::GetCharWidth(uint32_t charcode) const { + float fontsize = m_TextState.GetFontSize() / 1000; CPDF_Font* pFont = m_TextState.GetFont(); bool bVertWriting = false; CPDF_CIDFont* pCIDFont = pFont->AsCIDFont(); @@ -184,23 +184,23 @@ CPDF_Font* CPDF_TextObject::GetFont() const { return m_TextState.GetFont(); } -FX_FLOAT CPDF_TextObject::GetFontSize() const { +float CPDF_TextObject::GetFontSize() const { return m_TextState.GetFontSize(); } -CFX_PointF CPDF_TextObject::CalcPositionData(FX_FLOAT horz_scale) { - FX_FLOAT curpos = 0; - FX_FLOAT min_x = 10000 * 1.0f; - FX_FLOAT max_x = -10000 * 1.0f; - FX_FLOAT min_y = 10000 * 1.0f; - FX_FLOAT max_y = -10000 * 1.0f; +CFX_PointF CPDF_TextObject::CalcPositionData(float horz_scale) { + float curpos = 0; + float min_x = 10000 * 1.0f; + float max_x = -10000 * 1.0f; + float min_y = 10000 * 1.0f; + float max_y = -10000 * 1.0f; CPDF_Font* pFont = m_TextState.GetFont(); bool bVertWriting = false; CPDF_CIDFont* pCIDFont = pFont->AsCIDFont(); if (pCIDFont) bVertWriting = pCIDFont->IsVertWriting(); - FX_FLOAT fontsize = m_TextState.GetFontSize(); + float fontsize = m_TextState.GetFontSize(); for (int i = 0; i < pdfium::CollectionSize<int>(m_CharCodes); ++i) { uint32_t charcode = m_CharCodes[i]; if (i > 0) { @@ -212,14 +212,14 @@ CFX_PointF CPDF_TextObject::CalcPositionData(FX_FLOAT horz_scale) { } FX_RECT char_rect = pFont->GetCharBBox(charcode); - FX_FLOAT charwidth; + float charwidth; if (!bVertWriting) { - min_y = std::min(min_y, static_cast<FX_FLOAT>( - std::min(char_rect.top, char_rect.bottom))); - max_y = std::max(max_y, static_cast<FX_FLOAT>( - std::max(char_rect.top, char_rect.bottom))); - FX_FLOAT char_left = curpos + char_rect.left * fontsize / 1000; - FX_FLOAT char_right = curpos + char_rect.right * fontsize / 1000; + min_y = std::min( + min_y, static_cast<float>(std::min(char_rect.top, char_rect.bottom))); + max_y = std::max( + max_y, static_cast<float>(std::max(char_rect.top, char_rect.bottom))); + float char_left = curpos + char_rect.left * fontsize / 1000; + float char_right = curpos + char_rect.right * fontsize / 1000; min_x = std::min(min_x, std::min(char_left, char_right)); max_x = std::max(max_x, std::max(char_left, char_right)); charwidth = pFont->GetCharWidthF(charcode) * fontsize / 1000; @@ -232,12 +232,12 @@ CFX_PointF CPDF_TextObject::CalcPositionData(FX_FLOAT horz_scale) { char_rect.right -= vx; char_rect.top -= vy; char_rect.bottom -= vy; - min_x = std::min(min_x, static_cast<FX_FLOAT>( - std::min(char_rect.left, char_rect.right))); - max_x = std::max(max_x, static_cast<FX_FLOAT>( - std::max(char_rect.left, char_rect.right))); - FX_FLOAT char_top = curpos + char_rect.top * fontsize / 1000; - FX_FLOAT char_bottom = curpos + char_rect.bottom * fontsize / 1000; + min_x = std::min( + min_x, static_cast<float>(std::min(char_rect.left, char_rect.right))); + max_x = std::max( + max_x, static_cast<float>(std::max(char_rect.left, char_rect.right))); + float char_top = curpos + char_rect.top * fontsize / 1000; + float char_bottom = curpos + char_rect.bottom * fontsize / 1000; min_y = std::min(min_y, std::min(char_top, char_bottom)); max_y = std::max(max_y, std::max(char_top, char_bottom)); charwidth = pCIDFont->GetVertWidth(CID) * fontsize / 1000; @@ -269,7 +269,7 @@ CFX_PointF CPDF_TextObject::CalcPositionData(FX_FLOAT horz_scale) { if (!TextRenderingModeIsStrokeMode(m_TextState.GetTextMode())) return ret; - FX_FLOAT half_width = m_GraphState.GetLineWidth() / 2; + float half_width = m_GraphState.GetLineWidth() / 2; m_Left -= half_width; m_Right += half_width; m_Top += half_width; @@ -278,9 +278,9 @@ CFX_PointF CPDF_TextObject::CalcPositionData(FX_FLOAT horz_scale) { return ret; } -void CPDF_TextObject::SetPosition(FX_FLOAT x, FX_FLOAT y) { - FX_FLOAT dx = x - m_Pos.x; - FX_FLOAT dy = y - m_Pos.y; +void CPDF_TextObject::SetPosition(float x, float y) { + float dx = x - m_Pos.x; + float dy = y - m_Pos.y; m_Pos.x = x; m_Pos.y = y; m_Left += dx; diff --git a/core/fpdfapi/page/cpdf_textobject.h b/core/fpdfapi/page/cpdf_textobject.h index 59da718f62..e08b7280de 100644 --- a/core/fpdfapi/page/cpdf_textobject.h +++ b/core/fpdfapi/page/cpdf_textobject.h @@ -39,16 +39,16 @@ class CPDF_TextObject : public CPDF_PageObject { int CountItems() const; void GetItemInfo(int index, CPDF_TextObjectItem* pInfo) const; int CountChars() const; - void GetCharInfo(int index, uint32_t* charcode, FX_FLOAT* kerning) const; + void GetCharInfo(int index, uint32_t* charcode, float* kerning) const; void GetCharInfo(int index, CPDF_TextObjectItem* pInfo) const; - FX_FLOAT GetCharWidth(uint32_t charcode) const; + float GetCharWidth(uint32_t charcode) const; CFX_PointF GetPos() const { return m_Pos; } CFX_Matrix GetTextMatrix() const; CPDF_Font* GetFont() const; - FX_FLOAT GetFontSize() const; + float GetFontSize() const; void SetText(const CFX_ByteString& text); - void SetPosition(FX_FLOAT x, FX_FLOAT y); + void SetPosition(float x, float y); void RecalcPositionData(); @@ -59,14 +59,14 @@ class CPDF_TextObject : public CPDF_PageObject { friend class CPDF_PageContentGenerator; void SetSegments(const CFX_ByteString* pStrs, - const FX_FLOAT* pKerning, + const float* pKerning, int nSegs); - CFX_PointF CalcPositionData(FX_FLOAT horz_scale); + CFX_PointF CalcPositionData(float horz_scale); CFX_PointF m_Pos; std::vector<uint32_t> m_CharCodes; - std::vector<FX_FLOAT> m_CharPos; + std::vector<float> m_CharPos; }; #endif // CORE_FPDFAPI_PAGE_CPDF_TEXTOBJECT_H_ diff --git a/core/fpdfapi/page/cpdf_textstate.cpp b/core/fpdfapi/page/cpdf_textstate.cpp index 990c9cc311..520cb7365b 100644 --- a/core/fpdfapi/page/cpdf_textstate.cpp +++ b/core/fpdfapi/page/cpdf_textstate.cpp @@ -25,51 +25,51 @@ void CPDF_TextState::SetFont(CPDF_Font* pFont) { m_Ref.GetPrivateCopy()->SetFont(pFont); } -FX_FLOAT CPDF_TextState::GetFontSize() const { +float CPDF_TextState::GetFontSize() const { return m_Ref.GetObject()->m_FontSize; } -void CPDF_TextState::SetFontSize(FX_FLOAT size) { +void CPDF_TextState::SetFontSize(float size) { m_Ref.GetPrivateCopy()->m_FontSize = size; } -const FX_FLOAT* CPDF_TextState::GetMatrix() const { +const float* CPDF_TextState::GetMatrix() const { return m_Ref.GetObject()->m_Matrix; } -FX_FLOAT* CPDF_TextState::GetMutableMatrix() { +float* CPDF_TextState::GetMutableMatrix() { return m_Ref.GetPrivateCopy()->m_Matrix; } -FX_FLOAT CPDF_TextState::GetCharSpace() const { +float CPDF_TextState::GetCharSpace() const { return m_Ref.GetObject()->m_CharSpace; } -void CPDF_TextState::SetCharSpace(FX_FLOAT sp) { +void CPDF_TextState::SetCharSpace(float sp) { m_Ref.GetPrivateCopy()->m_CharSpace = sp; } -FX_FLOAT CPDF_TextState::GetWordSpace() const { +float CPDF_TextState::GetWordSpace() const { return m_Ref.GetObject()->m_WordSpace; } -void CPDF_TextState::SetWordSpace(FX_FLOAT sp) { +void CPDF_TextState::SetWordSpace(float sp) { m_Ref.GetPrivateCopy()->m_WordSpace = sp; } -FX_FLOAT CPDF_TextState::GetFontSizeV() const { +float CPDF_TextState::GetFontSizeV() const { return m_Ref.GetObject()->GetFontSizeV(); } -FX_FLOAT CPDF_TextState::GetFontSizeH() const { +float CPDF_TextState::GetFontSizeH() const { return m_Ref.GetObject()->GetFontSizeH(); } -FX_FLOAT CPDF_TextState::GetBaselineAngle() const { +float CPDF_TextState::GetBaselineAngle() const { return m_Ref.GetObject()->GetBaselineAngle(); } -FX_FLOAT CPDF_TextState::GetShearAngle() const { +float CPDF_TextState::GetShearAngle() const { return m_Ref.GetObject()->GetShearAngle(); } @@ -81,11 +81,11 @@ void CPDF_TextState::SetTextMode(TextRenderingMode mode) { m_Ref.GetPrivateCopy()->m_TextMode = mode; } -const FX_FLOAT* CPDF_TextState::GetCTM() const { +const float* CPDF_TextState::GetCTM() const { return m_Ref.GetObject()->m_CTM; } -FX_FLOAT* CPDF_TextState::GetMutableCTM() { +float* CPDF_TextState::GetMutableCTM() { return m_Ref.GetPrivateCopy()->m_CTM; } @@ -138,19 +138,19 @@ void CPDF_TextState::TextData::SetFont(CPDF_Font* pFont) { m_pFont = pFont; } -FX_FLOAT CPDF_TextState::TextData::GetFontSizeV() const { +float CPDF_TextState::TextData::GetFontSizeV() const { return FXSYS_fabs(FXSYS_sqrt2(m_Matrix[1], m_Matrix[3]) * m_FontSize); } -FX_FLOAT CPDF_TextState::TextData::GetFontSizeH() const { +float CPDF_TextState::TextData::GetFontSizeH() const { return FXSYS_fabs(FXSYS_sqrt2(m_Matrix[0], m_Matrix[2]) * m_FontSize); } -FX_FLOAT CPDF_TextState::TextData::GetBaselineAngle() const { +float CPDF_TextState::TextData::GetBaselineAngle() const { return FXSYS_atan2(m_Matrix[2], m_Matrix[0]); } -FX_FLOAT CPDF_TextState::TextData::GetShearAngle() const { +float CPDF_TextState::TextData::GetShearAngle() const { return GetBaselineAngle() + FXSYS_atan2(m_Matrix[1], m_Matrix[3]); } diff --git a/core/fpdfapi/page/cpdf_textstate.h b/core/fpdfapi/page/cpdf_textstate.h index 4723469fd9..07bee5ed04 100644 --- a/core/fpdfapi/page/cpdf_textstate.h +++ b/core/fpdfapi/page/cpdf_textstate.h @@ -35,28 +35,28 @@ class CPDF_TextState { CPDF_Font* GetFont() const; void SetFont(CPDF_Font* pFont); - FX_FLOAT GetFontSize() const; - void SetFontSize(FX_FLOAT size); + float GetFontSize() const; + void SetFontSize(float size); - const FX_FLOAT* GetMatrix() const; - FX_FLOAT* GetMutableMatrix(); + const float* GetMatrix() const; + float* GetMutableMatrix(); - FX_FLOAT GetCharSpace() const; - void SetCharSpace(FX_FLOAT sp); + float GetCharSpace() const; + void SetCharSpace(float sp); - FX_FLOAT GetWordSpace() const; - void SetWordSpace(FX_FLOAT sp); + float GetWordSpace() const; + void SetWordSpace(float sp); - FX_FLOAT GetFontSizeV() const; - FX_FLOAT GetFontSizeH() const; - FX_FLOAT GetBaselineAngle() const; - FX_FLOAT GetShearAngle() const; + float GetFontSizeV() const; + float GetFontSizeH() const; + float GetBaselineAngle() const; + float GetShearAngle() const; TextRenderingMode GetTextMode() const; void SetTextMode(TextRenderingMode mode); - const FX_FLOAT* GetCTM() const; - FX_FLOAT* GetMutableCTM(); + const float* GetCTM() const; + float* GetMutableCTM(); private: class TextData { @@ -66,19 +66,19 @@ class CPDF_TextState { ~TextData(); void SetFont(CPDF_Font* pFont); - FX_FLOAT GetFontSizeV() const; - FX_FLOAT GetFontSizeH() const; - FX_FLOAT GetBaselineAngle() const; - FX_FLOAT GetShearAngle() const; + float GetFontSizeV() const; + float GetFontSizeH() const; + float GetBaselineAngle() const; + float GetShearAngle() const; CPDF_Font* m_pFont; CPDF_Document* m_pDocument; - FX_FLOAT m_FontSize; - FX_FLOAT m_CharSpace; - FX_FLOAT m_WordSpace; + float m_FontSize; + float m_CharSpace; + float m_WordSpace; TextRenderingMode m_TextMode; - FX_FLOAT m_Matrix[4]; - FX_FLOAT m_CTM[4]; + float m_Matrix[4]; + float m_CTM[4]; }; CFX_SharedCopyOnWrite<TextData> m_Ref; diff --git a/core/fpdfapi/page/cpdf_tilingpattern.cpp b/core/fpdfapi/page/cpdf_tilingpattern.cpp index a041f38074..fb46dd2b3e 100644 --- a/core/fpdfapi/page/cpdf_tilingpattern.cpp +++ b/core/fpdfapi/page/cpdf_tilingpattern.cpp @@ -41,8 +41,8 @@ bool CPDF_TilingPattern::Load() { return false; m_bColored = pDict->GetIntegerFor("PaintType") == 1; - m_XStep = (FX_FLOAT)FXSYS_fabs(pDict->GetNumberFor("XStep")); - m_YStep = (FX_FLOAT)FXSYS_fabs(pDict->GetNumberFor("YStep")); + m_XStep = (float)FXSYS_fabs(pDict->GetNumberFor("XStep")); + m_YStep = (float)FXSYS_fabs(pDict->GetNumberFor("YStep")); CPDF_Stream* pStream = m_pPatternObj->AsStream(); if (!pStream) diff --git a/core/fpdfapi/page/cpdf_tilingpattern.h b/core/fpdfapi/page/cpdf_tilingpattern.h index 3f0851aa7e..d9450d7c2f 100644 --- a/core/fpdfapi/page/cpdf_tilingpattern.h +++ b/core/fpdfapi/page/cpdf_tilingpattern.h @@ -31,15 +31,15 @@ class CPDF_TilingPattern : public CPDF_Pattern { bool colored() const { return m_bColored; } const CFX_FloatRect& bbox() const { return m_BBox; } - FX_FLOAT x_step() const { return m_XStep; } - FX_FLOAT y_step() const { return m_YStep; } + float x_step() const { return m_XStep; } + float y_step() const { return m_YStep; } CPDF_Form* form() const { return m_pForm.get(); } private: bool m_bColored; CFX_FloatRect m_BBox; - FX_FLOAT m_XStep; - FX_FLOAT m_YStep; + float m_XStep; + float m_YStep; std::unique_ptr<CPDF_Form> m_pForm; }; diff --git a/core/fpdfapi/page/fpdf_page_colors.cpp b/core/fpdfapi/page/fpdf_page_colors.cpp index 54b61df975..8964a18cdb 100644 --- a/core/fpdfapi/page/fpdf_page_colors.cpp +++ b/core/fpdfapi/page/fpdf_page_colors.cpp @@ -21,7 +21,7 @@ namespace { -FX_FLOAT NormalizeChannel(FX_FLOAT fVal) { +float NormalizeChannel(float fVal) { return std::min(std::max(fVal, 0.0f), 1.0f); } @@ -36,13 +36,13 @@ uint32_t ComponentsForFamily(int family) { return 4; } -void sRGB_to_AdobeCMYK(FX_FLOAT R, - FX_FLOAT G, - FX_FLOAT B, - FX_FLOAT& c, - FX_FLOAT& m, - FX_FLOAT& y, - FX_FLOAT& k) { +void sRGB_to_AdobeCMYK(float R, + float G, + float B, + float& c, + float& m, + float& y, + float& k) { c = 1.0f - R; m = 1.0f - G; y = 1.0f - B; @@ -73,10 +73,7 @@ CPDF_DeviceCS::CPDF_DeviceCS(CPDF_Document* pDoc, int family) family == PDFCS_DEVICECMYK); } -bool CPDF_DeviceCS::GetRGB(FX_FLOAT* pBuf, - FX_FLOAT& R, - FX_FLOAT& G, - FX_FLOAT& B) const { +bool CPDF_DeviceCS::GetRGB(float* pBuf, float& R, float& G, float& B) const { switch (m_Family) { case PDFCS_DEVICEGRAY: R = NormalizeChannel(*pBuf); @@ -90,7 +87,7 @@ bool CPDF_DeviceCS::GetRGB(FX_FLOAT* pBuf, break; case PDFCS_DEVICECMYK: if (m_dwStdConversion) { - FX_FLOAT k = pBuf[3]; + float k = pBuf[3]; R = 1.0f - std::min(1.0f, pBuf[0] + k); G = 1.0f - std::min(1.0f, pBuf[1] + k); B = 1.0f - std::min(1.0f, pBuf[2] + k); @@ -107,11 +104,11 @@ bool CPDF_DeviceCS::GetRGB(FX_FLOAT* pBuf, return true; } -bool CPDF_DeviceCS::v_GetCMYK(FX_FLOAT* pBuf, - FX_FLOAT& c, - FX_FLOAT& m, - FX_FLOAT& y, - FX_FLOAT& k) const { +bool CPDF_DeviceCS::v_GetCMYK(float* pBuf, + float& c, + float& m, + float& y, + float& k) const { if (m_Family != PDFCS_DEVICECMYK) return false; @@ -122,10 +119,7 @@ bool CPDF_DeviceCS::v_GetCMYK(FX_FLOAT* pBuf, return true; } -bool CPDF_DeviceCS::SetRGB(FX_FLOAT* pBuf, - FX_FLOAT R, - FX_FLOAT G, - FX_FLOAT B) const { +bool CPDF_DeviceCS::SetRGB(float* pBuf, float R, float G, float B) const { switch (m_Family) { case PDFCS_DEVICEGRAY: if (R != G || R != B) @@ -146,11 +140,11 @@ bool CPDF_DeviceCS::SetRGB(FX_FLOAT* pBuf, } } -bool CPDF_DeviceCS::v_SetCMYK(FX_FLOAT* pBuf, - FX_FLOAT c, - FX_FLOAT m, - FX_FLOAT y, - FX_FLOAT k) const { +bool CPDF_DeviceCS::v_SetCMYK(float* pBuf, + float c, + float m, + float y, + float k) const { switch (m_Family) { case PDFCS_DEVICEGRAY: return false; diff --git a/core/fpdfapi/page/fpdf_page_func.cpp b/core/fpdfapi/page/fpdf_page_func.cpp index 9c0cc945b3..8e918f2526 100644 --- a/core/fpdfapi/page/fpdf_page_func.cpp +++ b/core/fpdfapi/page/fpdf_page_func.cpp @@ -70,12 +70,8 @@ bool IsValidBitsPerSample(uint32_t x) { } // See PDF Reference 1.7, page 170. -FX_FLOAT PDF_Interpolate(FX_FLOAT x, - FX_FLOAT xmin, - FX_FLOAT xmax, - FX_FLOAT ymin, - FX_FLOAT ymax) { - FX_FLOAT divisor = xmax - xmin; +float PDF_Interpolate(float x, float xmin, float xmax, float ymin, float ymax) { + float divisor = xmax - xmin; return ymin + (divisor ? (x - xmin) * (ymax - ymin) / divisor : 0); } @@ -86,7 +82,7 @@ class CPDF_PSFunc : public CPDF_Function { // CPDF_Function bool v_Init(CPDF_Object* pObj) override; - bool v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const override; + bool v_Call(float* inputs, float* results) const override; private: CPDF_PSEngine m_PS; @@ -99,7 +95,7 @@ bool CPDF_PSFunc::v_Init(CPDF_Object* pObj) { acc.GetSize()); } -bool CPDF_PSFunc::v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const { +bool CPDF_PSFunc::v_Call(float* inputs, float* results) const { CPDF_PSEngine& PS = const_cast<CPDF_PSEngine&>(m_PS); PS.Reset(); for (uint32_t i = 0; i < m_nInputs; i++) @@ -120,11 +116,11 @@ class CPDF_PSOP { ASSERT(m_op != PSOP_CONST); ASSERT(m_op != PSOP_PROC); } - explicit CPDF_PSOP(FX_FLOAT value) : m_op(PSOP_CONST), m_value(value) {} + explicit CPDF_PSOP(float value) : m_op(PSOP_CONST), m_value(value) {} explicit CPDF_PSOP(std::unique_ptr<CPDF_PSProc> proc) : m_op(PSOP_PROC), m_value(0), m_proc(std::move(proc)) {} - FX_FLOAT GetFloatValue() const { + float GetFloatValue() const { if (m_op == PSOP_CONST) return m_value; @@ -142,7 +138,7 @@ class CPDF_PSOP { private: const PDF_PSOP m_op; - const FX_FLOAT m_value; + const float m_value; std::unique_ptr<CPDF_PSProc> m_proc; }; @@ -188,13 +184,13 @@ CPDF_PSEngine::CPDF_PSEngine() { m_StackCount = 0; } CPDF_PSEngine::~CPDF_PSEngine() {} -void CPDF_PSEngine::Push(FX_FLOAT v) { +void CPDF_PSEngine::Push(float v) { if (m_StackCount == PSENGINE_STACKSIZE) { return; } m_Stack[m_StackCount++] = v; } -FX_FLOAT CPDF_PSEngine::Pop() { +float CPDF_PSEngine::Pop() { if (m_StackCount == 0) { return 0; } @@ -249,8 +245,8 @@ bool CPDF_PSProc::Parse(CPDF_SimpleParser* parser, int depth) { bool CPDF_PSEngine::DoOperator(PDF_PSOP op) { int i1; int i2; - FX_FLOAT d1; - FX_FLOAT d2; + float d1; + float d2; FX_SAFE_INT32 result; switch (op) { case PSOP_ADD: @@ -301,15 +297,15 @@ bool CPDF_PSEngine::DoOperator(PDF_PSOP op) { break; case PSOP_ABS: d1 = Pop(); - Push((FX_FLOAT)FXSYS_fabs(d1)); + Push((float)FXSYS_fabs(d1)); break; case PSOP_CEILING: d1 = Pop(); - Push((FX_FLOAT)FXSYS_ceil(d1)); + Push((float)FXSYS_ceil(d1)); break; case PSOP_FLOOR: d1 = Pop(); - Push((FX_FLOAT)FXSYS_floor(d1)); + Push((float)FXSYS_floor(d1)); break; case PSOP_ROUND: d1 = Pop(); @@ -321,20 +317,20 @@ bool CPDF_PSEngine::DoOperator(PDF_PSOP op) { break; case PSOP_SQRT: d1 = Pop(); - Push((FX_FLOAT)FXSYS_sqrt(d1)); + Push((float)FXSYS_sqrt(d1)); break; case PSOP_SIN: d1 = Pop(); - Push((FX_FLOAT)FXSYS_sin(d1 * FX_PI / 180.0f)); + Push((float)FXSYS_sin(d1 * FX_PI / 180.0f)); break; case PSOP_COS: d1 = Pop(); - Push((FX_FLOAT)FXSYS_cos(d1 * FX_PI / 180.0f)); + Push((float)FXSYS_cos(d1 * FX_PI / 180.0f)); break; case PSOP_ATAN: d2 = Pop(); d1 = Pop(); - d1 = (FX_FLOAT)(FXSYS_atan2(d1, d2) * 180.0 / FX_PI); + d1 = (float)(FXSYS_atan2(d1, d2) * 180.0 / FX_PI); if (d1 < 0) { d1 += 360; } @@ -343,15 +339,15 @@ bool CPDF_PSEngine::DoOperator(PDF_PSOP op) { case PSOP_EXP: d2 = Pop(); d1 = Pop(); - Push((FX_FLOAT)FXSYS_pow(d1, d2)); + Push((float)FXSYS_pow(d1, d2)); break; case PSOP_LN: d1 = Pop(); - Push((FX_FLOAT)FXSYS_log(d1)); + Push((float)FXSYS_log(d1)); break; case PSOP_LOG: d1 = Pop(); - Push((FX_FLOAT)FXSYS_log10(d1)); + Push((float)FXSYS_log10(d1)); break; case PSOP_CVI: i1 = (int)Pop(); @@ -514,7 +510,7 @@ bool CPDF_SampledFunc::v_Init(CPDF_Object* pObj) { } else { m_EncodeInfo[i].encode_min = 0; m_EncodeInfo[i].encode_max = - m_EncodeInfo[i].sizes == 1 ? 1 : (FX_FLOAT)m_EncodeInfo[i].sizes - 1; + m_EncodeInfo[i].sizes == 1 ? 1 : (float)m_EncodeInfo[i].sizes - 1; } } nTotalSampleBits *= m_nBitsPerSample; @@ -539,10 +535,10 @@ bool CPDF_SampledFunc::v_Init(CPDF_Object* pObj) { return true; } -bool CPDF_SampledFunc::v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const { +bool CPDF_SampledFunc::v_Call(float* inputs, float* results) const { int pos = 0; - CFX_FixedBufGrow<FX_FLOAT, 16> encoded_input_buf(m_nInputs); - FX_FLOAT* encoded_input = encoded_input_buf; + CFX_FixedBufGrow<float, 16> encoded_input_buf(m_nInputs); + float* encoded_input = encoded_input_buf; CFX_FixedBufGrow<uint32_t, 32> int_buf(m_nInputs * 2); uint32_t* index = int_buf; uint32_t* blocksize = index + m_nInputs; @@ -580,11 +576,11 @@ bool CPDF_SampledFunc::v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const { for (uint32_t j = 0; j < m_nOutputs; j++, bitpos += m_nBitsPerSample) { uint32_t sample = GetBits32(pSampleData, bitpos.ValueOrDie(), m_nBitsPerSample); - FX_FLOAT encoded = (FX_FLOAT)sample; + float encoded = (float)sample; for (uint32_t i = 0; i < m_nInputs; i++) { if (index[i] == m_EncodeInfo[i].sizes - 1) { if (index[i] == 0) - encoded = encoded_input[i] * (FX_FLOAT)sample; + encoded = encoded_input[i] * (float)sample; } else { FX_SAFE_INT32 bitpos2 = blocksize[i]; bitpos2 += pos; @@ -595,12 +591,12 @@ bool CPDF_SampledFunc::v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const { return false; uint32_t sample1 = GetBits32(pSampleData, bitpos2.ValueOrDie(), m_nBitsPerSample); - encoded += (encoded_input[i] - index[i]) * - ((FX_FLOAT)sample1 - (FX_FLOAT)sample); + encoded += + (encoded_input[i] - index[i]) * ((float)sample1 - (float)sample); } } results[j] = - PDF_Interpolate(encoded, 0, (FX_FLOAT)m_SampleMax, + PDF_Interpolate(encoded, 0, (float)m_SampleMax, m_DecodeInfo[j].decode_min, m_DecodeInfo[j].decode_max); } return true; @@ -628,8 +624,8 @@ bool CPDF_ExpIntFunc::v_Init(CPDF_Object* pObj) { } } CPDF_Array* pArray1 = pDict->GetArrayFor("C1"); - m_pBeginValues = FX_Alloc2D(FX_FLOAT, m_nOutputs, 2); - m_pEndValues = FX_Alloc2D(FX_FLOAT, m_nOutputs, 2); + m_pBeginValues = FX_Alloc2D(float, m_nOutputs, 2); + m_pEndValues = FX_Alloc2D(float, m_nOutputs, 2); for (uint32_t i = 0; i < m_nOutputs; i++) { m_pBeginValues[i] = pArray0 ? pArray0->GetFloatAt(i) : 0.0f; m_pEndValues[i] = pArray1 ? pArray1->GetFloatAt(i) : 1.0f; @@ -642,12 +638,12 @@ bool CPDF_ExpIntFunc::v_Init(CPDF_Object* pObj) { m_nOutputs *= m_nInputs; return true; } -bool CPDF_ExpIntFunc::v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const { +bool CPDF_ExpIntFunc::v_Call(float* inputs, float* results) const { for (uint32_t i = 0; i < m_nInputs; i++) for (uint32_t j = 0; j < m_nOrigOutputs; j++) { results[i * m_nOrigOutputs + j] = m_pBeginValues[j] + - (FX_FLOAT)FXSYS_pow(inputs[i], m_Exponent) * + (float)FXSYS_pow(inputs[i], m_Exponent) * (m_pEndValues[j] - m_pBeginValues[j]); } return true; @@ -699,7 +695,7 @@ bool CPDF_StitchFunc::v_Init(CPDF_Object* pObj) { m_pSubFunctions.push_back(std::move(pFunc)); } - m_pBounds = FX_Alloc(FX_FLOAT, nSubs + 1); + m_pBounds = FX_Alloc(float, nSubs + 1); m_pBounds[0] = m_pDomains[0]; pArray = pDict->GetArrayFor("Bounds"); if (!pArray) @@ -707,7 +703,7 @@ bool CPDF_StitchFunc::v_Init(CPDF_Object* pObj) { for (uint32_t i = 0; i < nSubs - 1; i++) m_pBounds[i + 1] = pArray->GetFloatAt(i); m_pBounds[nSubs] = m_pDomains[1]; - m_pEncode = FX_Alloc2D(FX_FLOAT, nSubs, 2); + m_pEncode = FX_Alloc2D(float, nSubs, 2); pArray = pDict->GetArrayFor("Encode"); if (!pArray) return false; @@ -717,8 +713,8 @@ bool CPDF_StitchFunc::v_Init(CPDF_Object* pObj) { return true; } -bool CPDF_StitchFunc::v_Call(FX_FLOAT* inputs, FX_FLOAT* outputs) const { - FX_FLOAT input = inputs[0]; +bool CPDF_StitchFunc::v_Call(float* inputs, float* outputs) const { + float input = inputs[0]; size_t i; for (i = 0; i < m_pSubFunctions.size() - 1; i++) { if (input < m_pBounds[i + 1]) @@ -792,7 +788,7 @@ bool CPDF_Function::Init(CPDF_Object* pObj) { if (m_nInputs == 0) return false; - m_pDomains = FX_Alloc2D(FX_FLOAT, m_nInputs, 2); + m_pDomains = FX_Alloc2D(float, m_nInputs, 2); for (uint32_t i = 0; i < m_nInputs * 2; i++) { m_pDomains[i] = pDomains->GetFloatAt(i); } @@ -800,7 +796,7 @@ bool CPDF_Function::Init(CPDF_Object* pObj) { m_nOutputs = 0; if (pRanges) { m_nOutputs = pRanges->GetCount() / 2; - m_pRanges = FX_Alloc2D(FX_FLOAT, m_nOutputs, 2); + m_pRanges = FX_Alloc2D(float, m_nOutputs, 2); for (uint32_t i = 0; i < m_nOutputs * 2; i++) m_pRanges[i] = pRanges->GetFloatAt(i); } @@ -808,18 +804,18 @@ bool CPDF_Function::Init(CPDF_Object* pObj) { if (!v_Init(pObj)) return false; if (m_pRanges && m_nOutputs > old_outputs) { - m_pRanges = FX_Realloc(FX_FLOAT, m_pRanges, m_nOutputs * 2); + m_pRanges = FX_Realloc(float, m_pRanges, m_nOutputs * 2); if (m_pRanges) { FXSYS_memset(m_pRanges + (old_outputs * 2), 0, - sizeof(FX_FLOAT) * (m_nOutputs - old_outputs) * 2); + sizeof(float) * (m_nOutputs - old_outputs) * 2); } } return true; } -bool CPDF_Function::Call(FX_FLOAT* inputs, +bool CPDF_Function::Call(float* inputs, uint32_t ninputs, - FX_FLOAT* results, + float* results, int& nresults) const { if (m_nInputs != ninputs) { return false; diff --git a/core/fpdfapi/page/pageint.h b/core/fpdfapi/page/pageint.h index 6700633604..88e9c15ff2 100644 --- a/core/fpdfapi/page/pageint.h +++ b/core/fpdfapi/page/pageint.h @@ -33,14 +33,14 @@ class CPDF_Function { static Type IntegerToFunctionType(int iType); virtual ~CPDF_Function(); - bool Call(FX_FLOAT* inputs, + bool Call(float* inputs, uint32_t ninputs, - FX_FLOAT* results, + float* results, int& nresults) const; uint32_t CountInputs() const { return m_nInputs; } uint32_t CountOutputs() const { return m_nOutputs; } - FX_FLOAT GetDomain(int i) const { return m_pDomains[i]; } - FX_FLOAT GetRange(int i) const { return m_pRanges[i]; } + float GetDomain(int i) const { return m_pDomains[i]; } + float GetRange(int i) const { return m_pRanges[i]; } const CPDF_SampledFunc* ToSampledFunc() const; const CPDF_ExpIntFunc* ToExpIntFunc() const; @@ -51,12 +51,12 @@ class CPDF_Function { bool Init(CPDF_Object* pObj); virtual bool v_Init(CPDF_Object* pObj) = 0; - virtual bool v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const = 0; + virtual bool v_Call(float* inputs, float* results) const = 0; uint32_t m_nInputs; uint32_t m_nOutputs; - FX_FLOAT* m_pDomains; - FX_FLOAT* m_pRanges; + float* m_pDomains; + float* m_pRanges; const Type m_Type; }; @@ -67,25 +67,25 @@ class CPDF_ExpIntFunc : public CPDF_Function { // CPDF_Function bool v_Init(CPDF_Object* pObj) override; - bool v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const override; + bool v_Call(float* inputs, float* results) const override; uint32_t m_nOrigOutputs; - FX_FLOAT m_Exponent; - FX_FLOAT* m_pBeginValues; - FX_FLOAT* m_pEndValues; + float m_Exponent; + float* m_pBeginValues; + float* m_pEndValues; }; class CPDF_SampledFunc : public CPDF_Function { public: struct SampleEncodeInfo { - FX_FLOAT encode_max; - FX_FLOAT encode_min; + float encode_max; + float encode_min; uint32_t sizes; }; struct SampleDecodeInfo { - FX_FLOAT decode_max; - FX_FLOAT decode_min; + float decode_max; + float decode_min; }; CPDF_SampledFunc(); @@ -93,7 +93,7 @@ class CPDF_SampledFunc : public CPDF_Function { // CPDF_Function bool v_Init(CPDF_Object* pObj) override; - bool v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const override; + bool v_Call(float* inputs, float* results) const override; const std::vector<SampleEncodeInfo>& GetEncodeInfo() const { return m_EncodeInfo; @@ -118,17 +118,17 @@ class CPDF_StitchFunc : public CPDF_Function { // CPDF_Function bool v_Init(CPDF_Object* pObj) override; - bool v_Call(FX_FLOAT* inputs, FX_FLOAT* results) const override; + bool v_Call(float* inputs, float* results) const override; const std::vector<std::unique_ptr<CPDF_Function>>& GetSubFunctions() const { return m_pSubFunctions; } - FX_FLOAT GetBound(size_t i) const { return m_pBounds[i]; } + float GetBound(size_t i) const { return m_pBounds[i]; } private: std::vector<std::unique_ptr<CPDF_Function>> m_pSubFunctions; - FX_FLOAT* m_pBounds; - FX_FLOAT* m_pEncode; + float* m_pBounds; + float* m_pEncode; static const uint32_t kRequiredNumInputs = 1; }; @@ -149,24 +149,18 @@ class CPDF_DeviceCS : public CPDF_ColorSpace { public: CPDF_DeviceCS(CPDF_Document* pDoc, int family); - bool GetRGB(FX_FLOAT* pBuf, - FX_FLOAT& R, - FX_FLOAT& G, - FX_FLOAT& B) const override; - bool SetRGB(FX_FLOAT* pBuf, - FX_FLOAT R, - FX_FLOAT G, - FX_FLOAT B) const override; - bool v_GetCMYK(FX_FLOAT* pBuf, - FX_FLOAT& c, - FX_FLOAT& m, - FX_FLOAT& y, - FX_FLOAT& k) const override; - bool v_SetCMYK(FX_FLOAT* pBuf, - FX_FLOAT c, - FX_FLOAT m, - FX_FLOAT y, - FX_FLOAT k) const override; + bool GetRGB(float* pBuf, float& R, float& G, float& B) const override; + bool SetRGB(float* pBuf, float R, float G, float B) const override; + bool v_GetCMYK(float* pBuf, + float& c, + float& m, + float& y, + float& k) const override; + bool v_SetCMYK(float* pBuf, + float c, + float m, + float y, + float k) const override; void TranslateImageLine(uint8_t* pDestBuf, const uint8_t* pSrcBuf, int pixels, @@ -180,10 +174,7 @@ class CPDF_PatternCS : public CPDF_ColorSpace { explicit CPDF_PatternCS(CPDF_Document* pDoc); ~CPDF_PatternCS() override; bool v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) override; - bool GetRGB(FX_FLOAT* pBuf, - FX_FLOAT& R, - FX_FLOAT& G, - FX_FLOAT& B) const override; + bool GetRGB(float* pBuf, float& R, float& G, float& B) const override; CPDF_ColorSpace* GetBaseCS() const override; private: @@ -196,7 +187,7 @@ struct PatternValue { CPDF_Pattern* m_pPattern; CPDF_CountedPattern* m_pCountedPattern; int m_nComps; - FX_FLOAT m_Comps[MAX_PATTERN_COLORCOMPS]; + float m_Comps[MAX_PATTERN_COLORCOMPS]; }; CFX_ByteStringC PDF_FindKeyAbbreviationForTesting(const CFX_ByteStringC& abbr); diff --git a/core/fpdfapi/parser/cpdf_array.cpp b/core/fpdfapi/parser/cpdf_array.cpp index 05a93702f1..bf8b51e604 100644 --- a/core/fpdfapi/parser/cpdf_array.cpp +++ b/core/fpdfapi/parser/cpdf_array.cpp @@ -108,7 +108,7 @@ int CPDF_Array::GetIntegerAt(size_t i) const { return m_Objects[i]->GetInteger(); } -FX_FLOAT CPDF_Array::GetNumberAt(size_t i) const { +float CPDF_Array::GetNumberAt(size_t i) const { if (i >= m_Objects.size()) return 0; return m_Objects[i]->GetNumber(); diff --git a/core/fpdfapi/parser/cpdf_array.h b/core/fpdfapi/parser/cpdf_array.h index 0b16f7f21b..8f8b600c7e 100644 --- a/core/fpdfapi/parser/cpdf_array.h +++ b/core/fpdfapi/parser/cpdf_array.h @@ -41,11 +41,11 @@ class CPDF_Array : public CPDF_Object { CPDF_Object* GetDirectObjectAt(size_t index) const; CFX_ByteString GetStringAt(size_t index) const; int GetIntegerAt(size_t index) const; - FX_FLOAT GetNumberAt(size_t index) const; + float GetNumberAt(size_t index) const; CPDF_Dictionary* GetDictAt(size_t index) const; CPDF_Stream* GetStreamAt(size_t index) const; CPDF_Array* GetArrayAt(size_t index) const; - FX_FLOAT GetFloatAt(size_t index) const { return GetNumberAt(index); } + float GetFloatAt(size_t index) const { return GetNumberAt(index); } CFX_Matrix GetMatrix(); CFX_FloatRect GetRect(); diff --git a/core/fpdfapi/parser/cpdf_dictionary.cpp b/core/fpdfapi/parser/cpdf_dictionary.cpp index 40877539b5..653ef45067 100644 --- a/core/fpdfapi/parser/cpdf_dictionary.cpp +++ b/core/fpdfapi/parser/cpdf_dictionary.cpp @@ -115,7 +115,7 @@ int CPDF_Dictionary::GetIntegerFor(const CFX_ByteString& key, int def) const { return p ? p->GetInteger() : def; } -FX_FLOAT CPDF_Dictionary::GetNumberFor(const CFX_ByteString& key) const { +float CPDF_Dictionary::GetNumberFor(const CFX_ByteString& key) const { CPDF_Object* p = GetObjectFor(key); return p ? p->GetNumber() : 0; } diff --git a/core/fpdfapi/parser/cpdf_dictionary.h b/core/fpdfapi/parser/cpdf_dictionary.h index 13cbdcf7ac..b14574fd61 100644 --- a/core/fpdfapi/parser/cpdf_dictionary.h +++ b/core/fpdfapi/parser/cpdf_dictionary.h @@ -48,13 +48,13 @@ class CPDF_Dictionary : public CPDF_Object { int GetIntegerFor(const CFX_ByteString& key) const; int GetIntegerFor(const CFX_ByteString& key, int default_int) const; bool GetBooleanFor(const CFX_ByteString& key, bool bDefault = false) const; - FX_FLOAT GetNumberFor(const CFX_ByteString& key) const; + float GetNumberFor(const CFX_ByteString& key) const; CPDF_Dictionary* GetDictFor(const CFX_ByteString& key) const; CPDF_Stream* GetStreamFor(const CFX_ByteString& key) const; CPDF_Array* GetArrayFor(const CFX_ByteString& key) const; CFX_FloatRect GetRectFor(const CFX_ByteString& key) const; CFX_Matrix GetMatrixFor(const CFX_ByteString& key) const; - FX_FLOAT GetFloatFor(const CFX_ByteString& key) const { + float GetFloatFor(const CFX_ByteString& key) const { return GetNumberFor(key); } diff --git a/core/fpdfapi/parser/cpdf_number.cpp b/core/fpdfapi/parser/cpdf_number.cpp index 24feb2a2e0..c83b9dcd38 100644 --- a/core/fpdfapi/parser/cpdf_number.cpp +++ b/core/fpdfapi/parser/cpdf_number.cpp @@ -11,7 +11,7 @@ CPDF_Number::CPDF_Number() : m_bInteger(true), m_Integer(0) {} CPDF_Number::CPDF_Number(int value) : m_bInteger(true), m_Integer(value) {} -CPDF_Number::CPDF_Number(FX_FLOAT value) : m_bInteger(false), m_Float(value) {} +CPDF_Number::CPDF_Number(float value) : m_bInteger(false), m_Float(value) {} CPDF_Number::CPDF_Number(const CFX_ByteStringC& str) : m_bInteger(FX_atonum(str, &m_Integer)) {} @@ -27,8 +27,8 @@ std::unique_ptr<CPDF_Object> CPDF_Number::Clone() const { : pdfium::MakeUnique<CPDF_Number>(m_Float); } -FX_FLOAT CPDF_Number::GetNumber() const { - return m_bInteger ? static_cast<FX_FLOAT>(m_Integer) : m_Float; +float CPDF_Number::GetNumber() const { + return m_bInteger ? static_cast<float>(m_Integer) : m_Float; } int CPDF_Number::GetInteger() const { diff --git a/core/fpdfapi/parser/cpdf_number.h b/core/fpdfapi/parser/cpdf_number.h index 85a78e5f1a..6e85044d2a 100644 --- a/core/fpdfapi/parser/cpdf_number.h +++ b/core/fpdfapi/parser/cpdf_number.h @@ -17,7 +17,7 @@ class CPDF_Number : public CPDF_Object { public: CPDF_Number(); explicit CPDF_Number(int value); - explicit CPDF_Number(FX_FLOAT value); + explicit CPDF_Number(float value); explicit CPDF_Number(const CFX_ByteStringC& str); ~CPDF_Number() override; @@ -25,7 +25,7 @@ class CPDF_Number : public CPDF_Object { Type GetType() const override; std::unique_ptr<CPDF_Object> Clone() const override; CFX_ByteString GetString() const override; - FX_FLOAT GetNumber() const override; + float GetNumber() const override; int GetInteger() const override; void SetString(const CFX_ByteString& str) override; bool IsNumber() const override; @@ -38,7 +38,7 @@ class CPDF_Number : public CPDF_Object { bool m_bInteger; union { int m_Integer; - FX_FLOAT m_Float; + float m_Float; }; }; diff --git a/core/fpdfapi/parser/cpdf_object.cpp b/core/fpdfapi/parser/cpdf_object.cpp index acda334c9e..f0ff81eeed 100644 --- a/core/fpdfapi/parser/cpdf_object.cpp +++ b/core/fpdfapi/parser/cpdf_object.cpp @@ -46,7 +46,7 @@ CFX_WideString CPDF_Object::GetUnicodeText() const { return CFX_WideString(); } -FX_FLOAT CPDF_Object::GetNumber() const { +float CPDF_Object::GetNumber() const { return 0; } diff --git a/core/fpdfapi/parser/cpdf_object.h b/core/fpdfapi/parser/cpdf_object.h index f6bc5b444f..616573724b 100644 --- a/core/fpdfapi/parser/cpdf_object.h +++ b/core/fpdfapi/parser/cpdf_object.h @@ -56,7 +56,7 @@ class CPDF_Object { virtual CPDF_Object* GetDirect() const; virtual CFX_ByteString GetString() const; virtual CFX_WideString GetUnicodeText() const; - virtual FX_FLOAT GetNumber() const; + virtual float GetNumber() const; virtual int GetInteger() const; virtual CPDF_Dictionary* GetDict() const; diff --git a/core/fpdfapi/parser/cpdf_object_unittest.cpp b/core/fpdfapi/parser/cpdf_object_unittest.cpp index 927b106474..9285993c52 100644 --- a/core/fpdfapi/parser/cpdf_object_unittest.cpp +++ b/core/fpdfapi/parser/cpdf_object_unittest.cpp @@ -218,14 +218,14 @@ TEST_F(PDFObjectsTest, GetUnicodeText) { } TEST_F(PDFObjectsTest, GetNumber) { - const FX_FLOAT direct_obj_results[] = {0, 0, 1245, 9.00345f, 0, 0, - 0, 0, 0, 0, 0}; + const float direct_obj_results[] = {0, 0, 1245, 9.00345f, 0, 0, + 0, 0, 0, 0, 0}; // Check for direct objects. for (size_t i = 0; i < m_DirectObjs.size(); ++i) EXPECT_EQ(direct_obj_results[i], m_DirectObjs[i]->GetNumber()); // Check indirect references. - const FX_FLOAT indirect_obj_results[] = {0, 1245, 0, 0, 0, 0, 0}; + const float indirect_obj_results[] = {0, 1245, 0, 0, 0, 0, 0}; for (size_t i = 0; i < m_RefObjs.size(); ++i) EXPECT_EQ(indirect_obj_results[i], m_RefObjs[i]->GetNumber()); } diff --git a/core/fpdfapi/parser/cpdf_reference.cpp b/core/fpdfapi/parser/cpdf_reference.cpp index 67b67c24dd..942bae58ba 100644 --- a/core/fpdfapi/parser/cpdf_reference.cpp +++ b/core/fpdfapi/parser/cpdf_reference.cpp @@ -24,7 +24,7 @@ CFX_ByteString CPDF_Reference::GetString() const { return obj ? obj->GetString() : CFX_ByteString(); } -FX_FLOAT CPDF_Reference::GetNumber() const { +float CPDF_Reference::GetNumber() const { CPDF_Object* obj = SafeGetDirect(); return obj ? obj->GetNumber() : 0; } diff --git a/core/fpdfapi/parser/cpdf_reference.h b/core/fpdfapi/parser/cpdf_reference.h index be7f18478e..ff8875572c 100644 --- a/core/fpdfapi/parser/cpdf_reference.h +++ b/core/fpdfapi/parser/cpdf_reference.h @@ -24,7 +24,7 @@ class CPDF_Reference : public CPDF_Object { std::unique_ptr<CPDF_Object> Clone() const override; CPDF_Object* GetDirect() const override; CFX_ByteString GetString() const override; - FX_FLOAT GetNumber() const override; + float GetNumber() const override; int GetInteger() const override; CPDF_Dictionary* GetDict() const override; bool IsReference() const override; diff --git a/core/fpdfapi/render/cpdf_charposlist.cpp b/core/fpdfapi/render/cpdf_charposlist.cpp index 639bdcf17b..6d4540e163 100644 --- a/core/fpdfapi/render/cpdf_charposlist.cpp +++ b/core/fpdfapi/render/cpdf_charposlist.cpp @@ -20,9 +20,9 @@ CPDF_CharPosList::~CPDF_CharPosList() { } void CPDF_CharPosList::Load(const std::vector<uint32_t>& charCodes, - const std::vector<FX_FLOAT>& charPos, + const std::vector<float>& charPos, CPDF_Font* pFont, - FX_FLOAT FontSize) { + float FontSize) { int nChars = pdfium::CollectionSize<int>(charCodes); m_pCharPos = FX_Alloc(FXTEXT_CHARPOS, nChars); m_nChars = 0; diff --git a/core/fpdfapi/render/cpdf_charposlist.h b/core/fpdfapi/render/cpdf_charposlist.h index 2f5a44dfa0..c4636bca51 100644 --- a/core/fpdfapi/render/cpdf_charposlist.h +++ b/core/fpdfapi/render/cpdf_charposlist.h @@ -19,9 +19,9 @@ class CPDF_CharPosList { CPDF_CharPosList(); ~CPDF_CharPosList(); void Load(const std::vector<uint32_t>& charCodes, - const std::vector<FX_FLOAT>& charPos, + const std::vector<float>& charPos, CPDF_Font* pFont, - FX_FLOAT font_size); + float font_size); FXTEXT_CHARPOS* m_pCharPos; uint32_t m_nChars; }; diff --git a/core/fpdfapi/render/cpdf_devicebuffer.cpp b/core/fpdfapi/render/cpdf_devicebuffer.cpp index dec13433e4..b8c174d97e 100644 --- a/core/fpdfapi/render/cpdf_devicebuffer.cpp +++ b/core/fpdfapi/render/cpdf_devicebuffer.cpp @@ -38,9 +38,9 @@ bool CPDF_DeviceBuffer::Initialize(CPDF_RenderContext* pContext, int dpiv = pDevice->GetDeviceCaps(FXDC_PIXEL_HEIGHT) * 254 / (vert_size * 10); if (dpih > max_dpi) - m_Matrix.Scale((FX_FLOAT)(max_dpi) / dpih, 1.0f); + m_Matrix.Scale((float)(max_dpi) / dpih, 1.0f); if (dpiv > max_dpi) - m_Matrix.Scale(1.0f, (FX_FLOAT)(max_dpi) / (FX_FLOAT)dpiv); + m_Matrix.Scale(1.0f, (float)(max_dpi) / (float)dpiv); } #endif CFX_Matrix ctm = m_pDevice->GetCTM(); diff --git a/core/fpdfapi/render/cpdf_dibsource.cpp b/core/fpdfapi/render/cpdf_dibsource.cpp index 33a8d930a5..403866300d 100644 --- a/core/fpdfapi/render/cpdf_dibsource.cpp +++ b/core/fpdfapi/render/cpdf_dibsource.cpp @@ -452,11 +452,11 @@ DIB_COMP_DATA* CPDF_DIBSource::GetDecodeAndMaskArray(bool& bDefaultDecode, if (pDecode) { for (uint32_t i = 0; i < m_nComponents; i++) { pCompData[i].m_DecodeMin = pDecode->GetNumberAt(i * 2); - FX_FLOAT max = pDecode->GetNumberAt(i * 2 + 1); + float max = pDecode->GetNumberAt(i * 2 + 1); pCompData[i].m_DecodeStep = (max - pCompData[i].m_DecodeMin) / max_data; - FX_FLOAT def_value; - FX_FLOAT def_min; - FX_FLOAT def_max; + float def_value; + float def_min; + float def_max; m_pColorSpace->GetDefaultValue(i, def_value, def_min, def_max); if (m_Family == PDFCS_INDEXED) { def_max = max_data; @@ -467,7 +467,7 @@ DIB_COMP_DATA* CPDF_DIBSource::GetDecodeAndMaskArray(bool& bDefaultDecode, } } else { for (uint32_t i = 0; i < m_nComponents; i++) { - FX_FLOAT def_value; + float def_value; m_pColorSpace->GetDefaultValue(i, def_value, pCompData[i].m_DecodeMin, pCompData[i].m_DecodeStep); if (m_Family == PDFCS_INDEXED) { @@ -699,8 +699,8 @@ int CPDF_DIBSource::StratLoadMask() { CPDF_Array* pMatte = m_pMaskStream->GetDict()->GetArrayFor("Matte"); if (pMatte && m_pColorSpace && m_pColorSpace->CountComponents() <= m_nComponents) { - FX_FLOAT R, G, B; - std::vector<FX_FLOAT> colors(m_nComponents); + float R, G, B; + std::vector<float> colors(m_nComponents); for (uint32_t i = 0; i < m_nComponents; i++) { colors[i] = pMatte->GetFloatAt(i); } @@ -775,10 +775,10 @@ void CPDF_DIBSource::LoadPalette() { if (m_pColorSpace->CountComponents() > 3) { return; } - FX_FLOAT color_values[3]; + float color_values[3]; color_values[0] = m_pCompData[0].m_DecodeMin; color_values[1] = color_values[2] = color_values[0]; - FX_FLOAT R = 0.0f, G = 0.0f, B = 0.0f; + float R = 0.0f, G = 0.0f, B = 0.0f; m_pColorSpace->GetRGB(color_values, R, G, B); FX_ARGB argb0 = ArgbEncode(255, FXSYS_round(R * 255), FXSYS_round(G * 255), FXSYS_round(B * 255)); @@ -798,8 +798,8 @@ void CPDF_DIBSource::LoadPalette() { m_bpc == 8 && m_bDefaultDecode) { } else { int palette_count = 1 << (m_bpc * m_nComponents); - CFX_FixedBufGrow<FX_FLOAT, 16> color_values(m_nComponents); - FX_FLOAT* color_value = color_values; + CFX_FixedBufGrow<float, 16> color_values(m_nComponents); + float* color_value = color_values; for (int i = 0; i < palette_count; i++) { int color_data = i; for (uint32_t j = 0; j < m_nComponents; j++) { @@ -808,11 +808,11 @@ void CPDF_DIBSource::LoadPalette() { color_value[j] = m_pCompData[j].m_DecodeMin + m_pCompData[j].m_DecodeStep * encoded_component; } - FX_FLOAT R = 0, G = 0, B = 0; + float R = 0, G = 0, B = 0; if (m_nComponents == 1 && m_Family == PDFCS_ICCBASED && m_pColorSpace->CountComponents() > 1) { int nComponents = m_pColorSpace->CountComponents(); - std::vector<FX_FLOAT> temp_buf(nComponents); + std::vector<float> temp_buf(nComponents); for (int k = 0; k < nComponents; k++) { temp_buf[k] = *color_value; } @@ -917,9 +917,9 @@ void CPDF_DIBSource::TranslateScanline24bpp(uint8_t* dest_scan, return; } } - CFX_FixedBufGrow<FX_FLOAT, 16> color_values1(m_nComponents); - FX_FLOAT* color_values = color_values1; - FX_FLOAT R = 0.0f, G = 0.0f, B = 0.0f; + CFX_FixedBufGrow<float, 16> color_values1(m_nComponents); + float* color_values = color_values1; + float R = 0.0f, G = 0.0f, B = 0.0f; if (m_bpc == 8) { uint64_t src_byte_pos = 0; size_t dest_byte_pos = 0; @@ -930,7 +930,7 @@ void CPDF_DIBSource::TranslateScanline24bpp(uint8_t* dest_scan, m_pCompData[color].m_DecodeStep * data; } if (TransMask()) { - FX_FLOAT k = 1.0f - color_values[3]; + float k = 1.0f - color_values[3]; R = (1.0f - color_values[0]) * k; G = (1.0f - color_values[1]) * k; B = (1.0f - color_values[2]) * k; @@ -956,7 +956,7 @@ void CPDF_DIBSource::TranslateScanline24bpp(uint8_t* dest_scan, src_bit_pos += m_bpc; } if (TransMask()) { - FX_FLOAT k = 1.0f - color_values[3]; + float k = 1.0f - color_values[3]; R = (1.0f - color_values[0]) * k; G = (1.0f - color_values[1]) * k; B = (1.0f - color_values[2]) * k; @@ -1332,7 +1332,7 @@ void CPDF_DIBSource::DownSampleScanline32Bit(int orig_Bpp, // in [0, src_width). Set the initial value to be an invalid src_x value. uint32_t last_src_x = src_width; FX_ARGB last_argb = FXARGB_MAKE(0xFF, 0xFF, 0xFF, 0xFF); - FX_FLOAT unit_To8Bpc = 255.0f / ((1 << m_bpc) - 1); + float unit_To8Bpc = 255.0f / ((1 << m_bpc) - 1); for (int i = 0; i < clip_width; i++) { int dest_x = clip_left + i; uint32_t src_x = (bFlipX ? (dest_width - dest_x - 1) : dest_x) * @@ -1376,8 +1376,7 @@ void CPDF_DIBSource::DownSampleScanline32Bit(int orig_Bpp, bTransMask); } else { for (uint32_t j = 0; j < m_nComponents; ++j) { - FX_FLOAT component_value = - static_cast<FX_FLOAT>(extracted_components[j]); + float component_value = static_cast<float>(extracted_components[j]); int color_value = static_cast<int>( (m_pCompData[j].m_DecodeMin + m_pCompData[j].m_DecodeStep * component_value) * diff --git a/core/fpdfapi/render/cpdf_dibsource.h b/core/fpdfapi/render/cpdf_dibsource.h index d5820d8bae..766025db7a 100644 --- a/core/fpdfapi/render/cpdf_dibsource.h +++ b/core/fpdfapi/render/cpdf_dibsource.h @@ -29,8 +29,8 @@ class CPDF_Document; class CPDF_Stream; typedef struct { - FX_FLOAT m_DecodeMin; - FX_FLOAT m_DecodeStep; + float m_DecodeMin; + float m_DecodeStep; int m_ColorKeyMin; int m_ColorKeyMax; } DIB_COMP_DATA; diff --git a/core/fpdfapi/render/cpdf_docrenderdata.cpp b/core/fpdfapi/render/cpdf_docrenderdata.cpp index 0e6f2d07e5..a6488c64d8 100644 --- a/core/fpdfapi/render/cpdf_docrenderdata.cpp +++ b/core/fpdfapi/render/cpdf_docrenderdata.cpp @@ -109,12 +109,12 @@ CPDF_TransferFunc* CPDF_DocRenderData::GetTransferFunc(CPDF_Object* pObj) { pdfium::MakeUnique<CPDF_TransferFunc>(m_pPDFDoc)); CPDF_TransferFunc* pTransfer = pTransferCounter->get(); m_TransferFuncMap[pObj] = pTransferCounter; - FX_FLOAT output[kMaxOutputs]; + float output[kMaxOutputs]; FXSYS_memset(output, 0, sizeof(output)); - FX_FLOAT input; + float input; int noutput; for (int v = 0; v < 256; ++v) { - input = (FX_FLOAT)v / 255.0f; + input = (float)v / 255.0f; if (bUniTransfer) { if (pFuncs[0] && pFuncs[0]->CountOutputs() <= kMaxOutputs) pFuncs[0]->Call(&input, 1, output, noutput); diff --git a/core/fpdfapi/render/cpdf_imagerenderer.cpp b/core/fpdfapi/render/cpdf_imagerenderer.cpp index 358d13edd0..7903ad4a62 100644 --- a/core/fpdfapi/render/cpdf_imagerenderer.cpp +++ b/core/fpdfapi/render/cpdf_imagerenderer.cpp @@ -305,7 +305,7 @@ bool CPDF_ImageRenderer::DrawPatternImage(const CFX_Matrix* pObj2Device) { &m_pRenderStatus->m_Options, 0, m_pRenderStatus->m_bDropObjects, nullptr, true); CFX_Matrix patternDevice = *pObj2Device; - patternDevice.Translate((FX_FLOAT)-rect.left, (FX_FLOAT)-rect.top); + patternDevice.Translate((float)-rect.left, (float)-rect.top); if (CPDF_TilingPattern* pTilingPattern = m_pPattern->AsTilingPattern()) { bitmap_render.DrawTilingPattern(pTilingPattern, m_pImageObject, &patternDevice, false); diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp index 682e6c0c91..28c7166013 100644 --- a/core/fpdfapi/render/cpdf_renderstatus.cpp +++ b/core/fpdfapi/render/cpdf_renderstatus.cpp @@ -108,12 +108,12 @@ void DrawAxialShading(CFX_DIBitmap* pBitmap, if (!pCoords) return; - FX_FLOAT start_x = pCoords->GetNumberAt(0); - FX_FLOAT start_y = pCoords->GetNumberAt(1); - FX_FLOAT end_x = pCoords->GetNumberAt(2); - FX_FLOAT end_y = pCoords->GetNumberAt(3); - FX_FLOAT t_min = 0; - FX_FLOAT t_max = 1.0f; + float start_x = pCoords->GetNumberAt(0); + float start_y = pCoords->GetNumberAt(1); + float end_x = pCoords->GetNumberAt(2); + float end_y = pCoords->GetNumberAt(3); + float t_min = 0; + float t_max = 1.0f; CPDF_Array* pArray = pDict->GetArrayFor("Domain"); if (pArray) { t_min = pArray->GetNumberAt(0); @@ -128,19 +128,19 @@ void DrawAxialShading(CFX_DIBitmap* pBitmap, } int width = pBitmap->GetWidth(); int height = pBitmap->GetHeight(); - FX_FLOAT x_span = end_x - start_x; - FX_FLOAT y_span = end_y - start_y; - FX_FLOAT axis_len_square = (x_span * x_span) + (y_span * y_span); + float x_span = end_x - start_x; + float y_span = end_y - start_y; + float axis_len_square = (x_span * x_span) + (y_span * y_span); CFX_Matrix matrix; matrix.SetReverse(*pObject2Bitmap); uint32_t total_results = std::max(CountOutputs(funcs), pCS->CountComponents()); - CFX_FixedBufGrow<FX_FLOAT, 16> result_array(total_results); - FX_FLOAT* pResults = result_array; - FXSYS_memset(pResults, 0, total_results * sizeof(FX_FLOAT)); + CFX_FixedBufGrow<float, 16> result_array(total_results); + float* pResults = result_array; + FXSYS_memset(pResults, 0, total_results * sizeof(float)); uint32_t rgb_array[SHADING_STEPS]; for (int i = 0; i < SHADING_STEPS; i++) { - FX_FLOAT input = (t_max - t_min) * i / SHADING_STEPS + t_min; + float input = (t_max - t_min) * i / SHADING_STEPS + t_min; int offset = 0; for (const auto& func : funcs) { if (func) { @@ -149,7 +149,7 @@ void DrawAxialShading(CFX_DIBitmap* pBitmap, offset += nresults; } } - FX_FLOAT R = 0.0f, G = 0.0f, B = 0.0f; + float R = 0.0f, G = 0.0f, B = 0.0f; pCS->GetRGB(pResults, R, G, B); rgb_array[i] = FXARGB_TODIB(FXARGB_MAKE(alpha, FXSYS_round(R * 255), @@ -159,9 +159,9 @@ void DrawAxialShading(CFX_DIBitmap* pBitmap, for (int row = 0; row < height; row++) { uint32_t* dib_buf = (uint32_t*)(pBitmap->GetBuffer() + row * pitch); for (int column = 0; column < width; column++) { - CFX_PointF pos = matrix.Transform(CFX_PointF( - static_cast<FX_FLOAT>(column), static_cast<FX_FLOAT>(row))); - FX_FLOAT scale = + CFX_PointF pos = matrix.Transform( + CFX_PointF(static_cast<float>(column), static_cast<float>(row))); + float scale = (((pos.x - start_x) * x_span) + ((pos.y - start_y) * y_span)) / axis_len_square; int index = (int32_t)(scale * (SHADING_STEPS - 1)); @@ -192,16 +192,16 @@ void DrawRadialShading(CFX_DIBitmap* pBitmap, if (!pCoords) return; - FX_FLOAT start_x = pCoords->GetNumberAt(0); - FX_FLOAT start_y = pCoords->GetNumberAt(1); - FX_FLOAT start_r = pCoords->GetNumberAt(2); - FX_FLOAT end_x = pCoords->GetNumberAt(3); - FX_FLOAT end_y = pCoords->GetNumberAt(4); - FX_FLOAT end_r = pCoords->GetNumberAt(5); + float start_x = pCoords->GetNumberAt(0); + float start_y = pCoords->GetNumberAt(1); + float start_r = pCoords->GetNumberAt(2); + float end_x = pCoords->GetNumberAt(3); + float end_y = pCoords->GetNumberAt(4); + float end_r = pCoords->GetNumberAt(5); CFX_Matrix matrix; matrix.SetReverse(*pObject2Bitmap); - FX_FLOAT t_min = 0; - FX_FLOAT t_max = 1.0f; + float t_min = 0; + float t_max = 1.0f; CPDF_Array* pArray = pDict->GetArrayFor("Domain"); if (pArray) { t_min = pArray->GetNumberAt(0); @@ -216,12 +216,12 @@ void DrawRadialShading(CFX_DIBitmap* pBitmap, } uint32_t total_results = std::max(CountOutputs(funcs), pCS->CountComponents()); - CFX_FixedBufGrow<FX_FLOAT, 16> result_array(total_results); - FX_FLOAT* pResults = result_array; - FXSYS_memset(pResults, 0, total_results * sizeof(FX_FLOAT)); + CFX_FixedBufGrow<float, 16> result_array(total_results); + float* pResults = result_array; + FXSYS_memset(pResults, 0, total_results * sizeof(float)); uint32_t rgb_array[SHADING_STEPS]; for (int i = 0; i < SHADING_STEPS; i++) { - FX_FLOAT input = (t_max - t_min) * i / SHADING_STEPS + t_min; + float input = (t_max - t_min) * i / SHADING_STEPS + t_min; int offset = 0; for (const auto& func : funcs) { if (func) { @@ -230,15 +230,15 @@ void DrawRadialShading(CFX_DIBitmap* pBitmap, offset += nresults; } } - FX_FLOAT R = 0.0f, G = 0.0f, B = 0.0f; + float R = 0.0f, G = 0.0f, B = 0.0f; pCS->GetRGB(pResults, R, G, B); rgb_array[i] = FXARGB_TODIB(FXARGB_MAKE(alpha, FXSYS_round(R * 255), FXSYS_round(G * 255), FXSYS_round(B * 255))); } - FX_FLOAT a = ((start_x - end_x) * (start_x - end_x)) + - ((start_y - end_y) * (start_y - end_y)) - - ((start_r - end_r) * (start_r - end_r)); + float a = ((start_x - end_x) * (start_x - end_x)) + + ((start_y - end_y) * (start_y - end_y)) - + ((start_r - end_r) * (start_r - end_r)); int width = pBitmap->GetWidth(); int height = pBitmap->GetHeight(); int pitch = pBitmap->GetPitch(); @@ -253,24 +253,23 @@ void DrawRadialShading(CFX_DIBitmap* pBitmap, for (int row = 0; row < height; row++) { uint32_t* dib_buf = (uint32_t*)(pBitmap->GetBuffer() + row * pitch); for (int column = 0; column < width; column++) { - CFX_PointF pos = matrix.Transform(CFX_PointF( - static_cast<FX_FLOAT>(column), static_cast<FX_FLOAT>(row))); - FX_FLOAT b = -2 * (((pos.x - start_x) * (end_x - start_x)) + - ((pos.y - start_y) * (end_y - start_y)) + - (start_r * (end_r - start_r))); - FX_FLOAT c = ((pos.x - start_x) * (pos.x - start_x)) + - ((pos.y - start_y) * (pos.y - start_y)) - - (start_r * start_r); - FX_FLOAT s; + CFX_PointF pos = matrix.Transform( + CFX_PointF(static_cast<float>(column), static_cast<float>(row))); + float b = -2 * (((pos.x - start_x) * (end_x - start_x)) + + ((pos.y - start_y) * (end_y - start_y)) + + (start_r * (end_r - start_r))); + float c = ((pos.x - start_x) * (pos.x - start_x)) + + ((pos.y - start_y) * (pos.y - start_y)) - (start_r * start_r); + float s; if (a == 0) { s = -c / b; } else { - FX_FLOAT b2_4ac = (b * b) - 4 * (a * c); + float b2_4ac = (b * b) - 4 * (a * c); if (b2_4ac < 0) { continue; } - FX_FLOAT root = FXSYS_sqrt(b2_4ac); - FX_FLOAT s1, s2; + float root = FXSYS_sqrt(b2_4ac); + float s1, s2; if (a > 0) { s1 = (-b - root) / (2 * a); s2 = (-b + root) / (2 * a); @@ -321,7 +320,7 @@ void DrawFuncShading(CFX_DIBitmap* pBitmap, int alpha) { ASSERT(pBitmap->GetFormat() == FXDIB_Argb); CPDF_Array* pDomain = pDict->GetArrayFor("Domain"); - FX_FLOAT xmin = 0, ymin = 0, xmax = 1.0f, ymax = 1.0f; + float xmin = 0, ymin = 0, xmax = 1.0f, ymax = 1.0f; if (pDomain) { xmin = pDomain->GetNumberAt(0); xmax = pDomain->GetNumberAt(1); @@ -340,18 +339,18 @@ void DrawFuncShading(CFX_DIBitmap* pBitmap, int pitch = pBitmap->GetPitch(); uint32_t total_results = std::max(CountOutputs(funcs), pCS->CountComponents()); - CFX_FixedBufGrow<FX_FLOAT, 16> result_array(total_results); - FX_FLOAT* pResults = result_array; - FXSYS_memset(pResults, 0, total_results * sizeof(FX_FLOAT)); + CFX_FixedBufGrow<float, 16> result_array(total_results); + float* pResults = result_array; + FXSYS_memset(pResults, 0, total_results * sizeof(float)); for (int row = 0; row < height; row++) { uint32_t* dib_buf = (uint32_t*)(pBitmap->GetBuffer() + row * pitch); for (int column = 0; column < width; column++) { - CFX_PointF pos = matrix.Transform(CFX_PointF( - static_cast<FX_FLOAT>(column), static_cast<FX_FLOAT>(row))); + CFX_PointF pos = matrix.Transform( + CFX_PointF(static_cast<float>(column), static_cast<float>(row))); if (pos.x < xmin || pos.x > xmax || pos.y < ymin || pos.y > ymax) continue; - FX_FLOAT input[] = {pos.x, pos.y}; + float input[] = {pos.x, pos.y}; int offset = 0; for (const auto& func : funcs) { if (func) { @@ -361,9 +360,9 @@ void DrawFuncShading(CFX_DIBitmap* pBitmap, } } - FX_FLOAT R = 0.0f; - FX_FLOAT G = 0.0f; - FX_FLOAT B = 0.0f; + float R = 0.0f; + float G = 0.0f; + float B = 0.0f; pCS->GetRGB(pResults, R, G, B); dib_buf[column] = FXARGB_TODIB(FXARGB_MAKE( alpha, (int32_t)(R * 255), (int32_t)(G * 255), (int32_t)(B * 255))); @@ -374,7 +373,7 @@ void DrawFuncShading(CFX_DIBitmap* pBitmap, bool GetScanlineIntersect(int y, const CFX_PointF& first, const CFX_PointF& second, - FX_FLOAT* x) { + float* x) { if (first.y == second.y) return false; @@ -391,8 +390,8 @@ bool GetScanlineIntersect(int y, void DrawGouraud(CFX_DIBitmap* pBitmap, int alpha, CPDF_MeshVertex triangle[3]) { - FX_FLOAT min_y = triangle[0].position.y; - FX_FLOAT max_y = triangle[0].position.y; + float min_y = triangle[0].position.y; + float max_y = triangle[0].position.y; for (int i = 1; i < 3; i++) { min_y = std::min(min_y, triangle[i].position.y); max_y = std::max(max_y, triangle[i].position.y); @@ -408,10 +407,10 @@ void DrawGouraud(CFX_DIBitmap* pBitmap, for (int y = min_yi; y <= max_yi; y++) { int nIntersects = 0; - FX_FLOAT inter_x[3]; - FX_FLOAT r[3]; - FX_FLOAT g[3]; - FX_FLOAT b[3]; + float inter_x[3]; + float r[3]; + float g[3]; + float b[3]; for (int i = 0; i < 3; i++) { CPDF_MeshVertex& vertex1 = triangle[i]; CPDF_MeshVertex& vertex2 = triangle[(i + 1) % 3]; @@ -422,7 +421,7 @@ void DrawGouraud(CFX_DIBitmap* pBitmap, if (!bIntersect) continue; - FX_FLOAT y_dist = (y - position1.y) / (position2.y - position1.y); + float y_dist = (y - position1.y) / (position2.y - position1.y); r[nIntersects] = vertex1.r + ((vertex2.r - vertex1.r) * y_dist); g[nIntersects] = vertex1.g + ((vertex2.g - vertex1.g) * y_dist); b[nIntersects] = vertex1.b + ((vertex2.b - vertex1.b) * y_dist); @@ -451,12 +450,12 @@ void DrawGouraud(CFX_DIBitmap* pBitmap, uint8_t* dib_buf = pBitmap->GetBuffer() + y * pBitmap->GetPitch() + start_x * 4; - FX_FLOAT r_unit = (r[end_index] - r[start_index]) / (max_x - min_x); - FX_FLOAT g_unit = (g[end_index] - g[start_index]) / (max_x - min_x); - FX_FLOAT b_unit = (b[end_index] - b[start_index]) / (max_x - min_x); - FX_FLOAT R = r[start_index] + (start_x - min_x) * r_unit; - FX_FLOAT G = g[start_index] + (start_x - min_x) * g_unit; - FX_FLOAT B = b[start_index] + (start_x - min_x) * b_unit; + float r_unit = (r[end_index] - r[start_index]) / (max_x - min_x); + float g_unit = (g[end_index] - g[start_index]) / (max_x - min_x); + float b_unit = (b[end_index] - b[start_index]) / (max_x - min_x); + float R = r[start_index] + (start_x - min_x) * r_unit; + float G = g[start_index] + (start_x - min_x) * g_unit; + float B = b[start_index] + (start_x - min_x) * b_unit; for (int x = start_x; x < end_x; x++) { R += r_unit; G += g_unit; @@ -862,9 +861,9 @@ void DrawCoonPatchMeshes( if (!stream.CanReadColor()) break; - FX_FLOAT r; - FX_FLOAT g; - FX_FLOAT b; + float r; + float g; + float b; std::tie(r, g, b) = stream.ReadColor(); patch.patch_colors[i].comp[0] = (int32_t)(r * 255); @@ -872,8 +871,8 @@ void DrawCoonPatchMeshes( patch.patch_colors[i].comp[2] = (int32_t)(b * 255); } CFX_FloatRect bbox = CFX_FloatRect::GetBBox(coords, point_count); - if (bbox.right <= 0 || bbox.left >= (FX_FLOAT)pBitmap->GetWidth() || - bbox.top <= 0 || bbox.bottom >= (FX_FLOAT)pBitmap->GetHeight()) { + if (bbox.right <= 0 || bbox.left >= (float)pBitmap->GetWidth() || + bbox.top <= 0 || bbox.bottom >= (float)pBitmap->GetHeight()) { continue; } Coon_Bezier C1, C2, D1, D2; @@ -908,7 +907,7 @@ std::unique_ptr<CFX_DIBitmap> DrawPatternBitmap( CFX_FloatRect cell_bbox = pPattern->bbox(); pPattern->pattern_to_form()->TransformRect(cell_bbox); pObject2Device->TransformRect(cell_bbox); - CFX_FloatRect bitmap_rect(0.0f, 0.0f, (FX_FLOAT)width, (FX_FLOAT)height); + CFX_FloatRect bitmap_rect(0.0f, 0.0f, (float)width, (float)height); CFX_Matrix mtAdjust; mtAdjust.MatchRect(bitmap_rect, cell_bbox); @@ -1128,15 +1127,15 @@ bool CPDF_RenderStatus::GetObjectClippedRect(const CPDF_PageObject* pObj, FX_RECT rtClip = m_pDevice->GetClipBox(); if (!bLogical) { CFX_Matrix dCTM = m_pDevice->GetCTM(); - FX_FLOAT a = FXSYS_fabs(dCTM.a); - FX_FLOAT d = FXSYS_fabs(dCTM.d); + float a = FXSYS_fabs(dCTM.a); + float d = FXSYS_fabs(dCTM.d); if (a != 1.0f || d != 1.0f) { - rect.right = rect.left + (int32_t)FXSYS_ceil((FX_FLOAT)rect.Width() * a); - rect.bottom = rect.top + (int32_t)FXSYS_ceil((FX_FLOAT)rect.Height() * d); + rect.right = rect.left + (int32_t)FXSYS_ceil((float)rect.Width() * a); + rect.bottom = rect.top + (int32_t)FXSYS_ceil((float)rect.Height() * d); rtClip.right = - rtClip.left + (int32_t)FXSYS_ceil((FX_FLOAT)rtClip.Width() * a); + rtClip.left + (int32_t)FXSYS_ceil((float)rtClip.Width() * a); rtClip.bottom = - rtClip.top + (int32_t)FXSYS_ceil((FX_FLOAT)rtClip.Height() * d); + rtClip.top + (int32_t)FXSYS_ceil((float)rtClip.Height() * d); } } rect.Intersect(rtClip); @@ -1462,7 +1461,7 @@ bool CPDF_RenderStatus::ProcessTransparency(CPDF_PageObject* pPageObj, } } CPDF_Dictionary* pFormResource = nullptr; - FX_FLOAT group_alpha = 1.0f; + float group_alpha = 1.0f; int Transparency = m_Transparency; bool bGroupTransparent = false; if (pPageObj->IsForm()) { @@ -1532,10 +1531,10 @@ bool CPDF_RenderStatus::ProcessTransparency(CPDF_PageObject* pPageObj, return true; } CFX_Matrix deviceCTM = m_pDevice->GetCTM(); - FX_FLOAT scaleX = FXSYS_fabs(deviceCTM.a); - FX_FLOAT scaleY = FXSYS_fabs(deviceCTM.d); - int width = FXSYS_round((FX_FLOAT)rect.Width() * scaleX); - int height = FXSYS_round((FX_FLOAT)rect.Height() * scaleY); + float scaleX = FXSYS_fabs(deviceCTM.a); + float scaleY = FXSYS_fabs(deviceCTM.d); + int width = FXSYS_round((float)rect.Width() * scaleX); + int height = FXSYS_round((float)rect.Height() * scaleY); CFX_FxgeDevice bitmap_device; std::unique_ptr<CFX_DIBitmap> oriDevice; if (!isolated && (m_pDevice->GetRenderCaps() & FXRC_GET_BITS)) { @@ -1626,8 +1625,8 @@ std::unique_ptr<CFX_DIBitmap> CPDF_RenderStatus::GetBackdrop( left = bbox.left; top = bbox.top; CFX_Matrix deviceCTM = m_pDevice->GetCTM(); - FX_FLOAT scaleX = FXSYS_fabs(deviceCTM.a); - FX_FLOAT scaleY = FXSYS_fabs(deviceCTM.d); + float scaleX = FXSYS_fabs(deviceCTM.a); + float scaleY = FXSYS_fabs(deviceCTM.d); int width = FXSYS_round(bbox.Width() * scaleX); int height = FXSYS_round(bbox.Height() * scaleY); auto pBackdrop = pdfium::MakeUnique<CFX_DIBitmap>(); @@ -1753,7 +1752,7 @@ bool CPDF_RenderStatus::ProcessText(CPDF_TextObject* textobj, if (!IsAvailableMatrix(text_matrix)) return true; - FX_FLOAT font_size = textobj->m_TextState.GetFontSize(); + float font_size = textobj->m_TextState.GetFontSize(); if (bPattern) { DrawTextPathWithPattern(textobj, pObj2Device, pFont, font_size, &text_matrix, bFill, bStroke); @@ -1763,7 +1762,7 @@ bool CPDF_RenderStatus::ProcessText(CPDF_TextObject* textobj, const CFX_Matrix* pDeviceMatrix = pObj2Device; CFX_Matrix device_matrix; if (bStroke) { - const FX_FLOAT* pCTM = textobj->m_TextState.GetCTM(); + const float* pCTM = textobj->m_TextState.GetCTM(); if (pCTM[0] != 1.0f || pCTM[3] != 1.0f) { CFX_Matrix ctm(pCTM[0], pCTM[1], pCTM[2], pCTM[3], 0, 0); text_matrix.ConcatInverse(ctm); @@ -1808,11 +1807,11 @@ bool CPDF_RenderStatus::ProcessType3Text(CPDF_TextObject* textobj, return true; CFX_Matrix dCTM = m_pDevice->GetCTM(); - FX_FLOAT sa = FXSYS_fabs(dCTM.a); - FX_FLOAT sd = FXSYS_fabs(dCTM.d); + float sa = FXSYS_fabs(dCTM.a); + float sd = FXSYS_fabs(dCTM.d); CFX_Matrix text_matrix = textobj->GetTextMatrix(); CFX_Matrix char_matrix = pType3Font->GetFontMatrix(); - FX_FLOAT font_size = textobj->m_TextState.GetFontSize(); + float font_size = textobj->m_TextState.GetFontSize(); char_matrix.Scale(font_size, font_size); FX_ARGB fill_argb = GetFillArgb(textobj, true); int fill_alpha = FXARGB_A(fill_argb); @@ -1968,7 +1967,7 @@ bool CPDF_RenderStatus::ProcessType3Text(CPDF_TextObject* textobj, void CPDF_RenderStatus::DrawTextPathWithPattern(const CPDF_TextObject* textobj, const CFX_Matrix* pObj2Device, CPDF_Font* pFont, - FX_FLOAT font_size, + float font_size, const CFX_Matrix* pTextMatrix, bool bFill, bool bStroke) { @@ -2039,10 +2038,10 @@ void CPDF_RenderStatus::DrawShading(CPDF_ShadingPattern* pPattern, CPDF_Array* pBackColor = pDict->GetArrayFor("Background"); if (pBackColor && pBackColor->GetCount() >= pColorSpace->CountComponents()) { - CFX_FixedBufGrow<FX_FLOAT, 16> comps(pColorSpace->CountComponents()); + CFX_FixedBufGrow<float, 16> comps(pColorSpace->CountComponents()); for (uint32_t i = 0; i < pColorSpace->CountComponents(); i++) comps[i] = pBackColor->GetNumberAt(i); - FX_FLOAT R = 0.0f, G = 0.0f, B = 0.0f; + float R = 0.0f, G = 0.0f, B = 0.0f; pColorSpace->GetRGB(comps, R, G, B); background = ArgbEncode(255, (int32_t)(R * 255), (int32_t)(G * 255), (int32_t)(B * 255)); @@ -2189,8 +2188,8 @@ void CPDF_RenderStatus::DrawTilingPattern(CPDF_TilingPattern* pPattern, return; } CFX_Matrix dCTM = m_pDevice->GetCTM(); - FX_FLOAT sa = FXSYS_fabs(dCTM.a); - FX_FLOAT sd = FXSYS_fabs(dCTM.d); + float sa = FXSYS_fabs(dCTM.a); + float sd = FXSYS_fabs(dCTM.d); clip_box.right = clip_box.left + (int32_t)FXSYS_ceil(clip_box.Width() * sa); clip_box.bottom = clip_box.top + (int32_t)FXSYS_ceil(clip_box.Height() * sd); CFX_Matrix mtPattern2Device = *pPattern->pattern_to_form(); @@ -2278,8 +2277,8 @@ void CPDF_RenderStatus::DrawTilingPattern(CPDF_TilingPattern* pPattern, max_row--; } } - FX_FLOAT left_offset = cell_bbox.left - mtPattern2Device.e; - FX_FLOAT top_offset = cell_bbox.bottom - mtPattern2Device.f; + float left_offset = cell_bbox.left - mtPattern2Device.e; + float top_offset = cell_bbox.bottom - mtPattern2Device.f; std::unique_ptr<CFX_DIBitmap> pPatternBitmap; if (width * height < 16) { std::unique_ptr<CFX_DIBitmap> pEnlargedBitmap = @@ -2569,15 +2568,15 @@ std::unique_ptr<CFX_DIBitmap> CPDF_RenderStatus::LoadSMask( // Store Color Space Family to use in CPDF_RenderStatus::Initialize. color_space_family = pCS->GetFamily(); - FX_FLOAT R, G, B; + float R, G, B; uint32_t comps = 8; if (pCS->CountComponents() > comps) { comps = pCS->CountComponents(); } - CFX_FixedBufGrow<FX_FLOAT, 8> float_array(comps); - FX_FLOAT* pFloats = float_array; + CFX_FixedBufGrow<float, 8> float_array(comps); + float* pFloats = float_array; FX_SAFE_UINT32 num_floats = comps; - num_floats *= sizeof(FX_FLOAT); + num_floats *= sizeof(float); if (!num_floats.IsValid()) { return nullptr; } @@ -2618,9 +2617,9 @@ std::unique_ptr<CFX_DIBitmap> CPDF_RenderStatus::LoadSMask( int src_pitch = bitmap.GetPitch(); std::vector<uint8_t> transfers(256); if (pFunc) { - CFX_FixedBufGrow<FX_FLOAT, 16> results(pFunc->CountOutputs()); + CFX_FixedBufGrow<float, 16> results(pFunc->CountOutputs()); for (int i = 0; i < 256; i++) { - FX_FLOAT input = (FX_FLOAT)i / 255.0f; + float input = (float)i / 255.0f; int nresult; pFunc->Call(&input, 1, results, nresult); transfers[i] = FXSYS_round(results[0] * 255); diff --git a/core/fpdfapi/render/cpdf_renderstatus.h b/core/fpdfapi/render/cpdf_renderstatus.h index 25ddfb06c3..6ae255271b 100644 --- a/core/fpdfapi/render/cpdf_renderstatus.h +++ b/core/fpdfapi/render/cpdf_renderstatus.h @@ -127,7 +127,7 @@ class CPDF_RenderStatus { void DrawTextPathWithPattern(const CPDF_TextObject* textobj, const CFX_Matrix* pObj2Device, CPDF_Font* pFont, - FX_FLOAT font_size, + float font_size, const CFX_Matrix* pTextMatrix, bool bFill, bool bStroke); diff --git a/core/fpdfapi/render/cpdf_scaledrenderbuffer.cpp b/core/fpdfapi/render/cpdf_scaledrenderbuffer.cpp index de60e732bb..927d23210c 100644 --- a/core/fpdfapi/render/cpdf_scaledrenderbuffer.cpp +++ b/core/fpdfapi/render/cpdf_scaledrenderbuffer.cpp @@ -40,9 +40,9 @@ bool CPDF_ScaledRenderBuffer::Initialize(CPDF_RenderContext* pContext, int dpiv = pDevice->GetDeviceCaps(FXDC_PIXEL_HEIGHT) * 254 / (vert_size * 10); if (dpih > max_dpi) - m_Matrix.Scale((FX_FLOAT)(max_dpi) / dpih, 1.0f); + m_Matrix.Scale((float)(max_dpi) / dpih, 1.0f); if (dpiv > max_dpi) - m_Matrix.Scale(1.0f, (FX_FLOAT)(max_dpi) / (FX_FLOAT)dpiv); + m_Matrix.Scale(1.0f, (float)(max_dpi) / (float)dpiv); } m_pBitmapDevice = pdfium::MakeUnique<CFX_FxgeDevice>(); FXDIB_Format dibFormat = FXDIB_Rgb; diff --git a/core/fpdfapi/render/cpdf_textrenderer.cpp b/core/fpdfapi/render/cpdf_textrenderer.cpp index 95af863f7a..c45c1ef792 100644 --- a/core/fpdfapi/render/cpdf_textrenderer.cpp +++ b/core/fpdfapi/render/cpdf_textrenderer.cpp @@ -18,9 +18,9 @@ // static bool CPDF_TextRenderer::DrawTextPath(CFX_RenderDevice* pDevice, const std::vector<uint32_t>& charCodes, - const std::vector<FX_FLOAT>& charPos, + const std::vector<float>& charPos, CPDF_Font* pFont, - FX_FLOAT font_size, + float font_size, const CFX_Matrix* pText2User, const CFX_Matrix* pUser2Device, const CFX_GraphStateData* pGraphState, @@ -65,10 +65,10 @@ bool CPDF_TextRenderer::DrawTextPath(CFX_RenderDevice* pDevice, // static void CPDF_TextRenderer::DrawTextString(CFX_RenderDevice* pDevice, - FX_FLOAT origin_x, - FX_FLOAT origin_y, + float origin_x, + float origin_y, CPDF_Font* pFont, - FX_FLOAT font_size, + float font_size, const CFX_Matrix* pMatrix, const CFX_ByteString& str, FX_ARGB fill_argb, @@ -83,10 +83,10 @@ void CPDF_TextRenderer::DrawTextString(CFX_RenderDevice* pDevice, int offset = 0; std::vector<uint32_t> codes; - std::vector<FX_FLOAT> positions; + std::vector<float> positions; codes.resize(nChars); positions.resize(nChars - 1); - FX_FLOAT cur_pos = 0; + float cur_pos = 0; for (int i = 0; i < nChars; i++) { codes[i] = pFont->GetNextChar(str.c_str(), str.GetLength(), offset); if (i) @@ -107,9 +107,9 @@ void CPDF_TextRenderer::DrawTextString(CFX_RenderDevice* pDevice, // static bool CPDF_TextRenderer::DrawNormalText(CFX_RenderDevice* pDevice, const std::vector<uint32_t>& charCodes, - const std::vector<FX_FLOAT>& charPos, + const std::vector<float>& charPos, CPDF_Font* pFont, - FX_FLOAT font_size, + float font_size, const CFX_Matrix* pText2Device, FX_ARGB fill_argb, const CPDF_RenderOptions* pOptions) { diff --git a/core/fpdfapi/render/cpdf_textrenderer.h b/core/fpdfapi/render/cpdf_textrenderer.h index 54e9d1bd05..31c44d9599 100644 --- a/core/fpdfapi/render/cpdf_textrenderer.h +++ b/core/fpdfapi/render/cpdf_textrenderer.h @@ -23,10 +23,10 @@ class CPDF_Font; class CPDF_TextRenderer { public: static void DrawTextString(CFX_RenderDevice* pDevice, - FX_FLOAT origin_x, - FX_FLOAT origin_y, + float origin_x, + float origin_y, CPDF_Font* pFont, - FX_FLOAT font_size, + float font_size, const CFX_Matrix* matrix, const CFX_ByteString& str, FX_ARGB fill_argb, @@ -35,9 +35,9 @@ class CPDF_TextRenderer { static bool DrawTextPath(CFX_RenderDevice* pDevice, const std::vector<uint32_t>& charCodes, - const std::vector<FX_FLOAT>& charPos, + const std::vector<float>& charPos, CPDF_Font* pFont, - FX_FLOAT font_size, + float font_size, const CFX_Matrix* pText2User, const CFX_Matrix* pUser2Device, const CFX_GraphStateData* pGraphState, @@ -48,9 +48,9 @@ class CPDF_TextRenderer { static bool DrawNormalText(CFX_RenderDevice* pDevice, const std::vector<uint32_t>& charCodes, - const std::vector<FX_FLOAT>& charPos, + const std::vector<float>& charPos, CPDF_Font* pFont, - FX_FLOAT font_size, + float font_size, const CFX_Matrix* pText2Device, FX_ARGB fill_argb, const CPDF_RenderOptions* pOptions); diff --git a/core/fpdfapi/render/cpdf_type3cache.cpp b/core/fpdfapi/render/cpdf_type3cache.cpp index a5de13b464..7d0cb18172 100644 --- a/core/fpdfapi/render/cpdf_type3cache.cpp +++ b/core/fpdfapi/render/cpdf_type3cache.cpp @@ -87,8 +87,8 @@ CPDF_Type3Cache::~CPDF_Type3Cache() { CFX_GlyphBitmap* CPDF_Type3Cache::LoadGlyph(uint32_t charcode, const CFX_Matrix* pMatrix, - FX_FLOAT retinaScaleX, - FX_FLOAT retinaScaleY) { + float retinaScaleX, + float retinaScaleY) { CPDF_UniqueKeyGen keygen; keygen.Generate( 4, FXSYS_round(pMatrix->a * 10000), FXSYS_round(pMatrix->b * 10000), @@ -115,8 +115,8 @@ CFX_GlyphBitmap* CPDF_Type3Cache::LoadGlyph(uint32_t charcode, CFX_GlyphBitmap* CPDF_Type3Cache::RenderGlyph(CPDF_Type3Glyphs* pSize, uint32_t charcode, const CFX_Matrix* pMatrix, - FX_FLOAT retinaScaleX, - FX_FLOAT retinaScaleY) { + float retinaScaleX, + float retinaScaleY) { const CPDF_Type3Char* pChar = m_pFont->LoadChar(charcode); if (!pChar || !pChar->m_pBitmap) return nullptr; @@ -134,11 +134,11 @@ CFX_GlyphBitmap* CPDF_Type3Cache::RenderGlyph(CPDF_Type3Glyphs* pSize, int top_line = DetectFirstLastScan(pBitmap, true); int bottom_line = DetectFirstLastScan(pBitmap, false); if (top_line == 0 && bottom_line == pBitmap->GetHeight() - 1) { - FX_FLOAT top_y = image_matrix.d + image_matrix.f; - FX_FLOAT bottom_y = image_matrix.f; + float top_y = image_matrix.d + image_matrix.f; + float bottom_y = image_matrix.f; bool bFlipped = top_y > bottom_y; if (bFlipped) { - FX_FLOAT temp = top_y; + float temp = top_y; top_y = bottom_y; bottom_y = temp; } diff --git a/core/fpdfapi/render/cpdf_type3cache.h b/core/fpdfapi/render/cpdf_type3cache.h index f74a43acc5..f03578650b 100644 --- a/core/fpdfapi/render/cpdf_type3cache.h +++ b/core/fpdfapi/render/cpdf_type3cache.h @@ -23,15 +23,15 @@ class CPDF_Type3Cache { CFX_GlyphBitmap* LoadGlyph(uint32_t charcode, const CFX_Matrix* pMatrix, - FX_FLOAT retinaScaleX, - FX_FLOAT retinaScaleY); + float retinaScaleX, + float retinaScaleY); private: CFX_GlyphBitmap* RenderGlyph(CPDF_Type3Glyphs* pSize, uint32_t charcode, const CFX_Matrix* pMatrix, - FX_FLOAT retinaScaleX, - FX_FLOAT retinaScaleY); + float retinaScaleX, + float retinaScaleY); CPDF_Type3Font* const m_pFont; std::map<CFX_ByteString, CPDF_Type3Glyphs*> m_SizeMap; diff --git a/core/fpdfapi/render/cpdf_type3glyphs.cpp b/core/fpdfapi/render/cpdf_type3glyphs.cpp index 189fc2439d..33d8ef1253 100644 --- a/core/fpdfapi/render/cpdf_type3glyphs.cpp +++ b/core/fpdfapi/render/cpdf_type3glyphs.cpp @@ -18,11 +18,11 @@ CPDF_Type3Glyphs::~CPDF_Type3Glyphs() { delete pair.second; } -static int _AdjustBlue(FX_FLOAT pos, int& count, int blues[]) { - FX_FLOAT min_distance = 1000000.0f; +static int _AdjustBlue(float pos, int& count, int blues[]) { + float min_distance = 1000000.0f; int closest_pos = -1; for (int i = 0; i < count; i++) { - FX_FLOAT distance = FXSYS_fabs(pos - static_cast<FX_FLOAT>(blues[i])); + float distance = FXSYS_fabs(pos - static_cast<float>(blues[i])); if (distance < 1.0f * 80.0f / 100.0f && distance < min_distance) { min_distance = distance; closest_pos = i; @@ -37,8 +37,8 @@ static int _AdjustBlue(FX_FLOAT pos, int& count, int blues[]) { return new_pos; } -void CPDF_Type3Glyphs::AdjustBlue(FX_FLOAT top, - FX_FLOAT bottom, +void CPDF_Type3Glyphs::AdjustBlue(float top, + float bottom, int& top_line, int& bottom_line) { top_line = _AdjustBlue(top, m_TopBlueCount, m_TopBlue); diff --git a/core/fpdfapi/render/cpdf_type3glyphs.h b/core/fpdfapi/render/cpdf_type3glyphs.h index 00814d5b3b..443910dac0 100644 --- a/core/fpdfapi/render/cpdf_type3glyphs.h +++ b/core/fpdfapi/render/cpdf_type3glyphs.h @@ -20,10 +20,7 @@ class CPDF_Type3Glyphs { CPDF_Type3Glyphs(); ~CPDF_Type3Glyphs(); - void AdjustBlue(FX_FLOAT top, - FX_FLOAT bottom, - int& top_line, - int& bottom_line); + void AdjustBlue(float top, float bottom, int& top_line, int& bottom_line); std::map<uint32_t, CFX_GlyphBitmap*> m_GlyphMap; int m_TopBlue[TYPE3_MAX_BLUES]; diff --git a/core/fpdfdoc/cpdf_annot.cpp b/core/fpdfdoc/cpdf_annot.cpp index f15d39d89b..a3ee70ab36 100644 --- a/core/fpdfdoc/cpdf_annot.cpp +++ b/core/fpdfdoc/cpdf_annot.cpp @@ -426,7 +426,7 @@ void CPDF_Annot::DrawBorder(CFX_RenderDevice* pDevice, } CPDF_Dictionary* pBS = m_pAnnotDict->GetDictFor("BS"); char style_char; - FX_FLOAT width; + float width; CPDF_Array* pDashArray = nullptr; if (!pBS) { CPDF_Array* pBorderArray = m_pAnnotDict->GetArrayFor("Border"); @@ -479,7 +479,7 @@ void CPDF_Annot::DrawBorder(CFX_RenderDevice* pDevice, if (dash_count % 2) { dash_count++; } - graph_state.m_DashArray = FX_Alloc(FX_FLOAT, dash_count); + graph_state.m_DashArray = FX_Alloc(float, dash_count); graph_state.m_DashCount = dash_count; size_t i; for (i = 0; i < pDashArray->GetCount(); ++i) { @@ -489,7 +489,7 @@ void CPDF_Annot::DrawBorder(CFX_RenderDevice* pDevice, graph_state.m_DashArray[i] = graph_state.m_DashArray[i - 1]; } } else { - graph_state.m_DashArray = FX_Alloc(FX_FLOAT, 2); + graph_state.m_DashArray = FX_Alloc(float, 2); graph_state.m_DashCount = 2; graph_state.m_DashArray[0] = graph_state.m_DashArray[1] = 3 * 1.0f; } diff --git a/core/fpdfdoc/cpdf_apsettings.cpp b/core/fpdfdoc/cpdf_apsettings.cpp index 9fc9c1aa06..4c44f5a13e 100644 --- a/core/fpdfdoc/cpdf_apsettings.cpp +++ b/core/fpdfdoc/cpdf_apsettings.cpp @@ -36,33 +36,32 @@ FX_ARGB CPDF_ApSettings::GetColor(int& iColorType, size_t dwCount = pEntry->GetCount(); if (dwCount == 1) { iColorType = COLORTYPE_GRAY; - FX_FLOAT g = pEntry->GetNumberAt(0) * 255; + float g = pEntry->GetNumberAt(0) * 255; return ArgbEncode(255, (int)g, (int)g, (int)g); } if (dwCount == 3) { iColorType = COLORTYPE_RGB; - FX_FLOAT r = pEntry->GetNumberAt(0) * 255; - FX_FLOAT g = pEntry->GetNumberAt(1) * 255; - FX_FLOAT b = pEntry->GetNumberAt(2) * 255; + float r = pEntry->GetNumberAt(0) * 255; + float g = pEntry->GetNumberAt(1) * 255; + float b = pEntry->GetNumberAt(2) * 255; return ArgbEncode(255, (int)r, (int)g, (int)b); } if (dwCount == 4) { iColorType = COLORTYPE_CMYK; - FX_FLOAT c = pEntry->GetNumberAt(0); - FX_FLOAT m = pEntry->GetNumberAt(1); - FX_FLOAT y = pEntry->GetNumberAt(2); - FX_FLOAT k = pEntry->GetNumberAt(3); - FX_FLOAT r = 1.0f - std::min(1.0f, c + k); - FX_FLOAT g = 1.0f - std::min(1.0f, m + k); - FX_FLOAT b = 1.0f - std::min(1.0f, y + k); + float c = pEntry->GetNumberAt(0); + float m = pEntry->GetNumberAt(1); + float y = pEntry->GetNumberAt(2); + float k = pEntry->GetNumberAt(3); + float r = 1.0f - std::min(1.0f, c + k); + float g = 1.0f - std::min(1.0f, m + k); + float b = 1.0f - std::min(1.0f, y + k); return ArgbEncode(255, (int)(r * 255), (int)(g * 255), (int)(b * 255)); } return color; } -FX_FLOAT CPDF_ApSettings::GetOriginalColor( - int index, - const CFX_ByteString& csEntry) const { +float CPDF_ApSettings::GetOriginalColor(int index, + const CFX_ByteString& csEntry) const { if (!m_pDict) return 0; @@ -71,7 +70,7 @@ FX_FLOAT CPDF_ApSettings::GetOriginalColor( } void CPDF_ApSettings::GetOriginalColor(int& iColorType, - FX_FLOAT fc[4], + float fc[4], const CFX_ByteString& csEntry) const { iColorType = COLORTYPE_TRANSPARENT; for (int i = 0; i < 4; i++) diff --git a/core/fpdfdoc/cpdf_apsettings.h b/core/fpdfdoc/cpdf_apsettings.h index ffddffdbe0..ba0b05bd2b 100644 --- a/core/fpdfdoc/cpdf_apsettings.h +++ b/core/fpdfdoc/cpdf_apsettings.h @@ -27,11 +27,11 @@ class CPDF_ApSettings { return GetColor(iColorType, "BC"); } - FX_FLOAT GetOriginalBorderColor(int index) const { + float GetOriginalBorderColor(int index) const { return GetOriginalColor(index, "BC"); } - void GetOriginalBorderColor(int& iColorType, FX_FLOAT fc[4]) const { + void GetOriginalBorderColor(int& iColorType, float fc[4]) const { GetOriginalColor(iColorType, fc, "BC"); } @@ -39,11 +39,11 @@ class CPDF_ApSettings { return GetColor(iColorType, "BG"); } - FX_FLOAT GetOriginalBackgroundColor(int index) const { + float GetOriginalBackgroundColor(int index) const { return GetOriginalColor(index, "BG"); } - void GetOriginalBackgroundColor(int& iColorType, FX_FLOAT fc[4]) const { + void GetOriginalBackgroundColor(int& iColorType, float fc[4]) const { GetOriginalColor(iColorType, fc, "BG"); } @@ -60,9 +60,9 @@ class CPDF_ApSettings { friend class CPDF_FormControl; FX_ARGB GetColor(int& iColorType, const CFX_ByteString& csEntry) const; - FX_FLOAT GetOriginalColor(int index, const CFX_ByteString& csEntry) const; + float GetOriginalColor(int index, const CFX_ByteString& csEntry) const; void GetOriginalColor(int& iColorType, - FX_FLOAT fc[4], + float fc[4], const CFX_ByteString& csEntry) const; CFX_WideString GetCaption(const CFX_ByteString& csEntry) const; diff --git a/core/fpdfdoc/cpdf_defaultappearance.cpp b/core/fpdfdoc/cpdf_defaultappearance.cpp index 19767650f3..1873c1ae58 100644 --- a/core/fpdfdoc/cpdf_defaultappearance.cpp +++ b/core/fpdfdoc/cpdf_defaultappearance.cpp @@ -37,7 +37,7 @@ CFX_ByteString CPDF_DefaultAppearance::GetFontString() { } void CPDF_DefaultAppearance::GetFont(CFX_ByteString& csFontNameTag, - FX_FLOAT& fFontSize) { + float& fFontSize) { csFontNameTag = ""; fFontSize = 0; if (m_csDA.IsEmpty()) @@ -110,7 +110,7 @@ CFX_ByteString CPDF_DefaultAppearance::GetColorString( } void CPDF_DefaultAppearance::GetColor(int& iColorType, - FX_FLOAT fc[4], + float fc[4], PaintOperation nOperation) { iColorType = COLORTYPE_TRANSPARENT; for (int c = 0; c < 4; c++) @@ -156,29 +156,29 @@ void CPDF_DefaultAppearance::GetColor(FX_ARGB& color, if (syntax.FindTagParamFromStart( (nOperation == PaintOperation::STROKE ? "G" : "g"), 1)) { iColorType = COLORTYPE_GRAY; - FX_FLOAT g = FX_atof(syntax.GetWord()) * 255 + 0.5f; + float g = FX_atof(syntax.GetWord()) * 255 + 0.5f; color = ArgbEncode(255, (int)g, (int)g, (int)g); return; } if (syntax.FindTagParamFromStart( (nOperation == PaintOperation::STROKE ? "RG" : "rg"), 3)) { iColorType = COLORTYPE_RGB; - FX_FLOAT r = FX_atof(syntax.GetWord()) * 255 + 0.5f; - FX_FLOAT g = FX_atof(syntax.GetWord()) * 255 + 0.5f; - FX_FLOAT b = FX_atof(syntax.GetWord()) * 255 + 0.5f; + float r = FX_atof(syntax.GetWord()) * 255 + 0.5f; + float g = FX_atof(syntax.GetWord()) * 255 + 0.5f; + float b = FX_atof(syntax.GetWord()) * 255 + 0.5f; color = ArgbEncode(255, (int)r, (int)g, (int)b); return; } if (syntax.FindTagParamFromStart( (nOperation == PaintOperation::STROKE ? "K" : "k"), 4)) { iColorType = COLORTYPE_CMYK; - FX_FLOAT c = FX_atof(syntax.GetWord()); - FX_FLOAT m = FX_atof(syntax.GetWord()); - FX_FLOAT y = FX_atof(syntax.GetWord()); - FX_FLOAT k = FX_atof(syntax.GetWord()); - FX_FLOAT r = 1.0f - std::min(1.0f, c + k); - FX_FLOAT g = 1.0f - std::min(1.0f, m + k); - FX_FLOAT b = 1.0f - std::min(1.0f, y + k); + float c = FX_atof(syntax.GetWord()); + float m = FX_atof(syntax.GetWord()); + float y = FX_atof(syntax.GetWord()); + float k = FX_atof(syntax.GetWord()); + float r = 1.0f - std::min(1.0f, c + k); + float g = 1.0f - std::min(1.0f, m + k); + float b = 1.0f - std::min(1.0f, y + k); color = ArgbEncode(255, (int)(r * 255 + 0.5f), (int)(g * 255 + 0.5f), (int)(b * 255 + 0.5f)); } @@ -216,7 +216,7 @@ CFX_Matrix CPDF_DefaultAppearance::GetTextMatrix() { if (!syntax.FindTagParamFromStart("Tm", 6)) return CFX_Matrix(); - FX_FLOAT f[6]; + float f[6]; for (int i = 0; i < 6; i++) f[i] = FX_atof(syntax.GetWord()); return CFX_Matrix(f); diff --git a/core/fpdfdoc/cpdf_defaultappearance.h b/core/fpdfdoc/cpdf_defaultappearance.h index 4fd32ebd0c..0edc18c31f 100644 --- a/core/fpdfdoc/cpdf_defaultappearance.h +++ b/core/fpdfdoc/cpdf_defaultappearance.h @@ -29,13 +29,13 @@ class CPDF_DefaultAppearance { bool HasFont(); CFX_ByteString GetFontString(); - void GetFont(CFX_ByteString& csFontNameTag, FX_FLOAT& fFontSize); + void GetFont(CFX_ByteString& csFontNameTag, float& fFontSize); bool HasColor(PaintOperation nOperation = PaintOperation::FILL); CFX_ByteString GetColorString( PaintOperation nOperation = PaintOperation::FILL); void GetColor(int& iColorType, - FX_FLOAT fc[4], + float fc[4], PaintOperation nOperation = PaintOperation::FILL); void GetColor(FX_ARGB& color, int& iColorType, diff --git a/core/fpdfdoc/cpdf_dest.cpp b/core/fpdfdoc/cpdf_dest.cpp index 11264f729d..ca380be957 100644 --- a/core/fpdfdoc/cpdf_dest.cpp +++ b/core/fpdfdoc/cpdf_dest.cpp @@ -113,7 +113,7 @@ bool CPDF_Dest::GetXYZ(bool* pHasX, return true; } -FX_FLOAT CPDF_Dest::GetParam(int index) { +float CPDF_Dest::GetParam(int index) { CPDF_Array* pArray = ToArray(m_pObj); return pArray ? pArray->GetNumberAt(2 + index) : 0; } diff --git a/core/fpdfdoc/cpdf_dest.h b/core/fpdfdoc/cpdf_dest.h index 527d1dcf8b..47559495a4 100644 --- a/core/fpdfdoc/cpdf_dest.h +++ b/core/fpdfdoc/cpdf_dest.h @@ -23,7 +23,7 @@ class CPDF_Dest { int GetPageIndex(CPDF_Document* pDoc); uint32_t GetPageObjNum(); int GetZoomMode(); - FX_FLOAT GetParam(int index); + float GetParam(int index); bool GetXYZ(bool* pHasX, bool* pHasY, diff --git a/core/fpdfdoc/cpdf_formcontrol.cpp b/core/fpdfdoc/cpdf_formcontrol.cpp index 0a5363ed96..b8a11cc204 100644 --- a/core/fpdfdoc/cpdf_formcontrol.cpp +++ b/core/fpdfdoc/cpdf_formcontrol.cpp @@ -216,13 +216,13 @@ FX_ARGB CPDF_FormControl::GetColor(int& iColorType, return GetMK().GetColor(iColorType, csEntry); } -FX_FLOAT CPDF_FormControl::GetOriginalColor(int index, - const CFX_ByteString& csEntry) { +float CPDF_FormControl::GetOriginalColor(int index, + const CFX_ByteString& csEntry) { return GetMK().GetOriginalColor(index, csEntry); } void CPDF_FormControl::GetOriginalColor(int& iColorType, - FX_FLOAT fc[4], + float fc[4], const CFX_ByteString& csEntry) { GetMK().GetOriginalColor(iColorType, fc, csEntry); } @@ -282,7 +282,7 @@ CPDF_DefaultAppearance CPDF_FormControl::GetDefaultAppearance() { CPDF_Font* CPDF_FormControl::GetDefaultControlFont() { CPDF_DefaultAppearance cDA = GetDefaultAppearance(); CFX_ByteString csFontNameTag; - FX_FLOAT fFontSize; + float fFontSize; cDA.GetFont(csFontNameTag, fFontSize); if (csFontNameTag.IsEmpty()) return nullptr; diff --git a/core/fpdfdoc/cpdf_formcontrol.h b/core/fpdfdoc/cpdf_formcontrol.h index c0dad39098..fff77fb32d 100644 --- a/core/fpdfdoc/cpdf_formcontrol.h +++ b/core/fpdfdoc/cpdf_formcontrol.h @@ -72,11 +72,11 @@ class CPDF_FormControl { FX_ARGB GetBorderColor(int& iColorType) { return GetColor(iColorType, "BC"); } - FX_FLOAT GetOriginalBorderColor(int index) { + float GetOriginalBorderColor(int index) { return GetOriginalColor(index, "BC"); } - void GetOriginalBorderColor(int& iColorType, FX_FLOAT fc[4]) { + void GetOriginalBorderColor(int& iColorType, float fc[4]) { GetOriginalColor(iColorType, fc, "BC"); } @@ -84,11 +84,11 @@ class CPDF_FormControl { return GetColor(iColorType, "BG"); } - FX_FLOAT GetOriginalBackgroundColor(int index) { + float GetOriginalBackgroundColor(int index) { return GetOriginalColor(index, "BG"); } - void GetOriginalBackgroundColor(int& iColorType, FX_FLOAT fc[4]) { + void GetOriginalBackgroundColor(int& iColorType, float fc[4]) { GetOriginalColor(iColorType, fc, "BG"); } @@ -117,9 +117,9 @@ class CPDF_FormControl { void SetOnStateName(const CFX_ByteString& csOn); void CheckControl(bool bChecked); FX_ARGB GetColor(int& iColorType, const CFX_ByteString& csEntry); - FX_FLOAT GetOriginalColor(int index, const CFX_ByteString& csEntry); + float GetOriginalColor(int index, const CFX_ByteString& csEntry); void GetOriginalColor(int& iColorType, - FX_FLOAT fc[4], + float fc[4], const CFX_ByteString& csEntry); CFX_WideString GetCaption(const CFX_ByteString& csEntry); diff --git a/core/fpdfdoc/cpdf_formfield.h b/core/fpdfdoc/cpdf_formfield.h index 0cb0a481c2..35eaca4866 100644 --- a/core/fpdfdoc/cpdf_formfield.h +++ b/core/fpdfdoc/cpdf_formfield.h @@ -125,7 +125,7 @@ class CPDF_FormField { bool bNotify = false); #endif // PDF_ENABLE_XFA - FX_FLOAT GetFontSize() const { return m_FontSize; } + float GetFontSize() const { return m_FontSize; } CPDF_Font* GetFont() const { return m_pFont; } private: @@ -160,7 +160,7 @@ class CPDF_FormField { CPDF_InterForm* const m_pForm; CPDF_Dictionary* m_pDict; std::vector<CPDF_FormControl*> m_ControlList; // Owned by InterForm parent. - FX_FLOAT m_FontSize; + float m_FontSize; CPDF_Font* m_pFont; }; diff --git a/core/fpdfdoc/cpdf_iconfit.cpp b/core/fpdfdoc/cpdf_iconfit.cpp index aedb785912..0f05d7de35 100644 --- a/core/fpdfdoc/cpdf_iconfit.cpp +++ b/core/fpdfdoc/cpdf_iconfit.cpp @@ -28,7 +28,7 @@ bool CPDF_IconFit::IsProportionalScale() { return m_pDict ? m_pDict->GetStringFor("S", "P") != "A" : true; } -void CPDF_IconFit::GetIconPosition(FX_FLOAT& fLeft, FX_FLOAT& fBottom) { +void CPDF_IconFit::GetIconPosition(float& fLeft, float& fBottom) { fLeft = fBottom = 0.5; if (!m_pDict) return; diff --git a/core/fpdfdoc/cpdf_iconfit.h b/core/fpdfdoc/cpdf_iconfit.h index 37df48d43e..6e3b8cf50a 100644 --- a/core/fpdfdoc/cpdf_iconfit.h +++ b/core/fpdfdoc/cpdf_iconfit.h @@ -19,7 +19,7 @@ class CPDF_IconFit { ScaleMethod GetScaleMethod(); bool IsProportionalScale(); - void GetIconPosition(FX_FLOAT& fLeft, FX_FLOAT& fBottom); + void GetIconPosition(float& fLeft, float& fBottom); bool GetFittingBounds(); const CPDF_Dictionary* GetDict() const { return m_pDict; } diff --git a/core/fpdfdoc/cpdf_variabletext.cpp b/core/fpdfdoc/cpdf_variabletext.cpp index aa393f7657..5dabf8db0c 100644 --- a/core/fpdfdoc/cpdf_variabletext.cpp +++ b/core/fpdfdoc/cpdf_variabletext.cpp @@ -773,7 +773,7 @@ const CFX_FloatRect& CPDF_VariableText::GetPlateRect() const { return m_rcPlate; } -FX_FLOAT CPDF_VariableText::GetWordFontSize(const CPVT_WordInfo& WordInfo) { +float CPDF_VariableText::GetWordFontSize(const CPVT_WordInfo& WordInfo) { return GetFontSize(); } @@ -781,66 +781,64 @@ int32_t CPDF_VariableText::GetWordFontIndex(const CPVT_WordInfo& WordInfo) { return WordInfo.nFontIndex; } -FX_FLOAT CPDF_VariableText::GetWordWidth(int32_t nFontIndex, - uint16_t Word, - uint16_t SubWord, - FX_FLOAT fCharSpace, - int32_t nHorzScale, - FX_FLOAT fFontSize, - FX_FLOAT fWordTail) { +float CPDF_VariableText::GetWordWidth(int32_t nFontIndex, + uint16_t Word, + uint16_t SubWord, + float fCharSpace, + int32_t nHorzScale, + float fFontSize, + float fWordTail) { return (GetCharWidth(nFontIndex, Word, SubWord) * fFontSize * kFontScale + fCharSpace) * nHorzScale * kScalePercent + fWordTail; } -FX_FLOAT CPDF_VariableText::GetWordWidth(const CPVT_WordInfo& WordInfo) { +float CPDF_VariableText::GetWordWidth(const CPVT_WordInfo& WordInfo) { return GetWordWidth(GetWordFontIndex(WordInfo), WordInfo.Word, GetSubWord(), GetCharSpace(WordInfo), GetHorzScale(WordInfo), GetWordFontSize(WordInfo), WordInfo.fWordTail); } -FX_FLOAT CPDF_VariableText::GetLineAscent(const CPVT_SectionInfo& SecInfo) { +float CPDF_VariableText::GetLineAscent(const CPVT_SectionInfo& SecInfo) { return GetFontAscent(GetDefaultFontIndex(), GetFontSize()); } -FX_FLOAT CPDF_VariableText::GetLineDescent(const CPVT_SectionInfo& SecInfo) { +float CPDF_VariableText::GetLineDescent(const CPVT_SectionInfo& SecInfo) { return GetFontDescent(GetDefaultFontIndex(), GetFontSize()); } -FX_FLOAT CPDF_VariableText::GetFontAscent(int32_t nFontIndex, - FX_FLOAT fFontSize) { - return (FX_FLOAT)GetTypeAscent(nFontIndex) * fFontSize * kFontScale; +float CPDF_VariableText::GetFontAscent(int32_t nFontIndex, float fFontSize) { + return (float)GetTypeAscent(nFontIndex) * fFontSize * kFontScale; } -FX_FLOAT CPDF_VariableText::GetFontDescent(int32_t nFontIndex, - FX_FLOAT fFontSize) { - return (FX_FLOAT)GetTypeDescent(nFontIndex) * fFontSize * kFontScale; +float CPDF_VariableText::GetFontDescent(int32_t nFontIndex, float fFontSize) { + return (float)GetTypeDescent(nFontIndex) * fFontSize * kFontScale; } -FX_FLOAT CPDF_VariableText::GetWordAscent(const CPVT_WordInfo& WordInfo, - FX_FLOAT fFontSize) { +float CPDF_VariableText::GetWordAscent(const CPVT_WordInfo& WordInfo, + float fFontSize) { return GetFontAscent(GetWordFontIndex(WordInfo), fFontSize); } -FX_FLOAT CPDF_VariableText::GetWordDescent(const CPVT_WordInfo& WordInfo, - FX_FLOAT fFontSize) { +float CPDF_VariableText::GetWordDescent(const CPVT_WordInfo& WordInfo, + float fFontSize) { return GetFontDescent(GetWordFontIndex(WordInfo), fFontSize); } -FX_FLOAT CPDF_VariableText::GetWordAscent(const CPVT_WordInfo& WordInfo) { +float CPDF_VariableText::GetWordAscent(const CPVT_WordInfo& WordInfo) { return GetFontAscent(GetWordFontIndex(WordInfo), GetWordFontSize(WordInfo)); } -FX_FLOAT CPDF_VariableText::GetWordDescent(const CPVT_WordInfo& WordInfo) { +float CPDF_VariableText::GetWordDescent(const CPVT_WordInfo& WordInfo) { return GetFontDescent(GetWordFontIndex(WordInfo), GetWordFontSize(WordInfo)); } -FX_FLOAT CPDF_VariableText::GetLineLeading(const CPVT_SectionInfo& SecInfo) { +float CPDF_VariableText::GetLineLeading(const CPVT_SectionInfo& SecInfo) { return m_fLineLeading; } -FX_FLOAT CPDF_VariableText::GetLineIndent(const CPVT_SectionInfo& SecInfo) { +float CPDF_VariableText::GetLineIndent(const CPVT_SectionInfo& SecInfo) { return 0.0f; } @@ -848,7 +846,7 @@ int32_t CPDF_VariableText::GetAlignment(const CPVT_SectionInfo& SecInfo) { return m_nAlignment; } -FX_FLOAT CPDF_VariableText::GetCharSpace(const CPVT_WordInfo& WordInfo) { +float CPDF_VariableText::GetCharSpace(const CPVT_WordInfo& WordInfo) { return m_fCharSpace; } @@ -979,7 +977,7 @@ CPVT_FloatRect CPDF_VariableText::Rearrange(const CPVT_WordRange& PlaceRange) { return rcRet; } -FX_FLOAT CPDF_VariableText::GetAutoFontSize() { +float CPDF_VariableText::GetAutoFontSize() { int32_t nTotal = sizeof(gFontSizeSteps) / sizeof(uint8_t); if (IsMultiLine()) nTotal /= 4; @@ -1002,10 +1000,10 @@ FX_FLOAT CPDF_VariableText::GetAutoFontSize() { continue; } } - return (FX_FLOAT)gFontSizeSteps[nMid]; + return (float)gFontSizeSteps[nMid]; } -bool CPDF_VariableText::IsBigger(FX_FLOAT fFontSize) const { +bool CPDF_VariableText::IsBigger(float fFontSize) const { CFX_SizeF szTotal; for (int32_t s = 0, sz = m_SectionArray.GetSize(); s < sz; s++) { if (CSection* pSection = m_SectionArray.GetAt(s)) { @@ -1024,8 +1022,8 @@ bool CPDF_VariableText::IsBigger(FX_FLOAT fFontSize) const { CPVT_FloatRect CPDF_VariableText::RearrangeSections( const CPVT_WordRange& PlaceRange) { CPVT_WordPlace place; - FX_FLOAT fPosY = 0; - FX_FLOAT fOldHeight; + float fPosY = 0; + float fOldHeight; int32_t nSSecIndex = PlaceRange.BeginPos.nSecIndex; int32_t nESecIndex = PlaceRange.EndPos.nSecIndex; CPVT_FloatRect rcRet; diff --git a/core/fpdfdoc/cpdf_variabletext.h b/core/fpdfdoc/cpdf_variabletext.h index 3bec89abec..59fe12402a 100644 --- a/core/fpdfdoc/cpdf_variabletext.h +++ b/core/fpdfdoc/cpdf_variabletext.h @@ -93,10 +93,10 @@ class CPDF_VariableText { void SetAlignment(int32_t nFormat) { m_nAlignment = nFormat; } void SetPasswordChar(uint16_t wSubWord) { m_wSubWord = wSubWord; } void SetLimitChar(int32_t nLimitChar) { m_nLimitChar = nLimitChar; } - void SetCharSpace(FX_FLOAT fCharSpace) { m_fCharSpace = fCharSpace; } + void SetCharSpace(float fCharSpace) { m_fCharSpace = fCharSpace; } void SetMultiLine(bool bMultiLine) { m_bMultiLine = bMultiLine; } void SetAutoReturn(bool bAuto) { m_bLimitWidth = bAuto; } - void SetFontSize(FX_FLOAT fFontSize) { m_fFontSize = fFontSize; } + void SetFontSize(float fFontSize) { m_fFontSize = fFontSize; } void SetCharArray(int32_t nCharArray) { m_nCharArray = nCharArray; } void SetAutoFontSize(bool bAuto) { m_bAutoFontSize = bAuto; } void Initialize(); @@ -120,14 +120,14 @@ class CPDF_VariableText { CPVT_WordPlace BackSpaceWord(const CPVT_WordPlace& place); int32_t GetTotalWords() const; - FX_FLOAT GetFontSize() const { return m_fFontSize; } + float GetFontSize() const { return m_fFontSize; } int32_t GetAlignment() const { return m_nAlignment; } uint16_t GetPasswordChar() const { return GetSubWord(); } int32_t GetCharArray() const { return m_nCharArray; } int32_t GetLimitChar() const { return m_nLimitChar; } bool IsMultiLine() const { return m_bMultiLine; } int32_t GetHorzScale() const { return m_nHorzScale; } - FX_FLOAT GetCharSpace() const { return m_fCharSpace; } + float GetCharSpace() const { return m_fCharSpace; } CPVT_WordPlace GetBeginWordPlace() const; CPVT_WordPlace GetEndWordPlace() const; CPVT_WordPlace GetPrevWordPlace(const CPVT_WordPlace& place) const; @@ -149,8 +149,8 @@ class CPDF_VariableText { uint16_t GetSubWord() const { return m_wSubWord; } - FX_FLOAT GetPlateWidth() const { return m_rcPlate.right - m_rcPlate.left; } - FX_FLOAT GetPlateHeight() const { return m_rcPlate.top - m_rcPlate.bottom; } + float GetPlateWidth() const { return m_rcPlate.right - m_rcPlate.left; } + float GetPlateHeight() const { return m_rcPlate.top - m_rcPlate.bottom; } CFX_SizeF GetPlateSize() const; CFX_PointF GetBTPoint() const; CFX_PointF GetETPoint() const; @@ -181,28 +181,28 @@ class CPDF_VariableText { bool SetWordInfo(const CPVT_WordPlace& place, const CPVT_WordInfo& wordinfo); bool GetLineInfo(const CPVT_WordPlace& place, CPVT_LineInfo& lineinfo); bool GetSectionInfo(const CPVT_WordPlace& place, CPVT_SectionInfo& secinfo); - FX_FLOAT GetWordFontSize(const CPVT_WordInfo& WordInfo); - FX_FLOAT GetWordWidth(int32_t nFontIndex, - uint16_t Word, - uint16_t SubWord, - FX_FLOAT fCharSpace, - int32_t nHorzScale, - FX_FLOAT fFontSize, - FX_FLOAT fWordTail); - FX_FLOAT GetWordWidth(const CPVT_WordInfo& WordInfo); - FX_FLOAT GetWordAscent(const CPVT_WordInfo& WordInfo, FX_FLOAT fFontSize); - FX_FLOAT GetWordDescent(const CPVT_WordInfo& WordInfo, FX_FLOAT fFontSize); - FX_FLOAT GetWordAscent(const CPVT_WordInfo& WordInfo); - FX_FLOAT GetWordDescent(const CPVT_WordInfo& WordInfo); - FX_FLOAT GetLineAscent(const CPVT_SectionInfo& SecInfo); - FX_FLOAT GetLineDescent(const CPVT_SectionInfo& SecInfo); - FX_FLOAT GetFontAscent(int32_t nFontIndex, FX_FLOAT fFontSize); - FX_FLOAT GetFontDescent(int32_t nFontIndex, FX_FLOAT fFontSize); + float GetWordFontSize(const CPVT_WordInfo& WordInfo); + float GetWordWidth(int32_t nFontIndex, + uint16_t Word, + uint16_t SubWord, + float fCharSpace, + int32_t nHorzScale, + float fFontSize, + float fWordTail); + float GetWordWidth(const CPVT_WordInfo& WordInfo); + float GetWordAscent(const CPVT_WordInfo& WordInfo, float fFontSize); + float GetWordDescent(const CPVT_WordInfo& WordInfo, float fFontSize); + float GetWordAscent(const CPVT_WordInfo& WordInfo); + float GetWordDescent(const CPVT_WordInfo& WordInfo); + float GetLineAscent(const CPVT_SectionInfo& SecInfo); + float GetLineDescent(const CPVT_SectionInfo& SecInfo); + float GetFontAscent(int32_t nFontIndex, float fFontSize); + float GetFontDescent(int32_t nFontIndex, float fFontSize); int32_t GetWordFontIndex(const CPVT_WordInfo& WordInfo); - FX_FLOAT GetCharSpace(const CPVT_WordInfo& WordInfo); + float GetCharSpace(const CPVT_WordInfo& WordInfo); int32_t GetHorzScale(const CPVT_WordInfo& WordInfo); - FX_FLOAT GetLineLeading(const CPVT_SectionInfo& SecInfo); - FX_FLOAT GetLineIndent(const CPVT_SectionInfo& SecInfo); + float GetLineLeading(const CPVT_SectionInfo& SecInfo); + float GetLineIndent(const CPVT_SectionInfo& SecInfo); int32_t GetAlignment(const CPVT_SectionInfo& SecInfo); void ClearSectionRightWords(const CPVT_WordPlace& place); @@ -215,8 +215,8 @@ class CPDF_VariableText { CPVT_WordPlace ClearRightWord(const CPVT_WordPlace& place); CPVT_FloatRect Rearrange(const CPVT_WordRange& PlaceRange); - FX_FLOAT GetAutoFontSize(); - bool IsBigger(FX_FLOAT fFontSize) const; + float GetAutoFontSize(); + bool IsBigger(float fFontSize) const; CPVT_FloatRect RearrangeSections(const CPVT_WordRange& PlaceRange); void ResetSectionArray(); @@ -228,11 +228,11 @@ class CPDF_VariableText { bool m_bLimitWidth; bool m_bAutoFontSize; int32_t m_nAlignment; - FX_FLOAT m_fLineLeading; - FX_FLOAT m_fCharSpace; + float m_fLineLeading; + float m_fCharSpace; int32_t m_nHorzScale; uint16_t m_wSubWord; - FX_FLOAT m_fFontSize; + float m_fFontSize; bool m_bInitial; CPDF_VariableText::Provider* m_pVTProvider; std::unique_ptr<CPDF_VariableText::Iterator> m_pVTIterator; diff --git a/core/fpdfdoc/cpvt_color.cpp b/core/fpdfdoc/cpvt_color.cpp index e0e6a26db7..584a85aaec 100644 --- a/core/fpdfdoc/cpvt_color.cpp +++ b/core/fpdfdoc/cpvt_color.cpp @@ -15,16 +15,16 @@ CPVT_Color CPVT_Color::ParseColor(const CFX_ByteString& str) { return CPVT_Color(CPVT_Color::kGray, FX_atof(syntax.GetWord())); if (syntax.FindTagParamFromStart("rg", 3)) { - FX_FLOAT f1 = FX_atof(syntax.GetWord()); - FX_FLOAT f2 = FX_atof(syntax.GetWord()); - FX_FLOAT f3 = FX_atof(syntax.GetWord()); + float f1 = FX_atof(syntax.GetWord()); + float f2 = FX_atof(syntax.GetWord()); + float f3 = FX_atof(syntax.GetWord()); return CPVT_Color(CPVT_Color::kRGB, f1, f2, f3); } if (syntax.FindTagParamFromStart("k", 4)) { - FX_FLOAT f1 = FX_atof(syntax.GetWord()); - FX_FLOAT f2 = FX_atof(syntax.GetWord()); - FX_FLOAT f3 = FX_atof(syntax.GetWord()); - FX_FLOAT f4 = FX_atof(syntax.GetWord()); + float f1 = FX_atof(syntax.GetWord()); + float f2 = FX_atof(syntax.GetWord()); + float f3 = FX_atof(syntax.GetWord()); + float f4 = FX_atof(syntax.GetWord()); return CPVT_Color(CPVT_Color::kCMYK, f1, f2, f3, f4); } return CPVT_Color(CPVT_Color::kTransparent); diff --git a/core/fpdfdoc/cpvt_color.h b/core/fpdfdoc/cpvt_color.h index 4d4942dbf9..2db3b8310e 100644 --- a/core/fpdfdoc/cpvt_color.h +++ b/core/fpdfdoc/cpvt_color.h @@ -15,10 +15,10 @@ struct CPVT_Color { enum Type { kTransparent = 0, kGray, kRGB, kCMYK }; CPVT_Color(Type type = kTransparent, - FX_FLOAT color1 = 0.0f, - FX_FLOAT color2 = 0.0f, - FX_FLOAT color3 = 0.0f, - FX_FLOAT color4 = 0.0f) + float color1 = 0.0f, + float color2 = 0.0f, + float color3 = 0.0f, + float color4 = 0.0f) : nColorType(type), fColor1(color1), fColor2(color2), @@ -26,10 +26,10 @@ struct CPVT_Color { fColor4(color4) {} Type nColorType; - FX_FLOAT fColor1; - FX_FLOAT fColor2; - FX_FLOAT fColor3; - FX_FLOAT fColor4; + float fColor1; + float fColor2; + float fColor3; + float fColor4; static CPVT_Color ParseColor(const CFX_ByteString& str); static CPVT_Color ParseColor(const CPDF_Array& array); diff --git a/core/fpdfdoc/cpvt_floatrect.h b/core/fpdfdoc/cpvt_floatrect.h index 6fc4b8ebce..a8b32dc7e5 100644 --- a/core/fpdfdoc/cpvt_floatrect.h +++ b/core/fpdfdoc/cpvt_floatrect.h @@ -13,10 +13,10 @@ class CPVT_FloatRect : public CFX_FloatRect { public: CPVT_FloatRect() { left = top = right = bottom = 0.0f; } - CPVT_FloatRect(FX_FLOAT other_left, - FX_FLOAT other_top, - FX_FLOAT other_right, - FX_FLOAT other_bottom) { + CPVT_FloatRect(float other_left, + float other_top, + float other_right, + float other_bottom) { left = other_left; top = other_top; right = other_right; @@ -32,7 +32,7 @@ class CPVT_FloatRect : public CFX_FloatRect { void Default() { left = top = right = bottom = 0.0f; } - FX_FLOAT Height() const { + float Height() const { if (top > bottom) return top - bottom; return bottom - top; diff --git a/core/fpdfdoc/cpvt_generateap.cpp b/core/fpdfdoc/cpvt_generateap.cpp index 15515151bc..7e895e5850 100644 --- a/core/fpdfdoc/cpvt_generateap.cpp +++ b/core/fpdfdoc/cpvt_generateap.cpp @@ -54,7 +54,7 @@ bool GenerateWidgetAP(CPDF_Document* pDoc, if (sFontName.IsEmpty()) return false; - FX_FLOAT fFontSize = FX_atof(syntax.GetWord()); + float fFontSize = FX_atof(syntax.GetWord()); CPVT_Color crText = CPVT_Color::ParseColor(DA); CPDF_Dictionary* pDRDict = pFormDict->GetDictFor("DR"); if (!pDRDict) @@ -109,7 +109,7 @@ bool GenerateWidgetAP(CPDF_Document* pDoc, } BorderStyle nBorderStyle = BorderStyle::SOLID; - FX_FLOAT fBorderWidth = 1; + float fBorderWidth = 1; CPVT_Dash dsBorder(3, 0, 0); CPVT_Color crLeftTop, crRightBottom; if (CPDF_Dictionary* pBSDict = pAnnotDict->GetDictFor("BS")) { @@ -353,7 +353,7 @@ bool GenerateWidgetAP(CPDF_Document* pDoc, int32_t nTop = pTi ? pTi->GetInteger() : 0; CFX_ByteTextBuf sBody; if (pOpts) { - FX_FLOAT fy = rcBody.top; + float fy = rcBody.top; for (size_t i = nTop, sz = pOpts->GetCount(); i < sz; i++) { if (IsFloatSmaller(fy, rcBody.bottom)) break; @@ -384,7 +384,7 @@ bool GenerateWidgetAP(CPDF_Document* pDoc, vt.Initialize(); vt.SetText(swItem); vt.RearrangeAll(); - FX_FLOAT fItemHeight = vt.GetContentRect().Height(); + float fItemHeight = vt.GetContentRect().Height(); if (bSelected) { CFX_FloatRect rcItem = CFX_FloatRect( rcBody.left, fy - fItemHeight, rcBody.right, fy); @@ -463,7 +463,7 @@ CFX_ByteString GetColorStringWithDefault(CPDF_Array* pColor, return CPVT_GenerateAP::GenerateColorAP(crDefaultColor, nOperation); } -FX_FLOAT GetBorderWidth(const CPDF_Dictionary& pAnnotDict) { +float GetBorderWidth(const CPDF_Dictionary& pAnnotDict) { if (CPDF_Dictionary* pBorderStyleDict = pAnnotDict.GetDictFor("BS")) { if (pBorderStyleDict->KeyExist("W")) return pBorderStyleDict->GetNumberFor("W"); @@ -552,7 +552,7 @@ std::unique_ptr<CPDF_Dictionary> GenerateExtGStateDict( pdfium::MakeUnique<CPDF_Dictionary>(pAnnotDict.GetByteStringPool()); pGSDict->SetNewFor<CPDF_String>("Type", "ExtGState", false); - FX_FLOAT fOpacity = + float fOpacity = pAnnotDict.KeyExist("CA") ? pAnnotDict.GetNumberFor("CA") : 1; pGSDict->SetNewFor<CPDF_Number>("CA", fOpacity); pGSDict->SetNewFor<CPDF_Number>("ca", fOpacity); @@ -630,11 +630,11 @@ CFX_ByteString GenerateTextSymbolAP(const CFX_FloatRect& rect) { sAppStream << CPVT_GenerateAP::GenerateColorAP( CPVT_Color(CPVT_Color::kRGB, 0, 0, 0), PaintOperation::STROKE); - const FX_FLOAT fBorderWidth = 1; + const float fBorderWidth = 1; sAppStream << fBorderWidth << " w\n"; - const FX_FLOAT fHalfWidth = fBorderWidth / 2; - const FX_FLOAT fTipDelta = 4; + const float fHalfWidth = fBorderWidth / 2; + const float fTipDelta = 4; CFX_FloatRect outerRect1 = rect; outerRect1.Deflate(fHalfWidth, fHalfWidth); @@ -644,7 +644,7 @@ CFX_ByteString GenerateTextSymbolAP(const CFX_FloatRect& rect) { outerRect2.left += fTipDelta; outerRect2.right = outerRect2.left + fTipDelta; outerRect2.top = outerRect2.bottom - fTipDelta; - FX_FLOAT outerRect2Middle = (outerRect2.left + outerRect2.right) / 2; + float outerRect2Middle = (outerRect2.left + outerRect2.right) / 2; // Draw outer boxes. sAppStream << outerRect1.left << " " << outerRect1.bottom << " m\n" @@ -658,8 +658,8 @@ CFX_ByteString GenerateTextSymbolAP(const CFX_FloatRect& rect) { // Draw inner lines. CFX_FloatRect lineRect = outerRect1; - const FX_FLOAT fXDelta = 2; - const FX_FLOAT fYDelta = (lineRect.top - lineRect.bottom) / 4; + const float fXDelta = 2; + const float fYDelta = (lineRect.top - lineRect.bottom) / 4; lineRect.left += fXDelta; lineRect.right -= fXDelta; @@ -744,7 +744,7 @@ bool CPVT_GenerateAP::GenerateCircleAP(CPDF_Document* pDoc, CPVT_Color(CPVT_Color::kRGB, 0, 0, 0), PaintOperation::STROKE); - FX_FLOAT fBorderWidth = GetBorderWidth(*pAnnotDict); + float fBorderWidth = GetBorderWidth(*pAnnotDict); bool bIsStrokeRect = fBorderWidth > 0; if (bIsStrokeRect) { @@ -762,15 +762,15 @@ bool CPVT_GenerateAP::GenerateCircleAP(CPDF_Document* pDoc, rect.Deflate(fBorderWidth / 2, fBorderWidth / 2); } - const FX_FLOAT fMiddleX = (rect.left + rect.right) / 2; - const FX_FLOAT fMiddleY = (rect.top + rect.bottom) / 2; + const float fMiddleX = (rect.left + rect.right) / 2; + const float fMiddleY = (rect.top + rect.bottom) / 2; // |fL| is precalculated approximate value of 4 * tan((3.14 / 2) / 4) / 3, // where |fL| * radius is a good approximation of control points for // arc with 90 degrees. - const FX_FLOAT fL = 0.5523f; - const FX_FLOAT fDeltaX = fL * rect.Width() / 2.0; - const FX_FLOAT fDeltaY = fL * rect.Height() / 2.0; + const float fL = 0.5523f; + const float fDeltaX = fL * rect.Width() / 2.0; + const float fDeltaY = fL * rect.Height() / 2.0; // Starting point sAppStream << fMiddleX << " " << rect.top << " m\n"; @@ -833,7 +833,7 @@ bool CPVT_GenerateAP::GenerateHighlightAP(CPDF_Document* pDoc, bool CPVT_GenerateAP::GenerateInkAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict) { - FX_FLOAT fBorderWidth = GetBorderWidth(*pAnnotDict); + float fBorderWidth = GetBorderWidth(*pAnnotDict); bool bIsStroke = fBorderWidth > 0; if (!bIsStroke) @@ -892,7 +892,7 @@ bool CPVT_GenerateAP::GenerateTextAP(CPDF_Document* pDoc, sAppStream << "/" << sExtGSDictName << " gs "; CFX_FloatRect rect = pAnnotDict->GetRectFor("Rect"); - const FX_FLOAT fNoteLength = 20; + const float fNoteLength = 20; CFX_FloatRect noteRect(rect.left, rect.bottom, rect.left + fNoteLength, rect.bottom + fNoteLength); pAnnotDict->SetRectFor("Rect", noteRect); @@ -921,7 +921,7 @@ bool CPVT_GenerateAP::GenerateUnderlineAP(CPDF_Document* pDoc, CFX_FloatRect rect = CPDF_Annot::RectFromQuadPoints(pAnnotDict); rect.Normalize(); - FX_FLOAT fLineWidth = 1.0; + float fLineWidth = 1.0; sAppStream << fLineWidth << " w " << rect.left << " " << rect.bottom + fLineWidth << " m " << rect.right << " " << rect.bottom + fLineWidth << " l S\n"; @@ -946,7 +946,7 @@ bool CPVT_GenerateAP::GeneratePopupAP(CPDF_Document* pDoc, sAppStream << GenerateColorAP(CPVT_Color(CPVT_Color::kRGB, 0, 0, 0), PaintOperation::STROKE); - const FX_FLOAT fBorderWidth = 1; + const float fBorderWidth = 1; sAppStream << fBorderWidth << " w\n"; CFX_FloatRect rect = pAnnotDict->GetRectFor("Rect"); @@ -988,7 +988,7 @@ bool CPVT_GenerateAP::GenerateSquareAP(CPDF_Document* pDoc, CPVT_Color(CPVT_Color::kRGB, 0, 0, 0), PaintOperation::STROKE); - FX_FLOAT fBorderWidth = GetBorderWidth(*pAnnotDict); + float fBorderWidth = GetBorderWidth(*pAnnotDict); bool bIsStrokeRect = fBorderWidth > 0; if (bIsStrokeRect) { @@ -1034,16 +1034,16 @@ bool CPVT_GenerateAP::GenerateSquigglyAP(CPDF_Document* pDoc, CFX_FloatRect rect = CPDF_Annot::RectFromQuadPoints(pAnnotDict); rect.Normalize(); - FX_FLOAT fLineWidth = 1.0; + float fLineWidth = 1.0; sAppStream << fLineWidth << " w "; - const FX_FLOAT fDelta = 2.0; - const FX_FLOAT fTop = rect.bottom + fDelta; - const FX_FLOAT fBottom = rect.bottom; + const float fDelta = 2.0; + const float fTop = rect.bottom + fDelta; + const float fBottom = rect.bottom; sAppStream << rect.left << " " << fTop << " m "; - FX_FLOAT fX = rect.left + fDelta; + float fX = rect.left + fDelta; bool isUpwards = false; while (fX < rect.right) { @@ -1053,7 +1053,7 @@ bool CPVT_GenerateAP::GenerateSquigglyAP(CPDF_Document* pDoc, isUpwards = !isUpwards; } - FX_FLOAT fRemainder = rect.right - (fX - fDelta); + float fRemainder = rect.right - (fX - fDelta); if (isUpwards) sAppStream << rect.right << " " << fBottom + fRemainder << " l "; else @@ -1083,8 +1083,8 @@ bool CPVT_GenerateAP::GenerateStrikeOutAP(CPDF_Document* pDoc, CFX_FloatRect rect = CPDF_Annot::RectFromQuadPoints(pAnnotDict); rect.Normalize(); - FX_FLOAT fLineWidth = 1.0; - FX_FLOAT fY = (rect.top + rect.bottom) / 2; + float fLineWidth = 1.0; + float fY = (rect.top + rect.bottom) / 2; sAppStream << fLineWidth << " w " << rect.left << " " << fY << " m " << rect.right << " " << fY << " l S\n"; @@ -1184,7 +1184,7 @@ CFX_ByteString CPVT_GenerateAP::GenerateEditAP( // Static. CFX_ByteString CPVT_GenerateAP::GenerateBorderAP( const CFX_FloatRect& rect, - FX_FLOAT fWidth, + float fWidth, const CPVT_Color& color, const CPVT_Color& crLeftTop, const CPVT_Color& crRightBottom, @@ -1192,12 +1192,12 @@ CFX_ByteString CPVT_GenerateAP::GenerateBorderAP( const CPVT_Dash& dash) { CFX_ByteTextBuf sAppStream; CFX_ByteString sColor; - FX_FLOAT fLeft = rect.left; - FX_FLOAT fRight = rect.right; - FX_FLOAT fTop = rect.top; - FX_FLOAT fBottom = rect.bottom; + float fLeft = rect.left; + float fRight = rect.right; + float fTop = rect.top; + float fBottom = rect.bottom; if (fWidth > 0.0f) { - FX_FLOAT fHalfWidth = fWidth / 2.0f; + float fHalfWidth = fWidth / 2.0f; switch (nStyle) { default: case BorderStyle::SOLID: @@ -1355,7 +1355,7 @@ CFX_ByteString CPVT_GenerateAP::GetWordRenderString( // Static. CFX_ByteString CPVT_GenerateAP::GetFontSetString(IPVT_FontMap* pFontMap, int32_t nFontIndex, - FX_FLOAT fFontSize) { + float fFontSize) { CFX_ByteTextBuf sRet; if (pFontMap) { CFX_ByteString sFontAlias = pFontMap->GetPDFFontAlias(nFontIndex); diff --git a/core/fpdfdoc/cpvt_generateap.h b/core/fpdfdoc/cpvt_generateap.h index 62a84531ee..c558636255 100644 --- a/core/fpdfdoc/cpvt_generateap.h +++ b/core/fpdfdoc/cpvt_generateap.h @@ -52,7 +52,7 @@ class CPVT_GenerateAP { bool bContinuous, uint16_t SubWord); static CFX_ByteString GenerateBorderAP(const CFX_FloatRect& rect, - FX_FLOAT fWidth, + float fWidth, const CPVT_Color& color, const CPVT_Color& crLeftTop, const CPVT_Color& crRightBottom, @@ -68,7 +68,7 @@ class CPVT_GenerateAP { static CFX_ByteString GetWordRenderString(const CFX_ByteString& strWords); static CFX_ByteString GetFontSetString(IPVT_FontMap* pFontMap, int32_t nFontIndex, - FX_FLOAT fFontSize); + float fFontSize); }; #endif // CORE_FPDFDOC_CPVT_GENERATEAP_H_ diff --git a/core/fpdfdoc/cpvt_line.h b/core/fpdfdoc/cpvt_line.h index 47c3e84d6a..087034d3d5 100644 --- a/core/fpdfdoc/cpvt_line.h +++ b/core/fpdfdoc/cpvt_line.h @@ -18,9 +18,9 @@ class CPVT_Line { CPVT_WordPlace lineplace; CPVT_WordPlace lineEnd; CFX_PointF ptLine; - FX_FLOAT fLineWidth; - FX_FLOAT fLineAscent; - FX_FLOAT fLineDescent; + float fLineWidth; + float fLineAscent; + float fLineDescent; }; inline CPVT_Line::CPVT_Line() diff --git a/core/fpdfdoc/cpvt_lineinfo.h b/core/fpdfdoc/cpvt_lineinfo.h index 8fb10de250..96a3234380 100644 --- a/core/fpdfdoc/cpvt_lineinfo.h +++ b/core/fpdfdoc/cpvt_lineinfo.h @@ -16,11 +16,11 @@ class CPVT_LineInfo { int32_t nTotalWord; int32_t nBeginWordIndex; int32_t nEndWordIndex; - FX_FLOAT fLineX; - FX_FLOAT fLineY; - FX_FLOAT fLineWidth; - FX_FLOAT fLineAscent; - FX_FLOAT fLineDescent; + float fLineX; + float fLineY; + float fLineWidth; + float fLineAscent; + float fLineDescent; }; inline CPVT_LineInfo::CPVT_LineInfo() diff --git a/core/fpdfdoc/cpvt_secprops.h b/core/fpdfdoc/cpvt_secprops.h index d1c4b589f1..93829f9b00 100644 --- a/core/fpdfdoc/cpvt_secprops.h +++ b/core/fpdfdoc/cpvt_secprops.h @@ -12,7 +12,7 @@ struct CPVT_SecProps { CPVT_SecProps() : fLineLeading(0.0f), fLineIndent(0.0f), nAlignment(0) {} - CPVT_SecProps(FX_FLOAT lineLeading, FX_FLOAT lineIndent, int32_t alignment) + CPVT_SecProps(float lineLeading, float lineIndent, int32_t alignment) : fLineLeading(lineLeading), fLineIndent(lineIndent), nAlignment(alignment) {} @@ -22,8 +22,8 @@ struct CPVT_SecProps { fLineIndent(other.fLineIndent), nAlignment(other.nAlignment) {} - FX_FLOAT fLineLeading; - FX_FLOAT fLineIndent; + float fLineLeading; + float fLineIndent; int32_t nAlignment; }; diff --git a/core/fpdfdoc/cpvt_word.h b/core/fpdfdoc/cpvt_word.h index 540f0416ad..28e192467b 100644 --- a/core/fpdfdoc/cpvt_word.h +++ b/core/fpdfdoc/cpvt_word.h @@ -19,11 +19,11 @@ class CPVT_Word { int32_t nCharset; CPVT_WordPlace WordPlace; CFX_PointF ptWord; - FX_FLOAT fAscent; - FX_FLOAT fDescent; - FX_FLOAT fWidth; + float fAscent; + float fDescent; + float fWidth; int32_t nFontIndex; - FX_FLOAT fFontSize; + float fFontSize; CPVT_WordProps WordProps; }; diff --git a/core/fpdfdoc/cpvt_wordinfo.h b/core/fpdfdoc/cpvt_wordinfo.h index 861534b0a5..00f5a45e70 100644 --- a/core/fpdfdoc/cpvt_wordinfo.h +++ b/core/fpdfdoc/cpvt_wordinfo.h @@ -25,9 +25,9 @@ struct CPVT_WordInfo { uint16_t Word; int32_t nCharset; - FX_FLOAT fWordX; - FX_FLOAT fWordY; - FX_FLOAT fWordTail; + float fWordX; + float fWordY; + float fWordTail; int32_t nFontIndex; std::unique_ptr<CPVT_WordProps> pWordProps; }; diff --git a/core/fpdfdoc/cpvt_wordprops.h b/core/fpdfdoc/cpvt_wordprops.h index 2b7084116a..2d0e5d51b3 100644 --- a/core/fpdfdoc/cpvt_wordprops.h +++ b/core/fpdfdoc/cpvt_wordprops.h @@ -22,12 +22,12 @@ struct CPVT_WordProps { nHorzScale(0) {} CPVT_WordProps(int32_t fontIndex, - FX_FLOAT fontSize, + float fontSize, FX_COLORREF wordColor = 0, CPDF_VariableText::ScriptType scriptType = CPDF_VariableText::ScriptType::Normal, int32_t wordStyle = 0, - FX_FLOAT charSpace = 0, + float charSpace = 0, int32_t horzScale = 100) : nFontIndex(fontIndex), fFontSize(fontSize), @@ -47,11 +47,11 @@ struct CPVT_WordProps { nHorzScale(other.nHorzScale) {} int32_t nFontIndex; - FX_FLOAT fFontSize; + float fFontSize; FX_COLORREF dwWordColor; CPDF_VariableText::ScriptType nScriptType; int32_t nWordStyle; - FX_FLOAT fCharSpace; + float fCharSpace; int32_t nHorzScale; }; diff --git a/core/fpdfdoc/csection.cpp b/core/fpdfdoc/csection.cpp index 490ef1b230..ce78418dc5 100644 --- a/core/fpdfdoc/csection.cpp +++ b/core/fpdfdoc/csection.cpp @@ -65,7 +65,7 @@ CPVT_FloatRect CSection::Rearrange() { return CTypeset(this).Typeset(); } -CFX_SizeF CSection::GetSectionSize(FX_FLOAT fFontSize) { +CFX_SizeF CSection::GetSectionSize(float fFontSize) { return CTypeset(this).GetEditSize(fFontSize); } @@ -154,8 +154,8 @@ CPVT_WordPlace CSection::SearchWordPlace(const CFX_PointF& point) const { int32_t nLeft = 0; int32_t nRight = m_LineArray.GetSize() - 1; int32_t nMid = m_LineArray.GetSize() / 2; - FX_FLOAT fTop = 0; - FX_FLOAT fBottom = 0; + float fTop = 0; + float fBottom = 0; while (nLeft <= nRight) { if (CLine* pLine = m_LineArray.GetAt(nMid)) { fTop = pLine->m_LineInfo.fLineY - pLine->m_LineInfo.fLineAscent - @@ -195,7 +195,7 @@ CPVT_WordPlace CSection::SearchWordPlace(const CFX_PointF& point) const { } CPVT_WordPlace CSection::SearchWordPlace( - FX_FLOAT fx, + float fx, const CPVT_WordPlace& lineplace) const { if (CLine* pLine = m_LineArray.GetAt(lineplace.nLineIndex)) { return SearchWordPlace( @@ -206,7 +206,7 @@ CPVT_WordPlace CSection::SearchWordPlace( return GetBeginWordPlace(); } -CPVT_WordPlace CSection::SearchWordPlace(FX_FLOAT fx, +CPVT_WordPlace CSection::SearchWordPlace(float fx, const CPVT_WordRange& range) const { CPVT_WordPlace wordplace = range.BeginPos; wordplace.nWordIndex = -1; diff --git a/core/fpdfdoc/csection.h b/core/fpdfdoc/csection.h index a2ac43b102..b82409dc6f 100644 --- a/core/fpdfdoc/csection.h +++ b/core/fpdfdoc/csection.h @@ -33,17 +33,16 @@ class CSection final { void ClearWords(const CPVT_WordRange& PlaceRange); void ClearWord(const CPVT_WordPlace& place); CPVT_FloatRect Rearrange(); - CFX_SizeF GetSectionSize(FX_FLOAT fFontSize); + CFX_SizeF GetSectionSize(float fFontSize); CPVT_WordPlace GetBeginWordPlace() const; CPVT_WordPlace GetEndWordPlace() const; CPVT_WordPlace GetPrevWordPlace(const CPVT_WordPlace& place) const; CPVT_WordPlace GetNextWordPlace(const CPVT_WordPlace& place) const; void UpdateWordPlace(CPVT_WordPlace& place) const; CPVT_WordPlace SearchWordPlace(const CFX_PointF& point) const; - CPVT_WordPlace SearchWordPlace(FX_FLOAT fx, + CPVT_WordPlace SearchWordPlace(float fx, const CPVT_WordPlace& lineplace) const; - CPVT_WordPlace SearchWordPlace(FX_FLOAT fx, - const CPVT_WordRange& range) const; + CPVT_WordPlace SearchWordPlace(float fx, const CPVT_WordRange& range) const; CPVT_WordPlace SecPlace; CPVT_SectionInfo m_SecInfo; diff --git a/core/fpdfdoc/ctypeset.cpp b/core/fpdfdoc/ctypeset.cpp index 452143e682..6cfaff5cc8 100644 --- a/core/fpdfdoc/ctypeset.cpp +++ b/core/fpdfdoc/ctypeset.cpp @@ -180,16 +180,16 @@ CTypeset::~CTypeset() {} CPVT_FloatRect CTypeset::CharArray() { ASSERT(m_pSection); - FX_FLOAT fLineAscent = + float fLineAscent = m_pVT->GetFontAscent(m_pVT->GetDefaultFontIndex(), m_pVT->GetFontSize()); - FX_FLOAT fLineDescent = + float fLineDescent = m_pVT->GetFontDescent(m_pVT->GetDefaultFontIndex(), m_pVT->GetFontSize()); m_rcRet.Default(); - FX_FLOAT x = 0.0f, y = 0.0f; - FX_FLOAT fNextWidth; + float x = 0.0f, y = 0.0f; + float fNextWidth; int32_t nStart = 0; - FX_FLOAT fNodeWidth = m_pVT->GetPlateWidth() / - (m_pVT->m_nCharArray <= 0 ? 1 : m_pVT->m_nCharArray); + float fNodeWidth = m_pVT->GetPlateWidth() / + (m_pVT->m_nCharArray <= 0 ? 1 : m_pVT->m_nCharArray); if (CLine* pLine = m_pSection->m_LineArray.GetAt(0)) { x = 0.0f; y += m_pVT->GetLineLeading(m_pSection->m_SecInfo); @@ -221,11 +221,11 @@ CPVT_FloatRect CTypeset::CharArray() { } if (CPVT_WordInfo* pWord = m_pSection->m_WordArray.GetAt(w)) { pWord->fWordTail = 0; - FX_FLOAT fWordWidth = m_pVT->GetWordWidth(*pWord); - FX_FLOAT fWordAscent = m_pVT->GetWordAscent(*pWord); - FX_FLOAT fWordDescent = m_pVT->GetWordDescent(*pWord); - x = (FX_FLOAT)(fNodeWidth * (w + nStart + 0.5) - - fWordWidth * VARIABLETEXT_HALF); + float fWordWidth = m_pVT->GetWordWidth(*pWord); + float fWordAscent = m_pVT->GetWordAscent(*pWord); + float fWordDescent = m_pVT->GetWordDescent(*pWord); + x = (float)(fNodeWidth * (w + nStart + 0.5) - + fWordWidth * VARIABLETEXT_HALF); pWord->fWordX = x; pWord->fWordY = y; if (w == 0) { @@ -255,7 +255,7 @@ CPVT_FloatRect CTypeset::CharArray() { return m_rcRet = CPVT_FloatRect(0, 0, x, y); } -CFX_SizeF CTypeset::GetEditSize(FX_FLOAT fFontSize) { +CFX_SizeF CTypeset::GetEditSize(float fFontSize) { ASSERT(m_pSection); ASSERT(m_pVT); SplitLines(false, fFontSize); @@ -271,22 +271,22 @@ CPVT_FloatRect CTypeset::Typeset() { return m_rcRet; } -void CTypeset::SplitLines(bool bTypeset, FX_FLOAT fFontSize) { +void CTypeset::SplitLines(bool bTypeset, float fFontSize) { ASSERT(m_pVT); ASSERT(m_pSection); int32_t nLineHead = 0; int32_t nLineTail = 0; - FX_FLOAT fMaxX = 0.0f, fMaxY = 0.0f; - FX_FLOAT fLineWidth = 0.0f, fBackupLineWidth = 0.0f; - FX_FLOAT fLineAscent = 0.0f, fBackupLineAscent = 0.0f; - FX_FLOAT fLineDescent = 0.0f, fBackupLineDescent = 0.0f; + float fMaxX = 0.0f, fMaxY = 0.0f; + float fLineWidth = 0.0f, fBackupLineWidth = 0.0f; + float fLineAscent = 0.0f, fBackupLineAscent = 0.0f; + float fLineDescent = 0.0f, fBackupLineDescent = 0.0f; int32_t nWordStartPos = 0; bool bFullWord = false; int32_t nLineFullWordIndex = 0; int32_t nCharIndex = 0; CPVT_LineInfo line; - FX_FLOAT fWordWidth = 0; - FX_FLOAT fTypesetWidth = std::max( + float fWordWidth = 0; + float fTypesetWidth = std::max( m_pVT->GetPlateWidth() - m_pVT->GetLineIndent(m_pSection->m_SecInfo), 0.0f); int32_t nTotalWords = m_pSection->m_WordArray.GetSize(); @@ -420,10 +420,10 @@ void CTypeset::SplitLines(bool bTypeset, FX_FLOAT fFontSize) { void CTypeset::OutputLines() { ASSERT(m_pVT); ASSERT(m_pSection); - FX_FLOAT fMinX = 0.0f, fMinY = 0.0f, fMaxX = 0.0f, fMaxY = 0.0f; - FX_FLOAT fPosX = 0.0f, fPosY = 0.0f; - FX_FLOAT fLineIndent = m_pVT->GetLineIndent(m_pSection->m_SecInfo); - FX_FLOAT fTypesetWidth = std::max(m_pVT->GetPlateWidth() - fLineIndent, 0.0f); + float fMinX = 0.0f, fMinY = 0.0f, fMaxX = 0.0f, fMaxY = 0.0f; + float fPosX = 0.0f, fPosY = 0.0f; + float fLineIndent = m_pVT->GetLineIndent(m_pSection->m_SecInfo); + float fTypesetWidth = std::max(m_pVT->GetPlateWidth() - fLineIndent, 0.0f); switch (m_pVT->GetAlignment(m_pSection->m_SecInfo)) { default: case 0: diff --git a/core/fpdfdoc/ctypeset.h b/core/fpdfdoc/ctypeset.h index 4161c03b42..f769fe1311 100644 --- a/core/fpdfdoc/ctypeset.h +++ b/core/fpdfdoc/ctypeset.h @@ -18,12 +18,12 @@ class CTypeset final { explicit CTypeset(CSection* pSection); ~CTypeset(); - CFX_SizeF GetEditSize(FX_FLOAT fFontSize); + CFX_SizeF GetEditSize(float fFontSize); CPVT_FloatRect Typeset(); CPVT_FloatRect CharArray(); private: - void SplitLines(bool bTypeset, FX_FLOAT fFontSize); + void SplitLines(bool bTypeset, float fFontSize); void OutputLines(); CPVT_FloatRect m_rcRet; diff --git a/core/fpdfdoc/doc_tagged.cpp b/core/fpdfdoc/doc_tagged.cpp index af5cf85938..418fab411a 100644 --- a/core/fpdfdoc/doc_tagged.cpp +++ b/core/fpdfdoc/doc_tagged.cpp @@ -291,7 +291,7 @@ void CPDF_StructElement::LoadKid(uint32_t PageObjNum, } static CPDF_Dictionary* FindAttrDict(CPDF_Object* pAttrs, const CFX_ByteStringC& owner, - FX_FLOAT nLevel = 0.0F) { + float nLevel = 0.0F) { if (nLevel > nMaxRecursion) return nullptr; if (!pAttrs) @@ -317,7 +317,7 @@ static CPDF_Dictionary* FindAttrDict(CPDF_Object* pAttrs, CPDF_Object* CPDF_StructElement::GetAttr(const CFX_ByteStringC& owner, const CFX_ByteStringC& name, bool bInheritable, - FX_FLOAT fLevel) { + float fLevel) { if (fLevel > nMaxRecursion) { return nullptr; } @@ -400,11 +400,11 @@ FX_ARGB CPDF_StructElement::GetColor(const CFX_ByteStringC& owner, ((int)(pArray->GetNumberAt(1) * 255) << 8) | (int)(pArray->GetNumberAt(2) * 255); } -FX_FLOAT CPDF_StructElement::GetNumber(const CFX_ByteStringC& owner, - const CFX_ByteStringC& name, - FX_FLOAT default_value, - bool bInheritable, - int subindex) { +float CPDF_StructElement::GetNumber(const CFX_ByteStringC& owner, + const CFX_ByteStringC& name, + float default_value, + bool bInheritable, + int subindex) { CPDF_Object* pAttr = GetAttr(owner, name, bInheritable, subindex); return ToNumber(pAttr) ? pAttr->GetNumber() : default_value; } diff --git a/core/fpdfdoc/fpdf_tagged.h b/core/fpdfdoc/fpdf_tagged.h index fbbb49f856..5e7b1827c5 100644 --- a/core/fpdfdoc/fpdf_tagged.h +++ b/core/fpdfdoc/fpdf_tagged.h @@ -42,7 +42,7 @@ class IPDF_StructElement { virtual CPDF_Object* GetAttr(const CFX_ByteStringC& owner, const CFX_ByteStringC& name, bool bInheritable = false, - FX_FLOAT fLevel = 0.0F) = 0; + float fLevel = 0.0F) = 0; virtual CFX_ByteString GetName(const CFX_ByteStringC& owner, const CFX_ByteStringC& name, @@ -56,11 +56,11 @@ class IPDF_StructElement { bool bInheritable = false, int subindex = -1) = 0; - virtual FX_FLOAT GetNumber(const CFX_ByteStringC& owner, - const CFX_ByteStringC& name, - FX_FLOAT default_value, - bool bInheritable = false, - int subindex = -1) = 0; + virtual float GetNumber(const CFX_ByteStringC& owner, + const CFX_ByteStringC& name, + float default_value, + bool bInheritable = false, + int subindex = -1) = 0; virtual int GetInteger(const CFX_ByteStringC& owner, const CFX_ByteStringC& name, diff --git a/core/fpdfdoc/tagged_int.h b/core/fpdfdoc/tagged_int.h index ce246023df..cafcbd42aa 100644 --- a/core/fpdfdoc/tagged_int.h +++ b/core/fpdfdoc/tagged_int.h @@ -73,7 +73,7 @@ class CPDF_StructElement final : public CFX_Retainable, CPDF_Object* GetAttr(const CFX_ByteStringC& owner, const CFX_ByteStringC& name, bool bInheritable = false, - FX_FLOAT fLevel = 0.0F) override; + float fLevel = 0.0F) override; CFX_ByteString GetName(const CFX_ByteStringC& owner, const CFX_ByteStringC& name, const CFX_ByteStringC& default_value, @@ -84,11 +84,11 @@ class CPDF_StructElement final : public CFX_Retainable, FX_ARGB default_value, bool bInheritable = false, int subindex = -1) override; - FX_FLOAT GetNumber(const CFX_ByteStringC& owner, - const CFX_ByteStringC& name, - FX_FLOAT default_value, - bool bInheritable = false, - int subindex = -1) override; + float GetNumber(const CFX_ByteStringC& owner, + const CFX_ByteStringC& name, + float default_value, + bool bInheritable = false, + int subindex = -1) override; int GetInteger(const CFX_ByteStringC& owner, const CFX_ByteStringC& name, int default_value, diff --git a/core/fpdftext/cpdf_textpage.cpp b/core/fpdftext/cpdf_textpage.cpp index 1a1edcb0ff..7a89b24171 100644 --- a/core/fpdftext/cpdf_textpage.cpp +++ b/core/fpdftext/cpdf_textpage.cpp @@ -26,12 +26,12 @@ namespace { -const FX_FLOAT kDefaultFontSize = 1.0f; +const float kDefaultFontSize = 1.0f; const uint16_t* const g_UnicodeData_Normalization_Maps[5] = { nullptr, g_UnicodeData_Normalization_Map1, g_UnicodeData_Normalization_Map2, g_UnicodeData_Normalization_Map3, g_UnicodeData_Normalization_Map4}; -FX_FLOAT NormalizeThreshold(FX_FLOAT threshold) { +float NormalizeThreshold(float threshold) { if (threshold < 300) return threshold / 2.0f; if (threshold < 500) @@ -41,21 +41,21 @@ FX_FLOAT NormalizeThreshold(FX_FLOAT threshold) { return threshold / 6.0f; } -FX_FLOAT CalculateBaseSpace(const CPDF_TextObject* pTextObj, - const CFX_Matrix& matrix) { - FX_FLOAT baseSpace = 0.0; +float CalculateBaseSpace(const CPDF_TextObject* pTextObj, + const CFX_Matrix& matrix) { + float baseSpace = 0.0; const int nItems = pTextObj->CountItems(); if (pTextObj->m_TextState.GetCharSpace() && nItems >= 3) { bool bAllChar = true; - FX_FLOAT spacing = + float spacing = matrix.TransformDistance(pTextObj->m_TextState.GetCharSpace()); baseSpace = spacing; for (int i = 0; i < nItems; i++) { CPDF_TextObjectItem item; pTextObj->GetItemInfo(i, &item); if (item.m_CharCode == static_cast<uint32_t>(-1)) { - FX_FLOAT fontsize_h = pTextObj->m_TextState.GetFontSizeH(); - FX_FLOAT kerning = -fontsize_h * item.m_Origin.x / 1000; + float fontsize_h = pTextObj->m_TextState.GetFontSizeH(); + float kerning = -fontsize_h * item.m_Origin.x / 1000; baseSpace = std::min(baseSpace, kerning + spacing); bAllChar = false; } @@ -277,7 +277,7 @@ std::vector<CFX_FloatRect> CPDF_TextPage::GetRectArray(int start, rect.top = origin.y + pCurObj->GetFont()->GetTypeAscent() * pCurObj->GetFontSize() / 1000; - FX_FLOAT xPosTemp = + float xPosTemp = origin.x + GetCharWidth(info_curchar.m_CharCode, pCurObj->GetFont()) * pCurObj->GetFontSize() / 1000; @@ -347,7 +347,7 @@ CFX_WideString CPDF_TextPage::GetTextByRect(const CFX_FloatRect& rect) const { if (!m_bIsParsed) return CFX_WideString(); - FX_FLOAT posy = 0; + float posy = 0; bool IsContainPreChar = false; bool IsAddLineFeed = false; CFX_WideString strText; @@ -492,10 +492,10 @@ int CPDF_TextPage::CountRects(int start, int nCount) { } void CPDF_TextPage::GetRect(int rectIndex, - FX_FLOAT& left, - FX_FLOAT& top, - FX_FLOAT& right, - FX_FLOAT& bottom) const { + float& left, + float& top, + float& right, + float& bottom) const { if (!m_bIsParsed) return; @@ -520,7 +520,7 @@ CPDF_TextPage::TextOrientation CPDF_TextPage::FindTextlineFlowOrientation() std::vector<bool> nHorizontalMask(nPageWidth); std::vector<bool> nVerticalMask(nPageHeight); - FX_FLOAT fLineHeight = 0.0f; + float fLineHeight = 0.0f; int32_t nStartH = nPageWidth; int32_t nEndH = 0; int32_t nStartV = nPageHeight; @@ -556,11 +556,11 @@ CPDF_TextPage::TextOrientation CPDF_TextPage::FindTextlineFlowOrientation() if ((nEndH - nStartH) < nDoubleLineHeight) return TextOrientation::Vertical; - const FX_FLOAT nSumH = MaskPercentFilled(nHorizontalMask, nStartH, nEndH); + const float nSumH = MaskPercentFilled(nHorizontalMask, nStartH, nEndH); if (nSumH > 0.8f) return TextOrientation::Horizontal; - const FX_FLOAT nSumV = MaskPercentFilled(nVerticalMask, nStartV, nEndV); + const float nSumV = MaskPercentFilled(nVerticalMask, nStartV, nEndV); if (nSumH > nSumV) return TextOrientation::Horizontal; if (nSumH < nSumV) @@ -762,7 +762,7 @@ void CPDF_TextPage::ProcessTextObject( CPDF_TextObjectItem item; int nItem = prev_Obj.m_pTextObj->CountItems(); prev_Obj.m_pTextObj->GetItemInfo(nItem - 1, &item); - FX_FLOAT prev_width = + float prev_width = GetCharWidth(item.m_CharCode, prev_Obj.m_pTextObj->GetFont()) * prev_Obj.m_pTextObj->GetFontSize() / 1000; @@ -771,8 +771,8 @@ void CPDF_TextPage::ProcessTextObject( prev_matrix.Concat(prev_Obj.m_formMatrix); prev_width = prev_matrix.TransformDistance(prev_width); pTextObj->GetItemInfo(0, &item); - FX_FLOAT this_width = GetCharWidth(item.m_CharCode, pTextObj->GetFont()) * - pTextObj->GetFontSize() / 1000; + float this_width = GetCharWidth(item.m_CharCode, pTextObj->GetFont()) * + pTextObj->GetFontSize() / 1000; this_width = FXSYS_fabs(this_width); CFX_Matrix this_matrix = pTextObj->GetTextMatrix(); @@ -780,8 +780,7 @@ void CPDF_TextPage::ProcessTextObject( this_matrix.Concat(formMatrix); this_width = this_matrix.TransformDistance(this_width); - FX_FLOAT threshold = - prev_width > this_width ? prev_width / 4 : this_width / 4; + float threshold = prev_width > this_width ? prev_width / 4 : this_width / 4; CFX_PointF prev_pos = m_DisplayMatrix.Transform( prev_Obj.m_formMatrix.Transform(prev_Obj.m_pTextObj->GetPos())); CFX_PointF this_pos = @@ -1041,7 +1040,7 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) { m_pPreTextObj = pTextObj; m_perMatrix = formMatrix; int nItems = pTextObj->CountItems(); - FX_FLOAT baseSpace = CalculateBaseSpace(pTextObj, matrix); + float baseSpace = CalculateBaseSpace(pTextObj, matrix); const bool bR2L = IsRightToLeft(pTextObj, pFont, nItems); const bool bIsBidiAndMirrorInverse = @@ -1050,7 +1049,7 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) { int32_t iCharListStartAppend = pdfium::CollectionSize<int32_t>(m_TempCharList); - FX_FLOAT spacing = 0; + float spacing = 0; for (int i = 0; i < nItems; i++) { CPDF_TextObjectItem item; PAGECHAR_INFO charinfo; @@ -1062,11 +1061,11 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) { if (str.IsEmpty() || str.GetAt(str.GetLength() - 1) == TEXT_SPACE_CHAR) continue; - FX_FLOAT fontsize_h = pTextObj->m_TextState.GetFontSizeH(); + float fontsize_h = pTextObj->m_TextState.GetFontSizeH(); spacing = -fontsize_h * item.m_Origin.x / 1000; continue; } - FX_FLOAT charSpace = pTextObj->m_TextState.GetCharSpace(); + float charSpace = pTextObj->m_TextState.GetCharSpace(); if (charSpace > 0.001) spacing += matrix.TransformDistance(charSpace); else if (charSpace < -0.001) @@ -1074,9 +1073,9 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) { spacing -= baseSpace; if (spacing && i > 0) { int last_width = 0; - FX_FLOAT fontsize_h = pTextObj->m_TextState.GetFontSizeH(); + float fontsize_h = pTextObj->m_TextState.GetFontSizeH(); uint32_t space_charcode = pFont->CharCodeFromUnicode(' '); - FX_FLOAT threshold = 0; + float threshold = 0; if (space_charcode != CPDF_Font::kInvalidCharCode) threshold = fontsize_h * pFont->GetCharWidthF(space_charcode) / 1000; if (threshold > fontsize_h / 3) @@ -1086,8 +1085,8 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) { if (threshold == 0) { threshold = fontsize_h; int this_width = FXSYS_abs(GetCharWidth(item.m_CharCode, pFont)); - threshold = this_width > last_width ? (FX_FLOAT)this_width - : (FX_FLOAT)last_width; + threshold = + this_width > last_width ? (float)this_width : (float)last_width; threshold = NormalizeThreshold(threshold); threshold = fontsize_h * threshold / 1000; } @@ -1155,8 +1154,8 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj) { bool bDel = false; const int count = std::min(pdfium::CollectionSize<int>(m_TempCharList), 7); - FX_FLOAT threshold = charinfo.m_Matrix.TransformXDistance( - (FX_FLOAT)TEXT_CHARRATIO_GAPDELTA * pTextObj->GetFontSize()); + float threshold = charinfo.m_Matrix.TransformXDistance( + (float)TEXT_CHARRATIO_GAPDELTA * pTextObj->GetFontSize()); for (int n = pdfium::CollectionSize<int>(m_TempCharList); n > pdfium::CollectionSize<int>(m_TempCharList) - count; n--) { const PAGECHAR_INFO& charinfo1 = m_TempCharList[n - 1]; @@ -1207,8 +1206,8 @@ CPDF_TextPage::TextOrientation CPDF_TextPage::GetTextObjectWritingMode( first.m_Origin = textMatrix.Transform(first.m_Origin); last.m_Origin = textMatrix.Transform(last.m_Origin); - FX_FLOAT dX = FXSYS_fabs(last.m_Origin.x - first.m_Origin.x); - FX_FLOAT dY = FXSYS_fabs(last.m_Origin.y - first.m_Origin.y); + float dX = FXSYS_fabs(last.m_Origin.x - first.m_Origin.x); + float dY = FXSYS_fabs(last.m_Origin.y - first.m_Origin.y); if (dX <= 0.0001f && dY <= 0.0001f) return TextOrientation::Unknown; @@ -1279,10 +1278,9 @@ CPDF_TextPage::GenerateCharacter CPDF_TextPage::ProcessInsertObject( wchar_t curChar = wstrItem.GetAt(0); if (WritingMode == TextOrientation::Horizontal) { if (this_rect.Height() > 4.5 && prev_rect.Height() > 4.5) { - FX_FLOAT top = - this_rect.top < prev_rect.top ? this_rect.top : prev_rect.top; - FX_FLOAT bottom = this_rect.bottom > prev_rect.bottom ? this_rect.bottom - : prev_rect.bottom; + float top = this_rect.top < prev_rect.top ? this_rect.top : prev_rect.top; + float bottom = this_rect.bottom > prev_rect.bottom ? this_rect.bottom + : prev_rect.bottom; if (bottom >= top) { return IsHyphen(curChar) ? GenerateCharacter::Hyphen : GenerateCharacter::LineBreak; @@ -1291,11 +1289,10 @@ CPDF_TextPage::GenerateCharacter CPDF_TextPage::ProcessInsertObject( } else if (WritingMode == TextOrientation::Vertical) { if (this_rect.Width() > pObj->GetFontSize() * 0.1f && prev_rect.Width() > m_pPreTextObj->GetFontSize() * 0.1f) { - FX_FLOAT left = this_rect.left > m_CurlineRect.left ? this_rect.left - : m_CurlineRect.left; - FX_FLOAT right = this_rect.right < m_CurlineRect.right - ? this_rect.right - : m_CurlineRect.right; + float left = this_rect.left > m_CurlineRect.left ? this_rect.left + : m_CurlineRect.left; + float right = this_rect.right < m_CurlineRect.right ? this_rect.right + : m_CurlineRect.right; if (right <= left) { return IsHyphen(curChar) ? GenerateCharacter::Hyphen : GenerateCharacter::LineBreak; @@ -1303,15 +1300,14 @@ CPDF_TextPage::GenerateCharacter CPDF_TextPage::ProcessInsertObject( } } - FX_FLOAT last_pos = PrevItem.m_Origin.x; + float last_pos = PrevItem.m_Origin.x; int nLastWidth = GetCharWidth(PrevItem.m_CharCode, m_pPreTextObj->GetFont()); - FX_FLOAT last_width = nLastWidth * m_pPreTextObj->GetFontSize() / 1000; + float last_width = nLastWidth * m_pPreTextObj->GetFontSize() / 1000; last_width = FXSYS_fabs(last_width); int nThisWidth = GetCharWidth(item.m_CharCode, pObj->GetFont()); - FX_FLOAT this_width = nThisWidth * pObj->GetFontSize() / 1000; + float this_width = nThisWidth * pObj->GetFontSize() / 1000; this_width = FXSYS_fabs(this_width); - FX_FLOAT threshold = - last_width > this_width ? last_width / 4 : this_width / 4; + float threshold = last_width > this_width ? last_width / 4 : this_width / 4; CFX_Matrix prev_matrix = m_pPreTextObj->GetTextMatrix(); prev_matrix.Concat(m_perMatrix); @@ -1372,7 +1368,7 @@ CPDF_TextPage::GenerateCharacter CPDF_TextPage::ProcessInsertObject( CFX_Matrix matrix = pObj->GetTextMatrix(); matrix.Concat(formMatrix); - threshold = (FX_FLOAT)(nLastWidth > nThisWidth ? nLastWidth : nThisWidth); + threshold = (float)(nLastWidth > nThisWidth ? nLastWidth : nThisWidth); threshold = threshold > 400 ? (threshold < 700 ? threshold / 4 @@ -1416,11 +1412,11 @@ bool CPDF_TextPage::IsSameTextObject(CPDF_TextObject* pTextObj1, CFX_FloatRect rcPreObj = pTextObj2->GetRect(); CFX_FloatRect rcCurObj = pTextObj1->GetRect(); if (rcPreObj.IsEmpty() && rcCurObj.IsEmpty()) { - FX_FLOAT dbXdif = FXSYS_fabs(rcPreObj.left - rcCurObj.left); + float dbXdif = FXSYS_fabs(rcPreObj.left - rcCurObj.left); size_t nCount = m_CharList.size(); if (nCount >= 2) { PAGECHAR_INFO perCharTemp = m_CharList[nCount - 2]; - FX_FLOAT dbSpace = perCharTemp.m_CharBox.Width(); + float dbSpace = perCharTemp.m_CharBox.Width(); if (dbXdif > dbSpace) return false; } @@ -1454,9 +1450,9 @@ bool CPDF_TextPage::IsSameTextObject(CPDF_TextObject* pTextObj1, } CFX_PointF diff = pTextObj1->GetPos() - pTextObj2->GetPos(); - FX_FLOAT font_size = pTextObj2->GetFontSize(); - FX_FLOAT char_size = GetCharWidth(itemPer.m_CharCode, pTextObj2->GetFont()); - FX_FLOAT max_pre_size = + float font_size = pTextObj2->GetFontSize(); + float char_size = GetCharWidth(itemPer.m_CharCode, pTextObj2->GetFont()); + float max_pre_size = std::max(std::max(rcPreObj.Height(), rcPreObj.Width()), font_size); if (FXSYS_fabs(diff.x) > char_size * font_size / 1000 * 0.9 || FXSYS_fabs(diff.y) > max_pre_size / 8) { @@ -1503,8 +1499,8 @@ bool CPDF_TextPage::GenerateCharInfo(wchar_t unicode, PAGECHAR_INFO& info) { GetCharWidth(preChar->m_CharCode, preChar->m_pTextObj->GetFont()); } - FX_FLOAT fFontSize = preChar->m_pTextObj ? preChar->m_pTextObj->GetFontSize() - : preChar->m_CharBox.Height(); + float fFontSize = preChar->m_pTextObj ? preChar->m_pTextObj->GetFontSize() + : preChar->m_CharBox.Height(); if (!fFontSize) fFontSize = kDefaultFontSize; diff --git a/core/fpdftext/cpdf_textpage.h b/core/fpdftext/cpdf_textpage.h index e8de6205a2..ebe58eb7ff 100644 --- a/core/fpdftext/cpdf_textpage.h +++ b/core/fpdftext/cpdf_textpage.h @@ -52,7 +52,7 @@ class FPDF_CHAR_INFO { wchar_t m_Unicode; wchar_t m_Charcode; int32_t m_Flag; - FX_FLOAT m_FontSize; + float m_FontSize; CFX_PointF m_Origin; CFX_FloatRect m_CharBox; CPDF_TextObject* m_pTextObj; @@ -103,10 +103,10 @@ class CPDF_TextPage { CFX_WideString GetPageText(int start = 0, int nCount = -1) const; int CountRects(int start, int nCount); void GetRect(int rectIndex, - FX_FLOAT& left, - FX_FLOAT& top, - FX_FLOAT& right, - FX_FLOAT& bottom) const; + float& left, + float& top, + float& right, + float& bottom) const; static bool IsRectIntersect(const CFX_FloatRect& rect1, const CFX_FloatRect& rect2); diff --git a/core/fxcodec/codec/ccodec_iccmodule.h b/core/fxcodec/codec/ccodec_iccmodule.h index 1f856faa04..c568a9b3c2 100644 --- a/core/fxcodec/codec/ccodec_iccmodule.h +++ b/core/fxcodec/codec/ccodec_iccmodule.h @@ -22,7 +22,7 @@ class CCodec_IccModule { int32_t intent = 0, uint32_t dwSrcFormat = Icc_FORMAT_DEFAULT); void DestroyTransform(void* pTransform); - void Translate(void* pTransform, FX_FLOAT* pSrcValues, FX_FLOAT* pDestValues); + void Translate(void* pTransform, float* pSrcValues, float* pDestValues); void TranslateScanline(void* pTransform, uint8_t* pDest, const uint8_t* pSrc, diff --git a/core/fxcodec/codec/ccodec_tiffmodule.cpp b/core/fxcodec/codec/ccodec_tiffmodule.cpp index 3d7db88b18..3807ec75aa 100644 --- a/core/fxcodec/codec/ccodec_tiffmodule.cpp +++ b/core/fxcodec/codec/ccodec_tiffmodule.cpp @@ -257,16 +257,14 @@ bool CCodec_TiffContext::LoadFrameInfo(int32_t frame, pAttribute->m_wDPIUnit--; } Tiff_Exif_GetInfo<uint16_t>(m_tif_ctx, TIFFTAG_ORIENTATION, pAttribute); - if (Tiff_Exif_GetInfo<FX_FLOAT>(m_tif_ctx, TIFFTAG_XRESOLUTION, - pAttribute)) { + if (Tiff_Exif_GetInfo<float>(m_tif_ctx, TIFFTAG_XRESOLUTION, pAttribute)) { void* val = pAttribute->m_Exif[TIFFTAG_XRESOLUTION]; - FX_FLOAT fDpi = val ? *reinterpret_cast<FX_FLOAT*>(val) : 0; + float fDpi = val ? *reinterpret_cast<float*>(val) : 0; pAttribute->m_nXDPI = (int32_t)(fDpi + 0.5f); } - if (Tiff_Exif_GetInfo<FX_FLOAT>(m_tif_ctx, TIFFTAG_YRESOLUTION, - pAttribute)) { + if (Tiff_Exif_GetInfo<float>(m_tif_ctx, TIFFTAG_YRESOLUTION, pAttribute)) { void* val = pAttribute->m_Exif[TIFFTAG_YRESOLUTION]; - FX_FLOAT fDpi = val ? *reinterpret_cast<FX_FLOAT*>(val) : 0; + float fDpi = val ? *reinterpret_cast<float*>(val) : 0; pAttribute->m_nYDPI = (int32_t)(fDpi + 0.5f); } Tiff_Exif_GetStringInfo(m_tif_ctx, TIFFTAG_IMAGEDESCRIPTION, pAttribute); diff --git a/core/fxcodec/codec/fx_codec_icc.cpp b/core/fxcodec/codec/fx_codec_icc.cpp index f77c8507bf..4f701aaed3 100644 --- a/core/fxcodec/codec/fx_codec_icc.cpp +++ b/core/fxcodec/codec/fx_codec_icc.cpp @@ -156,8 +156,8 @@ void IccLib_DestroyTransform(void* pTransform) { } void IccLib_Translate(void* pTransform, uint32_t nSrcComponents, - FX_FLOAT* pSrcValues, - FX_FLOAT* pDestValues) { + float* pSrcValues, + float* pDestValues) { if (!pTransform) { return; } @@ -226,8 +226,8 @@ void CCodec_IccModule::DestroyTransform(void* pTransform) { IccLib_DestroyTransform(pTransform); } void CCodec_IccModule::Translate(void* pTransform, - FX_FLOAT* pSrcValues, - FX_FLOAT* pDestValues) { + float* pSrcValues, + float* pDestValues) { IccLib_Translate(pTransform, m_nComponents, pSrcValues, pDestValues); } void CCodec_IccModule::TranslateScanline(void* pTransform, @@ -1631,13 +1631,13 @@ void AdobeCMYK_to_sRGB1(uint8_t c, G = fix_g >> 8; B = fix_b >> 8; } -void AdobeCMYK_to_sRGB(FX_FLOAT c, - FX_FLOAT m, - FX_FLOAT y, - FX_FLOAT k, - FX_FLOAT& R, - FX_FLOAT& G, - FX_FLOAT& B) { +void AdobeCMYK_to_sRGB(float c, + float m, + float y, + float k, + float& R, + float& G, + float& B) { // Convert to uint8_t with round-to-nearest. Avoid using FXSYS_round because // it is incredibly expensive with VC++ (tested on VC++ 2015) because round() // is very expensive. diff --git a/core/fxcodec/codec/fx_codec_jpx_unittest.cpp b/core/fxcodec/codec/fx_codec_jpx_unittest.cpp index 4d0564af67..2acb76c355 100644 --- a/core/fxcodec/codec/fx_codec_jpx_unittest.cpp +++ b/core/fxcodec/codec/fx_codec_jpx_unittest.cpp @@ -22,16 +22,16 @@ union Float_t { Float_t(float num = 0.0f) : f(num) {} int32_t i; - FX_FLOAT f; + float f; }; TEST(fxcodec, CMYK_Rounding) { // Testing all floats from 0.0 to 1.0 takes about 35 seconds in release // builds and much longer in debug builds, so just test the known-dangerous // range. - const FX_FLOAT startValue = 0.001f; - const FX_FLOAT endValue = 0.003f; - FX_FLOAT R = 0.0f, G = 0.0f, B = 0.0f; + const float startValue = 0.001f; + const float endValue = 0.003f; + float R = 0.0f, G = 0.0f, B = 0.0f; // Iterate through floats by incrementing the representation, as discussed in // https://randomascii.wordpress.com/2012/01/23/stupid-float-tricks-2/ for (Float_t f = startValue; f.f < endValue; f.i++) { diff --git a/core/fxcodec/codec/fx_codec_progress.cpp b/core/fxcodec/codec/fx_codec_progress.cpp index 1f2f50c29e..af7f24e4fe 100644 --- a/core/fxcodec/codec/fx_codec_progress.cpp +++ b/core/fxcodec/codec/fx_codec_progress.cpp @@ -51,25 +51,23 @@ void CCodec_ProgressiveDecoder::CFXCODEC_WeightTable::Calc(int dest_len, int src_max, bool bInterpol) { double scale, base; - scale = (FX_FLOAT)src_len / (FX_FLOAT)dest_len; + scale = (float)src_len / (float)dest_len; if (dest_len < 0) { - base = (FX_FLOAT)(src_len); + base = (float)(src_len); } else { base = 0.0f; } - m_ItemSize = - (int)(sizeof(int) * 2 + - sizeof(int) * (FXSYS_ceil(FXSYS_fabs((FX_FLOAT)scale)) + 1)); + m_ItemSize = (int)(sizeof(int) * 2 + + sizeof(int) * (FXSYS_ceil(FXSYS_fabs((float)scale)) + 1)); m_DestMin = dest_min; m_pWeightTables.resize((dest_max - dest_min) * m_ItemSize + 4); - if (FXSYS_fabs((FX_FLOAT)scale) < 1.0f) { + if (FXSYS_fabs((float)scale) < 1.0f) { for (int dest_pixel = dest_min; dest_pixel < dest_max; dest_pixel++) { PixelWeight& pixel_weights = *GetPixelWeight(dest_pixel); double src_pos = dest_pixel * scale + scale / 2 + base; if (bInterpol) { - pixel_weights.m_SrcStart = - (int)FXSYS_floor((FX_FLOAT)src_pos - 1.0f / 2); - pixel_weights.m_SrcEnd = (int)FXSYS_floor((FX_FLOAT)src_pos + 1.0f / 2); + pixel_weights.m_SrcStart = (int)FXSYS_floor((float)src_pos - 1.0f / 2); + pixel_weights.m_SrcEnd = (int)FXSYS_floor((float)src_pos + 1.0f / 2); if (pixel_weights.m_SrcStart < src_min) { pixel_weights.m_SrcStart = src_min; } @@ -80,13 +78,12 @@ void CCodec_ProgressiveDecoder::CFXCODEC_WeightTable::Calc(int dest_len, pixel_weights.m_Weights[0] = 65536; } else { pixel_weights.m_Weights[1] = FXSYS_round( - (FX_FLOAT)(src_pos - pixel_weights.m_SrcStart - 1.0f / 2) * - 65536); + (float)(src_pos - pixel_weights.m_SrcStart - 1.0f / 2) * 65536); pixel_weights.m_Weights[0] = 65536 - pixel_weights.m_Weights[1]; } } else { pixel_weights.m_SrcStart = pixel_weights.m_SrcEnd = - (int)FXSYS_floor((FX_FLOAT)src_pos); + (int)FXSYS_floor((float)src_pos); pixel_weights.m_Weights[0] = 65536; } } @@ -98,11 +95,11 @@ void CCodec_ProgressiveDecoder::CFXCODEC_WeightTable::Calc(int dest_len, double src_end = src_start + scale; int start_i, end_i; if (src_start < src_end) { - start_i = (int)FXSYS_floor((FX_FLOAT)src_start); - end_i = (int)FXSYS_ceil((FX_FLOAT)src_end); + start_i = (int)FXSYS_floor((float)src_start); + end_i = (int)FXSYS_ceil((float)src_end); } else { - start_i = (int)FXSYS_floor((FX_FLOAT)src_end); - end_i = (int)FXSYS_ceil((FX_FLOAT)src_start); + start_i = (int)FXSYS_floor((float)src_end); + end_i = (int)FXSYS_ceil((float)src_start); } if (start_i < src_min) { start_i = src_min; @@ -118,18 +115,17 @@ void CCodec_ProgressiveDecoder::CFXCODEC_WeightTable::Calc(int dest_len, pixel_weights.m_SrcStart = start_i; pixel_weights.m_SrcEnd = end_i; for (int j = start_i; j <= end_i; j++) { - double dest_start = ((FX_FLOAT)j - base) / scale; - double dest_end = ((FX_FLOAT)(j + 1) - base) / scale; + double dest_start = ((float)j - base) / scale; + double dest_end = ((float)(j + 1) - base) / scale; if (dest_start > dest_end) { double temp = dest_start; dest_start = dest_end; dest_end = temp; } - double area_start = dest_start > (FX_FLOAT)(dest_pixel) - ? dest_start - : (FX_FLOAT)(dest_pixel); - double area_end = dest_end > (FX_FLOAT)(dest_pixel + 1) - ? (FX_FLOAT)(dest_pixel + 1) + double area_start = + dest_start > (float)(dest_pixel) ? dest_start : (float)(dest_pixel); + double area_end = dest_end > (float)(dest_pixel + 1) + ? (float)(dest_pixel + 1) : dest_end; double weight = area_start >= area_end ? 0.0f : area_end - area_start; if (weight == 0 && j == end_i) { @@ -137,7 +133,7 @@ void CCodec_ProgressiveDecoder::CFXCODEC_WeightTable::Calc(int dest_len, break; } pixel_weights.m_Weights[j - start_i] = - FXSYS_round((FX_FLOAT)(weight * 65536)); + FXSYS_round((float)(weight * 65536)); } } } @@ -157,7 +153,7 @@ void CCodec_ProgressiveDecoder::CFXCODEC_HorzTable::Calc(int dest_len, int pre_des_col = 0; for (int src_col = 0; src_col < src_len; src_col++) { double des_col_f = src_col * scale; - int des_col = FXSYS_round((FX_FLOAT)des_col_f); + int des_col = FXSYS_round((float)des_col_f); PixelWeight* pWeight = GetPixelWeight(des_col); pWeight->m_SrcStart = pWeight->m_SrcEnd = src_col; pWeight->m_Weights[0] = 65536; @@ -179,10 +175,10 @@ void CCodec_ProgressiveDecoder::CFXCODEC_HorzTable::Calc(int dest_len, pWeight->m_SrcStart = src_col - 1; pWeight->m_SrcEnd = src_col; pWeight->m_Weights[0] = - bInterpol ? FXSYS_round((FX_FLOAT)( - ((FX_FLOAT)des_col - (FX_FLOAT)des_col_index) / - (FX_FLOAT)des_col_len * 65536)) - : 65536; + bInterpol + ? FXSYS_round((float)(((float)des_col - (float)des_col_index) / + (float)des_col_len * 65536)) + : 65536; pWeight->m_Weights[1] = 65536 - pWeight->m_Weights[0]; } pre_des_col = des_col; @@ -191,7 +187,7 @@ void CCodec_ProgressiveDecoder::CFXCODEC_HorzTable::Calc(int dest_len, } for (int des_col = 0; des_col < dest_len; des_col++) { double src_col_f = des_col / scale; - int src_col = FXSYS_round((FX_FLOAT)src_col_f); + int src_col = FXSYS_round((float)src_col_f); PixelWeight* pWeight = GetPixelWeight(des_col); pWeight->m_SrcStart = pWeight->m_SrcEnd = src_col; pWeight->m_Weights[0] = 65536; @@ -249,8 +245,8 @@ void CCodec_ProgressiveDecoder::CFXCODEC_VertTable::Calc(int dest_len, PixelWeight* pWeight = GetPixelWeight(des_row); pWeight->m_SrcStart = start_step; pWeight->m_SrcEnd = end_step; - pWeight->m_Weights[0] = FXSYS_round((FX_FLOAT)(end_step - des_row) / - (FX_FLOAT)length * 65536); + pWeight->m_Weights[0] = + FXSYS_round((float)(end_step - des_row) / (float)length * 65536); pWeight->m_Weights[1] = 65536 - pWeight->m_Weights[0]; } } @@ -1745,7 +1741,7 @@ void CCodec_ProgressiveDecoder::ResampleVert(CFX_DIBitmap* pDeviceBitmap, } return; } - int multiple = (int)FXSYS_ceil((FX_FLOAT)scale_y - 1); + int multiple = (int)FXSYS_ceil((float)scale_y - 1); if (multiple > 0) { uint8_t* scan_src = (uint8_t*)pDeviceBitmap->GetScanline(des_row) + des_ScanOffet; @@ -1871,21 +1867,21 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::StartDecode(CFX_DIBitmap* pDIBitmap, m_bInterpol = bInterpol; m_FrameCur = 0; if (start_x < 0 || out_range_x > 0) { - FX_FLOAT scaleX = (FX_FLOAT)m_clipBox.Width() / (FX_FLOAT)size_x; + float scaleX = (float)m_clipBox.Width() / (float)size_x; if (start_x < 0) { - m_clipBox.left -= (int32_t)FXSYS_ceil((FX_FLOAT)start_x * scaleX); + m_clipBox.left -= (int32_t)FXSYS_ceil((float)start_x * scaleX); } if (out_range_x > 0) { - m_clipBox.right -= (int32_t)FXSYS_floor((FX_FLOAT)out_range_x * scaleX); + m_clipBox.right -= (int32_t)FXSYS_floor((float)out_range_x * scaleX); } } if (start_y < 0 || out_range_y > 0) { - FX_FLOAT scaleY = (FX_FLOAT)m_clipBox.Height() / (FX_FLOAT)size_y; + float scaleY = (float)m_clipBox.Height() / (float)size_y; if (start_y < 0) { - m_clipBox.top -= (int32_t)FXSYS_ceil((FX_FLOAT)start_y * scaleY); + m_clipBox.top -= (int32_t)FXSYS_ceil((float)start_y * scaleY); } if (out_range_y > 0) { - m_clipBox.bottom -= (int32_t)FXSYS_floor((FX_FLOAT)out_range_y * scaleY); + m_clipBox.bottom -= (int32_t)FXSYS_floor((float)out_range_y * scaleY); } } if (m_clipBox.IsEmpty()) { diff --git a/core/fxcodec/fx_codec.h b/core/fxcodec/fx_codec.h index b0b9fa1821..fa4956c095 100644 --- a/core/fxcodec/fx_codec.h +++ b/core/fxcodec/fx_codec.h @@ -46,7 +46,7 @@ class CFX_DIBAttribute { int32_t m_nXDPI; int32_t m_nYDPI; - FX_FLOAT m_fAspectRatio; + float m_fAspectRatio; uint16_t m_wDPIUnit; CFX_ByteString m_strAuthor; uint8_t m_strTime[20]; @@ -112,20 +112,20 @@ class CCodec_ModuleMgr { void ReverseRGB(uint8_t* pDestBuf, const uint8_t* pSrcBuf, int pixels); uint32_t ComponentsForFamily(int family); -void sRGB_to_AdobeCMYK(FX_FLOAT R, - FX_FLOAT G, - FX_FLOAT B, - FX_FLOAT& c, - FX_FLOAT& m, - FX_FLOAT& y, - FX_FLOAT& k); -void AdobeCMYK_to_sRGB(FX_FLOAT c, - FX_FLOAT m, - FX_FLOAT y, - FX_FLOAT k, - FX_FLOAT& R, - FX_FLOAT& G, - FX_FLOAT& B); +void sRGB_to_AdobeCMYK(float R, + float G, + float B, + float& c, + float& m, + float& y, + float& k); +void AdobeCMYK_to_sRGB(float c, + float m, + float y, + float k, + float& R, + float& G, + float& B); void AdobeCMYK_to_sRGB1(uint8_t c, uint8_t m, uint8_t y, diff --git a/core/fxcrt/fx_basic.h b/core/fxcrt/fx_basic.h index 007c362ad6..a4069fddbd 100644 --- a/core/fxcrt/fx_basic.h +++ b/core/fxcrt/fx_basic.h @@ -506,12 +506,11 @@ class CFX_Vector_3by1 { public: CFX_Vector_3by1() : a(0.0f), b(0.0f), c(0.0f) {} - CFX_Vector_3by1(FX_FLOAT a1, FX_FLOAT b1, FX_FLOAT c1) - : a(a1), b(b1), c(c1) {} + CFX_Vector_3by1(float a1, float b1, float c1) : a(a1), b(b1), c(c1) {} - FX_FLOAT a; - FX_FLOAT b; - FX_FLOAT c; + float a; + float b; + float c; }; class CFX_Matrix_3by3 { public: @@ -526,15 +525,15 @@ class CFX_Matrix_3by3 { h(0.0f), i(0.0f) {} - CFX_Matrix_3by3(FX_FLOAT a1, - FX_FLOAT b1, - FX_FLOAT c1, - FX_FLOAT d1, - FX_FLOAT e1, - FX_FLOAT f1, - FX_FLOAT g1, - FX_FLOAT h1, - FX_FLOAT i1) + CFX_Matrix_3by3(float a1, + float b1, + float c1, + float d1, + float e1, + float f1, + float g1, + float h1, + float i1) : a(a1), b(b1), c(c1), d(d1), e(e1), f(f1), g(g1), h(h1), i(i1) {} CFX_Matrix_3by3 Inverse(); @@ -543,15 +542,15 @@ class CFX_Matrix_3by3 { CFX_Vector_3by1 TransformVector(const CFX_Vector_3by1& v); - FX_FLOAT a; - FX_FLOAT b; - FX_FLOAT c; - FX_FLOAT d; - FX_FLOAT e; - FX_FLOAT f; - FX_FLOAT g; - FX_FLOAT h; - FX_FLOAT i; + float a; + float b; + float c; + float d; + float e; + float f; + float g; + float h; + float i; }; uint32_t GetBits32(const uint8_t* pData, int bitpos, int nbits); diff --git a/core/fxcrt/fx_basic_bstring.cpp b/core/fxcrt/fx_basic_bstring.cpp index cbd8b379b9..b4eb4a75e0 100644 --- a/core/fxcrt/fx_basic_bstring.cpp +++ b/core/fxcrt/fx_basic_bstring.cpp @@ -958,7 +958,7 @@ void CFX_ByteString::TrimLeft() { uint32_t CFX_ByteString::GetID(FX_STRSIZE start_pos) const { return AsStringC().GetID(start_pos); } -FX_STRSIZE FX_ftoa(FX_FLOAT d, char* buf) { +FX_STRSIZE FX_ftoa(float d, char* buf) { buf[0] = '0'; buf[1] = '\0'; if (d == 0.0f) { @@ -1004,7 +1004,7 @@ FX_STRSIZE FX_ftoa(FX_FLOAT d, char* buf) { } return buf_size; } -CFX_ByteString CFX_ByteString::FormatFloat(FX_FLOAT d, int precision) { +CFX_ByteString CFX_ByteString::FormatFloat(float d, int precision) { char buf[32]; FX_STRSIZE len = FX_ftoa(d, buf); return CFX_ByteString(buf, len); diff --git a/core/fxcrt/fx_basic_buffer.cpp b/core/fxcrt/fx_basic_buffer.cpp index eaa79c9af1..341d9013ae 100644 --- a/core/fxcrt/fx_basic_buffer.cpp +++ b/core/fxcrt/fx_basic_buffer.cpp @@ -117,7 +117,7 @@ CFX_ByteTextBuf& CFX_ByteTextBuf::operator<<(uint32_t i) { CFX_ByteTextBuf& CFX_ByteTextBuf::operator<<(double f) { char buf[32]; - FX_STRSIZE len = FX_ftoa((FX_FLOAT)f, buf); + FX_STRSIZE len = FX_ftoa((float)f, buf); AppendBlock(buf, len); return *this; } @@ -158,7 +158,7 @@ CFX_WideTextBuf& CFX_WideTextBuf::operator<<(int i) { CFX_WideTextBuf& CFX_WideTextBuf::operator<<(double f) { char buf[32]; - FX_STRSIZE len = FX_ftoa((FX_FLOAT)f, buf); + FX_STRSIZE len = FX_ftoa((float)f, buf); ExpandBuf(len * sizeof(wchar_t)); wchar_t* str = (wchar_t*)(m_pBuffer.get() + m_DataSize); for (FX_STRSIZE i = 0; i < len; i++) { diff --git a/core/fxcrt/fx_basic_coords.cpp b/core/fxcrt/fx_basic_coords.cpp index cb5a010427..460f700f03 100644 --- a/core/fxcrt/fx_basic_coords.cpp +++ b/core/fxcrt/fx_basic_coords.cpp @@ -13,12 +13,12 @@ namespace { -void MatchFloatRange(FX_FLOAT f1, FX_FLOAT f2, int* i1, int* i2) { +void MatchFloatRange(float f1, 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); + float error1 = f1 - i1_1 + (float)FXSYS_fabs(f2 - i1_1 - length); + float error2 = i1_2 - f1 + (float)FXSYS_fabs(f2 - i1_2 - length); *i1 = (error1 > error2) ? i1_2 : i1_1; *i2 = *i1 + length; @@ -51,12 +51,12 @@ void FX_RECT::Intersect(const FX_RECT& src) { } } -bool GetIntersection(FX_FLOAT low1, - FX_FLOAT high1, - FX_FLOAT low2, - FX_FLOAT high2, - FX_FLOAT& interlow, - FX_FLOAT& interhigh) { +bool GetIntersection(float low1, + float high1, + float low2, + float high2, + float& interlow, + float& interhigh) { if (low1 >= high2 || low2 >= high1) { return false; } @@ -64,24 +64,24 @@ bool GetIntersection(FX_FLOAT low1, interhigh = high1 > high2 ? high2 : high1; return true; } -extern "C" int FXSYS_round(FX_FLOAT d) { - if (d < (FX_FLOAT)INT_MIN) { +extern "C" int FXSYS_round(float d) { + if (d < (float)INT_MIN) { return INT_MIN; } - if (d > (FX_FLOAT)INT_MAX) { + if (d > (float)INT_MAX) { return INT_MAX; } return (int)round(d); } CFX_FloatRect::CFX_FloatRect(const FX_RECT& rect) { - left = (FX_FLOAT)(rect.left); - right = (FX_FLOAT)(rect.right); - bottom = (FX_FLOAT)(rect.top); - top = (FX_FLOAT)(rect.bottom); + left = (float)(rect.left); + right = (float)(rect.right); + bottom = (float)(rect.top); + top = (float)(rect.bottom); } void CFX_FloatRect::Normalize() { - FX_FLOAT temp; + float temp; if (left > right) { temp = left; left = right; @@ -205,7 +205,7 @@ bool CFX_FloatRect::Contains(const CFX_FloatRect& other_rect) const { n2.top <= n1.top; } -void CFX_FloatRect::UpdateRect(FX_FLOAT x, FX_FLOAT y) { +void CFX_FloatRect::UpdateRect(float x, float y) { left = std::min(left, x); right = std::max(right, x); bottom = std::min(bottom, y); @@ -216,10 +216,10 @@ CFX_FloatRect CFX_FloatRect::GetBBox(const CFX_PointF* pPoints, int nPoints) { if (nPoints == 0) return CFX_FloatRect(); - FX_FLOAT min_x = pPoints->x; - FX_FLOAT max_x = pPoints->x; - FX_FLOAT min_y = pPoints->y; - FX_FLOAT max_y = pPoints->y; + float min_x = pPoints->x; + float max_x = pPoints->x; + float min_y = pPoints->y; + float max_y = pPoints->y; for (int i = 1; i < nPoints; i++) { min_x = std::min(min_x, pPoints[i].x); max_x = std::max(max_x, pPoints[i].x); @@ -230,11 +230,11 @@ CFX_FloatRect CFX_FloatRect::GetBBox(const CFX_PointF* pPoints, int nPoints) { } void CFX_Matrix::SetReverse(const CFX_Matrix& m) { - FX_FLOAT i = m.a * m.d - m.b * m.c; + float i = m.a * m.d - m.b * m.c; if (FXSYS_fabs(i) == 0) return; - FX_FLOAT j = -i; + float j = -i; a = m.d / i; b = m.b / j; c = m.c / j; @@ -263,7 +263,7 @@ bool CFX_Matrix::IsScaled() const { FXSYS_fabs(c * 1000) < FXSYS_fabs(d); } -void CFX_Matrix::Translate(FX_FLOAT x, FX_FLOAT y, bool bPrepended) { +void CFX_Matrix::Translate(float x, float y, bool bPrepended) { if (bPrepended) { e += x * a + y * c; f += y * d + x * b; @@ -273,7 +273,7 @@ void CFX_Matrix::Translate(FX_FLOAT x, FX_FLOAT y, bool bPrepended) { f += y; } -void CFX_Matrix::Scale(FX_FLOAT sx, FX_FLOAT sy, bool bPrepended) { +void CFX_Matrix::Scale(float sx, float sy, bool bPrepended) { a *= sx; d *= sy; if (bPrepended) { @@ -288,25 +288,20 @@ 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); +void CFX_Matrix::Rotate(float fRadian, bool bPrepended) { + float cosValue = FXSYS_cos(fRadian); + float sinValue = FXSYS_sin(fRadian); ConcatInternal(CFX_Matrix(cosValue, sinValue, -sinValue, cosValue, 0, 0), bPrepended); } -void CFX_Matrix::RotateAt(FX_FLOAT fRadian, - FX_FLOAT dx, - FX_FLOAT dy, - bool bPrepended) { +void CFX_Matrix::RotateAt(float fRadian, float dx, float dy, bool bPrepended) { Translate(dx, dy, bPrepended); Rotate(fRadian, bPrepended); Translate(-dx, -dy, bPrepended); } -void CFX_Matrix::Shear(FX_FLOAT fAlphaRadian, - FX_FLOAT fBetaRadian, - bool bPrepended) { +void CFX_Matrix::Shear(float fAlphaRadian, float fBetaRadian, bool bPrepended) { ConcatInternal( CFX_Matrix(1, FXSYS_tan(fAlphaRadian), FXSYS_tan(fBetaRadian), 1, 0, 0), bPrepended); @@ -314,7 +309,7 @@ void CFX_Matrix::Shear(FX_FLOAT fAlphaRadian, void CFX_Matrix::MatchRect(const CFX_FloatRect& dest, const CFX_FloatRect& src) { - FX_FLOAT fDiff = src.left - src.right; + float fDiff = src.left - src.right; a = FXSYS_fabs(fDiff) < 0.001f ? 1 : (dest.left - dest.right) / fDiff; fDiff = src.bottom - src.top; @@ -325,7 +320,7 @@ void CFX_Matrix::MatchRect(const CFX_FloatRect& dest, c = 0; } -FX_FLOAT CFX_Matrix::GetXUnit() const { +float CFX_Matrix::GetXUnit() const { if (b == 0) return (a > 0 ? a : -a); if (a == 0) @@ -333,7 +328,7 @@ FX_FLOAT CFX_Matrix::GetXUnit() const { return FXSYS_sqrt(a * a + b * b); } -FX_FLOAT CFX_Matrix::GetYUnit() const { +float CFX_Matrix::GetYUnit() const { if (c == 0) return (d > 0 ? d : -d); if (d == 0) @@ -347,19 +342,19 @@ CFX_FloatRect CFX_Matrix::GetUnitRect() const { return rect; } -FX_FLOAT CFX_Matrix::TransformXDistance(FX_FLOAT dx) const { - FX_FLOAT fx = a * dx; - FX_FLOAT fy = b * dx; +float CFX_Matrix::TransformXDistance(float dx) const { + float fx = a * dx; + float fy = b * dx; return 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; - FX_FLOAT fy = b * dx + d * dy; +float CFX_Matrix::TransformDistance(float dx, float dy) const { + float fx = a * dx + c * dy; + float fy = b * dx + d * dy; return FXSYS_sqrt(fx * fx + fy * fy); } -FX_FLOAT CFX_Matrix::TransformDistance(FX_FLOAT distance) const { +float CFX_Matrix::TransformDistance(float distance) const { return distance * (GetXUnit() + GetYUnit()) / 2; } @@ -369,16 +364,16 @@ CFX_PointF CFX_Matrix::Transform(const CFX_PointF& point) const { } void CFX_Matrix::TransformRect(CFX_RectF& rect) const { - FX_FLOAT right = rect.right(), bottom = rect.bottom(); + float right = rect.right(), bottom = rect.bottom(); TransformRect(rect.left, right, bottom, rect.top); rect.width = right - rect.left; rect.height = bottom - rect.top; } -void CFX_Matrix::TransformRect(FX_FLOAT& left, - FX_FLOAT& right, - FX_FLOAT& top, - FX_FLOAT& bottom) const { +void CFX_Matrix::TransformRect(float& left, + float& right, + float& top, + float& bottom) const { CFX_PointF points[] = { {left, top}, {left, bottom}, {right, top}, {right, bottom}}; for (int i = 0; i < 4; i++) diff --git a/core/fxcrt/fx_basic_util.cpp b/core/fxcrt/fx_basic_util.cpp index 45543dc317..b3c5829fc9 100644 --- a/core/fxcrt/fx_basic_util.cpp +++ b/core/fxcrt/fx_basic_util.cpp @@ -14,7 +14,7 @@ bool FX_atonum(const CFX_ByteStringC& strc, void* pData) { if (strc.Find('.') != -1) { - FX_FLOAT* pFloat = static_cast<FX_FLOAT*>(pData); + float* pFloat = static_cast<float*>(pData); *pFloat = FX_atof(strc); return false; } @@ -69,7 +69,7 @@ bool FX_atonum(const CFX_ByteStringC& strc, void* pData) { return true; } -static const FX_FLOAT fraction_scales[] = { +static const float fraction_scales[] = { 0.1f, 0.01f, 0.001f, 0.0001f, 0.00001f, 0.000001f, 0.0000001f, 0.00000001f, 0.000000001f, 0.0000000001f, 0.00000000001f}; @@ -78,11 +78,11 @@ int FXSYS_FractionalScaleCount() { return FX_ArraySize(fraction_scales); } -FX_FLOAT FXSYS_FractionalScale(size_t scale_factor, int value) { +float FXSYS_FractionalScale(size_t scale_factor, int value) { return fraction_scales[scale_factor] * value; } -FX_FLOAT FX_atof(const CFX_ByteStringC& strc) { +float FX_atof(const CFX_ByteStringC& strc) { if (strc.IsEmpty()) return 0.0; @@ -100,7 +100,7 @@ FX_FLOAT FX_atof(const CFX_ByteStringC& strc) { break; cc++; } - FX_FLOAT value = 0; + float value = 0; while (cc < len) { if (strc[cc] == '.') break; @@ -206,8 +206,7 @@ wchar_t FX_GetFolderSeparator() { } CFX_Matrix_3by3 CFX_Matrix_3by3::Inverse() { - FX_FLOAT det = - a * (e * i - f * h) - b * (i * d - f * g) + c * (d * h - e * g); + float det = a * (e * i - f * h) - b * (i * d - f * g) + c * (d * h - e * g); if (FXSYS_fabs(det) < 0.0000001) return CFX_Matrix_3by3(); diff --git a/core/fxcrt/fx_basic_wstring.cpp b/core/fxcrt/fx_basic_wstring.cpp index 3b9fa2435c..8522d42a38 100644 --- a/core/fxcrt/fx_basic_wstring.cpp +++ b/core/fxcrt/fx_basic_wstring.cpp @@ -945,7 +945,7 @@ void CFX_WideString::TrimLeft(wchar_t chTarget) { void CFX_WideString::TrimLeft() { TrimLeft(L"\x09\x0a\x0b\x0c\x0d\x20"); } -FX_FLOAT FX_wtof(const wchar_t* str, int len) { +float FX_wtof(const wchar_t* str, int len) { if (len == 0) { return 0.0; } @@ -965,17 +965,17 @@ FX_FLOAT FX_wtof(const wchar_t* str, int len) { integer = integer * 10 + FXSYS_toDecimalDigit(str[cc]); cc++; } - FX_FLOAT fraction = 0; + float fraction = 0; if (str[cc] == '.') { cc++; - FX_FLOAT scale = 0.1f; + float scale = 0.1f; while (cc < len) { fraction += scale * FXSYS_toDecimalDigit(str[cc]); scale *= 0.1f; cc++; } } - fraction += (FX_FLOAT)integer; + fraction += (float)integer; return bNegative ? -fraction : fraction; } @@ -983,7 +983,7 @@ int CFX_WideString::GetInteger() const { return m_pData ? FXSYS_wtoi(m_pData->m_String) : 0; } -FX_FLOAT CFX_WideString::GetFloat() const { +float CFX_WideString::GetFloat() const { return m_pData ? FX_wtof(m_pData->m_String, m_pData->m_nDataLength) : 0.0f; } diff --git a/core/fxcrt/fx_coordinates.h b/core/fxcrt/fx_coordinates.h index 2c84d0776c..5ccaf3d229 100644 --- a/core/fxcrt/fx_coordinates.h +++ b/core/fxcrt/fx_coordinates.h @@ -71,7 +71,7 @@ class CFX_PTemplate { BaseType y; }; using CFX_Point = CFX_PTemplate<int32_t>; -using CFX_PointF = CFX_PTemplate<FX_FLOAT>; +using CFX_PointF = CFX_PTemplate<float>; template <class BaseType> class CFX_STemplate { @@ -144,7 +144,7 @@ class CFX_STemplate { BaseType height; }; using CFX_Size = CFX_STemplate<int32_t>; -using CFX_SizeF = CFX_STemplate<FX_FLOAT>; +using CFX_SizeF = CFX_STemplate<float>; template <class BaseType> class CFX_VTemplate : public CFX_PTemplate<BaseType> { @@ -162,9 +162,9 @@ class CFX_VTemplate : public CFX_PTemplate<BaseType> { const CFX_PTemplate<BaseType>& point2) : CFX_PTemplate<BaseType>(point2.x - point1.x, point2.y - point1.y) {} - FX_FLOAT Length() const { return FXSYS_sqrt(x * x + y * y); } + float Length() const { return FXSYS_sqrt(x * x + y * y); } void Normalize() { - FX_FLOAT fLen = Length(); + float fLen = Length(); if (fLen < 0.0001f) return; @@ -179,15 +179,15 @@ class CFX_VTemplate : public CFX_PTemplate<BaseType> { x *= sx; y *= sy; } - void Rotate(FX_FLOAT fRadian) { - FX_FLOAT cosValue = FXSYS_cos(fRadian); - FX_FLOAT sinValue = FXSYS_sin(fRadian); + void Rotate(float fRadian) { + float cosValue = FXSYS_cos(fRadian); + float sinValue = FXSYS_sin(fRadian); x = x * cosValue - y * sinValue; y = x * sinValue + y * cosValue; } }; using CFX_Vector = CFX_VTemplate<int32_t>; -using CFX_VectorF = CFX_VTemplate<FX_FLOAT>; +using CFX_VectorF = CFX_VTemplate<float>; // Rectangles. // TODO(tsepez): Consolidate all these different rectangle classes. @@ -313,7 +313,7 @@ class CFX_RTemplate { Deflate(rt.left, rt.top, rt.top + rt.width, rt.top + rt.height); } bool IsEmpty() const { return width <= 0 || height <= 0; } - bool IsEmpty(FX_FLOAT fEpsilon) const { + bool IsEmpty(float fEpsilon) const { return width <= fEpsilon || height <= fEpsilon; } void Empty() { width = height = 0; } @@ -385,7 +385,7 @@ class CFX_RTemplate { rect.Intersect(*this); return !rect.IsEmpty(); } - bool IntersectWith(const RectType& rt, FX_FLOAT fEpsilon) const { + bool IntersectWith(const RectType& rt, float fEpsilon) const { RectType rect = rt; rect.Intersect(*this); return !rect.IsEmpty(fEpsilon); @@ -404,7 +404,7 @@ class CFX_RTemplate { BaseType height; }; using CFX_Rect = CFX_RTemplate<int32_t>; -using CFX_RectF = CFX_RTemplate<FX_FLOAT>; +using CFX_RectF = CFX_RTemplate<float>; // LTRB rectangles (y-axis runs downwards). struct FX_RECT { @@ -454,10 +454,10 @@ struct FX_RECT { class CFX_FloatRect { public: CFX_FloatRect() : CFX_FloatRect(0.0f, 0.0f, 0.0f, 0.0f) {} - CFX_FloatRect(FX_FLOAT l, FX_FLOAT b, FX_FLOAT r, FX_FLOAT t) + CFX_FloatRect(float l, float b, float r, float t) : left(l), bottom(b), right(r), top(t) {} - explicit CFX_FloatRect(const FX_FLOAT* pArray) + explicit CFX_FloatRect(const float* pArray) : CFX_FloatRect(pArray[0], pArray[1], pArray[2], pArray[3]) {} explicit CFX_FloatRect(const FX_RECT& rect); @@ -485,18 +485,18 @@ class CFX_FloatRect { int Substract4(CFX_FloatRect& substract_rect, CFX_FloatRect* pRects); - void InitRect(FX_FLOAT x, FX_FLOAT y) { + void InitRect(float x, float y) { left = x; right = x; bottom = y; top = y; } - void UpdateRect(FX_FLOAT x, FX_FLOAT y); + void UpdateRect(float x, float y); - FX_FLOAT Width() const { return right - left; } - FX_FLOAT Height() const { return top - bottom; } + float Width() const { return right - left; } + float Height() const { return top - bottom; } - void Inflate(FX_FLOAT x, FX_FLOAT y) { + void Inflate(float x, float y) { Normalize(); left -= x; right += x; @@ -504,10 +504,10 @@ class CFX_FloatRect { top += y; } - void Inflate(FX_FLOAT other_left, - FX_FLOAT other_bottom, - FX_FLOAT other_right, - FX_FLOAT other_top) { + void Inflate(float other_left, + float other_bottom, + float other_right, + float other_top) { Normalize(); left -= other_left; bottom -= other_bottom; @@ -519,7 +519,7 @@ class CFX_FloatRect { Inflate(rt.left, rt.bottom, rt.right, rt.top); } - void Deflate(FX_FLOAT x, FX_FLOAT y) { + void Deflate(float x, float y) { Normalize(); left += x; right -= x; @@ -527,10 +527,10 @@ class CFX_FloatRect { top -= y; } - void Deflate(FX_FLOAT other_left, - FX_FLOAT other_bottom, - FX_FLOAT other_right, - FX_FLOAT other_top) { + void Deflate(float other_left, + float other_bottom, + float other_right, + float other_top) { Normalize(); left += other_left; bottom += other_bottom; @@ -542,7 +542,7 @@ class CFX_FloatRect { Deflate(rt.left, rt.bottom, rt.right, rt.top); } - void Translate(FX_FLOAT e, FX_FLOAT f) { + void Translate(float e, float f) { left += e; right += e; top += f; @@ -560,17 +560,17 @@ class CFX_FloatRect { return CFX_FloatRect(rect.left, rect.top, rect.right(), rect.bottom()); } - FX_FLOAT left; - FX_FLOAT bottom; - FX_FLOAT right; - FX_FLOAT top; + float left; + float bottom; + float right; + float top; }; class CFX_Matrix { public: CFX_Matrix() { SetIdentity(); } - explicit CFX_Matrix(const FX_FLOAT n[6]) + explicit CFX_Matrix(const 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) @@ -581,12 +581,7 @@ class CFX_Matrix { 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) + CFX_Matrix(float a1, float b1, float c1, float d1, float e1, float f1) : a(a1), b(b1), c(c1), d(d1), e(e1), f(f1) {} void operator=(const CFX_Matrix& other) { @@ -620,49 +615,44 @@ class CFX_Matrix { 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 Translate(float x, float y, bool bPrepended = false); void Translate(int32_t x, int32_t y, bool bPrepended = false) { - Translate(static_cast<FX_FLOAT>(x), static_cast<FX_FLOAT>(y), bPrepended); + Translate(static_cast<float>(x), static_cast<float>(y), bPrepended); } - void Scale(FX_FLOAT sx, FX_FLOAT sy, bool bPrepended = false); - void Rotate(FX_FLOAT fRadian, bool bPrepended = false); - void RotateAt(FX_FLOAT fRadian, - FX_FLOAT x, - FX_FLOAT y, - bool bPrepended = false); + void Scale(float sx, float sy, bool bPrepended = false); + void Rotate(float fRadian, bool bPrepended = false); + void RotateAt(float fRadian, float x, float y, bool bPrepended = false); - void Shear(FX_FLOAT fAlphaRadian, - FX_FLOAT fBetaRadian, - bool bPrepended = false); + void Shear(float fAlphaRadian, float fBetaRadian, bool bPrepended = false); void MatchRect(const CFX_FloatRect& dest, const CFX_FloatRect& src); - FX_FLOAT GetXUnit() const; - FX_FLOAT GetYUnit() const; + float GetXUnit() const; + float GetYUnit() const; CFX_FloatRect GetUnitRect() const; - FX_FLOAT TransformXDistance(FX_FLOAT dx) const; - FX_FLOAT TransformDistance(FX_FLOAT dx, FX_FLOAT dy) const; - FX_FLOAT TransformDistance(FX_FLOAT distance) const; + float TransformXDistance(float dx) const; + float TransformDistance(float dx, float dy) const; + float TransformDistance(float distance) const; CFX_PointF Transform(const CFX_PointF& point) const; void TransformRect(CFX_RectF& rect) const; - void TransformRect(FX_FLOAT& left, - FX_FLOAT& right, - FX_FLOAT& top, - FX_FLOAT& bottom) const; + void TransformRect(float& left, + float& right, + float& top, + float& bottom) const; void TransformRect(CFX_FloatRect& rect) const { TransformRect(rect.left, rect.right, rect.top, rect.bottom); } - FX_FLOAT a; - FX_FLOAT b; - FX_FLOAT c; - FX_FLOAT d; - FX_FLOAT e; - FX_FLOAT f; + float a; + float b; + float c; + float d; + float e; + float f; private: void ConcatInternal(const CFX_Matrix& other, bool prepend); diff --git a/core/fxcrt/fx_ext.h b/core/fxcrt/fx_ext.h index 3ee5a4f91f..e605d04077 100644 --- a/core/fxcrt/fx_ext.h +++ b/core/fxcrt/fx_ext.h @@ -15,14 +15,14 @@ #define FX_INVALID_OFFSET static_cast<uint32_t>(-1) -FX_FLOAT FXSYS_tan(FX_FLOAT a); -FX_FLOAT FXSYS_logb(FX_FLOAT b, FX_FLOAT x); -FX_FLOAT FXSYS_strtof(const char* pcsStr, - int32_t iLength = -1, - int32_t* pUsedLen = nullptr); -FX_FLOAT FXSYS_wcstof(const wchar_t* pwsStr, - int32_t iLength = -1, - int32_t* pUsedLen = nullptr); +float FXSYS_tan(float a); +float FXSYS_logb(float b, float x); +float FXSYS_strtof(const char* pcsStr, + int32_t iLength = -1, + int32_t* pUsedLen = nullptr); +float FXSYS_wcstof(const wchar_t* pwsStr, + int32_t iLength = -1, + int32_t* pUsedLen = nullptr); wchar_t* FXSYS_wcsncpy(wchar_t* dstStr, const wchar_t* srcStr, size_t count); int32_t FXSYS_wcsnicmp(const wchar_t* s1, const wchar_t* s2, size_t count); int32_t FXSYS_strnicmp(const char* s1, const char* s2, size_t count); @@ -75,7 +75,7 @@ inline int FXSYS_toDecimalDigit(const wchar_t c) { return std::iswdigit(c) ? c - L'0' : 0; } -FX_FLOAT FXSYS_FractionalScale(size_t scale_factor, int value); +float FXSYS_FractionalScale(size_t scale_factor, int value); int FXSYS_FractionalScaleCount(); void* FX_Random_MT_Start(uint32_t dwSeed); diff --git a/core/fxcrt/fx_extension.cpp b/core/fxcrt/fx_extension.cpp index 0b7197ec7c..28c46c93f6 100644 --- a/core/fxcrt/fx_extension.cpp +++ b/core/fxcrt/fx_extension.cpp @@ -423,13 +423,13 @@ CFX_RetainPtr<IFX_MemoryStream> IFX_MemoryStream::Create(bool bConsecutive) { return pdfium::MakeRetain<CFX_MemoryStream>(bConsecutive); } -FX_FLOAT FXSYS_tan(FX_FLOAT a) { - return (FX_FLOAT)tan(a); +float FXSYS_tan(float a) { + return (float)tan(a); } -FX_FLOAT FXSYS_logb(FX_FLOAT b, FX_FLOAT x) { +float FXSYS_logb(float b, float x) { return FXSYS_log(x) / FXSYS_log(b); } -FX_FLOAT FXSYS_strtof(const char* pcsStr, int32_t iLength, int32_t* pUsedLen) { +float FXSYS_strtof(const char* pcsStr, int32_t iLength, int32_t* pUsedLen) { ASSERT(pcsStr); if (iLength < 0) { iLength = (int32_t)FXSYS_strlen(pcsStr); @@ -438,9 +438,7 @@ FX_FLOAT FXSYS_strtof(const char* pcsStr, int32_t iLength, int32_t* pUsedLen) { CFX_WideString::FromLocal(CFX_ByteStringC(pcsStr, iLength)); return FXSYS_wcstof(ws.c_str(), iLength, pUsedLen); } -FX_FLOAT FXSYS_wcstof(const wchar_t* pwsStr, - int32_t iLength, - int32_t* pUsedLen) { +float FXSYS_wcstof(const wchar_t* pwsStr, int32_t iLength, int32_t* pUsedLen) { ASSERT(pwsStr); if (iLength < 0) { iLength = (int32_t)FXSYS_wcslen(pwsStr); @@ -457,7 +455,7 @@ FX_FLOAT FXSYS_wcstof(const wchar_t* pwsStr, iUsedLen++; break; } - FX_FLOAT fValue = 0.0f; + float fValue = 0.0f; while (iUsedLen < iLength) { wchar_t wch = pwsStr[iUsedLen]; if (wch >= L'0' && wch <= L'9') { @@ -468,7 +466,7 @@ FX_FLOAT FXSYS_wcstof(const wchar_t* pwsStr, iUsedLen++; } if (iUsedLen < iLength && pwsStr[iUsedLen] == L'.') { - FX_FLOAT fPrecise = 0.1f; + float fPrecise = 0.1f; while (++iUsedLen < iLength) { wchar_t wch = pwsStr[iUsedLen]; if (wch >= L'0' && wch <= L'9') { diff --git a/core/fxcrt/fx_string.h b/core/fxcrt/fx_string.h index 01be6a1901..12304eb452 100644 --- a/core/fxcrt/fx_string.h +++ b/core/fxcrt/fx_string.h @@ -154,7 +154,7 @@ class CFX_ByteString { #define FXFORMAT_CAPITAL 4 static CFX_ByteString FormatInteger(int i, uint32_t flags = 0); - static CFX_ByteString FormatFloat(FX_FLOAT f, int precision = 0); + static CFX_ByteString FormatFloat(float f, int precision = 0); protected: using StringData = CFX_StringDataTemplate<char>; @@ -336,7 +336,7 @@ class CFX_WideString { void ReleaseBuffer(FX_STRSIZE len = -1); int GetInteger() const; - FX_FLOAT GetFloat() const; + float GetFloat() const; FX_STRSIZE Find(const CFX_WideStringC& pSub, FX_STRSIZE start = 0) const; FX_STRSIZE Find(wchar_t ch, FX_STRSIZE start = 0) const; @@ -421,12 +421,12 @@ inline bool operator!=(const CFX_WideStringC& lhs, const CFX_WideString& rhs) { } CFX_ByteString FX_UTF8Encode(const CFX_WideStringC& wsStr); -FX_FLOAT FX_atof(const CFX_ByteStringC& str); -inline FX_FLOAT FX_atof(const CFX_WideStringC& wsStr) { +float FX_atof(const CFX_ByteStringC& str); +inline float FX_atof(const CFX_WideStringC& wsStr) { return FX_atof(FX_UTF8Encode(wsStr).c_str()); } bool FX_atonum(const CFX_ByteStringC& str, void* pData); -FX_STRSIZE FX_ftoa(FX_FLOAT f, char* buf); +FX_STRSIZE FX_ftoa(float f, char* buf); uint32_t FX_HashCode_GetA(const CFX_ByteStringC& str, bool bIgnoreCase); uint32_t FX_HashCode_GetW(const CFX_WideStringC& str, bool bIgnoreCase); diff --git a/core/fxcrt/fx_system.h b/core/fxcrt/fx_system.h index 4c938d9b27..321a8e272e 100644 --- a/core/fxcrt/fx_system.h +++ b/core/fxcrt/fx_system.h @@ -68,7 +68,6 @@ extern "C" { #endif // __cplusplus typedef void* FX_POSITION; // Keep until fxcrt containers gone -typedef float FX_FLOAT; // Keep, allow upgrade to doubles. #define IsFloatZero(f) ((f) < 0.0001 && (f) > -0.0001) #define IsFloatBigger(fa, fb) ((fa) > (fb) && !IsFloatZero((fa) - (fb))) @@ -247,21 +246,21 @@ wchar_t* FXSYS_wcsupr(wchar_t* str); #endif // _FXM_PLATFORM == _FXM_PLATFORM_WINDOWS_ #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ -#define FXSYS_pow(a, b) (FX_FLOAT) powf(a, b) +#define FXSYS_pow(a, b) (float)powf(a, b) #else -#define FXSYS_pow(a, b) (FX_FLOAT) pow(a, b) +#define FXSYS_pow(a, b) (float)pow(a, b) #endif -#define FXSYS_sqrt(a) (FX_FLOAT) sqrt(a) -#define FXSYS_fabs(a) (FX_FLOAT) fabs(a) -#define FXSYS_atan2(a, b) (FX_FLOAT) atan2(a, b) -#define FXSYS_ceil(a) (FX_FLOAT) ceil(a) -#define FXSYS_floor(a) (FX_FLOAT) floor(a) -#define FXSYS_cos(a) (FX_FLOAT) cos(a) -#define FXSYS_acos(a) (FX_FLOAT) acos(a) -#define FXSYS_sin(a) (FX_FLOAT) sin(a) -#define FXSYS_log(a) (FX_FLOAT) log(a) -#define FXSYS_log10(a) (FX_FLOAT) log10(a) -#define FXSYS_fmod(a, b) (FX_FLOAT) fmod(a, b) +#define FXSYS_sqrt(a) (float)sqrt(a) +#define FXSYS_fabs(a) (float)fabs(a) +#define FXSYS_atan2(a, b) (float)atan2(a, b) +#define FXSYS_ceil(a) (float)ceil(a) +#define FXSYS_floor(a) (float)floor(a) +#define FXSYS_cos(a) (float)cos(a) +#define FXSYS_acos(a) (float)acos(a) +#define FXSYS_sin(a) (float)sin(a) +#define FXSYS_log(a) (float)log(a) +#define FXSYS_log10(a) (float)log10(a) +#define FXSYS_fmod(a, b) (float)fmod(a, b) #define FXSYS_abs abs #define FXDWORD_GET_LSBFIRST(p) \ ((static_cast<uint32_t>(p[3]) << 24) | (static_cast<uint32_t>(p[2]) << 16) | \ @@ -279,8 +278,8 @@ int32_t FXSYS_wtoi(const wchar_t* str); int64_t FXSYS_atoi64(const char* str); int64_t FXSYS_wtoi64(const wchar_t* str); const char* FXSYS_i64toa(int64_t value, char* str, int radix); -int FXSYS_round(FX_FLOAT f); -#define FXSYS_sqrt2(a, b) (FX_FLOAT) FXSYS_sqrt((a) * (a) + (b) * (b)) +int FXSYS_round(float f); +#define FXSYS_sqrt2(a, b) (float)FXSYS_sqrt((a) * (a) + (b) * (b)) #ifdef __cplusplus }; #endif diff --git a/core/fxcrt/fx_xml.h b/core/fxcrt/fx_xml.h index 87f1915cb1..0b0de23d67 100644 --- a/core/fxcrt/fx_xml.h +++ b/core/fxcrt/fx_xml.h @@ -107,19 +107,19 @@ class CXML_Element { return attr; } - bool GetAttrFloat(const CFX_ByteStringC& name, FX_FLOAT& attribute) const; - FX_FLOAT GetAttrFloat(const CFX_ByteStringC& name) const { - FX_FLOAT attr = 0; + bool GetAttrFloat(const CFX_ByteStringC& name, float& attribute) const; + float GetAttrFloat(const CFX_ByteStringC& name) const { + float attr = 0; GetAttrFloat(name, attr); return attr; } bool GetAttrFloat(const CFX_ByteStringC& space, const CFX_ByteStringC& name, - FX_FLOAT& attribute) const; - FX_FLOAT GetAttrFloat(const CFX_ByteStringC& space, - const CFX_ByteStringC& name) const { - FX_FLOAT attr = 0; + float& attribute) const; + float GetAttrFloat(const CFX_ByteStringC& space, + const CFX_ByteStringC& name) const { + float attr = 0; GetAttrFloat(space, name, attr); return attr; } diff --git a/core/fxcrt/fx_xml_parser.cpp b/core/fxcrt/fx_xml_parser.cpp index b81ae4e0d9..25024a1b2d 100644 --- a/core/fxcrt/fx_xml_parser.cpp +++ b/core/fxcrt/fx_xml_parser.cpp @@ -785,7 +785,7 @@ bool CXML_Element::GetAttrInteger(const CFX_ByteStringC& space, } bool CXML_Element::GetAttrFloat(const CFX_ByteStringC& name, - FX_FLOAT& attribute) const { + float& attribute) const { CFX_ByteStringC bsSpace; CFX_ByteStringC bsName; FX_XML_SplitQualifiedName(name, bsSpace, bsName); @@ -794,7 +794,7 @@ bool CXML_Element::GetAttrFloat(const CFX_ByteStringC& name, bool CXML_Element::GetAttrFloat(const CFX_ByteStringC& space, const CFX_ByteStringC& name, - FX_FLOAT& attribute) const { + float& attribute) const { const CFX_WideString* pValue = m_AttrMap.Lookup(CFX_ByteString(space), CFX_ByteString(name)); if (!pValue) diff --git a/core/fxge/agg/fx_agg_driver.cpp b/core/fxge/agg/fx_agg_driver.cpp index 8c7277752e..a3429a5b64 100644 --- a/core/fxge/agg/fx_agg_driver.cpp +++ b/core/fxge/agg/fx_agg_driver.cpp @@ -358,7 +358,7 @@ static void RasterizeStroke(agg::rasterizer_scanline_aa& rasterizer, agg::path_storage& path_data, const CFX_Matrix* pObject2Device, const CFX_GraphStateData* pGraphState, - FX_FLOAT scale = 1.0f, + float scale = 1.0f, bool bStrokeAdjust = false, bool bTextMode = false) { agg::line_cap_e cap; @@ -385,8 +385,8 @@ static void RasterizeStroke(agg::rasterizer_scanline_aa& rasterizer, join = agg::miter_join_revert; break; } - FX_FLOAT width = pGraphState->m_LineWidth * scale; - FX_FLOAT unit = 1.f; + float width = pGraphState->m_LineWidth * scale; + float unit = 1.f; if (pObject2Device) { unit = 1.0f / ((pObject2Device->GetXUnit() + pObject2Device->GetYUnit()) / 2); @@ -398,13 +398,13 @@ static void RasterizeStroke(agg::rasterizer_scanline_aa& rasterizer, typedef agg::conv_dash<agg::path_storage> dash_converter; dash_converter dash(path_data); for (int i = 0; i < (pGraphState->m_DashCount + 1) / 2; i++) { - FX_FLOAT on = pGraphState->m_DashArray[i * 2]; + float on = pGraphState->m_DashArray[i * 2]; if (on <= 0.000001f) { on = 1.0f / 10; } - FX_FLOAT off = i * 2 + 1 == pGraphState->m_DashCount - ? on - : pGraphState->m_DashArray[i * 2 + 1]; + float off = i * 2 + 1 == pGraphState->m_DashCount + ? on + : pGraphState->m_DashArray[i * 2 + 1]; if (off < 0) { off = 0; } @@ -460,7 +460,7 @@ bool CFX_AggDeviceDriver::DrawDeviceText(int nChars, const FXTEXT_CHARPOS* pCharPos, CFX_Font* pFont, const CFX_Matrix* pObject2Device, - FX_FLOAT font_size, + float font_size, uint32_t color) { return false; } @@ -556,9 +556,9 @@ bool CFX_AggDeviceDriver::SetClip_PathFill(const CFX_PathData* pPathData, if (size == 5 || size == 4) { CFX_FloatRect rectf; if (pPathData->IsRect(pObject2Device, &rectf)) { - rectf.Intersect( - CFX_FloatRect(0, 0, (FX_FLOAT)GetDeviceCaps(FXDC_PIXEL_WIDTH), - (FX_FLOAT)GetDeviceCaps(FXDC_PIXEL_HEIGHT))); + rectf.Intersect(CFX_FloatRect(0, 0, + (float)GetDeviceCaps(FXDC_PIXEL_WIDTH), + (float)GetDeviceCaps(FXDC_PIXEL_HEIGHT))); FX_RECT rect = rectf.GetOuterRect(); m_pClipRgn->IntersectRect(rect); return true; @@ -568,8 +568,8 @@ bool CFX_AggDeviceDriver::SetClip_PathFill(const CFX_PathData* pPathData, path_data.BuildPath(pPathData, pObject2Device); path_data.m_PathData.end_poly(); agg::rasterizer_scanline_aa rasterizer; - rasterizer.clip_box(0.0f, 0.0f, (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_WIDTH)), - (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_HEIGHT))); + rasterizer.clip_box(0.0f, 0.0f, (float)(GetDeviceCaps(FXDC_PIXEL_WIDTH)), + (float)(GetDeviceCaps(FXDC_PIXEL_HEIGHT))); rasterizer.add_path(path_data.m_PathData); rasterizer.filling_rule((fill_mode & 3) == FXFILL_WINDING ? agg::fill_non_zero @@ -589,8 +589,8 @@ bool CFX_AggDeviceDriver::SetClip_PathStroke( CAgg_PathData path_data; path_data.BuildPath(pPathData, nullptr); agg::rasterizer_scanline_aa rasterizer; - rasterizer.clip_box(0.0f, 0.0f, (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_WIDTH)), - (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_HEIGHT))); + rasterizer.clip_box(0.0f, 0.0f, (float)(GetDeviceCaps(FXDC_PIXEL_WIDTH)), + (float)(GetDeviceCaps(FXDC_PIXEL_HEIGHT))); RasterizeStroke(rasterizer, path_data.m_PathData, pObject2Device, pGraphState); rasterizer.filling_rule(agg::fill_non_zero); @@ -1467,8 +1467,8 @@ bool CFX_AggDeviceDriver::DrawPath(const CFX_PathData* pPathData, CAgg_PathData path_data; path_data.BuildPath(pPathData, pObject2Device); agg::rasterizer_scanline_aa rasterizer; - rasterizer.clip_box(0.0f, 0.0f, (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_WIDTH)), - (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_HEIGHT))); + rasterizer.clip_box(0.0f, 0.0f, (float)(GetDeviceCaps(FXDC_PIXEL_WIDTH)), + (float)(GetDeviceCaps(FXDC_PIXEL_HEIGHT))); rasterizer.add_path(path_data.m_PathData); rasterizer.filling_rule((fill_mode & 3) == FXFILL_WINDING ? agg::fill_non_zero @@ -1487,8 +1487,8 @@ bool CFX_AggDeviceDriver::DrawPath(const CFX_PathData* pPathData, CAgg_PathData path_data; path_data.BuildPath(pPathData, pObject2Device); agg::rasterizer_scanline_aa rasterizer; - rasterizer.clip_box(0.0f, 0.0f, (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_WIDTH)), - (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_HEIGHT))); + rasterizer.clip_box(0.0f, 0.0f, (float)(GetDeviceCaps(FXDC_PIXEL_WIDTH)), + (float)(GetDeviceCaps(FXDC_PIXEL_HEIGHT))); RasterizeStroke(rasterizer, path_data.m_PathData, nullptr, pGraphState, 1, false, !!(fill_mode & FX_STROKE_TEXT_MODE)); return RenderRasterizer(rasterizer, stroke_color, @@ -1514,8 +1514,8 @@ bool CFX_AggDeviceDriver::DrawPath(const CFX_PathData* pPathData, CAgg_PathData path_data; path_data.BuildPath(pPathData, &matrix1); agg::rasterizer_scanline_aa rasterizer; - rasterizer.clip_box(0.0f, 0.0f, (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_WIDTH)), - (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_HEIGHT))); + rasterizer.clip_box(0.0f, 0.0f, (float)(GetDeviceCaps(FXDC_PIXEL_WIDTH)), + (float)(GetDeviceCaps(FXDC_PIXEL_HEIGHT))); RasterizeStroke(rasterizer, path_data.m_PathData, &matrix2, pGraphState, matrix1.a, false, !!(fill_mode & FX_STROKE_TEXT_MODE)); return RenderRasterizer(rasterizer, stroke_color, diff --git a/core/fxge/agg/fx_agg_driver.h b/core/fxge/agg/fx_agg_driver.h index 8da63394a4..7b4c7209e8 100644 --- a/core/fxge/agg/fx_agg_driver.h +++ b/core/fxge/agg/fx_agg_driver.h @@ -93,7 +93,7 @@ class CFX_AggDeviceDriver : public IFX_RenderDeviceDriver { const FXTEXT_CHARPOS* pCharPos, CFX_Font* pFont, const CFX_Matrix* pObject2Device, - FX_FLOAT font_size, + float font_size, uint32_t color) override; int GetDriverType() const override; diff --git a/core/fxge/apple/apple_int.h b/core/fxge/apple/apple_int.h index fed6abcfb0..2a4029bd38 100644 --- a/core/fxge/apple/apple_int.h +++ b/core/fxge/apple/apple_int.h @@ -27,7 +27,7 @@ class CQuartz2D { void setGraphicsTextMatrix(void* graphics, CFX_Matrix* matrix); bool drawGraphicsString(void* graphics, void* font, - FX_FLOAT fontSize, + float fontSize, uint16_t* glyphIndices, CGPoint* glyphPositions, int32_t chars, diff --git a/core/fxge/apple/fx_apple_platform.cpp b/core/fxge/apple/fx_apple_platform.cpp index f576eb0ba2..20e86ed483 100644 --- a/core/fxge/apple/fx_apple_platform.cpp +++ b/core/fxge/apple/fx_apple_platform.cpp @@ -30,7 +30,7 @@ bool CGDrawGlyphRun(CGContextRef pContext, const FXTEXT_CHARPOS* pCharPos, CFX_Font* pFont, const CFX_Matrix* pObject2Device, - FX_FLOAT font_size, + float font_size, uint32_t argb) { if (nChars == 0) return true; @@ -102,7 +102,7 @@ bool CFX_AggDeviceDriver::DrawDeviceText(int nChars, const FXTEXT_CHARPOS* pCharPos, CFX_Font* pFont, const CFX_Matrix* pObject2Device, - FX_FLOAT font_size, + float font_size, uint32_t argb) { if (!pFont) return false; diff --git a/core/fxge/apple/fx_quartz_device.cpp b/core/fxge/apple/fx_quartz_device.cpp index 0cd5b6b93a..dbb121065d 100644 --- a/core/fxge/apple/fx_quartz_device.cpp +++ b/core/fxge/apple/fx_quartz_device.cpp @@ -77,7 +77,7 @@ void CQuartz2D::setGraphicsTextMatrix(void* graphics, CFX_Matrix* matrix) { bool CQuartz2D::drawGraphicsString(void* graphics, void* font, - FX_FLOAT fontSize, + float fontSize, uint16_t* glyphIndices, CGPoint* glyphPositions, int32_t charsCount, diff --git a/core/fxge/cfx_gemodule.h b/core/fxge/cfx_gemodule.h index c5bd841002..587ec89e59 100644 --- a/core/fxge/cfx_gemodule.h +++ b/core/fxge/cfx_gemodule.h @@ -24,7 +24,7 @@ class CFX_GEModule { void Init(const char** pUserFontPaths, CCodec_ModuleMgr* pCodecModule); CFX_FontCache* GetFontCache(); CFX_FontMgr* GetFontMgr() { return m_pFontMgr.get(); } - void SetTextGamma(FX_FLOAT gammaValue); + void SetTextGamma(float gammaValue); const uint8_t* GetTextGammaTable() const; CCodec_ModuleMgr* GetCodecModule() { return m_pCodecModule; } diff --git a/core/fxge/cfx_graphstate.h b/core/fxge/cfx_graphstate.h index a838dfc17c..b023ce790d 100644 --- a/core/fxge/cfx_graphstate.h +++ b/core/fxge/cfx_graphstate.h @@ -20,10 +20,10 @@ class CFX_GraphState { void Emplace(); - void SetLineDash(CPDF_Array* pArray, FX_FLOAT phase, FX_FLOAT scale); + void SetLineDash(CPDF_Array* pArray, float phase, float scale); - FX_FLOAT GetLineWidth() const; - void SetLineWidth(FX_FLOAT width); + float GetLineWidth() const; + void SetLineWidth(float width); CFX_GraphStateData::LineCap GetLineCap() const; void SetLineCap(CFX_GraphStateData::LineCap cap); @@ -31,8 +31,8 @@ class CFX_GraphState { CFX_GraphStateData::LineJoin GetLineJoin() const; void SetLineJoin(CFX_GraphStateData::LineJoin join); - FX_FLOAT GetMiterLimit() const; - void SetMiterLimit(FX_FLOAT limit); + float GetMiterLimit() const; + void SetMiterLimit(float limit); // FIXME(tsepez): remove when all GraphStateData usage gone. const CFX_GraphStateData* GetObject() const { return m_Ref.GetObject(); } diff --git a/core/fxge/cfx_graphstatedata.h b/core/fxge/cfx_graphstatedata.h index 03e4a8f51a..dc0098be3e 100644 --- a/core/fxge/cfx_graphstatedata.h +++ b/core/fxge/cfx_graphstatedata.h @@ -22,8 +22,8 @@ class CFX_GraphStateData { LineCap m_LineCap; int m_DashCount; - FX_FLOAT* m_DashArray; - FX_FLOAT m_DashPhase; + float* m_DashArray; + float m_DashPhase; enum LineJoin { LineJoinMiter = 0, @@ -31,8 +31,8 @@ class CFX_GraphStateData { LineJoinBevel = 2, }; LineJoin m_LineJoin; - FX_FLOAT m_MiterLimit; - FX_FLOAT m_LineWidth; + float m_MiterLimit; + float m_LineWidth; }; #endif // CORE_FXGE_CFX_GRAPHSTATEDATA_H_ diff --git a/core/fxge/cfx_pathdata.h b/core/fxge/cfx_pathdata.h index b0e30e32ad..bcb2b7aadf 100644 --- a/core/fxge/cfx_pathdata.h +++ b/core/fxge/cfx_pathdata.h @@ -47,7 +47,7 @@ class CFX_PathData { std::vector<FX_PATHPOINT>& GetPoints() { return m_Points; } CFX_FloatRect GetBoundingBox() const; - CFX_FloatRect GetBoundingBox(FX_FLOAT line_width, FX_FLOAT miter_limit) const; + CFX_FloatRect GetBoundingBox(float line_width, float miter_limit) const; void Transform(const CFX_Matrix* pMatrix); bool IsRect() const; @@ -59,7 +59,7 @@ class CFX_PathData { bool IsRect(const CFX_Matrix* pMatrix, CFX_FloatRect* rect) const; void Append(const CFX_PathData* pSrc, const CFX_Matrix* pMatrix); - void AppendRect(FX_FLOAT left, FX_FLOAT bottom, FX_FLOAT right, FX_FLOAT top); + void AppendRect(float left, float bottom, float right, float top); void AppendPoint(const CFX_PointF& pos, FXPT_TYPE type, bool closeFigure); void ClosePath(); diff --git a/core/fxge/cfx_renderdevice.h b/core/fxge/cfx_renderdevice.h index 2e9abf9963..41f8e4c690 100644 --- a/core/fxge/cfx_renderdevice.h +++ b/core/fxge/cfx_renderdevice.h @@ -68,7 +68,7 @@ class FXTEXT_CHARPOS { FXTEXT_CHARPOS(const FXTEXT_CHARPOS&); ~FXTEXT_CHARPOS(); - FX_FLOAT m_AdjustMatrix[4]; + float m_AdjustMatrix[4]; CFX_PointF m_Origin; uint32_t m_GlyphIndex; int32_t m_FontCharWidth; @@ -132,10 +132,10 @@ class CFX_RenderDevice { return FillRectWithBlend(pRect, color, FXDIB_BLEND_NORMAL); } bool FillRectWithBlend(const FX_RECT* pRect, uint32_t color, int blend_type); - bool DrawCosmeticLine(FX_FLOAT x1, - FX_FLOAT y1, - FX_FLOAT x2, - FX_FLOAT y2, + bool DrawCosmeticLine(float x1, + float y1, + float x2, + float y2, uint32_t color, int fill_mode, int blend_type); @@ -203,14 +203,14 @@ class CFX_RenderDevice { bool DrawNormalText(int nChars, const FXTEXT_CHARPOS* pCharPos, CFX_Font* pFont, - FX_FLOAT font_size, + float font_size, const CFX_Matrix* pText2Device, uint32_t fill_color, uint32_t text_flags); bool DrawTextPath(int nChars, const FXTEXT_CHARPOS* pCharPos, CFX_Font* pFont, - FX_FLOAT font_size, + float font_size, const CFX_Matrix* pText2User, const CFX_Matrix* pUser2Device, const CFX_GraphStateData* pGraphState, diff --git a/core/fxge/dib/fx_dib_engine.cpp b/core/fxge/dib/fx_dib_engine.cpp index c004aac538..8d90a72401 100644 --- a/core/fxge/dib/fx_dib_engine.cpp +++ b/core/fxge/dib/fx_dib_engine.cpp @@ -56,12 +56,12 @@ bool CWeightTable::Calc(int dest_len, FX_Free(m_pWeightTables); m_pWeightTables = nullptr; m_dwWeightTablesSize = 0; - const double scale = (FX_FLOAT)src_len / (FX_FLOAT)dest_len; - const double base = dest_len < 0 ? (FX_FLOAT)(src_len) : 0; + const double scale = (float)src_len / (float)dest_len; + const double base = dest_len < 0 ? (float)(src_len) : 0; const int ext_size = flags & FXDIB_BICUBIC_INTERPOL ? 3 : 1; m_ItemSize = sizeof(int) * 2 + - (int)(sizeof(int) * (FXSYS_ceil(FXSYS_fabs((FX_FLOAT)scale)) + ext_size)); + (int)(sizeof(int) * (FXSYS_ceil(FXSYS_fabs((float)scale)) + ext_size)); m_DestMin = dest_min; if ((dest_max - dest_min) > (int)((1U << 30) - 4) / m_ItemSize) return false; @@ -71,14 +71,13 @@ bool CWeightTable::Calc(int dest_len, if (!m_pWeightTables) return false; - if ((flags & FXDIB_NOSMOOTH) != 0 || FXSYS_fabs((FX_FLOAT)scale) < 1.0f) { + if ((flags & FXDIB_NOSMOOTH) != 0 || FXSYS_fabs((float)scale) < 1.0f) { for (int dest_pixel = dest_min; dest_pixel < dest_max; dest_pixel++) { PixelWeight& pixel_weights = *GetPixelWeight(dest_pixel); double src_pos = dest_pixel * scale + scale / 2 + base; if (flags & FXDIB_INTERPOL) { - pixel_weights.m_SrcStart = - (int)FXSYS_floor((FX_FLOAT)src_pos - 1.0f / 2); - pixel_weights.m_SrcEnd = (int)FXSYS_floor((FX_FLOAT)src_pos + 1.0f / 2); + pixel_weights.m_SrcStart = (int)FXSYS_floor((float)src_pos - 1.0f / 2); + pixel_weights.m_SrcEnd = (int)FXSYS_floor((float)src_pos + 1.0f / 2); if (pixel_weights.m_SrcStart < src_min) { pixel_weights.m_SrcStart = src_min; } @@ -89,14 +88,12 @@ bool CWeightTable::Calc(int dest_len, pixel_weights.m_Weights[0] = 65536; } else { pixel_weights.m_Weights[1] = FXSYS_round( - (FX_FLOAT)(src_pos - pixel_weights.m_SrcStart - 1.0f / 2) * - 65536); + (float)(src_pos - pixel_weights.m_SrcStart - 1.0f / 2) * 65536); pixel_weights.m_Weights[0] = 65536 - pixel_weights.m_Weights[1]; } } else if (flags & FXDIB_BICUBIC_INTERPOL) { - pixel_weights.m_SrcStart = - (int)FXSYS_floor((FX_FLOAT)src_pos - 1.0f / 2); - pixel_weights.m_SrcEnd = (int)FXSYS_floor((FX_FLOAT)src_pos + 1.0f / 2); + pixel_weights.m_SrcStart = (int)FXSYS_floor((float)src_pos - 1.0f / 2); + pixel_weights.m_SrcEnd = (int)FXSYS_floor((float)src_pos + 1.0f / 2); int start = pixel_weights.m_SrcStart - 1; int end = pixel_weights.m_SrcEnd + 1; if (start < src_min) { @@ -114,7 +111,7 @@ bool CWeightTable::Calc(int dest_len, } int weight; weight = FXSYS_round( - (FX_FLOAT)(src_pos - pixel_weights.m_SrcStart - 1.0f / 2) * 256); + (float)(src_pos - pixel_weights.m_SrcStart - 1.0f / 2) * 256); if (start == end) { pixel_weights.m_Weights[0] = (SDP_Table[256 + weight] + SDP_Table[weight] + @@ -179,7 +176,7 @@ bool CWeightTable::Calc(int dest_len, } } else { pixel_weights.m_SrcStart = pixel_weights.m_SrcEnd = - (int)FXSYS_floor((FX_FLOAT)src_pos); + (int)FXSYS_floor((float)src_pos); if (pixel_weights.m_SrcStart < src_min) { pixel_weights.m_SrcStart = src_min; } @@ -198,11 +195,11 @@ bool CWeightTable::Calc(int dest_len, double src_end = src_start + scale; int start_i, end_i; if (src_start < src_end) { - start_i = (int)FXSYS_floor((FX_FLOAT)src_start); - end_i = (int)FXSYS_ceil((FX_FLOAT)src_end); + start_i = (int)FXSYS_floor((float)src_start); + end_i = (int)FXSYS_ceil((float)src_end); } else { - start_i = (int)FXSYS_floor((FX_FLOAT)src_end); - end_i = (int)FXSYS_ceil((FX_FLOAT)src_start); + start_i = (int)FXSYS_floor((float)src_end); + end_i = (int)FXSYS_ceil((float)src_start); } if (start_i < src_min) { start_i = src_min; @@ -221,18 +218,17 @@ bool CWeightTable::Calc(int dest_len, pixel_weights.m_SrcStart = start_i; pixel_weights.m_SrcEnd = end_i; for (int j = start_i; j <= end_i; j++) { - double dest_start = ((FX_FLOAT)j - base) / scale; - double dest_end = ((FX_FLOAT)(j + 1) - base) / scale; + double dest_start = ((float)j - base) / scale; + double dest_end = ((float)(j + 1) - base) / scale; if (dest_start > dest_end) { double temp = dest_start; dest_start = dest_end; dest_end = temp; } - double area_start = dest_start > (FX_FLOAT)(dest_pixel) - ? dest_start - : (FX_FLOAT)(dest_pixel); - double area_end = dest_end > (FX_FLOAT)(dest_pixel + 1) - ? (FX_FLOAT)(dest_pixel + 1) + double area_start = + dest_start > (float)(dest_pixel) ? dest_start : (float)(dest_pixel); + double area_end = dest_end > (float)(dest_pixel + 1) + ? (float)(dest_pixel + 1) : dest_end; double weight = area_start >= area_end ? 0.0f : area_end - area_start; if (weight == 0 && j == end_i) { @@ -242,7 +238,7 @@ bool CWeightTable::Calc(int dest_len, size_t idx = j - start_i; if (idx >= GetPixelWeightSize()) return false; - pixel_weights.m_Weights[idx] = FXSYS_round((FX_FLOAT)(weight * 65536)); + pixel_weights.m_Weights[idx] = FXSYS_round((float)(weight * 65536)); } } return true; @@ -321,14 +317,14 @@ CStretchEngine::CStretchEngine(IFX_ScanlineComposer* pDestBitmap, m_Flags |= FXDIB_DOWNSAMPLE; } } - double scale_x = (FX_FLOAT)m_SrcWidth / (FX_FLOAT)m_DestWidth; - double scale_y = (FX_FLOAT)m_SrcHeight / (FX_FLOAT)m_DestHeight; - double base_x = m_DestWidth > 0 ? 0.0f : (FX_FLOAT)(m_DestWidth); - double base_y = m_DestHeight > 0 ? 0.0f : (FX_FLOAT)(m_DestHeight); - double src_left = scale_x * ((FX_FLOAT)(clip_rect.left) + base_x); - double src_right = scale_x * ((FX_FLOAT)(clip_rect.right) + base_x); - double src_top = scale_y * ((FX_FLOAT)(clip_rect.top) + base_y); - double src_bottom = scale_y * ((FX_FLOAT)(clip_rect.bottom) + base_y); + double scale_x = (float)m_SrcWidth / (float)m_DestWidth; + double scale_y = (float)m_SrcHeight / (float)m_DestHeight; + double base_x = m_DestWidth > 0 ? 0.0f : (float)(m_DestWidth); + double base_y = m_DestHeight > 0 ? 0.0f : (float)(m_DestHeight); + double src_left = scale_x * ((float)(clip_rect.left) + base_x); + double src_right = scale_x * ((float)(clip_rect.right) + base_x); + double src_top = scale_y * ((float)(clip_rect.top) + base_y); + double src_bottom = scale_y * ((float)(clip_rect.bottom) + base_y); if (src_left > src_right) { double temp = src_left; src_left = src_right; @@ -339,10 +335,10 @@ CStretchEngine::CStretchEngine(IFX_ScanlineComposer* pDestBitmap, src_top = src_bottom; src_bottom = temp; } - m_SrcClip.left = (int)FXSYS_floor((FX_FLOAT)src_left); - m_SrcClip.right = (int)FXSYS_ceil((FX_FLOAT)src_right); - m_SrcClip.top = (int)FXSYS_floor((FX_FLOAT)src_top); - m_SrcClip.bottom = (int)FXSYS_ceil((FX_FLOAT)src_bottom); + m_SrcClip.left = (int)FXSYS_floor((float)src_left); + m_SrcClip.right = (int)FXSYS_ceil((float)src_right); + m_SrcClip.top = (int)FXSYS_floor((float)src_top); + m_SrcClip.bottom = (int)FXSYS_ceil((float)src_bottom); FX_RECT src_rect(0, 0, m_SrcWidth, m_SrcHeight); m_SrcClip.Intersect(src_rect); if (m_SrcBpp == 1) { diff --git a/core/fxge/dib/fx_dib_transform.cpp b/core/fxge/dib/fx_dib_transform.cpp index bd88272941..4a1c3ee050 100644 --- a/core/fxge/dib/fx_dib_transform.cpp +++ b/core/fxge/dib/fx_dib_transform.cpp @@ -394,7 +394,7 @@ bool CFX_ImageTransformer::Start() { int stretch_width = (int)FXSYS_ceil(FXSYS_sqrt2(m_pMatrix->a, m_pMatrix->b)); int stretch_height = (int)FXSYS_ceil(FXSYS_sqrt2(m_pMatrix->c, m_pMatrix->d)); CFX_Matrix stretch2dest(1.0f, 0.0f, 0.0f, -1.0f, 0.0f, - (FX_FLOAT)(stretch_height)); + (float)(stretch_height)); stretch2dest.Concat( CFX_Matrix(m_pMatrix->a / stretch_width, m_pMatrix->b / stretch_width, m_pMatrix->c / stretch_height, m_pMatrix->d / stretch_height, @@ -453,8 +453,8 @@ bool CFX_ImageTransformer::Continue(IFX_Pause* pPause) { if (pTransformed->m_pAlphaMask) pTransformed->m_pAlphaMask->Clear(0); - CFX_Matrix result2stretch(1.0f, 0.0f, 0.0f, 1.0f, (FX_FLOAT)(m_result.left), - (FX_FLOAT)(m_result.top)); + CFX_Matrix result2stretch(1.0f, 0.0f, 0.0f, 1.0f, (float)(m_result.left), + (float)(m_result.top)); result2stretch.Concat(m_dest2stretch); result2stretch.Translate(-m_StretchClip.left, -m_StretchClip.top); if (!stretch_buf_mask && pTransformed->m_pAlphaMask) { diff --git a/core/fxge/fx_font.h b/core/fxge/fx_font.h index 07392fa07f..79957ef506 100644 --- a/core/fxge/fx_font.h +++ b/core/fxge/fx_font.h @@ -240,8 +240,8 @@ class FXTEXT_GLYPHPOS { FX_RECT FXGE_GetGlyphsBBox(const std::vector<FXTEXT_GLYPHPOS>& glyphs, int anti_alias, - FX_FLOAT retinaScaleX = 1.0f, - FX_FLOAT retinaScaleY = 1.0f); + float retinaScaleX = 1.0f, + float retinaScaleY = 1.0f); CFX_ByteString GetNameFromTT(const uint8_t* name_table, uint32_t name_table_size, diff --git a/core/fxge/ge/cfx_facecache.cpp b/core/fxge/ge/cfx_facecache.cpp index 314c95b8b2..3cdff44f8b 100644 --- a/core/fxge/ge/cfx_facecache.cpp +++ b/core/fxge/ge/cfx_facecache.cpp @@ -44,7 +44,7 @@ void ContrastAdjust(uint8_t* pDataIn, int nDstRowBytes) { int col, row, temp; int max = 0, min = 255; - FX_FLOAT rate; + float rate; for (row = 0; row < nHeight; row++) { uint8_t* pRow = pDataIn + row * nSrcRowBytes; for (col = 0; col < nWidth; col++) { diff --git a/core/fxge/ge/cfx_font.cpp b/core/fxge/ge/cfx_font.cpp index 87157b0101..068f0b032c 100644 --- a/core/fxge/ge/cfx_font.cpp +++ b/core/fxge/ge/cfx_font.cpp @@ -31,7 +31,7 @@ typedef struct { CFX_PathData* m_pPath; int m_CurX; int m_CurY; - FX_FLOAT m_CoordUnit; + float m_CoordUnit; } OUTLINE_PARAMS; #ifdef PDF_ENABLE_XFA diff --git a/core/fxge/ge/cfx_gemodule.cpp b/core/fxge/ge/cfx_gemodule.cpp index ed6d6cb32e..790b670e4f 100644 --- a/core/fxge/ge/cfx_gemodule.cpp +++ b/core/fxge/ge/cfx_gemodule.cpp @@ -59,11 +59,11 @@ CFX_FontCache* CFX_GEModule::GetFontCache() { return m_pFontCache; } -void CFX_GEModule::SetTextGamma(FX_FLOAT gammaValue) { +void CFX_GEModule::SetTextGamma(float gammaValue) { gammaValue /= 2.2f; for (int i = 0; i < 256; ++i) { m_GammaValue[i] = static_cast<uint8_t>( - FXSYS_pow(static_cast<FX_FLOAT>(i) / 255, gammaValue) * 255.0f + 0.5f); + FXSYS_pow(static_cast<float>(i) / 255, gammaValue) * 255.0f + 0.5f); } } diff --git a/core/fxge/ge/cfx_graphstate.cpp b/core/fxge/ge/cfx_graphstate.cpp index 6357aa51a4..54443b9636 100644 --- a/core/fxge/ge/cfx_graphstate.cpp +++ b/core/fxge/ge/cfx_graphstate.cpp @@ -19,9 +19,7 @@ void CFX_GraphState::Emplace() { m_Ref.Emplace(); } -void CFX_GraphState::SetLineDash(CPDF_Array* pArray, - FX_FLOAT phase, - FX_FLOAT scale) { +void CFX_GraphState::SetLineDash(CPDF_Array* pArray, float phase, float scale) { CFX_GraphStateData* pData = m_Ref.GetPrivateCopy(); pData->m_DashPhase = phase * scale; pData->SetDashCount(static_cast<int>(pArray->GetCount())); @@ -29,11 +27,11 @@ void CFX_GraphState::SetLineDash(CPDF_Array* pArray, pData->m_DashArray[i] = pArray->GetNumberAt(i) * scale; } -FX_FLOAT CFX_GraphState::GetLineWidth() const { +float CFX_GraphState::GetLineWidth() const { return m_Ref.GetObject() ? m_Ref.GetObject()->m_LineWidth : 1.f; } -void CFX_GraphState::SetLineWidth(FX_FLOAT width) { +void CFX_GraphState::SetLineWidth(float width) { m_Ref.GetPrivateCopy()->m_LineWidth = width; } @@ -52,10 +50,10 @@ void CFX_GraphState::SetLineJoin(CFX_GraphStateData::LineJoin join) { m_Ref.GetPrivateCopy()->m_LineJoin = join; } -FX_FLOAT CFX_GraphState::GetMiterLimit() const { +float CFX_GraphState::GetMiterLimit() const { return m_Ref.GetObject() ? m_Ref.GetObject()->m_MiterLimit : 10.f; } -void CFX_GraphState::SetMiterLimit(FX_FLOAT limit) { +void CFX_GraphState::SetMiterLimit(float limit) { m_Ref.GetPrivateCopy()->m_MiterLimit = limit; } diff --git a/core/fxge/ge/cfx_graphstatedata.cpp b/core/fxge/ge/cfx_graphstatedata.cpp index 03798a6320..8c5508f2f2 100644 --- a/core/fxge/ge/cfx_graphstatedata.cpp +++ b/core/fxge/ge/cfx_graphstatedata.cpp @@ -33,8 +33,8 @@ void CFX_GraphStateData::Copy(const CFX_GraphStateData& src) { m_MiterLimit = src.m_MiterLimit; m_LineWidth = src.m_LineWidth; if (m_DashCount) { - m_DashArray = FX_Alloc(FX_FLOAT, m_DashCount); - FXSYS_memcpy(m_DashArray, src.m_DashArray, m_DashCount * sizeof(FX_FLOAT)); + m_DashArray = FX_Alloc(float, m_DashCount); + FXSYS_memcpy(m_DashArray, src.m_DashArray, m_DashCount * sizeof(float)); } } @@ -48,5 +48,5 @@ void CFX_GraphStateData::SetDashCount(int count) { m_DashCount = count; if (count == 0) return; - m_DashArray = FX_Alloc(FX_FLOAT, count); + m_DashArray = FX_Alloc(float, count); } diff --git a/core/fxge/ge/cfx_pathdata.cpp b/core/fxge/ge/cfx_pathdata.cpp index 9fa2cd2aac..d4c657c3a4 100644 --- a/core/fxge/ge/cfx_pathdata.cpp +++ b/core/fxge/ge/cfx_pathdata.cpp @@ -14,7 +14,7 @@ namespace { void UpdateLineEndPoints(CFX_FloatRect* rect, const CFX_PointF& start_pos, const CFX_PointF& end_pos, - FX_FLOAT hw) { + float hw) { if (start_pos.x == end_pos.x) { if (start_pos.y == end_pos.y) { rect->UpdateRect(end_pos.x + hw, end_pos.y + hw); @@ -22,7 +22,7 @@ void UpdateLineEndPoints(CFX_FloatRect* rect, return; } - FX_FLOAT point_y; + float point_y; if (end_pos.y < start_pos.y) point_y = end_pos.y - hw; else @@ -34,7 +34,7 @@ void UpdateLineEndPoints(CFX_FloatRect* rect, } if (start_pos.y == end_pos.y) { - FX_FLOAT point_x; + float point_x; if (end_pos.x < start_pos.x) point_x = end_pos.x - hw; else @@ -46,11 +46,11 @@ void UpdateLineEndPoints(CFX_FloatRect* rect, } CFX_PointF diff = end_pos - start_pos; - FX_FLOAT ll = FXSYS_sqrt2(diff.x, diff.y); - FX_FLOAT mx = end_pos.x + hw * diff.x / ll; - FX_FLOAT my = end_pos.y + hw * diff.y / ll; - FX_FLOAT dx1 = hw * diff.y / ll; - FX_FLOAT dy1 = hw * diff.x / ll; + float ll = FXSYS_sqrt2(diff.x, diff.y); + float mx = end_pos.x + hw * diff.x / ll; + float my = end_pos.y + hw * diff.y / ll; + float dx1 = hw * diff.y / ll; + float dy1 = hw * diff.x / ll; rect->UpdateRect(mx - dx1, my + dy1); rect->UpdateRect(mx + dx1, my - dy1); } @@ -59,23 +59,23 @@ void UpdateLineJoinPoints(CFX_FloatRect* rect, const CFX_PointF& start_pos, const CFX_PointF& mid_pos, const CFX_PointF& end_pos, - FX_FLOAT half_width, - FX_FLOAT miter_limit) { - FX_FLOAT start_k = 0; - FX_FLOAT start_c = 0; - FX_FLOAT end_k = 0; - FX_FLOAT end_c = 0; - FX_FLOAT start_len = 0; - FX_FLOAT start_dc = 0; - FX_FLOAT end_len = 0; - FX_FLOAT end_dc = 0; - FX_FLOAT one_twentieth = 1.0f / 20; + float half_width, + float miter_limit) { + float start_k = 0; + float start_c = 0; + float end_k = 0; + float end_c = 0; + float start_len = 0; + float start_dc = 0; + float end_len = 0; + float end_dc = 0; + float one_twentieth = 1.0f / 20; bool bStartVert = FXSYS_fabs(start_pos.x - mid_pos.x) < one_twentieth; bool bEndVert = FXSYS_fabs(mid_pos.x - end_pos.x) < one_twentieth; if (bStartVert && bEndVert) { int start_dir = mid_pos.y > start_pos.y ? 1 : -1; - FX_FLOAT point_y = mid_pos.y + half_width * start_dir; + float point_y = mid_pos.y + half_width * start_dir; rect->UpdateRect(mid_pos.x + half_width, point_y); rect->UpdateRect(mid_pos.x - half_width, point_y); return; @@ -86,8 +86,8 @@ void UpdateLineJoinPoints(CFX_FloatRect* rect, start_k = (mid_pos.y - start_pos.y) / (mid_pos.x - start_pos.x); start_c = mid_pos.y - (start_k * mid_pos.x); start_len = FXSYS_sqrt2(start_to_mid.x, start_to_mid.y); - start_dc = static_cast<FX_FLOAT>( - FXSYS_fabs(half_width * start_len / start_to_mid.x)); + start_dc = + static_cast<float>(FXSYS_fabs(half_width * start_len / start_to_mid.x)); } if (!bEndVert) { CFX_PointF end_to_mid = end_pos - mid_pos; @@ -95,7 +95,7 @@ void UpdateLineJoinPoints(CFX_FloatRect* rect, end_c = mid_pos.y - (end_k * mid_pos.x); end_len = FXSYS_sqrt2(end_to_mid.x, end_to_mid.y); end_dc = - static_cast<FX_FLOAT>(FXSYS_fabs(half_width * end_len / end_to_mid.x)); + static_cast<float>(FXSYS_fabs(half_width * end_len / end_to_mid.x)); } if (bStartVert) { CFX_PointF outside(start_pos.x, 0); @@ -139,20 +139,20 @@ void UpdateLineJoinPoints(CFX_FloatRect* rect, return; } - FX_FLOAT start_outside_c = start_c; + float start_outside_c = start_c; if (end_pos.y < (start_k * end_pos.x) + start_c) start_outside_c += start_dc; else start_outside_c -= start_dc; - FX_FLOAT end_outside_c = end_c; + float end_outside_c = end_c; if (start_pos.y < (end_k * start_pos.x) + end_c) end_outside_c += end_dc; else end_outside_c -= end_dc; - FX_FLOAT join_x = (end_outside_c - start_outside_c) / (start_k - end_k); - FX_FLOAT join_y = start_k * join_x + start_outside_c; + float join_x = (end_outside_c - start_outside_c) / (start_k - end_k); + float join_y = start_k * join_x + start_outside_c; rect->UpdateRect(join_x, join_y); } @@ -203,10 +203,10 @@ void CFX_PathData::AppendPoint(const CFX_PointF& point, m_Points.push_back(FX_PATHPOINT(point, type, closeFigure)); } -void CFX_PathData::AppendRect(FX_FLOAT left, - FX_FLOAT bottom, - FX_FLOAT right, - FX_FLOAT top) { +void CFX_PathData::AppendRect(float left, + float bottom, + float right, + float top) { m_Points.push_back( FX_PATHPOINT(CFX_PointF(left, bottom), FXPT_TYPE::MoveTo, false)); m_Points.push_back( @@ -230,11 +230,11 @@ CFX_FloatRect CFX_PathData::GetBoundingBox() const { return rect; } -CFX_FloatRect CFX_PathData::GetBoundingBox(FX_FLOAT line_width, - FX_FLOAT miter_limit) const { +CFX_FloatRect CFX_PathData::GetBoundingBox(float line_width, + float miter_limit) const { CFX_FloatRect rect(100000.0f, 100000.0f, -100000.0f, -100000.0f); size_t iPoint = 0; - FX_FLOAT half_width = line_width; + float half_width = line_width; int iStartPoint = 0; int iEndPoint = 0; int iMiddlePoint = 0; diff --git a/core/fxge/ge/cfx_renderdevice.cpp b/core/fxge/ge/cfx_renderdevice.cpp index daa67ccc91..fab318373a 100644 --- a/core/fxge/ge/cfx_renderdevice.cpp +++ b/core/fxge/ge/cfx_renderdevice.cpp @@ -34,17 +34,16 @@ void AdjustGlyphSpace(std::vector<FXTEXT_GLYPHPOS>* pGlyphAndPos) { for (size_t i = glyphs.size() - 1; i > 1; --i) { FXTEXT_GLYPHPOS& next = glyphs[i]; int next_origin = bVertical ? next.m_Origin.y : next.m_Origin.x; - FX_FLOAT next_origin_f = bVertical ? next.m_fOrigin.y : next.m_fOrigin.x; + float next_origin_f = bVertical ? next.m_fOrigin.y : next.m_fOrigin.x; FXTEXT_GLYPHPOS& current = glyphs[i - 1]; int& current_origin = bVertical ? current.m_Origin.y : current.m_Origin.x; - FX_FLOAT current_origin_f = + float current_origin_f = bVertical ? current.m_fOrigin.y : current.m_fOrigin.x; int space = next_origin - current_origin; - FX_FLOAT space_f = next_origin_f - current_origin_f; - FX_FLOAT error = - FXSYS_fabs(space_f) - FXSYS_fabs(static_cast<FX_FLOAT>(space)); + float space_f = next_origin_f - current_origin_f; + float error = FXSYS_fabs(space_f) - FXSYS_fabs(static_cast<float>(space)); if (error > 0.5f) current_origin += space > 0 ? -1 : 1; } @@ -526,16 +525,16 @@ bool CFX_RenderDevice::DrawPathWithBlend(const CFX_PathData* pPathData, rect_i.bottom++; } if (rect_i.Width() >= width + 1) { - if (rect_f.left - (FX_FLOAT)(rect_i.left) > - (FX_FLOAT)(rect_i.right) - rect_f.right) { + if (rect_f.left - (float)(rect_i.left) > + (float)(rect_i.right) - rect_f.right) { rect_i.left++; } else { rect_i.right--; } } if (rect_i.Height() >= height + 1) { - if (rect_f.top - (FX_FLOAT)(rect_i.top) > - (FX_FLOAT)(rect_i.bottom) - rect_f.bottom) { + if (rect_f.top - (float)(rect_i.top) > + (float)(rect_i.bottom) - rect_f.bottom) { rect_i.top++; } else { rect_i.bottom--; @@ -608,8 +607,8 @@ bool CFX_RenderDevice::DrawFillStrokePath(const CFX_PathData* pPathData, pObject2Device->TransformRect(bbox); CFX_Matrix ctm = GetCTM(); - FX_FLOAT fScaleX = FXSYS_fabs(ctm.a); - FX_FLOAT fScaleY = FXSYS_fabs(ctm.d); + float fScaleX = FXSYS_fabs(ctm.a); + float fScaleY = FXSYS_fabs(ctm.d); FX_RECT rect = bbox.GetOuterRect(); CFX_DIBitmap bitmap, Backdrop; if (!CreateCompatibleBitmap(&bitmap, FXSYS_round(rect.Width() * fScaleX), @@ -679,10 +678,10 @@ bool CFX_RenderDevice::FillRectWithBlend(const FX_RECT* pRect, return true; } -bool CFX_RenderDevice::DrawCosmeticLine(FX_FLOAT x1, - FX_FLOAT y1, - FX_FLOAT x2, - FX_FLOAT y2, +bool CFX_RenderDevice::DrawCosmeticLine(float x1, + float y1, + float x2, + float y2, uint32_t color, int fill_mode, int blend_type) { @@ -714,8 +713,8 @@ bool CFX_RenderDevice::SetDIBitsWithBlend(const CFX_DIBSource* pBitmap, int blend_mode) { ASSERT(!pBitmap->IsAlphaMask()); CFX_Matrix ctm = GetCTM(); - FX_FLOAT fScaleX = FXSYS_fabs(ctm.a); - FX_FLOAT fScaleY = FXSYS_fabs(ctm.d); + float fScaleX = FXSYS_fabs(ctm.a); + float fScaleY = FXSYS_fabs(ctm.d); FX_RECT dest_rect(left, top, FXSYS_round(left + pBitmap->GetWidth() / fScaleX), FXSYS_round(top + pBitmap->GetHeight() / fScaleY)); @@ -848,7 +847,7 @@ bool CFX_RenderDevice::SetBitsWithMask(const CFX_DIBSource* pBitmap, bool CFX_RenderDevice::DrawNormalText(int nChars, const FXTEXT_CHARPOS* pCharPos, CFX_Font* pFont, - FX_FLOAT font_size, + float font_size, const CFX_Matrix* pText2Device, uint32_t fill_color, uint32_t text_flags) { @@ -916,8 +915,8 @@ bool CFX_RenderDevice::DrawNormalText(int nChars, } std::vector<FXTEXT_GLYPHPOS> glyphs(nChars); CFX_Matrix matrixCTM = GetCTM(); - FX_FLOAT scale_x = FXSYS_fabs(matrixCTM.a); - FX_FLOAT scale_y = FXSYS_fabs(matrixCTM.d); + float scale_x = FXSYS_fabs(matrixCTM.a); + float scale_y = FXSYS_fabs(matrixCTM.d); CFX_Matrix deviceCtm = char2device; CFX_Matrix m(scale_x, 0, 0, scale_y, 0, 0); deviceCtm.Concat(m); @@ -958,10 +957,10 @@ bool CFX_RenderDevice::DrawNormalText(int nChars, bmp_rect1.right++; bmp_rect1.bottom++; } - FX_RECT bmp_rect(FXSYS_round((FX_FLOAT)(bmp_rect1.left) / scale_x), - FXSYS_round((FX_FLOAT)(bmp_rect1.top) / scale_y), - FXSYS_round((FX_FLOAT)bmp_rect1.right / scale_x), - FXSYS_round((FX_FLOAT)bmp_rect1.bottom / scale_y)); + FX_RECT bmp_rect(FXSYS_round((float)(bmp_rect1.left) / scale_x), + FXSYS_round((float)(bmp_rect1.top) / scale_y), + FXSYS_round((float)bmp_rect1.right / scale_x), + FXSYS_round((float)bmp_rect1.bottom / scale_y)); bmp_rect.Intersect(m_ClipBox); if (bmp_rect.IsEmpty()) return true; @@ -1067,7 +1066,7 @@ bool CFX_RenderDevice::DrawNormalText(int nChars, bool CFX_RenderDevice::DrawTextPath(int nChars, const FXTEXT_CHARPOS* pCharPos, CFX_Font* pFont, - FX_FLOAT font_size, + float font_size, const CFX_Matrix* pText2User, const CFX_Matrix* pUser2Device, const CFX_GraphStateData* pGraphState, diff --git a/core/fxge/ge/fx_ge_text.cpp b/core/fxge/ge/fx_ge_text.cpp index 669969db0b..f3dea9178d 100644 --- a/core/fxge/ge/fx_ge_text.cpp +++ b/core/fxge/ge/fx_ge_text.cpp @@ -45,8 +45,8 @@ ScopedFontTransform::~ScopedFontTransform() { FX_RECT FXGE_GetGlyphsBBox(const std::vector<FXTEXT_GLYPHPOS>& glyphs, int anti_alias, - FX_FLOAT retinaScaleX, - FX_FLOAT retinaScaleY) { + float retinaScaleX, + float retinaScaleY) { FX_RECT rect(0, 0, 0, 0); bool bStarted = false; for (const FXTEXT_GLYPHPOS& glyph : glyphs) { diff --git a/core/fxge/ifx_renderdevicedriver.cpp b/core/fxge/ifx_renderdevicedriver.cpp index 77af00f430..44ce833d99 100644 --- a/core/fxge/ifx_renderdevicedriver.cpp +++ b/core/fxge/ifx_renderdevicedriver.cpp @@ -39,10 +39,10 @@ bool IFX_RenderDeviceDriver::FillRectWithBlend(const FX_RECT* pRect, return false; } -bool IFX_RenderDeviceDriver::DrawCosmeticLine(FX_FLOAT x1, - FX_FLOAT y1, - FX_FLOAT x2, - FX_FLOAT y2, +bool IFX_RenderDeviceDriver::DrawCosmeticLine(float x1, + float y1, + float x2, + float y2, uint32_t color, int blend_type) { return false; @@ -68,7 +68,7 @@ bool IFX_RenderDeviceDriver::DrawDeviceText(int nChars, const FXTEXT_CHARPOS* pCharPos, CFX_Font* pFont, const CFX_Matrix* pObject2Device, - FX_FLOAT font_size, + float font_size, uint32_t color) { return false; } diff --git a/core/fxge/ifx_renderdevicedriver.h b/core/fxge/ifx_renderdevicedriver.h index fd35149e42..3dd4730f9b 100644 --- a/core/fxge/ifx_renderdevicedriver.h +++ b/core/fxge/ifx_renderdevicedriver.h @@ -49,10 +49,10 @@ class IFX_RenderDeviceDriver { virtual bool FillRectWithBlend(const FX_RECT* pRect, uint32_t fill_color, int blend_type); - virtual bool DrawCosmeticLine(FX_FLOAT x1, - FX_FLOAT y1, - FX_FLOAT x2, - FX_FLOAT y2, + virtual bool DrawCosmeticLine(float x1, + float y1, + float x2, + float y2, uint32_t color, int blend_type); @@ -87,7 +87,7 @@ class IFX_RenderDeviceDriver { const FXTEXT_CHARPOS* pCharPos, CFX_Font* pFont, const CFX_Matrix* pObject2Device, - FX_FLOAT font_size, + float font_size, uint32_t color); virtual void* GetPlatformSurface() const; virtual int GetDriverType() const; diff --git a/core/fxge/skia/fx_skia_device.cpp b/core/fxge/skia/fx_skia_device.cpp index 7e23f97287..949ffb8031 100644 --- a/core/fxge/skia/fx_skia_device.cpp +++ b/core/fxge/skia/fx_skia_device.cpp @@ -368,7 +368,7 @@ bool AddColors(const CPDF_ExpIntFunc* pFunc, SkTDArray<SkColor>* skColors) { return true; } -uint8_t FloatToByte(FX_FLOAT f) { +uint8_t FloatToByte(float f) { ASSERT(0 <= f && f <= 1); return (uint8_t)(f * 255.99f); } @@ -395,25 +395,25 @@ bool AddSamples(const CPDF_SampledFunc* pFunc, if (pFunc->GetSampleStream()->GetSize() < sampleCount * 3 * sampleSize / 8) return false; - FX_FLOAT colorsMin[3]; - FX_FLOAT colorsMax[3]; + float colorsMin[3]; + float colorsMax[3]; for (int i = 0; i < 3; ++i) { colorsMin[i] = pFunc->GetRange(i * 2); colorsMax[i] = pFunc->GetRange(i * 2 + 1); } const uint8_t* pSampleData = pFunc->GetSampleStream()->GetData(); for (uint32_t i = 0; i < sampleCount; ++i) { - FX_FLOAT floatColors[3]; + float floatColors[3]; for (uint32_t j = 0; j < 3; ++j) { int sample = GetBits32(pSampleData, (i * 3 + j) * sampleSize, sampleSize); - FX_FLOAT interp = (FX_FLOAT)sample / (sampleCount - 1); + float interp = (float)sample / (sampleCount - 1); floatColors[j] = colorsMin[j] + (colorsMax[j] - colorsMin[j]) * interp; } SkColor color = SkPackARGB32(0xFF, FloatToByte(floatColors[0]), FloatToByte(floatColors[1]), FloatToByte(floatColors[2])); skColors->push(color); - skPos->push((FX_FLOAT)i / (sampleCount - 1)); + skPos->push((float)i / (sampleCount - 1)); } return true; } @@ -421,7 +421,7 @@ bool AddSamples(const CPDF_SampledFunc* pFunc, bool AddStitching(const CPDF_StitchFunc* pFunc, SkTDArray<SkColor>* skColors, SkTDArray<SkScalar>* skPos) { - FX_FLOAT boundsStart = pFunc->GetDomain(0); + float boundsStart = pFunc->GetDomain(0); const auto& subFunctions = pFunc->GetSubFunctions(); int subFunctionCount = subFunctions.size(); @@ -431,7 +431,7 @@ bool AddStitching(const CPDF_StitchFunc* pFunc, return false; if (!AddColors(pSubFunc, skColors)) return false; - FX_FLOAT boundsEnd = + float boundsEnd = i < subFunctionCount - 1 ? pFunc->GetBound(i + 1) : pFunc->GetDomain(1); skPos->push(boundsStart); skPos->push(boundsEnd); @@ -771,7 +771,7 @@ class SkiaState { const FXTEXT_CHARPOS* pCharPos, CFX_Font* pFont, const CFX_Matrix* pMatrix, - FX_FLOAT font_size, + float font_size, uint32_t color) { if (m_debugDisable) return false; @@ -973,7 +973,7 @@ class SkiaState { bool FontChanged(CFX_Font* pFont, const CFX_Matrix* pMatrix, - FX_FLOAT font_size, + float font_size, uint32_t color) const { return pFont != m_pFont || MatrixChanged(pMatrix, m_drawMatrix) || font_size != m_fontSize || color != m_fillColor; @@ -1118,7 +1118,7 @@ class SkiaState { CFX_Matrix m_clipMatrix; CFX_SkiaDeviceDriver* m_pDriver; CFX_Font* m_pFont; - FX_FLOAT m_fontSize; + float m_fontSize; uint32_t m_fillColor; uint32_t m_strokeColor; int m_blendType; @@ -1170,7 +1170,7 @@ void CFX_SkiaDeviceDriver::PaintStroke(SkPaint* spaint, inverse.set(SkMatrix::kMTransY, 0); SkVector deviceUnits[2] = {{0, 1}, {1, 0}}; inverse.mapPoints(deviceUnits, SK_ARRAY_COUNT(deviceUnits)); - FX_FLOAT width = + float width = SkTMax(pGraphState->m_LineWidth, SkTMin(deviceUnits[0].length(), deviceUnits[1].length())); if (pGraphState->m_DashArray) { @@ -1178,12 +1178,12 @@ void CFX_SkiaDeviceDriver::PaintStroke(SkPaint* spaint, SkScalar* intervals = FX_Alloc2D(SkScalar, count, sizeof(SkScalar)); // Set dash pattern for (int i = 0; i < count; i++) { - FX_FLOAT on = pGraphState->m_DashArray[i * 2]; + float on = pGraphState->m_DashArray[i * 2]; if (on <= 0.000001f) on = 1.f / 10; - FX_FLOAT off = i * 2 + 1 == pGraphState->m_DashCount - ? on - : pGraphState->m_DashArray[i * 2 + 1]; + float off = i * 2 + 1 == pGraphState->m_DashCount + ? on + : pGraphState->m_DashArray[i * 2 + 1]; if (off < 0) off = 0; intervals[i * 2] = on; @@ -1261,7 +1261,7 @@ bool CFX_SkiaDeviceDriver::DrawDeviceText(int nChars, const FXTEXT_CHARPOS* pCharPos, CFX_Font* pFont, const CFX_Matrix* pObject2Device, - FX_FLOAT font_size, + float font_size, uint32_t color) { if (m_pCache->DrawText(nChars, pCharPos, pFont, pObject2Device, font_size, color)) { @@ -1435,9 +1435,9 @@ bool CFX_SkiaDeviceDriver::SetClip_PathFill( pPathData->GetPoints().size() == 4) { CFX_FloatRect rectf; if (pPathData->IsRect(deviceMatrix, &rectf)) { - rectf.Intersect( - CFX_FloatRect(0, 0, (FX_FLOAT)GetDeviceCaps(FXDC_PIXEL_WIDTH), - (FX_FLOAT)GetDeviceCaps(FXDC_PIXEL_HEIGHT))); + rectf.Intersect(CFX_FloatRect(0, 0, + (float)GetDeviceCaps(FXDC_PIXEL_WIDTH), + (float)GetDeviceCaps(FXDC_PIXEL_HEIGHT))); // note that PDF's y-axis goes up; Skia's y-axis goes down if (!cached) { SkRect skClipRect = @@ -1573,10 +1573,10 @@ bool CFX_SkiaDeviceDriver::DrawPath( return true; } -bool CFX_SkiaDeviceDriver::DrawCosmeticLine(FX_FLOAT x1, - FX_FLOAT y1, - FX_FLOAT x2, - FX_FLOAT y2, +bool CFX_SkiaDeviceDriver::DrawCosmeticLine(float x1, + float y1, + float x2, + float y2, uint32_t color, int blend_type) { return false; @@ -1661,10 +1661,10 @@ bool CFX_SkiaDeviceDriver::DrawShading(const CPDF_ShadingPattern* pPattern, SkPath skClip; SkPath skPath; if (kAxialShading == shadingType) { - FX_FLOAT start_x = pCoords->GetNumberAt(0); - FX_FLOAT start_y = pCoords->GetNumberAt(1); - FX_FLOAT end_x = pCoords->GetNumberAt(2); - FX_FLOAT end_y = pCoords->GetNumberAt(3); + float start_x = pCoords->GetNumberAt(0); + float start_y = pCoords->GetNumberAt(1); + float end_x = pCoords->GetNumberAt(2); + float end_y = pCoords->GetNumberAt(3); SkPoint pts[] = {{start_x, start_y}, {end_x, end_y}}; skMatrix.mapPoints(pts, SK_ARRAY_COUNT(pts)); paint.setShader(SkGradientShader::MakeLinear( @@ -1701,12 +1701,12 @@ bool CFX_SkiaDeviceDriver::DrawShading(const CPDF_ShadingPattern* pPattern, skPath.addRect(skRect); skMatrix.setIdentity(); } else if (kRadialShading == shadingType) { - FX_FLOAT start_x = pCoords->GetNumberAt(0); - FX_FLOAT start_y = pCoords->GetNumberAt(1); - FX_FLOAT start_r = pCoords->GetNumberAt(2); - FX_FLOAT end_x = pCoords->GetNumberAt(3); - FX_FLOAT end_y = pCoords->GetNumberAt(4); - FX_FLOAT end_r = pCoords->GetNumberAt(5); + float start_x = pCoords->GetNumberAt(0); + float start_y = pCoords->GetNumberAt(1); + float start_r = pCoords->GetNumberAt(2); + float end_x = pCoords->GetNumberAt(3); + float end_y = pCoords->GetNumberAt(4); + float end_r = pCoords->GetNumberAt(5); SkPoint pts[] = {{start_x, start_y}, {end_x, end_y}}; paint.setShader(SkGradientShader::MakeTwoPointConical( @@ -1761,9 +1761,9 @@ bool CFX_SkiaDeviceDriver::DrawShading(const CPDF_ShadingPattern* pPattern, cubics[i].fY = point.y; } for (int i = iStartColor; i < (int)SK_ARRAY_COUNT(colors); i++) { - FX_FLOAT r; - FX_FLOAT g; - FX_FLOAT b; + float r; + float g; + float b; std::tie(r, g, b) = stream.ReadColor(); colors[i] = SkColorSetARGBInline(0xFF, (U8CPU)(r * 255), (U8CPU)(g * 255), (U8CPU)(b * 255)); diff --git a/core/fxge/skia/fx_skia_device.h b/core/fxge/skia/fx_skia_device.h index ecb1104518..b26ebdd724 100644 --- a/core/fxge/skia/fx_skia_device.h +++ b/core/fxge/skia/fx_skia_device.h @@ -69,10 +69,10 @@ class CFX_SkiaDeviceDriver : public IFX_RenderDeviceDriver { int blend_type) override; /** Draw a single pixel (device dependant) line */ - bool DrawCosmeticLine(FX_FLOAT x1, - FX_FLOAT y1, - FX_FLOAT x2, - FX_FLOAT y2, + bool DrawCosmeticLine(float x1, + float y1, + float x2, + float y2, uint32_t color, int blend_type) override; @@ -134,7 +134,7 @@ class CFX_SkiaDeviceDriver : public IFX_RenderDeviceDriver { const FXTEXT_CHARPOS* pCharPos, CFX_Font* pFont, const CFX_Matrix* pObject2Device, - FX_FLOAT font_size, + float font_size, uint32_t color) override; bool DrawShading(const CPDF_ShadingPattern* pPattern, diff --git a/core/fxge/skia/fx_skia_device_unittest.cpp b/core/fxge/skia/fx_skia_device_unittest.cpp index afd47780d7..d612840b4c 100644 --- a/core/fxge/skia/fx_skia_device_unittest.cpp +++ b/core/fxge/skia/fx_skia_device_unittest.cpp @@ -41,7 +41,7 @@ void CommonTest(CFX_SkiaDeviceDriver* driver, const State& state) { charPos[0].m_FontCharWidth = 4; CFX_Font font; - FX_FLOAT fontSize = 1; + float fontSize = 1; CFX_PathData clipPath, clipPath2; clipPath.AppendRect(0, 0, 3, 1); clipPath2.AppendRect(0, 0, 2, 1); diff --git a/core/fxge/win32/cfx_psrenderer.cpp b/core/fxge/win32/cfx_psrenderer.cpp index c3d2c66d9d..391af83630 100644 --- a/core/fxge/win32/cfx_psrenderer.cpp +++ b/core/fxge/win32/cfx_psrenderer.cpp @@ -22,7 +22,7 @@ struct PSGlyph { CFX_Font* m_pFont; uint32_t m_GlyphIndex; bool m_bGlyphAdjust; - FX_FLOAT m_AdjustMatrix[4]; + float m_AdjustMatrix[4]; }; class CPSFont { @@ -260,7 +260,7 @@ void CFX_PSRenderer::SetGraphState(const CFX_GraphStateData* pGraphState) { if (!m_bGraphStateSet || m_CurGraphState.m_DashCount != pGraphState->m_DashCount || FXSYS_memcmp(m_CurGraphState.m_DashArray, pGraphState->m_DashArray, - sizeof(FX_FLOAT) * m_CurGraphState.m_DashCount)) { + sizeof(float) * m_CurGraphState.m_DashCount)) { buf << "["; for (int i = 0; i < pGraphState->m_DashCount; ++i) { buf << pGraphState->m_DashArray[i] << " "; @@ -343,9 +343,9 @@ bool CFX_PSRenderer::SetDIBits(const CFX_DIBSource* pSource, int left, int top) { StartRendering(); - CFX_Matrix matrix((FX_FLOAT)(pSource->GetWidth()), 0.0f, 0.0f, - -(FX_FLOAT)(pSource->GetHeight()), (FX_FLOAT)(left), - (FX_FLOAT)(top + pSource->GetHeight())); + CFX_Matrix matrix((float)(pSource->GetWidth()), 0.0f, 0.0f, + -(float)(pSource->GetHeight()), (float)(left), + (float)(top + pSource->GetHeight())); return DrawDIBits(pSource, color, &matrix, 0); } @@ -357,9 +357,8 @@ bool CFX_PSRenderer::StretchDIBits(const CFX_DIBSource* pSource, int dest_height, uint32_t flags) { StartRendering(); - CFX_Matrix matrix((FX_FLOAT)(dest_width), 0.0f, 0.0f, - (FX_FLOAT)(-dest_height), (FX_FLOAT)(dest_left), - (FX_FLOAT)(dest_top + dest_height)); + CFX_Matrix matrix((float)(dest_width), 0.0f, 0.0f, (float)(-dest_height), + (float)(dest_left), (float)(dest_top + dest_height)); return DrawDIBits(pSource, color, &matrix, flags); } @@ -632,7 +631,7 @@ bool CFX_PSRenderer::DrawText(int nChars, const FXTEXT_CHARPOS* pCharPos, CFX_Font* pFont, const CFX_Matrix* pObject2Device, - FX_FLOAT font_size, + float font_size, uint32_t color) { StartRendering(); int alpha = FXARGB_A(color); diff --git a/core/fxge/win32/cfx_psrenderer.h b/core/fxge/win32/cfx_psrenderer.h index 163c6180af..133d7b9d72 100644 --- a/core/fxge/win32/cfx_psrenderer.h +++ b/core/fxge/win32/cfx_psrenderer.h @@ -70,7 +70,7 @@ class CFX_PSRenderer { const FXTEXT_CHARPOS* pCharPos, CFX_Font* pFont, const CFX_Matrix* pObject2Device, - FX_FLOAT font_size, + float font_size, uint32_t color); private: diff --git a/core/fxge/win32/dwrite_int.h b/core/fxge/win32/dwrite_int.h index 86ead89947..105c34998c 100644 --- a/core/fxge/win32/dwrite_int.h +++ b/core/fxge/win32/dwrite_int.h @@ -46,14 +46,14 @@ class CDWriteExt { FX_RECT& stringRect, CFX_Matrix* pMatrix, void* font, - FX_FLOAT font_size, + float font_size, FX_ARGB text_color, int glyph_count, unsigned short* glyph_indices, - FX_FLOAT baselineOriginX, - FX_FLOAT baselineOriginY, + float baselineOriginX, + float baselineOriginY, void* glyph_offsets, - FX_FLOAT* glyph_advances); + float* glyph_advances); void DwDeleteFont(void* pFont); protected: diff --git a/core/fxge/win32/fx_win32_device.cpp b/core/fxge/win32/fx_win32_device.cpp index d1d81b18e4..b2ee4549ea 100644 --- a/core/fxge/win32/fx_win32_device.cpp +++ b/core/fxge/win32/fx_win32_device.cpp @@ -91,8 +91,8 @@ bool IsGDIEnabled() { HPEN CreatePen(const CFX_GraphStateData* pGraphState, const CFX_Matrix* pMatrix, uint32_t argb) { - FX_FLOAT width; - FX_FLOAT scale = 1.f; + float width; + float scale = 1.f; if (pMatrix) scale = FXSYS_fabs(pMatrix->a) > FXSYS_fabs(pMatrix->b) ? FXSYS_fabs(pMatrix->a) @@ -215,26 +215,26 @@ void SetPathToDC(HDC hDC, // altogether and replace by Skia code. struct rect_base { - FX_FLOAT x1; - FX_FLOAT y1; - FX_FLOAT x2; - FX_FLOAT y2; + float x1; + float y1; + float x2; + float y2; }; -unsigned clip_liang_barsky(FX_FLOAT x1, - FX_FLOAT y1, - FX_FLOAT x2, - FX_FLOAT y2, +unsigned clip_liang_barsky(float x1, + float y1, + float x2, + float y2, const rect_base& clip_box, - FX_FLOAT* x, - FX_FLOAT* y) { - const FX_FLOAT nearzero = 1e-30f; - FX_FLOAT deltax = x2 - x1; - FX_FLOAT deltay = y2 - y1; + float* x, + float* y) { + const float nearzero = 1e-30f; + float deltax = x2 - x1; + float deltay = y2 - y1; unsigned np = 0; if (deltax == 0) deltax = (x1 > clip_box.x1) ? -nearzero : nearzero; - FX_FLOAT xin, xout; + float xin, xout; if (deltax > 0) { xin = clip_box.x1; xout = clip_box.x2; @@ -242,10 +242,10 @@ unsigned clip_liang_barsky(FX_FLOAT x1, xin = clip_box.x2; xout = clip_box.x1; } - FX_FLOAT tinx = (xin - x1) / deltax; + float tinx = (xin - x1) / deltax; if (deltay == 0) deltay = (y1 > clip_box.y1) ? -nearzero : nearzero; - FX_FLOAT yin, yout; + float yin, yout; if (deltay > 0) { yin = clip_box.y1; yout = clip_box.y2; @@ -253,8 +253,8 @@ unsigned clip_liang_barsky(FX_FLOAT x1, yin = clip_box.y2; yout = clip_box.y1; } - FX_FLOAT tiny = (yin - y1) / deltay; - FX_FLOAT tin1, tin2; + float tiny = (yin - y1) / deltay; + float tin1, tin2; if (tinx < tiny) { tin1 = tinx; tin2 = tiny; @@ -269,9 +269,9 @@ unsigned clip_liang_barsky(FX_FLOAT x1, ++np; } if (tin2 <= 1.0f) { - FX_FLOAT toutx = (xout - x1) / deltax; - FX_FLOAT touty = (yout - y1) / deltay; - FX_FLOAT tout1 = (toutx < touty) ? toutx : touty; + float toutx = (xout - x1) / deltax; + float touty = (yout - y1) / deltay; + float tout1 = (toutx < touty) ? toutx : touty; if (tin2 > 0 || tout1 > 0) { if (tin2 <= tout1) { if (tin2 > 0) { @@ -928,10 +928,7 @@ void* CGdiDeviceDriver::GetPlatformSurface() const { return (void*)m_hDC; } -void CGdiDeviceDriver::DrawLine(FX_FLOAT x1, - FX_FLOAT y1, - FX_FLOAT x2, - FX_FLOAT y2) { +void CGdiDeviceDriver::DrawLine(float x1, float y1, float x2, float y2) { if (!m_bMetafileDCType) { // EMF drawing is not bound to the DC. int startOutOfBoundsFlag = (x1 < 0) | ((x1 > m_Width) << 1) | ((y1 < 0) << 2) | ((y1 > m_Height) << 3); @@ -941,18 +938,18 @@ void CGdiDeviceDriver::DrawLine(FX_FLOAT x1, return; if (startOutOfBoundsFlag || endOutOfBoundsFlag) { - FX_FLOAT x[2]; - FX_FLOAT y[2]; + float x[2]; + float y[2]; int np; #ifdef _SKIA_SUPPORT_ // TODO(caryclark) temporary replacement of antigrain in line function // to permit removing antigrain altogether - rect_base rect = {0.0f, 0.0f, (FX_FLOAT)(m_Width), (FX_FLOAT)(m_Height)}; + rect_base rect = {0.0f, 0.0f, (float)(m_Width), (float)(m_Height)}; np = clip_liang_barsky(x1, y1, x2, y2, rect, x, y); #else - agg::rect_base<FX_FLOAT> rect(0.0f, 0.0f, (FX_FLOAT)(m_Width), - (FX_FLOAT)(m_Height)); - np = agg::clip_liang_barsky<FX_FLOAT>(x1, y1, x2, y2, rect, x, y); + agg::rect_base<float> rect(0.0f, 0.0f, (float)(m_Width), + (float)(m_Height)); + np = agg::clip_liang_barsky<float>(x1, y1, x2, y2, rect, x, y); #endif if (np == 0) return; @@ -994,13 +991,13 @@ bool CGdiDeviceDriver::DrawPath(const CFX_PathData* pPathData, FX_RECT bbox = bbox_f.GetInnerRect(); if (bbox.Width() <= 0) { - return DrawCosmeticLine( - (FX_FLOAT)(bbox.left), (FX_FLOAT)(bbox.top), (FX_FLOAT)(bbox.left), - (FX_FLOAT)(bbox.bottom + 1), fill_color, FXDIB_BLEND_NORMAL); + return DrawCosmeticLine((float)(bbox.left), (float)(bbox.top), + (float)(bbox.left), (float)(bbox.bottom + 1), + fill_color, FXDIB_BLEND_NORMAL); } if (bbox.Height() <= 0) { - return DrawCosmeticLine((FX_FLOAT)(bbox.left), (FX_FLOAT)(bbox.top), - (FX_FLOAT)(bbox.right + 1), (FX_FLOAT)(bbox.top), + return DrawCosmeticLine((float)(bbox.left), (float)(bbox.top), + (float)(bbox.right + 1), (float)(bbox.top), fill_color, FXDIB_BLEND_NORMAL); } } @@ -1133,10 +1130,10 @@ bool CGdiDeviceDriver::SetClip_PathStroke( return ret; } -bool CGdiDeviceDriver::DrawCosmeticLine(FX_FLOAT x1, - FX_FLOAT y1, - FX_FLOAT x2, - FX_FLOAT y2, +bool CGdiDeviceDriver::DrawCosmeticLine(float x1, + float y1, + float x2, + float y2, uint32_t color, int blend_type) { if (blend_type != FXDIB_BLEND_NORMAL) diff --git a/core/fxge/win32/fx_win32_dwrite.cpp b/core/fxge/win32/fx_win32_dwrite.cpp index dc0f5ed745..e088e832bc 100644 --- a/core/fxge/win32/fx_win32_dwrite.cpp +++ b/core/fxge/win32/fx_win32_dwrite.cpp @@ -227,14 +227,14 @@ bool CDWriteExt::DwRendingString(void* renderTarget, FX_RECT& stringRect, CFX_Matrix* pMatrix, void* font, - FX_FLOAT font_size, + float font_size, FX_ARGB text_color, int glyph_count, unsigned short* glyph_indices, - FX_FLOAT baselineOriginX, - FX_FLOAT baselineOriginY, + float baselineOriginX, + float baselineOriginY, void* glyph_offsets, - FX_FLOAT* glyph_advances) { + float* glyph_advances) { if (!renderTarget) { return true; } diff --git a/core/fxge/win32/fx_win32_gdipext.cpp b/core/fxge/win32/fx_win32_gdipext.cpp index 1e51bba2b3..8a7f55e0cb 100644 --- a/core/fxge/win32/fx_win32_gdipext.cpp +++ b/core/fxge/win32/fx_win32_gdipext.cpp @@ -779,7 +779,7 @@ bool CGdiplusExt::GdipCreateFontFamilyFromName(const wchar_t* name, return false; } bool CGdiplusExt::GdipCreateFontFromFamily(void* pFamily, - FX_FLOAT font_size, + float font_size, int fontstyle, int flag, void** pFont) { @@ -793,13 +793,13 @@ bool CGdiplusExt::GdipCreateFontFromFamily(void* pFamily, } return false; } -void CGdiplusExt::GdipGetFontSize(void* pFont, FX_FLOAT* size) { +void CGdiplusExt::GdipGetFontSize(void* pFont, float* size) { REAL get_size; CGdiplusExt& GdiplusExt = ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt; GpStatus status = CallFunc(GdipGetFontSize)((GpFont*)pFont, (REAL*)&get_size); if (status == Ok) { - *size = (FX_FLOAT)get_size; + *size = (float)get_size; } else { *size = 0; } @@ -845,7 +845,7 @@ void CGdiplusExt::GdipDeleteBrush(void* pBrush) { CallFunc(GdipDeleteBrush)((GpSolidFill*)pBrush); } void* CGdiplusExt::GdipCreateFontFromCollection(void* pFontCollection, - FX_FLOAT font_size, + float font_size, int fontstyle) { CGdiplusExt& GdiplusExt = ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt; @@ -869,12 +869,12 @@ void* CGdiplusExt::GdipCreateFontFromCollection(void* pFontCollection, } return pFont; } -void CGdiplusExt::GdipCreateMatrix(FX_FLOAT a, - FX_FLOAT b, - FX_FLOAT c, - FX_FLOAT d, - FX_FLOAT e, - FX_FLOAT f, +void CGdiplusExt::GdipCreateMatrix(float a, + float b, + float c, + float d, + float e, + float f, void** matrix) { CGdiplusExt& GdiplusExt = ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt; @@ -972,11 +972,11 @@ static GpPen* _GdipCreatePen(const CFX_GraphStateData* pGraphState, bool bTextMode = false) { CGdiplusExt& GdiplusExt = ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt; - FX_FLOAT width = pGraphState ? pGraphState->m_LineWidth : 1.0f; + float width = pGraphState ? pGraphState->m_LineWidth : 1.0f; if (!bTextMode) { - FX_FLOAT unit = - pMatrix ? 1.0f / ((pMatrix->GetXUnit() + pMatrix->GetYUnit()) / 2) - : 1.0f; + float unit = pMatrix + ? 1.0f / ((pMatrix->GetXUnit() + pMatrix->GetYUnit()) / 2) + : 1.0f; if (width < unit) { width = unit; } @@ -1015,13 +1015,13 @@ static GpPen* _GdipCreatePen(const CFX_GraphStateData* pGraphState, } CallFunc(GdipSetPenLineJoin)(pPen, lineJoin); if (pGraphState->m_DashCount) { - FX_FLOAT* pDashArray = FX_Alloc( - FX_FLOAT, pGraphState->m_DashCount + pGraphState->m_DashCount % 2); + float* pDashArray = FX_Alloc( + float, pGraphState->m_DashCount + pGraphState->m_DashCount % 2); int nCount = 0; - FX_FLOAT on_leftover = 0, off_leftover = 0; + float on_leftover = 0, off_leftover = 0; for (int i = 0; i < pGraphState->m_DashCount; i += 2) { - FX_FLOAT on_phase = pGraphState->m_DashArray[i]; - FX_FLOAT off_phase; + float on_phase = pGraphState->m_DashArray[i]; + float off_phase; if (i == pGraphState->m_DashCount - 1) { off_phase = on_phase; } else { @@ -1057,7 +1057,7 @@ static GpPen* _GdipCreatePen(const CFX_GraphStateData* pGraphState, } } CallFunc(GdipSetPenDashArray)(pPen, pDashArray, nCount); - FX_FLOAT phase = pGraphState->m_DashPhase; + float phase = pGraphState->m_DashPhase; if (bDashExtend) { if (phase < 0.5f) { phase = 0; @@ -1089,7 +1089,7 @@ static bool IsSmallTriangle(PointF* points, } CFX_PointF diff = p1 - p2; - FX_FLOAT distance_square = (diff.x * diff.x) + (diff.y * diff.y); + float distance_square = (diff.x * diff.x) + (diff.y * diff.y); if (distance_square < (1.0f * 2 + 1.0f / 4)) { v1 = i; v2 = pair1; diff --git a/core/fxge/win32/fx_win32_print.cpp b/core/fxge/win32/fx_win32_print.cpp index cda83ebc95..061896f09b 100644 --- a/core/fxge/win32/fx_win32_print.cpp +++ b/core/fxge/win32/fx_win32_print.cpp @@ -199,7 +199,7 @@ bool CGdiPrinterDriver::DrawDeviceText(int nChars, const FXTEXT_CHARPOS* pCharPos, CFX_Font* pFont, const CFX_Matrix* pObject2Device, - FX_FLOAT font_size, + float font_size, uint32_t color) { #if defined(PDFIUM_PRINT_TEXT_WITH_GDI) if (!g_pdfium_print_text_with_gdi) @@ -287,7 +287,7 @@ bool CGdiPrinterDriver::DrawDeviceText(int nChars, // Text CFX_WideString wsText; std::vector<INT> spacing(nChars); - FX_FLOAT fPreviousOriginX = 0; + float fPreviousOriginX = 0; for (int i = 0; i < nChars; ++i) { // Only works with PDFs from Skia's PDF generator. Cannot handle arbitrary // values from PDFs. @@ -300,8 +300,8 @@ bool CGdiPrinterDriver::DrawDeviceText(int nChars, // Round the spacing to the nearest integer, but keep track of the rounding // error for calculating the next spacing value. - FX_FLOAT fOriginX = charpos.m_Origin.x * kScaleFactor; - FX_FLOAT fPixelSpacing = fOriginX - fPreviousOriginX; + float fOriginX = charpos.m_Origin.x * kScaleFactor; + float fPixelSpacing = fOriginX - fPreviousOriginX; spacing[i] = FXSYS_round(fPixelSpacing); fPreviousOriginX = fOriginX - (fPixelSpacing - spacing[i]); @@ -349,10 +349,10 @@ CPSPrinterDriver::CPSPrinterDriver(HDC hDC, int pslevel, bool bCmykOutput) for (uint32_t i = 0; i < pData->rdh.nCount; i++) { RECT* pRect = reinterpret_cast<RECT*>(pData->Buffer + pData->rdh.nRgnSize * i); - path.AppendRect(static_cast<FX_FLOAT>(pRect->left), - static_cast<FX_FLOAT>(pRect->bottom), - static_cast<FX_FLOAT>(pRect->right), - static_cast<FX_FLOAT>(pRect->top)); + path.AppendRect(static_cast<float>(pRect->left), + static_cast<float>(pRect->bottom), + static_cast<float>(pRect->right), + static_cast<float>(pRect->top)); } m_PSRenderer.SetClip_PathFill(&path, nullptr, FXFILL_WINDING); } @@ -483,7 +483,7 @@ bool CPSPrinterDriver::DrawDeviceText(int nChars, const FXTEXT_CHARPOS* pCharPos, CFX_Font* pFont, const CFX_Matrix* pObject2Device, - FX_FLOAT font_size, + float font_size, uint32_t color) { return m_PSRenderer.DrawText(nChars, pCharPos, pFont, pObject2Device, font_size, color); diff --git a/core/fxge/win32/win32_int.h b/core/fxge/win32/win32_int.h index 08a8224db6..54ea3716e1 100644 --- a/core/fxge/win32/win32_int.h +++ b/core/fxge/win32/win32_int.h @@ -75,12 +75,12 @@ class CGdiplusExt { const void* matrix); void GdipCreateBrush(uint32_t fill_argb, void** pBrush); void GdipDeleteBrush(void* pBrush); - void GdipCreateMatrix(FX_FLOAT a, - FX_FLOAT b, - FX_FLOAT c, - FX_FLOAT d, - FX_FLOAT e, - FX_FLOAT f, + void GdipCreateMatrix(float a, + float b, + float c, + float d, + float e, + float f, void** matrix); void GdipDeleteMatrix(void* matrix); bool GdipCreateFontFamilyFromName(const wchar_t* name, @@ -88,17 +88,17 @@ class CGdiplusExt { void** pFamily); void GdipDeleteFontFamily(void* pFamily); bool GdipCreateFontFromFamily(void* pFamily, - FX_FLOAT font_size, + float font_size, int fontstyle, int flag, void** pFont); void* GdipCreateFontFromCollection(void* pFontCollection, - FX_FLOAT font_size, + float font_size, int fontstyle); void GdipDeleteFont(void* pFont); bool GdipCreateBitmap(CFX_DIBitmap* pBitmap, void** bitmap); void GdipDisposeImage(void* bitmap); - void GdipGetFontSize(void* pFont, FX_FLOAT* size); + void GdipGetFontSize(void* pFont, float* size); void* GdiAddFontMemResourceEx(void* pFontdata, uint32_t size, void* pdv, @@ -147,16 +147,16 @@ class CGdiDeviceDriver : public IFX_RenderDeviceDriver { bool FillRectWithBlend(const FX_RECT* pRect, uint32_t fill_color, int blend_type) override; - bool DrawCosmeticLine(FX_FLOAT x1, - FX_FLOAT y1, - FX_FLOAT x2, - FX_FLOAT y2, + bool DrawCosmeticLine(float x1, + float y1, + float x2, + float y2, uint32_t color, int blend_type) override; bool GetClipBox(FX_RECT* pRect) override; void* GetPlatformSurface() const override; - void DrawLine(FX_FLOAT x1, FX_FLOAT y1, FX_FLOAT x2, FX_FLOAT y2); + void DrawLine(float x1, float y1, float x2, float y2); bool GDI_SetDIBits(CFX_DIBitmap* pBitmap, const FX_RECT* pSrcRect, @@ -257,7 +257,7 @@ class CGdiPrinterDriver : public CGdiDeviceDriver { const FXTEXT_CHARPOS* pCharPos, CFX_Font* pFont, const CFX_Matrix* pObject2Device, - FX_FLOAT font_size, + float font_size, uint32_t color) override; const int m_HorzSize; @@ -316,7 +316,7 @@ class CPSPrinterDriver : public IFX_RenderDeviceDriver { const FXTEXT_CHARPOS* pCharPos, CFX_Font* pFont, const CFX_Matrix* pObject2Device, - FX_FLOAT font_size, + float font_size, uint32_t color) override; void* GetPlatformSurface() const override; |