diff options
author | Michael Lutz <michi@icosahedron.de> | 2019-04-02 21:31:10 +0200 |
---|---|---|
committer | Michael Lutz <michi@icosahedron.de> | 2019-04-09 22:45:15 +0200 |
commit | baf9229931e4d5a3479892007e9bcc875bc9930b (patch) | |
tree | 5332e36f2427214f3cd63e11a69334692444e5ee /src/os | |
parent | 329bb526134aca214a914f25006c805de78ec851 (diff) | |
download | openttd-baf9229931e4d5a3479892007e9bcc875bc9930b.tar.xz |
Codechange: Replace AutoDeleteSmallVector with direct std::vector use in text layout code.
Diffstat (limited to 'src/os')
-rw-r--r-- | src/os/macosx/string_osx.cpp | 14 | ||||
-rw-r--r-- | src/os/windows/string_uniscribe.cpp | 6 |
2 files changed, 10 insertions, 10 deletions
diff --git a/src/os/macosx/string_osx.cpp b/src/os/macosx/string_osx.cpp index 55eac42f9..580be3520 100644 --- a/src/os/macosx/string_osx.cpp +++ b/src/os/macosx/string_osx.cpp @@ -111,7 +111,7 @@ public: this->cur_offset = 0; } - const Line *NextLine(int max_width) override; + std::unique_ptr<const Line> NextLine(int max_width) override; }; @@ -188,7 +188,7 @@ static CTRunDelegateCallbacks _sprite_font_callback = { return typesetter != NULL ? new CoreTextParagraphLayout(typesetter, buff, length, fontMapping) : NULL; } -/* virtual */ const CoreTextParagraphLayout::Line *CoreTextParagraphLayout::NextLine(int max_width) +/* virtual */ std::unique_ptr<const ParagraphLayouter::Line> CoreTextParagraphLayout::NextLine(int max_width) { if (this->cur_offset >= this->length) return NULL; @@ -200,7 +200,7 @@ static CTRunDelegateCallbacks _sprite_font_callback = { CTLineRef line = CTTypesetterCreateLine(this->typesetter, CFRangeMake(this->cur_offset, len)); this->cur_offset += len; - return line != NULL ? new CoreTextLine(line, this->font_map, this->text_buffer) : NULL; + return std::unique_ptr<const Line>(line != NULL ? new CoreTextLine(line, this->font_map, this->text_buffer) : NULL); } CoreTextParagraphLayout::CoreTextVisualRun::CoreTextVisualRun(CTRunRef run, Font *font, const CoreTextParagraphLayoutFactory::CharType *buff) : font(font) @@ -244,8 +244,8 @@ CoreTextParagraphLayout::CoreTextVisualRun::CoreTextVisualRun(CTRunRef run, Font int CoreTextParagraphLayout::CoreTextLine::GetLeading() const { int leading = 0; - for (const CoreTextVisualRun * const &run : *this) { - leading = max(leading, run->GetLeading()); + for (const auto &run : *this) { + leading = max(leading, run.GetLeading()); } return leading; @@ -260,8 +260,8 @@ int CoreTextParagraphLayout::CoreTextLine::GetWidth() const if (this->size() == 0) return 0; int total_width = 0; - for (const CoreTextVisualRun * const &run : *this) { - total_width += run->GetAdvance(); + for (const auto &run : *this) { + total_width += run.GetAdvance(); } return total_width; diff --git a/src/os/windows/string_uniscribe.cpp b/src/os/windows/string_uniscribe.cpp index f47d9236a..5abe848bd 100644 --- a/src/os/windows/string_uniscribe.cpp +++ b/src/os/windows/string_uniscribe.cpp @@ -134,7 +134,7 @@ public: this->cur_range_offset = 0; } - const Line *NextLine(int max_width) override; + std::unique_ptr<const Line> NextLine(int max_width) override; }; void UniscribeResetScriptCache(FontSize size) @@ -318,7 +318,7 @@ static std::vector<SCRIPT_ITEM> UniscribeItemizeString(UniscribeParagraphLayoutF return new UniscribeParagraphLayout(ranges, buff); } -/* virtual */ const ParagraphLayouter::Line *UniscribeParagraphLayout::NextLine(int max_width) +/* virtual */ std::unique_ptr<const ParagraphLayouter::Line> UniscribeParagraphLayout::NextLine(int max_width) { std::vector<UniscribeRun>::iterator start_run = this->cur_range; std::vector<UniscribeRun>::iterator last_run = this->cur_range; @@ -404,7 +404,7 @@ static std::vector<SCRIPT_ITEM> UniscribeItemizeString(UniscribeParagraphLayoutF if (FAILED(ScriptLayout((int)bidi_level.size(), &bidi_level[0], &vis_to_log[0], NULL))) return NULL; /* Create line. */ - UniscribeLine *line = new UniscribeLine(); + std::unique_ptr<UniscribeLine> line(new UniscribeLine()); int cur_pos = 0; for (std::vector<INT>::iterator l = vis_to_log.begin(); l != vis_to_log.end(); l++) { |