本文整理汇总了C++中sk_sp::data方法的典型用法代码示例。如果您正苦于以下问题:C++ sk_sp::data方法的具体用法?C++ sk_sp::data怎么用?C++ sk_sp::data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sk_sp
的用法示例。
在下文中一共展示了sk_sp::data方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dump_output
static void dump_output(const sk_sp<SkData>& data,
const char* name, bool last = true) {
if (data) {
printf("\t\"%s\": \"", name);
encode_to_base64(data->data(), data->size(), stdout);
fputs(last ? "\"\n" : "\",\n", stdout);
}
}
示例2: ICCProfile
std::unique_ptr<SkEncodedInfo::ICCProfile> SkEncodedInfo::ICCProfile::Make(sk_sp<SkData> data) {
if (data) {
skcms_ICCProfile profile;
if (skcms_Parse(data->data(), data->size(), &profile)) {
return std::unique_ptr<ICCProfile>(new ICCProfile(profile, std::move(data)));
}
}
return nullptr;
}
示例3: 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;
}
SkDestinationSurfaceColorMode colorMode = provider.dstColorSpace()
? SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware
: SkDestinationSurfaceColorMode::kLegacy;
if (invScaleSize.width() > SK_Scalar1 || invScaleSize.height() > SK_Scalar1) {
fCurrMip.reset(SkMipMapCache::FindAndRef(provider.makeCacheDesc(), colorMode));
if (nullptr == fCurrMip.get()) {
SkBitmap orig;
if (!provider.asBitmap(&orig)) {
return false;
}
fCurrMip.reset(SkMipMapCache::AddAndRef(orig, colorMode));
if (nullptr == fCurrMip.get()) {
return false;
}
}
// diagnostic for a crasher...
SkASSERT_RELEASE(fCurrMip->data());
const SkSize scale = SkSize::Make(SkScalarInvert(invScaleSize.width()),
SkScalarInvert(invScaleSize.height()));
SkMipMap::Level level;
if (fCurrMip->extractLevel(scale, &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;
}
示例4: SkASSERT
sk_sp<SkPixelRef> SkMallocPixelRef::MakeWithData(const SkImageInfo& info,
size_t rowBytes,
sk_sp<SkColorTable> ctable,
sk_sp<SkData> data) {
SkASSERT(data != nullptr);
if (!is_valid(info, ctable.get())) {
return nullptr;
}
if ((rowBytes < info.minRowBytes()) || (data->size() < info.getSafeSize(rowBytes))) {
return nullptr;
}
// must get this address before we call release
void* pixels = const_cast<void*>(data->data());
SkPixelRef* pr = new SkMallocPixelRef(info, pixels, rowBytes, std::move(ctable),
sk_data_releaseproc, data.release());
pr->setImmutable(); // since we were created with (immutable) data
return sk_sp<SkPixelRef>(pr);
}
示例5: FuzzImageFilterDeserialize
void FuzzImageFilterDeserialize(sk_sp<SkData> bytes) {
const int BitmapSize = 24;
SkBitmap bitmap;
bitmap.allocN32Pixels(BitmapSize, BitmapSize);
SkCanvas canvas(bitmap);
canvas.clear(0x00000000);
auto flattenable = SkImageFilter::Deserialize(bytes->data(), bytes->size());
if (flattenable != nullptr) {
// Let's see if using the filters can cause any trouble...
SkPaint paint;
paint.setImageFilter(flattenable);
canvas.save();
canvas.clipRect(SkRect::MakeXYWH(
0, 0, SkIntToScalar(BitmapSize), SkIntToScalar(BitmapSize)));
// This call shouldn't crash or cause ASAN to flag any memory issues
// If nothing bad happens within this call, everything is fine
canvas.drawBitmap(bitmap, 0, 0, &paint);
canvas.restore();
}
}
示例6: SkCreateDataProviderFromData
CGDataProviderRef SkCreateDataProviderFromData(sk_sp<SkData> data) {
const void* addr = data->data();
size_t size = data->size();
return CGDataProviderCreateWithData(data.release(), addr, size, unref_proc);
}