Bug 1232822 (part 1) - Moz2Dify SetupCairoFont(). r=jfkthame.

This is now trivial.
This commit is contained in:
Nicholas Nethercote 2015-12-15 13:56:40 -08:00
parent d3fbd6b72e
commit 9979226ab1
14 changed files with 20 additions and 24 deletions

View File

@ -454,7 +454,7 @@ gfxDWriteFont::GetSpaceGlyph()
}
bool
gfxDWriteFont::SetupCairoFont(gfxContext *aContext)
gfxDWriteFont::SetupCairoFont(DrawTarget* aDrawTarget)
{
cairo_scaled_font_t *scaledFont = GetCairoScaledFont();
if (cairo_scaled_font_status(scaledFont) != CAIRO_STATUS_SUCCESS) {
@ -462,8 +462,7 @@ gfxDWriteFont::SetupCairoFont(gfxContext *aContext)
// the cairo_t, precluding any further drawing.
return false;
}
cairo_set_scaled_font(gfxContext::RefCairo(aContext->GetDrawTarget()),
scaledFont);
cairo_set_scaled_font(gfxContext::RefCairo(aDrawTarget), scaledFont);
return true;
}

View File

@ -33,7 +33,7 @@ public:
virtual uint32_t GetSpaceGlyph() override;
virtual bool SetupCairoFont(gfxContext *aContext) override;
virtual bool SetupCairoFont(DrawTarget* aDrawTarget) override;
virtual bool AllowSubpixelAA() override
{ return mAllowManualShowGlyphs; }

View File

@ -176,7 +176,7 @@ gfxFT2FontBase::GetGlyphWidth(DrawTarget& aDrawTarget, uint16_t aGID)
}
bool
gfxFT2FontBase::SetupCairoFont(gfxContext *aContext)
gfxFT2FontBase::SetupCairoFont(DrawTarget* aDrawTarget)
{
// The scaled font ctm is not relevant right here because
// cairo_set_scaled_font does not record the scaled font itself, but
@ -210,7 +210,6 @@ gfxFT2FontBase::SetupCairoFont(gfxContext *aContext)
// what is set here. It's too late to change things here as measuring has
// already taken place. We should really be measuring with a different
// font for pdf and ps surfaces (bug 403513).
cairo_set_scaled_font(gfxContext::RefCairo(aContext->GetDrawTarget()),
cairoFont);
cairo_set_scaled_font(gfxContext::RefCairo(aDrawTarget), cairoFont);
return true;
}

View File

@ -30,7 +30,7 @@ public:
uint16_t aGID) override;
cairo_scaled_font_t *CairoScaledFont() { return mScaledFont; };
virtual bool SetupCairoFont(gfxContext *aContext) override;
virtual bool SetupCairoFont(DrawTarget* aDrawTarget) override;
virtual FontType GetType() const override { return FONT_TYPE_FT2; }

View File

