Bug 1093066 - Get rid of gfxContext's Stroke() methods. r=mattwoodrow

This commit is contained in:
Jonathan Watt 2014-11-05 09:16:37 +00:00
Родитель 4954f4c54a
Коммит 2ac2b5426a
4 изменённых файлов: 30 добавлений и 62 удалений

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

@ -224,30 +224,6 @@ gfxContext::CurrentPoint()
return ThebesPoint(mPathBuilder->CurrentPoint());
}
void
gfxContext::Stroke()
{
Stroke(PatternFromState(this));
}
void
gfxContext::Stroke(const Pattern& aPattern)
{
AzureState &state = CurrentState();
if (mPathIsRect) {
MOZ_ASSERT(!mTransformChanged);
mDT->StrokeRect(mRect, aPattern,
state.strokeOptions,
DrawOptions(1.0f, GetOp(), state.aaMode));
} else {
EnsurePath();
mDT->Stroke(mPath, aPattern, state.strokeOptions,
DrawOptions(1.0f, GetOp(), state.aaMode));
}
}
void
gfxContext::Fill()
{
@ -523,26 +499,6 @@ gfxContext::CurrentAntialiasMode() const
return CurrentState().aaMode;
}
void
gfxContext::SetDash(gfxLineType ltype)
{
static double dash[] = {5.0, 5.0};
static double dot[] = {1.0, 1.0};
switch (ltype) {
case gfxLineDashed:
SetDash(dash, 2, 0.0);
break;
case gfxLineDotted:
SetDash(dot, 2, 0.0);
break;
case gfxLineSolid:
default:
SetDash(nullptr, 0, 0.0);
break;
}
}
void
gfxContext::SetDash(gfxFloat *dashes, int ndash, gfxFloat offset)
{

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

@ -100,15 +100,6 @@ public:
** Paths & Drawing
**/
/**
* Stroke the current path using the current settings (such as line
* width and color).
* A path is set up using functions such as Line, Rectangle and Arc.
*
* Does not consume the current path.
*/
void Stroke();
void Stroke(const Pattern& aPattern);
/**
* Fill the current path according to the current settings.
*
@ -368,13 +359,6 @@ public:
** Line Properties
**/
typedef enum {
gfxLineSolid,
gfxLineDashed,
gfxLineDotted
} gfxLineType;
void SetDash(gfxLineType ltype);
void SetDash(gfxFloat *dashes, int ndash, gfxFloat offset);
// Return true if dashing is set, false if it's not enabled or the
// context is in an error state. |offset| can be nullptr to mean

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

@ -2989,8 +2989,30 @@ SVGTextDrawPathCallbacks::StrokeGeometry()
GeneralPattern strokePattern;
nsSVGUtils::MakeStrokePatternFor(mFrame, gfx, &strokePattern, /*aContextPaint*/ nullptr);
if (strokePattern.GetPattern()) {
nsSVGUtils::SetupCairoStrokeGeometry(mFrame, gfx, /*aContextPaint*/ nullptr);
gfx->Stroke(strokePattern);
if (!mFrame->GetParent()->GetContent()->IsSVG()) {
// The cast that follows would be unsafe
MOZ_ASSERT(false, "Our nsTextFrame's parent's content should be SVG");
return;
}
nsSVGElement* svgOwner =
static_cast<nsSVGElement*>(mFrame->GetParent()->GetContent());
// Apply any stroke-specific transform
gfxMatrix outerSVGToUser;
if (nsSVGUtils::GetNonScalingStrokeTransform(mFrame, &outerSVGToUser) &&
outerSVGToUser.Invert()) {
gfx->Multiply(outerSVGToUser);
}
RefPtr<Path> path = gfx->GetPath();
SVGContentUtils::AutoStrokeOptions strokeOptions;
SVGContentUtils::GetStrokeOptions(&strokeOptions, svgOwner,
mFrame->StyleContext(),
/*aContextPaint*/ nullptr);
DrawOptions drawOptions;
drawOptions.mAntialiasMode =
nsSVGUtils::ToAntialiasMode(mFrame->StyleSVG()->mTextRendering);
gfx->GetDrawTarget()->Stroke(path, strokePattern, strokeOptions);
}
}
}

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

@ -187,6 +187,7 @@ class nsSVGUtils
{
public:
typedef mozilla::dom::Element Element;
typedef mozilla::gfx::AntialiasMode AntialiasMode;
typedef mozilla::gfx::FillRule FillRule;
typedef mozilla::gfx::GeneralPattern GeneralPattern;
@ -533,6 +534,11 @@ public:
FillRule::FILL_EVEN_ODD : FillRule::FILL_WINDING;
}
static AntialiasMode ToAntialiasMode(uint8_t aTextRendering) {
return aTextRendering == NS_STYLE_TEXT_RENDERING_OPTIMIZESPEED ?
AntialiasMode::NONE : AntialiasMode::SUBPIXEL;
}
/**
* Render a SVG glyph.
* @param aElement the SVG glyph element to render