diff options
author | halcanary <halcanary@google.com> | 2016-03-06 14:47:10 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-06 14:47:10 -0800 |
commit | fcad44bbb1e0384620e7b738a0f5904c940a6861 (patch) | |
tree | f6e9c8fdfb1b473f57ad968e5435d855db180bf0 /src | |
parent | 941da9d66171bd8efd2f6c5e25ff90c8c69885c1 (diff) |
SkPDF: AutoTUnref<T> changes in use
::detach() -> ::release()
::operator T*() -> ::get()
This makes all use of AutoTUnref work the same as sk_sp.
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1772493002
Review URL: https://codereview.chromium.org/1772493002
Diffstat (limited to 'src')
-rw-r--r-- | src/doc/SkDocument_PDF.cpp | 30 | ||||
-rw-r--r-- | src/pdf/SkPDFBitmap.cpp | 12 | ||||
-rw-r--r-- | src/pdf/SkPDFCanon.h | 5 | ||||
-rw-r--r-- | src/pdf/SkPDFDevice.cpp | 30 | ||||
-rw-r--r-- | src/pdf/SkPDFFont.cpp | 40 | ||||
-rw-r--r-- | src/pdf/SkPDFFormXObject.cpp | 6 | ||||
-rw-r--r-- | src/pdf/SkPDFGraphicState.cpp | 12 | ||||
-rw-r--r-- | src/pdf/SkPDFMetadata.cpp | 4 | ||||
-rw-r--r-- | src/pdf/SkPDFResourceDict.cpp | 14 | ||||
-rw-r--r-- | src/pdf/SkPDFShader.cpp | 12 | ||||
-rw-r--r-- | src/pdf/SkPDFTypes.h | 2 |
11 files changed, 85 insertions, 82 deletions
diff --git a/src/doc/SkDocument_PDF.cpp b/src/doc/SkDocument_PDF.cpp index a56de707fe..942e42c9c4 100644 --- a/src/doc/SkDocument_PDF.cpp +++ b/src/doc/SkDocument_PDF.cpp @@ -81,12 +81,12 @@ static SkPDFDict* create_pdf_page(const SkPDFDevice* pageDevice) { page->insertObject("Resources", pageDevice->createResourceDict()); page->insertObject("MediaBox", pageDevice->copyMediaBox()); SkAutoTUnref<SkPDFArray> annotations(new SkPDFArray); - pageDevice->appendAnnotations(annotations); + pageDevice->appendAnnotations(annotations.get()); if (annotations->size() > 0) { - page->insertObject("Annots", annotations.detach()); + page->insertObject("Annots", annotations.release()); } page->insertObjRef("Contents", create_pdf_page_content(pageDevice)); - return page.detach(); + return page.release(); } static void generate_page_tree(const SkTDArray<SkPDFDict*>& pages, @@ -151,8 +151,8 @@ static void generate_page_tree(const SkTDArray<SkPDFDict*>& pages, pageCount = ((pages.count() - 1) % treeCapacity) + 1; } newNode->insertInt("Count", pageCount); - newNode->insertObject("Kids", kids.detach()); - nextRoundNodes.push(newNode.detach()); // Transfer reference. + newNode->insertObject("Kids", kids.release()); + nextRoundNodes.push(newNode.release()); // Transfer reference. } curNodes = nextRoundNodes; @@ -181,8 +181,8 @@ static bool emit_pdf_document(const SkTDArray<const SkPDFDevice*>& pageDevices, SkASSERT(i == 0 || pageDevices[i - 1]->getCanon() == pageDevices[i]->getCanon()); SkAutoTUnref<SkPDFDict> page(create_pdf_page(pageDevices[i])); - pageDevices[i]->appendDestinations(dests, page.get()); - pages.push(page.detach()); + pageDevices[i]->appendDestinations(dests.get(), page.get()); + pages.push(page.release()); } SkAutoTUnref<SkPDFDict> docCatalog(new SkPDFDict("Catalog")); @@ -200,7 +200,7 @@ static bool emit_pdf_document(const SkTDArray<const SkPDFDevice*>& pageDevices, // works best with reproducible outputs. id.reset(SkPDFMetadata::CreatePdfId(uuid, uuid)); xmp.reset(metadata.createXMPObject(uuid, uuid)); - docCatalog->insertObjRef("Metadata", xmp.detach()); + docCatalog->insertObjRef("Metadata", xmp.release()); // sRGB is specified by HTML, CSS, and SVG. SkAutoTUnref<SkPDFDict> outputIntent(new SkPDFDict("OutputIntent")); @@ -209,10 +209,10 @@ static bool emit_pdf_document(const SkTDArray<const SkPDFDevice*>& pageDevices, outputIntent->insertString("OutputConditionIdentifier", "sRGB IEC61966-2.1"); SkAutoTUnref<SkPDFArray> intentArray(new SkPDFArray); - intentArray->appendObject(outputIntent.detach()); + intentArray->appendObject(outputIntent.release()); // Don't specify OutputIntents if we are not in PDF/A mode since // no one has ever asked for this feature. - docCatalog->insertObject("OutputIntents", intentArray.detach()); + docCatalog->insertObject("OutputIntents", intentArray.release()); #endif SkTDArray<SkPDFDict*> pageTree; @@ -221,7 +221,7 @@ static bool emit_pdf_document(const SkTDArray<const SkPDFDevice*>& pageDevices, docCatalog->insertObjRef("Pages", SkRef(pageTreeRoot)); if (dests->size() > 0) { - docCatalog->insertObjRef("Dests", dests.detach()); + docCatalog->insertObjRef("Dests", dests.release()); } // Build font subsetting info before proceeding. @@ -229,7 +229,7 @@ static bool emit_pdf_document(const SkTDArray<const SkPDFDevice*>& pageDevices, perform_font_subsetting(pageDevices, &substitutes); SkPDFObjNumMap objNumMap; - objNumMap.addObjectRecursively(infoDict, substitutes); + objNumMap.addObjectRecursively(infoDict.get(), substitutes); objNumMap.addObjectRecursively(docCatalog.get(), substitutes); size_t baseOffset = stream->bytesWritten(); emit_pdf_header(stream); @@ -262,7 +262,7 @@ static bool emit_pdf_document(const SkTDArray<const SkPDFDevice*>& pageDevices, stream->writeText(" 00000 n \n"); } emit_pdf_footer(stream, objNumMap, substitutes, docCatalog.get(), objCount, - xRefFileOffset, infoDict.detach(), id.detach()); + xRefFileOffset, infoDict.release(), id.release()); // The page tree has both child and parent pointers, so it creates a // reference cycle. We must clear that cycle to properly reclaim memory. @@ -326,7 +326,7 @@ public: SkPixelSerializer* jpegEncoder) : SkDocument(stream, doneProc) , fRasterDpi(rasterDpi) { - fCanon.fPixelSerializer.reset(SkSafeRef(jpegEncoder)); + fCanon.setPixelSerializer(SkSafeRef(jpegEncoder)); } virtual ~SkDocument_PDF() { @@ -344,7 +344,7 @@ protected: SkAutoTUnref<SkPDFDevice> device( SkPDFDevice::Create(pageSize, fRasterDpi, &fCanon)); fCanvas.reset(new SkCanvas(device.get())); - fPageDevices.push(device.detach()); + fPageDevices.push(device.release()); fCanvas->clipRect(trimBox); fCanvas->translate(trimBox.x(), trimBox.y()); return fCanvas.get(); diff --git a/src/pdf/SkPDFBitmap.cpp b/src/pdf/SkPDFBitmap.cpp index e067ed1c0b..66124cef35 100644 --- a/src/pdf/SkPDFBitmap.cpp +++ b/src/pdf/SkPDFBitmap.cpp @@ -387,7 +387,7 @@ public: void emitObject(SkWStream* stream, const SkPDFObjNumMap& objNumMap, const SkPDFSubstituteMap& subs) const override { - emit_image_xobject(stream, fImage, true, nullptr, objNumMap, subs); + emit_image_xobject(stream, fImage.get(), true, nullptr, objNumMap, subs); } private: @@ -404,7 +404,7 @@ public: void emitObject(SkWStream* stream, const SkPDFObjNumMap& objNumMap, const SkPDFSubstituteMap& subs) const override { - emit_image_xobject(stream, fImage, false, fSMask, objNumMap, subs); + emit_image_xobject(stream, fImage.get(), false, fSMask.get(), objNumMap, subs); } void addResources(SkPDFObjNumMap* catalog, const SkPDFSubstituteMap& subs) const override { @@ -472,7 +472,7 @@ SkPDFObject* SkPDFCreateBitmapObject(const SkImage* image, SkPixelSerializer* pixelSerializer) { SkAutoTUnref<SkData> data(image->refEncoded()); SkJFIFInfo info; - if (data && SkIsJFIF(data, &info) && + if (data && SkIsJFIF(data.get(), &info) && (!pixelSerializer || pixelSerializer->useEncodedData(data->data(), data->size()))) { // If there is a SkPixelSerializer, give it a chance to @@ -484,7 +484,7 @@ SkPDFObject* SkPDFCreateBitmapObject(const SkImage* image, #ifdef SK_PDF_IMAGE_STATS gJpegImageObjects.fetch_add(1); #endif - return new PDFJpegBitmap(info.fSize, data, yuv); + return new PDFJpegBitmap(info.fSize, data.get(), yuv); } } @@ -493,10 +493,10 @@ SkPDFObject* SkPDFCreateBitmapObject(const SkImage* image, SkAutoPixmapUnlock apu; if (as_IB(image)->getROPixels(&bm) && bm.requestLock(&apu)) { data.reset(pixelSerializer->encode(apu.pixmap())); - if (data && SkIsJFIF(data, &info)) { + if (data && SkIsJFIF(data.get(), &info)) { bool yuv = info.fType == SkJFIFInfo::kYCbCr; if (info.fSize == image->dimensions()) { // Sanity check. - return new PDFJpegBitmap(info.fSize, data, yuv); + return new PDFJpegBitmap(info.fSize, data.get(), yuv); } } } diff --git a/src/pdf/SkPDFCanon.h b/src/pdf/SkPDFCanon.h index 9ecb3a02d9..4c92fcbf6f 100644 --- a/src/pdf/SkPDFCanon.h +++ b/src/pdf/SkPDFCanon.h @@ -81,7 +81,8 @@ public: SkTHashMap<uint32_t, bool> fCanEmbedTypeface; - SkAutoTUnref<SkPixelSerializer> fPixelSerializer; + SkPixelSerializer* getPixelSerializer() const { return fPixelSerializer.get(); } + void setPixelSerializer(SkPixelSerializer* ps) { fPixelSerializer.reset(ps); } private: struct FontRec { @@ -116,5 +117,7 @@ private: SkTHashMap<SkBitmapKey, const SkImage*> fBitmapToImageMap; SkTHashMap<uint32_t /*ImageUniqueID*/, SkPDFObject*> fPDFBitmapMap; + + SkAutoTUnref<SkPixelSerializer> fPixelSerializer; }; #endif // SkPDFCanon_DEFINED diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp index 239b73823b..4feb78f334 100644 --- a/src/pdf/SkPDFDevice.cpp +++ b/src/pdf/SkPDFDevice.cpp @@ -888,7 +888,7 @@ static SkPDFDict* create_link_annotation(const SkRect& translatedRect) { border->appendInt(0); // Horizontal corner radius. border->appendInt(0); // Vertical corner radius. border->appendInt(0); // Width, 0 = no border. - annotation->insertObject("Border", border.detach()); + annotation->insertObject("Border", border.release()); SkAutoTUnref<SkPDFArray> rect(new SkPDFArray); rect->reserve(4); @@ -896,9 +896,9 @@ static SkPDFDict* create_link_annotation(const SkRect& translatedRect) { rect->appendScalar(translatedRect.fTop); rect->appendScalar(translatedRect.fRight); rect->appendScalar(translatedRect.fBottom); - annotation->insertObject("Rect", rect.detach()); + annotation->insertObject("Rect", rect.release()); - return annotation.detach(); + return annotation.release(); } static SkPDFDict* create_link_to_url(const SkData* urlData, const SkRect& r) { @@ -909,8 +909,8 @@ static SkPDFDict* create_link_to_url(const SkData* urlData, const SkRect& r) { SkAutoTUnref<SkPDFDict> action(new SkPDFDict("Action")); action->insertName("S", "URI"); action->insertString("URI", url); - annotation->insertObject("A", action.detach()); - return annotation.detach(); + annotation->insertObject("A", action.release()); + return annotation.release(); } static SkPDFDict* create_link_named_dest(const SkData* nameData, @@ -919,7 +919,7 @@ static SkPDFDict* create_link_named_dest(const SkData* nameData, SkString name(static_cast<const char *>(nameData->data()), nameData->size() - 1); annotation->insertName("Dest", name); - return annotation.detach(); + return annotation.release(); } void SkPDFDevice::drawRect(const SkDraw& d, @@ -1165,7 +1165,7 @@ void SkPDFDevice::drawImageRect(const SkDraw& draw, if (!autoImageUnref) { return; } - image = autoImageUnref; + image = autoImageUnref.get(); // Since we did an extract, we need to adjust the matrix accordingly SkScalar dx = 0, dy = 0; if (srcIR.fLeft > 0) { @@ -1533,7 +1533,7 @@ SkPDFArray* SkPDFDevice::copyMediaBox() const { mediaBox->appendInt(0); mediaBox->appendInt(fPageSize.fWidth); mediaBox->appendInt(fPageSize.fHeight); - return mediaBox.detach(); + return mediaBox.release(); } SkStreamAsset* SkPDFDevice::content() const { @@ -1719,7 +1719,7 @@ void SkPDFDevice::appendDestinations(SkPDFDict* dict, SkPDFObject* page) const { pdfDest->appendScalar(p.y()); pdfDest->appendInt(0); // Leave zoom unchanged SkString name(static_cast<const char*>(dest.nameData->data())); - dict->insertObject(name, pdfDest.detach()); + dict->insertObject(name, pdfDest.release()); } } @@ -1855,7 +1855,7 @@ ContentEntry* SkPDFDevice::setUpContentEntry(const SkClipStack* clipStack, lastContentEntry->fNext.reset(entry); setLastContentEntry(entry); } - newEntry.detach(); + newEntry.release(); return entry; } @@ -2209,7 +2209,7 @@ void SkPDFDevice::internalDrawImage(const SkMatrix& origMatrix, if (!autoImageUnref) { return; } - image = autoImageUnref; + image = autoImageUnref.get(); } // Rasterize the bitmap using perspective in a new bitmap. if (origMatrix.hasPerspective()) { @@ -2285,7 +2285,7 @@ void SkPDFDevice::internalDrawImage(const SkMatrix& origMatrix, srcRect = nullptr; autoImageUnref.reset(surface->newImageSnapshot()); - image = autoImageUnref; + image = autoImageUnref.get(); } SkMatrix scaled; @@ -2318,18 +2318,18 @@ void SkPDFDevice::internalDrawImage(const SkMatrix& origMatrix, // rasterize a layer on this backend). Fortuanely, this seems // to be how Chromium impements most color-filters. autoImageUnref.reset(color_filter(image, colorFilter)); - image = autoImageUnref; + image = autoImageUnref.get(); // TODO(halcanary): de-dupe this by caching filtered images. // (maybe in the resource cache?) } SkAutoTUnref<SkPDFObject> pdfimage(SkSafeRef(fCanon->findPDFBitmap(image))); if (!pdfimage) { pdfimage.reset(SkPDFCreateBitmapObject( - image, fCanon->fPixelSerializer)); + image, fCanon->getPixelSerializer())); if (!pdfimage) { return; } - fCanon->addPDFBitmap(image->uniqueID(), pdfimage); + fCanon->addPDFBitmap(image->uniqueID(), pdfimage.get()); } SkPDFUtils::DrawFormXObject(this->addXObjectResource(pdfimage.get()), &content.entry()->fContent); diff --git a/src/pdf/SkPDFFont.cpp b/src/pdf/SkPDFFont.cpp index 5c06bcc532..48899ebe12 100644 --- a/src/pdf/SkPDFFont.cpp +++ b/src/pdf/SkPDFFont.cpp @@ -343,7 +343,7 @@ SkPDFArray* composeAdvanceData( appendAdvance(advanceInfo->fAdvance[j], emSize, advanceArray.get()); result->appendInt(advanceInfo->fStartId); - result->appendObject(advanceArray.detach()); + result->appendObject(advanceArray.release()); break; } case SkAdvancedTypefaceMetrics::WidthRange::kRun: { @@ -1022,8 +1022,8 @@ bool SkPDFType0Font::populate(const SkPDFGlyphSet* subset) { SkAutoTUnref<SkPDFCIDFont> newCIDFont( new SkPDFCIDFont(fontInfo(), typeface(), subset)); SkAutoTUnref<SkPDFArray> descendantFonts(new SkPDFArray()); - descendantFonts->appendObjRef(newCIDFont.detach()); - this->insertObject("DescendantFonts", descendantFonts.detach()); + descendantFonts->appendObjRef(newCIDFont.release()); + this->insertObject("DescendantFonts", descendantFonts.release()); this->populateToUnicodeTable(subset); @@ -1049,7 +1049,7 @@ bool SkPDFCIDFont::addFontDescriptor(int16_t defaultWidth, SkAutoTUnref<SkPDFDict> descriptor(new SkPDFDict("FontDescriptor")); setFontDescriptor(descriptor.get()); if (!addCommonFontDescriptorEntries(defaultWidth)) { - this->insertObjRef("FontDescriptor", descriptor.detach()); + this->insertObjRef("FontDescriptor", descriptor.release()); return false; } SkASSERT(this->canEmbed()); @@ -1068,7 +1068,7 @@ bool SkPDFCIDFont::addFontDescriptor(int16_t defaultWidth, if (rawStream) { fontStream.reset(rawStream); fontStream->insertInt("Length1", fontSize); - descriptor->insertObjRef("FontFile2", fontStream.detach()); + descriptor->insertObjRef("FontFile2", fontStream.release()); break; } } @@ -1081,7 +1081,7 @@ bool SkPDFCIDFont::addFontDescriptor(int16_t defaultWidth, SkASSERT(fontSize > 0); fontStream.reset(new SkPDFSharedStream(fontData.detach())); fontStream->dict()->insertInt("Length1", fontSize); - descriptor->insertObjRef("FontFile2", fontStream.detach()); + descriptor->insertObjRef("FontFile2", fontStream.release()); break; } case SkAdvancedTypefaceMetrics::kCFF_Font: @@ -1094,13 +1094,13 @@ bool SkPDFCIDFont::addFontDescriptor(int16_t defaultWidth, } else { fontStream->dict()->insertName("Subtype", "CIDFontType0c"); } - descriptor->insertObjRef("FontFile3", fontStream.detach()); + descriptor->insertObjRef("FontFile3", fontStream.release()); break; } default: SkASSERT(false); } - this->insertObjRef("FontDescriptor", descriptor.detach()); + this->insertObjRef("FontDescriptor", descriptor.release()); return true; } @@ -1147,7 +1147,7 @@ bool SkPDFCIDFont::populate(const SkPDFGlyphSet* subset) { sysInfo->insertString("Registry", "Adobe"); sysInfo->insertString("Ordering", "Identity"); sysInfo->insertInt("Supplement", 0); - this->insertObject("CIDSystemInfo", sysInfo.detach()); + this->insertObject("CIDSystemInfo", sysInfo.release()); if (fontInfo()->fGlyphWidths.get()) { int16_t defaultWidth = 0; @@ -1156,7 +1156,7 @@ bool SkPDFCIDFont::populate(const SkPDFGlyphSet* subset) { fontInfo()->fEmSize, &appendWidth, &defaultWidth)); if (widths->size()) - this->insertObject("W", widths.detach()); + this->insertObject("W", widths.release()); if (defaultWidth != 0) { this->insertScalar( "DW", @@ -1173,7 +1173,7 @@ bool SkPDFCIDFont::populate(const SkPDFGlyphSet* subset) { fontInfo()->fEmSize, &appendVerticalAdvance, &defaultAdvance)); if (advances->size()) - this->insertObject("W2", advances.detach()); + this->insertObject("W2", advances.release()); if (defaultAdvance.fVerticalAdvance || defaultAdvance.fOriginXDisp || defaultAdvance.fOriginYDisp) { @@ -1225,9 +1225,9 @@ bool SkPDFType1Font::addFontDescriptor(int16_t defaultWidth) { fontStream->insertInt("Length1", header); fontStream->insertInt("Length2", data); fontStream->insertInt("Length3", trailer); - descriptor->insertObjRef("FontFile", fontStream.detach()); + descriptor->insertObjRef("FontFile", fontStream.release()); - this->insertObjRef("FontDescriptor", descriptor.detach()); + this->insertObjRef("FontDescriptor", descriptor.release()); return addCommonFontDescriptorEntries(defaultWidth); } @@ -1276,8 +1276,8 @@ bool SkPDFType1Font::populate(int16_t glyphID) { } SkAutoTUnref<SkPDFDict> encoding(new SkPDFDict("Encoding")); - encoding->insertObject("Differences", encDiffs.detach()); - this->insertObject("Encoding", encoding.detach()); + encoding->insertObject("Differences", encDiffs.release()); + this->insertObject("Encoding", encoding.release()); return true; } @@ -1307,7 +1307,7 @@ void SkPDFType1Font::addWidthInfoFromRange( } this->insertInt("FirstChar", firstChar); this->insertInt("LastChar", firstChar + widthArray->size() - 1); - this->insertObject("Widths", widthArray.detach()); + this->insertObject("Widths", widthArray.release()); } /////////////////////////////////////////////////////////////////////////////// @@ -1380,15 +1380,15 @@ bool SkPDFType3Font::populate(uint16_t glyphID) { new SkPDFStream(glyphStream.get())); } - encoding->insertObject("Differences", encDiffs.detach()); + encoding->insertObject("Differences", encDiffs.release()); - this->insertObject("CharProcs", charProcs.detach()); - this->insertObject("Encoding", encoding.detach()); + this->insertObject("CharProcs", charProcs.release()); + this->insertObject("Encoding", encoding.release()); this->insertObject("FontBBox", makeFontBBox(bbox, 1000)); this->insertInt("FirstChar", 1); this->insertInt("LastChar", lastGlyphID() - firstGlyphID() + 1); - this->insertObject("Widths", widthArray.detach()); + this->insertObject("Widths", widthArray.release()); this->insertName("CIDToGIDMap", "Identity"); this->populateToUnicodeTable(nullptr); diff --git a/src/pdf/SkPDFFormXObject.cpp b/src/pdf/SkPDFFormXObject.cpp index 09db1404c9..c6f1f70ba1 100644 --- a/src/pdf/SkPDFFormXObject.cpp +++ b/src/pdf/SkPDFFormXObject.cpp @@ -25,7 +25,7 @@ SkPDFFormXObject::SkPDFFormXObject(SkPDFDevice* device) { this->setData(content.get()); SkAutoTUnref<SkPDFArray> bboxArray(device->copyMediaBox()); - this->init(nullptr, resourceDict.get(), bboxArray); + this->init(nullptr, resourceDict.get(), bboxArray.get()); // We invert the initial transform and apply that to the xobject so that // it doesn't get applied twice. We can't just undo it because it's @@ -49,7 +49,7 @@ SkPDFFormXObject::SkPDFFormXObject(SkStream* content, SkRect bbox, setData(content); SkAutoTUnref<SkPDFArray> bboxArray(SkPDFUtils::RectToArray(bbox)); - init("DeviceRGB", resourceDict, bboxArray); + this->init("DeviceRGB", resourceDict, bboxArray.get()); } /** @@ -72,7 +72,7 @@ void SkPDFFormXObject::init(const char* colorSpace, group->insertName("CS", colorSpace); } group->insertBool("I", true); // Isolated. - this->insertObject("Group", group.detach()); + this->insertObject("Group", group.release()); } SkPDFFormXObject::~SkPDFFormXObject() {} diff --git a/src/pdf/SkPDFGraphicState.cpp b/src/pdf/SkPDFGraphicState.cpp index 0ad1853f3e..2bccac0cb9 100644 --- a/src/pdf/SkPDFGraphicState.cpp +++ b/src/pdf/SkPDFGraphicState.cpp @@ -139,11 +139,11 @@ static SkPDFObject* create_invert_function() { SkAutoTUnref<SkData> psInvertStream( SkData::NewWithoutCopy(psInvert, strlen(psInvert))); - SkPDFStream* invertFunction = new SkPDFStream(psInvertStream.get()); + SkAutoTUnref<SkPDFStream> invertFunction(new SkPDFStream(psInvertStream.get())); invertFunction->insertInt("FunctionType", 4); invertFunction->insertObject("Domain", SkRef(domainAndRange.get())); - invertFunction->insertObject("Range", domainAndRange.detach()); - return invertFunction; + invertFunction->insertObject("Range", domainAndRange.release()); + return invertFunction.release(); } SK_DECLARE_STATIC_ONCE_PTR(SkPDFObject, invertFunction); @@ -165,9 +165,9 @@ SkPDFDict* SkPDFGraphicState::GetSMaskGraphicState(SkPDFFormXObject* sMask, sMaskDict->insertObjRef("TR", SkRef(invertFunction.get(create_invert_function))); } - SkPDFDict* result = new SkPDFDict("ExtGState"); - result->insertObject("SMask", sMaskDict.detach()); - return result; + SkAutoTUnref<SkPDFDict> result(new SkPDFDict("ExtGState")); + result->insertObject("SMask", sMaskDict.release()); + return result.release(); } static SkPDFDict* create_no_smask_graphic_state() { diff --git a/src/pdf/SkPDFMetadata.cpp b/src/pdf/SkPDFMetadata.cpp index 51619c6748..8359786afe 100644 --- a/src/pdf/SkPDFMetadata.cpp +++ b/src/pdf/SkPDFMetadata.cpp @@ -45,7 +45,7 @@ SkPDFObject* SkPDFMetadata::createDocumentInformationDict() const { if (fModified) { dict->insertString("ModDate", pdf_date(*fModified.get())); } - return dict.detach(); + return dict.release(); } #ifdef SK_PDF_GENERATE_PDFA @@ -92,7 +92,7 @@ SkPDFObject* SkPDFMetadata::CreatePdfId(const UUID& doc, const UUID& instance) { SkString(reinterpret_cast<const char*>(&doc), sizeof(UUID))); array->appendString( SkString(reinterpret_cast<const char*>(&instance), sizeof(UUID))); - return array.detach(); + return array.release(); } // Improvement on SkStringPrintf to allow for arbitrarily long output. diff --git a/src/pdf/SkPDFResourceDict.cpp b/src/pdf/SkPDFResourceDict.cpp index 2f9abca8b6..b72e6667fd 100644 --- a/src/pdf/SkPDFResourceDict.cpp +++ b/src/pdf/SkPDFResourceDict.cpp @@ -66,7 +66,7 @@ static void add_subdict( resources->insertObjRef(SkPDFResourceDict::getResourceName(type, i), SkRef(resourceList[i])); } - dst->insertObject(get_resource_type_name(type), resources.detach()); + dst->insertObject(get_resource_type_name(type), resources.release()); } SkPDFDict* SkPDFResourceDict::Create( @@ -83,19 +83,19 @@ SkPDFDict* SkPDFResourceDict::Create( for (size_t i = 0; i < SK_ARRAY_COUNT(kProcs); i++) { procSets->appendName(kProcs[i]); } - dict->insertObject("ProcSets", procSets.detach()); + dict->insertObject("ProcSets", procSets.release()); if (gStateResources) { - add_subdict(*gStateResources, kExtGState_ResourceType, dict); + add_subdict(*gStateResources, kExtGState_ResourceType, dict.get()); } if (patternResources) { - add_subdict(*patternResources, kPattern_ResourceType, dict); + add_subdict(*patternResources, kPattern_ResourceType, dict.get()); } if (xObjectResources) { - add_subdict(*xObjectResources, kXObject_ResourceType, dict); + add_subdict(*xObjectResources, kXObject_ResourceType, dict.get()); } if (fontResources) { - add_subdict(*fontResources, kFont_ResourceType, dict); + add_subdict(*fontResources, kFont_ResourceType, dict.get()); } - return dict.detach(); + return dict.release(); } diff --git a/src/pdf/SkPDFShader.cpp b/src/pdf/SkPDFShader.cpp index fe6e47c1db..56926f3e6f 100644 --- a/src/pdf/SkPDFShader.cpp +++ b/src/pdf/SkPDFShader.cpp @@ -593,7 +593,7 @@ static SkPDFObject* create_smask_graphic_state( SkAutoTDelete<SkStream> alphaStream(create_pattern_fill_content(-1, bbox)); SkAutoTUnref<SkPDFDict> - resources(get_gradient_resource_dict(luminosityShader, nullptr)); + resources(get_gradient_resource_dict(luminosityShader.get(), nullptr)); SkAutoTUnref<SkPDFFormXObject> alphaMask( new SkPDFFormXObject(alphaStream.get(), bbox, resources.get())); @@ -806,17 +806,17 @@ SkPDFFunctionShader* SkPDFFunctionShader::Create( SkAutoTUnref<SkPDFStream> function( make_ps_function(functionCode, domain.get())); - pdfShader->insertObjRef("Function", function.detach()); + pdfShader->insertObjRef("Function", function.release()); - SkPDFFunctionShader* pdfFunctionShader = new SkPDFFunctionShader(autoState->detach()); + SkAutoTUnref<SkPDFFunctionShader> pdfFunctionShader(new SkPDFFunctionShader(autoState->detach())); pdfFunctionShader->insertInt("PatternType", 2); pdfFunctionShader->insertObject("Matrix", SkPDFUtils::MatrixToArray(finalMatrix)); - pdfFunctionShader->insertObject("Shading", pdfShader.detach()); + pdfFunctionShader->insertObject("Shading", pdfShader.release()); - canon->addFunctionShader(pdfFunctionShader); - return pdfFunctionShader; + canon->addFunctionShader(pdfFunctionShader.get()); + return pdfFunctionShader.release(); } SkPDFImageShader* SkPDFImageShader::Create( diff --git a/src/pdf/SkPDFTypes.h b/src/pdf/SkPDFTypes.h index 99320b1efc..97c4fa1dbf 100644 --- a/src/pdf/SkPDFTypes.h +++ b/src/pdf/SkPDFTypes.h @@ -318,7 +318,7 @@ class SkPDFSharedStream final : public SkPDFObject { public: // Takes ownership of asset. SkPDFSharedStream(SkStreamAsset* data) : fAsset(data), fDict(new SkPDFDict) { SkASSERT(data); } - SkPDFDict* dict() { return fDict; } + SkPDFDict* dict() { return fDict.get(); } void emitObject(SkWStream*, const SkPDFObjNumMap&, const SkPDFSubstituteMap&) const override; |