Remove unnecessary getColorSpace() API from SkCodec

Not needed since now we can get it from the SkImageInfo.

TBR=reed@google.com
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2170793004

Review-Url: https://codereview.chromium.org/2170793004
This commit is contained in:
msarett 2016-07-21 11:57:49 -07:00 committed by Commit bot
parent a95220d3b8
commit 530c844d25
8 changed files with 9 additions and 18 deletions

View File

@ -47,7 +47,7 @@ void ColorCodecBench::decodeAndXform() {
codec->startScanlineDecode(fSrcInfo);
SkASSERT(SkCodec::kSuccess == result);
sk_sp<SkColorSpace> srcSpace = sk_ref_sp(codec->getColorSpace());
sk_sp<SkColorSpace> srcSpace = sk_ref_sp(codec->getInfo().colorSpace());
if (!srcSpace) {
srcSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named);
}

View File

@ -902,7 +902,7 @@ Error ColorCodecSrc::draw(SkCanvas* canvas) const {
break;
case kDst_sRGB_Mode:
case kDst_HPZR30w_Mode: {
sk_sp<SkColorSpace> srcSpace = sk_ref_sp(codec->getColorSpace());
sk_sp<SkColorSpace> srcSpace = sk_ref_sp(codec->getInfo().colorSpace());
sk_sp<SkColorSpace> dstSpace = (kDst_sRGB_Mode == fMode) ?
SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named) :
SkColorSpace::NewICC(dstData->data(), dstData->size());

View File

@ -109,13 +109,6 @@ public:
const SkEncodedInfo& getEncodedInfo() const { return fEncodedInfo; }
/**
* Returns the color space associated with the codec.
* Does not affect ownership.
* Might be NULL.
*/
SkColorSpace* getColorSpace() const { return fColorSpace.get(); }
enum Origin {
kTopLeft_Origin = 1, // Default
kTopRight_Origin = 2, // Reflected across y-axis
@ -662,7 +655,6 @@ private:
const SkImageInfo fSrcInfo;
SkAutoTDelete<SkStream> fStream;
bool fNeedsRewind;
sk_sp<SkColorSpace> fColorSpace;
const Origin fOrigin;
// These fields are only meaningful during scanline decodes.

View File

@ -117,7 +117,7 @@ public:
* Returns an SkImageInfo with Skia color and alpha types that are the
* closest possible match to the encoded info.
*/
SkImageInfo makeImageInfo(int width, int height, const sk_sp<SkColorSpace>& colorSpace) const {
SkImageInfo makeImageInfo(int width, int height, sk_sp<SkColorSpace> colorSpace) const {
switch (fColor) {
case kGray_Color:
SkASSERT(kOpaque_Alpha == fAlpha);
@ -147,7 +147,7 @@ public:
case kYUVA_Color:
SkASSERT(kOpaque_Alpha != fAlpha);
return SkImageInfo::Make(width, height, kN32_SkColorType,
kUnpremul_SkAlphaType, colorSpace);
kUnpremul_SkAlphaType, std::move(colorSpace));
default:
SkASSERT(false);
return SkImageInfo::MakeUnknown();

View File

@ -117,10 +117,9 @@ SkCodec* SkCodec::NewFromData(SkData* data, SkPngChunkReader* reader) {
SkCodec::SkCodec(int width, int height, const SkEncodedInfo& info, SkStream* stream,
sk_sp<SkColorSpace> colorSpace, Origin origin)
: fEncodedInfo(info)
, fSrcInfo(info.makeImageInfo(width, height, colorSpace))
, fSrcInfo(info.makeImageInfo(width, height, std::move(colorSpace)))
, fStream(stream)
, fNeedsRewind(false)
, fColorSpace(std::move(colorSpace))
, fOrigin(origin)
, fDstInfo()
, fOptions()

View File

@ -65,7 +65,7 @@ DEF_TEST(ColorSpaceParsePngICCProfile, r) {
REPORTER_ASSERT(r, nullptr != codec);
#if (PNG_LIBPNG_VER_MAJOR > 1) || (PNG_LIBPNG_VER_MAJOR == 1 && PNG_LIBPNG_VER_MINOR >= 6)
SkColorSpace* colorSpace = codec->getColorSpace();
SkColorSpace* colorSpace = codec->getInfo().colorSpace();
REPORTER_ASSERT(r, nullptr != colorSpace);
test_space(r, colorSpace, &g_sRGB_XYZ[0], &g_sRGB_XYZ[3], &g_sRGB_XYZ[6],
@ -86,7 +86,7 @@ DEF_TEST(ColorSpaceParseJpegICCProfile, r) {
return;
}
SkColorSpace* colorSpace = codec->getColorSpace();
SkColorSpace* colorSpace = codec->getInfo().colorSpace();
REPORTER_ASSERT(r, nullptr != colorSpace);
const float red[] = { 0.385117f, 0.716904f, 0.0970612f };

View File

@ -41,7 +41,7 @@ void ImageSlide::load(SkScalar, SkScalar) {
fImage->asLegacyBitmap(&fOriginalBitmap, SkImage::kRO_LegacyBitmapMode);
SkAutoTDelete<SkCodec> codec(SkCodec::NewFromData(encoded.get()));
sk_sp<SkColorSpace> srcSpace = sk_ref_sp(codec->getColorSpace());
sk_sp<SkColorSpace> srcSpace = sk_ref_sp(codec->getInfo().colorSpace());
sk_sp<SkColorSpace> dstSpace = SkColorSpace::NewNamed(SkColorSpace::kAdobeRGB_Named);
std::unique_ptr<SkColorSpaceXform> xform = SkColorSpaceXform::New(srcSpace, dstSpace);
fOriginalBitmap.deepCopyTo(&fXformedBitmap);

View File

@ -151,7 +151,7 @@ int main(int argc, char** argv) {
}
// Draw gamut for the input image.
sk_sp<SkColorSpace> colorSpace = sk_ref_sp(codec->getColorSpace());
sk_sp<SkColorSpace> colorSpace = sk_ref_sp(codec->getInfo().colorSpace());
if (!colorSpace) {
SkDebugf("Image had no embedded color space information. Defaulting to sRGB.\n");
colorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named);