Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
SkMipmap Class Reference

#include <SkMipmap.h>

Inheritance diagram for SkMipmap:
SkCachedData SkNoncopyable

Classes

struct  Level
 

Public Member Functions

 ~SkMipmap () override
 
bool extractLevel (SkSize scale, Level *) const
 
int countLevels () const
 
bool getLevel (int index, Level *) const
 
bool validForRootLevel (const SkImageInfo &) const
 
- Public Member Functions inherited from SkCachedData
 SkCachedData (void *mallocData, size_t size)
 
 SkCachedData (size_t size, SkDiscardableMemory *)
 
virtual ~SkCachedData ()
 
size_t size () const
 
const void * data () const
 
void * writable_data ()
 
void ref () const
 
void unref () const
 
int testing_only_getRefCnt () const
 
bool testing_only_isLocked () const
 
bool testing_only_isInCache () const
 
SkDiscardableMemorydiagnostic_only_getDiscardable () const
 
void validate () const
 
void attachToCacheAndRef () const
 
void detachFromCacheAndUnref () const
 

Static Public Member Functions

static SkMipmapBuild (const SkPixmap &src, SkDiscardableFactoryProc, bool computeContents=true)
 
static SkMipmapBuild (const SkBitmap &src, SkDiscardableFactoryProc)
 
static int ComputeLevelCount (int baseWidth, int baseHeight)
 
static int ComputeLevelCount (SkISize s)
 
static SkISize ComputeLevelSize (int baseWidth, int baseHeight, int level)
 
static SkISize ComputeLevelSize (SkISize s, int level)
 
static float ComputeLevel (SkSize scaleSize)
 
static std::unique_ptr< SkMipmapDownSamplerMakeDownSampler (const SkPixmap &)
 

Protected Member Functions

void onDataChange (void *oldData, void *newData) override
 

Detailed Description

Definition at line 39 of file SkMipmap.h.

Constructor & Destructor Documentation

◆ ~SkMipmap()

SkMipmap::~SkMipmap ( )
overridedefault

Member Function Documentation

◆ Build() [1/2]

SkMipmap * SkMipmap::Build ( const SkBitmap src,
SkDiscardableFactoryProc  fact 
)
static

Definition at line 268 of file SkMipmap.cpp.

268 {
269 SkPixmap srcPixmap;
270 if (!src.peekPixels(&srcPixmap)) {
271 return nullptr;
272 }
273 return Build(srcPixmap, fact);
274}
static SkMipmap * Build(const SkPixmap &src, SkDiscardableFactoryProc, bool computeContents=true)
Definition SkMipmap.cpp:45

◆ Build() [2/2]

SkMipmap * SkMipmap::Build ( const SkPixmap src,
SkDiscardableFactoryProc  fact,
bool  computeContents = true 
)
static

Definition at line 45 of file SkMipmap.cpp.

