Remove unnecessary sk_tool_utils::EncodeImageToData
This template is only used in practice for SkBitmaps. There is already a public API that does the same thing, so there's no need for this one. Change-Id: I20b10aa8bc87a56face947689e1f0eaf4c3cc4e8 Reviewed-on: https://skia-review.googlesource.com/156540 Reviewed-by: Hal Canary <halcanary@google.com> Auto-Submit: Leon Scroggins <scroggo@google.com> Commit-Queue: Leon Scroggins <scroggo@google.com>
This commit is contained in:
parent
58527bcf56
commit
0098ccbab5
@ -5,7 +5,6 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
#include "gm.h"
|
||||
#include "sk_tool_utils.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkData.h"
|
||||
#include "SkImage.h"
|
||||
@ -30,13 +29,13 @@ protected:
|
||||
void onDraw(SkCanvas* canvas) override {
|
||||
SkBitmap orig;
|
||||
GetResourceAsBitmap("images/mandrill_512_q075.jpg", &orig);
|
||||
sk_sp<SkData> pngData(sk_tool_utils::EncodeImageToData(orig, SkEncodedImageFormat::kPNG, 100));
|
||||
sk_sp<SkData> jpegData(sk_tool_utils::EncodeImageToData(orig, SkEncodedImageFormat::kJPEG, 100));
|
||||
auto pngData = SkEncodeBitmap(orig, SkEncodedImageFormat::kPNG, 100);
|
||||
auto jpgData = SkEncodeBitmap(orig, SkEncodedImageFormat::kJPEG, 100);
|
||||
|
||||
sk_sp<SkImage> pngImage = SkImage::MakeFromEncoded(pngData);
|
||||
sk_sp<SkImage> jpegImage = SkImage::MakeFromEncoded(jpegData);
|
||||
sk_sp<SkImage> jpgImage = SkImage::MakeFromEncoded(jpgData);
|
||||
canvas->drawImage(pngImage.get(), 0.0f, 0.0f);
|
||||
canvas->drawImage(jpegImage.get(), 512.0f, 0.0f);
|
||||
canvas->drawImage(jpgImage.get(), 512.0f, 0.0f);
|
||||
|
||||
const char text[] = "Images should look identical.";
|
||||
canvas->drawText(text, sizeof(text) - 1, 450.0f, 550.0f, SkPaint());
|
||||
|
@ -311,14 +311,12 @@ DEF_SIMPLE_GM(new_texture_image, canvas, 280, 60) {
|
||||
},
|
||||
// Create encoded image.
|
||||
[bmp] {
|
||||
sk_sp<SkData> src(
|
||||
sk_tool_utils::EncodeImageToData(bmp, SkEncodedImageFormat::kPNG, 100));
|
||||
auto src = SkEncodeBitmap(bmp, SkEncodedImageFormat::kPNG, 100);
|
||||
return SkImage::MakeFromEncoded(std::move(src));
|
||||
},
|
||||
// Create YUV encoded image.
|
||||
[bmp] {
|
||||
sk_sp<SkData> src(
|
||||
sk_tool_utils::EncodeImageToData(bmp, SkEncodedImageFormat::kJPEG, 100));
|
||||
auto src = SkEncodeBitmap(bmp, SkEncodedImageFormat::kJPEG, 100);
|
||||
return SkImage::MakeFromEncoded(std::move(src));
|
||||
},
|
||||
// Create a picture image.
|
||||
|
@ -5,7 +5,6 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
#include "gm.h"
|
||||
#include "sk_tool_utils.h"
|
||||
#include "SkCanvas.h"
|
||||
#include "SkColorPriv.h"
|
||||
#include "SkData.h"
|
||||
@ -46,8 +45,8 @@ protected:
|
||||
bY += 64;
|
||||
}
|
||||
}
|
||||
auto jpegData(sk_tool_utils::EncodeImageToData(bmp, SkEncodedImageFormat::kJPEG, 100));
|
||||
fImage = SkImage::MakeFromEncoded(jpegData);
|
||||
auto jpegData = SkEncodeBitmap(bmp, SkEncodedImageFormat::kJPEG, 100);
|
||||
fImage = SkImage::MakeFromEncoded(std::move(jpegData));
|
||||
}
|
||||
|
||||
void onDraw(SkCanvas* canvas) override {
|
||||
|
@ -1065,8 +1065,7 @@ static void check_round_trip(skiatest::Reporter* r, SkCodec* origCodec, const Sk
|
||||
REPORTER_ASSERT(r, SkCodec::kSuccess == result);
|
||||
|
||||
// Encode the image to png.
|
||||
sk_sp<SkData> data =
|
||||
sk_sp<SkData>(sk_tool_utils::EncodeImageToData(bm1, SkEncodedImageFormat::kPNG, 100));
|
||||
auto data = SkEncodeBitmap(bm1, SkEncodedImageFormat::kPNG, 100);
|
||||
|
||||
std::unique_ptr<SkCodec> codec(SkCodec::MakeFromData(data));
|
||||
REPORTER_ASSERT(r, color_type_match(info.colorType(), codec->getInfo().colorType()));
|
||||
|
@ -143,7 +143,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(sk_tool_utils::EncodeImageToData(bitmap, SkEncodedImageFormat::kPNG, 100));
|
||||
auto src = SkEncodeBitmap(bitmap, SkEncodedImageFormat::kPNG, 100);
|
||||
return SkImage::MakeFromEncoded(std::move(src));
|
||||
}
|
||||
static sk_sp<SkImage> create_gpu_image(GrContext* context, bool withMips = false) {
|
||||
|
@ -238,12 +238,6 @@ namespace sk_tool_utils {
|
||||
return file.isValid() && SkEncodeImage(&file, src, f, q);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline sk_sp<SkData> EncodeImageToData(const T& src, SkEncodedImageFormat f, int q) {
|
||||
SkDynamicMemoryWStream buf;
|
||||
return SkEncodeImage(&buf, src , f, q) ? buf.detachAsData() : nullptr;
|
||||
}
|
||||
|
||||
bool copy_to(SkBitmap* dst, SkColorType dstCT, const SkBitmap& src);
|
||||
void copy_to_g8(SkBitmap* dst, const SkBitmap& src);
|
||||
} // namespace sk_tool_utils
|
||||
|
Loading…
Reference in New Issue
Block a user