diff options
author | 2015-02-20 12:45:50 -0800 | |
---|---|---|
committer | 2015-02-20 12:45:50 -0800 | |
commit | c1b71d6c30041f01675dd54a77adc9c177afdf44 (patch) | |
tree | 07aa62538ebb2dc12be32c46c3247c4f20ca76dc /src/pdf | |
parent | b2bed00ce143363d8192ae96fedf12a06a76b0f5 (diff) |
PDF: remove unnecessary mutexes.
We now force all SkPDFObjects to stay on one thread.
TBR=mtklein@google.com
Review URL: https://codereview.chromium.org/942153002
Diffstat (limited to 'src/pdf')
-rw-r--r-- | src/pdf/SkPDFFont.h | 1 | ||||
-rw-r--r-- | src/pdf/SkPDFGraphicState.h | 1 | ||||
-rw-r--r-- | src/pdf/SkPDFShader.cpp | 2 | ||||
-rw-r--r-- | src/pdf/SkPDFStream.cpp | 1 | ||||
-rw-r--r-- | src/pdf/SkPDFStream.h | 6 | ||||
-rw-r--r-- | src/pdf/SkPDFTypes.cpp | 20 | ||||
-rw-r--r-- | src/pdf/SkPDFTypes.h | 2 |
7 files changed, 4 insertions, 29 deletions
diff --git a/src/pdf/SkPDFFont.h b/src/pdf/SkPDFFont.h index 105ae8d25e..6ff4c7b15e 100644 --- a/src/pdf/SkPDFFont.h +++ b/src/pdf/SkPDFFont.h @@ -14,7 +14,6 @@ #include "SkBitSet.h" #include "SkPDFTypes.h" #include "SkTDArray.h" -#include "SkThread.h" #include "SkTypeface.h" class SkPaint; diff --git a/src/pdf/SkPDFGraphicState.h b/src/pdf/SkPDFGraphicState.h index b26e4a00cb..2c9198c142 100644 --- a/src/pdf/SkPDFGraphicState.h +++ b/src/pdf/SkPDFGraphicState.h @@ -13,7 +13,6 @@ #include "SkPaint.h" #include "SkPDFTypes.h" #include "SkTemplates.h" -#include "SkThread.h" class SkPDFFormXObject; diff --git a/src/pdf/SkPDFShader.cpp b/src/pdf/SkPDFShader.cpp index 21d767d700..d7605b3362 100644 --- a/src/pdf/SkPDFShader.cpp +++ b/src/pdf/SkPDFShader.cpp @@ -20,7 +20,6 @@ #include "SkScalar.h" #include "SkStream.h" #include "SkTemplates.h" -#include "SkThread.h" #include "SkTSet.h" #include "SkTypes.h" @@ -583,7 +582,6 @@ SkPDFObject* SkPDFShader::GetPDFShader(SkPDFCanon* canon, const SkMatrix& matrix, const SkIRect& surfaceBBox, SkScalar rasterScale) { - // There is only one mutex becasue we don't know which one we'll need. SkAutoTDelete<SkPDFShader::State> state( SkNEW_ARGS(State, (shader, matrix, surfaceBBox, rasterScale))); return get_pdf_shader_by_state(canon, dpi, &state); diff --git a/src/pdf/SkPDFStream.cpp b/src/pdf/SkPDFStream.cpp index 4aeb2dbe1e..ae3fe4abc4 100644 --- a/src/pdf/SkPDFStream.cpp +++ b/src/pdf/SkPDFStream.cpp @@ -41,7 +41,6 @@ SkPDFStream::SkPDFStream(const SkPDFStream& pdfStream) SkPDFStream::~SkPDFStream() {} void SkPDFStream::emitObject(SkWStream* stream, SkPDFCatalog* catalog) { - SkAutoMutexAcquire lock(fMutex); // multiple threads could be calling emit if (!this->populate(catalog)) { return fSubstitute->emitObject(stream, catalog); } diff --git a/src/pdf/SkPDFStream.h b/src/pdf/SkPDFStream.h index cf9316ff14..90c6bcacb6 100644 --- a/src/pdf/SkPDFStream.h +++ b/src/pdf/SkPDFStream.h @@ -39,8 +39,7 @@ public: virtual ~SkPDFStream(); - // The SkPDFObject interface. This two method uses a mutex to - // allow multiple threads to call at the same time. + // The SkPDFObject interface. virtual void emitObject(SkWStream* stream, SkPDFCatalog* catalog) SK_OVERRIDE; protected: @@ -90,9 +89,6 @@ private: // Indicates what form (or if) the stream has been requested. State fState; - // Mutex guards fState, fDataStream, and fSubstitute in public interface. - SkMutex fMutex; - SkAutoTDelete<SkStreamRewindable> fDataStream; SkAutoTUnref<SkPDFStream> fSubstitute; diff --git a/src/pdf/SkPDFTypes.cpp b/src/pdf/SkPDFTypes.cpp index 7902e599ce..43cd68450f 100644 --- a/src/pdf/SkPDFTypes.cpp +++ b/src/pdf/SkPDFTypes.cpp @@ -312,15 +312,10 @@ SkPDFDict::~SkPDFDict() { } int SkPDFDict::size() const { - SkAutoMutexAcquire lock(fMutex); return fValue.count(); } void SkPDFDict::emitObject(SkWStream* stream, SkPDFCatalog* catalog) { - SkAutoMutexAcquire lock(fMutex); // If another thread triggers a - // resize while this thread is in - // the for-loop, we can be left - // with a bad fValue[i] reference. stream->writeText("<<"); for (int i = 0; i < fValue.count(); i++) { SkASSERT(fValue[i].key); @@ -348,9 +343,6 @@ void SkPDFDict::addResources(SkTSet<SkPDFObject*>* resourceSet, SkPDFObject* SkPDFDict::append(SkPDFName* key, SkPDFObject* value) { SkASSERT(key); SkASSERT(value); - SkAutoMutexAcquire lock(fMutex); // If the SkTDArray resizes while - // two threads access array, one - // is left with a bad pointer. *(fValue.append()) = Rec(key, value); return value; } @@ -376,7 +368,6 @@ void SkPDFDict::insertName(const char key[], const char name[]) { } void SkPDFDict::clear() { - SkAutoMutexAcquire lock(fMutex); for (int i = 0; i < fValue.count(); i++) { SkASSERT(fValue[i].key); SkASSERT(fValue[i].value); @@ -389,7 +380,6 @@ void SkPDFDict::clear() { void SkPDFDict::remove(const char key[]) { SkASSERT(key); SkPDFName name(key); - SkAutoMutexAcquire lock(fMutex); for (int i = 0; i < fValue.count(); i++) { SkASSERT(fValue[i].key); if (*(fValue[i].key) == name) { @@ -403,12 +393,8 @@ void SkPDFDict::remove(const char key[]) { } void SkPDFDict::mergeFrom(const SkPDFDict& other) { - SkAutoMutexAcquire lockOther(other.fMutex); - SkTDArray<Rec> copy(other.fValue); - lockOther.release(); // Do not hold both mutexes at once. - - SkAutoMutexAcquire lock(fMutex); - for (int i = 0; i < copy.count(); i++) { - *(fValue.append()) = Rec(SkRef(copy[i].key), SkRef(copy[i].value)); + for (int i = 0; i < other.fValue.count(); i++) { + *(fValue.append()) = + Rec(SkRef(other.fValue[i].key), SkRef(other.fValue[i].value)); } } diff --git a/src/pdf/SkPDFTypes.h b/src/pdf/SkPDFTypes.h index 54c59f28be..7a72a38c78 100644 --- a/src/pdf/SkPDFTypes.h +++ b/src/pdf/SkPDFTypes.h @@ -10,7 +10,6 @@ #ifndef SkPDFTypes_DEFINED #define SkPDFTypes_DEFINED -#include "SkMutex.h" #include "SkRefCnt.h" #include "SkScalar.h" #include "SkString.h" @@ -384,7 +383,6 @@ private: static const int kMaxLen = 4095; - mutable SkMutex fMutex; // protects modifications to fValue SkTDArray<struct Rec> fValue; SkPDFObject* append(SkPDFName* key, SkPDFObject* value); |