本文整理汇总了C++中SkMemoryStream::getMemoryBase方法的典型用法代码示例。如果您正苦于以下问题:C++ SkMemoryStream::getMemoryBase方法的具体用法?C++ SkMemoryStream::getMemoryBase怎么用?C++ SkMemoryStream::getMemoryBase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkMemoryStream
的用法示例。
在下文中一共展示了SkMemoryStream::getMemoryBase方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Deserialize
SkTypeface* SkFontHost::Deserialize(SkStream* stream) {
{
SkAutoMutexAcquire ac(gFamilyMutex);
load_system_fonts();
}
SkFontDescriptor descriptor(stream);
const char* familyName = descriptor.getFamilyName();
const char* typefaceName = descriptor.getFontFileName();
const SkTypeface::Style style = descriptor.getStyle();
const uint32_t customFontDataLength = stream->readPackedUInt();
if (customFontDataLength > 0) {
// generate a new stream to store the custom typeface
SkMemoryStream* fontStream = new SkMemoryStream(customFontDataLength - 1);
stream->read((void*)fontStream->getMemoryBase(), customFontDataLength - 1);
SkTypeface* face = CreateTypefaceFromStream(fontStream);
fontStream->unref();
return face;
}
return SkFontHost::CreateTypeface(NULL, familyName, style);
}
示例2: Deserialize
SkTypeface* SkFontHost::Deserialize(SkStream* stream) {
load_system_fonts();
// read the length of the custom font from the stream
uint32_t len = stream->readU32();
// generate a new stream to store the custom typeface
SkMemoryStream* fontStream = new SkMemoryStream(len);
stream->read((void*)fontStream->getMemoryBase(), len);
SkTypeface* face = CreateTypefaceFromStream(fontStream);
fontStream->unref();
return face;
// sk_throw();
// return NULL;
}
示例3: Deserialize
SkTypeface* SkFontHost::Deserialize(SkStream* stream) {
{
SkAutoMutexAcquire ac(gFamilyHeadAndNameListMutex);
load_system_fonts();
}
SkFontDescriptor descriptor(stream);
const char* familyName = descriptor.getFamilyName();
const char* fontFileName = descriptor.getFontFileName();
const SkTypeface::Style style = descriptor.getStyle();
const uint32_t customFontDataLength = stream->readPackedUInt();
if (customFontDataLength > 0) {
// generate a new stream to store the custom typeface
SkMemoryStream* fontStream = new SkMemoryStream(customFontDataLength - 1);
stream->read((void*)fontStream->getMemoryBase(), customFontDataLength - 1);
SkTypeface* face = CreateTypefaceFromStream(fontStream);
fontStream->unref();
return face;
}
if (NULL != fontFileName && 0 != *fontFileName) {
const FontInitRec* rec = gSystemFonts;
for (size_t i = 0; i < gNumSystemFonts; i++) {
if (strcmp(rec[i].fFileName, fontFileName) == 0) {
// backup until we hit the fNames
for (int j = i; j >= 0; --j) {
if (rec[j].fNames != NULL) {
return SkFontHost::CreateTypeface(NULL,
rec[j].fNames[0], style);
}
}
}
}
}
return SkFontHost::CreateTypeface(NULL, familyName, style);
}
示例4: OpenStream
SkStream* SkFontHost::OpenStream(SkFontID uniqueID) {
SkAutoMutexAcquire ac(gFTMutex);
LogFontTypeface* rec = LogFontTypeface::FindById(uniqueID);
HDC hdc = ::CreateCompatibleDC(NULL);
HFONT font = CreateFontIndirect(&rec->logFont());
HFONT savefont = (HFONT)SelectObject(hdc, font);
size_t bufferSize = GetFontData(hdc, 0, 0, NULL, 0);
SkMemoryStream* stream = new SkMemoryStream(bufferSize);
if (!GetFontData(hdc, 0, 0, (void*)stream->getMemoryBase(), bufferSize)) {
delete stream;
stream = NULL;
}
SelectObject(hdc, savefont);
DeleteObject(font);
DeleteDC(hdc);
return stream;
}