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

Unified Diff: src/pdf/SkPDFGraphicState.cpp

Issue 313823004: Add assertHeld() to SkMutex. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: more Created 6 years, 6 months 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/core/SkScaledImageCache.cpp ('k') | src/ports/SkMutex_pthread.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pdf/SkPDFGraphicState.cpp
diff --git a/src/pdf/SkPDFGraphicState.cpp b/src/pdf/SkPDFGraphicState.cpp
index 9f8edfd2061bf593420e57e0090bbb37d83a81e8..1b495341b9159065c7bde6e25edfad6543335c3c 100644
--- a/src/pdf/SkPDFGraphicState.cpp
+++ b/src/pdf/SkPDFGraphicState.cpp
@@ -82,24 +82,20 @@ size_t SkPDFGraphicState::getOutputSize(SkPDFCatalog* catalog, bool indirect) {
}
// static
-SkTDArray<SkPDFGraphicState::GSCanonicalEntry>&
-SkPDFGraphicState::CanonicalPaints() {
- // This initialization is only thread safe with gcc.
+SkTDArray<SkPDFGraphicState::GSCanonicalEntry>& SkPDFGraphicState::CanonicalPaints() {
+ CanonicalPaintsMutex().assertHeld();
static SkTDArray<SkPDFGraphicState::GSCanonicalEntry> gCanonicalPaints;
return gCanonicalPaints;
}
// static
SkBaseMutex& SkPDFGraphicState::CanonicalPaintsMutex() {
- // This initialization is only thread safe with gcc or when
- // POD-style mutex initialization is used.
SK_DECLARE_STATIC_MUTEX(gCanonicalPaintsMutex);
return gCanonicalPaintsMutex;
}
// static
-SkPDFGraphicState* SkPDFGraphicState::GetGraphicStateForPaint(
- const SkPaint& paint) {
+SkPDFGraphicState* SkPDFGraphicState::GetGraphicStateForPaint(const SkPaint& paint) {
SkAutoMutexAcquire lock(CanonicalPaintsMutex());
int index = Find(paint);
if (index >= 0) {
@@ -114,6 +110,7 @@ SkPDFGraphicState* SkPDFGraphicState::GetGraphicStateForPaint(
// static
SkPDFObject* SkPDFGraphicState::GetInvertFunction() {
// This assumes that canonicalPaintsMutex is held.
+ CanonicalPaintsMutex().assertHeld();
static SkPDFStream* invertFunction = NULL;
if (!invertFunction) {
// Acrobat crashes if we use a type 0 function, kpdf crashes if we use
@@ -185,6 +182,7 @@ SkPDFGraphicState* SkPDFGraphicState::GetNoSMaskGraphicState() {
// static
int SkPDFGraphicState::Find(const SkPaint& paint) {
+ CanonicalPaintsMutex().assertHeld();
GSCanonicalEntry search(&paint);
return CanonicalPaints().find(search);
}
« no previous file with comments | « src/core/SkScaledImageCache.cpp ('k') | src/ports/SkMutex_pthread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698