diff options
Diffstat (limited to 'core/fpdfapi/page')
32 files changed, 496 insertions, 616 deletions
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); |