bungeman | 51daa25 | 2014-06-05 13:38:45 -0700 | [diff] [blame] | 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> |
kulshin | c4b0915 | 2016-06-01 08:31:28 -0700 | [diff] [blame^] | 17 | #if SK_HAS_DWRITE_2_H |
| 18 | #include <dwrite_2.h> |
| 19 | #endif |
bungeman | 51daa25 | 2014-06-05 13:38:45 -0700 | [diff] [blame] | 20 | |
herb | b69d0e0 | 2015-02-25 06:47:06 -0800 | [diff] [blame] | 21 | class SkGlyph; |
bungeman | 51daa25 | 2014-06-05 13:38:45 -0700 | [diff] [blame] | 22 | class SkDescriptor; |
| 23 | |
| 24 | class SkScalerContext_DW : public SkScalerContext { |
| 25 | public: |
reed | a9322c2 | 2016-04-12 06:47:05 -0700 | [diff] [blame] | 26 | SkScalerContext_DW(DWriteFontTypeface*, const SkScalerContextEffects&, const SkDescriptor*); |
bungeman | 51daa25 | 2014-06-05 13:38:45 -0700 | [diff] [blame] | 27 | virtual ~SkScalerContext_DW(); |
| 28 | |
| 29 | protected: |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 30 | unsigned generateGlyphCount() override; |
| 31 | uint16_t generateCharToGlyph(SkUnichar uni) override; |
| 32 | void generateAdvance(SkGlyph* glyph) override; |
| 33 | void generateMetrics(SkGlyph* glyph) override; |
| 34 | void generateImage(const SkGlyph& glyph) override; |
| 35 | void generatePath(const SkGlyph& glyph, SkPath* path) override; |
| 36 | void generateFontMetrics(SkPaint::FontMetrics*) override; |
bungeman | 51daa25 | 2014-06-05 13:38:45 -0700 | [diff] [blame] | 37 | |
| 38 | private: |
Ben Wagner | b2f7fce | 2014-08-27 19:17:41 -0400 | [diff] [blame] | 39 | const void* drawDWMask(const SkGlyph& glyph, |
| 40 | DWRITE_RENDERING_MODE renderingMode, |
| 41 | DWRITE_TEXTURE_TYPE textureType); |
| 42 | |
bungeman | 683a376 | 2014-08-28 11:42:29 -0700 | [diff] [blame] | 43 | HRESULT getBoundingBox(SkGlyph* glyph, |
| 44 | DWRITE_RENDERING_MODE renderingMode, |
| 45 | DWRITE_TEXTURE_TYPE textureType, |
| 46 | RECT* bbox); |
bungeman | 51daa25 | 2014-06-05 13:38:45 -0700 | [diff] [blame] | 47 | |
kulshin | c4b0915 | 2016-06-01 08:31:28 -0700 | [diff] [blame^] | 48 | bool isColorGlyph(const SkGlyph& glyph); |
| 49 | |
| 50 | #if SK_HAS_DWRITE_2_H |
| 51 | bool getColorGlyphRun(const SkGlyph& glyph, IDWriteColorGlyphRunEnumerator** colorGlyph); |
| 52 | |
| 53 | void generateColorGlyphImage(const SkGlyph& glyph); |
| 54 | #endif |
| 55 | |
bungeman | 51daa25 | 2014-06-05 13:38:45 -0700 | [diff] [blame] | 56 | SkTDArray<uint8_t> fBits; |
| 57 | /** The total matrix without the text height scale. */ |
| 58 | SkMatrix fSkXform; |
| 59 | /** The total matrix without the text height scale. */ |
| 60 | DWRITE_MATRIX fXform; |
| 61 | /** The non-rotational part of total matrix without the text height scale. |
| 62 | * This is used to find the magnitude of gdi compatible advances. |
| 63 | */ |
| 64 | DWRITE_MATRIX fGsA; |
| 65 | /** The inverse of the rotational part of the total matrix. |
| 66 | * This is used to find the direction of gdi compatible advances. |
| 67 | */ |
| 68 | SkMatrix fG_inv; |
| 69 | /** The text size to render with. */ |
| 70 | SkScalar fTextSizeRender; |
| 71 | /** The text size to measure with. */ |
| 72 | SkScalar fTextSizeMeasure; |
| 73 | SkAutoTUnref<DWriteFontTypeface> fTypeface; |
| 74 | int fGlyphCount; |
| 75 | DWRITE_RENDERING_MODE fRenderingMode; |
| 76 | DWRITE_TEXTURE_TYPE fTextureType; |
| 77 | DWRITE_MEASURING_MODE fMeasuringMode; |
kulshin | c4b0915 | 2016-06-01 08:31:28 -0700 | [diff] [blame^] | 78 | #if SK_HAS_DWRITE_2_H |
| 79 | SkTScopedComPtr<IDWriteFactory2> fFactory2; |
| 80 | bool fIsColorFont; |
| 81 | #endif |
bungeman | 51daa25 | 2014-06-05 13:38:45 -0700 | [diff] [blame] | 82 | }; |
| 83 | |
| 84 | #endif |