Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Unified Diff: tests/CodecTest.cpp

Issue 2333713002: change SkStreams to work with sk_sp<SkData> instead of SkData* (Closed)
Patch Set: fix xpsdevice Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/CodecPriv.h ('k') | tests/PDFDocumentTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/CodecTest.cpp
diff --git a/tests/CodecTest.cpp b/tests/CodecTest.cpp
index b01750d41074a42b7b4d4e9139f9bc42b741e1b5..348bc64739abb433e69a933c95d178ea17982fca 100644
--- a/tests/CodecTest.cpp
+++ b/tests/CodecTest.cpp
@@ -210,7 +210,7 @@ static void check(skiatest::Reporter* r,
if (isIncomplete) {
size_t size = stream->getLength();
sk_sp<SkData> data((SkData::MakeFromStream(stream, 2 * size / 3)));
- codec.reset(SkCodec::NewFromData(data.get()));
+ codec.reset(SkCodec::NewFromData(data));
} else {
codec.reset(SkCodec::NewFromStream(stream.release()));
}
@@ -339,7 +339,7 @@ static void check(skiatest::Reporter* r,
if (isIncomplete) {
size_t size = stream->getLength();
sk_sp<SkData> data((SkData::MakeFromStream(stream, 2 * size / 3)));
- androidCodec.reset(SkAndroidCodec::NewFromData(data.get()));
+ androidCodec.reset(SkAndroidCodec::NewFromData(data));
} else {
androidCodec.reset(SkAndroidCodec::NewFromStream(stream.release()));
}
@@ -824,8 +824,7 @@ DEF_TEST(Codec_pngChunkReader, r) {
ChunkReader chunkReader(r);
// Now read the file with SkCodec.
- sk_sp<SkData> data(wStream.copyToData());
- SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(data.get(), &chunkReader));
+ SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(wStream.detachAsData(), &chunkReader));
REPORTER_ASSERT(r, codec);
if (!codec) {
return;
@@ -865,8 +864,8 @@ DEF_TEST(Codec_pngChunkReader, r) {
// Stream that can only peek up to a limit
class LimitedPeekingMemStream : public SkStream {
public:
- LimitedPeekingMemStream(SkData* data, size_t limit)
- : fStream(data)
+ LimitedPeekingMemStream(sk_sp<SkData> data, size_t limit)
+ : fStream(std::move(data))
, fLimit(limit) {}
size_t peek(void* buf, size_t bytes) const override {
@@ -948,13 +947,13 @@ DEF_TEST(Codec_webp_peek, r) {
// The limit is less than webp needs to peek or read.
SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(
- new LimitedPeekingMemStream(data.get(), 25)));
+ new LimitedPeekingMemStream(data, 25)));
REPORTER_ASSERT(r, codec);
test_info(r, codec.get(), codec->getInfo(), SkCodec::kSuccess, nullptr);
// Similarly, a stream which does not peek should still succeed.
- codec.reset(SkCodec::NewFromStream(new LimitedPeekingMemStream(data.get(), 0)));
+ codec.reset(SkCodec::NewFromStream(new LimitedPeekingMemStream(data, 0)));
REPORTER_ASSERT(r, codec);
test_info(r, codec.get(), codec->getInfo(), SkCodec::kSuccess, nullptr);
@@ -978,7 +977,7 @@ DEF_TEST(Codec_wbmp, r) {
writeableData[1] = static_cast<uint8_t>(~0x9F);
// SkCodec should support this.
- SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(data.get()));
+ SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(data));
REPORTER_ASSERT(r, codec);
if (!codec) {
return;
@@ -1083,7 +1082,7 @@ static void check_round_trip(skiatest::Reporter* r, const SkBitmap& bm1) {
sk_sp<SkData>(SkImageEncoder::EncodeData(bm1, SkImageEncoder::kPNG_Type, 100));
// Prepare to decode. The codec should recognize that the PNG is 565.
- SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(data.get()));
+ SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(data));
REPORTER_ASSERT(r, origColorType == codec->getInfo().colorType());
REPORTER_ASSERT(r, origAlphaType == codec->getInfo().alphaType());
« no previous file with comments | « tests/CodecPriv.h ('k') | tests/PDFDocumentTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698