Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
SkImageInfo Struct Reference

#include <SkImageInfo.h>

Public Member Functions

 SkImageInfo ()=default
 
int width () const
 
int height () const
 
SkColorType colorType () const
 
SkAlphaType alphaType () const
 
SkColorSpacecolorSpace () const
 
sk_sp< SkColorSpacerefColorSpace () const
 
bool isEmpty () const
 
const SkColorInfocolorInfo () const
 
bool isOpaque () const
 
SkISize dimensions () const
 
SkIRect bounds () const
 
bool gammaCloseToSRGB () const
 
SkImageInfo makeWH (int newWidth, int newHeight) const
 
SkImageInfo makeDimensions (SkISize newSize) const
 
SkImageInfo makeAlphaType (SkAlphaType newAlphaType) const
 
SkImageInfo makeColorType (SkColorType newColorType) const
 
SkImageInfo makeColorSpace (sk_sp< SkColorSpace > cs) const
 
int bytesPerPixel () const
 
int shiftPerPixel () const
 
uint64_t minRowBytes64 () const
 
size_t minRowBytes () const
 
size_t computeOffset (int x, int y, size_t rowBytes) const
 
bool operator== (const SkImageInfo &other) const
 
bool operator!= (const SkImageInfo &other) const
 
size_t computeByteSize (size_t rowBytes) const
 
size_t computeMinByteSize () const
 
bool validRowBytes (size_t rowBytes) const
 
void reset ()
 
 SkImageInfo (SkISize dimensions, const SkColorInfo &colorInfo)
 
 SkImageInfo (SkISize dimensions, SkColorInfo &&colorInfo)
 

Static Public Member Functions

static SkImageInfo Make (int width, int height, SkColorType ct, SkAlphaType at)
 
static SkImageInfo Make (int width, int height, SkColorType ct, SkAlphaType at, sk_sp< SkColorSpace > cs)
 
static SkImageInfo Make (SkISize dimensions, SkColorType ct, SkAlphaType at)
 
static SkImageInfo Make (SkISize dimensions, SkColorType ct, SkAlphaType at, sk_sp< SkColorSpace > cs)
 
static SkImageInfo Make (SkISize dimensions, const SkColorInfo &colorInfo)
 
static SkImageInfo Make (SkISize dimensions, SkColorInfo &&colorInfo)
 
static SkImageInfo MakeN32 (int width, int height, SkAlphaType at)
 
static SkImageInfo MakeN32 (int width, int height, SkAlphaType at, sk_sp< SkColorSpace > cs)
 
static SkImageInfo MakeS32 (int width, int height, SkAlphaType at)
 
static SkImageInfo MakeN32Premul (int width, int height)
 
static SkImageInfo MakeN32Premul (int width, int height, sk_sp< SkColorSpace > cs)
 
static SkImageInfo MakeN32Premul (SkISize dimensions)
 
static SkImageInfo MakeN32Premul (SkISize dimensions, sk_sp< SkColorSpace > cs)
 
static SkImageInfo MakeA8 (int width, int height)
 
static SkImageInfo MakeA8 (SkISize dimensions)
 
static SkImageInfo MakeUnknown (int width, int height)
 
static SkImageInfo MakeUnknown ()
 
static bool ByteSizeOverflowed (size_t byteSize)
 

Public Attributes

SkDEBUGCODE(void validate() const ;) private SkISize fDimensions = {0, 0}
 

Detailed Description

Describes pixel dimensions and encoding. SkBitmap, SkImage, PixMap, and SkSurface can be created from SkImageInfo. SkImageInfo can be retrieved from SkBitmap and SkPixmap, but not from SkImage and SkSurface. For example, SkImage and SkSurface implementations may defer pixel depth, so may not completely specify SkImageInfo.

SkImageInfo contains dimensions, the pixel integral width and height. 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 208 of file SkImageInfo.h.

Constructor & Destructor Documentation

◆ SkImageInfo() [1/3]

SkImageInfo::SkImageInfo ( )
default

Creates an empty SkImageInfo with kUnknown_SkColorType, kUnknown_SkAlphaType, a width and height of zero, and no SkColorSpace.

Returns
empty SkImageInfo

◆ SkImageInfo() [2/3]

SkImageInfo::SkImageInfo ( SkISize  dimensions,
const SkColorInfo colorInfo 
)
inline

Definition at line 621 of file SkImageInfo.h.

622 : fColorInfo(colorInfo), fDimensions(dimensions) {}
const SkColorInfo & colorInfo() const
SkISize dimensions() const
SkDEBUGCODE(void validate() const ;) private SkISize fDimensions

◆ SkImageInfo() [3/3]

SkImageInfo::SkImageInfo ( SkISize  dimensions,
SkColorInfo &&  colorInfo 
)
inline

Definition at line 624 of file SkImageInfo.h.

625 : fColorInfo(std::move(colorInfo)), fDimensions(dimensions) {}

Member Function Documentation

◆ alphaType()

SkAlphaType SkImageInfo::alphaType ( ) const
inline

Definition at line 375 of file SkImageInfo.h.

375{ return fColorInfo.alphaType(); }

◆ bounds()

SkIRect SkImageInfo::bounds ( ) const
inline

Returns SkIRect { 0, 0, width(), height() }.

Returns
integral rectangle from origin to width() and height()

Definition at line 427 of file SkImageInfo.h.

static constexpr SkIRect MakeSize(const SkISize &size)
Definition SkRect.h:66

◆ ByteSizeOverflowed()

static bool SkImageInfo::ByteSizeOverflowed ( size_t  byteSize)
inlinestatic

Returns true if byteSize equals SIZE_MAX. computeByteSize() and computeMinByteSize() return SIZE_MAX if size_t can not hold buffer size.

Parameters
byteSizeresult of computeByteSize() or computeMinByteSize()
Returns
true if computeByteSize() or computeMinByteSize() result exceeds size_t

Definition at line 588 of file SkImageInfo.h.

588 {
589 return SIZE_MAX == byteSize;
590 }

◆ bytesPerPixel()

int SkImageInfo::bytesPerPixel ( ) const
inline

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

Returns
bytes in pixel

Definition at line 492 of file SkImageInfo.h.

492{ return fColorInfo.bytesPerPixel(); }

◆ colorInfo()

const SkColorInfo & SkImageInfo::colorInfo ( ) const
inline

Returns the dimensionless SkColorInfo that represents the same color type, alpha type, and color space as this SkImageInfo.

Definition at line 404 of file SkImageInfo.h.

404{ return fColorInfo; }

◆ colorSpace()

SkColorSpace * SkImageInfo::colorSpace ( ) const

Returns SkColorSpace, the range of colors. The reference count of SkColorSpace is unchanged. The returned SkColorSpace is immutable.

Returns
SkColorSpace, or nullptr

Definition at line 119 of file SkImageInfo.cpp.

119{ return fColorInfo.colorSpace(); }

◆ colorType()

SkColorType SkImageInfo::colorType ( ) const
inline

Definition at line 373 of file SkImageInfo.h.

373{ return fColorInfo.colorType(); }

◆ computeByteSize()

size_t SkImageInfo::computeByteSize ( size_t  rowBytes) const

Returns storage required by pixel array, given SkImageInfo dimensions, SkColorType, and rowBytes. rowBytes is assumed to be at least as large as minRowBytes().

Returns zero if height is zero. Returns SIZE_MAX if answer exceeds the range of size_t.

Parameters
rowBytessize of pixel row or larger
Returns
memory required by pixel buffer

Definition at line 104 of file SkImageInfo.cpp.

