本文整理汇总了C++中SkTScopedComPtr::get方法的典型用法代码示例。如果您正苦于以下问题:C++ SkTScopedComPtr::get方法的具体用法?C++ SkTScopedComPtr::get怎么用?C++ SkTScopedComPtr::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkTScopedComPtr
的用法示例。
在下文中一共展示了SkTScopedComPtr::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawGlyphRun
// IDWriteTextRenderer methods
virtual HRESULT STDMETHODCALLTYPE DrawGlyphRun(
void* clientDrawingContext,
FLOAT baselineOriginX,
FLOAT baselineOriginY,
DWRITE_MEASURING_MODE measuringMode,
DWRITE_GLYPH_RUN const* glyphRun,
DWRITE_GLYPH_RUN_DESCRIPTION const* glyphRunDescription,
IUnknown* clientDrawingEffect) override
{
SkTScopedComPtr<IDWriteFont> font;
HRM(fOuter->fFontCollection->GetFontFromFontFace(glyphRun->fontFace, &font),
"Could not get font from font face.");
// It is possible that the font passed does not actually have the requested character,
// due to no font being found and getting the fallback font.
// Check that the font actually contains the requested character.
BOOL exists;
HRM(font->HasCharacter(fCharacter, &exists), "Could not find character.");
if (exists) {
SkTScopedComPtr<IDWriteFontFamily> fontFamily;
HRM(font->GetFontFamily(&fontFamily), "Could not get family.");
fResolvedTypeface = fOuter->createTypefaceFromDWriteFont(glyphRun->fontFace,
font.get(),
fontFamily.get());
}
return S_OK;
}
示例2: matchStyle
SkTypeface* SkFontStyleSet_DirectWrite::matchStyle(const SkFontStyle& pattern) {
DWRITE_FONT_STYLE slant;
switch (pattern.slant()) {
case SkFontStyle::kUpright_Slant:
slant = DWRITE_FONT_STYLE_NORMAL;
break;
case SkFontStyle::kItalic_Slant:
slant = DWRITE_FONT_STYLE_ITALIC;
break;
default:
SkASSERT(false);
}
DWRITE_FONT_WEIGHT weight = (DWRITE_FONT_WEIGHT)pattern.weight();
DWRITE_FONT_STRETCH width = (DWRITE_FONT_STRETCH)pattern.width();
SkTScopedComPtr<IDWriteFont> font;
// TODO: perhaps use GetMatchingFonts and get the least simulated?
HRNM(fFontFamily->GetFirstMatchingFont(weight, width, slant, &font),
"Could not match font in family.");
SkTScopedComPtr<IDWriteFontFace> fontFace;
HRNM(font->CreateFontFace(&fontFace), "Could not create font face.");
return fFontMgr->createTypefaceFromDWriteFont(fontFace.get(), font.get(),
fFontFamily.get());
}
示例3: onLegacyCreateTypeface
SkTypeface* SkFontMgr_DirectWrite::onLegacyCreateTypeface(const char familyName[],
SkFontStyle style) const {
SkTScopedComPtr<IDWriteFontFamily> fontFamily;
if (familyName) {
SkSMallocWCHAR wideFamilyName;
if (SUCCEEDED(sk_cstring_to_wchar(familyName, &wideFamilyName))) {
this->getByFamilyName(wideFamilyName, &fontFamily);
}
}
if (nullptr == fontFamily.get()) {
// No family with given name, try default.
this->getDefaultFontFamily(&fontFamily);
}
if (nullptr == fontFamily.get()) {
// Could not obtain the default font.
HRNM(fFontCollection->GetFontFamily(0, &fontFamily),
"Could not get default-default font family.");
}
SkTScopedComPtr<IDWriteFont> font;
DWriteStyle dwStyle(style);
HRNM(fontFamily->GetFirstMatchingFont(dwStyle.fWeight, dwStyle.fWidth, dwStyle.fSlant, &font),
"Could not get matching font.");
SkTScopedComPtr<IDWriteFontFace> fontFace;
HRNM(font->CreateFontFace(&fontFace), "Could not create font face.");
return this->createTypefaceFromDWriteFont(fontFace.get(), font.get(), fontFamily.get());
}
示例4: GetCurrentFontFile
HRESULT StreamFontFileEnumerator::GetCurrentFontFile(IDWriteFontFile** fontFile) {
if (fCurrentFile.get() == nullptr) {
*fontFile = nullptr;
return E_FAIL;
}
*fontFile = SkRefComPtr(fCurrentFile.get());
return S_OK;
}
示例5: createTypeface
SkTypeface* SkFontStyleSet_DirectWrite::createTypeface(int index) {
SkTScopedComPtr<IDWriteFont> font;
HRNM(fFontFamily->GetFont(index, &font), "Could not get font.");
SkTScopedComPtr<IDWriteFontFace> fontFace;
HRNM(font->CreateFontFace(&fontFace), "Could not create font face.");
return fFontMgr->createTypefaceFromDWriteFont(fontFace.get(), font.get(), fFontFamily.get());
}
示例6: are_same
static HRESULT are_same(IUnknown* a, IUnknown* b, bool& same) {
SkTScopedComPtr<IUnknown> iunkA;
HRM(a->QueryInterface(&iunkA), "Failed to QI<IUnknown> for a.");
SkTScopedComPtr<IUnknown> iunkB;
HRM(b->QueryInterface(&iunkB), "Failed to QI<IUnknown> for b.");
same = (iunkA.get() == iunkB.get());
return S_OK;
}
示例7: matchStyle
SkTypeface* SkFontStyleSet_DirectWrite::matchStyle(const SkFontStyle& pattern) {
SkTScopedComPtr<IDWriteFont> font;
DWriteStyle dwStyle(pattern);
// TODO: perhaps use GetMatchingFonts and get the least simulated?
HRNM(fFontFamily->GetFirstMatchingFont(dwStyle.fWeight, dwStyle.fWidth, dwStyle.fSlant, &font),
"Could not match font in family.");
SkTScopedComPtr<IDWriteFontFace> fontFace;
HRNM(font->CreateFontFace(&fontFace), "Could not create font face.");
return fFontMgr->createTypefaceFromDWriteFont(fontFace.get(), font.get(),
fFontFamily.get());
}
示例8: getStyle
void SkFontStyleSet_DirectWrite::getStyle(int index, SkFontStyle* fs, SkString* styleName) {
SkTScopedComPtr<IDWriteFont> font;
HRVM(fFontFamily->GetFont(index, &font), "Could not get font.");
if (fs) {
*fs = get_style(font.get());
}
if (styleName) {
SkTScopedComPtr<IDWriteLocalizedStrings> faceNames;
if (SUCCEEDED(font->GetFaceNames(&faceNames))) {
sk_get_locale_string(faceNames.get(), fFontMgr->fLocaleName.get(), styleName);
}
}
}
示例9: FindOrAdd
int FindOrAdd(IDWriteFontFileLoader* fontFileLoader,
const void* refKey, UINT32 refKeySize) const
{
SkTScopedComPtr<IUnknown> fontFileLoaderId;
HR_GENERAL(fontFileLoader->QueryInterface(&fontFileLoaderId),
"Failed to re-convert to IDWriteFontFileLoader.",
SkFontIdentity::kInvalidDataId);
SkAutoMutexAcquire ama(fDataIdCacheMutex);
int count = fDataIdCache.count();
int i;
for (i = 0; i < count; ++i) {
const DataId& current = fDataIdCache[i];
if (fontFileLoaderId.get() == current.fLoader &&
refKeySize == current.fKeySize &&
0 == memcmp(refKey, current.fKey, refKeySize))
{
return i;
}
}
DataId& added = fDataIdCache.push_back();
added.fLoader = fontFileLoaderId.release(); // Ref is passed.
added.fKey = sk_malloc_throw(refKeySize);
memcpy(added.fKey, refKey, refKeySize);
added.fKeySize = refKeySize;
return i;
}
示例10: SkFontMgr_New_DirectWrite
SK_API SkFontMgr* SkFontMgr_New_DirectWrite(IDWriteFactory* factory) {
if (NULL == factory) {
factory = sk_get_dwrite_factory();
if (NULL == factory) {
return NULL;
}
}
SkTScopedComPtr<IDWriteFontCollection> sysFontCollection;
HRNM(SkFontMgr_GetFontCollectionToUse(&sysFontCollection, factory),
"Could not get system font collection.");
WCHAR localeNameStorage[LOCALE_NAME_MAX_LENGTH];
WCHAR* localeName = NULL;
int localeNameLen = 0;
// Dynamically load GetUserDefaultLocaleName function, as it is not available on XP.
SkGetUserDefaultLocaleNameProc getUserDefaultLocaleNameProc = NULL;
HRESULT hr = SkGetGetUserDefaultLocaleNameProc(&getUserDefaultLocaleNameProc);
if (NULL == getUserDefaultLocaleNameProc) {
SK_TRACEHR(hr, "Could not get GetUserDefaultLocaleName.");
} else {
localeNameLen = getUserDefaultLocaleNameProc(localeNameStorage, LOCALE_NAME_MAX_LENGTH);
if (localeNameLen) {
localeName = localeNameStorage;
};
}
return SkNEW_ARGS(SkFontMgr_DirectWrite, (factory, sysFontCollection.get(),
localeName, localeNameLen));
}
示例11: getStyle
void SkFontStyleSet_DirectWrite::getStyle(int index, SkFontStyle* fs, SkString* styleName) {
SkTScopedComPtr<IDWriteFont> font;
HRVM(fFontFamily->GetFont(index, &font), "Could not get font.");
if (fs) {
SkFontStyle::Slant slant;
switch (font->GetStyle()) {
case DWRITE_FONT_STYLE_NORMAL:
slant = SkFontStyle::kUpright_Slant;
break;
case DWRITE_FONT_STYLE_OBLIQUE:
case DWRITE_FONT_STYLE_ITALIC:
slant = SkFontStyle::kItalic_Slant;
break;
default:
SkASSERT(false);
}
int weight = font->GetWeight();
int width = font->GetStretch();
*fs = SkFontStyle(weight, width, slant);
}
if (styleName) {
SkTScopedComPtr<IDWriteLocalizedStrings> faceNames;
if (SUCCEEDED(font->GetFaceNames(&faceNames))) {
sk_get_locale_string(faceNames.get(), fFontMgr->fLocaleName.get(), styleName);
}
}
}
示例12: onOpenStream
SkStreamAsset* DWriteFontTypeface::onOpenStream(int* ttcIndex) const {
*ttcIndex = fDWriteFontFace->GetIndex();
UINT32 numFiles;
HRNM(fDWriteFontFace->GetFiles(&numFiles, nullptr),
"Could not get number of font files.");
if (numFiles != 1) {
return nullptr;
}
SkTScopedComPtr<IDWriteFontFile> fontFile;
HRNM(fDWriteFontFace->GetFiles(&numFiles, &fontFile), "Could not get font files.");
const void* fontFileKey;
UINT32 fontFileKeySize;
HRNM(fontFile->GetReferenceKey(&fontFileKey, &fontFileKeySize),
"Could not get font file reference key.");
SkTScopedComPtr<IDWriteFontFileLoader> fontFileLoader;
HRNM(fontFile->GetLoader(&fontFileLoader), "Could not get font file loader.");
SkTScopedComPtr<IDWriteFontFileStream> fontFileStream;
HRNM(fontFileLoader->CreateStreamFromKey(fontFileKey, fontFileKeySize,
&fontFileStream),
"Could not create font file stream.");
return new SkDWriteFontFileStream(fontFileStream.get());
}
示例13: SkFontMgr_New_DirectWrite
SK_API SkFontMgr* SkFontMgr_New_DirectWrite(IDWriteFactory* factory,
IDWriteFontCollection* collection,
IDWriteFontFallback* fallback) {
if (nullptr == factory) {
factory = sk_get_dwrite_factory();
if (nullptr == factory) {
return nullptr;
}
}
SkTScopedComPtr<IDWriteFontCollection> systemFontCollection;
if (nullptr == collection) {
HRNM(factory->GetSystemFontCollection(&systemFontCollection, FALSE),
"Could not get system font collection.");
collection = systemFontCollection.get();
}
WCHAR localeNameStorage[LOCALE_NAME_MAX_LENGTH];
WCHAR* localeName = nullptr;
int localeNameLen = 0;
// Dynamically load GetUserDefaultLocaleName function, as it is not available on XP.
SkGetUserDefaultLocaleNameProc getUserDefaultLocaleNameProc = nullptr;
HRESULT hr = SkGetGetUserDefaultLocaleNameProc(&getUserDefaultLocaleNameProc);
if (nullptr == getUserDefaultLocaleNameProc) {
SK_TRACEHR(hr, "Could not get GetUserDefaultLocaleName.");
} else {
localeNameLen = getUserDefaultLocaleNameProc(localeNameStorage, LOCALE_NAME_MAX_LENGTH);
if (localeNameLen) {
localeName = localeNameStorage;
};
}
return new SkFontMgr_DirectWrite(factory, collection, fallback, localeName, localeNameLen);
}
示例14: onGetFamilyName
void SkFontMgr_DirectWrite::onGetFamilyName(int index, SkString* familyName) const {
SkTScopedComPtr<IDWriteFontFamily> fontFamily;
HRVM(fFontCollection->GetFontFamily(index, &fontFamily), "Could not get requested family.");
SkTScopedComPtr<IDWriteLocalizedStrings> familyNames;
HRVM(fontFamily->GetFamilyNames(&familyNames), "Could not get family names.");
sk_get_locale_string(familyNames.get(), fLocaleName.get(), familyName);
}
示例15: CreateEnumeratorFromKey
HRESULT StreamFontCollectionLoader::CreateEnumeratorFromKey(
IDWriteFactory* factory,
void const* collectionKey,
UINT32 collectionKeySize,
IDWriteFontFileEnumerator** fontFileEnumerator)
{
SkTScopedComPtr<StreamFontFileEnumerator> enumerator;
HR(StreamFontFileEnumerator::Create(factory, fFontFileLoader.get(), &enumerator));
*fontFileEnumerator = enumerator.release();
return S_OK;
}