diff options
author | Nicolas Pena <npm@chromium.org> | 2018-05-31 18:30:32 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-05-31 18:30:32 +0000 |
commit | 08eaf467ed0bed35ecccf370df32b7d51f3bc5fa (patch) | |
tree | 5a56502bf869f2bc2155c119f01d4c840e69c9d2 /core/fpdfapi/render/cpdf_type3glyphs.cpp | |
parent | dd5459ce862dfe709b88f698a28e72b31be6fb7c (diff) | |
download | pdfium-08eaf467ed0bed35ecccf370df32b7d51f3bc5fa.tar.xz |
Clean up some nits in CPDF_Type3Glyph
Change-Id: Ia466bb0119d914794b0d7ed9385547a7be245858
Reviewed-on: https://pdfium-review.googlesource.com/33312
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
Diffstat (limited to 'core/fpdfapi/render/cpdf_type3glyphs.cpp')
-rw-r--r-- | core/fpdfapi/render/cpdf_type3glyphs.cpp | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/core/fpdfapi/render/cpdf_type3glyphs.cpp b/core/fpdfapi/render/cpdf_type3glyphs.cpp index 01b689f80f..ef14d731c4 100644 --- a/core/fpdfapi/render/cpdf_type3glyphs.cpp +++ b/core/fpdfapi/render/cpdf_type3glyphs.cpp @@ -6,38 +6,40 @@ #include "core/fpdfapi/render/cpdf_type3glyphs.h" +#include <algorithm> #include <map> #include "core/fxge/fx_font.h" -CPDF_Type3Glyphs::CPDF_Type3Glyphs() - : m_TopBlueCount(0), m_BottomBlueCount(0) {} +namespace { -CPDF_Type3Glyphs::~CPDF_Type3Glyphs() {} +constexpr int kType3MaxBlues = 16; -static int _AdjustBlue(float pos, int& count, int blues[]) { +int AdjustBlueHelper(float pos, std::vector<int>* blues) { float min_distance = 1000000.0f; int closest_pos = -1; - for (int i = 0; i < count; i++) { - float distance = fabs(pos - static_cast<float>(blues[i])); - if (distance < 1.0f * 80.0f / 100.0f && distance < min_distance) { + for (int i = 0; i < static_cast<int>(blues->size()); ++i) { + float distance = fabs(pos - static_cast<float>(blues->at(i))); + if (distance < std::min(0.8f, min_distance)) { min_distance = distance; closest_pos = i; } } if (closest_pos >= 0) - return blues[closest_pos]; + return blues->at(closest_pos); int new_pos = FXSYS_round(pos); - if (count == TYPE3_MAX_BLUES) - return new_pos; - blues[count++] = new_pos; + if (blues->size() < kType3MaxBlues) + blues->push_back(new_pos); return new_pos; } -void CPDF_Type3Glyphs::AdjustBlue(float top, - float bottom, - int& top_line, - int& bottom_line) { - top_line = _AdjustBlue(top, m_TopBlueCount, m_TopBlue); - bottom_line = _AdjustBlue(bottom, m_BottomBlueCount, m_BottomBlue); +} // namespace + +CPDF_Type3Glyphs::CPDF_Type3Glyphs() {} + +CPDF_Type3Glyphs::~CPDF_Type3Glyphs() {} + +std::pair<int, int> CPDF_Type3Glyphs::AdjustBlue(float top, float bottom) { + return std::make_pair(AdjustBlueHelper(top, &m_TopBlue), + AdjustBlueHelper(bottom, &m_BottomBlue)); } |