Revert "Hide SkEncodedInfo"

This reverts commit c6f7a4ffa9.

Reason for revert: Causing differences in Gold, stemming from the fact that this changes the recommended SkImageInfo for 16 bits-per-component PNG from N32 to F16.
- an F16 bitmap already png-encodes to a 16 bits-per-component PNG, but it does not encode a linear colorspace (possibly a bug?). when we decode this PNG using getInfo(), it fails because it has an F16 color type and non-linear colorspace. (In the encode-srgb-png gm, this results in blank results for F16.) We could correct this on the encoder side, but it seems possible that a 16 bits-per-component PNG could be encoded with a different color space. In that case, we'd want SkCodec to recommend F16/SRGBLinear, but I think we'd want the SkCodec to store the encoded SkColorSpace so that we can Xform between the two. Currently SkCodec only stores one color space, so that will require a refactor.
- When decoding 16-bits-per-component PNGs, we are now decoding them to F16. This shows differences in Gold. The srgb/gpu results now look more like F16. I think this is fine.

Original change's description:
> 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>

TBR=mtklein@chromium.org,scroggo@google.com,reed@google.com

Change-Id: I0c5dd1461e1b70d1e55349a8e7ee6b029c3f556e
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:7353, skia:6839
Reviewed-on: https://skia-review.googlesource.com/80660
Reviewed-by: Leon Scroggins <scroggo@google.com>
Commit-Queue: Leon Scroggins <scroggo@google.com>
This commit is contained in:
Leon Scroggins 2017-12-05 15:38:14 +00:00 committed by Skia Commit-Bot
parent a2e7f5ae10
commit 1793e7bb46
20 changed files with 102 additions and 109 deletions

View File

