Fix for Android batching bug
On Android it looks like we have: stencilClip1 draw1 stencilClip2 draw2 where draw1 is being forward combined with draw2 b.c. they are both stencil clipped but it shouldn't b.c. they are different stencil clips. Change-Id: Ia704d7ab869022a055eed0726e2b7fab8eaaf817 Reviewed-on: https://skia-review.googlesource.com/20977 Reviewed-by: Chris Dalton <csmartdalton@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
parent
c55a6cb05f
commit
a4f792da37
@ -170,7 +170,7 @@ class StencilOnlyClip final : public MaskOnlyClipBase {
|
||||
private:
|
||||
bool apply(GrContext*, GrRenderTargetContext*, bool, bool, GrAppliedClip* out,
|
||||
SkRect* bounds) const override {
|
||||
out->addStencilClip();
|
||||
out->addStencilClip(SkClipStack::kEmptyGenID);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
@ -12,6 +12,8 @@
|
||||
#include "GrScissorState.h"
|
||||
#include "GrWindowRectsState.h"
|
||||
|
||||
#include "SkClipStack.h"
|
||||
|
||||
/**
|
||||
* Produced by GrClip. It provides a set of modifications to the drawing state that are used to
|
||||
* create the final GrPipeline for a GrOp.
|
||||
@ -25,7 +27,7 @@ public:
|
||||
const GrScissorState& scissorState() const { return fScissorState; }
|
||||
const GrWindowRectsState& windowRectsState() const { return fWindowRectsState; }
|
||||
GrFragmentProcessor* clipCoverageFragmentProcessor() const { return fClipCoverageFP.get(); }
|
||||
bool hasStencilClip() const { return fHasStencilClip; }
|
||||
bool hasStencilClip() const { return SkClipStack::kInvalidGenID != fClipStackID; }
|
||||
|
||||
/**
|
||||
* Intersects the applied clip with the provided rect. Returns false if the draw became empty.
|
||||
@ -51,18 +53,18 @@ public:
|
||||
fClipCoverageFP = fp;
|
||||
}
|
||||
|
||||
void addStencilClip() {
|
||||
SkASSERT(!fHasStencilClip);
|
||||
fHasStencilClip = true;
|
||||
void addStencilClip(int32_t clipStackID) {
|
||||
SkASSERT(SkClipStack::kInvalidGenID == fClipStackID);
|
||||
fClipStackID = clipStackID;
|
||||
}
|
||||
|
||||
bool doesClip() const {
|
||||
return fScissorState.enabled() || fClipCoverageFP || fHasStencilClip ||
|
||||
return fScissorState.enabled() || fClipCoverageFP || this->hasStencilClip() ||
|
||||
fWindowRectsState.enabled();
|
||||
}
|
||||
|
||||
bool operator==(const GrAppliedClip& that) const {
|
||||
if (fScissorState != that.fScissorState || fHasStencilClip != that.fHasStencilClip) {
|
||||
if (fScissorState != that.fScissorState || fClipStackID != that.fClipStackID) {
|
||||
return false;
|
||||
}
|
||||
if (SkToBool(fClipCoverageFP)) {
|
||||
@ -81,7 +83,7 @@ private:
|
||||
GrScissorState fScissorState;
|
||||
GrWindowRectsState fWindowRectsState;
|
||||
sk_sp<GrFragmentProcessor> fClipCoverageFP;
|
||||
bool fHasStencilClip = false;
|
||||
int32_t fClipStackID = SkClipStack::kInvalidGenID;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -357,7 +357,7 @@ bool GrClipStackClip::apply(GrContext* context, GrRenderTargetContext* renderTar
|
||||
reducedClip.drawStencilClipMask(context, renderTargetContext);
|
||||
renderTargetContext->priv().setLastClip(reducedClip.elementsGenID(), reducedClip.ibounds());
|
||||
}
|
||||
out->addStencilClip();
|
||||
out->addStencilClip(reducedClip.elementsGenID());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -662,7 +662,11 @@ bool GrReducedClip::drawAlphaClipMask(GrRenderTargetContext* rtc) const {
|
||||
|
||||
class StencilClip final : public GrClip {
|
||||
public:
|
||||
StencilClip(const SkIRect& scissorRect) : fFixedClip(scissorRect) {}
|
||||
StencilClip(const SkIRect& scissorRect, int32_t clipStackID)
|
||||
: fFixedClip(scissorRect)
|
||||
, fClipStackID(clipStackID) {
|
||||
}
|
||||
|
||||
const GrFixedClip& fixedClip() const { return fFixedClip; }
|
||||
|
||||
void setWindowRectangles(const GrWindowRectangles& windows, GrWindowRectsState::Mode mode) {
|
||||
@ -685,11 +689,12 @@ private:
|
||||
bounds)) {
|
||||
return false;
|
||||
}
|
||||
out->addStencilClip();
|
||||
out->addStencilClip(fClipStackID);
|
||||
return true;
|
||||
}
|
||||
|
||||
GrFixedClip fFixedClip;
|
||||
int32_t fClipStackID;
|
||||
|
||||
typedef GrClip INHERITED;
|
||||
};
|
||||
@ -697,7 +702,7 @@ private:
|
||||
bool GrReducedClip::drawStencilClipMask(GrContext* context,
|
||||
GrRenderTargetContext* renderTargetContext) const {
|
||||
// We set the current clip to the bounds so that our recursive draws are scissored to them.
|
||||
StencilClip stencilClip(fIBounds);
|
||||
StencilClip stencilClip(fIBounds, this->elementsGenID());
|
||||
|
||||
if (!fWindowRects.empty()) {
|
||||
stencilClip.setWindowRectangles(fWindowRects, GrWindowRectsState::Mode::kExclusive);
|
||||
|
Loading…
Reference in New Issue
Block a user