本文整理汇总了C++中SkImageInfo::isEmpty方法的典型用法代码示例。如果您正苦于以下问题:C++ SkImageInfo::isEmpty方法的具体用法?C++ SkImageInfo::isEmpty怎么用?C++ SkImageInfo::isEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkImageInfo
的用法示例。
在下文中一共展示了SkImageInfo::isEmpty方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: validate_pixels_ctable
static void validate_pixels_ctable(const SkImageInfo& info, const SkColorTable* ctable) {
if (info.isEmpty()) {
return; // can't require ctable if the dimensions are empty
}
if (kIndex_8_SkColorType == info.colorType()) {
SkASSERT(ctable);
} else {
SkASSERT(NULL == ctable);
}
}
示例2: Valid
bool SkSurface_Raster::Valid(const SkImageInfo& info, size_t rowBytes) {
if (info.isEmpty()) {
return false;
}
static const size_t kMaxTotalSize = SK_MaxS32;
int shift = 0;
switch (info.colorType()) {
case kAlpha_8_SkColorType:
shift = 0;
break;
case kRGB_565_SkColorType:
shift = 1;
break;
case kN32_SkColorType:
shift = 2;
break;
case kRGBA_F16_SkColorType:
shift = 3;
break;
default:
return false;
}
if (kIgnoreRowBytesValue == rowBytes) {
return true;
}
uint64_t minRB = (uint64_t)info.width() << shift;
if (minRB > rowBytes) {
return false;
}
size_t alignedRowBytes = rowBytes >> shift << shift;
if (alignedRowBytes != rowBytes) {
return false;
}
uint64_t size = sk_64_mul(info.height(), rowBytes);
if (size > kMaxTotalSize) {
return false;
}
return true;
}
示例3: SkInstallDiscardablePixelRef
bool SkInstallDiscardablePixelRef(SkImageGenerator* generator, const SkIRect* subset, SkBitmap* dst,
SkDiscardableMemory::Factory* factory) {
SkAutoTDelete<SkImageGenerator> autoGenerator(generator);
if (NULL == autoGenerator.get()) {
return false;
}
SkImageInfo prInfo = autoGenerator->getInfo();
if (prInfo.isEmpty()) {
return false;
}
SkIPoint origin = SkIPoint::Make(0, 0);
SkImageInfo bmInfo = prInfo;
if (subset) {
const SkIRect prBounds = SkIRect::MakeWH(prInfo.width(), prInfo.height());
if (subset->isEmpty() || !prBounds.contains(*subset)) {
return false;
}
bmInfo = prInfo.makeWH(subset->width(), subset->height());
origin.set(subset->x(), subset->y());
}
// must compute our desired rowBytes w.r.t. the pixelRef's dimensions, not ours, which may be
// smaller.
if (!dst->setInfo(bmInfo, prInfo.minRowBytes())) {
return false;
}
// Since dst->setInfo() may have changed/fixed-up info, we check from the bitmap
SkASSERT(dst->info().colorType() != kUnknown_SkColorType);
if (dst->empty()) { // Use a normal pixelref.
return dst->tryAllocPixels();
}
SkAutoTUnref<SkDiscardablePixelRef> ref(
new SkDiscardablePixelRef(prInfo, autoGenerator.detach(), dst->rowBytes(), factory));
dst->setPixelRef(ref, origin.x(), origin.y());
return true;
}