Delete SkImage::encode(Type)

This doesn't appear to be used (fingers crossed).

We're not ready to support color correct encodes (and tagging with
color spaces) for all of the formats included in SkImageEncoder::Type.

I think it's good to restrict this for now.

BUG=skia:

GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4535

Change-Id: I73000f3d7bff1af153786d766531a2cbc8c5b77a
Reviewed-on: https://skia-review.googlesource.com/4535
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Matt Sarett <msarett@google.com>
This commit is contained in:
Matt Sarett 2016-11-07 18:06:06 -05:00 committed by Skia Commit-Bot
parent d3a2af75a9
commit e48b4c550d
5 changed files with 7 additions and 24 deletions

View File

@ -348,13 +348,16 @@ static SkImageGenerator* gen_picture(const SkImageInfo& info) {
static SkImageGenerator* gen_png(const SkImageInfo& info) {
sk_sp<SkImage> image(make_raster(info, nullptr, draw_opaque_contents));
sk_sp<SkData> data(image->encode(SkImageEncoder::kPNG_Type, 100));
sk_sp<SkData> data(image->encode());
return SkImageGenerator::NewFromEncoded(data.get());
}
static SkImageGenerator* gen_jpg(const SkImageInfo& info) {
sk_sp<SkImage> image(make_raster(info, nullptr, draw_opaque_contents));
sk_sp<SkData> data(image->encode(SkImageEncoder::kJPEG_Type, 100));
SkBitmap bitmap;
SkAssertResult(image->asLegacyBitmap(&bitmap, SkImage::kRO_LegacyBitmapMode));
sk_sp<SkData> data =
sk_ref_sp(SkImageEncoder::EncodeData(bitmap, SkImageEncoder::kJPEG_Type, 100));
return SkImageGenerator::NewFromEncoded(data.get());
}

View File

@ -55,7 +55,7 @@ static sk_sp<SkImage> make_encode_gen(GrContext* ctx, SkPicture* pic, const SkIm
if (!src) {
return nullptr;
}
sk_sp<SkData> encoded(src->encode(SkImageEncoder::kPNG_Type, 100));
sk_sp<SkData> encoded(src->encode());
if (!encoded) {
return nullptr;
}

View File

@ -265,18 +265,6 @@ public:
*/
bool scalePixels(const SkPixmap& dst, SkFilterQuality, CachingHint = kAllow_CachingHint) const;
/**
* Encode the image's pixels and return the result as a new SkData, which
* the caller must manage (i.e. call unref() when they are done).
*
* If the image type cannot be encoded, or the requested encoder type is
* not supported, this will return NULL.
*
* Note: this will attempt to encode the image's pixels in the specified format,
* even if the image returns a data from refEncoded(). That data will be ignored.
*/
SkData* encode(SkImageEncoder::Type, int quality) const;
/**
* Encode the image and return the result as a caller-managed SkData. This will
* attempt to reuse existing encoded data (as returned by refEncoded).

View File

@ -100,14 +100,6 @@ sk_sp<SkShader> SkImage::makeShader(SkShader::TileMode tileX, SkShader::TileMode
return SkImageShader::Make(sk_ref_sp(const_cast<SkImage*>(this)), tileX, tileY, localMatrix);
}
SkData* SkImage::encode(SkImageEncoder::Type type, int quality) const {
SkBitmap bm;
if (as_IB(this)->getROPixels(&bm)) {
return SkImageEncoder::EncodeData(bm, type, quality);
}
return nullptr;
}
SkData* SkImage::encode(SkPixelSerializer* serializer) const {
sk_sp<SkPixelSerializer> defaultSerializer;
SkPixelSerializer* effectiveSerializer = serializer;

View File

@ -1025,7 +1025,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());
auto img1 = SkImage::MakeFromEncoded(data);
SkBitmap bm1;