Bug 1282248 - Declare a bunch of gfxTextRun measurement/drawing methods and related helpers as const. r=m_kato

This commit is contained in:
Jonathan Kew
2016-06-27 17:41:55 +01:00
parent 6e7f759193
commit f1bd9b8155
11 changed files with 82 additions and 65 deletions

View File

@@ -559,7 +559,7 @@ gfxDWriteFont::GetCairoScaledFont()
} }
gfxFont::RunMetrics gfxFont::RunMetrics
gfxDWriteFont::Measure(gfxTextRun* aTextRun, gfxDWriteFont::Measure(const gfxTextRun* aTextRun,
uint32_t aStart, uint32_t aEnd, uint32_t aStart, uint32_t aEnd,
BoundingBoxType aBoundingBoxType, BoundingBoxType aBoundingBoxType,
DrawTarget* aRefDrawTarget, DrawTarget* aRefDrawTarget,

View File

@@ -48,7 +48,7 @@ public:
IDWriteFontFace *GetFontFace(); IDWriteFontFace *GetFontFace();
/* override Measure to add padding for antialiasing */ /* override Measure to add padding for antialiasing */
virtual RunMetrics Measure(gfxTextRun *aTextRun, virtual RunMetrics Measure(const gfxTextRun *aTextRun,
uint32_t aStart, uint32_t aEnd, uint32_t aStart, uint32_t aEnd,
BoundingBoxType aBoundingBoxType, BoundingBoxType aBoundingBoxType,
DrawTarget *aDrawTargetForTightBoundingBox, DrawTarget *aDrawTargetForTightBoundingBox,

View File

@@ -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. // Draw a run of CharacterGlyph records from the given offset in aShapedText.
// Returns true if glyph paths were actually emitted. // Returns true if glyph paths were actually emitted.
bool bool
gfxFont::DrawGlyphs(gfxShapedText *aShapedText, gfxFont::DrawGlyphs(const gfxShapedText *aShapedText,
uint32_t aOffset, // offset in the textrun uint32_t aOffset, // offset in the textrun
uint32_t aCount, // length of run to draw uint32_t aCount, // length of run to draw
gfxPoint *aPt, gfxPoint *aPt,
@@ -1924,7 +1924,7 @@ gfxFont::DrawGlyphs(gfxShapedText *aShapedText,
// This method is mostly parallel to DrawGlyphs. // This method is mostly parallel to DrawGlyphs.
void void
gfxFont::DrawEmphasisMarks(gfxTextRun* aShapedText, gfxPoint* aPt, gfxFont::DrawEmphasisMarks(const gfxTextRun* aShapedText, gfxPoint* aPt,
uint32_t aOffset, uint32_t aCount, uint32_t aOffset, uint32_t aCount,
const EmphasisMarkDrawParams& aParams) const EmphasisMarkDrawParams& aParams)
{ {
@@ -1963,7 +1963,7 @@ gfxFont::DrawEmphasisMarks(gfxTextRun* aShapedText, gfxPoint* aPt,
} }
void 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, gfxPoint *aPt, const TextRunDrawParams& aRunParams,
uint16_t aOrientation) 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 // if the font is a user font --- in which case the author may be relying
// on overflowing glyphs. // on overflowing glyphs.
static bool static bool
NeedsGlyphExtents(gfxFont *aFont, gfxTextRun *aTextRun) NeedsGlyphExtents(gfxFont *aFont, const gfxTextRun *aTextRun)
{ {
return (aTextRun->GetFlags() & gfxTextRunFactory::TEXT_NEED_BOUNDING_BOX) || return (aTextRun->GetFlags() & gfxTextRunFactory::TEXT_NEED_BOUNDING_BOX) ||
aFont->GetFontEntry()->IsUserFont(); aFont->GetFontEntry()->IsUserFont();
} }
bool bool
gfxFont::IsSpaceGlyphInvisible(DrawTarget* aRefDrawTarget, gfxTextRun* aTextRun) gfxFont::IsSpaceGlyphInvisible(DrawTarget* aRefDrawTarget,
const gfxTextRun* aTextRun)
{ {
if (!mFontEntry->mSpaceGlyphIsInvisibleInitialized && if (!mFontEntry->mSpaceGlyphIsInvisibleInitialized &&
GetAdjustedSize() >= 1.0) { GetAdjustedSize() >= 1.0) {
@@ -2235,7 +2236,7 @@ gfxFont::IsSpaceGlyphInvisible(DrawTarget* aRefDrawTarget, gfxTextRun* aTextRun)
} }
gfxFont::RunMetrics gfxFont::RunMetrics
gfxFont::Measure(gfxTextRun *aTextRun, gfxFont::Measure(const gfxTextRun *aTextRun,
uint32_t aStart, uint32_t aEnd, uint32_t aStart, uint32_t aEnd,
BoundingBoxType aBoundingBoxType, BoundingBoxType aBoundingBoxType,
DrawTarget* aRefDrawTarget, DrawTarget* aRefDrawTarget,

View File

@@ -900,6 +900,7 @@ public:
// Accessor for the array of CompressedGlyph records, which will be in // Accessor for the array of CompressedGlyph records, which will be in
// a different place in gfxShapedWord vs gfxTextRun // a different place in gfxShapedWord vs gfxTextRun
virtual const CompressedGlyph *GetCharacterGlyphs() const = 0;
virtual CompressedGlyph *GetCharacterGlyphs() = 0; virtual CompressedGlyph *GetCharacterGlyphs() = 0;
/** /**
@@ -939,7 +940,7 @@ public:
// NOTE that this must not be called for a character offset that does // NOTE that this must not be called for a character offset that does
// not have any DetailedGlyph records; callers must have verified that // not have any DetailedGlyph records; callers must have verified that
// GetCharacterGlyphs()[aCharIndex].GetGlyphCount() is greater than zero. // GetCharacterGlyphs()[aCharIndex].GetGlyphCount() is greater than zero.
DetailedGlyph *GetDetailedGlyphs(uint32_t aCharIndex) { DetailedGlyph *GetDetailedGlyphs(uint32_t aCharIndex) const {
NS_ASSERTION(GetCharacterGlyphs() && HasDetailedGlyphs() && NS_ASSERTION(GetCharacterGlyphs() && HasDetailedGlyphs() &&
!GetCharacterGlyphs()[aCharIndex].IsSimpleGlyph() && !GetCharacterGlyphs()[aCharIndex].IsSimpleGlyph() &&
GetCharacterGlyphs()[aCharIndex].GetGlyphCount() > 0, GetCharacterGlyphs()[aCharIndex].GetGlyphCount() > 0,
@@ -1239,6 +1240,9 @@ public:
free(p); free(p);
} }
virtual const CompressedGlyph *GetCharacterGlyphs() const override {
return &mCharGlyphsStorage[0];
}
virtual CompressedGlyph *GetCharacterGlyphs() override { virtual CompressedGlyph *GetCharacterGlyphs() override {
return &mCharGlyphsStorage[0]; return &mCharGlyphsStorage[0];
} }
@@ -1616,7 +1620,7 @@ public:
* -- aStart and aEnd are aligned to cluster and ligature boundaries * -- aStart and aEnd are aligned to cluster and ligature boundaries
* -- all glyphs use this font * -- 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, gfxPoint *aPt, const TextRunDrawParams& aRunParams,
uint16_t aOrientation); uint16_t aOrientation);
@@ -1626,7 +1630,7 @@ public:
* @param aPt the baseline origin of the emphasis marks. * @param aPt the baseline origin of the emphasis marks.
* @param aParams some drawing parameters, see EmphasisMarkDrawParams. * @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, uint32_t aOffset, uint32_t aCount,
const EmphasisMarkDrawParams& aParams); const EmphasisMarkDrawParams& aParams);
@@ -1651,7 +1655,7 @@ public:
* advances, and assumes no characters fall outside the font box. In * advances, and assumes no characters fall outside the font box. In
* general this is insufficient, because that assumption is not always true. * 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, uint32_t aStart, uint32_t aEnd,
BoundingBoxType aBoundingBoxType, BoundingBoxType aBoundingBoxType,
DrawTarget* aDrawTargetForTightBoundingBox, DrawTarget* aDrawTargetForTightBoundingBox,
@@ -1883,7 +1887,7 @@ protected:
// Output a run of glyphs at *aPt, which is updated to follow the last glyph // 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 the run. This method also takes account of any letter-spacing provided
// in aRunParams. // in aRunParams.
bool DrawGlyphs(gfxShapedText *aShapedText, bool DrawGlyphs(const gfxShapedText *aShapedText,
uint32_t aOffset, // offset in the textrun uint32_t aOffset, // offset in the textrun
uint32_t aCount, // length of run to draw uint32_t aCount, // length of run to draw
gfxPoint *aPt, gfxPoint *aPt,
@@ -1917,7 +1921,7 @@ protected:
} }
bool IsSpaceGlyphInvisible(DrawTarget* aRefDrawTarget, bool IsSpaceGlyphInvisible(DrawTarget* aRefDrawTarget,
gfxTextRun* aTextRun); const gfxTextRun* aTextRun);
void AddGlyphChangeObserver(GlyphChangeObserver *aObserver); void AddGlyphChangeObserver(GlyphChangeObserver *aObserver);
void RemoveGlyphChangeObserver(GlyphChangeObserver *aObserver); void RemoveGlyphChangeObserver(GlyphChangeObserver *aObserver);

View File

@@ -141,7 +141,7 @@ gfxGDIFont::SetupCairoFont(DrawTarget* aDrawTarget)
} }
gfxFont::RunMetrics gfxFont::RunMetrics
gfxGDIFont::Measure(gfxTextRun *aTextRun, gfxGDIFont::Measure(const gfxTextRun *aTextRun,
uint32_t aStart, uint32_t aEnd, uint32_t aStart, uint32_t aEnd,
BoundingBoxType aBoundingBoxType, BoundingBoxType aBoundingBoxType,
DrawTarget *aRefDrawTarget, DrawTarget *aRefDrawTarget,

View File

@@ -45,7 +45,7 @@ public:
virtual bool SetupCairoFont(DrawTarget* aDrawTarget) override; virtual bool SetupCairoFont(DrawTarget* aDrawTarget) override;
/* override Measure to add padding for antialiasing */ /* override Measure to add padding for antialiasing */
virtual RunMetrics Measure(gfxTextRun *aTextRun, virtual RunMetrics Measure(const gfxTextRun *aTextRun,
uint32_t aStart, uint32_t aEnd, uint32_t aStart, uint32_t aEnd,
BoundingBoxType aBoundingBoxType, BoundingBoxType aBoundingBoxType,
DrawTarget *aDrawTargetForTightBoundingBox, DrawTarget *aDrawTargetForTightBoundingBox,

View File

@@ -165,7 +165,7 @@ gfxMacFont::SetupCairoFont(DrawTarget* aDrawTarget)
} }
gfxFont::RunMetrics gfxFont::RunMetrics
gfxMacFont::Measure(gfxTextRun *aTextRun, gfxMacFont::Measure(const gfxTextRun *aTextRun,
uint32_t aStart, uint32_t aEnd, uint32_t aStart, uint32_t aEnd,
BoundingBoxType aBoundingBoxType, BoundingBoxType aBoundingBoxType,
DrawTarget *aRefDrawTarget, DrawTarget *aRefDrawTarget,

View File

@@ -31,7 +31,7 @@ public:
virtual bool SetupCairoFont(DrawTarget* aDrawTarget) override; virtual bool SetupCairoFont(DrawTarget* aDrawTarget) override;
/* override Measure to add padding for antialiasing */ /* override Measure to add padding for antialiasing */
virtual RunMetrics Measure(gfxTextRun *aTextRun, virtual RunMetrics Measure(const gfxTextRun *aTextRun,
uint32_t aStart, uint32_t aEnd, uint32_t aStart, uint32_t aEnd,
BoundingBoxType aBoundingBoxType, BoundingBoxType aBoundingBoxType,
DrawTarget *aDrawTargetForTightBoundingBox, DrawTarget *aDrawTargetForTightBoundingBox,

View File

@@ -231,14 +231,15 @@ gfxTextRun::SetPotentialLineBreaks(Range aRange, uint8_t *aBreakBefore)
} }
gfxTextRun::LigatureData gfxTextRun::LigatureData
gfxTextRun::ComputeLigatureData(Range aPartRange, PropertyProvider *aProvider) gfxTextRun::ComputeLigatureData(Range aPartRange,
PropertyProvider *aProvider) const
{ {
NS_ASSERTION(aPartRange.start < aPartRange.end, NS_ASSERTION(aPartRange.start < aPartRange.end,
"Computing ligature data for empty range"); "Computing ligature data for empty range");
NS_ASSERTION(aPartRange.end <= GetLength(), "Character length overflow"); NS_ASSERTION(aPartRange.end <= GetLength(), "Character length overflow");
LigatureData result; LigatureData result;
CompressedGlyph *charGlyphs = mCharacterGlyphs; const CompressedGlyph *charGlyphs = mCharacterGlyphs;
uint32_t i; uint32_t i;
for (i = aPartRange.start; !charGlyphs[i].IsLigatureGroupStart(); --i) { for (i = aPartRange.start; !charGlyphs[i].IsLigatureGroupStart(); --i) {
@@ -313,7 +314,7 @@ gfxTextRun::ComputeLigatureData(Range aPartRange, PropertyProvider *aProvider)
gfxFloat gfxFloat
gfxTextRun::ComputePartialLigatureWidth(Range aPartRange, gfxTextRun::ComputePartialLigatureWidth(Range aPartRange,
PropertyProvider *aProvider) PropertyProvider *aProvider) const
{ {
if (aPartRange.start >= aPartRange.end) if (aPartRange.start >= aPartRange.end)
return 0; return 0;
@@ -322,7 +323,7 @@ gfxTextRun::ComputePartialLigatureWidth(Range aPartRange,
} }
int32_t int32_t
gfxTextRun::GetAdvanceForGlyphs(Range aRange) gfxTextRun::GetAdvanceForGlyphs(Range aRange) const
{ {
int32_t advance = 0; int32_t advance = 0;
for (auto i = aRange.start; i < aRange.end; ++i) { for (auto i = aRange.start; i < aRange.end; ++i) {
@@ -332,7 +333,7 @@ gfxTextRun::GetAdvanceForGlyphs(Range aRange)
} }
static void static void
GetAdjustedSpacing(gfxTextRun *aTextRun, gfxTextRun::Range aRange, GetAdjustedSpacing(const gfxTextRun *aTextRun, gfxTextRun::Range aRange,
gfxTextRun::PropertyProvider *aProvider, gfxTextRun::PropertyProvider *aProvider,
gfxTextRun::PropertyProvider::Spacing *aSpacing) gfxTextRun::PropertyProvider::Spacing *aSpacing)
{ {
@@ -363,7 +364,8 @@ GetAdjustedSpacing(gfxTextRun *aTextRun, gfxTextRun::Range aRange,
bool bool
gfxTextRun::GetAdjustedSpacingArray(Range aRange, PropertyProvider *aProvider, gfxTextRun::GetAdjustedSpacingArray(Range aRange, PropertyProvider *aProvider,
Range aSpacingRange, Range aSpacingRange,
nsTArray<PropertyProvider::Spacing> *aSpacing) nsTArray<PropertyProvider::Spacing>*
aSpacing) const
{ {
if (!aProvider || !(mFlags & gfxTextRunFactory::TEXT_ENABLE_SPACING)) if (!aProvider || !(mFlags & gfxTextRunFactory::TEXT_ENABLE_SPACING))
return false; return false;
@@ -379,12 +381,12 @@ gfxTextRun::GetAdjustedSpacingArray(Range aRange, PropertyProvider *aProvider,
} }
void void
gfxTextRun::ShrinkToLigatureBoundaries(Range* aRange) gfxTextRun::ShrinkToLigatureBoundaries(Range* aRange) const
{ {
if (aRange->start >= aRange->end) if (aRange->start >= aRange->end)
return; return;
CompressedGlyph *charGlyphs = mCharacterGlyphs; const CompressedGlyph *charGlyphs = mCharacterGlyphs;
while (aRange->start < aRange->end && while (aRange->start < aRange->end &&
!charGlyphs[aRange->start].IsLigatureGroupStart()) { !charGlyphs[aRange->start].IsLigatureGroupStart()) {
@@ -401,7 +403,7 @@ gfxTextRun::ShrinkToLigatureBoundaries(Range* aRange)
void void
gfxTextRun::DrawGlyphs(gfxFont *aFont, Range aRange, gfxPoint *aPt, gfxTextRun::DrawGlyphs(gfxFont *aFont, Range aRange, gfxPoint *aPt,
PropertyProvider *aProvider, Range aSpacingRange, PropertyProvider *aProvider, Range aSpacingRange,
TextRunDrawParams& aParams, uint16_t aOrientation) TextRunDrawParams& aParams, uint16_t aOrientation) const
{ {
AutoTArray<PropertyProvider::Spacing,200> spacingBuffer; AutoTArray<PropertyProvider::Spacing,200> spacingBuffer;
bool haveSpacing = GetAdjustedSpacingArray(aRange, aProvider, bool haveSpacing = GetAdjustedSpacingArray(aRange, aProvider,
@@ -437,7 +439,8 @@ ClipPartialLigature(const gfxTextRun* aTextRun,
void void
gfxTextRun::DrawPartialLigature(gfxFont *aFont, Range aRange, gfxTextRun::DrawPartialLigature(gfxFont *aFont, Range aRange,
gfxPoint *aPt, PropertyProvider *aProvider, gfxPoint *aPt, PropertyProvider *aProvider,
TextRunDrawParams& aParams, uint16_t aOrientation) TextRunDrawParams& aParams,
uint16_t aOrientation) const
{ {
if (aRange.start >= aRange.end) { if (aRange.start >= aRange.end) {
return; return;
@@ -495,7 +498,7 @@ gfxTextRun::DrawPartialLigature(gfxFont *aFont, Range aRange,
// check whether the text run needs to be explicitly composited in order to // check whether the text run needs to be explicitly composited in order to
// support opacity. // support opacity.
static bool static bool
HasSyntheticBoldOrColor(gfxTextRun *aRun, gfxTextRun::Range aRange) HasSyntheticBoldOrColor(const gfxTextRun *aRun, gfxTextRun::Range aRange)
{ {
gfxTextRun::GlyphRunIterator iter(aRun, aRange); gfxTextRun::GlyphRunIterator iter(aRun, aRange);
while (iter.NextRun()) { while (iter.NextRun()) {
@@ -565,7 +568,7 @@ struct BufferAlphaColor {
}; };
void 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(aRange.end <= GetLength(), "Substring out of range");
NS_ASSERTION(aParams.drawMode == DrawMode::GLYPH_PATH || NS_ASSERTION(aParams.drawMode == DrawMode::GLYPH_PATH ||
@@ -689,7 +692,7 @@ gfxTextRun::Draw(Range aRange, gfxPoint aPt, const DrawParams& aParams)
void void
gfxTextRun::DrawEmphasisMarks(gfxContext *aContext, gfxTextRun* aMark, gfxTextRun::DrawEmphasisMarks(gfxContext *aContext, gfxTextRun* aMark,
gfxFloat aMarkAdvance, gfxPoint aPt, gfxFloat aMarkAdvance, gfxPoint aPt,
Range aRange, PropertyProvider* aProvider) Range aRange, PropertyProvider* aProvider) const
{ {
MOZ_ASSERT(aRange.end <= GetLength()); MOZ_ASSERT(aRange.end <= GetLength());
@@ -733,7 +736,7 @@ gfxTextRun::AccumulateMetricsForRun(gfxFont *aFont, Range aRange,
PropertyProvider *aProvider, PropertyProvider *aProvider,
Range aSpacingRange, Range aSpacingRange,
uint16_t aOrientation, uint16_t aOrientation,
Metrics *aMetrics) Metrics *aMetrics) const
{ {
AutoTArray<PropertyProvider::Spacing,200> spacingBuffer; AutoTArray<PropertyProvider::Spacing,200> spacingBuffer;
bool haveSpacing = GetAdjustedSpacingArray(aRange, aProvider, bool haveSpacing = GetAdjustedSpacingArray(aRange, aProvider,
@@ -748,7 +751,8 @@ gfxTextRun::AccumulateMetricsForRun(gfxFont *aFont, Range aRange,
void void
gfxTextRun::AccumulatePartialLigatureMetrics(gfxFont *aFont, Range aRange, gfxTextRun::AccumulatePartialLigatureMetrics(gfxFont *aFont, Range aRange,
gfxFont::BoundingBoxType aBoundingBoxType, DrawTarget* aRefDrawTarget, 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) if (aRange.start >= aRange.end)
return; return;
@@ -786,7 +790,7 @@ gfxTextRun::Metrics
gfxTextRun::MeasureText(Range aRange, gfxTextRun::MeasureText(Range aRange,
gfxFont::BoundingBoxType aBoundingBoxType, gfxFont::BoundingBoxType aBoundingBoxType,
DrawTarget* aRefDrawTarget, DrawTarget* aRefDrawTarget,
PropertyProvider *aProvider) PropertyProvider *aProvider) const
{ {
NS_ASSERTION(aRange.end <= GetLength(), "Substring out of range"); NS_ASSERTION(aRange.end <= GetLength(), "Substring out of range");
@@ -1006,7 +1010,7 @@ gfxTextRun::BreakAndMeasureText(uint32_t aStart, uint32_t aMaxLength,
gfxFloat gfxFloat
gfxTextRun::GetAdvanceWidth(Range aRange, PropertyProvider *aProvider, gfxTextRun::GetAdvanceWidth(Range aRange, PropertyProvider *aProvider,
PropertyProvider::Spacing* aSpacing) PropertyProvider::Spacing* aSpacing) const
{ {
NS_ASSERTION(aRange.end <= GetLength(), "Substring out of range"); NS_ASSERTION(aRange.end <= GetLength(), "Substring out of range");
@@ -1059,7 +1063,7 @@ gfxTextRun::SetLineBreaks(Range aRange,
} }
uint32_t uint32_t
gfxTextRun::FindFirstGlyphRunContaining(uint32_t aOffset) gfxTextRun::FindFirstGlyphRunContaining(uint32_t aOffset) const
{ {
NS_ASSERTION(aOffset <= GetLength(), "Bad offset looking for glyphrun"); NS_ASSERTION(aOffset <= GetLength(), "Bad offset looking for glyphrun");
NS_ASSERTION(GetLength() == 0 || mGlyphRuns.Length() > 0, NS_ASSERTION(GetLength() == 0 || mGlyphRuns.Length() > 0,
@@ -1204,7 +1208,7 @@ gfxTextRun::SanitizeGlyphRuns()
} }
uint32_t uint32_t
gfxTextRun::CountMissingGlyphs() gfxTextRun::CountMissingGlyphs() const
{ {
uint32_t i; uint32_t i;
uint32_t count = 0; uint32_t count = 0;
@@ -1286,7 +1290,7 @@ gfxTextRun::CopyGlyphDataFrom(gfxTextRun *aSource, Range aRange, uint32_t aDest)
// Copy glyph runs // Copy glyph runs
GlyphRunIterator iter(aSource, aRange); GlyphRunIterator iter(aSource, aRange);
#ifdef DEBUG #ifdef DEBUG
GlyphRun *prevRun = nullptr; const GlyphRun *prevRun = nullptr;
#endif #endif
while (iter.NextRun()) { while (iter.NextRun()) {
gfxFont *font = iter.GetGlyphRun()->mFont; gfxFont *font = iter.GetGlyphRun()->mFont;

View File

@@ -148,7 +148,7 @@ public:
Range() : start(0), end(0) {} Range() : start(0), end(0) {}
Range(uint32_t aStart, uint32_t aEnd) Range(uint32_t aStart, uint32_t aEnd)
: start(aStart), end(aEnd) {} : start(aStart), end(aEnd) {}
explicit Range(gfxTextRun* aTextRun) explicit Range(const gfxTextRun* aTextRun)
: start(0), end(aTextRun->GetLength()) {} : start(0), end(aTextRun->GetLength()) {}
}; };
@@ -267,7 +267,7 @@ public:
* Glyphs should be drawn in logical content order, which can be significant * Glyphs should be drawn in logical content order, which can be significant
* if they overlap (perhaps due to negative spacing). * 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 * Draws the emphasis marks for this text run. Uses only GetSpacing
@@ -276,7 +276,7 @@ public:
*/ */
void DrawEmphasisMarks(gfxContext* aContext, gfxTextRun* aMark, void DrawEmphasisMarks(gfxContext* aContext, gfxTextRun* aMark,
gfxFloat aMarkAdvance, gfxPoint aPt, gfxFloat aMarkAdvance, gfxPoint aPt,
Range aRange, PropertyProvider* aProvider); Range aRange, PropertyProvider* aProvider) const;
/** /**
* Computes the ReflowMetrics for a substring. * Computes the ReflowMetrics for a substring.
@@ -286,11 +286,11 @@ public:
Metrics MeasureText(Range aRange, Metrics MeasureText(Range aRange,
gfxFont::BoundingBoxType aBoundingBoxType, gfxFont::BoundingBoxType aBoundingBoxType,
DrawTarget* aDrawTargetForTightBoundingBox, DrawTarget* aDrawTargetForTightBoundingBox,
PropertyProvider* aProvider); PropertyProvider* aProvider) const;
Metrics MeasureText(gfxFont::BoundingBoxType aBoundingBoxType, Metrics MeasureText(gfxFont::BoundingBoxType aBoundingBoxType,
DrawTarget* aDrawTargetForTightBoundingBox, DrawTarget* aDrawTargetForTightBoundingBox,
PropertyProvider* aProvider = nullptr) { PropertyProvider* aProvider = nullptr) const {
return MeasureText(Range(this), aBoundingBoxType, return MeasureText(Range(this), aBoundingBoxType,
aDrawTargetForTightBoundingBox, aProvider); aDrawTargetForTightBoundingBox, aProvider);
} }
@@ -303,9 +303,10 @@ public:
* included in the advance width. * included in the advance width.
*/ */
gfxFloat GetAdvanceWidth(Range aRange, PropertyProvider *aProvider, 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); return GetAdvanceWidth(Range(this), nullptr);
} }
@@ -452,19 +453,19 @@ public:
class GlyphRunIterator { class GlyphRunIterator {
public: public:
GlyphRunIterator(gfxTextRun *aTextRun, Range aRange) GlyphRunIterator(const gfxTextRun *aTextRun, Range aRange)
: mTextRun(aTextRun) : mTextRun(aTextRun)
, mStartOffset(aRange.start) , mStartOffset(aRange.start)
, mEndOffset(aRange.end) { , mEndOffset(aRange.end) {
mNextIndex = mTextRun->FindFirstGlyphRunContaining(aRange.start); mNextIndex = mTextRun->FindFirstGlyphRunContaining(aRange.start);
} }
bool NextRun(); bool NextRun();
GlyphRun *GetGlyphRun() { return mGlyphRun; } const GlyphRun *GetGlyphRun() const { return mGlyphRun; }
uint32_t GetStringStart() { return mStringStart; } uint32_t GetStringStart() const { return mStringStart; }
uint32_t GetStringEnd() { return mStringEnd; } uint32_t GetStringEnd() const { return mStringEnd; }
private: private:
gfxTextRun *mTextRun; const gfxTextRun *mTextRun;
GlyphRun *mGlyphRun; const GlyphRun *mGlyphRun;
uint32_t mStringStart; uint32_t mStringStart;
uint32_t mStringEnd; uint32_t mStringEnd;
uint32_t mNextIndex; uint32_t mNextIndex;
@@ -512,6 +513,10 @@ public:
void SortGlyphRuns(); void SortGlyphRuns();
void SanitizeGlyphRuns(); void SanitizeGlyphRuns();
const CompressedGlyph* GetCharacterGlyphs() const final {
MOZ_ASSERT(mCharacterGlyphs, "failed to initialize mCharacterGlyphs");
return mCharacterGlyphs;
}
CompressedGlyph* GetCharacterGlyphs() final { CompressedGlyph* GetCharacterGlyphs() final {
MOZ_ASSERT(mCharacterGlyphs, "failed to initialize mCharacterGlyphs"); MOZ_ASSERT(mCharacterGlyphs, "failed to initialize mCharacterGlyphs");
return mCharacterGlyphs; return mCharacterGlyphs;
@@ -563,14 +568,14 @@ public:
*/ */
void FetchGlyphExtents(DrawTarget* aRefDrawTarget); void FetchGlyphExtents(DrawTarget* aRefDrawTarget);
uint32_t CountMissingGlyphs(); uint32_t CountMissingGlyphs() const;
const GlyphRun *GetGlyphRuns(uint32_t *aNumGlyphRuns) { const GlyphRun *GetGlyphRuns(uint32_t *aNumGlyphRuns) {
*aNumGlyphRuns = mGlyphRuns.Length(); *aNumGlyphRuns = mGlyphRuns.Length();
return mGlyphRuns.Elements(); return mGlyphRuns.Elements();
} }
// Returns the index of the GlyphRun containing the given offset. // Returns the index of the GlyphRun containing the given offset.
// Returns mGlyphRuns.Length() when aOffset is mCharacterCount. // 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. // Copy glyph data from a ShapedWord into this textrun.
void CopyGlyphDataFrom(gfxShapedWord *aSource, uint32_t aStart); void CopyGlyphDataFrom(gfxShapedWord *aSource, uint32_t aStart);
@@ -638,7 +643,7 @@ public:
mShapingState = aShapingState; mShapingState = aShapingState;
} }
int32_t GetAdvanceForGlyph(uint32_t aIndex) int32_t GetAdvanceForGlyph(uint32_t aIndex) const
{ {
const CompressedGlyph& glyphData = mCharacterGlyphs[aIndex]; const CompressedGlyph& glyphData = mCharacterGlyphs[aIndex];
if (glyphData.IsSimpleGlyph()) { if (glyphData.IsSimpleGlyph()) {
@@ -685,7 +690,7 @@ private:
// **** general helpers **** // **** general helpers ****
// Get the total advance for a range of glyphs. // 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 // Spacing for characters outside the range aSpacingStart/aSpacingEnd
// is assumed to be zero; such characters are not passed to aProvider. // is assumed to be zero; such characters are not passed to aProvider.
@@ -693,7 +698,8 @@ private:
// it is not currently able to handle. // it is not currently able to handle.
bool GetAdjustedSpacingArray(Range aRange, PropertyProvider *aProvider, bool GetAdjustedSpacingArray(Range aRange, PropertyProvider *aProvider,
Range aSpacingRange, Range aSpacingRange,
nsTArray<PropertyProvider::Spacing> *aSpacing); nsTArray<PropertyProvider::Spacing>*
aSpacing) const;
CompressedGlyph& EnsureComplexGlyph(uint32_t aIndex) CompressedGlyph& EnsureComplexGlyph(uint32_t aIndex)
{ {
@@ -707,24 +713,26 @@ private:
// if aProvider is null then mBeforeSpacing and mAfterSpacing are set to zero // if aProvider is null then mBeforeSpacing and mAfterSpacing are set to zero
LigatureData ComputeLigatureData(Range aPartRange, LigatureData ComputeLigatureData(Range aPartRange,
PropertyProvider *aProvider); PropertyProvider *aProvider) const;
gfxFloat ComputePartialLigatureWidth(Range aPartRange, gfxFloat ComputePartialLigatureWidth(Range aPartRange,
PropertyProvider *aProvider); PropertyProvider *aProvider) const;
void DrawPartialLigature(gfxFont *aFont, Range aRange, void DrawPartialLigature(gfxFont *aFont, Range aRange,
gfxPoint *aPt, PropertyProvider *aProvider, 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 // Advance aRange.start to the start of the nearest ligature, back
// up aRange.end to the nearest ligature end; may result in // up aRange.end to the nearest ligature end; may result in
// aRange->start == aRange->end. // aRange->start == aRange->end.
void ShrinkToLigatureBoundaries(Range* aRange); void ShrinkToLigatureBoundaries(Range* aRange) const;
// result in appunits // result in appunits
gfxFloat GetPartialLigatureWidth(Range aRange, PropertyProvider *aProvider); gfxFloat GetPartialLigatureWidth(Range aRange,
PropertyProvider *aProvider) const;
void AccumulatePartialLigatureMetrics(gfxFont *aFont, Range aRange, void AccumulatePartialLigatureMetrics(gfxFont *aFont, Range aRange,
gfxFont::BoundingBoxType aBoundingBoxType, gfxFont::BoundingBoxType aBoundingBoxType,
DrawTarget* aRefDrawTarget, DrawTarget* aRefDrawTarget,
PropertyProvider *aProvider, PropertyProvider *aProvider,
uint16_t aOrientation, uint16_t aOrientation,
Metrics *aMetrics); Metrics *aMetrics) const;
// **** measurement helper **** // **** measurement helper ****
void AccumulateMetricsForRun(gfxFont *aFont, Range aRange, void AccumulateMetricsForRun(gfxFont *aFont, Range aRange,
@@ -733,12 +741,12 @@ private:
PropertyProvider *aProvider, PropertyProvider *aProvider,
Range aSpacingRange, Range aSpacingRange,
uint16_t aOrientation, uint16_t aOrientation,
Metrics *aMetrics); Metrics *aMetrics) const;
// **** drawing helper **** // **** drawing helper ****
void DrawGlyphs(gfxFont *aFont, Range aRange, gfxPoint *aPt, void DrawGlyphs(gfxFont *aFont, Range aRange, gfxPoint *aPt,
PropertyProvider *aProvider, Range aSpacingRange, 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*, // XXX this should be changed to a GlyphRun plus a maybe-null GlyphRun*,
// for smaller size especially in the super-common one-glyphrun case // for smaller size especially in the super-common one-glyphrun case

View File

@@ -135,7 +135,7 @@ MergeCharactersInTextRun(gfxTextRun* aDest, gfxTextRun* aSrc,
uint32_t offset = 0; uint32_t offset = 0;
AutoTArray<gfxTextRun::DetailedGlyph,2> glyphs; AutoTArray<gfxTextRun::DetailedGlyph,2> glyphs;
while (iter.NextRun()) { while (iter.NextRun()) {
gfxTextRun::GlyphRun* run = iter.GetGlyphRun(); const gfxTextRun::GlyphRun* run = iter.GetGlyphRun();
nsresult rv = aDest->AddGlyphRun(run->mFont, run->mMatchType, nsresult rv = aDest->AddGlyphRun(run->mFont, run->mMatchType,
offset, false, run->mOrientation); offset, false, run->mOrientation);
if (NS_FAILED(rv)) if (NS_FAILED(rv))