Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- |
michael@0 | 2 | * This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef GFX_PLATFORM_GTK_H |
michael@0 | 7 | #define GFX_PLATFORM_GTK_H |
michael@0 | 8 | |
michael@0 | 9 | #include "gfxPlatform.h" |
michael@0 | 10 | #include "nsAutoRef.h" |
michael@0 | 11 | #include "nsTArray.h" |
michael@0 | 12 | |
michael@0 | 13 | #if (MOZ_WIDGET_GTK == 2) |
michael@0 | 14 | extern "C" { |
michael@0 | 15 | typedef struct _GdkDrawable GdkDrawable; |
michael@0 | 16 | } |
michael@0 | 17 | #endif |
michael@0 | 18 | |
michael@0 | 19 | class gfxFontconfigUtils; |
michael@0 | 20 | |
michael@0 | 21 | class gfxPlatformGtk : public gfxPlatform { |
michael@0 | 22 | public: |
michael@0 | 23 | gfxPlatformGtk(); |
michael@0 | 24 | virtual ~gfxPlatformGtk(); |
michael@0 | 25 | |
michael@0 | 26 | static gfxPlatformGtk *GetPlatform() { |
michael@0 | 27 | return (gfxPlatformGtk*) gfxPlatform::GetPlatform(); |
michael@0 | 28 | } |
michael@0 | 29 | |
michael@0 | 30 | virtual already_AddRefed<gfxASurface> |
michael@0 | 31 | CreateOffscreenSurface(const IntSize& size, |
michael@0 | 32 | gfxContentType contentType) MOZ_OVERRIDE; |
michael@0 | 33 | |
michael@0 | 34 | mozilla::TemporaryRef<mozilla::gfx::ScaledFont> |
michael@0 | 35 | GetScaledFontForFont(mozilla::gfx::DrawTarget* aTarget, gfxFont *aFont); |
michael@0 | 36 | |
michael@0 | 37 | nsresult GetFontList(nsIAtom *aLangGroup, |
michael@0 | 38 | const nsACString& aGenericFamily, |
michael@0 | 39 | nsTArray<nsString>& aListOfFonts); |
michael@0 | 40 | |
michael@0 | 41 | nsresult UpdateFontList(); |
michael@0 | 42 | |
michael@0 | 43 | nsresult ResolveFontName(const nsAString& aFontName, |
michael@0 | 44 | FontResolverCallback aCallback, |
michael@0 | 45 | void *aClosure, bool& aAborted); |
michael@0 | 46 | |
michael@0 | 47 | nsresult GetStandardFamilyName(const nsAString& aFontName, nsAString& aFamilyName); |
michael@0 | 48 | |
michael@0 | 49 | gfxFontGroup *CreateFontGroup(const nsAString &aFamilies, |
michael@0 | 50 | const gfxFontStyle *aStyle, |
michael@0 | 51 | gfxUserFontSet *aUserFontSet); |
michael@0 | 52 | |
michael@0 | 53 | /** |
michael@0 | 54 | * Look up a local platform font using the full font face name (needed to |
michael@0 | 55 | * support @font-face src local() ) |
michael@0 | 56 | */ |
michael@0 | 57 | virtual gfxFontEntry* LookupLocalFont(const gfxProxyFontEntry *aProxyEntry, |
michael@0 | 58 | const nsAString& aFontName); |
michael@0 | 59 | |
michael@0 | 60 | /** |
michael@0 | 61 | * Activate a platform font (needed to support @font-face src url() ) |
michael@0 | 62 | * |
michael@0 | 63 | */ |
michael@0 | 64 | virtual gfxFontEntry* MakePlatformFont(const gfxProxyFontEntry *aProxyEntry, |
michael@0 | 65 | const uint8_t *aFontData, |
michael@0 | 66 | uint32_t aLength); |
michael@0 | 67 | |
michael@0 | 68 | /** |
michael@0 | 69 | * Check whether format is supported on a platform or not (if unclear, |
michael@0 | 70 | * returns true). |
michael@0 | 71 | */ |
michael@0 | 72 | virtual bool IsFontFormatSupported(nsIURI *aFontURI, |
michael@0 | 73 | uint32_t aFormatFlags); |
michael@0 | 74 | |
michael@0 | 75 | #if (MOZ_WIDGET_GTK == 2) |
michael@0 | 76 | static void SetGdkDrawable(cairo_surface_t *target, |
michael@0 | 77 | GdkDrawable *drawable); |
michael@0 | 78 | static GdkDrawable *GetGdkDrawable(cairo_surface_t *target); |
michael@0 | 79 | #endif |
michael@0 | 80 | |
michael@0 | 81 | static int32_t GetDPI(); |
michael@0 | 82 | |
michael@0 | 83 | bool UseXRender() { |
michael@0 | 84 | #if defined(MOZ_X11) |
michael@0 | 85 | if (GetContentBackend() != mozilla::gfx::BackendType::NONE && |
michael@0 | 86 | GetContentBackend() != mozilla::gfx::BackendType::CAIRO) |
michael@0 | 87 | return false; |
michael@0 | 88 | |
michael@0 | 89 | return sUseXRender; |
michael@0 | 90 | #else |
michael@0 | 91 | return false; |
michael@0 | 92 | #endif |
michael@0 | 93 | } |
michael@0 | 94 | |
michael@0 | 95 | virtual gfxImageFormat GetOffscreenFormat(); |
michael@0 | 96 | |
michael@0 | 97 | virtual int GetScreenDepth() const; |
michael@0 | 98 | |
michael@0 | 99 | protected: |
michael@0 | 100 | static gfxFontconfigUtils *sFontconfigUtils; |
michael@0 | 101 | |
michael@0 | 102 | private: |
michael@0 | 103 | virtual void GetPlatformCMSOutputProfile(void *&mem, size_t &size); |
michael@0 | 104 | |
michael@0 | 105 | virtual bool SupportsOffMainThreadCompositing(); |
michael@0 | 106 | #ifdef MOZ_X11 |
michael@0 | 107 | static bool sUseXRender; |
michael@0 | 108 | #endif |
michael@0 | 109 | }; |
michael@0 | 110 | |
michael@0 | 111 | #endif /* GFX_PLATFORM_GTK_H */ |