本文整理汇总了C++中SkAutoTUnref::openStream方法的典型用法代码示例。如果您正苦于以下问题:C++ SkAutoTUnref::openStream方法的具体用法?C++ SkAutoTUnref::openStream怎么用?C++ SkAutoTUnref::openStream使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkAutoTUnref
的用法示例。
在下文中一共展示了SkAutoTUnref::openStream方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createTypefaceFromFontId
SkTypeface* SkFontMgr_Indirect::createTypefaceFromFontId(const SkFontIdentity& id) const {
if (id.fDataId == SkFontIdentity::kInvalidDataId) {
return nullptr;
}
SkAutoMutexAcquire ama(fDataCacheMutex);
SkAutoTUnref<SkTypeface> dataTypeface;
int dataTypefaceIndex = 0;
for (int i = 0; i < fDataCache.count(); ++i) {
const DataEntry& entry = fDataCache[i];
if (entry.fDataId == id.fDataId) {
if (entry.fTtcIndex == id.fTtcIndex &&
!entry.fTypeface->weak_expired() && entry.fTypeface->try_ref())
{
return entry.fTypeface;
}
if (dataTypeface.get() == nullptr &&
!entry.fTypeface->weak_expired() && entry.fTypeface->try_ref())
{
dataTypeface.reset(entry.fTypeface);
dataTypefaceIndex = entry.fTtcIndex;
}
}
if (entry.fTypeface->weak_expired()) {
fDataCache.removeShuffle(i);
--i;
}
}
// No exact match, but did find a data match.
if (dataTypeface.get() != nullptr) {
SkAutoTDelete<SkStreamAsset> stream(dataTypeface->openStream(nullptr));
if (stream.get() != nullptr) {
return fImpl->createFromStream(stream.release(), dataTypefaceIndex);
}
}
// No data match, request data and add entry.
SkAutoTDelete<SkStreamAsset> stream(fProxy->getData(id.fDataId));
if (stream.get() == nullptr) {
return nullptr;
}
SkAutoTUnref<SkTypeface> typeface(fImpl->createFromStream(stream.release(), id.fTtcIndex));
if (typeface.get() == nullptr) {
return nullptr;
}
DataEntry& newEntry = fDataCache.push_back();
typeface->weak_ref();
newEntry.fDataId = id.fDataId;
newEntry.fTtcIndex = id.fTtcIndex;
newEntry.fTypeface = typeface.get(); // weak reference passed to new entry.
return typeface.release();
}