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);
}
/**