Revert 248ff023 & 2cb6cb72
Revert "SkImageEncoder: simplify API"
This reverts commit 248ff02331d7f73ee4b6c5a7eabeae1080c16cd4.
Revert "Fix bug: can't convert nullptr -> bool"
This reverts commit 2cb6cb7218171b357bb5c934f032ba69c7b78401.
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=5151
NOTRY=true
Change-Id: I5f6414392d6545f74db0b5bb50608d04f053a8ec
Reviewed-on: https://skia-review.googlesource.com/5151
Commit-Queue: Hal Canary <halcanary@google.com>
Reviewed-by: Hal Canary <halcanary@google.com>
diff --git a/tests/BlitRowTest.cpp b/tests/BlitRowTest.cpp
index 3439a5e..b4a4a64 100644
--- a/tests/BlitRowTest.cpp
+++ b/tests/BlitRowTest.cpp
@@ -12,8 +12,6 @@
#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"
@@ -180,7 +178,7 @@
#include "SkImageEncoder.h"
static void save_bm(const SkBitmap& bm, const char name[]) {
- sk_tool_utils::EncodeImageToFile(name, bm, SkEncodedImageFormat::kPNG, 100);
+ SkImageEncoder::EncodeFile(name, bm, SkImageEncoder::kPNG_Type, 100);
}
static bool gOnce;
diff --git a/tests/CodecTest.cpp b/tests/CodecTest.cpp
index d15c710..dacabca 100644
--- a/tests/CodecTest.cpp
+++ b/tests/CodecTest.cpp
@@ -23,8 +23,6 @@
#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.
@@ -1104,7 +1102,7 @@
// Encode the image to png.
sk_sp<SkData> data =
- sk_sp<SkData>(sk_tool_utils::EncodeImageToData(bm1, SkEncodedImageFormat::kPNG, 100));
+ sk_sp<SkData>(SkImageEncoder::EncodeData(bm1, SkImageEncoder::kPNG_Type, 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 020e322..18883fe 100644
--- a/tests/ImageTest.cpp
+++ b/tests/ImageTest.cpp
@@ -26,8 +26,6 @@
#include "SkUtils.h"
#include "Test.h"
-#include "sk_tool_utils.h"
-
#if SK_SUPPORT_GPU
#include "GrGpu.h"
#endif
@@ -155,7 +153,7 @@
sk_sp<SkData> data(create_image_data(&info));
SkBitmap bitmap;
bitmap.installPixels(info, data->writable_data(), info.minRowBytes());
- sk_sp<SkData> src(sk_tool_utils::EncodeImageToData(bitmap, SkEncodedImageFormat::kPNG, 100));
+ sk_sp<SkData> src(SkImageEncoder::EncodeData(bitmap, SkImageEncoder::kPNG_Type, 100));
return SkImage::MakeFromEncoded(std::move(src));
}
#if SK_SUPPORT_GPU
@@ -1028,7 +1026,7 @@
make_all_premul(&bm0);
auto img0 = SkImage::MakeFromBitmap(bm0);
- sk_sp<SkData> data(img0->encode(SkEncodedImageFormat::kPNG, 100));
+ sk_sp<SkData> data(img0->encode(SkImageEncoder::kPNG_Type, 100));
auto img1 = SkImage::MakeFromEncoded(data);
SkBitmap bm1;
diff --git a/tests/PDFDocumentTest.cpp b/tests/PDFDocumentTest.cpp
index b320015..fca8496 100644
--- a/tests/PDFDocumentTest.cpp
+++ b/tests/PDFDocumentTest.cpp
@@ -14,8 +14,6 @@
#include "SkStream.h"
#include "SkPixelSerializer.h"
-#include "sk_tool_utils.h"
-
static void test_empty(skiatest::Reporter* reporter) {
SkDynamicMemoryWStream stream;
@@ -121,7 +119,14 @@
class JPEGSerializer final : public SkPixelSerializer {
bool onUseEncodedData(const void*, size_t) override { return true; }
SkData* onEncode(const SkPixmap& pixmap) override {
- return sk_tool_utils::EncodeImageToData(pixmap, SkEncodedImageFormat::kJPEG, 85).release();
+ SkBitmap bm;
+ return bm.installPixels(pixmap.info(),
+ pixmap.writable_addr(),
+ pixmap.rowBytes(),
+ pixmap.ctable(),
+ nullptr, nullptr)
+ ? SkImageEncoder::EncodeData(bm, SkImageEncoder::kJPEG_Type, 85)
+ : nullptr;
}
};
} // namespace
diff --git a/tests/PathOpsConicIntersectionTest.cpp b/tests/PathOpsConicIntersectionTest.cpp
index 1de1583..41c0acb 100644
--- a/tests/PathOpsConicIntersectionTest.cpp
+++ b/tests/PathOpsConicIntersectionTest.cpp
@@ -110,8 +110,8 @@
canvas.drawPath(path, paint);
SkString filename("c:\\Users\\caryclark\\Documents\\");
filename.appendf("%s.png", name);
- sk_tool_utils::EncodeImageToFile(filename.c_str(), bitmap,
- SkEncodedImageFormat::kPNG, 100);
+ SkImageEncoder::EncodeFile(filename.c_str(), bitmap,
+ SkImageEncoder::kPNG_Type, 100);
}
static void writeDPng(const SkDConic& dC, const char* name) {
@@ -152,8 +152,8 @@
canvas.drawPath(path, paint);
SkString filename("c:\\Users\\caryclark\\Documents\\");
filename.appendf("%s.png", name);
- sk_tool_utils::EncodeImageToFile(filename.c_str(), bitmap,
- SkEncodedImageFormat::kPNG, 100);
+ SkImageEncoder::EncodeFile(filename.c_str(), bitmap,
+ SkImageEncoder::kPNG_Type, 100);
}
#endif
@@ -290,7 +290,7 @@
}
SkString filename("c:\\Users\\caryclark\\Documents\\");
filename.appendf("f%d.png", index);
- sk_tool_utils::EncodeImageToFile(filename.c_str(), bitmap, SkEncodedImageFormat::kPNG, 100);
+ SkImageEncoder::EncodeFile(filename.c_str(), bitmap, SkImageEncoder::kPNG_Type, 100);
}
}
#endif
diff --git a/tests/PathOpsSkpClipTest.cpp b/tests/PathOpsSkpClipTest.cpp
index 57e9bd1..3cbe7ef 100644
--- a/tests/PathOpsSkpClipTest.cpp
+++ b/tests/PathOpsSkpClipTest.cpp
@@ -429,7 +429,7 @@
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 (!sk_tool_utils::EncodeImageToFile(outFile.c_str(), bitmap, SkEncodedImageFormat::kPNG, 100)) {
+ if (!SkImageEncoder::EncodeFile(outFile.c_str(), bitmap, SkImageEncoder::kPNG_Type, 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 0e425a0..c87926e 100644
--- a/tests/SkpSkGrTest.cpp
+++ b/tests/SkpSkGrTest.cpp
@@ -368,8 +368,8 @@
static void writePict(const SkBitmap& bitmap, const char* outDir, const char* pngName) {
SkString outFile = make_filepath(0, outDir, pngName);
- if (!sk_tool_utils::EncodeImageToFile(outFile.c_str(), bitmap,
- SkEncodedImageFormat::kPNG, 100)) {
+ if (!SkImageEncoder::EncodeFile(outFile.c_str(), bitmap,
+ SkImageEncoder::kPNG_Type, 100)) {
SkDebugf("unable to encode gr %s (width=%d height=%d)br \n", pngName,
bitmap.width(), bitmap.height());
}