diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2017-03-14 14:43:42 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-03-14 19:05:58 +0000 |
commit | 05df075154a832fcb476e1dfcfb865722d0ea898 (patch) | |
tree | b8b771b62adae74d5d5ee561db75d10de3a848bf /core/fxcodec/codec | |
parent | 6b94f01d1c8ad386d497428c7397b1a99614aeba (diff) | |
download | pdfium-05df075154a832fcb476e1dfcfb865722d0ea898.tar.xz |
Replace FX_FLOAT with underlying float type.
Change-Id: I158b7d80b0ec28b742a9f2d5a96f3dde7fb3ab56
Reviewed-on: https://pdfium-review.googlesource.com/3031
Commit-Queue: dsinclair <dsinclair@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Nicolás Peña <npm@chromium.org>
Diffstat (limited to 'core/fxcodec/codec')
-rw-r--r-- | core/fxcodec/codec/ccodec_iccmodule.h | 2 | ||||
-rw-r--r-- | core/fxcodec/codec/ccodec_tiffmodule.cpp | 10 | ||||
-rw-r--r-- | core/fxcodec/codec/fx_codec_icc.cpp | 22 | ||||
-rw-r--r-- | core/fxcodec/codec/fx_codec_jpx_unittest.cpp | 8 | ||||
-rw-r--r-- | core/fxcodec/codec/fx_codec_progress.cpp | 74 |
5 files changed, 55 insertions, 61 deletions
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()) { |