| Index: src/pdf/SkPDFCanon.cpp
|
| diff --git a/src/pdf/SkPDFCanon.cpp b/src/pdf/SkPDFCanon.cpp
|
| index 8bbe835028d0742333418a0e07eef7cefce8907d..1572a2831da4188fd95bb081b4bc273bfa5804d5 100644
|
| --- a/src/pdf/SkPDFCanon.cpp
|
| +++ b/src/pdf/SkPDFCanon.cpp
|
| @@ -13,24 +13,27 @@
|
|
|
| ////////////////////////////////////////////////////////////////////////////////
|
|
|
| -SkPDFCanon::SkPDFCanon() {}
|
| -
|
| -SkPDFCanon::~SkPDFCanon() {}
|
| +void SkPDFCanon::reset() {
|
| + for (int i = 0; i < fFontRecords.count(); ++i) {
|
| + fFontRecords[i].fFont->unref();
|
| + }
|
| + fFontRecords.reset();
|
| + fFunctionShaderRecords.unrefAll();
|
| + fFunctionShaderRecords.reset();
|
| + fAlphaShaderRecords.unrefAll();
|
| + fAlphaShaderRecords.reset();
|
| + fImageShaderRecords.unrefAll();
|
| + fImageShaderRecords.reset();
|
| + fGraphicStateRecords.unrefAll();
|
| + fGraphicStateRecords.reset();
|
| + fBitmapRecords.unrefAll();
|
| + fBitmapRecords.reset();
|
| +}
|
|
|
| ////////////////////////////////////////////////////////////////////////////////
|
|
|
| template <class T> T* assert_ptr(T* p) { SkASSERT(p); return p; }
|
|
|
| -template <typename T>
|
| -bool remove_item(SkTDArray<T>* array, const T& elem) {
|
| - int i = array->find(elem);
|
| - if (i >= 0) {
|
| - array->removeShuffle(i);
|
| - return true;
|
| - }
|
| - return false;
|
| -}
|
| -
|
| // requires `bool T::equals(const U&) const`
|
| template <typename T, typename U>
|
| T* find_item(const SkTDArray<T*>& ptrArray, const U& object) {
|
| @@ -71,16 +74,6 @@ void SkPDFCanon::addFont(SkPDFFont* font, uint32_t fontID, uint16_t fGlyphID) {
|
| rec->fGlyphID = fGlyphID;
|
| }
|
|
|
| -void SkPDFCanon::removeFont(SkPDFFont* pdfFont) {
|
| - for (int i = 0; i < fFontRecords.count(); i++) {
|
| - if (fFontRecords[i].fFont == pdfFont) {
|
| - fFontRecords.removeShuffle(i);
|
| - return;
|
| - }
|
| - }
|
| - // Not all SkPDFFonts are added to the Canon.
|
| -}
|
| -
|
| ////////////////////////////////////////////////////////////////////////////////
|
|
|
| SkPDFFunctionShader* SkPDFCanon::findFunctionShader(
|
| @@ -90,9 +83,6 @@ SkPDFFunctionShader* SkPDFCanon::findFunctionShader(
|
| void SkPDFCanon::addFunctionShader(SkPDFFunctionShader* pdfShader) {
|
| fFunctionShaderRecords.push(assert_ptr(pdfShader));
|
| }
|
| -void SkPDFCanon::removeFunctionShader(SkPDFFunctionShader* pdfShader) {
|
| - SkAssertResult(remove_item(&fFunctionShaderRecords, pdfShader));
|
| -}
|
|
|
| ////////////////////////////////////////////////////////////////////////////////
|
|
|
| @@ -103,9 +93,6 @@ SkPDFAlphaFunctionShader* SkPDFCanon::findAlphaShader(
|
| void SkPDFCanon::addAlphaShader(SkPDFAlphaFunctionShader* pdfShader) {
|
| fAlphaShaderRecords.push(assert_ptr(pdfShader));
|
| }
|
| -void SkPDFCanon::removeAlphaShader(SkPDFAlphaFunctionShader* pdfShader) {
|
| - SkAssertResult(remove_item(&fAlphaShaderRecords, pdfShader));
|
| -}
|
|
|
| ////////////////////////////////////////////////////////////////////////////////
|
|
|
| @@ -118,10 +105,6 @@ void SkPDFCanon::addImageShader(SkPDFImageShader* pdfShader) {
|
| fImageShaderRecords.push(assert_ptr(pdfShader));
|
| }
|
|
|
| -void SkPDFCanon::removeImageShader(SkPDFImageShader* pdfShader) {
|
| - SkAssertResult(remove_item(&fImageShaderRecords, pdfShader));
|
| -}
|
| -
|
| ////////////////////////////////////////////////////////////////////////////////
|
|
|
| SkPDFGraphicState* SkPDFCanon::findGraphicState(const SkPaint& paint) const {
|
| @@ -132,10 +115,6 @@ void SkPDFCanon::addGraphicState(SkPDFGraphicState* state) {
|
| fGraphicStateRecords.push(assert_ptr(state));
|
| }
|
|
|
| -void SkPDFCanon::removeGraphicState(SkPDFGraphicState* pdfGraphicState) {
|
| - SkAssertResult(remove_item(&fGraphicStateRecords, pdfGraphicState));
|
| -}
|
| -
|
| ////////////////////////////////////////////////////////////////////////////////
|
|
|
| SkPDFBitmap* SkPDFCanon::findBitmap(const SkBitmap& bm) const {
|
| @@ -145,7 +124,3 @@ SkPDFBitmap* SkPDFCanon::findBitmap(const SkBitmap& bm) const {
|
| void SkPDFCanon::addBitmap(SkPDFBitmap* pdfBitmap) {
|
| fBitmapRecords.push(assert_ptr(pdfBitmap));
|
| }
|
| -
|
| -void SkPDFCanon::removeBitmap(SkPDFBitmap* pdfBitmap) {
|
| - SkAssertResult(remove_item(&fBitmapRecords, pdfBitmap));
|
| -}
|
|
|