104 {
105 if (0 == this->height()) {
106 return 0;
107 }
108 SkSafeMath safe;
109 size_t bytes = safe.add(safe.mul(safe.addInt(this->height(), -1), rowBytes),
110 safe.mul(this->width(), this->bytesPerPixel()));
111
112 // The CPU backend implements some memory operations on images using instructions that take a
113 // signed 32-bit offset from the base. If we ever make an image larger than that, overflow can
114 // cause us to read/write memory that starts 2GB *before* the buffer. (crbug.com/1264705)
115 constexpr size_t kMaxSigned32BitSize = SK_MaxS32;
116 return (safe.ok() && (bytes <= kMaxSigned32BitSize)) ? bytes : SIZE_MAX;
117}
static constexpr int32_t SK_MaxS32
Definition SkMath.h:21
int addInt(int a, int b)
Definition SkSafeMath.h:43
size_t add(size_t x, size_t y)
Definition SkSafeMath.h:33
bool ok() const
Definition SkSafeMath.h:26
size_t mul(size_t x, size_t y)
Definition SkSafeMath.h:29
int32_t height

◆ computeMinByteSize()

size_t SkImageInfo::computeMinByteSize ( ) const
inline

Returns storage required by pixel array, given SkImageInfo dimensions, and SkColorType. Uses minRowBytes() to compute bytes for pixel row.

Returns zero if height is zero. Returns SIZE_MAX if answer exceeds the range of size_t.

Returns
least memory required by pixel buffer

Definition at line 578 of file SkImageInfo.h.

578 {
579 return this->computeByteSize(this->minRowBytes());
580 }
size_t minRowBytes() const
size_t computeByteSize(size_t rowBytes) const

◆ computeOffset()

size_t SkImageInfo::computeOffset ( int  x,
int  y,
size_t  rowBytes 
) const

Returns byte offset of pixel from pixel base address.

Asserts in debug build if x or y is outside of bounds. Does not assert if rowBytes is smaller than minRowBytes(), even though result may be incorrect.

Parameters
xcolumn index, zero or greater, and less than width()
yrow index, zero or greater, and less than height()
rowBytessize of pixel row or larger
Returns
offset within pixel array

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

Definition at line 98 of file SkImageInfo.cpp.

98 {
99 SkASSERT((unsigned)x < (unsigned)this->width());
100 SkASSERT((unsigned)y < (unsigned)this->height());
101 return SkColorTypeComputeOffset(this->colorType(), x, y, rowBytes);
102}
#define SkASSERT(cond)
Definition SkAssert.h:116
static size_t SkColorTypeComputeOffset(SkColorType ct, int x, int y, size_t rowBytes)
double y
double x
int32_t width
SkColorType colorType() const

◆ dimensions()

SkISize SkImageInfo::dimensions ( ) const
inline

Returns SkISize { width(), height() }.

Returns
integral size of width() and height()

Definition at line 421 of file SkImageInfo.h.

421{ return fDimensions; }

◆ gammaCloseToSRGB()

bool SkImageInfo::gammaCloseToSRGB ( ) const
inline

Returns true if associated SkColorSpace is not nullptr, and SkColorSpace gamma is approximately the same as sRGB. This includes the

Returns
true if SkColorSpace gamma is approximately the same as sRGB

Definition at line 435 of file SkImageInfo.h.

435{ return fColorInfo.gammaCloseToSRGB(); }

◆ height()

int SkImageInfo::height ( ) const
inline

Returns pixel row count.

Returns
pixel height

Definition at line 371 of file SkImageInfo.h.

371{ return fDimensions.height(); }
constexpr int32_t height() const
Definition SkSize.h:37

◆ isEmpty()

bool SkImageInfo::isEmpty ( ) const
inline

Returns if SkImageInfo describes an empty area of pixels by checking if either width or height is zero or smaller.

Returns
true if either dimension is zero or smaller

Definition at line 399 of file SkImageInfo.h.

399{ return fDimensions.isEmpty(); }
bool isEmpty() const
Definition SkSize.h:31

◆ isOpaque()

bool SkImageInfo::isOpaque ( ) const
inline

Returns true if SkAlphaType is set to hint that all pixels are opaque; their alpha value is implicitly or explicitly 1.0. If true, and all pixels are not opaque, Skia may draw incorrectly.

