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>
diff --git a/include/codec/SkCodec.h b/include/codec/SkCodec.h
index 2e263ea..b0287a8 100644
--- a/include/codec/SkCodec.h
+++ b/include/codec/SkCodec.h
@@ -169,9 +169,14 @@
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 @@
// 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 @@
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 @@
private:
const SkEncodedInfo fEncodedInfo;
- const SkImageInfo fSrcInfo;
const XformFormat fSrcXformFormat;
std::unique_ptr<SkStream> fStream;
bool fNeedsRewind;
@@ -819,8 +823,8 @@
*
* 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 @@
* 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);
}
/**
diff --git a/src/codec/SkBmpCodec.cpp b/src/codec/SkBmpCodec.cpp
index cb57f5b..e20e6c9 100644
--- a/src/codec/SkBmpCodec.cpp
+++ b/src/codec/SkBmpCodec.cpp
@@ -605,7 +605,7 @@
: 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)
{}
diff --git a/src/codec/SkBmpMaskCodec.cpp b/src/codec/SkBmpMaskCodec.cpp
index 0cb0924..055954c 100644
--- a/src/codec/SkBmpMaskCodec.cpp
+++ b/src/codec/SkBmpMaskCodec.cpp
@@ -32,7 +32,7 @@
// 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 @@
}
}
- // 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);
diff --git a/src/codec/SkBmpRLECodec.cpp b/src/codec/SkBmpRLECodec.cpp
index 8a7fb9e8..8fc0ea8 100644
--- a/src/codec/SkBmpRLECodec.cpp
+++ b/src/codec/SkBmpRLECodec.cpp
@@ -275,7 +275,7 @@
*/
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::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 @@
}
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 @@
int SkBmpRLECodec::setSampleX(int sampleX){
fSampleX = sampleX;
- return get_scaled_dimension(this->getInfo().width(), sampleX);
+ return get_scaled_dimension(this->dimensions().width(), sampleX);
}
diff --git a/src/codec/SkBmpStandardCodec.cpp b/src/codec/SkBmpStandardCodec.cpp
index 8e01ac0..784b8f5 100644
--- a/src/codec/SkBmpStandardCodec.cpp
+++ b/src/codec/SkBmpStandardCodec.cpp
@@ -28,7 +28,7 @@
, 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 @@
// 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 @@
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 @@
// 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);
diff --git a/src/codec/SkCodec.cpp b/src/codec/SkCodec.cpp
index 929cc6e..73a6a29 100644
--- a/src/codec/SkCodec.cpp
+++ b/src/codec/SkCodec.cpp
@@ -128,7 +128,6 @@
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() {}
-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 @@
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 @@
// 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 @@
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 @@
}
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 @@
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 @@
}
}
- if (!this->conversionSupported(dstInfo, fSrcInfo.colorType(), srcIsOpaque, needsColorXform)) {
+ if (!this->conversionSupported(dstInfo, srcIsOpaque, needsColorXform)) {
return false;
}
diff --git a/src/codec/SkGifCodec.cpp b/src/codec/SkGifCodec.cpp
index 34dfbef..2e03b79 100644
--- a/src/codec/SkGifCodec.cpp
+++ b/src/codec/SkGifCodec.cpp
@@ -282,7 +282,7 @@
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 @@
// 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 @@
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))
diff --git a/src/codec/SkHeifCodec.cpp b/src/codec/SkHeifCodec.cpp
index c6ce0b9..32a128b 100644
--- a/src/codec/SkHeifCodec.cpp
+++ b/src/codec/SkHeifCodec.cpp
@@ -161,8 +161,8 @@
{}
-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()) {
diff --git a/src/codec/SkHeifCodec.h b/src/codec/SkHeifCodec.h
index 0796805..e409097 100644
--- a/src/codec/SkHeifCodec.h
+++ b/src/codec/SkHeifCodec.h
@@ -41,7 +41,7 @@
return SkEncodedImageFormat::kHEIF;
}
- bool conversionSupported(const SkImageInfo&, SkColorType, bool, bool) override;
+ bool conversionSupported(const SkImageInfo&, bool, bool) override;
private:
/*
diff --git a/src/codec/SkIcoCodec.cpp b/src/codec/SkIcoCodec.cpp
index d838079..3e5d3ec 100644
--- a/src/codec/SkIcoCodec.cpp
+++ b/src/codec/SkIcoCodec.cpp
@@ -203,15 +203,16 @@
// 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 @@
}
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 @@
// 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;
}
}
diff --git a/src/codec/SkIcoCodec.h b/src/codec/SkIcoCodec.h
index e733e9f..9464f47 100644
--- a/src/codec/SkIcoCodec.h
+++ b/src/codec/SkIcoCodec.h
@@ -48,7 +48,7 @@
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;
}
diff --git a/src/codec/SkJpegCodec.cpp b/src/codec/SkJpegCodec.cpp
index 926fedf..257b764 100644
--- a/src/codec/SkJpegCodec.cpp
+++ b/src/codec/SkJpegCodec.cpp
@@ -360,8 +360,8 @@
// 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 @@
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 @@
// 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
diff --git a/src/codec/SkJpegCodec.h b/src/codec/SkJpegCodec.h
index 1b51dbf..5eff1d5 100644
--- a/src/codec/SkJpegCodec.h
+++ b/src/codec/SkJpegCodec.h
@@ -56,7 +56,7 @@
bool onDimensionsSupported(const SkISize&) override;
- bool conversionSupported(const SkImageInfo&, SkColorType, bool, bool) override;
+ bool conversionSupported(const SkImageInfo&, bool, bool) override;
private:
/*
diff --git a/src/codec/SkMaskSwizzler.cpp b/src/codec/SkMaskSwizzler.cpp
index 81e3d6e..eeae007 100644
--- a/src/codec/SkMaskSwizzler.cpp
+++ b/src/codec/SkMaskSwizzler.cpp
@@ -385,7 +385,7 @@
*
*/
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 @@
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 @@
}
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 @@
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 @@
}
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 @@
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 @@
}
break;
case kBGRA_8888_SkColorType:
- if (kOpaque_SkAlphaType == srcInfo.alphaType()) {
+ if (srcIsOpaque) {
proc = &swizzle_mask32_to_bgra_opaque;
} else {
switch (dstInfo.alphaType()) {
diff --git a/src/codec/SkMaskSwizzler.h b/src/codec/SkMaskSwizzler.h
index 9425174..b8289f3 100644
--- a/src/codec/SkMaskSwizzler.h
+++ b/src/codec/SkMaskSwizzler.h
@@ -22,11 +22,10 @@
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);
diff --git a/src/codec/SkPngCodec.cpp b/src/codec/SkPngCodec.cpp
index 288870a..71f07c6 100644
--- a/src/codec/SkPngCodec.cpp
+++ b/src/codec/SkPngCodec.cpp
@@ -515,7 +515,7 @@
}
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 @@
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 @@
}
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);
diff --git a/src/codec/SkRawCodec.cpp b/src/codec/SkRawCodec.cpp
index 2b361b5..e520c89 100644
--- a/src/codec/SkRawCodec.cpp
+++ b/src/codec/SkRawCodec.cpp
@@ -762,7 +762,7 @@
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 @@
}
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));
diff --git a/src/codec/SkSampledCodec.cpp b/src/codec/SkSampledCodec.cpp
index 0ba7ef9..5aa0a21 100644
--- a/src/codec/SkSampledCodec.cpp
+++ b/src/codec/SkSampledCodec.cpp
@@ -18,7 +18,7 @@
{}
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 @@
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);
}
diff --git a/src/codec/SkWbmpCodec.cpp b/src/codec/SkWbmpCodec.cpp
index cc1462e..6836256 100644
--- a/src/codec/SkWbmpCodec.cpp
+++ b/src/codec/SkWbmpCodec.cpp
@@ -101,7 +101,7 @@
// 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 @@
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);
}
diff --git a/src/codec/SkWbmpCodec.h b/src/codec/SkWbmpCodec.h
index b9df0b9..6e72763 100644
--- a/src/codec/SkWbmpCodec.h
+++ b/src/codec/SkWbmpCodec.h
@@ -28,8 +28,8 @@
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:
diff --git a/src/codec/SkWebpCodec.cpp b/src/codec/SkWebpCodec.cpp
index 2737806..d637b19 100644
--- a/src/codec/SkWebpCodec.cpp
+++ b/src/codec/SkWebpCodec.cpp
@@ -178,7 +178,7 @@
}
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 @@
}
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 @@
return false;
}
- SkIRect dimensions = SkIRect::MakeSize(this->getInfo().dimensions());
- if (!dimensions.contains(*desiredSubset)) {
+ if (!this->bounds().contains(*desiredSubset)) {
return false;
}
@@ -415,8 +414,6 @@
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 @@
// 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 @@
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 @@
// 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;
diff --git a/tests/ColorSpaceTest.cpp b/tests/ColorSpaceTest.cpp
index 9e92b32..22f6304 100644
--- a/tests/ColorSpaceTest.cpp
+++ b/tests/ColorSpaceTest.cpp
@@ -65,8 +65,8 @@
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[]{