Retract PipelineBuilder from GrClip::apply

GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2147443004

Review-Url: https://codereview.chromium.org/2147443004
This commit is contained in:
robertphillips 2016-07-13 09:18:21 -07:00 committed by Commit bot
parent 0e1161d03f
commit 59cf61ab03
9 changed files with 84 additions and 68 deletions

View File

@ -13,7 +13,6 @@
#include "SkClipStack.h"
class GrDrawContext;
class GrPipelineBuilder;
/**
* Produced by GrClip. It provides a set of modifications to the drawing state that are used to
@ -105,8 +104,12 @@ public:
virtual bool quickContains(const SkRect&) const = 0;
virtual void getConservativeBounds(int width, int height, SkIRect* devResult,
bool* isIntersectionOfRects = nullptr) const = 0;
virtual bool apply(GrContext*, const GrPipelineBuilder&, GrDrawContext*,
const SkRect* devBounds, GrAppliedClip*) const = 0;
virtual bool apply(GrContext*,
GrDrawContext*,
const SkRect* devBounds,
bool useHWAA,
bool hasUserStencilSettings,
GrAppliedClip* out) const = 0;
virtual ~GrClip() {}
};
@ -119,8 +122,12 @@ private:
bool quickContains(const SkRect&) const final { return true; }
void getConservativeBounds(int width, int height, SkIRect* devResult,
bool* isIntersectionOfRects) const final;
bool apply(GrContext*, const GrPipelineBuilder&, GrDrawContext*,
const SkRect*, GrAppliedClip*) const final { return true; }
bool apply(GrContext*,
GrDrawContext*,
const SkRect* /* devBounds */,
bool /* useHWAA */,
bool /* hasUserStencilSettings */,
GrAppliedClip* /* out */) const final { return true; }
};
/**
@ -180,8 +187,12 @@ public:
bool* isIntersectionOfRects) const final;
private:
bool apply(GrContext*, const GrPipelineBuilder&, GrDrawContext*,
const SkRect* devBounds, GrAppliedClip* out) const final;
bool apply(GrContext*,
GrDrawContext*,
const SkRect* devBounds,
bool useHWAA,
bool hasUserStencilSettings,
GrAppliedClip* out) const final;
GrScissorState fScissorState;
SkRect fDeviceBounds;
@ -209,8 +220,12 @@ public:
bool quickContains(const SkRect&) const final;
void getConservativeBounds(int width, int height, SkIRect* devResult,
bool* isIntersectionOfRects) const final;
bool apply(GrContext*, const GrPipelineBuilder&, GrDrawContext*,
const SkRect* devBounds, GrAppliedClip*) const final;
bool apply(GrContext*,
GrDrawContext*,
const SkRect* devBounds,
bool useHWAA,
bool hasUserStencilSettings,
GrAppliedClip* out) const final;
private:
SkIPoint fOrigin;

View File

@ -41,9 +41,12 @@ void GrFixedClip::getConservativeBounds(int width, int height, SkIRect* devResul
}
}
bool GrFixedClip::apply(GrContext*, const GrPipelineBuilder& pipelineBuilder,
bool GrFixedClip::apply(GrContext*,
GrDrawContext* drawContext,
const SkRect* devBounds, GrAppliedClip* out) const {
const SkRect* devBounds,
bool isHWAntiAlias,
bool hasUserStencilSettings,
GrAppliedClip* out) const {
SkASSERT(!fDeviceBounds.isLargest());
if (fScissorState.enabled()) {
SkIRect tightScissor;
@ -90,8 +93,11 @@ void GrClipStackClip::getConservativeBounds(int width, int height, SkIRect* devR
}
bool GrClipStackClip::apply(GrContext* context,
const GrPipelineBuilder& pipelineBuilder, GrDrawContext* drawContext,
const SkRect* devBounds, GrAppliedClip* out) const {
return GrClipMaskManager::SetupClipping(context, pipelineBuilder, drawContext,
*this, devBounds, out);
GrDrawContext* drawContext,
const SkRect* devBounds,
bool useHWAA,
bool hasUserStencilSettings,
GrAppliedClip* out) const {
return GrClipMaskManager::SetupClipping(context, drawContext, *this, devBounds,
useHWAA, hasUserStencilSettings, out);
}

View File

@ -115,7 +115,7 @@ bool GrClipMaskManager::PathNeedsSWRenderer(GrContext* context,
* entire clip should be rendered in SW and then uploaded en masse to the gpu.
*/
bool GrClipMaskManager::UseSWOnlyPath(GrContext* context,
const GrPipelineBuilder& pipelineBuilder,
bool hasUserStencilSettings,
const GrDrawContext* drawContext,
const SkVector& clipToMaskOffset,
const GrReducedClip::ElementList& elements) {
@ -135,7 +135,7 @@ bool GrClipMaskManager::UseSWOnlyPath(GrContext* context,
bool needsStencil = invert ||
SkRegion::kIntersect_Op == op || SkRegion::kReverseDifference_Op == op;
if (PathNeedsSWRenderer(context, pipelineBuilder.hasUserStencilSettings(),
if (PathNeedsSWRenderer(context, hasUserStencilSettings,
drawContext, translate, element, nullptr, needsStencil)) {
return true;
}
@ -226,10 +226,11 @@ static bool get_analytic_clip_processor(const GrReducedClip::ElementList& elemen
// sort out what kind of clip mask needs to be created: alpha, stencil,
// scissor, or entirely software
bool GrClipMaskManager::SetupClipping(GrContext* context,
const GrPipelineBuilder& pipelineBuilder,
GrDrawContext* drawContext,
const GrClipStackClip& clip,
const SkRect* origDevBounds,
bool useHWAA,
bool hasUserStencilSettings,
GrAppliedClip* out) {
if (!clip.clipStack() || clip.clipStack()->isWideOpen()) {
return true;
@ -293,8 +294,7 @@ bool GrClipMaskManager::SetupClipping(GrContext* context,
// With a single color sample, any coverage info is lost from color once it hits the
// color buffer anyway, so we may as well use coverage AA if nothing else in the pipe
// is multisampled.
disallowAnalyticAA = pipelineBuilder.isHWAntialias() ||
pipelineBuilder.hasUserStencilSettings();
disallowAnalyticAA = useHWAA || hasUserStencilSettings;
}
sk_sp<GrFragmentProcessor> clipFP;
if (requiresAA &&
@ -321,7 +321,7 @@ bool GrClipMaskManager::SetupClipping(GrContext* context,
SkIntToScalar(-clipSpaceIBounds.fTop)
};
if (UseSWOnlyPath(context, pipelineBuilder, drawContext,
if (UseSWOnlyPath(context, hasUserStencilSettings, drawContext,
clipToMaskOffset, elements)) {
// The clip geometry is complex enough that it will be more efficient to create it
// entirely in software

View File

@ -15,15 +15,10 @@ class GrAppliedClip;
class GrClipStackClip;
class GrContext;
class GrDrawContext;
class GrFixedClip;
class GrPathRenderer;
class GrPathRendererChain;
class GrPipelineBuilder;
class GrResourceProvider;
class GrTexture;
class GrTextureProvider;
class GrUniqueKey;
struct GrUserStencilSettings;
/**
@ -43,8 +38,13 @@ public:
* then the draw can be skipped. devBounds is optional but can help optimize
* clipping.
*/
static bool SetupClipping(GrContext*, const GrPipelineBuilder&, GrDrawContext*,
const GrClipStackClip&, const SkRect* devBounds, GrAppliedClip*);
static bool SetupClipping(GrContext*,
GrDrawContext*,
const GrClipStackClip&,
const SkRect* devBounds,
bool useHWAA,
bool hasUserStencilSettings,
GrAppliedClip* out);
private:
static bool PathNeedsSWRenderer(GrContext* context,
@ -82,7 +82,7 @@ private:
const SkIRect& clipSpaceIBounds);
static bool UseSWOnlyPath(GrContext*,
const GrPipelineBuilder&,
bool hasUserStencilSettings,
const GrDrawContext*,
const SkVector& clipToMaskOffset,
const GrReducedClip::ElementList& elements);

View File

@ -486,13 +486,12 @@ void GrDrawContextPriv::clearStencilClip(const SkIRect& rect, bool insideClip) {
fDrawContext->accessRenderTarget());
}
void GrDrawContextPriv::stencilPath(const GrPipelineBuilder& pipelineBuilder,
const GrClip& clip,
void GrDrawContextPriv::stencilPath(const GrClip& clip,
const GrUserStencilSettings* ss,
bool useHWAA,
const SkMatrix& viewMatrix,
const GrPath* path,
GrPathRendering::FillType fill) {
fDrawContext->getDrawTarget()->stencilPath(pipelineBuilder, fDrawContext,
clip, viewMatrix, path, fill);
const GrPath* path) {
fDrawContext->getDrawTarget()->stencilPath(fDrawContext, clip, ss, useHWAA, viewMatrix, path);
}
void GrDrawContextPriv::stencilRect(const GrFixedClip& clip,

View File

@ -33,11 +33,11 @@ public:
const SkMatrix& viewMatrix,
const SkRect& rect);
void stencilPath(const GrPipelineBuilder&,
const GrClip&,
void stencilPath(const GrClip&,
const GrUserStencilSettings* ss,
bool useHWAA,
const SkMatrix& viewMatrix,
const GrPath*,
GrPathRendering::FillType);
const GrPath*);
bool drawAndStencilRect(const GrFixedClip&,
const GrUserStencilSettings*,

View File

@ -329,7 +329,9 @@ void GrDrawTarget::drawBatch(const GrPipelineBuilder& pipelineBuilder,
GrAppliedClip appliedClip;
SkRect bounds;
batch_bounds(&bounds, batch);
if (!clip.apply(fContext, pipelineBuilder, drawContext, &bounds, &appliedClip)) {
if (!clip.apply(fContext, drawContext, &bounds,
pipelineBuilder.isHWAntialias(), pipelineBuilder.hasUserStencilSettings(),
&appliedClip)) {
return;
}
@ -403,19 +405,19 @@ void GrDrawTarget::drawBatch(const GrPipelineBuilder& pipelineBuilder,
this->recordBatch(batch, clippedBounds);
}
void GrDrawTarget::stencilPath(const GrPipelineBuilder& pipelineBuilder,
GrDrawContext* drawContext,
void GrDrawTarget::stencilPath(GrDrawContext* drawContext,
const GrClip& clip,
const GrUserStencilSettings* ss,
bool useHWAA,
const SkMatrix& viewMatrix,
const GrPath* path,
GrPathRendering::FillType fill) {
const GrPath* path) {
// TODO: extract portions of checkDraw that are relevant to path stenciling.
SkASSERT(path);
SkASSERT(this->caps()->shaderCaps()->pathRenderingSupport());
// Setup clip
GrAppliedClip appliedClip;
if (!clip.apply(fContext, pipelineBuilder, drawContext, nullptr, &appliedClip)) {
if (!clip.apply(fContext, drawContext, nullptr, useHWAA, SkToBool(ss), &appliedClip)) {
return;
}
// TODO: respect fClipBatchToBounds if we ever start computing bounds here.
@ -432,8 +434,8 @@ void GrDrawTarget::stencilPath(const GrPipelineBuilder& pipelineBuilder,
}
GrBatch* batch = GrStencilPathBatch::Create(viewMatrix,
pipelineBuilder.isHWAntialias(),
fill,
useHWAA,
path->getFillType(),
appliedClip.hasStencilClip(),
stencilAttachment->bits(),
appliedClip.scissorState(),

View File

@ -109,14 +109,17 @@ public:
void addBatch(sk_sp<GrBatch>);
/**
* Draws path into the stencil buffer. The fill must be either even/odd or
* winding (not inverse or hairline). It will respect the HW antialias flag
* on the GrPipelineBuilder (if possible in the 3D API). Note, we will never have an inverse
* Draws path into the stencil buffer. The path's fill must be either even/odd or
* winding (not inverse or hairline). It will respect the HW antialias boolean
* (if possible in the 3D API). Note, we will never have an inverse
* fill with stencil path
*/
void stencilPath(const GrPipelineBuilder&, GrDrawContext*,
const GrClip&, const SkMatrix& viewMatrix,
const GrPath*, GrPathRendering::FillType);
void stencilPath(GrDrawContext*,
const GrClip&,
const GrUserStencilSettings*,
bool useHWAA,
const SkMatrix& viewMatrix,
const GrPath*);
/** Discards the contents render target. */
void discard(GrRenderTarget*);

View File

@ -74,15 +74,9 @@ void GrStencilAndCoverPathRenderer::onStencilPath(const StencilPathArgs& args) {
SkPath path;
args.fShape->asPath(&path);
GrPaint paint;
paint.setXPFactory(GrDisableColorXPFactory::Make());
paint.setAntiAlias(args.fIsAA);
const GrPipelineBuilder pipelineBuilder(paint, args.fIsAA);
SkAutoTUnref<GrPath> p(get_gr_path(fResourceProvider, path, GrStyle::SimpleFill()));
args.fDrawContext->drawContextPriv().stencilPath(pipelineBuilder, *args.fClip,
*args.fViewMatrix, p, p->getFillType());
args.fDrawContext->drawContextPriv().stencilPath(*args.fClip, nullptr, args.fIsAA,
*args.fViewMatrix, p);
}
bool GrStencilAndCoverPathRenderer::onDrawPath(const DrawPathArgs& args) {
@ -113,13 +107,10 @@ bool GrStencilAndCoverPathRenderer::onDrawPath(const DrawPathArgs& args) {
);
// fake inverse with a stencil and cover
{
GrPipelineBuilder pipelineBuilder(*args.fPaint, args.fPaint->isAntiAlias());
pipelineBuilder.setUserStencil(&kInvertedCoverPass);
args.fDrawContext->drawContextPriv().stencilPath(pipelineBuilder, *args.fClip,
viewMatrix, p, p->getFillType());
}
args.fDrawContext->drawContextPriv().stencilPath(*args.fClip,
&kInvertedCoverPass,
args.fPaint->isAntiAlias(),
viewMatrix, p);
SkMatrix invert = SkMatrix::I();
SkRect bounds =