Changeset - r28510:44c3f063764d
[Not reviewed]
master
0 5 0
Peter Nelson - 11 months ago 2024-01-12 01:39:44
peter1138@openttd.org
Codechange: Return vector references instead of pointer to first item.
5 files changed with 21 insertions and 26 deletions:
0 comments (0 inline, 0 general)
src/gfx_layout.h
Show inline comments
 
@@ -96,10 +96,10 @@ public:
 
		virtual ~VisualRun() = default;
 
		virtual const Font *GetFont() const = 0;
 
		virtual int GetGlyphCount() const = 0;
 
		virtual const GlyphID *GetGlyphs() const = 0;
 
		virtual const float *GetPositions() const = 0;
 
		virtual const std::vector<GlyphID> &GetGlyphs() const = 0;
 
		virtual const std::vector<float> &GetPositions() const = 0;
 
		virtual int GetLeading() const = 0;
 
		virtual const int *GetGlyphToCharMap() const = 0;
 
		virtual const std::vector<int> &GetGlyphToCharMap() const = 0;
 
	};
 

	
 
	/** A single line worth of VisualRuns. */
src/gfx_layout_fallback.cpp
Show inline comments
 
@@ -49,10 +49,10 @@ public:
 
		FallbackVisualRun(Font *font, const char32_t *chars, int glyph_count, int char_offset, int x);
 
		const Font *GetFont() const override { return this->font; }
 
		int GetGlyphCount() const override { return static_cast<int>(this->glyphs.size()); }
 
		const GlyphID *GetGlyphs() const override { return this->glyphs.data(); }
 
		const float *GetPositions() const override { return this->positions.data(); }
 
		const std::vector<GlyphID> &GetGlyphs() const override { return this->glyphs; }
 
		const std::vector<float> &GetPositions() const override { return this->positions; }
 
		int GetLeading() const override { return this->GetFont()->fc->GetHeight(); }
 
		const int *GetGlyphToCharMap() const override { return this->glyph_to_char.data(); }
 
		const std::vector<int> &GetGlyphToCharMap() const override { return this->glyph_to_char; }
 
	};
 

	
 
	/** A single line worth of VisualRuns. */
src/gfx_layout_icu.cpp
Show inline comments
 
@@ -71,9 +71,9 @@ public:
 
	public:
 
		ICUVisualRun(const ICURun &run, int x);
 

	
 
		const GlyphID *GetGlyphs() const override { return this->glyphs.data(); }
 
		const float *GetPositions() const override { return this->positions.data(); }
 
		const int *GetGlyphToCharMap() const override { return this->glyph_to_char.data(); }
 
		const std::vector<GlyphID> &GetGlyphs() const override { return this->glyphs; }
 
		const std::vector<float> &GetPositions() const override { return this->positions; }
 
		const std::vector<int> &GetGlyphToCharMap() const override { return this->glyph_to_char; }
 

	
 
		const Font *GetFont() const override { return this->font; }
 
		int GetLeading() const override { return this->font->fc->GetHeight(); }
src/os/macosx/string_osx.cpp
Show inline comments
 
@@ -81,9 +81,9 @@ public:
 
		CoreTextVisualRun(CTRunRef run, Font *font, const CoreTextParagraphLayoutFactory::CharType *buff);
 
		CoreTextVisualRun(CoreTextVisualRun &&other) = default;
 

	
 
		const GlyphID *GetGlyphs() const override { return &this->glyphs[0]; }
 
		const float *GetPositions() const override { return &this->positions[0]; }
 
		const int *GetGlyphToCharMap() const override { return &this->glyph_to_char[0]; }
 
		const std::vector<GlyphID> &GetGlyphs() const override { return this->glyphs; }
 
		const std::vector<float> &GetPositions() const override { return this->positions; }
 
		const std::vector<int> &GetGlyphToCharMap() const override { return this->glyph_to_char; }
 

	
 
		const Font *GetFont() const override { return this->font;  }
 
		int GetLeading() const override { return this->font->fc->GetHeight(); }
src/os/windows/string_uniscribe.cpp
Show inline comments
 
@@ -82,19 +82,15 @@ public:
 
		int num_glyphs;
 
		Font *font;
 

	
 
		mutable int *glyph_to_char = nullptr;
 
		mutable std::vector<int> glyph_to_char;
 

	
 
	public:
 
		UniscribeVisualRun(const UniscribeRun &range, int x);
 
		UniscribeVisualRun(UniscribeVisualRun &&other) noexcept;
 
		~UniscribeVisualRun() override
 
		{
 
			free(this->glyph_to_char);
 
		}
 

	
 
		const GlyphID *GetGlyphs() const override { return &this->glyphs[0]; }
 
		const float *GetPositions() const override { return &this->positions[0]; }
 
		const int *GetGlyphToCharMap() const override;
 
		const std::vector<GlyphID> &GetGlyphs() const override { return this->glyphs; }
 
		const std::vector<float> &GetPositions() const override { return this->positions; }
 
		const std::vector<int> &GetGlyphToCharMap() const override;
 

	
 
		const Font *GetFont() const override { return this->font;  }
 
		int GetLeading() const override { return this->font->fc->GetHeight(); }
 
@@ -492,16 +488,15 @@ UniscribeParagraphLayout::UniscribeVisua
 

	
 
UniscribeParagraphLayout::UniscribeVisualRun::UniscribeVisualRun(UniscribeVisualRun&& other) noexcept
 
								: glyphs(std::move(other.glyphs)), positions(std::move(other.positions)), char_to_glyph(std::move(other.char_to_glyph)),
 
								  start_pos(other.start_pos), total_advance(other.total_advance), num_glyphs(other.num_glyphs), font(other.font)
 
								  start_pos(other.start_pos), total_advance(other.total_advance), num_glyphs(other.num_glyphs), font(other.font),
 
								  glyph_to_char(std::move(other.glyph_to_char))
 
{
 
	this->glyph_to_char = other.glyph_to_char;
 
	other.glyph_to_char = nullptr;
 
}
 

	
 
const int *UniscribeParagraphLayout::UniscribeVisualRun::GetGlyphToCharMap() const
 
const std::vector<int> &UniscribeParagraphLayout::UniscribeVisualRun::GetGlyphToCharMap() const
 
{
 
	if (this->glyph_to_char == nullptr) {
 
		this->glyph_to_char = CallocT<int>(this->GetGlyphCount());
 
	if (this->glyph_to_char.empty()) {
 
		this->glyph_to_char.resize(this->GetGlyphCount());
 

	
 
		/* The char to glyph array contains the first glyph index of the cluster that is associated
 
		 * with each character. It is possible for a cluster to be formed of several chars. */
0 comments (0 inline, 0 general)