本文整理汇总了C++中GrContext::drawFontCache方法的典型用法代码示例。如果您正苦于以下问题:C++ GrContext::drawFontCache方法的具体用法?C++ GrContext::drawFontCache怎么用?C++ GrContext::drawFontCache使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GrContext
的用法示例。
在下文中一共展示了GrContext::drawFontCache方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onDrawContent
void onDrawContent(SkCanvas* canvas) override {
SkPaint paint;
SkSafeUnref(paint.setTypeface(SkTypeface::CreateFromFile("/skimages/samplefont.ttf")));
paint.setAntiAlias(true);
paint.setFilterQuality(kMedium_SkFilterQuality);
SkString outString("fps: ");
fTimer.end();
// TODO: generalize this timing code in utils
fTimes[fCurrentTime] = (float)(fTimer.fWall);
fCurrentTime = (fCurrentTime + 1) & 0x1f;
float meanTime = 0.0f;
for (int i = 0; i < 32; ++i) {
meanTime += fTimes[i];
}
meanTime /= 32.f;
SkScalar fps = 1000.f / meanTime;
outString.appendScalar(fps);
outString.append(" ms: ");
outString.appendScalar(meanTime);
SkString modeString("Text scale: ");
modeString.appendU32(fSizeScale);
modeString.append("x");
fTimer.start();
canvas->save();
#if SK_SUPPORT_GPU
SkBaseDevice* device = canvas->getDevice_just_for_deprecated_compatibility_testing();
GrContext* grContext = canvas->getGrContext();
if (grContext) {
grContext->drawFontCache(SkRect::MakeXYWH(512, 10, 512, 512), kA8_GrMaskFormat, paint,
reinterpret_cast<SkGpuDevice*>(device)->accessRenderTarget());
}
#endif
canvas->translate(180, 180);
canvas->rotate(fRotation);
canvas->scale(fScale, fScale);
canvas->translate(-180, -180);
const char* text = "Hamburgefons";
size_t length = strlen(text);
SkScalar y = SkIntToScalar(0);
for (int i = 12; i <= 26; i++) {
paint.setTextSize(SkIntToScalar(i*fSizeScale));
y += paint.getFontSpacing();
DrawTheText(canvas, text, length, SkIntToScalar(110), y, paint);
}
canvas->restore();
paint.setTextSize(16);
// canvas->drawText(outString.c_str(), outString.size(), 512.f, 540.f, paint);
canvas->drawText(modeString.c_str(), modeString.size(), 768.f, 540.f, paint);
}