| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkPDFDevice.h" | 8 #include "SkPDFDevice.h" |
| 9 | 9 |
| 10 #include "SkAnnotation.h" | 10 #include "SkAnnotation.h" |
| (...skipping 1263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1274 fLastMarginContentEntry = contentEntry; | 1274 fLastMarginContentEntry = contentEntry; |
| 1275 } | 1275 } |
| 1276 } | 1276 } |
| 1277 | 1277 |
| 1278 void SkPDFDevice::setDrawingArea(DrawingArea drawingArea) { | 1278 void SkPDFDevice::setDrawingArea(DrawingArea drawingArea) { |
| 1279 // A ScopedContentEntry only exists during the course of a draw call, so | 1279 // A ScopedContentEntry only exists during the course of a draw call, so |
| 1280 // this can't be called while a ScopedContentEntry exists. | 1280 // this can't be called while a ScopedContentEntry exists. |
| 1281 fDrawingArea = drawingArea; | 1281 fDrawingArea = drawingArea; |
| 1282 } | 1282 } |
| 1283 | 1283 |
| 1284 SkPDFResourceDict* SkPDFDevice::createResourceDict() const { | 1284 SkPDFDict* SkPDFDevice::createResourceDict() const { |
| 1285 SkAutoTUnref<SkPDFResourceDict> resourceDict(SkNEW(SkPDFResourceDict)); | 1285 SkTDArray<SkPDFObject*> fonts; |
| 1286 if (fGraphicStateResources.count()) { | 1286 fonts.setReserve(fFontResources.count()); |
| 1287 for (int i = 0; i < fGraphicStateResources.count(); i++) { | 1287 for (SkPDFFont* font : fFontResources) { |
| 1288 resourceDict->insertResourceAsReference( | 1288 fonts.push(font); |
| 1289 SkPDFResourceDict::kExtGState_ResourceType, | |
| 1290 i, fGraphicStateResources[i]); | |
| 1291 } | |
| 1292 } | 1289 } |
| 1293 | 1290 return SkPDFResourceDict::Create( |
| 1294 if (fXObjectResources.count()) { | 1291 &fGraphicStateResources, |
| 1295 for (int i = 0; i < fXObjectResources.count(); i++) { | 1292 &fShaderResources, |
| 1296 resourceDict->insertResourceAsReference( | 1293 &fXObjectResources, |
| 1297 SkPDFResourceDict::kXObject_ResourceType, | 1294 &fonts); |
| 1298 i, fXObjectResources[i]); | |
| 1299 } | |
| 1300 } | |
| 1301 | |
| 1302 if (fFontResources.count()) { | |
| 1303 for (int i = 0; i < fFontResources.count(); i++) { | |
| 1304 resourceDict->insertResourceAsReference( | |
| 1305 SkPDFResourceDict::kFont_ResourceType, | |
| 1306 i, fFontResources[i]); | |
| 1307 } | |
| 1308 } | |
| 1309 | |
| 1310 if (fShaderResources.count()) { | |
| 1311 SkAutoTUnref<SkPDFDict> patterns(new SkPDFDict()); | |
| 1312 for (int i = 0; i < fShaderResources.count(); i++) { | |
| 1313 resourceDict->insertResourceAsReference( | |
| 1314 SkPDFResourceDict::kPattern_ResourceType, | |
| 1315 i, fShaderResources[i]); | |
| 1316 } | |
| 1317 } | |
| 1318 return resourceDict.detach(); | |
| 1319 } | 1295 } |
| 1320 | 1296 |
| 1321 const SkTDArray<SkPDFFont*>& SkPDFDevice::getFontResources() const { | 1297 const SkTDArray<SkPDFFont*>& SkPDFDevice::getFontResources() const { |
| 1322 return fFontResources; | 1298 return fFontResources; |
| 1323 } | 1299 } |
| 1324 | 1300 |
| 1325 SkPDFArray* SkPDFDevice::copyMediaBox() const { | 1301 SkPDFArray* SkPDFDevice::copyMediaBox() const { |
| 1326 // should this be a singleton? | 1302 // should this be a singleton? |
| 1327 SkAutoTUnref<SkPDFInt> zero(SkNEW_ARGS(SkPDFInt, (0))); | 1303 SkAutoTUnref<SkPDFInt> zero(SkNEW_ARGS(SkPDFInt, (0))); |
| 1328 | 1304 |
| (...skipping 838 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2167 return; | 2143 return; |
| 2168 } | 2144 } |
| 2169 SkAutoTUnref<SkPDFObject> image(SkPDFBitmap::Create(fCanon, subsetBitmap)); | 2145 SkAutoTUnref<SkPDFObject> image(SkPDFBitmap::Create(fCanon, subsetBitmap)); |
| 2170 if (!image) { | 2146 if (!image) { |
| 2171 return; | 2147 return; |
| 2172 } | 2148 } |
| 2173 | 2149 |
| 2174 SkPDFUtils::DrawFormXObject(this->addXObjectResource(image.get()), | 2150 SkPDFUtils::DrawFormXObject(this->addXObjectResource(image.get()), |
| 2175 &content.entry()->fContent); | 2151 &content.entry()->fContent); |
| 2176 } | 2152 } |
| OLD | NEW |