From 547019e1a671b1b30746e69b9647b201500e1504 Mon Sep 17 00:00:00 2001 From: halcanary Date: Tue, 24 Mar 2015 08:12:55 -0700 Subject: SkPDF: clean up extra references This cleans up code left behind from http://crrev.com/870333002 Review URL: https://codereview.chromium.org/1029263004 --- src/pdf/SkPDFDevice.cpp | 1 - src/pdf/SkPDFDocument.cpp | 1 - src/pdf/SkPDFResourceDict.cpp | 1 - src/pdf/SkPDFResourceDict.h | 2 -- src/pdf/SkPDFShader.cpp | 30 ++++++++++-------------------- src/pdf/SkPDFShader.h | 6 ++---- 6 files changed, 12 insertions(+), 29 deletions(-) diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp index a0ad1343af..72e9135876 100644 --- a/src/pdf/SkPDFDevice.cpp +++ b/src/pdf/SkPDFDevice.cpp @@ -33,7 +33,6 @@ #include "SkTextFormatParams.h" #include "SkTemplates.h" #include "SkTypefacePriv.h" -#include "SkTSet.h" #define DPI_FOR_RASTER_SCALE_ONE 72 diff --git a/src/pdf/SkPDFDocument.cpp b/src/pdf/SkPDFDocument.cpp index 8280551f8a..1807673edc 100644 --- a/src/pdf/SkPDFDocument.cpp +++ b/src/pdf/SkPDFDocument.cpp @@ -14,7 +14,6 @@ #include "SkPDFPage.h" #include "SkPDFTypes.h" #include "SkStream.h" -#include "SkTSet.h" static void addResourcesToCatalog(bool firstPage, SkTSet* resourceSet, diff --git a/src/pdf/SkPDFResourceDict.cpp b/src/pdf/SkPDFResourceDict.cpp index 40fc1d8dc9..69618de714 100644 --- a/src/pdf/SkPDFResourceDict.cpp +++ b/src/pdf/SkPDFResourceDict.cpp @@ -72,7 +72,6 @@ SkPDFObject* SkPDFResourceDict::insertResourceAsReference( SkPDFResourceType type, int key, SkPDFObject* value) { SkAutoTUnref ref(SkNEW_ARGS(SkPDFObjRef, (value))); insertResource(type, key, ref); - fResources.add(value); return value; } diff --git a/src/pdf/SkPDFResourceDict.h b/src/pdf/SkPDFResourceDict.h index fa9bb448c8..551d20bc8c 100644 --- a/src/pdf/SkPDFResourceDict.h +++ b/src/pdf/SkPDFResourceDict.h @@ -78,8 +78,6 @@ private: SkPDFObject* insertResource(SkPDFResourceType type, int key, SkPDFObject* value); - SkTSet fResources; - SkTDArray fTypes; typedef SkPDFDict INHERITED; }; diff --git a/src/pdf/SkPDFShader.cpp b/src/pdf/SkPDFShader.cpp index 0b66191953..8fc97da307 100644 --- a/src/pdf/SkPDFShader.cpp +++ b/src/pdf/SkPDFShader.cpp @@ -20,7 +20,6 @@ #include "SkScalar.h" #include "SkStream.h" #include "SkTemplates.h" -#include "SkTSet.h" #include "SkTypes.h" static bool inverse_transform_bbox(const SkMatrix& matrix, SkRect* bbox) { @@ -509,9 +508,7 @@ private: SkPDFFunctionShader::SkPDFFunctionShader(SkPDFShader::State* state) : SkPDFDict("Pattern"), fShaderState(state) {} -SkPDFFunctionShader::~SkPDFFunctionShader() { - fResources.unrefAll(); -} +SkPDFFunctionShader::~SkPDFFunctionShader() {} bool SkPDFFunctionShader::equals(const SkPDFShader::State& state) const { return state == *fShaderState; @@ -537,9 +534,7 @@ bool SkPDFImageShader::equals(const SkPDFShader::State& state) const { return state == *fShaderState; } -SkPDFImageShader::~SkPDFImageShader() { - fResources.unrefAll(); -} +SkPDFImageShader::~SkPDFImageShader() {} //////////////////////////////////////////////////////////////////////////////// @@ -599,8 +594,9 @@ static SkPDFResourceDict* get_gradient_resource_dict( } static void populate_tiling_pattern_dict(SkPDFDict* pattern, - SkRect& bbox, SkPDFDict* resources, - const SkMatrix& matrix) { + SkRect& bbox, + SkPDFDict* resources, + const SkMatrix& matrix) { const int kTiling_PatternType = 1; const int kColoredTilingPattern_PaintType = 1; const int kConstantSpacing_TilingType = 1; @@ -673,8 +669,8 @@ SkPDFAlphaFunctionShader* SkPDFAlphaFunctionShader::Create( SkAutoTDelete opaqueState(state.CreateOpaqueState()); - SkPDFObject* colorShader = - get_pdf_shader_by_state(canon, dpi, &opaqueState); + SkAutoTUnref colorShader( + get_pdf_shader_by_state(canon, dpi, &opaqueState)); if (!colorShader) { return NULL; } @@ -687,17 +683,14 @@ SkPDFAlphaFunctionShader* SkPDFAlphaFunctionShader::Create( SkPDFAlphaFunctionShader* alphaFunctionShader = SkNEW_ARGS(SkPDFAlphaFunctionShader, (autoState->detach())); - alphaFunctionShader->fColorShader.reset(colorShader); - - alphaFunctionShader->fResourceDict.reset(get_gradient_resource_dict( - alphaFunctionShader->fColorShader.get(), alphaGs.get())); + SkAutoTUnref resourceDict( + get_gradient_resource_dict(colorShader.get(), alphaGs.get())); SkAutoTDelete colorStream( create_pattern_fill_content(0, bbox)); alphaFunctionShader->setData(colorStream.get()); - populate_tiling_pattern_dict(alphaFunctionShader, bbox, - alphaFunctionShader->fResourceDict.get(), + populate_tiling_pattern_dict(alphaFunctionShader, bbox, resourceDict.get(), SkMatrix::I()); canon->addAlphaShader(alphaFunctionShader); return alphaFunctionShader; @@ -893,9 +886,6 @@ SkPDFFunctionShader* SkPDFFunctionShader::Create( SkPDFFunctionShader* pdfFunctionShader = SkNEW_ARGS(SkPDFFunctionShader, (autoState->detach())); - pdfFunctionShader->fResources.push(function); - // Pass ownership to resource list. - pdfFunctionShader->insertInt("PatternType", 2); pdfFunctionShader->insert("Matrix", matrixArray.get()); pdfFunctionShader->insert("Shading", pdfShader.get()); diff --git a/src/pdf/SkPDFShader.h b/src/pdf/SkPDFShader.h index 4fdbc44cf7..51add585a7 100644 --- a/src/pdf/SkPDFShader.h +++ b/src/pdf/SkPDFShader.h @@ -62,7 +62,6 @@ public: private: SkAutoTDelete fShaderState; - SkTDArray fResources; SkPDFFunctionShader(SkPDFShader::State*); typedef SkPDFDict INHERITED; }; @@ -82,9 +81,8 @@ public: private: SkAutoTDelete fShaderState; - SkAutoTUnref fColorShader; - SkAutoTUnref fResourceDict; SkPDFAlphaFunctionShader(SkPDFShader::State*); + typedef SkPDFStream INHERITED; }; class SkPDFImageShader : public SkPDFStream { @@ -97,8 +95,8 @@ public: private: SkAutoTDelete fShaderState; - SkTSet fResources; SkPDFImageShader(SkPDFShader::State*); + typedef SkPDFStream INHERITED; }; #endif -- cgit v1.2.3