aboutsummaryrefslogtreecommitdiff
path: root/src/codec
diff options
context:
space:
mode:
authorLeon Scroggins III <scroggo@google.com>2018-10-03 15:47:00 -0400
committerSkia Commit-Bot <skia-commit-bot@chromium.org>2018-10-03 20:14:18 +0000
commit712476ecdb0d8159f369766c2f80504a68aae6a4 (patch)
tree22be775a31b7942f50f97d3198f13ee2559cce7d /src/codec
parent9e0efe3189e0212c6936a9d3103f222ebe46bc1f (diff)
downloadskqp-712476ecdb0d8159f369766c2f80504a68aae6a4.tar.gz
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>
Diffstat (limited to 'src/codec')
-rw-r--r--src/codec/SkBmpCodec.cpp2
-rw-r--r--src/codec/SkBmpMaskCodec.cpp6
-rw-r--r--src/codec/SkBmpRLECodec.cpp11
-rw-r--r--src/codec/SkBmpStandardCodec.cpp8
-rw-r--r--src/codec/SkCodec.cpp20
-rw-r--r--src/codec/SkGifCodec.cpp8
-rw-r--r--src/codec/SkHeifCodec.cpp4
-rw-r--r--src/codec/SkHeifCodec.h2
-rw-r--r--src/codec/SkIcoCodec.cpp13
-rw-r--r--src/codec/SkIcoCodec.h2
-rw-r--r--src/codec/SkJpegCodec.cpp12
-rw-r--r--src/codec/SkJpegCodec.h2
-rw-r--r--src/codec/SkMaskSwizzler.cpp14
-rw-r--r--src/codec/SkMaskSwizzler.h3
-rw-r--r--src/codec/SkPngCodec.cpp6
-rw-r--r--src/codec/SkRawCodec.cpp4
-rw-r--r--src/codec/SkSampledCodec.cpp4
-rw-r--r--src/codec/SkWbmpCodec.cpp6
-rw-r--r--src/codec/SkWbmpCodec.h4
-rw-r--r--src/codec/SkWebpCodec.cpp17
20 files changed, 71 insertions, 77 deletions
diff --git a/src/codec/SkBmpCodec.cpp b/src/codec/SkBmpCodec.cpp
index cb57f5b99a..e20e6c9fc2 100644
--- a/src/codec/SkBmpCodec.cpp
+++ b/src/codec/SkBmpCodec.cpp
@@ -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)
{}
diff --git a/src/codec/SkBmpMaskCodec.cpp b/src/codec/SkBmpMaskCodec.cpp
index 0cb0924d61..055954cac4 100644
--- a/src/codec/SkBmpMaskCodec.cpp
+++ b/src/codec/SkBmpMaskCodec.cpp
@@ -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);
diff --git a/src/codec/SkBmpRLECodec.cpp b/src/codec/SkBmpRLECodec.cpp
index 8a7fb9e8ca..8fc0ea8045 100644
--- a/src/codec/SkBmpRLECodec.cpp
+++ b/src/codec/SkBmpRLECodec.cpp
@@ -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);
}
diff --git a/src/codec/SkBmpStandardCodec.cpp b/src/codec/SkBmpStandardCodec.cpp
index 8e01ac0367..784b8f5fde 100644
--- a/src/codec/SkBmpStandardCodec.cpp
+++ b/src/codec/SkBmpStandardCodec.cpp
@@ -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);
diff --git a/src/codec/SkCodec.cpp b/src/codec/SkCodec.cpp
index 929cc6e868..73a6a2925a 100644
--- a/src/codec/SkCodec.cpp
+++ b/src/codec/SkCodec.cpp
@@ -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;
}
diff --git a/src/codec/SkGifCodec.cpp b/src/codec/SkGifCodec.cpp
index 34dfbef164..2e03b79a47 100644
--- a/src/codec/SkGifCodec.cpp
+++ b/src/codec/SkGifCodec.cpp
@@ -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))
diff --git a/src/codec/SkHeifCodec.cpp b/src/codec/SkHeifCodec.cpp
index c6ce0b9331..32a128b2e2 100644
--- a/src/codec/SkHeifCodec.cpp
+++ b/src/codec/SkHeifCodec.cpp
@@ -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()) {
diff --git a/src/codec/SkHeifCodec.h b/src/codec/SkHeifCodec.h
index 07968058ba..e409097f30 100644
--- a/src/codec/SkHeifCodec.h
+++ b/src/codec/SkHeifCodec.h
@@ -41,7 +41,7 @@ protected:
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 d838079c18..3e5d3eca22 100644
--- a/src/codec/SkIcoCodec.cpp
+++ b/src/codec/SkIcoCodec.cpp
@@ -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;
}
}
diff --git a/src/codec/SkIcoCodec.h b/src/codec/SkIcoCodec.h
index e733e9f19f..9464f47afd 100644
--- a/src/codec/SkIcoCodec.h
+++ b/src/codec/SkIcoCodec.h
@@ -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;
}
diff --git a/src/codec/SkJpegCodec.cpp b/src/codec/SkJpegCodec.cpp
index 926fedf8d2..257b7645e6 100644
--- a/src/codec/SkJpegCodec.cpp
+++ b/src/codec/SkJpegCodec.cpp
@@ -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
diff --git a/src/codec/SkJpegCodec.h b/src/codec/SkJpegCodec.h
index 1b51dbf489..5eff1d5177 100644
--- a/src/codec/SkJpegCodec.h
+++ b/src/codec/SkJpegCodec.h
@@ -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:
/*
diff --git a/src/codec/SkMaskSwizzler.cpp b/src/codec/SkMaskSwizzler.cpp
index 81e3d6e8e8..eeae007d9e 100644
--- a/src/codec/SkMaskSwizzler.cpp
+++ b/src/codec/SkMaskSwizzler.cpp
@@ -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()) {
diff --git a/src/codec/SkMaskSwizzler.h b/src/codec/SkMaskSwizzler.h
index 9425174f1f..b8289f35c3 100644
--- a/src/codec/SkMaskSwizzler.h
+++ b/src/codec/SkMaskSwizzler.h
@@ -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);
diff --git a/src/codec/SkPngCodec.cpp b/src/codec/SkPngCodec.cpp
index 288870a52e..71f07c67b8 100644
--- a/src/codec/SkPngCodec.cpp
+++ b/src/codec/SkPngCodec.cpp
@@ -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);
diff --git a/src/codec/SkRawCodec.cpp b/src/codec/SkRawCodec.cpp
index 2b361b53e6..e520c89c7f 100644
--- a/src/codec/SkRawCodec.cpp
+++ b/src/codec/SkRawCodec.cpp
@@ -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));
diff --git a/src/codec/SkSampledCodec.cpp b/src/codec/SkSampledCodec.cpp
index 0ba7ef9df7..5aa0a2167e 100644
--- a/src/codec/SkSampledCodec.cpp
+++ b/src/codec/SkSampledCodec.cpp
@@ -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);
}
diff --git a/src/codec/SkWbmpCodec.cpp b/src/codec/SkWbmpCodec.cpp
index cc1462e692..6836256433 100644
--- a/src/codec/SkWbmpCodec.cpp
+++ b/src/codec/SkWbmpCodec.cpp
@@ -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);
}
diff --git a/src/codec/SkWbmpCodec.h b/src/codec/SkWbmpCodec.h
index b9df0b9a7d..6e727635ab 100644
--- a/src/codec/SkWbmpCodec.h
+++ b/src/codec/SkWbmpCodec.h
@@ -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:
diff --git a/src/codec/SkWebpCodec.cpp b/src/codec/SkWebpCodec.cpp
index 2737806aee..d637b199cc 100644
--- a/src/codec/SkWebpCodec.cpp
+++ b/src/codec/SkWebpCodec.cpp
@@ -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;