gfx/2d/ScaledFontBase.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/2d/ScaledFontBase.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,69 @@
     1.4 +/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
     1.5 + * This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef MOZILLA_GFX_SCALEDFONTBASE_H_
    1.10 +#define MOZILLA_GFX_SCALEDFONTBASE_H_
    1.11 +
    1.12 +#include "2D.h"
    1.13 +
    1.14 +// Skia uses cairo_scaled_font_t as the internal font type in ScaledFont
    1.15 +#if defined(USE_SKIA) || defined(USE_CAIRO)
    1.16 +#define USE_CAIRO_SCALED_FONT
    1.17 +#endif
    1.18 +
    1.19 +#ifdef USE_SKIA
    1.20 +#include "skia/SkPath.h"
    1.21 +#include "skia/SkTypeface.h"
    1.22 +#endif
    1.23 +#ifdef USE_CAIRO_SCALED_FONT
    1.24 +#include "cairo.h"
    1.25 +#endif
    1.26 +
    1.27 +class gfxFont;
    1.28 +
    1.29 +namespace mozilla {
    1.30 +namespace gfx {
    1.31 +
    1.32 +class ScaledFontBase : public ScaledFont
    1.33 +{
    1.34 +public:
    1.35 +  MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(ScaledFontBase)
    1.36 +  ScaledFontBase(Float aSize);
    1.37 +  virtual ~ScaledFontBase();
    1.38 +
    1.39 +  virtual TemporaryRef<Path> GetPathForGlyphs(const GlyphBuffer &aBuffer, const DrawTarget *aTarget);
    1.40 +
    1.41 +  virtual void CopyGlyphsToBuilder(const GlyphBuffer &aBuffer, PathBuilder *aBuilder, BackendType aBackendType, const Matrix *aTransformHint);
    1.42 +
    1.43 +  float GetSize() { return mSize; }
    1.44 +
    1.45 +#ifdef USE_SKIA
    1.46 +  virtual SkTypeface* GetSkTypeface() { return mTypeface; }
    1.47 +#endif
    1.48 +
    1.49 +  // Not true, but required to instantiate a ScaledFontBase.
    1.50 +  virtual FontType GetType() const { return FontType::SKIA; }
    1.51 +
    1.52 +#ifdef USE_CAIRO_SCALED_FONT
    1.53 +  cairo_scaled_font_t* GetCairoScaledFont() { return mScaledFont; }
    1.54 +  void SetCairoScaledFont(cairo_scaled_font_t* font);
    1.55 +#endif
    1.56 +
    1.57 +protected:
    1.58 +  friend class DrawTargetSkia;
    1.59 +#ifdef USE_SKIA
    1.60 +  SkTypeface* mTypeface;
    1.61 +  SkPath GetSkiaPathForGlyphs(const GlyphBuffer &aBuffer);
    1.62 +#endif
    1.63 +#ifdef USE_CAIRO_SCALED_FONT
    1.64 +  cairo_scaled_font_t* mScaledFont;
    1.65 +#endif
    1.66 +  Float mSize;
    1.67 +};
    1.68 +
    1.69 +}
    1.70 +}
    1.71 +
    1.72 +#endif /* MOZILLA_GFX_SCALEDFONTBASE_H_ */

mercurial