Does not check if SkColorType allows alpha, or if any pixel value has transparency.

Returns
true if SkAlphaType is kOpaque_SkAlphaType

Definition at line 415 of file SkImageInfo.h.

415{ return fColorInfo.isOpaque(); }

◆ Make() [1/6]

SkImageInfo SkImageInfo::Make ( int  width,
int  height,
SkColorType  ct,
SkAlphaType  at 
)
static

Creates SkImageInfo from integral dimensions width and height, SkColorType ct, SkAlphaType at, and optionally SkColorSpace cs.

If SkColorSpace cs is nullptr and SkImageInfo 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.

Parameters
widthpixel column count; must be zero or greater
heightpixel row count; must be zero or greater
csrange of colors; may be nullptr
Returns
created SkImageInfo

Definition at line 127 of file SkImageInfo.cpp.

127 {
128 return Make(width, height, ct, at, nullptr);
129}
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)

◆ Make() [2/6]

SkImageInfo SkImageInfo::Make ( int  width,
int  height,
SkColorType  ct,
SkAlphaType  at,
sk_sp< SkColorSpace cs 
)
static

Definition at line 131 of file SkImageInfo.cpp.

132 {
133 return SkImageInfo({width, height}, {ct, at, std::move(cs)});
134}
SkImageInfo()=default

◆ Make() [3/6]

static SkImageInfo SkImageInfo::Make ( SkISize  dimensions,
const SkColorInfo colorInfo 
)
inlinestatic

Creates SkImageInfo from integral dimensions and SkColorInfo colorInfo,

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

Parameters
dimensionspixel column and row count; must be zeros or greater
SkColorInfothe pixel encoding consisting of SkColorType, SkAlphaType, and SkColorSpace (which may be nullptr)
Returns
created SkImageInfo

Definition at line 249 of file SkImageInfo.h.

249 {
251 }

◆ Make() [4/6]

static SkImageInfo SkImageInfo::Make ( SkISize  dimensions,
SkColorInfo &&  colorInfo 
)
inlinestatic

Definition at line 252 of file SkImageInfo.h.

252 {
253 return SkImageInfo(dimensions, std::move(colorInfo));
254 }

◆ Make() [5/6]

SkImageInfo SkImageInfo::Make ( SkISize  dimensions,
SkColorType  ct,
SkAlphaType  at 
)
static

Definition at line 136 of file SkImageInfo.cpp.

136 {
137 return Make(dimensions, ct, at, nullptr);
138}

◆ Make() [6/6]

SkImageInfo SkImageInfo::Make ( SkISize  dimensions,
SkColorType  ct,
SkAlphaType  at,
sk_sp< SkColorSpace cs 
)
static

Definition at line 140 of file SkImageInfo.cpp.

141 {
142 return SkImageInfo(dimensions, {ct, at, std::move(cs)});
143}

◆ MakeA8() [1/2]

SkImageInfo SkImageInfo::MakeA8 ( int  width,
int  height 
)
static

Creates SkImageInfo from integral dimensions width and height, kAlpha_8_SkColorType, kPremul_SkAlphaType, with SkColorSpace set to nullptr.

Parameters
widthpixel column count; must be zero or greater
heightpixel row count; must be zero or greater
Returns
created SkImageInfo

Definition at line 173 of file SkImageInfo.cpp.

173 {
175}
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition SkAlphaType.h:29
@ kAlpha_8_SkColorType
pixel with alpha in 8-bit byte
Definition SkColorType.h:21

◆ MakeA8() [2/2]

SkImageInfo SkImageInfo::MakeA8 ( SkISize  dimensions)
static

Creates SkImageInfo from integral dimensions, kAlpha_8_SkColorType, kPremul_SkAlphaType, with SkColorSpace set to nullptr.

Parameters
dimensionspixel row and column count; must be zero or greater
Returns
created SkImageInfo

Definition at line 177 of file SkImageInfo.cpp.

177 {
179}

