blob: d5a217d5b4bdf3dcea26b67e1024ec5012d371ce [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>
bungeman73c7c3c2016-06-16 14:41:53 -070017#include <dwrite_2.h>
bungeman51daa252014-06-05 13:38:45 -070018
herbb69d0e02015-02-25 06:47:06 -080019class SkGlyph;
bungeman51daa252014-06-05 13:38:45 -070020class SkDescriptor;
21
22class SkScalerContext_DW : public SkScalerContext {
23public:
bungeman7cfd46a2016-10-20 16:06:52 -040024 SkScalerContext_DW(sk_sp<DWriteFontTypeface>,
25 const SkScalerContextEffects&,
26 const SkDescriptor*);
Chris Dalton1ef80942017-12-04 12:01:30 -070027 ~SkScalerContext_DW() override;
bungeman51daa252014-06-05 13:38:45 -070028
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;
Ben Wagner5ddb3082018-03-29 11:18:06 -040035 bool generatePath(SkGlyphID glyph, SkPath* path) override;
mtklein36352bf2015-03-25 18:17:31 -070036 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
bungeman7cfd46a2016-10-20 16:06:52 -040050 DWriteFontTypeface* getDWriteTypeface() {
51 return static_cast<DWriteFontTypeface*>(this->getTypeface());
52 }
53
kulshinc4b09152016-06-01 08:31:28 -070054 bool getColorGlyphRun(const SkGlyph& glyph, IDWriteColorGlyphRunEnumerator** colorGlyph);
Bruce Wang46f25632018-06-13 13:38:34 -040055
56 void generateColorMetrics(SkGlyph* glyph);
57
kulshinc4b09152016-06-01 08:31:28 -070058 void generateColorGlyphImage(const SkGlyph& glyph);
kulshinc4b09152016-06-01 08:31:28 -070059
bungeman51daa252014-06-05 13:38:45 -070060 SkTDArray<uint8_t> fBits;
61 /** The total matrix without the text height scale. */
62 SkMatrix fSkXform;
63 /** The total matrix without the text height scale. */
64 DWRITE_MATRIX fXform;
bungeman51daa252014-06-05 13:38:45 -070065 /** The text size to render with. */
66 SkScalar fTextSizeRender;
67 /** The text size to measure with. */
68 SkScalar fTextSizeMeasure;
bungeman51daa252014-06-05 13:38:45 -070069 int fGlyphCount;
70 DWRITE_RENDERING_MODE fRenderingMode;
71 DWRITE_TEXTURE_TYPE fTextureType;
72 DWRITE_MEASURING_MODE fMeasuringMode;
Ben Wagner22253062017-03-16 12:38:46 -040073 DWRITE_TEXT_ANTIALIAS_MODE fAntiAliasMode;
74 DWRITE_GRID_FIT_MODE fGridFitMode;
bungemanbd770d62016-06-16 10:42:23 -070075 bool fIsColorFont;
bungeman51daa252014-06-05 13:38:45 -070076};
77
78#endif