blob: 7b45c320caf9313b90759b27d8635cdfb4365290 [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
bungeman73c7c3c2016-06-16 14:41:53 -070018#include <dwrite_2.h>
kulshinc4b09152016-06-01 08:31:28 -070019#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:
bungeman7cfd46a2016-10-20 16:06:52 -040026 SkScalerContext_DW(sk_sp<DWriteFontTypeface>,
27 const SkScalerContextEffects&,
28 const SkDescriptor*);
bungeman51daa252014-06-05 13:38:45 -070029 virtual ~SkScalerContext_DW();
30
31protected:
mtklein36352bf2015-03-25 18:17:31 -070032 unsigned generateGlyphCount() override;
33 uint16_t generateCharToGlyph(SkUnichar uni) override;
34 void generateAdvance(SkGlyph* glyph) override;
35 void generateMetrics(SkGlyph* glyph) override;
36 void generateImage(const SkGlyph& glyph) override;
Ben Wagner6e9ac122016-11-11 14:31:06 -050037 void generatePath(SkGlyphID glyph, SkPath* path) override;
mtklein36352bf2015-03-25 18:17:31 -070038 void generateFontMetrics(SkPaint::FontMetrics*) override;
bungeman51daa252014-06-05 13:38:45 -070039
40private:
Ben Wagnerb2f7fce2014-08-27 19:17:41 -040041 const void* drawDWMask(const SkGlyph& glyph,
42 DWRITE_RENDERING_MODE renderingMode,
43 DWRITE_TEXTURE_TYPE textureType);
44
bungeman683a3762014-08-28 11:42:29 -070045 HRESULT getBoundingBox(SkGlyph* glyph,
46 DWRITE_RENDERING_MODE renderingMode,
47 DWRITE_TEXTURE_TYPE textureType,
48 RECT* bbox);
bungeman51daa252014-06-05 13:38:45 -070049
kulshinc4b09152016-06-01 08:31:28 -070050 bool isColorGlyph(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#if SK_HAS_DWRITE_2_H
57 bool getColorGlyphRun(const SkGlyph& glyph, IDWriteColorGlyphRunEnumerator** colorGlyph);
58
59 void generateColorGlyphImage(const SkGlyph& glyph);
60#endif
61
bungeman51daa252014-06-05 13:38:45 -070062 SkTDArray<uint8_t> fBits;
63 /** The total matrix without the text height scale. */
64 SkMatrix fSkXform;
65 /** The total matrix without the text height scale. */
66 DWRITE_MATRIX fXform;
67 /** The non-rotational part of total matrix without the text height scale.
68 * This is used to find the magnitude of gdi compatible advances.
69 */
70 DWRITE_MATRIX fGsA;
71 /** The inverse of the rotational part of the total matrix.
72 * This is used to find the direction of gdi compatible advances.
73 */
74 SkMatrix fG_inv;
75 /** The text size to render with. */
76 SkScalar fTextSizeRender;
77 /** The text size to measure with. */
78 SkScalar fTextSizeMeasure;
bungeman51daa252014-06-05 13:38:45 -070079 int fGlyphCount;
80 DWRITE_RENDERING_MODE fRenderingMode;
81 DWRITE_TEXTURE_TYPE fTextureType;
82 DWRITE_MEASURING_MODE fMeasuringMode;
kulshinc4b09152016-06-01 08:31:28 -070083#if SK_HAS_DWRITE_2_H
bungeman73c7c3c2016-06-16 14:41:53 -070084 SkTScopedComPtr<IDWriteFactory2> fFactory2;
bungemanbd770d62016-06-16 10:42:23 -070085 bool fIsColorFont;
bungeman73c7c3c2016-06-16 14:41:53 -070086#endif
bungeman51daa252014-06-05 13:38:45 -070087};
88
89#endif