|
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 |
|
13 #if (MOZ_WIDGET_GTK == 2) |
|
14 extern "C" { |
|
15 typedef struct _GdkDrawable GdkDrawable; |
|
16 } |
|
17 #endif |
|
18 |
|
19 class gfxFontconfigUtils; |
|
20 |
|
21 class gfxPlatformGtk : public gfxPlatform { |
|
22 public: |
|
23 gfxPlatformGtk(); |
|
24 virtual ~gfxPlatformGtk(); |
|
25 |
|
26 static gfxPlatformGtk *GetPlatform() { |
|
27 return (gfxPlatformGtk*) gfxPlatform::GetPlatform(); |
|
28 } |
|
29 |
|
30 virtual already_AddRefed<gfxASurface> |
|
31 CreateOffscreenSurface(const IntSize& size, |
|
32 gfxContentType contentType) MOZ_OVERRIDE; |
|
33 |
|
34 mozilla::TemporaryRef<mozilla::gfx::ScaledFont> |
|
35 GetScaledFontForFont(mozilla::gfx::DrawTarget* aTarget, gfxFont *aFont); |
|
36 |
|
37 nsresult GetFontList(nsIAtom *aLangGroup, |
|
38 const nsACString& aGenericFamily, |
|
39 nsTArray<nsString>& aListOfFonts); |
|
40 |
|
41 nsresult UpdateFontList(); |
|
42 |
|
43 nsresult ResolveFontName(const nsAString& aFontName, |
|
44 FontResolverCallback aCallback, |
|
45 void *aClosure, bool& aAborted); |
|
46 |
|
47 nsresult GetStandardFamilyName(const nsAString& aFontName, nsAString& aFamilyName); |
|
48 |
|
49 gfxFontGroup *CreateFontGroup(const nsAString &aFamilies, |
|
50 const gfxFontStyle *aStyle, |
|
51 gfxUserFontSet *aUserFontSet); |
|
52 |
|
53 /** |
|
54 * Look up a local platform font using the full font face name (needed to |
|
55 * support @font-face src local() ) |
|
56 */ |
|
57 virtual gfxFontEntry* LookupLocalFont(const gfxProxyFontEntry *aProxyEntry, |
|
58 const nsAString& aFontName); |
|
59 |
|
60 /** |
|
61 * Activate a platform font (needed to support @font-face src url() ) |
|
62 * |
|
63 */ |
|
64 virtual gfxFontEntry* MakePlatformFont(const gfxProxyFontEntry *aProxyEntry, |
|
65 const uint8_t *aFontData, |
|
66 uint32_t aLength); |
|
67 |
|
68 /** |
|
69 * Check whether format is supported on a platform or not (if unclear, |
|
70 * returns true). |
|
71 */ |
|
72 virtual bool IsFontFormatSupported(nsIURI *aFontURI, |
|
73 uint32_t aFormatFlags); |
|
74 |
|
75 #if (MOZ_WIDGET_GTK == 2) |
|
76 static void SetGdkDrawable(cairo_surface_t *target, |
|
77 GdkDrawable *drawable); |
|
78 static GdkDrawable *GetGdkDrawable(cairo_surface_t *target); |
|
79 #endif |
|
80 |
|
81 static int32_t GetDPI(); |
|
82 |
|
83 bool UseXRender() { |
|
84 #if defined(MOZ_X11) |
|
85 if (GetContentBackend() != mozilla::gfx::BackendType::NONE && |
|
86 GetContentBackend() != mozilla::gfx::BackendType::CAIRO) |
|
87 return false; |
|
88 |
|
89 return sUseXRender; |
|
90 #else |
|
91 return false; |
|
92 #endif |
|
93 } |
|
94 |
|
95 virtual gfxImageFormat GetOffscreenFormat(); |
|
96 |
|
97 virtual int GetScreenDepth() const; |
|
98 |
|
99 protected: |
|
100 static gfxFontconfigUtils *sFontconfigUtils; |
|
101 |
|
102 private: |
|
103 virtual void GetPlatformCMSOutputProfile(void *&mem, size_t &size); |
|
104 |
|
105 virtual bool SupportsOffMainThreadCompositing(); |
|
106 #ifdef MOZ_X11 |
|
107 static bool sUseXRender; |
|
108 #endif |
|
109 }; |
|
110 |
|
111 #endif /* GFX_PLATFORM_GTK_H */ |