aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/codec
diff options
context:
space:
mode:
Diffstat (limited to 'src/codec')
-rw-r--r--src/codec/SkAndroidCodec.cpp11
-rw-r--r--src/codec/SkCodec.cpp16
-rw-r--r--src/codec/SkFrameHolder.h10
-rw-r--r--src/codec/SkGifCodec.cpp4
-rw-r--r--src/codec/SkHeifCodec.h2
-rw-r--r--src/codec/SkIcoCodec.h2
-rw-r--r--src/codec/SkJpegCodec.h2
-rw-r--r--src/codec/SkWbmpCodec.cpp2
-rw-r--r--src/codec/SkWbmpCodec.h2
-rw-r--r--src/codec/SkWebpCodec.cpp7
-rw-r--r--src/codec/SkWebpCodec.h12
11 files changed, 35 insertions, 35 deletions
diff --git a/src/codec/SkAndroidCodec.cpp b/src/codec/SkAndroidCodec.cpp
index cd23680932..4c76bdccb4 100644
--- a/src/codec/SkAndroidCodec.cpp
+++ b/src/codec/SkAndroidCodec.cpp
@@ -64,10 +64,6 @@ SkAndroidCodec::SkAndroidCodec(SkCodec* codec)
SkAndroidCodec::~SkAndroidCodec() {}
-const SkEncodedInfo& SkAndroidCodec::getEncodedInfo() const {
- return fCodec->getEncodedInfo();
-}
-
std::unique_ptr<SkAndroidCodec> SkAndroidCodec::MakeFromStream(std::unique_ptr<SkStream> stream, SkPngChunkReader* chunkReader) {
auto codec = SkCodec::MakeFromStream(std::move(stream), nullptr, chunkReader);
if (nullptr == codec) {
@@ -112,7 +108,6 @@ std::unique_ptr<SkAndroidCodec> SkAndroidCodec::MakeFromData(sk_sp<SkData> data,
}
SkColorType SkAndroidCodec::computeOutputColorType(SkColorType requestedColorType) {
- bool highPrecision = fCodec->getEncodedInfo().bitsPerComponent() > 8;
switch (requestedColorType) {
case kARGB_4444_SkColorType:
return kN32_SkColorType;
@@ -138,8 +133,10 @@ SkColorType SkAndroidCodec::computeOutputColorType(SkColorType requestedColorTyp
break;
}
- // F16 is the Android default for high precision images.
- return highPrecision ? kRGBA_F16_SkColorType : kN32_SkColorType;
+ if (this->getInfo().colorType() == kRGBA_F16_SkColorType) {
+ return kRGBA_F16_SkColorType;
+ }
+ return kN32_SkColorType;
}
SkAlphaType SkAndroidCodec::computeOutputAlphaType(bool requestedUnpremul) {
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)) {
diff --git a/src/codec/SkFrameHolder.h b/src/codec/SkFrameHolder.h
index 29539ff908..ab308b39db 100644
--- a/src/codec/SkFrameHolder.h
+++ b/src/codec/SkFrameHolder.h
@@ -40,14 +40,14 @@ public:
int frameId() const { return fId; }
/**
- * Whether this frame reports alpha.
+ * How this frame reports its alpha.
*
* This only considers the rectangle of this frame, and
* considers it to have alpha even if it is opaque once
* blended with the frame behind it.
*/
- bool reportsAlpha() const {
- return this->onReportsAlpha();
+ SkEncodedInfo::Alpha reportedAlpha() const {
+ return this->onReportedAlpha();
}
/**
@@ -130,7 +130,7 @@ public:
}
protected:
- virtual bool onReportsAlpha() const = 0;
+ virtual SkEncodedInfo::Alpha onReportedAlpha() const = 0;
private:
static constexpr int kUninitialized = -2;
@@ -166,7 +166,7 @@ public:
/**
* Compute the opacity and required frame, based on
- * whether the frame reportsAlpha and how it blends
+ * the frame's reportedAlpha and how it blends
* with prior frames.
*/
void setAlphaAndRequiredFrame(SkFrame*);
diff --git a/src/codec/SkGifCodec.cpp b/src/codec/SkGifCodec.cpp
index 17c8617500..dff8136d75 100644
--- a/src/codec/SkGifCodec.cpp
+++ b/src/codec/SkGifCodec.cpp
@@ -144,8 +144,8 @@ bool SkGifCodec::onGetFrameInfo(int i, SkCodec::FrameInfo* frameInfo) const {
frameInfo->fDuration = frameContext->getDuration();
frameInfo->fRequiredFrame = frameContext->getRequiredFrame();
frameInfo->fFullyReceived = frameContext->isComplete();
- frameInfo->fAlpha = frameContext->hasAlpha() ? SkEncodedInfo::kBinary_Alpha
- : SkEncodedInfo::kOpaque_Alpha;
+ frameInfo->fAlphaType = frameContext->hasAlpha() ? kUnpremul_SkAlphaType
+ : kOpaque_SkAlphaType;
frameInfo->fDisposalMethod = frameContext->getDisposalMethod();
}
return true;
diff --git a/src/codec/SkHeifCodec.h b/src/codec/SkHeifCodec.h
index 6eb8e9c3b8..20bec6539e 100644
--- a/src/codec/SkHeifCodec.h
+++ b/src/codec/SkHeifCodec.h
@@ -47,7 +47,7 @@ protected:
return SkEncodedImageFormat::kHEIF;
}
- bool conversionSupported(const SkImageInfo&, SkEncodedInfo::Color, bool,
+ bool conversionSupported(const SkImageInfo&, SkColorType, bool,
const SkColorSpace*) const override {
// This class checks for conversion after creating colorXform.
return true;
diff --git a/src/codec/SkIcoCodec.h b/src/codec/SkIcoCodec.h
index 06ddeba9b4..c43fcf8cc0 100644
--- a/src/codec/SkIcoCodec.h
+++ b/src/codec/SkIcoCodec.h
@@ -48,7 +48,7 @@ protected:
SkScanlineOrder onGetScanlineOrder() const override;
- bool conversionSupported(const SkImageInfo&, SkEncodedInfo::Color, bool,
+ bool conversionSupported(const SkImageInfo&, SkColorType, bool,
const SkColorSpace*) const override {
// This will be checked by the embedded codec.
return true;
diff --git a/src/codec/SkJpegCodec.h b/src/codec/SkJpegCodec.h
index 41814d2ead..7fab209b6e 100644
--- a/src/codec/SkJpegCodec.h
+++ b/src/codec/SkJpegCodec.h
@@ -58,7 +58,7 @@ protected:
bool onDimensionsSupported(const SkISize&) override;
- bool conversionSupported(const SkImageInfo&, SkEncodedInfo::Color, bool,
+ bool conversionSupported(const SkImageInfo&, SkColorType, bool,
const SkColorSpace*) const override {
// This class checks for conversion after creating colorXform.
return true;
diff --git a/src/codec/SkWbmpCodec.cpp b/src/codec/SkWbmpCodec.cpp
index 63380e109c..d8b10287f6 100644
--- a/src/codec/SkWbmpCodec.cpp
+++ b/src/codec/SkWbmpCodec.cpp
@@ -108,7 +108,7 @@ SkEncodedImageFormat SkWbmpCodec::onGetEncodedFormat() const {
return SkEncodedImageFormat::kWBMP;
}
-bool SkWbmpCodec::conversionSupported(const SkImageInfo& dst, SkEncodedInfo::Color srcColor,
+bool SkWbmpCodec::conversionSupported(const SkImageInfo& dst, SkColorType /*srcColor*/,
bool srcIsOpaque, const SkColorSpace* srcCS) const {
return valid_color_type(dst) && valid_alpha(dst.alphaType(), srcIsOpaque);
}
diff --git a/src/codec/SkWbmpCodec.h b/src/codec/SkWbmpCodec.h
index 57efe21e3b..192189d1ec 100644
--- a/src/codec/SkWbmpCodec.h
+++ b/src/codec/SkWbmpCodec.h
@@ -28,7 +28,7 @@ protected:
Result onGetPixels(const SkImageInfo&, void*, size_t,
const Options&, int*) override;
bool onRewind() override;
- bool conversionSupported(const SkImageInfo& dst, SkEncodedInfo::Color srcColor,
+ bool conversionSupported(const SkImageInfo& dst, SkColorType srcColor,
bool srcIsOpaque, const SkColorSpace* srcCS) const override;
// No need to Xform; all pixels are either black or white.
bool usesColorXform() const override { return false; }
diff --git a/src/codec/SkWebpCodec.cpp b/src/codec/SkWebpCodec.cpp
index d5614d6213..2ff4681337 100644
--- a/src/codec/SkWebpCodec.cpp
+++ b/src/codec/SkWebpCodec.cpp
@@ -192,7 +192,8 @@ static WEBP_CSP_MODE webp_decode_mode(SkColorType dstCT, bool premultiply) {
SkWebpCodec::Frame* SkWebpCodec::FrameHolder::appendNewFrame(bool hasAlpha) {
const int i = this->size();
- fFrames.emplace_back(i, hasAlpha);
+ fFrames.emplace_back(i, hasAlpha ? SkEncodedInfo::kUnpremul_Alpha
+ : SkEncodedInfo::kOpaque_Alpha);
return &fFrames[i];
}
@@ -300,8 +301,8 @@ bool SkWebpCodec::onGetFrameInfo(int i, FrameInfo* frameInfo) const {
// libwebp only reports fully received frames for an
// animated image.
frameInfo->fFullyReceived = true;
- frameInfo->fAlpha = frame->hasAlpha() ? SkEncodedInfo::kUnpremul_Alpha
- : SkEncodedInfo::kOpaque_Alpha;
+ frameInfo->fAlphaType = frame->hasAlpha() ? kUnpremul_SkAlphaType
+ : kOpaque_SkAlphaType;
frameInfo->fDisposalMethod = frame->getDisposalMethod();
}
diff --git a/src/codec/SkWebpCodec.h b/src/codec/SkWebpCodec.h
index 134dafa3d5..010771bcff 100644
--- a/src/codec/SkWebpCodec.h
+++ b/src/codec/SkWebpCodec.h
@@ -58,22 +58,22 @@ private:
class Frame : public SkFrame {
public:
- Frame(int i, bool alpha)
+ Frame(int i, SkEncodedInfo::Alpha alpha)
: INHERITED(i)
- , fReportsAlpha(alpha)
+ , fReportedAlpha(alpha)
{}
Frame(Frame&& other)
: INHERITED(other.frameId())
- , fReportsAlpha(other.fReportsAlpha)
+ , fReportedAlpha(other.fReportedAlpha)
{}
protected:
- bool onReportsAlpha() const override {
- return fReportsAlpha;
+ SkEncodedInfo::Alpha onReportedAlpha() const override {
+ return fReportedAlpha;
}
private:
- const bool fReportsAlpha;
+ const SkEncodedInfo::Alpha fReportedAlpha;
typedef SkFrame INHERITED;
};