aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/pdf
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2014-06-09 14:18:02 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-06-09 14:18:03 -0700
commitb83f6c3cbdabc14d8290b00d9f38ba59bf6719a1 (patch)
treea27fbddc35397dc0f32549e2af8a9c6d13e9c641 /src/pdf
parent919ed4c73633e92bfc6694161360c5c3f45728e8 (diff)
Add assertHeld() to SkMutex.
BUG=skia: R=bungeman@google.com, mtklein@google.com, reed@google.com Author: mtklein@chromium.org Review URL: https://codereview.chromium.org/313823004
Diffstat (limited to 'src/pdf')
-rw-r--r--src/pdf/SkPDFGraphicState.cpp12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/pdf/SkPDFGraphicState.cpp b/src/pdf/SkPDFGraphicState.cpp
index 9f8edfd206..1b495341b9 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);
}