michael@0: /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef MOZILLA_GFX_SCALEDFONTBASE_H_ michael@0: #define MOZILLA_GFX_SCALEDFONTBASE_H_ michael@0: michael@0: #include "2D.h" michael@0: michael@0: // Skia uses cairo_scaled_font_t as the internal font type in ScaledFont michael@0: #if defined(USE_SKIA) || defined(USE_CAIRO) michael@0: #define USE_CAIRO_SCALED_FONT michael@0: #endif michael@0: michael@0: #ifdef USE_SKIA michael@0: #include "skia/SkPath.h" michael@0: #include "skia/SkTypeface.h" michael@0: #endif michael@0: #ifdef USE_CAIRO_SCALED_FONT michael@0: #include "cairo.h" michael@0: #endif michael@0: michael@0: class gfxFont; michael@0: michael@0: namespace mozilla { michael@0: namespace gfx { michael@0: michael@0: class ScaledFontBase : public ScaledFont michael@0: { michael@0: public: michael@0: MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(ScaledFontBase) michael@0: ScaledFontBase(Float aSize); michael@0: virtual ~ScaledFontBase(); michael@0: michael@0: virtual TemporaryRef GetPathForGlyphs(const GlyphBuffer &aBuffer, const DrawTarget *aTarget); michael@0: michael@0: virtual void CopyGlyphsToBuilder(const GlyphBuffer &aBuffer, PathBuilder *aBuilder, BackendType aBackendType, const Matrix *aTransformHint); michael@0: michael@0: float GetSize() { return mSize; } michael@0: michael@0: #ifdef USE_SKIA michael@0: virtual SkTypeface* GetSkTypeface() { return mTypeface; } michael@0: #endif michael@0: michael@0: // Not true, but required to instantiate a ScaledFontBase. michael@0: virtual FontType GetType() const { return FontType::SKIA; } michael@0: michael@0: #ifdef USE_CAIRO_SCALED_FONT michael@0: cairo_scaled_font_t* GetCairoScaledFont() { return mScaledFont; } michael@0: void SetCairoScaledFont(cairo_scaled_font_t* font); michael@0: #endif michael@0: michael@0: protected: michael@0: friend class DrawTargetSkia; michael@0: #ifdef USE_SKIA michael@0: SkTypeface* mTypeface; michael@0: SkPath GetSkiaPathForGlyphs(const GlyphBuffer &aBuffer); michael@0: #endif michael@0: #ifdef USE_CAIRO_SCALED_FONT michael@0: cairo_scaled_font_t* mScaledFont; michael@0: #endif michael@0: Float mSize; michael@0: }; michael@0: michael@0: } michael@0: } michael@0: michael@0: #endif /* MOZILLA_GFX_SCALEDFONTBASE_H_ */