Index: src/pdf/SkPDFDevice.cpp |
diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp |
index f624cb49f97b7bce0096ccb127663e091923b9a3..5167474f106295cc15808104801308d7d256e1eb 100644 |
--- a/src/pdf/SkPDFDevice.cpp |
+++ b/src/pdf/SkPDFDevice.cpp |
@@ -1281,41 +1281,17 @@ void SkPDFDevice::setDrawingArea(DrawingArea drawingArea) { |
fDrawingArea = drawingArea; |
} |
-SkPDFResourceDict* SkPDFDevice::createResourceDict() const { |
- SkAutoTUnref<SkPDFResourceDict> resourceDict(SkNEW(SkPDFResourceDict)); |
- if (fGraphicStateResources.count()) { |
- for (int i = 0; i < fGraphicStateResources.count(); i++) { |
- resourceDict->insertResourceAsReference( |
- SkPDFResourceDict::kExtGState_ResourceType, |
- i, fGraphicStateResources[i]); |
- } |
- } |
- |
- if (fXObjectResources.count()) { |
- for (int i = 0; i < fXObjectResources.count(); i++) { |
- resourceDict->insertResourceAsReference( |
- SkPDFResourceDict::kXObject_ResourceType, |
- i, fXObjectResources[i]); |
- } |
- } |
- |
- if (fFontResources.count()) { |
- for (int i = 0; i < fFontResources.count(); i++) { |
- resourceDict->insertResourceAsReference( |
- SkPDFResourceDict::kFont_ResourceType, |
- i, fFontResources[i]); |
- } |
- } |
- |
- if (fShaderResources.count()) { |
- SkAutoTUnref<SkPDFDict> patterns(new SkPDFDict()); |
- for (int i = 0; i < fShaderResources.count(); i++) { |
- resourceDict->insertResourceAsReference( |
- SkPDFResourceDict::kPattern_ResourceType, |
- i, fShaderResources[i]); |
- } |
- } |
- return resourceDict.detach(); |
+SkPDFDict* SkPDFDevice::createResourceDict() const { |
+ SkTDArray<SkPDFObject*> fonts; |
+ fonts.setReserve(fFontResources.count()); |
+ for (SkPDFFont* font : fFontResources) { |
+ fonts.push(font); |
+ } |
+ return SkPDFResourceDict::Create( |
+ &fGraphicStateResources, |
+ &fShaderResources, |
+ &fXObjectResources, |
+ &fonts); |
} |
const SkTDArray<SkPDFFont*>& SkPDFDevice::getFontResources() const { |