From 2e3f9d8a9309686eeb4c76ccfde5800da87a68b3 Mon Sep 17 00:00:00 2001 From: halcanary Date: Fri, 27 Feb 2015 12:41:03 -0800 Subject: PDF: Canon now owns a reference to all interned objects Add SkPDFCanon::reset function to unref all objects. No longer possible to remove object from canon Motivation: this doesn't change these object's lifetime, (they will still be fully unrefed when SkDocument::close() is called, but we no longer have to remove them from the array when their destructor is called. Review URL: https://codereview.chromium.org/966863002 --- src/pdf/SkPDFBitmap.cpp | 9 +++--- src/pdf/SkPDFBitmap.h | 3 +- src/pdf/SkPDFCanon.cpp | 69 ++++++++++++++----------------------------- src/pdf/SkPDFCanon.h | 29 ++++++------------ src/pdf/SkPDFFont.cpp | 38 ++++++++++-------------- src/pdf/SkPDFFont.h | 5 +--- src/pdf/SkPDFFontImpl.h | 12 +++----- src/pdf/SkPDFGraphicState.cpp | 14 ++++----- src/pdf/SkPDFGraphicState.h | 3 +- src/pdf/SkPDFShader.cpp | 26 +++++++--------- src/pdf/SkPDFShader.h | 9 ++---- 11 files changed, 76 insertions(+), 141 deletions(-) (limited to 'src/pdf') diff --git a/src/pdf/SkPDFBitmap.cpp b/src/pdf/SkPDFBitmap.cpp index 03230341a4..5774360a7c 100644 --- a/src/pdf/SkPDFBitmap.cpp +++ b/src/pdf/SkPDFBitmap.cpp @@ -247,12 +247,11 @@ void SkPDFBitmap::emitDict(SkWStream* stream, pdfDict.emitObject(stream, catalog); } -SkPDFBitmap::SkPDFBitmap(SkPDFCanon* canon, - const SkBitmap& bm, +SkPDFBitmap::SkPDFBitmap(const SkBitmap& bm, SkPDFObject* smask) - : fCanon(canon), fBitmap(bm), fSMask(smask) {} + : fBitmap(bm), fSMask(smask) {} -SkPDFBitmap::~SkPDFBitmap() { fCanon->removeBitmap(this); } +SkPDFBitmap::~SkPDFBitmap() {} //////////////////////////////////////////////////////////////////////////////// static bool is_transparent(const SkBitmap& bm) { @@ -312,7 +311,7 @@ SkPDFBitmap* SkPDFBitmap::Create(SkPDFCanon* canon, // are refed by the SkPDFBitmap). smask = SkNEW_ARGS(PDFAlphaBitmap, (bm)); } - pdfBitmap = SkNEW_ARGS(SkPDFBitmap, (canon, bm, smask)); + pdfBitmap = SkNEW_ARGS(SkPDFBitmap, (bm, smask)); canon->addBitmap(pdfBitmap); return pdfBitmap; } diff --git a/src/pdf/SkPDFBitmap.h b/src/pdf/SkPDFBitmap.h index eae6877a12..45a8aa6350 100644 --- a/src/pdf/SkPDFBitmap.h +++ b/src/pdf/SkPDFBitmap.h @@ -40,10 +40,9 @@ public: } private: - SkPDFCanon* const fCanon; const SkBitmap fBitmap; const SkAutoTUnref fSMask; - SkPDFBitmap(SkPDFCanon*, const SkBitmap&, SkPDFObject*); + SkPDFBitmap(const SkBitmap&, SkPDFObject*); void emitDict(SkWStream*, SkPDFCatalog*, size_t, bool) const; }; diff --git a/src/pdf/SkPDFCanon.cpp b/src/pdf/SkPDFCanon.cpp index 8bbe835028..eda255051a 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 T* assert_ptr(T* p) { SkASSERT(p); return p; } -template -bool remove_item(SkTDArray* 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 T* find_item(const SkTDArray& ptrArray, const U& object) { @@ -66,21 +69,11 @@ SkPDFFont* SkPDFCanon::findFont(uint32_t fontID, void SkPDFCanon::addFont(SkPDFFont* font, uint32_t fontID, uint16_t fGlyphID) { SkPDFCanon::FontRec* rec = fFontRecords.push(); - rec->fFont = font; + rec->fFont = SkRef(font); rec->fFontID = fontID; 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( @@ -88,10 +81,7 @@ SkPDFFunctionShader* SkPDFCanon::findFunctionShader( return find_item(fFunctionShaderRecords, state); } void SkPDFCanon::addFunctionShader(SkPDFFunctionShader* pdfShader) { - fFunctionShaderRecords.push(assert_ptr(pdfShader)); -} -void SkPDFCanon::removeFunctionShader(SkPDFFunctionShader* pdfShader) { - SkAssertResult(remove_item(&fFunctionShaderRecords, pdfShader)); + fFunctionShaderRecords.push(SkRef(pdfShader)); } //////////////////////////////////////////////////////////////////////////////// @@ -101,10 +91,7 @@ SkPDFAlphaFunctionShader* SkPDFCanon::findAlphaShader( return find_item(fAlphaShaderRecords, state); } void SkPDFCanon::addAlphaShader(SkPDFAlphaFunctionShader* pdfShader) { - fAlphaShaderRecords.push(assert_ptr(pdfShader)); -} -void SkPDFCanon::removeAlphaShader(SkPDFAlphaFunctionShader* pdfShader) { - SkAssertResult(remove_item(&fAlphaShaderRecords, pdfShader)); + fAlphaShaderRecords.push(SkRef(pdfShader)); } //////////////////////////////////////////////////////////////////////////////// @@ -115,11 +102,7 @@ SkPDFImageShader* SkPDFCanon::findImageShader( } void SkPDFCanon::addImageShader(SkPDFImageShader* pdfShader) { - fImageShaderRecords.push(assert_ptr(pdfShader)); -} - -void SkPDFCanon::removeImageShader(SkPDFImageShader* pdfShader) { - SkAssertResult(remove_item(&fImageShaderRecords, pdfShader)); + fImageShaderRecords.push(SkRef(pdfShader)); } //////////////////////////////////////////////////////////////////////////////// @@ -129,11 +112,7 @@ SkPDFGraphicState* SkPDFCanon::findGraphicState(const SkPaint& paint) const { } void SkPDFCanon::addGraphicState(SkPDFGraphicState* state) { - fGraphicStateRecords.push(assert_ptr(state)); -} - -void SkPDFCanon::removeGraphicState(SkPDFGraphicState* pdfGraphicState) { - SkAssertResult(remove_item(&fGraphicStateRecords, pdfGraphicState)); + fGraphicStateRecords.push(SkRef(state)); } //////////////////////////////////////////////////////////////////////////////// @@ -143,9 +122,5 @@ 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)); + fBitmapRecords.push(SkRef(pdfBitmap)); } diff --git a/src/pdf/SkPDFCanon.h b/src/pdf/SkPDFCanon.h index 369106ada4..d0bef27ed6 100644 --- a/src/pdf/SkPDFCanon.h +++ b/src/pdf/SkPDFCanon.h @@ -26,14 +26,18 @@ class SkPaint; * The SkDocument_PDF class makes this happen by owning a single * SkPDFCanon. * - * Note that this class does not create, delete, reference or - * dereference the SkPDFObject objects that it indexes. It is up to - * the caller to manage the lifetime of these objects. + * The addFoo() methods will ref the Foo; the canon's destructor will + * call foo->unref() on all of these objects. + * + * The findFoo() methods do not change the ref count of the Foo + * objects. */ class SkPDFCanon : SkNoncopyable { public: - SkPDFCanon(); - ~SkPDFCanon(); + ~SkPDFCanon() { this->reset(); } + + // reset to original setting, unrefs all objects. + void reset(); // Returns exact match if there is one. If not, it returns NULL. // If there is no exact match, but there is a related font, we @@ -42,36 +46,21 @@ public: uint16_t glyphID, SkPDFFont** relatedFont) const; void addFont(SkPDFFont* font, uint32_t fontID, uint16_t fGlyphID); - void removeFont(SkPDFFont*); SkPDFFunctionShader* findFunctionShader(const SkPDFShader::State&) const; void addFunctionShader(SkPDFFunctionShader*); - void removeFunctionShader(SkPDFFunctionShader*); SkPDFAlphaFunctionShader* findAlphaShader(const SkPDFShader::State&) const; void addAlphaShader(SkPDFAlphaFunctionShader*); - void removeAlphaShader(SkPDFAlphaFunctionShader*); SkPDFImageShader* findImageShader(const SkPDFShader::State&) const; void addImageShader(SkPDFImageShader*); - void removeImageShader(SkPDFImageShader*); SkPDFGraphicState* findGraphicState(const SkPaint&) const; void addGraphicState(SkPDFGraphicState*); - void removeGraphicState(SkPDFGraphicState*); SkPDFBitmap* findBitmap(const SkBitmap&) const; void addBitmap(SkPDFBitmap*); - void removeBitmap(SkPDFBitmap*); - - void assertEmpty() const { - SkASSERT(fFontRecords.isEmpty()); - SkASSERT(fFunctionShaderRecords.isEmpty()); - SkASSERT(fAlphaShaderRecords.isEmpty()); - SkASSERT(fImageShaderRecords.isEmpty()); - SkASSERT(fGraphicStateRecords.isEmpty()); - SkASSERT(fBitmapRecords.isEmpty()); - } private: struct FontRec { diff --git a/src/pdf/SkPDFFont.cpp b/src/pdf/SkPDFFont.cpp index f386b71523..d36a1d75c9 100644 --- a/src/pdf/SkPDFFont.cpp +++ b/src/pdf/SkPDFFont.cpp @@ -747,7 +747,7 @@ SkPDFGlyphSet* SkPDFGlyphSetMap::getGlyphSetForFont(SkPDFFont* font) { * from each page and combine it and ask for a resource with that subset. */ -SkPDFFont::~SkPDFFont() { fCanon->removeFont(this); } +SkPDFFont::~SkPDFFont() {} SkTypeface* SkPDFFont::typeface() { return fTypeface.get(); @@ -862,12 +862,10 @@ SkPDFFont* SkPDFFont::getFontSubset(const SkPDFGlyphSet*) { return NULL; // Default: no support. } -SkPDFFont::SkPDFFont(SkPDFCanon* canon, - const SkAdvancedTypefaceMetrics* info, +SkPDFFont::SkPDFFont(const SkAdvancedTypefaceMetrics* info, SkTypeface* typeface, SkPDFDict* relatedFontDescriptor) : SkPDFDict("Font") - , fCanon(canon) , fTypeface(ref_or_default(typeface)) , fFirstGlyphID(1) , fLastGlyphID(info ? info->fLastGlyphID : 0) @@ -893,22 +891,22 @@ SkPDFFont* SkPDFFont::Create(SkPDFCanon* canon, if (info && (info->fFlags & SkAdvancedTypefaceMetrics::kMultiMaster_FontFlag)) { NOT_IMPLEMENTED(true, true); - return new SkPDFType3Font(canon, info, typeface, glyphID); + return new SkPDFType3Font(info, typeface, glyphID); } if (type == SkAdvancedTypefaceMetrics::kType1CID_Font || type == SkAdvancedTypefaceMetrics::kTrueType_Font) { SkASSERT(relatedFontDescriptor == NULL); - return new SkPDFType0Font(canon, info, typeface); + return new SkPDFType0Font(info, typeface); } if (type == SkAdvancedTypefaceMetrics::kType1_Font) { - return new SkPDFType1Font(canon, info, typeface, glyphID, + return new SkPDFType1Font(info, typeface, glyphID, relatedFontDescriptor); } SkASSERT(type == SkAdvancedTypefaceMetrics::kCFF_Font || type == SkAdvancedTypefaceMetrics::kOther_Font); - return new SkPDFType3Font(canon, info, typeface, glyphID); + return new SkPDFType3Font(info, typeface, glyphID); } const SkAdvancedTypefaceMetrics* SkPDFFont::fontInfo() { @@ -996,10 +994,9 @@ void SkPDFFont::populateToUnicodeTable(const SkPDFGlyphSet* subset) { // class SkPDFType0Font /////////////////////////////////////////////////////////////////////////////// -SkPDFType0Font::SkPDFType0Font(SkPDFCanon* canon, - const SkAdvancedTypefaceMetrics* info, +SkPDFType0Font::SkPDFType0Font(const SkAdvancedTypefaceMetrics* info, SkTypeface* typeface) - : SkPDFFont(canon, info, typeface, NULL) { + : SkPDFFont(info, typeface, NULL) { SkDEBUGCODE(fPopulated = false); if (!canSubset()) { populate(NULL); @@ -1013,7 +1010,7 @@ SkPDFFont* SkPDFType0Font::getFontSubset(const SkPDFGlyphSet* subset) { return NULL; } SkPDFType0Font* newSubset = - new SkPDFType0Font(fCanon, fontInfo(), typeface()); + new SkPDFType0Font(fontInfo(), typeface()); newSubset->populate(subset); return newSubset; } @@ -1031,7 +1028,7 @@ bool SkPDFType0Font::populate(const SkPDFGlyphSet* subset) { insertName("Encoding", "Identity-H"); SkAutoTUnref newCIDFont( - new SkPDFCIDFont(fCanon, fontInfo(), typeface(), subset)); + new SkPDFCIDFont(fontInfo(), typeface(), subset)); SkAutoTUnref descendantFonts(new SkPDFArray()); descendantFonts->append(new SkPDFObjRef(newCIDFont.get()))->unref(); insert("DescendantFonts", descendantFonts.get()); @@ -1046,11 +1043,10 @@ bool SkPDFType0Font::populate(const SkPDFGlyphSet* subset) { // class SkPDFCIDFont /////////////////////////////////////////////////////////////////////////////// -SkPDFCIDFont::SkPDFCIDFont(SkPDFCanon* canon, - const SkAdvancedTypefaceMetrics* info, +SkPDFCIDFont::SkPDFCIDFont(const SkAdvancedTypefaceMetrics* info, SkTypeface* typeface, const SkPDFGlyphSet* subset) - : SkPDFFont(canon, info, typeface, NULL) { + : SkPDFFont(info, typeface, NULL) { populate(subset); } @@ -1201,12 +1197,11 @@ bool SkPDFCIDFont::populate(const SkPDFGlyphSet* subset) { // class SkPDFType1Font /////////////////////////////////////////////////////////////////////////////// -SkPDFType1Font::SkPDFType1Font(SkPDFCanon* canon, - const SkAdvancedTypefaceMetrics* info, +SkPDFType1Font::SkPDFType1Font(const SkAdvancedTypefaceMetrics* info, SkTypeface* typeface, uint16_t glyphID, SkPDFDict* relatedFontDescriptor) - : SkPDFFont(canon, info, typeface, relatedFontDescriptor) { + : SkPDFFont(info, typeface, relatedFontDescriptor) { populate(glyphID); } @@ -1329,11 +1324,10 @@ void SkPDFType1Font::addWidthInfoFromRange( // class SkPDFType3Font /////////////////////////////////////////////////////////////////////////////// -SkPDFType3Font::SkPDFType3Font(SkPDFCanon* canon, - const SkAdvancedTypefaceMetrics* info, +SkPDFType3Font::SkPDFType3Font(const SkAdvancedTypefaceMetrics* info, SkTypeface* typeface, uint16_t glyphID) - : SkPDFFont(canon, info, typeface, NULL) { + : SkPDFFont(info, typeface, NULL) { populate(glyphID); } diff --git a/src/pdf/SkPDFFont.h b/src/pdf/SkPDFFont.h index 6ff4c7b15e..c286fa481a 100644 --- a/src/pdf/SkPDFFont.h +++ b/src/pdf/SkPDFFont.h @@ -150,11 +150,8 @@ public: uint16_t searchGlyphID); protected: - SkPDFCanon* const fCanon; - // Common constructor to handle common members. - SkPDFFont(SkPDFCanon* canon, - const SkAdvancedTypefaceMetrics* fontInfo, + SkPDFFont(const SkAdvancedTypefaceMetrics* fontInfo, SkTypeface* typeface, SkPDFDict* relatedFontDescriptor); diff --git a/src/pdf/SkPDFFontImpl.h b/src/pdf/SkPDFFontImpl.h index 4c3e525985..a0689a338e 100644 --- a/src/pdf/SkPDFFontImpl.h +++ b/src/pdf/SkPDFFontImpl.h @@ -28,8 +28,7 @@ private: typedef SkPDFDict INHERITED; #endif - SkPDFType0Font(SkPDFCanon* canon, - const SkAdvancedTypefaceMetrics* info, + SkPDFType0Font(const SkAdvancedTypefaceMetrics* info, SkTypeface* typeface); bool populate(const SkPDFGlyphSet* subset); @@ -43,8 +42,7 @@ public: private: friend class SkPDFType0Font; // to access the constructor - SkPDFCIDFont(SkPDFCanon* canon, - const SkAdvancedTypefaceMetrics* info, + SkPDFCIDFont(const SkAdvancedTypefaceMetrics* info, SkTypeface* typeface, const SkPDFGlyphSet* subset); @@ -61,8 +59,7 @@ public: private: friend class SkPDFFont; // to access the constructor - SkPDFType1Font(SkPDFCanon* canon, - const SkAdvancedTypefaceMetrics* info, + SkPDFType1Font(const SkAdvancedTypefaceMetrics* info, SkTypeface* typeface, uint16_t glyphID, SkPDFDict* relatedFontDescriptor); @@ -81,8 +78,7 @@ public: private: friend class SkPDFFont; // to access the constructor - SkPDFType3Font(SkPDFCanon* canon, - const SkAdvancedTypefaceMetrics* info, + SkPDFType3Font(const SkAdvancedTypefaceMetrics* info, SkTypeface* typeface, uint16_t glyphID); diff --git a/src/pdf/SkPDFGraphicState.cpp b/src/pdf/SkPDFGraphicState.cpp index 4ec0821974..09545d1356 100644 --- a/src/pdf/SkPDFGraphicState.cpp +++ b/src/pdf/SkPDFGraphicState.cpp @@ -112,11 +112,7 @@ bool SkPDFGraphicState::equals(const SkPaint& paint) const { return equivalent(paint, fPaint); } -SkPDFGraphicState::~SkPDFGraphicState() { - if (fCanon) { - fCanon->removeGraphicState(this); - } -} +SkPDFGraphicState::~SkPDFGraphicState() {} void SkPDFGraphicState::emitObject(SkWStream* stream, SkPDFCatalog* catalog) { populateDict(); @@ -131,7 +127,7 @@ SkPDFGraphicState* SkPDFGraphicState::GetGraphicStateForPaint( if (pdfGraphicState) { return SkRef(pdfGraphicState); } - pdfGraphicState = new SkPDFGraphicState(canon, paint); + pdfGraphicState = new SkPDFGraphicState(paint); canon->addGraphicState(pdfGraphicState); return pdfGraphicState; } @@ -207,10 +203,10 @@ SkPDFGraphicState* SkPDFGraphicState::GetNoSMaskGraphicState() { } SkPDFGraphicState::SkPDFGraphicState() - : fCanon(NULL), fPopulated(false) {} + : fPopulated(false) {} -SkPDFGraphicState::SkPDFGraphicState(SkPDFCanon* canon, const SkPaint& paint) - : fCanon(canon), fPaint(paint), fPopulated(false) {} +SkPDFGraphicState::SkPDFGraphicState(const SkPaint& paint) + : fPaint(paint), fPopulated(false) {} // populateDict and operator== have to stay in sync with each other. void SkPDFGraphicState::populateDict() { diff --git a/src/pdf/SkPDFGraphicState.h b/src/pdf/SkPDFGraphicState.h index 2c9198c142..dc41fc6229 100644 --- a/src/pdf/SkPDFGraphicState.h +++ b/src/pdf/SkPDFGraphicState.h @@ -74,12 +74,11 @@ public: static SkPDFGraphicState* CreateNoSMaskGraphicState(); private: - SkPDFCanon* const fCanon; const SkPaint fPaint; bool fPopulated; SkPDFGraphicState(); - SkPDFGraphicState(SkPDFCanon* canon, const SkPaint& paint); + SkPDFGraphicState(const SkPaint& paint); void populateDict(); diff --git a/src/pdf/SkPDFShader.cpp b/src/pdf/SkPDFShader.cpp index d7a5044591..0b66191953 100644 --- a/src/pdf/SkPDFShader.cpp +++ b/src/pdf/SkPDFShader.cpp @@ -506,12 +506,10 @@ private: //////////////////////////////////////////////////////////////////////////////// -SkPDFFunctionShader::SkPDFFunctionShader(SkPDFCanon* canon, - SkPDFShader::State* state) - : SkPDFDict("Pattern"), fCanon(canon), fShaderState(state) {} +SkPDFFunctionShader::SkPDFFunctionShader(SkPDFShader::State* state) + : SkPDFDict("Pattern"), fShaderState(state) {} SkPDFFunctionShader::~SkPDFFunctionShader() { - fCanon->removeFunctionShader(this); fResources.unrefAll(); } @@ -521,29 +519,25 @@ bool SkPDFFunctionShader::equals(const SkPDFShader::State& state) const { //////////////////////////////////////////////////////////////////////////////// -SkPDFAlphaFunctionShader::SkPDFAlphaFunctionShader(SkPDFCanon* canon, - SkPDFShader::State* state) - : fCanon(canon), fShaderState(state) {} +SkPDFAlphaFunctionShader::SkPDFAlphaFunctionShader(SkPDFShader::State* state) + : fShaderState(state) {} bool SkPDFAlphaFunctionShader::equals(const SkPDFShader::State& state) const { return state == *fShaderState; } -SkPDFAlphaFunctionShader::~SkPDFAlphaFunctionShader() { - fCanon->removeAlphaShader(this); -} +SkPDFAlphaFunctionShader::~SkPDFAlphaFunctionShader() {} //////////////////////////////////////////////////////////////////////////////// -SkPDFImageShader::SkPDFImageShader(SkPDFCanon* canon, SkPDFShader::State* state) - : fCanon(canon), fShaderState(state) {} +SkPDFImageShader::SkPDFImageShader(SkPDFShader::State* state) + : fShaderState(state) {} bool SkPDFImageShader::equals(const SkPDFShader::State& state) const { return state == *fShaderState; } SkPDFImageShader::~SkPDFImageShader() { - fCanon->removeImageShader(this); fResources.unrefAll(); } @@ -691,7 +685,7 @@ SkPDFAlphaFunctionShader* SkPDFAlphaFunctionShader::Create( create_smask_graphic_state(canon, dpi, state)); SkPDFAlphaFunctionShader* alphaFunctionShader = - SkNEW_ARGS(SkPDFAlphaFunctionShader, (canon, autoState->detach())); + SkNEW_ARGS(SkPDFAlphaFunctionShader, (autoState->detach())); alphaFunctionShader->fColorShader.reset(colorShader); @@ -897,7 +891,7 @@ SkPDFFunctionShader* SkPDFFunctionShader::Create( SkPDFUtils::MatrixToArray(finalMatrix)); SkPDFFunctionShader* pdfFunctionShader = - SkNEW_ARGS(SkPDFFunctionShader, (canon, autoState->detach())); + SkNEW_ARGS(SkPDFFunctionShader, (autoState->detach())); pdfFunctionShader->fResources.push(function); // Pass ownership to resource list. @@ -1113,7 +1107,7 @@ SkPDFImageShader* SkPDFImageShader::Create( SkAutoTDelete content(patternDevice->content()); SkPDFImageShader* imageShader = - SkNEW_ARGS(SkPDFImageShader, (canon, autoState->detach())); + SkNEW_ARGS(SkPDFImageShader, (autoState->detach())); imageShader->setData(content.get()); populate_tiling_pattern_dict(imageShader, patternBBox, diff --git a/src/pdf/SkPDFShader.h b/src/pdf/SkPDFShader.h index 5be47a382f..4fdbc44cf7 100644 --- a/src/pdf/SkPDFShader.h +++ b/src/pdf/SkPDFShader.h @@ -61,10 +61,9 @@ public: bool equals(const SkPDFShader::State&) const; private: - SkPDFCanon* fCanon; SkAutoTDelete fShaderState; SkTDArray fResources; - SkPDFFunctionShader(SkPDFCanon*, SkPDFShader::State*); + SkPDFFunctionShader(SkPDFShader::State*); typedef SkPDFDict INHERITED; }; @@ -82,11 +81,10 @@ public: bool equals(const SkPDFShader::State&) const; private: - SkPDFCanon* fCanon; SkAutoTDelete fShaderState; SkAutoTUnref fColorShader; SkAutoTUnref fResourceDict; - SkPDFAlphaFunctionShader(SkPDFCanon*, SkPDFShader::State*); + SkPDFAlphaFunctionShader(SkPDFShader::State*); }; class SkPDFImageShader : public SkPDFStream { @@ -98,10 +96,9 @@ public: bool equals(const SkPDFShader::State&) const; private: - SkPDFCanon* fCanon; SkAutoTDelete fShaderState; SkTSet fResources; - SkPDFImageShader(SkPDFCanon*, SkPDFShader::State*); + SkPDFImageShader(SkPDFShader::State*); }; #endif -- cgit v1.2.3