gfx/2d/ScaledFontCairo.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_SCALEDFONTCAIRO_H_
     7 #define MOZILLA_GFX_SCALEDFONTCAIRO_H_
     9 #include "ScaledFontBase.h"
    11 #include "cairo.h"
    13 namespace mozilla {
    14 namespace gfx {
    16 class ScaledFontCairo : public ScaledFontBase
    17 {
    18 public:
    19   MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(ScaledFontCairo)
    21   ScaledFontCairo(cairo_scaled_font_t* aScaledFont, Float aSize);
    23 #if defined(USE_SKIA) && defined(MOZ_ENABLE_FREETYPE)
    24   virtual SkTypeface* GetSkTypeface();
    25 #endif
    26 };
    28 // We need to be able to tell Skia whether or not to use
    29 // hinting when rendering text, so that the glyphs it renders
    30 // are the same as what layout is expecting. At the moment, only
    31 // Skia uses this class when rendering with FreeType, as gfxFT2Font
    32 // is the only gfxFont that honours gfxPlatform::FontHintingEnabled().
    33 class GlyphRenderingOptionsCairo : public GlyphRenderingOptions
    34 {
    35 public:
    36   MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(GlyphRenderingOptionsCairo)
    37   GlyphRenderingOptionsCairo()
    38     : mHinting(FontHinting::NORMAL)
    39     , mAutoHinting(false)
    40   {
    41   }
    43   void SetHinting(FontHinting aHinting) { mHinting = aHinting; }
    44   void SetAutoHinting(bool aAutoHinting) { mAutoHinting = aAutoHinting; }
    45   FontHinting GetHinting() const { return mHinting; }
    46   bool GetAutoHinting() const { return mAutoHinting; }
    47   virtual FontType GetType() const { return FontType::CAIRO; }
    48 private:
    49   FontHinting mHinting;
    50   bool mAutoHinting;
    51 };
    53 }
    54 }
    56 #endif /* MOZILLA_GFX_SCALEDFONTCAIRO_H_ */

mercurial