46 {
47 if (src.width() <= 1 && src.height() <= 1) {
48 return nullptr;
49 }
50
51 const SkColorType ct = src.colorType();
52 const SkAlphaType at = src.alphaType();
53
54 // whip through our loop to compute the exact size needed
55 size_t size = 0;
56 int countLevels = ComputeLevelCount(src.width(), src.height());
57 for (int currentMipLevel = countLevels; currentMipLevel >= 0; currentMipLevel--) {
58 SkISize mipSize = ComputeLevelSize(src.width(), src.height(), currentMipLevel);
59 size += SkColorTypeMinRowBytes(ct, mipSize.fWidth) * mipSize.fHeight;
60 }
61
62 size_t storageSize = SkMipmap::AllocLevelsSize(countLevels, size);
63 if (0 == storageSize) {
64 return nullptr;
65 }
66
67 SkMipmap* mipmap;
68 if (fact) {
69 SkDiscardableMemory* dm = fact(storageSize);
70 if (nullptr == dm) {
71 return nullptr;
72 }
73 mipmap = new SkMipmap(storageSize, dm);
74 } else {
75 void* tmp = sk_malloc_canfail(storageSize);
76 if (!tmp) {
77 return nullptr;
78 }
79
80 mipmap = new SkMipmap(tmp, storageSize);
81 }
82
83 // init
84 mipmap->fCS = sk_ref_sp(src.info().colorSpace());
85 mipmap->fCount = countLevels;
86 mipmap->fLevels = (Level*)mipmap->writable_data();
87 SkASSERT(mipmap->fLevels);
88
89 Level* levels = mipmap->fLevels;
90 uint8_t* baseAddr = (uint8_t*)&levels[countLevels];
91 uint8_t* addr = baseAddr;
92 int width = src.width();
93 int height = src.height();
94 uint32_t rowBytes;
95 SkPixmap srcPM(src);
96
97 // Depending on architecture and other factors, the pixel data alignment may need to be as
98 // large as 8 (for F16 pixels). See the comment on SkMipmap::Level.
99 SkASSERT(SkIsAlign8((uintptr_t)addr));
100
101 std::unique_ptr<SkMipmapDownSampler> downsampler;
102 if (computeContents) {
103 downsampler = MakeDownSampler(src);
104 if (!downsampler) {
105 return nullptr;
106 }
107 }
108
109 for (int i = 0; i < countLevels; ++i) {
110 width = std::max(1, width >> 1);
111 height = std::max(1, height >> 1);
112 rowBytes = SkToU32(SkColorTypeMinRowBytes(ct, width));
113
114 // We make the Info w/o any colorspace, since that storage is not under our control, and
115 // will not be deleted in a controlled fashion. When the caller is given the pixmap for
116 // a given level, we augment this pixmap with fCS (which we do manage).
117 new (&levels[i].fPixmap) SkPixmap(SkImageInfo::Make(width, height, ct, at), addr, rowBytes);
118 levels[i].fScale = SkSize::Make(SkIntToScalar(width) / src.width(),
119 SkIntToScalar(height) / src.height());
120
121 const SkPixmap& dstPM = levels[i].fPixmap;
122 if (downsampler) {
123 downsampler->buildLevel(dstPM, srcPM);
124 }
125 srcPM = dstPM;
126 addr += height * rowBytes;
127 }
128 SkASSERT(addr == baseAddr + size);
129
130 SkASSERT(mipmap->fLevels);
131 return mipmap;
132}
static constexpr bool SkIsAlign8(T x)
Definition SkAlign.h:21
SkAlphaType
Definition SkAlphaType.h:26
#define SkASSERT(cond)
Definition SkAssert.h:116
SkColorType
Definition SkColorType.h:19
static size_t SkColorTypeMinRowBytes(SkColorType ct, int width)
static void * sk_malloc_canfail(size_t size)
Definition SkMalloc.h:93
sk_sp< T > sk_ref_sp(T *obj)
Definition SkRefCnt.h:381
#define SkIntToScalar(x)
Definition SkScalar.h:57
constexpr uint32_t SkToU32(S x)
Definition SkTo.h:26
void * writable_data()
size_t size() const
static SkISize ComputeLevelSize(int baseWidth, int baseHeight, int level)
Definition SkMipmap.cpp:168
static std::unique_ptr< SkMipmapDownSampler > MakeDownSampler(const SkPixmap &)
int countLevels() const
Definition SkMipmap.cpp:276
static int ComputeLevelCount(int baseWidth, int baseHeight)
Definition SkMipmap.cpp:134
int32_t height
int32_t width
int32_t fHeight
Definition SkSize.h:18
int32_t fWidth
Definition SkSize.h:17
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
static constexpr SkSize Make(SkScalar w, SkScalar h)
Definition SkSize.h:56

◆ ComputeLevel()

float SkMipmap::ComputeLevel ( SkSize  scaleSize)
static

Definition at line 195 of file SkMipmap.cpp.

