PathOpSubmitter: switch from using a Mutex to using SkOnce
Change-Id: I6e014afe71d056912a2afb2adf18cf517cd87364
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/565910
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Herb Derby <herb@google.com>
diff --git a/src/text/gpu/SubRunContainer.cpp b/src/text/gpu/SubRunContainer.cpp
index 27d0066..e352010 100644
--- a/src/text/gpu/SubRunContainer.cpp
+++ b/src/text/gpu/SubRunContainer.cpp
@@ -8,7 +8,7 @@
#include "src/text/gpu/SubRunContainer.h"
#include "include/core/SkScalar.h"
-#include "include/private/SkMutex.h"
+#include "include/private/SkOnce.h"
#include "include/private/chromium/SkChromeRemoteGlyphCache.h"
#include "src/core/SkDescriptor.h"
#include "src/core/SkDistanceFieldGen.h"
@@ -540,6 +540,7 @@
// If fStrikeRef.getStrikeAndSetToNullptr() is nullptr, then fIDsOrPaths holds SkPaths.
mutable StrikeRef fStrikeRef;
+ mutable SkOnce fConvertIDsToPaths;
};
int PathOpSubmitter::unflattenSize() const {
@@ -645,16 +646,13 @@
void PathOpSubmitter::submitDraws(SkCanvas* canvas,
SkPoint drawOrigin,
const SkPaint& paint) const {
- {
- // Add a mutex to get trough DDL testing. If this ends up being a problem we can change
- // over to using atomic pointers on the object.
- static SkMutex mu;
- SkAutoMutexExclusive lock{mu};
- // Convert all the SkGlyphIDs to SkPaths
+
+ // Convert the glyph IDs to paths if it hasn't been done yet. This is thread safe.
+ fConvertIDsToPaths([&]() {
if (sk_sp<SkStrike> strike = fStrikeRef.getStrikeAndSetToNullptr()) {
strike->glyphIDsToPaths(fIDsOrPaths);
}
- }
+ });
SkPaint runPaint{paint};
runPaint.setAntiAlias(fIsAntiAliased);