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: 2 -*- |
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 MOZILLA_GFX_SCALEDFONTDWRITE_H_ |
michael@0 | 7 | #define MOZILLA_GFX_SCALEDFONTDWRITE_H_ |
michael@0 | 8 | |
michael@0 | 9 | #include <dwrite.h> |
michael@0 | 10 | #include "ScaledFontBase.h" |
michael@0 | 11 | |
michael@0 | 12 | struct ID2D1GeometrySink; |
michael@0 | 13 | |
michael@0 | 14 | namespace mozilla { |
michael@0 | 15 | namespace gfx { |
michael@0 | 16 | |
michael@0 | 17 | class ScaledFontDWrite MOZ_FINAL : public ScaledFontBase |
michael@0 | 18 | { |
michael@0 | 19 | public: |
michael@0 | 20 | MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(ScaledFontDwrite) |
michael@0 | 21 | ScaledFontDWrite(IDWriteFontFace *aFont, Float aSize) |
michael@0 | 22 | : mFontFace(aFont) |
michael@0 | 23 | , ScaledFontBase(aSize) |
michael@0 | 24 | {} |
michael@0 | 25 | ScaledFontDWrite(uint8_t *aData, uint32_t aSize, uint32_t aIndex, Float aGlyphSize); |
michael@0 | 26 | |
michael@0 | 27 | virtual FontType GetType() const { return FontType::DWRITE; } |
michael@0 | 28 | |
michael@0 | 29 | virtual TemporaryRef<Path> GetPathForGlyphs(const GlyphBuffer &aBuffer, const DrawTarget *aTarget); |
michael@0 | 30 | virtual void CopyGlyphsToBuilder(const GlyphBuffer &aBuffer, PathBuilder *aBuilder, BackendType aBackendType, const Matrix *aTransformHint); |
michael@0 | 31 | |
michael@0 | 32 | void CopyGlyphsToSink(const GlyphBuffer &aBuffer, ID2D1GeometrySink *aSink); |
michael@0 | 33 | |
michael@0 | 34 | virtual bool GetFontFileData(FontFileDataOutput aDataCallback, void *aBaton); |
michael@0 | 35 | |
michael@0 | 36 | virtual AntialiasMode GetDefaultAAMode(); |
michael@0 | 37 | |
michael@0 | 38 | #ifdef USE_SKIA |
michael@0 | 39 | virtual SkTypeface* GetSkTypeface() |
michael@0 | 40 | { |
michael@0 | 41 | MOZ_ASSERT(false, "Skia and DirectWrite do not mix"); |
michael@0 | 42 | return nullptr; |
michael@0 | 43 | } |
michael@0 | 44 | #endif |
michael@0 | 45 | |
michael@0 | 46 | RefPtr<IDWriteFontFace> mFontFace; |
michael@0 | 47 | }; |
michael@0 | 48 | |
michael@0 | 49 | class GlyphRenderingOptionsDWrite : public GlyphRenderingOptions |
michael@0 | 50 | { |
michael@0 | 51 | public: |
michael@0 | 52 | MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(GlyphRenderingOptionsDWrite) |
michael@0 | 53 | GlyphRenderingOptionsDWrite(IDWriteRenderingParams *aParams) |
michael@0 | 54 | : mParams(aParams) |
michael@0 | 55 | { |
michael@0 | 56 | } |
michael@0 | 57 | |
michael@0 | 58 | virtual FontType GetType() const { return FontType::DWRITE; } |
michael@0 | 59 | |
michael@0 | 60 | private: |
michael@0 | 61 | friend class DrawTargetD2D; |
michael@0 | 62 | friend class DrawTargetD2D1; |
michael@0 | 63 | |
michael@0 | 64 | RefPtr<IDWriteRenderingParams> mParams; |
michael@0 | 65 | }; |
michael@0 | 66 | |
michael@0 | 67 | } |
michael@0 | 68 | } |
michael@0 | 69 | |
michael@0 | 70 | #endif /* MOZILLA_GFX_SCALEDFONTDWRITE_H_ */ |