1 /* 2 * Copyright 2014 Google Inc. 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8 #ifndef SkScalarContext_win_dw_DEFINED 9 #define SkScalarContext_win_dw_DEFINED 10 11 #include "SkScalar.h" 12 #include "SkScalerContext.h" 13 #include "SkTypeface_win_dw.h" 14 #include "SkTypes.h" 15 16 #include <dwrite.h> 17 18 struct SkGlyph; 19 class SkDescriptor; 20 21 class SkScalerContext_DW : public SkScalerContext { 22 public: 23 SkScalerContext_DW(DWriteFontTypeface*, const SkDescriptor* desc); 24 virtual ~SkScalerContext_DW(); 25 26 protected: 27 virtual unsigned generateGlyphCount() SK_OVERRIDE; 28 virtual uint16_t generateCharToGlyph(SkUnichar uni) SK_OVERRIDE; 29 virtual void generateAdvance(SkGlyph* glyph) SK_OVERRIDE; 30 virtual void generateMetrics(SkGlyph* glyph) SK_OVERRIDE; 31 virtual void generateImage(const SkGlyph& glyph) SK_OVERRIDE; 32 virtual void generatePath(const SkGlyph& glyph, SkPath* path) SK_OVERRIDE; 33 virtual void generateFontMetrics(SkPaint::FontMetrics* mX, 34 SkPaint::FontMetrics* mY) SK_OVERRIDE; 35 36 private: 37 const void* drawDWMask(const SkGlyph& glyph); 38 39 SkTDArray<uint8_t> fBits; 40 /** The total matrix without the text height scale. */ 41 SkMatrix fSkXform; 42 /** The total matrix without the text height scale. */ 43 DWRITE_MATRIX fXform; 44 /** The non-rotational part of total matrix without the text height scale. 45 * This is used to find the magnitude of gdi compatible advances. 46 */ 47 DWRITE_MATRIX fGsA; 48 /** The inverse of the rotational part of the total matrix. 49 * This is used to find the direction of gdi compatible advances. 50 */ 51 SkMatrix fG_inv; 52 /** The text size to render with. */ 53 SkScalar fTextSizeRender; 54 /** The text size to measure with. */ 55 SkScalar fTextSizeMeasure; 56 SkAutoTUnref<DWriteFontTypeface> fTypeface; 57 int fGlyphCount; 58 DWRITE_RENDERING_MODE fRenderingMode; 59 DWRITE_TEXTURE_TYPE fTextureType; 60 DWRITE_MEASURING_MODE fMeasuringMode; 61 }; 62 63 #endif 64