195 {
196 SkASSERT(scaleSize.width() >= 0 && scaleSize.height() >= 0);
197
198#ifndef SK_SUPPORT_LEGACY_ANISOTROPIC_MIPMAP_SCALE
199 // Use the smallest scale to match the GPU impl.
200 const float scale = std::min(scaleSize.width(), scaleSize.height());
201#else
202 // Ideally we'd pick the smaller scale, to match Ganesh. But ignoring one of the
203 // scales can produce some atrocious results, so for now we use the geometric mean.
204 // (https://bugs.chromium.org/p/skia/issues/detail?id=4863)
205 const float scale = std::sqrt(scaleSize.width() * scaleSize.height());
206#endif
207
208 if (scale >= SK_Scalar1 || scale <= 0 || !SkIsFinite(scale)) {
209 return -1;
210 }
211
212 // The -0.5 bias here is to emulate GPU's sharpen mipmap option.
213 float L = std::max(-SkScalarLog2(scale) - 0.5f, 0.f);
214 if (!SkIsFinite(L)) {
215 return -1;
216 }
217 return L;
218}
static bool SkIsFinite(T x, Pack... values)
#define SK_Scalar1
Definition SkScalar.h:18
#define SkScalarLog2(x)
Definition SkScalar.h:53
const Scalar scale
SkScalar width() const
Definition SkSize.h:76
SkScalar height() const
Definition SkSize.h:77

◆ ComputeLevelCount() [1/2]

int SkMipmap::ComputeLevelCount ( int  baseWidth,
int  baseHeight 
)
static

Definition at line 134 of file SkMipmap.cpp.

134 {
135 if (baseWidth < 1 || baseHeight < 1) {
136 return 0;
137 }
138
139 // OpenGL's spec requires that each mipmap level have height/width equal to
140 // max(1, floor(original_height / 2^i)
141 // (or original_width) where i is the mipmap level.
142 // Continue scaling down until both axes are size 1.
143
144 const int largestAxis = std::max(baseWidth, baseHeight);
145 if (largestAxis < 2) {
146 // SkMipmap::Build requires a minimum size of 2.
147 return 0;
148 }
149 const int leadingZeros = SkCLZ(static_cast<uint32_t>(largestAxis));
150 // If the value 00011010 has 3 leading 0s then it has 5 significant bits
151 // (the bits which are not leading zeros)
152 const int significantBits = (sizeof(uint32_t) * 8) - leadingZeros;
153 // This is making the assumption that the size of a byte is 8 bits
154 // and that sizeof(uint32_t)'s implementation-defined behavior is 4.
155 int mipLevelCount = significantBits;
156
157 // SkMipmap does not include the base mip level.
158 // For example, it contains levels 1-x instead of 0-x.
159 // This is because the image used to create SkMipmap is the base level.
160 // So subtract 1 from the mip level count.
161 if (mipLevelCount > 0) {
162 --mipLevelCount;
163 }
164
165 return mipLevelCount;
166}
static int SkCLZ(uint32_t mask)
Definition SkMathPriv.h:186

◆ ComputeLevelCount() [2/2]

static int SkMipmap::ComputeLevelCount ( SkISize  s)
inlinestatic

Definition at line 53 of file SkMipmap.h.

53{ return ComputeLevelCount(s.width(), s.height()); }
struct MyStruct s

◆ ComputeLevelSize() [1/2]

SkISize SkMipmap::ComputeLevelSize ( int  baseWidth,
int  baseHeight,
int  level 
)
static

Definition at line 168 of file SkMipmap.cpp.

168 {
169 if (baseWidth < 1 || baseHeight < 1) {
170 return SkISize::Make(0, 0);
171 }
172
173 int maxLevelCount = ComputeLevelCount(baseWidth, baseHeight);
174 if (level >= maxLevelCount || level < 0) {
175 return SkISize::Make(0, 0);
176 }
177 // OpenGL's spec requires that each mipmap level have height/width equal to
178 // max(1, floor(original_height / 2^i)
179 // (or original_width) where i is the mipmap level.
180
181 // SkMipmap does not include the base mip level.
182 // For example, it contains levels 1-x instead of 0-x.
183 // This is because the image used to create SkMipmap is the base level.
184 // So subtract 1 from the mip level to get the index stored by SkMipmap.
185 int width = std::max(1, baseWidth >> (level + 1));
186 int height = std::max(1, baseHeight >> (level + 1));
187
188 return SkISize::Make(width, height);
189}
static constexpr SkISize Make(int32_t w, int32_t h)
Definition SkSize.h:20

◆ ComputeLevelSize() [2/2]

