Bug 780392; Make ScaledFontDWrite inherit from ScaledFontBase. r=bas

--HG--
extra : rebase_source : 83ffee7d64f1ecdfa15b8cf96024c27fdf00c29b
This commit is contained in:
Nicholas Cameron 2012-08-09 08:17:04 +12:00
parent e36380e0c6
commit ebac508850
6 changed files with 24 additions and 16 deletions

View File

@ -355,10 +355,7 @@ DrawTargetCairo::DrawSurface(SourceSurface *aSurface,
cairo_push_group(mContext);
cairo_new_path(mContext);
cairo_rectangle(mContext, 0, 0, aDest.Width(), aDest.Height());
//TODO[nrc] remove comments if test ok
//cairo_clip(mContext);
cairo_set_source(mContext, pat);
//cairo_paint(mContext);
cairo_fill(mContext);
cairo_pop_group_to_source(mContext);
} else {
@ -449,10 +446,7 @@ DrawTargetCairo::DrawSurfaceWithShadow(SourceSurface *aSurface,
cairo_push_group(mContext);
cairo_new_path(mContext);
cairo_rectangle(mContext, 0, 0, width, height);
//TODO[nrc] remove comments if test ok
//cairo_clip(mContext);
cairo_set_source(mContext, pat);
//cairo_paint(mContext);
cairo_fill(mContext);
cairo_pop_group_to_source(mContext);
} else {

View File

@ -1803,7 +1803,7 @@ DrawTargetD2D::FillGlyphsManual(ScaledFontDWrite *aFont,
DWRITE_RENDERING_MODE renderMode = DWRITE_RENDERING_MODE_DEFAULT;
if (params) {
hr = aFont->mFontFace->GetRecommendedRenderingMode(
(FLOAT)aFont->mSize,
(FLOAT)aFont->GetSize(),
1.0f,
DWRITE_MEASURING_MODE_NATURAL,
params,
@ -1822,7 +1822,7 @@ DrawTargetD2D::FillGlyphsManual(ScaledFontDWrite *aFont,
case DWRITE_RENDERING_MODE_DEFAULT:
// As per DWRITE_RENDERING_MODE documentation, pick Natural for font
// sizes under 16 ppem
if (aFont->mSize < 16.0f) {
if (aFont->GetSize() < 16.0f) {
renderMode = DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL;
} else {
renderMode = DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL_SYMMETRIC;

View File

@ -242,7 +242,7 @@ DWriteGlyphRunFromGlyphs(const GlyphBuffer &aGlyphs, ScaledFontDWrite *aFont, Au
run->bidiLevel = 0;
run->fontFace = aFont->mFontFace;
run->fontEmSize = aFont->mSize;
run->fontEmSize = aFont->GetSize();
run->glyphCount = aGlyphs.mNumGlyphs;
run->isSideways = FALSE;
}

View File

@ -30,6 +30,8 @@ public:
virtual void CopyGlyphsToBuilder(const GlyphBuffer &aBuffer, PathBuilder *aBuilder);
float GetSize() { return mSize; }
#ifdef USE_SKIA
virtual SkTypeface* GetSkTypeface() { return mTypeface; }
#endif

View File

@ -6,20 +6,20 @@
#ifndef MOZILLA_GFX_SCALEDFONTDWRITE_H_
#define MOZILLA_GFX_SCALEDFONTDWRITE_H_
#include "2D.h"
#include <dwrite.h>
#include "ScaledFontBase.h"
struct ID2D1GeometrySink;
namespace mozilla {
namespace gfx {
class ScaledFontDWrite : public ScaledFont
class ScaledFontDWrite : public ScaledFontBase
{
public:
ScaledFontDWrite(IDWriteFontFace *aFont, Float aSize)
: mFontFace(aFont)
, mSize(aSize)
, ScaledFontBase(aSize)
{}
virtual FontType GetType() const { return FONT_DWRITE; }
@ -29,8 +29,15 @@ public:
void CopyGlyphsToSink(const GlyphBuffer &aBuffer, ID2D1GeometrySink *aSink);
#ifdef USE_SKIA
virtual SkTypeface* GetSkTypeface()
{
MOZ_ASSERT(false, "Skia and DirectWrite do not mix");
return nullptr;
}
#endif
RefPtr<IDWriteFontFace> mFontFace;
Float mSize;
};
class GlyphRenderingOptionsDWrite : public GlyphRenderingOptions

View File

@ -779,10 +779,15 @@ gfxWindowsPlatform::GetScaledFontForFont(DrawTarget* aTarget, gfxFont *aFont)
NativeFont nativeFont;
nativeFont.mType = NATIVE_FONT_DWRITE_FONT_FACE;
nativeFont.mFont = font->GetFontFace();
RefPtr<ScaledFont> scaledFont =
mozilla::gfx::Factory::CreateScaledFontForNativeFont(nativeFont, font->GetAdjustedSize());
return scaledFont;
if (aTarget->GetType() == BACKEND_CAIRO) {
return Factory::CreateScaledFontWithCairo(nativeFont,
font->GetAdjustedSize(),
font->GetCairoScaledFont());
}
return Factory::CreateScaledFontForNativeFont(nativeFont,
font->GetAdjustedSize());
}
NS_ASSERTION(aFont->GetType() == gfxFont::FONT_TYPE_GDI,