@ -731,7 +731,7 @@ static void push_codec_srcs(Path path) {
};
for (const char* brdExt : brdExts) {
if (0 == strcmp(brdExt, ext)) {
bool gray = codec->getInfo().colorType() == kGray_8_SkColorType;
bool gray = codec->getEncodedInfo().color() == SkEncodedInfo::kGray_Color;
push_brd_srcs(path, gray);
break;
}

View File

@ -35,7 +35,6 @@ tests_sources = [
"$_tests/CodecAnimTest.cpp",
"$_tests/CodecExactReadTest.cpp",
"$_tests/CodecPartialTest.cpp",
"$_tests/CodecRecommendedTypeTest.cpp",
"$_tests/CodecTest.cpp",
"$_tests/ColorFilterTest.cpp",
"$_tests/ColorMatrixTest.cpp",

View File

@ -43,6 +43,8 @@ public:
virtual ~SkAndroidCodec();
const SkEncodedInfo& getEncodedInfo() const;
const SkImageInfo& getInfo() const { return fInfo; }
/**

View File

@ -9,11 +9,11 @@
#define SkCodec_DEFINED
#include "../private/SkTemplates.h"
#include "../private/SkEncodedInfo.h"
#include "SkCodecAnimation.h"
#include "SkColor.h"
#include "SkColorSpaceXform.h"
#include "SkEncodedImageFormat.h"
#include "SkEncodedInfo.h"
#include "SkEncodedOrigin.h"
#include "SkImageInfo.h"
#include "SkPixmap.h"
@ -169,6 +169,8 @@ public:
*/
const SkImageInfo& getInfo() const { return fSrcInfo; }
const SkEncodedInfo& getEncodedInfo() const { return fEncodedInfo; }
/**
* Returns the image orientation stored in the EXIF data.
* If there is no EXIF data, or if we cannot read the EXIF data, returns kTopLeft.
@ -610,7 +612,7 @@ public:
* This is conservative; it will still return non-opaque if e.g. a
* color index-based frame has a color with alpha but does not use it.
*/
SkAlphaType fAlphaType;
SkEncodedInfo::Alpha fAlpha;
/**
* How this frame should be modified before decoding the next one.
@ -660,8 +662,6 @@ public:
}
protected:
const SkEncodedInfo& getEncodedInfo() const { return fEncodedInfo; }
using XformFormat = SkColorSpaceXform::ColorFormat;
SkCodec(int width,
@ -847,7 +847,7 @@ private:
*
* Will be called for the appropriate frame, prior to initializing the colorXform.
*/
virtual bool conversionSupported(const SkImageInfo& dst, SkColorType srcColor,
virtual bool conversionSupported(const SkImageInfo& dst, SkEncodedInfo::Color srcColor,
bool srcIsOpaque, const SkColorSpace* srcCS) const;
/**
* Return whether these dimensions are supported as a scale.

View File

@ -118,12 +118,40 @@ public:
* closest possible match to the encoded info.
*/
SkImageInfo makeImageInfo(int width, int height, sk_sp<SkColorSpace> colorSpace) const {
auto ct = kGray_Color == fColor ? kGray_8_SkColorType :
fBitsPerComponent > 8 ? kRGBA_F16_SkColorType :
kN32_SkColorType ;
auto alpha = kOpaque_Alpha == fAlpha ? kOpaque_SkAlphaType
: kUnpremul_SkAlphaType;
return SkImageInfo::Make(width, height, ct, alpha, std::move(colorSpace));
switch (fColor) {
case kGray_Color:
SkASSERT(kOpaque_Alpha == fAlpha);
return SkImageInfo::Make(width, height, kGray_8_SkColorType,
kOpaque_SkAlphaType, colorSpace);
case kGrayAlpha_Color:
SkASSERT(kOpaque_Alpha != fAlpha);
return SkImageInfo::Make(width, height, kN32_SkColorType,
kUnpremul_SkAlphaType, colorSpace);
case kPalette_Color: {
SkAlphaType alphaType = (kOpaque_Alpha == fAlpha) ? kOpaque_SkAlphaType :
kUnpremul_SkAlphaType;
return SkImageInfo::Make(width, height, kN32_SkColorType,
alphaType, colorSpace);
}
case kRGB_Color:
case kBGR_Color:
case kBGRX_Color:
case kYUV_Color:
case kInvertedCMYK_Color:
case kYCCK_Color:
SkASSERT(kOpaque_Alpha == fAlpha);
return SkImageInfo::Make(width, height, kN32_SkColorType,
kOpaque_SkAlphaType, colorSpace);
case kRGBA_Color:
case kBGRA_Color:
case kYUVA_Color:
SkASSERT(kOpaque_Alpha != fAlpha);
return SkImageInfo::Make(width, height, kN32_SkColorType,
kUnpremul_SkAlphaType, std::move(colorSpace));
default:
SkASSERT(false);
return SkImageInfo::MakeUnknown();
}
}
Color color() const { return fColor; }

View File

@ -64,6 +64,10 @@ 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) {
@ -108,6 +112,7 @@ 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;
@ -133,10 +138,8 @@ SkColorType SkAndroidCodec::computeOutputColorType(SkColorType requestedColorTyp
break;
}
if (this->getInfo().colorType() == kRGBA_F16_SkColorType) {
return kRGBA_F16_SkColorType;
}
return kN32_SkColorType;
// F16 is the Android default for high precision images.
return highPrecision ? kRGBA_F16_SkColorType : kN32_SkColorType;
}
SkAlphaType SkAndroidCodec::computeOutputAlphaType(bool requestedUnpremul) {

View File

@ -158,7 +158,7 @@ SkCodec::SkCodec(const SkEncodedInfo& info, const SkImageInfo& imageInfo,
SkCodec::~SkCodec() {}
bool SkCodec::conversionSupported(const SkImageInfo& dst, SkColorType srcColor,
bool SkCodec::conversionSupported(const SkImageInfo& dst, SkEncodedInfo::Color 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, SkColorType srcColor,
case kRGB_565_SkColorType:
return srcIsOpaque;
case kGray_8_SkColorType:
return kGray_8_SkColorType == srcColor && srcIsOpaque &&
return SkEncodedInfo::kGray_Color == 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, fSrcInfo.colorType(), fEncodedInfo.opaque(),
if (!this->conversionSupported(info, fEncodedInfo.color(), 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, fSrcInfo.colorType(), !frame->hasAlpha(),
if (!this->conversionSupported(info, fEncodedInfo.color(), !frame->hasAlpha(),
fSrcInfo.colorSpace())) {
return kInvalidConversion;
}
@ -297,7 +297,9 @@ SkCodec::Result SkCodec::handleFrameIndex(const SkImageInfo& info, void* pixels,
}
}
return this->initializeColorXform(info, frame->reportedAlpha(), options.fPremulBehavior)
FrameInfo frameInfo;
SkAssertResult(this->getFrameInfo(index, &frameInfo));
return this->initializeColorXform(info, frameInfo.fAlpha, options.fPremulBehavior)
? kSuccess : kInvalidConversion;
}
@ -628,10 +630,6 @@ 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)) {

View File

@ -40,14 +40,14 @@ public:
int frameId() const { return fId; }
/**
* How this frame reports its alpha.
* Whether this frame reports 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.
*/
SkEncodedInfo::Alpha reportedAlpha() const {
return this->onReportedAlpha();
bool reportsAlpha() const {
return this->onReportsAlpha();
}
/**
@ -130,7 +130,7 @@ public:
}
protected:
virtual SkEncodedInfo::Alpha onReportedAlpha() const = 0;
virtual bool onReportsAlpha() const = 0;
private:
static constexpr int kUninitialized = -2;
@ -166,7 +166,7 @@ public:
/**
* Compute the opacity and required frame, based on
* the frame's reportedAlpha and how it blends
* whether the frame reportsAlpha and how it blends
* with prior frames.
*/
void setAlphaAndRequiredFrame(SkFrame*);

View File

@ -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->fAlphaType = frameContext->hasAlpha() ? kUnpremul_SkAlphaType
: kOpaque_SkAlphaType;
frameInfo->fAlpha = frameContext->hasAlpha() ? SkEncodedInfo::kBinary_Alpha
: SkEncodedInfo::kOpaque_Alpha;
frameInfo->fDisposalMethod = frameContext->getDisposalMethod();
}
return true;

View File

@ -47,7 +47,7 @@ protected:
return SkEncodedImageFormat::kHEIF;
}
bool conversionSupported(const SkImageInfo&, SkColorType, bool,
bool conversionSupported(const SkImageInfo&, SkEncodedInfo::Color, bool,
const SkColorSpace*) const override {
// This class checks for conversion after creating colorXform.
return true;

View File

@ -48,7 +48,7 @@ protected:
SkScanlineOrder onGetScanlineOrder() const override;
bool conversionSupported(const SkImageInfo&, SkColorType, bool,
bool conversionSupported(const SkImageInfo&, SkEncodedInfo::Color, bool,
const SkColorSpace*) const override {
// This will be checked by the embedded codec.
return true;

View File

@ -58,7 +58,7 @@ protected:
bool onDimensionsSupported(const SkISize&) override;
bool conversionSupported(const SkImageInfo&, SkColorType, bool,
bool conversionSupported(const SkImageInfo&, SkEncodedInfo::Color, bool,
const SkColorSpace*) const override {
// This class checks for conversion after creating colorXform.
return true;

View File

@ -108,7 +108,7 @@ SkEncodedImageFormat SkWbmpCodec::onGetEncodedFormat() const {
return SkEncodedImageFormat::kWBMP;
}
bool SkWbmpCodec::conversionSupported(const SkImageInfo& dst, SkColorType /*srcColor*/,
bool SkWbmpCodec::conversionSupported(const SkImageInfo& dst, SkEncodedInfo::Color srcColor,
bool srcIsOpaque, const SkColorSpace* srcCS) const {
return valid_color_type(dst) && valid_alpha(dst.alphaType(), srcIsOpaque);
}

View File

@ -28,7 +28,7 @@ protected:
Result onGetPixels(const SkImageInfo&, void*, size_t,
const Options&, int*) override;
bool onRewind() override;
bool conversionSupported(const SkImageInfo& dst, SkColorType srcColor,
bool conversionSupported(const SkImageInfo& dst, SkEncodedInfo::Color 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; }

View File

@ -192,8 +192,7 @@ 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 ? SkEncodedInfo::kUnpremul_Alpha
: SkEncodedInfo::kOpaque_Alpha);
fFrames.emplace_back(i, hasAlpha);
return &fFrames[i];
}
@ -301,8 +300,8 @@ bool SkWebpCodec::onGetFrameInfo(int i, FrameInfo* frameInfo) const {
// libwebp only reports fully received frames for an
// animated image.
frameInfo->fFullyReceived = true;
frameInfo->fAlphaType = frame->hasAlpha() ? kUnpremul_SkAlphaType
: kOpaque_SkAlphaType;
frameInfo->fAlpha = frame->hasAlpha() ? SkEncodedInfo::kUnpremul_Alpha
: SkEncodedInfo::kOpaque_Alpha;
frameInfo->fDisposalMethod = frame->getDisposalMethod();
}

View File

@ -58,22 +58,22 @@ private:
class Frame : public SkFrame {
public:
Frame(int i, SkEncodedInfo::Alpha alpha)
Frame(int i, bool alpha)
: INHERITED(i)
, fReportedAlpha(alpha)
, fReportsAlpha(alpha)
{}
Frame(Frame&& other)
: INHERITED(other.frameId())
, fReportedAlpha(other.fReportedAlpha)
, fReportsAlpha(other.fReportsAlpha)
{}
protected:
SkEncodedInfo::Alpha onReportedAlpha() const override {
return fReportedAlpha;
bool onReportsAlpha() const override {
return fReportsAlpha;
}
private:
const SkEncodedInfo::Alpha fReportedAlpha;
const bool fReportsAlpha;
typedef SkFrame INHERITED;
};

View File

@ -67,8 +67,9 @@ static bool restore_previous(const SkCodec::FrameInfo& info) {
}
DEF_TEST(Codec_frames, r) {
#define kOpaque kOpaque_SkAlphaType
#define kUnpremul kUnpremul_SkAlphaType
#define kOpaque SkEncodedInfo::kOpaque_Alpha
#define kUnpremul SkEncodedInfo::kUnpremul_Alpha
#define kBinary SkEncodedInfo::kBinary_Alpha
#define kKeep SkCodecAnimation::DisposalMethod::kKeep
#define kRestoreBG SkCodecAnimation::DisposalMethod::kRestoreBGColor
#define kRestorePrev SkCodecAnimation::DisposalMethod::kRestorePrevious
@ -78,8 +79,8 @@ DEF_TEST(Codec_frames, r) {
// One less than fFramecount, since the first frame is always
// independent.
std::vector<int> fRequiredFrames;
// Same, since the first frame should match getInfo
std::vector<SkAlphaType> fAlphas;
// Same, since the first frame should match getEncodedInfo
std::vector<SkEncodedInfo::Alpha> fAlphas;
// The size of this one should match fFrameCount for animated, empty
// otherwise.
std::vector<int> fDurations;
@ -88,15 +89,15 @@ DEF_TEST(Codec_frames, r) {
} gRecs[] = {
{ "required.gif", 7,
{ 0, 1, 2, 3, 4, 5 },
{ kOpaque, kUnpremul, kUnpremul, kUnpremul, kUnpremul, kUnpremul },
{ kOpaque, kBinary, kBinary, kBinary, kBinary, kBinary },
{ 100, 100, 100, 100, 100, 100, 100 },
0,
{ kKeep, kRestoreBG, kKeep, kKeep, kKeep, kRestoreBG, kKeep } },
{ "alphabetAnim.gif", 13,
{ SkCodec::kNone, 0, 0, 0, 0, 5, 6, SkCodec::kNone,
SkCodec::kNone, 9, 10, 11 },
{ kUnpremul, kUnpremul, kUnpremul, kUnpremul, kUnpremul, kUnpremul,
kUnpremul, kUnpremul, kUnpremul, kUnpremul, kUnpremul, kUnpremul },
{ kBinary, kBinary, kBinary, kBinary, kBinary, kBinary,
kBinary, kBinary, kBinary, kBinary, kBinary, kBinary },
{ 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100 },
0,
{ kKeep, kRestorePrev, kRestorePrev, kRestorePrev, kRestorePrev,
@ -115,8 +116,8 @@ DEF_TEST(Codec_frames, r) {
{ "randPixelsAnim.gif", 13,
// required frames
{ 0, 1, 2, 3, 4, 3, 6, 7, 7, 7, 9, 9 },
{ kUnpremul, kUnpremul, kUnpremul, kUnpremul, kUnpremul, kUnpremul,
kUnpremul, kUnpremul, kUnpremul, kUnpremul, kUnpremul, kUnpremul },
{ kBinary, kBinary, kBinary, kBinary, kBinary, kBinary,
kBinary, kBinary, kBinary, kBinary, kBinary, kBinary },
// durations
{ 0, 1000, 170, 40, 220, 7770, 90, 90, 90, 90, 90, 90, 90 },
// repetition count
@ -160,6 +161,7 @@ DEF_TEST(Codec_frames, r) {
};
#undef kOpaque
#undef kUnpremul
#undef kBinary
#undef kKeep
#undef kRestorePrev
#undef kRestoreBG
@ -268,20 +270,22 @@ DEF_TEST(Codec_frames, r) {
rec.fName, i, rec.fDurations[i], frameInfo.fDuration);
}
auto to_string = [](SkAlphaType alpha) {
auto to_string = [](SkEncodedInfo::Alpha alpha) {
switch (alpha) {
case kUnpremul_SkAlphaType:
case SkEncodedInfo::kUnpremul_Alpha:
return "unpremul";
case kOpaque_SkAlphaType:
case SkEncodedInfo::kOpaque_Alpha:
return "opaque";
case SkEncodedInfo::kBinary_Alpha:
return "binary";
default:
SkASSERT(false);
return "unknown";
}
};
auto expectedAlpha = 0 == i ? codec->getInfo().alphaType() : rec.fAlphas[i-1];
auto alpha = frameInfo.fAlphaType;
auto expectedAlpha = 0 == i ? codec->getEncodedInfo().alpha() : rec.fAlphas[i-1];
auto alpha = frameInfo.fAlpha;
if (expectedAlpha != alpha) {
ERRORF(r, "%s's frame %i has wrong alpha type! expected: %s\tactual: %s",
rec.fName, i, to_string(expectedAlpha), to_string(alpha));
@ -315,7 +319,9 @@ DEF_TEST(Codec_frames, r) {
auto decode = [&](SkBitmap* bm, int index, int cachedIndex) {
auto decodeInfo = info;
if (index > 0) {
decodeInfo = info.makeAlphaType(frameInfos[index].fAlphaType);
auto alphaType = frameInfos[index].fAlpha == SkEncodedInfo::kOpaque_Alpha
? kOpaque_SkAlphaType : kPremul_SkAlphaType;
decodeInfo = info.makeAlphaType(alphaType);
}
bm->allocPixels(decodeInfo);
if (cachedIndex != SkCodec::kNone) {

View File

@ -1,41 +0,0 @@
/*
* Copyright 2017 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "SkAndroidCodec.h"
#include "SkBitmap.h"
#include "SkCodec.h"
#include "SkColorSpace.h"
#include "SkEncodedImageFormat.h"
#include "SkImageEncoder.h"
#include "SkImageInfo.h"
#include "SkStream.h"
#include "Test.h"
DEF_TEST(Codec_recommendedF16, r) {
// Encode an F16 bitmap. SkEncodeImage will encode this to a true-color PNG
// with a bit depth of 16. SkAndroidCodec should always recommend F16 for
// such a PNG.
SkBitmap bm;
bm.allocPixels(SkImageInfo::Make(10, 10, kRGBA_F16_SkColorType,
kPremul_SkAlphaType, SkColorSpace::MakeSRGBLinear()));
// What is drawn is not important.
bm.eraseColor(SK_ColorBLUE);
SkDynamicMemoryWStream wstream;
REPORTER_ASSERT(r, SkEncodeImage(&wstream, bm, SkEncodedImageFormat::kPNG, 100));
auto data = wstream.detachAsData();
auto androidCodec = SkAndroidCodec::MakeFromData(std::move(data));
if (!androidCodec) {
ERRORF(r, "Failed to create SkAndroidCodec");
return;
}
REPORTER_ASSERT(r, androidCodec->getInfo().colorType() == kRGBA_F16_SkColorType);
REPORTER_ASSERT(r, androidCodec->computeOutputColorType(kN32_SkColorType)
== kRGBA_F16_SkColorType);
}

View File

@ -879,16 +879,15 @@ static bool restore_bg(const SkFrame& frame) {
return frame.getDisposalMethod() == SkCodecAnimation::DisposalMethod::kRestoreBGColor;
}
SkEncodedInfo::Alpha SkGIFFrameContext::onReportedAlpha() const {
bool SkGIFFrameContext::onReportsAlpha() const {
// Note: We could correct these after decoding - i.e. some frames may turn out to be
// independent and opaque if they do not use the transparent pixel, but that would require
// checking whether each pixel used the transparent index.
return is_palette_index_valid(this->transparentPixel()) ? SkEncodedInfo::kBinary_Alpha
: SkEncodedInfo::kOpaque_Alpha;
return is_palette_index_valid(this->transparentPixel());
}
void SkFrameHolder::setAlphaAndRequiredFrame(SkFrame* frame) {
const bool reportsAlpha = frame->reportedAlpha() != SkEncodedInfo::kOpaque_Alpha;
const bool reportsAlpha = frame->reportsAlpha();
const auto screenRect = SkIRect::MakeWH(fScreenWidth, fScreenHeight);
const auto frameRect = frame_rect_on_screen(frame->frameRect(), screenRect);

View File

@ -247,7 +247,7 @@ public:
SkGIFColorMap& localColorMap() { return m_localColorMap; }
protected:
SkEncodedInfo::Alpha onReportedAlpha() const override;
bool onReportsAlpha() const override;
private:
int m_transparentPixel; // Index of transparent pixel. Value is kNotFound if there is no transparent pixel.