gfx/2d/ScaledFontDWrite.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.

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

mercurial