1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/thebes/gfxQtPlatform.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,121 @@ 1.4 +/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- 1.5 + * This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef GFX_PLATFORM_QT_H 1.10 +#define GFX_PLATFORM_QT_H 1.11 + 1.12 +#include "gfxPlatform.h" 1.13 +#include "nsAutoRef.h" 1.14 +#include "nsDataHashtable.h" 1.15 +#include "nsTArray.h" 1.16 +#ifdef MOZ_X11 1.17 +#include "X11/Xlib.h" 1.18 +#endif 1.19 + 1.20 +class gfxImageSurface; 1.21 +class gfxFontconfigUtils; 1.22 +class QWindow; 1.23 + 1.24 +class gfxQtPlatform : public gfxPlatform { 1.25 +public: 1.26 + gfxQtPlatform(); 1.27 + virtual ~gfxQtPlatform(); 1.28 + 1.29 + static gfxQtPlatform *GetPlatform() { 1.30 + return static_cast<gfxQtPlatform*>(gfxPlatform::GetPlatform()); 1.31 + } 1.32 + 1.33 + virtual already_AddRefed<gfxASurface> 1.34 + OptimizeImage(gfxImageSurface *aSurface, 1.35 + gfxImageFormat format) MOZ_OVERRIDE; 1.36 + virtual already_AddRefed<gfxASurface> 1.37 + CreateOffscreenSurface(const IntSize& size, 1.38 + gfxContentType contentType) MOZ_OVERRIDE; 1.39 + 1.40 + virtual mozilla::TemporaryRef<mozilla::gfx::ScaledFont> 1.41 + GetScaledFontForFont(mozilla::gfx::DrawTarget* aTarget, gfxFont *aFont) MOZ_OVERRIDE; 1.42 + 1.43 + virtual nsresult GetFontList(nsIAtom *aLangGroup, 1.44 + const nsACString& aGenericFamily, 1.45 + nsTArray<nsString>& aListOfFonts) MOZ_OVERRIDE; 1.46 + 1.47 + virtual nsresult UpdateFontList() MOZ_OVERRIDE; 1.48 + 1.49 + virtual nsresult ResolveFontName(const nsAString& aFontName, 1.50 + FontResolverCallback aCallback, 1.51 + void *aClosure, bool& aAborted) MOZ_OVERRIDE; 1.52 + 1.53 + virtual nsresult GetStandardFamilyName(const nsAString& aFontName, nsAString& aFamilyName) MOZ_OVERRIDE; 1.54 + 1.55 + virtual gfxFontGroup *CreateFontGroup(const nsAString &aFamilies, 1.56 + const gfxFontStyle *aStyle, 1.57 + gfxUserFontSet* aUserFontSet) MOZ_OVERRIDE; 1.58 + 1.59 + /** 1.60 + * Look up a local platform font using the full font face name (needed to 1.61 + * support @font-face src local() ) 1.62 + */ 1.63 + virtual gfxFontEntry* LookupLocalFont(const gfxProxyFontEntry *aProxyEntry, 1.64 + const nsAString& aFontName) MOZ_OVERRIDE; 1.65 + 1.66 + /** 1.67 + * Activate a platform font (needed to support @font-face src url() ) 1.68 + * 1.69 + */ 1.70 + virtual gfxFontEntry* MakePlatformFont(const gfxProxyFontEntry *aProxyEntry, 1.71 + const uint8_t *aFontData, 1.72 + uint32_t aLength) MOZ_OVERRIDE; 1.73 + 1.74 + /** 1.75 + * Check whether format is supported on a platform or not (if unclear, 1.76 + * returns true). 1.77 + */ 1.78 + virtual bool IsFontFormatSupported(nsIURI *aFontURI, 1.79 + uint32_t aFormatFlags) MOZ_OVERRIDE; 1.80 + 1.81 + virtual void ClearPrefFonts() { mPrefFonts.Clear(); } 1.82 + 1.83 + static int32_t GetDPI(); 1.84 + 1.85 + virtual gfxImageFormat GetOffscreenFormat() MOZ_OVERRIDE; 1.86 +#ifdef MOZ_X11 1.87 + static Display* GetXDisplay(QWindow* aWindow = 0); 1.88 + static Screen* GetXScreen(QWindow* aWindow = 0); 1.89 +#endif 1.90 + 1.91 + virtual int GetScreenDepth() const MOZ_OVERRIDE; 1.92 + 1.93 + virtual bool SupportsOffMainThreadCompositing() MOZ_OVERRIDE; 1.94 + 1.95 +protected: 1.96 + static gfxFontconfigUtils *sFontconfigUtils; 1.97 + 1.98 +private: 1.99 + 1.100 + bool UseXRender() { 1.101 +#if defined(MOZ_X11) 1.102 + if (GetContentBackend() != mozilla::gfx::BackendType::NONE && 1.103 + GetContentBackend() != mozilla::gfx::BackendType::CAIRO) 1.104 + return false; 1.105 + 1.106 + return sUseXRender; 1.107 +#else 1.108 + return false; 1.109 +#endif 1.110 + } 1.111 + 1.112 + virtual void GetPlatformCMSOutputProfile(void *&mem, size_t &size) MOZ_OVERRIDE; 1.113 + 1.114 + // TODO: unify this with mPrefFonts (NB: holds families, not fonts) in gfxPlatformFontList 1.115 + nsDataHashtable<nsCStringHashKey, nsTArray<nsRefPtr<gfxFontEntry> > > mPrefFonts; 1.116 + 1.117 + int mScreenDepth; 1.118 +#ifdef MOZ_X11 1.119 + static bool sUseXRender; 1.120 +#endif 1.121 +}; 1.122 + 1.123 +#endif /* GFX_PLATFORM_QT_H */ 1.124 +