|
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/. */ |
|
5 |
|
6 #ifndef MOZILLA_GFX_SCALEDFONTBASE_H_ |
|
7 #define MOZILLA_GFX_SCALEDFONTBASE_H_ |
|
8 |
|
9 #include "2D.h" |
|
10 |
|
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 |
|
15 |
|
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 |
|
23 |
|
24 class gfxFont; |
|
25 |
|
26 namespace mozilla { |
|
27 namespace gfx { |
|
28 |
|
29 class ScaledFontBase : public ScaledFont |
|
30 { |
|
31 public: |
|
32 MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(ScaledFontBase) |
|
33 ScaledFontBase(Float aSize); |
|
34 virtual ~ScaledFontBase(); |
|
35 |
|
36 virtual TemporaryRef<Path> GetPathForGlyphs(const GlyphBuffer &aBuffer, const DrawTarget *aTarget); |
|
37 |
|
38 virtual void CopyGlyphsToBuilder(const GlyphBuffer &aBuffer, PathBuilder *aBuilder, BackendType aBackendType, const Matrix *aTransformHint); |
|
39 |
|
40 float GetSize() { return mSize; } |
|
41 |
|
42 #ifdef USE_SKIA |
|
43 virtual SkTypeface* GetSkTypeface() { return mTypeface; } |
|
44 #endif |
|
45 |
|
46 // Not true, but required to instantiate a ScaledFontBase. |
|
47 virtual FontType GetType() const { return FontType::SKIA; } |
|
48 |
|
49 #ifdef USE_CAIRO_SCALED_FONT |
|
50 cairo_scaled_font_t* GetCairoScaledFont() { return mScaledFont; } |
|
51 void SetCairoScaledFont(cairo_scaled_font_t* font); |
|
52 #endif |
|
53 |
|
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; |
|
64 }; |
|
65 |
|
66 } |
|
67 } |
|
68 |
|
69 #endif /* MOZILLA_GFX_SCALEDFONTBASE_H_ */ |