Chromium Code Reviews| Index: src/pdf/SkPDFCanon.cpp |
| diff --git a/src/pdf/SkPDFCanon.cpp b/src/pdf/SkPDFCanon.cpp |
| index 3dcf4e9f0f743b66d07aab48061b6dffc6abf28e..62faa8c30a1951eaf039f2dd7c584be47a09d76e 100644 |
| --- a/src/pdf/SkPDFCanon.cpp |
| +++ b/src/pdf/SkPDFCanon.cpp |
| @@ -12,52 +12,18 @@ |
| //////////////////////////////////////////////////////////////////////////////// |
| -void SkPDFCanon::reset() { |
| - for (int i = 0; i < fFontRecords.count(); ++i) { |
| - fFontRecords[i].fFont->unref(); |
| - } |
| - fFontRecords.reset(); |
| - |
| - fFunctionShaderRecords.reset(); |
| - fAlphaShaderRecords.reset(); |
| - fImageShaderRecords.reset(); |
| - |
| +SkPDFCanon::~SkPDFCanon() { |
| // TODO(halcanary): make SkTHashSet work nicely with sk_sp<>, |
| // or use std::unordered_set<> |
| fGraphicStateRecords.foreach ([](WrapGS w) { w.fPtr->unref(); }); |
| fGraphicStateRecords.reset(); |
| fPDFBitmapMap.foreach([](SkBitmapKey, SkPDFObject** p) { (*p)->unref(); }); |
| - fPDFBitmapMap.reset(); |
|
bungeman-skia
2016/08/17 18:56:04
Not clear why this reset is being removed but not
hal.canary
2016/08/17 19:29:49
Done.
|
| -} |
| - |
| -//////////////////////////////////////////////////////////////////////////////// |
| - |
| -SkPDFFont* SkPDFCanon::findFont(uint32_t fontID, |
| - uint16_t glyphID, |
| - SkPDFFont** relatedFontPtr) const { |
| - SkASSERT(relatedFontPtr); |
| - |
| - SkPDFFont* relatedFont = nullptr; |
| - for (int i = 0; i < fFontRecords.count(); ++i) { |
| - SkPDFFont::Match match = SkPDFFont::IsMatch( |
| - fFontRecords[i].fFont, fFontRecords[i].fFontID, |
| - fFontRecords[i].fGlyphID, fontID, glyphID); |
| - if (SkPDFFont::kExact_Match == match) { |
| - return fFontRecords[i].fFont; |
| - } else if (!relatedFont && SkPDFFont::kRelated_Match == match) { |
| - relatedFont = fFontRecords[i].fFont; |
| - } |
| - } |
| - *relatedFontPtr = relatedFont; // May still be nullptr. |
| - return nullptr; |
| } |
| -void SkPDFCanon::addFont(SkPDFFont* font, uint32_t fontID, uint16_t fGlyphID) { |
| - SkPDFCanon::FontRec* rec = fFontRecords.push(); |
| - rec->fFont = SkRef(font); |
| - rec->fFontID = fontID; |
| - rec->fGlyphID = fGlyphID; |
| +void SkPDFCanon::reset() { |
| + this->~SkPDFCanon(); |
| + new (this)SkPDFCanon; |
| } |
| //////////////////////////////////////////////////////////////////////////////// |