77 return canonicalColor;
88 SkASSERT(strikeDevice.fSDFTControl !=
nullptr);
93 bool canCache = glyphRunList.canCache() &&
94 !(
paint.getPathEffect() ||
99 bool hasLCD = glyphRunList.anyRunsLCD();
102 SkPixelGeometry pixelGeometry = hasLCD ? strikeDevice.fSurfaceProps.pixelGeometry()
105 SkColor canonicalColor = compute_canonical_color(
paint, hasLCD);
107 key.fPixelGeometry = pixelGeometry;
108 key.fUniqueID = glyphRunList.uniqueID();
111 key.fFrameWidth =
paint.getStrokeWidth();
112 key.fMiterLimit =
paint.getStrokeMiter();
115 key.fHasBlur = maskFilter !=
nullptr;
117 key.fBlurRec = blurRec;
119 key.fCanonicalColor = canonicalColor;
120 key.fScalerContextFlags = SkTo<uint32_t>(strikeDevice.fScalerContextFlags);
123 key.fHasSomeDirectSubRuns =
false;
124 SkPoint glyphRunListLocation = glyphRunList.sourceBoundsWithOrigin().center();
125 for (
auto&
run : glyphRunList) {
126 SkScalar approximateDeviceTextSize =
128 glyphRunListLocation);
129 key.fHasSomeDirectSubRuns |=
130 strikeDevice.fSDFTControl->isDirect(approximateDeviceTextSize,
paint,
134 if (
key.fHasSomeDirectSubRuns) {
137 SkPoint mappedOrigin = drawMatrix.mapOrigin();
138 key.fPositionMatrix = drawMatrix;
139 key.fPositionMatrix.setTranslateX(
141 key.fPositionMatrix.setTranslateY(
149 return {canCache,
key};
188void TextBlob::operator
delete(
void*
p) { ::operator
delete(
p); }
189void* TextBlob::operator
new(size_t) {
SK_ABORT(
"All blobs are created by placement new."); }
190void* TextBlob::operator
new(size_t,
void*
p) {
return p; }
201 SubRunAllocator::AllocateClassMemoryAndArena<TextBlob>(subRunSizeHint);
204 glyphRunList, positionMatrix,
paint,
209 std::move(container),
210 totalMemoryAllocated,
222 if (fSubRuns->isEmpty() && fSubRuns->initialPosition() != positionMatrix) {
234 return fSubRuns->canReuse(
paint, positionMatrix);
243 fSubRuns->draw(canvas, drawOrigin,
paint,
this, atlasDelegate);
250 : fAlloc{
std::move(alloc)}
251 , fSubRuns{
std::move(subRuns)}
252 , fSize(totalMemorySize)
253 , fInitialLuminance{initialLuminance} { }
static struct Initializer initializer
static bool compatible(const MTLRenderPassAttachmentDescriptor *first, const MTLRenderPassAttachmentDescriptor *second, const GrMtlPipelineState *pipelineState)
#define SK_ABORT(message,...)
static U8CPU SkComputeLuminance(U8CPU r, U8CPU g, U8CPU b)
#define SkColorGetR(color)
#define SkColorGetG(color)
#define SkColorSetRGB(r, g, b)
constexpr SkColor SK_ColorTRANSPARENT
#define SkColorGetB(color)
SkMaskFilterBase * as_MFB(SkMaskFilter *mf)
#define SkScalarFloorToScalar(x)
static bool SkScalarIsInt(SkScalar x)
@ kUnknown_SkPixelGeometry
static SkScalar ApproximateTransformedTextSize(const SkFont &font, const SkMatrix &matrix, const SkPoint &textLocation)
virtual bool asABlur(BlurRec *) const
SkScalar getSkewY() const
SkScalar getSkewX() const
SkScalar getScaleX() const
static const SkMatrix & I()
SkScalar getScaleY() const
SkPoint mapOrigin() const
bool hasPerspective() const
static SkColor ComputeLuminanceColor(const SkPaint &)
@ kFill_Style
set to fill geometry
static SkColor CanonicalColor(SkColor color)
static sk_sp< SlugImpl > Make(const SkMatrix &viewMatrix, const sktext::GlyphRunList &glyphRunList, const SkPaint &paint, SkStrikeDeviceInfo strikeDeviceInfo, sktext::StrikeForGPUCacheInterface *strikeCache)
static SubRunContainerOwner MakeInAlloc(const GlyphRunList &glyphRunList, const SkMatrix &positionMatrix, const SkPaint &runPaint, SkStrikeDeviceInfo strikeDeviceInfo, StrikeForGPUCacheInterface *strikeCache, sktext::gpu::SubRunAllocator *alloc, SubRunCreationBehavior creationBehavior, const char *tag)
static size_t EstimateAllocSize(const GlyphRunList &glyphRunList)
TextBlob(SubRunAllocator &&alloc, SubRunContainerOwner subRuns, int totalMemorySize, SkColor initialLuminance)
bool canReuse(const SkPaint &paint, const SkMatrix &positionMatrix) const
void addKey(const Key &key)
void draw(SkCanvas *, SkPoint drawOrigin, const SkPaint &paint, const AtlasDrawDelegate &)
static sk_sp< TextBlob > Make(const sktext::GlyphRunList &glyphRunList, const SkPaint &paint, const SkMatrix &positionMatrix, SkStrikeDeviceInfo strikeDeviceInfo, StrikeForGPUCacheInterface *strikeCache)
static float lum(float r, float g, float b)
static std::tuple< bool, SkVector > can_use_direct(const SkMatrix &creationMatrix, const SkMatrix &positionMatrix)
std::unique_ptr< SubRunContainer, SubRunAllocator::Destroyer > SubRunContainerOwner
sk_sp< Slug > MakeSlug(const SkMatrix &drawMatrix, const sktext::GlyphRunList &glyphRunList, const SkPaint &paint, SkStrikeDeviceInfo strikeDeviceInfo, sktext::StrikeForGPUCacheInterface *strikeCache)
std::function< void(const sktext::gpu::AtlasSubRun *subRun, SkPoint drawOrigin, const SkPaint &paint, sk_sp< SkRefCnt > subRunStorage, sktext::gpu::RendererData)> AtlasDrawDelegate
constexpr float y() const
constexpr float x() const
SkPixelGeometry fPixelGeometry
uint32_t fScalerContextFlags
bool fHasSomeDirectSubRuns
static std::tuple< bool, Key > Make(const GlyphRunList &glyphRunList, const SkPaint &paint, const SkMatrix &drawMatrix, const SkStrikeDeviceInfo &strikeDevice)
SkMaskFilterBase::BlurRec fBlurRec
bool operator==(const Key &other) const