Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
SkColorInfo Struct Reference

#include <SkImageInfo.h>

Public Member Functions

 SkColorInfo ()
 
 ~SkColorInfo ()
 
 SkColorInfo (SkColorType ct, SkAlphaType at, sk_sp< SkColorSpace > cs)
 
 SkColorInfo (const SkColorInfo &)
 
 SkColorInfo (SkColorInfo &&)
 
SkColorInfooperator= (const SkColorInfo &)
 
SkColorInfooperator= (SkColorInfo &&)
 
SkColorSpacecolorSpace () const
 
sk_sp< SkColorSpacerefColorSpace () const
 
SkColorType colorType () const
 
SkAlphaType alphaType () const
 
bool isOpaque () const
 
bool gammaCloseToSRGB () const
 
bool operator== (const SkColorInfo &other) const
 
bool operator!= (const SkColorInfo &other) const
 
SkColorInfo makeAlphaType (SkAlphaType newAlphaType) const
 
SkColorInfo makeColorType (SkColorType newColorType) const
 
SkColorInfo makeColorSpace (sk_sp< SkColorSpace > cs) const
 
int bytesPerPixel () const
 
int shiftPerPixel () const
 

Detailed Description

Describes pixel and encoding. SkImageInfo can be created from SkColorInfo by providing dimensions.

It encodes how pixel bits describe alpha, transparency; color components red, blue, and green; and SkColorSpace, the range and linearity of colors.

Definition at line 111 of file SkImageInfo.h.

Constructor & Destructor Documentation

◆ SkColorInfo() [1/4]

SkColorInfo::SkColorInfo ( )
default

Creates an SkColorInfo with kUnknown_SkColorType, kUnknown_SkAlphaType, and no SkColorSpace.

Returns
empty SkImageInfo

◆ ~SkColorInfo()

SkColorInfo::~SkColorInfo ( )
default

◆ SkColorInfo() [2/4]

SkColorInfo::SkColorInfo ( SkColorType  ct,
SkAlphaType  at,
sk_sp< SkColorSpace cs 
)

Creates SkColorInfo from SkColorType ct, SkAlphaType at, and optionally SkColorSpace cs.

If SkColorSpace cs is nullptr and SkColorInfo is part of drawing source: SkColorSpace defaults to sRGB, mapping into SkSurface SkColorSpace.

Parameters are not validated to see if their values are legal, or that the combination is supported.

Returns
created SkColorInfo

Definition at line 57 of file SkImageInfo.cpp.

58 : fColorSpace(std::move(cs)), fColorType(ct), fAlphaType(at) {}

◆ SkColorInfo() [3/4]

SkColorInfo::SkColorInfo ( const SkColorInfo )
default

◆ SkColorInfo() [4/4]

SkColorInfo::SkColorInfo ( SkColorInfo &&  )
default

Member Function Documentation

◆ alphaType()

SkAlphaType SkColorInfo::alphaType ( ) const
inline

Definition at line 141 of file SkImageInfo.h.

141{ return fAlphaType; }

◆ bytesPerPixel()

int SkColorInfo::bytesPerPixel ( ) const

Returns number of bytes per pixel required by SkColorType. Returns zero if colorType() is kUnknown_SkColorType.

Returns
bytes in pixel

example: https://fiddle.skia.org/c/@ImageInfo_bytesPerPixel

Definition at line 88 of file SkImageInfo.cpp.

88{ return SkColorTypeBytesPerPixel(fColorType); }
int SkColorTypeBytesPerPixel(SkColorType ct)
Definition: SkImageInfo.cpp:16

◆ colorSpace()

SkColorSpace * SkColorInfo::colorSpace ( ) const

Definition at line 66 of file SkImageInfo.cpp.

66{ return fColorSpace.get(); }
T * get() const
Definition: SkRefCnt.h:303

◆ colorType()

SkColorType SkColorInfo::colorType ( ) const
inline

Definition at line 140 of file SkImageInfo.h.

140{ return fColorType; }

◆ gammaCloseToSRGB()

bool SkColorInfo::gammaCloseToSRGB ( ) const

