diff options
author | Hal Canary <halcanary@google.com> | 2016-11-22 09:03:03 -0700 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2016-11-22 18:25:55 +0000 |
commit | 248ff02331d7f73ee4b6c5a7eabeae1080c16cd4 (patch) | |
tree | a55e2402ef1494e2fb719bc046f1f97c8e75da53 /tests | |
parent | 46e66a2bf51546a7c3b08625769899b9ead56ec6 (diff) |
SkImageEncoder: simplify API
- Hide SkImageEncoder class in private header.
- SkImageEncoder::Type becomes SkEncodedImageFormat
- SkEncodedFormat becomes SkEncodedImageFormat
- SkImageEncoder static functions replaced with
single function EncodeImage()
- utility wrappers for EncodeImage() are in
sk_tool_utils.h
TODO: remove link-time registration mechanism.
TODO: clean up clients use of API and flip the flag.
TODO: implement EncodeImage() in chromeium/skia/ext
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4909
Change-Id: Ib48b31fdc05cf23cda7f56ebfd67c841c149ce70
Reviewed-on: https://skia-review.googlesource.com/4909
Reviewed-by: Mike Reed <reed@google.com>
Reviewed-by: Leon Scroggins <scroggo@google.com>
Commit-Queue: Hal Canary <halcanary@google.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/BlitRowTest.cpp | 4 | ||||
-rw-r--r-- | tests/CodecTest.cpp | 4 | ||||
-rw-r--r-- | tests/ImageTest.cpp | 6 | ||||
-rw-r--r-- | tests/PDFDocumentTest.cpp | 11 | ||||
-rw-r--r-- | tests/PathOpsConicIntersectionTest.cpp | 10 | ||||
-rw-r--r-- | tests/PathOpsSkpClipTest.cpp | 2 | ||||
-rw-r--r-- | tests/SkpSkGrTest.cpp | 4 |
7 files changed, 21 insertions, 20 deletions
diff --git a/tests/BlitRowTest.cpp b/tests/BlitRowTest.cpp index b4a4a64dfe..3439a5e09d 100644 --- a/tests/BlitRowTest.cpp +++ b/tests/BlitRowTest.cpp @@ -12,6 +12,8 @@ #include "SkRect.h" #include "Test.h" +#include "sk_tool_utils.h" + // these are in the same order as the SkColorType enum static const char* gColorTypeName[] = { "None", "A8", "565", "4444", "RGBA", "BGRA", "Index8" @@ -178,7 +180,7 @@ struct Mesh { #include "SkImageEncoder.h" static void save_bm(const SkBitmap& bm, const char name[]) { - SkImageEncoder::EncodeFile(name, bm, SkImageEncoder::kPNG_Type, 100); + sk_tool_utils::EncodeImageToFile(name, bm, SkEncodedImageFormat::kPNG, 100); } static bool gOnce; diff --git a/tests/CodecTest.cpp b/tests/CodecTest.cpp index dacabca3fd..d15c710325 100644 --- a/tests/CodecTest.cpp +++ b/tests/CodecTest.cpp @@ -23,6 +23,8 @@ #include "png.h" +#include "sk_tool_utils.h" + #if PNG_LIBPNG_VER_MAJOR == 1 && PNG_LIBPNG_VER_MINOR < 5 // FIXME (scroggo): Google3 needs to be updated to use a newer version of libpng. In // the meantime, we had to break some pieces of SkPngCodec in order to support Google3. @@ -1102,7 +1104,7 @@ static void check_round_trip(skiatest::Reporter* r, SkCodec* origCodec, const Sk // Encode the image to png. sk_sp<SkData> data = - sk_sp<SkData>(SkImageEncoder::EncodeData(bm1, SkImageEncoder::kPNG_Type, 100)); + sk_sp<SkData>(sk_tool_utils::EncodeImageToData(bm1, SkEncodedImageFormat::kPNG, 100)); std::unique_ptr<SkCodec> codec(SkCodec::NewFromData(data)); REPORTER_ASSERT(r, color_type_match(info.colorType(), codec->getInfo().colorType())); diff --git a/tests/ImageTest.cpp b/tests/ImageTest.cpp index 18883feded..020e322f91 100644 --- a/tests/ImageTest.cpp +++ b/tests/ImageTest.cpp @@ -26,6 +26,8 @@ #include "SkUtils.h" #include "Test.h" +#include "sk_tool_utils.h" + #if SK_SUPPORT_GPU #include "GrGpu.h" #endif @@ -153,7 +155,7 @@ static sk_sp<SkImage> create_codec_image() { sk_sp<SkData> data(create_image_data(&info)); SkBitmap bitmap; bitmap.installPixels(info, data->writable_data(), info.minRowBytes()); - sk_sp<SkData> src(SkImageEncoder::EncodeData(bitmap, SkImageEncoder::kPNG_Type, 100)); + sk_sp<SkData> src(sk_tool_utils::EncodeImageToData(bitmap, SkEncodedImageFormat::kPNG, 100)); return SkImage::MakeFromEncoded(std::move(src)); } #if SK_SUPPORT_GPU @@ -1026,7 +1028,7 @@ DEF_TEST(image_roundtrip_encode, reporter) { make_all_premul(&bm0); auto img0 = SkImage::MakeFromBitmap(bm0); - sk_sp<SkData> data(img0->encode(SkImageEncoder::kPNG_Type, 100)); + sk_sp<SkData> data(img0->encode(SkEncodedImageFormat::kPNG, 100)); auto img1 = SkImage::MakeFromEncoded(data); SkBitmap bm1; diff --git a/tests/PDFDocumentTest.cpp b/tests/PDFDocumentTest.cpp index fca8496f26..b3200156c6 100644 --- a/tests/PDFDocumentTest.cpp +++ b/tests/PDFDocumentTest.cpp @@ -14,6 +14,8 @@ #include "SkStream.h" #include "SkPixelSerializer.h" +#include "sk_tool_utils.h" + static void test_empty(skiatest::Reporter* reporter) { SkDynamicMemoryWStream stream; @@ -119,14 +121,7 @@ namespace { class JPEGSerializer final : public SkPixelSerializer { bool onUseEncodedData(const void*, size_t) override { return true; } SkData* onEncode(const SkPixmap& pixmap) override { - SkBitmap bm; - return bm.installPixels(pixmap.info(), - pixmap.writable_addr(), - pixmap.rowBytes(), - pixmap.ctable(), - nullptr, nullptr) - ? SkImageEncoder::EncodeData(bm, SkImageEncoder::kJPEG_Type, 85) - : nullptr; + return sk_tool_utils::EncodeImageToData(pixmap, SkEncodedImageFormat::kJPEG, 85).release(); } }; } // namespace diff --git a/tests/PathOpsConicIntersectionTest.cpp b/tests/PathOpsConicIntersectionTest.cpp index 41c0acb9fd..1de1583a7b 100644 --- a/tests/PathOpsConicIntersectionTest.cpp +++ b/tests/PathOpsConicIntersectionTest.cpp @@ -110,8 +110,8 @@ static void writePng(const SkConic& c, const SkConic ch[2], const char* name) { canvas.drawPath(path, paint); SkString filename("c:\\Users\\caryclark\\Documents\\"); filename.appendf("%s.png", name); - SkImageEncoder::EncodeFile(filename.c_str(), bitmap, - SkImageEncoder::kPNG_Type, 100); + sk_tool_utils::EncodeImageToFile(filename.c_str(), bitmap, + SkEncodedImageFormat::kPNG, 100); } static void writeDPng(const SkDConic& dC, const char* name) { @@ -152,8 +152,8 @@ static void writeDPng(const SkDConic& dC, const char* name) { canvas.drawPath(path, paint); SkString filename("c:\\Users\\caryclark\\Documents\\"); filename.appendf("%s.png", name); - SkImageEncoder::EncodeFile(filename.c_str(), bitmap, - SkImageEncoder::kPNG_Type, 100); + sk_tool_utils::EncodeImageToFile(filename.c_str(), bitmap, + SkEncodedImageFormat::kPNG, 100); } #endif @@ -290,7 +290,7 @@ static void writeFrames() { } SkString filename("c:\\Users\\caryclark\\Documents\\"); filename.appendf("f%d.png", index); - SkImageEncoder::EncodeFile(filename.c_str(), bitmap, SkImageEncoder::kPNG_Type, 100); + sk_tool_utils::EncodeImageToFile(filename.c_str(), bitmap, SkEncodedImageFormat::kPNG, 100); } } #endif diff --git a/tests/PathOpsSkpClipTest.cpp b/tests/PathOpsSkpClipTest.cpp index 3cbe7efdba..57e9bd1b64 100644 --- a/tests/PathOpsSkpClipTest.cpp +++ b/tests/PathOpsSkpClipTest.cpp @@ -429,7 +429,7 @@ static void drawPict(SkPicture* pic, SkCanvas* canvas, int scale) { static void writePict(const SkBitmap& bitmap, const char* outDir, const char* pngName) { SkString outFile = get_sum_path(outDir); outFile.appendf("%s%s", PATH_SLASH, pngName); - if (!SkImageEncoder::EncodeFile(outFile.c_str(), bitmap, SkImageEncoder::kPNG_Type, 100)) { + if (!sk_tool_utils::EncodeImageToFile(outFile.c_str(), bitmap, SkEncodedImageFormat::kPNG, 100)) { SkDebugf("unable to encode gr %s (width=%d height=%d)\n", pngName, bitmap.width(), bitmap.height()); } diff --git a/tests/SkpSkGrTest.cpp b/tests/SkpSkGrTest.cpp index c87926ecf8..0e425a006a 100644 --- a/tests/SkpSkGrTest.cpp +++ b/tests/SkpSkGrTest.cpp @@ -368,8 +368,8 @@ static void drawPict(SkPicture* pic, SkCanvas* canvas, int scale) { static void writePict(const SkBitmap& bitmap, const char* outDir, const char* pngName) { SkString outFile = make_filepath(0, outDir, pngName); - if (!SkImageEncoder::EncodeFile(outFile.c_str(), bitmap, - SkImageEncoder::kPNG_Type, 100)) { + if (!sk_tool_utils::EncodeImageToFile(outFile.c_str(), bitmap, + SkEncodedImageFormat::kPNG, 100)) { SkDebugf("unable to encode gr %s (width=%d height=%d)br \n", pngName, bitmap.width(), bitmap.height()); } |