Flutter Engine
The Flutter Engine
SkScalerContext_win_dw.h
Go to the documentation of this file.
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
16
17#include <dwrite.h>
18#include <dwrite_2.h>
19#include <dwrite_3.h>
20
21class SkGlyph;
22class SkDescriptor;
23
24interface IDWritePaintReader;
25struct DWRITE_PAINT_ELEMENT;
26
28public:
31 const SkDescriptor*);
33
34protected:
36 void generateImage(const SkGlyph&, void* imageBuffer) override;
37 bool generatePath(const SkGlyph&, SkPath*) override;
40
41private:
42 bool setAdvance(const SkGlyph&, SkVector*);
43
44 struct ScalerContextBits {
45 using value_type = uint16_t;
46 static const constexpr value_type NONE = 0;
47 static const constexpr value_type DW = 1;
48 static const constexpr value_type DW_1 = 2;
49 static const constexpr value_type PNG = 3;
50 static const constexpr value_type SVG = 4;
51 static const constexpr value_type COLR = 5;
52 static const constexpr value_type COLRv1 = 6;
53 static const constexpr value_type PATH = 7;
54 };
55
56 static void BilevelToBW(const uint8_t* SK_RESTRICT src, const SkGlyph& glyph, void* dst);
57
58 template<bool APPLY_PREBLEND>
59 static void GrayscaleToA8(const uint8_t* SK_RESTRICT src,
60 const SkGlyph& glyph, void* dst,
61 const uint8_t* table8);
62
63 template<bool APPLY_PREBLEND>
64 static void RGBToA8(const uint8_t* SK_RESTRICT src,
65 const SkGlyph& glyph, void* dst,
66 const uint8_t* table8);
67
68 template<bool APPLY_PREBLEND, bool RGB>
69 static void RGBToLcd16(const uint8_t* SK_RESTRICT src, const SkGlyph& glyph, void* dst,
70 const uint8_t* tableR, const uint8_t* tableG, const uint8_t* tableB);
71
72 DWriteFontTypeface* getDWriteTypeface() {
73 return static_cast<DWriteFontTypeface*>(this->getTypeface());
74 }
75
76 bool generateColorV1PaintBounds(SkMatrix*, SkRect*, IDWritePaintReader&, DWRITE_PAINT_ELEMENT const &);
77 bool generateColorV1Metrics(const SkGlyph&, SkRect*);
78 bool generateColorV1Image(const SkGlyph&, void* dst);
79 bool drawColorV1Paint(SkCanvas&, IDWritePaintReader&, DWRITE_PAINT_ELEMENT const &);
80 bool drawColorV1Image(const SkGlyph&, SkCanvas&);
81
82 bool getColorGlyphRun(const SkGlyph&, IDWriteColorGlyphRunEnumerator**);
83 bool generateColorMetrics(const SkGlyph&, SkRect*);
84 bool generateColorImage(const SkGlyph&, void* dst);
85 bool drawColorImage(const SkGlyph&, SkCanvas&);
86
87 bool generateSVGMetrics(const SkGlyph&, SkRect*);
88 bool generateSVGImage(const SkGlyph&, void* dst);
89 bool drawSVGImage(const SkGlyph&, SkCanvas&);
90
91 bool generatePngMetrics(const SkGlyph&, SkRect*);
92 bool generatePngImage(const SkGlyph&, void* dst);
93 bool drawPngImage(const SkGlyph&, SkCanvas&);
94
95 bool generateDWMetrics(const SkGlyph&, DWRITE_RENDERING_MODE, DWRITE_TEXTURE_TYPE, SkRect*);
96 const void* getDWMaskBits(const SkGlyph&, DWRITE_RENDERING_MODE, DWRITE_TEXTURE_TYPE);
97 bool generateDWImage(const SkGlyph&, void* dst);
98
100 /** The total matrix without the text height scale. */
101 SkMatrix fSkXform;
102 /** The total matrix without the text height scale. */
103 DWRITE_MATRIX fXform;
104 /** The text size to render with. */
105 SkScalar fTextSizeRender;
106 /** The text size to measure with. */
107 SkScalar fTextSizeMeasure;
108 int fGlyphCount;
109 DWRITE_RENDERING_MODE fRenderingMode;
110 DWRITE_TEXTURE_TYPE fTextureType;
111 DWRITE_MEASURING_MODE fMeasuringMode;
112 DWRITE_TEXT_ANTIALIAS_MODE fAntiAliasMode;
113 DWRITE_GRID_FIT_MODE fGridFitMode;
114};
115
116#endif
#define PNG(FLAG, ZLIBLEVEL)
Definition: EncodeBench.cpp:85
#define SK_RESTRICT
Definition: SkFeatures.h:42
Definition: SkPath.h:59
void generateImage(const SkGlyph &, void *imageBuffer) override
~SkScalerContext_DW() override
SkScalerContext_DW(sk_sp< DWriteFontTypeface >, const SkScalerContextEffects &, const SkDescriptor *)
sk_sp< SkDrawable > generateDrawable(const SkGlyph &) override
GlyphMetrics generateMetrics(const SkGlyph &, SkArenaAlloc *) override
void generateFontMetrics(SkFontMetrics *) override
bool generatePath(const SkGlyph &, SkPath *) override
SkTypeface * getTypeface() const
float SkScalar
Definition: extension.cpp:12
dst
Definition: cp.py:12