Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
sktext::gpu::TextBlob::Key Struct Reference

#include <TextBlob.h>

Public Member Functions

bool operator== (const Key &other) const
 

Static Public Member Functions

static std::tuple< bool, KeyMake (const GlyphRunList &glyphRunList, const SkPaint &paint, const SkMatrix &drawMatrix, const SkStrikeDeviceInfo &strikeDevice)
 

Public Attributes

uint32_t fUniqueID
 
SkColor fCanonicalColor
 
SkScalar fFrameWidth
 
SkScalar fMiterLimit
 
SkPixelGeometry fPixelGeometry
 
SkMaskFilterBase::BlurRec fBlurRec
 
uint32_t fScalerContextFlags
 
SkMatrix fPositionMatrix
 
bool fHasSomeDirectSubRuns
 
bool fHasBlur
 
SkPaint::Style fStyle
 
SkPaint::Join fJoin
 

Detailed Description

Definition at line 58 of file TextBlob.h.

Member Function Documentation

◆ Make()

auto sktext::gpu::TextBlob::Key::Make ( const GlyphRunList glyphRunList,
const SkPaint paint,
const SkMatrix drawMatrix,
const SkStrikeDeviceInfo strikeDevice 
)
static

Definition at line 84 of file TextBlob.cpp.

87 {
88 SkASSERT(strikeDevice.fSDFTControl != nullptr);
90 // It might be worth caching these things, but its not clear at this time
91 // TODO for animated mask filters, this will fill up our cache. We need a safeguard here
92 const SkMaskFilter* maskFilter = paint.getMaskFilter();
93 bool canCache = glyphRunList.canCache() &&
94 !(paint.getPathEffect() ||
95 (maskFilter && !as_MFB(maskFilter)->asABlur(&blurRec)));
96
98 if (canCache) {
99 bool hasLCD = glyphRunList.anyRunsLCD();
100
101 // We canonicalize all non-lcd draws to use kUnknown_SkPixelGeometry
102 SkPixelGeometry pixelGeometry = hasLCD ? strikeDevice.fSurfaceProps.pixelGeometry()
104
105 SkColor canonicalColor = compute_canonical_color(paint, hasLCD);
106
107 key.fPixelGeometry = pixelGeometry;
108 key.fUniqueID = glyphRunList.uniqueID();
109 key.fStyle = paint.getStyle();
111 key.fFrameWidth = paint.getStrokeWidth();
112 key.fMiterLimit = paint.getStrokeMiter();
113 key.fJoin = paint.getStrokeJoin();
114 }
115 key.fHasBlur = maskFilter != nullptr;
116 if (key.fHasBlur) {
117 key.fBlurRec = blurRec;
118 }
119 key.fCanonicalColor = canonicalColor;
120 key.fScalerContextFlags = SkTo<uint32_t>(strikeDevice.fScalerContextFlags);
121
122 // Do any runs use direct drawing types?.
124 SkPoint glyphRunListLocation = glyphRunList.sourceBoundsWithOrigin().center();
125 for (auto& run : glyphRunList) {
126 SkScalar approximateDeviceTextSize =
128 glyphRunListLocation);
130 strikeDevice.fSDFTControl->isDirect(approximateDeviceTextSize, paint,
131 drawMatrix);
132 }
133
135 // Store the fractional offset of the position. We know that the matrix can't be
136 // perspective at this point.
137 SkPoint mappedOrigin = drawMatrix.mapOrigin();
138 key.fPositionMatrix = drawMatrix;
140 mappedOrigin.x() - SkScalarFloorToScalar(mappedOrigin.x()));
142 mappedOrigin.y() - SkScalarFloorToScalar(mappedOrigin.y()));
143 } else {
144 // For path and SDFT, the matrix doesn't matter.
146 }
147 }
148
149 return {canCache, key};
150}
#define SkASSERT(cond)
Definition SkAssert.h:116
uint32_t SkColor
Definition SkColor.h:37
SkMaskFilterBase * as_MFB(SkMaskFilter *mf)
#define SkScalarFloorToScalar(x)
Definition SkScalar.h:30
SkPixelGeometry
@ kUnknown_SkPixelGeometry
static SkScalar ApproximateTransformedTextSize(const SkFont &font, const SkMatrix &matrix, const SkPoint &textLocation)
Definition SkFont.cpp:366
virtual bool asABlur(BlurRec *) const
SkMatrix & setTranslateY(SkScalar v)
Definition SkMatrix.h:530
SkMatrix & setTranslateX(SkScalar v)
Definition SkMatrix.h:524
static const SkMatrix & I()
SkPoint mapOrigin() const
Definition SkMatrix.h:1437
@ kFill_Style
set to fill geometry
Definition SkPaint.h:193
SkPixelGeometry pixelGeometry() const
bool isDirect(SkScalar approximateDeviceTextSize, const SkPaint &paint, const SkMatrix &matrix) const
const Key & key()
Definition TextBlob.h:106
const Paint & paint
float SkScalar
Definition extension.cpp:12
Definition run.py:1
constexpr float y() const
constexpr float x() const
const SkSurfaceProps fSurfaceProps
Definition SkDevice.h:80
const SkScalerContextFlags fScalerContextFlags
Definition SkDevice.h:81
const sktext::gpu::SDFTControl *const fSDFTControl
Definition SkDevice.h:83
SkPixelGeometry fPixelGeometry
Definition TextBlob.h:71
SkPaint::Style fStyle
Definition TextBlob.h:78
SkMaskFilterBase::BlurRec fBlurRec
Definition TextBlob.h:72