static SkISize SkMipmap::ComputeLevelSize ( SkISize  s,
int  level 
)
inlinestatic

Definition at line 59 of file SkMipmap.h.

59 {
60 return ComputeLevelSize(s.width(), s.height(), level);
61 }

◆ countLevels()

int SkMipmap::countLevels ( ) const

Definition at line 276 of file SkMipmap.cpp.

276 {
277 return fCount;
278}

◆ extractLevel()

bool SkMipmap::extractLevel ( SkSize  scale,
Level levelPtr 
) const

Definition at line 220 of file SkMipmap.cpp.

220 {
221 if (nullptr == fLevels) {
222 return false;
223 }
224
225 float L = ComputeLevel(scaleSize);
226 int level = sk_float_round2int(L);
227 if (level <= 0) {
228 return false;
229 }
230
231 if (level > fCount) {
232 level = fCount;
233 }
234 if (levelPtr) {
235 *levelPtr = fLevels[level - 1];
236 // need to augment with our colorspace
237 levelPtr->fPixmap.setColorSpace(fCS);
238 }
239 return true;
240}
#define sk_float_round2int(x)
static float ComputeLevel(SkSize scaleSize)
Definition SkMipmap.cpp:195
void setColorSpace(sk_sp< SkColorSpace > colorSpace)
Definition SkPixmap.cpp:57
SkPixmap fPixmap
Definition SkMipmap.h:71

◆ getLevel()

bool SkMipmap::getLevel ( int  index,
Level levelPtr 
) const

Definition at line 280 of file SkMipmap.cpp.

280 {
281 if (nullptr == fLevels) {
282 return false;
283 }
284 if (index < 0) {
285 return false;
286 }
287 if (index > fCount - 1) {
288 return false;
289 }
290 if (levelPtr) {
291 *levelPtr = fLevels[index];
292 // need to augment with our colorspace
293 levelPtr->fPixmap.setColorSpace(fCS);
294 }
295 return true;
296}

◆ MakeDownSampler()

std::unique_ptr< SkMipmapDownSampler > SkMipmap::MakeDownSampler ( const SkPixmap root)
static

Definition at line 441 of file SkMipmapHQDownSampler.cpp.

