Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(265)

Unified Diff: include/core/SkImageInfo.h

Issue 2075853002: remove colorprofiletype from imageinfo (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: continue writing an enum, with forward-mode for flattening the actual profile Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/core/SkColorSpace.h ('k') | src/core/SkBitmapScaler.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkImageInfo.h
diff --git a/include/core/SkImageInfo.h b/include/core/SkImageInfo.h
index f7a619f9ea45b7a60b100a2f4e6345b7005cc25f..ba4f85026486c2a30a414e5534baa71704ef3b9a 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)
{}
};
« no previous file with comments | « include/core/SkColorSpace.h ('k') | src/core/SkBitmapScaler.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698