blob: a462d98de009e39e691b61da347357b755d6eb60 [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;
Ben Wagnere5416452018-08-09 14:03:42 -040032 bool generateAdvance(SkGlyph* glyph) override;
mtklein36352bf2015-03-25 18:17:31 -070033 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;
Mike Reedb5784ac2018-11-12 09:35:15 -050036 void generateFontMetrics(SkFontMetrics*) 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
Bruce Wange3986752018-07-15 17:11:25 -040050 bool isPngGlyph(const SkGlyph& glyph);
51
bungeman7cfd46a2016-10-20 16:06:52 -040052 DWriteFontTypeface* getDWriteTypeface() {
53 return static_cast<DWriteFontTypeface*>(this->getTypeface());
54 }
55
kulshinc4b09152016-06-01 08:31:28 -070056 bool getColorGlyphRun(const SkGlyph& glyph, IDWriteColorGlyphRunEnumerator** colorGlyph);
Hal Canaryd4998172018-07-11 11:31:34 -040057
Bruce Wang46f25632018-06-13 13:38:34 -040058 void generateColorMetrics(SkGlyph* glyph);
Hal Canaryd4998172018-07-11 11:31:34 -040059
kulshinc4b09152016-06-01 08:31:28 -070060 void generateColorGlyphImage(const SkGlyph& glyph);
kulshinc4b09152016-06-01 08:31:28 -070061
Bruce Wange3986752018-07-15 17:11:25 -040062 void generatePngMetrics(SkGlyph* glyph);
63
64 void generatePngGlyphImage(const SkGlyph& glyph);
65
66
bungeman51daa252014-06-05 13:38:45 -070067 SkTDArray<uint8_t> fBits;
68 /** The total matrix without the text height scale. */
69 SkMatrix fSkXform;
70 /** The total matrix without the text height scale. */
71 DWRITE_MATRIX fXform;
bungeman51daa252014-06-05 13:38:45 -070072 /** The text size to render with. */
73 SkScalar fTextSizeRender;
74 /** The text size to measure with. */
75 SkScalar fTextSizeMeasure;
bungeman51daa252014-06-05 13:38:45 -070076 int fGlyphCount;
77 DWRITE_RENDERING_MODE fRenderingMode;
78 DWRITE_TEXTURE_TYPE fTextureType;
79 DWRITE_MEASURING_MODE fMeasuringMode;
Ben Wagner22253062017-03-16 12:38:46 -040080 DWRITE_TEXT_ANTIALIAS_MODE fAntiAliasMode;
81 DWRITE_GRID_FIT_MODE fGridFitMode;
bungemanbd770d62016-06-16 10:42:23 -070082 bool fIsColorFont;
bungeman51daa252014-06-05 13:38:45 -070083};
84
85#endif