1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/2d/ScaledFontDWrite.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,70 @@ 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_SCALEDFONTDWRITE_H_ 1.10 +#define MOZILLA_GFX_SCALEDFONTDWRITE_H_ 1.11 + 1.12 +#include <dwrite.h> 1.13 +#include "ScaledFontBase.h" 1.14 + 1.15 +struct ID2D1GeometrySink; 1.16 + 1.17 +namespace mozilla { 1.18 +namespace gfx { 1.19 + 1.20 +class ScaledFontDWrite MOZ_FINAL : public ScaledFontBase 1.21 +{ 1.22 +public: 1.23 + MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(ScaledFontDwrite) 1.24 + ScaledFontDWrite(IDWriteFontFace *aFont, Float aSize) 1.25 + : mFontFace(aFont) 1.26 + , ScaledFontBase(aSize) 1.27 + {} 1.28 + ScaledFontDWrite(uint8_t *aData, uint32_t aSize, uint32_t aIndex, Float aGlyphSize); 1.29 + 1.30 + virtual FontType GetType() const { return FontType::DWRITE; } 1.31 + 1.32 + virtual TemporaryRef<Path> GetPathForGlyphs(const GlyphBuffer &aBuffer, const DrawTarget *aTarget); 1.33 + virtual void CopyGlyphsToBuilder(const GlyphBuffer &aBuffer, PathBuilder *aBuilder, BackendType aBackendType, const Matrix *aTransformHint); 1.34 + 1.35 + void CopyGlyphsToSink(const GlyphBuffer &aBuffer, ID2D1GeometrySink *aSink); 1.36 + 1.37 + virtual bool GetFontFileData(FontFileDataOutput aDataCallback, void *aBaton); 1.38 + 1.39 + virtual AntialiasMode GetDefaultAAMode(); 1.40 + 1.41 +#ifdef USE_SKIA 1.42 + virtual SkTypeface* GetSkTypeface() 1.43 + { 1.44 + MOZ_ASSERT(false, "Skia and DirectWrite do not mix"); 1.45 + return nullptr; 1.46 + } 1.47 +#endif 1.48 + 1.49 + RefPtr<IDWriteFontFace> mFontFace; 1.50 +}; 1.51 + 1.52 +class GlyphRenderingOptionsDWrite : public GlyphRenderingOptions 1.53 +{ 1.54 +public: 1.55 + MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(GlyphRenderingOptionsDWrite) 1.56 + GlyphRenderingOptionsDWrite(IDWriteRenderingParams *aParams) 1.57 + : mParams(aParams) 1.58 + { 1.59 + } 1.60 + 1.61 + virtual FontType GetType() const { return FontType::DWRITE; } 1.62 + 1.63 +private: 1.64 + friend class DrawTargetD2D; 1.65 + friend class DrawTargetD2D1; 1.66 + 1.67 + RefPtr<IDWriteRenderingParams> mParams; 1.68 +}; 1.69 + 1.70 +} 1.71 +} 1.72 + 1.73 +#endif /* MOZILLA_GFX_SCALEDFONTDWRITE_H_ */