本文整理汇总了C++中GrPipelineBuilder::setXPFactory方法的典型用法代码示例。如果您正苦于以下问题:C++ GrPipelineBuilder::setXPFactory方法的具体用法?C++ GrPipelineBuilder::setXPFactory怎么用?C++ GrPipelineBuilder::setXPFactory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GrPipelineBuilder
的用法示例。
在下文中一共展示了GrPipelineBuilder::setXPFactory方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_path
static void test_path(GrDrawTarget* dt, GrRenderTarget* rt, GrResourceProvider* rp,
const SkPath& path) {
GrTessellatingPathRenderer tess;
GrPipelineBuilder pipelineBuilder;
pipelineBuilder.setXPFactory(
GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode))->unref();
pipelineBuilder.setRenderTarget(rt);
GrStrokeInfo stroke(SkStrokeRec::kFill_InitStyle);
GrPathRenderer::DrawPathArgs args;
args.fTarget = dt;
args.fPipelineBuilder = &pipelineBuilder;
args.fResourceProvider = rp;
args.fColor = GrColor_WHITE;
args.fViewMatrix = &SkMatrix::I();
args.fPath = &path;
args.fStroke = &stroke;
args.fAntiAlias = false;
tess.drawPath(args);
}
示例2: clear
void GrDrawTarget::clear(const SkIRect* rect,
GrColor color,
bool canIgnoreRect,
GrRenderTarget* renderTarget) {
SkIRect rtRect = SkIRect::MakeWH(renderTarget->width(), renderTarget->height());
SkIRect clippedRect;
if (!rect ||
(canIgnoreRect && this->caps()->fullClearIsFree()) ||
rect->contains(rtRect)) {
rect = &rtRect;
} else {
clippedRect = *rect;
if (!clippedRect.intersect(rtRect)) {
return;
}
rect = &clippedRect;
}
if (this->caps()->useDrawInsteadOfClear()) {
// This works around a driver bug with clear by drawing a rect instead.
// The driver will ignore a clear if it is the only thing rendered to a
// target before the target is read.
if (rect == &rtRect) {
this->discard(renderTarget);
}
GrPipelineBuilder pipelineBuilder;
pipelineBuilder.setXPFactory(
GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode))->unref();
pipelineBuilder.setRenderTarget(renderTarget);
SkRect scalarRect = SkRect::Make(*rect);
SkAutoTUnref<GrDrawBatch> batch(
GrRectBatchFactory::CreateNonAAFill(color, SkMatrix::I(), scalarRect,
nullptr, nullptr));
this->drawBatch(pipelineBuilder, batch);
} else {
GrBatch* batch = new GrClearBatch(*rect, color, renderTarget);
this->recordBatch(batch);
batch->unref();
}
}
示例3: ProgramUnitTest
bool GrDrawingManager::ProgramUnitTest(GrContext* context,
GrDrawTarget* drawTarget,
int maxStages) {
GrDrawingManager* drawingManager = context->drawingManager();
// setup dummy textures
GrSurfaceDesc dummyDesc;
dummyDesc.fFlags = kRenderTarget_GrSurfaceFlag;
dummyDesc.fConfig = kSkia8888_GrPixelConfig;
dummyDesc.fWidth = 34;
dummyDesc.fHeight = 18;
SkAutoTUnref<GrTexture> dummyTexture1(
context->textureProvider()->createTexture(dummyDesc, false, nullptr, 0));
dummyDesc.fFlags = kNone_GrSurfaceFlags;
dummyDesc.fConfig = kAlpha_8_GrPixelConfig;
dummyDesc.fWidth = 16;
dummyDesc.fHeight = 22;
SkAutoTUnref<GrTexture> dummyTexture2(
context->textureProvider()->createTexture(dummyDesc, false, nullptr, 0));
if (!dummyTexture1 || ! dummyTexture2) {
SkDebugf("Could not allocate dummy textures");
return false;
}
GrTexture* dummyTextures[] = {dummyTexture1.get(), dummyTexture2.get()};
// dummy scissor state
GrScissorState scissor;
// wide open clip
GrClip clip;
SkRandom random;
static const int NUM_TESTS = 2048;
for (int t = 0; t < NUM_TESTS; t++) {
// setup random render target(can fail)
SkAutoTUnref<GrRenderTarget> rt(random_render_target(
context->textureProvider(), &random, context->caps()));
if (!rt.get()) {
SkDebugf("Could not allocate render target");
return false;
}
GrPipelineBuilder pipelineBuilder;
pipelineBuilder.setRenderTarget(rt.get());
pipelineBuilder.setClip(clip);
SkAutoTUnref<GrDrawBatch> batch(GrRandomDrawBatch(&random, context));
SkASSERT(batch);
GrProcessorTestData ptd(&random, context, context->caps(), dummyTextures);
set_random_color_coverage_stages(&pipelineBuilder, &ptd, maxStages);
set_random_xpf(&pipelineBuilder, &ptd);
set_random_state(&pipelineBuilder, &random);
set_random_stencil(&pipelineBuilder, &random);
drawTarget->drawBatch(pipelineBuilder, batch);
}
// Flush everything, test passes if flush is successful(ie, no asserts are hit, no crashes)
drawingManager->flush();
// Validate that GrFPs work correctly without an input.
GrSurfaceDesc rtDesc;
rtDesc.fWidth = kRenderTargetWidth;
rtDesc.fHeight = kRenderTargetHeight;
rtDesc.fFlags = kRenderTarget_GrSurfaceFlag;
rtDesc.fConfig = kRGBA_8888_GrPixelConfig;
SkAutoTUnref<GrRenderTarget> rt(
context->textureProvider()->createTexture(rtDesc, false)->asRenderTarget());
int fpFactoryCnt = GrProcessorTestFactory<GrFragmentProcessor>::Count();
for (int i = 0; i < fpFactoryCnt; ++i) {
// Since FP factories internally randomize, call each 10 times.
for (int j = 0; j < 10; ++j) {
SkAutoTUnref<GrDrawBatch> batch(GrRandomDrawBatch(&random, context));
SkASSERT(batch);
GrProcessorTestData ptd(&random, context, context->caps(), dummyTextures);
GrPipelineBuilder builder;
builder.setXPFactory(GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode))->unref();
builder.setRenderTarget(rt);
builder.setClip(clip);
SkAutoTUnref<const GrFragmentProcessor> fp(
GrProcessorTestFactory<GrFragmentProcessor>::CreateIdx(i, &ptd));
SkAutoTUnref<const GrFragmentProcessor> blockFP(
BlockInputFragmentProcessor::Create(fp));
builder.addColorFragmentProcessor(blockFP);
drawTarget->drawBatch(builder, batch);
drawingManager->flush();
}
}
return true;
}