From 05df075154a832fcb476e1dfcfb865722d0ea898 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Tue, 14 Mar 2017 14:43:42 -0400 Subject: Replace FX_FLOAT with underlying float type. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I158b7d80b0ec28b742a9f2d5a96f3dde7fb3ab56 Reviewed-on: https://pdfium-review.googlesource.com/3031 Commit-Queue: dsinclair Reviewed-by: Tom Sepez Reviewed-by: Nicolás Peña --- core/fxge/ge/cfx_facecache.cpp | 2 +- core/fxge/ge/cfx_font.cpp | 2 +- core/fxge/ge/cfx_gemodule.cpp | 4 +-- core/fxge/ge/cfx_graphstate.cpp | 12 +++---- core/fxge/ge/cfx_graphstatedata.cpp | 6 ++-- core/fxge/ge/cfx_pathdata.cpp | 68 ++++++++++++++++++------------------- core/fxge/ge/cfx_renderdevice.cpp | 49 +++++++++++++------------- core/fxge/ge/fx_ge_text.cpp | 4 +-- 8 files changed, 72 insertions(+), 75 deletions(-) (limited to 'core/fxge/ge') diff --git a/core/fxge/ge/cfx_facecache.cpp b/core/fxge/ge/cfx_facecache.cpp index 314c95b8b2..3cdff44f8b 100644 --- a/core/fxge/ge/cfx_facecache.cpp +++ b/core/fxge/ge/cfx_facecache.cpp @@ -44,7 +44,7 @@ void ContrastAdjust(uint8_t* pDataIn, int nDstRowBytes) { int col, row, temp; int max = 0, min = 255; - FX_FLOAT rate; + float rate; for (row = 0; row < nHeight; row++) { uint8_t* pRow = pDataIn + row * nSrcRowBytes; for (col = 0; col < nWidth; col++) { diff --git a/core/fxge/ge/cfx_font.cpp b/core/fxge/ge/cfx_font.cpp index 87157b0101..068f0b032c 100644 --- a/core/fxge/ge/cfx_font.cpp +++ b/core/fxge/ge/cfx_font.cpp @@ -31,7 +31,7 @@ typedef struct { CFX_PathData* m_pPath; int m_CurX; int m_CurY; - FX_FLOAT m_CoordUnit; + float m_CoordUnit; } OUTLINE_PARAMS; #ifdef PDF_ENABLE_XFA diff --git a/core/fxge/ge/cfx_gemodule.cpp b/core/fxge/ge/cfx_gemodule.cpp index ed6d6cb32e..790b670e4f 100644 --- a/core/fxge/ge/cfx_gemodule.cpp +++ b/core/fxge/ge/cfx_gemodule.cpp @@ -59,11 +59,11 @@ CFX_FontCache* CFX_GEModule::GetFontCache() { return m_pFontCache; } -void CFX_GEModule::SetTextGamma(FX_FLOAT gammaValue) { +void CFX_GEModule::SetTextGamma(float gammaValue) { gammaValue /= 2.2f; for (int i = 0; i < 256; ++i) { m_GammaValue[i] = static_cast( - FXSYS_pow(static_cast(i) / 255, gammaValue) * 255.0f + 0.5f); + FXSYS_pow(static_cast(i) / 255, gammaValue) * 255.0f + 0.5f); } } diff --git a/core/fxge/ge/cfx_graphstate.cpp b/core/fxge/ge/cfx_graphstate.cpp index 6357aa51a4..54443b9636 100644 --- a/core/fxge/ge/cfx_graphstate.cpp +++ b/core/fxge/ge/cfx_graphstate.cpp @@ -19,9 +19,7 @@ void CFX_GraphState::Emplace() { m_Ref.Emplace(); } -void CFX_GraphState::SetLineDash(CPDF_Array* pArray, - FX_FLOAT phase, - FX_FLOAT scale) { +void CFX_GraphState::SetLineDash(CPDF_Array* pArray, float phase, float scale) { CFX_GraphStateData* pData = m_Ref.GetPrivateCopy(); pData->m_DashPhase = phase * scale; pData->SetDashCount(static_cast(pArray->GetCount())); @@ -29,11 +27,11 @@ void CFX_GraphState::SetLineDash(CPDF_Array* pArray, pData->m_DashArray[i] = pArray->GetNumberAt(i) * scale; } -FX_FLOAT CFX_GraphState::GetLineWidth() const { +float CFX_GraphState::GetLineWidth() const { return m_Ref.GetObject() ? m_Ref.GetObject()->m_LineWidth : 1.f; } -void CFX_GraphState::SetLineWidth(FX_FLOAT width) { +void CFX_GraphState::SetLineWidth(float width) { m_Ref.GetPrivateCopy()->m_LineWidth = width; } @@ -52,10 +50,10 @@ void CFX_GraphState::SetLineJoin(CFX_GraphStateData::LineJoin join) { m_Ref.GetPrivateCopy()->m_LineJoin = join; } -FX_FLOAT CFX_GraphState::GetMiterLimit() const { +float CFX_GraphState::GetMiterLimit() const { return m_Ref.GetObject() ? m_Ref.GetObject()->m_MiterLimit : 10.f; } -void CFX_GraphState::SetMiterLimit(FX_FLOAT limit) { +void CFX_GraphState::SetMiterLimit(float limit) { m_Ref.GetPrivateCopy()->m_MiterLimit = limit; } diff --git a/core/fxge/ge/cfx_graphstatedata.cpp b/core/fxge/ge/cfx_graphstatedata.cpp index 03798a6320..8c5508f2f2 100644 --- a/core/fxge/ge/cfx_graphstatedata.cpp +++ b/core/fxge/ge/cfx_graphstatedata.cpp @@ -33,8 +33,8 @@ void CFX_GraphStateData::Copy(const CFX_GraphStateData& src) { m_MiterLimit = src.m_MiterLimit; m_LineWidth = src.m_LineWidth; if (m_DashCount) { - m_DashArray = FX_Alloc(FX_FLOAT, m_DashCount); - FXSYS_memcpy(m_DashArray, src.m_DashArray, m_DashCount * sizeof(FX_FLOAT)); + m_DashArray = FX_Alloc(float, m_DashCount); + FXSYS_memcpy(m_DashArray, src.m_DashArray, m_DashCount * sizeof(float)); } } @@ -48,5 +48,5 @@ void CFX_GraphStateData::SetDashCount(int count) { m_DashCount = count; if (count == 0) return; - m_DashArray = FX_Alloc(FX_FLOAT, count); + m_DashArray = FX_Alloc(float, count); } diff --git a/core/fxge/ge/cfx_pathdata.cpp b/core/fxge/ge/cfx_pathdata.cpp index 9fa2cd2aac..d4c657c3a4 100644 --- a/core/fxge/ge/cfx_pathdata.cpp +++ b/core/fxge/ge/cfx_pathdata.cpp @@ -14,7 +14,7 @@ namespace { void UpdateLineEndPoints(CFX_FloatRect* rect, const CFX_PointF& start_pos, const CFX_PointF& end_pos, - FX_FLOAT hw) { + float hw) { if (start_pos.x == end_pos.x) { if (start_pos.y == end_pos.y) { rect->UpdateRect(end_pos.x + hw, end_pos.y + hw); @@ -22,7 +22,7 @@ void UpdateLineEndPoints(CFX_FloatRect* rect, return; } - FX_FLOAT point_y; + float point_y; if (end_pos.y < start_pos.y) point_y = end_pos.y - hw; else @@ -34,7 +34,7 @@ void UpdateLineEndPoints(CFX_FloatRect* rect, } if (start_pos.y == end_pos.y) { - FX_FLOAT point_x; + float point_x; if (end_pos.x < start_pos.x) point_x = end_pos.x - hw; else @@ -46,11 +46,11 @@ void UpdateLineEndPoints(CFX_FloatRect* rect, } CFX_PointF diff = end_pos - start_pos; - FX_FLOAT ll = FXSYS_sqrt2(diff.x, diff.y); - FX_FLOAT mx = end_pos.x + hw * diff.x / ll; - FX_FLOAT my = end_pos.y + hw * diff.y / ll; - FX_FLOAT dx1 = hw * diff.y / ll; - FX_FLOAT dy1 = hw * diff.x / ll; + float ll = FXSYS_sqrt2(diff.x, diff.y); + float mx = end_pos.x + hw * diff.x / ll; + float my = end_pos.y + hw * diff.y / ll; + float dx1 = hw * diff.y / ll; + float dy1 = hw * diff.x / ll; rect->UpdateRect(mx - dx1, my + dy1); rect->UpdateRect(mx + dx1, my - dy1); } @@ -59,23 +59,23 @@ void UpdateLineJoinPoints(CFX_FloatRect* rect, const CFX_PointF& start_pos, const CFX_PointF& mid_pos, const CFX_PointF& end_pos, - FX_FLOAT half_width, - FX_FLOAT miter_limit) { - FX_FLOAT start_k = 0; - FX_FLOAT start_c = 0; - FX_FLOAT end_k = 0; - FX_FLOAT end_c = 0; - FX_FLOAT start_len = 0; - FX_FLOAT start_dc = 0; - FX_FLOAT end_len = 0; - FX_FLOAT end_dc = 0; - FX_FLOAT one_twentieth = 1.0f / 20; + float half_width, + float miter_limit) { + float start_k = 0; + float start_c = 0; + float end_k = 0; + float end_c = 0; + float start_len = 0; + float start_dc = 0; + float end_len = 0; + float end_dc = 0; + float one_twentieth = 1.0f / 20; bool bStartVert = FXSYS_fabs(start_pos.x - mid_pos.x) < one_twentieth; bool bEndVert = FXSYS_fabs(mid_pos.x - end_pos.x) < one_twentieth; if (bStartVert && bEndVert) { int start_dir = mid_pos.y > start_pos.y ? 1 : -1; - FX_FLOAT point_y = mid_pos.y + half_width * start_dir; + float point_y = mid_pos.y + half_width * start_dir; rect->UpdateRect(mid_pos.x + half_width, point_y); rect->UpdateRect(mid_pos.x - half_width, point_y); return; @@ -86,8 +86,8 @@ void UpdateLineJoinPoints(CFX_FloatRect* rect, start_k = (mid_pos.y - start_pos.y) / (mid_pos.x - start_pos.x); start_c = mid_pos.y - (start_k * mid_pos.x); start_len = FXSYS_sqrt2(start_to_mid.x, start_to_mid.y); - start_dc = static_cast( - FXSYS_fabs(half_width * start_len / start_to_mid.x)); + start_dc = + static_cast(FXSYS_fabs(half_width * start_len / start_to_mid.x)); } if (!bEndVert) { CFX_PointF end_to_mid = end_pos - mid_pos; @@ -95,7 +95,7 @@ void UpdateLineJoinPoints(CFX_FloatRect* rect, end_c = mid_pos.y - (end_k * mid_pos.x); end_len = FXSYS_sqrt2(end_to_mid.x, end_to_mid.y); end_dc = - static_cast(FXSYS_fabs(half_width * end_len / end_to_mid.x)); + static_cast(FXSYS_fabs(half_width * end_len / end_to_mid.x)); } if (bStartVert) { CFX_PointF outside(start_pos.x, 0); @@ -139,20 +139,20 @@ void UpdateLineJoinPoints(CFX_FloatRect* rect, return; } - FX_FLOAT start_outside_c = start_c; + float start_outside_c = start_c; if (end_pos.y < (start_k * end_pos.x) + start_c) start_outside_c += start_dc; else start_outside_c -= start_dc; - FX_FLOAT end_outside_c = end_c; + float end_outside_c = end_c; if (start_pos.y < (end_k * start_pos.x) + end_c) end_outside_c += end_dc; else end_outside_c -= end_dc; - FX_FLOAT join_x = (end_outside_c - start_outside_c) / (start_k - end_k); - FX_FLOAT join_y = start_k * join_x + start_outside_c; + float join_x = (end_outside_c - start_outside_c) / (start_k - end_k); + float join_y = start_k * join_x + start_outside_c; rect->UpdateRect(join_x, join_y); } @@ -203,10 +203,10 @@ void CFX_PathData::AppendPoint(const CFX_PointF& point, m_Points.push_back(FX_PATHPOINT(point, type, closeFigure)); } -void CFX_PathData::AppendRect(FX_FLOAT left, - FX_FLOAT bottom, - FX_FLOAT right, - FX_FLOAT top) { +void CFX_PathData::AppendRect(float left, + float bottom, + float right, + float top) { m_Points.push_back( FX_PATHPOINT(CFX_PointF(left, bottom), FXPT_TYPE::MoveTo, false)); m_Points.push_back( @@ -230,11 +230,11 @@ CFX_FloatRect CFX_PathData::GetBoundingBox() const { return rect; } -CFX_FloatRect CFX_PathData::GetBoundingBox(FX_FLOAT line_width, - FX_FLOAT miter_limit) const { +CFX_FloatRect CFX_PathData::GetBoundingBox(float line_width, + float miter_limit) const { CFX_FloatRect rect(100000.0f, 100000.0f, -100000.0f, -100000.0f); size_t iPoint = 0; - FX_FLOAT half_width = line_width; + float half_width = line_width; int iStartPoint = 0; int iEndPoint = 0; int iMiddlePoint = 0; diff --git a/core/fxge/ge/cfx_renderdevice.cpp b/core/fxge/ge/cfx_renderdevice.cpp index daa67ccc91..fab318373a 100644 --- a/core/fxge/ge/cfx_renderdevice.cpp +++ b/core/fxge/ge/cfx_renderdevice.cpp @@ -34,17 +34,16 @@ void AdjustGlyphSpace(std::vector* pGlyphAndPos) { for (size_t i = glyphs.size() - 1; i > 1; --i) { FXTEXT_GLYPHPOS& next = glyphs[i]; int next_origin = bVertical ? next.m_Origin.y : next.m_Origin.x; - FX_FLOAT next_origin_f = bVertical ? next.m_fOrigin.y : next.m_fOrigin.x; + float next_origin_f = bVertical ? next.m_fOrigin.y : next.m_fOrigin.x; FXTEXT_GLYPHPOS& current = glyphs[i - 1]; int& current_origin = bVertical ? current.m_Origin.y : current.m_Origin.x; - FX_FLOAT current_origin_f = + float current_origin_f = bVertical ? current.m_fOrigin.y : current.m_fOrigin.x; int space = next_origin - current_origin; - FX_FLOAT space_f = next_origin_f - current_origin_f; - FX_FLOAT error = - FXSYS_fabs(space_f) - FXSYS_fabs(static_cast(space)); + float space_f = next_origin_f - current_origin_f; + float error = FXSYS_fabs(space_f) - FXSYS_fabs(static_cast(space)); if (error > 0.5f) current_origin += space > 0 ? -1 : 1; } @@ -526,16 +525,16 @@ bool CFX_RenderDevice::DrawPathWithBlend(const CFX_PathData* pPathData, rect_i.bottom++; } if (rect_i.Width() >= width + 1) { - if (rect_f.left - (FX_FLOAT)(rect_i.left) > - (FX_FLOAT)(rect_i.right) - rect_f.right) { + if (rect_f.left - (float)(rect_i.left) > + (float)(rect_i.right) - rect_f.right) { rect_i.left++; } else { rect_i.right--; } } if (rect_i.Height() >= height + 1) { - if (rect_f.top - (FX_FLOAT)(rect_i.top) > - (FX_FLOAT)(rect_i.bottom) - rect_f.bottom) { + if (rect_f.top - (float)(rect_i.top) > + (float)(rect_i.bottom) - rect_f.bottom) { rect_i.top++; } else { rect_i.bottom--; @@ -608,8 +607,8 @@ bool CFX_RenderDevice::DrawFillStrokePath(const CFX_PathData* pPathData, pObject2Device->TransformRect(bbox); CFX_Matrix ctm = GetCTM(); - FX_FLOAT fScaleX = FXSYS_fabs(ctm.a); - FX_FLOAT fScaleY = FXSYS_fabs(ctm.d); + float fScaleX = FXSYS_fabs(ctm.a); + float fScaleY = FXSYS_fabs(ctm.d); FX_RECT rect = bbox.GetOuterRect(); CFX_DIBitmap bitmap, Backdrop; if (!CreateCompatibleBitmap(&bitmap, FXSYS_round(rect.Width() * fScaleX), @@ -679,10 +678,10 @@ bool CFX_RenderDevice::FillRectWithBlend(const FX_RECT* pRect, return true; } -bool CFX_RenderDevice::DrawCosmeticLine(FX_FLOAT x1, - FX_FLOAT y1, - FX_FLOAT x2, - FX_FLOAT y2, +bool CFX_RenderDevice::DrawCosmeticLine(float x1, + float y1, + float x2, + float y2, uint32_t color, int fill_mode, int blend_type) { @@ -714,8 +713,8 @@ bool CFX_RenderDevice::SetDIBitsWithBlend(const CFX_DIBSource* pBitmap, int blend_mode) { ASSERT(!pBitmap->IsAlphaMask()); CFX_Matrix ctm = GetCTM(); - FX_FLOAT fScaleX = FXSYS_fabs(ctm.a); - FX_FLOAT fScaleY = FXSYS_fabs(ctm.d); + float fScaleX = FXSYS_fabs(ctm.a); + float fScaleY = FXSYS_fabs(ctm.d); FX_RECT dest_rect(left, top, FXSYS_round(left + pBitmap->GetWidth() / fScaleX), FXSYS_round(top + pBitmap->GetHeight() / fScaleY)); @@ -848,7 +847,7 @@ bool CFX_RenderDevice::SetBitsWithMask(const CFX_DIBSource* pBitmap, bool CFX_RenderDevice::DrawNormalText(int nChars, const FXTEXT_CHARPOS* pCharPos, CFX_Font* pFont, - FX_FLOAT font_size, + float font_size, const CFX_Matrix* pText2Device, uint32_t fill_color, uint32_t text_flags) { @@ -916,8 +915,8 @@ bool CFX_RenderDevice::DrawNormalText(int nChars, } std::vector glyphs(nChars); CFX_Matrix matrixCTM = GetCTM(); - FX_FLOAT scale_x = FXSYS_fabs(matrixCTM.a); - FX_FLOAT scale_y = FXSYS_fabs(matrixCTM.d); + float scale_x = FXSYS_fabs(matrixCTM.a); + float scale_y = FXSYS_fabs(matrixCTM.d); CFX_Matrix deviceCtm = char2device; CFX_Matrix m(scale_x, 0, 0, scale_y, 0, 0); deviceCtm.Concat(m); @@ -958,10 +957,10 @@ bool CFX_RenderDevice::DrawNormalText(int nChars, bmp_rect1.right++; bmp_rect1.bottom++; } - FX_RECT bmp_rect(FXSYS_round((FX_FLOAT)(bmp_rect1.left) / scale_x), - FXSYS_round((FX_FLOAT)(bmp_rect1.top) / scale_y), - FXSYS_round((FX_FLOAT)bmp_rect1.right / scale_x), - FXSYS_round((FX_FLOAT)bmp_rect1.bottom / scale_y)); + FX_RECT bmp_rect(FXSYS_round((float)(bmp_rect1.left) / scale_x), + FXSYS_round((float)(bmp_rect1.top) / scale_y), + FXSYS_round((float)bmp_rect1.right / scale_x), + FXSYS_round((float)bmp_rect1.bottom / scale_y)); bmp_rect.Intersect(m_ClipBox); if (bmp_rect.IsEmpty()) return true; @@ -1067,7 +1066,7 @@ bool CFX_RenderDevice::DrawNormalText(int nChars, bool CFX_RenderDevice::DrawTextPath(int nChars, const FXTEXT_CHARPOS* pCharPos, CFX_Font* pFont, - FX_FLOAT font_size, + float font_size, const CFX_Matrix* pText2User, const CFX_Matrix* pUser2Device, const CFX_GraphStateData* pGraphState, diff --git a/core/fxge/ge/fx_ge_text.cpp b/core/fxge/ge/fx_ge_text.cpp index 669969db0b..f3dea9178d 100644 --- a/core/fxge/ge/fx_ge_text.cpp +++ b/core/fxge/ge/fx_ge_text.cpp @@ -45,8 +45,8 @@ ScopedFontTransform::~ScopedFontTransform() { FX_RECT FXGE_GetGlyphsBBox(const std::vector& glyphs, int anti_alias, - FX_FLOAT retinaScaleX, - FX_FLOAT retinaScaleY) { + float retinaScaleX, + float retinaScaleY) { FX_RECT rect(0, 0, 0, 0); bool bStarted = false; for (const FXTEXT_GLYPHPOS& glyph : glyphs) { -- cgit v1.2.3