зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1282248 - Declare a bunch of gfxTextRun measurement/drawing methods and related helpers as const. r=m_kato
This commit is contained in:
Родитель
b2cd16a8c5
Коммит
48c59f0c3d
|
@ -559,7 +559,7 @@ gfxDWriteFont::GetCairoScaledFont()
|
|||
}
|
||||
|
||||
gfxFont::RunMetrics
|
||||
gfxDWriteFont::Measure(gfxTextRun* aTextRun,
|
||||
gfxDWriteFont::Measure(const gfxTextRun* aTextRun,
|
||||
uint32_t aStart, uint32_t aEnd,
|
||||
BoundingBoxType aBoundingBoxType,
|
||||
DrawTarget* aRefDrawTarget,
|
||||
|
|
|
@ -48,7 +48,7 @@ public:
|
|||
IDWriteFontFace *GetFontFace();
|
||||
|
||||
/* override Measure to add padding for antialiasing */
|
||||
virtual RunMetrics Measure(gfxTextRun *aTextRun,
|
||||
virtual RunMetrics Measure(const gfxTextRun *aTextRun,
|
||||
uint32_t aStart, uint32_t aEnd,
|
||||
BoundingBoxType aBoundingBoxType,
|
||||
DrawTarget *aDrawTargetForTightBoundingBox,
|
||||
|
|
|
@ -1812,7 +1812,7 @@ gfxFont::DrawOneGlyph(uint32_t aGlyphID, double aAdvance, gfxPoint *aPt,
|
|||
// Draw a run of CharacterGlyph records from the given offset in aShapedText.
|
||||
// Returns true if glyph paths were actually emitted.
|
||||
bool
|
||||
gfxFont::DrawGlyphs(gfxShapedText *aShapedText,
|
||||
gfxFont::DrawGlyphs(const gfxShapedText *aShapedText,
|
||||
uint32_t aOffset, // offset in the textrun
|
||||
uint32_t aCount, // length of run to draw
|
||||
gfxPoint *aPt,
|
||||
|
@ -1924,7 +1924,7 @@ gfxFont::DrawGlyphs(gfxShapedText *aShapedText,
|
|||
|
||||
// This method is mostly parallel to DrawGlyphs.
|
||||
void
|
||||
gfxFont::DrawEmphasisMarks(gfxTextRun* aShapedText, gfxPoint* aPt,
|
||||
gfxFont::DrawEmphasisMarks(const gfxTextRun* aShapedText, gfxPoint* aPt,
|
||||
uint32_t aOffset, uint32_t aCount,
|
||||
const EmphasisMarkDrawParams& aParams)
|
||||
{
|
||||
|
@ -1963,7 +1963,7 @@ gfxFont::DrawEmphasisMarks(gfxTextRun* aShapedText, gfxPoint* aPt,
|
|||
}
|
||||
|
||||
void
|
||||
gfxFont::Draw(gfxTextRun *aTextRun, uint32_t aStart, uint32_t aEnd,
|
||||
gfxFont::Draw(const gfxTextRun *aTextRun, uint32_t aStart, uint32_t aEnd,
|
||||
gfxPoint *aPt, const TextRunDrawParams& aRunParams,
|
||||
uint16_t aOrientation)
|
||||
{
|
||||
|
@ -2211,14 +2211,15 @@ UnionRange(gfxFloat aX, gfxFloat* aDestMin, gfxFloat* aDestMax)
|
|||
// if the font is a user font --- in which case the author may be relying
|
||||
// on overflowing glyphs.
|
||||
static bool
|
||||
NeedsGlyphExtents(gfxFont *aFont, gfxTextRun *aTextRun)
|
||||
NeedsGlyphExtents(gfxFont *aFont, const gfxTextRun *aTextRun)
|
||||
{
|
||||
return (aTextRun->GetFlags() & gfxTextRunFactory::TEXT_NEED_BOUNDING_BOX) ||
|
||||
aFont->GetFontEntry()->IsUserFont();
|
||||
}
|
||||
|
||||
bool
|
||||
gfxFont::IsSpaceGlyphInvisible(DrawTarget* aRefDrawTarget, gfxTextRun* aTextRun)
|
||||
gfxFont::IsSpaceGlyphInvisible(DrawTarget* aRefDrawTarget,
|
||||
const gfxTextRun* aTextRun)
|
||||
{
|
||||
if (!mFontEntry->mSpaceGlyphIsInvisibleInitialized &&
|
||||
GetAdjustedSize() >= 1.0) {
|
||||
|
@ -2235,7 +2236,7 @@ gfxFont::IsSpaceGlyphInvisible(DrawTarget* aRefDrawTarget, gfxTextRun* aTextRun)
|
|||
}
|
||||
|
||||
gfxFont::RunMetrics
|
||||
gfxFont::Measure(gfxTextRun *aTextRun,
|
||||
gfxFont::Measure(const gfxTextRun *aTextRun,
|
||||
uint32_t aStart, uint32_t aEnd,
|
||||
BoundingBoxType aBoundingBoxType,
|
||||
DrawTarget* aRefDrawTarget,
|
||||
|
|
|
@ -900,6 +900,7 @@ public:
|
|||
|
||||
// Accessor for the array of CompressedGlyph records, which will be in
|
||||
// a different place in gfxShapedWord vs gfxTextRun
|
||||
virtual const CompressedGlyph *GetCharacterGlyphs() const = 0;
|
||||
virtual CompressedGlyph *GetCharacterGlyphs() = 0;
|
||||
|
||||
/**
|
||||
|
@ -939,7 +940,7 @@ public:
|
|||
// NOTE that this must not be called for a character offset that does
|
||||
// not have any DetailedGlyph records; callers must have verified that
|
||||
// GetCharacterGlyphs()[aCharIndex].GetGlyphCount() is greater than zero.
|
||||
DetailedGlyph *GetDetailedGlyphs(uint32_t aCharIndex) {
|
||||
DetailedGlyph *GetDetailedGlyphs(uint32_t aCharIndex) const {
|
||||
NS_ASSERTION(GetCharacterGlyphs() && HasDetailedGlyphs() &&
|
||||
!GetCharacterGlyphs()[aCharIndex].IsSimpleGlyph() &&
|
||||
GetCharacterGlyphs()[aCharIndex].GetGlyphCount() > 0,
|
||||
|
@ -1239,6 +1240,9 @@ public:
|
|||
free(p);
|
||||
}
|
||||
|
||||
virtual const CompressedGlyph *GetCharacterGlyphs() const override {
|
||||
return &mCharGlyphsStorage[0];
|
||||
}
|
||||
virtual CompressedGlyph *GetCharacterGlyphs() override {
|
||||
return &mCharGlyphsStorage[0];
|
||||
}
|
||||
|
@ -1616,7 +1620,7 @@ public:
|
|||
* -- aStart and aEnd are aligned to cluster and ligature boundaries
|
||||
* -- all glyphs use this font
|
||||
*/
|
||||
void Draw(gfxTextRun *aTextRun, uint32_t aStart, uint32_t aEnd,
|
||||
void Draw(const gfxTextRun *aTextRun, uint32_t aStart, uint32_t aEnd,
|
||||
gfxPoint *aPt, const TextRunDrawParams& aRunParams,
|
||||
uint16_t aOrientation);
|
||||
|
||||
|
@ -1626,7 +1630,7 @@ public:
|
|||
* @param aPt the baseline origin of the emphasis marks.
|
||||
* @param aParams some drawing parameters, see EmphasisMarkDrawParams.
|
||||
*/
|
||||
void DrawEmphasisMarks(gfxTextRun* aShapedText, gfxPoint* aPt,
|
||||
void DrawEmphasisMarks(const gfxTextRun* aShapedText, gfxPoint* aPt,
|
||||
uint32_t aOffset, uint32_t aCount,
|
||||
const EmphasisMarkDrawParams& aParams);
|
||||
|
||||
|
@ -1651,7 +1655,7 @@ public:
|
|||
* advances, and assumes no characters fall outside the font box. In
|
||||
* general this is insufficient, because that assumption is not always true.
|
||||
*/
|
||||
virtual RunMetrics Measure(gfxTextRun *aTextRun,
|
||||
virtual RunMetrics Measure(const gfxTextRun *aTextRun,
|
||||
uint32_t aStart, uint32_t aEnd,
|
||||
BoundingBoxType aBoundingBoxType,
|
||||
DrawTarget* aDrawTargetForTightBoundingBox,
|
||||
|
@ -1883,7 +1887,7 @@ protected:
|
|||
// Output a run of glyphs at *aPt, which is updated to follow the last glyph
|
||||
// in the run. This method also takes account of any letter-spacing provided
|
||||
// in aRunParams.
|
||||
bool DrawGlyphs(gfxShapedText *aShapedText,
|
||||
bool DrawGlyphs(const gfxShapedText *aShapedText,
|
||||
uint32_t aOffset, // offset in the textrun
|
||||
uint32_t aCount, // length of run to draw
|
||||
gfxPoint *aPt,
|
||||
|
@ -1917,7 +1921,7 @@ protected:
|
|||
}
|
||||
|
||||
bool IsSpaceGlyphInvisible(DrawTarget* aRefDrawTarget,
|
||||
gfxTextRun* aTextRun);
|
||||
const gfxTextRun* aTextRun);
|
||||
|
||||
void AddGlyphChangeObserver(GlyphChangeObserver *aObserver);
|
||||
void RemoveGlyphChangeObserver(GlyphChangeObserver *aObserver);
|
||||
|
|
|
@ -141,7 +141,7 @@ gfxGDIFont::SetupCairoFont(DrawTarget* aDrawTarget)
|
|||
}
|
||||
|
||||
gfxFont::RunMetrics
|
||||
gfxGDIFont::Measure(gfxTextRun *aTextRun,
|
||||
gfxGDIFont::Measure(const gfxTextRun *aTextRun,
|
||||
uint32_t aStart, uint32_t aEnd,
|
||||
BoundingBoxType aBoundingBoxType,
|
||||
DrawTarget *aRefDrawTarget,
|
||||
|
|
|
@ -45,7 +45,7 @@ public:
|
|||
virtual bool SetupCairoFont(DrawTarget* aDrawTarget) override;
|
||||
|
||||
/* override Measure to add padding for antialiasing */
|
||||
virtual RunMetrics Measure(gfxTextRun *aTextRun,
|
||||
virtual RunMetrics Measure(const gfxTextRun *aTextRun,
|
||||
uint32_t aStart, uint32_t aEnd,
|
||||
BoundingBoxType aBoundingBoxType,
|
||||
DrawTarget *aDrawTargetForTightBoundingBox,
|
||||
|
|
|
@ -165,7 +165,7 @@ gfxMacFont::SetupCairoFont(DrawTarget* aDrawTarget)
|
|||
}
|
||||
|
||||
gfxFont::RunMetrics
|
||||
gfxMacFont::Measure(gfxTextRun *aTextRun,
|
||||
gfxMacFont::Measure(const gfxTextRun *aTextRun,
|
||||
uint32_t aStart, uint32_t aEnd,
|
||||
BoundingBoxType aBoundingBoxType,
|
||||
DrawTarget *aRefDrawTarget,
|
||||
|
|
|
@ -31,7 +31,7 @@ public:
|
|||
virtual bool SetupCairoFont(DrawTarget* aDrawTarget) override;
|
||||
|
||||
/* override Measure to add padding for antialiasing */
|
||||
virtual RunMetrics Measure(gfxTextRun *aTextRun,
|
||||
virtual RunMetrics Measure(const gfxTextRun *aTextRun,
|
||||
uint32_t aStart, uint32_t aEnd,
|
||||
BoundingBoxType aBoundingBoxType,
|
||||
DrawTarget *aDrawTargetForTightBoundingBox,
|
||||
|
|
|
@ -231,14 +231,15 @@ gfxTextRun::SetPotentialLineBreaks(Range aRange, uint8_t *aBreakBefore)
|
|||
}
|
||||
|
||||
gfxTextRun::LigatureData
|
||||
gfxTextRun::ComputeLigatureData(Range aPartRange, PropertyProvider *aProvider)
|
||||
gfxTextRun::ComputeLigatureData(Range aPartRange,
|
||||
PropertyProvider *aProvider) const
|
||||
{
|
||||
NS_ASSERTION(aPartRange.start < aPartRange.end,
|
||||
"Computing ligature data for empty range");
|
||||
NS_ASSERTION(aPartRange.end <= GetLength(), "Character length overflow");
|
||||
|
||||
LigatureData result;
|
||||
CompressedGlyph *charGlyphs = mCharacterGlyphs;
|
||||
const CompressedGlyph *charGlyphs = mCharacterGlyphs;
|
||||
|
||||
uint32_t i;
|
||||
for (i = aPartRange.start; !charGlyphs[i].IsLigatureGroupStart(); --i) {
|
||||
|
@ -313,7 +314,7 @@ gfxTextRun::ComputeLigatureData(Range aPartRange, PropertyProvider *aProvider)
|
|||
|
||||
gfxFloat
|
||||
gfxTextRun::ComputePartialLigatureWidth(Range aPartRange,
|
||||
PropertyProvider *aProvider)
|
||||
PropertyProvider *aProvider) const
|
||||
{
|
||||
if (aPartRange.start >= aPartRange.end)
|
||||
return 0;
|
||||
|
@ -322,7 +323,7 @@ gfxTextRun::ComputePartialLigatureWidth(Range aPartRange,
|
|||
}
|
||||
|
||||
int32_t
|
||||
gfxTextRun::GetAdvanceForGlyphs(Range aRange)
|
||||
gfxTextRun::GetAdvanceForGlyphs(Range aRange) const
|
||||
{
|
||||
int32_t advance = 0;
|
||||
for (auto i = aRange.start; i < aRange.end; ++i) {
|
||||
|
@ -332,7 +333,7 @@ gfxTextRun::GetAdvanceForGlyphs(Range aRange)
|
|||
}
|
||||
|
||||
static void
|
||||
GetAdjustedSpacing(gfxTextRun *aTextRun, gfxTextRun::Range aRange,
|
||||
GetAdjustedSpacing(const gfxTextRun *aTextRun, gfxTextRun::Range aRange,
|
||||
gfxTextRun::PropertyProvider *aProvider,
|
||||
gfxTextRun::PropertyProvider::Spacing *aSpacing)
|
||||
{
|
||||
|
@ -363,7 +364,8 @@ GetAdjustedSpacing(gfxTextRun *aTextRun, gfxTextRun::Range aRange,
|
|||
bool
|
||||
gfxTextRun::GetAdjustedSpacingArray(Range aRange, PropertyProvider *aProvider,
|
||||
Range aSpacingRange,
|
||||
nsTArray<PropertyProvider::Spacing> *aSpacing)
|
||||
nsTArray<PropertyProvider::Spacing>*
|
||||
aSpacing) const
|
||||
{
|
||||
if (!aProvider || !(mFlags & gfxTextRunFactory::TEXT_ENABLE_SPACING))
|
||||
return false;
|
||||
|
@ -379,12 +381,12 @@ gfxTextRun::GetAdjustedSpacingArray(Range aRange, PropertyProvider *aProvider,
|
|||
}
|
||||
|
||||
void
|
||||
gfxTextRun::ShrinkToLigatureBoundaries(Range* aRange)
|
||||
gfxTextRun::ShrinkToLigatureBoundaries(Range* aRange) const
|
||||
{
|
||||
if (aRange->start >= aRange->end)
|
||||
return;
|
||||
|
||||
CompressedGlyph *charGlyphs = mCharacterGlyphs;
|
||||
const CompressedGlyph *charGlyphs = mCharacterGlyphs;
|
||||
|
||||
while (aRange->start < aRange->end &&
|
||||
!charGlyphs[aRange->start].IsLigatureGroupStart()) {
|
||||
|
@ -401,7 +403,7 @@ gfxTextRun::ShrinkToLigatureBoundaries(Range* aRange)
|
|||
void
|
||||
gfxTextRun::DrawGlyphs(gfxFont *aFont, Range aRange, gfxPoint *aPt,
|
||||
PropertyProvider *aProvider, Range aSpacingRange,
|
||||
TextRunDrawParams& aParams, uint16_t aOrientation)
|
||||
TextRunDrawParams& aParams, uint16_t aOrientation) const
|
||||
{
|
||||
AutoTArray<PropertyProvider::Spacing,200> spacingBuffer;
|
||||
bool haveSpacing = GetAdjustedSpacingArray(aRange, aProvider,
|
||||
|
@ -437,7 +439,8 @@ ClipPartialLigature(const gfxTextRun* aTextRun,
|
|||
void
|
||||
gfxTextRun::DrawPartialLigature(gfxFont *aFont, Range aRange,
|
||||
gfxPoint *aPt, PropertyProvider *aProvider,
|
||||
TextRunDrawParams& aParams, uint16_t aOrientation)
|
||||
TextRunDrawParams& aParams,
|
||||
uint16_t aOrientation) const
|
||||
{
|
||||
if (aRange.start >= aRange.end) {
|
||||
return;
|
||||
|
@ -495,7 +498,7 @@ gfxTextRun::DrawPartialLigature(gfxFont *aFont, Range aRange,
|
|||
// check whether the text run needs to be explicitly composited in order to
|
||||
// support opacity.
|
||||
static bool
|
||||
HasSyntheticBoldOrColor(gfxTextRun *aRun, gfxTextRun::Range aRange)
|
||||
HasSyntheticBoldOrColor(const gfxTextRun *aRun, gfxTextRun::Range aRange)
|
||||
{
|
||||
gfxTextRun::GlyphRunIterator iter(aRun, aRange);
|
||||
while (iter.NextRun()) {
|
||||
|
@ -565,7 +568,7 @@ struct BufferAlphaColor {
|
|||
};
|
||||
|
||||
void
|
||||
gfxTextRun::Draw(Range aRange, gfxPoint aPt, const DrawParams& aParams)
|
||||
gfxTextRun::Draw(Range aRange, gfxPoint aPt, const DrawParams& aParams) const
|
||||
{
|
||||
NS_ASSERTION(aRange.end <= GetLength(), "Substring out of range");
|
||||
NS_ASSERTION(aParams.drawMode == DrawMode::GLYPH_PATH ||
|
||||
|
@ -689,7 +692,7 @@ gfxTextRun::Draw(Range aRange, gfxPoint aPt, const DrawParams& aParams)
|
|||
void
|
||||
gfxTextRun::DrawEmphasisMarks(gfxContext *aContext, gfxTextRun* aMark,
|
||||
gfxFloat aMarkAdvance, gfxPoint aPt,
|
||||
Range aRange, PropertyProvider* aProvider)
|
||||
Range aRange, PropertyProvider* aProvider) const
|
||||
{
|
||||
MOZ_ASSERT(aRange.end <= GetLength());
|
||||
|
||||
|
@ -733,7 +736,7 @@ gfxTextRun::AccumulateMetricsForRun(gfxFont *aFont, Range aRange,
|
|||
PropertyProvider *aProvider,
|
||||
Range aSpacingRange,
|
||||
uint16_t aOrientation,
|
||||
Metrics *aMetrics)
|
||||
Metrics *aMetrics) const
|
||||
{
|
||||
AutoTArray<PropertyProvider::Spacing,200> spacingBuffer;
|
||||
bool haveSpacing = GetAdjustedSpacingArray(aRange, aProvider,
|
||||
|
@ -748,7 +751,8 @@ gfxTextRun::AccumulateMetricsForRun(gfxFont *aFont, Range aRange,
|
|||
void
|
||||
gfxTextRun::AccumulatePartialLigatureMetrics(gfxFont *aFont, Range aRange,
|
||||
gfxFont::BoundingBoxType aBoundingBoxType, DrawTarget* aRefDrawTarget,
|
||||
PropertyProvider *aProvider, uint16_t aOrientation, Metrics *aMetrics)
|
||||
PropertyProvider *aProvider, uint16_t aOrientation,
|
||||
Metrics *aMetrics) const
|
||||
{
|
||||
if (aRange.start >= aRange.end)
|
||||
return;
|
||||
|
@ -786,7 +790,7 @@ gfxTextRun::Metrics
|
|||
gfxTextRun::MeasureText(Range aRange,
|
||||
gfxFont::BoundingBoxType aBoundingBoxType,
|
||||
DrawTarget* aRefDrawTarget,
|
||||
PropertyProvider *aProvider)
|
||||
PropertyProvider *aProvider) const
|
||||
{
|
||||
NS_ASSERTION(aRange.end <= GetLength(), "Substring out of range");
|
||||
|
||||
|
@ -1006,7 +1010,7 @@ gfxTextRun::BreakAndMeasureText(uint32_t aStart, uint32_t aMaxLength,
|
|||
|
||||
gfxFloat
|
||||
gfxTextRun::GetAdvanceWidth(Range aRange, PropertyProvider *aProvider,
|
||||
PropertyProvider::Spacing* aSpacing)
|
||||
PropertyProvider::Spacing* aSpacing) const
|
||||
{
|
||||
NS_ASSERTION(aRange.end <= GetLength(), "Substring out of range");
|
||||
|
||||
|
@ -1059,7 +1063,7 @@ gfxTextRun::SetLineBreaks(Range aRange,
|
|||
}
|
||||
|
||||
uint32_t
|
||||
gfxTextRun::FindFirstGlyphRunContaining(uint32_t aOffset)
|
||||
gfxTextRun::FindFirstGlyphRunContaining(uint32_t aOffset) const
|
||||
{
|
||||
NS_ASSERTION(aOffset <= GetLength(), "Bad offset looking for glyphrun");
|
||||
NS_ASSERTION(GetLength() == 0 || mGlyphRuns.Length() > 0,
|
||||
|
@ -1204,7 +1208,7 @@ gfxTextRun::SanitizeGlyphRuns()
|
|||
}
|
||||
|
||||
uint32_t
|
||||
gfxTextRun::CountMissingGlyphs()
|
||||
gfxTextRun::CountMissingGlyphs() const
|
||||
{
|
||||
uint32_t i;
|
||||
uint32_t count = 0;
|
||||
|
@ -1286,7 +1290,7 @@ gfxTextRun::CopyGlyphDataFrom(gfxTextRun *aSource, Range aRange, uint32_t aDest)
|
|||
// Copy glyph runs
|
||||
GlyphRunIterator iter(aSource, aRange);
|
||||
#ifdef DEBUG
|
||||
GlyphRun *prevRun = nullptr;
|
||||
const GlyphRun *prevRun = nullptr;
|
||||
#endif
|
||||
while (iter.NextRun()) {
|
||||
gfxFont *font = iter.GetGlyphRun()->mFont;
|
||||
|
|
|
@ -148,7 +148,7 @@ public:
|
|||
Range() : start(0), end(0) {}
|
||||
Range(uint32_t aStart, uint32_t aEnd)
|
||||
: start(aStart), end(aEnd) {}
|
||||
explicit Range(gfxTextRun* aTextRun)
|
||||
explicit Range(const gfxTextRun* aTextRun)
|
||||
: start(0), end(aTextRun->GetLength()) {}
|
||||
};
|
||||
|
||||
|
@ -267,7 +267,7 @@ public:
|
|||
* Glyphs should be drawn in logical content order, which can be significant
|
||||
* if they overlap (perhaps due to negative spacing).
|
||||
*/
|
||||
void Draw(Range aRange, gfxPoint aPt, const DrawParams& aParams);
|
||||
void Draw(Range aRange, gfxPoint aPt, const DrawParams& aParams) const;
|
||||
|
||||
/**
|
||||
* Draws the emphasis marks for this text run. Uses only GetSpacing
|
||||
|
@ -276,7 +276,7 @@ public:
|
|||
*/
|
||||
void DrawEmphasisMarks(gfxContext* aContext, gfxTextRun* aMark,
|
||||
gfxFloat aMarkAdvance, gfxPoint aPt,
|
||||
Range aRange, PropertyProvider* aProvider);
|
||||
Range aRange, PropertyProvider* aProvider) const;
|
||||
|
||||
/**
|
||||
* Computes the ReflowMetrics for a substring.
|
||||
|
@ -286,11 +286,11 @@ public:
|
|||
Metrics MeasureText(Range aRange,
|
||||
gfxFont::BoundingBoxType aBoundingBoxType,
|
||||
DrawTarget* aDrawTargetForTightBoundingBox,
|
||||
PropertyProvider* aProvider);
|
||||
PropertyProvider* aProvider) const;
|
||||
|
||||
Metrics MeasureText(gfxFont::BoundingBoxType aBoundingBoxType,
|
||||
DrawTarget* aDrawTargetForTightBoundingBox,
|
||||
PropertyProvider* aProvider = nullptr) {
|
||||
PropertyProvider* aProvider = nullptr) const {
|
||||
return MeasureText(Range(this), aBoundingBoxType,
|
||||
aDrawTargetForTightBoundingBox, aProvider);
|
||||
}
|
||||
|
@ -303,9 +303,10 @@ public:
|
|||
* included in the advance width.
|
||||
*/
|
||||
gfxFloat GetAdvanceWidth(Range aRange, PropertyProvider *aProvider,
|
||||
PropertyProvider::Spacing* aSpacing = nullptr);
|
||||
PropertyProvider::Spacing*
|
||||
aSpacing = nullptr) const;
|
||||
|
||||
gfxFloat GetAdvanceWidth() {
|
||||
gfxFloat GetAdvanceWidth() const {
|
||||
return GetAdvanceWidth(Range(this), nullptr);
|
||||
}
|
||||
|
||||
|
@ -452,19 +453,19 @@ public:
|
|||
|
||||
class GlyphRunIterator {
|
||||
public:
|
||||
GlyphRunIterator(gfxTextRun *aTextRun, Range aRange)
|
||||
GlyphRunIterator(const gfxTextRun *aTextRun, Range aRange)
|
||||
: mTextRun(aTextRun)
|
||||
, mStartOffset(aRange.start)
|
||||
, mEndOffset(aRange.end) {
|
||||
mNextIndex = mTextRun->FindFirstGlyphRunContaining(aRange.start);
|
||||
}
|
||||
bool NextRun();
|
||||
GlyphRun *GetGlyphRun() { return mGlyphRun; }
|
||||
uint32_t GetStringStart() { return mStringStart; }
|
||||
uint32_t GetStringEnd() { return mStringEnd; }
|
||||
const GlyphRun *GetGlyphRun() const { return mGlyphRun; }
|
||||
uint32_t GetStringStart() const { return mStringStart; }
|
||||
uint32_t GetStringEnd() const { return mStringEnd; }
|
||||
private:
|
||||
gfxTextRun *mTextRun;
|
||||
GlyphRun *mGlyphRun;
|
||||
const gfxTextRun *mTextRun;
|
||||
const GlyphRun *mGlyphRun;
|
||||
uint32_t mStringStart;
|
||||
uint32_t mStringEnd;
|
||||
uint32_t mNextIndex;
|
||||
|
@ -512,6 +513,10 @@ public:
|
|||
void SortGlyphRuns();
|
||||
void SanitizeGlyphRuns();
|
||||
|
||||
const CompressedGlyph* GetCharacterGlyphs() const final {
|
||||
MOZ_ASSERT(mCharacterGlyphs, "failed to initialize mCharacterGlyphs");
|
||||
return mCharacterGlyphs;
|
||||
}
|
||||
CompressedGlyph* GetCharacterGlyphs() final {
|
||||
MOZ_ASSERT(mCharacterGlyphs, "failed to initialize mCharacterGlyphs");
|
||||
return mCharacterGlyphs;
|
||||
|
@ -563,14 +568,14 @@ public:
|
|||
*/
|
||||
void FetchGlyphExtents(DrawTarget* aRefDrawTarget);
|
||||
|
||||
uint32_t CountMissingGlyphs();
|
||||
uint32_t CountMissingGlyphs() const;
|
||||
const GlyphRun *GetGlyphRuns(uint32_t *aNumGlyphRuns) {
|
||||
*aNumGlyphRuns = mGlyphRuns.Length();
|
||||
return mGlyphRuns.Elements();
|
||||
}
|
||||
// Returns the index of the GlyphRun containing the given offset.
|
||||
// Returns mGlyphRuns.Length() when aOffset is mCharacterCount.
|
||||
uint32_t FindFirstGlyphRunContaining(uint32_t aOffset);
|
||||
uint32_t FindFirstGlyphRunContaining(uint32_t aOffset) const;
|
||||
|
||||
// Copy glyph data from a ShapedWord into this textrun.
|
||||
void CopyGlyphDataFrom(gfxShapedWord *aSource, uint32_t aStart);
|
||||
|
@ -638,7 +643,7 @@ public:
|
|||
mShapingState = aShapingState;
|
||||
}
|
||||
|
||||
int32_t GetAdvanceForGlyph(uint32_t aIndex)
|
||||
int32_t GetAdvanceForGlyph(uint32_t aIndex) const
|
||||
{
|
||||
const CompressedGlyph& glyphData = mCharacterGlyphs[aIndex];
|
||||
if (glyphData.IsSimpleGlyph()) {
|
||||
|
@ -685,7 +690,7 @@ private:
|
|||
// **** general helpers ****
|
||||
|
||||
// Get the total advance for a range of glyphs.
|
||||
int32_t GetAdvanceForGlyphs(Range aRange);
|
||||
int32_t GetAdvanceForGlyphs(Range aRange) const;
|
||||
|
||||
// Spacing for characters outside the range aSpacingStart/aSpacingEnd
|
||||
// is assumed to be zero; such characters are not passed to aProvider.
|
||||
|
@ -693,7 +698,8 @@ private:
|
|||
// it is not currently able to handle.
|
||||
bool GetAdjustedSpacingArray(Range aRange, PropertyProvider *aProvider,
|
||||
Range aSpacingRange,
|
||||
nsTArray<PropertyProvider::Spacing> *aSpacing);
|
||||
nsTArray<PropertyProvider::Spacing>*
|
||||
aSpacing) const;
|
||||
|
||||
CompressedGlyph& EnsureComplexGlyph(uint32_t aIndex)
|
||||
{
|
||||
|
@ -707,24 +713,26 @@ private:
|
|||
|
||||
// if aProvider is null then mBeforeSpacing and mAfterSpacing are set to zero
|
||||
LigatureData ComputeLigatureData(Range aPartRange,
|
||||
PropertyProvider *aProvider);
|
||||
PropertyProvider *aProvider) const;
|
||||
gfxFloat ComputePartialLigatureWidth(Range aPartRange,
|
||||
PropertyProvider *aProvider);
|
||||
PropertyProvider *aProvider) const;
|
||||
void DrawPartialLigature(gfxFont *aFont, Range aRange,
|
||||
gfxPoint *aPt, PropertyProvider *aProvider,
|
||||
TextRunDrawParams& aParams, uint16_t aOrientation);
|
||||
TextRunDrawParams& aParams,
|
||||
uint16_t aOrientation) const;
|
||||
// Advance aRange.start to the start of the nearest ligature, back
|
||||
// up aRange.end to the nearest ligature end; may result in
|
||||
// aRange->start == aRange->end.
|
||||
void ShrinkToLigatureBoundaries(Range* aRange);
|
||||
void ShrinkToLigatureBoundaries(Range* aRange) const;
|
||||
// result in appunits
|
||||
gfxFloat GetPartialLigatureWidth(Range aRange, PropertyProvider *aProvider);
|
||||
gfxFloat GetPartialLigatureWidth(Range aRange,
|
||||
PropertyProvider *aProvider) const;
|
||||
void AccumulatePartialLigatureMetrics(gfxFont *aFont, Range aRange,
|
||||
gfxFont::BoundingBoxType aBoundingBoxType,
|
||||
DrawTarget* aRefDrawTarget,
|
||||
PropertyProvider *aProvider,
|
||||
uint16_t aOrientation,
|
||||
Metrics *aMetrics);
|
||||
Metrics *aMetrics) const;
|
||||
|
||||
// **** measurement helper ****
|
||||
void AccumulateMetricsForRun(gfxFont *aFont, Range aRange,
|
||||
|
@ -733,12 +741,12 @@ private:
|
|||
PropertyProvider *aProvider,
|
||||
Range aSpacingRange,
|
||||
uint16_t aOrientation,
|
||||
Metrics *aMetrics);
|
||||
Metrics *aMetrics) const;
|
||||
|
||||
// **** drawing helper ****
|
||||
void DrawGlyphs(gfxFont *aFont, Range aRange, gfxPoint *aPt,
|
||||
PropertyProvider *aProvider, Range aSpacingRange,
|
||||
TextRunDrawParams& aParams, uint16_t aOrientation);
|
||||
TextRunDrawParams& aParams, uint16_t aOrientation) const;
|
||||
|
||||
// XXX this should be changed to a GlyphRun plus a maybe-null GlyphRun*,
|
||||
// for smaller size especially in the super-common one-glyphrun case
|
||||
|
|
|
@ -135,7 +135,7 @@ MergeCharactersInTextRun(gfxTextRun* aDest, gfxTextRun* aSrc,
|
|||
uint32_t offset = 0;
|
||||
AutoTArray<gfxTextRun::DetailedGlyph,2> glyphs;
|
||||
while (iter.NextRun()) {
|
||||
gfxTextRun::GlyphRun* run = iter.GetGlyphRun();
|
||||
const gfxTextRun::GlyphRun* run = iter.GetGlyphRun();
|
||||
nsresult rv = aDest->AddGlyphRun(run->mFont, run->mMatchType,
|
||||
offset, false, run->mOrientation);
|
||||
if (NS_FAILED(rv))
|
||||
|
|
Загрузка…
Ссылка в новой задаче