aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/pdf/SkPDFPage.h
diff options
context:
space:
mode:
authorGravatar edisonn@google.com <edisonn@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-02-27 16:54:44 +0000
committerGravatar edisonn@google.com <edisonn@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-02-27 16:54:44 +0000
commit676aef05ab1b8e913032648470ff483185e92b51 (patch)
tree066cd423e43ed0e43db04b20694dbceb0c1c925b /src/pdf/SkPDFPage.h
parent94ba6c62c70614ff4825db80c2d3af24a49b1e78 (diff)
Use SkSet to fix issue when pdf generates an exp number of resources.
The problem fixed - http://code.google.com/p/skia/issues/detail?id=940 - is that getResources will recursively obtain all child resource recursively without checking for duplicates. If we have lots of duplicates, then we try to build a very large vector (exponential with the number of nodes usually) and sooner or later we end up using too much memory and crash. A possible solution could have been to make sure resources do not have duplicates, but that requirement is impractical, and it this leaves the solution fragile, if there is any issue in the tree, we crash. When we emit the pdf, the large number of duplicates is not an issue, because SkPDFCatalog::addObject will deal with duplicates. I have run the gm with --config pdf, and the images are 100% same bits, while the pdfs have the same size but some very small changes, the order of some objects. Review URL: https://codereview.appspot.com/6744050 git-svn-id: http://skia.googlecode.com/svn/trunk@7883 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/pdf/SkPDFPage.h')
-rw-r--r--src/pdf/SkPDFPage.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/pdf/SkPDFPage.h b/src/pdf/SkPDFPage.h
index 72ba335e66..17fd437623 100644
--- a/src/pdf/SkPDFPage.h
+++ b/src/pdf/SkPDFPage.h
@@ -40,13 +40,15 @@ public:
* that the page is part of.
* @param catalog The catalog to add page content objects to.
* @param firstPage Indicate if this is the first page of a document.
- * @param resourceObjects All the resource objects (recursively) used on
+ * @param newResourceObjects All the resource objects (recursively) used on
* the page are added to this array. This gives
* the caller a chance to deduplicate resources
* across pages.
+ * @param knownResourceObjects The set of resources to be ignored.
*/
void finalizePage(SkPDFCatalog* catalog, bool firstPage,
- SkTDArray<SkPDFObject*>* resourceObjects);
+ const SkTSet<SkPDFObject*>& knownResourceObjects,
+ SkTSet<SkPDFObject*>* newResourceObjects);
/** Determine the size of the page content and store to the catalog
* the offsets of all nonresource-indirect objects that make up the page