diff options
author | reed <reed@google.com> | 2016-06-17 09:26:41 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-06-17 09:26:41 -0700 |
commit | 960b2d69bbae19dc814f06d841b94ef71e291b48 (patch) | |
tree | ed69d0f4d45e4e7e223a1fc9d8d631addce15e43 /include/core | |
parent | 7d2f607ac16788eac985d4738b8cb901971f33c3 (diff) |
remove colorprofiletype from imageinfo
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2075853002
Review-Url: https://codereview.chromium.org/2075853002
Diffstat (limited to 'include/core')
-rw-r--r-- | include/core/SkBitmap.h | 2 | ||||
-rw-r--r-- | include/core/SkColorSpace.h | 2 | ||||
-rw-r--r-- | include/core/SkImageInfo.h | 115 |
3 files changed, 69 insertions, 50 deletions
diff --git a/include/core/SkBitmap.h b/include/core/SkBitmap.h index b28eca817e..8b499097e9 100644 --- a/include/core/SkBitmap.h +++ b/include/core/SkBitmap.h @@ -86,7 +86,9 @@ public: SkColorType colorType() const { return fInfo.colorType(); } SkAlphaType alphaType() const { return fInfo.alphaType(); } SkColorSpace* colorSpace() const { return fInfo.colorSpace(); } +#ifdef SK_SUPPORT_LEGACY_COLORPROFILETYPE SkColorProfileType profileType() const { return fInfo.profileType(); } +#endif /** * Return the number of bytes per pixel based on the colortype. If the colortype is diff --git a/include/core/SkColorSpace.h b/include/core/SkColorSpace.h index 0f57b6d680..ea3e6726b2 100644 --- a/include/core/SkColorSpace.h +++ b/include/core/SkColorSpace.h @@ -79,6 +79,8 @@ protected: SkColorSpace(GammaNamed gammaNamed, const SkMatrix44& toXYZD50, Named named); + friend Named sk_deduce_named_from_colorspace(SkColorSpace*); + const GammaNamed fGammaNamed; const SkMatrix44 fToXYZD50; const Named fNamed; diff --git a/include/core/SkImageInfo.h b/include/core/SkImageInfo.h index f7a619f9ea..ba4f850264 100644 --- a/include/core/SkImageInfo.h +++ b/include/core/SkImageInfo.h @@ -13,6 +13,8 @@ #include "SkRect.h" #include "SkSize.h" +#define SK_SUPPORT_LEGACY_COLORPROFILETYPE + class SkReadBuffer; class SkWriteBuffer; @@ -169,12 +171,14 @@ enum SkYUVColorSpace { /////////////////////////////////////////////////////////////////////////////// +#ifdef SK_SUPPORT_LEGACY_COLORPROFILETYPE enum SkColorProfileType { kLinear_SkColorProfileType, kSRGB_SkColorProfileType, kLastEnum_SkColorProfileType = kSRGB_SkColorProfileType }; +#endif enum class SkSourceGammaTreatment { kRespect, @@ -193,106 +197,121 @@ public: , fHeight(0) , fColorType(kUnknown_SkColorType) , fAlphaType(kUnknown_SkAlphaType) - , fProfileType(kLinear_SkColorProfileType) {} static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at, - SkColorProfileType pt = kLinear_SkColorProfileType) { - sk_sp<SkColorSpace> cs = (kSRGB_SkColorProfileType == pt) ? - SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named) : nullptr; - return SkImageInfo(width, height, ct, at, pt, cs); + sk_sp<SkColorSpace> cs = nullptr) { + return SkImageInfo(width, height, ct, at, std::move(cs)); } - static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at, - sk_sp<SkColorSpace> cs); - /** * Sets colortype to the native ARGB32 type. */ static SkImageInfo MakeN32(int width, int height, SkAlphaType at, - SkColorProfileType pt = kLinear_SkColorProfileType) { - sk_sp<SkColorSpace> cs = (kSRGB_SkColorProfileType == pt) ? - SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named) : nullptr; - return SkImageInfo(width, height, kN32_SkColorType, at, pt, cs); + sk_sp<SkColorSpace> cs = nullptr) { + return Make(width, height, kN32_SkColorType, at, cs); } /** - * Sets colortype to the native ARGB32 type, and the alphatype to premul. + * Create an ImageInfo marked as SRGB with N32 swizzle. */ - static SkImageInfo MakeN32Premul(int width, int height, - SkColorProfileType pt = kLinear_SkColorProfileType) { - sk_sp<SkColorSpace> cs = (kSRGB_SkColorProfileType == pt) ? - SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named) : nullptr; - return SkImageInfo(width, height, kN32_SkColorType, kPremul_SkAlphaType, pt, cs); - } + static SkImageInfo MakeS32(int width, int height, SkAlphaType at); /** * Sets colortype to the native ARGB32 type, and the alphatype to premul. */ - static SkImageInfo MakeN32Premul(const SkISize& size, - SkColorProfileType pt = kLinear_SkColorProfileType) { - return MakeN32Premul(size.width(), size.height(), pt); + static SkImageInfo MakeN32Premul(int width, int height) { + return Make(width, height, kN32_SkColorType, kPremul_SkAlphaType, nullptr); } - /** - * Create an ImageInfo marked as SRGB with N32 swizzle. - */ - static SkImageInfo MakeS32(int width, int height, SkAlphaType at); + static SkImageInfo MakeN32Premul(const SkISize& size) { + return MakeN32Premul(size.width(), size.height()); + } static SkImageInfo MakeA8(int width, int height) { - return SkImageInfo(width, height, kAlpha_8_SkColorType, kPremul_SkAlphaType, - kLinear_SkColorProfileType, nullptr); + return Make(width, height, kAlpha_8_SkColorType, kPremul_SkAlphaType, nullptr); } static SkImageInfo MakeUnknown(int width, int height) { - return SkImageInfo(width, height, kUnknown_SkColorType, kUnknown_SkAlphaType, - kLinear_SkColorProfileType, nullptr); + return Make(width, height, kUnknown_SkColorType, kUnknown_SkAlphaType, nullptr); } static SkImageInfo MakeUnknown() { - return SkImageInfo(); + return MakeUnknown(0, 0); + } + +#ifdef SK_SUPPORT_LEGACY_COLORPROFILETYPE + static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at, + SkColorProfileType pt) { + sk_sp<SkColorSpace> cs = (kSRGB_SkColorProfileType == pt) ? + SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named) : nullptr; + return Make(width, height, ct, at, cs); } + static SkImageInfo MakeN32(int width, int height, SkAlphaType at, SkColorProfileType pt) { + sk_sp<SkColorSpace> cs = (kSRGB_SkColorProfileType == pt) ? + SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named) : nullptr; + return SkImageInfo(width, height, kN32_SkColorType, at, cs); + } + + /** + * Sets colortype to the native ARGB32 type, and the alphatype to premul. + */ + static SkImageInfo MakeN32Premul(int width, int height, SkColorProfileType pt) { + sk_sp<SkColorSpace> cs = (kSRGB_SkColorProfileType == pt) ? + SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named) : nullptr; + return Make(width, height, kN32_SkColorType, kPremul_SkAlphaType, cs); + } + + /** + * Sets colortype to the native ARGB32 type, and the alphatype to premul. + */ + static SkImageInfo MakeN32Premul(const SkISize& size, SkColorProfileType pt) { + return MakeN32Premul(size.width(), size.height(), pt); + } + + SkColorProfileType profileType() const; + bool isLinear() const { return kLinear_SkColorProfileType == this->profileType(); } + bool isSRGB() const { return kSRGB_SkColorProfileType == this->profileType(); } +#endif + int width() const { return fWidth; } int height() const { return fHeight; } SkColorType colorType() const { return fColorType; } SkAlphaType alphaType() const { return fAlphaType; } SkColorSpace* colorSpace() const { return fColorSpace.get(); } - // Deprecated - SkColorProfileType profileType() const { return fProfileType; } - bool isEmpty() const { return fWidth <= 0 || fHeight <= 0; } bool isOpaque() const { return SkAlphaTypeIsOpaque(fAlphaType); } - // Deprecated - bool isLinear() const { return kLinear_SkColorProfileType == fProfileType; } - bool isSRGB() const { return kSRGB_SkColorProfileType == fProfileType; } - SkISize dimensions() const { return SkISize::Make(fWidth, fHeight); } SkIRect bounds() const { return SkIRect::MakeWH(fWidth, fHeight); } + bool gammaCloseToSRGB() const { + return fColorSpace && fColorSpace->gammaCloseToSRGB(); + } + /** * Return a new ImageInfo with the same colortype and alphatype as this info, * but with the specified width and height. */ SkImageInfo makeWH(int newWidth, int newHeight) const { - return SkImageInfo(newWidth, newHeight, fColorType, fAlphaType, fProfileType, fColorSpace); + return Make(newWidth, newHeight, fColorType, fAlphaType, fColorSpace); } SkImageInfo makeAlphaType(SkAlphaType newAlphaType) const { - return SkImageInfo(fWidth, fHeight, fColorType, newAlphaType, fProfileType, fColorSpace); + return Make(fWidth, fHeight, fColorType, newAlphaType, fColorSpace); } SkImageInfo makeColorType(SkColorType newColorType) const { - return SkImageInfo(fWidth, fHeight, newColorType, fAlphaType, fProfileType, fColorSpace); + return Make(fWidth, fHeight, newColorType, fAlphaType, fColorSpace); } SkImageInfo makeColorSpace(sk_sp<SkColorSpace> cs) const { - return SkImageInfo::Make(fWidth, fHeight, fColorType, fAlphaType, std::move(cs)); + return Make(fWidth, fHeight, fColorType, fAlphaType, std::move(cs)); } int bytesPerPixel() const { return SkColorTypeBytesPerPixel(fColorType); } @@ -316,12 +335,12 @@ public: bool operator==(const SkImageInfo& other) const { return fWidth == other.fWidth && fHeight == other.fHeight && fColorType == other.fColorType && fAlphaType == other.fAlphaType && - fProfileType == other.fProfileType && fColorSpace == other.fColorSpace; + fColorSpace == other.fColorSpace; } bool operator!=(const SkImageInfo& other) const { return fWidth != other.fWidth || fHeight != other.fHeight || fColorType != other.fColorType || fAlphaType != other.fAlphaType || - fProfileType != other.fProfileType || fColorSpace != other.fColorSpace; + fColorSpace != other.fColorSpace; } void unflatten(SkReadBuffer&); @@ -348,12 +367,11 @@ public: } void reset() { + fColorSpace = nullptr; fWidth = 0; fHeight = 0; fColorType = kUnknown_SkColorType; fAlphaType = kUnknown_SkAlphaType; - fProfileType = kLinear_SkColorProfileType; - fColorSpace = nullptr; } SkDEBUGCODE(void validate() const;) @@ -364,16 +382,13 @@ private: int fHeight; SkColorType fColorType; SkAlphaType fAlphaType; - SkColorProfileType fProfileType; - SkImageInfo(int width, int height, SkColorType ct, SkAlphaType at, SkColorProfileType pt, - sk_sp<SkColorSpace> cs) + SkImageInfo(int width, int height, SkColorType ct, SkAlphaType at, sk_sp<SkColorSpace> cs) : fColorSpace(std::move(cs)) , fWidth(width) , fHeight(height) , fColorType(ct) , fAlphaType(at) - , fProfileType(pt) {} }; |