diff options
author | bungeman <bungeman@google.com> | 2016-09-15 10:57:38 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-09-15 10:57:39 -0700 |
commit | 606add3dfb2f6d1dc3ee4921876e7c9fa01643f9 (patch) | |
tree | f358bd464a80b6739601ef2c653ce78c532f3a7c /tests | |
parent | a846c7223c531a634a549e7e6ed7d28eeec95bef (diff) |
Revert of SkFontData to use smart pointers. (patchset #3 id:40001 of https://codereview.chromium.org/2339273002/ )
Reason for revert:
Killing Mac
Original issue's description:
> SkFontData to use smart pointers.
>
> The SkFontData type is not exposed externally, so any method which uses
> it can be updated to use smart pointers without affecting external
> users. Updating this first will make updating the public API much
> easier.
>
> This also updates SkStreamAsset* SkStream::NewFromFile(const char*) to
> std::unique_ptr<SkStreamAsset> SkStream::MakeFromFile(const char*). It
> appears that no one outside Skia is currently using SkStream::NewfromFile
> so this is a good time to update it as well.
>
> GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2339273002
>
> Committed: https://skia.googlesource.com/skia/+/d8c2476a8b1e1e1a1771b17e8dd4db8645914f8c
TBR=mtklein@chromium.org,halcanary@google.com,mtklein@google.com,reed@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/2343933002
Diffstat (limited to 'tests')
-rw-r--r-- | tests/BadIcoTest.cpp | 6 | ||||
-rw-r--r-- | tests/CodecTest.cpp | 45 | ||||
-rw-r--r-- | tests/ColorSpaceTest.cpp | 7 | ||||
-rw-r--r-- | tests/ExifTest.cpp | 9 | ||||
-rw-r--r-- | tests/SerializationTest.cpp | 5 | ||||
-rw-r--r-- | tests/YUVTest.cpp | 8 |
6 files changed, 54 insertions, 26 deletions
diff --git a/tests/BadIcoTest.cpp b/tests/BadIcoTest.cpp index 4affa85b7b..5c01490f9b 100644 --- a/tests/BadIcoTest.cpp +++ b/tests/BadIcoTest.cpp @@ -26,9 +26,11 @@ DEF_TEST(BadImage, reporter) { const char* badImagesFolder = "invalid_images"; + SkString resourcePath = GetResourcePath(badImagesFolder); + for (size_t i = 0; i < SK_ARRAY_COUNT(badImages); ++i) { - SkString resourcePath = SkOSPath::Join(badImagesFolder, badImages[i]); - SkAutoTDelete<SkStream> stream(GetResourceAsStream(resourcePath.c_str())); + SkString fullPath = SkOSPath::Join(resourcePath.c_str(), badImages[i]); + SkAutoTDelete<SkStream> stream(SkStream::NewFromFile(fullPath.c_str())); SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.release())); // These images are corrupt. It's not important whether we succeed/fail in codec diff --git a/tests/CodecTest.cpp b/tests/CodecTest.cpp index 341433b379..044c2fd6b4 100644 --- a/tests/CodecTest.cpp +++ b/tests/CodecTest.cpp @@ -22,6 +22,11 @@ #include "png.h" +static SkStreamAsset* resource(const char path[]) { + SkString fullPath = GetResourcePath(path); + return SkStream::NewFromFile(fullPath.c_str()); +} + static void md5(const SkBitmap& bm, SkMD5::Digest* digest) { SkAutoLockPixels autoLockPixels(bm); SkASSERT(bm.getPixels()); @@ -194,8 +199,9 @@ static void check(skiatest::Reporter* r, bool supportsSubsetDecoding, bool supportsIncomplete = true) { - SkAutoTDelete<SkStream> stream(GetResourceAsStream(path)); + SkAutoTDelete<SkStream> stream(resource(path)); if (!stream) { + SkDebugf("Missing resource '%s'\n", path); return; } @@ -323,8 +329,9 @@ static void check(skiatest::Reporter* r, // SkAndroidCodec tests if (supportsScanlineDecoding || supportsSubsetDecoding) { - SkAutoTDelete<SkStream> stream(GetResourceAsStream(path)); + SkAutoTDelete<SkStream> stream(resource(path)); if (!stream) { + SkDebugf("Missing resource '%s'\n", path); return; } @@ -349,7 +356,7 @@ static void check(skiatest::Reporter* r, if (!isIncomplete) { // Test SkCodecImageGenerator - SkAutoTDelete<SkStream> stream(GetResourceAsStream(path)); + SkAutoTDelete<SkStream> stream(resource(path)); sk_sp<SkData> fullData(SkData::MakeFromStream(stream, stream->getLength())); SkAutoTDelete<SkImageGenerator> gen( SkCodecImageGenerator::NewFromEncodedCodec(fullData.get())); @@ -442,10 +449,9 @@ DEF_TEST(Codec, r) { // Test interlaced PNG in stripes, similar to DM's kStripe_Mode DEF_TEST(Codec_stripes, r) { const char * path = "plane_interlaced.png"; - SkAutoTDelete<SkStream> stream(GetResourceAsStream(path)); - REPORTER_ASSERT(r, stream); + SkAutoTDelete<SkStream> stream(resource(path)); if (!stream) { - return; + SkDebugf("Missing resource '%s'\n", path); } SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.release())); @@ -576,8 +582,9 @@ DEF_TEST(Codec_null, r) { static void test_dimensions(skiatest::Reporter* r, const char path[]) { // Create the codec from the resource file - SkAutoTDelete<SkStream> stream(GetResourceAsStream(path)); + SkAutoTDelete<SkStream> stream(resource(path)); if (!stream) { + SkDebugf("Missing resource '%s'\n", path); return; } SkAutoTDelete<SkAndroidCodec> codec(SkAndroidCodec::NewFromStream(stream.release())); @@ -640,8 +647,9 @@ DEF_TEST(Codec_Dimensions, r) { } static void test_invalid(skiatest::Reporter* r, const char path[]) { - SkAutoTDelete<SkStream> stream(GetResourceAsStream(path)); + SkAutoTDelete<SkStream> stream(resource(path)); if (!stream) { + SkDebugf("Missing resource '%s'\n", path); return; } SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.release())); @@ -665,8 +673,9 @@ DEF_TEST(Codec_Empty, r) { } static void test_invalid_parameters(skiatest::Reporter* r, const char path[]) { - SkAutoTDelete<SkStream> stream(GetResourceAsStream(path)); + SkAutoTDelete<SkStream> stream(resource(path)); if (!stream) { + SkDebugf("Missing resource '%s'\n", path); return; } SkAutoTDelete<SkCodec> decoder(SkCodec::NewFromStream(stream.release())); @@ -956,8 +965,9 @@ DEF_TEST(Codec_webp_peek, r) { // Test that SkCodec now supports an image with these bits set. DEF_TEST(Codec_wbmp, r) { const char* path = "mandrill.wbmp"; - SkAutoTDelete<SkStream> stream(GetResourceAsStream(path)); + SkAutoTDelete<SkStream> stream(resource(path)); if (!stream) { + SkDebugf("Missing resource '%s'\n", path); return; } @@ -1006,8 +1016,9 @@ DEF_TEST(Codec_wbmp_max_size, r) { DEF_TEST(Codec_jpeg_rewind, r) { const char* path = "mandrill_512_q075.jpg"; - SkAutoTDelete<SkStream> stream(GetResourceAsStream(path)); + SkAutoTDelete<SkStream> stream(resource(path)); if (!stream) { + SkDebugf("Missing resource '%s'\n", path); return; } SkAutoTDelete<SkAndroidCodec> codec(SkAndroidCodec::NewFromStream(stream.release())); @@ -1033,7 +1044,7 @@ DEF_TEST(Codec_jpeg_rewind, r) { } static void check_color_xform(skiatest::Reporter* r, const char* path) { - SkAutoTDelete<SkAndroidCodec> codec(SkAndroidCodec::NewFromStream(GetResourceAsStream(path))); + SkAutoTDelete<SkAndroidCodec> codec(SkAndroidCodec::NewFromStream(resource(path))); SkAndroidCodec::AndroidOptions opts; opts.fSampleSize = 3; @@ -1119,7 +1130,7 @@ static void check_round_trip(skiatest::Reporter* r, SkCodec* origCodec, const Sk DEF_TEST(Codec_PngRoundTrip, r) { const char* path = "mandrill_512_q075.jpg"; - SkAutoTDelete<SkStream> stream(GetResourceAsStream(path)); + SkAutoTDelete<SkStream> stream(resource(path)); SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.release())); SkColorType colorTypesOpaque[] = { @@ -1131,12 +1142,12 @@ DEF_TEST(Codec_PngRoundTrip, r) { } path = "grayscale.jpg"; - stream.reset(GetResourceAsStream(path)); + stream.reset(resource(path)); codec.reset(SkCodec::NewFromStream(stream.release())); check_round_trip(r, codec.get(), codec->getInfo()); path = "yellow_rose.png"; - stream.reset(GetResourceAsStream(path)); + stream.reset(resource(path)); codec.reset(SkCodec::NewFromStream(stream.release())); SkColorType colorTypesWithAlpha[] = { @@ -1156,7 +1167,7 @@ DEF_TEST(Codec_PngRoundTrip, r) { } path = "index8.png"; - stream.reset(GetResourceAsStream(path)); + stream.reset(resource(path)); codec.reset(SkCodec::NewFromStream(stream.release())); for (SkAlphaType alphaType : alphaTypes) { @@ -1168,7 +1179,7 @@ DEF_TEST(Codec_PngRoundTrip, r) { static void test_conversion_possible(skiatest::Reporter* r, const char* path, bool testScanlineDecoder) { - SkAutoTDelete<SkStream> stream(GetResourceAsStream(path)); + SkAutoTDelete<SkStream> stream(resource(path)); SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.release())); SkImageInfo infoF16 = codec->getInfo().makeColorType(kRGBA_F16_SkColorType); diff --git a/tests/ColorSpaceTest.cpp b/tests/ColorSpaceTest.cpp index 7e247d304d..4a64460370 100644 --- a/tests/ColorSpaceTest.cpp +++ b/tests/ColorSpaceTest.cpp @@ -40,10 +40,15 @@ static void test_space(skiatest::Reporter* r, SkColorSpace* space, } } +static SkStreamAsset* resource(const char path[]) { + SkString fullPath = GetResourcePath(path); + return SkStream::NewFromFile(fullPath.c_str()); +} + static void test_path(skiatest::Reporter* r, const char* path, const float red[], const float green[], const float blue[], const SkGammaNamed expectedGamma) { - SkAutoTDelete<SkStream> stream(GetResourceAsStream(path)); + SkAutoTDelete<SkStream> stream(resource(path)); REPORTER_ASSERT(r, nullptr != stream); if (!stream) { return; diff --git a/tests/ExifTest.cpp b/tests/ExifTest.cpp index 4aac487064..7fcd8b861d 100644 --- a/tests/ExifTest.cpp +++ b/tests/ExifTest.cpp @@ -9,8 +9,13 @@ #include "SkCodec.h" #include "Test.h" +static SkStreamAsset* resource(const char path[]) { + SkString fullPath = GetResourcePath(path); + return SkStream::NewFromFile(fullPath.c_str()); +} + DEF_TEST(ExifOrientation, r) { - SkAutoTDelete<SkStream> stream(GetResourceAsStream("exif-orientation-2-ur.jpg")); + SkAutoTDelete<SkStream> stream(resource("exif-orientation-2-ur.jpg")); REPORTER_ASSERT(r, nullptr != stream); if (!stream) { return; @@ -21,7 +26,7 @@ DEF_TEST(ExifOrientation, r) { SkCodec::Origin origin = codec->getOrigin(); REPORTER_ASSERT(r, SkCodec::kTopRight_Origin == origin); - stream.reset(GetResourceAsStream("mandrill_512_q075.jpg")); + stream.reset(resource("mandrill_512_q075.jpg")); codec.reset(SkCodec::NewFromStream(stream.release())); REPORTER_ASSERT(r, nullptr != codec); origin = codec->getOrigin(); diff --git a/tests/SerializationTest.cpp b/tests/SerializationTest.cpp index bc2770ebda..ff9b342074 100644 --- a/tests/SerializationTest.cpp +++ b/tests/SerializationTest.cpp @@ -13,7 +13,6 @@ #include "SkImage.h" #include "SkImageSource.h" #include "SkLightingShader.h" -#include "SkMakeUnique.h" #include "SkMallocPixelRef.h" #include "SkNormalSource.h" #include "SkOSFile.h" @@ -371,13 +370,13 @@ static void TestPictureTypefaceSerialization(skiatest::Reporter* reporter) { { // Load typeface as stream to create with axis settings. - std::unique_ptr<SkStreamAsset> distortable(GetResourceAsStream("/fonts/Distortable.ttf")); + SkAutoTDelete<SkStreamAsset> distortable(GetResourceAsStream("/fonts/Distortable.ttf")); if (!distortable) { INFOF(reporter, "Could not run fontstream test because Distortable.ttf not found."); } else { SkFixed axis = SK_FixedSqrt2; sk_sp<SkTypeface> typeface(SkTypeface::MakeFromFontData( - skstd::make_unique<SkFontData>(std::move(distortable), 0, &axis, 1))); + new SkFontData(distortable.release(), 0, &axis, 1))); if (!typeface) { INFOF(reporter, "Could not run fontstream test because Distortable.ttf not created."); } else { diff --git a/tests/YUVTest.cpp b/tests/YUVTest.cpp index d3b9167843..f7b3306b98 100644 --- a/tests/YUVTest.cpp +++ b/tests/YUVTest.cpp @@ -12,11 +12,17 @@ #include "SkYUVSizeInfo.h" #include "Test.h" +static SkStreamAsset* resource(const char path[]) { + SkString fullPath = GetResourcePath(path); + return SkStream::NewFromFile(fullPath.c_str()); +} + static void codec_yuv(skiatest::Reporter* reporter, const char path[], SkISize expectedSizes[3]) { - SkAutoTDelete<SkStream> stream(GetResourceAsStream(path)); + SkAutoTDelete<SkStream> stream(resource(path)); if (!stream) { + INFOF(reporter, "Missing resource '%s'\n", path); return; } SkAutoTDelete<SkCodec> codec(SkCodec::NewFromStream(stream.release())); |