Definition at line 90 of file SkImageInfo.cpp.

90 {
91 return fColorSpace && fColorSpace->gammaCloseToSRGB();
92}
bool gammaCloseToSRGB() const

◆ isOpaque()

bool SkColorInfo::isOpaque ( ) const
inline

Definition at line 143 of file SkImageInfo.h.

143 {
144 return SkAlphaTypeIsOpaque(fAlphaType)
145 || SkColorTypeIsAlwaysOpaque(fColorType);
146 }
static bool SkAlphaTypeIsOpaque(SkAlphaType at)
Definition: SkAlphaType.h:41
SK_API bool SkColorTypeIsAlwaysOpaque(SkColorType ct)
Definition: SkImageInfo.cpp:48

◆ makeAlphaType()

SkColorInfo SkColorInfo::makeAlphaType ( SkAlphaType  newAlphaType) const

Creates SkColorInfo with same SkColorType, SkColorSpace, with SkAlphaType set to newAlphaType.

Created SkColorInfo contains newAlphaType even if it is incompatible with SkColorType, in which case SkAlphaType in SkColorInfo is ignored.

Definition at line 76 of file SkImageInfo.cpp.

76 {
77 return SkColorInfo(this->colorType(), newAlphaType, this->refColorSpace());
78}
sk_sp< SkColorSpace > refColorSpace() const
Definition: SkImageInfo.cpp:67
SkColorType colorType() const
Definition: SkImageInfo.h:140

◆ makeColorSpace()

SkColorInfo SkColorInfo::makeColorSpace ( sk_sp< SkColorSpace cs) const

Creates SkColorInfo with same SkAlphaType, SkColorType, with SkColorSpace set to cs. cs may be nullptr.

Definition at line 84 of file SkImageInfo.cpp.

84 {
85 return SkColorInfo(this->colorType(), this->alphaType(), std::move(cs));
86}
SkAlphaType alphaType() const
Definition: SkImageInfo.h:141

◆ makeColorType()

SkColorInfo SkColorInfo::makeColorType ( SkColorType  newColorType) const

Creates new SkColorInfo with same SkAlphaType, SkColorSpace, with SkColorType set to newColorType.

Definition at line 80 of file SkImageInfo.cpp.

80 {
81 return SkColorInfo(newColorType, this->alphaType(), this->refColorSpace());
82}

◆ operator!=()

bool SkColorInfo::operator!= ( const SkColorInfo other) const

Does other represent a different color type, alpha type, or color space?

Definition at line 74 of file SkImageInfo.cpp.

74{ return !(*this == other); }

◆ operator=() [1/2]

SkColorInfo & SkColorInfo::operator= ( const SkColorInfo )
default

◆ operator=() [2/2]

SkColorInfo & SkColorInfo::operator= ( SkColorInfo &&  )
default

◆ operator==()

bool SkColorInfo::operator== ( const SkColorInfo other) const

Does other represent the same color type, alpha type, and color space?

Definition at line 69 of file SkImageInfo.cpp.

69 {
70 return fColorType == other.fColorType && fAlphaType == other.fAlphaType &&
71 SkColorSpace::Equals(fColorSpace.get(), other.fColorSpace.get());
72}
static bool Equals(const SkColorSpace *, const SkColorSpace *)

◆ refColorSpace()

sk_sp< SkColorSpace > SkColorInfo::refColorSpace ( ) const

Definition at line 67 of file SkImageInfo.cpp.

67{ return fColorSpace; }

◆ shiftPerPixel()

int SkColorInfo::shiftPerPixel ( ) const

Returns bit shift converting row bytes to row pixels. Returns zero for kUnknown_SkColorType.

Returns
one of: 0, 1, 2, 3, 4; left shift to convert pixels to bytes

example: https://fiddle.skia.org/c/@ImageInfo_shiftPerPixel

Definition at line 94 of file SkImageInfo.cpp.

94{ return SkColorTypeShiftPerPixel(fColorType); }
static int SkColorTypeShiftPerPixel(SkColorType ct)

The documentation for this struct was generated from the following files: