Line data Source code
1 : /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
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 GFX_PLATFORM_GTK_H
7 : #define GFX_PLATFORM_GTK_H
8 :
9 : #include "gfxPlatform.h"
10 : #include "nsAutoRef.h"
11 : #include "nsTArray.h"
12 : #include "mozilla/gfx/gfxVars.h"
13 :
14 : #if (MOZ_WIDGET_GTK == 2)
15 : extern "C" {
16 : typedef struct _GdkDrawable GdkDrawable;
17 : }
18 : #endif
19 :
20 : #ifdef MOZ_X11
21 : struct _XDisplay;
22 : typedef struct _XDisplay Display;
23 : #endif // MOZ_X11
24 :
25 : class gfxFontconfigUtils;
26 :
27 : class gfxPlatformGtk : public gfxPlatform {
28 : public:
29 : gfxPlatformGtk();
30 : virtual ~gfxPlatformGtk();
31 :
32 27 : static gfxPlatformGtk *GetPlatform() {
33 27 : return (gfxPlatformGtk*) gfxPlatform::GetPlatform();
34 : }
35 :
36 : virtual already_AddRefed<gfxASurface>
37 : CreateOffscreenSurface(const IntSize& aSize,
38 : gfxImageFormat aFormat) override;
39 :
40 : virtual already_AddRefed<mozilla::gfx::ScaledFont>
41 : GetScaledFontForFont(mozilla::gfx::DrawTarget* aTarget, gfxFont *aFont) override;
42 :
43 : virtual nsresult GetFontList(nsIAtom *aLangGroup,
44 : const nsACString& aGenericFamily,
45 : nsTArray<nsString>& aListOfFonts) override;
46 :
47 : virtual nsresult UpdateFontList() override;
48 :
49 : virtual void
50 : GetCommonFallbackFonts(uint32_t aCh, uint32_t aNextCh,
51 : Script aRunScript,
52 : nsTArray<const char*>& aFontList) override;
53 :
54 : virtual gfxPlatformFontList* CreatePlatformFontList() override;
55 :
56 : virtual nsresult GetStandardFamilyName(const nsAString& aFontName,
57 : nsAString& aFamilyName) override;
58 :
59 : gfxFontGroup*
60 : CreateFontGroup(const mozilla::FontFamilyList& aFontFamilyList,
61 : const gfxFontStyle *aStyle,
62 : gfxTextPerfMetrics* aTextPerf,
63 : gfxUserFontSet *aUserFontSet,
64 : gfxFloat aDevToCssSize) override;
65 :
66 : /**
67 : * Look up a local platform font using the full font face name (needed to
68 : * support @font-face src local() )
69 : */
70 : virtual gfxFontEntry* LookupLocalFont(const nsAString& aFontName,
71 : uint16_t aWeight,
72 : int16_t aStretch,
73 : uint8_t aStyle) override;
74 :
75 : /**
76 : * Activate a platform font (needed to support @font-face src url() )
77 : *
78 : */
79 : virtual gfxFontEntry* MakePlatformFont(const nsAString& aFontName,
80 : uint16_t aWeight,
81 : int16_t aStretch,
82 : uint8_t aStyle,
83 : const uint8_t* aFontData,
84 : uint32_t aLength) override;
85 :
86 : /**
87 : * Check whether format is supported on a platform or not (if unclear,
88 : * returns true).
89 : */
90 : virtual bool IsFontFormatSupported(uint32_t aFormatFlags) override;
91 :
92 : /**
93 : * Calls XFlush if xrender is enabled.
94 : */
95 : virtual void FlushContentDrawing() override;
96 :
97 : FT_Library GetFTLibrary() override;
98 :
99 : #if (MOZ_WIDGET_GTK == 2)
100 : static void SetGdkDrawable(cairo_surface_t *target,
101 : GdkDrawable *drawable);
102 : static GdkDrawable *GetGdkDrawable(cairo_surface_t *target);
103 : #endif
104 :
105 : static int32_t GetDPI();
106 : static double GetDPIScale();
107 :
108 : #ifdef MOZ_X11
109 0 : virtual void GetAzureBackendInfo(mozilla::widget::InfoObject &aObj) override {
110 0 : gfxPlatform::GetAzureBackendInfo(aObj);
111 0 : aObj.DefineProperty("CairoUseXRender", mozilla::gfx::gfxVars::UseXRender());
112 0 : }
113 : #endif
114 :
115 : bool UseImageOffscreenSurfaces();
116 :
117 : virtual gfxImageFormat GetOffscreenFormat() override;
118 :
119 0 : bool SupportsApzWheelInput() const override {
120 0 : return true;
121 : }
122 :
123 : void FontsPrefsChanged(const char *aPref) override;
124 :
125 : // maximum number of fonts to substitute for a generic
126 : uint32_t MaxGenericSubstitions();
127 :
128 0 : bool SupportsPluginDirectBitmapDrawing() override {
129 0 : return true;
130 : }
131 :
132 3 : bool AccelerateLayersByDefault() override {
133 3 : return false;
134 : }
135 :
136 : #ifdef GL_PROVIDER_GLX
137 : already_AddRefed<mozilla::gfx::VsyncSource> CreateHardwareVsyncSource() override;
138 : #endif
139 :
140 : #ifdef MOZ_X11
141 0 : Display* GetCompositorDisplay() {
142 0 : return mCompositorDisplay;
143 : }
144 : #endif // MOZ_X11
145 :
146 : protected:
147 : static gfxFontconfigUtils *sFontconfigUtils;
148 :
149 : int8_t mMaxGenericSubstitutions;
150 :
151 : private:
152 : virtual void GetPlatformCMSOutputProfile(void *&mem,
153 : size_t &size) override;
154 :
155 : #ifdef MOZ_X11
156 : Display* mCompositorDisplay;
157 : #endif
158 : };
159 :
160 : #endif /* GFX_PLATFORM_GTK_H */
|