◆ operator==()

bool sktext::gpu::TextBlob::Key::operator== ( const Key other) const

Definition at line 152 of file TextBlob.cpp.

152 {
153 if (fUniqueID != that.fUniqueID) { return false; }
154 if (fCanonicalColor != that.fCanonicalColor) { return false; }
155 if (fStyle != that.fStyle) { return false; }
157 if (fFrameWidth != that.fFrameWidth ||
158 fMiterLimit != that.fMiterLimit ||
159 fJoin != that.fJoin) {
160 return false;
161 }
162 }
163 if (fPixelGeometry != that.fPixelGeometry) { return false; }
164 if (fHasBlur != that.fHasBlur) { return false; }
165 if (fHasBlur) {
166 if (fBlurRec.fStyle != that.fBlurRec.fStyle || fBlurRec.fSigma != that.fBlurRec.fSigma) {
167 return false;
168 }
169 }
170
171 if (fScalerContextFlags != that.fScalerContextFlags) { return false; }
172
173 // DirectSubRuns do not support perspective when used with a TextBlob. SDFT, Transformed,
174 // Path, and Drawable do support perspective.
175 if (fPositionMatrix.hasPerspective() && fHasSomeDirectSubRuns) { return false; }
176
177 if (fHasSomeDirectSubRuns != that.fHasSomeDirectSubRuns) { return false; }
178
180 auto [compatible, _] = can_use_direct(fPositionMatrix, that.fPositionMatrix);
181 return compatible;
182 }
183
184 return true;
185}
static bool compatible(const MTLRenderPassAttachmentDescriptor *first, const MTLRenderPassAttachmentDescriptor *second, const GrMtlPipelineState *pipelineState)
bool hasPerspective() const
Definition SkMatrix.h:312
static std::tuple< bool, SkVector > can_use_direct(const SkMatrix &creationMatrix, const SkMatrix &positionMatrix)

Member Data Documentation

◆ fBlurRec

SkMaskFilterBase::BlurRec sktext::gpu::TextBlob::Key::fBlurRec

Definition at line 72 of file TextBlob.h.

◆ fCanonicalColor

SkColor sktext::gpu::TextBlob::Key::fCanonicalColor

Definition at line 68 of file TextBlob.h.

◆ fFrameWidth

SkScalar sktext::gpu::TextBlob::Key::fFrameWidth

Definition at line 69 of file TextBlob.h.

◆ fHasBlur

bool sktext::gpu::TextBlob::Key::fHasBlur

Definition at line 77 of file TextBlob.h.

◆ fHasSomeDirectSubRuns

bool sktext::gpu::TextBlob::Key::fHasSomeDirectSubRuns

Definition at line 76 of file TextBlob.h.

◆ fJoin

SkPaint::Join sktext::gpu::TextBlob::Key::fJoin

Definition at line 79 of file TextBlob.h.

◆ fMiterLimit

SkScalar sktext::gpu::TextBlob::Key::fMiterLimit

Definition at line 70 of file TextBlob.h.

◆ fPixelGeometry

SkPixelGeometry sktext::gpu::TextBlob::Key::fPixelGeometry

Definition at line 71 of file TextBlob.h.

◆ fPositionMatrix

SkMatrix sktext::gpu::TextBlob::Key::fPositionMatrix

Definition at line 74 of file TextBlob.h.

◆ fScalerContextFlags

uint32_t sktext::gpu::TextBlob::Key::fScalerContextFlags

Definition at line 73 of file TextBlob.h.

◆ fStyle

SkPaint::Style sktext::gpu::TextBlob::Key::fStyle

Definition at line 78 of file TextBlob.h.

◆ fUniqueID

uint32_t sktext::gpu::TextBlob::Key::fUniqueID

Definition at line 63 of file TextBlob.h.


The documentation for this struct was generated from the following files: