当前位置: 首页>>代码示例>>C++>>正文


C++ SkTypeface::unref方法代码示例

本文整理汇总了C++中SkTypeface::unref方法的典型用法代码示例。如果您正苦于以下问题:C++ SkTypeface::unref方法的具体用法?C++ SkTypeface::unref怎么用?C++ SkTypeface::unref使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SkTypeface的用法示例。


在下文中一共展示了SkTypeface::unref方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: setFont

	bool setFont(const char * pFontName = NULL, int nSize = 0)
	{
		bool bRet = false;

		if (m_pPaint)
		{
			delete m_pPaint;
			m_pPaint = NULL;
		}

		do 
		{
			/* init paint */
			m_pPaint = new SkPaint();
			CC_BREAK_IF(! m_pPaint);
			m_pPaint->setColor(SK_ColorWHITE);
			m_pPaint->setTextSize(nSize);

			/* create font */
			SkTypeface *pTypeFace = SkTypeface::CreateFromName(pFontName, SkTypeface::kNormal);
			if (! pTypeFace)
			{
				CC_SAFE_DELETE(m_pPaint);
				break;
			}
			m_pPaint->setTypeface( pTypeFace );
			/* can not unref, I don't know why. It may be memory leak, but how to avoid? */
			pTypeFace->unref();

			bRet = true;
		} while (0);

		return bRet;
	}
开发者ID:DmitriyKirakosyan,项目名称:testNinjaX,代码行数:34,代码来源:CCImage_android.cpp

示例2: createFontPlatformData

FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomicString& family)
{
    const char* name = 0;

    // If a fallback font is being created (e.g. "-webkit-monospace"), convert
    // it in to the fallback name (e.g. "monospace").
    if (!family.length() || family.startsWith("-webkit-"))
        name = getFallbackFontName(fontDescription);
    else
        name = family.string().utf8().data();

    int style = SkTypeface::kNormal;
    if (fontDescription.weight() >= FontWeightBold)
        style |= SkTypeface::kBold;
    if (fontDescription.italic())
        style |= SkTypeface::kItalic;

    SkTypeface* typeface = SkTypeface::CreateFromName(name, SkTypeface::kNormal);
    FontPlatformData* result = 0;

    // CreateFromName always returns a typeface, falling back to a default font
    // if the one requested could not be found. Calling Equal() with a null
    // pointer will compare the returned font against the default, with the
    // caveat that the default is always of normal style. When that happens,
    // ignore the default font and allow WebCore to provide the next font on the
    // CSS fallback list. The only exception to this occurs when the family name
    // is a commonly used generic family, which is the case when called by
    // getSimilarFontPlatformData() or getLastResortFallbackFont(). In that case
    // the default font is an acceptable result.

    if (!SkTypeface::Equal(typeface, 0) || isFallbackFamily(family.string())) {
        if (style != SkTypeface::kNormal) {
            typeface->unref();
            typeface = SkTypeface::CreateFromName(name, static_cast<SkTypeface::Style>(style));
        }

        result = new FontPlatformData(typeface, name, fontDescription.computedSize(),
                                      (style & SkTypeface::kBold) && !typeface->isBold(),
                                      (style & SkTypeface::kItalic) && !typeface->isItalic(),
                                      fontDescription.orientation(),
                                      fontDescription.textOrientation());
    }

    typeface->unref();
    return result;
}
开发者ID:jparound30,项目名称:webkit,代码行数:46,代码来源:FontCacheAndroid.cpp

示例3: createFontPlatformData

FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontDescription,
                                                    const AtomicString& family)
{
    const char* name = 0;
    CString s;

    if (family.length() == 0) {
        static const struct {
            FontDescription::GenericFamilyType mType;
            const char* mName;
        } fontDescriptions[] = {
            { FontDescription::SerifFamily, "serif" },
            { FontDescription::SansSerifFamily, "sans-serif" },
            { FontDescription::MonospaceFamily, "monospace" },
            { FontDescription::CursiveFamily, "cursive" },
            { FontDescription::FantasyFamily, "fantasy" }
        };

        FontDescription::GenericFamilyType type = fontDescription.genericFamily();
        for (unsigned i = 0; i < SK_ARRAY_COUNT(fontDescriptions); i++) {
            if (type == fontDescriptions[i].mType) {
                name = fontDescriptions[i].mName;
                break;
            }
        }
        // if we fall out of the loop, it's ok for name to still be 0
    }
    else {    // convert the name to utf8
        s = family.string().utf8();
        name = s.data();
    }

    int style = SkTypeface::kNormal;
    if (fontDescription.weight() >= FontWeightBold)
        style |= SkTypeface::kBold;
    if (fontDescription.italic())
        style |= SkTypeface::kItalic;

    // FIXME:  This #ifdef can go away once we're firmly using the new Skia.
    // During the transition, this makes the code compatible with both versions.
#ifdef SK_USE_OLD_255_TO_256
    SkTypeface* tf = SkTypeface::CreateFromName(name, static_cast<SkTypeface::Style>(style));
#else
    SkTypeface* tf = SkTypeface::Create(name, static_cast<SkTypeface::Style>(style));
#endif
    if (!tf)
        return 0;

    FontPlatformData* result =
        new FontPlatformData(tf,
                             fontDescription.computedSize(),
                             (style & SkTypeface::kBold) && !tf->isBold(),
                             (style & SkTypeface::kItalic) && !tf->isItalic());
    tf->unref();
    return result;
}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:56,代码来源:FontCacheLinux.cpp

示例4: createFontPlatformData

FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontDescription,
                                                    const AtomicString& family)
{
    const char* name = 0;
    CString s;

    // If we're creating a fallback font (e.g. "-webkit-monospace"), convert the name into
    // the fallback name (like "monospace") that fontconfig understands.
    if (!family.length() || family.startsWith("-webkit-")) {
        static const struct {
            FontDescription::GenericFamilyType mType;
            const char* mName;
        } fontDescriptions[] = {
            { FontDescription::SerifFamily, "serif" },
            { FontDescription::SansSerifFamily, "sans-serif" },
            { FontDescription::MonospaceFamily, "monospace" },
            { FontDescription::CursiveFamily, "cursive" },
            { FontDescription::FantasyFamily, "fantasy" }
        };

        FontDescription::GenericFamilyType type = fontDescription.genericFamily();
        for (unsigned i = 0; i < SK_ARRAY_COUNT(fontDescriptions); i++) {
            if (type == fontDescriptions[i].mType) {
                name = fontDescriptions[i].mName;
                break;
            }
        }
        if (!name)
            name = "";
    } else {
        // convert the name to utf8
        s = family.string().utf8();
        name = s.data();
    }

    int style = SkTypeface::kNormal;
    if (fontDescription.weight() >= FontWeightBold)
        style |= SkTypeface::kBold;
    if (fontDescription.italic())
        style |= SkTypeface::kItalic;

    SkTypeface* tf = SkTypeface::CreateFromName(name, static_cast<SkTypeface::Style>(style));
    if (!tf)
        return 0;

    FontPlatformData* result =
        new FontPlatformData(tf,
                             name,
                             fontDescription.computedSize(),
                             (style & SkTypeface::kBold) && !tf->isBold(),
                             (style & SkTypeface::kItalic) && !tf->isItalic(),
                             fontDescription.orientation(),
                             fontDescription.textOrientation());
    tf->unref();
    return result;
}
开发者ID:sanyaade-mobiledev,项目名称:Webkit-Projects,代码行数:56,代码来源:FontCacheLinux.cpp

示例5:

ACanvasSkia::~ACanvasSkia()
{
	for(std::map<AString,SkTypeface*>::iterator it=m_aFontType.begin();it!=m_aFontType.end();it++)
	{
		SkTypeface* p = it->second;
		p->unref();
	}
	m_aFontType.clear();
	Free();
}
开发者ID:emuikernel,项目名称:BaijieCppUILib,代码行数:10,代码来源:ACanvasSkia.cpp

示例6: UniqueID

uint32_t SkTypeface::UniqueID(const SkTypeface* face) {
    if (face) {
        return face->uniqueID();
    }

    // We cache the default fontID, assuming it will not change during a boot
    // The initial value of 0 is fine, since a typeface's uniqueID should not
    // be zero.
    static uint32_t gDefaultFontID;
    
    if (0 == gDefaultFontID) {
        SkTypeface* defaultFace = SkFontHost::CreateTypeface(NULL, NULL,
                                                    SkTypeface::kNormal);
        SkASSERT(defaultFace);
        gDefaultFontID = defaultFace->uniqueID();
        defaultFace->unref();
    }
    return gDefaultFontID;
}
开发者ID:AOSP-JF-MM,项目名称:platform_external_skia,代码行数:19,代码来源:SkTypeface.cpp


注:本文中的SkTypeface::unref方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。