aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/codec/SkCodec.cpp
diff options
context:
space:
mode:
authorGravatar Leon Scroggins III <scroggo@google.com>2017-12-04 16:40:24 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-12-05 00:52:42 +0000
commitc6f7a4ffa9522159efc42f7c948bba5e66bb8844 (patch)
tree90de4148501653aa680b137398d58a2f5621c96b /src/codec/SkCodec.cpp
parent06ab3836f779dbcbcd067a9261300616ff7cc594 (diff)
Hide SkEncodedInfo
Bug: skia:7353 Bug: skia:6839 This contains information that is not necessary for clients to know. The Color enum tells the number of components in the input, but this is only interesting internally (to the SkSwizzler). Similarly, the Alpha enum differs from SkAlphaType in that it has kBinary instead of kPremul. This is useful information only internally for determining whether the SkColorSpaceXform needs to premultiply. The bitsPerComponent is potentially useful for a client; Android (in SkAndroidCodec) uses it to determine the SkColorType. Rather than exposing bitsPerComponent, use it to make the same decision that Android would have made - 16 bits per component means to set the info to F16. Add a test that computeOutputColorType behaves as expected. Switch conversionSupported to use an SkColorType, which is enough info. Replace the SkEncodedInfo::Alpha field on SkCodec::FrameInfo with an SkAlphaType. SkCodec still needs an SkEncodedInfo, so move its header (which is already not SK_API) to include/private. Change-Id: Ie2cf11339bf999ebfd4390c0f448f7edd6feabda Reviewed-on: https://skia-review.googlesource.com/79260 Reviewed-by: Mike Reed <reed@google.com> Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Leon Scroggins <scroggo@google.com>
Diffstat (limited to 'src/codec/SkCodec.cpp')
-rw-r--r--src/codec/SkCodec.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/codec/SkCodec.cpp b/src/codec/SkCodec.cpp
index a0f1fb2706..7de083db3c 100644
--- a/src/codec/SkCodec.cpp
+++ b/src/codec/SkCodec.cpp
@@ -158,7 +158,7 @@ SkCodec::SkCodec(const SkEncodedInfo& info, const SkImageInfo& imageInfo,
SkCodec::~SkCodec() {}
-bool SkCodec::conversionSupported(const SkImageInfo& dst, SkEncodedInfo::Color srcColor,
+bool SkCodec::conversionSupported(const SkImageInfo& dst, SkColorType srcColor,
bool srcIsOpaque, const SkColorSpace* srcCS) const {
if (!valid_alpha(dst.alphaType(), srcIsOpaque)) {
return false;
@@ -173,7 +173,7 @@ bool SkCodec::conversionSupported(const SkImageInfo& dst, SkEncodedInfo::Color s
case kRGB_565_SkColorType:
return srcIsOpaque;
case kGray_8_SkColorType:
- return SkEncodedInfo::kGray_Color == srcColor && srcIsOpaque &&
+ return kGray_8_SkColorType == srcColor && srcIsOpaque &&
!needs_color_xform(dst, srcCS, false);
case kAlpha_8_SkColorType:
// conceptually we can convert anything into alpha_8, but we haven't actually coded
@@ -224,7 +224,7 @@ SkCodec::Result SkCodec::handleFrameIndex(const SkImageInfo& info, void* pixels,
const Options& options) {
const int index = options.fFrameIndex;
if (0 == index) {
- if (!this->conversionSupported(info, fEncodedInfo.color(), fEncodedInfo.opaque(),
+ if (!this->conversionSupported(info, fSrcInfo.colorType(), fEncodedInfo.opaque(),
fSrcInfo.colorSpace())
|| !this->initializeColorXform(info, fEncodedInfo.alpha(), options.fPremulBehavior))
{
@@ -253,7 +253,7 @@ SkCodec::Result SkCodec::handleFrameIndex(const SkImageInfo& info, void* pixels,
const auto* frame = frameHolder->getFrame(index);
SkASSERT(frame);
- if (!this->conversionSupported(info, fEncodedInfo.color(), !frame->hasAlpha(),
+ if (!this->conversionSupported(info, fSrcInfo.colorType(), !frame->hasAlpha(),
fSrcInfo.colorSpace())) {
return kInvalidConversion;
}
@@ -297,9 +297,7 @@ SkCodec::Result SkCodec::handleFrameIndex(const SkImageInfo& info, void* pixels,
}
}
- FrameInfo frameInfo;
- SkAssertResult(this->getFrameInfo(index, &frameInfo));
- return this->initializeColorXform(info, frameInfo.fAlpha, options.fPremulBehavior)
+ return this->initializeColorXform(info, frame->reportedAlpha(), options.fPremulBehavior)
? kSuccess : kInvalidConversion;
}
@@ -630,6 +628,10 @@ bool SkCodec::initializeColorXform(const SkImageInfo& dstInfo, SkEncodedInfo::Al
if (!this->usesColorXform()) {
return true;
}
+ // FIXME: In SkWebpCodec, if a frame is blending with a prior frame, we don't need
+ // a colorXform to do a color correct premul, since the blend step will handle
+ // premultiplication. But there is no way to know whether we need to blend from
+ // inside this call.
bool needsColorCorrectPremul = needs_premul(dstInfo.alphaType(), encodedAlpha) &&
SkTransferFunctionBehavior::kRespect == premulBehavior;
if (needs_color_xform(dstInfo, fSrcInfo.colorSpace(), needsColorCorrectPremul)) {