Bug 1093811 - Convert the gfxFont::GetGlyphWidth() virtual method to take a Moz2D DrawTarget instead of a Thebes gfxContext. r=jfkthame

This commit is contained in:
Jonathan Watt 2014-11-10 21:41:41 +00:00
parent 34c0ce8374
commit 788f36f152
10 changed files with 17 additions and 13 deletions

View File

@ -584,7 +584,7 @@ gfxDWriteFont::ProvidesGlyphWidths() const
}
int32_t
gfxDWriteFont::GetGlyphWidth(gfxContext *aCtx, uint16_t aGID)
gfxDWriteFont::GetGlyphWidth(DrawTarget& aDrawTarget, uint16_t aGID)
{
if (!mGlyphWidths) {
mGlyphWidths = new nsDataHashtable<nsUint32HashKey,int32_t>(128);

View File

@ -54,7 +54,7 @@ public:
virtual bool ProvidesGlyphWidths() const;
virtual int32_t GetGlyphWidth(gfxContext *aCtx, uint16_t aGID);
virtual int32_t GetGlyphWidth(DrawTarget& aDrawTarget, uint16_t aGID);
virtual mozilla::TemporaryRef<mozilla::gfx::GlyphRenderingOptions>
GetGlyphRenderingOptions(const TextRunDrawParams* aRunParams = nullptr) MOZ_OVERRIDE;

View File

@ -168,7 +168,7 @@ gfxFT2FontBase::GetGlyph(uint32_t unicode, uint32_t variation_selector)
}
int32_t
gfxFT2FontBase::GetGlyphWidth(gfxContext *aCtx, uint16_t aGID)
gfxFT2FontBase::GetGlyphWidth(DrawTarget& aDrawTarget, uint16_t aGID)
{
cairo_text_extents_t extents;
GetGlyphExtents(aGID, &extents);

View File

@ -25,7 +25,7 @@ public:
virtual bool ProvidesGetGlyph() const { return true; }
virtual uint32_t GetGlyph(uint32_t unicode, uint32_t variation_selector);
virtual bool ProvidesGlyphWidths() const { return true; }
virtual int32_t GetGlyphWidth(gfxContext *aCtx, uint16_t aGID);
virtual int32_t GetGlyphWidth(DrawTarget& aDrawTarget, uint16_t aGID);
cairo_scaled_font_t *CairoScaledFont() { return mScaledFont; };
virtual bool SetupCairoFont(gfxContext *aContext);

View File

@ -791,7 +791,7 @@ gfxFont::GetGlyphHAdvance(gfxContext *aCtx, uint16_t aGID)
return 0;
}
if (ProvidesGlyphWidths()) {
return GetGlyphWidth(aCtx, aGID) / 65536.0;
return GetGlyphWidth(*aCtx->GetDrawTarget(), aGID) / 65536.0;
}
if (mFUnitsConvFactor == 0.0f) {
GetMetrics(eHorizontal);

View File

@ -1267,6 +1267,9 @@ class gfxFont {
friend class gfxHarfBuzzShaper;
friend class gfxGraphiteShaper;
protected:
typedef mozilla::gfx::DrawTarget DrawTarget;
public:
nsrefcnt AddRef(void) {
NS_PRECONDITION(int32_t(mRefCnt) >= 0, "illegal refcnt");
@ -1709,7 +1712,7 @@ public:
virtual FontType GetType() const = 0;
virtual mozilla::TemporaryRef<mozilla::gfx::ScaledFont> GetScaledFont(mozilla::gfx::DrawTarget *aTarget)
virtual mozilla::TemporaryRef<mozilla::gfx::ScaledFont> GetScaledFont(DrawTarget* aTarget)
{ return gfxPlatform::GetPlatform()->GetScaledFontForFont(aTarget, this); }
bool KerningDisabled() {
@ -1820,7 +1823,7 @@ protected:
// The return value is interpreted as a horizontal advance in 16.16 fixed
// point format.
virtual int32_t GetGlyphWidth(gfxContext *aCtx, uint16_t aGID) {
virtual int32_t GetGlyphWidth(DrawTarget& aDrawTarget, uint16_t aGID) {
return -1;
}

View File

@ -460,7 +460,7 @@ gfxGDIFont::GetGlyph(uint32_t aUnicode, uint32_t aVarSelector)
}
int32_t
gfxGDIFont::GetGlyphWidth(gfxContext *aCtx, uint16_t aGID)
gfxGDIFont::GetGlyphWidth(DrawTarget& aDrawTarget, uint16_t aGID)
{
if (!mGlyphWidths) {
mGlyphWidths = new nsDataHashtable<nsUint32HashKey,int32_t>(128);
@ -471,7 +471,7 @@ gfxGDIFont::GetGlyphWidth(gfxContext *aCtx, uint16_t aGID)
return width;
}
DCFromDrawTarget dc(*aCtx->GetDrawTarget());
DCFromDrawTarget dc(aDrawTarget);
AutoSelectFont fs(dc, GetHFONT());
int devWidth;

View File

@ -60,7 +60,7 @@ public:
virtual bool ProvidesGlyphWidths() const { return true; }
// get hinted glyph width in pixels as 16.16 fixed-point value
virtual int32_t GetGlyphWidth(gfxContext *aCtx, uint16_t aGID);
virtual int32_t GetGlyphWidth(DrawTarget& aDrawTarget, uint16_t aGID);
virtual void AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf,
FontCacheSizes* aSizes) const;

View File

@ -50,7 +50,8 @@ gfxGraphiteShaper::GrGetAdvance(const void* appFontHandle, uint16_t glyphid)
{
const CallbackData *cb =
static_cast<const CallbackData*>(appFontHandle);
return FixedToFloat(cb->mFont->GetGlyphWidth(cb->mContext, glyphid));
return FixedToFloat(cb->mFont->GetGlyphWidth(*cb->mContext->GetDrawTarget(),
glyphid));
}
static inline uint32_t

View File

@ -241,7 +241,7 @@ gfxHarfBuzzShaper::HBGetGlyphHAdvance(hb_font_t *font, void *font_data,
static_cast<const gfxHarfBuzzShaper::FontCallbackData*>(font_data);
gfxFont *gfxfont = fcd->mShaper->GetFont();
if (gfxfont->ProvidesGlyphWidths()) {
return gfxfont->GetGlyphWidth(fcd->mContext, glyph);
return gfxfont->GetGlyphWidth(*fcd->mContext->GetDrawTarget(), glyph);
}
return fcd->mShaper->GetGlyphHAdvance(glyph);
}
@ -255,7 +255,7 @@ gfxHarfBuzzShaper::HBGetGlyphVAdvance(hb_font_t *font, void *font_data,
static_cast<const gfxHarfBuzzShaper::FontCallbackData*>(font_data);
gfxFont *gfxfont = fcd->mShaper->GetFont();
if (gfxfont->ProvidesGlyphWidths()) {
return gfxfont->GetGlyphWidth(fcd->mContext, glyph);
return gfxfont->GetGlyphWidth(*fcd->mContext->GetDrawTarget(), glyph);
}
return fcd->mShaper->GetGlyphVAdvance(glyph);
}