@ -781,7 +781,7 @@ gfxFont::~gfxFont()
gfxFloat
gfxFont::GetGlyphHAdvance(gfxContext *aCtx, uint16_t aGID)
{
if (!SetupCairoFont(aCtx)) {
if (!SetupCairoFont(aCtx->GetDrawTarget())) {
return 0;
}
if (ProvidesGlyphWidths()) {

View File

@ -1660,7 +1660,7 @@ public:
bool aNeedTight, gfxGlyphExtents *aExtents);
// This is called by the default Draw() implementation above.
virtual bool SetupCairoFont(gfxContext *aContext) = 0;
virtual bool SetupCairoFont(DrawTarget* aDrawTarget) = 0;
virtual bool AllowSubpixelAA() { return true; }

View File

@ -98,7 +98,7 @@ gfxGDIFont::ShapeText(gfxContext *aContext,
// creating a "toy" font internally (see bug 544617).
// We must check that this succeeded, otherwise we risk cairo creating the
// wrong kind of font internally as a fallback (bug 744480).
if (!SetupCairoFont(aContext)) {
if (!SetupCairoFont(aContext->GetDrawTarget())) {
return false;
}
@ -125,7 +125,7 @@ gfxGDIFont::GetSpaceGlyph()
}
bool
gfxGDIFont::SetupCairoFont(gfxContext *aContext)
gfxGDIFont::SetupCairoFont(DrawTarget* aDrawTarget)
{
if (!mMetrics) {
Initialize();
@ -136,8 +136,7 @@ gfxGDIFont::SetupCairoFont(gfxContext *aContext)
// the cairo_t, precluding any further drawing.
return false;
}
cairo_set_scaled_font(gfxContext::RefCairo(aContext->GetDrawTarget()),
mScaledFont);
cairo_set_scaled_font(gfxContext::RefCairo(aDrawTarget), mScaledFont);
return true;
}

View File

@ -42,7 +42,7 @@ public:
/* overrides for the pure virtual methods in gfxFont */
virtual uint32_t GetSpaceGlyph() override;
virtual bool SetupCairoFont(gfxContext *aContext) override;
virtual bool SetupCairoFont(DrawTarget* aDrawTarget) override;
/* override Measure to add padding for antialiasing */
virtual RunMetrics Measure(gfxTextRun *aTextRun,

View File

@ -45,7 +45,7 @@ gfxGlyphExtents::GetTightGlyphExtentsAppUnits(gfxFont *aFont,
return false;
}
if (aFont->SetupCairoFont(aContext)) {
if (aFont->SetupCairoFont(aContext->GetDrawTarget())) {
#ifdef DEBUG_TEXT_RUN_STORAGE_METRICS
++gGlyphExtentsSetupLazyTight;
#endif

View File

@ -91,7 +91,7 @@ gfxGraphiteShaper::ShapeText(gfxContext *aContext,
gfxShapedText *aShapedText)
{
// some font back-ends require this in order to get proper hinted metrics
if (!mFont->SetupCairoFont(aContext)) {
if (!mFont->SetupCairoFont(aContext->GetDrawTarget())) {
return false;
}

View File

@ -1471,7 +1471,7 @@ gfxHarfBuzzShaper::ShapeText(gfxContext *aContext,
gfxShapedText *aShapedText)
{
// some font back-ends require this in order to get proper hinted metrics
if (!mFont->SetupCairoFont(aContext)) {
if (!mFont->SetupCairoFont(aContext->GetDrawTarget())) {
return false;
}

View File

@ -153,15 +153,14 @@ gfxMacFont::ShapeText(gfxContext *aContext,
}
bool
gfxMacFont::SetupCairoFont(gfxContext *aContext)
gfxMacFont::SetupCairoFont(DrawTarget* aDrawTarget)
{
if (cairo_scaled_font_status(mScaledFont) != CAIRO_STATUS_SUCCESS) {
// Don't cairo_set_scaled_font as that would propagate the error to
// the cairo_t, precluding any further drawing.
return false;
}
cairo_set_scaled_font(gfxContext::RefCairo(aContext->GetDrawTarget()),
mScaledFont);
cairo_set_scaled_font(gfxContext::RefCairo(aDrawTarget), mScaledFont);
return true;
}

View File

@ -28,7 +28,7 @@ public:
return mSpaceGlyph;
}
virtual bool SetupCairoFont(gfxContext *aContext) override;
virtual bool SetupCairoFont(DrawTarget* aDrawTarget) override;
/* override Measure to add padding for antialiasing */
virtual RunMetrics Measure(gfxTextRun *aTextRun,

View File

@ -1411,7 +1411,7 @@ gfxTextRun::FetchGlyphExtents(gfxContext *aRefContext)
uint32_t glyphIndex = glyphData->GetSimpleGlyph();
if (!extents->IsGlyphKnown(glyphIndex)) {
if (!fontIsSetup) {
if (!font->SetupCairoFont(aRefContext)) {
if (!font->SetupCairoFont(aRefContext->GetDrawTarget())) {
NS_WARNING("failed to set up font for glyph extents");
break;
}
@ -1437,7 +1437,7 @@ gfxTextRun::FetchGlyphExtents(gfxContext *aRefContext)
uint32_t glyphIndex = details->mGlyphID;
if (!extents->IsGlyphKnownWithTightExtents(glyphIndex)) {
if (!fontIsSetup) {
if (!font->SetupCairoFont(aRefContext)) {
if (!font->SetupCairoFont(aRefContext->GetDrawTarget())) {
NS_WARNING("failed to set up font for glyph extents");
break;
}