Revert "SkImageEncoder::* going away"

This reverts commit d7e16661bb.
Reason for revert: breaking g3
NOTRY=true
Change-Id: I56d53adca64a94b4f66dd0539634804a96e92ddf
Reviewed-on: https://skia-review.googlesource.com/5672
Commit-Queue: Hal Canary <halcanary@google.com>
Reviewed-by: Hal Canary <halcanary@google.com>
Reviewed-by: Herb Derby <herb@google.com>
This commit is contained in:
Hal Canary 2016-12-07 16:37:43 +00:00 committed by Skia Commit-Bot
parent 92964124c5
commit b88ca7eca4
5 changed files with 46 additions and 0 deletions

View File

@ -14,5 +14,6 @@ android_framework_defines = [
"SK_IGNORE_GPU_DITHER",
"SK_SUPPORT_LEGACY_CANVAS_IS_REFCNT",
"SK_SUPPORT_LEGACY_CLIP_REGIONOPS",
"SK_SUPPORT_LEGACY_IMAGE_ENCODER_CLASS",
"SK_SUPPORT_LEGACY_SHADER_ISABITMAP",
]

View File

@ -276,6 +276,11 @@ public:
* even if the image returns a data from refEncoded(). That data will be ignored.
*/
SkData* encode(SkEncodedImageFormat, int quality) const;
#ifdef SK_SUPPORT_LEGACY_IMAGE_ENCODER_CLASS
SkData* encode(SkImageEncoder::Type t, int quality) const {
return this->encode((SkEncodedImageFormat)t, quality);
}
#endif
/**
* Encode the image and return the result as a caller-managed SkData. This will

View File

@ -39,4 +39,36 @@ inline bool SkEncodeImage(SkWStream* dst, const SkBitmap& src, SkEncodedImageFor
return src.peekPixels(&pixmap) && SkEncodeImage(dst, pixmap, f, q);
}
//TODO(halcanary): remove this code once all changes land.
#ifdef SK_SUPPORT_LEGACY_IMAGE_ENCODER_CLASS
class SkImageEncoder {
public:
enum Type {
#ifdef GOOGLE3
kUnknown_Type = (int)SkEncodedImageFormat::kUnknown,
#endif
kBMP_Type = (int)SkEncodedImageFormat::kBMP,
kGIF_Type = (int)SkEncodedImageFormat::kGIF,
kICO_Type = (int)SkEncodedImageFormat::kICO,
kJPEG_Type = (int)SkEncodedImageFormat::kJPEG,
kPNG_Type = (int)SkEncodedImageFormat::kPNG,
kWBMP_Type = (int)SkEncodedImageFormat::kWBMP,
kWEBP_Type = (int)SkEncodedImageFormat::kWEBP,
kKTX_Type = (int)SkEncodedImageFormat::kKTX,
};
static SkData* EncodeData(const SkBitmap& src, Type t, int quality) {
SkDynamicMemoryWStream buf;
return SkEncodeImage(&buf, src, (SkEncodedImageFormat)t, quality)
? buf.detachAsData().release() : nullptr;
}
static bool EncodeFile(const char path[], const SkBitmap& src, Type t, int quality) {
SkFILEWStream file(path);
return SkEncodeImage(&file, src, (SkEncodedImageFormat)t, quality);
}
static bool EncodeStream(SkWStream* dst, const SkBitmap& bm, Type t, int quality) {
return SkEncodeImage(dst, bm, (SkEncodedImageFormat)t, quality);
}
};
#endif // SK_SUPPORT_LEGACY_IMAGE_ENCODER_CLASS
#endif // SkImageEncoder_DEFINED

View File

@ -0,0 +1,7 @@
/*
* Copyright 2013 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
// TODO(halcanary): delete this file.

View File

@ -591,6 +591,7 @@ DEFINES_ALL = [
"GOOGLE3",
# Staging flags for API changes
"SK_SUPPORT_LEGACY_CLIP_REGIONOPS",
"SK_SUPPORT_LEGACY_IMAGE_ENCODER_CLASS",
# Temporarily Disable analytic AA for Google3
"SK_NO_ANALYTIC_AA",
]