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