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>
diff --git a/src/gpu/GrReducedClip.cpp b/src/gpu/GrReducedClip.cpp
index 8c98ac1..dfa4166 100644
--- a/src/gpu/GrReducedClip.cpp
+++ b/src/gpu/GrReducedClip.cpp
@@ -662,7 +662,11 @@
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 @@
bounds)) {
return false;
}
- out->addStencilClip();
+ out->addStencilClip(fClipStackID);
return true;
}
GrFixedClip fFixedClip;
+ int32_t fClipStackID;
typedef GrClip INHERITED;
};
@@ -697,7 +702,7 @@
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);