|
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_QT_H |
|
7 #define GFX_PLATFORM_QT_H |
|
8 |
|
9 #include "gfxPlatform.h" |
|
10 #include "nsAutoRef.h" |
|
11 #include "nsDataHashtable.h" |
|
12 #include "nsTArray.h" |
|
13 #ifdef MOZ_X11 |
|
14 #include "X11/Xlib.h" |
|
15 #endif |
|
16 |
|
17 class gfxImageSurface; |
|
18 class gfxFontconfigUtils; |
|
19 class QWindow; |
|
20 |
|
21 class gfxQtPlatform : public gfxPlatform { |
|
22 public: |
|
23 gfxQtPlatform(); |
|
24 virtual ~gfxQtPlatform(); |
|
25 |
|
26 static gfxQtPlatform *GetPlatform() { |
|
27 return static_cast<gfxQtPlatform*>(gfxPlatform::GetPlatform()); |
|
28 } |
|
29 |
|
30 virtual already_AddRefed<gfxASurface> |
|
31 OptimizeImage(gfxImageSurface *aSurface, |
|
32 gfxImageFormat format) MOZ_OVERRIDE; |
|
33 virtual already_AddRefed<gfxASurface> |
|
34 CreateOffscreenSurface(const IntSize& size, |
|
35 gfxContentType contentType) MOZ_OVERRIDE; |
|
36 |
|
37 virtual mozilla::TemporaryRef<mozilla::gfx::ScaledFont> |
|
38 GetScaledFontForFont(mozilla::gfx::DrawTarget* aTarget, gfxFont *aFont) MOZ_OVERRIDE; |
|
39 |
|
40 virtual nsresult GetFontList(nsIAtom *aLangGroup, |
|
41 const nsACString& aGenericFamily, |
|
42 nsTArray<nsString>& aListOfFonts) MOZ_OVERRIDE; |
|
43 |
|
44 virtual nsresult UpdateFontList() MOZ_OVERRIDE; |
|
45 |
|
46 virtual nsresult ResolveFontName(const nsAString& aFontName, |
|
47 FontResolverCallback aCallback, |
|
48 void *aClosure, bool& aAborted) MOZ_OVERRIDE; |
|
49 |
|
50 virtual nsresult GetStandardFamilyName(const nsAString& aFontName, nsAString& aFamilyName) MOZ_OVERRIDE; |
|
51 |
|
52 virtual gfxFontGroup *CreateFontGroup(const nsAString &aFamilies, |
|
53 const gfxFontStyle *aStyle, |
|
54 gfxUserFontSet* aUserFontSet) MOZ_OVERRIDE; |
|
55 |
|
56 /** |
|
57 * Look up a local platform font using the full font face name (needed to |
|
58 * support @font-face src local() ) |
|
59 */ |
|
60 virtual gfxFontEntry* LookupLocalFont(const gfxProxyFontEntry *aProxyEntry, |
|
61 const nsAString& aFontName) MOZ_OVERRIDE; |
|
62 |
|
63 /** |
|
64 * Activate a platform font (needed to support @font-face src url() ) |
|
65 * |
|
66 */ |
|
67 virtual gfxFontEntry* MakePlatformFont(const gfxProxyFontEntry *aProxyEntry, |
|
68 const uint8_t *aFontData, |
|
69 uint32_t aLength) MOZ_OVERRIDE; |
|
70 |
|
71 /** |
|
72 * Check whether format is supported on a platform or not (if unclear, |
|
73 * returns true). |
|
74 */ |
|
75 virtual bool IsFontFormatSupported(nsIURI *aFontURI, |
|
76 uint32_t aFormatFlags) MOZ_OVERRIDE; |
|
77 |
|
78 virtual void ClearPrefFonts() { mPrefFonts.Clear(); } |
|
79 |
|
80 static int32_t GetDPI(); |
|
81 |
|
82 virtual gfxImageFormat GetOffscreenFormat() MOZ_OVERRIDE; |
|
83 #ifdef MOZ_X11 |
|
84 static Display* GetXDisplay(QWindow* aWindow = 0); |
|
85 static Screen* GetXScreen(QWindow* aWindow = 0); |
|
86 #endif |
|
87 |
|
88 virtual int GetScreenDepth() const MOZ_OVERRIDE; |
|
89 |
|
90 virtual bool SupportsOffMainThreadCompositing() MOZ_OVERRIDE; |
|
91 |
|
92 protected: |
|
93 static gfxFontconfigUtils *sFontconfigUtils; |
|
94 |
|
95 private: |
|
96 |
|
97 bool UseXRender() { |
|
98 #if defined(MOZ_X11) |
|
99 if (GetContentBackend() != mozilla::gfx::BackendType::NONE && |
|
100 GetContentBackend() != mozilla::gfx::BackendType::CAIRO) |
|
101 return false; |
|
102 |
|
103 return sUseXRender; |
|
104 #else |
|
105 return false; |
|
106 #endif |
|
107 } |
|
108 |
|
109 virtual void GetPlatformCMSOutputProfile(void *&mem, size_t &size) MOZ_OVERRIDE; |
|
110 |
|
111 // TODO: unify this with mPrefFonts (NB: holds families, not fonts) in gfxPlatformFontList |
|
112 nsDataHashtable<nsCStringHashKey, nsTArray<nsRefPtr<gfxFontEntry> > > mPrefFonts; |
|
113 |
|
114 int mScreenDepth; |
|
115 #ifdef MOZ_X11 |
|
116 static bool sUseXRender; |
|
117 #endif |
|
118 }; |
|
119 |
|
120 #endif /* GFX_PLATFORM_QT_H */ |
|
121 |