| Index: src/pdf/SkPDFDevice.cpp
|
| diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp
|
| index 9f7a3700ef721307e5871dacce51366e8cd80108..e988112f3764fd32b2d52dde2a89f944e9540d1d 100644
|
| --- a/src/pdf/SkPDFDevice.cpp
|
| +++ b/src/pdf/SkPDFDevice.cpp
|
| @@ -879,7 +879,7 @@
|
| }
|
| }
|
|
|
| -static sk_sp<SkPDFDict> create_link_annotation(const SkRect& translatedRect) {
|
| +static SkPDFDict* create_link_annotation(const SkRect& translatedRect) {
|
| auto annotation = sk_make_sp<SkPDFDict>("Annot");
|
| annotation->insertName("Subtype", "Link");
|
|
|
| @@ -888,7 +888,7 @@
|
| border->appendInt(0); // Horizontal corner radius.
|
| border->appendInt(0); // Vertical corner radius.
|
| border->appendInt(0); // Width, 0 = no border.
|
| - annotation->insertObject("Border", std::move(border));
|
| + annotation->insertObject("Border", border.release());
|
|
|
| auto rect = sk_make_sp<SkPDFArray>();
|
| rect->reserve(4);
|
| @@ -896,29 +896,30 @@
|
| rect->appendScalar(translatedRect.fTop);
|
| rect->appendScalar(translatedRect.fRight);
|
| rect->appendScalar(translatedRect.fBottom);
|
| - annotation->insertObject("Rect", std::move(rect));
|
| -
|
| - return std::move(annotation);
|
| -}
|
| -
|
| -static sk_sp<SkPDFDict> create_link_to_url(const SkData* urlData, const SkRect& r) {
|
| - auto annotation = create_link_annotation(r);
|
| + annotation->insertObject("Rect", rect.release());
|
| +
|
| + return annotation.release();
|
| +}
|
| +
|
| +static SkPDFDict* create_link_to_url(const SkData* urlData, const SkRect& r) {
|
| + sk_sp<SkPDFDict> annotation(create_link_annotation(r));
|
| +
|
| SkString url(static_cast<const char *>(urlData->data()),
|
| urlData->size() - 1);
|
| auto action = sk_make_sp<SkPDFDict>("Action");
|
| action->insertName("S", "URI");
|
| action->insertString("URI", url);
|
| - annotation->insertObject("A", std::move(action));
|
| - return std::move(annotation);
|
| -}
|
| -
|
| -static sk_sp<SkPDFDict> create_link_named_dest(const SkData* nameData,
|
| - const SkRect& r) {
|
| - auto annotation = create_link_annotation(r);
|
| + annotation->insertObject("A", action.release());
|
| + return annotation.release();
|
| +}
|
| +
|
| +static SkPDFDict* create_link_named_dest(const SkData* nameData,
|
| + const SkRect& r) {
|
| + sk_sp<SkPDFDict> annotation(create_link_annotation(r));
|
| SkString name(static_cast<const char *>(nameData->data()),
|
| nameData->size() - 1);
|
| annotation->insertName("Dest", name);
|
| - return std::move(annotation);
|
| + return annotation.release();
|
| }
|
|
|
| void SkPDFDevice::drawRect(const SkDraw& d,
|
| @@ -1506,13 +1507,13 @@
|
| fDrawingArea = drawingArea;
|
| }
|
|
|
| -sk_sp<SkPDFDict> SkPDFDevice::makeResourceDict() const {
|
| +SkPDFDict* SkPDFDevice::createResourceDict() const {
|
| SkTDArray<SkPDFObject*> fonts;
|
| fonts.setReserve(fFontResources.count());
|
| for (SkPDFFont* font : fFontResources) {
|
| fonts.push(font);
|
| }
|
| - return SkPDFResourceDict::Make(
|
| + return SkPDFResourceDict::Create(
|
| &fGraphicStateResources,
|
| &fShaderResources,
|
| &fXObjectResources,
|
| @@ -1523,23 +1524,24 @@
|
| return fFontResources;
|
| }
|
|
|
| -sk_sp<SkPDFArray> SkPDFDevice::copyMediaBox() const {
|
| +SkPDFArray* SkPDFDevice::copyMediaBox() const {
|
| + // should this be a singleton?
|
| +
|
| auto mediaBox = sk_make_sp<SkPDFArray>();
|
| mediaBox->reserve(4);
|
| mediaBox->appendInt(0);
|
| mediaBox->appendInt(0);
|
| - mediaBox->appendInt(fPageSize.width());
|
| - mediaBox->appendInt(fPageSize.height());
|
| - return std::move(mediaBox);
|
| -}
|
| -
|
| -skstd::unique_ptr<SkStreamAsset> SkPDFDevice::content() const {
|
| + mediaBox->appendInt(fPageSize.fWidth);
|
| + mediaBox->appendInt(fPageSize.fHeight);
|
| + return mediaBox.release();
|
| +}
|
| +
|
| +SkStreamAsset* SkPDFDevice::content() const {
|
| SkDynamicMemoryWStream buffer;
|
| this->writeContent(&buffer);
|
| - return skstd::unique_ptr<SkStreamAsset>(
|
| - buffer.bytesWritten() > 0
|
| - ? buffer.detachAsStream()
|
| - : new SkMemoryStream);
|
| + return buffer.bytesWritten() > 0
|
| + ? buffer.detachAsStream()
|
| + : new SkMemoryStream;
|
| }
|
|
|
| void SkPDFDevice::copyContentEntriesToData(ContentEntry* entry,
|
| @@ -1711,14 +1713,14 @@
|
| for (const NamedDestination& dest : fNamedDestinations) {
|
| auto pdfDest = sk_make_sp<SkPDFArray>();
|
| pdfDest->reserve(5);
|
| - pdfDest->appendObjRef(sk_sp<SkPDFObject>(SkRef(page)));
|
| + pdfDest->appendObjRef(SkRef(page));
|
| pdfDest->appendName("XYZ");
|
| SkPoint p = fInitialTransform.mapXY(dest.point.x(), dest.point.y());
|
| pdfDest->appendScalar(p.x());
|
| pdfDest->appendScalar(p.y());
|
| pdfDest->appendInt(0); // Leave zoom unchanged
|
| SkString name(static_cast<const char*>(dest.nameData->data()));
|
| - dict->insertObject(name, std::move(pdfDest));
|
| + dict->insertObject(name, pdfDest.release());
|
| }
|
| }
|
|
|
|
|