Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(969)

Unified Diff: src/gpu/text/GrAtlasTextContext.cpp

Issue 1552513003: Revert of Make draw* lines responsible for cache management (Closed) Base URL: https://skia.googlesource.com/skia.git@cleanuptext13reallytexutilsdf
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/text/GrAtlasTextContext.h ('k') | src/gpu/text/GrTextUtils.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/text/GrAtlasTextContext.cpp
diff --git a/src/gpu/text/GrAtlasTextContext.cpp b/src/gpu/text/GrAtlasTextContext.cpp
index 37cd53d08061bc51e8c82e36c29cf9126fd58b70..3769b0b439b0af840a4f11948d5930673321bf02 100644
--- a/src/gpu/text/GrAtlasTextContext.cpp
+++ b/src/gpu/text/GrAtlasTextContext.cpp
@@ -103,6 +103,15 @@
}
}
return false;
+}
+
+inline SkGlyphCache* GrAtlasTextContext::setupCache(GrAtlasTextBlob::Run* run,
+ const SkPaint& skPaint,
+ const SkMatrix* viewMatrix,
+ bool noGamma) {
+ skPaint.getScalerContextDescriptor(&run->fDescriptor, fSurfaceProps, viewMatrix, noGamma);
+ run->fTypeface.reset(SkSafeRef(skPaint.getTypeface()));
+ return SkGlyphCache::DetachCache(run->fTypeface, run->fDescriptor.getDesc());
}
void GrAtlasTextContext::drawTextBlob(GrDrawContext* dc,
@@ -282,17 +291,18 @@
PerSubRunInfo& subRun = runIdx.fSubRunInfo.back();
subRun.setUseLCDText(runPaint.isLCDRenderText());
subRun.setDrawAsDistanceFields();
+ SkGlyphCache* cache = this->setupCache(&cacheBlob->fRuns[run], dfPaint, nullptr, true);
switch (it.positioning()) {
case SkTextBlob::kDefault_Positioning: {
- this->internalDrawDFText(cacheBlob, run, dfPaint, color, viewMatrix,
+ this->internalDrawDFText(cacheBlob, run, cache, dfPaint, color, viewMatrix,
(const char *)it.glyphs(), textLen,
x + offset.x(), y + offset.y(), textRatio, runPaint);
break;
}
case SkTextBlob::kHorizontal_Positioning: {
SkPoint dfOffset = SkPoint::Make(x, y + offset.y());
- this->internalDrawDFPosText(cacheBlob, run, dfPaint, color, viewMatrix,
+ this->internalDrawDFPosText(cacheBlob, run, cache, dfPaint, color, viewMatrix,
(const char*)it.glyphs(), textLen, it.pos(),
1, dfOffset, textRatio,
runPaint);
@@ -300,36 +310,40 @@
}
case SkTextBlob::kFull_Positioning: {
SkPoint dfOffset = SkPoint::Make(x, y);
- this->internalDrawDFPosText(cacheBlob, run, dfPaint, color, viewMatrix,
+ this->internalDrawDFPosText(cacheBlob, run, cache, dfPaint, color, viewMatrix,
(const char*)it.glyphs(), textLen, it.pos(),
2, dfOffset, textRatio, runPaint);
break;
}
}
+ SkGlyphCache::AttachCache(cache);
} else if (SkDraw::ShouldDrawTextAsPaths(runPaint, viewMatrix)) {
cacheBlob->fRuns[run].fDrawAsPaths = true;
} else {
cacheBlob->setHasBitmap();
+ SkGlyphCache* cache = this->setupCache(&cacheBlob->fRuns[run], runPaint, &viewMatrix,
+ false);
switch (it.positioning()) {
case SkTextBlob::kDefault_Positioning:
GrTextUtils::DrawBmpText(cacheBlob, run, fContext->getBatchFontCache(),
- fSurfaceProps, runPaint, color, viewMatrix,
+ cache, runPaint, color, viewMatrix,
(const char *)it.glyphs(), textLen,
x + offset.x(), y + offset.y());
break;
case SkTextBlob::kHorizontal_Positioning:
GrTextUtils::DrawBmpPosText(cacheBlob, run, fContext->getBatchFontCache(),
- fSurfaceProps, runPaint, color, viewMatrix,
+ cache, runPaint, color, viewMatrix,
(const char*)it.glyphs(), textLen, it.pos(), 1,
SkPoint::Make(x, y + offset.y()));
break;
case SkTextBlob::kFull_Positioning:
GrTextUtils::DrawBmpPosText(cacheBlob, run, fContext->getBatchFontCache(),
- fSurfaceProps, runPaint, color, viewMatrix,
+ cache, runPaint, color, viewMatrix,
(const char*)it.glyphs(), textLen, it.pos(), 2,
SkPoint::Make(x, y));
break;
}
+ SkGlyphCache::AttachCache(cache);
}
if (drawFilter) {
@@ -408,9 +422,14 @@
// Push back a new subrun to fill and set the override descriptor
run.push_back();
run.fOverrideDescriptor.reset(new SkAutoDescriptor);
- GrTextUtils::DrawBmpPosText(blob, runIndex, fContext->getBatchFontCache(), fSurfaceProps,
- skPaint, color, viewMatrix, fallbackTxt.begin(), fallbackTxt.count(),
+ skPaint.getScalerContextDescriptor(run.fOverrideDescriptor,
+ fSurfaceProps, &viewMatrix, false);
+ SkGlyphCache* cache = SkGlyphCache::DetachCache(run.fTypeface,
+ run.fOverrideDescriptor->getDesc());
+ GrTextUtils::DrawBmpPosText(blob, runIndex, fContext->getBatchFontCache(), cache, skPaint,
+ color, viewMatrix, fallbackTxt.begin(), fallbackTxt.count(),
fallbackPos.begin(), scalarsPerPosition, offset);
+ SkGlyphCache::AttachCache(cache);
}
inline GrAtlasTextBlob*
@@ -442,15 +461,19 @@
SkPaint dfPaint;
SkScalar textRatio;
blob = this->setupDFBlob(glyphCount, skPaint, viewMatrix, &dfPaint, &textRatio);
-
- this->internalDrawDFText(blob, 0, dfPaint, paint.getColor(), viewMatrix, text,
+ SkGlyphCache* cache = this->setupCache(&blob->fRuns[0], dfPaint, nullptr, true);
+
+ this->internalDrawDFText(blob, 0, cache, dfPaint, paint.getColor(), viewMatrix, text,
byteLength, x, y, textRatio, skPaint);
+ SkGlyphCache::AttachCache(cache);
} else {
blob = fCache->createBlob(glyphCount, 1, GrAtlasTextBlob::kGrayTextVASize);
blob->fViewMatrix = viewMatrix;
- GrTextUtils::DrawBmpText(blob, 0, fContext->getBatchFontCache(), fSurfaceProps, skPaint,
+ SkGlyphCache* cache = this->setupCache(&blob->fRuns[0], skPaint, &viewMatrix, false);
+ GrTextUtils::DrawBmpText(blob, 0, fContext->getBatchFontCache(), cache, skPaint,
paint.getColor(), viewMatrix, text, byteLength, x, y);
+ SkGlyphCache::AttachCache(cache);
}
return blob;
}
@@ -468,16 +491,20 @@
SkPaint dfPaint;
SkScalar textRatio;
blob = this->setupDFBlob(glyphCount, skPaint, viewMatrix, &dfPaint, &textRatio);
-
- this->internalDrawDFPosText(blob, 0, dfPaint, paint.getColor(), viewMatrix, text,
+ SkGlyphCache* cache = this->setupCache(&blob->fRuns[0], dfPaint, nullptr, true);
+
+ this->internalDrawDFPosText(blob, 0, cache, dfPaint, paint.getColor(), viewMatrix, text,
byteLength, pos, scalarsPerPosition, offset, textRatio,
skPaint);
+ SkGlyphCache::AttachCache(cache);
} else {
blob = fCache->createBlob(glyphCount, 1, GrAtlasTextBlob::kGrayTextVASize);
blob->fViewMatrix = viewMatrix;
- GrTextUtils::DrawBmpPosText(blob, 0, fContext->getBatchFontCache(), fSurfaceProps, skPaint,
+ SkGlyphCache* cache = this->setupCache(&blob->fRuns[0], skPaint, &viewMatrix, false);
+ GrTextUtils::DrawBmpPosText(blob, 0, fContext->getBatchFontCache(), cache, skPaint,
paint.getColor(), viewMatrix, text,
byteLength, pos, scalarsPerPosition, offset);
+ SkGlyphCache::AttachCache(cache);
}
return blob;
}
@@ -512,6 +539,7 @@
}
void GrAtlasTextContext::internalDrawDFText(GrAtlasTextBlob* blob, int runIndex,
+ SkGlyphCache* cache,
const SkPaint& skPaint, GrColor color,
const SkMatrix& viewMatrix,
const char text[], size_t byteLength,
@@ -577,11 +605,12 @@
y -= alignY;
SkPoint offset = SkPoint::Make(x, y);
- this->internalDrawDFPosText(blob, runIndex, skPaint, color, viewMatrix, text, byteLength,
+ this->internalDrawDFPosText(blob, runIndex, cache, skPaint, color, viewMatrix, text, byteLength,
positions.begin(), 2, offset, textRatio, origPaint);
}
void GrAtlasTextContext::internalDrawDFPosText(GrAtlasTextBlob* blob, int runIndex,
+ SkGlyphCache* cache,
const SkPaint& skPaint,
GrColor color,
const SkMatrix& viewMatrix,
@@ -604,7 +633,6 @@
fCurrStrike = nullptr;
- SkGlyphCache* cache = blob->setupCache(runIndex, fSurfaceProps, skPaint, nullptr, true);
SkDrawCacheProc glyphCacheProc = skPaint.getDrawCacheProc();
GrFontScaler* fontScaler = GetGrFontScaler(cache);
@@ -669,7 +697,6 @@
}
}
- SkGlyphCache::AttachCache(cache);
if (fallbackTxt.count()) {
this->fallbackDrawPosText(blob, runIndex, origPaint.getColor(), origPaint, viewMatrix,
fallbackTxt, fallbackPos, scalarsPerPosition, offset);
« no previous file with comments | « src/gpu/text/GrAtlasTextContext.h ('k') | src/gpu/text/GrTextUtils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698