本文整理汇总了C++中SkAutoTUnref::getCanvas方法的典型用法代码示例。如果您正苦于以下问题:C++ SkAutoTUnref::getCanvas方法的具体用法?C++ SkAutoTUnref::getCanvas怎么用?C++ SkAutoTUnref::getCanvas使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkAutoTUnref
的用法示例。
在下文中一共展示了SkAutoTUnref::getCanvas方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawTriangle
void FatBits::drawTriangle(SkCanvas* canvas, SkPoint pts[3]) {
SkPaint paint;
fInverse.mapPoints(pts, 3);
if (fGrid) {
apply_grid(pts, 3);
}
SkPath path;
path.moveTo(pts[0]);
path.lineTo(pts[1]);
path.lineTo(pts[2]);
path.close();
erase(fMinSurface);
this->setupPaint(&paint);
paint.setColor(FAT_PIXEL_COLOR);
fMinSurface->getCanvas()->drawPath(path, paint);
this->copyMinToMax();
SkCanvas* max = fMaxSurface->getCanvas();
fMatrix.mapPoints(pts, 3);
this->drawTriangleSkeleton(max, pts);
fMaxSurface->draw(canvas, 0, 0, NULL);
}
示例2: drawLine
void FatBits::drawLine(SkCanvas* canvas, SkPoint pts[]) {
SkPaint paint;
fInverse.mapPoints(pts, 2);
if (fGrid) {
apply_grid(pts, 2);
}
erase(fMinSurface);
this->setupPaint(&paint);
paint.setColor(FAT_PIXEL_COLOR);
if (fUseClip) {
fMinSurface->getCanvas()->save();
SkRect r = fClipRect;
r.inset(SK_Scalar1/3, SK_Scalar1/3);
fMinSurface->getCanvas()->clipRect(r, SkRegion::kIntersect_Op, true);
}
fMinSurface->getCanvas()->drawLine(pts[0].fX, pts[0].fY, pts[1].fX, pts[1].fY, paint);
if (fUseClip) {
fMinSurface->getCanvas()->restore();
}
this->copyMinToMax();
SkCanvas* max = fMaxSurface->getCanvas();
fMatrix.mapPoints(pts, 2);
this->drawLineSkeleton(max, pts);
fMaxSurface->draw(canvas, 0, 0, NULL);
}
示例3: drawRect
void FatBits::drawRect(SkCanvas* canvas, SkPoint pts[2]) {
SkPaint paint;
fInverse.mapPoints(pts, 2);
if (fGrid) {
apply_grid(pts, 2);
}
SkRect r;
r.set(pts, 2);
erase(fMinSurface);
this->setupPaint(&paint);
paint.setColor(FAT_PIXEL_COLOR);
{
SkCanvas* c = fMinSurface->getCanvas();
fRectAsOval ? c->drawOval(r, paint) : c->drawRect(r, paint);
}
this->copyMinToMax();
SkCanvas* max = fMaxSurface->getCanvas();
fMatrix.mapPoints(pts, 2);
r.set(pts, 2);
this->drawRectSkeleton(max, r);
fMaxSurface->draw(canvas, 0, 0, NULL);
}
示例4: 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()));
}
}
示例5:
ImageRenderingContext(BitmapContainer*image)
{
Image = image;
IsGpu = false;
if (Context != nullptr && Options[proForceSoftware] == nullptr)
Surface.reset(SkSurface::NewRenderTarget(Context, SkSurface::kNo_Budgeted, Image->Bitmap.info()));
if (Surface.get() != nullptr)
IsGpu = true;
else
{
Surface.reset(SkSurface::NewRasterDirect(image->Bitmap.info(), image->Bitmap.getPixels(), image->Bitmap.rowBytes()));
}
Surface.reset(SkSurface::NewRasterDirect(image->Bitmap.info(), image->Bitmap.getPixels(), image->Bitmap.rowBytes()));
Canvas = Surface->getCanvas();
Canvas->clear(SkColor());
}
示例6: copyMinToMax
void copyMinToMax() {
erase(fMaxSurface);
SkCanvas* canvas = fMaxSurface->getCanvas();
canvas->save();
canvas->concat(fMatrix);
fMinSurface->draw(canvas, 0, 0, NULL);
canvas->restore();
SkPaint paint;
paint.setXfermodeMode(SkXfermode::kClear_Mode);
for (int iy = 1; iy < fH; ++iy) {
SkScalar y = SkIntToScalar(iy * fZoom);
canvas->drawLine(0, y - SK_ScalarHalf, 999, y - SK_ScalarHalf, paint);
}
for (int ix = 1; ix < fW; ++ix) {
SkScalar x = SkIntToScalar(ix * fZoom);
canvas->drawLine(x - SK_ScalarHalf, 0, x - SK_ScalarHalf, 999, paint);
}
}
示例7: tool_main
//.........这里部分代码省略.........
SkAutoTUnref<SkPicture> recordFrom;
SkPictureRecorder recorderTo;
const SkIPoint dim = bench->getSize();
SkAutoTUnref<SkSurface> surface;
if (Benchmark::kNonRendering_Backend != config.backend) {
surface.reset(make_surface(config.fColorType,
dim,
config.backend,
config.sampleCount,
context));
if (!surface.get()) {
logger.logError(SkStringPrintf(
"Device creation failure for config %s. Will skip.\n", config.name));
continue;
}
switch(benchMode) {
case kDeferredSilent_BenchMode:
case kDeferred_BenchMode:
canvas.reset(SkDeferredCanvas::Create(surface.get()));
break;
case kRecord_BenchMode:
canvas.reset(SkRef(recorderTo.beginRecording(dim.fX, dim.fY)));
break;
case kPictureRecord_BenchMode: {
SkPictureRecorder recorderFrom;
bench->draw(1, recorderFrom.beginRecording(dim.fX, dim.fY));
recordFrom.reset(recorderFrom.endRecording());
canvas.reset(SkRef(recorderTo.beginRecording(dim.fX, dim.fY)));
break;
}
case kNormal_BenchMode:
canvas.reset(SkRef(surface->getCanvas()));
break;
default:
SkASSERT(false);
}
}
if (NULL != canvas) {
canvas->clear(SK_ColorWHITE);
if (FLAGS_clip) {
perform_clip(canvas, dim.fX, dim.fY);
}
if (FLAGS_scale) {
perform_scale(canvas, dim.fX, dim.fY);
}
if (FLAGS_rotate) {
perform_rotate(canvas, dim.fX, dim.fY);
}
}
if (!loggedBenchName) {
loggedBenchName = true;
writer.bench(bench->getName(), dim.fX, dim.fY);
}
#if SK_SUPPORT_GPU
SkGLContextHelper* contextHelper = NULL;
if (Benchmark::kGPU_Backend == config.backend) {
contextHelper = gContextFactory.getGLContext(config.contextType);
}
BenchTimer timer(contextHelper);
#else
BenchTimer timer;
示例8: draw_stroke
void draw_stroke(SkCanvas* canvas, const SkPath& path, SkScalar width, SkScalar scale,
bool drawText) {
if (path.isEmpty()) {
return;
}
SkRect bounds = path.getBounds();
this->setWHZ(SkScalarCeilToInt(bounds.right()), drawText
? SkScalarRoundToInt(scale * 3 / 2) : SkScalarRoundToInt(scale),
SkScalarRoundToInt(950.0f / scale));
erase(fMinSurface);
SkPaint paint;
paint.setColor(0x1f1f0f0f);
paint.setStyle(SkPaint::kStroke_Style);
paint.setStrokeWidth(width * scale * scale);
paint.setColor(0x3f0f1f3f);
if (drawText) {
fMinSurface->getCanvas()->drawPath(path, paint);
this->copyMinToMax();
fMaxSurface->draw(canvas, 0, 0, NULL);
}
paint.setAntiAlias(true);
paint.setStyle(SkPaint::kStroke_Style);
paint.setStrokeWidth(1);
paint.setColor(SKELETON_COLOR);
SkPath scaled;
SkMatrix matrix;
matrix.reset();
matrix.setScale(950 / scale, 950 / scale);
if (drawText) {
path.transform(matrix, &scaled);
} else {
scaled = path;
}
canvas->drawPath(scaled, paint);
draw_points(canvas, scaled, SKELETON_COLOR, true);
if (fDrawRibs) {
draw_ribs(canvas, scaled, width, 0xFF00FF00);
}
SkPath fill;
SkPaint p;
p.setStyle(SkPaint::kStroke_Style);
if (drawText) {
p.setStrokeWidth(width * scale * scale);
} else {
p.setStrokeWidth(width);
}
p.getFillPath(path, &fill);
SkPath scaledFill;
if (drawText) {
fill.transform(matrix, &scaledFill);
} else {
scaledFill = fill;
}
paint.setColor(WIREFRAME_COLOR);
canvas->drawPath(scaledFill, paint);
draw_points(canvas, scaledFill, WIREFRAME_COLOR, false);
}