gfx/thebes/gfxQtPlatform.h

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

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

mercurial