本文整理汇总了C++中SkTArray::front方法的典型用法代码示例。如果您正苦于以下问题:C++ SkTArray::front方法的具体用法?C++ SkTArray::front怎么用?C++ SkTArray::front使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkTArray
的用法示例。
在下文中一共展示了SkTArray::front方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createGlyphs
GrPathRange* GrGLPathRendering::createGlyphs(const SkTypeface* typeface,
const SkDescriptor* desc,
const SkStrokeRec& stroke) {
if (NULL != desc || !caps().glyphLoadingSupport) {
return GrPathRendering::createGlyphs(typeface, desc, stroke);
}
if (NULL == typeface) {
typeface = SkTypeface::GetDefaultTypeface();
SkASSERT(NULL != typeface);
}
int faceIndex;
SkAutoTDelete<SkStream> fontStream(typeface->openStream(&faceIndex));
const size_t fontDataLength = fontStream->getLength();
if (0 == fontDataLength) {
return GrPathRendering::createGlyphs(typeface, NULL, stroke);
}
SkTArray<uint8_t> fontTempBuffer;
const void* fontData = fontStream->getMemoryBase();
if (NULL == fontData) {
// TODO: Find a more efficient way to pass the font data (e.g. open file descriptor).
fontTempBuffer.reset(SkToInt(fontDataLength));
fontStream->read(&fontTempBuffer.front(), fontDataLength);
fontData = &fontTempBuffer.front();
}
const int numPaths = typeface->countGlyphs();
const GrGLuint basePathID = this->genPaths(numPaths);
SkAutoTUnref<GrGLPath> templatePath(SkNEW_ARGS(GrGLPath, (fGpu, SkPath(), stroke)));
GrGLenum status;
GL_CALL_RET(status, PathMemoryGlyphIndexArray(basePathID, GR_GL_STANDARD_FONT_FORMAT,
fontDataLength, fontData, faceIndex, 0,
numPaths, templatePath->pathID(),
SkPaint::kCanonicalTextSizeForPaths));
if (GR_GL_FONT_GLYPHS_AVAILABLE != status) {
this->deletePaths(basePathID, numPaths);
return GrPathRendering::createGlyphs(typeface, NULL, stroke);
}
// This is a crude approximation. We may want to consider giving this class
// a pseudo PathGenerator whose sole purpose is to track the approximate gpu
// memory size.
const size_t gpuMemorySize = fontDataLength / 4;
return SkNEW_ARGS(GrGLPathRange, (fGpu, basePathID, numPaths, gpuMemorySize, stroke));
}
示例2: find_string
// finds the index of ext in strings or a negative result if ext is not found.
static int find_string(const SkTArray<SkString>& strings, const char ext[]) {
if (strings.empty()) {
return -1;
}
SkString extensionStr(ext);
int idx = SkTSearch<SkString, extension_compare>(&strings.front(),
strings.count(),
extensionStr,
sizeof(SkString));
return idx;
}