Bug 1136486 - Simplify the SVG text rendering callbacks by getting rid of NotifyBeforeSVGGlyphPainted and NotifyAfterSVGGlyphPainted. r=heycam

This commit is contained in:
Jonathan Watt 2015-02-17 22:01:54 +00:00
Родитель 991b019ff2
Коммит 6c3e865ef2
4 изменённых файлов: 15 добавлений и 46 удалений

Просмотреть файл

@ -2038,14 +2038,18 @@ gfxFont::RenderSVGGlyph(gfxContext *aContext, gfxPoint aPoint, DrawMode aDrawMod
GetAdjustedSize() / GetFontEntry()->UnitsPerEm();
gfxContextMatrixAutoSaveRestore matrixRestore(aContext);
aContext->Save();
aContext->SetMatrix(
aContext->CurrentMatrix().Translate(aPoint.x, aPoint.y).
Scale(devUnitsPerSVGUnit, devUnitsPerSVGUnit));
aContextPaint->InitStrokeGeometry(aContext, devUnitsPerSVGUnit);
return GetFontEntry()->RenderSVGGlyph(aContext, aGlyphId, int(aDrawMode),
aContextPaint);
bool rv = GetFontEntry()->RenderSVGGlyph(aContext, aGlyphId,
int(aDrawMode), aContextPaint);
aContext->Restore();
aContext->NewPath();
return rv;
}
bool
@ -2054,19 +2058,11 @@ gfxFont::RenderSVGGlyph(gfxContext *aContext, gfxPoint aPoint, DrawMode aDrawMod
gfxTextRunDrawCallbacks *aCallbacks,
bool& aEmittedGlyphs) const
{
if (aCallbacks) {
if (aEmittedGlyphs) {
aCallbacks->NotifyGlyphPathEmitted();
aEmittedGlyphs = false;
}
aCallbacks->NotifyBeforeSVGGlyphPainted();
if (aCallbacks && aEmittedGlyphs) {
aCallbacks->NotifyGlyphPathEmitted();
aEmittedGlyphs = false;
}
bool rendered = RenderSVGGlyph(aContext, aPoint, aDrawMode, aGlyphId,
aContextPaint);
if (aCallbacks) {
aCallbacks->NotifyAfterSVGGlyphPainted();
}
return rendered;
return RenderSVGGlyph(aContext, aPoint, aDrawMode, aGlyphId, aContextPaint);
}
bool

Просмотреть файл

@ -39,10 +39,9 @@ struct gfxTextRunDrawCallbacks {
/**
* Constructs a new DrawCallbacks object.
*
* @param aShouldPaintSVGGlyphs If true, SVG glyphs will be
* painted and the NotifyBeforeSVGGlyphPainted/NotifyAfterSVGGlyphPainted
* callbacks will be invoked for each SVG glyph. If false, SVG glyphs
* will not be painted; fallback plain glyphs are not emitted either.
* @param aShouldPaintSVGGlyphs If true, SVG glyphs will be painted. If
* false, SVG glyphs will not be painted; fallback plain glyphs are not
* emitted either.
*/
explicit gfxTextRunDrawCallbacks(bool aShouldPaintSVGGlyphs = false)
: mShouldPaintSVGGlyphs(aShouldPaintSVGGlyphs)
@ -56,16 +55,6 @@ struct gfxTextRunDrawCallbacks {
*/
virtual void NotifyGlyphPathEmitted() = 0;
/**
* Called just before an SVG glyph has been painted to the gfxContext.
*/
virtual void NotifyBeforeSVGGlyphPainted() { }
/**
* Called just after an SVG glyph has been painted to the gfxContext.
*/
virtual void NotifyAfterSVGGlyphPainted() { }
bool mShouldPaintSVGGlyphs;
};

Просмотреть файл

@ -304,11 +304,10 @@ public:
*
* Callbacks are invoked in the following order:
*
* (NotifySelectionBackgroundNeedsFill)?
* NotifySelectionBackgroundNeedsFill?
* PaintDecorationLine*
* NotifyBeforeText
* (NotifyGlyphPathEmitted |
* (NotifyBeforeSVGGlyphPainted NotifyAfterSVGGlyphPainted))*
* NotifyGlyphPathEmitted*
* NotifyAfterText
* PaintDecorationLine*
* PaintSelectionDecorationLine*

Просмотреть файл

@ -2726,8 +2726,6 @@ public:
void PaintSelectionDecorationLine(Rect aPath, nscolor aColor) MOZ_OVERRIDE;
void NotifyBeforeText(nscolor aColor) MOZ_OVERRIDE;
void NotifyGlyphPathEmitted() MOZ_OVERRIDE;
void NotifyBeforeSVGGlyphPainted() MOZ_OVERRIDE;
void NotifyAfterSVGGlyphPainted() MOZ_OVERRIDE;
void NotifyAfterText() MOZ_OVERRIDE;
private:
@ -2816,19 +2814,6 @@ SVGTextDrawPathCallbacks::NotifyGlyphPathEmitted()
gfx->NewPath();
}
void
SVGTextDrawPathCallbacks::NotifyBeforeSVGGlyphPainted()
{
gfx->Save();
}
void
SVGTextDrawPathCallbacks::NotifyAfterSVGGlyphPainted()
{
gfx->Restore();
gfx->NewPath();
}
void
SVGTextDrawPathCallbacks::NotifyAfterText()
{