Use SkMutex::assertHeld in SkPDFFont and SkPDFShader.
R=mtklein@google.com
Author: halcanary@google.com
Review URL: https://codereview.chromium.org/348113002
diff --git a/src/pdf/SkPDFFont.cpp b/src/pdf/SkPDFFont.cpp
index 49d383b..014b328 100644
--- a/src/pdf/SkPDFFont.cpp
+++ b/src/pdf/SkPDFFont.cpp
@@ -872,15 +872,13 @@
// static
SkTDArray<SkPDFFont::FontRec>& SkPDFFont::CanonicalFonts() {
- // This initialization is only thread safe with gcc.
+ SkPDFFont::CanonicalFontsMutex().assertHeld();
static SkTDArray<FontRec> gCanonicalFonts;
return gCanonicalFonts;
}
// static
SkBaseMutex& SkPDFFont::CanonicalFontsMutex() {
- // This initialization is only thread safe with gcc, or when
- // POD-style mutex initialization is used.
SK_DECLARE_STATIC_MUTEX(gCanonicalFontsMutex);
return gCanonicalFontsMutex;
}
diff --git a/src/pdf/SkPDFShader.cpp b/src/pdf/SkPDFShader.cpp
index 62adf58..23bd203 100644
--- a/src/pdf/SkPDFShader.cpp
+++ b/src/pdf/SkPDFShader.cpp
@@ -659,22 +659,20 @@
// static
SkTDArray<SkPDFShader::ShaderCanonicalEntry>& SkPDFShader::CanonicalShaders() {
- // This initialization is only thread safe with gcc.
+ SkPDFShader::CanonicalShadersMutex().assertHeld();
static SkTDArray<ShaderCanonicalEntry> gCanonicalShaders;
return gCanonicalShaders;
}
// static
SkBaseMutex& SkPDFShader::CanonicalShadersMutex() {
- // This initialization is only thread safe with gcc or when
- // POD-style mutex initialization is used.
SK_DECLARE_STATIC_MUTEX(gCanonicalShadersMutex);
return gCanonicalShadersMutex;
}
// static
SkPDFObject* SkPDFFunctionShader::RangeObject() {
- // This initialization is only thread safe with gcc.
+ SkPDFShader::CanonicalShadersMutex().assertHeld();
static SkPDFArray* range = NULL;
// This method is only used with CanonicalShadersMutex, so it's safe to
// populate domain.