本文整理汇总了C++中SkAutoTUnref::extractLevel方法的典型用法代码示例。如果您正苦于以下问题:C++ SkAutoTUnref::extractLevel方法的具体用法?C++ SkAutoTUnref::extractLevel怎么用?C++ SkAutoTUnref::extractLevel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkAutoTUnref
的用法示例。
在下文中一共展示了SkAutoTUnref::extractLevel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: processMediumRequest
/*
* Modulo internal errors, this should always succeed *if* the matrix is downscaling
* (in this case, we have the inverse, so it succeeds if fInvMatrix is upscaling)
*/
bool SkDefaultBitmapControllerState::processMediumRequest(const SkBitmapProvider& provider) {
SkASSERT(fQuality <= kMedium_SkFilterQuality);
if (fQuality != kMedium_SkFilterQuality) {
return false;
}
// Our default return state is to downgrade the request to Low, w/ or w/o setting fBitmap
// to a valid bitmap.
fQuality = kLow_SkFilterQuality;
SkSize invScaleSize;
if (!fInvMatrix.decomposeScale(&invScaleSize, nullptr)) {
return false;
}
// Use the largest (non-inverse) scale, to ensure anisotropic consistency.
SkASSERT(invScaleSize.width() >= 0 && invScaleSize.height() >= 0);
const SkScalar invScale = SkTMin(invScaleSize.width(), invScaleSize.height());
if (invScale > SK_Scalar1) {
fCurrMip.reset(SkMipMapCache::FindAndRef(provider.makeCacheDesc()));
if (nullptr == fCurrMip.get()) {
SkBitmap orig;
if (!provider.asBitmap(&orig)) {
return false;
}
fCurrMip.reset(SkMipMapCache::AddAndRef(orig));
if (nullptr == fCurrMip.get()) {
return false;
}
}
// diagnostic for a crasher...
if (nullptr == fCurrMip->data()) {
sk_throw();
}
SkScalar levelScale = SkScalarInvert(invScale);
SkMipMap::Level level;
if (fCurrMip->extractLevel(levelScale, &level)) {
const SkSize& invScaleFixup = level.fScale;
fInvMatrix.postScale(invScaleFixup.width(), invScaleFixup.height());
// todo: if we could wrap the fCurrMip in a pixelref, then we could just install
// that here, and not need to explicitly track it ourselves.
return fResultBitmap.installPixels(level.fPixmap);
} else {
// failed to extract, so release the mipmap
fCurrMip.reset(nullptr);
}
}
return false;
}
示例2: processMediumRequest
/*
* Modulo internal errors, this should always succeed *if* the matrix is downscaling
* (in this case, we have the inverse, so it succeeds if fInvMatrix is upscaling)
*/
bool SkDefaultBitmapControllerState::processMediumRequest(const SkBitmap& origBitmap) {
SkASSERT(fQuality <= kMedium_SkFilterQuality);
if (fQuality != kMedium_SkFilterQuality) {
return false;
}
// Our default return state is to downgrade the request to Low, w/ or w/o setting fBitmap
// to a valid bitmap.
fQuality = kLow_SkFilterQuality;
SkSize invScaleSize;
if (!fInvMatrix.decomposeScale(&invScaleSize, NULL)) {
return false;
}
SkScalar invScale = SkScalarSqrt(invScaleSize.width() * invScaleSize.height());
if (invScale > SK_Scalar1) {
fCurrMip.reset(SkMipMapCache::FindAndRef(origBitmap));
if (NULL == fCurrMip.get()) {
fCurrMip.reset(SkMipMapCache::AddAndRef(origBitmap));
if (NULL == fCurrMip.get()) {
return false;
}
}
// diagnostic for a crasher...
if (NULL == fCurrMip->data()) {
sk_throw();
}
SkScalar levelScale = SkScalarInvert(invScale);
SkMipMap::Level level;
if (fCurrMip->extractLevel(levelScale, &level)) {
SkScalar invScaleFixup = level.fScale;
fInvMatrix.postScale(invScaleFixup, invScaleFixup);
const SkImageInfo info = origBitmap.info().makeWH(level.fWidth, level.fHeight);
// todo: if we could wrap the fCurrMip in a pixelref, then we could just install
// that here, and not need to explicitly track it ourselves.
return fResultBitmap.installPixels(info, level.fPixels, level.fRowBytes);
} else {
// failed to extract, so release the mipmap
fCurrMip.reset(NULL);
}
}
return false;
}