Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(208)

Unified Diff: src/gpu/GrDrawTarget.cpp

Issue 1966763002: Eliminate special case nvpr batch handling (Closed) Base URL: https://skia.googlesource.com/skia.git@reallyupload_userstencil
Patch Set: fixes Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrDrawTarget.h ('k') | src/gpu/GrPathRendering.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrDrawTarget.cpp
diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp
index 7166fc7160008159ab4bcc7208fcb6ae8d93f64f..26b271f3b35221665cfff1cc9607f5dd3f51a1fe 100644
--- a/src/gpu/GrDrawTarget.cpp
+++ b/src/gpu/GrDrawTarget.cpp
@@ -257,8 +257,51 @@ void GrDrawTarget::drawBatch(const GrPipelineBuilder& pipelineBuilder,
}
GrPipeline::CreateArgs args;
- if (!this->installPipelineInDrawBatch(&pipelineBuilder, &clip.scissorState(),
- clip.hasStencilClip(), batch)) {
+ args.fPipelineBuilder = &pipelineBuilder;
+ args.fCaps = this->caps();
+ args.fScissor = &clip.scissorState();
+ args.fHasStencilClip = clip.hasStencilClip();
+ if (pipelineBuilder.hasUserStencilSettings() || clip.hasStencilClip()) {
+ fResourceProvider->attachStencilAttachment(pipelineBuilder.getRenderTarget());
+ }
+ batch->getPipelineOptimizations(&args.fOpts);
+ GrScissorState finalScissor;
+ if (args.fOpts.fOverrides.fUsePLSDstRead) {
+ GrRenderTarget* rt = pipelineBuilder.getRenderTarget();
+ GrGLIRect viewport;
+ viewport.fLeft = 0;
+ viewport.fBottom = 0;
+ viewport.fWidth = rt->width();
+ viewport.fHeight = rt->height();
+ SkIRect ibounds;
+ ibounds.fLeft = SkTPin(SkScalarFloorToInt(batch->bounds().fLeft), viewport.fLeft,
+ viewport.fWidth);
+ ibounds.fTop = SkTPin(SkScalarFloorToInt(batch->bounds().fTop), viewport.fBottom,
+ viewport.fHeight);
+ ibounds.fRight = SkTPin(SkScalarCeilToInt(batch->bounds().fRight), viewport.fLeft,
+ viewport.fWidth);
+ ibounds.fBottom = SkTPin(SkScalarCeilToInt(batch->bounds().fBottom), viewport.fBottom,
+ viewport.fHeight);
+ if (clip.scissorState().enabled()) {
+ const SkIRect& scissorRect = clip.scissorState().rect();
+ if (!ibounds.intersect(scissorRect)) {
+ ibounds = scissorRect;
+ }
+ }
+ finalScissor.set(ibounds);
+ args.fScissor = &finalScissor;
+ }
+ args.fOpts.fColorPOI.completeCalculations(pipelineBuilder.fColorFragmentProcessors.begin(),
+ pipelineBuilder.numColorFragmentProcessors());
+ args.fOpts.fCoveragePOI.completeCalculations(
+ pipelineBuilder.fCoverageFragmentProcessors.begin(),
+ pipelineBuilder.numCoverageFragmentProcessors());
+ if (!this->setupDstReadIfNecessary(pipelineBuilder, args.fOpts, &args.fDstTexture,
+ batch->bounds())) {
+ return;
+ }
+
+ if (!batch->installPipeline(args)) {
return;
}
@@ -270,38 +313,6 @@ void GrDrawTarget::drawBatch(const GrPipelineBuilder& pipelineBuilder,
this->recordBatch(batch);
}
-inline static const GrUserStencilSettings& get_path_stencil_settings_for_fill(
- GrPathRendering::FillType fill) {
- static constexpr GrUserStencilSettings kWindingStencilSettings(
- GrUserStencilSettings::StaticInit<
- 0xffff,
- GrUserStencilTest::kAlwaysIfInClip,
- 0xffff,
- GrUserStencilOp::kIncMaybeClamp, // TODO: Use wrap ops for NVPR.
- GrUserStencilOp::kIncMaybeClamp,
- 0xffff>()
- );
-
- static constexpr GrUserStencilSettings kEvenOddStencilSettings(
- GrUserStencilSettings::StaticInit<
- 0xffff,
- GrUserStencilTest::kAlwaysIfInClip,
- 0xffff,
- GrUserStencilOp::kInvert,
- GrUserStencilOp::kInvert,
- 0xffff>()
- );
-
- switch (fill) {
- default:
- SkFAIL("Unexpected path fill.");
- case GrPathRendering::kWinding_FillType:
- return kWindingStencilSettings;
- case GrPathRendering::kEvenOdd_FillType:
- return kEvenOddStencilSettings;
- }
-}
-
void GrDrawTarget::stencilPath(const GrPipelineBuilder& pipelineBuilder,
const SkMatrix& viewMatrix,
const GrPath* path,
@@ -327,7 +338,7 @@ void GrDrawTarget::stencilPath(const GrPipelineBuilder& pipelineBuilder,
GrBatch* batch = GrStencilPathBatch::Create(viewMatrix,
pipelineBuilder.isHWAntialias(),
- get_path_stencil_settings_for_fill(fill),
+ fill,
clip.hasStencilClip(),
stencilAttachment->bits(),
clip.scissorState(),
@@ -337,42 +348,6 @@ void GrDrawTarget::stencilPath(const GrPipelineBuilder& pipelineBuilder,
batch->unref();
}
-void GrDrawTarget::drawPathBatch(const GrPipelineBuilder& pipelineBuilder,
- GrDrawPathBatchBase* batch) {
- // This looks like drawBatch() but there is an added wrinkle that stencil settings get inserted
- // after setting up clipping but before onDrawBatch(). TODO: Figure out a better model for
- // handling stencil settings WRT interactions between pipeline(builder), clipmaskmanager, and
- // batches.
- SkASSERT(this->caps()->shaderCaps()->pathRenderingSupport());
-
- GrAppliedClip clip;
- if (!fClipMaskManager->setupClipping(pipelineBuilder, &batch->bounds(), &clip)) {
- return;
- }
-
- GrPipelineBuilder::AutoRestoreFragmentProcessorState arfps;
- if (clip.clipCoverageFragmentProcessor()) {
- arfps.set(&pipelineBuilder);
- arfps.addCoverageFragmentProcessor(clip.clipCoverageFragmentProcessor());
- }
-
- // Ensure the render target has a stencil buffer and get the stencil settings.
- GrRenderTarget* rt = pipelineBuilder.getRenderTarget();
- GrStencilAttachment* sb = fResourceProvider->attachStencilAttachment(rt);
- // TODO: Move this step into GrDrawPathPath::onPrepare().
- batch->setStencilSettings(get_path_stencil_settings_for_fill(batch->fillType()),
- clip.hasStencilClip(),
- sb->bits());
-
- GrPipeline::CreateArgs args;
- if (!this->installPipelineInDrawBatch(&pipelineBuilder, &clip.scissorState(),
- clip.hasStencilClip(), batch)) {
- return;
- }
-
- this->recordBatch(batch);
-}
-
void GrDrawTarget::clear(const SkIRect* rect,
GrColor color,
bool canIgnoreRect,
@@ -548,65 +523,6 @@ void GrDrawTarget::forwardCombine() {
///////////////////////////////////////////////////////////////////////////////
-bool GrDrawTarget::installPipelineInDrawBatch(const GrPipelineBuilder* pipelineBuilder,
- const GrScissorState* scissor,
- bool hasStencilClip,
- GrDrawBatch* batch) {
- GrPipeline::CreateArgs args;
- args.fPipelineBuilder = pipelineBuilder;
- args.fCaps = this->caps();
- args.fScissor = scissor;
- if (pipelineBuilder->hasUserStencilSettings() || hasStencilClip) {
- GrRenderTarget* rt = pipelineBuilder->getRenderTarget();
- GrStencilAttachment* sb = fResourceProvider->attachStencilAttachment(rt);
- args.fNumStencilBits = sb->bits();
- } else {
- args.fNumStencilBits = 0;
- }
- args.fHasStencilClip = hasStencilClip;
- batch->getPipelineOptimizations(&args.fOpts);
- GrScissorState finalScissor;
- if (args.fOpts.fOverrides.fUsePLSDstRead) {
- GrRenderTarget* rt = pipelineBuilder->getRenderTarget();
- GrGLIRect viewport;
- viewport.fLeft = 0;
- viewport.fBottom = 0;
- viewport.fWidth = rt->width();
- viewport.fHeight = rt->height();
- SkIRect ibounds;
- ibounds.fLeft = SkTPin(SkScalarFloorToInt(batch->bounds().fLeft), viewport.fLeft,
- viewport.fWidth);
- ibounds.fTop = SkTPin(SkScalarFloorToInt(batch->bounds().fTop), viewport.fBottom,
- viewport.fHeight);
- ibounds.fRight = SkTPin(SkScalarCeilToInt(batch->bounds().fRight), viewport.fLeft,
- viewport.fWidth);
- ibounds.fBottom = SkTPin(SkScalarCeilToInt(batch->bounds().fBottom), viewport.fBottom,
- viewport.fHeight);
- if (scissor != nullptr && scissor->enabled()) {
- if (!ibounds.intersect(scissor->rect())) {
- ibounds = scissor->rect();
- }
- }
- finalScissor.set(ibounds);
- args.fScissor = &finalScissor;
- }
- args.fOpts.fColorPOI.completeCalculations(pipelineBuilder->fColorFragmentProcessors.begin(),
- pipelineBuilder->numColorFragmentProcessors());
- args.fOpts.fCoveragePOI.completeCalculations(
- pipelineBuilder->fCoverageFragmentProcessors.begin(),
- pipelineBuilder->numCoverageFragmentProcessors());
- if (!this->setupDstReadIfNecessary(*pipelineBuilder, args.fOpts, &args.fDstTexture,
- batch->bounds())) {
- return false;
- }
-
- if (!batch->installPipeline(args)) {
- return false;
- }
-
- return true;
-}
-
void GrDrawTarget::clearStencilClip(const SkIRect& rect, bool insideClip, GrRenderTarget* rt) {
GrBatch* batch = new GrClearStencilClipBatch(rect, insideClip, rt);
this->recordBatch(batch);
« no previous file with comments | « src/gpu/GrDrawTarget.h ('k') | src/gpu/GrPathRendering.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698