gfx/2d/ScaledFontBase.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: 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_SCALEDFONTBASE_H_
michael@0 7 #define MOZILLA_GFX_SCALEDFONTBASE_H_
michael@0 8
michael@0 9 #include "2D.h"
michael@0 10
michael@0 11 // Skia uses cairo_scaled_font_t as the internal font type in ScaledFont
michael@0 12 #if defined(USE_SKIA) || defined(USE_CAIRO)
michael@0 13 #define USE_CAIRO_SCALED_FONT
michael@0 14 #endif
michael@0 15
michael@0 16 #ifdef USE_SKIA
michael@0 17 #include "skia/SkPath.h"
michael@0 18 #include "skia/SkTypeface.h"
michael@0 19 #endif
michael@0 20 #ifdef USE_CAIRO_SCALED_FONT
michael@0 21 #include "cairo.h"
michael@0 22 #endif
michael@0 23
michael@0 24 class gfxFont;
michael@0 25
michael@0 26 namespace mozilla {
michael@0 27 namespace gfx {
michael@0 28
michael@0 29 class ScaledFontBase : public ScaledFont
michael@0 30 {
michael@0 31 public:
michael@0 32 MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(ScaledFontBase)
michael@0 33 ScaledFontBase(Float aSize);
michael@0 34 virtual ~ScaledFontBase();
michael@0 35
michael@0 36 virtual TemporaryRef<Path> GetPathForGlyphs(const GlyphBuffer &aBuffer, const DrawTarget *aTarget);
michael@0 37
michael@0 38 virtual void CopyGlyphsToBuilder(const GlyphBuffer &aBuffer, PathBuilder *aBuilder, BackendType aBackendType, const Matrix *aTransformHint);
michael@0 39
michael@0 40 float GetSize() { return mSize; }
michael@0 41
michael@0 42 #ifdef USE_SKIA
michael@0 43 virtual SkTypeface* GetSkTypeface() { return mTypeface; }
michael@0 44 #endif
michael@0 45
michael@0 46 // Not true, but required to instantiate a ScaledFontBase.
michael@0 47 virtual FontType GetType() const { return FontType::SKIA; }
michael@0 48
michael@0 49 #ifdef USE_CAIRO_SCALED_FONT
michael@0 50 cairo_scaled_font_t* GetCairoScaledFont() { return mScaledFont; }
michael@0 51 void SetCairoScaledFont(cairo_scaled_font_t* font);
michael@0 52 #endif
michael@0 53
michael@0 54 protected:
michael@0 55 friend class DrawTargetSkia;
michael@0 56 #ifdef USE_SKIA
michael@0 57 SkTypeface* mTypeface;
michael@0 58 SkPath GetSkiaPathForGlyphs(const GlyphBuffer &aBuffer);
michael@0 59 #endif
michael@0 60 #ifdef USE_CAIRO_SCALED_FONT
michael@0 61 cairo_scaled_font_t* mScaledFont;
michael@0 62 #endif
michael@0 63 Float mSize;
michael@0 64 };
michael@0 65
michael@0 66 }
michael@0 67 }
michael@0 68
michael@0 69 #endif /* MOZILLA_GFX_SCALEDFONTBASE_H_ */

mercurial