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

Unified Diff: src/pdf/SkPDFGraphicState.cpp

Issue 944643002: PDF: Now threadsafe! (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase on 35b5b6f Created 5 years, 10 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
Index: src/pdf/SkPDFGraphicState.cpp
diff --git a/src/pdf/SkPDFGraphicState.cpp b/src/pdf/SkPDFGraphicState.cpp
index 46aa1d1ea40aa3d85ba85fb72ea899eabefbd68d..499eb8e4ecf7623a546c09442520ddc5b75fa082 100644
--- a/src/pdf/SkPDFGraphicState.cpp
+++ b/src/pdf/SkPDFGraphicState.cpp
@@ -113,9 +113,10 @@ bool SkPDFGraphicState::equals(const SkPaint& paint) const {
}
SkPDFGraphicState::~SkPDFGraphicState() {
- SkAutoMutexAcquire lock(SkPDFCanon::GetPaintMutex());
- if (!fSMask) {
- SkPDFCanon::GetCanon().removeGraphicState(this);
+ // Exactly one of the two is NULL.
mtklein 2015/02/20 15:05:27 Let's at least just remove the comment. The asser
hal.canary 2015/02/20 15:10:01 Acknowledged.
+ SkASSERT((!fSMask) != (!fCanon));
+ if (fCanon) {
+ fCanon->removeGraphicState(this);
}
}
@@ -126,15 +127,14 @@ void SkPDFGraphicState::emitObject(SkWStream* stream, SkPDFCatalog* catalog) {
// static
SkPDFGraphicState* SkPDFGraphicState::GetGraphicStateForPaint(
- const SkPaint& paint) {
- SkAutoMutexAcquire lock(SkPDFCanon::GetPaintMutex());
- SkPDFGraphicState* pdfGraphicState =
- SkPDFCanon::GetCanon().findGraphicState(paint);
+ SkPDFCanon* canon, const SkPaint& paint) {
+ SkASSERT(canon);
+ SkPDFGraphicState* pdfGraphicState = canon->findGraphicState(paint);
if (pdfGraphicState) {
return SkRef(pdfGraphicState);
}
- pdfGraphicState = new SkPDFGraphicState(paint);
- SkPDFCanon::GetCanon().addGraphicState(pdfGraphicState);
+ pdfGraphicState = new SkPDFGraphicState(canon, paint);
+ canon->addGraphicState(pdfGraphicState);
return pdfGraphicState;
}
@@ -211,15 +211,10 @@ SkPDFGraphicState* SkPDFGraphicState::GetNoSMaskGraphicState() {
}
SkPDFGraphicState::SkPDFGraphicState()
- : fPopulated(false),
- fSMask(false) {
-}
+ : fCanon(NULL), fPopulated(false), fSMask(false) {}
-SkPDFGraphicState::SkPDFGraphicState(const SkPaint& paint)
- : fPaint(paint),
- fPopulated(false),
- fSMask(false) {
-}
+SkPDFGraphicState::SkPDFGraphicState(SkPDFCanon* canon, const SkPaint& paint)
+ : fCanon(canon), fPaint(paint), fPopulated(false), fSMask(false) {}
// populateDict and operator== have to stay in sync with each other.
void SkPDFGraphicState::populateDict() {
« src/pdf/SkPDFBitmap.cpp ('K') | « src/pdf/SkPDFGraphicState.h ('k') | src/pdf/SkPDFImage.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698