Clean up GPU strike sk_sp
Change-Id: Icece7d2e34307a52e58b195ba964d981999e15d1 Reviewed-on: https://skia-review.googlesource.com/155642 Commit-Queue: Herb Derby <herb@google.com> Reviewed-by: Ben Wagner <bungeman@google.com>
This commit is contained in:
parent
473b40b7ca
commit
cf370b1fc1
@ -388,21 +388,16 @@ void GrTextContext::drawGlyphRunList(
|
||||
}
|
||||
|
||||
void GrTextContext::AppendGlyph(GrTextBlob* blob, int runIndex,
|
||||
GrGlyphCache* grGlyphCache,
|
||||
sk_sp<GrTextStrike>* strike,
|
||||
const sk_sp<GrTextStrike>& strike,
|
||||
const SkGlyph& skGlyph, GrGlyph::MaskStyle maskStyle,
|
||||
SkScalar sx, SkScalar sy,
|
||||
GrColor color, SkGlyphCache* skGlyphCache,
|
||||
SkScalar textRatio, bool needsTransform) {
|
||||
if (!*strike) {
|
||||
*strike = grGlyphCache->getStrike(skGlyphCache);
|
||||
}
|
||||
|
||||
GrGlyph::PackedID id = GrGlyph::Pack(skGlyph.getGlyphID(),
|
||||
skGlyph.getSubXFixed(),
|
||||
skGlyph.getSubYFixed(),
|
||||
maskStyle);
|
||||
GrGlyph* glyph = (*strike)->getGlyph(skGlyph, id, skGlyphCache);
|
||||
GrGlyph* glyph = strike->getGlyph(skGlyph, id, skGlyphCache);
|
||||
if (!glyph) {
|
||||
return;
|
||||
}
|
||||
@ -415,7 +410,7 @@ void GrTextContext::AppendGlyph(GrTextBlob* blob, int runIndex,
|
||||
SkRect glyphRect = rect_to_draw(skGlyph, {sx, sy}, textRatio, isDFT);
|
||||
|
||||
if (!glyphRect.isEmpty()) {
|
||||
blob->appendGlyph(runIndex, glyphRect, color, *strike, glyph, !needsTransform);
|
||||
blob->appendGlyph(runIndex, glyphRect, color, strike, glyph, !needsTransform);
|
||||
}
|
||||
}
|
||||
|
||||
@ -457,20 +452,19 @@ void GrTextContext::regenerateGlyphRunList(GrTextBlob* cacheBlob,
|
||||
|
||||
FallbackGlyphRunHelper fallbackTextHelper(viewMatrix, runPaint, textRatio);
|
||||
|
||||
sk_sp<GrTextStrike> currStrike;
|
||||
|
||||
{
|
||||
|
||||
auto cache = cacheBlob->setupCache(
|
||||
runIndex, props, flags, distanceFieldPaint, nullptr);
|
||||
|
||||
sk_sp<GrTextStrike> currStrike = glyphCache->getStrike(cache.get());
|
||||
|
||||
auto perSDF =
|
||||
[cacheBlob, runIndex, glyphCache, &currStrike,
|
||||
filteredColor, cache{cache.get()}, textRatio]
|
||||
[cacheBlob, runIndex, &currStrike, filteredColor, cache{cache.get()}, textRatio]
|
||||
(const SkGlyph& glyph, SkPoint position) {
|
||||
SkScalar sx = position.fX,
|
||||
sy = position.fY;
|
||||
AppendGlyph(cacheBlob, runIndex, glyphCache, &currStrike,
|
||||
AppendGlyph(cacheBlob, runIndex, currStrike,
|
||||
glyph, GrGlyph::kDistance_MaskStyle, sx, sy,
|
||||
filteredColor,
|
||||
cache, textRatio, true);
|
||||
@ -546,19 +540,21 @@ void GrTextContext::regenerateGlyphRunList(GrTextBlob* cacheBlob,
|
||||
} else {
|
||||
// Ensure the blob is set for bitmaptext
|
||||
cacheBlob->setHasBitmap();
|
||||
sk_sp<GrTextStrike> currStrike;
|
||||
|
||||
auto cache = cacheBlob->setupCache(
|
||||
runIndex, props, scalerContextFlags, runPaint, &viewMatrix);
|
||||
|
||||
sk_sp<GrTextStrike> currStrike = glyphCache->getStrike(cache.get());
|
||||
|
||||
auto perGlyph =
|
||||
[cacheBlob, runIndex, glyphCache, &currStrike, filteredColor, cache{cache.get()}]
|
||||
[cacheBlob, runIndex, &currStrike, filteredColor, cache{cache.get()}]
|
||||
(const SkGlyph& glyph, SkPoint mappedPt) {
|
||||
if (!glyph.isEmpty()) {
|
||||
const void* glyphImage = cache->findImage(glyph);
|
||||
if (glyphImage != nullptr) {
|
||||
SkScalar sx = SkScalarFloorToScalar(mappedPt.fX),
|
||||
sy = SkScalarFloorToScalar(mappedPt.fY);
|
||||
AppendGlyph(cacheBlob, runIndex, glyphCache, &currStrike,
|
||||
AppendGlyph(cacheBlob, runIndex, currStrike,
|
||||
glyph, GrGlyph::kCoverage_MaskStyle, sx, sy,
|
||||
filteredColor, cache, SK_Scalar1, false);
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ SkExclusiveStrikePtr GrTextBlob::setupCache(int runIndex,
|
||||
void GrTextBlob::appendGlyph(int runIndex,
|
||||
const SkRect& positions,
|
||||
GrColor color,
|
||||
sk_sp<GrTextStrike> strike,
|
||||
const sk_sp<GrTextStrike>& strike,
|
||||
GrGlyph* glyph, bool preTransformed) {
|
||||
|
||||
Run& run = fRuns[runIndex];
|
||||
@ -82,9 +82,9 @@ void GrTextBlob::appendGlyph(int runIndex,
|
||||
Run::SubRunInfo* subRun = &run.fSubRunInfo.back();
|
||||
if (run.fInitialized && subRun->maskFormat() != format) {
|
||||
subRun = &run.push_back();
|
||||
subRun->setStrike(std::move(strike));
|
||||
subRun->setStrike(strike);
|
||||
} else if (!run.fInitialized) {
|
||||
subRun->setStrike(std::move(strike));
|
||||
subRun->setStrike(strike);
|
||||
}
|
||||
|
||||
run.fInitialized = true;
|
||||
|
@ -177,7 +177,7 @@ public:
|
||||
void appendGlyph(int runIndex,
|
||||
const SkRect& positions,
|
||||
GrColor color,
|
||||
sk_sp<GrTextStrike> strike,
|
||||
const sk_sp<GrTextStrike>& strike,
|
||||
GrGlyph* glyph, bool preTransformed);
|
||||
|
||||
// Appends a glyph to the blob as a path only.
|
||||
|
@ -243,7 +243,7 @@ void GrTextContext::FallbackGlyphRunHelper::drawGlyphs(
|
||||
SkExclusiveStrikePtr cache =
|
||||
blob->setupCache(runIndex, props, scalerContextFlags, fallbackPaint, &matrix);
|
||||
|
||||
sk_sp<GrTextStrike> currStrike;
|
||||
sk_sp<GrTextStrike> currStrike = glyphCache->getStrike(cache.get());
|
||||
auto glyphPos = fFallbackPos.begin();
|
||||
for (auto glyphID : fFallbackTxt) {
|
||||
const SkGlyph& glyph = cache->getGlyphIDMetrics(glyphID);
|
||||
@ -252,7 +252,7 @@ void GrTextContext::FallbackGlyphRunHelper::drawGlyphs(
|
||||
glyphPos->fX = SkScalarFloorToScalar(glyphPos->fX);
|
||||
glyphPos->fY = SkScalarFloorToScalar(glyphPos->fY);
|
||||
}
|
||||
GrTextContext::AppendGlyph(blob, runIndex, glyphCache, &currStrike,
|
||||
GrTextContext::AppendGlyph(blob, runIndex, currStrike,
|
||||
glyph, GrGlyph::kCoverage_MaskStyle,
|
||||
glyphPos->fX, glyphPos->fY, textColor,
|
||||
cache.get(), textRatio, fUseTransformedFallback);
|
||||
|
@ -122,9 +122,9 @@ private:
|
||||
const SkGlyphRunList& glyphRunList,
|
||||
SkGlyphRunListPainter* glyphPainter);
|
||||
|
||||
static void AppendGlyph(GrTextBlob*, int runIndex, GrGlyphCache*,
|
||||
sk_sp<GrTextStrike>*, const SkGlyph&, GrGlyph::MaskStyle maskStyle,
|
||||
SkScalar sx, SkScalar sy,
|
||||
static void AppendGlyph(GrTextBlob*, int runIndex,
|
||||
const sk_sp<GrTextStrike>&, const SkGlyph&,
|
||||
GrGlyph::MaskStyle maskStyle, SkScalar sx, SkScalar sy,
|
||||
GrColor color, SkGlyphCache*, SkScalar textRatio,
|
||||
bool needsTransform);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user