mirror of https://github.com/OpenTTD/OpenTTD.git
Codechange: Return vector references instead of pointer to first item.
This commit is contained in:
parent
2f8de227dc
commit
f7cc88f370
|
@ -96,10 +96,10 @@ public:
|
||||||
virtual ~VisualRun() = default;
|
virtual ~VisualRun() = default;
|
||||||
virtual const Font *GetFont() const = 0;
|
virtual const Font *GetFont() const = 0;
|
||||||
virtual int GetGlyphCount() const = 0;
|
virtual int GetGlyphCount() const = 0;
|
||||||
virtual const GlyphID *GetGlyphs() const = 0;
|
virtual const std::vector<GlyphID> &GetGlyphs() const = 0;
|
||||||
virtual const float *GetPositions() const = 0;
|
virtual const std::vector<float> &GetPositions() const = 0;
|
||||||
virtual int GetLeading() 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. */
|
/** A single line worth of VisualRuns. */
|
||||||
|
|
|
@ -49,10 +49,10 @@ public:
|
||||||
FallbackVisualRun(Font *font, const char32_t *chars, int glyph_count, int char_offset, int x);
|
FallbackVisualRun(Font *font, const char32_t *chars, int glyph_count, int char_offset, int x);
|
||||||
const Font *GetFont() const override { return this->font; }
|
const Font *GetFont() const override { return this->font; }
|
||||||
int GetGlyphCount() const override { return static_cast<int>(this->glyphs.size()); }
|
int GetGlyphCount() const override { return static_cast<int>(this->glyphs.size()); }
|
||||||
const GlyphID *GetGlyphs() const override { return this->glyphs.data(); }
|
const std::vector<GlyphID> &GetGlyphs() const override { return this->glyphs; }
|
||||||
const float *GetPositions() const override { return this->positions.data(); }
|
const std::vector<float> &GetPositions() const override { return this->positions; }
|
||||||
int GetLeading() const override { return this->GetFont()->fc->GetHeight(); }
|
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. */
|
/** A single line worth of VisualRuns. */
|
||||||
|
|
|
@ -71,9 +71,9 @@ public:
|
||||||
public:
|
public:
|
||||||
ICUVisualRun(const ICURun &run, int x);
|
ICUVisualRun(const ICURun &run, int x);
|
||||||
|
|
||||||
const GlyphID *GetGlyphs() const override { return this->glyphs.data(); }
|
const std::vector<GlyphID> &GetGlyphs() const override { return this->glyphs; }
|
||||||
const float *GetPositions() const override { return this->positions.data(); }
|
const std::vector<float> &GetPositions() const override { return this->positions; }
|
||||||
const int *GetGlyphToCharMap() const override { return this->glyph_to_char.data(); }
|
const std::vector<int> &GetGlyphToCharMap() const override { return this->glyph_to_char; }
|
||||||
|
|
||||||
const Font *GetFont() const override { return this->font; }
|
const Font *GetFont() const override { return this->font; }
|
||||||
int GetLeading() const override { return this->font->fc->GetHeight(); }
|
int GetLeading() const override { return this->font->fc->GetHeight(); }
|
||||||
|
|
|
@ -81,9 +81,9 @@ public:
|
||||||
CoreTextVisualRun(CTRunRef run, Font *font, const CoreTextParagraphLayoutFactory::CharType *buff);
|
CoreTextVisualRun(CTRunRef run, Font *font, const CoreTextParagraphLayoutFactory::CharType *buff);
|
||||||
CoreTextVisualRun(CoreTextVisualRun &&other) = default;
|
CoreTextVisualRun(CoreTextVisualRun &&other) = default;
|
||||||
|
|
||||||
const GlyphID *GetGlyphs() const override { return &this->glyphs[0]; }
|
const std::vector<GlyphID> &GetGlyphs() const override { return this->glyphs; }
|
||||||
const float *GetPositions() const override { return &this->positions[0]; }
|
const std::vector<float> &GetPositions() const override { return this->positions; }
|
||||||
const int *GetGlyphToCharMap() const override { return &this->glyph_to_char[0]; }
|
const std::vector<int> &GetGlyphToCharMap() const override { return this->glyph_to_char; }
|
||||||
|
|
||||||
const Font *GetFont() const override { return this->font; }
|
const Font *GetFont() const override { return this->font; }
|
||||||
int GetLeading() const override { return this->font->fc->GetHeight(); }
|
int GetLeading() const override { return this->font->fc->GetHeight(); }
|
||||||
|
|
|
@ -82,19 +82,15 @@ public:
|
||||||
int num_glyphs;
|
int num_glyphs;
|
||||||
Font *font;
|
Font *font;
|
||||||
|
|
||||||
mutable int *glyph_to_char = nullptr;
|
mutable std::vector<int> glyph_to_char;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
UniscribeVisualRun(const UniscribeRun &range, int x);
|
UniscribeVisualRun(const UniscribeRun &range, int x);
|
||||||
UniscribeVisualRun(UniscribeVisualRun &&other) noexcept;
|
UniscribeVisualRun(UniscribeVisualRun &&other) noexcept;
|
||||||
~UniscribeVisualRun() override
|
|
||||||
{
|
|
||||||
free(this->glyph_to_char);
|
|
||||||
}
|
|
||||||
|
|
||||||
const GlyphID *GetGlyphs() const override { return &this->glyphs[0]; }
|
const std::vector<GlyphID> &GetGlyphs() const override { return this->glyphs; }
|
||||||
const float *GetPositions() const override { return &this->positions[0]; }
|
const std::vector<float> &GetPositions() const override { return this->positions; }
|
||||||
const int *GetGlyphToCharMap() const override;
|
const std::vector<int> &GetGlyphToCharMap() const override;
|
||||||
|
|
||||||
const Font *GetFont() const override { return this->font; }
|
const Font *GetFont() const override { return this->font; }
|
||||||
int GetLeading() const override { return this->font->fc->GetHeight(); }
|
int GetLeading() const override { return this->font->fc->GetHeight(); }
|
||||||
|
@ -492,16 +488,15 @@ UniscribeParagraphLayout::UniscribeVisualRun::UniscribeVisualRun(const Uniscribe
|
||||||
|
|
||||||
UniscribeParagraphLayout::UniscribeVisualRun::UniscribeVisualRun(UniscribeVisualRun&& other) noexcept
|
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)),
|
: 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) {
|
if (this->glyph_to_char.empty()) {
|
||||||
this->glyph_to_char = CallocT<int>(this->GetGlyphCount());
|
this->glyph_to_char.resize(this->GetGlyphCount());
|
||||||
|
|
||||||
/* The char to glyph array contains the first glyph index of the cluster that is associated
|
/* 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. */
|
* with each character. It is possible for a cluster to be formed of several chars. */
|
||||||
|
|
Loading…
Reference in New Issue