441 {
442 FilterProc* proc_1_2 = nullptr;
443 FilterProc* proc_1_3 = nullptr;
444 FilterProc* proc_2_1 = nullptr;
445 FilterProc* proc_2_2 = nullptr;
446 FilterProc* proc_2_3 = nullptr;
447 FilterProc* proc_3_1 = nullptr;
448 FilterProc* proc_3_2 = nullptr;
449 FilterProc* proc_3_3 = nullptr;
450
451 switch (root.colorType()) {
454 proc_1_2 = downsample_1_2<ColorTypeFilter_8888>;
455 proc_1_3 = downsample_1_3<ColorTypeFilter_8888>;
456 proc_2_1 = downsample_2_1<ColorTypeFilter_8888>;
457 proc_2_2 = downsample_2_2<ColorTypeFilter_8888>;
458 proc_2_3 = downsample_2_3<ColorTypeFilter_8888>;
459 proc_3_1 = downsample_3_1<ColorTypeFilter_8888>;
460 proc_3_2 = downsample_3_2<ColorTypeFilter_8888>;
461 proc_3_3 = downsample_3_3<ColorTypeFilter_8888>;
462 break;
464 proc_1_2 = downsample_1_2<ColorTypeFilter_565>;
465 proc_1_3 = downsample_1_3<ColorTypeFilter_565>;
466 proc_2_1 = downsample_2_1<ColorTypeFilter_565>;
467 proc_2_2 = downsample_2_2<ColorTypeFilter_565>;
468 proc_2_3 = downsample_2_3<ColorTypeFilter_565>;
469 proc_3_1 = downsample_3_1<ColorTypeFilter_565>;
470 proc_3_2 = downsample_3_2<ColorTypeFilter_565>;
471 proc_3_3 = downsample_3_3<ColorTypeFilter_565>;
472 break;
474 proc_1_2 = downsample_1_2<ColorTypeFilter_4444>;
475 proc_1_3 = downsample_1_3<ColorTypeFilter_4444>;
476 proc_2_1 = downsample_2_1<ColorTypeFilter_4444>;
477 proc_2_2 = downsample_2_2<ColorTypeFilter_4444>;
478 proc_2_3 = downsample_2_3<ColorTypeFilter_4444>;
479 proc_3_1 = downsample_3_1<ColorTypeFilter_4444>;
480 proc_3_2 = downsample_3_2<ColorTypeFilter_4444>;
481 proc_3_3 = downsample_3_3<ColorTypeFilter_4444>;
482 break;
486 proc_1_2 = downsample_1_2<ColorTypeFilter_8>;
487 proc_1_3 = downsample_1_3<ColorTypeFilter_8>;
488 proc_2_1 = downsample_2_1<ColorTypeFilter_8>;
489 proc_2_2 = downsample_2_2<ColorTypeFilter_8>;
490 proc_2_3 = downsample_2_3<ColorTypeFilter_8>;
491 proc_3_1 = downsample_3_1<ColorTypeFilter_8>;
492 proc_3_2 = downsample_3_2<ColorTypeFilter_8>;
493 proc_3_3 = downsample_3_3<ColorTypeFilter_8>;
494 break;
497 proc_1_2 = downsample_1_2<ColorTypeFilter_RGBA_F16>;
498 proc_1_3 = downsample_1_3<ColorTypeFilter_RGBA_F16>;
499 proc_2_1 = downsample_2_1<ColorTypeFilter_RGBA_F16>;
500 proc_2_2 = downsample_2_2<ColorTypeFilter_RGBA_F16>;
501 proc_2_3 = downsample_2_3<ColorTypeFilter_RGBA_F16>;
502 proc_3_1 = downsample_3_1<ColorTypeFilter_RGBA_F16>;
503 proc_3_2 = downsample_3_2<ColorTypeFilter_RGBA_F16>;
504 proc_3_3 = downsample_3_3<ColorTypeFilter_RGBA_F16>;
505 break;
507 proc_1_2 = downsample_1_2<ColorTypeFilter_88>;
508 proc_1_3 = downsample_1_3<ColorTypeFilter_88>;
509 proc_2_1 = downsample_2_1<ColorTypeFilter_88>;
510 proc_2_2 = downsample_2_2<ColorTypeFilter_88>;
511 proc_2_3 = downsample_2_3<ColorTypeFilter_88>;
512 proc_3_1 = downsample_3_1<ColorTypeFilter_88>;
513 proc_3_2 = downsample_3_2<ColorTypeFilter_88>;
514 proc_3_3 = downsample_3_3<ColorTypeFilter_88>;
515 break;
517 proc_1_2 = downsample_1_2<ColorTypeFilter_1616>;
518 proc_1_3 = downsample_1_3<ColorTypeFilter_1616>;
519 proc_2_1 = downsample_2_1<ColorTypeFilter_1616>;
520 proc_2_2 = downsample_2_2<ColorTypeFilter_1616>;
521 proc_2_3 = downsample_2_3<ColorTypeFilter_1616>;
522 proc_3_1 = downsample_3_1<ColorTypeFilter_1616>;
523 proc_3_2 = downsample_3_2<ColorTypeFilter_1616>;
524 proc_3_3 = downsample_3_3<ColorTypeFilter_1616>;
525 break;
527 proc_1_2 = downsample_1_2<ColorTypeFilter_16>;
528 proc_1_3 = downsample_1_3<ColorTypeFilter_16>;
529 proc_2_1 = downsample_2_1<ColorTypeFilter_16>;
530 proc_2_2 = downsample_2_2<ColorTypeFilter_16>;
531 proc_2_3 = downsample_2_3<ColorTypeFilter_16>;
532 proc_3_1 = downsample_3_1<ColorTypeFilter_16>;
533 proc_3_2 = downsample_3_2<ColorTypeFilter_16>;
534 proc_3_3 = downsample_3_3<ColorTypeFilter_16>;
535 break;
538 proc_1_2 = downsample_1_2<ColorTypeFilter_1010102>;
539 proc_1_3 = downsample_1_3<ColorTypeFilter_1010102>;
540 proc_2_1 = downsample_2_1<ColorTypeFilter_1010102>;
541 proc_2_2 = downsample_2_2<ColorTypeFilter_1010102>;
542 proc_2_3 = downsample_2_3<ColorTypeFilter_1010102>;
543 proc_3_1 = downsample_3_1<ColorTypeFilter_1010102>;
544 proc_3_2 = downsample_3_2<ColorTypeFilter_1010102>;
545 proc_3_3 = downsample_3_3<ColorTypeFilter_1010102>;
546 break;
548 proc_1_2 = downsample_1_2<ColorTypeFilter_Alpha_F16>;
549 proc_1_3 = downsample_1_3<ColorTypeFilter_Alpha_F16>;
550 proc_2_1 = downsample_2_1<ColorTypeFilter_Alpha_F16>;
551 proc_2_2 = downsample_2_2<ColorTypeFilter_Alpha_F16>;
552 proc_2_3 = downsample_2_3<ColorTypeFilter_Alpha_F16>;
553 proc_3_1 = downsample_3_1<ColorTypeFilter_Alpha_F16>;
554 proc_3_2 = downsample_3_2<ColorTypeFilter_Alpha_F16>;
555 proc_3_3 = downsample_3_3<ColorTypeFilter_Alpha_F16>;
556 break;
558 proc_1_2 = downsample_1_2<ColorTypeFilter_F16F16>;
559 proc_1_3 = downsample_1_3<ColorTypeFilter_F16F16>;
560 proc_2_1 = downsample_2_1<ColorTypeFilter_F16F16>;
561 proc_2_2 = downsample_2_2<ColorTypeFilter_F16F16>;
562 proc_2_3 = downsample_2_3<ColorTypeFilter_F16F16>;
563 proc_3_1 = downsample_3_1<ColorTypeFilter_F16F16>;
564 proc_3_2 = downsample_3_2<ColorTypeFilter_F16F16>;
565 proc_3_3 = downsample_3_3<ColorTypeFilter_F16F16>;
566 break;
568 proc_1_2 = downsample_1_2<ColorTypeFilter_16161616>;
569 proc_1_3 = downsample_1_3<ColorTypeFilter_16161616>;
570 proc_2_1 = downsample_2_1<ColorTypeFilter_16161616>;
571 proc_2_2 = downsample_2_2<ColorTypeFilter_16161616>;
572 proc_2_3 = downsample_2_3<ColorTypeFilter_16161616>;
573 proc_3_1 = downsample_3_1<ColorTypeFilter_16161616>;
574 proc_3_2 = downsample_3_2<ColorTypeFilter_16161616>;
575 proc_3_3 = downsample_3_3<ColorTypeFilter_16161616>;
576 break;
577
579 case kRGB_888x_SkColorType: // TODO: use 8888?
580 case kRGB_101010x_SkColorType: // TODO: use 1010102?
581 case kBGR_101010x_SkColorType: // TODO: use 1010102?
582 case kBGR_101010x_XR_SkColorType: // TODO: use 1010102?
586 return nullptr;
587
588 case kSRGBA_8888_SkColorType: // TODO: needs careful handling
589 return nullptr;
590 }
591
592 auto sampler = std::make_unique<HQDownSampler>();
593 sampler->proc_1_2 = proc_1_2;
594 sampler->proc_1_3 = proc_1_3;
595 sampler->proc_2_1 = proc_2_1;
596 sampler->proc_2_2 = proc_2_2;
597 sampler->proc_2_3 = proc_2_3;
598 sampler->proc_3_1 = proc_3_1;
599 sampler->proc_3_2 = proc_3_2;
600 sampler->proc_3_3 = proc_3_3;
601 return sampler;
602}
@ kR16G16B16A16_unorm_SkColorType
pixel with a little endian uint16_t for red, green, blue
Definition SkColorType.h:50
@ kRGBA_10x6_SkColorType
pixel with 10 used bits (most significant) followed by 6 unused
Definition SkColorType.h:33
@ kR8_unorm_SkColorType
Definition SkColorType.h:54
@ kBGR_101010x_SkColorType
pixel with 10 bits each for blue, green, red; in 32-bit word
Definition SkColorType.h:30
@ kARGB_4444_SkColorType
pixel with 4 bits for alpha, red, green, blue; in 16-bit word
Definition SkColorType.h:23
@ kR8G8_unorm_SkColorType
pixel with a uint8_t for red and green
Definition SkColorType.h:43
@ kBGRA_8888_SkColorType
pixel with 8 bits for blue, green, red, alpha; in 32-bit word
Definition SkColorType.h:26
@ kA16_unorm_SkColorType
pixel with a little endian uint16_t for alpha
Definition SkColorType.h:48
@ kRGBA_F16_SkColorType
pixel with half floats for red, green, blue, alpha;
Definition SkColorType.h:38
@ kAlpha_8_SkColorType
pixel with alpha in 8-bit byte
Definition SkColorType.h:21
@ kRGB_101010x_SkColorType
pixel with 10 bits each for red, green, blue; in 32-bit word
Definition SkColorType.h:29
@ kSRGBA_8888_SkColorType
Definition SkColorType.h:53
@ kGray_8_SkColorType
pixel with grayscale level in 8-bit byte
Definition SkColorType.h:35
@ kRGB_565_SkColorType
pixel with 5 bits red, 6 bits green, 5 bits blue, in 16-bit word
Definition SkColorType.h:22
@ kBGRA_10101010_XR_SkColorType
pixel with 10 bits each for blue, green, red, alpha; in 64-bit word, extended range
Definition SkColorType.h:32
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
Definition SkColorType.h:24
@ kRGB_888x_SkColorType
pixel with 8 bits each for red, green, blue; in 32-bit word
Definition SkColorType.h:25
@ kBGRA_1010102_SkColorType
10 bits for blue, green, red; 2 bits for alpha; in 32-bit word
Definition SkColorType.h:28
@ kA16_float_SkColorType
pixel with a half float for alpha
Definition SkColorType.h:45
@ kRGBA_F32_SkColorType
pixel using C float for red, green, blue, alpha; in 128-bit word
Definition SkColorType.h:40
@ kRGBA_1010102_SkColorType
10 bits for red, green, blue; 2 bits for alpha; in 32-bit word
Definition SkColorType.h:27
@ kBGR_101010x_XR_SkColorType
pixel with 10 bits each for blue, green, red; in 32-bit word, extended range
Definition SkColorType.h:31
@ kR16G16_unorm_SkColorType
pixel with a little endian uint16_t for red and green
Definition SkColorType.h:49
@ kRGBA_F16Norm_SkColorType
pixel with half floats in [0,1] for red, green, blue, alpha;
Definition SkColorType.h:36
@ kUnknown_SkColorType
uninitialized
Definition SkColorType.h:20
@ kR16G16_float_SkColorType
pixel with a half float for red and green
Definition SkColorType.h:46

