Backed out 2 changesets (bug 1855992) for causing talos failures @ mozilla::net:...
[gecko.git] / gfx / 2d / ScaledFontBase.h
blob0eb875955eb04f2c2daa6b6e381eac9c605023f9
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/. */
7 #ifndef MOZILLA_GFX_SCALEDFONTBASE_H_
8 #define MOZILLA_GFX_SCALEDFONTBASE_H_
10 #include "2D.h"
12 #include "skia/include/core/SkFont.h"
13 #include "skia/include/core/SkPath.h"
14 #include "skia/include/core/SkTypeface.h"
15 // Skia uses cairo_scaled_font_t as the internal font type in ScaledFont
16 #include "cairo.h"
18 namespace mozilla {
19 namespace gfx {
21 class ScaledFontBase : public ScaledFont {
22 public:
23 MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(ScaledFontBase, override)
25 ScaledFontBase(const RefPtr<UnscaledFont>& aUnscaledFont, Float aSize);
26 virtual ~ScaledFontBase();
28 virtual already_AddRefed<Path> GetPathForGlyphs(
29 const GlyphBuffer& aBuffer, const DrawTarget* aTarget) override;
31 virtual void CopyGlyphsToBuilder(const GlyphBuffer& aBuffer,
32 PathBuilder* aBuilder,
33 const Matrix* aTransformHint) override;
35 virtual Float GetSize() const override { return mSize; }
37 SkTypeface* GetSkTypeface();
38 virtual void SetupSkFontDrawOptions(SkFont& aFont) {}
40 virtual cairo_scaled_font_t* GetCairoScaledFont() override;
42 protected:
43 friend class DrawTargetSkia;
44 Atomic<SkTypeface*> mTypeface;
45 virtual SkTypeface* CreateSkTypeface() { return nullptr; }
46 SkPath GetSkiaPathForGlyphs(const GlyphBuffer& aBuffer);
47 virtual cairo_font_face_t* CreateCairoFontFace(
48 cairo_font_options_t* aFontOptions) {
49 return nullptr;
51 virtual void PrepareCairoScaledFont(cairo_scaled_font_t* aFont) {}
52 cairo_scaled_font_t* mScaledFont;
53 Float mSize;
56 } // namespace gfx
57 } // namespace mozilla
59 #endif /* MOZILLA_GFX_SCALEDFONTBASE_H_ */