46 : fPixelRef (
src.fPixelRef)
47 , fPixmap (
src.fPixmap)
55 : fPixelRef (
std::move(other.fPixelRef))
56 , fPixmap (
std::move(other.fPixmap))
57 , fMips (
std::move(other.fMips))
60 other.fPixmap.reset();
67 fPixelRef =
src.fPixelRef;
68 fPixmap =
src.fPixmap;
77 fPixelRef = std::move(other.fPixelRef);
78 fPixmap = std::move(other.fPixmap);
79 fMips = std::move(other.fMips);
81 other.fPixmap.reset();
123 if (!SkTFitsIn<int32_t>(mrb)) {
126 if (!SkTFitsIn<int32_t>(
rowBytes)) {
169 const char*
addr = (
const char*)fPixmap.
addr();
170 const char* pix = (
const char*)(fPixelRef ? fPixelRef->
pixels() :
nullptr);
172 if (!pix || 0 == rb) {
178 size_t off =
addr - pix;
213 fPixelRef =
p ? sk_make_sp<SkPixelRef>(this->
width(), this->
height(), p, rb) :
nullptr;
220 if (
nullptr == allocator) {
221 allocator = &stdalloc;
223 return allocator->allocPixelRef(
this);
245 SK_ABORT(
"SkBitmap::tryAllocPixels failed "
246 "ColorType:%d AlphaType:%d [w:%d h:%d] rb:%zu",
253 "ColorType:%d AlphaType:%d [w:%d h:%d] rb:%zu flags: 0x%x",
255 this->rowBytes(),
flags);
260 "ColorType:%d AlphaType:%d [w:%d h:%d] rb:%zu",
297 if (!this->
setInfo(requestedInfo)) {
325 if (!this->
setInfo(requestedInfo, rb)) {
330 if (
nullptr == pixels) {
389 dst->setPixelRef(std::move(pr), 0, 0);
397 return fPixelRef ? fPixelRef->
isImmutable() :
false;
433 if (
result.erase(c, &area)) {
439 this->
erase(SkColor4f::FromColor(c), area);
456 if (
nullptr ==
result || !fPixelRef) {
468 SkASSERT(
static_cast<unsigned>(r.
fLeft) <
static_cast<unsigned>(this->width()));
469 SkASSERT(
static_cast<unsigned>(r.
fTop) <
static_cast<unsigned>(this->height()));
472 dst.setInfo(this->
info().makeDimensions(r.
size()), this->rowBytes());
489 int x,
int y)
const {
494 return src.readPixels(requestedDstInfo, dstPixels, dstRB,
x,
y);
507 if (!rec.
trim(this->width(), this->height())) {
528 if (!
src.peekPixels(&pmap)) {
529 for (
int y = 0;
y <
src.height(); ++
y) {
530 memset(alpha, 0,
src.width());
531 alpha += alphaRowBytes;
559 if (!
as_MFB(filter)->filterMask(&dstM, srcM,
identity,
nullptr)) {
566 if (!tmpBitmap.tryAllocPixels(allocator)) {
568 SkDebugf(
"extractAlpha failed to allocate (%d,%d) alpha bitmap\n",
569 tmpBitmap.width(), tmpBitmap.height());
576 tmpBitmap.swap(*
dst);
583 if (!
as_MFB(filter)->filterMask(&dstM, srcM,
identity,
nullptr)) {
590 if (!tmpBitmap.tryAllocPixels(allocator)) {
592 SkDebugf(
"extractAlpha failed to allocate (%d,%d) alpha bitmap\n",
593 tmpBitmap.width(), tmpBitmap.height());
602 tmpBitmap.swap(*
dst);
609void SkBitmap::validate()
const {
610 this->
info().validate();
614 if (fPixelRef && fPixelRef->
pixels()) {
662 if (!lm.
invert(
nullptr)) {
672 if (lm && !lm->
invert(
nullptr)) {
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
static constexpr T SkAlign4(T x)
@ kOpaque_SkAlphaType
pixel is opaque
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
#define SK_ABORT(message,...)
#define SkASSERTF_RELEASE(cond, fmt,...)
static bool reset_return_false(SkBitmap *bm)
static bool GetBitmapAlpha(const SkBitmap &src, uint8_t *SK_RESTRICT alpha, int alphaRowBytes)
static void invoke_release_proc(void(*proc)(void *pixels, void *ctx), void *pixels, void *ctx)
@ kUnknown_SkColorType
uninitialized
bool SkConvertPixels(const SkImageInfo &dstInfo, void *dstPixels, size_t dstRB, const SkImageInfo &srcInfo, const void *srcPixels, size_t srcRB)
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
static void releaseProc(const void *ptr, void *context)
static bool SkImageInfoValidConversion(const SkImageInfo &dst, const SkImageInfo &src)
SK_API bool SkColorTypeValidateAlphaType(SkColorType colorType, SkAlphaType alphaType, SkAlphaType *canonical=nullptr)
SK_SPI sk_sp< SkImage > SkMakeImageFromRasterBitmap(const SkBitmap &, SkCopyPixelsMode)
@ kIfMutable_SkCopyPixelsMode
only copy src pixels if they are marked mutable
SkMaskFilterBase * as_MFB(SkMaskFilter *mf)
std::unique_ptr< uint8_t, SkFunctionObject< SkMaskBuilder::FreeImage > > SkAutoMaskFreeImage
sk_sp< SkPixelRef > SkMakePixelRefWithProc(int width, int height, size_t rowBytes, void *addr, void(*releaseProc)(void *addr, void *ctx), void *ctx)
void swap(sk_sp< T > &a, sk_sp< T > &b)
SkDEBUGCODE(SK_SPI) SkThreadID SkGetThreadID()
constexpr int32_t SkToS32(S x)
constexpr uint32_t SkToU32(S x)
bool allocPixelRef(SkBitmap *bitmap) override
bool extractAlpha(SkBitmap *dst) const
bool installMaskPixels(SkMaskBuilder &mask)
SkColorSpace * colorSpace() const
sk_sp< SkImage > asImage() const
int shiftPerPixel() const
bool installPixels(const SkImageInfo &info, void *pixels, size_t rowBytes, void(*releaseProc)(void *addr, void *context), void *context)
SkIPoint pixelRefOrigin() const
SkBitmap & operator=(const SkBitmap &src)
void notifyPixelsChanged() const
void getBounds(SkRect *bounds) const
SkAlphaType alphaType() const
sk_sp< SkColorSpace > refColorSpace() const
bool extractSubset(SkBitmap *dst, const SkIRect &subset) const
SkISize dimensions() const
const SkPixmap & pixmap() const
bool writePixels(const SkPixmap &src, int dstX, int dstY)
void * getAddr(int x, int y) const
void setColorSpace(sk_sp< SkColorSpace > colorSpace)
SkColorType colorType() const
void setPixels(void *pixels)
sk_sp< SkShader > makeShader(SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &, const SkMatrix *localMatrix=nullptr) const
const SkImageInfo & info() const
int bytesPerPixel() const
bool readPixels(const SkImageInfo &dstInfo, void *dstPixels, size_t dstRowBytes, int srcX, int srcY) const
uint32_t getGenerationID() const
void allocN32Pixels(int width, int height, bool isOpaque=false)
bool peekPixels(SkPixmap *pixmap) const
bool setInfo(const SkImageInfo &imageInfo, size_t rowBytes=0)
bool setAlphaType(SkAlphaType alphaType)
void allocPixelsFlags(const SkImageInfo &info, uint32_t flags)
void setPixelRef(sk_sp< SkPixelRef > pixelRef, int dx, int dy)
bool tryAllocN32Pixels(int width, int height, bool isOpaque=false)
void swap(SkBitmap &other)
bool tryAllocPixelsFlags(const SkImageInfo &info, uint32_t flags)
void erase(SkColor4f c, const SkIRect &area) const
void eraseColor(SkColor4f) const
static sk_sp< SkShader > Make(sk_sp< SkImage >, SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &, const SkMatrix *localMatrix, bool clampAsIfUnpremul=false)
bool invert(SkMatrix *inverse) const
void notifyPixelsChanged()
uint32_t getGenerationID() const
SkColorSpace * colorSpace() const
const SkImageInfo & info() const
void * writable_addr() const
const void * addr() const
void reset(T *ptr=nullptr)
FlutterSemanticsFlag flags
SK_API sk_sp< SkImage > RasterFromBitmap(const SkBitmap &bitmap)
SK_API sk_sp< SkPixelRef > MakeAllocate(const SkImageInfo &, size_t rowBytes)
Optional< SkRect > bounds
SkSamplingOptions sampling
skia_private::AutoTArray< sk_sp< SkImageFilter > > filters TypedMatrix matrix TypedMatrix matrix SkScalar dx
constexpr int32_t y() const
constexpr int32_t x() const
bool intersect(const SkIRect &r)
constexpr SkISize size() const
constexpr int32_t height() const
int32_t fTop
smaller y-axis bounds
constexpr int32_t width() const
static constexpr SkIRect MakeWH(int32_t w, int32_t h)
void setWH(int32_t width, int32_t height)
int32_t fLeft
smaller x-axis bounds
SkImageInfo makeAlphaType(SkAlphaType newAlphaType) const
sk_sp< SkColorSpace > refColorSpace() const
size_t minRowBytes() const
SkImageInfo makeDimensions(SkISize newSize) const
SkISize dimensions() const
SkImageInfo makeColorSpace(sk_sp< SkColorSpace > cs) const
static SkImageInfo MakeN32(int width, int height, SkAlphaType at)
SkAlphaType alphaType() const
SkColorType colorType() const
uint64_t minRowBytes64() const
bool validRowBytes(size_t rowBytes) const
static SkImageInfo MakeA8(int width, int height)
static uint8_t * AllocImage(size_t bytes, AllocType=kUninit_Alloc)
@ kA8_Format
8bits per pixel mask (e.g. antialiasing)
uint8_t const *const fImage
size_t computeImageSize() const
static SkRect Make(const SkISize &size)
bool trim(int dstWidth, int dstHeight)