◆ onDataChange()

void SkMipmap::onDataChange ( void *  oldData,
void *  newData 
)
inlineoverrideprotectedvirtual

Reimplemented from SkCachedData.

Definition at line 90 of file SkMipmap.h.

90 {
91 fLevels = (Level*)newData; // could be nullptr
92 }

◆ validForRootLevel()

bool SkMipmap::validForRootLevel ( const SkImageInfo root) const

Definition at line 242 of file SkMipmap.cpp.

242 {
243 if (nullptr == fLevels) {
244 return false;
245 }
246
247 const SkISize dimension = root.dimensions();
248 if (dimension.width() <= 1 && dimension.height() <= 1) {
249 return false;
250 }
251
252 if (fLevels[0].fPixmap. width() != std::max(1, dimension. width() >> 1) ||
253 fLevels[0].fPixmap.height() != std::max(1, dimension.height() >> 1)) {
254 return false;
255 }
256
257 for (int i = 0; i < this->countLevels(); ++i) {
258 if (fLevels[i].fPixmap.colorType() != root.colorType() ||
259 fLevels[i].fPixmap.alphaType() != root.alphaType()) {
260 return false;
261 }
262 }
263 return true;
264}
SkAlphaType alphaType() const
Definition SkPixmap.h:175
constexpr int32_t width() const
Definition SkSize.h:36
constexpr int32_t height() const
Definition SkSize.h:37

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