Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(126)

Side by Side Diff: src/pdf/SkPDFFormXObject.cpp

Issue 12387086: Unwind PDFObject destructor calls into heap instead of stack. Notice: the order of the destructors … (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/pdf/SkPDFDevice.cpp ('k') | src/pdf/SkPDFGraphicState.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2010 The Android Open Source Project 3 * Copyright 2010 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "SkPDFFormXObject.h" 10 #include "SkPDFFormXObject.h"
11 11
12 #include "SkMatrix.h" 12 #include "SkMatrix.h"
13 #include "SkPDFCatalog.h" 13 #include "SkPDFCatalog.h"
14 #include "SkPDFDevice.h" 14 #include "SkPDFDevice.h"
15 #include "SkPDFUtils.h" 15 #include "SkPDFUtils.h"
16 #include "SkStream.h" 16 #include "SkStream.h"
17 #include "SkTypes.h" 17 #include "SkTypes.h"
18 18
19 SkPDFFormXObject::SkPDFFormXObject(SkPDFDevice* device) { 19 SkPDFFormXObject::SkPDFFormXObject(SkPDFDevice* device) {
20 // We don't want to keep around device because we'd have two copies 20 // We don't want to keep around device because we'd have two copies
21 // of content, so reference or copy everything we need (content and 21 // of content, so reference or copy everything we need (content and
22 // resources). 22 // resources).
23 device->getResources(&fResources, false); 23 device->getResources(&fResources, false);
24 24
25 // Fail fast if in the tree of resources a child references a parent. 25 // Fail fast if in the tree of resources a child references a parent.
26 // If there is an issue, getResources will end up consuming all memory. 26 // If there is an issue, getResources will end up consuming all memory.
27 // TODO: A better approach might be for all SkPDFObject to keep track 27 // TODO: A better approach might be for all SkPDFObject to keep track
28 // of possible cycles. 28 // of possible cycles.
29 #ifdef SK_DEBUG
30 SkTDArray<SkPDFObject*> dummy_resourceList;
31 getResources(&dummy_resourceList);
32 #endif
33 29
34 SkAutoTUnref<SkStream> content(device->content()); 30 SkAutoTUnref<SkStream> content(device->content());
35 setData(content.get()); 31 setData(content.get());
36 32
37 insertName("Type", "XObject"); 33 insertName("Type", "XObject");
38 insertName("Subtype", "Form"); 34 insertName("Subtype", "Form");
39 SkSafeUnref(this->insert("BBox", device->copyMediaBox())); 35 SkSafeUnref(this->insert("BBox", device->copyMediaBox()));
40 insert("Resources", device->getResourceDict()); 36 insert("Resources", device->getResourceDict());
41 37
42 // We invert the initial transform and apply that to the xobject so that 38 // We invert the initial transform and apply that to the xobject so that
(...skipping 17 matching lines...) Expand all
60 insert("Group", group.get()); 56 insert("Group", group.get());
61 } 57 }
62 58
63 SkPDFFormXObject::~SkPDFFormXObject() { 59 SkPDFFormXObject::~SkPDFFormXObject() {
64 fResources.unrefAll(); 60 fResources.unrefAll();
65 } 61 }
66 62
67 void SkPDFFormXObject::getResources(SkTDArray<SkPDFObject*>* resourceList) { 63 void SkPDFFormXObject::getResources(SkTDArray<SkPDFObject*>* resourceList) {
68 GetResourcesHelper(&fResources, resourceList); 64 GetResourcesHelper(&fResources, resourceList);
69 } 65 }
OLDNEW
« no previous file with comments | « src/pdf/SkPDFDevice.cpp ('k') | src/pdf/SkPDFGraphicState.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698