blob: 98c4910b27f0501d9df0fa7d2e924d371c2bf998 [file] [log] [blame]
bungeman51daa252014-06-05 13:38:45 -07001/*
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>
kulshinc4b09152016-06-01 08:31:28 -070017#if SK_HAS_DWRITE_2_H
18#include <dwrite_2.h>
19#endif
bungeman51daa252014-06-05 13:38:45 -070020
herbb69d0e02015-02-25 06:47:06 -080021class SkGlyph;
bungeman51daa252014-06-05 13:38:45 -070022class SkDescriptor;
23
24class SkScalerContext_DW : public SkScalerContext {
25public:
reeda9322c22016-04-12 06:47:05 -070026 SkScalerContext_DW(DWriteFontTypeface*, const SkScalerContextEffects&, const SkDescriptor*);
bungeman51daa252014-06-05 13:38:45 -070027 virtual ~SkScalerContext_DW();
28
29protected:
mtklein36352bf2015-03-25 18:17:31 -070030 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;
bungeman51daa252014-06-05 13:38:45 -070037
38private:
Ben Wagnerb2f7fce2014-08-27 19:17:41 -040039 const void* drawDWMask(const SkGlyph& glyph,
40 DWRITE_RENDERING_MODE renderingMode,
41 DWRITE_TEXTURE_TYPE textureType);
42
bungeman683a3762014-08-28 11:42:29 -070043 HRESULT getBoundingBox(SkGlyph* glyph,
44 DWRITE_RENDERING_MODE renderingMode,
45 DWRITE_TEXTURE_TYPE textureType,
46 RECT* bbox);
bungeman51daa252014-06-05 13:38:45 -070047
kulshinc4b09152016-06-01 08:31:28 -070048 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
bungeman51daa252014-06-05 13:38:45 -070056 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;
kulshinc4b09152016-06-01 08:31:28 -070078#if SK_HAS_DWRITE_2_H
79 SkTScopedComPtr<IDWriteFactory2> fFactory2;
80 bool fIsColorFont;
81#endif
bungeman51daa252014-06-05 13:38:45 -070082};
83
84#endif