diff options
author | halcanary <halcanary@google.com> | 2016-03-08 13:03:55 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-08 13:03:55 -0800 |
commit | 51d04d3c17954f9f8629e7d8a9fe870a7b19962f (patch) | |
tree | 0238b33291f8166aacc332d0c0d5df0c0b3e5dcf /tests | |
parent | 647cc8474828202c98d540f799742e3074a2aace (diff) |
Revert of SkPDF: Add sk_sp setters; .release() becomes std::move() (patchset #2 id:20001 of https://codereview.chromium.org/1775043002/ )
Reason for revert:
https://build.chromium.org/p/client.skia/builders/Linux%20Builder/builds/6405/steps/compile/logs/stdio
Original issue's description:
> SkPDF: Add sk_sp setters; .release() becomes std::move()
>
> Note to reviewers: Start with changes to SkPDFTypes.h
>
> Many places that had a bare pointer owning a reference are refactored to
> use a sk_sp.
>
> There remain several places where a non-owning pointer `T*` should be
> replaced with `const sk_sp<T>&` to eliminate the common pattern
> `sk_sp<T>(SkRef(x))`.
>
> Committed: https://skia.googlesource.com/skia/+/9904c9212074279380e21f96575078734dbbd308
TBR=bungeman@google.com
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
Review URL: https://codereview.chromium.org/1775143002
Diffstat (limited to 'tests')
-rw-r--r-- | tests/PDFPrimitivesTest.cpp | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/tests/PDFPrimitivesTest.cpp b/tests/PDFPrimitivesTest.cpp index 57b0b60b87..f618e6f68b 100644 --- a/tests/PDFPrimitivesTest.cpp +++ b/tests/PDFPrimitivesTest.cpp @@ -83,7 +83,7 @@ static void TestPDFStream(skiatest::Reporter* reporter) { char streamBytes[] = "Test\nFoo\tBar"; SkAutoTDelete<SkMemoryStream> streamData(new SkMemoryStream( streamBytes, strlen(streamBytes), true)); - sk_sp<SkPDFStream> stream(new SkPDFStream(streamData.get())); + SkAutoTUnref<SkPDFStream> stream(new SkPDFStream(streamData.get())); ASSERT_EMIT_EQ(reporter, *stream, "<</Length 12>> stream\nTest\nFoo\tBar\nendstream"); @@ -100,7 +100,7 @@ static void TestPDFStream(skiatest::Reporter* reporter) { "with an uncompressed string."; SkAutoDataUnref streamData2(SkData::NewWithCopy(streamBytes2, strlen(streamBytes2))); - sk_sp<SkPDFStream> stream(new SkPDFStream(streamData2.get())); + SkAutoTUnref<SkPDFStream> stream(new SkPDFStream(streamData2.get())); SkDynamicMemoryWStream compressedByteStream; SkDeflateWStream deflateWStream(&compressedByteStream); @@ -123,9 +123,9 @@ static void TestPDFStream(skiatest::Reporter* reporter) { static void TestObjectNumberMap(skiatest::Reporter* reporter) { SkPDFObjNumMap objNumMap; - sk_sp<SkPDFArray> a1(new SkPDFArray); - sk_sp<SkPDFArray> a2(new SkPDFArray); - sk_sp<SkPDFArray> a3(new SkPDFArray); + SkAutoTUnref<SkPDFArray> a1(new SkPDFArray); + SkAutoTUnref<SkPDFArray> a2(new SkPDFArray); + SkAutoTUnref<SkPDFArray> a3(new SkPDFArray); objNumMap.addObject(a1.get()); objNumMap.addObject(a2.get()); @@ -142,9 +142,9 @@ static void TestObjectNumberMap(skiatest::Reporter* reporter) { } static void TestObjectRef(skiatest::Reporter* reporter) { - sk_sp<SkPDFArray> a1(new SkPDFArray); - sk_sp<SkPDFArray> a2(new SkPDFArray); - a2->appendObjRef(a1); + SkAutoTUnref<SkPDFArray> a1(new SkPDFArray); + SkAutoTUnref<SkPDFArray> a2(new SkPDFArray); + a2->appendObjRef(SkRef(a1.get())); Catalog catalog; catalog.numbers.addObject(a1.get()); @@ -157,8 +157,8 @@ static void TestObjectRef(skiatest::Reporter* reporter) { } static void TestSubstitute(skiatest::Reporter* reporter) { - sk_sp<SkPDFDict> proxy(new SkPDFDict()); - sk_sp<SkPDFDict> stub(new SkPDFDict()); + SkAutoTUnref<SkPDFDict> proxy(new SkPDFDict()); + SkAutoTUnref<SkPDFDict> stub(new SkPDFDict()); proxy->insertInt("Value", 33); stub->insertInt("Value", 44); @@ -168,8 +168,8 @@ static void TestSubstitute(skiatest::Reporter* reporter) { SkPDFObjNumMap catalog; catalog.addObject(proxy.get()); - REPORTER_ASSERT(reporter, stub.get() == substituteMap.getSubstitute(proxy.get())); - REPORTER_ASSERT(reporter, proxy.get() != substituteMap.getSubstitute(stub.get())); + REPORTER_ASSERT(reporter, stub.get() == substituteMap.getSubstitute(proxy)); + REPORTER_ASSERT(reporter, proxy.get() != substituteMap.getSubstitute(stub)); } // This test used to assert without the fix submitted for @@ -178,7 +178,7 @@ static void TestSubstitute(skiatest::Reporter* reporter) { // and there is no assert on input data in Debug mode. static void test_issue1083() { SkDynamicMemoryWStream outStream; - sk_sp<SkDocument> doc(SkDocument::CreatePDF(&outStream)); + SkAutoTUnref<SkDocument> doc(SkDocument::CreatePDF(&outStream)); SkCanvas* canvas = doc->beginPage(100.0f, 100.0f); SkPaint paint; paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); @@ -238,7 +238,7 @@ static void TestPDFUnion(skiatest::Reporter* reporter) { } static void TestPDFArray(skiatest::Reporter* reporter) { - sk_sp<SkPDFArray> array(new SkPDFArray); + SkAutoTUnref<SkPDFArray> array(new SkPDFArray); ASSERT_EMIT_EQ(reporter, *array, "[]"); array->appendInt(42); @@ -268,19 +268,19 @@ static void TestPDFArray(skiatest::Reporter* reporter) { "[42 .5 0 true /ThisName /AnotherName (This String) " "(Another String)]"); - sk_sp<SkPDFArray> innerArray(new SkPDFArray); + SkAutoTUnref<SkPDFArray> innerArray(new SkPDFArray); innerArray->appendInt(-1); - array->appendObject(std::move(innerArray)); + array->appendObject(innerArray.detach()); ASSERT_EMIT_EQ(reporter, *array, "[42 .5 0 true /ThisName /AnotherName (This String) " "(Another String) [-1]]"); - sk_sp<SkPDFArray> referencedArray(new SkPDFArray); + SkAutoTUnref<SkPDFArray> referencedArray(new SkPDFArray); Catalog catalog; catalog.numbers.addObject(referencedArray.get()); REPORTER_ASSERT(reporter, catalog.numbers.getObjectNumber( referencedArray.get()) == 1); - array->appendObjRef(std::move(referencedArray)); + array->appendObjRef(referencedArray.detach()); SkString result = emit_to_string(*array, &catalog); ASSERT_EQ(reporter, result, @@ -289,7 +289,7 @@ static void TestPDFArray(skiatest::Reporter* reporter) { } static void TestPDFDict(skiatest::Reporter* reporter) { - sk_sp<SkPDFDict> dict(new SkPDFDict); + SkAutoTUnref<SkPDFDict> dict(new SkPDFDict); ASSERT_EMIT_EQ(reporter, *dict, "<<>>"); dict->insertInt("n1", SkToSizeT(42)); @@ -304,9 +304,9 @@ static void TestPDFDict(skiatest::Reporter* reporter) { dict->insertScalar("n2", SK_ScalarHalf); SkString n3("n3"); - sk_sp<SkPDFArray> innerArray(new SkPDFArray); + SkAutoTUnref<SkPDFArray> innerArray(new SkPDFArray); innerArray->appendInt(-100); - dict->insertObject(n3, std::move(innerArray)); + dict->insertObject(n3, innerArray.detach()); ASSERT_EMIT_EQ(reporter, *dict, "<</n1 42\n/n2 .5\n/n3 [-100]>>"); dict.reset(new SkPDFDict); @@ -339,12 +339,12 @@ static void TestPDFDict(skiatest::Reporter* reporter) { dict.reset(new SkPDFDict("DType")); ASSERT_EMIT_EQ(reporter, *dict, "<</Type /DType>>"); - sk_sp<SkPDFArray> referencedArray(new SkPDFArray); + SkAutoTUnref<SkPDFArray> referencedArray(new SkPDFArray); Catalog catalog; catalog.numbers.addObject(referencedArray.get()); REPORTER_ASSERT(reporter, catalog.numbers.getObjectNumber( referencedArray.get()) == 1); - dict->insertObjRef("n1", std::move(referencedArray)); + dict->insertObjRef("n1", referencedArray.detach()); SkString result = emit_to_string(*dict, &catalog); ASSERT_EQ(reporter, result, "<</Type /DType\n/n1 1 0 R>>"); } @@ -400,10 +400,10 @@ void DummyImageFilter::toString(SkString* str) const { // CPU rasterization. DEF_TEST(PDFImageFilter, reporter) { SkDynamicMemoryWStream stream; - sk_sp<SkDocument> doc(SkDocument::CreatePDF(&stream)); + SkAutoTUnref<SkDocument> doc(SkDocument::CreatePDF(&stream)); SkCanvas* canvas = doc->beginPage(100.0f, 100.0f); - sk_sp<DummyImageFilter> filter(new DummyImageFilter()); + SkAutoTUnref<DummyImageFilter> filter(new DummyImageFilter()); // Filter just created; should be unvisited. REPORTER_ASSERT(reporter, !filter->visited()); @@ -422,15 +422,15 @@ DEF_TEST(PDFFontCanEmbedTypeface, reporter) { SkPDFCanon canon; const char resource[] = "fonts/Roboto2-Regular_NoEmbed.ttf"; - sk_sp<SkTypeface> noEmbedTypeface(GetResourceAsTypeface(resource)); + SkAutoTUnref<SkTypeface> noEmbedTypeface(GetResourceAsTypeface(resource)); if (noEmbedTypeface) { REPORTER_ASSERT(reporter, - !SkPDFFont::CanEmbedTypeface(noEmbedTypeface.get(), &canon)); + !SkPDFFont::CanEmbedTypeface(noEmbedTypeface, &canon)); } - sk_sp<SkTypeface> portableTypeface( + SkAutoTUnref<SkTypeface> portableTypeface( sk_tool_utils::create_portable_typeface(NULL, SkTypeface::kNormal)); REPORTER_ASSERT(reporter, - SkPDFFont::CanEmbedTypeface(portableTypeface.get(), &canon)); + SkPDFFont::CanEmbedTypeface(portableTypeface, &canon)); } |