Bumping manifests a=b2g-bump
[gecko.git] / gfx / 2d / ScaledFontBase.h
blob93f4441be3aca096da3283b8f71f23ee458e0657
1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef MOZILLA_GFX_SCALEDFONTBASE_H_
7 #define MOZILLA_GFX_SCALEDFONTBASE_H_
9 #include "2D.h"
11 // Skia uses cairo_scaled_font_t as the internal font type in ScaledFont
12 #if defined(USE_SKIA) || defined(USE_CAIRO)
13 #define USE_CAIRO_SCALED_FONT
14 #endif
16 #ifdef USE_SKIA
17 #include "skia/SkPath.h"
18 #include "skia/SkTypeface.h"
19 #endif
20 #ifdef USE_CAIRO_SCALED_FONT
21 #include "cairo.h"
22 #endif
24 class gfxFont;
26 namespace mozilla {
27 namespace gfx {
29 class ScaledFontBase : public ScaledFont
31 public:
32 MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(ScaledFontBase)
33 explicit ScaledFontBase(Float aSize);
34 virtual ~ScaledFontBase();
36 virtual TemporaryRef<Path> GetPathForGlyphs(const GlyphBuffer &aBuffer, const DrawTarget *aTarget);
38 virtual void CopyGlyphsToBuilder(const GlyphBuffer &aBuffer, PathBuilder *aBuilder, BackendType aBackendType, const Matrix *aTransformHint);
40 float GetSize() { return mSize; }
42 #ifdef USE_SKIA
43 virtual SkTypeface* GetSkTypeface() { return mTypeface; }
44 #endif
46 // Not true, but required to instantiate a ScaledFontBase.
47 virtual FontType GetType() const { return FontType::SKIA; }
49 #ifdef USE_CAIRO_SCALED_FONT
50 cairo_scaled_font_t* GetCairoScaledFont() { return mScaledFont; }
51 void SetCairoScaledFont(cairo_scaled_font_t* font);
52 #endif
54 protected:
55 friend class DrawTargetSkia;
56 #ifdef USE_SKIA
57 SkTypeface* mTypeface;
58 SkPath GetSkiaPathForGlyphs(const GlyphBuffer &aBuffer);
59 #endif
60 #ifdef USE_CAIRO_SCALED_FONT
61 cairo_scaled_font_t* mScaledFont;
62 #endif
63 Float mSize;
69 #endif /* MOZILLA_GFX_SCALEDFONTBASE_H_ */