/src/mozilla-central/gfx/2d/ScaledFontBase.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* vim: set ts=8 sts=2 et sw=2 tw=80: */ |
3 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
4 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
5 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | #ifndef MOZILLA_GFX_SCALEDFONTBASE_H_ |
8 | | #define MOZILLA_GFX_SCALEDFONTBASE_H_ |
9 | | |
10 | | #include "2D.h" |
11 | | |
12 | | // Skia uses cairo_scaled_font_t as the internal font type in ScaledFont |
13 | | #if defined(USE_SKIA) || defined(USE_CAIRO) |
14 | | #define USE_CAIRO_SCALED_FONT |
15 | | #endif |
16 | | |
17 | | #ifdef USE_SKIA |
18 | | #include "skia/include/core/SkPath.h" |
19 | | #include "skia/include/core/SkTypeface.h" |
20 | | #endif |
21 | | #ifdef USE_CAIRO_SCALED_FONT |
22 | | #include "cairo.h" |
23 | | #endif |
24 | | |
25 | | namespace mozilla { |
26 | | namespace gfx { |
27 | | |
28 | | class ScaledFontBase : public ScaledFont |
29 | | { |
30 | | public: |
31 | | MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(ScaledFontBase, override) |
32 | | |
33 | | ScaledFontBase(const RefPtr<UnscaledFont>& aUnscaledFont, Float aSize); |
34 | | virtual ~ScaledFontBase(); |
35 | | |
36 | | virtual already_AddRefed<Path> GetPathForGlyphs(const GlyphBuffer &aBuffer, const DrawTarget *aTarget) override; |
37 | | |
38 | | virtual void CopyGlyphsToBuilder(const GlyphBuffer &aBuffer, PathBuilder *aBuilder, const Matrix *aTransformHint) override; |
39 | | |
40 | | virtual void GetGlyphDesignMetrics(const uint16_t* aGlyphIndices, uint32_t aNumGlyphs, GlyphMetrics* aGlyphMetrics) override; |
41 | | |
42 | 0 | virtual Float GetSize() const override { return mSize; } |
43 | | |
44 | | #ifdef USE_SKIA |
45 | | SkTypeface* GetSkTypeface(); |
46 | | #endif |
47 | | |
48 | | #ifdef USE_CAIRO_SCALED_FONT |
49 | | bool PopulateCairoScaledFont(); |
50 | 0 | virtual cairo_scaled_font_t* GetCairoScaledFont() override { return mScaledFont; } |
51 | | virtual void SetCairoScaledFont(cairo_scaled_font_t* font) override; |
52 | | #endif |
53 | | |
54 | | protected: |
55 | | friend class DrawTargetSkia; |
56 | | #ifdef USE_SKIA |
57 | | Atomic<SkTypeface*> mTypeface; |
58 | 0 | virtual SkTypeface* CreateSkTypeface() { return nullptr; } |
59 | | SkPath GetSkiaPathForGlyphs(const GlyphBuffer &aBuffer); |
60 | | #endif |
61 | | #ifdef USE_CAIRO_SCALED_FONT |
62 | | // Overridders should ensure the cairo_font_face_t has been addrefed. |
63 | 0 | virtual cairo_font_face_t* GetCairoFontFace() { return nullptr; } |
64 | | cairo_scaled_font_t* mScaledFont; |
65 | | #endif |
66 | | Float mSize; |
67 | | }; |
68 | | |
69 | | } // namespace gfx |
70 | | } // namespace mozilla |
71 | | |
72 | | #endif /* MOZILLA_GFX_SCALEDFONTBASE_H_ */ |