本文整理汇总了C++中GrPipelineBuilder::setUserStencil方法的典型用法代码示例。如果您正苦于以下问题:C++ GrPipelineBuilder::setUserStencil方法的具体用法?C++ GrPipelineBuilder::setUserStencil怎么用?C++ GrPipelineBuilder::setUserStencil使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GrPipelineBuilder
的用法示例。
在下文中一共展示了GrPipelineBuilder::setUserStencil方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onDrawPath
bool GrStencilAndCoverPathRenderer::onDrawPath(const DrawPathArgs& args) {
GR_AUDIT_TRAIL_AUTO_FRAME(args.fTarget->getAuditTrail(),
"GrStencilAndCoverPathRenderer::onDrawPath");
SkASSERT(!args.fStyle->strokeRec().isHairlineStyle());
const SkPath& path = *args.fPath;
GrPipelineBuilder* pipelineBuilder = args.fPipelineBuilder;
const SkMatrix& viewMatrix = *args.fViewMatrix;
SkASSERT(!pipelineBuilder->hasUserStencilSettings());
if (args.fAntiAlias) {
SkASSERT(pipelineBuilder->getRenderTarget()->isStencilBufferMultisampled());
pipelineBuilder->enableState(GrPipelineBuilder::kHWAntialias_Flag);
}
SkAutoTUnref<GrPath> p(get_gr_path(fResourceProvider, path, *args.fStyle));
if (path.isInverseFillType()) {
static constexpr GrUserStencilSettings kInvertedCoverPass(
GrUserStencilSettings::StaticInit<
0x0000,
// We know our rect will hit pixels outside the clip and the user bits will be 0
// outside the clip. So we can't just fill where the user bits are 0. We also need
// to check that the clip bit is set.
GrUserStencilTest::kEqualIfInClip,
0xffff,
GrUserStencilOp::kKeep,
GrUserStencilOp::kZero,
0xffff>()
);
pipelineBuilder->setUserStencil(&kInvertedCoverPass);
// fake inverse with a stencil and cover
args.fTarget->stencilPath(*pipelineBuilder, viewMatrix, p, p->getFillType());
SkMatrix invert = SkMatrix::I();
SkRect bounds =
SkRect::MakeLTRB(0, 0, SkIntToScalar(pipelineBuilder->getRenderTarget()->width()),
SkIntToScalar(pipelineBuilder->getRenderTarget()->height()));
SkMatrix vmi;
// mapRect through persp matrix may not be correct
if (!viewMatrix.hasPerspective() && viewMatrix.invert(&vmi)) {
vmi.mapRect(&bounds);
// theoretically could set bloat = 0, instead leave it because of matrix inversion
// precision.
SkScalar bloat = viewMatrix.getMaxScale() * SK_ScalarHalf;
bounds.outset(bloat, bloat);
} else {
if (!viewMatrix.invert(&invert)) {
return false;
}
}
const SkMatrix& viewM = viewMatrix.hasPerspective() ? SkMatrix::I() : viewMatrix;
if (pipelineBuilder->getRenderTarget()->hasMixedSamples()) {
pipelineBuilder->disableState(GrPipelineBuilder::kHWAntialias_Flag);
}
SkAutoTUnref<GrDrawBatch> batch(
GrRectBatchFactory::CreateNonAAFill(args.fColor, viewM, bounds, nullptr,
&invert));
args.fTarget->drawBatch(*pipelineBuilder, batch);
} else {
static constexpr GrUserStencilSettings kCoverPass(
GrUserStencilSettings::StaticInit<
0x0000,
GrUserStencilTest::kNotEqual,
0xffff,
GrUserStencilOp::kZero,
GrUserStencilOp::kKeep,
0xffff>()
);
pipelineBuilder->setUserStencil(&kCoverPass);
SkAutoTUnref<GrDrawPathBatchBase> batch(
GrDrawPathBatch::Create(viewMatrix, args.fColor, p->getFillType(), p));
args.fTarget->drawPathBatch(*pipelineBuilder, batch);
}
pipelineBuilder->disableUserStencil();
return true;
}