2013-11-13 19:09:13 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2013 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SkImageInfo_DEFINED
|
|
|
|
#define SkImageInfo_DEFINED
|
|
|
|
|
2022-03-09 14:50:30 +00:00
|
|
|
#include "include/core/SkAlphaType.h"
|
|
|
|
#include "include/core/SkColorType.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/core/SkMath.h"
|
|
|
|
#include "include/core/SkRect.h"
|
2022-03-31 19:07:44 +00:00
|
|
|
#include "include/core/SkRefCnt.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/core/SkSize.h"
|
2018-06-13 13:59:02 +00:00
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/private/SkTFitsIn.h"
|
|
|
|
#include "include/private/SkTo.h"
|
2013-11-13 19:09:13 +00:00
|
|
|
|
2014-01-30 18:58:24 +00:00
|
|
|
class SkReadBuffer;
|
2014-10-24 19:54:53 +00:00
|
|
|
class SkWriteBuffer;
|
2022-03-31 19:07:44 +00:00
|
|
|
class SkColorSpace;
|
2018-04-03 19:24:12 +00:00
|
|
|
|
|
|
|
/** Returns the number of bytes required to store a pixel, including unused padding.
|
|
|
|
Returns zero if ct is kUnknown_SkColorType or invalid.
|
|
|
|
|
|
|
|
@return bytes per pixel
|
|
|
|
*/
|
|
|
|
SK_API int SkColorTypeBytesPerPixel(SkColorType ct);
|
|
|
|
|
2018-05-30 13:20:29 +00:00
|
|
|
/** Returns true if SkColorType always decodes alpha to 1.0, making the pixel
|
|
|
|
fully opaque. If true, SkColorType does not reserve bits to encode alpha.
|
2018-04-03 19:24:12 +00:00
|
|
|
|
2018-05-30 13:20:29 +00:00
|
|
|
@return true if alpha is always set to 1.0
|
2018-04-03 19:24:12 +00:00
|
|
|
*/
|
|
|
|
SK_API bool SkColorTypeIsAlwaysOpaque(SkColorType ct);
|
|
|
|
|
|
|
|
/** Returns true if canonical can be set to a valid SkAlphaType for colorType. If
|
|
|
|
there is more than one valid canonical SkAlphaType, set to alphaType, if valid.
|
|
|
|
If true is returned and canonical is not nullptr, store valid SkAlphaType.
|
|
|
|
|
|
|
|
Returns false only if alphaType is kUnknown_SkAlphaType, color type is not
|
|
|
|
kUnknown_SkColorType, and SkColorType is not always opaque. If false is returned,
|
|
|
|
canonical is ignored.
|
|
|
|
|
|
|
|
@param canonical storage for SkAlphaType
|
|
|
|
@return true if valid SkAlphaType can be associated with colorType
|
|
|
|
*/
|
|
|
|
SK_API bool SkColorTypeValidateAlphaType(SkColorType colorType, SkAlphaType alphaType,
|
2018-04-03 15:49:10 +00:00
|
|
|
SkAlphaType* canonical = nullptr);
|
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
/** \enum SkImageInfo::SkYUVColorSpace
|
|
|
|
Describes color range of YUV pixels. The color mapping from YUV to RGB varies
|
|
|
|
depending on the source. YUV pixels may be generated by JPEG images, standard
|
|
|
|
video streams, or high definition video streams. Each has its own mapping from
|
2020-06-03 16:41:27 +00:00
|
|
|
YUV to RGB.
|
2018-04-03 15:49:10 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
JPEG YUV values encode the full range of 0 to 255 for all three components.
|
2020-07-23 18:22:22 +00:00
|
|
|
Video YUV values often range from 16 to 235 for Y and from 16 to 240 for U and V (limited).
|
2020-06-03 16:41:27 +00:00
|
|
|
Details of encoding and conversion to RGB are described in YCbCr color space.
|
2019-03-06 17:36:47 +00:00
|
|
|
|
|
|
|
The identity colorspace exists to provide a utility mapping from Y to R, U to G and V to B.
|
|
|
|
It can be used to visualize the YUV planes or to explicitly post process the YUV channels.
|
2018-04-03 19:24:12 +00:00
|
|
|
*/
|
2021-07-21 18:09:29 +00:00
|
|
|
enum SkYUVColorSpace : int {
|
2020-07-23 18:22:22 +00:00
|
|
|
kJPEG_Full_SkYUVColorSpace, //!< describes full range
|
|
|
|
kRec601_Limited_SkYUVColorSpace, //!< describes SDTV range
|
|
|
|
kRec709_Full_SkYUVColorSpace, //!< describes HDTV range
|
|
|
|
kRec709_Limited_SkYUVColorSpace,
|
|
|
|
kBT2020_8bit_Full_SkYUVColorSpace, //!< describes UHDTV range, non-constant-luminance
|
|
|
|
kBT2020_8bit_Limited_SkYUVColorSpace,
|
|
|
|
kBT2020_10bit_Full_SkYUVColorSpace,
|
|
|
|
kBT2020_10bit_Limited_SkYUVColorSpace,
|
|
|
|
kBT2020_12bit_Full_SkYUVColorSpace,
|
|
|
|
kBT2020_12bit_Limited_SkYUVColorSpace,
|
2019-11-01 14:02:24 +00:00
|
|
|
kIdentity_SkYUVColorSpace, //!< maps Y->R, U->G, V->B
|
2019-03-06 17:36:47 +00:00
|
|
|
|
|
|
|
kLastEnum_SkYUVColorSpace = kIdentity_SkYUVColorSpace, //!< last valid value
|
2020-07-23 18:22:22 +00:00
|
|
|
|
|
|
|
// Legacy (deprecated) names:
|
|
|
|
kJPEG_SkYUVColorSpace = kJPEG_Full_SkYUVColorSpace,
|
|
|
|
kRec601_SkYUVColorSpace = kRec601_Limited_SkYUVColorSpace,
|
|
|
|
kRec709_SkYUVColorSpace = kRec709_Limited_SkYUVColorSpace,
|
|
|
|
kBT2020_SkYUVColorSpace = kBT2020_8bit_Limited_SkYUVColorSpace,
|
2018-04-03 19:24:12 +00:00
|
|
|
};
|
2018-04-03 15:49:10 +00:00
|
|
|
|
2019-10-01 13:59:02 +00:00
|
|
|
/** \struct SkColorInfo
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
class SK_API SkColorInfo {
|
|
|
|
public:
|
|
|
|
/** Creates an SkColorInfo with kUnknown_SkColorType, kUnknown_SkAlphaType,
|
|
|
|
and no SkColorSpace.
|
|
|
|
|
|
|
|
@return empty SkImageInfo
|
|
|
|
*/
|
2022-03-31 19:07:44 +00:00
|
|
|
SkColorInfo();
|
|
|
|
~SkColorInfo();
|
2019-10-01 13:59:02 +00:00
|
|
|
|
|
|
|
/** 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.
|
|
|
|
@return created SkColorInfo
|
|
|
|
*/
|
2022-03-31 19:07:44 +00:00
|
|
|
SkColorInfo(SkColorType ct, SkAlphaType at, sk_sp<SkColorSpace> cs);
|
2019-10-01 13:59:02 +00:00
|
|
|
|
2022-03-31 19:07:44 +00:00
|
|
|
SkColorInfo(const SkColorInfo&);
|
|
|
|
SkColorInfo(SkColorInfo&&);
|
2019-10-01 13:59:02 +00:00
|
|
|
|
2022-03-31 19:07:44 +00:00
|
|
|
SkColorInfo& operator=(const SkColorInfo&);
|
|
|
|
SkColorInfo& operator=(SkColorInfo&&);
|
2019-10-01 13:59:02 +00:00
|
|
|
|
2022-03-31 19:07:44 +00:00
|
|
|
SkColorSpace* colorSpace() const;
|
|
|
|
sk_sp<SkColorSpace> refColorSpace() const;
|
2019-10-01 13:59:02 +00:00
|
|
|
SkColorType colorType() const { return fColorType; }
|
|
|
|
SkAlphaType alphaType() const { return fAlphaType; }
|
|
|
|
|
2020-03-23 13:58:08 +00:00
|
|
|
bool isOpaque() const {
|
|
|
|
return SkAlphaTypeIsOpaque(fAlphaType)
|
|
|
|
|| SkColorTypeIsAlwaysOpaque(fColorType);
|
|
|
|
}
|
2019-10-01 13:59:02 +00:00
|
|
|
|
2022-03-31 19:07:44 +00:00
|
|
|
bool gammaCloseToSRGB() const;
|
2019-10-01 13:59:02 +00:00
|
|
|
|
|
|
|
/** Does other represent the same color type, alpha type, and color space? */
|
2022-03-31 19:07:44 +00:00
|
|
|
bool operator==(const SkColorInfo& other) const;
|
2019-10-01 13:59:02 +00:00
|
|
|
|
|
|
|
/** Does other represent a different color type, alpha type, or color space? */
|
2022-03-31 19:07:44 +00:00
|
|
|
bool operator!=(const SkColorInfo& other) const;
|
2019-10-01 13:59:02 +00:00
|
|
|
|
|
|
|
/** 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.
|
|
|
|
*/
|
2022-03-31 19:07:44 +00:00
|
|
|
SkColorInfo makeAlphaType(SkAlphaType newAlphaType) const;
|
2019-10-01 13:59:02 +00:00
|
|
|
|
|
|
|
/** Creates new SkColorInfo with same SkAlphaType, SkColorSpace, with SkColorType
|
|
|
|
set to newColorType.
|
|
|
|
*/
|
2022-03-31 19:07:44 +00:00
|
|
|
SkColorInfo makeColorType(SkColorType newColorType) const;
|
2019-10-01 13:59:02 +00:00
|
|
|
|
|
|
|
/** Creates SkColorInfo with same SkAlphaType, SkColorType, with SkColorSpace
|
|
|
|
set to cs. cs may be nullptr.
|
|
|
|
*/
|
2022-03-31 19:07:44 +00:00
|
|
|
SkColorInfo makeColorSpace(sk_sp<SkColorSpace> cs) const;
|
2019-10-01 13:59:02 +00:00
|
|
|
|
|
|
|
/** Returns number of bytes per pixel required by SkColorType.
|
|
|
|
Returns zero if colorType() is kUnknown_SkColorType.
|
|
|
|
|
|
|
|
@return bytes in pixel
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@ImageInfo_bytesPerPixel
|
2019-10-01 13:59:02 +00:00
|
|
|
*/
|
|
|
|
int bytesPerPixel() const;
|
|
|
|
|
|
|
|
/** Returns bit shift converting row bytes to row pixels.
|
|
|
|
Returns zero for kUnknown_SkColorType.
|
|
|
|
|
|
|
|
@return one of: 0, 1, 2, 3, 4; left shift to convert pixels to bytes
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@ImageInfo_shiftPerPixel
|
2019-10-01 13:59:02 +00:00
|
|
|
*/
|
|
|
|
int shiftPerPixel() const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
sk_sp<SkColorSpace> fColorSpace;
|
|
|
|
SkColorType fColorType = kUnknown_SkColorType;
|
|
|
|
SkAlphaType fAlphaType = kUnknown_SkAlphaType;
|
|
|
|
};
|
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
/** \struct SkImageInfo
|
|
|
|
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.
|
2018-04-03 15:49:10 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
SkImageInfo contains dimensions, the pixel integral width and height. It encodes
|
2018-05-30 13:20:29 +00:00
|
|
|
how pixel bits describe alpha, transparency; color components red, blue,
|
2018-04-03 19:24:12 +00:00
|
|
|
and green; and SkColorSpace, the range and linearity of colors.
|
|
|
|
*/
|
|
|
|
struct SK_API SkImageInfo {
|
2014-09-03 18:54:58 +00:00
|
|
|
public:
|
2018-04-03 15:49:10 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
/** Creates an empty SkImageInfo with kUnknown_SkColorType, kUnknown_SkAlphaType,
|
|
|
|
a width and height of zero, and no SkColorSpace.
|
2018-04-03 15:49:10 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
@return empty SkImageInfo
|
|
|
|
*/
|
2019-10-01 13:59:02 +00:00
|
|
|
SkImageInfo() = default;
|
2013-11-13 19:09:13 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
/** 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.
|
|
|
|
|
|
|
|
@param width pixel column count; must be zero or greater
|
|
|
|
@param height pixel row count; must be zero or greater
|
|
|
|
@param cs range of colors; may be nullptr
|
|
|
|
@return created SkImageInfo
|
|
|
|
*/
|
2022-03-31 19:07:44 +00:00
|
|
|
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at);
|
2018-04-03 19:24:12 +00:00
|
|
|
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at,
|
2022-03-31 19:07:44 +00:00
|
|
|
sk_sp<SkColorSpace> cs);
|
|
|
|
static SkImageInfo Make(SkISize dimensions, SkColorType ct, SkAlphaType at);
|
2019-09-30 19:12:27 +00:00
|
|
|
static SkImageInfo Make(SkISize dimensions, SkColorType ct, SkAlphaType at,
|
2022-03-31 19:07:44 +00:00
|
|
|
sk_sp<SkColorSpace> cs);
|
2019-10-01 13:59:02 +00:00
|
|
|
|
|
|
|
/** 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.
|
|
|
|
|
|
|
|
@param dimensions pixel column and row count; must be zeros or greater
|
|
|
|
@param SkColorInfo the pixel encoding consisting of SkColorType, SkAlphaType, and
|
|
|
|
SkColorSpace (which may be nullptr)
|
|
|
|
@return created SkImageInfo
|
|
|
|
*/
|
|
|
|
static SkImageInfo Make(SkISize dimensions, const SkColorInfo& colorInfo) {
|
|
|
|
return SkImageInfo(dimensions, colorInfo);
|
|
|
|
}
|
|
|
|
static SkImageInfo Make(SkISize dimensions, SkColorInfo&& colorInfo) {
|
|
|
|
return SkImageInfo(dimensions, std::move(colorInfo));
|
2014-01-15 02:38:22 +00:00
|
|
|
}
|
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
/** 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.
|
|
|
|
|
|
|
|
@param width pixel column count; must be zero or greater
|
|
|
|
@param height pixel row count; must be zero or greater
|
|
|
|
@param cs range of colors; may be nullptr
|
|
|
|
@return created SkImageInfo
|
|
|
|
*/
|
2022-03-31 19:07:44 +00:00
|
|
|
static SkImageInfo MakeN32(int width, int height, SkAlphaType at);
|
|
|
|
static SkImageInfo MakeN32(int width, int height, SkAlphaType at, sk_sp<SkColorSpace> cs);
|
2014-01-15 02:38:22 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
/** Creates SkImageInfo from integral dimensions width and height, kN32_SkColorType,
|
|
|
|
SkAlphaType at, with sRGB SkColorSpace.
|
2014-01-15 07:01:43 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
Parameters are not validated to see if their values are legal, or that the
|
|
|
|
combination is supported.
|
2018-04-03 15:49:10 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
@param width pixel column count; must be zero or greater
|
|
|
|
@param height pixel row count; must be zero or greater
|
|
|
|
@return created SkImageInfo
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@ImageInfo_MakeS32
|
2018-04-03 19:24:12 +00:00
|
|
|
*/
|
|
|
|
static SkImageInfo MakeS32(int width, int height, SkAlphaType at);
|
2018-04-03 15:49:10 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
/** Creates SkImageInfo from integral dimensions width and height, kN32_SkColorType,
|
|
|
|
kPremul_SkAlphaType, with optional SkColorSpace.
|
2018-04-03 15:49:10 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
If SkColorSpace cs is nullptr and SkImageInfo is part of drawing source: SkColorSpace
|
|
|
|
defaults to sRGB, mapping into SkSurface SkColorSpace.
|
2018-04-03 15:49:10 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
Parameters are not validated to see if their values are legal, or that the
|
|
|
|
combination is supported.
|
2018-04-03 15:49:10 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
@param width pixel column count; must be zero or greater
|
|
|
|
@param height pixel row count; must be zero or greater
|
|
|
|
@param cs range of colors; may be nullptr
|
|
|
|
@return created SkImageInfo
|
|
|
|
*/
|
2022-03-31 19:07:44 +00:00
|
|
|
static SkImageInfo MakeN32Premul(int width, int height);
|
|
|
|
static SkImageInfo MakeN32Premul(int width, int height, sk_sp<SkColorSpace> cs);
|
2014-01-15 07:01:43 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
/** Creates SkImageInfo from integral dimensions width and height, kN32_SkColorType,
|
|
|
|
kPremul_SkAlphaType, with SkColorSpace set to nullptr.
|
2018-04-03 15:49:10 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
If SkImageInfo is part of drawing source: SkColorSpace defaults to sRGB, mapping
|
|
|
|
into SkSurface SkColorSpace.
|
2018-04-03 15:49:10 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
Parameters are not validated to see if their values are legal, or that the
|
|
|
|
combination is supported.
|
2018-04-03 15:49:10 +00:00
|
|
|
|
2019-11-11 18:47:25 +00:00
|
|
|
@param dimensions width and height, each must be zero or greater
|
|
|
|
@param cs range of colors; may be nullptr
|
|
|
|
@return created SkImageInfo
|
2018-04-03 19:24:12 +00:00
|
|
|
*/
|
2022-03-31 19:07:44 +00:00
|
|
|
static SkImageInfo MakeN32Premul(SkISize dimensions);
|
|
|
|
static SkImageInfo MakeN32Premul(SkISize dimensions, sk_sp<SkColorSpace> cs);
|
2016-06-02 19:40:22 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
/** Creates SkImageInfo from integral dimensions width and height, kAlpha_8_SkColorType,
|
|
|
|
kPremul_SkAlphaType, with SkColorSpace set to nullptr.
|
2018-04-03 15:49:10 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
@param width pixel column count; must be zero or greater
|
|
|
|
@param height pixel row count; must be zero or greater
|
|
|
|
@return created SkImageInfo
|
|
|
|
*/
|
2022-03-31 19:07:44 +00:00
|
|
|
static SkImageInfo MakeA8(int width, int height);
|
2019-11-11 18:47:25 +00:00
|
|
|
/** Creates SkImageInfo from integral dimensions, kAlpha_8_SkColorType,
|
|
|
|
kPremul_SkAlphaType, with SkColorSpace set to nullptr.
|
|
|
|
|
|
|
|
@param dimensions pixel row and column count; must be zero or greater
|
|
|
|
@return created SkImageInfo
|
|
|
|
*/
|
2022-03-31 19:07:44 +00:00
|
|
|
static SkImageInfo MakeA8(SkISize dimensions);
|
2014-01-15 07:01:43 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
/** Creates SkImageInfo from integral dimensions width and height, kUnknown_SkColorType,
|
|
|
|
kUnknown_SkAlphaType, with SkColorSpace set to nullptr.
|
2018-04-03 15:49:10 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
Returned SkImageInfo as part of source does not draw, and as part of destination
|
|
|
|
can not be drawn to.
|
2018-04-03 15:49:10 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
@param width pixel column count; must be zero or greater
|
|
|
|
@param height pixel row count; must be zero or greater
|
|
|
|
@return created SkImageInfo
|
|
|
|
*/
|
2022-03-31 19:07:44 +00:00
|
|
|
static SkImageInfo MakeUnknown(int width, int height);
|
2014-02-20 20:55:37 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
/** Creates SkImageInfo from integral dimensions width and height set to zero,
|
|
|
|
kUnknown_SkColorType, kUnknown_SkAlphaType, with SkColorSpace set to nullptr.
|
2018-04-03 15:49:10 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
Returned SkImageInfo as part of source does not draw, and as part of destination
|
|
|
|
can not be drawn to.
|
2018-04-03 15:49:10 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
@return created SkImageInfo
|
|
|
|
*/
|
|
|
|
static SkImageInfo MakeUnknown() {
|
2016-06-17 16:26:41 +00:00
|
|
|
return MakeUnknown(0, 0);
|
|
|
|
}
|
2017-10-09 19:45:33 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
/** Returns pixel count in each row.
|
2018-04-03 15:49:10 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
@return pixel width
|
|
|
|
*/
|
2018-06-14 13:52:49 +00:00
|
|
|
int width() const { return fDimensions.width(); }
|
2018-04-03 15:49:10 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
/** Returns pixel row count.
|
2018-04-03 15:49:10 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
@return pixel height
|
|
|
|
*/
|
2018-06-14 13:52:49 +00:00
|
|
|
int height() const { return fDimensions.height(); }
|
2018-04-03 15:49:10 +00:00
|
|
|
|
2019-10-01 13:59:02 +00:00
|
|
|
SkColorType colorType() const { return fColorInfo.colorType(); }
|
2014-02-11 18:21:45 +00:00
|
|
|
|
2019-10-01 13:59:02 +00:00
|
|
|
SkAlphaType alphaType() const { return fColorInfo.alphaType(); }
|
2018-04-03 15:49:10 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
/** Returns SkColorSpace, the range of colors. The reference count of
|
|
|
|
SkColorSpace is unchanged. The returned SkColorSpace is immutable.
|
2018-04-03 15:49:10 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
@return SkColorSpace, or nullptr
|
|
|
|
*/
|
2022-03-31 19:07:44 +00:00
|
|
|
SkColorSpace* colorSpace() const;
|
2018-04-03 15:49:10 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
/** 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.
|
2018-04-03 15:49:10 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
The returned SkColorSpace is immutable.
|
2018-04-03 15:49:10 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
@return SkColorSpace wrapped in a smart pointer
|
|
|
|
*/
|
2022-03-31 19:07:44 +00:00
|
|
|
sk_sp<SkColorSpace> refColorSpace() const;
|
2018-04-03 15:49:10 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
/** Returns if SkImageInfo describes an empty area of pixels by checking if either
|
|
|
|
width or height is zero or smaller.
|
2018-04-03 15:49:10 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
@return true if either dimension is zero or smaller
|
|
|
|
*/
|
2018-06-14 13:52:49 +00:00
|
|
|
bool isEmpty() const { return fDimensions.isEmpty(); }
|
2018-04-03 15:49:10 +00:00
|
|
|
|
2019-10-01 13:59:02 +00:00
|
|
|
/** Returns the dimensionless SkColorInfo that represents the same color type,
|
|
|
|
alpha type, and color space as this SkImageInfo.
|
|
|
|
*/
|
|
|
|
const SkColorInfo& colorInfo() const { return fColorInfo; }
|
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
/** Returns true if SkAlphaType is set to hint that all pixels are opaque; their
|
2018-05-30 13:20:29 +00:00
|
|
|
alpha value is implicitly or explicitly 1.0. If true, and all pixels are
|
2018-04-03 19:24:12 +00:00
|
|
|
not opaque, Skia may draw incorrectly.
|
2018-04-03 15:49:10 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
Does not check if SkColorType allows alpha, or if any pixel value has
|
|
|
|
transparency.
|
2018-04-03 15:49:10 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
@return true if SkAlphaType is kOpaque_SkAlphaType
|
|
|
|
*/
|
2019-10-01 13:59:02 +00:00
|
|
|
bool isOpaque() const { return fColorInfo.isOpaque(); }
|
2013-11-13 19:09:13 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
/** Returns SkISize { width(), height() }.
|
2018-04-03 15:49:10 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
@return integral size of width() and height()
|
|
|
|
*/
|
2018-06-14 13:52:49 +00:00
|
|
|
SkISize dimensions() const { return fDimensions; }
|
2018-04-03 15:49:10 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
/** Returns SkIRect { 0, 0, width(), height() }.
|
2014-02-11 18:21:45 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
@return integral rectangle from origin to width() and height()
|
|
|
|
*/
|
2018-06-14 13:52:49 +00:00
|
|
|
SkIRect bounds() const { return SkIRect::MakeSize(fDimensions); }
|
2018-04-03 15:49:10 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
/** Returns true if associated SkColorSpace is not nullptr, and SkColorSpace gamma
|
|
|
|
is approximately the same as sRGB.
|
|
|
|
This includes the
|
2018-04-03 15:49:10 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
@return true if SkColorSpace gamma is approximately the same as sRGB
|
|
|
|
*/
|
2019-10-01 13:59:02 +00:00
|
|
|
bool gammaCloseToSRGB() const { return fColorInfo.gammaCloseToSRGB(); }
|
2016-06-17 16:26:41 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
/** Creates SkImageInfo with the same SkColorType, SkColorSpace, and SkAlphaType,
|
|
|
|
with dimensions set to width and height.
|
2018-04-03 15:49:10 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
@param newWidth pixel column count; must be zero or greater
|
|
|
|
@param newHeight pixel row count; must be zero or greater
|
|
|
|
@return created SkImageInfo
|
|
|
|
*/
|
|
|
|
SkImageInfo makeWH(int newWidth, int newHeight) const {
|
2019-10-01 13:59:02 +00:00
|
|
|
return Make({newWidth, newHeight}, fColorInfo);
|
2014-06-02 20:07:26 +00:00
|
|
|
}
|
|
|
|
|
2019-10-03 17:26:54 +00:00
|
|
|
/** Creates SkImageInfo with the same SkColorType, SkColorSpace, and SkAlphaType,
|
|
|
|
with dimensions set to newDimensions.
|
|
|
|
|
|
|
|
@param newSize pixel column and row count; must be zero or greater
|
|
|
|
@return created SkImageInfo
|
|
|
|
*/
|
|
|
|
SkImageInfo makeDimensions(SkISize newSize) const {
|
|
|
|
return Make(newSize, fColorInfo);
|
|
|
|
}
|
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
/** Creates SkImageInfo with same SkColorType, SkColorSpace, width, and height,
|
|
|
|
with SkAlphaType set to newAlphaType.
|
2018-04-03 15:49:10 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
Created SkImageInfo contains newAlphaType even if it is incompatible with
|
|
|
|
SkColorType, in which case SkAlphaType in SkImageInfo is ignored.
|
2018-04-03 15:49:10 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
@return created SkImageInfo
|
|
|
|
*/
|
|
|
|
SkImageInfo makeAlphaType(SkAlphaType newAlphaType) const {
|
2019-10-01 13:59:02 +00:00
|
|
|
return Make(fDimensions, fColorInfo.makeAlphaType(newAlphaType));
|
2014-09-03 18:54:58 +00:00
|
|
|
}
|
2017-10-09 19:45:33 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
/** Creates SkImageInfo with same SkAlphaType, SkColorSpace, width, and height,
|
|
|
|
with SkColorType set to newColorType.
|
|
|
|
|
|
|
|
@return created SkImageInfo
|
|
|
|
*/
|
|
|
|
SkImageInfo makeColorType(SkColorType newColorType) const {
|
2019-10-01 13:59:02 +00:00
|
|
|
return Make(fDimensions, fColorInfo.makeColorType(newColorType));
|
2014-09-03 18:54:58 +00:00
|
|
|
}
|
2014-11-10 16:57:21 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
/** Creates SkImageInfo with same SkAlphaType, SkColorType, width, and height,
|
|
|
|
with SkColorSpace set to cs.
|
2018-04-03 15:49:10 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
@param cs range of colors; may be nullptr
|
|
|
|
@return created SkImageInfo
|
|
|
|
*/
|
2022-03-31 19:07:44 +00:00
|
|
|
SkImageInfo makeColorSpace(sk_sp<SkColorSpace> cs) const;
|
2016-06-09 18:03:45 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
/** Returns number of bytes per pixel required by SkColorType.
|
|
|
|
Returns zero if colorType( is kUnknown_SkColorType.
|
2013-11-13 19:09:13 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
@return bytes in pixel
|
|
|
|
*/
|
2019-10-01 13:59:02 +00:00
|
|
|
int bytesPerPixel() const { return fColorInfo.bytesPerPixel(); }
|
2018-04-03 15:49:10 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
/** Returns bit shift converting row bytes to row pixels.
|
|
|
|
Returns zero for kUnknown_SkColorType.
|
2018-04-03 15:49:10 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
@return one of: 0, 1, 2, 3; left shift to convert pixels to bytes
|
|
|
|
*/
|
2019-10-01 13:59:02 +00:00
|
|
|
int shiftPerPixel() const { return fColorInfo.shiftPerPixel(); }
|
2018-04-03 15:49:10 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
/** Returns minimum bytes per row, computed from pixel width() and SkColorType, which
|
2018-05-30 13:20:29 +00:00
|
|
|
specifies bytesPerPixel(). SkBitmap maximum value for row bytes must fit
|
|
|
|
in 31 bits.
|
2018-04-03 15:49:10 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
@return width() times bytesPerPixel() as unsigned 64-bit integer
|
|
|
|
*/
|
2020-06-01 20:50:19 +00:00
|
|
|
uint64_t minRowBytes64() const {
|
|
|
|
return (uint64_t)sk_64_mul(this->width(), this->bytesPerPixel());
|
|
|
|
}
|
2014-02-11 18:21:45 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
/** Returns minimum bytes per row, computed from pixel width() and SkColorType, which
|
2018-05-30 13:20:29 +00:00
|
|
|
specifies bytesPerPixel(). SkBitmap maximum value for row bytes must fit
|
|
|
|
in 31 bits.
|
2018-04-03 15:49:10 +00:00
|
|
|
|
2020-06-01 20:50:19 +00:00
|
|
|
@return width() times bytesPerPixel() as size_t
|
2018-04-03 19:24:12 +00:00
|
|
|
*/
|
|
|
|
size_t minRowBytes() const {
|
2016-10-17 18:32:46 +00:00
|
|
|
uint64_t minRowBytes = this->minRowBytes64();
|
2017-09-20 15:56:00 +00:00
|
|
|
if (!SkTFitsIn<int32_t>(minRowBytes)) {
|
2016-10-17 18:32:46 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2020-06-01 20:50:19 +00:00
|
|
|
return (size_t)minRowBytes;
|
2013-12-09 22:01:03 +00:00
|
|
|
}
|
2014-02-11 03:02:13 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
/** Returns byte offset of pixel from pixel base address.
|
2018-04-03 15:49:10 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
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.
|
2015-05-22 15:06:21 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
@param x column index, zero or greater, and less than width()
|
|
|
|
@param y row index, zero or greater, and less than height()
|
|
|
|
@param rowBytes size of pixel row or larger
|
|
|
|
@return offset within pixel array
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@ImageInfo_computeOffset
|
2018-04-03 19:24:12 +00:00
|
|
|
*/
|
|
|
|
size_t computeOffset(int x, int y, size_t rowBytes) const;
|
2018-04-03 15:49:10 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
/** Compares SkImageInfo with other, and returns true if width, height, SkColorType,
|
|
|
|
SkAlphaType, and SkColorSpace are equivalent.
|
2018-04-03 15:49:10 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
@param other SkImageInfo to compare
|
|
|
|
@return true if SkImageInfo equals other
|
|
|
|
*/
|
|
|
|
bool operator==(const SkImageInfo& other) const {
|
2019-10-01 13:59:02 +00:00
|
|
|
return fDimensions == other.fDimensions && fColorInfo == other.fColorInfo;
|
2013-11-13 19:09:13 +00:00
|
|
|
}
|
2018-04-03 15:49:10 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
/** Compares SkImageInfo with other, and returns true if width, height, SkColorType,
|
2018-05-30 13:20:29 +00:00
|
|
|
SkAlphaType, and SkColorSpace are not equivalent.
|
2018-04-03 15:49:10 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
@param other SkImageInfo to compare
|
|
|
|
@return true if SkImageInfo is not equal to other
|
|
|
|
*/
|
|
|
|
bool operator!=(const SkImageInfo& other) const {
|
2016-08-01 16:43:08 +00:00
|
|
|
return !(*this == other);
|
2013-11-13 19:09:13 +00:00
|
|
|
}
|
2013-12-09 22:01:03 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
/** Returns storage required by pixel array, given SkImageInfo dimensions, SkColorType,
|
|
|
|
and rowBytes. rowBytes is assumed to be at least as large as minRowBytes().
|
2017-09-29 17:41:58 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
Returns zero if height is zero.
|
Reland "Remove SK_MaxSizeT, SK_M{in|ax}U{16|32}, #defines."
This reverts commit ab17347df32807cabd9f2a518d22c3bd420e482f.
Reason for revert: Chromium should now be ok.
Original change's description:
> Revert "Remove SK_MaxSizeT, SK_M{in|ax}U{16|32}, #defines."
>
> This reverts commit e1bc7de7c07686b28b00b850e44e0722189f3592.
>
> Reason for revert: chrome used it
>
> Original change's description:
> > Remove SK_MaxSizeT, SK_M{in|ax}U{16|32}, #defines.
> >
> > sed 's/SK_MaxSizeT/SIZE_MAX/g'
> > sed 's/SK_MaxU32/UINT32_MAX/g'
> > sed 's/SK_MaxU16/UINT16_MAX/g'
> >
> > SK_MinU32 and SK_MinU16 were unused
> >
> > Change-Id: I6b6c824df47b05bde7e73b13a58e851a5f63fe0e
> > Reviewed-on: https://skia-review.googlesource.com/134607
> > Commit-Queue: Hal Canary <halcanary@google.com>
> > Reviewed-by: Ben Wagner <bungeman@google.com>
>
> TBR=halcanary@google.com,bungeman@google.com,reed@google.com
>
> Change-Id: I1e2c440dcf9f59bf87c1fea113248cd5136f7519
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://skia-review.googlesource.com/134921
> Reviewed-by: Hal Canary <halcanary@google.com>
> Commit-Queue: Hal Canary <halcanary@google.com>
CQ_INCLUDE_TRYBOTS=luci.chromium.try:linux-ozone-rel
TBR=halcanary@google.com,bungeman@google.com,reed@google.com
Change-Id: I7709f9715bea0463b85b5b0a89712ac1020fcddb
Reviewed-on: https://skia-review.googlesource.com/135180
Commit-Queue: Ben Wagner <bungeman@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
2018-06-15 15:37:57 +00:00
|
|
|
Returns SIZE_MAX if answer exceeds the range of size_t.
|
2018-04-03 15:49:10 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
@param rowBytes size of pixel row or larger
|
|
|
|
@return memory required by pixel buffer
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@ImageInfo_computeByteSize
|
2018-04-03 19:24:12 +00:00
|
|
|
*/
|
|
|
|
size_t computeByteSize(size_t rowBytes) const;
|
2018-04-03 15:49:10 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
/** Returns storage required by pixel array, given SkImageInfo dimensions, and
|
|
|
|
SkColorType. Uses minRowBytes() to compute bytes for pixel row.
|
2018-04-03 15:49:10 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
Returns zero if height is zero.
|
Reland "Remove SK_MaxSizeT, SK_M{in|ax}U{16|32}, #defines."
This reverts commit ab17347df32807cabd9f2a518d22c3bd420e482f.
Reason for revert: Chromium should now be ok.
Original change's description:
> Revert "Remove SK_MaxSizeT, SK_M{in|ax}U{16|32}, #defines."
>
> This reverts commit e1bc7de7c07686b28b00b850e44e0722189f3592.
>
> Reason for revert: chrome used it
>
> Original change's description:
> > Remove SK_MaxSizeT, SK_M{in|ax}U{16|32}, #defines.
> >
> > sed 's/SK_MaxSizeT/SIZE_MAX/g'
> > sed 's/SK_MaxU32/UINT32_MAX/g'
> > sed 's/SK_MaxU16/UINT16_MAX/g'
> >
> > SK_MinU32 and SK_MinU16 were unused
> >
> > Change-Id: I6b6c824df47b05bde7e73b13a58e851a5f63fe0e
> > Reviewed-on: https://skia-review.googlesource.com/134607
> > Commit-Queue: Hal Canary <halcanary@google.com>
> > Reviewed-by: Ben Wagner <bungeman@google.com>
>
> TBR=halcanary@google.com,bungeman@google.com,reed@google.com
>
> Change-Id: I1e2c440dcf9f59bf87c1fea113248cd5136f7519
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://skia-review.googlesource.com/134921
> Reviewed-by: Hal Canary <halcanary@google.com>
> Commit-Queue: Hal Canary <halcanary@google.com>
CQ_INCLUDE_TRYBOTS=luci.chromium.try:linux-ozone-rel
TBR=halcanary@google.com,bungeman@google.com,reed@google.com
Change-Id: I7709f9715bea0463b85b5b0a89712ac1020fcddb
Reviewed-on: https://skia-review.googlesource.com/135180
Commit-Queue: Ben Wagner <bungeman@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
2018-06-15 15:37:57 +00:00
|
|
|
Returns SIZE_MAX if answer exceeds the range of size_t.
|
2018-04-03 15:49:10 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
@return least memory required by pixel buffer
|
|
|
|
*/
|
|
|
|
size_t computeMinByteSize() const {
|
2017-09-29 17:41:58 +00:00
|
|
|
return this->computeByteSize(this->minRowBytes());
|
|
|
|
}
|
|
|
|
|
Reland "Remove SK_MaxSizeT, SK_M{in|ax}U{16|32}, #defines."
This reverts commit ab17347df32807cabd9f2a518d22c3bd420e482f.
Reason for revert: Chromium should now be ok.
Original change's description:
> Revert "Remove SK_MaxSizeT, SK_M{in|ax}U{16|32}, #defines."
>
> This reverts commit e1bc7de7c07686b28b00b850e44e0722189f3592.
>
> Reason for revert: chrome used it
>
> Original change's description:
> > Remove SK_MaxSizeT, SK_M{in|ax}U{16|32}, #defines.
> >
> > sed 's/SK_MaxSizeT/SIZE_MAX/g'
> > sed 's/SK_MaxU32/UINT32_MAX/g'
> > sed 's/SK_MaxU16/UINT16_MAX/g'
> >
> > SK_MinU32 and SK_MinU16 were unused
> >
> > Change-Id: I6b6c824df47b05bde7e73b13a58e851a5f63fe0e
> > Reviewed-on: https://skia-review.googlesource.com/134607
> > Commit-Queue: Hal Canary <halcanary@google.com>
> > Reviewed-by: Ben Wagner <bungeman@google.com>
>
> TBR=halcanary@google.com,bungeman@google.com,reed@google.com
>
> Change-Id: I1e2c440dcf9f59bf87c1fea113248cd5136f7519
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://skia-review.googlesource.com/134921
> Reviewed-by: Hal Canary <halcanary@google.com>
> Commit-Queue: Hal Canary <halcanary@google.com>
CQ_INCLUDE_TRYBOTS=luci.chromium.try:linux-ozone-rel
TBR=halcanary@google.com,bungeman@google.com,reed@google.com
Change-Id: I7709f9715bea0463b85b5b0a89712ac1020fcddb
Reviewed-on: https://skia-review.googlesource.com/135180
Commit-Queue: Ben Wagner <bungeman@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
2018-06-15 15:37:57 +00:00
|
|
|
/** Returns true if byteSize equals SIZE_MAX. computeByteSize() and
|
|
|
|
computeMinByteSize() return SIZE_MAX if size_t can not hold buffer size.
|
2018-04-03 15:49:10 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
@param byteSize result of computeByteSize() or computeMinByteSize()
|
|
|
|
@return true if computeByteSize() or computeMinByteSize() result exceeds size_t
|
|
|
|
*/
|
|
|
|
static bool ByteSizeOverflowed(size_t byteSize) {
|
Reland "Remove SK_MaxSizeT, SK_M{in|ax}U{16|32}, #defines."
This reverts commit ab17347df32807cabd9f2a518d22c3bd420e482f.
Reason for revert: Chromium should now be ok.
Original change's description:
> Revert "Remove SK_MaxSizeT, SK_M{in|ax}U{16|32}, #defines."
>
> This reverts commit e1bc7de7c07686b28b00b850e44e0722189f3592.
>
> Reason for revert: chrome used it
>
> Original change's description:
> > Remove SK_MaxSizeT, SK_M{in|ax}U{16|32}, #defines.
> >
> > sed 's/SK_MaxSizeT/SIZE_MAX/g'
> > sed 's/SK_MaxU32/UINT32_MAX/g'
> > sed 's/SK_MaxU16/UINT16_MAX/g'
> >
> > SK_MinU32 and SK_MinU16 were unused
> >
> > Change-Id: I6b6c824df47b05bde7e73b13a58e851a5f63fe0e
> > Reviewed-on: https://skia-review.googlesource.com/134607
> > Commit-Queue: Hal Canary <halcanary@google.com>
> > Reviewed-by: Ben Wagner <bungeman@google.com>
>
> TBR=halcanary@google.com,bungeman@google.com,reed@google.com
>
> Change-Id: I1e2c440dcf9f59bf87c1fea113248cd5136f7519
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://skia-review.googlesource.com/134921
> Reviewed-by: Hal Canary <halcanary@google.com>
> Commit-Queue: Hal Canary <halcanary@google.com>
CQ_INCLUDE_TRYBOTS=luci.chromium.try:linux-ozone-rel
TBR=halcanary@google.com,bungeman@google.com,reed@google.com
Change-Id: I7709f9715bea0463b85b5b0a89712ac1020fcddb
Reviewed-on: https://skia-review.googlesource.com/135180
Commit-Queue: Ben Wagner <bungeman@google.com>
Reviewed-by: Ben Wagner <bungeman@google.com>
2018-06-15 15:37:57 +00:00
|
|
|
return SIZE_MAX == byteSize;
|
2017-10-09 14:42:51 +00:00
|
|
|
}
|
|
|
|
|
2020-01-22 15:44:00 +00:00
|
|
|
/** Returns true if rowBytes is valid for this SkImageInfo.
|
2018-04-03 15:49:10 +00:00
|
|
|
|
2020-01-22 15:44:00 +00:00
|
|
|
@param rowBytes size of pixel row including padding
|
|
|
|
@return true if rowBytes is large enough to contain pixel row and is properly
|
|
|
|
aligned
|
2018-04-03 19:24:12 +00:00
|
|
|
*/
|
|
|
|
bool validRowBytes(size_t rowBytes) const {
|
2020-01-22 15:44:00 +00:00
|
|
|
if (rowBytes < this->minRowBytes64()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
int shift = this->shiftPerPixel();
|
|
|
|
size_t alignedRowBytes = rowBytes >> shift << shift;
|
|
|
|
return alignedRowBytes == rowBytes;
|
2014-02-11 18:21:45 +00:00
|
|
|
}
|
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
/** Creates an empty SkImageInfo with kUnknown_SkColorType, kUnknown_SkAlphaType,
|
|
|
|
a width and height of zero, and no SkColorSpace.
|
|
|
|
*/
|
2019-10-01 13:59:02 +00:00
|
|
|
void reset() { *this = {}; }
|
2016-05-27 14:39:02 +00:00
|
|
|
|
2018-04-03 19:24:12 +00:00
|
|
|
/** Asserts if internal values are illegal or inconsistent. Only available if
|
|
|
|
SK_DEBUG is defined at compile time.
|
|
|
|
*/
|
|
|
|
SkDEBUGCODE(void validate() const;)
|
2014-09-03 18:54:58 +00:00
|
|
|
|
|
|
|
private:
|
2019-10-01 13:59:02 +00:00
|
|
|
SkColorInfo fColorInfo;
|
|
|
|
SkISize fDimensions = {0, 0};
|
|
|
|
|
|
|
|
SkImageInfo(SkISize dimensions, const SkColorInfo& colorInfo)
|
|
|
|
: fColorInfo(colorInfo), fDimensions(dimensions) {}
|
|
|
|
|
|
|
|
SkImageInfo(SkISize dimensions, SkColorInfo&& colorInfo)
|
|
|
|
: fColorInfo(std::move(colorInfo)), fDimensions(dimensions) {}
|
2013-11-13 19:09:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|