SkPDF: SkPDFObject no longer reference-counted!
* sed 's/sk_sp<SkPDF\(Object\|Array\|Dict\)>/std::unique_ptr<SkPDF\1>/g'
* Added SkPDFMakeDict()
* Let SkPDFMakeArray() take zero arguments.
Bug: skia:8630
Change-Id: I08dc11e974f1d71e09a33af6bdbcb5f01b07d186
Reviewed-on: https://skia-review.googlesource.com/c/179063
Commit-Queue: Hal Canary <halcanary@google.com>
Reviewed-by: Herb Derby <herb@google.com>
Auto-Submit: Hal Canary <halcanary@google.com>
diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp
index 352a4cc..a6780b0 100644
--- a/src/pdf/SkPDFDevice.cpp
+++ b/src/pdf/SkPDFDevice.cpp
@@ -646,8 +646,8 @@
}
}
-static sk_sp<SkPDFDict> create_link_annotation(const SkRect& translatedRect) {
- auto annotation = sk_make_sp<SkPDFDict>("Annot");
+static std::unique_ptr<SkPDFDict> create_link_annotation(const SkRect& translatedRect) {
+ auto annotation = SkPDFMakeDict("Annot");
annotation->insertName("Subtype", "Link");
annotation->insertInt("F", 4); // required by ISO 19005
// Border: 0 = Horizontal corner radius.
@@ -662,20 +662,20 @@
return annotation;
}
-static sk_sp<SkPDFDict> create_link_to_url(const SkData* urlData, const SkRect& r) {
- sk_sp<SkPDFDict> annotation = create_link_annotation(r);
+static std::unique_ptr<SkPDFDict> create_link_to_url(const SkData* urlData, const SkRect& r) {
+ std::unique_ptr<SkPDFDict> annotation = create_link_annotation(r);
SkString url(static_cast<const char *>(urlData->data()),
urlData->size() - 1);
- auto action = sk_make_sp<SkPDFDict>("Action");
+ auto action = SkPDFMakeDict("Action");
action->insertName("S", "URI");
action->insertString("URI", url);
annotation->insertObject("A", std::move(action));
return annotation;
}
-static sk_sp<SkPDFDict> create_link_named_dest(const SkData* nameData,
- const SkRect& r) {
- sk_sp<SkPDFDict> annotation = create_link_annotation(r);
+static std::unique_ptr<SkPDFDict> create_link_named_dest(const SkData* nameData,
+ const SkRect& r) {
+ std::unique_ptr<SkPDFDict> annotation = create_link_annotation(r);
SkString name(static_cast<const char *>(nameData->data()),
nameData->size() - 1);
annotation->insertName("Dest", name);
@@ -1333,7 +1333,7 @@
return dst;
}
-sk_sp<SkPDFDict> SkPDFDevice::makeResourceDict() {
+std::unique_ptr<SkPDFDict> SkPDFDevice::makeResourceDict() {
return SkPDFMakeResourceDict(sort(fGraphicStateResources),
sort(fShaderResources),
sort(fXObjectResources),
@@ -1426,13 +1426,13 @@
return true;
}
-sk_sp<SkPDFArray> SkPDFDevice::getAnnotations() {
- sk_sp<SkPDFArray> array;
+std::unique_ptr<SkPDFArray> SkPDFDevice::getAnnotations() {
+ std::unique_ptr<SkPDFArray> array;
size_t count = fLinkToURLs.size() + fLinkToDestinations.size();
if (0 == count) {
return array;
}
- array = sk_make_sp<SkPDFArray>();
+ array = SkPDFMakeArray();
array->reserve(count);
for (const RectWithData& rectWithURL : fLinkToURLs) {
SkRect r;
@@ -1451,7 +1451,7 @@
void SkPDFDevice::appendDestinations(SkPDFDict* dict, SkPDFIndirectReference page) const {
for (const NamedDestination& dest : fNamedDestinations) {
SkPoint p = fInitialTransform.mapXY(dest.point.x(), dest.point.y());
- auto pdfDest = sk_make_sp<SkPDFArray>();
+ auto pdfDest = SkPDFMakeArray();
pdfDest->reserve(5);
pdfDest->appendRef(page);
pdfDest->appendName("XYZ");
diff --git a/src/pdf/SkPDFDevice.h b/src/pdf/SkPDFDevice.h
index 46fc64b..069e1cb 100644
--- a/src/pdf/SkPDFDevice.h
+++ b/src/pdf/SkPDFDevice.h
@@ -14,6 +14,7 @@
#include "SkClipStackDevice.h"
#include "SkData.h"
#include "SkKeyedImage.h"
+#include "SkPDFTypes.h"
#include "SkPaint.h"
#include "SkRect.h"
#include "SkRefCnt.h"
@@ -99,10 +100,10 @@
// PDF specific methods.
/** Create the resource dictionary for this device. Destructive. */
- sk_sp<SkPDFDict> makeResourceDict();
+ std::unique_ptr<SkPDFDict> makeResourceDict();
/** return annotations (link to urls and destinations) or nulltpr */
- sk_sp<SkPDFArray> getAnnotations();
+ std::unique_ptr<SkPDFArray> getAnnotations();
/** Add our named destinations to the supplied dictionary.
* @param dict Dictionary to add destinations to.
diff --git a/src/pdf/SkPDFDocument.cpp b/src/pdf/SkPDFDocument.cpp
index 275ca6b..0e2c079 100644
--- a/src/pdf/SkPDFDocument.cpp
+++ b/src/pdf/SkPDFDocument.cpp
@@ -118,7 +118,7 @@
static SkPDFIndirectReference generate_page_tree(
SkPDFDocument* doc,
- std::vector<sk_sp<SkPDFDict>> pages,
+ std::vector<std::unique_ptr<SkPDFDict>> pages,
const std::vector<SkPDFIndirectReference>& pageRefs) {
// PDF wants a tree describing all the pages in the document. We arbitrary
// choose 8 (kNodeSize) as the number of allowed children. The internal
@@ -129,14 +129,14 @@
// one child.
SkASSERT(pages.size() > 0);
struct PageTreeNode {
- sk_sp<SkPDFDict> fNode;
+ std::unique_ptr<SkPDFDict> fNode;
SkPDFIndirectReference fReservedRef;
int fPageObjectDescendantCount;
- static void Layer(std::vector<PageTreeNode>* vec, SkPDFDocument* doc) {
+ static std::vector<PageTreeNode> Layer(std::vector<PageTreeNode> vec, SkPDFDocument* doc) {
std::vector<PageTreeNode> result;
static constexpr size_t kMaxNodeSize = 8;
- const size_t n = vec->size();
+ const size_t n = vec.size();
SkASSERT(n >= 1);
const size_t result_len = (n - 1) / kMaxNodeSize + 1;
SkASSERT(result_len >= 1);
@@ -145,24 +145,24 @@
size_t index = 0;
for (size_t i = 0; i < result_len; ++i) {
if (n != 1 && index + 1 == n) { // No need to create a new node.
- result.push_back(std::move((*vec)[index++]));
+ result.push_back(std::move(vec[index++]));
continue;
}
SkPDFIndirectReference parent = doc->reserveRef();
- auto kids_list = sk_make_sp<SkPDFArray>();
+ auto kids_list = SkPDFMakeArray();
int descendantCount = 0;
for (size_t j = 0; j < kMaxNodeSize && index < n; ++j) {
- PageTreeNode& node = (*vec)[index++];
+ PageTreeNode& node = vec[index++];
node.fNode->insertRef("Parent", parent);
kids_list->appendRef(doc->emit(*node.fNode, node.fReservedRef));
descendantCount += node.fPageObjectDescendantCount;
}
- auto next = sk_make_sp<SkPDFDict>("Pages");
+ auto next = SkPDFMakeDict("Pages");
next->insertInt("Count", descendantCount);
next->insertObject("Kids", std::move(kids_list));
result.push_back(PageTreeNode{std::move(next), parent, descendantCount});
}
- *vec = result;
+ return result;
}
};
std::vector<PageTreeNode> currentLayer;
@@ -171,9 +171,9 @@
for (size_t i = 0; i < pages.size(); ++i) {
currentLayer.push_back(PageTreeNode{std::move(pages[i]), pageRefs[i], 1});
}
- PageTreeNode::Layer(¤tLayer, doc);
+ currentLayer = PageTreeNode::Layer(std::move(currentLayer), doc);
while (currentLayer.size() > 1) {
- PageTreeNode::Layer(¤tLayer, doc);
+ currentLayer = PageTreeNode::Layer(std::move(currentLayer), doc);
}
SkASSERT(currentLayer.size() == 1);
const PageTreeNode& root = currentLayer[0];
@@ -272,7 +272,7 @@
reset_object(&fCanvas);
SkASSERT(fPageDevice);
- auto page = sk_make_sp<SkPDFDict>("Page");
+ auto page = SkPDFMakeDict("Page");
SkSize mediaSize = fPageDevice->imageInfo().dimensions() * fInverseRasterScale;
std::unique_ptr<SkStreamAsset> pageContent = fPageDevice->content();
@@ -282,7 +282,7 @@
fPageDevice->appendDestinations(&fDests, fPageRefs.back());
fPageDevice = nullptr;
- page->insertObject("Resources", resourceDict);
+ page->insertObject("Resources", std::move(resourceDict));
page->insertObject("MediaBox", SkPDFUtils::RectToArray(SkRect::MakeSize(mediaSize)));
if (annotations) {
@@ -303,7 +303,7 @@
reset_object(&fObjectSerializer);
fCanon = SkPDFCanon();
reset_object(&fCanvas);
- fPages = std::vector<sk_sp<SkPDFDict>>();
+ fPages = std::vector<std::unique_ptr<SkPDFDict>>();
fPageRefs = std::vector<SkPDFIndirectReference>();
reset_object(&fDests);
fPageDevice = nullptr;
@@ -429,22 +429,22 @@
}
static SkPDFIndirectReference make_srgb_color_profile(SkPDFDocument* doc) {
- sk_sp<SkPDFDict> dict = sk_make_sp<SkPDFDict>();
+ std::unique_ptr<SkPDFDict> dict = SkPDFMakeDict();
dict->insertInt("N", 3);
dict->insertObject("Range", SkPDFMakeArray(0, 1, 0, 1, 0, 1));
return SkPDFStreamOut(std::move(dict), SkMemoryStream::Make(SkSrgbIcm()), doc, true);
}
-static sk_sp<SkPDFArray> make_srgb_output_intents(SkPDFDocument* doc) {
+static std::unique_ptr<SkPDFArray> make_srgb_output_intents(SkPDFDocument* doc) {
// sRGB is specified by HTML, CSS, and SVG.
- auto outputIntent = sk_make_sp<SkPDFDict>("OutputIntent");
+ auto outputIntent = SkPDFMakeDict("OutputIntent");
outputIntent->insertName("S", "GTS_PDFA1");
outputIntent->insertString("RegistryName", "http://www.color.org");
outputIntent->insertString("OutputConditionIdentifier",
"Custom");
outputIntent->insertString("Info","sRGB IEC61966-2.1");
outputIntent->insertRef("DestOutputProfile", make_srgb_color_profile(doc));
- auto intentArray = sk_make_sp<SkPDFArray>();
+ auto intentArray = SkPDFMakeArray();
intentArray->appendObject(std::move(outputIntent));
return intentArray;
}
@@ -475,7 +475,7 @@
this->reset();
return;
}
- auto docCatalog = sk_make_sp<SkPDFDict>("Catalog");
+ auto docCatalog = SkPDFMakeDict("Catalog");
if (fMetadata.fPDFA) {
SkASSERT(fXMP != SkPDFIndirectReference());
docCatalog->insertRef("Metadata", fXMP);
@@ -494,9 +494,9 @@
// Handle tagged PDFs.
if (SkPDFIndirectReference root = fTagTree.makeStructTreeRoot(this)) {
// In the document catalog, indicate that this PDF is tagged.
- auto markInfo = sk_make_sp<SkPDFDict>("MarkInfo");
+ auto markInfo = SkPDFMakeDict("MarkInfo");
markInfo->insertBool("Marked", true);
- docCatalog->insertObject("MarkInfo", markInfo);
+ docCatalog->insertObject("MarkInfo", std::move(markInfo));
docCatalog->insertRef("StructTreeRoot", root);
}
diff --git a/src/pdf/SkPDFDocumentPriv.h b/src/pdf/SkPDFDocumentPriv.h
index b73b2cd..87755e5 100644
--- a/src/pdf/SkPDFDocumentPriv.h
+++ b/src/pdf/SkPDFDocumentPriv.h
@@ -77,7 +77,6 @@
It might go without saying that objects should not be changed
after calling serialize, since those changes will be too late.
*/
-// SkPDFIndirectReference serialize(const sk_sp<SkPDFObject>&);
SkPDFIndirectReference emit(const SkPDFObject&, SkPDFIndirectReference);
SkPDFIndirectReference emit(const SkPDFObject& o) { return this->emit(o, this->reserveRef()); }
SkPDFCanon* canon() { return &fCanon; }
@@ -99,7 +98,7 @@
SkPDFObjectSerializer fObjectSerializer;
SkPDFCanon fCanon;
SkCanvas fCanvas;
- std::vector<sk_sp<SkPDFDict>> fPages;
+ std::vector<std::unique_ptr<SkPDFDict>> fPages;
std::vector<SkPDFIndirectReference> fPageRefs;
SkPDFDict fDests;
sk_sp<SkPDFDevice> fPageDevice;
diff --git a/src/pdf/SkPDFFont.cpp b/src/pdf/SkPDFFont.cpp
index f90f773..71696d0 100644
--- a/src/pdf/SkPDFFont.cpp
+++ b/src/pdf/SkPDFFont.cpp
@@ -299,7 +299,7 @@
SkTypeface* face = font.typeface();
SkASSERT(face);
- auto descriptor = sk_make_sp<SkPDFDict>("FontDescriptor");
+ auto descriptor = SkPDFMakeDict("FontDescriptor");
uint16_t emSize = SkToU16(font.typeface()->getUnitsPerEm());
add_common_font_descriptor_entries(descriptor.get(), metrics, emSize , 0);
@@ -321,7 +321,7 @@
stream_to_data(std::move(fontAsset)), font.glyphUsage(),
metrics.fFontName.c_str(), ttcIndex);
if (subsetFontData) {
- sk_sp<SkPDFDict> tmp = sk_make_sp<SkPDFDict>();
+ std::unique_ptr<SkPDFDict> tmp = SkPDFMakeDict();
tmp->insertInt("Length1", SkToInt(subsetFontData->size()));
descriptor->insertRef(
"FontFile2",
@@ -337,7 +337,7 @@
if (!fontAsset || fontAsset->getLength() == 0) { break; }
}
#endif // SK_PDF_SUBSET_SUPPORTED
- sk_sp<SkPDFDict> tmp = sk_make_sp<SkPDFDict>();
+ std::unique_ptr<SkPDFDict> tmp = SkPDFMakeDict();
tmp->insertInt("Length1", fontSize);
descriptor->insertRef("FontFile2",
SkPDFStreamOut(std::move(tmp), std::move(fontAsset),
@@ -345,7 +345,7 @@
break;
}
case SkAdvancedTypefaceMetrics::kType1CID_Font: {
- sk_sp<SkPDFDict> tmp = sk_make_sp<SkPDFDict>();
+ std::unique_ptr<SkPDFDict> tmp = SkPDFMakeDict();
tmp->insertName("Subtype", "CIDFontType0C");
descriptor->insertRef("FontFile3",
SkPDFStreamOut(std::move(tmp), std::move(fontAsset),
@@ -357,7 +357,7 @@
}
}
- auto newCIDFont = sk_make_sp<SkPDFDict>("Font");
+ auto newCIDFont = SkPDFMakeDict("Font");
newCIDFont->insertRef("FontDescriptor", doc->emit(*descriptor));
newCIDFont->insertName("BaseFont", metrics.fPostScriptName);
@@ -372,7 +372,7 @@
default:
SkASSERT(false);
}
- auto sysInfo = sk_make_sp<SkPDFDict>();
+ auto sysInfo = SkPDFMakeDict();
sysInfo->insertString("Registry", "Adobe");
sysInfo->insertString("Ordering", "Identity");
sysInfo->insertInt("Supplement", 0);
@@ -382,7 +382,7 @@
{
int emSize;
auto glyphCache = SkPDFFont::MakeVectorCache(face, &emSize);
- sk_sp<SkPDFArray> widths = SkPDFMakeCIDGlyphWidthsArray(
+ std::unique_ptr<SkPDFArray> widths = SkPDFMakeCIDGlyphWidthsArray(
glyphCache.get(), &font.glyphUsage(), SkToS16(emSize), &defaultWidth);
if (widths && widths->size() > 0) {
newCIDFont->insertObject("W", std::move(widths));
@@ -397,7 +397,7 @@
fontDict.insertName("Subtype", "Type0");
fontDict.insertName("BaseFont", metrics.fPostScriptName);
fontDict.insertName("Encoding", "Identity-H");
- auto descendantFonts = sk_make_sp<SkPDFArray>();
+ auto descendantFonts = SkPDFMakeArray();
descendantFonts->appendRef(doc->emit(*newCIDFont));
fontDict.insertObject("DescendantFonts", std::move(descendantFonts));
@@ -435,7 +435,7 @@
sk_sp<SkData> fontData = SkPDFConvertType1FontStream(std::move(rawFontData),
&header, &data, &trailer);
if (fontData) {
- sk_sp<SkPDFDict> dict = sk_make_sp<SkPDFDict>();
+ std::unique_ptr<SkPDFDict> dict = SkPDFMakeDict();
dict->insertInt("Length1", header);
dict->insertInt("Length2", data);
dict->insertInt("Length3", trailer);
@@ -496,7 +496,7 @@
{
int emSize;
auto glyphCache = SkPDFFont::MakeVectorCache(typeface, &emSize);
- auto widths = sk_make_sp<SkPDFArray>();
+ auto widths = SkPDFMakeArray();
SkScalar advance = glyphCache->getGlyphIDAdvance(0).fAdvanceX;
widths->appendScalar(from_font_units(advance, SkToU16(emSize)));
for (unsigned gID = firstGlyphID; gID <= lastGlyphID; gID++) {
@@ -505,7 +505,7 @@
}
font.insertObject("Widths", std::move(widths));
}
- auto encDiffs = sk_make_sp<SkPDFArray>();
+ auto encDiffs = SkPDFMakeArray();
encDiffs->reserve(lastGlyphID - firstGlyphID + 3);
encDiffs->appendInt(0);
@@ -516,7 +516,7 @@
encDiffs->appendName(glyphNames[gID].isEmpty() ? unknown : glyphNames[gID]);
}
- auto encoding = sk_make_sp<SkPDFDict>("Encoding");
+ auto encoding = SkPDFMakeDict("Encoding");
encoding->insertObject("Differences", std::move(encDiffs));
font.insertObject("Encoding", std::move(encoding));
@@ -661,10 +661,10 @@
fontMatrix.setScale(SkScalarInvert(emSize), -SkScalarInvert(emSize));
font.insertObject("FontMatrix", SkPDFUtils::MatrixToArray(fontMatrix));
- auto charProcs = sk_make_sp<SkPDFDict>();
- auto encoding = sk_make_sp<SkPDFDict>("Encoding");
+ auto charProcs = SkPDFMakeDict();
+ auto encoding = SkPDFMakeDict("Encoding");
- auto encDiffs = sk_make_sp<SkPDFArray>();
+ auto encDiffs = SkPDFMakeArray();
// length(firstGlyphID .. lastGlyphID) == lastGlyphID - firstGlyphID + 1
// plus 1 for glyph 0;
SkASSERT(firstGlyphID > 0);
@@ -674,7 +674,7 @@
encDiffs->reserve(glyphCount + 1);
encDiffs->appendInt(0); // index of first glyph
- auto widthArray = sk_make_sp<SkPDFArray>();
+ auto widthArray = SkPDFMakeArray();
widthArray->reserve(glyphCount);
SkIRect bbox = SkIRect::MakeEmpty();
@@ -729,11 +729,11 @@
}
if (!imageGlyphs.empty()) {
- auto d0 = sk_make_sp<SkPDFDict>();
+ auto d0 = SkPDFMakeDict();
for (const auto& pair : imageGlyphs) {
d0->insertRef(SkStringPrintf("Xg%X", pair.first), pair.second);
}
- auto d1 = sk_make_sp<SkPDFDict>();
+ auto d1 = SkPDFMakeDict();
d1->insertObject("XObject", std::move(d0));
font.insertObject("Resources", std::move(d1));
}
diff --git a/src/pdf/SkPDFFormXObject.cpp b/src/pdf/SkPDFFormXObject.cpp
index 7dfa562..1586063 100644
--- a/src/pdf/SkPDFFormXObject.cpp
+++ b/src/pdf/SkPDFFormXObject.cpp
@@ -11,11 +11,11 @@
SkPDFIndirectReference SkPDFMakeFormXObject(SkPDFDocument* doc,
std::unique_ptr<SkStreamAsset> content,
- sk_sp<SkPDFArray> mediaBox,
- sk_sp<SkPDFDict> resourceDict,
+ std::unique_ptr<SkPDFArray> mediaBox,
+ std::unique_ptr<SkPDFDict> resourceDict,
const SkMatrix& inverseTransform,
const char* colorSpace) {
- sk_sp<SkPDFDict> dict = sk_make_sp<SkPDFDict>();
+ std::unique_ptr<SkPDFDict> dict = SkPDFMakeDict();
dict->insertName("Type", "XObject");
dict->insertName("Subtype", "Form");
if (!inverseTransform.isIdentity()) {
@@ -28,7 +28,7 @@
// isolated blending. Do this conditionally if that changes.
// TODO(halcanary): Is this comment obsolete, since we use it for
// alpha masks?
- auto group = sk_make_sp<SkPDFDict>("Group");
+ auto group = SkPDFMakeDict("Group");
group->insertName("S", "Transparency");
if (colorSpace != nullptr) {
group->insertName("CS", colorSpace);
diff --git a/src/pdf/SkPDFFormXObject.h b/src/pdf/SkPDFFormXObject.h
index 5fa52c9..1304960 100644
--- a/src/pdf/SkPDFFormXObject.h
+++ b/src/pdf/SkPDFFormXObject.h
@@ -21,8 +21,8 @@
*/
SkPDFIndirectReference SkPDFMakeFormXObject(SkPDFDocument* doc,
std::unique_ptr<SkStreamAsset> content,
- sk_sp<SkPDFArray> mediaBox,
- sk_sp<SkPDFDict> resourceDict,
+ std::unique_ptr<SkPDFArray> mediaBox,
+ std::unique_ptr<SkPDFDict> resourceDict,
const SkMatrix& inverseTransform,
const char* colorSpace);
#endif
diff --git a/src/pdf/SkPDFGradientShader.cpp b/src/pdf/SkPDFGradientShader.cpp
index 032a876..21f1300 100644
--- a/src/pdf/SkPDFGradientShader.cpp
+++ b/src/pdf/SkPDFGradientShader.cpp
@@ -195,17 +195,17 @@
}
}
-static sk_sp<SkPDFDict> createInterpolationFunction(const ColorTuple& color1,
+static std::unique_ptr<SkPDFDict> createInterpolationFunction(const ColorTuple& color1,
const ColorTuple& color2) {
- auto retval = sk_make_sp<SkPDFDict>();
+ auto retval = SkPDFMakeDict();
- auto c0 = sk_make_sp<SkPDFArray>();
+ auto c0 = SkPDFMakeArray();
c0->appendColorComponent(color1[0]);
c0->appendColorComponent(color1[1]);
c0->appendColorComponent(color1[2]);
retval->insertObject("C0", std::move(c0));
- auto c1 = sk_make_sp<SkPDFArray>();
+ auto c1 = SkPDFMakeArray();
c1->appendColorComponent(color2[0]);
c1->appendColorComponent(color2[1]);
c1->appendColorComponent(color2[2]);
@@ -219,8 +219,8 @@
return retval;
}
-static sk_sp<SkPDFDict> gradientStitchCode(const SkShader::GradientInfo& info) {
- auto retval = sk_make_sp<SkPDFDict>();
+static std::unique_ptr<SkPDFDict> gradientStitchCode(const SkShader::GradientInfo& info) {
+ auto retval = SkPDFMakeDict();
// normalize color stops
int colorCount = info.fColorCount;
@@ -266,9 +266,9 @@
if (colorCount == 2)
return createInterpolationFunction(colorData[0], colorData[1]);
- auto encode = sk_make_sp<SkPDFArray>();
- auto bounds = sk_make_sp<SkPDFArray>();
- auto functions = sk_make_sp<SkPDFArray>();
+ auto encode = SkPDFMakeArray();
+ auto bounds = SkPDFMakeArray();
+ auto functions = SkPDFMakeArray();
retval->insertObject("Domain", SkPDFMakeArray(0, 1));
retval->insertInt("FunctionType", 3);
@@ -575,10 +575,10 @@
}
static SkPDFIndirectReference make_ps_function(std::unique_ptr<SkStreamAsset> psCode,
- sk_sp<SkPDFArray> domain,
- sk_sp<SkPDFObject> range,
+ std::unique_ptr<SkPDFArray> domain,
+ std::unique_ptr<SkPDFObject> range,
SkPDFDocument* doc) {
- sk_sp<SkPDFDict> dict = sk_make_sp<SkPDFDict>();
+ std::unique_ptr<SkPDFDict> dict = SkPDFMakeDict();
dict->insertInt("FunctionType", 4);
dict->insertObject("Domain", std::move(domain));
dict->insertObject("Range", std::move(range));
@@ -599,7 +599,7 @@
!finalMatrix.hasPerspective();
int32_t shadingType = 1;
- auto pdfShader = sk_make_sp<SkPDFDict>();
+ auto pdfShader = SkPDFMakeDict();
// The two point radial gradient further references
// state.fInfo
// in translating from x, y coordinates to the t parameter. So, we have
@@ -608,13 +608,13 @@
pdfShader->insertObject("Function", gradientStitchCode(info));
shadingType = (state.fType == SkShader::kLinear_GradientType) ? 2 : 3;
- auto extend = sk_make_sp<SkPDFArray>();
+ auto extend = SkPDFMakeArray();
extend->reserve(2);
extend->appendBool(true);
extend->appendBool(true);
pdfShader->insertObject("Extend", std::move(extend));
- sk_sp<SkPDFArray> coords;
+ std::unique_ptr<SkPDFArray> coords;
if (state.fType == SkShader::kConical_GradientType) {
SkScalar r1 = info.fRadius[0];
SkScalar r2 = info.fRadius[1];
@@ -729,13 +729,11 @@
default:
SkASSERT(false);
}
- auto domain = SkPDFMakeArray(bbox.left(),
- bbox.right(),
- bbox.top(),
- bbox.bottom());
- pdfShader->insertObject("Domain", domain);
+ pdfShader->insertObject(
+ "Domain", SkPDFMakeArray(bbox.left(), bbox.right(), bbox.top(), bbox.bottom()));
- sk_sp<SkPDFArray> rangeObject = SkPDFMakeArray(0, 1, 0, 1, 0, 1);
+ auto domain = SkPDFMakeArray(bbox.left(), bbox.right(), bbox.top(), bbox.bottom());
+ std::unique_ptr<SkPDFArray> rangeObject = SkPDFMakeArray(0, 1, 0, 1, 0, 1);
pdfShader->insertRef("Function",
make_ps_function(functionCode.detachAsStream(), std::move(domain),
std::move(rangeObject), doc));
@@ -755,7 +753,7 @@
SkPDFGradientShader::Key key,
bool keyHasAlpha);
-static sk_sp<SkPDFDict> get_gradient_resource_dict(SkPDFIndirectReference functionShader,
+static std::unique_ptr<SkPDFDict> get_gradient_resource_dict(SkPDFIndirectReference functionShader,
SkPDFIndirectReference gState) {
std::vector<SkPDFIndirectReference> patternShaders;
if (functionShader != SkPDFIndirectReference()) {
@@ -828,7 +826,7 @@
SkASSERT(!gradient_has_alpha(luminosityState));
SkPDFIndirectReference luminosityShader = find_pdf_shader(doc, std::move(luminosityState), false);
- sk_sp<SkPDFDict> resources = get_gradient_resource_dict(luminosityShader,
+ std::unique_ptr<SkPDFDict> resources = get_gradient_resource_dict(luminosityShader,
SkPDFIndirectReference());
SkRect bbox = SkRect::Make(state.fBBox);
SkPDFIndirectReference alphaMask =
@@ -861,11 +859,11 @@
// pattern shader as P0, then write content stream.
SkPDFIndirectReference alphaGsRef = create_smask_graphic_state(doc, state);
- sk_sp<SkPDFDict> resourceDict = get_gradient_resource_dict(colorShader, alphaGsRef);
+ std::unique_ptr<SkPDFDict> resourceDict = get_gradient_resource_dict(colorShader, alphaGsRef);
std::unique_ptr<SkStreamAsset> colorStream =
create_pattern_fill_content(alphaGsRef.fValue, colorShader.fValue, bbox);
- sk_sp<SkPDFDict> alphaFunctionShader = sk_make_sp<SkPDFDict>();
+ std::unique_ptr<SkPDFDict> alphaFunctionShader = SkPDFMakeDict();
SkPDFUtils::PopulateTilingPatternDict(alphaFunctionShader.get(), bbox,
std::move(resourceDict), SkMatrix::I());
return SkPDFStreamOut(std::move(alphaFunctionShader), std::move(colorStream), doc);
diff --git a/src/pdf/SkPDFGraphicState.cpp b/src/pdf/SkPDFGraphicState.cpp
index 7bf4a92..dc5b2f0 100644
--- a/src/pdf/SkPDFGraphicState.cpp
+++ b/src/pdf/SkPDFGraphicState.cpp
@@ -108,7 +108,7 @@
// Do not copy the trailing '\0' into the SkData.
auto invertFunction = SkData::MakeWithoutCopy(psInvert, strlen(psInvert));
- sk_sp<SkPDFDict> dict = sk_make_sp<SkPDFDict>();
+ std::unique_ptr<SkPDFDict> dict = SkPDFMakeDict();
dict->insertInt("FunctionType", 4);
dict->insertObject("Domain", SkPDFMakeArray(0, 1));
dict->insertObject("Range", SkPDFMakeArray(0, 1));
@@ -122,7 +122,7 @@
// The practical chances of using the same mask more than once are unlikely
// enough that it's not worth canonicalizing.
SkPDFCanon* canon = doc->canon();
- auto sMaskDict = sk_make_sp<SkPDFDict>("Mask");
+ auto sMaskDict = SkPDFMakeDict("Mask");
if (sMaskMode == kAlpha_SMaskMode) {
sMaskDict->insertName("S", "Alpha");
} else if (sMaskMode == kLuminosity_SMaskMode) {
diff --git a/src/pdf/SkPDFMakeCIDGlyphWidthsArray.cpp b/src/pdf/SkPDFMakeCIDGlyphWidthsArray.cpp
index 1090e36..8834f6e 100644
--- a/src/pdf/SkPDFMakeCIDGlyphWidthsArray.cpp
+++ b/src/pdf/SkPDFMakeCIDGlyphWidthsArray.cpp
@@ -121,7 +121,7 @@
break;
}
case AdvanceMetric::kRange: {
- auto advanceArray = sk_make_sp<SkPDFArray>();
+ auto advanceArray = SkPDFMakeArray();
for (size_t j = 0; j < range.fAdvance.size(); j++)
advanceArray->appendScalar(
scale_from_font_units(range.fAdvance[j], emSize));
@@ -143,10 +143,10 @@
/** Retrieve advance data for glyphs. Used by the PDF backend. */
// TODO(halcanary): this function is complex enough to need its logic
// tested with unit tests.
-sk_sp<SkPDFArray> SkPDFMakeCIDGlyphWidthsArray(SkGlyphCache* cache,
- const SkPDFGlyphUse* subset,
- uint16_t emSize,
- int16_t* defaultAdvance) {
+std::unique_ptr<SkPDFArray> SkPDFMakeCIDGlyphWidthsArray(SkGlyphCache* cache,
+ const SkPDFGlyphUse* subset,
+ uint16_t emSize,
+ int16_t* defaultAdvance) {
// Assuming that on average, the ASCII representation of an advance plus
// a space is 8 characters and the ASCII representation of a glyph id is 3
// characters, then the following cut offs for using different range types
@@ -162,7 +162,7 @@
// d. Removing a leading 0/don't cares is a win because it is omitted
// e. Removing 2 repeating advances is a win
- auto result = sk_make_sp<SkPDFArray>();
+ auto result = SkPDFMakeArray();
int num_glyphs = SkToInt(cache->getGlyphCount());
bool prevRange = false;
diff --git a/src/pdf/SkPDFMakeCIDGlyphWidthsArray.h b/src/pdf/SkPDFMakeCIDGlyphWidthsArray.h
index bfa4a38..657fc9d 100644
--- a/src/pdf/SkPDFMakeCIDGlyphWidthsArray.h
+++ b/src/pdf/SkPDFMakeCIDGlyphWidthsArray.h
@@ -15,9 +15,9 @@
/* PDF 32000-1:2008, page 270: "The array's elements have a variable
format that can specify individual widths for consecutive CIDs or
one width for a range of CIDs". */
-sk_sp<SkPDFArray> SkPDFMakeCIDGlyphWidthsArray(SkGlyphCache* cache,
- const SkPDFGlyphUse* subset,
- uint16_t emSize,
- int16_t* defaultWidth);
+std::unique_ptr<SkPDFArray> SkPDFMakeCIDGlyphWidthsArray(SkGlyphCache* cache,
+ const SkPDFGlyphUse* subset,
+ uint16_t emSize,
+ int16_t* defaultWidth);
#endif // SkPDFMakeCIDGlyphWidthsArray_DEFINED
diff --git a/src/pdf/SkPDFMetadata.cpp b/src/pdf/SkPDFMetadata.cpp
index 34d7ab1..efae8bb 100644
--- a/src/pdf/SkPDFMetadata.cpp
+++ b/src/pdf/SkPDFMetadata.cpp
@@ -126,9 +126,9 @@
};
} // namespace
-sk_sp<SkPDFObject> SkPDFMetadata::MakeDocumentInformationDict(
+std::unique_ptr<SkPDFObject> SkPDFMetadata::MakeDocumentInformationDict(
const SkPDF::Metadata& metadata) {
- auto dict = sk_make_sp<SkPDFDict>();
+ auto dict = SkPDFMakeDict();
for (const auto keyValuePtr : gMetadataKeys) {
const SkString& value = metadata.*(keyValuePtr.valuePtr);
if (value.size() > 0) {
@@ -182,11 +182,11 @@
return uuid;
}
-sk_sp<SkPDFObject> SkPDFMetadata::MakePdfId(const SkUUID& doc,
+std::unique_ptr<SkPDFObject> SkPDFMetadata::MakePdfId(const SkUUID& doc,
const SkUUID& instance) {
// /ID [ <81b14aafa313db63dbd6f981e49f94f4>
// <81b14aafa313db63dbd6f981e49f94f4> ]
- auto array = sk_make_sp<SkPDFArray>();
+ auto array = SkPDFMakeArray();
static_assert(sizeof(SkUUID) == 16, "uuid_size");
array->appendString(
SkString(reinterpret_cast<const char*>(&doc), sizeof(SkUUID)));
@@ -400,7 +400,7 @@
keywords1.c_str(), documentID.c_str(), instanceID.c_str(),
producer.c_str(), keywords2.c_str());
- sk_sp<SkPDFDict> dict = sk_make_sp<SkPDFDict>("Metadata");
+ std::unique_ptr<SkPDFDict> dict = SkPDFMakeDict("Metadata");
dict->insertName("Subtype", "XML");
return SkPDFStreamOut(std::move(dict),
SkMemoryStream::MakeCopy(value.c_str(), value.size()),
diff --git a/src/pdf/SkPDFMetadata.h b/src/pdf/SkPDFMetadata.h
index 04f96f0..323a222 100644
--- a/src/pdf/SkPDFMetadata.h
+++ b/src/pdf/SkPDFMetadata.h
@@ -15,11 +15,11 @@
class SkPDFObject;
namespace SkPDFMetadata {
-sk_sp<SkPDFObject> MakeDocumentInformationDict(const SkPDF::Metadata&);
+std::unique_ptr<SkPDFObject> MakeDocumentInformationDict(const SkPDF::Metadata&);
SkUUID CreateUUID(const SkPDF::Metadata&);
-sk_sp<SkPDFObject> MakePdfId(const SkUUID& doc, const SkUUID& instance);
+std::unique_ptr<SkPDFObject> MakePdfId(const SkUUID& doc, const SkUUID& instance);
SkPDFIndirectReference MakeXMPObject(const SkPDF::Metadata& metadata,
const SkUUID& doc,
diff --git a/src/pdf/SkPDFResourceDict.cpp b/src/pdf/SkPDFResourceDict.cpp
index 68ebfdf..0754219 100644
--- a/src/pdf/SkPDFResourceDict.cpp
+++ b/src/pdf/SkPDFResourceDict.cpp
@@ -63,7 +63,7 @@
SkPDFResourceType type,
SkPDFDict* dst) {
if (!resourceList.empty()) {
- auto resources = sk_make_sp<SkPDFDict>();
+ auto resources = SkPDFMakeDict();
for (SkPDFIndirectReference ref : resourceList) {
resources->insertRef(resource(type, ref.fValue), ref);
}
@@ -71,8 +71,8 @@
}
}
-static sk_sp<SkPDFArray> make_proc_set() {
- auto procSets = sk_make_sp<SkPDFArray>();
+static std::unique_ptr<SkPDFArray> make_proc_set() {
+ auto procSets = SkPDFMakeArray();
static const char kProcs[][7] = { "PDF", "Text", "ImageB", "ImageC", "ImageI"};
procSets->reserve(SK_ARRAY_COUNT(kProcs));
for (const char* proc : kProcs) {
@@ -81,11 +81,12 @@
return procSets;
}
-sk_sp<SkPDFDict> SkPDFMakeResourceDict(std::vector<SkPDFIndirectReference> graphicStateResources,
- std::vector<SkPDFIndirectReference> shaderResources,
- std::vector<SkPDFIndirectReference> xObjectResources,
- std::vector<SkPDFIndirectReference> fontResources) {
- auto dict = sk_make_sp<SkPDFDict>();
+std::unique_ptr<SkPDFDict> SkPDFMakeResourceDict(
+ const std::vector<SkPDFIndirectReference>& graphicStateResources,
+ const std::vector<SkPDFIndirectReference>& shaderResources,
+ const std::vector<SkPDFIndirectReference>& xObjectResources,
+ const std::vector<SkPDFIndirectReference>& fontResources) {
+ auto dict = SkPDFMakeDict();
dict->insertObject("ProcSets", make_proc_set());
add_subdict(graphicStateResources, SkPDFResourceType::kExtGState, dict.get());
add_subdict(shaderResources, SkPDFResourceType::kPattern, dict.get());
diff --git a/src/pdf/SkPDFResourceDict.h b/src/pdf/SkPDFResourceDict.h
index a278b0c..5cce6a8 100644
--- a/src/pdf/SkPDFResourceDict.h
+++ b/src/pdf/SkPDFResourceDict.h
@@ -32,10 +32,11 @@
*
* Any arguments can be nullptr.
*/
-sk_sp<SkPDFDict> SkPDFMakeResourceDict(std::vector<SkPDFIndirectReference> graphicStateResources,
- std::vector<SkPDFIndirectReference> shaderResources,
- std::vector<SkPDFIndirectReference> xObjectResources,
- std::vector<SkPDFIndirectReference> fontResources);
+std::unique_ptr<SkPDFDict> SkPDFMakeResourceDict(
+ const std::vector<SkPDFIndirectReference>& graphicStateResources,
+ const std::vector<SkPDFIndirectReference>& shaderResources,
+ const std::vector<SkPDFIndirectReference>& xObjectResources,
+ const std::vector<SkPDFIndirectReference>& fontResources);
/**
* Writes the name for the resource that will be generated by the resource
diff --git a/src/pdf/SkPDFShader.cpp b/src/pdf/SkPDFShader.cpp
index 168805b..0f2ac72 100644
--- a/src/pdf/SkPDFShader.cpp
+++ b/src/pdf/SkPDFShader.cpp
@@ -245,8 +245,8 @@
}
auto imageShader = patternDevice->content();
- sk_sp<SkPDFDict> resourceDict = patternDevice->makeResourceDict();
- sk_sp<SkPDFDict> dict = sk_make_sp<SkPDFDict>();
+ std::unique_ptr<SkPDFDict> resourceDict = patternDevice->makeResourceDict();
+ std::unique_ptr<SkPDFDict> dict = SkPDFMakeDict();
SkPDFUtils::PopulateTilingPatternDict(dict.get(), patternBBox,
std::move(resourceDict), finalMatrix);
return SkPDFStreamOut(std::move(dict), std::move(imageShader), doc);
diff --git a/src/pdf/SkPDFTag.cpp b/src/pdf/SkPDFTag.cpp
index 82de2e8..62d2068 100644
--- a/src/pdf/SkPDFTag.cpp
+++ b/src/pdf/SkPDFTag.cpp
@@ -159,7 +159,7 @@
SkPDFTagNode* node,
SkPDFDocument* doc) {
SkPDFIndirectReference ref = doc->reserveRef();
- sk_sp<SkPDFArray> kids = sk_make_sp<SkPDFArray>();
+ std::unique_ptr<SkPDFArray> kids = SkPDFMakeArray();
SkPDFTagNode* children = node->fChildren;
size_t childCount = node->fChildCount;
for (size_t i = 0; i < childCount; ++i) {
@@ -169,7 +169,7 @@
}
}
for (const SkPDFTagNode::MarkedContentInfo& info : node->fMarkedContent) {
- sk_sp<SkPDFDict> mcr = sk_make_sp<SkPDFDict>("MCR");
+ std::unique_ptr<SkPDFDict> mcr = SkPDFMakeDict("MCR");
mcr->insertRef("Pg", doc->getPage(info.fPageIndex));
mcr->insertInt("MCID", info.fMarkId);
kids->appendObject(std::move(mcr));
@@ -201,7 +201,7 @@
// Build the parent tree, which is a mapping from the marked
// content IDs on each page to their corressponding tags.
SkPDFDict parentTree("ParentTree");
- auto parentTreeNums = sk_make_sp<SkPDFArray>();
+ auto parentTreeNums = SkPDFMakeArray();
SkASSERT(fMarksPerPage.size() <= pageCount);
for (size_t j = 0; j < fMarksPerPage.size(); ++j) {
@@ -214,7 +214,7 @@
parentTreeNums->appendInt(j);
parentTreeNums->appendRef(doc->emit(markToTagArray));
}
- parentTree.insertObject("Nums", parentTreeNums);
+ parentTree.insertObject("Nums", std::move(parentTreeNums));
structTreeRoot.insertRef("ParentTree", doc->emit(parentTree));
return doc->emit(structTreeRoot, ref);
}
diff --git a/src/pdf/SkPDFTypes.cpp b/src/pdf/SkPDFTypes.cpp
index 854f01f..e45d7ed 100644
--- a/src/pdf/SkPDFTypes.cpp
+++ b/src/pdf/SkPDFTypes.cpp
@@ -36,7 +36,7 @@
return;
case Type::kObject:
SkASSERT(fObject);
- fObject->unref();
+ delete fObject;
return;
default:
return;
@@ -246,7 +246,7 @@
SkPDFUnion SkPDFUnion::String(SkString s) { return SkPDFUnion(Type::kStringSkS, std::move(s)); }
-SkPDFUnion SkPDFUnion::Object(sk_sp<SkPDFObject> objSp) {
+SkPDFUnion SkPDFUnion::Object(std::unique_ptr<SkPDFObject> objSp) {
SkPDFUnion u(Type::kObject);
SkASSERT(objSp.get());
u.fObject = objSp.release(); // take ownership into union{}
@@ -324,7 +324,7 @@
this->append(SkPDFUnion::String(value));
}
-void SkPDFArray::appendObject(sk_sp<SkPDFObject> objSp) {
+void SkPDFArray::appendObject(std::unique_ptr<SkPDFObject>&& objSp) {
this->append(SkPDFUnion::Object(std::move(objSp)));
}
@@ -374,10 +374,10 @@
fRecords.emplace_back(SkPDFUnion::Name(std::move(key)), SkPDFUnion::Ref(ref));
}
-void SkPDFDict::insertObject(const char key[], sk_sp<SkPDFObject> objSp) {
+void SkPDFDict::insertObject(const char key[], std::unique_ptr<SkPDFObject>&& objSp) {
fRecords.emplace_back(SkPDFUnion::Name(key), SkPDFUnion::Object(std::move(objSp)));
}
-void SkPDFDict::insertObject(SkString key, sk_sp<SkPDFObject> objSp) {
+void SkPDFDict::insertObject(SkString key, std::unique_ptr<SkPDFObject>&& objSp) {
fRecords.emplace_back(SkPDFUnion::Name(std::move(key)),
SkPDFUnion::Object(std::move(objSp)));
}
@@ -474,7 +474,7 @@
doc->endObject();
}
-SkPDFIndirectReference SkPDFStreamOut(sk_sp<SkPDFDict> dict,
+SkPDFIndirectReference SkPDFStreamOut(std::unique_ptr<SkPDFDict> dict,
std::unique_ptr<SkStreamAsset> content,
SkPDFDocument* doc,
bool deflate) {
@@ -486,7 +486,7 @@
// only be executed once.
executor->add([dictPtr, contentPtr, deflate, doc, ref]() {
serialize_stream(dictPtr, contentPtr, deflate, doc, ref);
- SkSafeUnref(dictPtr);
+ delete dictPtr;
delete contentPtr;
});
return ref;
diff --git a/src/pdf/SkPDFTypes.h b/src/pdf/SkPDFTypes.h
index 3fe7a99..79c0fe5 100644
--- a/src/pdf/SkPDFTypes.h
+++ b/src/pdf/SkPDFTypes.h
@@ -57,7 +57,7 @@
which are common in the PDF format.
*/
-class SkPDFObject : public SkRefCnt {
+class SkPDFObject {
public:
SkPDFObject() = default;
@@ -113,7 +113,7 @@
void appendName(SkString);
void appendString(const char[]);
void appendString(SkString);
- void appendObject(sk_sp<SkPDFObject>);
+ void appendObject(std::unique_ptr<SkPDFObject>&&);
void appendRef(SkPDFIndirectReference);
private:
@@ -126,7 +126,7 @@
static inline void SkPDFArray_Append(SkPDFArray* a, SkScalar v) { a->appendScalar(v); }
template <typename T, typename... Args>
-inline void SkPDFArray_Append(SkPDFArray* a, T v, Args... args) {
+static inline void SkPDFArray_Append(SkPDFArray* a, T v, Args... args) {
SkPDFArray_Append(a, v);
SkPDFArray_Append(a, args...);
}
@@ -134,8 +134,8 @@
static inline void SkPDFArray_Append(SkPDFArray* a) {}
template <typename... Args>
-inline sk_sp<SkPDFArray> SkPDFMakeArray(Args... args) {
- auto ret = sk_make_sp<SkPDFArray>();
+static inline std::unique_ptr<SkPDFArray> SkPDFMakeArray(Args... args) {
+ std::unique_ptr<SkPDFArray> ret(new SkPDFArray());
ret->reserve(sizeof...(Args));
SkPDFArray_Append(ret.get(), args...);
return ret;
@@ -145,7 +145,7 @@
A dictionary object in a PDF.
*/
-class SkPDFDict : public SkPDFObject {
+class SkPDFDict final : public SkPDFObject {
public:
/** Create a PDF dictionary.
* @param type The value of the Type entry, nullptr for no type.
@@ -168,8 +168,8 @@
* @param key The text of the key for this dictionary entry.
* @param value The value for this dictionary entry.
*/
- void insertObject(const char key[], sk_sp<SkPDFObject>);
- void insertObject(SkString, sk_sp<SkPDFObject>);
+ void insertObject(const char key[], std::unique_ptr<SkPDFObject>&&);
+ void insertObject(SkString, std::unique_ptr<SkPDFObject>&&);
void insertRef(const char key[], SkPDFIndirectReference);
void insertRef(SkString, SkPDFIndirectReference);
@@ -195,13 +195,17 @@
std::vector<std::pair<SkPDFUnion, SkPDFUnion>> fRecords;
};
+static inline std::unique_ptr<SkPDFDict> SkPDFMakeDict(const char* type = nullptr) {
+ return std::unique_ptr<SkPDFDict>(new SkPDFDict(type));
+}
+
#ifdef SK_PDF_LESS_COMPRESSION
static constexpr bool kSkPDFDefaultDoDeflate = false;
#else
static constexpr bool kSkPDFDefaultDoDeflate = true;
#endif
-SkPDFIndirectReference SkPDFStreamOut(sk_sp<SkPDFDict> dict,
+SkPDFIndirectReference SkPDFStreamOut(std::unique_ptr<SkPDFDict> dict,
std::unique_ptr<SkStreamAsset> stream,
SkPDFDocument* doc,
bool deflate = kSkPDFDefaultDoDeflate);
diff --git a/src/pdf/SkPDFUnion.h b/src/pdf/SkPDFUnion.h
index d46a5a6..b6536cf 100644
--- a/src/pdf/SkPDFUnion.h
+++ b/src/pdf/SkPDFUnion.h
@@ -76,7 +76,7 @@
/** SkPDFUnion::String will encode the passed string. */
static SkPDFUnion String(SkString);
- static SkPDFUnion Object(sk_sp<SkPDFObject>);
+ static SkPDFUnion Object(std::unique_ptr<SkPDFObject>);
static SkPDFUnion Ref(SkPDFIndirectReference);
diff --git a/src/pdf/SkPDFUtils.cpp b/src/pdf/SkPDFUtils.cpp
index 252d698..b15bd9a 100644
--- a/src/pdf/SkPDFUtils.cpp
+++ b/src/pdf/SkPDFUtils.cpp
@@ -44,11 +44,11 @@
}
}
-sk_sp<SkPDFArray> SkPDFUtils::RectToArray(const SkRect& r) {
+std::unique_ptr<SkPDFArray> SkPDFUtils::RectToArray(const SkRect& r) {
return SkPDFMakeArray(r.left(), r.top(), r.right(), r.bottom());
}
-sk_sp<SkPDFArray> SkPDFUtils::MatrixToArray(const SkMatrix& matrix) {
+std::unique_ptr<SkPDFArray> SkPDFUtils::MatrixToArray(const SkMatrix& matrix) {
SkScalar a[6];
if (!matrix.asAffine(a)) {
SkMatrix::SetAffineIdentity(a);
@@ -304,7 +304,7 @@
void SkPDFUtils::PopulateTilingPatternDict(SkPDFDict* pattern,
SkRect& bbox,
- sk_sp<SkPDFDict> resources,
+ std::unique_ptr<SkPDFDict> resources,
const SkMatrix& matrix) {
const int kTiling_PatternType = 1;
const int kColoredTilingPattern_PaintType = 1;
diff --git a/src/pdf/SkPDFUtils.h b/src/pdf/SkPDFUtils.h
index f252c76..7c655ea 100644
--- a/src/pdf/SkPDFUtils.h
+++ b/src/pdf/SkPDFUtils.h
@@ -44,8 +44,8 @@
const char* BlendModeName(SkBlendMode);
-sk_sp<SkPDFArray> RectToArray(const SkRect& rect);
-sk_sp<SkPDFArray> MatrixToArray(const SkMatrix& matrix);
+std::unique_ptr<SkPDFArray> RectToArray(const SkRect& rect);
+std::unique_ptr<SkPDFArray> MatrixToArray(const SkMatrix& matrix);
void MoveTo(SkScalar x, SkScalar y, SkWStream* content);
void AppendLine(SkScalar x, SkScalar y, SkWStream* content);
@@ -121,7 +121,7 @@
bool InverseTransformBBox(const SkMatrix& matrix, SkRect* bbox);
void PopulateTilingPatternDict(SkPDFDict* pattern,
SkRect& bbox,
- sk_sp<SkPDFDict> resources,
+ std::unique_ptr<SkPDFDict> resources,
const SkMatrix& matrix);
bool ToBitmap(const SkImage* img, SkBitmap* dst);
diff --git a/tests/PDFPrimitivesTest.cpp b/tests/PDFPrimitivesTest.cpp
index 1b75704..fe22750 100644
--- a/tests/PDFPrimitivesTest.cpp
+++ b/tests/PDFPrimitivesTest.cpp
@@ -150,7 +150,7 @@
}
static void TestPDFArray(skiatest::Reporter* reporter) {
- sk_sp<SkPDFArray> array(new SkPDFArray);
+ std::unique_ptr<SkPDFArray> array(new SkPDFArray);
assert_emit_eq(reporter, *array, "[]");
array->appendInt(42);
@@ -180,7 +180,7 @@
"[42 .5 0 true /ThisName /AnotherName (This String) "
"(Another String)]");
- sk_sp<SkPDFArray> innerArray(new SkPDFArray);
+ std::unique_ptr<SkPDFArray> innerArray(new SkPDFArray);
innerArray->appendInt(-1);
array->appendObject(std::move(innerArray));
assert_emit_eq(reporter, *array,
@@ -189,7 +189,7 @@
}
static void TestPDFDict(skiatest::Reporter* reporter) {
- sk_sp<SkPDFDict> dict(new SkPDFDict);
+ std::unique_ptr<SkPDFDict> dict(new SkPDFDict);
assert_emit_eq(reporter, *dict, "<<>>");
dict->insertInt("n1", SkToSizeT(42));
@@ -204,7 +204,7 @@
dict->insertScalar("n2", SK_ScalarHalf);
SkString n3("n3");
- sk_sp<SkPDFArray> innerArray(new SkPDFArray);
+ std::unique_ptr<SkPDFArray> innerArray(new SkPDFArray);
innerArray->appendInt(-100);
dict->insertObject(n3, std::move(innerArray));
assert_emit_eq(reporter, *dict, "<</n1 42\n/n2 .5\n/n3 [-100]>>");