build the entire blob and runs while single threaded
Change-Id: I4e98dd9da7a003fd6cd857301f1cfd1fabc65662
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/376176
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Herb Derby <herb@google.com>
diff --git a/src/gpu/GrSurfaceDrawContext.cpp b/src/gpu/GrSurfaceDrawContext.cpp
index 51ee7eb..a628b14 100644
--- a/src/gpu/GrSurfaceDrawContext.cpp
+++ b/src/gpu/GrSurfaceDrawContext.cpp
@@ -424,13 +424,6 @@
}
blob = GrTextBlob::Make(glyphRunList, drawMatrix);
- if (canCache) {
- blob->addKey(key);
- // The blob may already have been created on a different thread. Use the first one
- // that was there.
- blob = textBlobCache->addOrReturnExisting(glyphRunList, blob);
- }
-
bool supportsSDFT = fContext->priv().caps()->shaderCaps()->supportsDistanceFieldText();
blob->makeSubRuns(&fGlyphPainter,
glyphRunList,
@@ -440,6 +433,13 @@
fSurfaceProps,
supportsSDFT,
options);
+
+ if (canCache) {
+ blob->addKey(key);
+ // The blob may already have been created on a different thread. Use the first one
+ // that was there.
+ blob = textBlobCache->addOrReturnExisting(glyphRunList, blob);
+ }
}
for (const GrSubRun& subRun : blob->subRunList()) {
diff --git a/src/gpu/text/GrTextBlob.cpp b/src/gpu/text/GrTextBlob.cpp
index 618d2dc..1b14062 100644
--- a/src/gpu/text/GrTextBlob.cpp
+++ b/src/gpu/text/GrTextBlob.cpp
@@ -1498,19 +1498,15 @@
const SkSurfaceProps& props,
bool contextSupportsDistanceFieldText,
const GrSDFTOptions& options) {
- SkAutoSpinlock lock{fSpinLock};
- if (!fSubRunsCreated) {
- for (auto& glyphRun : glyphRunList) {
- painter->processGlyphRun(glyphRun,
- drawMatrix,
- drawOrigin,
- runPaint,
- props,
- contextSupportsDistanceFieldText,
- options,
- this);
- }
- fSubRunsCreated = true;
+ for (auto& glyphRun : glyphRunList) {
+ painter->processGlyphRun(glyphRun,
+ drawMatrix,
+ drawOrigin,
+ runPaint,
+ props,
+ contextSupportsDistanceFieldText,
+ options,
+ this);
}
}
diff --git a/src/gpu/text/GrTextBlob.h b/src/gpu/text/GrTextBlob.h
index 80998a7..bd3757a 100644
--- a/src/gpu/text/GrTextBlob.h
+++ b/src/gpu/text/GrTextBlob.h
@@ -407,7 +407,7 @@
const SkPaint& runPaint,
const SkSurfaceProps& props,
bool contextSupportsDistanceFieldText,
- const GrSDFTOptions& options) SK_EXCLUDES(fSpinLock);
+ const GrSDFTOptions& options);
static const Key& GetKey(const GrTextBlob& blob);
static uint32_t Hash(const Key& key);
@@ -452,14 +452,6 @@
void processSourceMasks(const SkZip<SkGlyphVariant, SkPoint>& drawables,
const SkStrikeSpec& strikeSpec) override;
- // The run must be created only once.
- bool fSubRunsCreated SK_GUARDED_BY(fSpinLock) {false};
-
- // This lock guards makeSubRuns, but also guards addMultiMaskFormat, processDeviceMasks,
- // processSourcePaths, processSourceSDFT, and processSourceMasks. These are callbacks, and
- // there is no way for the annotation system to track the lock through processGlyphRun.
- mutable SkSpinlock fSpinLock;
-
// The allocator must come first because it needs to be destroyed last. Other fields of this
// structure may have pointers into it.
GrSubRunAllocator fAlloc;