gfx/thebes/gfxQtPlatform.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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/. */
     6 #ifndef GFX_PLATFORM_QT_H
     7 #define GFX_PLATFORM_QT_H
     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
    17 class gfxImageSurface;
    18 class gfxFontconfigUtils;
    19 class QWindow;
    21 class gfxQtPlatform : public gfxPlatform {
    22 public:
    23     gfxQtPlatform();
    24     virtual ~gfxQtPlatform();
    26     static gfxQtPlatform *GetPlatform() {
    27         return static_cast<gfxQtPlatform*>(gfxPlatform::GetPlatform());
    28     }
    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;
    37     virtual mozilla::TemporaryRef<mozilla::gfx::ScaledFont>
    38       GetScaledFontForFont(mozilla::gfx::DrawTarget* aTarget, gfxFont *aFont) MOZ_OVERRIDE;
    40     virtual nsresult GetFontList(nsIAtom *aLangGroup,
    41                                  const nsACString& aGenericFamily,
    42                                  nsTArray<nsString>& aListOfFonts) MOZ_OVERRIDE;
    44     virtual nsresult UpdateFontList() MOZ_OVERRIDE;
    46     virtual nsresult ResolveFontName(const nsAString& aFontName,
    47                                      FontResolverCallback aCallback,
    48                                      void *aClosure, bool& aAborted) MOZ_OVERRIDE;
    50     virtual nsresult GetStandardFamilyName(const nsAString& aFontName, nsAString& aFamilyName) MOZ_OVERRIDE;
    52     virtual gfxFontGroup *CreateFontGroup(const nsAString &aFamilies,
    53                                           const gfxFontStyle *aStyle,
    54                                           gfxUserFontSet* aUserFontSet) MOZ_OVERRIDE;
    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;
    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;
    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;
    78     virtual void ClearPrefFonts() { mPrefFonts.Clear(); }
    80     static int32_t GetDPI();
    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
    88     virtual int GetScreenDepth() const MOZ_OVERRIDE;
    90     virtual bool SupportsOffMainThreadCompositing() MOZ_OVERRIDE;
    92 protected:
    93     static gfxFontconfigUtils *sFontconfigUtils;
    95 private:
    97     bool UseXRender() {
    98 #if defined(MOZ_X11)
    99         if (GetContentBackend() != mozilla::gfx::BackendType::NONE &&
   100             GetContentBackend() != mozilla::gfx::BackendType::CAIRO)
   101             return false;
   103         return sUseXRender;
   104 #else
   105         return false;
   106 #endif
   107     }
   109     virtual void GetPlatformCMSOutputProfile(void *&mem, size_t &size) MOZ_OVERRIDE;
   111     // TODO: unify this with mPrefFonts (NB: holds families, not fonts) in gfxPlatformFontList
   112     nsDataHashtable<nsCStringHashKey, nsTArray<nsRefPtr<gfxFontEntry> > > mPrefFonts;
   114     int mScreenDepth;
   115 #ifdef MOZ_X11
   116     static bool sUseXRender;
   117 #endif
   118 };
   120 #endif /* GFX_PLATFORM_QT_H */

mercurial