◆ makeAlphaType()

SkImageInfo SkImageInfo::makeAlphaType ( SkAlphaType  newAlphaType) const
inline

Creates SkImageInfo with same SkColorType, SkColorSpace, width, and height, with SkAlphaType set to newAlphaType.

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

Returns
created SkImageInfo

Definition at line 466 of file SkImageInfo.h.

466 {
467 return Make(fDimensions, fColorInfo.makeAlphaType(newAlphaType));
468 }

◆ makeColorSpace()

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

Creates SkImageInfo with same SkAlphaType, SkColorType, width, and height, with SkColorSpace set to cs.

Parameters
csrange of colors; may be nullptr
Returns
created SkImageInfo

Definition at line 123 of file SkImageInfo.cpp.

123 {
124 return Make(fDimensions, fColorInfo.makeColorSpace(std::move(cs)));
125}

◆ makeColorType()

SkImageInfo SkImageInfo::makeColorType ( SkColorType  newColorType) const
inline

Creates SkImageInfo with same SkAlphaType, SkColorSpace, width, and height, with SkColorType set to newColorType.

Returns
created SkImageInfo

Definition at line 475 of file SkImageInfo.h.

475 {
476 return Make(fDimensions, fColorInfo.makeColorType(newColorType));
477 }

◆ makeDimensions()

SkImageInfo SkImageInfo::makeDimensions ( SkISize  newSize) const
inline

Creates SkImageInfo with the same SkColorType, SkColorSpace, and SkAlphaType, with dimensions set to newDimensions.

Parameters
newSizepixel column and row count; must be zero or greater
Returns
created SkImageInfo

Definition at line 454 of file SkImageInfo.h.

454 {
455 return Make(newSize, fColorInfo);
456 }

◆ MakeN32() [1/2]

SkImageInfo SkImageInfo::MakeN32 ( int  width,
int  height,
SkAlphaType  at 
)
static

Creates SkImageInfo from integral dimensions width and height, kN32_SkColorType, SkAlphaType at, and optionally SkColorSpace cs. kN32_SkColorType will equal either kBGRA_8888_SkColorType or kRGBA_8888_SkColorType, whichever is optimal.

If SkColorSpace cs is nullptr and SkImageInfo 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.

Parameters
widthpixel column count; must be zero or greater
heightpixel row count; must be zero or greater
csrange of colors; may be nullptr
Returns
created SkImageInfo

Definition at line 145 of file SkImageInfo.cpp.

145 {
146 return MakeN32(width, height, at, nullptr);
147}
static SkImageInfo MakeN32(int width, int height, SkAlphaType at)

◆ MakeN32() [2/2]

SkImageInfo SkImageInfo::MakeN32 ( int  width,
int  height,
SkAlphaType  at,
sk_sp< SkColorSpace cs 
)
static

Definition at line 149 of file SkImageInfo.cpp.

149 {
150 return Make({width, height}, kN32_SkColorType, at, std::move(cs));
151}

◆ MakeN32Premul() [1/4]

SkImageInfo SkImageInfo::MakeN32Premul ( int  width,
int  height 
)
static

Creates SkImageInfo from integral dimensions width and height, kN32_SkColorType, kPremul_SkAlphaType, with optional SkColorSpace.

If SkColorSpace cs is nullptr and SkImageInfo 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.

Parameters
widthpixel column count; must be zero or greater
heightpixel row count; must be zero or greater
csrange of colors; may be nullptr
Returns
created SkImageInfo

Definition at line 157 of file SkImageInfo.cpp.

157 {
158 return MakeN32Premul(width, height, nullptr);
159}
static SkImageInfo MakeN32Premul(int width, int height)

◆ MakeN32Premul() [2/4]

SkImageInfo SkImageInfo::MakeN32Premul ( int  width,
int  height,
sk_sp< SkColorSpace cs 
)
static

Definition at line 161 of file SkImageInfo.cpp.

161 {
162 return Make({width, height}, kN32_SkColorType, kPremul_SkAlphaType, std::move(cs));
163}

