本文整理汇总了C++中SkPixmap::reset方法的典型用法代码示例。如果您正苦于以下问题:C++ SkPixmap::reset方法的具体用法?C++ SkPixmap::reset怎么用?C++ SkPixmap::reset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkPixmap
的用法示例。
在下文中一共展示了SkPixmap::reset方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MakeTextureFromMipMap
sk_sp<SkImage> SkImage::MakeFromDeferredTextureImageData(GrContext* context, const void* data,
SkBudgeted budgeted) {
if (!data) {
return nullptr;
}
const DeferredTextureImage* dti = reinterpret_cast<const DeferredTextureImage*>(data);
if (!context || context->uniqueID() != dti->fContextUniqueID) {
return nullptr;
}
int mipLevelCount = dti->fMipMapLevelCount;
SkASSERT(mipLevelCount >= 1);
sk_sp<SkColorSpace> colorSpace;
if (dti->fColorSpaceSize) {
colorSpace = SkColorSpace::Deserialize(dti->fColorSpace, dti->fColorSpaceSize);
}
SkImageInfo info = SkImageInfo::Make(dti->fWidth, dti->fHeight,
dti->fColorType, dti->fAlphaType, colorSpace);
if (mipLevelCount == 1) {
SkPixmap pixmap;
pixmap.reset(info, dti->fMipMapLevelData[0].fPixelData, dti->fMipMapLevelData[0].fRowBytes);
// Use the NoCheck version because we have already validated the SkImage. The |data|
// used to be an SkImage before calling getDeferredTextureImageData(). In legacy mode,
// getDeferredTextureImageData() will allow parametric transfer functions for images
// generated from codecs - which is slightly more lenient than typical SkImage
// constructors.
sk_sp<GrTextureProxy> proxy(GrUploadPixmapToTextureProxyNoCheck(
context->resourceProvider(), pixmap, budgeted));
if (!proxy) {
return nullptr;
}
return sk_make_sp<SkImage_Gpu>(context, kNeedNewImageUniqueID, pixmap.alphaType(),
std::move(proxy), std::move(colorSpace), budgeted);
} else {
std::unique_ptr<GrMipLevel[]> texels(new GrMipLevel[mipLevelCount]);
for (int i = 0; i < mipLevelCount; i++) {
texels[i].fPixels = dti->fMipMapLevelData[i].fPixelData;
texels[i].fRowBytes = dti->fMipMapLevelData[i].fRowBytes;
}
return SkImage::MakeTextureFromMipMap(context, info, texels.get(),
mipLevelCount, SkBudgeted::kYes,
dti->fColorMode);
}
}
示例2: MakeTextureFromPixmap
sk_sp<SkImage> SkImage::MakeFromDeferredTextureImageData(GrContext* context, const void* data,
SkBudgeted budgeted) {
if (!data) {
return nullptr;
}
const DeferredTextureImage* dti = reinterpret_cast<const DeferredTextureImage*>(data);
if (!context || context->uniqueID() != dti->fContextUniqueID) {
return nullptr;
}
SkAutoTUnref<SkColorTable> colorTable;
if (dti->fData.fColorTableCnt) {
SkASSERT(dti->fData.fColorTableData);
colorTable.reset(new SkColorTable(dti->fData.fColorTableData, dti->fData.fColorTableCnt));
}
SkPixmap pixmap;
pixmap.reset(dti->fData.fInfo, dti->fData.fPixelData, dti->fData.fRowBytes, colorTable.get());
return SkImage::MakeTextureFromPixmap(context, pixmap, budgeted);
}
示例3: MakeTextureFromPixmap
sk_sp<SkImage> SkImage::MakeFromDeferredTextureImageData(GrContext* context, const void* data,
SkBudgeted budgeted) {
if (!data) {
return nullptr;
}
const DeferredTextureImage* dti = reinterpret_cast<const DeferredTextureImage*>(data);
if (!context || context->uniqueID() != dti->fContextUniqueID) {
return nullptr;
}
SkAutoTUnref<SkColorTable> colorTable;
if (dti->fColorTableCnt) {
SkASSERT(dti->fColorTableData);
colorTable.reset(new SkColorTable(dti->fColorTableData, dti->fColorTableCnt));
}
int mipLevelCount = dti->fMipMapLevelCount;
SkASSERT(mipLevelCount >= 1);
sk_sp<SkColorSpace> colorSpace;
if (dti->fColorSpaceSize) {
colorSpace = SkColorSpace::Deserialize(dti->fColorSpace, dti->fColorSpaceSize);
}
SkImageInfo info = SkImageInfo::Make(dti->fWidth, dti->fHeight,
dti->fColorType, dti->fAlphaType, colorSpace);
if (mipLevelCount == 1) {
SkPixmap pixmap;
pixmap.reset(info, dti->fMipMapLevelData[0].fPixelData,
dti->fMipMapLevelData[0].fRowBytes, colorTable.get());
return SkImage::MakeTextureFromPixmap(context, pixmap, budgeted);
} else {
SkAutoTDeleteArray<GrMipLevel> texels(new GrMipLevel[mipLevelCount]);
for (int i = 0; i < mipLevelCount; i++) {
texels[i].fPixels = dti->fMipMapLevelData[i].fPixelData;
texels[i].fRowBytes = dti->fMipMapLevelData[i].fRowBytes;
}
return SkImage::MakeTextureFromMipMap(context, info, texels.get(),
mipLevelCount, SkBudgeted::kYes,
dti->fGammaTreatment);
}
}