Tue, 06 Jan 2015 21:39:09 +0100
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_WINDOWSDWRITEFONTS_H |
michael@0 | 7 | #define GFX_WINDOWSDWRITEFONTS_H |
michael@0 | 8 | |
michael@0 | 9 | #include "mozilla/MemoryReporting.h" |
michael@0 | 10 | #include <dwrite.h> |
michael@0 | 11 | |
michael@0 | 12 | #include "gfxFont.h" |
michael@0 | 13 | #include "gfxUserFontSet.h" |
michael@0 | 14 | #include "cairo-win32.h" |
michael@0 | 15 | |
michael@0 | 16 | #include "nsDataHashtable.h" |
michael@0 | 17 | #include "nsHashKeys.h" |
michael@0 | 18 | |
michael@0 | 19 | /** |
michael@0 | 20 | * \brief Class representing a font face for a font entry. |
michael@0 | 21 | */ |
michael@0 | 22 | class gfxDWriteFont : public gfxFont |
michael@0 | 23 | { |
michael@0 | 24 | public: |
michael@0 | 25 | gfxDWriteFont(gfxFontEntry *aFontEntry, |
michael@0 | 26 | const gfxFontStyle *aFontStyle, |
michael@0 | 27 | bool aNeedsBold = false, |
michael@0 | 28 | AntialiasOption = kAntialiasDefault); |
michael@0 | 29 | ~gfxDWriteFont(); |
michael@0 | 30 | |
michael@0 | 31 | virtual gfxFont* CopyWithAntialiasOption(AntialiasOption anAAOption); |
michael@0 | 32 | |
michael@0 | 33 | virtual const gfxFont::Metrics& GetMetrics(); |
michael@0 | 34 | |
michael@0 | 35 | virtual uint32_t GetSpaceGlyph(); |
michael@0 | 36 | |
michael@0 | 37 | virtual bool SetupCairoFont(gfxContext *aContext); |
michael@0 | 38 | |
michael@0 | 39 | virtual bool AllowSubpixelAA() { return mAllowManualShowGlyphs; } |
michael@0 | 40 | |
michael@0 | 41 | virtual bool IsValid(); |
michael@0 | 42 | |
michael@0 | 43 | gfxFloat GetAdjustedSize() { |
michael@0 | 44 | return mAdjustedSize; |
michael@0 | 45 | } |
michael@0 | 46 | |
michael@0 | 47 | IDWriteFontFace *GetFontFace(); |
michael@0 | 48 | |
michael@0 | 49 | /* override Measure to add padding for antialiasing */ |
michael@0 | 50 | virtual RunMetrics Measure(gfxTextRun *aTextRun, |
michael@0 | 51 | uint32_t aStart, uint32_t aEnd, |
michael@0 | 52 | BoundingBoxType aBoundingBoxType, |
michael@0 | 53 | gfxContext *aContextForTightBoundingBox, |
michael@0 | 54 | Spacing *aSpacing); |
michael@0 | 55 | |
michael@0 | 56 | virtual bool ProvidesGlyphWidths(); |
michael@0 | 57 | |
michael@0 | 58 | virtual int32_t GetGlyphWidth(gfxContext *aCtx, uint16_t aGID); |
michael@0 | 59 | |
michael@0 | 60 | virtual mozilla::TemporaryRef<mozilla::gfx::GlyphRenderingOptions> GetGlyphRenderingOptions(); |
michael@0 | 61 | |
michael@0 | 62 | virtual void AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf, |
michael@0 | 63 | FontCacheSizes* aSizes) const; |
michael@0 | 64 | virtual void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf, |
michael@0 | 65 | FontCacheSizes* aSizes) const; |
michael@0 | 66 | |
michael@0 | 67 | virtual FontType GetType() const { return FONT_TYPE_DWRITE; } |
michael@0 | 68 | |
michael@0 | 69 | virtual mozilla::TemporaryRef<mozilla::gfx::ScaledFont> GetScaledFont(mozilla::gfx::DrawTarget *aTarget); |
michael@0 | 70 | |
michael@0 | 71 | virtual cairo_scaled_font_t *GetCairoScaledFont(); |
michael@0 | 72 | |
michael@0 | 73 | protected: |
michael@0 | 74 | friend class gfxDWriteShaper; |
michael@0 | 75 | |
michael@0 | 76 | virtual void CreatePlatformShaper(); |
michael@0 | 77 | |
michael@0 | 78 | bool GetFakeMetricsForArialBlack(DWRITE_FONT_METRICS *aFontMetrics); |
michael@0 | 79 | |
michael@0 | 80 | void ComputeMetrics(AntialiasOption anAAOption); |
michael@0 | 81 | |
michael@0 | 82 | bool HasBitmapStrikeForSize(uint32_t aSize); |
michael@0 | 83 | |
michael@0 | 84 | cairo_font_face_t *CairoFontFace(); |
michael@0 | 85 | |
michael@0 | 86 | gfxFloat MeasureGlyphWidth(uint16_t aGlyph); |
michael@0 | 87 | |
michael@0 | 88 | DWRITE_MEASURING_MODE GetMeasuringMode(); |
michael@0 | 89 | bool GetForceGDIClassic(); |
michael@0 | 90 | |
michael@0 | 91 | nsRefPtr<IDWriteFontFace> mFontFace; |
michael@0 | 92 | cairo_font_face_t *mCairoFontFace; |
michael@0 | 93 | |
michael@0 | 94 | gfxFont::Metrics *mMetrics; |
michael@0 | 95 | |
michael@0 | 96 | // cache of glyph widths in 16.16 fixed-point pixels |
michael@0 | 97 | nsAutoPtr<nsDataHashtable<nsUint32HashKey,int32_t> > mGlyphWidths; |
michael@0 | 98 | |
michael@0 | 99 | bool mNeedsOblique; |
michael@0 | 100 | bool mNeedsBold; |
michael@0 | 101 | bool mUseSubpixelPositions; |
michael@0 | 102 | bool mAllowManualShowGlyphs; |
michael@0 | 103 | bool mAzureScaledFontIsCairo; |
michael@0 | 104 | }; |
michael@0 | 105 | |
michael@0 | 106 | #endif |