SkPDF: s/SkAutoTUnref/sk_sp/g
Review URL: https://codereview.chromium.org/1771073002
This commit is contained in:
parent
28f45b949a
commit
48810a0237
@ -62,7 +62,7 @@ static void perform_font_subsetting(
|
||||
SkPDFGlyphSetMap::F2BIter iterator(usage);
|
||||
const SkPDFGlyphSetMap::FontGlyphSetPair* entry = iterator.next();
|
||||
while (entry) {
|
||||
SkAutoTUnref<SkPDFFont> subsetFont(
|
||||
sk_sp<SkPDFFont> subsetFont(
|
||||
entry->fFont->getFontSubset(entry->fGlyphSet));
|
||||
if (subsetFont) {
|
||||
substituteMap->setSubstitute(entry->fFont, subsetFont.get());
|
||||
@ -77,10 +77,10 @@ static SkPDFObject* create_pdf_page_content(const SkPDFDevice* pageDevice) {
|
||||
}
|
||||
|
||||
static SkPDFDict* create_pdf_page(const SkPDFDevice* pageDevice) {
|
||||
SkAutoTUnref<SkPDFDict> page(new SkPDFDict("Page"));
|
||||
sk_sp<SkPDFDict> page(new SkPDFDict("Page"));
|
||||
page->insertObject("Resources", pageDevice->createResourceDict());
|
||||
page->insertObject("MediaBox", pageDevice->copyMediaBox());
|
||||
SkAutoTUnref<SkPDFArray> annotations(new SkPDFArray);
|
||||
sk_sp<SkPDFArray> annotations(new SkPDFArray);
|
||||
pageDevice->appendAnnotations(annotations.get());
|
||||
if (annotations->size() > 0) {
|
||||
page->insertObject("Annots", annotations.release());
|
||||
@ -121,8 +121,8 @@ static void generate_page_tree(const SkTDArray<SkPDFDict*>& pages,
|
||||
break;
|
||||
}
|
||||
|
||||
SkAutoTUnref<SkPDFDict> newNode(new SkPDFDict("Pages"));
|
||||
SkAutoTUnref<SkPDFArray> kids(new SkPDFArray);
|
||||
sk_sp<SkPDFDict> newNode(new SkPDFDict("Pages"));
|
||||
sk_sp<SkPDFArray> kids(new SkPDFArray);
|
||||
kids->reserve(kNodeSize);
|
||||
|
||||
int count = 0;
|
||||
@ -174,23 +174,23 @@ static bool emit_pdf_document(const SkTDArray<const SkPDFDevice*>& pageDevices,
|
||||
}
|
||||
|
||||
SkTDArray<SkPDFDict*> pages;
|
||||
SkAutoTUnref<SkPDFDict> dests(new SkPDFDict);
|
||||
sk_sp<SkPDFDict> dests(new SkPDFDict);
|
||||
|
||||
for (int i = 0; i < pageDevices.count(); i++) {
|
||||
SkASSERT(pageDevices[i]);
|
||||
SkASSERT(i == 0 ||
|
||||
pageDevices[i - 1]->getCanon() == pageDevices[i]->getCanon());
|
||||
SkAutoTUnref<SkPDFDict> page(create_pdf_page(pageDevices[i]));
|
||||
sk_sp<SkPDFDict> page(create_pdf_page(pageDevices[i]));
|
||||
pageDevices[i]->appendDestinations(dests.get(), page.get());
|
||||
pages.push(page.release());
|
||||
}
|
||||
|
||||
SkAutoTUnref<SkPDFDict> docCatalog(new SkPDFDict("Catalog"));
|
||||
sk_sp<SkPDFDict> docCatalog(new SkPDFDict("Catalog"));
|
||||
|
||||
SkAutoTUnref<SkPDFObject> infoDict(
|
||||
sk_sp<SkPDFObject> infoDict(
|
||||
metadata.createDocumentInformationDict());
|
||||
|
||||
SkAutoTUnref<SkPDFObject> id, xmp;
|
||||
sk_sp<SkPDFObject> id, xmp;
|
||||
#ifdef SK_PDF_GENERATE_PDFA
|
||||
SkPDFMetadata::UUID uuid = metadata.uuid();
|
||||
// We use the same UUID for Document ID and Instance ID since this
|
||||
@ -203,12 +203,12 @@ static bool emit_pdf_document(const SkTDArray<const SkPDFDevice*>& pageDevices,
|
||||
docCatalog->insertObjRef("Metadata", xmp.release());
|
||||
|
||||
// sRGB is specified by HTML, CSS, and SVG.
|
||||
SkAutoTUnref<SkPDFDict> outputIntent(new SkPDFDict("OutputIntent"));
|
||||
sk_sp<SkPDFDict> outputIntent(new SkPDFDict("OutputIntent"));
|
||||
outputIntent->insertName("S", "GTS_PDFA1");
|
||||
outputIntent->insertString("RegistryName", "http://www.color.org");
|
||||
outputIntent->insertString("OutputConditionIdentifier",
|
||||
"sRGB IEC61966-2.1");
|
||||
SkAutoTUnref<SkPDFArray> intentArray(new SkPDFArray);
|
||||
sk_sp<SkPDFArray> intentArray(new SkPDFArray);
|
||||
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.
|
||||
@ -341,7 +341,7 @@ protected:
|
||||
|
||||
SkISize pageSize = SkISize::Make(
|
||||
SkScalarRoundToInt(width), SkScalarRoundToInt(height));
|
||||
SkAutoTUnref<SkPDFDevice> device(
|
||||
sk_sp<SkPDFDevice> device(
|
||||
SkPDFDevice::Create(pageSize, fRasterDpi, &fCanon));
|
||||
fCanvas.reset(new SkCanvas(device.get()));
|
||||
fPageDevices.push(device.release());
|
||||
@ -382,7 +382,7 @@ protected:
|
||||
private:
|
||||
SkPDFCanon fCanon;
|
||||
SkTDArray<const SkPDFDevice*> fPageDevices;
|
||||
SkAutoTUnref<SkCanvas> fCanvas;
|
||||
sk_sp<SkCanvas> fCanvas;
|
||||
SkScalar fRasterDpi;
|
||||
SkPDFMetadata fMetadata;
|
||||
};
|
||||
|
@ -391,7 +391,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
SkAutoTUnref<const SkImage> fImage;
|
||||
sk_sp<const SkImage> fImage;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
@ -418,8 +418,8 @@ public:
|
||||
: fImage(SkRef(image)), fSMask(smask) {}
|
||||
|
||||
private:
|
||||
SkAutoTUnref<const SkImage> fImage;
|
||||
const SkAutoTUnref<SkPDFObject> fSMask;
|
||||
sk_sp<const SkImage> fImage;
|
||||
const sk_sp<SkPDFObject> fSMask;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
@ -434,7 +434,7 @@ namespace {
|
||||
class PDFJpegBitmap final : public SkPDFObject {
|
||||
public:
|
||||
SkISize fSize;
|
||||
SkAutoTUnref<SkData> fData;
|
||||
sk_sp<SkData> fData;
|
||||
bool fIsYUV;
|
||||
PDFJpegBitmap(SkISize size, SkData* data, bool isYUV)
|
||||
: fSize(size), fData(SkRef(data)), fIsYUV(isYUV) {}
|
||||
@ -470,7 +470,7 @@ void PDFJpegBitmap::emitObject(SkWStream* stream,
|
||||
|
||||
SkPDFObject* SkPDFCreateBitmapObject(const SkImage* image,
|
||||
SkPixelSerializer* pixelSerializer) {
|
||||
SkAutoTUnref<SkData> data(image->refEncoded());
|
||||
sk_sp<SkData> data(image->refEncoded());
|
||||
SkJFIFInfo info;
|
||||
if (data && SkIsJFIF(data.get(), &info) &&
|
||||
(!pixelSerializer ||
|
||||
|
@ -118,6 +118,6 @@ private:
|
||||
SkTHashMap<SkBitmapKey, const SkImage*> fBitmapToImageMap;
|
||||
SkTHashMap<uint32_t /*ImageUniqueID*/, SkPDFObject*> fPDFBitmapMap;
|
||||
|
||||
SkAutoTUnref<SkPixelSerializer> fPixelSerializer;
|
||||
sk_sp<SkPixelSerializer> fPixelSerializer;
|
||||
};
|
||||
#endif // SkPDFCanon_DEFINED
|
||||
|
@ -880,17 +880,17 @@ void SkPDFDevice::drawPoints(const SkDraw& d,
|
||||
}
|
||||
|
||||
static SkPDFDict* create_link_annotation(const SkRect& translatedRect) {
|
||||
SkAutoTUnref<SkPDFDict> annotation(new SkPDFDict("Annot"));
|
||||
sk_sp<SkPDFDict> annotation(new SkPDFDict("Annot"));
|
||||
annotation->insertName("Subtype", "Link");
|
||||
|
||||
SkAutoTUnref<SkPDFArray> border(new SkPDFArray);
|
||||
sk_sp<SkPDFArray> border(new SkPDFArray);
|
||||
border->reserve(3);
|
||||
border->appendInt(0); // Horizontal corner radius.
|
||||
border->appendInt(0); // Vertical corner radius.
|
||||
border->appendInt(0); // Width, 0 = no border.
|
||||
annotation->insertObject("Border", border.release());
|
||||
|
||||
SkAutoTUnref<SkPDFArray> rect(new SkPDFArray);
|
||||
sk_sp<SkPDFArray> rect(new SkPDFArray);
|
||||
rect->reserve(4);
|
||||
rect->appendScalar(translatedRect.fLeft);
|
||||
rect->appendScalar(translatedRect.fTop);
|
||||
@ -902,11 +902,11 @@ static SkPDFDict* create_link_annotation(const SkRect& translatedRect) {
|
||||
}
|
||||
|
||||
static SkPDFDict* create_link_to_url(const SkData* urlData, const SkRect& r) {
|
||||
SkAutoTUnref<SkPDFDict> annotation(create_link_annotation(r));
|
||||
sk_sp<SkPDFDict> annotation(create_link_annotation(r));
|
||||
|
||||
SkString url(static_cast<const char *>(urlData->data()),
|
||||
urlData->size() - 1);
|
||||
SkAutoTUnref<SkPDFDict> action(new SkPDFDict("Action"));
|
||||
sk_sp<SkPDFDict> action(new SkPDFDict("Action"));
|
||||
action->insertName("S", "URI");
|
||||
action->insertString("URI", url);
|
||||
annotation->insertObject("A", action.release());
|
||||
@ -915,7 +915,7 @@ static SkPDFDict* create_link_to_url(const SkData* urlData, const SkRect& r) {
|
||||
|
||||
static SkPDFDict* create_link_named_dest(const SkData* nameData,
|
||||
const SkRect& r) {
|
||||
SkAutoTUnref<SkPDFDict> annotation(create_link_annotation(r));
|
||||
sk_sp<SkPDFDict> annotation(create_link_annotation(r));
|
||||
SkString name(static_cast<const char *>(nameData->data()),
|
||||
nameData->size() - 1);
|
||||
annotation->insertName("Dest", name);
|
||||
@ -1146,7 +1146,7 @@ void SkPDFDevice::drawImageRect(const SkDraw& draw,
|
||||
|
||||
// clip the tmpSrc to the bounds of the bitmap, and recompute dstRect if
|
||||
// needed (if the src was clipped). No check needed if src==null.
|
||||
SkAutoTUnref<const SkImage> autoImageUnref;
|
||||
sk_sp<const SkImage> autoImageUnref;
|
||||
if (src) {
|
||||
if (!imageBounds.contains(*src)) {
|
||||
if (!tmpSrc.intersect(imageBounds)) {
|
||||
@ -1448,7 +1448,7 @@ void SkPDFDevice::drawDevice(const SkDraw& d, SkBaseDevice* device,
|
||||
return;
|
||||
}
|
||||
|
||||
SkAutoTUnref<SkPDFFormXObject> xObject(new SkPDFFormXObject(pdfDevice));
|
||||
sk_sp<SkPDFFormXObject> xObject(new SkPDFFormXObject(pdfDevice));
|
||||
SkPDFUtils::DrawFormXObject(this->addXObjectResource(xObject.get()),
|
||||
&content.entry()->fContent);
|
||||
|
||||
@ -1527,7 +1527,7 @@ const SkTDArray<SkPDFFont*>& SkPDFDevice::getFontResources() const {
|
||||
SkPDFArray* SkPDFDevice::copyMediaBox() const {
|
||||
// should this be a singleton?
|
||||
|
||||
SkAutoTUnref<SkPDFArray> mediaBox(new SkPDFArray);
|
||||
sk_sp<SkPDFArray> mediaBox(new SkPDFArray);
|
||||
mediaBox->reserve(4);
|
||||
mediaBox->appendInt(0);
|
||||
mediaBox->appendInt(0);
|
||||
@ -1711,7 +1711,7 @@ void SkPDFDevice::appendAnnotations(SkPDFArray* array) const {
|
||||
|
||||
void SkPDFDevice::appendDestinations(SkPDFDict* dict, SkPDFObject* page) const {
|
||||
for (const NamedDestination& dest : fNamedDestinations) {
|
||||
SkAutoTUnref<SkPDFArray> pdfDest(new SkPDFArray);
|
||||
sk_sp<SkPDFArray> pdfDest(new SkPDFArray);
|
||||
pdfDest->reserve(5);
|
||||
pdfDest->appendObjRef(SkRef(page));
|
||||
pdfDest->appendName("XYZ");
|
||||
@ -1744,7 +1744,7 @@ void SkPDFDevice::drawFormXObjectWithMask(int xObjectIndex,
|
||||
return;
|
||||
}
|
||||
|
||||
SkAutoTUnref<SkPDFObject> sMaskGS(SkPDFGraphicState::GetSMaskGraphicState(
|
||||
sk_sp<SkPDFObject> sMaskGS(SkPDFGraphicState::GetSMaskGraphicState(
|
||||
mask, invertClip, SkPDFGraphicState::kAlpha_SMaskMode));
|
||||
|
||||
SkMatrix identity;
|
||||
@ -1908,7 +1908,7 @@ void SkPDFDevice::finishContentEntry(SkXfermode::Mode xfermode,
|
||||
identity.reset();
|
||||
SkPaint stockPaint;
|
||||
|
||||
SkAutoTUnref<SkPDFFormXObject> srcFormXObject;
|
||||
sk_sp<SkPDFFormXObject> srcFormXObject;
|
||||
if (isContentEmpty()) {
|
||||
// If nothing was drawn and there's no shape, then the draw was a
|
||||
// no-op, but dst needs to be restored for that to be true.
|
||||
@ -1942,7 +1942,7 @@ void SkPDFDevice::finishContentEntry(SkXfermode::Mode xfermode,
|
||||
&fExistingClipStack, fExistingClipRegion,
|
||||
SkXfermode::kSrcOver_Mode, true);
|
||||
} else {
|
||||
SkAutoTUnref<SkPDFFormXObject> dstMaskStorage;
|
||||
sk_sp<SkPDFFormXObject> dstMaskStorage;
|
||||
SkPDFFormXObject* dstMask = srcFormXObject.get();
|
||||
if (shape != nullptr) {
|
||||
// Draw shape into a form-xobject.
|
||||
@ -2043,7 +2043,7 @@ void SkPDFDevice::populateGraphicStateEntryFromPaint(
|
||||
entry->fShaderIndex = -1;
|
||||
|
||||
// PDF treats a shader as a color, so we only set one or the other.
|
||||
SkAutoTUnref<SkPDFObject> pdfShader;
|
||||
sk_sp<SkPDFObject> pdfShader;
|
||||
const SkShader* shader = paint.getShader();
|
||||
SkColor color = paint.getColor();
|
||||
if (shader) {
|
||||
@ -2094,7 +2094,7 @@ void SkPDFDevice::populateGraphicStateEntryFromPaint(
|
||||
}
|
||||
}
|
||||
|
||||
SkAutoTUnref<SkPDFGraphicState> newGraphicState;
|
||||
sk_sp<SkPDFGraphicState> newGraphicState;
|
||||
if (color == paint.getColor()) {
|
||||
newGraphicState.reset(
|
||||
SkPDFGraphicState::GetGraphicStateForPaint(fCanon, paint));
|
||||
@ -2158,7 +2158,7 @@ void SkPDFDevice::updateFont(const SkPaint& paint, uint16_t glyphID,
|
||||
}
|
||||
|
||||
int SkPDFDevice::getFontResourceIndex(SkTypeface* typeface, uint16_t glyphID) {
|
||||
SkAutoTUnref<SkPDFFont> newFont(
|
||||
sk_sp<SkPDFFont> newFont(
|
||||
SkPDFFont::GetFontResource(fCanon, typeface, glyphID));
|
||||
int resourceIndex = fFontResources.find(newFont.get());
|
||||
if (resourceIndex < 0) {
|
||||
@ -2175,7 +2175,7 @@ static SkSize rect_to_size(const SkRect& r) {
|
||||
|
||||
static const SkImage* color_filter(const SkImage* image,
|
||||
SkColorFilter* colorFilter) {
|
||||
SkAutoTUnref<SkSurface> surface(SkSurface::NewRaster(
|
||||
sk_sp<SkSurface> surface(SkSurface::NewRaster(
|
||||
SkImageInfo::MakeN32Premul(image->dimensions())));
|
||||
if (!surface) {
|
||||
return image;
|
||||
@ -2203,7 +2203,7 @@ void SkPDFDevice::internalDrawImage(const SkMatrix& origMatrix,
|
||||
SkMatrix matrix = origMatrix;
|
||||
SkRegion perspectiveBounds;
|
||||
const SkRegion* clipRegion = &origClipRegion;
|
||||
SkAutoTUnref<const SkImage> autoImageUnref;
|
||||
sk_sp<const SkImage> autoImageUnref;
|
||||
|
||||
if (srcRect) {
|
||||
autoImageUnref.reset(image->newSubset(*srcRect));
|
||||
@ -2254,7 +2254,7 @@ void SkPDFDevice::internalDrawImage(const SkMatrix& origMatrix,
|
||||
|
||||
SkISize wh = rect_to_size(physicalPerspectiveBounds).toCeil();
|
||||
|
||||
SkAutoTUnref<SkSurface> surface(
|
||||
sk_sp<SkSurface> surface(
|
||||
SkSurface::NewRaster(SkImageInfo::MakeN32Premul(wh)));
|
||||
if (!surface) {
|
||||
return;
|
||||
@ -2323,7 +2323,7 @@ void SkPDFDevice::internalDrawImage(const SkMatrix& origMatrix,
|
||||
// TODO(halcanary): de-dupe this by caching filtered images.
|
||||
// (maybe in the resource cache?)
|
||||
}
|
||||
SkAutoTUnref<SkPDFObject> pdfimage(SkSafeRef(fCanon->findPDFBitmap(image)));
|
||||
sk_sp<SkPDFObject> pdfimage(SkSafeRef(fCanon->findPDFBitmap(image)));
|
||||
if (!pdfimage) {
|
||||
pdfimage.reset(SkPDFCreateBitmapObject(
|
||||
image, fCanon->getPixelSerializer()));
|
||||
|
@ -338,7 +338,7 @@ SkPDFArray* composeAdvanceData(
|
||||
break;
|
||||
}
|
||||
case SkAdvancedTypefaceMetrics::WidthRange::kRange: {
|
||||
SkAutoTUnref<SkPDFArray> advanceArray(new SkPDFArray());
|
||||
sk_sp<SkPDFArray> advanceArray(new SkPDFArray());
|
||||
for (int j = 0; j < advanceInfo->fAdvance.count(); j++)
|
||||
appendAdvance(advanceInfo->fAdvance[j], emSize,
|
||||
advanceArray.get());
|
||||
@ -574,7 +574,7 @@ static SkPDFStream* generate_tounicode_cmap(
|
||||
append_cmap_sections(glyphToUnicode, subset, &cmap, multiByteGlyphs,
|
||||
firstGlyphID, lastGlyphID);
|
||||
append_cmap_footer(&cmap);
|
||||
SkAutoTUnref<SkData> cmapData(cmap.copyToData());
|
||||
sk_sp<SkData> cmapData(cmap.copyToData());
|
||||
return new SkPDFStream(cmapData.get());
|
||||
}
|
||||
|
||||
@ -806,7 +806,7 @@ SkPDFFont* SkPDFFont::GetFontResource(SkPDFCanon* canon,
|
||||
return SkRef(pdfFont);
|
||||
}
|
||||
|
||||
SkAutoTUnref<const SkAdvancedTypefaceMetrics> fontMetrics;
|
||||
sk_sp<const SkAdvancedTypefaceMetrics> fontMetrics;
|
||||
SkPDFDict* relatedFontDescriptor = nullptr;
|
||||
if (relatedFont) {
|
||||
fontMetrics.reset(SkSafeRef(relatedFont->fontInfo()));
|
||||
@ -1019,9 +1019,9 @@ bool SkPDFType0Font::populate(const SkPDFGlyphSet* subset) {
|
||||
insertName("BaseFont", fontInfo()->fFontName);
|
||||
insertName("Encoding", "Identity-H");
|
||||
|
||||
SkAutoTUnref<SkPDFCIDFont> newCIDFont(
|
||||
sk_sp<SkPDFCIDFont> newCIDFont(
|
||||
new SkPDFCIDFont(fontInfo(), typeface(), subset));
|
||||
SkAutoTUnref<SkPDFArray> descendantFonts(new SkPDFArray());
|
||||
sk_sp<SkPDFArray> descendantFonts(new SkPDFArray());
|
||||
descendantFonts->appendObjRef(newCIDFont.release());
|
||||
this->insertObject("DescendantFonts", descendantFonts.release());
|
||||
|
||||
@ -1046,7 +1046,7 @@ SkPDFCIDFont::~SkPDFCIDFont() {}
|
||||
|
||||
bool SkPDFCIDFont::addFontDescriptor(int16_t defaultWidth,
|
||||
const SkTDArray<uint32_t>* subset) {
|
||||
SkAutoTUnref<SkPDFDict> descriptor(new SkPDFDict("FontDescriptor"));
|
||||
sk_sp<SkPDFDict> descriptor(new SkPDFDict("FontDescriptor"));
|
||||
setFontDescriptor(descriptor.get());
|
||||
if (!addCommonFontDescriptorEntries(defaultWidth)) {
|
||||
this->insertObjRef("FontDescriptor", descriptor.release());
|
||||
@ -1059,7 +1059,7 @@ bool SkPDFCIDFont::addFontDescriptor(int16_t defaultWidth,
|
||||
size_t fontSize = 0;
|
||||
#if defined(SK_SFNTLY_SUBSETTER)
|
||||
if (this->canSubset()) {
|
||||
SkAutoTUnref<SkPDFStream> fontStream;
|
||||
sk_sp<SkPDFStream> fontStream;
|
||||
SkPDFStream* rawStream = nullptr;
|
||||
fontSize = get_subset_font_stream(fontInfo()->fFontName.c_str(),
|
||||
typeface(),
|
||||
@ -1073,7 +1073,7 @@ bool SkPDFCIDFont::addFontDescriptor(int16_t defaultWidth,
|
||||
}
|
||||
}
|
||||
#endif
|
||||
SkAutoTUnref<SkPDFSharedStream> fontStream;
|
||||
sk_sp<SkPDFSharedStream> fontStream;
|
||||
SkAutoTDelete<SkStreamAsset> fontData(
|
||||
this->typeface()->openStream(nullptr));
|
||||
SkASSERT(fontData);
|
||||
@ -1086,7 +1086,7 @@ bool SkPDFCIDFont::addFontDescriptor(int16_t defaultWidth,
|
||||
}
|
||||
case SkAdvancedTypefaceMetrics::kCFF_Font:
|
||||
case SkAdvancedTypefaceMetrics::kType1CID_Font: {
|
||||
SkAutoTUnref<SkPDFSharedStream> fontStream(
|
||||
sk_sp<SkPDFSharedStream> fontStream(
|
||||
new SkPDFSharedStream(this->typeface()->openStream(nullptr)));
|
||||
|
||||
if (getType() == SkAdvancedTypefaceMetrics::kCFF_Font) {
|
||||
@ -1123,7 +1123,7 @@ bool SkPDFCIDFont::populate(const SkPDFGlyphSet* subset) {
|
||||
info, SkTypeface::kHAdvance_PerGlyphInfo);
|
||||
uint32_t* glyphs = (glyphIDs.count() == 0) ? nullptr : glyphIDs.begin();
|
||||
uint32_t glyphsCount = glyphs ? glyphIDs.count() : 0;
|
||||
SkAutoTUnref<const SkAdvancedTypefaceMetrics> fontMetrics(
|
||||
sk_sp<const SkAdvancedTypefaceMetrics> fontMetrics(
|
||||
typeface()->getAdvancedTypefaceMetrics(info, glyphs, glyphsCount));
|
||||
setFontInfo(fontMetrics.get());
|
||||
addFontDescriptor(0, &glyphIDs);
|
||||
@ -1143,7 +1143,7 @@ bool SkPDFCIDFont::populate(const SkPDFGlyphSet* subset) {
|
||||
SkASSERT(false);
|
||||
}
|
||||
|
||||
SkAutoTUnref<SkPDFDict> sysInfo(new SkPDFDict);
|
||||
sk_sp<SkPDFDict> sysInfo(new SkPDFDict);
|
||||
sysInfo->insertString("Registry", "Adobe");
|
||||
sysInfo->insertString("Ordering", "Identity");
|
||||
sysInfo->insertInt("Supplement", 0);
|
||||
@ -1151,7 +1151,7 @@ bool SkPDFCIDFont::populate(const SkPDFGlyphSet* subset) {
|
||||
|
||||
if (fontInfo()->fGlyphWidths.get()) {
|
||||
int16_t defaultWidth = 0;
|
||||
SkAutoTUnref<SkPDFArray> widths(
|
||||
sk_sp<SkPDFArray> widths(
|
||||
composeAdvanceData(fontInfo()->fGlyphWidths.get(),
|
||||
fontInfo()->fEmSize, &appendWidth,
|
||||
&defaultWidth));
|
||||
@ -1168,7 +1168,7 @@ bool SkPDFCIDFont::populate(const SkPDFGlyphSet* subset) {
|
||||
defaultAdvance.fVerticalAdvance = 0;
|
||||
defaultAdvance.fOriginXDisp = 0;
|
||||
defaultAdvance.fOriginYDisp = 0;
|
||||
SkAutoTUnref<SkPDFArray> advances(
|
||||
sk_sp<SkPDFArray> advances(
|
||||
composeAdvanceData(fontInfo()->fVerticalMetrics.get(),
|
||||
fontInfo()->fEmSize, &appendVerticalAdvance,
|
||||
&defaultAdvance));
|
||||
@ -1207,7 +1207,7 @@ bool SkPDFType1Font::addFontDescriptor(int16_t defaultWidth) {
|
||||
return true;
|
||||
}
|
||||
|
||||
SkAutoTUnref<SkPDFDict> descriptor(new SkPDFDict("FontDescriptor"));
|
||||
sk_sp<SkPDFDict> descriptor(new SkPDFDict("FontDescriptor"));
|
||||
setFontDescriptor(descriptor.get());
|
||||
|
||||
int ttcIndex;
|
||||
@ -1215,13 +1215,13 @@ bool SkPDFType1Font::addFontDescriptor(int16_t defaultWidth) {
|
||||
size_t data SK_INIT_TO_AVOID_WARNING;
|
||||
size_t trailer SK_INIT_TO_AVOID_WARNING;
|
||||
SkAutoTDelete<SkStream> rawFontData(typeface()->openStream(&ttcIndex));
|
||||
SkAutoTUnref<SkData> fontData(handle_type1_stream(rawFontData.get(), &header,
|
||||
sk_sp<SkData> fontData(handle_type1_stream(rawFontData.get(), &header,
|
||||
&data, &trailer));
|
||||
if (fontData.get() == nullptr) {
|
||||
return false;
|
||||
}
|
||||
SkASSERT(this->canEmbed());
|
||||
SkAutoTUnref<SkPDFStream> fontStream(new SkPDFStream(fontData.get()));
|
||||
sk_sp<SkPDFStream> fontStream(new SkPDFStream(fontData.get()));
|
||||
fontStream->insertInt("Length1", header);
|
||||
fontStream->insertInt("Length2", data);
|
||||
fontStream->insertInt("Length3", trailer);
|
||||
@ -1268,14 +1268,14 @@ bool SkPDFType1Font::populate(int16_t glyphID) {
|
||||
addWidthInfoFromRange(defaultWidth, widthRangeEntry);
|
||||
|
||||
|
||||
SkAutoTUnref<SkPDFArray> encDiffs(new SkPDFArray);
|
||||
sk_sp<SkPDFArray> encDiffs(new SkPDFArray);
|
||||
encDiffs->reserve(lastGlyphID() - firstGlyphID() + 2);
|
||||
encDiffs->appendInt(1);
|
||||
for (int gID = firstGlyphID(); gID <= lastGlyphID(); gID++) {
|
||||
encDiffs->appendName(fontInfo()->fGlyphNames->get()[gID].c_str());
|
||||
}
|
||||
|
||||
SkAutoTUnref<SkPDFDict> encoding(new SkPDFDict("Encoding"));
|
||||
sk_sp<SkPDFDict> encoding(new SkPDFDict("Encoding"));
|
||||
encoding->insertObject("Differences", encDiffs.release());
|
||||
this->insertObject("Encoding", encoding.release());
|
||||
return true;
|
||||
@ -1284,7 +1284,7 @@ bool SkPDFType1Font::populate(int16_t glyphID) {
|
||||
void SkPDFType1Font::addWidthInfoFromRange(
|
||||
int16_t defaultWidth,
|
||||
const SkAdvancedTypefaceMetrics::WidthRange* widthRangeEntry) {
|
||||
SkAutoTUnref<SkPDFArray> widthArray(new SkPDFArray());
|
||||
sk_sp<SkPDFArray> widthArray(new SkPDFArray());
|
||||
int firstChar = 0;
|
||||
if (widthRangeEntry) {
|
||||
const uint16_t emSize = fontInfo()->fEmSize;
|
||||
@ -1343,14 +1343,14 @@ bool SkPDFType3Font::populate(uint16_t glyphID) {
|
||||
fontMatrix.setScale(SkScalarInvert(1000), -SkScalarInvert(1000));
|
||||
this->insertObject("FontMatrix", SkPDFUtils::MatrixToArray(fontMatrix));
|
||||
|
||||
SkAutoTUnref<SkPDFDict> charProcs(new SkPDFDict);
|
||||
SkAutoTUnref<SkPDFDict> encoding(new SkPDFDict("Encoding"));
|
||||
sk_sp<SkPDFDict> charProcs(new SkPDFDict);
|
||||
sk_sp<SkPDFDict> encoding(new SkPDFDict("Encoding"));
|
||||
|
||||
SkAutoTUnref<SkPDFArray> encDiffs(new SkPDFArray);
|
||||
sk_sp<SkPDFArray> encDiffs(new SkPDFArray);
|
||||
encDiffs->reserve(lastGlyphID() - firstGlyphID() + 2);
|
||||
encDiffs->appendInt(1);
|
||||
|
||||
SkAutoTUnref<SkPDFArray> widthArray(new SkPDFArray());
|
||||
sk_sp<SkPDFArray> widthArray(new SkPDFArray());
|
||||
|
||||
SkIRect bbox = SkIRect::MakeEmpty();
|
||||
for (int gID = firstGlyphID(); gID <= lastGlyphID(); gID++) {
|
||||
@ -1424,7 +1424,7 @@ bool SkPDFFont::CanEmbedTypeface(SkTypeface* typeface, SkPDFCanon* canon) {
|
||||
return *value;
|
||||
}
|
||||
bool canEmbed = true;
|
||||
SkAutoTUnref<const SkAdvancedTypefaceMetrics> fontMetrics(
|
||||
sk_sp<const SkAdvancedTypefaceMetrics> fontMetrics(
|
||||
face->getAdvancedTypefaceMetrics(
|
||||
SkTypeface::kNo_PerGlyphInfo, nullptr, 0));
|
||||
if (fontMetrics) {
|
||||
|
@ -194,14 +194,14 @@ protected:
|
||||
static bool Find(uint32_t fontID, uint16_t glyphID, int* index);
|
||||
|
||||
private:
|
||||
SkAutoTUnref<SkTypeface> fTypeface;
|
||||
sk_sp<SkTypeface> fTypeface;
|
||||
|
||||
// The glyph IDs accessible with this font. For Type1 (non CID) fonts,
|
||||
// this will be a subset if the font has more than 255 glyphs.
|
||||
uint16_t fFirstGlyphID;
|
||||
uint16_t fLastGlyphID;
|
||||
SkAutoTUnref<const SkAdvancedTypefaceMetrics> fFontInfo;
|
||||
SkAutoTUnref<SkPDFDict> fDescriptor;
|
||||
sk_sp<const SkAdvancedTypefaceMetrics> fFontInfo;
|
||||
sk_sp<SkPDFDict> fDescriptor;
|
||||
|
||||
SkAdvancedTypefaceMetrics::FontType fFontType;
|
||||
|
||||
|
@ -19,12 +19,12 @@ SkPDFFormXObject::SkPDFFormXObject(SkPDFDevice* device) {
|
||||
// We don't want to keep around device because we'd have two copies
|
||||
// of content, so reference or copy everything we need (content and
|
||||
// resources).
|
||||
SkAutoTUnref<SkPDFDict> resourceDict(device->createResourceDict());
|
||||
sk_sp<SkPDFDict> resourceDict(device->createResourceDict());
|
||||
|
||||
SkAutoTDelete<SkStreamAsset> content(device->content());
|
||||
this->setData(content.get());
|
||||
|
||||
SkAutoTUnref<SkPDFArray> bboxArray(device->copyMediaBox());
|
||||
sk_sp<SkPDFArray> bboxArray(device->copyMediaBox());
|
||||
this->init(nullptr, resourceDict.get(), bboxArray.get());
|
||||
|
||||
// We invert the initial transform and apply that to the xobject so that
|
||||
@ -48,7 +48,7 @@ SkPDFFormXObject::SkPDFFormXObject(SkStream* content, SkRect bbox,
|
||||
SkPDFDict* resourceDict) {
|
||||
setData(content);
|
||||
|
||||
SkAutoTUnref<SkPDFArray> bboxArray(SkPDFUtils::RectToArray(bbox));
|
||||
sk_sp<SkPDFArray> bboxArray(SkPDFUtils::RectToArray(bbox));
|
||||
this->init("DeviceRGB", resourceDict, bboxArray.get());
|
||||
}
|
||||
|
||||
@ -65,7 +65,7 @@ void SkPDFFormXObject::init(const char* colorSpace,
|
||||
|
||||
// Right now SkPDFFormXObject is only used for saveLayer, which implies
|
||||
// isolated blending. Do this conditionally if that changes.
|
||||
SkAutoTUnref<SkPDFDict> group(new SkPDFDict("Group"));
|
||||
sk_sp<SkPDFDict> group(new SkPDFDict("Group"));
|
||||
group->insertName("S", "Transparency");
|
||||
|
||||
if (colorSpace != nullptr) {
|
||||
|
@ -129,17 +129,17 @@ SkPDFGraphicState* SkPDFGraphicState::GetGraphicStateForPaint(
|
||||
static SkPDFObject* create_invert_function() {
|
||||
// Acrobat crashes if we use a type 0 function, kpdf crashes if we use
|
||||
// a type 2 function, so we use a type 4 function.
|
||||
SkAutoTUnref<SkPDFArray> domainAndRange(new SkPDFArray);
|
||||
sk_sp<SkPDFArray> domainAndRange(new SkPDFArray);
|
||||
domainAndRange->reserve(2);
|
||||
domainAndRange->appendInt(0);
|
||||
domainAndRange->appendInt(1);
|
||||
|
||||
static const char psInvert[] = "{1 exch sub}";
|
||||
// Do not copy the trailing '\0' into the SkData.
|
||||
SkAutoTUnref<SkData> psInvertStream(
|
||||
sk_sp<SkData> psInvertStream(
|
||||
SkData::NewWithoutCopy(psInvert, strlen(psInvert)));
|
||||
|
||||
SkAutoTUnref<SkPDFStream> invertFunction(new SkPDFStream(psInvertStream.get()));
|
||||
sk_sp<SkPDFStream> invertFunction(new SkPDFStream(psInvertStream.get()));
|
||||
invertFunction->insertInt("FunctionType", 4);
|
||||
invertFunction->insertObject("Domain", SkRef(domainAndRange.get()));
|
||||
invertFunction->insertObject("Range", domainAndRange.release());
|
||||
@ -154,7 +154,7 @@ SkPDFDict* SkPDFGraphicState::GetSMaskGraphicState(SkPDFFormXObject* sMask,
|
||||
SkPDFSMaskMode sMaskMode) {
|
||||
// The practical chances of using the same mask more than once are unlikely
|
||||
// enough that it's not worth canonicalizing.
|
||||
SkAutoTUnref<SkPDFDict> sMaskDict(new SkPDFDict("Mask"));
|
||||
sk_sp<SkPDFDict> sMaskDict(new SkPDFDict("Mask"));
|
||||
if (sMaskMode == kAlpha_SMaskMode) {
|
||||
sMaskDict->insertName("S", "Alpha");
|
||||
} else if (sMaskMode == kLuminosity_SMaskMode) {
|
||||
@ -165,7 +165,7 @@ SkPDFDict* SkPDFGraphicState::GetSMaskGraphicState(SkPDFFormXObject* sMask,
|
||||
sMaskDict->insertObjRef("TR", SkRef(invertFunction.get(create_invert_function)));
|
||||
}
|
||||
|
||||
SkAutoTUnref<SkPDFDict> result(new SkPDFDict("ExtGState"));
|
||||
sk_sp<SkPDFDict> result(new SkPDFDict("ExtGState"));
|
||||
result->insertObject("SMask", sMaskDict.release());
|
||||
return result.release();
|
||||
}
|
||||
@ -186,7 +186,7 @@ void SkPDFGraphicState::emitObject(
|
||||
SkWStream* stream,
|
||||
const SkPDFObjNumMap& objNumMap,
|
||||
const SkPDFSubstituteMap& substitutes) const {
|
||||
SkAutoTUnref<SkPDFDict> dict(new SkPDFDict("ExtGState"));
|
||||
sk_sp<SkPDFDict> dict(new SkPDFDict("ExtGState"));
|
||||
dict->insertName("Type", "ExtGState");
|
||||
|
||||
SkScalar alpha = SkIntToScalar(fAlpha) / 0xFF;
|
||||
|
@ -28,7 +28,7 @@ static SkString pdf_date(const SkTime::DateTime& dt) {
|
||||
}
|
||||
|
||||
SkPDFObject* SkPDFMetadata::createDocumentInformationDict() const {
|
||||
SkAutoTUnref<SkPDFDict> dict(new SkPDFDict);
|
||||
sk_sp<SkPDFDict> dict(new SkPDFDict);
|
||||
static const char* keys[] = {
|
||||
"Title", "Author", "Subject", "Keywords", "Creator"};
|
||||
for (const char* key : keys) {
|
||||
@ -86,7 +86,7 @@ SkPDFMetadata::UUID SkPDFMetadata::uuid() const {
|
||||
SkPDFObject* SkPDFMetadata::CreatePdfId(const UUID& doc, const UUID& instance) {
|
||||
// /ID [ <81b14aafa313db63dbd6f981e49f94f4>
|
||||
// <81b14aafa313db63dbd6f981e49f94f4> ]
|
||||
SkAutoTUnref<SkPDFArray> array(new SkPDFArray);
|
||||
sk_sp<SkPDFArray> array(new SkPDFArray);
|
||||
static_assert(sizeof(UUID) == 16, "uuid_size");
|
||||
array->appendString(
|
||||
SkString(reinterpret_cast<const char*>(&doc), sizeof(UUID)));
|
||||
|
@ -61,7 +61,7 @@ static void add_subdict(
|
||||
if (0 == resourceList.count()) {
|
||||
return;
|
||||
}
|
||||
SkAutoTUnref<SkPDFDict> resources(new SkPDFDict);
|
||||
sk_sp<SkPDFDict> resources(new SkPDFDict);
|
||||
for (int i = 0; i < resourceList.count(); i++) {
|
||||
resources->insertObjRef(SkPDFResourceDict::getResourceName(type, i),
|
||||
SkRef(resourceList[i]));
|
||||
@ -74,10 +74,10 @@ SkPDFDict* SkPDFResourceDict::Create(
|
||||
const SkTDArray<SkPDFObject*>* patternResources,
|
||||
const SkTDArray<SkPDFObject*>* xObjectResources,
|
||||
const SkTDArray<SkPDFObject*>* fontResources) {
|
||||
SkAutoTUnref<SkPDFDict> dict(new SkPDFDict);
|
||||
sk_sp<SkPDFDict> dict(new SkPDFDict);
|
||||
static const char kProcs[][7] = {
|
||||
"PDF", "Text", "ImageB", "ImageC", "ImageI"};
|
||||
SkAutoTUnref<SkPDFArray> procSets(new SkPDFArray);
|
||||
sk_sp<SkPDFArray> procSets(new SkPDFArray);
|
||||
|
||||
procSets->reserve(SK_ARRAY_COUNT(kProcs));
|
||||
for (size_t i = 0; i < SK_ARRAY_COUNT(kProcs); i++) {
|
||||
|
@ -587,15 +587,15 @@ static SkPDFObject* create_smask_graphic_state(
|
||||
|
||||
SkAutoTDelete<SkPDFShader::State> alphaToLuminosityState(
|
||||
state.CreateAlphaToLuminosityState());
|
||||
SkAutoTUnref<SkPDFObject> luminosityShader(
|
||||
sk_sp<SkPDFObject> luminosityShader(
|
||||
get_pdf_shader_by_state(canon, dpi, &alphaToLuminosityState));
|
||||
|
||||
SkAutoTDelete<SkStream> alphaStream(create_pattern_fill_content(-1, bbox));
|
||||
|
||||
SkAutoTUnref<SkPDFDict>
|
||||
sk_sp<SkPDFDict>
|
||||
resources(get_gradient_resource_dict(luminosityShader.get(), nullptr));
|
||||
|
||||
SkAutoTUnref<SkPDFFormXObject> alphaMask(
|
||||
sk_sp<SkPDFFormXObject> alphaMask(
|
||||
new SkPDFFormXObject(alphaStream.get(), bbox, resources.get()));
|
||||
|
||||
return SkPDFGraphicState::GetSMaskGraphicState(
|
||||
@ -613,7 +613,7 @@ SkPDFAlphaFunctionShader* SkPDFAlphaFunctionShader::Create(
|
||||
|
||||
SkAutoTDelete<SkPDFShader::State> opaqueState(state.CreateOpaqueState());
|
||||
|
||||
SkAutoTUnref<SkPDFObject> colorShader(
|
||||
sk_sp<SkPDFObject> colorShader(
|
||||
get_pdf_shader_by_state(canon, dpi, &opaqueState));
|
||||
if (!colorShader) {
|
||||
return nullptr;
|
||||
@ -621,13 +621,13 @@ SkPDFAlphaFunctionShader* SkPDFAlphaFunctionShader::Create(
|
||||
|
||||
// Create resource dict with alpha graphics state as G0 and
|
||||
// pattern shader as P0, then write content stream.
|
||||
SkAutoTUnref<SkPDFObject> alphaGs(
|
||||
sk_sp<SkPDFObject> alphaGs(
|
||||
create_smask_graphic_state(canon, dpi, state));
|
||||
|
||||
SkPDFAlphaFunctionShader* alphaFunctionShader =
|
||||
new SkPDFAlphaFunctionShader(autoState->detach());
|
||||
|
||||
SkAutoTUnref<SkPDFDict> resourceDict(
|
||||
sk_sp<SkPDFDict> resourceDict(
|
||||
get_gradient_resource_dict(colorShader.get(), alphaGs.get()));
|
||||
|
||||
SkAutoTDelete<SkStream> colorStream(
|
||||
@ -771,7 +771,7 @@ SkPDFFunctionShader* SkPDFFunctionShader::Create(
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
SkAutoTUnref<SkPDFArray> domain(new SkPDFArray);
|
||||
sk_sp<SkPDFArray> domain(new SkPDFArray);
|
||||
domain->reserve(4);
|
||||
domain->appendScalar(bbox.fLeft);
|
||||
domain->appendScalar(bbox.fRight);
|
||||
@ -799,16 +799,16 @@ SkPDFFunctionShader* SkPDFFunctionShader::Create(
|
||||
functionCode = codeFunction(*info, perspectiveInverseOnly);
|
||||
}
|
||||
|
||||
SkAutoTUnref<SkPDFDict> pdfShader(new SkPDFDict);
|
||||
sk_sp<SkPDFDict> pdfShader(new SkPDFDict);
|
||||
pdfShader->insertInt("ShadingType", 1);
|
||||
pdfShader->insertName("ColorSpace", "DeviceRGB");
|
||||
pdfShader->insertObject("Domain", SkRef(domain.get()));
|
||||
|
||||
SkAutoTUnref<SkPDFStream> function(
|
||||
sk_sp<SkPDFStream> function(
|
||||
make_ps_function(functionCode, domain.get()));
|
||||
pdfShader->insertObjRef("Function", function.release());
|
||||
|
||||
SkAutoTUnref<SkPDFFunctionShader> pdfFunctionShader(new SkPDFFunctionShader(autoState->detach()));
|
||||
sk_sp<SkPDFFunctionShader> pdfFunctionShader(new SkPDFFunctionShader(autoState->detach()));
|
||||
|
||||
pdfFunctionShader->insertInt("PatternType", 2);
|
||||
pdfFunctionShader->insertObject("Matrix",
|
||||
@ -859,7 +859,7 @@ SkPDFImageShader* SkPDFImageShader::Create(
|
||||
|
||||
SkISize size = SkISize::Make(SkScalarRoundToInt(deviceBounds.width()),
|
||||
SkScalarRoundToInt(deviceBounds.height()));
|
||||
SkAutoTUnref<SkPDFDevice> patternDevice(
|
||||
sk_sp<SkPDFDevice> patternDevice(
|
||||
SkPDFDevice::CreateUnflipped(size, dpi, canon));
|
||||
SkCanvas canvas(patternDevice.get());
|
||||
|
||||
@ -1024,7 +1024,7 @@ SkPDFImageShader* SkPDFImageShader::Create(
|
||||
SkPDFImageShader* imageShader = new SkPDFImageShader(autoState->detach());
|
||||
imageShader->setData(content.get());
|
||||
|
||||
SkAutoTUnref<SkPDFDict> resourceDict(
|
||||
sk_sp<SkPDFDict> resourceDict(
|
||||
patternDevice->createResourceDict());
|
||||
populate_tiling_pattern_dict(imageShader, patternBBox,
|
||||
resourceDict.get(), finalMatrix);
|
||||
|
@ -109,13 +109,13 @@ public:
|
||||
static SkPDFUnion String(const SkString&);
|
||||
|
||||
/** This function DOES take ownership of the object. E.g.
|
||||
SkAutoTUnref<SkPDFDict> dict(new SkPDFDict);
|
||||
sk_sp<SkPDFDict> dict(new SkPDFDict);
|
||||
dict->insert(.....);
|
||||
SkPDFUnion u = SkPDFUnion::Object(dict.detach()) */
|
||||
static SkPDFUnion Object(SkPDFObject*);
|
||||
|
||||
/** This function DOES take ownership of the object. E.g.
|
||||
SkAutoTUnref<SkPDFBitmap> image(
|
||||
sk_sp<SkPDFBitmap> image(
|
||||
SkPDFBitmap::Create(fCanon, bitmap));
|
||||
SkPDFUnion u = SkPDFUnion::ObjRef(image.detach()) */
|
||||
static SkPDFUnion ObjRef(SkPDFObject*);
|
||||
@ -327,7 +327,7 @@ public:
|
||||
|
||||
private:
|
||||
SkAutoTDelete<SkStreamAsset> fAsset;
|
||||
SkAutoTUnref<SkPDFDict> fDict;
|
||||
sk_sp<SkPDFDict> fDict;
|
||||
typedef SkPDFObject INHERITED;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user