◆ MakeN32Premul() [3/4]

SkImageInfo SkImageInfo::MakeN32Premul ( SkISize  dimensions)
static

Creates SkImageInfo from integral dimensions width and height, kN32_SkColorType, kPremul_SkAlphaType, with SkColorSpace set to nullptr.

If SkImageInfo 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.

Parameters
dimensionswidth and height, each must be zero or greater
csrange of colors; may be nullptr
Returns
created SkImageInfo

Definition at line 165 of file SkImageInfo.cpp.

165 {
166 return MakeN32Premul(dimensions, nullptr);
167}

◆ MakeN32Premul() [4/4]

SkImageInfo SkImageInfo::MakeN32Premul ( SkISize  dimensions,
sk_sp< SkColorSpace cs 
)
static

Definition at line 169 of file SkImageInfo.cpp.

169 {
170 return Make(dimensions, kN32_SkColorType, kPremul_SkAlphaType, std::move(cs));
171}

◆ MakeS32()

SkImageInfo SkImageInfo::MakeS32 ( int  width,
int  height,
SkAlphaType  at 
)
static

Creates SkImageInfo from integral dimensions width and height, kN32_SkColorType, SkAlphaType at, with sRGB SkColorSpace.

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

Parameters
widthpixel column count; must be zero or greater
heightpixel row count; must be zero or greater
Returns
created SkImageInfo

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

Definition at line 153 of file SkImageInfo.cpp.

153 {
154 return SkImageInfo({width, height}, {kN32_SkColorType, at, SkColorSpace::MakeSRGB()});
155}
static sk_sp< SkColorSpace > MakeSRGB()

◆ MakeUnknown() [1/2]

static SkImageInfo SkImageInfo::MakeUnknown ( )
inlinestatic

Creates SkImageInfo from integral dimensions width and height set to zero, kUnknown_SkColorType, kUnknown_SkAlphaType, with SkColorSpace set to nullptr.

Returned SkImageInfo as part of source does not draw, and as part of destination can not be drawn to.

Returns
created SkImageInfo

Definition at line 357 of file SkImageInfo.h.

357 {
358 return MakeUnknown(0, 0);
359 }
static SkImageInfo MakeUnknown()

◆ MakeUnknown() [2/2]

SkImageInfo SkImageInfo::MakeUnknown ( int  width,
int  height 
)
static

Creates SkImageInfo from integral dimensions width and height, kUnknown_SkColorType, kUnknown_SkAlphaType, with SkColorSpace set to nullptr.

Returned SkImageInfo as part of source does not draw, and as part of destination can not be drawn to.

Parameters
widthpixel column count; must be zero or greater
heightpixel row count; must be zero or greater
Returns
created SkImageInfo

Definition at line 181 of file SkImageInfo.cpp.

181 {
183}
@ kUnknown_SkAlphaType
uninitialized
Definition SkAlphaType.h:27
@ kUnknown_SkColorType
uninitialized
Definition SkColorType.h:20

◆ makeWH()

SkImageInfo SkImageInfo::makeWH ( int  newWidth,
int  newHeight 
) const
inline

Creates SkImageInfo with the same SkColorType, SkColorSpace, and SkAlphaType, with dimensions set to width and height.

Parameters
newWidthpixel column count; must be zero or greater
newHeightpixel row count; must be zero or greater
Returns
created SkImageInfo

Definition at line 444 of file SkImageInfo.h.

444 {
445 return Make({newWidth, newHeight}, fColorInfo);
446 }

◆ minRowBytes()

size_t SkImageInfo::minRowBytes ( ) const
inline

Returns minimum bytes per row, computed from pixel width() and SkColorType, which specifies bytesPerPixel(). SkBitmap maximum value for row bytes must fit in 31 bits.

Returns
width() times bytesPerPixel() as size_t

Definition at line 517 of file SkImageInfo.h.

