1 : /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 : * ***** BEGIN LICENSE BLOCK *****
3 : * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 : *
5 : * The contents of this file are subject to the Mozilla Public License Version
6 : * 1.1 (the "License"); you may not use this file except in compliance with
7 : * the License. You may obtain a copy of the License at
8 : * http://www.mozilla.org/MPL/
9 : *
10 : * Software distributed under the License is distributed on an "AS IS" basis,
11 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 : * for the specific language governing rights and limitations under the
13 : * License.
14 : *
15 : * The Original Code is Mozilla Foundation code.
16 : *
17 : * The Initial Developer of the Original Code is Mozilla Foundation.
18 : * Portions created by the Initial Developer are Copyright (C) 2005
19 : * the Initial Developer. All Rights Reserved.
20 : *
21 : * Contributor(s):
22 : * Vladimir Vukicevic <vladimir@pobox.com>
23 : * Masayuki Nakano <masayuki@d-toybox.com>
24 : *
25 : * Alternatively, the contents of this file may be used under the terms of
26 : * either the GNU General Public License Version 2 or later (the "GPL"), or
27 : * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 : * in which case the provisions of the GPL or the LGPL are applicable instead
29 : * of those above. If you wish to allow use of your version of this file only
30 : * under the terms of either the GPL or the LGPL, and not to allow others to
31 : * use your version of this file under the terms of the MPL, indicate your
32 : * decision by deleting the provisions above and replace them with the notice
33 : * and other provisions required by the GPL or the LGPL. If you do not delete
34 : * the provisions above, a recipient may use your version of this file under
35 : * the terms of any one of the MPL, the GPL or the LGPL.
36 : *
37 : * ***** END LICENSE BLOCK ***** */
38 :
39 : #ifndef GFX_PLATFORM_GTK_H
40 : #define GFX_PLATFORM_GTK_H
41 :
42 : #include "gfxPlatform.h"
43 : #include "nsAutoRef.h"
44 : #include "nsTArray.h"
45 :
46 : extern "C" {
47 : typedef struct _GdkDrawable GdkDrawable;
48 : }
49 :
50 : class gfxFontconfigUtils;
51 : #ifndef MOZ_PANGO
52 : class FontFamily;
53 : class FontEntry;
54 : typedef struct FT_LibraryRec_ *FT_Library;
55 : #endif
56 :
57 : class THEBES_API gfxPlatformGtk : public gfxPlatform {
58 : public:
59 : gfxPlatformGtk();
60 : virtual ~gfxPlatformGtk();
61 :
62 : static gfxPlatformGtk *GetPlatform() {
63 : return (gfxPlatformGtk*) gfxPlatform::GetPlatform();
64 : }
65 :
66 : already_AddRefed<gfxASurface> CreateOffscreenSurface(const gfxIntSize& size,
67 : gfxASurface::gfxContentType contentType);
68 :
69 : mozilla::RefPtr<mozilla::gfx::ScaledFont>
70 : GetScaledFontForFont(gfxFont *aFont);
71 :
72 : virtual bool SupportsAzure(mozilla::gfx::BackendType& aBackend);
73 :
74 : nsresult GetFontList(nsIAtom *aLangGroup,
75 : const nsACString& aGenericFamily,
76 : nsTArray<nsString>& aListOfFonts);
77 :
78 : nsresult UpdateFontList();
79 :
80 : nsresult ResolveFontName(const nsAString& aFontName,
81 : FontResolverCallback aCallback,
82 : void *aClosure, bool& aAborted);
83 :
84 : nsresult GetStandardFamilyName(const nsAString& aFontName, nsAString& aFamilyName);
85 :
86 : gfxFontGroup *CreateFontGroup(const nsAString &aFamilies,
87 : const gfxFontStyle *aStyle,
88 : gfxUserFontSet *aUserFontSet);
89 :
90 : #ifdef MOZ_PANGO
91 : /**
92 : * Look up a local platform font using the full font face name (needed to
93 : * support @font-face src local() )
94 : */
95 : virtual gfxFontEntry* LookupLocalFont(const gfxProxyFontEntry *aProxyEntry,
96 : const nsAString& aFontName);
97 :
98 : /**
99 : * Activate a platform font (needed to support @font-face src url() )
100 : *
101 : */
102 : virtual gfxFontEntry* MakePlatformFont(const gfxProxyFontEntry *aProxyEntry,
103 : const PRUint8 *aFontData,
104 : PRUint32 aLength);
105 :
106 : /**
107 : * Check whether format is supported on a platform or not (if unclear,
108 : * returns true).
109 : */
110 : virtual bool IsFontFormatSupported(nsIURI *aFontURI,
111 : PRUint32 aFormatFlags);
112 : #endif
113 :
114 : #ifndef MOZ_PANGO
115 : FontFamily *FindFontFamily(const nsAString& aName);
116 : FontEntry *FindFontEntry(const nsAString& aFamilyName, const gfxFontStyle& aFontStyle);
117 : already_AddRefed<gfxFont> FindFontForChar(PRUint32 aCh, gfxFont *aFont);
118 : bool GetPrefFontEntries(const nsCString& aLangGroup, nsTArray<nsRefPtr<gfxFontEntry> > *aFontEntryList);
119 : void SetPrefFontEntries(const nsCString& aLangGroup, nsTArray<nsRefPtr<gfxFontEntry> >& aFontEntryList);
120 : #endif
121 :
122 : #ifndef MOZ_PANGO
123 : FT_Library GetFTLibrary();
124 : #endif
125 :
126 : static void SetGdkDrawable(gfxASurface *target,
127 : GdkDrawable *drawable);
128 : static GdkDrawable *GetGdkDrawable(gfxASurface *target);
129 :
130 : static PRInt32 GetDPI();
131 :
132 0 : static bool UseClientSideRendering() {
133 : #if defined(MOZ_X11) && defined(MOZ_PLATFORM_MAEMO)
134 : // XRender is not accelerated on the Maemo at the moment, and
135 : // X server pixman is out of our control; it's likely to be
136 : // older than (our) cairo's. So fall back on software
137 : // rendering for more predictable performance.
138 : // This setting will likely not be relevant when we have
139 : // GL-accelerated compositing. We know of other platforms
140 : // with bad drivers where we'd like to also use client side
141 : // rendering, but until we have the ability to featuer test
142 : // this, we'll only disable this for maemo.
143 : return true;
144 : #else
145 0 : return false;
146 : #endif
147 : }
148 :
149 : virtual gfxImageFormat GetOffscreenFormat();
150 :
151 : protected:
152 : static gfxFontconfigUtils *sFontconfigUtils;
153 :
154 : private:
155 : virtual qcms_profile *GetPlatformCMSOutputProfile();
156 : };
157 :
158 : #endif /* GFX_PLATFORM_GTK_H */
|