Bug 1866777 - Disable test_race_cache_with_network.js on windows opt for frequent...
[gecko.git] / gfx / 2d / ScaledFontFontconfig.h
blobe6dfd480977e4b6be697c4c7ca6d03e794f0de39
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_SCALEDFONTFONTCONFIG_H_
8 #define MOZILLA_GFX_SCALEDFONTFONTCONFIG_H_
10 #include "ScaledFontBase.h"
12 #include <cairo-ft.h>
14 namespace mozilla {
15 namespace gfx {
17 class NativeFontResourceFontconfig;
18 class UnscaledFontFontconfig;
20 class ScaledFontFontconfig : public ScaledFontBase {
21 public:
22 MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(ScaledFontFontconfig, override)
23 ScaledFontFontconfig(RefPtr<SharedFTFace>&& aFace, FcPattern* aPattern,
24 const RefPtr<UnscaledFont>& aUnscaledFont, Float aSize);
26 FontType GetType() const override { return FontType::FONTCONFIG; }
28 SkTypeface* CreateSkTypeface() override;
29 void SetupSkFontDrawOptions(SkFont& aFont) override;
31 AntialiasMode GetDefaultAAMode() override;
33 bool UseSubpixelPosition() const override;
35 bool CanSerialize() override { return true; }
37 bool MayUseBitmaps() override;
39 bool GetFontInstanceData(FontInstanceDataOutput aCb, void* aBaton) override;
41 bool GetWRFontInstanceOptions(
42 Maybe<wr::FontInstanceOptions>* aOutOptions,
43 Maybe<wr::FontInstancePlatformOptions>* aOutPlatformOptions,
44 std::vector<FontVariation>* aOutVariations) override;
46 bool HasVariationSettings() override;
48 protected:
49 cairo_font_face_t* CreateCairoFontFace(
50 cairo_font_options_t* aFontOptions) override;
52 private:
53 friend class NativeFontResourceFontconfig;
54 friend class UnscaledFontFontconfig;
56 struct InstanceData {
57 enum {
58 AUTOHINT = 1 << 0,
59 EMBEDDED_BITMAP = 1 << 1,
60 EMBOLDEN = 1 << 2,
61 HINT_METRICS = 1 << 3,
62 LCD_VERTICAL = 1 << 4,
63 SUBPIXEL_BGR = 1 << 5,
66 explicit InstanceData(FcPattern* aPattern);
67 InstanceData(const wr::FontInstanceOptions* aOptions,
68 const wr::FontInstancePlatformOptions* aPlatformOptions);
70 void SetupFontOptions(cairo_font_options_t* aFontOptions,
71 int* aOutLoadFlags,
72 unsigned int* aOutSynthFlags) const;
74 uint8_t mFlags;
75 AntialiasMode mAntialias;
76 FontHinting mHinting;
77 uint8_t mLcdFilter;
80 ScaledFontFontconfig(RefPtr<SharedFTFace>&& aFace,
81 const InstanceData& aInstanceData,
82 const RefPtr<UnscaledFont>& aUnscaledFont, Float aSize);
84 RefPtr<SharedFTFace> mFace;
85 InstanceData mInstanceData;
88 } // namespace gfx
89 } // namespace mozilla
91 #endif /* MOZILLA_GFX_SCALEDFONTFONTCONFIG_H_ */