517 {
518 uint64_t minRowBytes = this->minRowBytes64();
519 if (!SkTFitsIn<int32_t>(minRowBytes)) {
520 return 0;
521 }
522 return (size_t)minRowBytes;
523 }
uint64_t minRowBytes64() const

◆ minRowBytes64()

uint64_t SkImageInfo::minRowBytes64 ( ) const
inline

Returns minimum bytes per row, computed from pixel width() and SkColorType, which specifies bytesPerPixel(). SkBitmap maximum value for row bytes must fit in 31 bits.

Returns
width() times bytesPerPixel() as unsigned 64-bit integer

Definition at line 507 of file SkImageInfo.h.

507 {
508 return (uint64_t)sk_64_mul(this->width(), this->bytesPerPixel());
509 }
static int64_t sk_64_mul(int64_t a, int64_t b)
Definition SkMath.h:33
int bytesPerPixel() const

◆ operator!=()

bool SkImageInfo::operator!= ( const SkImageInfo other) const
inline

Compares SkImageInfo with other, and returns true if width, height, SkColorType, SkAlphaType, and SkColorSpace are not equivalent.

Parameters
otherSkImageInfo to compare
Returns
true if SkImageInfo is not equal to other

Definition at line 555 of file SkImageInfo.h.

555 {
556 return !(*this == other);
557 }

◆ operator==()

bool SkImageInfo::operator== ( const SkImageInfo other) const
inline

Compares SkImageInfo with other, and returns true if width, height, SkColorType, SkAlphaType, and SkColorSpace are equivalent.

Parameters
otherSkImageInfo to compare
Returns
true if SkImageInfo equals other

Definition at line 545 of file SkImageInfo.h.

545 {
546 return fDimensions == other.fDimensions && fColorInfo == other.fColorInfo;
547 }

◆ refColorSpace()

sk_sp< SkColorSpace > SkImageInfo::refColorSpace ( ) const

Returns smart pointer to SkColorSpace, the range of colors. The smart pointer tracks the number of objects sharing this SkColorSpace reference so the memory is released when the owners destruct.

The returned SkColorSpace is immutable.

Returns
SkColorSpace wrapped in a smart pointer

Definition at line 121 of file SkImageInfo.cpp.

121{ return fColorInfo.refColorSpace(); }

◆ reset()

void SkImageInfo::reset ( )
inline

Creates an empty SkImageInfo with kUnknown_SkColorType, kUnknown_SkAlphaType, a width and height of zero, and no SkColorSpace.

Definition at line 610 of file SkImageInfo.h.

610{ *this = {}; }

◆ shiftPerPixel()

int SkImageInfo::shiftPerPixel ( ) const
inline

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

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

Definition at line 499 of file SkImageInfo.h.

499{ return fColorInfo.shiftPerPixel(); }

◆ validRowBytes()

bool SkImageInfo::validRowBytes ( size_t  rowBytes) const
inline

Returns true if rowBytes is valid for this SkImageInfo.

Parameters
rowBytessize of pixel row including padding
Returns
true if rowBytes is large enough to contain pixel row and is properly aligned

Definition at line 598 of file SkImageInfo.h.

598 {
599 if (rowBytes < this->minRowBytes64()) {
600 return false;
601 }
602 int shift = this->shiftPerPixel();
603 size_t alignedRowBytes = rowBytes >> shift << shift;
604 return alignedRowBytes == rowBytes;
605 }
int shiftPerPixel() const

◆ width()

int SkImageInfo::width ( ) const
inline

Returns pixel count in each row.

Returns
pixel width

Definition at line 365 of file SkImageInfo.h.

365{ return fDimensions.width(); }
constexpr int32_t width() const
Definition SkSize.h:36

Member Data Documentation

◆ fDimensions

SkDEBUGCODE (void validate() const;) private SkISize SkImageInfo::fDimensions = {0, 0}

Asserts if internal values are illegal or inconsistent. Only available if SK_DEBUG is defined at compile time.

Definition at line 619 of file SkImageInfo.h.

619{0, 0};

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