#define SkEncodedInfo_DEFINED
#include "SkImageInfo.h"
-#include "../private/SkImageInfoPriv.h"
+
+class SkColorSpace;
struct SkEncodedInfo {
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 {
- SkColorProfileType profileType = SkDefaultColorProfile();
+ SkImageInfo makeImageInfo(int width, int height, const sk_sp<SkColorSpace>& colorSpace) const {
switch (fColor) {
case kGray_Color:
SkASSERT(kOpaque_Alpha == fAlpha);
return SkImageInfo::Make(width, height, kGray_8_SkColorType,
- kOpaque_SkAlphaType, profileType);
+ kOpaque_SkAlphaType, colorSpace);
case kGrayAlpha_Color:
SkASSERT(kOpaque_Alpha != fAlpha);
return SkImageInfo::Make(width, height, kN32_SkColorType,
- kUnpremul_SkAlphaType, profileType);
+ kUnpremul_SkAlphaType, colorSpace);
case kPalette_Color: {
SkAlphaType alphaType = (kOpaque_Alpha == fAlpha) ? kOpaque_SkAlphaType :
kUnpremul_SkAlphaType;
return SkImageInfo::Make(width, height, kIndex_8_SkColorType,
- alphaType, profileType);
+ alphaType, colorSpace);
}
case kRGB_Color:
case kBGR_Color:
case kYCCK_Color:
SkASSERT(kOpaque_Alpha == fAlpha);
return SkImageInfo::Make(width, height, kN32_SkColorType,
- kOpaque_SkAlphaType, profileType);
+ kOpaque_SkAlphaType, colorSpace);
case kRGBA_Color:
case kBGRA_Color:
case kYUVA_Color:
SkASSERT(kOpaque_Alpha != fAlpha);
return SkImageInfo::Make(width, height, kN32_SkColorType,
- kUnpremul_SkAlphaType, profileType);
+ kUnpremul_SkAlphaType, colorSpace);
default:
SkASSERT(false);
return SkImageInfo::MakeUnknown();
#ifndef SkImageInfo_DEFINED
#define SkImageInfo_DEFINED
+#include "SkColorSpace.h"
#include "SkMath.h"
#include "SkRect.h"
#include "SkSize.h"
struct SK_API SkImageInfo {
public:
SkImageInfo()
- : fWidth(0)
+ : fColorSpace(nullptr)
+ , fWidth(0)
, fHeight(0)
, fColorType(kUnknown_SkColorType)
, fAlphaType(kUnknown_SkAlphaType)
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at,
SkColorProfileType pt = kLinear_SkColorProfileType) {
- return SkImageInfo(width, height, ct, at, pt);
+ return SkImageInfo(width, height, ct, at, pt, nullptr);
}
+ 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) {
- return SkImageInfo(width, height, kN32_SkColorType, at, pt);
+ return SkImageInfo(width, height, kN32_SkColorType, at, pt, nullptr);
}
/**
*/
static SkImageInfo MakeN32Premul(int width, int height,
SkColorProfileType pt = kLinear_SkColorProfileType) {
- return SkImageInfo(width, height, kN32_SkColorType, kPremul_SkAlphaType, pt);
+ return SkImageInfo(width, height, kN32_SkColorType, kPremul_SkAlphaType, pt, nullptr);
}
/**
static SkImageInfo MakeA8(int width, int height) {
return SkImageInfo(width, height, kAlpha_8_SkColorType, kPremul_SkAlphaType,
- kLinear_SkColorProfileType);
+ kLinear_SkColorProfileType, nullptr);
}
static SkImageInfo MakeUnknown(int width, int height) {
return SkImageInfo(width, height, kUnknown_SkColorType, kUnknown_SkAlphaType,
- kLinear_SkColorProfileType);
+ kLinear_SkColorProfileType, nullptr);
}
static SkImageInfo MakeUnknown() {
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; }
return SkAlphaTypeIsOpaque(fAlphaType);
}
+ // Deprecated
bool isLinear() const { return kLinear_SkColorProfileType == fProfileType; }
bool isSRGB() const { return kSRGB_SkColorProfileType == fProfileType; }
* but with the specified width and height.
*/
SkImageInfo makeWH(int newWidth, int newHeight) const {
- return SkImageInfo::Make(newWidth, newHeight, fColorType, fAlphaType, fProfileType);
+ return SkImageInfo(newWidth, newHeight, fColorType, fAlphaType, fProfileType, fColorSpace);
}
SkImageInfo makeAlphaType(SkAlphaType newAlphaType) const {
- return SkImageInfo::Make(fWidth, fHeight, fColorType, newAlphaType, fProfileType);
+ return SkImageInfo(fWidth, fHeight, fColorType, newAlphaType, fProfileType, fColorSpace);
}
SkImageInfo makeColorType(SkColorType newColorType) const {
- return SkImageInfo::Make(fWidth, fHeight, newColorType, fAlphaType, fProfileType);
+ return SkImageInfo(fWidth, fHeight, newColorType, fAlphaType, fProfileType, fColorSpace);
}
int bytesPerPixel() const { return SkColorTypeBytesPerPixel(fColorType); }
}
bool operator==(const SkImageInfo& other) const {
- return 0 == memcmp(this, &other, sizeof(other));
+ return fWidth == other.fWidth && fHeight == other.fHeight &&
+ fColorType == other.fColorType && fAlphaType == other.fAlphaType &&
+ fProfileType == other.fProfileType && fColorSpace == other.fColorSpace;
}
bool operator!=(const SkImageInfo& other) const {
- return 0 != memcmp(this, &other, sizeof(other));
+ return fWidth != other.fWidth || fHeight != other.fHeight ||
+ fColorType != other.fColorType || fAlphaType != other.fAlphaType ||
+ fProfileType != other.fProfileType || fColorSpace != other.fColorSpace;
}
void unflatten(SkReadBuffer&);
return rowBytes >= rb;
}
+ void reset() {
+ fWidth = 0;
+ fHeight = 0;
+ fColorType = kUnknown_SkColorType;
+ fAlphaType = kUnknown_SkAlphaType;
+ fProfileType = kLinear_SkColorProfileType;
+ fColorSpace = nullptr;
+ }
+
SkDEBUGCODE(void validate() const;)
private:
+ sk_sp<SkColorSpace> fColorSpace;
int fWidth;
int fHeight;
SkColorType fColorType;
SkAlphaType fAlphaType;
SkColorProfileType fProfileType;
- SkImageInfo(int width, int height, SkColorType ct, SkAlphaType at, SkColorProfileType pt)
- : fWidth(width)
+ SkImageInfo(int width, int height, SkColorType ct, SkAlphaType at, SkColorProfileType pt,
+ sk_sp<SkColorSpace> cs)
+ : fColorSpace(std::move(cs))
+ , fWidth(width)
, fHeight(height)
, fColorType(ct)
, fAlphaType(at)