Flutter Engine
The Flutter Engine
SkBitmap.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2008 The Android Open Source Project
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
9
10#include "include/core/SkColorSpace.h" // IWYU pragma: keep
17#include "include/core/SkRect.h"
27#include "src/core/SkMask.h"
29#include "src/core/SkMipmap.h"
33
34#include <cstring>
35#include <utility>
36class SkMaskFilter;
37
38static bool reset_return_false(SkBitmap* bm) {
39 bm->reset();
40 return false;
41}
42
44
46 : fPixelRef (src.fPixelRef)
47 , fPixmap (src.fPixmap)
48 , fMips (src.fMips)
49{
50 SkDEBUGCODE(src.validate();)
51 SkDEBUGCODE(this->validate();)
52}
53
55 : fPixelRef (std::move(other.fPixelRef))
56 , fPixmap (std::move(other.fPixmap))
57 , fMips (std::move(other.fMips))
58{
59 SkASSERT(!other.fPixelRef);
60 other.fPixmap.reset();
61}
62
64
66 if (this != &src) {
67 fPixelRef = src.fPixelRef;
68 fPixmap = src.fPixmap;
69 fMips = src.fMips;
70 }
71 SkDEBUGCODE(this->validate();)
72 return *this;
73}
74
76 if (this != &other) {
77 fPixelRef = std::move(other.fPixelRef);
78 fPixmap = std::move(other.fPixmap);
79 fMips = std::move(other.fMips);
80 SkASSERT(!other.fPixelRef);
81 other.fPixmap.reset();
82 }
83 return *this;
84}
85
87 using std::swap;
88 swap(*this, other);
89 SkDEBUGCODE(this->validate();)
90}
91
93 fPixelRef = nullptr; // Free pixels.
94 fPixmap.reset();
95 fMips.reset();
96}
97
100 *bounds = SkRect::Make(this->dimensions());
101}
102
105 *bounds = fPixmap.bounds();
106}
107
108SkColorSpace* SkBitmap::colorSpace() const { return fPixmap.colorSpace(); }
109
111
112///////////////////////////////////////////////////////////////////////////////
113
114bool SkBitmap::setInfo(const SkImageInfo& info, size_t rowBytes) {
115 SkAlphaType newAT = info.alphaType();
117 return reset_return_false(this);
118 }
119 // don't look at info.alphaType(), since newAT is the real value...
120
121 // require that rowBytes fit in 31bits
122 int64_t mrb = info.minRowBytes64();
123 if (!SkTFitsIn<int32_t>(mrb)) {
124 return reset_return_false(this);
125 }
126 if (!SkTFitsIn<int32_t>(rowBytes)) {
127 return reset_return_false(this);
128 }
129
130 if (info.width() < 0 || info.height() < 0) {
131 return reset_return_false(this);
132 }
133
135 rowBytes = 0;
136 } else if (0 == rowBytes) {
137 rowBytes = (size_t)mrb;
138 } else if (!info.validRowBytes(rowBytes)) {
139 return reset_return_false(this);
140 }
141
142 fPixelRef = nullptr; // Free pixels.
143 fPixmap.reset(info.makeAlphaType(newAT), nullptr, SkToU32(rowBytes));
144 SkDEBUGCODE(this->validate();)
145 return true;
146}
147
149 if (!SkColorTypeValidateAlphaType(this->colorType(), newAlphaType, &newAlphaType)) {
150 return false;
151 }
152 if (this->alphaType() != newAlphaType) {
153 auto newInfo = fPixmap.info().makeAlphaType(newAlphaType);
154 fPixmap.reset(std::move(newInfo), fPixmap.addr(), fPixmap.rowBytes());
155 }
156 SkDEBUGCODE(this->validate();)
157 return true;
158}
159
161 if (this->colorSpace() != newColorSpace.get()) {
162 SkImageInfo newInfo = fPixmap.info().makeColorSpace(std::move(newColorSpace));
163 fPixmap.reset(std::move(newInfo), fPixmap.addr(), fPixmap.rowBytes());
164 }
165 SkDEBUGCODE(this->validate();)
166}
167
169 const char* addr = (const char*)fPixmap.addr();
170 const char* pix = (const char*)(fPixelRef ? fPixelRef->pixels() : nullptr);
171 size_t rb = this->rowBytes();
172 if (!pix || 0 == rb) {
173 return {0, 0};
174 }
175 SkASSERT(this->bytesPerPixel() > 0);
176 SkASSERT(this->bytesPerPixel() == (1 << this->shiftPerPixel()));
177 SkASSERT(addr >= pix);
178 size_t off = addr - pix;
179 return {SkToS32((off % rb) >> this->shiftPerPixel()), SkToS32(off / rb)};
180}
181
183#ifdef SK_DEBUG
184 if (pr) {
185 if (kUnknown_SkColorType != this->colorType()) {
186 SkASSERT(dx >= 0 && this->width() + dx <= pr->width());
187 SkASSERT(dy >= 0 && this->height() + dy <= pr->height());
188 }
189 }
190#endif
191 fPixelRef = kUnknown_SkColorType != this->colorType() ? std::move(pr) : nullptr;
192 void* p = nullptr;
193 size_t rowBytes = this->rowBytes();
194 // ignore dx,dy if there is no pixelref
195 if (fPixelRef) {
196 rowBytes = fPixelRef->rowBytes();
197 // TODO(reed): Enforce that PixelRefs must have non-null pixels.
198 p = fPixelRef->pixels();
199 if (p) {
200 p = (char*)p + dy * rowBytes + dx * this->bytesPerPixel();
201 }
202 }
203 fPixmap.reset(fPixmap.info(), p, rowBytes);
204 SkDEBUGCODE(this->validate();)
205}
206
208 if (kUnknown_SkColorType == this->colorType()) {
209 p = nullptr;
210 }
211 size_t rb = this->rowBytes();
212 fPixmap.reset(fPixmap.info(), p, rb);
213 fPixelRef = p ? sk_make_sp<SkPixelRef>(this->width(), this->height(), p, rb) : nullptr;
214 SkDEBUGCODE(this->validate();)
215}
216
218 HeapAllocator stdalloc;
219
220 if (nullptr == allocator) {
221 allocator = &stdalloc;
222 }
223 return allocator->allocPixelRef(this);
224}
225
226bool SkBitmap::tryAllocN32Pixels(int width, int height, bool isOpaque) {
229 return this->tryAllocPixels(info);
230}
231
232void SkBitmap::allocN32Pixels(int width, int height, bool isOpaque) {
235 this->allocPixels(info);
236}
237
239 this->allocPixels((Allocator*)nullptr);
240}
241
243 if (!this->tryAllocPixels(allocator)) {
244 const SkImageInfo& info = this->info();
245 SK_ABORT("SkBitmap::tryAllocPixels failed "
246 "ColorType:%d AlphaType:%d [w:%d h:%d] rb:%zu",
247 info.colorType(), info.alphaType(), info.width(), info.height(), this->rowBytes());
248 }
249}
250
253 "ColorType:%d AlphaType:%d [w:%d h:%d] rb:%zu flags: 0x%x",
255 this->rowBytes(), flags);
256}
257
258void SkBitmap::allocPixels(const SkImageInfo& info, size_t rowBytes) {
260 "ColorType:%d AlphaType:%d [w:%d h:%d] rb:%zu",
262 this->rowBytes());
263}
264
266 this->allocPixels(info, info.minRowBytes());
267}
268
269///////////////////////////////////////////////////////////////////////////////
270
271bool SkBitmap::tryAllocPixels(const SkImageInfo& requestedInfo, size_t rowBytes) {
272 if (!this->setInfo(requestedInfo, rowBytes)) {
273 return reset_return_false(this);
274 }
275
276 // setInfo may have corrected info (e.g. 565 is always opaque).
277 const SkImageInfo& correctedInfo = this->info();
278 if (kUnknown_SkColorType == correctedInfo.colorType()) {
279 return true;
280 }
281 // setInfo may have computed a valid rowbytes if 0 were passed in
282 rowBytes = this->rowBytes();
283
285 if (!pr) {
286 return reset_return_false(this);
287 }
288 this->setPixelRef(std::move(pr), 0, 0);
289 if (nullptr == this->getPixels()) {
290 return reset_return_false(this);
291 }
292 SkDEBUGCODE(this->validate();)
293 return true;
294}
295
296bool SkBitmap::tryAllocPixelsFlags(const SkImageInfo& requestedInfo, uint32_t allocFlags) {
297 if (!this->setInfo(requestedInfo)) {
298 return reset_return_false(this);
299 }
300
301 // setInfo may have corrected info (e.g. 565 is always opaque).
302 const SkImageInfo& correctedInfo = this->info();
303
305 correctedInfo.minRowBytes());
306 if (!pr) {
307 return reset_return_false(this);
308 }
309 this->setPixelRef(std::move(pr), 0, 0);
310 if (nullptr == this->getPixels()) {
311 return reset_return_false(this);
312 }
313 SkDEBUGCODE(this->validate();)
314 return true;
315}
316
317static void invoke_release_proc(void (*proc)(void* pixels, void* ctx), void* pixels, void* ctx) {
318 if (proc) {
319 proc(pixels, ctx);
320 }
321}
322
323bool SkBitmap::installPixels(const SkImageInfo& requestedInfo, void* pixels, size_t rb,
324 void (*releaseProc)(void* addr, void* context), void* context) {
325 if (!this->setInfo(requestedInfo, rb)) {
326 invoke_release_proc(releaseProc, pixels, context);
327 this->reset();
328 return false;
329 }
330 if (nullptr == pixels) {
331 invoke_release_proc(releaseProc, pixels, context);
332 return true; // we behaved as if they called setInfo()
333 }
334
335 // setInfo may have corrected info (e.g. 565 is always opaque).
336 const SkImageInfo& correctedInfo = this->info();
337 this->setPixelRef(
338 SkMakePixelRefWithProc(correctedInfo.width(), correctedInfo.height(),
339 rb, pixels, releaseProc, context), 0, 0);
340 SkDEBUGCODE(this->validate();)
341 return true;
342}
343
345 return this->installPixels(pixmap.info(), pixmap.writable_addr(), pixmap.rowBytes(),
346 nullptr, nullptr);
347}
348
350 if (SkMask::kA8_Format != mask.fFormat) {
351 this->reset();
352 return false;
353 }
355 mask.fBounds.height()),
356 mask.image(), mask.fRowBytes);
357}
358
359///////////////////////////////////////////////////////////////////////////////
360
362 return fPixelRef ? fPixelRef->getGenerationID() : 0;
363}
364
366 SkASSERT(!this->isImmutable());
367 if (fPixelRef) {
368 fPixelRef->notifyPixelsChanged();
369 }
370}
371
372///////////////////////////////////////////////////////////////////////////////
373
374/** We explicitly use the same allocator for our pixels that SkMask does,
375 so that we can freely assign memory allocated by one class to the other.
376 */
378 const SkImageInfo& info = dst->info();
380// SkDebugf("unsupported config for info %d\n", dst->config());
381 return false;
382 }
383
385 if (!pr) {
386 return false;
387 }
388
389 dst->setPixelRef(std::move(pr), 0, 0);
390 SkDEBUGCODE(dst->validate();)
391 return true;
392}
393
394///////////////////////////////////////////////////////////////////////////////
395
397 return fPixelRef ? fPixelRef->isImmutable() : false;
398}
399
401 if (fPixelRef) {
402 fPixelRef->setImmutable();
403 }
404}
405
406void* SkBitmap::getAddr(int x, int y) const {
407 SkASSERT((unsigned)x < (unsigned)this->width());
408 SkASSERT((unsigned)y < (unsigned)this->height());
409
410 char* base = (char*)this->getPixels();
411 if (base) {
412 base += (y * this->rowBytes()) + (x << this->shiftPerPixel());
413 }
414 return base;
415}
416
417///////////////////////////////////////////////////////////////////////////////
418///////////////////////////////////////////////////////////////////////////////
419
420void SkBitmap::erase(SkColor4f c, const SkIRect& area) const {
421 SkDEBUGCODE(this->validate();)
422
423 if (kUnknown_SkColorType == this->colorType()) {
424 // TODO: can we ASSERT that we never get here?
425 return; // can't erase. Should we bzero so the memory is not uninitialized?
426 }
427
429 if (!this->peekPixels(&result)) {
430 return;
431 }
432
433 if (result.erase(c, &area)) {
434 this->notifyPixelsChanged();
435 }
436}
437
438void SkBitmap::erase(SkColor c, const SkIRect& area) const {
439 this->erase(SkColor4f::FromColor(c), area);
440}
441
443 this->erase(c, SkIRect::MakeWH(this->width(), this->height()));
444}
445
447 this->erase(SkColor4f::FromColor(c), SkIRect::MakeWH(this->width(), this->height()));
448}
449
450//////////////////////////////////////////////////////////////////////////////////////
451//////////////////////////////////////////////////////////////////////////////////////
452
453bool SkBitmap::extractSubset(SkBitmap* result, const SkIRect& subset) const {
454 SkDEBUGCODE(this->validate();)
455
456 if (nullptr == result || !fPixelRef) {
457 return false; // no src pixels
458 }
459
460 SkIRect srcRect, r;
461 srcRect.setWH(this->width(), this->height());
462 if (!r.intersect(srcRect, subset)) {
463 return false; // r is empty (i.e. no intersection)
464 }
465
466 // If the upper left of the rectangle was outside the bounds of this SkBitmap, we should have
467 // exited above.
468 SkASSERT(static_cast<unsigned>(r.fLeft) < static_cast<unsigned>(this->width()));
469 SkASSERT(static_cast<unsigned>(r.fTop) < static_cast<unsigned>(this->height()));
470
472 dst.setInfo(this->info().makeDimensions(r.size()), this->rowBytes());
473
474 if (fPixelRef) {
475 SkIPoint origin = this->pixelRefOrigin();
476 // share the pixelref with a custom offset
477 dst.setPixelRef(fPixelRef, origin.x() + r.fLeft, origin.y() + r.fTop);
478 }
479 SkDEBUGCODE(dst.validate();)
480
481 // we know we're good, so commit to result
482 result->swap(dst);
483 return true;
484}
485
486///////////////////////////////////////////////////////////////////////////////
487
488bool SkBitmap::readPixels(const SkImageInfo& requestedDstInfo, void* dstPixels, size_t dstRB,
489 int x, int y) const {
491 if (!this->peekPixels(&src)) {
492 return false;
493 }
494 return src.readPixels(requestedDstInfo, dstPixels, dstRB, x, y);
495}
496
497bool SkBitmap::readPixels(const SkPixmap& dst, int srcX, int srcY) const {
498 return this->readPixels(dst.info(), dst.writable_addr(), dst.rowBytes(), srcX, srcY);
499}
500
501bool SkBitmap::writePixels(const SkPixmap& src, int dstX, int dstY) {
502 if (!SkImageInfoValidConversion(this->info(), src.info())) {
503 return false;
504 }
505
506 SkWritePixelsRec rec(src.info(), src.addr(), src.rowBytes(), dstX, dstY);
507 if (!rec.trim(this->width(), this->height())) {
508 return false;
509 }
510
511 void* dstPixels = this->getAddr(rec.fX, rec.fY);
512 const SkImageInfo dstInfo = this->info().makeDimensions(rec.fInfo.dimensions());
513 if (!SkConvertPixels(dstInfo, dstPixels, this->rowBytes(),
514 rec.fInfo, rec.fPixels, rec.fRowBytes)) {
515 return false;
516 }
517 this->notifyPixelsChanged();
518 return true;
519}
520
521///////////////////////////////////////////////////////////////////////////////
522
523static bool GetBitmapAlpha(const SkBitmap& src, uint8_t* SK_RESTRICT alpha, int alphaRowBytes) {
524 SkASSERT(alpha != nullptr);
525 SkASSERT(alphaRowBytes >= src.width());
526
527 SkPixmap pmap;
528 if (!src.peekPixels(&pmap)) {
529 for (int y = 0; y < src.height(); ++y) {
530 memset(alpha, 0, src.width());
531 alpha += alphaRowBytes;
532 }
533 return false;
534 }
535 return SkConvertPixels(SkImageInfo::MakeA8(pmap.width(), pmap.height()), alpha, alphaRowBytes,
536 pmap.info(), pmap.addr(), pmap.rowBytes());
537}
538
540 Allocator *allocator, SkIPoint* offset) const {
541 SkDEBUGCODE(this->validate();)
542
543 SkBitmap tmpBitmap;
545 SkMaskBuilder srcM, dstM;
546
547 if (this->width() == 0 || this->height() == 0) {
548 return false;
549 }
550 srcM.bounds().setWH(this->width(), this->height());
551 srcM.rowBytes() = SkAlign4(this->width());
552 srcM.format() = SkMask::kA8_Format;
553
554 SkMaskFilter* filter = paint ? paint->getMaskFilter() : nullptr;
555
556 // compute our (larger?) dst bounds if we have a filter
557 if (filter) {
558 identity.reset();
559 if (!as_MFB(filter)->filterMask(&dstM, srcM, identity, nullptr)) {
560 goto NO_FILTER_CASE;
561 }
562 dstM.rowBytes() = SkAlign4(dstM.fBounds.width());
563 } else {
564 NO_FILTER_CASE:
565 tmpBitmap.setInfo(SkImageInfo::MakeA8(this->width(), this->height()), srcM.fRowBytes);
566 if (!tmpBitmap.tryAllocPixels(allocator)) {
567 // Allocation of pixels for alpha bitmap failed.
568 SkDebugf("extractAlpha failed to allocate (%d,%d) alpha bitmap\n",
569 tmpBitmap.width(), tmpBitmap.height());
570 return false;
571 }
572 GetBitmapAlpha(*this, tmpBitmap.getAddr8(0, 0), srcM.fRowBytes);
573 if (offset) {
574 offset->set(0, 0);
575 }
576 tmpBitmap.swap(*dst);
577 return true;
578 }
580 SkAutoMaskFreeImage srcCleanup(srcM.image());
581
582 GetBitmapAlpha(*this, srcM.image(), srcM.fRowBytes);
583 if (!as_MFB(filter)->filterMask(&dstM, srcM, identity, nullptr)) {
584 goto NO_FILTER_CASE;
585 }
586 SkAutoMaskFreeImage dstCleanup(dstM.image());
587
588 tmpBitmap.setInfo(SkImageInfo::MakeA8(dstM.fBounds.width(), dstM.fBounds.height()),
589 dstM.fRowBytes);
590 if (!tmpBitmap.tryAllocPixels(allocator)) {
591 // Allocation of pixels for alpha bitmap failed.
592 SkDebugf("extractAlpha failed to allocate (%d,%d) alpha bitmap\n",
593 tmpBitmap.width(), tmpBitmap.height());
594 return false;
595 }
596 memcpy(tmpBitmap.getPixels(), dstM.fImage, dstM.computeImageSize());
597 if (offset) {
598 offset->set(dstM.fBounds.fLeft, dstM.fBounds.fTop);
599 }
600 SkDEBUGCODE(tmpBitmap.validate();)
601
602 tmpBitmap.swap(*dst);
603 return true;
604}
605
606///////////////////////////////////////////////////////////////////////////////
607
608#ifdef SK_DEBUG
609void SkBitmap::validate() const {
610 this->info().validate();
611
612 SkASSERT(this->info().validRowBytes(this->rowBytes()));
613
614 if (fPixelRef && fPixelRef->pixels()) {
615 SkASSERT(this->getPixels());
616 } else {
617 SkASSERT(!this->getPixels());
618 }
619
620 if (this->getPixels()) {
621 SkASSERT(fPixelRef);
622 SkASSERT(fPixelRef->rowBytes() == this->rowBytes());
623 SkIPoint origin = this->pixelRefOrigin();
624 SkASSERT(origin.fX >= 0);
625 SkASSERT(origin.fY >= 0);
626 SkASSERT(fPixelRef->width() >= (int)this->width() + origin.fX);
627 SkASSERT(fPixelRef->height() >= (int)this->height() + origin.fY);
628 SkASSERT(fPixelRef->rowBytes() >= this->info().minRowBytes());
629 }
630}
631#endif
632
633///////////////////////////////////////////////////////////////////////////////
634
636 if (this->getPixels()) {
637 if (pmap) {
638 *pmap = fPixmap;
639 }
640 return true;
641 }
642 return false;
643}
644
646
648 const SkMatrix& lm) const {
650 sampling, &lm);
651}
652
654 const SkMatrix* lm) const {
656 sampling, lm);
657}
658
661 const SkMatrix& lm) const {
662 if (!lm.invert(nullptr)) {
663 return nullptr;
664 }
666 tmx, tmy, sampling, &lm);
667}
668
671 const SkMatrix* lm) const {
672 if (lm && !lm->invert(nullptr)) {
673 return nullptr;
674 }
676 tmx, tmy, sampling, lm);
677}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
static constexpr T SkAlign4(T x)
Definition: SkAlign.h:16
SkAlphaType
Definition: SkAlphaType.h:26
@ kOpaque_SkAlphaType
pixel is opaque
Definition: SkAlphaType.h:28
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition: SkAlphaType.h:29
#define SK_ABORT(message,...)
Definition: SkAssert.h:70
#define SkASSERTF_RELEASE(cond, fmt,...)
Definition: SkAssert.h:103
#define SkASSERT(cond)
Definition: SkAssert.h:116
static bool reset_return_false(SkBitmap *bm)
Definition: SkBitmap.cpp:38
static bool GetBitmapAlpha(const SkBitmap &src, uint8_t *SK_RESTRICT alpha, int alphaRowBytes)
Definition: SkBitmap.cpp:523
static void invoke_release_proc(void(*proc)(void *pixels, void *ctx), void *pixels, void *ctx)
Definition: SkBitmap.cpp:317
@ kUnknown_SkColorType
uninitialized
Definition: SkColorType.h:20
uint32_t SkColor
Definition: SkColor.h:37
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
#define SK_RESTRICT
Definition: SkFeatures.h:42
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
Definition: SkImagePriv.h:18
SkMaskFilterBase * as_MFB(SkMaskFilter *mf)
std::unique_ptr< uint8_t, SkFunctionObject< SkMaskBuilder::FreeImage > > SkAutoMaskFreeImage
Definition: SkMask.h:316
sk_sp< SkPixelRef > SkMakePixelRefWithProc(int width, int height, size_t rowBytes, void *addr, void(*releaseProc)(void *addr, void *ctx), void *ctx)
Definition: SkPixelRef.cpp:137
void swap(sk_sp< T > &a, sk_sp< T > &b)
Definition: SkRefCnt.h:341
SkDEBUGCODE(SK_SPI) SkThreadID SkGetThreadID()
SkTileMode
Definition: SkTileMode.h:13
constexpr int32_t SkToS32(S x)
Definition: SkTo.h:25
constexpr uint32_t SkToU32(S x)
Definition: SkTo.h:26
bool allocPixelRef(SkBitmap *bitmap) override
Definition: SkBitmap.cpp:377
bool extractAlpha(SkBitmap *dst) const
Definition: SkBitmap.h:1134
bool installMaskPixels(SkMaskBuilder &mask)
Definition: SkBitmap.cpp:349
SkColorSpace * colorSpace() const
Definition: SkBitmap.cpp:108
sk_sp< SkImage > asImage() const
Definition: SkBitmap.cpp:645
int shiftPerPixel() const
Definition: SkBitmap.h:201
void setImmutable()
Definition: SkBitmap.cpp:400
bool installPixels(const SkImageInfo &info, void *pixels, size_t rowBytes, void(*releaseProc)(void *addr, void *context), void *context)
Definition: SkBitmap.cpp:323
SkIPoint pixelRefOrigin() const
Definition: SkBitmap.cpp:168
SkBitmap & operator=(const SkBitmap &src)
Definition: SkBitmap.cpp:65
void notifyPixelsChanged() const
Definition: SkBitmap.cpp:365
void getBounds(SkRect *bounds) const
Definition: SkBitmap.cpp:98
SkAlphaType alphaType() const
Definition: SkBitmap.h:162
bool tryAllocPixels()
Definition: SkBitmap.h:674
sk_sp< SkColorSpace > refColorSpace() const
Definition: SkBitmap.cpp:110
bool extractSubset(SkBitmap *dst, const SkIRect &subset) const
Definition: SkBitmap.cpp:453
SkISize dimensions() const
Definition: SkBitmap.h:388
bool isOpaque() const
Definition: SkBitmap.h:324
int width() const
Definition: SkBitmap.h:149
const SkPixmap & pixmap() const
Definition: SkBitmap.h:133
bool writePixels(const SkPixmap &src, int dstX, int dstY)
Definition: SkBitmap.cpp:501
void * getAddr(int x, int y) const
Definition: SkBitmap.cpp:406
bool isImmutable() const
Definition: SkBitmap.cpp:396
void allocPixels()
Definition: SkBitmap.cpp:238
void setColorSpace(sk_sp< SkColorSpace > colorSpace)
Definition: SkBitmap.cpp:160
size_t rowBytes() const
Definition: SkBitmap.h:238
void reset()
Definition: SkBitmap.cpp:92
SkColorType colorType() const
Definition: SkBitmap.h:160
void setPixels(void *pixels)
Definition: SkBitmap.cpp:207
~SkBitmap()
Definition: SkBitmap.cpp:63
void * getPixels() const
Definition: SkBitmap.h:283
sk_sp< SkShader > makeShader(SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &, const SkMatrix *localMatrix=nullptr) const
Definition: SkBitmap.cpp:669
const SkImageInfo & info() const
Definition: SkBitmap.h:139
int bytesPerPixel() const
Definition: SkBitmap.h:187
SkBitmap()
Definition: SkBitmap.cpp:43
bool readPixels(const SkImageInfo &dstInfo, void *dstPixels, size_t dstRowBytes, int srcX, int srcY) const
Definition: SkBitmap.cpp:488
uint32_t getGenerationID() const
Definition: SkBitmap.cpp:361
void allocN32Pixels(int width, int height, bool isOpaque=false)
Definition: SkBitmap.cpp:232
SkIRect bounds() const
Definition: SkBitmap.h:382
bool peekPixels(SkPixmap *pixmap) const
Definition: SkBitmap.cpp:635
bool setInfo(const SkImageInfo &imageInfo, size_t rowBytes=0)
Definition: SkBitmap.cpp:114
bool setAlphaType(SkAlphaType alphaType)
Definition: SkBitmap.cpp:148
int height() const
Definition: SkBitmap.h:158
void allocPixelsFlags(const SkImageInfo &info, uint32_t flags)
Definition: SkBitmap.cpp:251
void setPixelRef(sk_sp< SkPixelRef > pixelRef, int dx, int dy)
Definition: SkBitmap.cpp:182
bool tryAllocN32Pixels(int width, int height, bool isOpaque=false)
Definition: SkBitmap.cpp:226
void swap(SkBitmap &other)
Definition: SkBitmap.cpp:86
bool tryAllocPixelsFlags(const SkImageInfo &info, uint32_t flags)
Definition: SkBitmap.cpp:296
void erase(SkColor4f c, const SkIRect &area) const
Definition: SkBitmap.cpp:420
void eraseColor(SkColor4f) const
Definition: SkBitmap.cpp:442
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
Definition: SkMatrix.h:1206
void notifyPixelsChanged()
Definition: SkPixelRef.cpp:102
void * pixels() const
Definition: SkPixelRef.h:36
uint32_t getGenerationID() const
Definition: SkPixelRef.cpp:63
void setImmutable()
Definition: SkPixelRef.cpp:112
bool isImmutable() const
Definition: SkPixelRef.h:55
int width() const
Definition: SkPixelRef.h:34
int height() const
Definition: SkPixelRef.h:35
size_t rowBytes() const
Definition: SkPixelRef.h:37
SkIRect bounds() const
Definition: SkPixmap.h:207
size_t rowBytes() const
Definition: SkPixmap.h:145
int width() const
Definition: SkPixmap.h:160
SkColorSpace * colorSpace() const
Definition: SkPixmap.cpp:61
const SkImageInfo & info() const
Definition: SkPixmap.h:135
void * writable_addr() const
Definition: SkPixmap.h:483
const void * addr() const
Definition: SkPixmap.h:153
int height() const
Definition: SkPixmap.h:166
void reset()
Definition: SkPixmap.cpp:32
T * get() const
Definition: SkRefCnt.h:303
void reset(T *ptr=nullptr)
Definition: SkRefCnt.h:310
const Paint & paint
Definition: color_source.cc:38
FlutterSemanticsFlag flags
GAsyncResult * result
double y
double x
SK_API sk_sp< SkImage > RasterFromBitmap(const SkBitmap &bitmap)
SK_API sk_sp< SkPixelRef > MakeAllocate(const SkImageInfo &, size_t rowBytes)
Optional< SkRect > bounds
Definition: SkRecords.h:189
SkSamplingOptions sampling
Definition: SkRecords.h:337
skia_private::AutoTArray< sk_sp< SkImageFilter > > filters TypedMatrix matrix TypedMatrix matrix SkScalar dx
Definition: SkRecords.h:208
dst
Definition: cp.py:12
Definition: ref_ptr.h:256
SkTileMode tmy
SkTileMode tmx
int32_t height
int32_t width
SeparatedVector2 offset
constexpr int32_t y() const
Definition: SkPoint_impl.h:52
int32_t fX
x-axis value
Definition: SkPoint_impl.h:29
int32_t fY
y-axis value
Definition: SkPoint_impl.h:30
constexpr int32_t x() const
Definition: SkPoint_impl.h:46
Definition: SkRect.h:32
bool intersect(const SkIRect &r)
Definition: SkRect.h:513
constexpr SkISize size() const
Definition: SkRect.h:172
constexpr int32_t height() const
Definition: SkRect.h:165
int32_t fTop
smaller y-axis bounds
Definition: SkRect.h:34
constexpr int32_t width() const
Definition: SkRect.h:158
static constexpr SkIRect MakeWH(int32_t w, int32_t h)
Definition: SkRect.h:56
void setWH(int32_t width, int32_t height)
Definition: SkRect.h:275
int32_t fLeft
smaller x-axis bounds
Definition: SkRect.h:33
SkImageInfo makeAlphaType(SkAlphaType newAlphaType) const
Definition: SkImageInfo.h:466
sk_sp< SkColorSpace > refColorSpace() const
size_t minRowBytes() const
Definition: SkImageInfo.h:517
SkImageInfo makeDimensions(SkISize newSize) const
Definition: SkImageInfo.h:454
SkISize dimensions() const
Definition: SkImageInfo.h:421
SkImageInfo makeColorSpace(sk_sp< SkColorSpace > cs) const
int width() const
Definition: SkImageInfo.h:365
static SkImageInfo MakeN32(int width, int height, SkAlphaType at)
SkAlphaType alphaType() const
Definition: SkImageInfo.h:375
SkColorType colorType() const
Definition: SkImageInfo.h:373
uint64_t minRowBytes64() const
Definition: SkImageInfo.h:507
int height() const
Definition: SkImageInfo.h:371
bool validRowBytes(size_t rowBytes) const
Definition: SkImageInfo.h:598
static SkImageInfo MakeA8(int width, int height)
Format & format()
Definition: SkMask.h:239
uint32_t & rowBytes()
Definition: SkMask.h:238
static uint8_t * AllocImage(size_t bytes, AllocType=kUninit_Alloc)
Definition: SkMask.cpp:45
SkIRect & bounds()
Definition: SkMask.h:237
uint8_t *& image()
Definition: SkMask.h:236
const uint32_t fRowBytes
Definition: SkMask.h:43
@ kA8_Format
8bits per pixel mask (e.g. antialiasing)
Definition: SkMask.h:28
uint8_t const *const fImage
Definition: SkMask.h:41
const SkIRect fBounds
Definition: SkMask.h:42
size_t computeImageSize() const
Definition: SkMask.cpp:30
const Format fFormat
Definition: SkMask.h:44
static SkRect Make(const SkISize &size)
Definition: SkRect.h:669
bool trim(int dstWidth, int dstHeight)
const void * fPixels