Remove SkCodec::fSrcInfo
This object is now redundant with fEncodedInfo. It holds an SkColorSpace, which is never used now that SkCodec uses skcms. SkCodec::getInfo() no longer returns a reference, but creates an SkImageInfo from the SkEncodedInfo the same way fSrcInfo was previously created. Add SkCodec::bounds() and ::dimensions() to replace calling these methods on getInfo(). Remove srcInfo from SkMaskSwizzler::Create, which just wants to know whether the src is opaque. Remove the srcColorType from conversionSupported. Only the base class version used it. Make it look at fEncodedInfo.color() instead. Bug: skia:6839 Bug: chromium:887372 Change-Id: I2c0583cae76121211c1a6b49979972fa86daf077 Reviewed-on: https://skia-review.googlesource.com/c/157563 Commit-Queue: Leon Scroggins <scroggo@google.com> Reviewed-by: Mike Reed <reed@google.com> Reviewed-by: Brian Osman <brianosman@google.com>
This commit is contained in:
parent
9e0efe3189
commit
712476ecdb
@ -169,9 +169,14 @@ public:
|
|||||||
virtual ~SkCodec();
|
virtual ~SkCodec();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the ImageInfo associated with this codec.
|
* Return a reasonable SkImageInfo to decode into.
|
||||||
*/
|
*/
|
||||||
const SkImageInfo& getInfo() const { return fSrcInfo; }
|
SkImageInfo getInfo() const { return fEncodedInfo.makeImageInfo(); }
|
||||||
|
|
||||||
|
SkISize dimensions() const { return {fEncodedInfo.width(), fEncodedInfo.height()}; }
|
||||||
|
SkIRect bounds() const {
|
||||||
|
return SkIRect::MakeWH(fEncodedInfo.width(), fEncodedInfo.height());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the image orientation stored in the EXIF data.
|
* Returns the image orientation stored in the EXIF data.
|
||||||
@ -196,7 +201,7 @@ public:
|
|||||||
// Upscaling is not supported. Return the original size if the client
|
// Upscaling is not supported. Return the original size if the client
|
||||||
// requests an upscale.
|
// requests an upscale.
|
||||||
if (desiredScale >= 1.0f) {
|
if (desiredScale >= 1.0f) {
|
||||||
return this->getInfo().dimensions();
|
return this->dimensions();
|
||||||
}
|
}
|
||||||
return this->onGetScaledDimensions(desiredScale);
|
return this->onGetScaledDimensions(desiredScale);
|
||||||
}
|
}
|
||||||
@ -679,7 +684,7 @@ protected:
|
|||||||
|
|
||||||
virtual SkISize onGetScaledDimensions(float /*desiredScale*/) const {
|
virtual SkISize onGetScaledDimensions(float /*desiredScale*/) const {
|
||||||
// By default, scaling is not supported.
|
// By default, scaling is not supported.
|
||||||
return this->getInfo().dimensions();
|
return this->dimensions();
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: What to do about subsets??
|
// FIXME: What to do about subsets??
|
||||||
@ -790,7 +795,6 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
const SkEncodedInfo fEncodedInfo;
|
const SkEncodedInfo fEncodedInfo;
|
||||||
const SkImageInfo fSrcInfo;
|
|
||||||
const XformFormat fSrcXformFormat;
|
const XformFormat fSrcXformFormat;
|
||||||
std::unique_ptr<SkStream> fStream;
|
std::unique_ptr<SkStream> fStream;
|
||||||
bool fNeedsRewind;
|
bool fNeedsRewind;
|
||||||
@ -819,8 +823,8 @@ private:
|
|||||||
*
|
*
|
||||||
* Will be called for the appropriate frame, prior to initializing the colorXform.
|
* 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, bool srcIsOpaque,
|
||||||
bool srcIsOpaque, bool needsColorXform);
|
bool needsColorXform);
|
||||||
|
|
||||||
bool initializeColorXform(const SkImageInfo& dstInfo, SkEncodedInfo::Alpha, bool srcIsOpaque);
|
bool initializeColorXform(const SkImageInfo& dstInfo, SkEncodedInfo::Alpha, bool srcIsOpaque);
|
||||||
|
|
||||||
@ -834,7 +838,7 @@ private:
|
|||||||
* This must return true for a size returned from getScaledDimensions.
|
* This must return true for a size returned from getScaledDimensions.
|
||||||
*/
|
*/
|
||||||
bool dimensionsSupported(const SkISize& dim) {
|
bool dimensionsSupported(const SkISize& dim) {
|
||||||
return dim == fSrcInfo.dimensions() || this->onDimensionsSupported(dim);
|
return dim == this->dimensions() || this->onDimensionsSupported(dim);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -605,7 +605,7 @@ SkBmpCodec::SkBmpCodec(SkEncodedInfo&& info, std::unique_ptr<SkStream> stream,
|
|||||||
: INHERITED(std::move(info), kXformSrcColorFormat, std::move(stream))
|
: INHERITED(std::move(info), kXformSrcColorFormat, std::move(stream))
|
||||||
, fBitsPerPixel(bitsPerPixel)
|
, fBitsPerPixel(bitsPerPixel)
|
||||||
, fRowOrder(rowOrder)
|
, fRowOrder(rowOrder)
|
||||||
, fSrcRowBytes(SkAlign4(compute_row_bytes(this->getEncodedInfo().width(), fBitsPerPixel)))
|
, fSrcRowBytes(SkAlign4(compute_row_bytes(this->dimensions().width(), fBitsPerPixel)))
|
||||||
, fXformBuffer(nullptr)
|
, fXformBuffer(nullptr)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ SkCodec::Result SkBmpMaskCodec::onGetPixels(const SkImageInfo& dstInfo,
|
|||||||
// Subsets are not supported.
|
// Subsets are not supported.
|
||||||
return kUnimplemented;
|
return kUnimplemented;
|
||||||
}
|
}
|
||||||
if (dstInfo.dimensions() != this->getInfo().dimensions()) {
|
if (dstInfo.dimensions() != this->dimensions()) {
|
||||||
SkCodecPrintf("Error: scaling not supported.\n");
|
SkCodecPrintf("Error: scaling not supported.\n");
|
||||||
return kInvalidScale;
|
return kInvalidScale;
|
||||||
}
|
}
|
||||||
@ -64,8 +64,8 @@ SkCodec::Result SkBmpMaskCodec::onPrepareToDecode(const SkImageInfo& dstInfo,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize the mask swizzler
|
bool srcIsOpaque = this->getEncodedInfo().opaque();
|
||||||
fMaskSwizzler.reset(SkMaskSwizzler::CreateMaskSwizzler(swizzlerInfo, this->getInfo(),
|
fMaskSwizzler.reset(SkMaskSwizzler::CreateMaskSwizzler(swizzlerInfo, srcIsOpaque,
|
||||||
fMasks.get(), this->bitsPerPixel(), options));
|
fMasks.get(), this->bitsPerPixel(), options));
|
||||||
SkASSERT(fMaskSwizzler);
|
SkASSERT(fMaskSwizzler);
|
||||||
|
|
||||||
|
@ -275,7 +275,7 @@ SkCodec::Result SkBmpRLECodec::onPrepareToDecode(const SkImageInfo& dstInfo,
|
|||||||
*/
|
*/
|
||||||
int SkBmpRLECodec::decodeRows(const SkImageInfo& info, void* dst, size_t dstRowBytes,
|
int SkBmpRLECodec::decodeRows(const SkImageInfo& info, void* dst, size_t dstRowBytes,
|
||||||
const Options& opts) {
|
const Options& opts) {
|
||||||
const int width = this->getInfo().width();
|
const int width = this->dimensions().width();
|
||||||
int height = info.height();
|
int height = info.height();
|
||||||
|
|
||||||
// Account for sampling.
|
// Account for sampling.
|
||||||
@ -332,7 +332,7 @@ int SkBmpRLECodec::decodeRows(const SkImageInfo& info, void* dst, size_t dstRowB
|
|||||||
|
|
||||||
int SkBmpRLECodec::decodeRLE(const SkImageInfo& dstInfo, void* dst, size_t dstRowBytes) {
|
int SkBmpRLECodec::decodeRLE(const SkImageInfo& dstInfo, void* dst, size_t dstRowBytes) {
|
||||||
// Use the original width to count the number of pixels in each row.
|
// Use the original width to count the number of pixels in each row.
|
||||||
const int width = this->getInfo().width();
|
const int width = this->dimensions().width();
|
||||||
|
|
||||||
// This tells us the number of rows that we are meant to decode.
|
// This tells us the number of rows that we are meant to decode.
|
||||||
const int height = dstInfo.height();
|
const int height = dstInfo.height();
|
||||||
@ -522,9 +522,8 @@ int SkBmpRLECodec::decodeRLE(const SkImageInfo& dstInfo, void* dst, size_t dstRo
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool SkBmpRLECodec::skipRows(int count) {
|
bool SkBmpRLECodec::skipRows(int count) {
|
||||||
const SkImageInfo rowInfo = SkImageInfo::Make(this->getInfo().width(), count, kN32_SkColorType,
|
const SkImageInfo rowInfo = SkImageInfo::Make(this->dimensions().width(), count,
|
||||||
kUnpremul_SkAlphaType);
|
kN32_SkColorType, kUnpremul_SkAlphaType);
|
||||||
|
|
||||||
return count == this->decodeRows(rowInfo, nullptr, 0, this->options());
|
return count == this->decodeRows(rowInfo, nullptr, 0, this->options());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -563,5 +562,5 @@ SkSampler* SkBmpRLECodec::getSampler(bool /*createIfNecessary*/) {
|
|||||||
|
|
||||||
int SkBmpRLECodec::setSampleX(int sampleX){
|
int SkBmpRLECodec::setSampleX(int sampleX){
|
||||||
fSampleX = sampleX;
|
fSampleX = sampleX;
|
||||||
return get_scaled_dimension(this->getInfo().width(), sampleX);
|
return get_scaled_dimension(this->dimensions().width(), sampleX);
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ SkBmpStandardCodec::SkBmpStandardCodec(SkEncodedInfo&& info, std::unique_ptr<SkS
|
|||||||
, fSwizzler(nullptr)
|
, fSwizzler(nullptr)
|
||||||
, fIsOpaque(isOpaque)
|
, fIsOpaque(isOpaque)
|
||||||
, fInIco(inIco)
|
, fInIco(inIco)
|
||||||
, fAndMaskRowBytes(fInIco ? SkAlign4(compute_row_bytes(this->getInfo().width(), 1)) : 0)
|
, fAndMaskRowBytes(fInIco ? SkAlign4(compute_row_bytes(this->dimensions().width(), 1)) : 0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -42,7 +42,7 @@ SkCodec::Result SkBmpStandardCodec::onGetPixels(const SkImageInfo& dstInfo,
|
|||||||
// Subsets are not supported.
|
// Subsets are not supported.
|
||||||
return kUnimplemented;
|
return kUnimplemented;
|
||||||
}
|
}
|
||||||
if (dstInfo.dimensions() != this->getInfo().dimensions()) {
|
if (dstInfo.dimensions() != this->dimensions()) {
|
||||||
SkCodecPrintf("Error: scaling not supported.\n");
|
SkCodecPrintf("Error: scaling not supported.\n");
|
||||||
return kInvalidScale;
|
return kInvalidScale;
|
||||||
}
|
}
|
||||||
@ -265,7 +265,7 @@ int SkBmpStandardCodec::decodeRows(const SkImageInfo& dstInfo, void* dst, size_t
|
|||||||
const size_t currPosition = this->stream()->getPosition();
|
const size_t currPosition = this->stream()->getPosition();
|
||||||
|
|
||||||
// Calculate how many bytes we must skip to reach the AND mask.
|
// Calculate how many bytes we must skip to reach the AND mask.
|
||||||
const int remainingScanlines = this->getInfo().height() - startScanline - height;
|
const int remainingScanlines = this->dimensions().height() - startScanline - height;
|
||||||
const size_t bytesToSkip = remainingScanlines * this->srcRowBytes() +
|
const size_t bytesToSkip = remainingScanlines * this->srcRowBytes() +
|
||||||
startScanline * fAndMaskRowBytes;
|
startScanline * fAndMaskRowBytes;
|
||||||
const size_t subStreamStartPosition = currPosition + bytesToSkip;
|
const size_t subStreamStartPosition = currPosition + bytesToSkip;
|
||||||
@ -303,7 +303,7 @@ void SkBmpStandardCodec::decodeIcoMask(SkStream* stream, const SkImageInfo& dstI
|
|||||||
// We do not need to worry about sampling in the y-dimension because that
|
// We do not need to worry about sampling in the y-dimension because that
|
||||||
// should be handled by SkSampledCodec.
|
// should be handled by SkSampledCodec.
|
||||||
const int sampleX = fSwizzler->sampleX();
|
const int sampleX = fSwizzler->sampleX();
|
||||||
const int sampledWidth = get_scaled_dimension(this->getInfo().width(), sampleX);
|
const int sampledWidth = get_scaled_dimension(this->dimensions().width(), sampleX);
|
||||||
const int srcStartX = get_start_coord(sampleX);
|
const int srcStartX = get_start_coord(sampleX);
|
||||||
|
|
||||||
|
|
||||||
|
@ -128,7 +128,6 @@ std::unique_ptr<SkCodec> SkCodec::MakeFromData(sk_sp<SkData> data, SkPngChunkRea
|
|||||||
SkCodec::SkCodec(SkEncodedInfo&& info, XformFormat srcFormat, std::unique_ptr<SkStream> stream,
|
SkCodec::SkCodec(SkEncodedInfo&& info, XformFormat srcFormat, std::unique_ptr<SkStream> stream,
|
||||||
SkEncodedOrigin origin)
|
SkEncodedOrigin origin)
|
||||||
: fEncodedInfo(std::move(info))
|
: fEncodedInfo(std::move(info))
|
||||||
, fSrcInfo(fEncodedInfo.makeImageInfo())
|
|
||||||
, fSrcXformFormat(srcFormat)
|
, fSrcXformFormat(srcFormat)
|
||||||
, fStream(std::move(stream))
|
, fStream(std::move(stream))
|
||||||
, fNeedsRewind(false)
|
, fNeedsRewind(false)
|
||||||
@ -141,8 +140,7 @@ SkCodec::SkCodec(SkEncodedInfo&& info, XformFormat srcFormat, std::unique_ptr<Sk
|
|||||||
|
|
||||||
SkCodec::~SkCodec() {}
|
SkCodec::~SkCodec() {}
|
||||||
|
|
||||||
bool SkCodec::conversionSupported(const SkImageInfo& dst, SkColorType srcColor,
|
bool SkCodec::conversionSupported(const SkImageInfo& dst, bool srcIsOpaque, bool needsColorXform) {
|
||||||
bool srcIsOpaque, bool needsColorXform) {
|
|
||||||
if (!valid_alpha(dst.alphaType(), srcIsOpaque)) {
|
if (!valid_alpha(dst.alphaType(), srcIsOpaque)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -156,11 +154,11 @@ bool SkCodec::conversionSupported(const SkImageInfo& dst, SkColorType srcColor,
|
|||||||
case kRGB_565_SkColorType:
|
case kRGB_565_SkColorType:
|
||||||
return srcIsOpaque;
|
return srcIsOpaque;
|
||||||
case kGray_8_SkColorType:
|
case kGray_8_SkColorType:
|
||||||
return kGray_8_SkColorType == srcColor && srcIsOpaque;
|
return SkEncodedInfo::kGray_Color == fEncodedInfo.color() && srcIsOpaque;
|
||||||
case kAlpha_8_SkColorType:
|
case kAlpha_8_SkColorType:
|
||||||
// conceptually we can convert anything into alpha_8, but we haven't actually coded
|
// conceptually we can convert anything into alpha_8, but we haven't actually coded
|
||||||
// all of those other conversions yet, so only return true for the case we have codec.
|
// all of those other conversions yet.
|
||||||
return fSrcInfo.colorType() == kAlpha_8_SkColorType;;
|
return SkEncodedInfo::kXAlpha_Color == fEncodedInfo.color();
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -268,7 +266,7 @@ SkCodec::Result SkCodec::handleFrameIndex(const SkImageInfo& info, void* pixels,
|
|||||||
// need to clear, since it must be covered by the desired frame.
|
// need to clear, since it must be covered by the desired frame.
|
||||||
if (options.fPriorFrame == requiredFrame) {
|
if (options.fPriorFrame == requiredFrame) {
|
||||||
SkIRect prevRect = prevFrame->frameRect();
|
SkIRect prevRect = prevFrame->frameRect();
|
||||||
if (!zero_rect(info, pixels, rowBytes, fSrcInfo.dimensions(), prevRect)) {
|
if (!zero_rect(info, pixels, rowBytes, this->dimensions(), prevRect)) {
|
||||||
return kInternalError;
|
return kInternalError;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -288,7 +286,7 @@ SkCodec::Result SkCodec::handleFrameIndex(const SkImageInfo& info, void* pixels,
|
|||||||
const auto disposalMethod = prevFrame->getDisposalMethod();
|
const auto disposalMethod = prevFrame->getDisposalMethod();
|
||||||
if (disposalMethod == SkCodecAnimation::DisposalMethod::kRestoreBGColor) {
|
if (disposalMethod == SkCodecAnimation::DisposalMethod::kRestoreBGColor) {
|
||||||
auto prevRect = prevFrame->frameRect();
|
auto prevRect = prevFrame->frameRect();
|
||||||
if (!zero_rect(info, pixels, rowBytes, fSrcInfo.dimensions(), prevRect)) {
|
if (!zero_rect(info, pixels, rowBytes, this->dimensions(), prevRect)) {
|
||||||
return kInternalError;
|
return kInternalError;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -535,7 +533,7 @@ bool SkCodec::skipScanlines(int countLines) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int SkCodec::outputScanline(int inputScanline) const {
|
int SkCodec::outputScanline(int inputScanline) const {
|
||||||
SkASSERT(0 <= inputScanline && inputScanline < this->getInfo().height());
|
SkASSERT(0 <= inputScanline && inputScanline < fEncodedInfo.height());
|
||||||
return this->onOutputScanline(inputScanline);
|
return this->onOutputScanline(inputScanline);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -544,7 +542,7 @@ int SkCodec::onOutputScanline(int inputScanline) const {
|
|||||||
case kTopDown_SkScanlineOrder:
|
case kTopDown_SkScanlineOrder:
|
||||||
return inputScanline;
|
return inputScanline;
|
||||||
case kBottomUp_SkScanlineOrder:
|
case kBottomUp_SkScanlineOrder:
|
||||||
return this->getInfo().height() - inputScanline - 1;
|
return fEncodedInfo.height() - inputScanline - 1;
|
||||||
default:
|
default:
|
||||||
// This case indicates an interlaced gif and is implemented by SkGifCodec.
|
// This case indicates an interlaced gif and is implemented by SkGifCodec.
|
||||||
SkASSERT(false);
|
SkASSERT(false);
|
||||||
@ -642,7 +640,7 @@ bool SkCodec::initializeColorXform(const SkImageInfo& dstInfo, SkEncodedInfo::Al
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this->conversionSupported(dstInfo, fSrcInfo.colorType(), srcIsOpaque, needsColorXform)) {
|
if (!this->conversionSupported(dstInfo, srcIsOpaque, needsColorXform)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -282,7 +282,7 @@ SkCodec::Result SkGifCodec::onGetPixels(const SkImageInfo& dstInfo,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dstInfo.dimensions() != this->getInfo().dimensions()) {
|
if (dstInfo.dimensions() != this->dimensions()) {
|
||||||
return gif_error("Scaling not supported.\n", kInvalidScale);
|
return gif_error("Scaling not supported.\n", kInvalidScale);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -341,7 +341,7 @@ SkCodec::Result SkGifCodec::decodeFrame(bool firstAttempt, const Options& opts,
|
|||||||
// cover all rows? If so, we do not have to fill here.)
|
// cover all rows? If so, we do not have to fill here.)
|
||||||
// - There is no color table for this frame. In that case will not
|
// - There is no color table for this frame. In that case will not
|
||||||
// draw anything, so we need to fill.
|
// draw anything, so we need to fill.
|
||||||
if (frameContext->frameRect() != this->getInfo().bounds()
|
if (frameContext->frameRect() != this->bounds()
|
||||||
|| frameContext->interlaced() || !fCurrColorTableIsReal) {
|
|| frameContext->interlaced() || !fCurrColorTableIsReal) {
|
||||||
// fill ignores the width (replaces it with the actual, scaled width).
|
// fill ignores the width (replaces it with the actual, scaled width).
|
||||||
// But we need to scale in Y.
|
// But we need to scale in Y.
|
||||||
@ -423,8 +423,8 @@ void SkGifCodec::haveDecodedRow(int frameIndex, const unsigned char* rowBegin,
|
|||||||
const int width = frameContext->width();
|
const int width = frameContext->width();
|
||||||
const int xBegin = frameContext->xOffset();
|
const int xBegin = frameContext->xOffset();
|
||||||
const int yBegin = frameContext->yOffset() + rowNumber;
|
const int yBegin = frameContext->yOffset() + rowNumber;
|
||||||
const int xEnd = std::min(xBegin + width, this->getInfo().width());
|
const int xEnd = std::min(xBegin + width, this->dimensions().width());
|
||||||
const int yEnd = std::min(yBegin + rowNumber + repeatCount, this->getInfo().height());
|
const int yEnd = std::min(yBegin + rowNumber + repeatCount, this->dimensions().height());
|
||||||
// FIXME: No need to make the checks on width/xBegin/xEnd for every row. We could instead do
|
// FIXME: No need to make the checks on width/xBegin/xEnd for every row. We could instead do
|
||||||
// this once in prepareToDecode.
|
// this once in prepareToDecode.
|
||||||
if (!width || (xBegin < 0) || (yBegin < 0) || (xEnd <= xBegin) || (yEnd <= yBegin))
|
if (!width || (xBegin < 0) || (yBegin < 0) || (xEnd <= xBegin) || (yEnd <= yBegin))
|
||||||
|
@ -161,8 +161,8 @@ SkHeifCodec::SkHeifCodec(SkEncodedInfo&& info, HeifDecoder* heifDecoder, SkEncod
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
bool SkHeifCodec::conversionSupported(const SkImageInfo& dstInfo, SkColorType /*srcColorType*/,
|
bool SkHeifCodec::conversionSupported(const SkImageInfo& dstInfo, bool srcIsOpaque,
|
||||||
bool srcIsOpaque, bool needsColorXform) {
|
bool needsColorXform) {
|
||||||
SkASSERT(srcIsOpaque);
|
SkASSERT(srcIsOpaque);
|
||||||
|
|
||||||
if (kUnknown_SkAlphaType == dstInfo.alphaType()) {
|
if (kUnknown_SkAlphaType == dstInfo.alphaType()) {
|
||||||
|
@ -41,7 +41,7 @@ protected:
|
|||||||
return SkEncodedImageFormat::kHEIF;
|
return SkEncodedImageFormat::kHEIF;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool conversionSupported(const SkImageInfo&, SkColorType, bool, bool) override;
|
bool conversionSupported(const SkImageInfo&, bool, bool) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/*
|
/*
|
||||||
|
@ -203,15 +203,16 @@ SkISize SkIcoCodec::onGetScaledDimensions(float desiredScale) const {
|
|||||||
// We set the dimensions to the largest candidate image by default.
|
// We set the dimensions to the largest candidate image by default.
|
||||||
// Regardless of the scale request, this is the largest image that we
|
// Regardless of the scale request, this is the largest image that we
|
||||||
// will decode.
|
// will decode.
|
||||||
int origWidth = this->getInfo().width();
|
int origWidth = this->dimensions().width();
|
||||||
int origHeight = this->getInfo().height();
|
int origHeight = this->dimensions().height();
|
||||||
float desiredSize = desiredScale * origWidth * origHeight;
|
float desiredSize = desiredScale * origWidth * origHeight;
|
||||||
// At least one image will have smaller error than this initial value
|
// At least one image will have smaller error than this initial value
|
||||||
float minError = ((float) (origWidth * origHeight)) - desiredSize + 1.0f;
|
float minError = ((float) (origWidth * origHeight)) - desiredSize + 1.0f;
|
||||||
int32_t minIndex = -1;
|
int32_t minIndex = -1;
|
||||||
for (int32_t i = 0; i < fEmbeddedCodecs->count(); i++) {
|
for (int32_t i = 0; i < fEmbeddedCodecs->count(); i++) {
|
||||||
int width = fEmbeddedCodecs->operator[](i)->getInfo().width();
|
auto dimensions = fEmbeddedCodecs->operator[](i)->dimensions();
|
||||||
int height = fEmbeddedCodecs->operator[](i)->getInfo().height();
|
int width = dimensions.width();
|
||||||
|
int height = dimensions.height();
|
||||||
float error = SkTAbs(((float) (width * height)) - desiredSize);
|
float error = SkTAbs(((float) (width * height)) - desiredSize);
|
||||||
if (error < minError) {
|
if (error < minError) {
|
||||||
minError = error;
|
minError = error;
|
||||||
@ -220,7 +221,7 @@ SkISize SkIcoCodec::onGetScaledDimensions(float desiredScale) const {
|
|||||||
}
|
}
|
||||||
SkASSERT(minIndex >= 0);
|
SkASSERT(minIndex >= 0);
|
||||||
|
|
||||||
return fEmbeddedCodecs->operator[](minIndex)->getInfo().dimensions();
|
return fEmbeddedCodecs->operator[](minIndex)->dimensions();
|
||||||
}
|
}
|
||||||
|
|
||||||
int SkIcoCodec::chooseCodec(const SkISize& requestedSize, int startIndex) {
|
int SkIcoCodec::chooseCodec(const SkISize& requestedSize, int startIndex) {
|
||||||
@ -228,7 +229,7 @@ int SkIcoCodec::chooseCodec(const SkISize& requestedSize, int startIndex) {
|
|||||||
|
|
||||||
// FIXME: Cache the index from onGetScaledDimensions?
|
// FIXME: Cache the index from onGetScaledDimensions?
|
||||||
for (int i = startIndex; i < fEmbeddedCodecs->count(); i++) {
|
for (int i = startIndex; i < fEmbeddedCodecs->count(); i++) {
|
||||||
if (fEmbeddedCodecs->operator[](i)->getInfo().dimensions() == requestedSize) {
|
if (fEmbeddedCodecs->operator[](i)->dimensions() == requestedSize) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ protected:
|
|||||||
|
|
||||||
SkScanlineOrder onGetScanlineOrder() const override;
|
SkScanlineOrder onGetScanlineOrder() const override;
|
||||||
|
|
||||||
bool conversionSupported(const SkImageInfo&, SkColorType, bool, bool) override {
|
bool conversionSupported(const SkImageInfo&, bool, bool) override {
|
||||||
// This will be checked by the embedded codec.
|
// This will be checked by the embedded codec.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -360,8 +360,8 @@ SkISize SkJpegCodec::onGetScaledDimensions(float desiredScale) const {
|
|||||||
// Set up a fake decompress struct in order to use libjpeg to calculate output dimensions
|
// Set up a fake decompress struct in order to use libjpeg to calculate output dimensions
|
||||||
jpeg_decompress_struct dinfo;
|
jpeg_decompress_struct dinfo;
|
||||||
sk_bzero(&dinfo, sizeof(dinfo));
|
sk_bzero(&dinfo, sizeof(dinfo));
|
||||||
dinfo.image_width = this->getInfo().width();
|
dinfo.image_width = this->dimensions().width();
|
||||||
dinfo.image_height = this->getInfo().height();
|
dinfo.image_height = this->dimensions().height();
|
||||||
dinfo.global_state = fReadyState;
|
dinfo.global_state = fReadyState;
|
||||||
calc_output_dimensions(&dinfo, num, denom);
|
calc_output_dimensions(&dinfo, num, denom);
|
||||||
|
|
||||||
@ -385,8 +385,8 @@ bool SkJpegCodec::onRewind() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SkJpegCodec::conversionSupported(const SkImageInfo& dstInfo, SkColorType srcCT,
|
bool SkJpegCodec::conversionSupported(const SkImageInfo& dstInfo, bool srcIsOpaque,
|
||||||
bool srcIsOpaque, bool needsColorXform) {
|
bool needsColorXform) {
|
||||||
SkASSERT(srcIsOpaque);
|
SkASSERT(srcIsOpaque);
|
||||||
|
|
||||||
if (kUnknown_SkAlphaType == dstInfo.alphaType()) {
|
if (kUnknown_SkAlphaType == dstInfo.alphaType()) {
|
||||||
@ -467,8 +467,8 @@ bool SkJpegCodec::onDimensionsSupported(const SkISize& size) {
|
|||||||
// FIXME: Why is this necessary?
|
// FIXME: Why is this necessary?
|
||||||
jpeg_decompress_struct dinfo;
|
jpeg_decompress_struct dinfo;
|
||||||
sk_bzero(&dinfo, sizeof(dinfo));
|
sk_bzero(&dinfo, sizeof(dinfo));
|
||||||
dinfo.image_width = this->getInfo().width();
|
dinfo.image_width = this->dimensions().width();
|
||||||
dinfo.image_height = this->getInfo().height();
|
dinfo.image_height = this->dimensions().height();
|
||||||
dinfo.global_state = fReadyState;
|
dinfo.global_state = fReadyState;
|
||||||
|
|
||||||
// libjpeg-turbo can scale to 1/8, 1/4, 3/8, 1/2, 5/8, 3/4, 7/8, and 1/1
|
// libjpeg-turbo can scale to 1/8, 1/4, 3/8, 1/2, 5/8, 3/4, 7/8, and 1/1
|
||||||
|
@ -56,7 +56,7 @@ protected:
|
|||||||
|
|
||||||
bool onDimensionsSupported(const SkISize&) override;
|
bool onDimensionsSupported(const SkISize&) override;
|
||||||
|
|
||||||
bool conversionSupported(const SkImageInfo&, SkColorType, bool, bool) override;
|
bool conversionSupported(const SkImageInfo&, bool, bool) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/*
|
/*
|
||||||
|
@ -385,7 +385,7 @@ static void swizzle_mask32_to_565(
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
SkMaskSwizzler* SkMaskSwizzler::CreateMaskSwizzler(const SkImageInfo& dstInfo,
|
SkMaskSwizzler* SkMaskSwizzler::CreateMaskSwizzler(const SkImageInfo& dstInfo,
|
||||||
const SkImageInfo& srcInfo, SkMasks* masks, uint32_t bitsPerPixel,
|
bool srcIsOpaque, SkMasks* masks, uint32_t bitsPerPixel,
|
||||||
const SkCodec::Options& options) {
|
const SkCodec::Options& options) {
|
||||||
|
|
||||||
// Choose the appropriate row procedure
|
// Choose the appropriate row procedure
|
||||||
@ -394,7 +394,7 @@ SkMaskSwizzler* SkMaskSwizzler::CreateMaskSwizzler(const SkImageInfo& dstInfo,
|
|||||||
case 16:
|
case 16:
|
||||||
switch (dstInfo.colorType()) {
|
switch (dstInfo.colorType()) {
|
||||||
case kRGBA_8888_SkColorType:
|
case kRGBA_8888_SkColorType:
|
||||||
if (kOpaque_SkAlphaType == srcInfo.alphaType()) {
|
if (srcIsOpaque) {
|
||||||
proc = &swizzle_mask16_to_rgba_opaque;
|
proc = &swizzle_mask16_to_rgba_opaque;
|
||||||
} else {
|
} else {
|
||||||
switch (dstInfo.alphaType()) {
|
switch (dstInfo.alphaType()) {
|
||||||
@ -410,7 +410,7 @@ SkMaskSwizzler* SkMaskSwizzler::CreateMaskSwizzler(const SkImageInfo& dstInfo,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case kBGRA_8888_SkColorType:
|
case kBGRA_8888_SkColorType:
|
||||||
if (kOpaque_SkAlphaType == srcInfo.alphaType()) {
|
if (srcIsOpaque) {
|
||||||
proc = &swizzle_mask16_to_bgra_opaque;
|
proc = &swizzle_mask16_to_bgra_opaque;
|
||||||
} else {
|
} else {
|
||||||
switch (dstInfo.alphaType()) {
|
switch (dstInfo.alphaType()) {
|
||||||
@ -435,7 +435,7 @@ SkMaskSwizzler* SkMaskSwizzler::CreateMaskSwizzler(const SkImageInfo& dstInfo,
|
|||||||
case 24:
|
case 24:
|
||||||
switch (dstInfo.colorType()) {
|
switch (dstInfo.colorType()) {
|
||||||
case kRGBA_8888_SkColorType:
|
case kRGBA_8888_SkColorType:
|
||||||
if (kOpaque_SkAlphaType == srcInfo.alphaType()) {
|
if (srcIsOpaque) {
|
||||||
proc = &swizzle_mask24_to_rgba_opaque;
|
proc = &swizzle_mask24_to_rgba_opaque;
|
||||||
} else {
|
} else {
|
||||||
switch (dstInfo.alphaType()) {
|
switch (dstInfo.alphaType()) {
|
||||||
@ -451,7 +451,7 @@ SkMaskSwizzler* SkMaskSwizzler::CreateMaskSwizzler(const SkImageInfo& dstInfo,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case kBGRA_8888_SkColorType:
|
case kBGRA_8888_SkColorType:
|
||||||
if (kOpaque_SkAlphaType == srcInfo.alphaType()) {
|
if (srcIsOpaque) {
|
||||||
proc = &swizzle_mask24_to_bgra_opaque;
|
proc = &swizzle_mask24_to_bgra_opaque;
|
||||||
} else {
|
} else {
|
||||||
switch (dstInfo.alphaType()) {
|
switch (dstInfo.alphaType()) {
|
||||||
@ -476,7 +476,7 @@ SkMaskSwizzler* SkMaskSwizzler::CreateMaskSwizzler(const SkImageInfo& dstInfo,
|
|||||||
case 32:
|
case 32:
|
||||||
switch (dstInfo.colorType()) {
|
switch (dstInfo.colorType()) {
|
||||||
case kRGBA_8888_SkColorType:
|
case kRGBA_8888_SkColorType:
|
||||||
if (kOpaque_SkAlphaType == srcInfo.alphaType()) {
|
if (srcIsOpaque) {
|
||||||
proc = &swizzle_mask32_to_rgba_opaque;
|
proc = &swizzle_mask32_to_rgba_opaque;
|
||||||
} else {
|
} else {
|
||||||
switch (dstInfo.alphaType()) {
|
switch (dstInfo.alphaType()) {
|
||||||
@ -492,7 +492,7 @@ SkMaskSwizzler* SkMaskSwizzler::CreateMaskSwizzler(const SkImageInfo& dstInfo,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case kBGRA_8888_SkColorType:
|
case kBGRA_8888_SkColorType:
|
||||||
if (kOpaque_SkAlphaType == srcInfo.alphaType()) {
|
if (srcIsOpaque) {
|
||||||
proc = &swizzle_mask32_to_bgra_opaque;
|
proc = &swizzle_mask32_to_bgra_opaque;
|
||||||
} else {
|
} else {
|
||||||
switch (dstInfo.alphaType()) {
|
switch (dstInfo.alphaType()) {
|
||||||
|
@ -22,11 +22,10 @@ class SkMaskSwizzler : public SkSampler {
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create a new swizzler
|
|
||||||
* @param masks Unowned pointer to helper class
|
* @param masks Unowned pointer to helper class
|
||||||
*/
|
*/
|
||||||
static SkMaskSwizzler* CreateMaskSwizzler(const SkImageInfo& dstInfo,
|
static SkMaskSwizzler* CreateMaskSwizzler(const SkImageInfo& dstInfo,
|
||||||
const SkImageInfo& srcInfo,
|
bool srcIsOpaque,
|
||||||
SkMasks* masks,
|
SkMasks* masks,
|
||||||
uint32_t bitsPerPixel,
|
uint32_t bitsPerPixel,
|
||||||
const SkCodec::Options& options);
|
const SkCodec::Options& options);
|
||||||
|
@ -515,7 +515,7 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
Result decodeAllRows(void* dst, size_t rowBytes, int* rowsDecoded) override {
|
Result decodeAllRows(void* dst, size_t rowBytes, int* rowsDecoded) override {
|
||||||
const int height = this->getInfo().height();
|
const int height = this->dimensions().height();
|
||||||
png_set_progressive_read_fn(this->png_ptr(), this, nullptr, AllRowsCallback, nullptr);
|
png_set_progressive_read_fn(this->png_ptr(), this, nullptr, AllRowsCallback, nullptr);
|
||||||
fDst = dst;
|
fDst = dst;
|
||||||
fRowBytes = rowBytes;
|
fRowBytes = rowBytes;
|
||||||
@ -654,7 +654,7 @@ private:
|
|||||||
if (fNumberPasses - 1 == pass && rowNum == fLastRow) {
|
if (fNumberPasses - 1 == pass && rowNum == fLastRow) {
|
||||||
// Last pass, and we have read all of the rows we care about.
|
// Last pass, and we have read all of the rows we care about.
|
||||||
fInterlacedComplete = true;
|
fInterlacedComplete = true;
|
||||||
if (fLastRow != this->getInfo().height() - 1 ||
|
if (fLastRow != this->dimensions().height() - 1 ||
|
||||||
(this->swizzler() && this->swizzler()->sampleY() != 1)) {
|
(this->swizzler() && this->swizzler()->sampleY() != 1)) {
|
||||||
// Fake error to stop decoding scanlines. Only stop if we're not decoding the
|
// Fake error to stop decoding scanlines. Only stop if we're not decoding the
|
||||||
// whole image, in which case processing the rest of the image might be
|
// whole image, in which case processing the rest of the image might be
|
||||||
@ -667,7 +667,7 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
SkCodec::Result decodeAllRows(void* dst, size_t rowBytes, int* rowsDecoded) override {
|
SkCodec::Result decodeAllRows(void* dst, size_t rowBytes, int* rowsDecoded) override {
|
||||||
const int height = this->getInfo().height();
|
const int height = this->dimensions().height();
|
||||||
this->setUpInterlaceBuffer(height);
|
this->setUpInterlaceBuffer(height);
|
||||||
png_set_progressive_read_fn(this->png_ptr(), this, nullptr, InterlacedRowCallback,
|
png_set_progressive_read_fn(this->png_ptr(), this, nullptr, InterlacedRowCallback,
|
||||||
nullptr);
|
nullptr);
|
||||||
|
@ -762,7 +762,7 @@ SkCodec::Result SkRawCodec::onGetPixels(const SkImageInfo& dstInfo, void* dst,
|
|||||||
SkISize SkRawCodec::onGetScaledDimensions(float desiredScale) const {
|
SkISize SkRawCodec::onGetScaledDimensions(float desiredScale) const {
|
||||||
SkASSERT(desiredScale <= 1.f);
|
SkASSERT(desiredScale <= 1.f);
|
||||||
|
|
||||||
const SkISize dim = this->getInfo().dimensions();
|
const SkISize dim = this->dimensions();
|
||||||
SkASSERT(dim.fWidth != 0 && dim.fHeight != 0);
|
SkASSERT(dim.fWidth != 0 && dim.fHeight != 0);
|
||||||
|
|
||||||
if (!fDngImage->isScalable()) {
|
if (!fDngImage->isScalable()) {
|
||||||
@ -788,7 +788,7 @@ SkISize SkRawCodec::onGetScaledDimensions(float desiredScale) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool SkRawCodec::onDimensionsSupported(const SkISize& dim) {
|
bool SkRawCodec::onDimensionsSupported(const SkISize& dim) {
|
||||||
const SkISize fullDim = this->getInfo().dimensions();
|
const SkISize fullDim = this->dimensions();
|
||||||
const float fullShortEdge = static_cast<float>(SkTMin(fullDim.fWidth, fullDim.fHeight));
|
const float fullShortEdge = static_cast<float>(SkTMin(fullDim.fWidth, fullDim.fHeight));
|
||||||
const float shortEdge = static_cast<float>(SkTMin(dim.fWidth, dim.fHeight));
|
const float shortEdge = static_cast<float>(SkTMin(dim.fWidth, dim.fHeight));
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ SkSampledCodec::SkSampledCodec(SkCodec* codec, ExifOrientationBehavior behavior)
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
SkISize SkSampledCodec::accountForNativeScaling(int* sampleSizePtr, int* nativeSampleSize) const {
|
SkISize SkSampledCodec::accountForNativeScaling(int* sampleSizePtr, int* nativeSampleSize) const {
|
||||||
SkISize preSampledSize = this->codec()->getInfo().dimensions();
|
SkISize preSampledSize = this->codec()->dimensions();
|
||||||
int sampleSize = *sampleSizePtr;
|
int sampleSize = *sampleSizePtr;
|
||||||
SkASSERT(sampleSize > 1);
|
SkASSERT(sampleSize > 1);
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ SkCodec::Result SkSampledCodec::onGetAndroidPixels(const SkImageInfo& info, void
|
|||||||
codecOptions.fZeroInitialized = options.fZeroInitialized;
|
codecOptions.fZeroInitialized = options.fZeroInitialized;
|
||||||
|
|
||||||
SkIRect* subset = options.fSubset;
|
SkIRect* subset = options.fSubset;
|
||||||
if (!subset || subset->size() == this->codec()->getInfo().dimensions()) {
|
if (!subset || subset->size() == this->codec()->dimensions()) {
|
||||||
if (this->codec()->dimensionsSupported(info.dimensions())) {
|
if (this->codec()->dimensionsSupported(info.dimensions())) {
|
||||||
return this->codec()->getPixels(info, pixels, rowBytes, &codecOptions);
|
return this->codec()->getPixels(info, pixels, rowBytes, &codecOptions);
|
||||||
}
|
}
|
||||||
|
@ -101,7 +101,7 @@ SkWbmpCodec::SkWbmpCodec(SkEncodedInfo&& info, std::unique_ptr<SkStream> stream)
|
|||||||
// Wbmp does not need a colorXform, so choose an arbitrary srcFormat.
|
// Wbmp does not need a colorXform, so choose an arbitrary srcFormat.
|
||||||
: INHERITED(std::move(info), skcms_PixelFormat(),
|
: INHERITED(std::move(info), skcms_PixelFormat(),
|
||||||
std::move(stream))
|
std::move(stream))
|
||||||
, fSrcRowBytes(get_src_row_bytes(this->getInfo().width()))
|
, fSrcRowBytes(get_src_row_bytes(this->dimensions().width()))
|
||||||
, fSwizzler(nullptr)
|
, fSwizzler(nullptr)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@ -109,8 +109,8 @@ SkEncodedImageFormat SkWbmpCodec::onGetEncodedFormat() const {
|
|||||||
return SkEncodedImageFormat::kWBMP;
|
return SkEncodedImageFormat::kWBMP;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SkWbmpCodec::conversionSupported(const SkImageInfo& dst, SkColorType /*srcColor*/,
|
bool SkWbmpCodec::conversionSupported(const SkImageInfo& dst, bool srcIsOpaque,
|
||||||
bool srcIsOpaque, bool /*needsXform*/) {
|
bool /*needsColorXform*/) {
|
||||||
return valid_color_type(dst) && valid_alpha(dst.alphaType(), srcIsOpaque);
|
return valid_color_type(dst) && valid_alpha(dst.alphaType(), srcIsOpaque);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,8 +28,8 @@ protected:
|
|||||||
Result onGetPixels(const SkImageInfo&, void*, size_t,
|
Result onGetPixels(const SkImageInfo&, void*, size_t,
|
||||||
const Options&, int*) override;
|
const Options&, int*) override;
|
||||||
bool onRewind() override;
|
bool onRewind() override;
|
||||||
bool conversionSupported(const SkImageInfo& dst, SkColorType srcColor,
|
bool conversionSupported(const SkImageInfo& dst, bool srcIsOpaque,
|
||||||
bool srcIsOpaque, bool needsXform) override;
|
bool needsXform) override;
|
||||||
// No need to Xform; all pixels are either black or white.
|
// No need to Xform; all pixels are either black or white.
|
||||||
bool usesColorXform() const override { return false; }
|
bool usesColorXform() const override { return false; }
|
||||||
private:
|
private:
|
||||||
|
@ -178,7 +178,7 @@ std::unique_ptr<SkCodec> SkWebpCodec::MakeFromStream(std::unique_ptr<SkStream> s
|
|||||||
}
|
}
|
||||||
|
|
||||||
SkISize SkWebpCodec::onGetScaledDimensions(float desiredScale) const {
|
SkISize SkWebpCodec::onGetScaledDimensions(float desiredScale) const {
|
||||||
SkISize dim = this->getInfo().dimensions();
|
SkISize dim = this->dimensions();
|
||||||
// SkCodec treats zero dimensional images as errors, so the minimum size
|
// SkCodec treats zero dimensional images as errors, so the minimum size
|
||||||
// that we will recommend is 1x1.
|
// that we will recommend is 1x1.
|
||||||
dim.fWidth = SkTMax(1, SkScalarRoundToInt(desiredScale * dim.fWidth));
|
dim.fWidth = SkTMax(1, SkScalarRoundToInt(desiredScale * dim.fWidth));
|
||||||
@ -187,7 +187,7 @@ SkISize SkWebpCodec::onGetScaledDimensions(float desiredScale) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool SkWebpCodec::onDimensionsSupported(const SkISize& dim) {
|
bool SkWebpCodec::onDimensionsSupported(const SkISize& dim) {
|
||||||
const SkImageInfo& info = this->getInfo();
|
const SkEncodedInfo& info = this->getEncodedInfo();
|
||||||
return dim.width() >= 1 && dim.width() <= info.width()
|
return dim.width() >= 1 && dim.width() <= info.width()
|
||||||
&& dim.height() >= 1 && dim.height() <= info.height();
|
&& dim.height() >= 1 && dim.height() <= info.height();
|
||||||
}
|
}
|
||||||
@ -217,8 +217,7 @@ bool SkWebpCodec::onGetValidSubset(SkIRect* desiredSubset) const {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SkIRect dimensions = SkIRect::MakeSize(this->getInfo().dimensions());
|
if (!this->bounds().contains(*desiredSubset)) {
|
||||||
if (!dimensions.contains(*desiredSubset)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -415,8 +414,6 @@ SkCodec::Result SkWebpCodec::onGetPixels(const SkImageInfo& dstInfo, void* dst,
|
|||||||
const Options& options, int* rowsDecodedPtr) {
|
const Options& options, int* rowsDecodedPtr) {
|
||||||
const int index = options.fFrameIndex;
|
const int index = options.fFrameIndex;
|
||||||
SkASSERT(0 == index || index < fFrameHolder.size());
|
SkASSERT(0 == index || index < fFrameHolder.size());
|
||||||
|
|
||||||
const auto& srcInfo = this->getInfo();
|
|
||||||
SkASSERT(0 == index || !options.fSubset);
|
SkASSERT(0 == index || !options.fSubset);
|
||||||
|
|
||||||
WebPDecoderConfig config;
|
WebPDecoderConfig config;
|
||||||
@ -439,8 +436,8 @@ SkCodec::Result SkWebpCodec::onGetPixels(const SkImageInfo& dstInfo, void* dst,
|
|||||||
// Get the frameRect. libwebp will have already signaled an error if this is not fully
|
// Get the frameRect. libwebp will have already signaled an error if this is not fully
|
||||||
// contained by the canvas.
|
// contained by the canvas.
|
||||||
auto frameRect = SkIRect::MakeXYWH(frame.x_offset, frame.y_offset, frame.width, frame.height);
|
auto frameRect = SkIRect::MakeXYWH(frame.x_offset, frame.y_offset, frame.width, frame.height);
|
||||||
SkASSERT(srcInfo.bounds().contains(frameRect));
|
SkASSERT(this->bounds().contains(frameRect));
|
||||||
const bool frameIsSubset = frameRect != srcInfo.bounds();
|
const bool frameIsSubset = frameRect != this->bounds();
|
||||||
if (independent && frameIsSubset) {
|
if (independent && frameIsSubset) {
|
||||||
SkSampler::Fill(dstInfo, dst, rowBytes, options.fZeroInitialized);
|
SkSampler::Fill(dstInfo, dst, rowBytes, options.fZeroInitialized);
|
||||||
}
|
}
|
||||||
@ -451,7 +448,7 @@ SkCodec::Result SkWebpCodec::onGetPixels(const SkImageInfo& dstInfo, void* dst,
|
|||||||
int subsetHeight = frameRect.height();
|
int subsetHeight = frameRect.height();
|
||||||
if (options.fSubset) {
|
if (options.fSubset) {
|
||||||
SkIRect subset = *options.fSubset;
|
SkIRect subset = *options.fSubset;
|
||||||
SkASSERT(this->getInfo().bounds().contains(subset));
|
SkASSERT(this->bounds().contains(subset));
|
||||||
SkASSERT(SkIsAlign2(subset.fLeft) && SkIsAlign2(subset.fTop));
|
SkASSERT(SkIsAlign2(subset.fLeft) && SkIsAlign2(subset.fTop));
|
||||||
SkASSERT(this->getValidSubset(&subset) && subset == *options.fSubset);
|
SkASSERT(this->getValidSubset(&subset) && subset == *options.fSubset);
|
||||||
|
|
||||||
@ -486,7 +483,7 @@ SkCodec::Result SkWebpCodec::onGetPixels(const SkImageInfo& dstInfo, void* dst,
|
|||||||
// Ignore the frame size and offset when determining if scaling is necessary.
|
// Ignore the frame size and offset when determining if scaling is necessary.
|
||||||
int scaledWidth = subsetWidth;
|
int scaledWidth = subsetWidth;
|
||||||
int scaledHeight = subsetHeight;
|
int scaledHeight = subsetHeight;
|
||||||
SkISize srcSize = options.fSubset ? options.fSubset->size() : srcInfo.dimensions();
|
SkISize srcSize = options.fSubset ? options.fSubset->size() : this->dimensions();
|
||||||
if (srcSize != dstInfo.dimensions()) {
|
if (srcSize != dstInfo.dimensions()) {
|
||||||
config.options.use_scaling = 1;
|
config.options.use_scaling = 1;
|
||||||
|
|
||||||
|
@ -65,8 +65,8 @@ static void test_path(skiatest::Reporter* r, const char* path,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SkColorSpace* colorSpace = codec->getInfo().colorSpace();
|
auto colorSpace = codec->getInfo().refColorSpace();
|
||||||
test_space(r, colorSpace, red, green, blue, expectedGamma);
|
test_space(r, colorSpace.get(), red, green, blue, expectedGamma);
|
||||||
}
|
}
|
||||||
|
|
||||||
static constexpr float g_sRGB_XYZ[]{
|
static constexpr float g_sRGB_XYZ[]{
|
||||||
|
Loading…
Reference in New Issue
Block a user