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

Unified Diff: src/pdf/SkPDFBitmap.cpp

Issue 944643002: PDF: Now threadsafe! (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: TODO=DONE 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
« no previous file with comments | « src/pdf/SkPDFBitmap.h ('k') | src/pdf/SkPDFCanon.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pdf/SkPDFBitmap.cpp
diff --git a/src/pdf/SkPDFBitmap.cpp b/src/pdf/SkPDFBitmap.cpp
index b65709cf7c31f8629d187dd70ba56ed7fa08b75c..f8742a674ed9122bcf010d51f7a3e8c38728b693 100644
--- a/src/pdf/SkPDFBitmap.cpp
+++ b/src/pdf/SkPDFBitmap.cpp
@@ -247,13 +247,12 @@ void SkPDFBitmap::emitDict(SkWStream* stream,
pdfDict.emitObject(stream, catalog);
}
-SkPDFBitmap::SkPDFBitmap(const SkBitmap& bm, SkPDFObject* smask)
- : fBitmap(bm), fSMask(smask) {}
+SkPDFBitmap::SkPDFBitmap(SkPDFCanon* canon,
+ const SkBitmap& bm,
+ SkPDFObject* smask)
+ : fCanon(canon), fBitmap(bm), fSMask(smask) {}
-SkPDFBitmap::~SkPDFBitmap() {
- SkAutoMutexAcquire autoMutexAcquire(SkPDFCanon::GetBitmapMutex());
- SkPDFCanon::GetCanon().removeBitmap(this);
-}
+SkPDFBitmap::~SkPDFBitmap() { fCanon->removeBitmap(this); }
////////////////////////////////////////////////////////////////////////////////
static bool is_transparent(const SkBitmap& bm) {
@@ -275,9 +274,10 @@ static bool is_transparent(const SkBitmap& bm) {
return true;
}
-// TODO(halcanary): SkPDFBitmap::Create should take a SkPDFCanon* parameter.
-SkPDFBitmap* SkPDFBitmap::Create(const SkBitmap& bitmap,
+SkPDFBitmap* SkPDFBitmap::Create(SkPDFCanon* canon,
+ const SkBitmap& bitmap,
const SkIRect& subset) {
+ SkASSERT(canon);
if (kN32_SkColorType != bitmap.colorType()) {
// TODO(halcanary): support other colortypes.
return NULL;
@@ -299,9 +299,7 @@ SkPDFBitmap* SkPDFBitmap::Create(const SkBitmap& bitmap,
bm = copy;
}
- SkAutoMutexAcquire autoMutexAcquire(SkPDFCanon::GetBitmapMutex());
- SkPDFCanon& canon = SkPDFCanon::GetCanon();
- SkPDFBitmap* pdfBitmap = canon.findBitmap(bm);
+ SkPDFBitmap* pdfBitmap = canon->findBitmap(bm);
if (pdfBitmap) {
return SkRef(pdfBitmap);
}
@@ -314,7 +312,7 @@ SkPDFBitmap* SkPDFBitmap::Create(const SkBitmap& bitmap,
// are refed by the SkPDFBitmap).
smask = SkNEW_ARGS(PDFAlphaBitmap, (bm));
}
- pdfBitmap = SkNEW_ARGS(SkPDFBitmap, (bm, smask));
- canon.addBitmap(pdfBitmap);
+ pdfBitmap = SkNEW_ARGS(SkPDFBitmap, (canon, bm, smask));
+ canon->addBitmap(pdfBitmap);
return pdfBitmap;
}
« no previous file with comments | « src/pdf/SkPDFBitmap.h ('k') | src/pdf/SkPDFCanon.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698