本文整理汇总了C++中SkDescriptor::addEntry方法的典型用法代码示例。如果您正苦于以下问题:C++ SkDescriptor::addEntry方法的具体用法?C++ SkDescriptor::addEntry怎么用?C++ SkDescriptor::addEntry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkDescriptor
的用法示例。
在下文中一共展示了SkDescriptor::addEntry方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateFallbackScalerContext
SkScalerContext* SkFontHost::CreateFallbackScalerContext(const SkScalerContext::Rec& rec) {
const LOGFONT* face = get_default_font();
SkAutoDescriptor ad(sizeof(rec) + sizeof(face) + SkDescriptor::ComputeOverhead(2));
SkDescriptor* desc = ad.getDesc();
desc->init();
desc->addEntry(kRec_SkDescriptorTag, sizeof(rec), &rec);
desc->addEntry(kTypeface_SkDescriptorTag, sizeof(face), &face);
desc->computeChecksum();
return SkFontHost::CreateScalerContext(desc);
}
示例2: allocNextContext
// Return the context associated with the next logical typeface, or NULL if
// there are no more entries in the fallback chain.
SkScalerContext* SkScalerContext::allocNextContext() const {
#ifdef SK_BUILD_FOR_ANDROID
SkTypeface* newFace = SkAndroidNextLogicalTypeface(fRec.fFontID,
fRec.fOrigFontID,
fPaintOptionsAndroid);
if (0 == newFace) {
return NULL;
}
SkAutoTUnref<SkTypeface> aur(newFace);
uint32_t newFontID = newFace->uniqueID();
SkOrderedWriteBuffer androidBuffer(128);
fPaintOptionsAndroid.flatten(androidBuffer);
SkAutoDescriptor ad(sizeof(fRec) + androidBuffer.size() + SkDescriptor::ComputeOverhead(2));
SkDescriptor* desc = ad.getDesc();
desc->init();
SkScalerContext::Rec* newRec =
(SkScalerContext::Rec*)desc->addEntry(kRec_SkDescriptorTag,
sizeof(fRec), &fRec);
androidBuffer.writeToMemory(desc->addEntry(kAndroidOpts_SkDescriptorTag,
androidBuffer.size(), NULL));
newRec->fFontID = newFontID;
desc->computeChecksum();
return newFace->createScalerContext(desc);
#else
return NULL;
#endif
}
示例3: createGlyphs
GrPathRange* GrPathRendering::createGlyphs(const SkTypeface* typeface,
const SkScalerContextEffects& effects,
const SkDescriptor* desc,
const GrStyle& style) {
if (nullptr == typeface) {
typeface = SkTypeface::GetDefaultTypeface();
SkASSERT(nullptr != typeface);
}
if (desc) {
SkAutoTUnref<GlyphGenerator> generator(new GlyphGenerator(*typeface, effects, *desc));
return this->createPathRange(generator, style);
}
SkScalerContextRec rec;
memset(&rec, 0, sizeof(rec));
rec.fFontID = typeface->uniqueID();
rec.fTextSize = SkPaint::kCanonicalTextSizeForPaths;
rec.fPreScaleX = rec.fPost2x2[0][0] = rec.fPost2x2[1][1] = SK_Scalar1;
// Don't bake stroke information into the glyphs, we'll let the GPU do the stroking.
SkAutoDescriptor ad(sizeof(rec) + SkDescriptor::ComputeOverhead(1));
SkDescriptor* genericDesc = ad.getDesc();
genericDesc->init();
genericDesc->addEntry(kRec_SkDescriptorTag, sizeof(rec), &rec);
genericDesc->computeChecksum();
// No effects, so we make a dummy struct
SkScalerContextEffects noEffects;
SkAutoTUnref<GlyphGenerator> generator(new GlyphGenerator(*typeface, noEffects, *genericDesc));
return this->createPathRange(generator, style);
}
示例4: onComputeBounds
bool SkTypeface::onComputeBounds(SkRect* bounds) const {
// we use a big size to ensure lots of significant bits from the scalercontext.
// then we scale back down to return our final answer (at 1-pt)
const SkScalar textSize = 2048;
const SkScalar invTextSize = 1 / textSize;
SkPaint paint;
paint.setTypeface(const_cast<SkTypeface*>(this));
paint.setTextSize(textSize);
paint.setLinearText(true);
SkScalerContext::Rec rec;
SkScalerContext::MakeRec(paint, NULL, NULL, &rec);
SkAutoDescriptor ad(sizeof(rec) + SkDescriptor::ComputeOverhead(1));
SkDescriptor* desc = ad.getDesc();
desc->init();
desc->addEntry(kRec_SkDescriptorTag, sizeof(rec), &rec);
SkAutoTDelete<SkScalerContext> ctx(this->createScalerContext(desc, true));
if (ctx.get()) {
SkPaint::FontMetrics fm;
ctx->getFontMetrics(&fm);
bounds->set(fm.fXMin * invTextSize, fm.fTop * invTextSize,
fm.fXMax * invTextSize, fm.fBottom * invTextSize);
return true;
}
return false;
}
示例5: allocNextContext
static SkScalerContext* allocNextContext(const SkScalerContext::Rec& rec) {
// fonthost will determine the next possible font to search, based
// on the current font in fRec. It will return NULL if ctx is our
// last font that can be searched (i.e. ultimate fallback font)
#ifdef SK_BUILD_FOR_ANDROID
// On Android, pass entire rec structure so that clients can change fallback behavior
uint32_t newFontID = SkFontHost::NextLogicalFont(rec);
#else
uint32_t newFontID = SkFontHost::NextLogicalFont(rec.fFontID, rec.fOrigFontID);
#endif
if (0 == newFontID) {
return NULL;
}
SkAutoDescriptor ad(sizeof(rec) + SkDescriptor::ComputeOverhead(1));
SkDescriptor* desc = ad.getDesc();
desc->init();
SkScalerContext::Rec* newRec =
(SkScalerContext::Rec*)desc->addEntry(kRec_SkDescriptorTag,
sizeof(rec), &rec);
newRec->fFontID = newFontID;
desc->computeChecksum();
return SkFontHost::CreateScalerContext(desc);
}
示例6: ad
SkGScalerContext::SkGScalerContext(SkGTypeface* face, const SkDescriptor* desc)
: SkScalerContext(face, desc)
, fFace(face)
{
size_t descSize = SkDescriptor::ComputeOverhead(1) + sizeof(SkScalerContext::Rec);
SkAutoDescriptor ad(descSize);
SkDescriptor* newDesc = ad.getDesc();
newDesc->init();
void* entry = newDesc->addEntry(kRec_SkDescriptorTag,
sizeof(SkScalerContext::Rec), &fRec);
{
SkScalerContext::Rec* rec = (SkScalerContext::Rec*)entry;
rec->fTextSize = STD_SIZE;
rec->fPreScaleX = SK_Scalar1;
rec->fPreSkewX = 0;
rec->fPost2x2[0][0] = rec->fPost2x2[1][1] = SK_Scalar1;
rec->fPost2x2[1][0] = rec->fPost2x2[0][1] = 0;
}
SkASSERT(descSize == newDesc->getLength());
newDesc->computeChecksum();
fProxy = face->proxy()->createScalerContext(newDesc);
fRec.getSingleMatrix(&fMatrix);
fMatrix.preScale(SK_Scalar1 / STD_SIZE, SK_Scalar1 / STD_SIZE);
}
示例7: allocNextContext
static SkScalerContext* allocNextContext(const SkScalerContext::Rec& rec) {
// fonthost will determine the next possible font to search, based
// on the current font in fRec. It will return NULL if ctx is our
// last font that can be searched (i.e. ultimate fallback font)
uint32_t newFontID = SkFontHost::NextLogicalFont(rec.fFontID, rec.fOrigFontID);
if (0 == newFontID) {
return NULL;
}
SkAutoDescriptor ad(sizeof(rec) + SkDescriptor::ComputeOverhead(1));
SkDescriptor* desc = ad.getDesc();
desc->init();
SkScalerContext::Rec* newRec =
(SkScalerContext::Rec*)desc->addEntry(kRec_SkDescriptorTag,
sizeof(rec), &rec);
newRec->fFontID = newFontID;
desc->computeChecksum();
return SkFontHost::CreateScalerContext(desc);
}