aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/pdf/SkPDFShader.h
diff options
context:
space:
mode:
authorGravatar halcanary <halcanary@google.com>2015-02-10 13:32:09 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-02-10 13:32:09 -0800
commitbf799cd228282431e6311900dd383083f8af7164 (patch)
tree4c5e1bf301d96a16f58998e89ff048cebc7732cc /src/pdf/SkPDFShader.h
parentc8262ccbf988390729ad77734254a342d3c2cb33 (diff)
Simplify reference management in SkPDF
Prior to this change, SkPDFObject subclasses were required to track their resources separately from the document structure. (An object has a resource if it depends, via an indirect reference, on another object). This led to a lot of extra code to duplicate effort. I replace the getResources() function with the much simpler addResources() function. I only define a non-trivial addResources() method on arrays, dictionaries, and indirect object references. All other specialized classes simply rely on their parent class's implementation. SkPDFObject::addResources() works by recursively walking the directed graph of object (direct and indirect) references and adding resources to a set. It doesn't matter that there are closed loops in the graph, since we check the set before walking down a branch. - Add SkPDFObject::addResources() virtual function, with four implementations - Remove SkPDFObject::getResources() virtual function and all implementations. - Remove SkPDFObject::GetResourcesHelper() - Remove SkPDFObject::AddResourceHelper() - In SkPDFCatalog::findObjectIndex(), add an object to the catalog if it doesn't exist yet. - SkPDFCatalog::setSubstitute() no longer sets up resources - SkPDFDocument.cpp no longer needs the Streamer object - SkPDFDocument.cpp calls fDocCatalog->addResources to build the resource list. - SkPDFFont::addResource() removed - All SkPDF-::fResource sets removed (they are redundant). - removed SkPDFImage::addSMask() function - SkPDFResourceDict::getReferencedResources() removed. Motivation: this removes quite a bit of code and makes the objects slightly slimmer in memory. Most importantly, this will lead the way towards removing SkPDFObject's inheritance from SkRefCnt, which will greatly simplify everything. Testing: I usually test changes to the PDF backend by comparing checksums of PDF files rendered from GMs and SKPs before and after the change. This change both re-orders and re-numbers the indirect PDF objects. I used the qpdf program to normalize the PDFs and then compared the normalized outputs from before and after the change; they matched. Review URL: https://codereview.chromium.org/870333002
Diffstat (limited to 'src/pdf/SkPDFShader.h')
-rw-r--r--src/pdf/SkPDFShader.h6
1 files changed, 0 insertions, 6 deletions
diff --git a/src/pdf/SkPDFShader.h b/src/pdf/SkPDFShader.h
index 1547aaf8c4..3fb962ab21 100644
--- a/src/pdf/SkPDFShader.h
+++ b/src/pdf/SkPDFShader.h
@@ -55,8 +55,6 @@ public:
static SkPDFFunctionShader* Create(SkAutoTDelete<SkPDFShader::State>*);
virtual ~SkPDFFunctionShader();
bool equals(const SkPDFShader::State&) const;
- void getResources(const SkTSet<SkPDFObject*>&,
- SkTSet<SkPDFObject*>*) SK_OVERRIDE;
private:
SkAutoTDelete<const SkPDFShader::State> fShaderState;
@@ -74,8 +72,6 @@ class SkPDFAlphaFunctionShader : public SkPDFStream {
public:
static SkPDFAlphaFunctionShader* Create(SkAutoTDelete<SkPDFShader::State>*);
virtual ~SkPDFAlphaFunctionShader();
- void getResources(const SkTSet<SkPDFObject*>&,
- SkTSet<SkPDFObject*>*) SK_OVERRIDE;
bool equals(const SkPDFShader::State&) const;
private:
@@ -89,8 +85,6 @@ class SkPDFImageShader : public SkPDFStream {
public:
static SkPDFImageShader* Create(SkAutoTDelete<SkPDFShader::State>*);
virtual ~SkPDFImageShader();
- void getResources(const SkTSet<SkPDFObject*>&,
- SkTSet<SkPDFObject*>*) SK_OVERRIDE;
bool equals(const SkPDFShader::State&) const;
private: