8 #ifndef SkImageInfo_DEFINED
9 #define SkImageInfo_DEFINED
16 #include "include/private/base/SkAPI.h"
17 #include "include/private/base/SkDebug.h"
18 #include "include/private/base/SkMath.h"
19 #include "include/private/base/SkTFitsIn.h"
239 return SkImageInfo(dimensions, std::move(colorInfo));
344 return MakeUnknown(0, 0);
351 int width()
const {
return fDimensions.width(); }
357 int height()
const {
return fDimensions.height(); }
385 bool isEmpty()
const {
return fDimensions.isEmpty(); }
401 bool isOpaque()
const {
return fColorInfo.isOpaque(); }
431 return Make({newWidth, newHeight}, fColorInfo);
441 return Make(newSize, fColorInfo);
453 return Make(fDimensions, fColorInfo.makeAlphaType(newAlphaType));
462 return Make(fDimensions, fColorInfo.makeColorType(newColorType));
494 return (uint64_t)sk_64_mul(this->width(), this->bytesPerPixel());
504 uint64_t minRowBytes = this->minRowBytes64();
505 if (!SkTFitsIn<int32_t>(minRowBytes)) {
508 return (
size_t)minRowBytes;
532 return fDimensions == other.
fDimensions && fColorInfo == other.fColorInfo;
542 return !(*
this == other);
565 return this->computeByteSize(this->minRowBytes());
575 return SIZE_MAX == byteSize;
585 if (rowBytes < this->minRowBytes64()) {
588 int shift = this->shiftPerPixel();
589 size_t alignedRowBytes = rowBytes >> shift << shift;
590 return alignedRowBytes == rowBytes;
601 SkDEBUGCODE(
void validate()
const;)
608 : fColorInfo(colorInfo), fDimensions(dimensions) {}
611 : fColorInfo(std::move(colorInfo)), fDimensions(dimensions) {}
static bool SkAlphaTypeIsOpaque(SkAlphaType at)
Returns true if SkAlphaType equals kOpaque_SkAlphaType.
Definition: SkAlphaType.h:41
SkAlphaType
Describes how to interpret the alpha component of a pixel.
Definition: SkAlphaType.h:26
@ kUnknown_SkAlphaType
uninitialized
Definition: SkAlphaType.h:27
SkColorType
Describes how pixel bits encode color.
Definition: SkColorType.h:19
@ kUnknown_SkColorType
uninitialized
Definition: SkColorType.h:20
SK_API int SkColorTypeBytesPerPixel(SkColorType ct)
Returns the number of bytes required to store a pixel, including unused padding.
SkYUVColorSpace
Definition: SkImageInfo.h:68
@ kRec709_Full_SkYUVColorSpace
describes HDTV range
Definition: SkImageInfo.h:71
@ kBT2020_8bit_Limited_SkYUVColorSpace
Definition: SkImageInfo.h:74
@ kBT2020_SkYUVColorSpace
Definition: SkImageInfo.h:87
@ kJPEG_SkYUVColorSpace
Definition: SkImageInfo.h:84
@ kLastEnum_SkYUVColorSpace
last valid value
Definition: SkImageInfo.h:81
@ kRec601_SkYUVColorSpace
Definition: SkImageInfo.h:85
@ kBT2020_12bit_Limited_SkYUVColorSpace
Definition: SkImageInfo.h:78
@ kBT2020_8bit_Full_SkYUVColorSpace
describes UHDTV range, non-constant-luminance
Definition: SkImageInfo.h:73
@ kRec601_Limited_SkYUVColorSpace
describes SDTV range
Definition: SkImageInfo.h:70
@ kRec709_Limited_SkYUVColorSpace
Definition: SkImageInfo.h:72
@ kBT2020_12bit_Full_SkYUVColorSpace
Definition: SkImageInfo.h:77
@ kBT2020_10bit_Full_SkYUVColorSpace
Definition: SkImageInfo.h:75
@ kRec709_SkYUVColorSpace
Definition: SkImageInfo.h:86
@ kIdentity_SkYUVColorSpace
maps Y->R, U->G, V->B
Definition: SkImageInfo.h:79
@ kBT2020_10bit_Limited_SkYUVColorSpace
Definition: SkImageInfo.h:76
@ kJPEG_Full_SkYUVColorSpace
describes full range
Definition: SkImageInfo.h:69
SK_API bool SkColorTypeIsAlwaysOpaque(SkColorType ct)
Returns true if SkColorType always decodes alpha to 1.0, making the pixel fully opaque.
SK_API bool SkColorTypeValidateAlphaType(SkColorType colorType, SkAlphaType alphaType, SkAlphaType *canonical=nullptr)
Returns true if canonical can be set to a valid SkAlphaType for colorType.
Describes pixel and encoding.
Definition: SkImageInfo.h:97
SkColorInfo()
Creates an SkColorInfo with kUnknown_SkColorType, kUnknown_SkAlphaType, and no SkColorSpace.
int bytesPerPixel() const
Returns number of bytes per pixel required by SkColorType.
SkColorInfo makeAlphaType(SkAlphaType newAlphaType) const
Creates SkColorInfo with same SkColorType, SkColorSpace, with SkAlphaType set to newAlphaType.
SkColorInfo(SkColorType ct, SkAlphaType at, sk_sp< SkColorSpace > cs)
Creates SkColorInfo from SkColorType ct, SkAlphaType at, and optionally SkColorSpace cs.
SkAlphaType alphaType() const
Definition: SkImageInfo.h:127
SkColorInfo(const SkColorInfo &)
bool isOpaque() const
Definition: SkImageInfo.h:129
bool operator!=(const SkColorInfo &other) const
Does other represent a different color type, alpha type, or color space?
sk_sp< SkColorSpace > refColorSpace() const
SkColorInfo makeColorSpace(sk_sp< SkColorSpace > cs) const
Creates SkColorInfo with same SkAlphaType, SkColorType, with SkColorSpace set to cs.
int shiftPerPixel() const
Returns bit shift converting row bytes to row pixels.
SkColorInfo makeColorType(SkColorType newColorType) const
Creates new SkColorInfo with same SkAlphaType, SkColorSpace, with SkColorType set to newColorType.
bool gammaCloseToSRGB() const
SkColorInfo & operator=(const SkColorInfo &)
SkColorInfo & operator=(SkColorInfo &&)
SkColorInfo(SkColorInfo &&)
bool operator==(const SkColorInfo &other) const
Does other represent the same color type, alpha type, and color space?
SkColorSpace * colorSpace() const
SkColorType colorType() const
Definition: SkImageInfo.h:126
Definition: SkColorSpace.h:107
sk_sp< SkDrawLooper > SK_API Make(SkColor4f color, SkColorSpace *cs, SkScalar sigma, SkScalar dx, SkScalar dy)
SkIRect holds four 32-bit integer coordinates describing the upper and lower bounds of a rectangle.
Definition: SkRect.h:32
static constexpr SkIRect MakeSize(const SkISize &size)
Returns constructed SkIRect set to (0, 0, size.width(), size.height()).
Definition: SkRect.h:66
Describes pixel dimensions and encoding.
Definition: SkImageInfo.h:194
SkImageInfo makeWH(int newWidth, int newHeight) const
Creates SkImageInfo with the same SkColorType, SkColorSpace, and SkAlphaType, with dimensions set to ...
Definition: SkImageInfo.h:430
static bool ByteSizeOverflowed(size_t byteSize)
Returns true if byteSize equals SIZE_MAX.
Definition: SkImageInfo.h:574
static SkImageInfo MakeA8(SkISize dimensions)
Creates SkImageInfo from integral dimensions, kAlpha_8_SkColorType, kPremul_SkAlphaType,...
static SkImageInfo Make(SkISize dimensions, SkColorType ct, SkAlphaType at)
bool isEmpty() const
Returns if SkImageInfo describes an empty area of pixels by checking if either width or height is zer...
Definition: SkImageInfo.h:385
bool isOpaque() const
Returns true if SkAlphaType is set to hint that all pixels are opaque; their alpha value is implicitl...
Definition: SkImageInfo.h:401
bool operator!=(const SkImageInfo &other) const
Compares SkImageInfo with other, and returns true if width, height, SkColorType, SkAlphaType,...
Definition: SkImageInfo.h:541
SkImageInfo(SkISize dimensions, SkColorInfo &&colorInfo)
Definition: SkImageInfo.h:610
static SkImageInfo Make(SkISize dimensions, SkColorType ct, SkAlphaType at, sk_sp< SkColorSpace > cs)
static SkImageInfo Make(SkISize dimensions, SkColorInfo &&colorInfo)
Definition: SkImageInfo.h:238
SkImageInfo makeAlphaType(SkAlphaType newAlphaType) const
Creates SkImageInfo with same SkColorType, SkColorSpace, width, and height, with SkAlphaType set to n...
Definition: SkImageInfo.h:452
bool operator==(const SkImageInfo &other) const
Compares SkImageInfo with other, and returns true if width, height, SkColorType, SkAlphaType,...
Definition: SkImageInfo.h:531
static SkImageInfo MakeN32Premul(SkISize dimensions, sk_sp< SkColorSpace > cs)
SkIRect bounds() const
Returns SkIRect { 0, 0, width(), height() }.
Definition: SkImageInfo.h:413
SkColorSpace * colorSpace() const
Returns SkColorSpace, the range of colors.
void reset()
Creates an empty SkImageInfo with kUnknown_SkColorType, kUnknown_SkAlphaType, a width and height of z...
Definition: SkImageInfo.h:596
const SkColorInfo & colorInfo() const
Returns the dimensionless SkColorInfo that represents the same color type, alpha type,...
Definition: SkImageInfo.h:390
size_t minRowBytes() const
Returns minimum bytes per row, computed from pixel width() and SkColorType, which specifies bytesPerP...
Definition: SkImageInfo.h:503
static SkImageInfo Make(SkISize dimensions, const SkColorInfo &colorInfo)
Creates SkImageInfo from integral dimensions and SkColorInfo colorInfo,.
Definition: SkImageInfo.h:235
static SkImageInfo MakeS32(int width, int height, SkAlphaType at)
Creates SkImageInfo from integral dimensions width and height, kN32_SkColorType, SkAlphaType at,...
size_t computeByteSize(size_t rowBytes) const
Returns storage required by pixel array, given SkImageInfo dimensions, SkColorType,...
static SkImageInfo MakeN32Premul(int width, int height)
Creates SkImageInfo from integral dimensions width and height, kN32_SkColorType, kPremul_SkAlphaType,...
SkImageInfo makeDimensions(SkISize newSize) const
Creates SkImageInfo with the same SkColorType, SkColorSpace, and SkAlphaType, with dimensions set to ...
Definition: SkImageInfo.h:440
static SkImageInfo MakeUnknown(int width, int height)
Creates SkImageInfo from integral dimensions width and height, kUnknown_SkColorType,...
sk_sp< SkColorSpace > refColorSpace() const
Returns smart pointer to SkColorSpace, the range of colors.
int bytesPerPixel() const
Returns number of bytes per pixel required by SkColorType.
Definition: SkImageInfo.h:478
SkISize dimensions() const
Returns SkISize { width(), height() }.
Definition: SkImageInfo.h:407
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
Creates SkImageInfo from integral dimensions width and height, SkColorType ct, SkAlphaType at,...
SkDEBUGCODE(void validate() const ;) private SkISize fDimensions
Asserts if internal values are illegal or inconsistent.
Definition: SkImageInfo.h:605
bool gammaCloseToSRGB() const
Returns true if associated SkColorSpace is not nullptr, and SkColorSpace gamma is approximately the s...
Definition: SkImageInfo.h:421
SkImageInfo makeColorSpace(sk_sp< SkColorSpace > cs) const
Creates SkImageInfo with same SkAlphaType, SkColorType, width, and height, with SkColorSpace set to c...
size_t computeMinByteSize() const
Returns storage required by pixel array, given SkImageInfo dimensions, and SkColorType.
Definition: SkImageInfo.h:564
static SkImageInfo MakeUnknown()
Creates SkImageInfo from integral dimensions width and height set to zero, kUnknown_SkColorType,...
Definition: SkImageInfo.h:343
static SkImageInfo MakeN32Premul(SkISize dimensions)
Creates SkImageInfo from integral dimensions width and height, kN32_SkColorType, kPremul_SkAlphaType,...
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at, sk_sp< SkColorSpace > cs)
int width() const
Returns pixel count in each row.
Definition: SkImageInfo.h:351
static SkImageInfo MakeN32(int width, int height, SkAlphaType at)
Creates SkImageInfo from integral dimensions width and height, kN32_SkColorType, SkAlphaType at,...
SkImageInfo(SkISize dimensions, const SkColorInfo &colorInfo)
Definition: SkImageInfo.h:607
SkAlphaType alphaType() const
Definition: SkImageInfo.h:361
SkColorType colorType() const
Definition: SkImageInfo.h:359
static SkImageInfo MakeA8(int width, int height)
Creates SkImageInfo from integral dimensions width and height, kAlpha_8_SkColorType,...
static SkImageInfo MakeN32(int width, int height, SkAlphaType at, sk_sp< SkColorSpace > cs)
uint64_t minRowBytes64() const
Returns minimum bytes per row, computed from pixel width() and SkColorType, which specifies bytesPerP...
Definition: SkImageInfo.h:493
int shiftPerPixel() const
Returns bit shift converting row bytes to row pixels.
Definition: SkImageInfo.h:485
int height() const
Returns pixel row count.
Definition: SkImageInfo.h:357
static SkImageInfo MakeN32Premul(int width, int height, sk_sp< SkColorSpace > cs)
size_t computeOffset(int x, int y, size_t rowBytes) const
Returns byte offset of pixel from pixel base address.
SkImageInfo()=default
Creates an empty SkImageInfo with kUnknown_SkColorType, kUnknown_SkAlphaType, a width and height of z...
SkImageInfo makeColorType(SkColorType newColorType) const
Creates SkImageInfo with same SkAlphaType, SkColorSpace, width, and height, with SkColorType set to n...
Definition: SkImageInfo.h:461
bool validRowBytes(size_t rowBytes) const
Returns true if rowBytes is valid for this SkImageInfo.
Definition: SkImageInfo.h:584