本文整理汇总了C++中SkAutoTUnref::newImageSnapshot方法的典型用法代码示例。如果您正苦于以下问题:C++ SkAutoTUnref::newImageSnapshot方法的具体用法?C++ SkAutoTUnref::newImageSnapshot怎么用?C++ SkAutoTUnref::newImageSnapshot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkAutoTUnref
的用法示例。
在下文中一共展示了SkAutoTUnref::newImageSnapshot方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawHere
void drawHere(SkCanvas* canvas, SkFilterQuality filter, SkScalar dx, SkScalar dy) {
SkCanvas* origCanvas = canvas;
SkAutoCanvasRestore acr(canvas, true);
SkISize size = SkISize::Make(fImage->width(), fImage->height());
SkAutoTUnref<SkSurface> surface;
if (fShowFatBits) {
// scale up so we don't clip rotations
SkImageInfo info = SkImageInfo::MakeN32(fImage->width() * 2, fImage->height() * 2,
kOpaque_SkAlphaType);
surface.reset(make_surface(canvas, info));
canvas = surface->getCanvas();
canvas->drawColor(SK_ColorWHITE);
size.set(info.width(), info.height());
} else {
canvas->translate(SkScalarHalf(fCell.width() - fImage->width()),
SkScalarHalf(fCell.height() - fImage->height()));
}
this->drawTheImage(canvas, size, filter, dx, dy);
if (surface) {
SkAutoTUnref<SkImage> orig(surface->newImageSnapshot());
SkAutoTUnref<SkImage> zoomed(zoom_up(orig));
origCanvas->drawImage(zoomed,
SkScalarHalf(fCell.width() - zoomed->width()),
SkScalarHalf(fCell.height() - zoomed->height()));
}
}
示例2:
~ImageRenderingContext()
{
if (IsGpu)
{
SkAutoTUnref<SkImage> image;
image.reset(Surface->newImageSnapshot(SkSurface::kNo_Budgeted));
image.get()->readPixels(Image->Bitmap.info(), Image->Bitmap.getPixels(), Image->Bitmap.rowBytes(), 0, 0);
}
Surface.reset(nullptr);
}
示例3: tool_main
//.........这里部分代码省略.........
} else {
loops = loopCount;
loopCount = 0;
}
if (benchMode == kPictureRecord_BenchMode) {
recordFrom->draw(canvas);
} else {
bench->draw(loops, canvas);
}
if (kDeferredSilent_BenchMode == benchMode) {
static_cast<SkDeferredCanvas*>(canvas.get())->silentFlush();
} else if (NULL != canvas) {
canvas->flush();
}
#if SK_SUPPORT_GPU
// swap drawing buffers on each frame to prevent the GPU
// from queuing up too much work
if (NULL != glContext) {
glContext->swapBuffers();
}
#endif
}
// Stop truncated timers before GL calls complete, and stop the full timers after.
timer.truncatedEnd();
#if SK_SUPPORT_GPU
if (NULL != glContext) {
context->flush();
SK_GL(*glContext, Finish());
}
#endif
timer.end();
// setup the frame interval for subsequent iterations
if (!frameIntervalComputed) {
frameIntervalTime += timer.fWall;
frameIntervalTotalLoops += loopsPerIter;
if (frameIntervalTime >= FLAGS_minMs) {
frameIntervalComputed = true;
loopsPerFrame =
(int)(((double)frameIntervalTotalLoops / frameIntervalTime) * FLAGS_minMs);
if (loopsPerFrame < 1) {
loopsPerFrame = 1;
}
// SkDebugf(" %s has %d loops in %f ms (normalized to %d)\n",
// bench->getName(), frameIntervalTotalLoops,
// timer.fWall, loopsPerFrame);
}
}
const double current = timer.fWall / loopsPerIter;
if (FLAGS_verbose && current > previous) { SkDebugf("↑"); }
if (FLAGS_verbose) { SkDebugf("%.3g ", current); }
converged = HasConverged(previous, current, timer.fWall);
previous = current;
} while (!FLAGS_runOnce && !converged);
}
if (FLAGS_verbose) { SkDebugf("\n"); }
if (!FLAGS_dryRun && FLAGS_outDir.count() && Benchmark::kNonRendering_Backend != config.backend) {
SkAutoTUnref<SkImage> image(surface->newImageSnapshot());
if (image.get()) {
saveFile(bench->getName(), config.name, FLAGS_outDir[0],
image);
}
}
if (FLAGS_runOnce) {
// Let's not mislead ourselves by looking at Debug build or single iteration bench times!
continue;
}
// Normalize to ms per 1000 iterations.
const double normalize = 1000.0 / loopsPerIter;
const struct { char shortName; const char* longName; double ms; } times[] = {
{'w', "msecs", normalize * timer.fWall},
{'W', "Wmsecs", normalize * timer.fTruncatedWall},
{'c', "cmsecs", normalize * timer.fCpu},
{'C', "Cmsecs", normalize * timer.fTruncatedCpu},
{'g', "gmsecs", normalize * timer.fGpu},
};
writer.config(config.name);
for (size_t i = 0; i < SK_ARRAY_COUNT(times); i++) {
if (strchr(FLAGS_timers[0], times[i].shortName) && times[i].ms > 0) {
writer.timer(times[i].longName, times[i].ms);
}
}
}
}
#if SK_SUPPORT_GPU
gContextFactory.destroyContexts();
#endif
return 0;
}