Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkStrikeSpec.h
Go to the documentation of this file.
1/*
2 * Copyright 2019 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 SkStrikeSpec_DEFINED
9#define SkStrikeSpec_DEFINED
10
15#include "include/core/SkSpan.h"
22
23#include <memory>
24#include <tuple>
25
26class SkFont;
27class SkGlyph;
28class SkMatrix;
29class SkPaint;
30class SkStrike;
31class SkStrikeCache;
32class SkSurfaceProps;
33struct SkPackedGlyphID;
34namespace sktext {
35class StrikeForGPU;
36class StrikeForGPUCacheInterface;
37}
38
40public:
44
47
49
50 // Create a strike spec for mask style cache entries.
52 const SkFont& font,
53 const SkPaint& paint,
54 const SkSurfaceProps& surfaceProps,
55 SkScalerContextFlags scalerContextFlags,
56 const SkMatrix& deviceMatrix);
57
58 // A strike for finding the max size for transforming masks. This is used to calculate the
59 // maximum dimension of a SubRun of text.
61 const SkFont& font,
62 const SkPaint& paint,
63 const SkSurfaceProps& surfaceProps,
64 SkScalerContextFlags scalerContextFlags,
65 const SkMatrix& deviceMatrix);
66
67 // Create a strike spec for path style cache entries.
68 static std::tuple<SkStrikeSpec, SkScalar> MakePath(
69 const SkFont& font,
70 const SkPaint& paint,
71 const SkSurfaceProps& surfaceProps,
72 SkScalerContextFlags scalerContextFlags);
73
74 // Create a canonical strike spec for device-less measurements.
75 static std::tuple<SkStrikeSpec, SkScalar> MakeCanonicalized(
76 const SkFont& font, const SkPaint* paint = nullptr);
77
78 // Create a strike spec without a device, and does not switch over to path for large sizes.
79 static SkStrikeSpec MakeWithNoDevice(const SkFont& font, const SkPaint* paint = nullptr);
80
81 // Make a strike spec for PDF Vector strikes
82 static SkStrikeSpec MakePDFVector(const SkTypeface& typeface, int* size);
83
86
88
90
91 std::unique_ptr<SkScalerContext> createScalerContext() const {
92 SkScalerContextEffects effects{fPathEffect.get(), fMaskFilter.get()};
93 return fTypeface->createScalerContext(effects, fAutoDescriptor.getDesc());
94 }
95
96 const SkDescriptor& descriptor() const { return *fAutoDescriptor.getDesc(); }
97 const SkTypeface& typeface() const { return *fTypeface; }
98 static bool ShouldDrawAsPath(const SkPaint& paint, const SkFont& font, const SkMatrix& matrix);
99 SkString dump() const;
100
101private:
103 const SkFont& font,
104 const SkPaint& paint,
105 const SkSurfaceProps& surfaceProps,
106 SkScalerContextFlags scalerContextFlags,
107 const SkMatrix& deviceMatrix);
108
109 SkAutoDescriptor fAutoDescriptor;
110 sk_sp<SkMaskFilter> fMaskFilter{nullptr};
111 sk_sp<SkPathEffect> fPathEffect{nullptr};
112 sk_sp<SkTypeface> fTypeface;
113};
114
116public:
117 explicit SkBulkGlyphMetrics(const SkStrikeSpec& spec);
120 const SkGlyph* glyph(SkGlyphID glyphID);
121
122private:
123 inline static constexpr int kTypicalGlyphCount = 20;
125 sk_sp<SkStrike> fStrike;
126};
127
129public:
130 explicit SkBulkGlyphMetricsAndPaths(const SkStrikeSpec& spec);
134 const SkGlyph* glyph(SkGlyphID glyphID);
135 void findIntercepts(const SkScalar bounds[2], SkScalar scale, SkScalar xPos,
136 const SkGlyph* glyph, SkScalar* array, int* count);
137
138private:
139 inline static constexpr int kTypicalGlyphCount = 20;
141 sk_sp<SkStrike> fStrike;
142};
143
145public:
146 explicit SkBulkGlyphMetricsAndDrawables(const SkStrikeSpec& spec);
150 const SkGlyph* glyph(SkGlyphID glyphID);
151
152private:
153 inline static constexpr int kTypicalGlyphCount = 20;
155 sk_sp<SkStrike> fStrike;
156};
157
159public:
160 explicit SkBulkGlyphMetricsAndImages(const SkStrikeSpec& spec);
164 const SkGlyph* glyph(SkPackedGlyphID packedID);
165 const SkDescriptor& descriptor() const;
166
167private:
168 inline static constexpr int kTypicalGlyphCount = 64;
170 sk_sp<SkStrike> fStrike;
171};
172
173#endif // SkStrikeSpec_DEFINED
uint16_t glyphs[5]
int count
SkScalerContextFlags
uint16_t SkGlyphID
Definition SkTypes.h:179
SkDescriptor * getDesc() const
const SkGlyph * glyph(SkGlyphID glyphID)
const SkDescriptor & descriptor() const
const SkGlyph * glyph(SkPackedGlyphID packedID)
void findIntercepts(const SkScalar bounds[2], SkScalar scale, SkScalar xPos, const SkGlyph *glyph, SkScalar *array, int *count)
const SkGlyph * glyph(SkGlyphID glyphID)
const SkGlyph * glyph(SkGlyphID glyphID)
sk_sp< sktext::StrikeForGPU > findOrCreateScopedStrike(sktext::StrikeForGPUCacheInterface *cache) const
static SkStrikeSpec MakeTransformMask(const SkFont &font, const SkPaint &paint, const SkSurfaceProps &surfaceProps, SkScalerContextFlags scalerContextFlags, const SkMatrix &deviceMatrix)
SkStrikeSpec & operator=(const SkStrikeSpec &)=delete
static SkStrikeSpec MakeMask(const SkFont &font, const SkPaint &paint, const SkSurfaceProps &surfaceProps, SkScalerContextFlags scalerContextFlags, const SkMatrix &deviceMatrix)
SkString dump() const
static SkStrikeSpec MakeWithNoDevice(const SkFont &font, const SkPaint *paint=nullptr)
const SkTypeface & typeface() const
SkStrikeSpec(SkStrikeSpec &&)
static bool ShouldDrawAsPath(const SkPaint &paint, const SkFont &font, const SkMatrix &matrix)
std::unique_ptr< SkScalerContext > createScalerContext() const
SkStrikeSpec & operator=(SkStrikeSpec &&)=delete
sk_sp< SkStrike > findOrCreateStrike() const
static std::tuple< SkStrikeSpec, SkScalar > MakeCanonicalized(const SkFont &font, const SkPaint *paint=nullptr)
static SkStrikeSpec MakePDFVector(const SkTypeface &typeface, int *size)
static std::tuple< SkStrikeSpec, SkScalar > MakePath(const SkFont &font, const SkPaint &paint, const SkSurfaceProps &surfaceProps, SkScalerContextFlags scalerContextFlags)
SkStrikeSpec(const SkStrikeSpec &)
const SkDescriptor & descriptor() const
std::unique_ptr< SkScalerContext > createScalerContext(const SkScalerContextEffects &, const SkDescriptor *) const
T * get() const
Definition SkRefCnt.h:303
const Paint & paint
float SkScalar
Definition extension.cpp:12
const Scalar scale