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();
|
||||
|
||||
/**
|
||||
* 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.
|
||||
@ -196,7 +201,7 @@ public:
|
||||
// Upscaling is not supported. Return the original size if the client
|
||||
// requests an upscale.
|
||||
if (desiredScale >= 1.0f) {
|
||||
return this->getInfo().dimensions();
|
||||
return this->dimensions();
|
||||
}
|
||||
return this->onGetScaledDimensions(desiredScale);
|
||||
}
|
||||
@ -679,7 +684,7 @@ protected:
|
||||
|
||||
virtual SkISize onGetScaledDimensions(float /*desiredScale*/) const {
|
||||
// By default, scaling is not supported.
|
||||
return this->getInfo().dimensions();
|
||||
return this->dimensions();
|
||||
}
|
||||
|
||||
// FIXME: What to do about subsets??
|
||||
@ -790,7 +795,6 @@ protected:
|
||||
|
||||
private:
|
||||
const SkEncodedInfo fEncodedInfo;
|
||||
const SkImageInfo fSrcInfo;
|
||||
const XformFormat fSrcXformFormat;
|
||||
std::unique_ptr<SkStream> fStream;
|
||||
bool fNeedsRewind;
|
||||
@ -819,8 +823,8 @@ private:
|
||||
*
|
||||
* Will be called for the appropriate frame, prior to initializing the colorXform.
|
||||
*/
|
||||
virtual bool conversionSupported(const SkImageInfo& dst, SkColorType srcColor,
|
||||
bool srcIsOpaque, bool needsColorXform);
|
||||
virtual bool conversionSupported(const SkImageInfo& dst, bool srcIsOpaque,
|
||||
bool needsColorXform);
|
||||
|
||||
bool initializeColorXform(const SkImageInfo& dstInfo, SkEncodedInfo::Alpha, bool srcIsOpaque);
|
||||
|
||||
@ -834,7 +838,7 @@ private:
|
||||
* This must return true for a size returned from getScaledDimensions.
|
||||
*/
|
||||
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))
|
||||
, fBitsPerPixel(bitsPerPixel)
|
||||
, fRowOrder(rowOrder)
|
||||
, fSrcRowBytes(SkAlign4(compute_row_bytes(this->getEncodedInfo().width(), fBitsPerPixel)))
|
||||
, fSrcRowBytes(SkAlign4(compute_row_bytes(this->dimensions().width(), fBitsPerPixel)))
|
||||
, fXformBuffer(nullptr)
|
||||
{}
|
||||
|
||||
|
@ -32,7 +32,7 @@ SkCodec::Result SkBmpMaskCodec::onGetPixels(const SkImageInfo& dstInfo,
|
||||
// Subsets are not supported.
|
||||
return kUnimplemented;
|
||||
}
|
||||
if (dstInfo.dimensions() != this->getInfo().dimensions()) {
|
||||
if (dstInfo.dimensions() != this->dimensions()) {
|
||||
SkCodecPrintf("Error: scaling not supported.\n");
|
||||
return kInvalidScale;
|
||||
}
|
||||
@ -64,8 +64,8 @@ SkCodec::Result SkBmpMaskCodec::onPrepareToDecode(const SkImageInfo& dstInfo,
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize the mask swizzler
|
||||
fMaskSwizzler.reset(SkMaskSwizzler::CreateMaskSwizzler(swizzlerInfo, this->getInfo(),
|
||||
bool srcIsOpaque = this->getEncodedInfo().opaque();
|
||||
fMaskSwizzler.reset(SkMaskSwizzler::CreateMaskSwizzler(swizzlerInfo, srcIsOpaque,
|
||||
fMasks.get(), this->bitsPerPixel(), options));
|
||||
SkASSERT(fMaskSwizzler);
|
||||
|
||||
|
@ -275,7 +275,7 @@ SkCodec::Result SkBmpRLECodec::onPrepareToDecode(const SkImageInfo& dstInfo,
|
||||
*/
|
||||
int SkBmpRLECodec::decodeRows(const SkImageInfo& info, void* dst, size_t dstRowBytes,
|
||||
const Options& opts) {
|
||||
const int width = this->getInfo().width();
|
||||
const int width = this->dimensions().width();
|
||||
int height = info.height();
|
||||
|
||||
// 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) {
|
||||
// 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.
|
||||
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) {
|
||||
const SkImageInfo rowInfo = SkImageInfo::Make(this->getInfo().width(), count, kN32_SkColorType,
|
||||
kUnpremul_SkAlphaType);
|
||||
|
||||
const SkImageInfo rowInfo = SkImageInfo::Make(this->dimensions().width(), count,
|
||||
kN32_SkColorType, kUnpremul_SkAlphaType);
|
||||
return count == this->decodeRows(rowInfo, nullptr, 0, this->options());
|
||||
}
|
||||
|
||||
@ -563,5 +562,5 @@ SkSampler* SkBmpRLECodec::getSampler(bool /*createIfNecessary*/) {
|
||||
|
||||
int SkBmpRLECodec::setSampleX(int 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)
|
||||
, fIsOpaque(isOpaque)
|
||||
, 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.
|
||||
return kUnimplemented;
|
||||
}
|
||||
if (dstInfo.dimensions() != this->getInfo().dimensions()) {
|
||||
if (dstInfo.dimensions() != this->dimensions()) {
|
||||
SkCodecPrintf("Error: scaling not supported.\n");
|
||||
return kInvalidScale;
|
||||
}
|
||||
@ -265,7 +265,7 @@ int SkBmpStandardCodec::decodeRows(const SkImageInfo& dstInfo, void* dst, size_t
|
||||
const size_t currPosition = this->stream()->getPosition();
|
||||
|
||||
// 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() +
|
||||
startScanline * fAndMaskRowBytes;
|
||||
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
|
||||
// should be handled by SkSampledCodec.
|
||||
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);
|
||||
|
||||
|
||||
|
@ -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,
|
||||
SkEncodedOrigin origin)
|
||||
: fEncodedInfo(std::move(info))
|
||||
, fSrcInfo(fEncodedInfo.makeImageInfo())
|
||||
, fSrcXformFormat(srcFormat)
|
||||
, fStream(std::move(stream))
|
||||
, fNeedsRewind(false)
|
||||
@ -141,8 +140,7 @@ SkCodec::SkCodec(SkEncodedInfo&& info, XformFormat srcFormat, std::unique_ptr<Sk
|
||||
|
||||
SkCodec::~SkCodec() {}
|
||||
|
||||
bool SkCodec::conversionSupported(const SkImageInfo& dst, SkColorType srcColor,
|
||||
bool srcIsOpaque, bool needsColorXform) {
|
||||
bool SkCodec::conversionSupported(const SkImageInfo& dst, bool srcIsOpaque, bool needsColorXform) {
|
||||
if (!valid_alpha(dst.alphaType(), srcIsOpaque)) {
|
||||
return false;
|
||||
}
|
||||
@ -156,11 +154,11 @@ 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 == fEncodedInfo.color() && srcIsOpaque;
|
||||
case kAlpha_8_SkColorType:
|
||||
// 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.
|
||||
return fSrcInfo.colorType() == kAlpha_8_SkColorType;;
|
||||
// all of those other conversions yet.
|
||||
return SkEncodedInfo::kXAlpha_Color == fEncodedInfo.color();
|
||||
default:
|
||||
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.
|
||||
if (options.fPriorFrame == requiredFrame) {
|
||||
SkIRect prevRect = prevFrame->frameRect();
|
||||
if (!zero_rect(info, pixels, rowBytes, fSrcInfo.dimensions(), prevRect)) {
|
||||
if (!zero_rect(info, pixels, rowBytes, this->dimensions(), prevRect)) {
|
||||
return kInternalError;
|
||||
}
|
||||
}
|
||||
@ -288,7 +286,7 @@ SkCodec::Result SkCodec::handleFrameIndex(const SkImageInfo& info, void* pixels,
|
||||
const auto disposalMethod = prevFrame->getDisposalMethod();
|
||||
if (disposalMethod == SkCodecAnimation::DisposalMethod::kRestoreBGColor) {
|
||||
auto prevRect = prevFrame->frameRect();
|
||||
if (!zero_rect(info, pixels, rowBytes, fSrcInfo.dimensions(), prevRect)) {
|
||||
if (!zero_rect(info, pixels, rowBytes, this->dimensions(), prevRect)) {
|
||||
return kInternalError;
|
||||
}
|
||||
}
|
||||
@ -535,7 +533,7 @@ bool SkCodec::skipScanlines(int countLines) {
|
||||
}
|
||||
|
||||
int SkCodec::outputScanline(int inputScanline) const {
|
||||
SkASSERT(0 <= inputScanline && inputScanline < this->getInfo().height());
|
||||
SkASSERT(0 <= inputScanline && inputScanline < fEncodedInfo.height());
|
||||
return this->onOutputScanline(inputScanline);
|
||||
}
|
||||
|
||||
@ -544,7 +542,7 @@ int SkCodec::onOutputScanline(int inputScanline) const {
|
||||
case kTopDown_SkScanlineOrder:
|
||||
return inputScanline;
|
||||
case kBottomUp_SkScanlineOrder:
|
||||
return this->getInfo().height() - inputScanline - 1;
|
||||
return fEncodedInfo.height() - inputScanline - 1;
|
||||
default:
|
||||
// This case indicates an interlaced gif and is implemented by SkGifCodec.
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -282,7 +282,7 @@ SkCodec::Result SkGifCodec::onGetPixels(const SkImageInfo& dstInfo,
|
||||
return result;
|
||||
}
|
||||
|
||||
if (dstInfo.dimensions() != this->getInfo().dimensions()) {
|
||||
if (dstInfo.dimensions() != this->dimensions()) {
|
||||
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.)
|
||||
// - There is no color table for this frame. In that case will not
|
||||
// draw anything, so we need to fill.
|
||||
if (frameContext->frameRect() != this->getInfo().bounds()
|
||||
if (frameContext->frameRect() != this->bounds()
|
||||
|| frameContext->interlaced() || !fCurrColorTableIsReal) {
|
||||
// fill ignores the width (replaces it with the actual, scaled width).
|
||||
// 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 xBegin = frameContext->xOffset();
|
||||
const int yBegin = frameContext->yOffset() + rowNumber;
|
||||
const int xEnd = std::min(xBegin + width, this->getInfo().width());
|
||||
const int yEnd = std::min(yBegin + rowNumber + repeatCount, this->getInfo().height());
|
||||
const int xEnd = std::min(xBegin + width, this->dimensions().width());
|
||||
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
|
||||
// this once in prepareToDecode.
|
||||
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 srcIsOpaque, bool needsColorXform) {
|
||||
bool SkHeifCodec::conversionSupported(const SkImageInfo& dstInfo, bool srcIsOpaque,
|
||||
bool needsColorXform) {
|
||||
SkASSERT(srcIsOpaque);
|
||||
|
||||
if (kUnknown_SkAlphaType == dstInfo.alphaType()) {
|
||||
|
@ -41,7 +41,7 @@ protected:
|
||||
return SkEncodedImageFormat::kHEIF;
|
||||
}
|
||||
|
||||
bool conversionSupported(const SkImageInfo&, SkColorType, bool, bool) override;
|
||||
bool conversionSupported(const SkImageInfo&, bool, bool) override;
|
||||
|
||||
private:
|
||||
/*
|
||||
|
@ -203,15 +203,16 @@ SkISize SkIcoCodec::onGetScaledDimensions(float desiredScale) const {
|
||||
// We set the dimensions to the largest candidate image by default.
|
||||
// Regardless of the scale request, this is the largest image that we
|
||||
// will decode.
|
||||
int origWidth = this->getInfo().width();
|
||||
int origHeight = this->getInfo().height();
|
||||
int origWidth = this->dimensions().width();
|
||||
int origHeight = this->dimensions().height();
|
||||
float desiredSize = desiredScale * origWidth * origHeight;
|
||||
// At least one image will have smaller error than this initial value
|
||||
float minError = ((float) (origWidth * origHeight)) - desiredSize + 1.0f;
|
||||
int32_t minIndex = -1;
|
||||
for (int32_t i = 0; i < fEmbeddedCodecs->count(); i++) {
|
||||
int width = fEmbeddedCodecs->operator[](i)->getInfo().width();
|
||||
int height = fEmbeddedCodecs->operator[](i)->getInfo().height();
|
||||
auto dimensions = fEmbeddedCodecs->operator[](i)->dimensions();
|
||||
int width = dimensions.width();
|
||||
int height = dimensions.height();
|
||||
float error = SkTAbs(((float) (width * height)) - desiredSize);
|
||||
if (error < minError) {
|
||||
minError = error;
|
||||
@ -220,7 +221,7 @@ SkISize SkIcoCodec::onGetScaledDimensions(float desiredScale) const {
|
||||
}
|
||||
SkASSERT(minIndex >= 0);
|
||||
|
||||
return fEmbeddedCodecs->operator[](minIndex)->getInfo().dimensions();
|
||||
return fEmbeddedCodecs->operator[](minIndex)->dimensions();
|
||||
}
|
||||
|
||||
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?
|
||||
for (int i = startIndex; i < fEmbeddedCodecs->count(); i++) {
|
||||
if (fEmbeddedCodecs->operator[](i)->getInfo().dimensions() == requestedSize) {
|
||||
if (fEmbeddedCodecs->operator[](i)->dimensions() == requestedSize) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ protected:
|
||||
|
||||
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.
|
||||
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
|
||||
jpeg_decompress_struct dinfo;
|
||||
sk_bzero(&dinfo, sizeof(dinfo));
|
||||
dinfo.image_width = this->getInfo().width();
|
||||
dinfo.image_height = this->getInfo().height();
|
||||
dinfo.image_width = this->dimensions().width();
|
||||
dinfo.image_height = this->dimensions().height();
|
||||
dinfo.global_state = fReadyState;
|
||||
calc_output_dimensions(&dinfo, num, denom);
|
||||
|
||||
@ -385,8 +385,8 @@ bool SkJpegCodec::onRewind() {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SkJpegCodec::conversionSupported(const SkImageInfo& dstInfo, SkColorType srcCT,
|
||||
bool srcIsOpaque, bool needsColorXform) {
|
||||
bool SkJpegCodec::conversionSupported(const SkImageInfo& dstInfo, bool srcIsOpaque,
|
||||
bool needsColorXform) {
|
||||
SkASSERT(srcIsOpaque);
|
||||
|
||||
if (kUnknown_SkAlphaType == dstInfo.alphaType()) {
|
||||
@ -467,8 +467,8 @@ bool SkJpegCodec::onDimensionsSupported(const SkISize& size) {
|
||||
// FIXME: Why is this necessary?
|
||||
jpeg_decompress_struct dinfo;
|
||||
sk_bzero(&dinfo, sizeof(dinfo));
|
||||
dinfo.image_width = this->getInfo().width();
|
||||
dinfo.image_height = this->getInfo().height();
|
||||
dinfo.image_width = this->dimensions().width();
|
||||
dinfo.image_height = this->dimensions().height();
|
||||
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
|
||||
|
@ -56,7 +56,7 @@ protected:
|
||||
|
||||
bool onDimensionsSupported(const SkISize&) override;
|
||||
|
||||
bool conversionSupported(const SkImageInfo&, SkColorType, bool, bool) override;
|
||||
bool conversionSupported(const SkImageInfo&, bool, bool) override;
|
||||
|
||||
private:
|
||||
/*
|
||||
|
@ -385,7 +385,7 @@ static void swizzle_mask32_to_565(
|
||||
*
|
||||
*/
|
||||
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) {
|
||||
|
||||
// Choose the appropriate row procedure
|
||||
@ -394,7 +394,7 @@ SkMaskSwizzler* SkMaskSwizzler::CreateMaskSwizzler(const SkImageInfo& dstInfo,
|
||||
case 16:
|
||||
switch (dstInfo.colorType()) {
|
||||
case kRGBA_8888_SkColorType:
|
||||
if (kOpaque_SkAlphaType == srcInfo.alphaType()) {
|
||||
if (srcIsOpaque) {
|
||||
proc = &swizzle_mask16_to_rgba_opaque;
|
||||
} else {
|
||||
switch (dstInfo.alphaType()) {
|
||||
@ -410,7 +410,7 @@ SkMaskSwizzler* SkMaskSwizzler::CreateMaskSwizzler(const SkImageInfo& dstInfo,
|
||||
}
|
||||
break;
|
||||
case kBGRA_8888_SkColorType:
|
||||
if (kOpaque_SkAlphaType == srcInfo.alphaType()) {
|
||||
if (srcIsOpaque) {
|
||||
proc = &swizzle_mask16_to_bgra_opaque;
|
||||
} else {
|
||||
switch (dstInfo.alphaType()) {
|
||||
@ -435,7 +435,7 @@ SkMaskSwizzler* SkMaskSwizzler::CreateMaskSwizzler(const SkImageInfo& dstInfo,
|
||||
case 24:
|
||||
switch (dstInfo.colorType()) {
|
||||
case kRGBA_8888_SkColorType:
|
||||
if (kOpaque_SkAlphaType == srcInfo.alphaType()) {
|
||||
if (srcIsOpaque) {
|
||||
proc = &swizzle_mask24_to_rgba_opaque;
|
||||
} else {
|
||||
switch (dstInfo.alphaType()) {
|
||||
@ -451,7 +451,7 @@ SkMaskSwizzler* SkMaskSwizzler::CreateMaskSwizzler(const SkImageInfo& dstInfo,
|
||||
}
|
||||
break;
|
||||
case kBGRA_8888_SkColorType:
|
||||
if (kOpaque_SkAlphaType == srcInfo.alphaType()) {
|
||||
if (srcIsOpaque) {
|
||||
proc = &swizzle_mask24_to_bgra_opaque;
|
||||
} else {
|
||||
switch (dstInfo.alphaType()) {
|
||||
@ -476,7 +476,7 @@ SkMaskSwizzler* SkMaskSwizzler::CreateMaskSwizzler(const SkImageInfo& dstInfo,
|
||||
case 32:
|
||||
switch (dstInfo.colorType()) {
|
||||
case kRGBA_8888_SkColorType:
|
||||
if (kOpaque_SkAlphaType == srcInfo.alphaType()) {
|
||||
if (srcIsOpaque) {
|
||||
proc = &swizzle_mask32_to_rgba_opaque;
|
||||
} else {
|
||||
switch (dstInfo.alphaType()) {
|
||||
@ -492,7 +492,7 @@ SkMaskSwizzler* SkMaskSwizzler::CreateMaskSwizzler(const SkImageInfo& dstInfo,
|
||||
}
|
||||
break;
|
||||
case kBGRA_8888_SkColorType:
|
||||
if (kOpaque_SkAlphaType == srcInfo.alphaType()) {
|
||||
if (srcIsOpaque) {
|
||||
proc = &swizzle_mask32_to_bgra_opaque;
|
||||
} else {
|
||||
switch (dstInfo.alphaType()) {
|
||||
|
@ -22,11 +22,10 @@ class SkMaskSwizzler : public SkSampler {
|
||||
public:
|
||||
|
||||
/*
|
||||
* Create a new swizzler
|
||||
* @param masks Unowned pointer to helper class
|
||||
*/
|
||||
static SkMaskSwizzler* CreateMaskSwizzler(const SkImageInfo& dstInfo,
|
||||
const SkImageInfo& srcInfo,
|
||||
bool srcIsOpaque,
|
||||
SkMasks* masks,
|
||||
uint32_t bitsPerPixel,
|
||||
const SkCodec::Options& options);
|
||||
|
@ -515,7 +515,7 @@ private:
|
||||
}
|
||||
|
||||
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);
|
||||
fDst = dst;
|
||||
fRowBytes = rowBytes;
|
||||
@ -654,7 +654,7 @@ private:
|
||||
if (fNumberPasses - 1 == pass && rowNum == fLastRow) {
|
||||
// Last pass, and we have read all of the rows we care about.
|
||||
fInterlacedComplete = true;
|
||||
if (fLastRow != this->getInfo().height() - 1 ||
|
||||
if (fLastRow != this->dimensions().height() - 1 ||
|
||||
(this->swizzler() && this->swizzler()->sampleY() != 1)) {
|
||||
// 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
|
||||
@ -667,7 +667,7 @@ private:
|
||||
}
|
||||
|
||||
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);
|
||||
png_set_progressive_read_fn(this->png_ptr(), this, nullptr, InterlacedRowCallback,
|
||||
nullptr);
|
||||
|
@ -762,7 +762,7 @@ SkCodec::Result SkRawCodec::onGetPixels(const SkImageInfo& dstInfo, void* dst,
|
||||
SkISize SkRawCodec::onGetScaledDimensions(float desiredScale) const {
|
||||
SkASSERT(desiredScale <= 1.f);
|
||||
|
||||
const SkISize dim = this->getInfo().dimensions();
|
||||
const SkISize dim = this->dimensions();
|
||||
SkASSERT(dim.fWidth != 0 && dim.fHeight != 0);
|
||||
|
||||
if (!fDngImage->isScalable()) {
|
||||
@ -788,7 +788,7 @@ SkISize SkRawCodec::onGetScaledDimensions(float desiredScale) const {
|
||||
}
|
||||
|
||||
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 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 preSampledSize = this->codec()->getInfo().dimensions();
|
||||
SkISize preSampledSize = this->codec()->dimensions();
|
||||
int sampleSize = *sampleSizePtr;
|
||||
SkASSERT(sampleSize > 1);
|
||||
|
||||
@ -78,7 +78,7 @@ SkCodec::Result SkSampledCodec::onGetAndroidPixels(const SkImageInfo& info, void
|
||||
codecOptions.fZeroInitialized = options.fZeroInitialized;
|
||||
|
||||
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())) {
|
||||
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.
|
||||
: INHERITED(std::move(info), skcms_PixelFormat(),
|
||||
std::move(stream))
|
||||
, fSrcRowBytes(get_src_row_bytes(this->getInfo().width()))
|
||||
, fSrcRowBytes(get_src_row_bytes(this->dimensions().width()))
|
||||
, fSwizzler(nullptr)
|
||||
{}
|
||||
|
||||
@ -109,8 +109,8 @@ SkEncodedImageFormat SkWbmpCodec::onGetEncodedFormat() const {
|
||||
return SkEncodedImageFormat::kWBMP;
|
||||
}
|
||||
|
||||
bool SkWbmpCodec::conversionSupported(const SkImageInfo& dst, SkColorType /*srcColor*/,
|
||||
bool srcIsOpaque, bool /*needsXform*/) {
|
||||
bool SkWbmpCodec::conversionSupported(const SkImageInfo& dst, bool srcIsOpaque,
|
||||
bool /*needsColorXform*/) {
|
||||
return valid_color_type(dst) && valid_alpha(dst.alphaType(), srcIsOpaque);
|
||||
}
|
||||
|
||||
|
@ -28,8 +28,8 @@ protected:
|
||||
Result onGetPixels(const SkImageInfo&, void*, size_t,
|
||||
const Options&, int*) override;
|
||||
bool onRewind() override;
|
||||
bool conversionSupported(const SkImageInfo& dst, SkColorType srcColor,
|
||||
bool srcIsOpaque, bool needsXform) override;
|
||||
bool conversionSupported(const SkImageInfo& dst, bool srcIsOpaque,
|
||||
bool needsXform) override;
|
||||
// No need to Xform; all pixels are either black or white.
|
||||
bool usesColorXform() const override { return false; }
|
||||
private:
|
||||
|
@ -178,7 +178,7 @@ std::unique_ptr<SkCodec> SkWebpCodec::MakeFromStream(std::unique_ptr<SkStream> s
|
||||
}
|
||||
|
||||
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
|
||||
// that we will recommend is 1x1.
|
||||
dim.fWidth = SkTMax(1, SkScalarRoundToInt(desiredScale * dim.fWidth));
|
||||
@ -187,7 +187,7 @@ SkISize SkWebpCodec::onGetScaledDimensions(float desiredScale) const {
|
||||
}
|
||||
|
||||
bool SkWebpCodec::onDimensionsSupported(const SkISize& dim) {
|
||||
const SkImageInfo& info = this->getInfo();
|
||||
const SkEncodedInfo& info = this->getEncodedInfo();
|
||||
return dim.width() >= 1 && dim.width() <= info.width()
|
||||
&& dim.height() >= 1 && dim.height() <= info.height();
|
||||
}
|
||||
@ -217,8 +217,7 @@ bool SkWebpCodec::onGetValidSubset(SkIRect* desiredSubset) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
SkIRect dimensions = SkIRect::MakeSize(this->getInfo().dimensions());
|
||||
if (!dimensions.contains(*desiredSubset)) {
|
||||
if (!this->bounds().contains(*desiredSubset)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -415,8 +414,6 @@ SkCodec::Result SkWebpCodec::onGetPixels(const SkImageInfo& dstInfo, void* dst,
|
||||
const Options& options, int* rowsDecodedPtr) {
|
||||
const int index = options.fFrameIndex;
|
||||
SkASSERT(0 == index || index < fFrameHolder.size());
|
||||
|
||||
const auto& srcInfo = this->getInfo();
|
||||
SkASSERT(0 == index || !options.fSubset);
|
||||
|
||||
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
|
||||
// contained by the canvas.
|
||||
auto frameRect = SkIRect::MakeXYWH(frame.x_offset, frame.y_offset, frame.width, frame.height);
|
||||
SkASSERT(srcInfo.bounds().contains(frameRect));
|
||||
const bool frameIsSubset = frameRect != srcInfo.bounds();
|
||||
SkASSERT(this->bounds().contains(frameRect));
|
||||
const bool frameIsSubset = frameRect != this->bounds();
|
||||
if (independent && frameIsSubset) {
|
||||
SkSampler::Fill(dstInfo, dst, rowBytes, options.fZeroInitialized);
|
||||
}
|
||||
@ -451,7 +448,7 @@ SkCodec::Result SkWebpCodec::onGetPixels(const SkImageInfo& dstInfo, void* dst,
|
||||
int subsetHeight = frameRect.height();
|
||||
if (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(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.
|
||||
int scaledWidth = subsetWidth;
|
||||
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()) {
|
||||
config.options.use_scaling = 1;
|
||||
|
||||
|
@ -65,8 +65,8 @@ static void test_path(skiatest::Reporter* r, const char* path,
|
||||
return;
|
||||
}
|
||||
|
||||
SkColorSpace* colorSpace = codec->getInfo().colorSpace();
|
||||
test_space(r, colorSpace, red, green, blue, expectedGamma);
|
||||
auto colorSpace = codec->getInfo().refColorSpace();
|
||||
test_space(r, colorSpace.get(), red, green, blue, expectedGamma);
|
||||
}
|
||||
|
||||
static constexpr float g_sRGB_XYZ[]{
|
||||
|
Loading…
Reference in New Issue
Block a user